@atlaskit/form 8.8.2 → 8.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/dist/cjs/checkbox-field.js +15 -29
- package/dist/cjs/entry-points/checkbox-field.js +0 -2
- package/dist/cjs/entry-points/field.js +0 -2
- package/dist/cjs/entry-points/fieldset.js +0 -2
- package/dist/cjs/entry-points/form-footer.js +0 -2
- package/dist/cjs/entry-points/form-header.js +0 -2
- package/dist/cjs/entry-points/form-section.js +0 -2
- package/dist/cjs/entry-points/form.js +0 -2
- package/dist/cjs/entry-points/label.js +0 -2
- package/dist/cjs/entry-points/messages.js +0 -1
- package/dist/cjs/entry-points/range-field.js +0 -2
- package/dist/cjs/field.js +49 -85
- package/dist/cjs/fieldset.js +27 -23
- package/dist/cjs/form-footer.js +4 -6
- package/dist/cjs/form-header.js +9 -23
- package/dist/cjs/form-section.js +9 -21
- package/dist/cjs/form.js +40 -63
- package/dist/cjs/index.js +0 -11
- package/dist/cjs/label.js +29 -23
- package/dist/cjs/messages.js +54 -55
- package/dist/cjs/range-field.js +8 -19
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/checkbox-field.js +6 -5
- package/dist/es2019/field.js +16 -31
- package/dist/es2019/fieldset.js +21 -12
- package/dist/es2019/form-footer.js +2 -1
- package/dist/es2019/form-header.js +6 -10
- package/dist/es2019/form-section.js +5 -9
- package/dist/es2019/form.js +4 -11
- package/dist/es2019/index.js +2 -1
- package/dist/es2019/label.js +22 -11
- package/dist/es2019/messages.js +47 -31
- package/dist/es2019/range-field.js +2 -4
- package/dist/es2019/version.json +1 -1
- package/dist/esm/checkbox-field.js +15 -22
- package/dist/esm/field.js +49 -73
- package/dist/esm/fieldset.js +27 -18
- package/dist/esm/form-footer.js +4 -3
- package/dist/esm/form-header.js +9 -15
- package/dist/esm/form-section.js +8 -14
- package/dist/esm/form.js +40 -53
- package/dist/esm/index.js +2 -1
- package/dist/esm/label.js +29 -18
- package/dist/esm/messages.js +53 -38
- package/dist/esm/range-field.js +8 -15
- package/dist/esm/version.json +1 -1
- package/dist/types/messages.d.ts +11 -7
- package/package.json +5 -4
- package/report.api.md +27 -9
|
@@ -18,20 +18,20 @@ const formSectionTitleStyles = css({
|
|
|
18
18
|
});
|
|
19
19
|
const formSectionWrapperStyles = css({
|
|
20
20
|
marginTop: `${gridSize * 3}px`
|
|
21
|
-
});
|
|
21
|
+
});
|
|
22
22
|
|
|
23
|
+
// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
23
24
|
const lightH600Styles = css(h600({
|
|
24
25
|
theme: {
|
|
25
26
|
mode: 'light'
|
|
26
27
|
}
|
|
27
|
-
}));
|
|
28
|
-
|
|
28
|
+
}));
|
|
29
|
+
// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
29
30
|
const darkH600Styles = css(h600({
|
|
30
31
|
theme: {
|
|
31
32
|
mode: 'dark'
|
|
32
33
|
}
|
|
33
34
|
}));
|
|
34
|
-
|
|
35
35
|
const FormSectionWrapper = ({
|
|
36
36
|
children
|
|
37
37
|
}) => {
|
|
@@ -39,7 +39,6 @@ const FormSectionWrapper = ({
|
|
|
39
39
|
css: formSectionWrapperStyles
|
|
40
40
|
}, children);
|
|
41
41
|
};
|
|
42
|
-
|
|
43
42
|
const FormSectionTitle = ({
|
|
44
43
|
children
|
|
45
44
|
}) => {
|
|
@@ -50,7 +49,6 @@ const FormSectionTitle = ({
|
|
|
50
49
|
css: [formSectionTitleStyles, mode === 'light' ? lightH600Styles : darkH600Styles]
|
|
51
50
|
}, children);
|
|
52
51
|
};
|
|
53
|
-
|
|
54
52
|
const FormSectionDescription = ({
|
|
55
53
|
children
|
|
56
54
|
}) => {
|
|
@@ -58,6 +56,7 @@ const FormSectionDescription = ({
|
|
|
58
56
|
css: formSectionDescriptionStyles
|
|
59
57
|
}, children);
|
|
60
58
|
};
|
|
59
|
+
|
|
61
60
|
/**
|
|
62
61
|
* __Form section__
|
|
63
62
|
*
|
|
@@ -68,8 +67,6 @@ const FormSectionDescription = ({
|
|
|
68
67
|
* - [Code](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout)
|
|
69
68
|
* - [Usage](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout)
|
|
70
69
|
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
70
|
const FormSection = ({
|
|
74
71
|
children,
|
|
75
72
|
description,
|
|
@@ -77,5 +74,4 @@ const FormSection = ({
|
|
|
77
74
|
}) => {
|
|
78
75
|
return jsx(FormSectionWrapper, null, title && jsx(FormSectionTitle, null, title), description && jsx(FormSectionDescription, null, description), children);
|
|
79
76
|
};
|
|
80
|
-
|
|
81
77
|
export default FormSection;
|
package/dist/es2019/form.js
CHANGED
|
@@ -2,7 +2,6 @@ import React, { createContext, useCallback, useEffect, useMemo, useRef, useState
|
|
|
2
2
|
import { createForm } from 'final-form';
|
|
3
3
|
import createDecorator from 'final-form-focus';
|
|
4
4
|
import set from 'lodash/set';
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* __Form context__
|
|
8
7
|
*
|
|
@@ -14,12 +13,12 @@ export const FormContext = /*#__PURE__*/createContext({
|
|
|
14
13
|
},
|
|
15
14
|
getCurrentValue: () => undefined
|
|
16
15
|
});
|
|
16
|
+
|
|
17
17
|
/**
|
|
18
18
|
* __Is disabled context__
|
|
19
19
|
*
|
|
20
20
|
* An is disabled context creates the context for when a value is disabled.
|
|
21
21
|
*/
|
|
22
|
-
|
|
23
22
|
export const IsDisabledContext = /*#__PURE__*/createContext(false);
|
|
24
23
|
export default function Form(props) {
|
|
25
24
|
const formRef = useRef(null);
|
|
@@ -37,8 +36,8 @@ export default function Form(props) {
|
|
|
37
36
|
const initialValues = state.formState.initialValues;
|
|
38
37
|
const values = state.formState.values;
|
|
39
38
|
const value = name && typeof defaultValue === 'function' ? defaultValue(initialValues[name]) : defaultValue;
|
|
40
|
-
/* eslint-disable no-param-reassign */
|
|
41
39
|
|
|
40
|
+
/* eslint-disable no-param-reassign */
|
|
42
41
|
set(initialValues, name, value);
|
|
43
42
|
set(values, name, value);
|
|
44
43
|
/* eslint-enable */
|
|
@@ -46,6 +45,7 @@ export default function Form(props) {
|
|
|
46
45
|
}
|
|
47
46
|
}
|
|
48
47
|
});
|
|
48
|
+
|
|
49
49
|
createDecorator(() => formRef.current ? Array.from(formRef.current.querySelectorAll('input')) : [])(finalForm);
|
|
50
50
|
return finalForm;
|
|
51
51
|
});
|
|
@@ -75,31 +75,24 @@ export default function Form(props) {
|
|
|
75
75
|
form.resumeValidation();
|
|
76
76
|
return unsubscribe;
|
|
77
77
|
}, [form]);
|
|
78
|
-
|
|
79
78
|
const handleSubmit = e => {
|
|
80
79
|
if (e) {
|
|
81
80
|
e.preventDefault();
|
|
82
81
|
}
|
|
83
|
-
|
|
84
82
|
form.submit();
|
|
85
83
|
};
|
|
86
|
-
|
|
87
84
|
const handleReset = initialValues => {
|
|
88
85
|
form.reset(initialValues);
|
|
89
86
|
};
|
|
90
|
-
|
|
91
87
|
const handleKeyDown = e => {
|
|
92
88
|
if (e.key === 'Enter' && (e.ctrlKey || e.metaKey) && formRef.current) {
|
|
93
89
|
const submitButton = formRef.current.querySelector('button:not([type]), button[type="submit"], input[type="submit"]');
|
|
94
|
-
|
|
95
90
|
if (submitButton) {
|
|
96
91
|
submitButton.click();
|
|
97
92
|
}
|
|
98
|
-
|
|
99
93
|
e.preventDefault();
|
|
100
94
|
}
|
|
101
95
|
};
|
|
102
|
-
|
|
103
96
|
const {
|
|
104
97
|
isDisabled = false,
|
|
105
98
|
children
|
|
@@ -108,11 +101,11 @@ export default function Form(props) {
|
|
|
108
101
|
dirty,
|
|
109
102
|
submitting
|
|
110
103
|
} = state;
|
|
104
|
+
|
|
111
105
|
/**
|
|
112
106
|
* This method is needed in FormContext to use it on the field level
|
|
113
107
|
* to check the current value of the field in case of the component re-mounting.
|
|
114
108
|
*/
|
|
115
|
-
|
|
116
109
|
const getCurrentValue = useCallback(name => {
|
|
117
110
|
const formState = form.getState();
|
|
118
111
|
return (formState === null || formState === void 0 ? void 0 : formState.values[name]) || undefined;
|
package/dist/es2019/index.js
CHANGED
|
@@ -7,4 +7,5 @@ export { default as CheckboxField } from './checkbox-field';
|
|
|
7
7
|
export { default as RangeField } from './range-field';
|
|
8
8
|
export { default as Label } from './label';
|
|
9
9
|
export { HelperMessage, ErrorMessage, ValidMessage } from './messages';
|
|
10
|
-
export { default as Fieldset } from './fieldset';
|
|
10
|
+
export { default as Fieldset } from './fieldset';
|
|
11
|
+
// eslint-disable-next-line import/no-unresolved
|
package/dist/es2019/label.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
+
|
|
2
3
|
import { css, jsx } from '@emotion/react';
|
|
4
|
+
import { subtleHeading } from '@atlaskit/theme/colors';
|
|
3
5
|
import { useGlobalTheme } from '@atlaskit/theme/components';
|
|
4
6
|
import { fontFamily as getFontFamily, gridSize as getGridSize } from '@atlaskit/theme/constants';
|
|
5
7
|
import { h200 } from '@atlaskit/theme/typography';
|
|
@@ -10,19 +12,30 @@ const labelStyles = css({
|
|
|
10
12
|
marginTop: 0,
|
|
11
13
|
marginBottom: gridSize / 2,
|
|
12
14
|
fontFamily: fontFamily
|
|
13
|
-
});
|
|
15
|
+
});
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
/**
|
|
18
|
+
* TODO: Address duplication with packages/design-system/form/src/fieldset.tsx
|
|
19
|
+
* in https://product-fabric.atlassian.net/browse/DSP-7731
|
|
20
|
+
*/
|
|
21
|
+
const getFieldsetLabelDynamicStyles = mode => css([h200({
|
|
16
22
|
theme: {
|
|
17
|
-
mode
|
|
23
|
+
mode
|
|
18
24
|
}
|
|
19
|
-
})
|
|
25
|
+
}), {
|
|
26
|
+
color: `var(--ds-text-subtle, ${subtleHeading({
|
|
27
|
+
theme: {
|
|
28
|
+
mode
|
|
29
|
+
}
|
|
30
|
+
})})`
|
|
31
|
+
}]);
|
|
32
|
+
|
|
33
|
+
// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
34
|
+
const lightH200Styles = getFieldsetLabelDynamicStyles('light');
|
|
35
|
+
|
|
36
|
+
// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
37
|
+
const darkH200Styles = getFieldsetLabelDynamicStyles('dark');
|
|
20
38
|
|
|
21
|
-
const darkH200Styles = css(h200({
|
|
22
|
-
theme: {
|
|
23
|
-
mode: 'dark'
|
|
24
|
-
}
|
|
25
|
-
}));
|
|
26
39
|
/**
|
|
27
40
|
* __Label__
|
|
28
41
|
*
|
|
@@ -31,7 +44,6 @@ const darkH200Styles = css(h200({
|
|
|
31
44
|
* It's recommended that a label has a `4px` spacing above its associated
|
|
32
45
|
* control element.
|
|
33
46
|
*/
|
|
34
|
-
|
|
35
47
|
const Label = ({
|
|
36
48
|
children,
|
|
37
49
|
htmlFor,
|
|
@@ -46,5 +58,4 @@ const Label = ({
|
|
|
46
58
|
htmlFor: htmlFor
|
|
47
59
|
}, children);
|
|
48
60
|
};
|
|
49
|
-
|
|
50
61
|
export default Label;
|
package/dist/es2019/messages.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
+
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import { css, jsx } from '@emotion/react';
|
|
4
5
|
import SuccessIcon from '@atlaskit/icon/glyph/editor/success';
|
|
@@ -9,28 +10,20 @@ import { fontFamily as getFontFamily, gridSize as getGridSize } from '@atlaskit/
|
|
|
9
10
|
import { h200 } from '@atlaskit/theme/typography';
|
|
10
11
|
import { FieldId } from './field';
|
|
11
12
|
const gridSize = getGridSize();
|
|
12
|
-
const fontFamily = getFontFamily();
|
|
13
|
+
const fontFamily = getFontFamily();
|
|
13
14
|
|
|
15
|
+
// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
14
16
|
const lightH200Styles = css(h200({
|
|
15
17
|
theme: {
|
|
16
18
|
mode: 'light'
|
|
17
19
|
}
|
|
18
|
-
}));
|
|
19
|
-
|
|
20
|
+
}));
|
|
21
|
+
// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
20
22
|
const darkH200Styles = css(h200({
|
|
21
23
|
theme: {
|
|
22
24
|
mode: 'dark'
|
|
23
25
|
}
|
|
24
26
|
}));
|
|
25
|
-
const messageErrorColorStyles = css({
|
|
26
|
-
color: "var(--ds-text-danger, #AE2A19)"
|
|
27
|
-
});
|
|
28
|
-
const messageNeutralColorStyles = css({
|
|
29
|
-
color: `var(--ds-text-subtlest, ${N200})`
|
|
30
|
-
});
|
|
31
|
-
const messageValidColorStyles = css({
|
|
32
|
-
color: "var(--ds-text-success, #216E4E)"
|
|
33
|
-
});
|
|
34
27
|
const messageStyles = css({
|
|
35
28
|
display: 'flex',
|
|
36
29
|
marginTop: `${gridSize * 0.5}px`,
|
|
@@ -38,10 +31,20 @@ const messageStyles = css({
|
|
|
38
31
|
fontFamily: `${fontFamily}`,
|
|
39
32
|
fontWeight: 'normal'
|
|
40
33
|
});
|
|
34
|
+
const messageAppearanceStyles = {
|
|
35
|
+
default: css({
|
|
36
|
+
color: `var(--ds-text-subtlest, ${N200})`
|
|
37
|
+
}),
|
|
38
|
+
error: css({
|
|
39
|
+
color: "var(--ds-text-danger, #AE2A19)"
|
|
40
|
+
}),
|
|
41
|
+
valid: css({
|
|
42
|
+
color: "var(--ds-text-success, #216E4E)"
|
|
43
|
+
})
|
|
44
|
+
};
|
|
41
45
|
const iconWrapperStyles = css({
|
|
42
46
|
display: 'flex'
|
|
43
47
|
});
|
|
44
|
-
|
|
45
48
|
const IconWrapper = ({
|
|
46
49
|
children
|
|
47
50
|
}) => {
|
|
@@ -49,22 +52,41 @@ const IconWrapper = ({
|
|
|
49
52
|
css: iconWrapperStyles
|
|
50
53
|
}, children);
|
|
51
54
|
};
|
|
52
|
-
|
|
55
|
+
const messageIcons = {
|
|
56
|
+
error: jsx(ErrorIcon, {
|
|
57
|
+
size: "small",
|
|
58
|
+
label: "error"
|
|
59
|
+
}),
|
|
60
|
+
valid: jsx(SuccessIcon, {
|
|
61
|
+
size: "small",
|
|
62
|
+
label: "success"
|
|
63
|
+
})
|
|
64
|
+
};
|
|
53
65
|
const Message = ({
|
|
54
66
|
children,
|
|
55
|
-
|
|
56
|
-
valid,
|
|
67
|
+
appearance = 'default',
|
|
57
68
|
fieldId,
|
|
58
69
|
testId
|
|
59
70
|
}) => {
|
|
60
71
|
const {
|
|
61
72
|
mode
|
|
62
73
|
} = useGlobalTheme();
|
|
74
|
+
const icon = messageIcons[appearance];
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The wrapping span is necessary to preserve spaces between children.
|
|
78
|
+
* Otherwise the flex layout of the message will remove any whitespace
|
|
79
|
+
* between children.
|
|
80
|
+
*
|
|
81
|
+
* If the child is just a string, this is not required and we can use one
|
|
82
|
+
* less DOM element.
|
|
83
|
+
*/
|
|
84
|
+
const content = typeof children === 'string' ? children : jsx("span", null, children);
|
|
63
85
|
return jsx("div", {
|
|
64
|
-
css: [mode === 'light' ? lightH200Styles : darkH200Styles, messageStyles,
|
|
86
|
+
css: [mode === 'light' ? lightH200Styles : darkH200Styles, messageStyles, messageAppearanceStyles[appearance]],
|
|
65
87
|
"data-testid": testId,
|
|
66
88
|
id: fieldId
|
|
67
|
-
},
|
|
89
|
+
}, icon && jsx(IconWrapper, null, icon), content);
|
|
68
90
|
};
|
|
69
91
|
|
|
70
92
|
/**
|
|
@@ -81,6 +103,7 @@ export const HelperMessage = ({
|
|
|
81
103
|
fieldId: fieldId ? `${fieldId}-helper` : undefined,
|
|
82
104
|
testId: testId
|
|
83
105
|
}, children));
|
|
106
|
+
|
|
84
107
|
/**
|
|
85
108
|
* __Error message__
|
|
86
109
|
*
|
|
@@ -88,18 +111,15 @@ export const HelperMessage = ({
|
|
|
88
111
|
* 'Invalid username, needs to be more than 4 characters'.
|
|
89
112
|
*
|
|
90
113
|
*/
|
|
91
|
-
|
|
92
114
|
export const ErrorMessage = ({
|
|
93
115
|
children,
|
|
94
116
|
testId
|
|
95
117
|
}) => jsx(FieldId.Consumer, null, fieldId => jsx(Message, {
|
|
96
|
-
|
|
118
|
+
appearance: "error",
|
|
97
119
|
fieldId: fieldId ? `${fieldId}-error` : undefined,
|
|
98
120
|
testId: testId
|
|
99
|
-
},
|
|
100
|
-
|
|
101
|
-
label: "error"
|
|
102
|
-
})), children));
|
|
121
|
+
}, children));
|
|
122
|
+
|
|
103
123
|
/**
|
|
104
124
|
* __Valid message__
|
|
105
125
|
*
|
|
@@ -107,15 +127,11 @@ export const ErrorMessage = ({
|
|
|
107
127
|
* a helper message could be 'Nice one, this username is available'.
|
|
108
128
|
*
|
|
109
129
|
*/
|
|
110
|
-
|
|
111
130
|
export const ValidMessage = ({
|
|
112
131
|
children,
|
|
113
132
|
testId
|
|
114
133
|
}) => jsx(FieldId.Consumer, null, fieldId => jsx(Message, {
|
|
134
|
+
appearance: "valid",
|
|
115
135
|
fieldId: fieldId ? `${fieldId}-valid` : undefined,
|
|
116
|
-
testId: testId
|
|
117
|
-
|
|
118
|
-
}, jsx(IconWrapper, null, jsx(SuccessIcon, {
|
|
119
|
-
size: "small",
|
|
120
|
-
label: "success"
|
|
121
|
-
})), children));
|
|
136
|
+
testId: testId
|
|
137
|
+
}, children));
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import Field from './field';
|
|
4
|
-
|
|
5
4
|
/**
|
|
6
5
|
* __Range field__
|
|
7
6
|
*
|
|
@@ -15,8 +14,8 @@ const RangeField = props => {
|
|
|
15
14
|
const {
|
|
16
15
|
children,
|
|
17
16
|
...strippedProps
|
|
18
|
-
} = props;
|
|
19
|
-
|
|
17
|
+
} = props;
|
|
18
|
+
// isInvalid and isRequired are specifically invalid for range inputs
|
|
20
19
|
return (
|
|
21
20
|
/*#__PURE__*/
|
|
22
21
|
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
@@ -35,5 +34,4 @@ const RangeField = props => {
|
|
|
35
34
|
}))
|
|
36
35
|
);
|
|
37
36
|
};
|
|
38
|
-
|
|
39
37
|
export default RangeField;
|
package/dist/es2019/version.json
CHANGED
|
@@ -3,18 +3,14 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
3
3
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
5
5
|
var _excluded = ["children", "defaultIsChecked", "value"],
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
_excluded2 = ["value"],
|
|
7
|
+
_excluded3 = ["fieldProps"],
|
|
8
|
+
_excluded4 = ["value"],
|
|
9
|
+
_excluded5 = ["fieldProps"];
|
|
11
10
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
12
|
-
|
|
13
11
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
14
|
-
|
|
15
12
|
import React, { useCallback } from 'react';
|
|
16
13
|
import Field from './field';
|
|
17
|
-
|
|
18
14
|
/**
|
|
19
15
|
* __Checkbox field__
|
|
20
16
|
*
|
|
@@ -26,12 +22,12 @@ import Field from './field';
|
|
|
26
22
|
*/
|
|
27
23
|
var CheckboxField = function CheckboxField(props) {
|
|
28
24
|
var children = props.children,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
_props$defaultIsCheck = props.defaultIsChecked,
|
|
26
|
+
defaultIsChecked = _props$defaultIsCheck === void 0 ? false : _props$defaultIsCheck,
|
|
27
|
+
value = props.value,
|
|
28
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
34
29
|
|
|
30
|
+
// Maintains a memoised list of the default values
|
|
35
31
|
var defaultValue = useCallback(function () {
|
|
36
32
|
var currentValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
37
33
|
return defaultIsChecked && value !== undefined ? [].concat(_toConsumableArray(currentValue), [value]) : currentValue;
|
|
@@ -45,10 +41,9 @@ var CheckboxField = function CheckboxField(props) {
|
|
|
45
41
|
}
|
|
46
42
|
}), function (_ref) {
|
|
47
43
|
var _ref$fieldProps = _ref.fieldProps,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
fieldValue = _ref$fieldProps.value,
|
|
45
|
+
otherFieldProps = _objectWithoutProperties(_ref$fieldProps, _excluded2),
|
|
46
|
+
others = _objectWithoutProperties(_ref, _excluded3);
|
|
52
47
|
return children(_objectSpread({
|
|
53
48
|
fieldProps: _objectSpread(_objectSpread({}, otherFieldProps), {}, {
|
|
54
49
|
isChecked: !!fieldValue.find(function (v) {
|
|
@@ -64,10 +59,9 @@ var CheckboxField = function CheckboxField(props) {
|
|
|
64
59
|
}
|
|
65
60
|
}), function (_ref2) {
|
|
66
61
|
var _ref2$fieldProps = _ref2.fieldProps,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
62
|
+
fieldValue = _ref2$fieldProps.value,
|
|
63
|
+
otherFieldProps = _objectWithoutProperties(_ref2$fieldProps, _excluded4),
|
|
64
|
+
others = _objectWithoutProperties(_ref2, _excluded5);
|
|
71
65
|
return children(_objectSpread({
|
|
72
66
|
fieldProps: _objectSpread(_objectSpread({}, otherFieldProps), {}, {
|
|
73
67
|
isChecked: fieldValue,
|
|
@@ -76,7 +70,6 @@ var CheckboxField = function CheckboxField(props) {
|
|
|
76
70
|
}, others));
|
|
77
71
|
});
|
|
78
72
|
};
|
|
79
|
-
|
|
80
73
|
CheckboxField.defaultProps = {
|
|
81
74
|
defaultIsChecked: false
|
|
82
75
|
};
|