Skip to content

Commit bf5b30a

Browse files
committed
Catch 'component' props in all non-fields components
1 parent 593200d commit bf5b30a

File tree

10 files changed

+21
-36
lines changed

10 files changed

+21
-36
lines changed

packages/common/src/wizard/wizard.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import flattenDeep from 'lodash/flattenDeep';
88
import handleEnter from './enter-handler';
99
import reducer, { DYNAMIC_WIZARD_TYPES, findCurrentStep } from './reducer';
1010

11-
const Wizard = ({ fields, isDynamic, crossroads, Wizard, ...props }) => {
11+
const Wizard = ({ fields, isDynamic, crossroads, Wizard, component, ...props }) => {
1212
const formOptions = useFormApi();
1313

1414
const [state, dispatch] = useReducer(reducer, {
@@ -94,7 +94,8 @@ Wizard.propTypes = {
9494
).isRequired,
9595
isDynamic: PropTypes.bool,
9696
crossroads: PropTypes.arrayOf(PropTypes.string),
97-
Wizard: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
97+
Wizard: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
98+
component: PropTypes.any
9899
};
99100

100101
export default Wizard;

packages/mui-component-mapper/src/files/plain-text.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import { Typography } from '@material-ui/core';
33
import PropTypes from 'prop-types';
44

5-
const PlainText = ({ label, name, ...props }) =>
5+
const PlainText = ({ label, name, component, ...props }) =>
66
label.split('\n').map((paragraph, index) => (
77
<Typography key={`${index}-${name}`} {...props}>
88
{paragraph}
@@ -11,7 +11,8 @@ const PlainText = ({ label, name, ...props }) =>
1111

1212
PlainText.propTypes = {
1313
label: PropTypes.string.isRequired,
14-
name: PropTypes.string.isRequired
14+
name: PropTypes.string.isRequired,
15+
component: PropTypes.any
1516
};
1617

1718
PlainText.defaultProps = {

packages/mui-component-mapper/src/files/sub-form.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const useStyles = makeStyles(() => ({
1212
}
1313
}));
1414

15-
const SubForm = ({ fields, title, description, ...rest }) => {
15+
const SubForm = ({ fields, title, description, component, ...rest }) => {
1616
const { renderForm } = useFormApi();
1717
const classes = useStyles();
1818

@@ -38,7 +38,8 @@ const SubForm = ({ fields, title, description, ...rest }) => {
3838
SubForm.propTypes = {
3939
fields: PropTypes.oneOfType([PropTypes.object, PropTypes.array]).isRequired,
4040
title: PropTypes.string,
41-
description: PropTypes.string
41+
description: PropTypes.string,
42+
component: PropTypes.any
4243
};
4344

4445
export default SubForm;

packages/pf3-component-mapper/src/files/button.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33
import { Button as PFButton } from 'patternfly-react';
44

5-
export const Button = ({ label, variant, dataType, validate, children, ...rest }) => (
5+
export const Button = ({ label, variant, dataType, validate, children, component, ...rest }) => (
66
<PFButton bsStyle={variant} {...rest}>
77
{label || children}
88
</PFButton>
@@ -14,7 +14,8 @@ Button.propTypes = {
1414
className: PropTypes.string,
1515
dataType: PropTypes.any, // should be inside inner props or something
1616
validate: PropTypes.any, // should be inside inner props or something
17-
children: PropTypes.any
17+
children: PropTypes.any,
18+
component: PropTypes.any
1819
};
1920

2021
export default Button;

packages/pf3-component-mapper/src/files/sub-form.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33
import { useFormApi } from '@data-driven-forms/react-form-renderer';
44

5-
const SubForm = ({ fields, title, description, ...rest }) => {
5+
const SubForm = ({ fields, title, description, component, ...rest }) => {
66
const formOptions = useFormApi();
77
return (
88
<div {...rest}>
@@ -16,7 +16,8 @@ const SubForm = ({ fields, title, description, ...rest }) => {
1616
SubForm.propTypes = {
1717
fields: PropTypes.oneOfType([PropTypes.object, PropTypes.array]).isRequired,
1818
title: PropTypes.string,
19-
description: PropTypes.string
19+
description: PropTypes.string,
20+
component: PropTypes.any
2021
};
2122

2223
export default SubForm;

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -570,14 +570,12 @@ exports[`<Input Addon> should render group button before input addon correctly 1
570570
block={false}
571571
bsClass="btn"
572572
bsStyle="default"
573-
component="button"
574573
disabled={false}
575574
name="set1"
576575
onClick={[Function]}
577576
>
578577
<button
579578
className="btn btn-default"
580-
component="button"
581579
disabled={false}
582580
name="set1"
583581
onClick={[Function]}
@@ -610,13 +608,11 @@ exports[`<Input Addon> should render group button before input addon correctly 1
610608
block={false}
611609
bsClass="btn"
612610
bsStyle="default"
613-
component="button"
614611
disabled={false}
615612
name="set2"
616613
>
617614
<button
618615
className="btn btn-default"
619-
component="button"
620616
disabled={false}
621617
name="set2"
622618
type="button"
@@ -1367,13 +1363,11 @@ exports[`<Input Addon> should render group mixed before input addon correctly 1`
13671363
block={false}
13681364
bsClass="btn"
13691365
bsStyle="default"
1370-
component="button"
13711366
disabled={false}
13721367
name="set3"
13731368
>
13741369
<button
13751370
className="btn btn-default"
1376-
component="button"
13771371
disabled={false}
13781372
name="set3"
13791373
type="button"
@@ -2726,13 +2720,11 @@ exports[`<Input Addon> should render single button after input addon correctly 1
27262720
block={false}
27272721
bsClass="btn"
27282722
bsStyle="default"
2729-
component="button"
27302723
disabled={false}
27312724
name="set3"
27322725
>
27332726
<button
27342727
className="btn btn-default"
2735-
component="button"
27362728
disabled={false}
27372729
name="set3"
27382730
type="button"
@@ -3254,13 +3246,11 @@ exports[`<Input Addon> should render single button before input addon correctly
32543246
block={false}
32553247
bsClass="btn"
32563248
bsStyle="default"
3257-
component="button"
32583249
disabled={false}
32593250
name="set2"
32603251
>
32613252
<button
32623253
className="btn btn-default"
3263-
component="button"
32643254
disabled={false}
32653255
name="set2"
32663256
type="button"
@@ -4185,14 +4175,12 @@ exports[`<Input Addon> should render the ultimate input addon correctly 1`] = `
41854175
block={false}
41864176
bsClass="btn"
41874177
bsStyle="default"
4188-
component="button"
41894178
disabled={false}
41904179
name="set1"
41914180
onClick={[Function]}
41924181
>
41934182
<button
41944183
className="btn btn-default"
4195-
component="button"
41964184
disabled={false}
41974185
name="set1"
41984186
onClick={[Function]}
@@ -4225,13 +4213,11 @@ exports[`<Input Addon> should render the ultimate input addon correctly 1`] = `
42254213
block={false}
42264214
bsClass="btn"
42274215
bsStyle="default"
4228-
component="button"
42294216
disabled={false}
42304217
name="set2"
42314218
>
42324219
<button
42334220
className="btn btn-default"
4234-
component="button"
42354221
disabled={false}
42364222
name="set2"
42374223
type="button"
@@ -4397,13 +4383,11 @@ exports[`<Input Addon> should render the ultimate input addon correctly 1`] = `
43974383
block={false}
43984384
bsClass="btn"
43994385
bsStyle="default"
4400-
component="button"
44014386
disabled={false}
44024387
name="set3"
44034388
>
44044389
<button
44054390
className="btn btn-default"
4406-
component="button"
44074391
disabled={false}
44084392
name="set3"
44094393
type="button"

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,6 @@ exports[`<Wizard /> should render Wizard correctly 1`] = `
313313
>
314314
<WizardInternal
315315
activeStepIndex={0}
316-
component="wizard"
317316
currentStep={
318317
Object {
319318
"fields": Array [],
@@ -1097,7 +1096,6 @@ exports[`<Wizard /> should render Wizard with conditional steps correctly 1`] =
10971096
>
10981097
<WizardInternal
10991098
activeStepIndex={0}
1100-
component="wizard"
11011099
currentStep={
11021100
Object {
11031101
"fields": Array [],
@@ -1993,7 +1991,6 @@ exports[`<Wizard /> should render Wizard with stepsInfo correctly 1`] = `
19931991
>
19941992
<WizardInternal
19951993
activeStepIndex={0}
1996-
component="wizard"
19971994
currentStep={
19981995
Object {
19991996
"fields": Array [],
@@ -2841,7 +2838,6 @@ exports[`<Wizard /> should render Wizard with title correctly 1`] = `
28412838
>
28422839
<WizardInternal
28432840
activeStepIndex={0}
2844-
component="wizard"
28452841
currentStep={
28462842
Object {
28472843
"fields": Array [],

packages/pf4-component-mapper/src/files/sub-form.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useFormApi } from '@data-driven-forms/react-form-renderer';
44

55
import { Title, Grid, GridItem, TextContent, Text, TextVariants } from '@patternfly/react-core';
66

7-
const SubForm = ({ fields, title, description, validate: _validate, ...rest }) => {
7+
const SubForm = ({ fields, title, description, validate: _validate, component, ...rest }) => {
88
const formOptions = useFormApi();
99

1010
return (
@@ -33,7 +33,8 @@ SubForm.propTypes = {
3333
name: PropTypes.string,
3434
title: PropTypes.string,
3535
description: PropTypes.string,
36-
validate: PropTypes.any
36+
validate: PropTypes.any,
37+
component: PropTypes.any
3738
};
3839

3940
export default SubForm;

packages/pf4-component-mapper/src/files/tabs.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useFormApi } from '@data-driven-forms/react-form-renderer';
44

55
import { Tab, Tabs } from '@patternfly/react-core';
66

7-
const FormTabs = ({ fields, dataType, validate, ...rest }) => {
7+
const FormTabs = ({ fields, dataType, validate, component, ...rest }) => {
88
const formOptions = useFormApi();
99
const [activeTabKey, setActiveTabKey] = useState(0);
1010

@@ -30,7 +30,8 @@ const FormTabs = ({ fields, dataType, validate, ...rest }) => {
3030
FormTabs.propTypes = {
3131
fields: PropTypes.array.isRequired,
3232
dataType: PropTypes.any,
33-
validate: PropTypes.any
33+
validate: PropTypes.any,
34+
component: PropTypes.any
3435
};
3536

3637
export default FormTabs;

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,6 @@ exports[`<Wizard /> should render correctly and unmount 1`] = `
423423
"submit": "Submit",
424424
}
425425
}
426-
component="wizard"
427426
currentStep={
428427
Object {
429428
"fields": Array [
@@ -1500,7 +1499,6 @@ exports[`<Wizard /> should render correctly in modal and unmount 1`] = `
15001499
"submit": "Submit",
15011500
}
15021501
}
1503-
component="wizard"
15041502
currentStep={
15051503
Object {
15061504
"fields": Array [

0 commit comments

Comments
 (0)