Skip to content

Commit 2a088f8

Browse files
committed
Merge branch 'master' into rebeaseMasterMUI5
2 parents 8b56ab7 + 82b9673 commit 2a088f8

File tree

28 files changed

+272
-129
lines changed

28 files changed

+272
-129
lines changed

packages/ant-component-mapper/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@data-driven-forms/ant-component-mapper",
3-
"version": "3.15.3",
3+
"version": "3.15.7",
44
"description": "Ant Design React component mapper for Data Driven Forms.",
55
"main": "index.js",
66
"module": "esm/index.js",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Meta } from "@data-driven-forms/react-form-renderer";
22

3-
export type validationError = (meta: Meta<any>, validateOnMount?: boolean) => boolean | any | undefined
3+
export function validationError(meta: Meta<any>, validateOnMount?: boolean): boolean | any | undefined
44

55
export default validationError;

packages/blueprint-component-mapper/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@data-driven-forms/blueprint-component-mapper",
3-
"version": "3.15.3",
3+
"version": "3.15.7",
44
"description": "BlueprintJS React component mapper for Data Driven Forms.",
55
"main": "index.js",
66
"module": "esm/index.js",
@@ -36,7 +36,9 @@
3636
"peerDependencies": {
3737
"@blueprintjs/core": "^3.26.1",
3838
"@blueprintjs/datetime": "^3.17.0",
39-
"@blueprintjs/select": "^3.12.3"
39+
"@blueprintjs/select": "^3.12.3",
40+
"react": "^16.13.1 || ^17.0.2",
41+
"react-dom": "^16.13.1 || ^17.0.2"
4042
},
4143
"dependencies": {
4244
"@data-driven-forms/common": "*",

packages/carbon-component-mapper/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@data-driven-forms/carbon-component-mapper",
3-
"version": "3.15.3",
3+
"version": "3.15.7",
44
"description": "Carbon React component mapper for Data Driven Forms.",
55
"main": "index.js",
66
"module": "esm/index.js",
@@ -35,7 +35,10 @@
3535
"carbon-components-react": "^7.46.0",
3636
"carbon-icons": "^7.0.7"
3737
},
38-
"peerDependencies": {},
38+
"peerDependencies": {
39+
"react": "^16.13.1 || ^17.0.2",
40+
"react-dom": "^16.13.1 || ^17.0.2"
41+
},
3942
"dependencies": {
4043
"@data-driven-forms/common": "*",
4144
"clsx": "^1.1.1",

packages/carbon-component-mapper/src/tests/time-picker-string.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ describe('TimePicker<String>', () => {
193193
onSubmit.mockReset();
194194

195195
await act(async () => {
196-
wrapper.find('select#time-picker-12h').simulate('change', { target: { value: 'UTC' } });
196+
wrapper.find('select#time-picker-timezones').simulate('change', { target: { value: 'UTC' } });
197197
});
198198
wrapper.update();
199199

@@ -203,7 +203,7 @@ describe('TimePicker<String>', () => {
203203
wrapper.update();
204204

205205
expect(wrapper.find('input').props().value).toEqual('00:35');
206-
expect(onSubmit).toHaveBeenLastCalledWith({ 'time-picker': '00:35 UTC EST' });
206+
expect(onSubmit).toHaveBeenLastCalledWith({ 'time-picker': '00:35 AM UTC' });
207207
});
208208

209209
it('handles initial value', async () => {

packages/carbon-component-mapper/src/tests/time-picker.test.js

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ describe('TimePicker', () => {
194194
onSubmit.mockReset();
195195

196196
await act(async () => {
197-
wrapper.find('select#time-picker-12h').simulate('change', { target: { value: 'UTC' } });
197+
wrapper.find('select#time-picker-timezones').simulate('change', { target: { value: 'UTC' } });
198198
});
199199
wrapper.update();
200200

@@ -203,8 +203,47 @@ describe('TimePicker', () => {
203203
});
204204
wrapper.update();
205205

206-
expect(wrapper.find('input').props().value).toEqual('10:35');
207-
expect(onSubmit.mock.calls[0][0]['time-picker'].getHours()).toEqual(10);
206+
expect(wrapper.find('input').props().value).toEqual('05:35');
207+
expect(onSubmit.mock.calls[0][0]['time-picker'].getHours()).toEqual(5);
208208
expect(onSubmit.mock.calls[0][0]['time-picker'].getMinutes()).toEqual(35);
209209
});
210+
211+
it('handles initial value', async () => {
212+
schema = {
213+
fields: [
214+
{
215+
component: componentTypes.TIME_PICKER,
216+
name: 'time-picker',
217+
initialValue: new Date('December 17, 1995 16:00:00'),
218+
twelveHoursFormat: true,
219+
},
220+
],
221+
};
222+
223+
await act(async () => {
224+
wrapper = mount(<FormRenderer schema={schema} {...initialProps} />);
225+
});
226+
wrapper.update();
227+
228+
expect(wrapper.find('input').props().value).toEqual('04:00');
229+
expect(wrapper.find('select').props().defaultValue).toEqual('PM');
230+
231+
await act(async () => {
232+
wrapper.find('input').simulate('change', { target: { value: '03:00' } });
233+
});
234+
wrapper.update();
235+
236+
await act(async () => {
237+
wrapper.find('input').simulate('blur');
238+
});
239+
wrapper.update();
240+
241+
await act(async () => {
242+
wrapper.find('form').simulate('submit');
243+
});
244+
wrapper.update();
245+
246+
expect(onSubmit.mock.calls[0][0]['time-picker'].getHours()).toEqual(15);
247+
expect(onSubmit.mock.calls[0][0]['time-picker'].getMinutes()).toEqual(0);
248+
});
210249
});

packages/carbon-component-mapper/src/time-picker-base/time-picker-base.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ interface InternalTimePickerBaseProps extends CarbonTimePickerProps, AnyObject {
2020
warnText?: ReactNode;
2121
selectFormat: (value: 'AM' | 'PM') => void;
2222
selectTimezone: (value: string) => void;
23+
format?: 'AM' | 'PM';
24+
defaultTimezone?: string;
2325
}
2426

2527
export type TimePickerBaseProps = InternalTimePickerBaseProps & FormGroupProps;

packages/carbon-component-mapper/src/time-picker-base/time-picker-base.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ const TimePickerBase = ({
1818
warnText,
1919
selectFormat,
2020
selectTimezone,
21+
format,
22+
timezone,
2123
...rest
2224
}) => (
2325
<div {...WrapperProps}>
@@ -34,13 +36,23 @@ const TimePickerBase = ({
3436
{...rest}
3537
>
3638
{twelveHoursFormat && (
37-
<TimePickerSelect labelText="Period" id={`${rest.id || input.name}-12h`} onChange={({ target: { value } }) => selectFormat(value)}>
39+
<TimePickerSelect
40+
defaultValue={format}
41+
labelText="Period"
42+
id={`${rest.id || input.name}-12h`}
43+
onChange={({ target: { value } }) => selectFormat(value)}
44+
>
3845
<SelectItem value="AM" text="AM" />
3946
<SelectItem value="PM" text="PM" />
4047
</TimePickerSelect>
4148
)}
4249
{timezones && (
43-
<TimePickerSelect labelText="Timezone" id={`${rest.id || input.name}-timezones`} onChange={({ target: { value } }) => selectTimezone(value)}>
50+
<TimePickerSelect
51+
defaultValue={timezone}
52+
labelText="Timezone"
53+
id={`${rest.id || input.name}-timezones`}
54+
onChange={({ target: { value } }) => selectTimezone(value)}
55+
>
4456
{timezones.map(({ showAs, ...tz }) => (
4557
<SelectItem key={tz.value} text={tz.label} {...tz} />
4658
))}
@@ -78,6 +90,8 @@ TimePickerBase.propTypes = {
7890
warnText: PropTypes.node,
7991
selectFormat: PropTypes.func.isRequired,
8092
selectTimezone: PropTypes.func.isRequired,
93+
format: PropTypes.oneOf(['AM', 'PM']),
94+
timezone: PropTypes.string,
8195
};
8296

8397
export default TimePickerBase;

packages/carbon-component-mapper/src/time-picker-date/time-picker-date.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface Timezone extends SelectItemProps {
1212
interface InternalTimePickerProps extends CarbonTimePickerProps {
1313
twelveHoursFormat?: boolean;
1414
timezones?: Timezone[];
15+
defaultTimezone?: string;
1516
}
1617

1718
export type TimePickerDateProps = InternalTimePickerProps & FormGroupProps & UseFieldApiComponentConfig;

packages/carbon-component-mapper/src/time-picker-date/time-picker-date.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import prepareProps from '../prepare-props';
66
import TimePickerBase from '../time-picker-base';
77

88
const TimePickerDate = (props) => {
9-
const { input, meta, twelveHoursFormat, timezones, validateOnMount, helperText, WrapperProps, ...rest } = useFieldApi(prepareProps(props));
9+
const { input, meta, twelveHoursFormat, timezones, validateOnMount, helperText, WrapperProps, defaultTimezone, ...rest } = useFieldApi(
10+
prepareProps(props)
11+
);
1012

11-
const [timezone, selectTimezone] = useState(timezones ? timezones[0]?.value : '');
12-
const [format, selectFormat] = useState('AM');
13+
const [timezone, selectTimezone] = useState(defaultTimezone || timezones ? timezones[0]?.value : '');
14+
const [format, selectFormat] = useState(() => (input.value?.getHours?.() >= 12 ? 'PM' : 'AM'));
1315
const isMounted = useRef(false);
1416

1517
const invalid = (meta.touched || validateOnMount) && (meta.error || meta.submitError);
@@ -75,6 +77,8 @@ const TimePickerDate = (props) => {
7577
warnText={warnText}
7678
selectFormat={selectFormat}
7779
selectTimezone={selectTimezone}
80+
format={format}
81+
timezone={timezone}
7882
{...rest}
7983
/>
8084
);
@@ -96,6 +100,7 @@ TimePickerDate.propTypes = {
96100
})
97101
),
98102
WrapperProps: PropTypes.object,
103+
defaultTimezone: PropTypes.string,
99104
};
100105

101106
export default TimePickerDate;

packages/carbon-component-mapper/src/time-picker-string/time-picker-string.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ const TimePickerString = (props) => {
4242
warnText={warnText}
4343
selectFormat={selectFormat}
4444
selectTimezone={selectTimezone}
45+
format={format}
46+
timezone={timezone}
4547
{...rest}
4648
/>
4749
);

packages/common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@data-driven-forms/common",
3-
"version": "3.15.3",
3+
"version": "3.15.7",
44
"description": "Common components, helpers and other pieces of code for Data Driven Forms",
55
"license": "Apache-2.0",
66
"main": "index.js",

packages/mui-component-mapper/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@data-driven-forms/mui-component-mapper",
3-
"version": "3.15.6",
3+
"version": "3.15.7",
44
"description": "Component mapper for Material ui component mapper form data-driven-forms.",
55
"main": "index.js",
66
"module": "esm/index.js",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Meta } from "@data-driven-forms/react-form-renderer";
22

3-
export type validationError = (meta: Meta<any>, validateOnMount?: boolean) => boolean | any | undefined;
3+
export function validationError(meta: Meta<any>, validateOnMount?: boolean): boolean | any | undefined;
44

55
export default validationError;

packages/parsers/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@data-driven-forms/parsers",
3-
"version": "3.15.3",
3+
"version": "3.15.7",
44
"description": "Parsers for Data Driven Forms.",
55
"main": "dist/cjs/index.js",
66
"module": "dist/esm/index.js",

packages/pf4-component-mapper/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@data-driven-forms/pf4-component-mapper",
3-
"version": "3.15.3",
3+
"version": "3.15.7",
44
"description": "Patternfly 4 React component mapper for Data Driven Forms.",
55
"main": "index.js",
66
"module": "esm/index.js",
@@ -36,7 +36,9 @@
3636
"peerDependencies": {
3737
"@data-driven-forms/react-form-renderer": ">=3.2.1",
3838
"@patternfly/react-core": "^4.157.3",
39-
"@patternfly/react-icons": "^4.11.7"
39+
"@patternfly/react-icons": "^4.11.7",
40+
"react": "^16.13.1 || ^17.0.2",
41+
"react-dom": "^16.13.1 || ^17.0.2"
4042
},
4143
"dependencies": {
4244
"@data-driven-forms/common": "*",

packages/pf4-component-mapper/src/radio/radio.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ RadioOption.propTypes = {
3030
radioGroupValue: PropTypes.any,
3131
};
3232

33-
const Radio = ({ name, options, type, ...props }) => {
33+
const Radio = ({ name, type, ...props }) => {
3434
/**
3535
* You cannot assign type radio to PF4 radio buttons input. It will break and will not set input value, only checked property
3636
* It has to be reqular input and we have change the radio value manully to the option value
3737
*/
38-
const { label, isRequired, helperText, meta, validateOnMount, description, hideLabel, input, isReadOnly, isDisabled, id, FormGroupProps } =
38+
const { label, isRequired, helperText, meta, validateOnMount, description, hideLabel, input, isReadOnly, isDisabled, id, FormGroupProps, options } =
3939
useFieldApi({
4040
name,
4141
...props,

packages/react-form-renderer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@data-driven-forms/react-form-renderer",
3-
"version": "3.15.3",
3+
"version": "3.15.7",
44
"description": "React Form Renderer. Data Driven Forms converts JSON form definitions into fully functional React forms.",
55
"main": "index.js",
66
"module": "esm/index.js",

packages/react-form-renderer/src/component-types/component-types.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export type ComponentType = 'text-field'|'field-array'|'checkbox'|'sub-form'|'radio'|'tabs'|'tab-item'|'date-picker'|'time-picker'|'wizard'|'switch'|'textarea'|'select'|'plain-text'|'button'|'input-addon-group'|'input-addon-button-group'|'dual-list-select'|'slider';
22

3-
interface componentTypes {
3+
interface IcomponentTypes {
44
TEXT_FIELD: 'text-field';
55
FIELD_ARRAY: 'field-array';
66
CHECKBOX: 'checkbox';
@@ -22,6 +22,6 @@ interface componentTypes {
2222
SLIDER: 'slider';
2323
}
2424

25-
declare const componentTypes: componentTypes;
25+
declare const componentTypes: IcomponentTypes;
2626

2727
export default componentTypes;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
export type DataType = 'integer'|'float'|'number'|'boolean'|'string';
22

3-
interface dataTypes {
3+
interface IdataTypes {
44
INTEGER: 'integer';
55
FLOAT: 'float';
66
NUMBER: 'number';
77
BOOLEAN: 'boolean';
88
STRING: 'string';
99
}
1010

11-
declare const dataTypes: dataTypes;
11+
declare const dataTypes: IdataTypes;
1212

1313
export default dataTypes;

packages/react-form-renderer/src/validator-types/validator-types.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
interface validatorTypes {
1+
interface IvalidatorTypes {
22
REQUIRED: 'required';
33
MIN_LENGTH: 'min-length';
44
MAX_LENGTH: 'max-length';
@@ -10,6 +10,6 @@ interface validatorTypes {
1010
URL: 'url';
1111
}
1212

13-
declare const validatorTypes: validatorTypes;
13+
declare const validatorTypes: IvalidatorTypes;
1414

1515
export default validatorTypes;

packages/react-renderer-demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@data-driven-forms/react-renderer-demo",
3-
"version": "3.15.3",
3+
"version": "3.15.7",
44
"main": "firebaseFunctions.js",
55
"description": "Documentation page for Data Driven Forms.",
66
"homepage": "https://data-driven-forms.org/",

packages/react-renderer-demo/src/doc-components/examples-texts/carbon/time-picker.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ This component also accepts all other original props, please see [here](https://
44

55
|Props|Description|default|
66
|-----|-----------|-------|
7+
|defaultTimezone|string - a value of default timezone, use only in Date varian|undefined|
78
|useStringFormat|boolean - save value as string|false|
89
|twelveHoursFormat|boolean - if true an AM/PM selector is shown|false|
910
|timezones|array of timezones - if not empty, an timezone selector is shown|undefined|

packages/react-renderer-demo/src/pages/_document.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react';
22
import Document, { Head, Main, NextScript } from 'next/document';
33
import { ServerStyleSheets } from '@mui/styles';
4-
import theme from '../theme';
54

65
class MyDocument extends Document {
76
render() {
@@ -15,7 +14,7 @@ class MyDocument extends Document {
1514
<link rel="apple-touch-icon" href="/192x192.png"></link>
1615
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width, shrink-to-fit=no" />
1716
{/* PWA primary color */}
18-
<meta name="theme-color" content={theme.palette.primary.main} />
17+
<meta name="theme-color" content="#430f8f" />
1918
<link rel="preload" as="style" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
2019
<link rel="preload" as="style" href="https://fonts.googleapis.com/css?family=Montserrat:700&display=swap" />
2120
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css" />

0 commit comments

Comments
 (0)