@atlaskit/form 10.5.12 → 10.6.0

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/form
2
2
 
3
+ ## 10.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#168743](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/168743)
8
+ [`b27dba8a5f3cd`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b27dba8a5f3cd) -
9
+ Update types to improve compatibility with React 18.
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
3
15
  ## 10.5.12
4
16
 
5
17
  ### Patch Changes
package/dist/cjs/form.js CHANGED
@@ -141,27 +141,33 @@ function Form(props) {
141
141
  subscribe: form.subscribe
142
142
  };
143
143
  }, [registerField, getCurrentValue, form.subscribe]);
144
+ var childrenContent = function () {
145
+ if (typeof children === 'function') {
146
+ var result = children.length > 0 ? children({
147
+ formProps: {
148
+ onSubmit: handleSubmit,
149
+ ref: formRef,
150
+ onKeyDown: handleKeyDown
151
+ },
152
+ dirty: dirty,
153
+ reset: handleReset,
154
+ submitting: submitting,
155
+ disabled: isDisabled,
156
+ getState: function getState() {
157
+ return form.getState();
158
+ },
159
+ getValues: function getValues() {
160
+ return form.getState().values;
161
+ },
162
+ setFieldValue: form.change
163
+ }) : children();
164
+ return result === undefined ? null : result;
165
+ }
166
+ return children;
167
+ }();
144
168
  return /*#__PURE__*/_react.default.createElement(FormContext.Provider, {
145
169
  value: FormContextValue
146
170
  }, /*#__PURE__*/_react.default.createElement(IsDisabledContext.Provider, {
147
171
  value: isDisabled
148
- }, children({
149
- formProps: {
150
- onSubmit: handleSubmit,
151
- ref: formRef,
152
- onKeyDown: handleKeyDown
153
- },
154
- dirty: dirty,
155
- reset: handleReset,
156
- submitting: submitting,
157
- disabled: isDisabled,
158
- getState: function getState() {
159
- return form.getState();
160
- },
161
- getValues: function getValues() {
162
- return form.getState().values;
163
- },
164
- // TODO: deprecate
165
- setFieldValue: form.change
166
- })));
172
+ }, childrenContent));
167
173
  }
@@ -119,23 +119,29 @@ export default function Form(props) {
119
119
  subscribe: form.subscribe
120
120
  };
121
121
  }, [registerField, getCurrentValue, form.subscribe]);
122
+ const childrenContent = (() => {
123
+ if (typeof children === 'function') {
124
+ const result = children.length > 0 ? children({
125
+ formProps: {
126
+ onSubmit: handleSubmit,
127
+ ref: formRef,
128
+ onKeyDown: handleKeyDown
129
+ },
130
+ dirty,
131
+ reset: handleReset,
132
+ submitting,
133
+ disabled: isDisabled,
134
+ getState: () => form.getState(),
135
+ getValues: () => form.getState().values,
136
+ setFieldValue: form.change
137
+ }) : children();
138
+ return result === undefined ? null : result;
139
+ }
140
+ return children;
141
+ })();
122
142
  return /*#__PURE__*/React.createElement(FormContext.Provider, {
123
143
  value: FormContextValue
124
144
  }, /*#__PURE__*/React.createElement(IsDisabledContext.Provider, {
125
145
  value: isDisabled
126
- }, children({
127
- formProps: {
128
- onSubmit: handleSubmit,
129
- ref: formRef,
130
- onKeyDown: handleKeyDown
131
- },
132
- dirty,
133
- reset: handleReset,
134
- submitting,
135
- disabled: isDisabled,
136
- getState: () => form.getState(),
137
- getValues: () => form.getState().values,
138
- // TODO: deprecate
139
- setFieldValue: form.change
140
- })));
146
+ }, childrenContent));
141
147
  }
package/dist/esm/form.js CHANGED
@@ -130,27 +130,33 @@ export default function Form(props) {
130
130
  subscribe: form.subscribe
131
131
  };
132
132
  }, [registerField, getCurrentValue, form.subscribe]);
133
+ var childrenContent = function () {
134
+ if (typeof children === 'function') {
135
+ var result = children.length > 0 ? children({
136
+ formProps: {
137
+ onSubmit: handleSubmit,
138
+ ref: formRef,
139
+ onKeyDown: handleKeyDown
140
+ },
141
+ dirty: dirty,
142
+ reset: handleReset,
143
+ submitting: submitting,
144
+ disabled: isDisabled,
145
+ getState: function getState() {
146
+ return form.getState();
147
+ },
148
+ getValues: function getValues() {
149
+ return form.getState().values;
150
+ },
151
+ setFieldValue: form.change
152
+ }) : children();
153
+ return result === undefined ? null : result;
154
+ }
155
+ return children;
156
+ }();
133
157
  return /*#__PURE__*/React.createElement(FormContext.Provider, {
134
158
  value: FormContextValue
135
159
  }, /*#__PURE__*/React.createElement(IsDisabledContext.Provider, {
136
160
  value: isDisabled
137
- }, children({
138
- formProps: {
139
- onSubmit: handleSubmit,
140
- ref: formRef,
141
- onKeyDown: handleKeyDown
142
- },
143
- dirty: dirty,
144
- reset: handleReset,
145
- submitting: submitting,
146
- disabled: isDisabled,
147
- getState: function getState() {
148
- return form.getState();
149
- },
150
- getValues: function getValues() {
151
- return form.getState().values;
152
- },
153
- // TODO: deprecate
154
- setFieldValue: form.change
155
- })));
161
+ }, childrenContent));
156
162
  }
@@ -25,24 +25,22 @@ interface FormChildrenProps {
25
25
  onSubmit: (event?: React.FormEvent<HTMLFormElement> | React.SyntheticEvent<HTMLElement>) => void;
26
26
  onKeyDown: (event: React.KeyboardEvent<HTMLElement>) => void;
27
27
  }
