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