@atlaskit/form 8.11.1 → 8.11.3
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 +12 -0
- package/dist/cjs/messages.js +2 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/messages.js +2 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/messages.js +2 -1
- package/dist/esm/version.json +1 -1
- package/dist/types-ts4.5/checkbox-field.d.ts +51 -0
- package/dist/types-ts4.5/entry-points/checkbox-field.d.ts +2 -0
- package/dist/types-ts4.5/entry-points/field.d.ts +2 -0
- package/dist/types-ts4.5/entry-points/fieldset.d.ts +1 -0
- package/dist/types-ts4.5/entry-points/form-footer.d.ts +1 -0
- package/dist/types-ts4.5/entry-points/form-header.d.ts +1 -0
- package/dist/types-ts4.5/entry-points/form-section.d.ts +1 -0
- package/dist/types-ts4.5/entry-points/form.d.ts +1 -0
- package/dist/types-ts4.5/entry-points/label.d.ts +2 -0
- package/dist/types-ts4.5/entry-points/messages.d.ts +1 -0
- package/dist/types-ts4.5/entry-points/range-field.d.ts +2 -0
- package/dist/types-ts4.5/field.d.ts +87 -0
- package/dist/types-ts4.5/fieldset.d.ts +25 -0
- package/dist/types-ts4.5/form-footer.d.ts +24 -0
- package/dist/types-ts4.5/form-header.d.ts +38 -0
- package/dist/types-ts4.5/form-section.d.ts +28 -0
- package/dist/types-ts4.5/form.d.ts +55 -0
- package/dist/types-ts4.5/index.d.ts +17 -0
- package/dist/types-ts4.5/label.d.ts +18 -0
- package/dist/types-ts4.5/messages.d.ts +52 -0
- package/dist/types-ts4.5/range-field.d.ts +41 -0
- package/dist/types-ts4.5/required-asterisk.d.ts +3 -0
- package/dist/types-ts4.5/types.d.ts +4 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/form
|
|
2
2
|
|
|
3
|
+
## 8.11.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`e8dbb0a281b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/e8dbb0a281b) - add a11y support for alert messages
|
|
8
|
+
|
|
9
|
+
## 8.11.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`9d00501a414`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9d00501a414) - Ensure legacy types are published for TS 4.5-4.8
|
|
14
|
+
|
|
3
15
|
## 8.11.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/cjs/messages.js
CHANGED
|
@@ -98,7 +98,8 @@ var Message = function Message(_ref2) {
|
|
|
98
98
|
return (0, _react2.jsx)("div", {
|
|
99
99
|
css: [mode === 'light' ? lightH200Styles : darkH200Styles, messageStyles, messageAppearanceStyles[appearance]],
|
|
100
100
|
"data-testid": testId,
|
|
101
|
-
id: fieldId
|
|
101
|
+
id: fieldId,
|
|
102
|
+
role: "alert"
|
|
102
103
|
}, icon && (0, _react2.jsx)(IconWrapper, null, icon), content);
|
|
103
104
|
};
|
|
104
105
|
|
package/dist/cjs/version.json
CHANGED
package/dist/es2019/messages.js
CHANGED
|
@@ -94,7 +94,8 @@ const Message = ({
|
|
|
94
94
|
return jsx("div", {
|
|
95
95
|
css: [mode === 'light' ? lightH200Styles : darkH200Styles, messageStyles, messageAppearanceStyles[appearance]],
|
|
96
96
|
"data-testid": testId,
|
|
97
|
-
id: fieldId
|
|
97
|
+
id: fieldId,
|
|
98
|
+
role: "alert"
|
|
98
99
|
}, icon && jsx(IconWrapper, null, icon), content);
|
|
99
100
|
};
|
|
100
101
|
|
package/dist/es2019/version.json
CHANGED
package/dist/esm/messages.js
CHANGED
|
@@ -92,7 +92,8 @@ var Message = function Message(_ref2) {
|
|
|
92
92
|
return jsx("div", {
|
|
93
93
|
css: [mode === 'light' ? lightH200Styles : darkH200Styles, messageStyles, messageAppearanceStyles[appearance]],
|
|
94
94
|
"data-testid": testId,
|
|
95
|
-
id: fieldId
|
|
95
|
+
id: fieldId,
|
|
96
|
+
role: "alert"
|
|
96
97
|
}, icon && jsx(IconWrapper, null, icon), content);
|
|
97
98
|
};
|
|
98
99
|
|
package/dist/esm/version.json
CHANGED
|
@@ -0,0 +1,51 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Fieldset } from '../fieldset';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as FormFooter } from '../form-footer';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as FormHeader } from '../form-header';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as FormSection } from '../form-section';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '../form';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { HelperMessage, ErrorMessage, ValidMessage } from '../messages';
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { FormEvent, ReactNode } from 'react';
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
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
|
+
* Element displayed after the label, and after the red asterisk if field is required.
|
|
61
|
+
*/
|
|
62
|
+
elementAfterLabel?: ReactNode;
|
|
63
|
+
/**
|
|
64
|
+
* Specifies the name of the field. This is important for referencing the form data.
|
|
65
|
+
*/
|
|
66
|
+
name: string;
|
|
67
|
+
/**
|
|
68
|
+
* Access the current field value and transform it to return a different field value.
|
|
69
|
+
*/
|
|
70
|
+
transform?: (event: FormEvent<Element> | FieldValue, current: FieldValue) => FieldValue;
|
|
71
|
+
/**
|
|
72
|
+
* 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`.
|
|
73
|
+
*/
|
|
74
|
+
validate?: (value: FieldValue | undefined, formState: Object, fieldState: Meta) => string | void | Promise<string | void>;
|
|
75
|
+
/**
|
|
76
|
+
* A `testId` prop is provided for specified elements, which is a unique string that appears as a data attribute `data-testid` in the rendered code, serving as a hook for automated tests
|
|
77
|
+
*/
|
|
78
|
+
testId?: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* __Field id__
|
|
82
|
+
*
|
|
83
|
+
* 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.
|
|
84
|
+
*/
|
|
85
|
+
export declare const FieldId: import("react").Context<string | undefined>;
|
|
86
|
+
export default function Field<FieldValue = string, Element extends SupportedElements = HTMLInputElement>(props: FieldComponentProps<FieldValue, Element>): jsx.JSX.Element;
|
|
87
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
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;
|
|
@@ -0,0 +1,24 @@
|
|
|
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;
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
children: ReactNode;
|
|
19
|
+
}>;
|
|
20
|
+
declare const FormHeaderDescription: React.FC<{
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
}>;
|
|
23
|
+
declare const FormHeaderTitle: React.FC<{
|
|
24
|
+
children: ReactNode;
|
|
25
|
+
}>;
|
|
26
|
+
/**
|
|
27
|
+
* __Form header__
|
|
28
|
+
*
|
|
29
|
+
* A form header contains the form component's heading and subheadings. This provides the correct padding
|
|
30
|
+
* and styling for it.
|
|
31
|
+
*
|
|
32
|
+
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout)
|
|
33
|
+
* - [Code](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout)
|
|
34
|
+
* - [Usage](https://atlaskit.atlassian.com/packages/design-system/form/docs/layout)
|
|
35
|
+
*/
|
|
36
|
+
declare const FormHeader: React.FC<FormHeaderProps>;
|
|
37
|
+
export default FormHeader;
|
|
38
|
+
export { FormHeaderContent, FormHeaderDescription, FormHeaderTitle };
|
|
@@ -0,0 +1,28 @@
|
|
|
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;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { FieldConfig, FieldSubscriber, FieldSubscription, FormState, Unsubscribe } from 'final-form';
|
|
3
|
+
import { OnSubmitHandler } from './types';
|
|
4
|
+
type DefaultValue<FieldValue> = (value?: FieldValue) => FieldValue;
|
|
5
|
+
type RegisterField = <FieldValue>(name: string, defaultValue: FieldValue | DefaultValue<FieldValue>, subscriber: FieldSubscriber<FieldValue>, subscription: FieldSubscription, config: FieldConfig<FieldValue>) => Unsubscribe;
|
|
6
|
+
type GetCurrentValue = <FormValues>(name: string) => FormValues[keyof FormValues] | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* __Form context__
|
|
9
|
+
*
|
|
10
|
+
* A form context creates a context for the field values and allows them to be accessed by the children.
|
|
11
|
+
*/
|
|
12
|
+
export declare const FormContext: React.Context<{
|
|
13
|
+
registerField: RegisterField;
|
|
14
|
+
getCurrentValue: GetCurrentValue;
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* __Is disabled context__
|
|
18
|
+
*
|
|
19
|
+
* An is disabled context creates the context for when a value is disabled.
|
|
20
|
+
*/
|
|
21
|
+
export declare const IsDisabledContext: React.Context<boolean>;
|
|
22
|
+
interface FormChildrenProps {
|
|
23
|
+
ref: React.RefObject<HTMLFormElement>;
|
|
24
|
+
onSubmit: (event?: React.FormEvent<HTMLFormElement> | React.SyntheticEvent<HTMLElement>) => void;
|
|
25
|
+
onKeyDown: (event: React.KeyboardEvent<HTMLElement>) => void;
|
|
26
|
+
}
|
|
27
|
+
export interface FormProps<FormValues> {
|
|
28
|
+
/**
|
|
29
|
+
* 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`.
|
|
30
|
+
* You can read more about these props in [react-final form documentation](https://final-form.org/docs/final-form/types/FormState).
|
|
31
|
+
*/
|
|
32
|
+
children: (args: {
|
|
33
|
+
formProps: FormChildrenProps;
|
|
34
|
+
disabled: boolean;
|
|
35
|
+
dirty: boolean;
|
|
36
|
+
submitting: boolean;
|
|
37
|
+
getState: () => FormState<FormValues>;
|
|
38
|
+
/**
|
|
39
|
+
* @deprecated
|
|
40
|
+
*/
|
|
41
|
+
getValues: () => FormValues;
|
|
42
|
+
setFieldValue: (name: string, value: any) => void;
|
|
43
|
+
reset: (initialValues?: FormValues) => void;
|
|
44
|
+
}) => ReactNode;
|
|
45
|
+
/**
|
|
46
|
+
* Event handler called when the form is submitted. Fields must be free of validation errors.
|
|
47
|
+
*/
|
|
48
|
+
onSubmit: OnSubmitHandler<FormValues>;
|
|
49
|
+
/**
|
|
50
|
+
* Sets the form and its fields as disabled. Users cannot edit or focus on the fields.
|
|
51
|
+
*/
|
|
52
|
+
isDisabled?: boolean;
|
|
53
|
+
}
|
|
54
|
+
export default function Form<FormValues extends Record<string, any> = {}>(props: FormProps<FormValues>): JSX.Element;
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
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 { default as RequiredAsterisk } from './required-asterisk';
|
|
17
|
+
export type { OnSubmitHandler, FormApi } from './types';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { FC, ReactNode } from 'react';
|
|
3
|
+
export interface LabelProps {
|
|
4
|
+
id?: string;
|
|
5
|
+
htmlFor: string;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
testId?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* __Label__
|
|
11
|
+
*
|
|
12
|
+
* A label represents a caption for an item in a user interface.
|
|
13
|
+
*
|
|
14
|
+
* It's recommended that a label has a `4px` spacing above its associated
|
|
15
|
+
* control element.
|
|
16
|
+
*/
|
|
17
|
+
declare const Label: FC<LabelProps>;
|
|
18
|
+
export default Label;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import React, { ReactNode } from 'react';
|
|
3
|
+
type MessageAppearance = 'default' | 'error' | 'valid';
|
|
4
|
+
/**
|
|
5
|
+
* API for the internal `<Message />` component. This is not public API.
|
|
6
|
+
*/
|
|
7
|
+
interface InternalMessageProps {
|
|
8
|
+
/**
|
|
9
|
+
* The content of the message
|
|
10
|
+
*/
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* A testId prop is provided for specified elements, which is a unique string
|
|
14
|
+
* that appears as a data attribute data-testid in the rendered code,
|
|
15
|
+
* serving as a hook for automated tests
|
|
16
|
+
*/
|
|
17
|
+
testId?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Determines the appearance of the message.
|
|
20
|
+
*/
|
|
21
|
+
appearance?: MessageAppearance;
|
|
22
|
+
fieldId?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Public API of the various message components.
|
|
26
|
+
*/
|
|
27
|
+
type MessageProps = Pick<InternalMessageProps, 'children' | 'testId'>;
|
|
28
|
+
/**
|
|
29
|
+
* __Helper message__
|
|
30
|
+
*
|
|
31
|
+
* A helper message tells the user what kind of input the field takes. For example, a helper message could be
|
|
32
|
+
* 'Password should be more than 4 characters'
|
|
33
|
+
*
|
|
34
|
+
*/
|
|
35
|
+
export declare const HelperMessage: React.FC<MessageProps>;
|
|
36
|
+
/**
|
|
37
|
+
* __Error message__
|
|
38
|
+
*
|
|
39
|
+
* An error message is used to tell a user that the field input is invalid. For example, an error message could be
|
|
40
|
+
* 'Invalid username, needs to be more than 4 characters'.
|
|
41
|
+
*
|
|
42
|
+
*/
|
|
43
|
+
export declare const ErrorMessage: React.FC<MessageProps>;
|
|
44
|
+
/**
|
|
45
|
+
* __Valid message__
|
|
46
|
+
*
|
|
47
|
+
* A valid message is used to tell a user that the field input is valid. For example,
|
|
48
|
+
* a helper message could be 'Nice one, this username is available'.
|
|
49
|
+
*
|
|
50
|
+
*/
|
|
51
|
+
export declare const ValidMessage: React.FC<MessageProps>;
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React, { FC, ReactNode } from 'react';
|
|
2
|
+
import { FieldProps, Meta } from './field';
|
|
3
|
+
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;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { FormApi as FinalFormAPI } from 'final-form';
|
|
2
|
+
export type Align = 'start' | 'end';
|
|
3
|
+
export type FormApi<FormData> = FinalFormAPI<FormData>;
|
|
4
|
+
export type OnSubmitHandler<FormData> = (values: FormData, form: FormApi<FormData>, callback?: (errors?: Record<string, string>) => void) => void | Object | Promise<Object | void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/form",
|
|
3
|
-
"version": "8.11.
|
|
3
|
+
"version": "8.11.3",
|
|
4
4
|
"description": "A form allows users to input information.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@atlaskit/checkbox": "^12.6.0",
|
|
67
67
|
"@atlaskit/datetime-picker": "^12.5.0",
|
|
68
68
|
"@atlaskit/docs": "^9.1.0",
|
|
69
|
-
"@atlaskit/dropdown-menu": "^11.
|
|
69
|
+
"@atlaskit/dropdown-menu": "^11.9.0",
|
|
70
70
|
"@atlaskit/ds-lib": "^2.2.0",
|
|
71
71
|
"@atlaskit/lozenge": "^11.4.0",
|
|
72
72
|
"@atlaskit/modal-dialog": "^12.5.0",
|