@atlaskit/link-create 0.1.2 → 0.2.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 +10 -0
- package/dist/cjs/common/types.js +5 -0
- package/dist/cjs/controllers/form-context/index.js +18 -0
- package/dist/cjs/controllers/form-context/main.js +52 -0
- package/dist/cjs/index.js +29 -4
- package/dist/cjs/ui/create-form/async-select/index.js +12 -0
- package/dist/cjs/ui/create-form/async-select/main.js +49 -0
- package/dist/cjs/ui/create-form/async-select/types.js +5 -0
- package/dist/cjs/ui/create-form/index.js +26 -0
- package/dist/cjs/ui/create-form/main.js +83 -0
- package/dist/cjs/ui/create-form/textfield/index.js +12 -0
- package/dist/cjs/ui/create-form/textfield/main.js +49 -0
- package/dist/cjs/ui/create-form/textfield/types.js +5 -0
- package/dist/cjs/ui/create-form/types.js +5 -0
- package/dist/cjs/ui/create-form/utils/index.js +34 -0
- package/dist/cjs/ui/index.js +14 -7
- package/dist/cjs/ui/main.js +4 -54
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/common/types.js +1 -0
- package/dist/es2019/controllers/form-context/index.js +1 -0
- package/dist/es2019/controllers/form-context/main.js +31 -0
- package/dist/es2019/index.js +3 -2
- package/dist/es2019/ui/create-form/async-select/index.js +1 -0
- package/dist/es2019/ui/create-form/async-select/main.js +41 -0
- package/dist/es2019/ui/create-form/async-select/types.js +1 -0
- package/dist/es2019/ui/create-form/index.js +3 -0
- package/dist/es2019/ui/create-form/main.js +48 -0
- package/dist/es2019/ui/create-form/textfield/index.js +1 -0
- package/dist/es2019/ui/create-form/textfield/main.js +42 -0
- package/dist/es2019/ui/create-form/textfield/types.js +1 -0
- package/dist/es2019/ui/create-form/types.js +1 -0
- package/dist/es2019/ui/create-form/utils/index.js +28 -0
- package/dist/es2019/ui/index.js +4 -1
- package/dist/es2019/ui/main.js +3 -50
- package/dist/es2019/version.json +1 -1
- package/dist/esm/common/types.js +1 -0
- package/dist/esm/controllers/form-context/index.js +1 -0
- package/dist/esm/controllers/form-context/main.js +40 -0
- package/dist/esm/index.js +3 -2
- package/dist/esm/ui/create-form/async-select/index.js +1 -0
- package/dist/esm/ui/create-form/async-select/main.js +42 -0
- package/dist/esm/ui/create-form/async-select/types.js +1 -0
- package/dist/esm/ui/create-form/index.js +3 -0
- package/dist/esm/ui/create-form/main.js +73 -0
- package/dist/esm/ui/create-form/textfield/index.js +1 -0
- package/dist/esm/ui/create-form/textfield/main.js +41 -0
- package/dist/esm/ui/create-form/textfield/types.js +1 -0
- package/dist/esm/ui/create-form/types.js +1 -0
- package/dist/esm/ui/create-form/utils/index.js +28 -0
- package/dist/esm/ui/index.js +4 -1
- package/dist/esm/ui/main.js +3 -50
- package/dist/esm/version.json +1 -1
- package/dist/types/common/types.d.ts +8 -0
- package/dist/types/controllers/form-context/index.d.ts +1 -0
- package/dist/types/controllers/form-context/main.d.ts +10 -0
- package/dist/types/index.d.ts +7 -3
- package/dist/types/ui/create-form/async-select/index.d.ts +1 -0
- package/dist/types/ui/create-form/async-select/main.d.ts +10 -0
- package/dist/types/ui/create-form/async-select/types.d.ts +18 -0
- package/dist/types/ui/create-form/index.d.ts +3 -0
- package/dist/types/ui/create-form/main.d.ts +8 -0
- package/dist/types/ui/create-form/textfield/index.d.ts +1 -0
- package/dist/types/ui/create-form/textfield/main.d.ts +9 -0
- package/dist/types/ui/create-form/textfield/types.d.ts +17 -0
- package/dist/types/ui/create-form/types.d.ts +6 -0
- package/dist/types/{utils.d.ts → ui/create-form/utils/index.d.ts} +3 -3
- package/dist/types/ui/index.d.ts +5 -1
- package/dist/types/ui/main.d.ts +2 -9
- package/dist/types/ui/types.d.ts +0 -36
- package/package.json +7 -7
- package/report.api.md +73 -20
- package/tmp/api-report-tmp.d.ts +63 -15
- package/dist/cjs/utils.js +0 -94
- package/dist/es2019/utils.js +0 -35
- package/dist/esm/utils.js +0 -87
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Validator, ValidatorMap } from '../../common/types';
|
|
3
|
+
interface FormContextType {
|
|
4
|
+
assignValidator: (name: string, validators: Validator[]) => void;
|
|
5
|
+
getValidators: () => ValidatorMap;
|
|
6
|
+
}
|
|
7
|
+
export declare const FormContext: React.Context<FormContextType>;
|
|
8
|
+
declare const FormContextProvider: React.FC<{}>;
|
|
9
|
+
declare const useFormContext: () => FormContextType;
|
|
10
|
+
export { FormContextProvider, useFormContext };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export
|
|
1
|
+
export type { LinkCreatePlugin, Option } from './ui/types';
|
|
2
|
+
export type { CreateFormProps } from './ui/index';
|
|
3
|
+
export { default, TextField, CreateForm, AsyncSelect } from './ui/index';
|
|
4
|
+
export { useLinkCreateCallback, LinkCreateCallbackProvider, } from './controllers/callback-context';
|
|
5
|
+
export { FormContextProvider, useFormContext, } from './controllers/form-context';
|
|
6
|
+
export type { LinkCreateProps } from './ui/types';
|
|
7
|
+
export type { Validator, ValidatorMap } from './common/types';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AsyncSelect } from './main';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx } from '@emotion/react';
|
|
2
|
+
import { OptionType } from '@atlaskit/select';
|
|
3
|
+
import { AsyncSelectProps } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* An async select utilising the Atlaskit AsyncSelect and Field objects from `@atlaskit/form`.
|
|
6
|
+
* Validation is handled by the form as it is on form submission. Any errors returned by
|
|
7
|
+
* the handleSubmit function passed to the form <Form> that have a key matching the `name`
|
|
8
|
+
* of this text field are shown above the field.
|
|
9
|
+
*/
|
|
10
|
+
export declare function AsyncSelect<T = OptionType>({ label, name, validationHelpText, isRequired, testId, validators, ...rest }: AsyncSelectProps<T>): jsx.JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AsyncSelectProps as AKAsyncSelectProps, OptionType } from '@atlaskit/select';
|
|
2
|
+
import { Validator } from '../../../common/types';
|
|
3
|
+
export declare type AsyncSelectProps<T = OptionType> = AKAsyncSelectProps<T> & {
|
|
4
|
+
/** Name passed to the <Field>.*/
|
|
5
|
+
name: string;
|
|
6
|
+
/** This should be properly internationalization-ed */
|
|
7
|
+
label: string;
|
|
8
|
+
/**
|
|
9
|
+
* Optional text below the textfield explaining any requirements for a valid value.
|
|
10
|
+
* eg. "Must be 4 or more letters"
|
|
11
|
+
*/
|
|
12
|
+
validationHelpText?: string;
|
|
13
|
+
testId?: string;
|
|
14
|
+
/** Will display a red astrix next to the field title if true */
|
|
15
|
+
isRequired?: boolean;
|
|
16
|
+
/** Validators for this field */
|
|
17
|
+
validators?: Validator[];
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TextField } from './main';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx } from '@emotion/react';
|
|
2
|
+
import { TextFieldProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* A text field utilising the Atlaskit Textfield and Field objects from `@atlaskit/form`.
|
|
5
|
+
* Validation is handled by the form as it is on form submission. Any errors returned by
|
|
6
|
+
* the handleSubmit function passed to the form <Form> that have a key matching the `name`
|
|
7
|
+
* of this text field are shown above the field.
|
|
8
|
+
*/
|
|
9
|
+
export declare function TextField({ label, name, validationHelpText, isRequired, testId, validators, }: TextFieldProps): jsx.JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Validator } from '../../../common/types';
|
|
2
|
+
export interface TextFieldProps {
|
|
3
|
+
/** Name passed to the <Field>.*/
|
|
4
|
+
name: string;
|
|
5
|
+
/** This should be properly internationalization-ed */
|
|
6
|
+
label: string;
|
|
7
|
+
/**
|
|
8
|
+
* Optional text below the textfield explaining any requirements for a valid value.
|
|
9
|
+
* eg. "Must be 4 or more letters"
|
|
10
|
+
*/
|
|
11
|
+
validationHelpText?: string;
|
|
12
|
+
testId?: string;
|
|
13
|
+
/** Will display a red astrix next to the field title if true */
|
|
14
|
+
isRequired?: boolean;
|
|
15
|
+
/** Validators for this field */
|
|
16
|
+
validators?: Validator[];
|
|
17
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare type Validator = {
|
|
2
|
+
/** Return true when the given input is valid */
|
|
3
|
+
isValid: (val: unknown) => boolean;
|
|
4
|
+
/** An error message is used to tell a user that the field input is invalid. For example, an error message could be 'Invalid username, needs to be more than 4 characters'. */
|
|
5
|
+
errorMessage: string;
|
|
6
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ValidatorMap } from '../../../common/types';
|
|
2
2
|
/** Map of field names to errors for that field (or undefined if no error for that field) */
|
|
3
3
|
export declare type ValidatorResults = {
|
|
4
4
|
[name: string]: string | undefined;
|
|
@@ -9,5 +9,5 @@ export declare type ValidatorResults = {
|
|
|
9
9
|
*/
|
|
10
10
|
export declare function validateFormData({ data, validators, }: {
|
|
11
11
|
data: Record<string, unknown>;
|
|
12
|
-
validators:
|
|
13
|
-
}):
|
|
12
|
+
validators: ValidatorMap;
|
|
13
|
+
}): ValidatorResults;
|
package/dist/types/ui/index.d.ts
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
export { default
|
|
1
|
+
export { default } from './main';
|
|
2
|
+
export { TextField } from './create-form/textfield';
|
|
3
|
+
export { CreateForm } from './create-form/main';
|
|
4
|
+
export type { CreateFormProps } from './create-form/main';
|
|
5
|
+
export { AsyncSelect } from './create-form/async-select';
|
package/dist/types/ui/main.d.ts
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
1
2
|
import { jsx } from '@emotion/react';
|
|
2
|
-
import { LinkCreateProps
|
|
3
|
+
import { LinkCreateProps } from './types';
|
|
3
4
|
export default function LinkCreate({ plugins, testId, groupKey, entityKey, onCreate, onFailure, onCancel, active, }: LinkCreateProps): jsx.JSX.Element;
|
|
4
|
-
export declare function Select({ name, title, options, defaultOption, placeholder, }: SelectProps): jsx.JSX.Element;
|
|
5
|
-
/**
|
|
6
|
-
* A text field utilising the Atlaskit Textfield and Field objects from `@atlaskit/form`.
|
|
7
|
-
* Validation is handled by the form as it is on form submission. Any errors returned by
|
|
8
|
-
* the handleSubmit function passed to the form <Form> that have a key matching the `name`
|
|
9
|
-
* of this text field are shown above the field.
|
|
10
|
-
*/
|
|
11
|
-
export declare function TextField({ label, name, validationHelpText }: TextFieldProps): jsx.JSX.Element;
|
package/dist/types/ui/types.d.ts
CHANGED
|
@@ -59,45 +59,9 @@ export interface LinkCreateProps {
|
|
|
59
59
|
*/
|
|
60
60
|
active?: boolean;
|
|
61
61
|
}
|
|
62
|
-
export declare type Validator<FieldName extends string> = {
|
|
63
|
-
/** The field of the form that should be validated (eg. referencing name of TextFieldProps) */
|
|
64
|
-
fieldName: FieldName;
|
|
65
|
-
/** Return true when the given input is invalid */
|
|
66
|
-
isInvalid: (val: string) => Promise<boolean>;
|
|
67
|
-
/** An error message is used to tell a user that the field input is invalid. For example, an error message could be 'Invalid username, needs to be more than 4 characters'. */
|
|
68
|
-
errorMessage: string;
|
|
69
|
-
};
|
|
70
|
-
export interface TextFieldProps {
|
|
71
|
-
/** Name passed to the <Field>.*/
|
|
72
|
-
name: string;
|
|
73
|
-
/** This should be properly internationalization-ed */
|
|
74
|
-
label: string;
|
|
75
|
-
/**
|
|
76
|
-
* Optional text below the textfield explaining any requirements for a valid value.
|
|
77
|
-
* eg. "Must be 4 or more letters"
|
|
78
|
-
*/
|
|
79
|
-
validationHelpText?: string;
|
|
80
|
-
}
|
|
81
62
|
export interface Option {
|
|
82
63
|
/** html `value` attribute to differentiate options */
|
|
83
64
|
value: string;
|
|
84
65
|
/** This should be properly internationalization-ed */
|
|
85
66
|
label: string;
|
|
86
67
|
}
|
|
87
|
-
export interface SelectProps {
|
|
88
|
-
name: string;
|
|
89
|
-
title: string;
|
|
90
|
-
/** Placeholder to go in the select */
|
|
91
|
-
placeholder?: string;
|
|
92
|
-
/** Options available in the select */
|
|
93
|
-
options: Option[];
|
|
94
|
-
/** Default select option */
|
|
95
|
-
defaultOption?: Option;
|
|
96
|
-
}
|
|
97
|
-
export interface FormProps<Fields extends string> {
|
|
98
|
-
/**
|
|
99
|
-
* Each validator will run on form submit. If multiple validators for a given field, the
|
|
100
|
-
* last validator's error will be shown
|
|
101
|
-
*/
|
|
102
|
-
validators: Validator<Fields>[];
|
|
103
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/link-create",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "The driver component of meta creation flow",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -26,20 +26,19 @@
|
|
|
26
26
|
".": "./src/index.ts"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
+
"@atlaskit/button": "^16.6.0",
|
|
29
30
|
"@atlaskit/form": "^8.8.4",
|
|
30
31
|
"@atlaskit/modal-dialog": "^12.4.4",
|
|
31
|
-
"@atlaskit/select": "^16.1.
|
|
32
|
+
"@atlaskit/select": "^16.1.5",
|
|
32
33
|
"@atlaskit/textfield": "^5.3.5",
|
|
33
34
|
"@babel/runtime": "^7.0.0",
|
|
34
|
-
"@emotion/react": "^11.7.1"
|
|
35
|
-
"react-select": "^5.4.0"
|
|
35
|
+
"@emotion/react": "^11.7.1"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"react": "^16.8.0",
|
|
39
39
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@atlaskit/button": "^16.6.0",
|
|
43
42
|
"@atlaskit/docs": "*",
|
|
44
43
|
"@atlaskit/link-picker": "^1.18.0",
|
|
45
44
|
"@atlaskit/link-provider": "^1.4.0",
|
|
@@ -48,12 +47,13 @@
|
|
|
48
47
|
"@atlaskit/visual-regression": "*",
|
|
49
48
|
"@atlaskit/webdriver-runner": "*",
|
|
50
49
|
"@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
|
|
51
|
-
"@atlassian/link-create-confluence": "^
|
|
52
|
-
"@atlassian/link-create-presets": "^
|
|
50
|
+
"@atlassian/link-create-confluence": "^2.0.0",
|
|
51
|
+
"@atlassian/link-create-presets": "^1.0.0",
|
|
53
52
|
"@atlassian/link-picker-plugins": "^18.1.0",
|
|
54
53
|
"@atlassian/recent-work-client": "^1.7.0",
|
|
55
54
|
"@atlassian/search-client": "^0.5.0",
|
|
56
55
|
"@testing-library/react": "^12.1.5",
|
|
56
|
+
"@testing-library/user-event": "^14.4.3",
|
|
57
57
|
"react-dom": "^16.8.0",
|
|
58
58
|
"typescript": "4.5.5",
|
|
59
59
|
"wait-for-expect": "^1.2.0"
|
package/report.api.md
CHANGED
|
@@ -15,9 +15,59 @@
|
|
|
15
15
|
<!--SECTION START: Main Entry Types-->
|
|
16
16
|
|
|
17
17
|
```ts
|
|
18
|
+
import { AsyncSelectProps as AsyncSelectProps_2 } from '@atlaskit/select';
|
|
18
19
|
import { jsx } from '@emotion/react';
|
|
20
|
+
import { OptionType } from '@atlaskit/select';
|
|
21
|
+
import { default as React_2 } from 'react';
|
|
19
22
|
import { ReactNode } from 'react';
|
|
20
23
|
|
|
24
|
+
// @public
|
|
25
|
+
export function AsyncSelect<T = OptionType>({
|
|
26
|
+
label,
|
|
27
|
+
name,
|
|
28
|
+
validationHelpText,
|
|
29
|
+
isRequired,
|
|
30
|
+
testId,
|
|
31
|
+
validators,
|
|
32
|
+
...rest
|
|
33
|
+
}: AsyncSelectProps<T>): jsx.JSX.Element;
|
|
34
|
+
|
|
35
|
+
// @public (undocumented)
|
|
36
|
+
type AsyncSelectProps<T = OptionType> = AsyncSelectProps_2<T> & {
|
|
37
|
+
name: string;
|
|
38
|
+
label: string;
|
|
39
|
+
validationHelpText?: string;
|
|
40
|
+
testId?: string;
|
|
41
|
+
isRequired?: boolean;
|
|
42
|
+
validators?: Validator[];
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// @public (undocumented)
|
|
46
|
+
export const CreateForm: (props: any) => JSX.Element;
|
|
47
|
+
|
|
48
|
+
// @public (undocumented)
|
|
49
|
+
export interface CreateFormProps {
|
|
50
|
+
// (undocumented)
|
|
51
|
+
children: ReactNode;
|
|
52
|
+
// (undocumented)
|
|
53
|
+
onCancel?: () => void;
|
|
54
|
+
// (undocumented)
|
|
55
|
+
onSubmit: (data: Record<string, unknown>) => void;
|
|
56
|
+
// (undocumented)
|
|
57
|
+
testId?: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// @public (undocumented)
|
|
61
|
+
export const FormContextProvider: React_2.FC<{}>;
|
|
62
|
+
|
|
63
|
+
// @public (undocumented)
|
|
64
|
+
interface FormContextType {
|
|
65
|
+
// (undocumented)
|
|
66
|
+
assignValidator: (name: string, validators: Validator[]) => void;
|
|
67
|
+
// (undocumented)
|
|
68
|
+
getValidators: () => ValidatorMap;
|
|
69
|
+
}
|
|
70
|
+
|
|
21
71
|
// @public (undocumented)
|
|
22
72
|
interface Group {
|
|
23
73
|
icon: string;
|
|
@@ -38,6 +88,9 @@ function LinkCreate({
|
|
|
38
88
|
}: LinkCreateProps): jsx.JSX.Element;
|
|
39
89
|
export default LinkCreate;
|
|
40
90
|
|
|
91
|
+
// @public (undocumented)
|
|
92
|
+
export const LinkCreateCallbackProvider: React_2.FC<LinkCreateCallbackProviderProps>;
|
|
93
|
+
|
|
41
94
|
// @public (undocumented)
|
|
42
95
|
interface LinkCreateCallbackProviderProps {
|
|
43
96
|
onCancel?: () => void;
|
|
@@ -72,44 +125,44 @@ interface Option_2 {
|
|
|
72
125
|
label: string;
|
|
73
126
|
value: string;
|
|
74
127
|
}
|
|
75
|
-
|
|
76
|
-
// @public (undocumented)
|
|
77
|
-
export function Select({
|
|
78
|
-
name,
|
|
79
|
-
title,
|
|
80
|
-
options,
|
|
81
|
-
defaultOption,
|
|
82
|
-
placeholder,
|
|
83
|
-
}: SelectProps): jsx.JSX.Element;
|
|
84
|
-
|
|
85
|
-
// @public (undocumented)
|
|
86
|
-
interface SelectProps {
|
|
87
|
-
defaultOption?: Option_2;
|
|
88
|
-
// (undocumented)
|
|
89
|
-
name: string;
|
|
90
|
-
options: Option_2[];
|
|
91
|
-
placeholder?: string;
|
|
92
|
-
// (undocumented)
|
|
93
|
-
title: string;
|
|
94
|
-
}
|
|
128
|
+
export { Option_2 as Option };
|
|
95
129
|
|
|
96
130
|
// @public
|
|
97
131
|
export function TextField({
|
|
98
132
|
label,
|
|
99
133
|
name,
|
|
100
134
|
validationHelpText,
|
|
135
|
+
isRequired,
|
|
136
|
+
testId,
|
|
137
|
+
validators,
|
|
101
138
|
}: TextFieldProps): jsx.JSX.Element;
|
|
102
139
|
|
|
103
140
|
// @public (undocumented)
|
|
104
141
|
interface TextFieldProps {
|
|
142
|
+
isRequired?: boolean;
|
|
105
143
|
label: string;
|
|
106
144
|
name: string;
|
|
145
|
+
// (undocumented)
|
|
146
|
+
testId?: string;
|
|
107
147
|
validationHelpText?: string;
|
|
148
|
+
validators?: Validator[];
|
|
108
149
|
}
|
|
109
150
|
|
|
151
|
+
// @public (undocumented)
|
|
152
|
+
export const useFormContext: () => FormContextType;
|
|
153
|
+
|
|
110
154
|
// @public (undocumented)
|
|
111
155
|
export const useLinkCreateCallback: () => LinkCreateCallbackProviderProps;
|
|
112
156
|
|
|
157
|
+
// @public (undocumented)
|
|
158
|
+
export type Validator = {
|
|
159
|
+
isValid: (val: unknown) => boolean;
|
|
160
|
+
errorMessage: string;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
// @public
|
|
164
|
+
export type ValidatorMap = Record<string, Validator[]>;
|
|
165
|
+
|
|
113
166
|
// (No @packageDocumentation comment for this package)
|
|
114
167
|
```
|
|
115
168
|
|
package/tmp/api-report-tmp.d.ts
CHANGED
|
@@ -4,9 +4,51 @@
|
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
6
|
|
|
7
|
+
import { AsyncSelectProps as AsyncSelectProps_2 } from '@atlaskit/select';
|
|
7
8
|
import { jsx } from '@emotion/react';
|
|
9
|
+
import { OptionType } from '@atlaskit/select';
|
|
10
|
+
import { default as React_2 } from 'react';
|
|
8
11
|
import { ReactNode } from 'react';
|
|
9
12
|
|
|
13
|
+
// @public
|
|
14
|
+
export function AsyncSelect<T = OptionType>({ label, name, validationHelpText, isRequired, testId, validators, ...rest }: AsyncSelectProps<T>): jsx.JSX.Element;
|
|
15
|
+
|
|
16
|
+
// @public (undocumented)
|
|
17
|
+
type AsyncSelectProps<T = OptionType> = AsyncSelectProps_2<T> & {
|
|
18
|
+
name: string;
|
|
19
|
+
label: string;
|
|
20
|
+
validationHelpText?: string;
|
|
21
|
+
testId?: string;
|
|
22
|
+
isRequired?: boolean;
|
|
23
|
+
validators?: Validator[];
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// @public (undocumented)
|
|
27
|
+
export const CreateForm: (props: any) => JSX.Element;
|
|
28
|
+
|
|
29
|
+
// @public (undocumented)
|
|
30
|
+
export interface CreateFormProps {
|
|
31
|
+
// (undocumented)
|
|
32
|
+
children: ReactNode;
|
|
33
|
+
// (undocumented)
|
|
34
|
+
onCancel?: () => void;
|
|
35
|
+
// (undocumented)
|
|
36
|
+
onSubmit: (data: Record<string, unknown>) => void;
|
|
37
|
+
// (undocumented)
|
|
38
|
+
testId?: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// @public (undocumented)
|
|
42
|
+
export const FormContextProvider: React_2.FC<{}>;
|
|
43
|
+
|
|
44
|
+
// @public (undocumented)
|
|
45
|
+
interface FormContextType {
|
|
46
|
+
// (undocumented)
|
|
47
|
+
assignValidator: (name: string, validators: Validator[]) => void;
|
|
48
|
+
// (undocumented)
|
|
49
|
+
getValidators: () => ValidatorMap;
|
|
50
|
+
}
|
|
51
|
+
|
|
10
52
|
// @public (undocumented)
|
|
11
53
|
interface Group {
|
|
12
54
|
icon: string;
|
|
@@ -18,6 +60,9 @@ interface Group {
|
|
|
18
60
|
function LinkCreate({ plugins, testId, groupKey, entityKey, onCreate, onFailure, onCancel, active, }: LinkCreateProps): jsx.JSX.Element;
|
|
19
61
|
export default LinkCreate;
|
|
20
62
|
|
|
63
|
+
// @public (undocumented)
|
|
64
|
+
export const LinkCreateCallbackProvider: React_2.FC<LinkCreateCallbackProviderProps>;
|
|
65
|
+
|
|
21
66
|
// @public (undocumented)
|
|
22
67
|
interface LinkCreateCallbackProviderProps {
|
|
23
68
|
onCancel?: () => void;
|
|
@@ -52,34 +97,37 @@ interface Option_2 {
|
|
|
52
97
|
label: string;
|
|
53
98
|
value: string;
|
|
54
99
|
}
|
|
55
|
-
|
|
56
|
-
// @public (undocumented)
|
|
57
|
-
export function Select({ name, title, options, defaultOption, placeholder, }: SelectProps): jsx.JSX.Element;
|
|
58
|
-
|
|
59
|
-
// @public (undocumented)
|
|
60
|
-
interface SelectProps {
|
|
61
|
-
defaultOption?: Option_2;
|
|
62
|
-
// (undocumented)
|
|
63
|
-
name: string;
|
|
64
|
-
options: Option_2[];
|
|
65
|
-
placeholder?: string;
|
|
66
|
-
// (undocumented)
|
|
67
|
-
title: string;
|
|
68
|
-
}
|
|
100
|
+
export { Option_2 as Option }
|
|
69
101
|
|
|
70
102
|
// @public
|
|
71
|
-
export function TextField({ label, name, validationHelpText }: TextFieldProps): jsx.JSX.Element;
|
|
103
|
+
export function TextField({ label, name, validationHelpText, isRequired, testId, validators, }: TextFieldProps): jsx.JSX.Element;
|
|
72
104
|
|
|
73
105
|
// @public (undocumented)
|
|
74
106
|
interface TextFieldProps {
|
|
107
|
+
isRequired?: boolean;
|
|
75
108
|
label: string;
|
|
76
109
|
name: string;
|
|
110
|
+
// (undocumented)
|
|
111
|
+
testId?: string;
|
|
77
112
|
validationHelpText?: string;
|
|
113
|
+
validators?: Validator[];
|
|
78
114
|
}
|
|
79
115
|
|
|
116
|
+
// @public (undocumented)
|
|
117
|
+
export const useFormContext: () => FormContextType;
|
|
118
|
+
|
|
80
119
|
// @public (undocumented)
|
|
81
120
|
export const useLinkCreateCallback: () => LinkCreateCallbackProviderProps;
|
|
82
121
|
|
|
122
|
+
// @public (undocumented)
|
|
123
|
+
export type Validator = {
|
|
124
|
+
isValid: (val: unknown) => boolean;
|
|
125
|
+
errorMessage: string;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// @public
|
|
129
|
+
export type ValidatorMap = Record<string, Validator[]>;
|
|
130
|
+
|
|
83
131
|
// (No @packageDocumentation comment for this package)
|
|
84
132
|
|
|
85
133
|
```
|
package/dist/cjs/utils.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.validateFormData = validateFormData;
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
-
/** Map of field names to errors for that field (or undefined if no error for that field) */
|
|
11
|
-
|
|
12
|
-
function isOption(maybeOption) {
|
|
13
|
-
return maybeOption !== undefined && maybeOption !== null && maybeOption.value !== undefined && typeof maybeOption.value === 'string';
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Returns an object where the keys are names of form fields, and values are a string if the field
|
|
17
|
-
* has an error, or undefined if the field is valid.
|
|
18
|
-
*/
|
|
19
|
-
function validateFormData(_x) {
|
|
20
|
-
return _validateFormData.apply(this, arguments);
|
|
21
|
-
}
|
|
22
|
-
function _validateFormData() {
|
|
23
|
-
_validateFormData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref) {
|
|
24
|
-
var data, validators, map, i, v, fieldName, maybeValue;
|
|
25
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
26
|
-
while (1) {
|
|
27
|
-
switch (_context.prev = _context.next) {
|
|
28
|
-
case 0:
|
|
29
|
-
data = _ref.data, validators = _ref.validators;
|
|
30
|
-
// Run each validator on the input.
|
|
31
|
-
map = {};
|
|
32
|
-
i = 0;
|
|
33
|
-
case 3:
|
|
34
|
-
if (!(i < validators.length)) {
|
|
35
|
-
_context.next = 26;
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
v = validators[i];
|
|
39
|
-
fieldName = v.fieldName;
|
|
40
|
-
maybeValue = data[fieldName]; // If maybeValue is undefined, the fieldname of the current validator doesn't exist
|
|
41
|
-
// in our form.
|
|
42
|
-
// Value should always be in form, but if not, check if it's undefined here
|
|
43
|
-
if (!(maybeValue === undefined || maybeValue === null)) {
|
|
44
|
-
_context.next = 9;
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
return _context.abrupt("continue", 23);
|
|
48
|
-
case 9:
|
|
49
|
-
_context.t0 = typeof maybeValue === 'string';
|
|
50
|
-
if (!_context.t0) {
|
|
51
|
-
_context.next = 14;
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
_context.next = 13;
|
|
55
|
-
return v.isInvalid(maybeValue);
|
|
56
|
-
case 13:
|
|
57
|
-
_context.t0 = _context.sent;
|
|
58
|
-
case 14:
|
|
59
|
-
if (!_context.t0) {
|
|
60
|
-
_context.next = 16;
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
map[v.fieldName] = v.errorMessage;
|
|
64
|
-
case 16:
|
|
65
|
-
_context.t1 = isOption(maybeValue);
|
|
66
|
-
if (!_context.t1) {
|
|
67
|
-
_context.next = 21;
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
70
|
-
_context.next = 20;
|
|
71
|
-
return v.isInvalid(maybeValue.value);
|
|
72
|
-
case 20:
|
|
73
|
-
_context.t1 = _context.sent;
|
|
74
|
-
case 21:
|
|
75
|
-
if (!_context.t1) {
|
|
76
|
-
_context.next = 23;
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
map[v.fieldName] = v.errorMessage;
|
|
80
|
-
case 23:
|
|
81
|
-
i++;
|
|
82
|
-
_context.next = 3;
|
|
83
|
-
break;
|
|
84
|
-
case 26:
|
|
85
|
-
return _context.abrupt("return", map);
|
|
86
|
-
case 27:
|
|
87
|
-
case "end":
|
|
88
|
-
return _context.stop();
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}, _callee);
|
|
92
|
-
}));
|
|
93
|
-
return _validateFormData.apply(this, arguments);
|
|
94
|
-
}
|
package/dist/es2019/utils.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/** Map of field names to errors for that field (or undefined if no error for that field) */
|
|
2
|
-
|
|
3
|
-
function isOption(maybeOption) {
|
|
4
|
-
return maybeOption !== undefined && maybeOption !== null && maybeOption.value !== undefined && typeof maybeOption.value === 'string';
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Returns an object where the keys are names of form fields, and values are a string if the field
|
|
8
|
-
* has an error, or undefined if the field is valid.
|
|
9
|
-
*/
|
|
10
|
-
export async function validateFormData({
|
|
11
|
-
data,
|
|
12
|
-
validators
|
|
13
|
-
}) {
|
|
14
|
-
// Run each validator on the input.
|
|
15
|
-
const map = {};
|
|
16
|
-
for (let i = 0; i < validators.length; i++) {
|
|
17
|
-
const v = validators[i];
|
|
18
|
-
const fieldName = v.fieldName;
|
|
19
|
-
const maybeValue = data[fieldName];
|
|
20
|
-
|
|
21
|
-
// If maybeValue is undefined, the fieldname of the current validator doesn't exist
|
|
22
|
-
// in our form.
|
|
23
|
-
// Value should always be in form, but if not, check if it's undefined here
|
|
24
|
-
if (maybeValue === undefined || maybeValue === null) {
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
if (typeof maybeValue === 'string' && (await v.isInvalid(maybeValue))) {
|
|
28
|
-
map[v.fieldName] = v.errorMessage;
|
|
29
|
-
}
|
|
30
|
-
if (isOption(maybeValue) && (await v.isInvalid(maybeValue.value))) {
|
|
31
|
-
map[v.fieldName] = v.errorMessage;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return map;
|
|
35
|
-
}
|