@atlaskit/form 8.6.0 → 8.7.1
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 +16 -0
- package/dist/cjs/field.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/field.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/field.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/field.d.ts +4 -0
- package/package.json +5 -11
- package/report.api.md +126 -276
- package/dist/types-ts4.0/checkbox-field.d.ts +0 -51
- package/dist/types-ts4.0/entry-points/checkbox-field.d.ts +0 -2
- package/dist/types-ts4.0/entry-points/field.d.ts +0 -2
- package/dist/types-ts4.0/entry-points/fieldset.d.ts +0 -1
- package/dist/types-ts4.0/entry-points/form-footer.d.ts +0 -1
- package/dist/types-ts4.0/entry-points/form-header.d.ts +0 -1
- package/dist/types-ts4.0/entry-points/form-section.d.ts +0 -1
- package/dist/types-ts4.0/entry-points/form.d.ts +0 -1
- package/dist/types-ts4.0/entry-points/label.d.ts +0 -2
- package/dist/types-ts4.0/entry-points/messages.d.ts +0 -1
- package/dist/types-ts4.0/entry-points/range-field.d.ts +0 -2
- package/dist/types-ts4.0/field.d.ts +0 -79
- package/dist/types-ts4.0/fieldset.d.ts +0 -25
- package/dist/types-ts4.0/form-footer.d.ts +0 -24
- package/dist/types-ts4.0/form-header.d.ts +0 -32
- package/dist/types-ts4.0/form-section.d.ts +0 -28
- package/dist/types-ts4.0/form.d.ts +0 -51
- package/dist/types-ts4.0/index.d.ts +0 -16
- package/dist/types-ts4.0/label.d.ts +0 -16
- package/dist/types-ts4.0/messages.d.ts +0 -48
- package/dist/types-ts4.0/range-field.d.ts +0 -41
- package/dist/types-ts4.0/types.d.ts +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/form
|
|
2
2
|
|
|
3
|
+
## 8.7.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 8.7.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`500a96aa7de`](https://bitbucket.org/atlassian/atlassian-frontend/commits/500a96aa7de) - Add elementAfterLabel prop to form Field.
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [`001c650e983`](https://bitbucket.org/atlassian/atlassian-frontend/commits/001c650e983) - Add ds-lib devDependency. No behaviour change.
|
|
18
|
+
|
|
3
19
|
## 8.6.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
package/dist/cjs/field.js
CHANGED
|
@@ -274,7 +274,7 @@ function Field(props) {
|
|
|
274
274
|
}, props.label, props.isRequired && (0, _react2.jsx)("span", {
|
|
275
275
|
css: requiredIndicatorStyles,
|
|
276
276
|
"aria-hidden": "true"
|
|
277
|
-
}, "*")), (0, _react2.jsx)(FieldId.Provider, {
|
|
277
|
+
}, "*"), props.elementAfterLabel), (0, _react2.jsx)(FieldId.Provider, {
|
|
278
278
|
value: fieldId
|
|
279
279
|
}, props.children({
|
|
280
280
|
fieldProps: extendedFieldProps,
|
package/dist/cjs/version.json
CHANGED
package/dist/es2019/field.js
CHANGED
|
@@ -236,7 +236,7 @@ export default function Field(props) {
|
|
|
236
236
|
}, props.label, props.isRequired && jsx("span", {
|
|
237
237
|
css: requiredIndicatorStyles,
|
|
238
238
|
"aria-hidden": "true"
|
|
239
|
-
}, "*")), jsx(FieldId.Provider, {
|
|
239
|
+
}, "*"), props.elementAfterLabel), jsx(FieldId.Provider, {
|
|
240
240
|
value: fieldId
|
|
241
241
|
}, props.children({
|
|
242
242
|
fieldProps: extendedFieldProps,
|
package/dist/es2019/version.json
CHANGED
package/dist/esm/field.js
CHANGED
|
@@ -254,7 +254,7 @@ export default function Field(props) {
|
|
|
254
254
|
}, props.label, props.isRequired && jsx("span", {
|
|
255
255
|
css: requiredIndicatorStyles,
|
|
256
256
|
"aria-hidden": "true"
|
|
257
|
-
}, "*")), jsx(FieldId.Provider, {
|
|
257
|
+
}, "*"), props.elementAfterLabel), jsx(FieldId.Provider, {
|
|
258
258
|
value: fieldId
|
|
259
259
|
}, props.children({
|
|
260
260
|
fieldProps: extendedFieldProps,
|
package/dist/esm/version.json
CHANGED
package/dist/types/field.d.ts
CHANGED
|
@@ -56,6 +56,10 @@ export interface FieldComponentProps<FieldValue, Element extends SupportedElemen
|
|
|
56
56
|
* Label displayed above the form field.
|
|
57
57
|
*/
|
|
58
58
|
label?: ReactNode;
|
|
59
|
+
/**
|
|
60
|
+
* Element displayed after the label, and after the red asterisk if field is required.
|
|
61
|
+
*/
|
|
62
|
+
elementAfterLabel?: ReactNode;
|
|
59
63
|
/**
|
|
60
64
|
* Specifies the name of the field. This is important for referencing the form data.
|
|
61
65
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/form",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.7.1",
|
|
4
4
|
"description": "A form allows users to input information.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -12,13 +12,6 @@
|
|
|
12
12
|
"module": "dist/esm/index.js",
|
|
13
13
|
"module:es2019": "dist/es2019/index.js",
|
|
14
14
|
"types": "dist/types/index.d.ts",
|
|
15
|
-
"typesVersions": {
|
|
16
|
-
">=4.0 <4.5": {
|
|
17
|
-
"*": [
|
|
18
|
-
"dist/types-ts4.0/*"
|
|
19
|
-
]
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
15
|
"sideEffects": false,
|
|
23
16
|
"atlaskit:src": "src/index.tsx",
|
|
24
17
|
"atlaskit:designLink": "https://atlassian.design/guidelines/product/patterns/forms",
|
|
@@ -36,6 +29,7 @@
|
|
|
36
29
|
".": "./src/index.tsx"
|
|
37
30
|
},
|
|
38
31
|
"atlassian": {
|
|
32
|
+
"disableProductCI": true,
|
|
39
33
|
"team": "Design System Team",
|
|
40
34
|
"releaseModel": "scheduled",
|
|
41
35
|
"website": {
|
|
@@ -47,7 +41,7 @@
|
|
|
47
41
|
"dependencies": {
|
|
48
42
|
"@atlaskit/icon": "^21.11.0",
|
|
49
43
|
"@atlaskit/theme": "^12.2.0",
|
|
50
|
-
"@atlaskit/tokens": "^0.
|
|
44
|
+
"@atlaskit/tokens": "^0.11.0",
|
|
51
45
|
"@babel/runtime": "^7.0.0",
|
|
52
46
|
"@emotion/react": "^11.7.1",
|
|
53
47
|
"final-form": "^4.20.1",
|
|
@@ -60,7 +54,7 @@
|
|
|
60
54
|
"react": "^16.8.0"
|
|
61
55
|
},
|
|
62
56
|
"devDependencies": {
|
|
63
|
-
"@atlaskit/button": "^16.
|
|
57
|
+
"@atlaskit/button": "^16.4.0",
|
|
64
58
|
"@atlaskit/calendar": "^12.4.0",
|
|
65
59
|
"@atlaskit/checkbox": "^12.4.0",
|
|
66
60
|
"@atlaskit/datetime-picker": "^12.3.0",
|
|
@@ -70,7 +64,7 @@
|
|
|
70
64
|
"@atlaskit/ds-lib": "^2.1.1",
|
|
71
65
|
"@atlaskit/modal-dialog": "^12.4.0",
|
|
72
66
|
"@atlaskit/radio": "^5.4.0",
|
|
73
|
-
"@atlaskit/range": "^
|
|
67
|
+
"@atlaskit/range": "^7.0.0",
|
|
74
68
|
"@atlaskit/section-message": "^6.3.0",
|
|
75
69
|
"@atlaskit/select": "^15.7.0",
|
|
76
70
|
"@atlaskit/ssr": "*",
|
package/report.api.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
## API Report File for "@atlaskit/form"
|
|
1
|
+
## API Report File for "@atlaskit/form"
|
|
2
2
|
|
|
3
|
-
> Do not edit this file.
|
|
3
|
+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
+
|
|
5
|
+
<!--
|
|
6
|
+
Generated API Report version: 2.0
|
|
7
|
+
-->
|
|
4
8
|
|
|
5
9
|
[Learn more about API reports](https://hello.atlassian.net/wiki/spaces/UR/pages/1825484529/Package+API+Reports)
|
|
6
10
|
|
|
@@ -13,123 +17,63 @@ import { jsx } from '@emotion/react';
|
|
|
13
17
|
import { default as React_2 } from 'react';
|
|
14
18
|
import { ReactNode } from 'react';
|
|
15
19
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
* - [Usage] https://atlaskit.atlassian.com/packages/design-system/form/docs/fields#checkboxfield-reference
|
|
26
|
-
*/
|
|
27
|
-
export declare const CheckboxField: FC<CheckboxProps>;
|
|
28
|
-
|
|
29
|
-
export declare interface CheckboxFieldProps
|
|
30
|
-
extends FieldProps<string | undefined> {
|
|
20
|
+
// @public (undocumented)
|
|
21
|
+
type Align = 'start' | 'end';
|
|
22
|
+
|
|
23
|
+
// @public
|
|
24
|
+
export const CheckboxField: FC<CheckboxProps>;
|
|
25
|
+
|
|
26
|
+
// @public (undocumented)
|
|
27
|
+
export interface CheckboxFieldProps extends FieldProps<string | undefined> {
|
|
28
|
+
// (undocumented)
|
|
31
29
|
isChecked: boolean;
|
|
32
30
|
}
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
* Content to render in the checkbox field. This is a function that is called with information about the field.
|
|
37
|
-
*/
|
|
32
|
+
// @public (undocumented)
|
|
33
|
+
interface CheckboxProps {
|
|
38
34
|
children: (args: {
|
|
39
35
|
fieldProps: CheckboxFieldProps;
|
|
40
36
|
error?: string;
|
|
41
37
|
valid: boolean;
|
|
42
38
|
meta: Meta;
|
|
43
39
|
}) => ReactNode;
|
|
44
|
-
/**
|
|
45
|
-
* Sets the default state of the checkbox as checked.
|
|
46
|
-
*/
|
|
47
40
|
defaultIsChecked?: boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Sets whether the field is required for submission. Required fields are marked with a red asterisk.
|
|
50
|
-
*/
|
|
51
|
-
isRequired?: boolean;
|
|
52
|
-
/**
|
|
53
|
-
* Sets whether the field is disabled. Users cannot edit or focus on the fields. If the parent form component is disabled, then the field will always be disabled.
|
|
54
|
-
*/
|
|
55
41
|
isDisabled?: boolean;
|
|
56
|
-
|
|
57
|
-
* Label displayed beside the checkbox.
|
|
58
|
-
*/
|
|
42
|
+
isRequired?: boolean;
|
|
59
43
|
label?: ReactNode;
|
|
60
|
-
/**
|
|
61
|
-
* Specifies the name of the field. This is important for referencing the form data.
|
|
62
|
-
*/
|
|
63
44
|
name: string;
|
|
64
|
-
/**
|
|
65
|
-
* The value of the checkbox. This is the value used in the form state when the checkbox is checked.
|
|
66
|
-
*/
|
|
67
45
|
value?: string;
|
|
68
46
|
}
|
|
69
47
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
*
|
|
73
|
-
* An error message is used to tell a user that the field input is invalid. For example, an error message could be
|
|
74
|
-
* 'Invalid username, needs to be more than 4 characters'.
|
|
75
|
-
*
|
|
76
|
-
*/
|
|
77
|
-
export declare const ErrorMessage: React_2.FC<MessageProps>;
|
|
48
|
+
// @public
|
|
49
|
+
export const ErrorMessage: React_2.FC<MessageProps>;
|
|
78
50
|
|
|
79
|
-
|
|
51
|
+
// @public (undocumented)
|
|
52
|
+
export function Field<
|
|
80
53
|
FieldValue = string,
|
|
81
|
-
Element extends SupportedElements = HTMLInputElement
|
|
54
|
+
Element extends SupportedElements = HTMLInputElement,
|
|
82
55
|
>(props: FieldComponentProps<FieldValue, Element>): jsx.JSX.Element;
|
|
83
56
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
Element extends SupportedElements
|
|
87
|
-
> {
|
|
88
|
-
/**
|
|
89
|
-
* Content to render in the field. This is a function that is called with props for the field component and other information about the field.
|
|
90
|
-
*/
|
|
57
|
+
// @public (undocumented)
|
|
58
|
+
interface FieldComponentProps<FieldValue, Element extends SupportedElements> {
|
|
91
59
|
children: (args: {
|
|
92
60
|
fieldProps: FieldProps<FieldValue, Element>;
|
|
93
61
|
error?: string;
|
|
94
62
|
valid: boolean;
|
|
95
63
|
meta: Meta;
|
|
96
64
|
}) => ReactNode;
|
|
97
|
-
/**
|
|
98
|
-
* Sets the default value of the field. If a function is provided, it is called with the current default value of the field.
|
|
99
|
-
*/
|
|
100
65
|
defaultValue?:
|
|
101
66
|
| FieldValue
|
|
102
67
|
| ((currentDefaultValue?: FieldValue) => FieldValue);
|
|
103
|
-
/**
|
|
104
|
-
* Passed to the ID attribute of the field. This is randomly generated if it is not specified.
|
|
105
|
-
*/
|
|
106
68
|
id?: string;
|
|
107
|
-
/**
|
|
108
|
-
* Sets whether the field is required for submission. Required fields are marked with a red asterisk.
|
|
109
|
-
*/
|
|
110
|
-
isRequired?: boolean;
|
|
111
|
-
/**
|
|
112
|
-
* Sets whether the field is disabled. Users cannot edit or focus on the fields. If the parent form component is disabled, then the field will always be disabled.
|
|
113
|
-
*/
|
|
114
69
|
isDisabled?: boolean;
|
|
115
|
-
|
|
116
|
-
* Label displayed above the form field.
|
|
117
|
-
*/
|
|
70
|
+
isRequired?: boolean;
|
|
118
71
|
label?: ReactNode;
|
|
119
|
-
/**
|
|
120
|
-
* Specifies the name of the field. This is important for referencing the form data.
|
|
121
|
-
*/
|
|
122
72
|
name: string;
|
|
123
|
-
/**
|
|
124
|
-
* Access the current field value and transform it to return a different field value.
|
|
125
|
-
*/
|
|
126
73
|
transform?: (
|
|
127
74
|
event: FormEvent<Element> | FieldValue,
|
|
128
75
|
current: FieldValue,
|
|
129
76
|
) => FieldValue;
|
|
130
|
-
/**
|
|
131
|
-
* Checks whether the field input is valid. This is usually used to display a message relevant to the current value using `ErrorMessage`, `HelperMessage` or `ValidMessage`.
|
|
132
|
-
*/
|
|
133
77
|
validate?: (
|
|
134
78
|
value: FieldValue | undefined,
|
|
135
79
|
formState: Object,
|
|
@@ -137,291 +81,197 @@ declare interface FieldComponentProps<
|
|
|
137
81
|
) => string | void | Promise<string | void>;
|
|
138
82
|
}
|
|
139
83
|
|
|
140
|
-
|
|
84
|
+
// @public (undocumented)
|
|
85
|
+
export interface FieldProps<
|
|
141
86
|
FieldValue,
|
|
142
|
-
Element extends SupportedElements = HTMLInputElement
|
|
87
|
+
Element extends SupportedElements = HTMLInputElement,
|
|
143
88
|
> {
|
|
89
|
+
// (undocumented)
|
|
90
|
+
'aria-invalid': 'true' | 'false';
|
|
91
|
+
// (undocumented)
|
|
92
|
+
'aria-labelledby': string;
|
|
93
|
+
// (undocumented)
|
|
144
94
|
id: string;
|
|
145
|
-
|
|
95
|
+
// (undocumented)
|
|
146
96
|
isDisabled: boolean;
|
|
97
|
+
// (undocumented)
|
|
147
98
|
isInvalid: boolean;
|
|
148
|
-
|
|
99
|
+
// (undocumented)
|
|
100
|
+
isRequired: boolean;
|
|
101
|
+
// (undocumented)
|
|
102
|
+
name: string;
|
|
103
|
+
// (undocumented)
|
|
149
104
|
onBlur: () => void;
|
|
105
|
+
// (undocumented)
|
|
106
|
+
onChange: (value: FormEvent<Element> | FieldValue) => void;
|
|
107
|
+
// (undocumented)
|
|
150
108
|
onFocus: () => void;
|
|
109
|
+
// (undocumented)
|
|
151
110
|
value: FieldValue;
|
|
152
|
-
name: string;
|
|
153
|
-
'aria-invalid': 'true' | 'false';
|
|
154
|
-
'aria-labelledby': string;
|
|
155
111
|
}
|
|
156
112
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
*
|
|
160
|
-
* A fieldset groups a number of fields together. For example, when multiple CheckboxFields share the same name,
|
|
161
|
-
* a fieldset can be used to group them together. This makes the form more accessible.
|
|
162
|
-
*
|
|
163
|
-
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/form/docs/fields)
|
|
164
|
-
* - [Code](https://atlaskit.atlassian.com/packages/design-system/form/docs/fields)
|
|
165
|
-
* - [Usage](https://atlaskit.atlassian.com/packages/design-system/form/docs/fields)
|
|
166
|
-
*/
|
|
167
|
-
export declare const Fieldset: ({
|
|
168
|
-
children,
|
|
169
|
-
legend,
|
|
170
|
-
}: FieldsetProps) => jsx.JSX.Element;
|
|
113
|
+
// @public
|
|
114
|
+
export const Fieldset: ({ children, legend }: FieldsetProps) => jsx.JSX.Element;
|
|
171
115
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
* Content to render in the fieldset.
|
|
175
|
-
*/
|
|
116
|
+
// @public (undocumented)
|
|
117
|
+
interface FieldsetProps {
|
|
176
118
|
children: ReactNode;
|
|
177
|
-
/**
|
|
178
|
-
* Label describing the contents of the fieldset.
|
|
179
|
-
*/
|
|
180
119
|
legend?: ReactNode;
|
|
181
120
|
}
|
|
182
121
|
|
|
183
|
-
|
|
122
|
+
// @public (undocumented)
|
|
123
|
+
function Form<FormValues extends Record<string, any> = {}>(
|
|
184
124
|
props: FormProps<FormValues>,
|
|
185
125
|
): JSX.Element;
|
|
186
126
|
export default Form;
|
|
187
127
|
|
|
188
|
-
|
|
128
|
+
// @public (undocumented)
|
|
129
|
+
export type FormApi<FormData> = FormApi_2<FormData>;
|
|
189
130
|
|
|
190
|
-
|
|
191
|
-
|
|
131
|
+
// @public (undocumented)
|
|
132
|
+
interface FormChildrenProps {
|
|
133
|
+
// (undocumented)
|
|
134
|
+
onKeyDown: (event: React_2.KeyboardEvent<HTMLElement>) => void;
|
|
135
|
+
// (undocumented)
|
|
192
136
|
onSubmit: (
|
|
193
137
|
event?:
|
|
194
138
|
| React_2.FormEvent<HTMLFormElement>
|
|
195
139
|
| React_2.SyntheticEvent<HTMLElement>,
|
|
196
140
|
) => void;
|
|
197
|
-
|
|
141
|
+
// (undocumented)
|
|
142
|
+
ref: React_2.RefObject<HTMLFormElement>;
|
|
198
143
|
}
|
|
199
144
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
*
|
|
203
|
-
* A form footer has the content to be shown at the bottom of the form. This is usually the submit button.
|
|
204
|
-
*
|
|
205
|
-
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout)
|
|
206
|
-
* - [Code](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout)
|
|
207
|
-
* - [Usage](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout)
|
|
208
|
-
*/
|
|
209
|
-
export declare function FormFooter({
|
|
145
|
+
// @public
|
|
146
|
+
export function FormFooter({
|
|
210
147
|
align,
|
|
211
148
|
children,
|
|
212
149
|
}: FormFooterProps): jsx.JSX.Element;
|
|
213
150
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
* Content to render in the footer of the form.
|
|
217
|
-
*/
|
|
218
|
-
children?: ReactNode;
|
|
219
|
-
/**
|
|
220
|
-
* Sets the alignment of the footer contents. This is often a button. This should be left-aligned in single-page forms, flags, cards, and section messages.
|
|
221
|
-
*/
|
|
151
|
+
// @public (undocumented)
|
|
152
|
+
interface FormFooterProps {
|
|
222
153
|
align?: Align;
|
|
154
|
+
children?: ReactNode;
|
|
223
155
|
}
|
|
224
156
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
*
|
|
231
|
-
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout)
|
|
232
|
-
* - [Code](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout)
|
|
233
|
-
* - [Usage](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout)
|
|
234
|
-
*/
|
|
235
|
-
export declare const FormHeader: React.FC<FormHeaderProps>;
|
|
236
|
-
|
|
237
|
-
declare interface FormHeaderProps {
|
|
238
|
-
/**
|
|
239
|
-
* Title of the form. This is a header.
|
|
240
|
-
*/
|
|
241
|
-
title?: ReactNode;
|
|
242
|
-
/**
|
|
243
|
-
* Description or subtitle of the form.
|
|
244
|
-
*/
|
|
245
|
-
description?: ReactNode;
|
|
246
|
-
/**
|
|
247
|
-
* Child content to render in the form below the title and description.
|
|
248
|
-
*/
|
|
157
|
+
// @public
|
|
158
|
+
export const FormHeader: React.FC<FormHeaderProps>;
|
|
159
|
+
|
|
160
|
+
// @public (undocumented)
|
|
161
|
+
interface FormHeaderProps {
|
|
249
162
|
children?: ReactNode;
|
|
163
|
+
description?: ReactNode;
|
|
164
|
+
title?: ReactNode;
|
|
250
165
|
}
|
|
251
166
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
* 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`.
|
|
255
|
-
* You can read more about these props in [react-final form documentation](https://final-form.org/docs/final-form/types/FormState).
|
|
256
|
-
*/
|
|
167
|
+
// @public (undocumented)
|
|
168
|
+
export interface FormProps<FormValues> {
|
|
257
169
|
children: (args: {
|
|
258
170
|
formProps: FormChildrenProps;
|
|
259
171
|
disabled: boolean;
|
|
260
172
|
dirty: boolean;
|
|
261
173
|
submitting: boolean;
|
|
262
174
|
getState: () => FormState<FormValues>;
|
|
263
|
-
/**
|
|
264
|
-
* @deprecated
|
|
265
|
-
*/
|
|
266
175
|
getValues: () => FormValues;
|
|
267
176
|
setFieldValue: (name: string, value: any) => void;
|
|
268
177
|
reset: (initialValues?: FormValues) => void;
|
|
269
178
|
}) => ReactNode;
|
|
270
|
-
/**
|
|
271
|
-
* Event handler called when the form is submitted. Fields must be free of validation errors.
|
|
272
|
-
*/
|
|
273
|
-
onSubmit: OnSubmitHandler<FormValues>;
|
|
274
|
-
/**
|
|
275
|
-
* Sets the form and its fields as disabled. Users cannot edit or focus on the fields.
|
|
276
|
-
*/
|
|
277
179
|
isDisabled?: boolean;
|
|
180
|
+
onSubmit: OnSubmitHandler<FormValues>;
|
|
278
181
|
}
|
|
279
182
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
*
|
|
286
|
-
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout)
|
|
287
|
-
* - [Code](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout)
|
|
288
|
-
* - [Usage](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout)
|
|
289
|
-
*/
|
|
290
|
-
export declare const FormSection: React_2.FC<FormSectionProps>;
|
|
291
|
-
|
|
292
|
-
declare interface FormSectionProps {
|
|
293
|
-
/**
|
|
294
|
-
* Title of the form section.
|
|
295
|
-
*/
|
|
296
|
-
title?: ReactNode;
|
|
297
|
-
/**
|
|
298
|
-
* Content or components to render after the description.
|
|
299
|
-
*/
|
|
183
|
+
// @public
|
|
184
|
+
export const FormSection: React_2.FC<FormSectionProps>;
|
|
185
|
+
|
|
186
|
+
// @public (undocumented)
|
|
187
|
+
interface FormSectionProps {
|
|
300
188
|
children?: ReactNode;
|
|
301
|
-
/**
|
|
302
|
-
* Description of the contents of the section.
|
|
303
|
-
*/
|
|
304
189
|
description?: ReactNode;
|
|
190
|
+
title?: ReactNode;
|
|
305
191
|
}
|
|
306
192
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
export
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* __Label__
|
|
318
|
-
*
|
|
319
|
-
* A label represents a caption for an item in a user interface.
|
|
320
|
-
*
|
|
321
|
-
* It's recommended that a label has a `4px` spacing above its associated
|
|
322
|
-
* control element.
|
|
323
|
-
*/
|
|
324
|
-
export declare const Label: FC<LabelProps>;
|
|
325
|
-
|
|
326
|
-
export declare interface LabelProps {
|
|
327
|
-
id?: string;
|
|
193
|
+
// @public
|
|
194
|
+
export const HelperMessage: React_2.FC<MessageProps>;
|
|
195
|
+
|
|
196
|
+
// @public
|
|
197
|
+
export const Label: FC<LabelProps>;
|
|
198
|
+
|
|
199
|
+
// @public (undocumented)
|
|
200
|
+
export interface LabelProps {
|
|
201
|
+
// (undocumented)
|
|
328
202
|
htmlFor: string;
|
|
203
|
+
// (undocumented)
|
|
204
|
+
id?: string;
|
|
329
205
|
}
|
|
330
206
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
* The content of the message
|
|
334
|
-
*/
|
|
207
|
+
// @public (undocumented)
|
|
208
|
+
interface MessageProps {
|
|
335
209
|
children: ReactNode;
|
|
336
|
-
/**
|
|
337
|
-
* A testId prop is provided for specified elements, which is a unique string
|
|
338
|
-
* that appears as a data attribute data-testid in the rendered code,
|
|
339
|
-
* serving as a hook for automated tests
|
|
340
|
-
*/
|
|
341
|
-
testId?: string;
|
|
342
|
-
/**
|
|
343
|
-
* Checks whether message input is invalid and should show an error.
|
|
344
|
-
*/
|
|
345
210
|
error?: boolean;
|
|
346
|
-
|
|
347
|
-
* Checks whether message input is valid.
|
|
348
|
-
*/
|
|
349
|
-
valid?: boolean;
|
|
211
|
+
// (undocumented)
|
|
350
212
|
fieldId?: string;
|
|
213
|
+
testId?: string;
|
|
214
|
+
valid?: boolean;
|
|
351
215
|
}
|
|
352
216
|
|
|
353
|
-
|
|
217
|
+
// @public (undocumented)
|
|
218
|
+
interface Meta {
|
|
219
|
+
// (undocumented)
|
|
354
220
|
dirty: boolean;
|
|
221
|
+
// (undocumented)
|
|
355
222
|
dirtySinceLastSubmit: boolean;
|
|
223
|
+
// (undocumented)
|
|
224
|
+
error?: string;
|
|
225
|
+
// (undocumented)
|
|
226
|
+
submitError?: boolean;
|
|
227
|
+
// (undocumented)
|
|
356
228
|
submitFailed: boolean;
|
|
229
|
+
// (undocumented)
|
|
357
230
|
submitting: boolean;
|
|
231
|
+
// (undocumented)
|
|
358
232
|
touched: boolean;
|
|
233
|
+
// (undocumented)
|
|
359
234
|
valid: boolean;
|
|
360
|
-
|
|
361
|
-
submitError?: boolean;
|
|
235
|
+
// (undocumented)
|
|
362
236
|
validating?: boolean;
|
|
363
237
|
}
|
|
364
238
|
|
|
365
|
-
|
|
239
|
+
// @public (undocumented)
|
|
240
|
+
export type OnSubmitHandler<FormData> = (
|
|
366
241
|
values: FormData,
|
|
367
242
|
form: FormApi<FormData>,
|
|
368
243
|
callback?: (errors?: Record<string, string>) => void,
|
|
369
244
|
) => void | Object | Promise<Object | void>;
|
|
370
245
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
* - [Code](https://atlaskit.atlassian.com/packages/design-system/form/docs/fields#rangefield-reference)
|
|
378
|
-
* - [Usage](https://atlaskit.atlassian.com/packages/design-system/form/docs/fields#rangefield-reference)
|
|
379
|
-
*/
|
|
380
|
-
export declare const RangeField: FC<RangeFieldProps>;
|
|
381
|
-
|
|
382
|
-
export declare interface RangeFieldProps {
|
|
246
|
+
// @public
|
|
247
|
+
export const RangeField: FC<RangeFieldProps>;
|
|
248
|
+
|
|
249
|
+
// @public (undocumented)
|
|
250
|
+
export interface RangeFieldProps {
|
|
251
|
+
// (undocumented)
|
|
383
252
|
children: (args: {
|
|
384
253
|
fieldProps: RangeProps;
|
|
385
254
|
error?: string;
|
|
386
255
|
meta: Meta;
|
|
387
256
|
}) => React_2.ReactNode;
|
|
388
|
-
/**
|
|
389
|
-
* Specifies the name of the field. This is important for referencing the form data.
|
|
390
|
-
*/
|
|
391
|
-
name: string;
|
|
392
|
-
/**
|
|
393
|
-
* Sets the default value of the field. If a function is provided, it is called with the current default value of the field.
|
|
394
|
-
*/
|
|
395
257
|
defaultValue: number | ((currentDefaultValue?: number) => number);
|
|
396
|
-
/**
|
|
397
|
-
* Value passed to the `id` attribute of the field. This is randomly generated if it is not specified.
|
|
398
|
-
*/
|
|
399
258
|
id?: string;
|
|
400
|
-
/**
|
|
401
|
-
* Sets whether the field is disabled. Users cannot edit or focus on the fields. If the parent form component is disabled, then the field will always be disabled.
|
|
402
|
-
*/
|
|
403
259
|
isDisabled?: boolean;
|
|
404
|
-
/**
|
|
405
|
-
* Displays a label above the range field and identifies the form fields.
|
|
406
|
-
*/
|
|
407
260
|
label?: ReactNode;
|
|
261
|
+
name: string;
|
|
408
262
|
}
|
|
409
263
|
|
|
410
|
-
|
|
264
|
+
// @public (undocumented)
|
|
265
|
+
type RangeProps = Omit<FieldProps<number>, 'isInvalid' | 'isRequired'>;
|
|
411
266
|
|
|
412
|
-
|
|
267
|
+
// @public (undocumented)
|
|
268
|
+
type SupportedElements =
|
|
413
269
|
| HTMLInputElement
|
|
414
270
|
| HTMLTextAreaElement
|
|
415
271
|
| HTMLSelectElement;
|
|
416
272
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
*
|
|
420
|
-
* A valid message is used to tell a user that the field input is valid. For example,
|
|
421
|
-
* a helper message could be 'Nice one, this username is available'.
|
|
422
|
-
*
|
|
423
|
-
*/
|
|
424
|
-
export declare const ValidMessage: React_2.FC<MessageProps>;
|
|
273
|
+
// @public
|
|
274
|
+
export const ValidMessage: React_2.FC<MessageProps>;
|
|
425
275
|
|
|
426
|
-
|
|
276
|
+
// (No @packageDocumentation comment for this package)
|
|
427
277
|
```
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { FC, ReactNode } from 'react';
|
|
2
|
-
import { FieldProps, Meta } from './field';
|
|
3
|
-
export interface CheckboxFieldProps extends FieldProps<string | undefined> {
|
|
4
|
-
isChecked: boolean;
|
|
5
|
-
}
|
|
6
|
-
export interface CheckboxProps {
|
|
7
|
-
/**
|
|
8
|
-
* Content to render in the checkbox field. This is a function that is called with information about the field.
|
|
9
|
-
*/
|
|
10
|
-
children: (args: {
|
|
11
|
-
fieldProps: CheckboxFieldProps;
|
|
12
|
-
error?: string;
|
|
13
|
-
valid: boolean;
|
|
14
|
-
meta: Meta;
|
|
15
|
-
}) => ReactNode;
|
|
16
|
-
/**
|
|
17
|
-
* Sets the default state of the checkbox as checked.
|
|
18
|
-
*/
|
|
19
|
-
defaultIsChecked?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Sets whether the field is required for submission. Required fields are marked with a red asterisk.
|
|
22
|
-
*/
|
|
23
|
-
isRequired?: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Sets whether the field is disabled. Users cannot edit or focus on the fields. If the parent form component is disabled, then the field will always be disabled.
|
|
26
|
-
*/
|
|
27
|
-
isDisabled?: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Label displayed beside the checkbox.
|
|
30
|
-
*/
|
|
31
|
-
label?: ReactNode;
|
|
32
|
-
/**
|
|
33
|
-
* Specifies the name of the field. This is important for referencing the form data.
|
|
34
|
-
*/
|
|
35
|
-
name: string;
|
|
36
|
-
/**
|
|
37
|
-
* The value of the checkbox. This is the value used in the form state when the checkbox is checked.
|
|
38
|
-
*/
|
|
39
|
-
value?: string;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* __Checkbox field__
|
|
43
|
-
*
|
|
44
|
-
* A checkbox field is a form field that lets users select an item. Users can check or uncheck the checkbox.
|
|
45
|
-
*
|
|
46
|
-
* - [Examples] https://atlaskit.atlassian.com/packages/design-system/form/docs/fields#checkboxfield-reference
|
|
47
|
-
* - [Code] https://atlaskit.atlassian.com/packages/design-system/form/docs/fields#checkboxfield-reference
|
|
48
|
-
* - [Usage] https://atlaskit.atlassian.com/packages/design-system/form/docs/fields#checkboxfield-reference
|
|
49
|
-
*/
|
|
50
|
-
declare const CheckboxField: FC<CheckboxProps>;
|
|
51
|
-
export default CheckboxField;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Fieldset } from '../fieldset';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as FormFooter } from '../form-footer';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as FormHeader } from '../form-header';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as FormSection } from '../form-section';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from '../form';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { HelperMessage, ErrorMessage, ValidMessage } from '../messages';
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import { FormEvent, ReactNode } from 'react';
|
|
3
|
-
import { jsx } from '@emotion/react';
|
|
4
|
-
declare type SupportedElements = HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement;
|
|
5
|
-
export interface FieldProps<FieldValue, Element extends SupportedElements = HTMLInputElement> {
|
|
6
|
-
id: string;
|
|
7
|
-
isRequired: boolean;
|
|
8
|
-
isDisabled: boolean;
|
|
9
|
-
isInvalid: boolean;
|
|
10
|
-
onChange: (value: FormEvent<Element> | FieldValue) => void;
|
|
11
|
-
onBlur: () => void;
|
|
12
|
-
onFocus: () => void;
|
|
13
|
-
value: FieldValue;
|
|
14
|
-
name: string;
|
|
15
|
-
'aria-invalid': 'true' | 'false';
|
|
16
|
-
'aria-labelledby': string;
|
|
17
|
-
}
|
|
18
|
-
export interface Meta {
|
|
19
|
-
dirty: boolean;
|
|
20
|
-
dirtySinceLastSubmit: boolean;
|
|
21
|
-
submitFailed: boolean;
|
|
22
|
-
submitting: boolean;
|
|
23
|
-
touched: boolean;
|
|
24
|
-
valid: boolean;
|
|
25
|
-
error?: string;
|
|
26
|
-
submitError?: boolean;
|
|
27
|
-
validating?: boolean;
|
|
28
|
-
}
|
|
29
|
-
export interface FieldComponentProps<FieldValue, Element extends SupportedElements> {
|
|
30
|
-
/**
|
|
31
|
-
* Content to render in the field. This is a function that is called with props for the field component and other information about the field.
|
|
32
|
-
*/
|
|
33
|
-
children: (args: {
|
|
34
|
-
fieldProps: FieldProps<FieldValue, Element>;
|
|
35
|
-
error?: string;
|
|
36
|
-
valid: boolean;
|
|
37
|
-
meta: Meta;
|
|
38
|
-
}) => ReactNode;
|
|
39
|
-
/**
|
|
40
|
-
* Sets the default value of the field. If a function is provided, it is called with the current default value of the field.
|
|
41
|
-
*/
|
|
42
|
-
defaultValue?: FieldValue | ((currentDefaultValue?: FieldValue) => FieldValue);
|
|
43
|
-
/**
|
|
44
|
-
* Passed to the ID attribute of the field. This is randomly generated if it is not specified.
|
|
45
|
-
*/
|
|
46
|
-
id?: string;
|
|
47
|
-
/**
|
|
48
|
-
* Sets whether the field is required for submission. Required fields are marked with a red asterisk.
|
|
49
|
-
*/
|
|
50
|
-
isRequired?: boolean;
|
|
51
|
-
/**
|
|
52
|
-
* Sets whether the field is disabled. Users cannot edit or focus on the fields. If the parent form component is disabled, then the field will always be disabled.
|
|
53
|
-
*/
|
|
54
|
-
isDisabled?: boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Label displayed above the form field.
|
|
57
|
-
*/
|
|
58
|
-
label?: ReactNode;
|
|
59
|
-
/**
|
|
60
|
-
* Specifies the name of the field. This is important for referencing the form data.
|
|
61
|
-
*/
|
|
62
|
-
name: string;
|
|
63
|
-
/**
|
|
64
|
-
* Access the current field value and transform it to return a different field value.
|
|
65
|
-
*/
|
|
66
|
-
transform?: (event: FormEvent<Element> | FieldValue, current: FieldValue) => FieldValue;
|
|
67
|
-
/**
|
|
68
|
-
* Checks whether the field input is valid. This is usually used to display a message relevant to the current value using `ErrorMessage`, `HelperMessage` or `ValidMessage`.
|
|
69
|
-
*/
|
|
70
|
-
validate?: (value: FieldValue | undefined, formState: Object, fieldState: Meta) => string | void | Promise<string | void>;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* __Field id__
|
|
74
|
-
*
|
|
75
|
-
* A field id uses the context API. It provides the id of the field to message components. This links the message with the field of screenreaders.
|
|
76
|
-
*/
|
|
77
|
-
export declare const FieldId: import("react").Context<string | undefined>;
|
|
78
|
-
export default function Field<FieldValue = string, Element extends SupportedElements = HTMLInputElement>(props: FieldComponentProps<FieldValue, Element>): jsx.JSX.Element;
|
|
79
|
-
export {};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
import { jsx } from '@emotion/react';
|
|
4
|
-
export interface FieldsetProps {
|
|
5
|
-
/**
|
|
6
|
-
* Content to render in the fieldset.
|
|
7
|
-
*/
|
|
8
|
-
children: ReactNode;
|
|
9
|
-
/**
|
|
10
|
-
* Label describing the contents of the fieldset.
|
|
11
|
-
*/
|
|
12
|
-
legend?: ReactNode;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* __Fieldset__
|
|
16
|
-
*
|
|
17
|
-
* A fieldset groups a number of fields together. For example, when multiple CheckboxFields share the same name,
|
|
18
|
-
* a fieldset can be used to group them together. This makes the form more accessible.
|
|
19
|
-
*
|
|
20
|
-
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/form/docs/fields)
|
|
21
|
-
* - [Code](https://atlaskit.atlassian.com/packages/design-system/form/docs/fields)
|
|
22
|
-
* - [Usage](https://atlaskit.atlassian.com/packages/design-system/form/docs/fields)
|
|
23
|
-
*/
|
|
24
|
-
declare const Fieldset: ({ children, legend }: FieldsetProps) => jsx.JSX.Element;
|
|
25
|
-
export default Fieldset;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
import { jsx } from '@emotion/react';
|
|
4
|
-
import { Align } from './types';
|
|
5
|
-
export interface FormFooterProps {
|
|
6
|
-
/**
|
|
7
|
-
* Content to render in the footer of the form.
|
|
8
|
-
*/
|
|
9
|
-
children?: ReactNode;
|
|
10
|
-
/**
|
|
11
|
-
* Sets the alignment of the footer contents. This is often a button. This should be left-aligned in single-page forms, flags, cards, and section messages.
|
|
12
|
-
*/
|
|
13
|
-
align?: Align;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* __Form footer__
|
|
17
|
-
*
|
|
18
|
-
* A form footer has the content to be shown at the bottom of the form. This is usually the submit button.
|
|
19
|
-
*
|
|
20
|
-
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout)
|
|
21
|
-
* - [Code](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout)
|
|
22
|
-
* - [Usage](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout)
|
|
23
|
-
*/
|
|
24
|
-
export default function FormFooter({ align, children, }: FormFooterProps): jsx.JSX.Element;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
export interface FormHeaderProps {
|
|
4
|
-
/**
|
|
5
|
-
* Title of the form. This is a header.
|
|
6
|
-
*/
|
|
7
|
-
title?: ReactNode;
|
|
8
|
-
/**
|
|
9
|
-
* Description or subtitle of the form.
|
|
10
|
-
*/
|
|
11
|
-
description?: ReactNode;
|
|
12
|
-
/**
|
|
13
|
-
* Child content to render in the form below the title and description.
|
|
14
|
-
*/
|
|
15
|
-
children?: ReactNode;
|
|
16
|
-
}
|
|
17
|
-
declare const FormHeaderContent: React.FC;
|
|
18
|
-
declare const FormHeaderDescription: React.FC;
|
|
19
|
-
declare const FormHeaderTitle: React.FC;
|
|
20
|
-
/**
|
|
21
|
-
* __Form header__
|
|
22
|
-
*
|
|
23
|
-
* A form header contains the form component's heading and subheadings. This provides the correct padding
|
|
24
|
-
* and styling for it.
|
|
25
|
-
*
|
|
26
|
-
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout)
|
|
27
|
-
* - [Code](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout)
|
|
28
|
-
* - [Usage](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout)
|
|
29
|
-
*/
|
|
30
|
-
declare const FormHeader: React.FC<FormHeaderProps>;
|
|
31
|
-
export default FormHeader;
|
|
32
|
-
export { FormHeaderContent, FormHeaderDescription, FormHeaderTitle };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import React, { ReactNode } from 'react';
|
|
3
|
-
export interface FormSectionProps {
|
|
4
|
-
/**
|
|
5
|
-
* Title of the form section.
|
|
6
|
-
*/
|
|
7
|
-
title?: ReactNode;
|
|
8
|
-
/**
|
|
9
|
-
* Content or components to render after the description.
|
|
10
|
-
*/
|
|
11
|
-
children?: ReactNode;
|
|
12
|
-
/**
|
|
13
|
-
* Description of the contents of the section.
|
|
14
|
-
*/
|
|
15
|
-
description?: ReactNode;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* __Form section__
|
|
19
|
-
*
|
|
20
|
-
* A form section is used to define a section of a form layout. This contains a section title, content
|
|
21
|
-
* and a description of the section.
|
|
22
|
-
*
|
|
23
|
-
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout)
|
|
24
|
-
* - [Code](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout)
|
|
25
|
-
* - [Usage](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout)
|
|
26
|
-
*/
|
|
27
|
-
declare const FormSection: React.FC<FormSectionProps>;
|
|
28
|
-
export default FormSection;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from 'react';
|
|
2
|
-
import { FieldConfig, FieldSubscriber, FieldSubscription, FormState, Unsubscribe } from 'final-form';
|
|
3
|
-
import { OnSubmitHandler } from './types';
|
|
4
|
-
declare type DefaultValue<FieldValue> = (value?: FieldValue) => FieldValue;
|
|
5
|
-
declare type RegisterField = <FieldValue>(name: string, defaultValue: FieldValue | DefaultValue<FieldValue>, subscriber: FieldSubscriber<FieldValue>, subscription: FieldSubscription, config: FieldConfig<FieldValue>) => Unsubscribe;
|
|
6
|
-
/**
|
|
7
|
-
* __Form context__
|
|
8
|
-
*
|
|
9
|
-
* A form context creates a context for the field values and allows them to be accessed by the children.
|
|
10
|
-
*/
|
|
11
|
-
export declare const FormContext: React.Context<RegisterField>;
|
|
12
|
-
/**
|
|
13
|
-
* __Is disabled context__
|
|
14
|
-
*
|
|
15
|
-
* An is disabled context creates the context for when a value is disabled.
|
|
16
|
-
*/
|
|
17
|
-
export declare const IsDisabledContext: React.Context<boolean>;
|
|
18
|
-
interface FormChildrenProps {
|
|
19
|
-
ref: React.RefObject<HTMLFormElement>;
|
|
20
|
-
onSubmit: (event?: React.FormEvent<HTMLFormElement> | React.SyntheticEvent<HTMLElement>) => void;
|
|
21
|
-
onKeyDown: (event: React.KeyboardEvent<HTMLElement>) => void;
|
|
22
|
-
}
|
|
23
|
-
export interface FormProps<FormValues> {
|
|
24
|
-
/**
|
|
25
|
-
* 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`.
|
|
26
|
-
* You can read more about these props in [react-final form documentation](https://final-form.org/docs/final-form/types/FormState).
|
|
27
|
-
*/
|
|
28
|
-
children: (args: {
|
|
29
|
-
formProps: FormChildrenProps;
|
|
30
|
-
disabled: boolean;
|
|
31
|
-
dirty: boolean;
|
|
32
|
-
submitting: boolean;
|
|
33
|
-
getState: () => FormState<FormValues>;
|
|
34
|
-
/**
|
|
35
|
-
* @deprecated
|
|
36
|
-
*/
|
|
37
|
-
getValues: () => FormValues;
|
|
38
|
-
setFieldValue: (name: string, value: any) => void;
|
|
39
|
-
reset: (initialValues?: FormValues) => void;
|
|
40
|
-
}) => ReactNode;
|
|
41
|
-
/**
|
|
42
|
-
* Event handler called when the form is submitted. Fields must be free of validation errors.
|
|
43
|
-
*/
|
|
44
|
-
onSubmit: OnSubmitHandler<FormValues>;
|
|
45
|
-
/**
|
|
46
|
-
* Sets the form and its fields as disabled. Users cannot edit or focus on the fields.
|
|
47
|
-
*/
|
|
48
|
-
isDisabled?: boolean;
|
|
49
|
-
}
|
|
50
|
-
export default function Form<FormValues extends Record<string, any> = {}>(props: FormProps<FormValues>): JSX.Element;
|
|
51
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export { default } from './form';
|
|
2
|
-
export type { FormProps } from './form';
|
|
3
|
-
export { default as FormHeader } from './form-header';
|
|
4
|
-
export { default as FormFooter } from './form-footer';
|
|
5
|
-
export { default as FormSection } from './form-section';
|
|
6
|
-
export { default as Field } from './field';
|
|
7
|
-
export type { FieldProps } from './field';
|
|
8
|
-
export { default as CheckboxField } from './checkbox-field';
|
|
9
|
-
export type { CheckboxFieldProps } from './checkbox-field';
|
|
10
|
-
export { default as RangeField } from './range-field';
|
|
11
|
-
export type { RangeFieldProps } from './range-field';
|
|
12
|
-
export { default as Label } from './label';
|
|
13
|
-
export type { LabelProps } from './label';
|
|
14
|
-
export { HelperMessage, ErrorMessage, ValidMessage } from './messages';
|
|
15
|
-
export { default as Fieldset } from './fieldset';
|
|
16
|
-
export type { OnSubmitHandler, FormApi } from './types';
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import { FC } from 'react';
|
|
3
|
-
export interface LabelProps {
|
|
4
|
-
id?: string;
|
|
5
|
-
htmlFor: string;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* __Label__
|
|
9
|
-
*
|
|
10
|
-
* A label represents a caption for an item in a user interface.
|
|
11
|
-
*
|
|
12
|
-
* It's recommended that a label has a `4px` spacing above its associated
|
|
13
|
-
* control element.
|
|
14
|
-
*/
|
|
15
|
-
declare const Label: FC<LabelProps>;
|
|
16
|
-
export default Label;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import React, { ReactNode } from 'react';
|
|
3
|
-
interface MessageProps {
|
|
4
|
-
/**
|
|
5
|
-
* The content of the message
|
|
6
|
-
*/
|
|
7
|
-
children: ReactNode;
|
|
8
|
-
/**
|
|
9
|
-
* A testId prop is provided for specified elements, which is a unique string
|
|
10
|
-
* that appears as a data attribute data-testid in the rendered code,
|
|
11
|
-
* serving as a hook for automated tests
|
|
12
|
-
*/
|
|
13
|
-
testId?: string;
|
|
14
|
-
/**
|
|
15
|
-
* Checks whether message input is invalid and should show an error.
|
|
16
|
-
*/
|
|
17
|
-
error?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Checks whether message input is valid.
|
|
20
|
-
*/
|
|
21
|
-
valid?: boolean;
|
|
22
|
-
fieldId?: string;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* __Helper message__
|
|
26
|
-
*
|
|
27
|
-
* A helper message tells the user what kind of input the field takes. For example, a helper message could be
|
|
28
|
-
* 'Password should be more than 4 characters'
|
|
29
|
-
*
|
|
30
|
-
*/
|
|
31
|
-
export declare const HelperMessage: React.FC<MessageProps>;
|
|
32
|
-
/**
|
|
33
|
-
* __Error message__
|
|
34
|
-
*
|
|
35
|
-
* An error message is used to tell a user that the field input is invalid. For example, an error message could be
|
|
36
|
-
* 'Invalid username, needs to be more than 4 characters'.
|
|
37
|
-
*
|
|
38
|
-
*/
|
|
39
|
-
export declare const ErrorMessage: React.FC<MessageProps>;
|
|
40
|
-
/**
|
|
41
|
-
* __Valid message__
|
|
42
|
-
*
|
|
43
|
-
* A valid message is used to tell a user that the field input is valid. For example,
|
|
44
|
-
* a helper message could be 'Nice one, this username is available'.
|
|
45
|
-
*
|
|
46
|
-
*/
|
|
47
|
-
export declare const ValidMessage: React.FC<MessageProps>;
|
|
48
|
-
export {};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import React, { FC, ReactNode } from 'react';
|
|
2
|
-
import { FieldProps, Meta } from './field';
|
|
3
|
-
declare type RangeProps = Omit<FieldProps<number>, 'isInvalid' | 'isRequired'>;
|
|
4
|
-
export interface RangeFieldProps {
|
|
5
|
-
children: (args: {
|
|
6
|
-
fieldProps: RangeProps;
|
|
7
|
-
error?: string;
|
|
8
|
-
meta: Meta;
|
|
9
|
-
}) => React.ReactNode;
|
|
10
|
-
/**
|
|
11
|
-
* Specifies the name of the field. This is important for referencing the form data.
|
|
12
|
-
*/
|
|
13
|
-
name: string;
|
|
14
|
-
/**
|
|
15
|
-
* Sets the default value of the field. If a function is provided, it is called with the current default value of the field.
|
|
16
|
-
*/
|
|
17
|
-
defaultValue: number | ((currentDefaultValue?: number) => number);
|
|
18
|
-
/**
|
|
19
|
-
* Value passed to the `id` attribute of the field. This is randomly generated if it is not specified.
|
|
20
|
-
*/
|
|
21
|
-
id?: string;
|
|
22
|
-
/**
|
|
23
|
-
* Sets whether the field is disabled. Users cannot edit or focus on the fields. If the parent form component is disabled, then the field will always be disabled.
|
|
24
|
-
*/
|
|
25
|
-
isDisabled?: boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Displays a label above the range field and identifies the form fields.
|
|
28
|
-
*/
|
|
29
|
-
label?: ReactNode;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* __Range field__
|
|
33
|
-
*
|
|
34
|
-
* A range field is where a user can submit a range input as a part of a form.
|
|
35
|
-
*
|
|
36
|
-
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/form/docs/fields#rangefield-reference)
|
|
37
|
-
* - [Code](https://atlaskit.atlassian.com/packages/design-system/form/docs/fields#rangefield-reference)
|
|
38
|
-
* - [Usage](https://atlaskit.atlassian.com/packages/design-system/form/docs/fields#rangefield-reference)
|
|
39
|
-
*/
|
|
40
|
-
declare const RangeField: FC<RangeFieldProps>;
|
|
41
|
-
export default RangeField;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { FormApi as FinalFormAPI } from 'final-form';
|
|
2
|
-
export declare type Align = 'start' | 'end';
|
|
3
|
-
export declare type FormApi<FormData> = FinalFormAPI<FormData>;
|
|
4
|
-
export declare type OnSubmitHandler<FormData> = (values: FormData, form: FormApi<FormData>, callback?: (errors?: Record<string, string>) => void) => void | Object | Promise<Object | void>;
|