28
+ type FormChildrenArgs<FormValues> = {
29
+ formProps: FormChildrenProps;
30
+ disabled: boolean;
31
+ dirty: boolean;
32
+ submitting: boolean;
33
+ getState: () => FormState<FormValues>;
34
+ getValues: () => FormValues;
35
+ setFieldValue: (name: string, value: any) => void;
36
+ reset: (initialValues?: FormValues) => void;
37
+ };
28
38
  export interface FormProps<FormValues> {
29
39
  /**
30
40
  * The contents rendered inside of the form. This is a function where the props will be passed from the form. The function props you can access are `dirty`, `submitting` and `disabled`.
31
41
  * You can read more about these props in [react-final form documentation](https://final-form.org/docs/final-form/types/FormState).
32
42
  */
33
- children: (args: {
34
- formProps: FormChildrenProps;
35
- disabled: boolean;
36
- dirty: boolean;
37
- submitting: boolean;
38
- getState: () => FormState<FormValues>;
39
- /**
40
- * @deprecated
41
- */
42
- getValues: () => FormValues;
43
- setFieldValue: (name: string, value: any) => void;
44
- reset: (initialValues?: FormValues) => void;
45
- }) => ReactNode;
43
+ children: ((args: FormChildrenArgs<FormValues>) => ReactNode) | (() => void) | ReactNode;
46
44
  /**
47
45
  * Event handler called when the form is submitted. Fields must be free of validation errors.
48
46
  */
@@ -25,24 +25,22 @@ interface FormChildrenProps {
25
25
  onSubmit: (event?: React.FormEvent<HTMLFormElement> | React.SyntheticEvent<HTMLElement>) => void;
26
26
  onKeyDown: (event: React.KeyboardEvent<HTMLElement>) => void;
27
27
  }
28
+ type FormChildrenArgs<FormValues> = {
29
+ formProps: FormChildrenProps;
30
+ disabled: boolean;
31
+ dirty: boolean;
32
+ submitting: boolean;
33
+ getState: () => FormState<FormValues>;
34
+ getValues: () => FormValues;
35
+ setFieldValue: (name: string, value: any) => void;
36
+ reset: (initialValues?: FormValues) => void;
37
+ };
28
38
  export interface FormProps<FormValues> {
29
39
  /**
30
40
  * The contents rendered inside of the form. This is a function where the props will be passed from the form. The function props you can access are `dirty`, `submitting` and `disabled`.
31
41
  * You can read more about these props in [react-final form documentation](https://final-form.org/docs/final-form/types/FormState).
32
42
  */
33
- children: (args: {
34
- formProps: FormChildrenProps;
35
- disabled: boolean;
36
- dirty: boolean;
37
- submitting: boolean;
38
- getState: () => FormState<FormValues>;
39
- /**
40
- * @deprecated
41
- */
42
- getValues: () => FormValues;
43
- setFieldValue: (name: string, value: any) => void;
44
- reset: (initialValues?: FormValues) => void;
45
- }) => ReactNode;
43
+ children: ((args: FormChildrenArgs<FormValues>) => ReactNode) | (() => void) | ReactNode;
46
44
  /**
47
45
  * Event handler called when the form is submitted. Fields must be free of validation errors.
48
46
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/form",
3
- "version": "10.5.12",
3
+ "version": "10.6.0",
4
4
  "description": "A form allows users to input information.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -21,17 +21,17 @@
21
21
  "team": "Design System Team",
22
22
  "website": {
23
23
  "name": "Form",
24
- "category": "Components"
24
+ "category": "Forms and input"
25
25
  },
26
26
  "runReact18": true
27
27
  },
28
28
  "dependencies": {
29
- "@atlaskit/ds-lib": "^3.2.0",
29
+ "@atlaskit/ds-lib": "^3.3.0",
30
30
  "@atlaskit/heading": "^3.1.0",
31
- "@atlaskit/icon": "^22.24.0",
32
- "@atlaskit/primitives": "^13.2.0",
31
+ "@atlaskit/icon": "^22.27.0",
32
+ "@atlaskit/primitives": "^13.3.0",
33
33
  "@atlaskit/theme": "^14.0.0",
34
- "@atlaskit/tokens": "^2.2.0",
34
+ "@atlaskit/tokens": "^2.4.0",
35
35
  "@babel/runtime": "^7.0.0",
36
36
  "@emotion/react": "^11.7.1",
37
37
  "final-form": "^4.20.3",
@@ -46,15 +46,15 @@
46
46
  "@af/accessibility-testing": "*",
47
47
  "@af/integration-testing": "*",
48
48
  "@af/visual-regression": "*",
49
- "@atlaskit/banner": "^12.5.0",
49
+ "@atlaskit/banner": "^12.6.0",
50
50
  "@atlaskit/button": "^20.3.0",
51
- "@atlaskit/checkbox": "^15.1.0",
51
+ "@atlaskit/checkbox": "^15.2.0",
52
52
  "@atlaskit/modal-dialog": "^12.17.0",
53
- "@atlaskit/radio": "^6.5.0",
53
+ "@atlaskit/radio": "^6.6.0",
54
54
  "@atlaskit/range": "^7.4.0",
55
- "@atlaskit/select": "^18.5.0",
55
+ "@atlaskit/select": "^18.6.0",
56
56
  "@atlaskit/ssr": "*",
57
- "@atlaskit/textfield": "^6.5.0",
57
+ "@atlaskit/textfield": "^6.6.0",
58
58
  "@atlaskit/toggle": "^13.4.0",
59
59
  "@atlaskit/visual-regression": "*",
60
60
  "@testing-library/react": "^12.1.5",