Skip to content

Commit 0dac8a8

Browse files
committed
fix(renderer): move functionality from render to useField
1 parent e67a30d commit 0dac8a8

File tree

18 files changed

+187
-115
lines changed

18 files changed

+187
-115
lines changed

packages/pf3-component-mapper/src/tests/__snapshots__/form-fields.test.js.snap

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,6 @@ exports[`FormFields <Switch /> should render Switch correctly 1`] = `
390390
>
391391
<Switch
392392
FieldProvider={[Function]}
393-
dataType="someDataType"
394393
id="someIdKey"
395394
input={
396395
Object {
@@ -535,7 +534,6 @@ exports[`FormFields <Switch /> should render Switch with label correctly 1`] = `
535534
>
536535
<Switch
537536
FieldProvider={[Function]}
538-
dataType="someDataType"
539537
id="someIdKey"
540538
input={
541539
Object {
@@ -692,7 +690,6 @@ exports[`FormFields <Switch /> should render Switch with onText (custom prop) co
692690
>
693691
<Switch
694692
FieldProvider={[Function]}
695-
dataType="someDataType"
696693
id="someIdKey"
697694
input={
698695
Object {
@@ -838,7 +835,6 @@ exports[`FormFields <Switch /> should render Switch with placeholder correctly 1
838835
>
839836
<Switch
840837
FieldProvider={[Function]}
841-
dataType="someDataType"
842838
id="someIdKey"
843839
input={
844840
Object {
@@ -984,7 +980,6 @@ exports[`FormFields <Switch /> should render disabled Switch correctly 1`] = `
984980
>
985981
<Switch
986982
FieldProvider={[Function]}
987-
dataType="someDataType"
988983
id="someIdKey"
989984
input={
990985
Object {
@@ -1133,7 +1128,6 @@ exports[`FormFields <Switch /> should render mini Switch correctly 1`] = `
11331128
<Switch
11341129
FieldProvider={[Function]}
11351130
bsSize="mini"
1136-
dataType="someDataType"
11371131
id="someIdKey"
11381132
input={
11391133
Object {
@@ -1279,7 +1273,6 @@ exports[`FormFields <Switch /> should render readOnly Switch correctly 1`] = `
12791273
>
12801274
<Switch
12811275
FieldProvider={[Function]}
1282-
dataType="someDataType"
12831276
id="someIdKey"
12841277
input={
12851278
Object {
@@ -1428,7 +1421,6 @@ exports[`FormFields <Switch /> should render sm Switch correctly 1`] = `
14281421
<Switch
14291422
FieldProvider={[Function]}
14301423
bsSize="mn"
1431-
dataType="someDataType"
14321424
id="someIdKey"
14331425
input={
14341426
Object {

packages/pf3-component-mapper/src/tests/__snapshots__/input-addon.test.js.snap

Lines changed: 42 additions & 0 deletions
Large diffs are not rendered by default.

packages/pf3-component-mapper/src/tests/__snapshots__/wizard.test.js.snap

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ exports[`<Wizard /> should render Wizard correctly 1`] = `
273273
hideField={false}
274274
>
275275
<WizardFinal
276+
component="wizard"
276277
fields={
277278
Array [
278279
Object {
@@ -292,6 +293,7 @@ exports[`<Wizard /> should render Wizard correctly 1`] = `
292293
>
293294
<Wizard
294295
Wizard={[Function]}
296+
component="wizard"
295297
fields={
296298
Array [
297299
Object {
@@ -311,6 +313,7 @@ exports[`<Wizard /> should render Wizard correctly 1`] = `
311313
>
312314
<WizardInternal
313315
activeStepIndex={0}
316+
component="wizard"
314317
currentStep={
315318
Object {
316319
"fields": Array [],
@@ -1044,6 +1047,7 @@ exports[`<Wizard /> should render Wizard with conditional steps correctly 1`] =
10441047
hideField={false}
10451048
>
10461049
<WizardFinal
1050+
component="wizard"
10471051
fields={
10481052
Array [
10491053
Object {
@@ -1068,6 +1072,7 @@ exports[`<Wizard /> should render Wizard with conditional steps correctly 1`] =
10681072
>
10691073
<Wizard
10701074
Wizard={[Function]}
1075+
component="wizard"
10711076
fields={
10721077
Array [
10731078
Object {
@@ -1092,6 +1097,7 @@ exports[`<Wizard /> should render Wizard with conditional steps correctly 1`] =
10921097
>
10931098
<WizardInternal
10941099
activeStepIndex={0}
1100+
component="wizard"
10951101
currentStep={
10961102
Object {
10971103
"fields": Array [],
@@ -1927,6 +1933,7 @@ exports[`<Wizard /> should render Wizard with stepsInfo correctly 1`] = `
19271933
hideField={false}
19281934
>
19291935
<WizardFinal
1936+
component="wizard"
19301937
fields={
19311938
Array [
19321939
Object {
@@ -1956,6 +1963,7 @@ exports[`<Wizard /> should render Wizard with stepsInfo correctly 1`] = `
19561963
>
19571964
<Wizard
19581965
Wizard={[Function]}
1966+
component="wizard"
19591967
fields={
19601968
Array [
19611969
Object {
@@ -1985,6 +1993,7 @@ exports[`<Wizard /> should render Wizard with stepsInfo correctly 1`] = `
19851993
>
19861994
<WizardInternal
19871995
activeStepIndex={0}
1996+
component="wizard"
19881997
currentStep={
19891998
Object {
19901999
"fields": Array [],
@@ -2790,6 +2799,7 @@ exports[`<Wizard /> should render Wizard with title correctly 1`] = `
27902799
hideField={false}
27912800
>
27922801
<WizardFinal
2802+
component="wizard"
27932803
fields={
27942804
Array [
27952805
Object {
@@ -2810,6 +2820,7 @@ exports[`<Wizard /> should render Wizard with title correctly 1`] = `
28102820
>
28112821
<Wizard
28122822
Wizard={[Function]}
2823+
component="wizard"
28132824
fields={
28142825
Array [
28152826
Object {
@@ -2830,6 +2841,7 @@ exports[`<Wizard /> should render Wizard with title correctly 1`] = `
28302841
>
28312842
<WizardInternal
28322843
activeStepIndex={0}
2844+
component="wizard"
28332845
currentStep={
28342846
Object {
28352847
"fields": Array [],

packages/pf3-component-mapper/src/tests/form-fields.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ describe('FormFields', () => {
3737
value: ''
3838
},
3939
id: 'someIdKey',
40-
dataType: 'someDataType',
4140
meta: {
4241
error: false,
4342
touched: false

packages/pf4-component-mapper/demo/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const fieldArrayState = { schema: arraySchemaDDF, additionalOptions: {
2222
class App extends React.Component {
2323
constructor(props) {
2424
super(props);
25-
this.state = { schema: wizardSchema, additionalOptions: { showFormControls: false, wizard: true } }
25+
this.state = fieldArrayState
2626
}
2727

2828
render() {

packages/pf4-component-mapper/src/tests/__snapshots__/form-fields.test.js.snap

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ exports[`FormFields should render Checkbox correctly 1`] = `
66
onSubmit={[Function]}
77
>
88
<Checkbox
9-
dataType="someDataType"
109
id="someIdKey"
1110
name="Name of the field"
1211
>
1312
<SingleCheckbox
14-
dataType="someDataType"
1513
id="someIdKey"
1614
name="Name of the field"
1715
>
@@ -96,7 +94,6 @@ exports[`FormFields should render Checkbox with options correctly 1`] = `
9694
onSubmit={[Function]}
9795
>
9896
<Checkbox
99-
dataType="someDataType"
10097
id="someIdKey"
10198
name="Name of the field"
10299
options={
@@ -117,7 +114,6 @@ exports[`FormFields should render Checkbox with options correctly 1`] = `
117114
}
118115
>
119116
<MultipleChoiceList
120-
dataType="someDataType"
121117
id="someIdKey"
122118
name="Name of the field"
123119
options={
@@ -140,7 +136,6 @@ exports[`FormFields should render Checkbox with options correctly 1`] = `
140136
<MultipleChoiceList
141137
Checkbox={[Function]}
142138
Wrapper={[Function]}
143-
dataType="someDataType"
144139
id="someIdKey"
145140
name="Name of the field"
146141
options={
@@ -711,7 +706,6 @@ exports[`FormFields should render DatePicker correctly 1`] = `
711706
onSubmit={[Function]}
712707
>
713708
<DatePicker
714-
dataType="someDataType"
715709
id="someIdKey"
716710
name="Name of the field"
717711
>
@@ -806,7 +800,6 @@ exports[`FormFields should render Radio correctly 1`] = `
806800
onSubmit={[Function]}
807801
>
808802
<Radio
809-
dataType="someDataType"
810803
id="someIdKey"
811804
name="Name of the field"
812805
options={
@@ -1055,7 +1048,6 @@ exports[`FormFields should render Select correctly 1`] = `
10551048
}
10561049
>
10571050
<Select
1058-
dataType="someDataType"
10591051
id="someIdKey"
10601052
name="Name of the field"
10611053
options={
@@ -1085,7 +1077,6 @@ exports[`FormFields should render Switch correctly 1`] = `
10851077
onSubmit={[Function]}
10861078
>
10871079
<Switch
1088-
dataType="someDataType"
10891080
id="someIdKey"
10901081
name="Name of the field"
10911082
>
@@ -1240,7 +1231,6 @@ exports[`FormFields should render TextField correctly 1`] = `
12401231
onSubmit={[Function]}
12411232
>
12421233
<TextField
1243-
dataType="someDataType"
12441234
id="someIdKey"
12451235
name="Name of the field"
12461236
>
@@ -1334,7 +1324,6 @@ exports[`FormFields should render TextField with description correctly 1`] = `
13341324
onSubmit={[Function]}
13351325
>
13361326
<TextField
1337-
dataType="someDataType"
13381327
description="This is description"
13391328
id="someIdKey"
13401329
name="Name of the field"
@@ -1446,7 +1435,6 @@ exports[`FormFields should render TextField without id correctly 1`] = `
14461435
onSubmit={[Function]}
14471436
>
14481437
<TextField
1449-
dataType="someDataType"
14501438
name="Name of the field"
14511439
>
14521440
<FormGroup
@@ -1539,7 +1527,6 @@ exports[`FormFields should render Textarea correctly 1`] = `
15391527
onSubmit={[Function]}
15401528
>
15411529
<Textarea
1542-
dataType="someDataType"
15431530
id="someIdKey"
15441531
name="Name of the field"
15451532
>
@@ -1618,7 +1605,6 @@ exports[`FormFields should render TimePicker correctly 1`] = `
16181605
onSubmit={[Function]}
16191606
>
16201607
<TimePicker
1621-
dataType="someDataType"
16221608
id="someIdKey"
16231609
name="Name of the field"
16241610
>
@@ -1713,7 +1699,6 @@ exports[`FormFields should render disabled Checkbox with options correctly 1`] =
17131699
onSubmit={[Function]}
17141700
>
17151701
<Checkbox
1716-
dataType="someDataType"
17171702
disabled={true}
17181703
id="someIdKey"
17191704
name="Name of the field"
@@ -1735,7 +1720,6 @@ exports[`FormFields should render disabled Checkbox with options correctly 1`] =
17351720
}
17361721
>
17371722
<MultipleChoiceList
1738-
dataType="someDataType"
17391723
disabled={true}
17401724
id="someIdKey"
17411725
name="Name of the field"
@@ -1759,7 +1743,6 @@ exports[`FormFields should render disabled Checkbox with options correctly 1`] =
17591743
<MultipleChoiceList
17601744
Checkbox={[Function]}
17611745
Wrapper={[Function]}
1762-
dataType="someDataType"
17631746
disabled={true}
17641747
id="someIdKey"
17651748
name="Name of the field"
@@ -2342,7 +2325,6 @@ exports[`FormFields should render disabled Radio correctly 1`] = `
23422325
onSubmit={[Function]}
23432326
>
23442327
<Radio
2345-
dataType="someDataType"
23462328
disabled={true}
23472329
id="someIdKey"
23482330
name="Name of the field"
@@ -2592,7 +2574,6 @@ exports[`FormFields should render disabled Select correctly 1`] = `
25922574
}
25932575
>
25942576
<Select
2595-
dataType="someDataType"
25962577
id="someIdKey"
25972578
isDisabled={true}
25982579
name="Name of the field"
@@ -2623,7 +2604,6 @@ exports[`FormFields should render disabled Switch correctly 1`] = `
26232604
onSubmit={[Function]}
26242605
>
26252606
<Switch
2626-
dataType="someDataType"
26272607
id="someIdKey"
26282608
isDisabled={true}
26292609
name="Name of the field"
@@ -2780,7 +2760,6 @@ exports[`FormFields should render disabled Switch correctly 2`] = `
27802760
onSubmit={[Function]}
27812761
>
27822762
<Switch
2783-
dataType="someDataType"
27842763
id="someIdKey"
27852764
isDisabled={true}
27862765
name="Name of the field"
@@ -2937,7 +2916,6 @@ exports[`FormFields should render disabled Textarea correctly 1`] = `
29372916
onSubmit={[Function]}
29382917
>
29392918
<Textarea
2940-
dataType="someDataType"
29412919
id="someIdKey"
29422920
isDisabled={true}
29432921
name="Name of the field"
@@ -3019,7 +2997,6 @@ exports[`FormFields should render touched TextField id correctly 1`] = `
30192997
onSubmit={[Function]}
30202998
>
30212999
<TextField
3022-
dataType="someDataType"
30233000
id="someIdKey"
30243001
meta={
30253002
Object {
@@ -3119,7 +3096,6 @@ exports[`FormFields should render with onText/OffText Switch correctly 1`] = `
31193096
onSubmit={[Function]}
31203097
>
31213098
<Switch
3122-
dataType="someDataType"
31233099
id="someIdKey"
31243100
name="Name of the field"
31253101
offText="Turned off"

packages/pf4-component-mapper/src/tests/form-fields.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ import MultipleChoiceListCommon from '@data-driven-forms/common/src/multiple-cho
2222
describe('FormFields', () => {
2323
const props = {
2424
name: 'Name of the field',
25-
id: 'someIdKey',
26-
dataType: 'someDataType'
25+
id: 'someIdKey'
2726
};
2827
const propsWithOptions = {
2928
...props,

0 commit comments

Comments
 (0)