@atlaskit/link-create 0.9.1 → 1.0.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 +12 -0
- package/analytics.spec.yaml +9 -0
- package/dist/cjs/common/utils/analytics/analytics.codegen.js +1 -1
- package/dist/cjs/controllers/callback-context/main.js +22 -3
- package/dist/cjs/controllers/create-field/index.js +12 -0
- package/dist/cjs/controllers/create-field/main.js +62 -0
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/ui/create-form/async-select/main.js +117 -35
- package/dist/cjs/ui/create-form/form-footer/main.js +9 -2
- package/dist/cjs/ui/create-form/form-spy/index.js +27 -0
- package/dist/cjs/ui/create-form/index.js +15 -1
- package/dist/cjs/ui/create-form/main.js +20 -10
- package/dist/cjs/ui/create-form/select/index.js +12 -0
- package/dist/cjs/ui/create-form/select/main.js +50 -0
- package/dist/cjs/ui/create-form/select/types.js +5 -0
- package/dist/cjs/ui/create-form/textfield/main.js +26 -48
- package/dist/cjs/ui/index.js +15 -1
- package/dist/cjs/ui/link-create/main.js +3 -3
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/common/utils/analytics/analytics.codegen.js +1 -1
- package/dist/es2019/controllers/callback-context/main.js +6 -1
- package/dist/es2019/controllers/create-field/index.js +1 -0
- package/dist/es2019/controllers/create-field/main.js +57 -0
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/ui/create-form/async-select/main.js +75 -34
- package/dist/es2019/ui/create-form/form-footer/main.js +9 -2
- package/dist/es2019/ui/create-form/form-spy/index.js +18 -0
- package/dist/es2019/ui/create-form/index.js +3 -1
- package/dist/es2019/ui/create-form/main.js +25 -16
- package/dist/es2019/ui/create-form/select/index.js +1 -0
- package/dist/es2019/ui/create-form/select/main.js +40 -0
- package/dist/es2019/ui/create-form/textfield/main.js +24 -48
- package/dist/es2019/ui/index.js +3 -1
- package/dist/es2019/ui/link-create/main.js +3 -3
- package/dist/es2019/version.json +1 -1
- package/dist/esm/common/utils/analytics/analytics.codegen.js +1 -1
- package/dist/esm/controllers/callback-context/main.js +22 -3
- package/dist/esm/controllers/create-field/index.js +1 -0
- package/dist/esm/controllers/create-field/main.js +56 -0
- package/dist/esm/controllers/create-field/types.js +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/ui/create-form/async-select/main.js +118 -36
- package/dist/esm/ui/create-form/form-footer/main.js +9 -2
- package/dist/esm/ui/create-form/form-spy/index.js +19 -0
- package/dist/esm/ui/create-form/index.js +3 -1
- package/dist/esm/ui/create-form/main.js +19 -8
- package/dist/esm/ui/create-form/select/index.js +1 -0
- package/dist/esm/ui/create-form/select/main.js +42 -0
- package/dist/esm/ui/create-form/select/types.js +1 -0
- package/dist/esm/ui/create-form/textfield/main.js +25 -47
- package/dist/esm/ui/index.js +3 -1
- package/dist/esm/ui/link-create/main.js +3 -3
- package/dist/esm/version.json +1 -1
- package/dist/types/common/utils/analytics/analytics.codegen.d.ts +5 -1
- package/dist/types/common/utils/form/index.d.ts +2 -2
- package/dist/types/controllers/callback-context/main.d.ts +1 -1
- package/dist/types/controllers/create-field/index.d.ts +1 -0
- package/dist/types/controllers/create-field/main.d.ts +3 -0
- package/dist/types/controllers/create-field/types.d.ts +24 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/ui/create-form/async-select/main.d.ts +5 -5
- package/dist/types/ui/create-form/async-select/types.d.ts +9 -4
- package/dist/types/ui/create-form/form-spy/index.d.ts +12 -0
- package/dist/types/ui/create-form/index.d.ts +2 -0
- package/dist/types/ui/create-form/main.d.ts +2 -1
- package/dist/types/ui/create-form/select/index.d.ts +1 -0
- package/dist/types/ui/create-form/select/main.d.ts +12 -0
- package/dist/types/ui/create-form/select/types.d.ts +18 -0
- package/dist/types/ui/create-form/textfield/main.d.ts +2 -1
- package/dist/types/ui/index.d.ts +2 -0
- package/dist/types-ts4.5/common/utils/analytics/analytics.codegen.d.ts +5 -1
- package/dist/types-ts4.5/common/utils/form/index.d.ts +2 -2
- package/dist/types-ts4.5/controllers/callback-context/main.d.ts +1 -1
- package/dist/types-ts4.5/controllers/create-field/index.d.ts +1 -0
- package/dist/types-ts4.5/controllers/create-field/main.d.ts +3 -0
- package/dist/types-ts4.5/controllers/create-field/types.d.ts +24 -0
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/create-form/async-select/main.d.ts +5 -5
- package/dist/types-ts4.5/ui/create-form/async-select/types.d.ts +9 -4
- package/dist/types-ts4.5/ui/create-form/form-spy/index.d.ts +12 -0
- package/dist/types-ts4.5/ui/create-form/index.d.ts +2 -0
- package/dist/types-ts4.5/ui/create-form/main.d.ts +2 -1
- package/dist/types-ts4.5/ui/create-form/select/index.d.ts +1 -0
- package/dist/types-ts4.5/ui/create-form/select/main.d.ts +12 -0
- package/dist/types-ts4.5/ui/create-form/select/types.d.ts +18 -0
- package/dist/types-ts4.5/ui/create-form/textfield/main.d.ts +2 -1
- package/dist/types-ts4.5/ui/index.d.ts +2 -0
- package/example-helpers/mock-plugin-form.tsx +3 -4
- package/package.json +6 -3
- package/report.api.md +55 -12
- package/tmp/api-report-tmp.d.ts +164 -0
- package/dist/cjs/ui/group-selection/index.js +0 -22
- package/dist/es2019/ui/group-selection/index.js +0 -16
- package/dist/esm/ui/group-selection/index.js +0 -15
- package/dist/types/ui/group-selection/index.d.ts +0 -4
- package/dist/types/ui/group-selection/types.d.ts +0 -12
- package/dist/types-ts4.5/ui/group-selection/index.d.ts +0 -4
- package/dist/types-ts4.5/ui/group-selection/types.d.ts +0 -12
- /package/dist/cjs/{ui/group-selection → controllers/create-field}/types.js +0 -0
- /package/dist/es2019/{ui/group-selection → controllers/create-field}/types.js +0 -0
- /package/dist/{esm/ui/group-selection → es2019/ui/create-form/select}/types.js +0 -0
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { CreateFormProps } from './ui/index';
|
|
2
2
|
export type { LinkCreateProps, LinkCreatePlugin, LinkCreateWithModalProps, CreatePayload, } from './common/types';
|
|
3
|
-
export { default, TextField, CreateForm, AsyncSelect, CreateFormLoader, } from './ui/index';
|
|
3
|
+
export { default, TextField, CreateForm, Select, AsyncSelect, CreateFormLoader, FormSpy, } from './ui/index';
|
|
4
4
|
export { useLinkCreateCallback, LinkCreateCallbackProvider, } from './controllers/callback-context';
|
|
5
5
|
export type { Validator, ValidatorMap } from './common/types';
|
|
@@ -3,9 +3,9 @@ import { OptionType } from '@atlaskit/select';
|
|
|
3
3
|
import { AsyncSelectProps } from './types';
|
|
4
4
|
export declare const TEST_ID = "link-create-async-select";
|
|
5
5
|
/**
|
|
6
|
-
* An async select utilising the Atlaskit AsyncSelect and Field
|
|
7
|
-
* Validation is handled by the form
|
|
8
|
-
* the handleSubmit function passed to the form <Form> that
|
|
9
|
-
* of this
|
|
6
|
+
* An async select utilising the Atlaskit AsyncSelect and Field components from
|
|
7
|
+
* `@atlaskit/form`. Validation is handled by the form on form submission. Any
|
|
8
|
+
* errors returned by the handleSubmit function passed to the form <Form> that
|
|
9
|
+
* have a key matching the `name` of this field are shown below the field.
|
|
10
10
|
*/
|
|
11
|
-
export declare function AsyncSelect<T = OptionType>({
|
|
11
|
+
export declare function AsyncSelect<T = OptionType>({ id, name, label, isRequired, validators, validationHelpText, testId, defaultOption: propsDefaultValue, loadOptions, ...restProps }: AsyncSelectProps<T>): jsx.JSX.Element;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { AsyncSelectProps as AKAsyncSelectProps, OptionType } from '@atlaskit/select';
|
|
1
|
+
import { AsyncSelectProps as AKAsyncSelectProps, GroupType, OptionType } from '@atlaskit/select';
|
|
2
2
|
import { Validator } from '../../../common/types';
|
|
3
|
-
export type AsyncSelectProps<T = OptionType> = AKAsyncSelectProps<T> & {
|
|
4
|
-
/** Name passed to the <Field
|
|
3
|
+
export type AsyncSelectProps<T = OptionType> = Omit<AKAsyncSelectProps<T>, 'loadOptions'> & {
|
|
4
|
+
/** Name passed to the <Field> */
|
|
5
5
|
name: string;
|
|
6
6
|
/** This should be properly internationalization-ed */
|
|
7
7
|
label: string;
|
|
8
8
|
/**
|
|
9
|
-
* Optional text below the
|
|
9
|
+
* Optional text below the field explaining any requirements for a valid value.
|
|
10
10
|
* eg. "Must be 4 or more letters"
|
|
11
11
|
*/
|
|
12
12
|
validationHelpText?: string;
|
|
@@ -15,4 +15,9 @@ export type AsyncSelectProps<T = OptionType> = AKAsyncSelectProps<T> & {
|
|
|
15
15
|
isRequired?: boolean;
|
|
16
16
|
/** Validators for this field */
|
|
17
17
|
validators?: Validator[];
|
|
18
|
+
/**
|
|
19
|
+
* Function to options to display in async select.
|
|
20
|
+
* **WARNING** Will refetch if function changes.
|
|
21
|
+
*/
|
|
22
|
+
loadOptions?: (inputValue: string) => Promise<T[] | GroupType<T>[]>;
|
|
18
23
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type FormSpyProps<T> = {
|
|
3
|
+
children: ({ values }: {
|
|
4
|
+
values: T;
|
|
5
|
+
}) => React.ReactNode;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Lightweight wrapper around the react-final-form
|
|
9
|
+
* FormSpy component so that we can control selectively
|
|
10
|
+
* how much of the API we are commited to.
|
|
11
|
+
*/
|
|
12
|
+
export declare const FormSpy: <T extends Record<string, unknown>>({ children, }: FormSpyProps<T>) => JSX.Element;
|
|
@@ -8,6 +8,7 @@ export interface CreateFormProps<FormData> {
|
|
|
8
8
|
onCancel?: () => void;
|
|
9
9
|
isLoading?: boolean;
|
|
10
10
|
hideFooter?: boolean;
|
|
11
|
+
initialValues?: FormData;
|
|
11
12
|
}
|
|
12
13
|
export declare const TEST_ID = "link-create-form";
|
|
13
|
-
export declare const CreateForm: <FormData_1 extends Record<string, any> = {}>({ children, testId, onSubmit, onCancel, isLoading, hideFooter, }: CreateFormProps<FormData_1>) => jsx.JSX.Element;
|
|
14
|
+
export declare const CreateForm: <FormData_1 extends Record<string, any> = {}>({ children, testId, onSubmit, onCancel, isLoading, hideFooter, initialValues, }: CreateFormProps<FormData_1>) => jsx.JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Select } from './main';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
|
+
import { OptionType } from '@atlaskit/select';
|
|
4
|
+
import { SelectProps } from './types';
|
|
5
|
+
export declare const TEST_ID = "link-create-select";
|
|
6
|
+
/**
|
|
7
|
+
* A select utilising the Atlaskit Select and Field components from
|
|
8
|
+
* `@atlaskit/form`. Validation is handled by the form on form submission. Any
|
|
9
|
+
* errors returned by the handleSubmit function passed to the form <Form> that
|
|
10
|
+
* have a key matching the `name` of this field are shown below the field.
|
|
11
|
+
*/
|
|
12
|
+
export declare function Select<T = OptionType>({ id, name, label, isRequired, validators, validationHelpText, testId, ...restProps }: SelectProps<T>): jsx.JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SelectProps as AKSelectProps, OptionType } from '@atlaskit/select';
|
|
2
|
+
import { Validator } from '../../../common/types';
|
|
3
|
+
export type SelectProps<T = OptionType> = AKSelectProps<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 field 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
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
1
2
|
import { jsx } from '@emotion/react';
|
|
2
3
|
import { TextFieldProps } from './types';
|
|
3
4
|
export declare const TEST_ID = "link-create-text-field";
|
|
@@ -7,4 +8,4 @@ export declare const TEST_ID = "link-create-text-field";
|
|
|
7
8
|
* the handleSubmit function passed to the form <Form> that have a key matching the `name`
|
|
8
9
|
* of this text field are shown above the field.
|
|
9
10
|
*/
|
|
10
|
-
export declare function TextField({
|
|
11
|
+
export declare function TextField({ id, name, label, isRequired, validators, validationHelpText, testId, ...restProps }: TextFieldProps): jsx.JSX.Element;
|
package/dist/types/ui/index.d.ts
CHANGED
|
@@ -3,4 +3,6 @@ export { TextField } from './create-form/textfield';
|
|
|
3
3
|
export { CreateForm } from './create-form/main';
|
|
4
4
|
export { CreateFormLoader } from './create-form/form-loader';
|
|
5
5
|
export type { CreateFormProps } from './create-form/main';
|
|
6
|
+
export { Select } from './create-form/select';
|
|
6
7
|
export { AsyncSelect } from './create-form/async-select';
|
|
8
|
+
export { FormSpy } from './create-form/form-spy';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Generates Typescript types for analytics events from analytics.spec.yaml
|
|
5
5
|
*
|
|
6
|
-
* @codegen <<SignedSource::
|
|
6
|
+
* @codegen <<SignedSource::50073590468fe2604f65d3e0b23d517b>>
|
|
7
7
|
* @codegenCommand yarn workspace @atlaskit/link-create run codegen-analytics
|
|
8
8
|
*/
|
|
9
9
|
export type PackageMetaDataType = {
|
|
@@ -30,6 +30,9 @@ export type ObjectCreatedLinkCreateAttributesType = {
|
|
|
30
30
|
objectId: string;
|
|
31
31
|
objectType: string;
|
|
32
32
|
};
|
|
33
|
+
export type ObjectCreateFailedLinkCreateAttributesType = {
|
|
34
|
+
failureType: string;
|
|
35
|
+
};
|
|
33
36
|
type AnalyticsEventAttributes = {
|
|
34
37
|
'screen.linkCreateScreen.viewed': LinkCreateScreenViewedAttributesType;
|
|
35
38
|
'ui.button.clicked.create': ButtonClickedCreateAttributesType;
|
|
@@ -37,6 +40,7 @@ type AnalyticsEventAttributes = {
|
|
|
37
40
|
'ui.modalDialog.closed.linkCreate': ModalDialogClosedLinkCreateAttributesType;
|
|
38
41
|
'operational.linkCreate.unhandledErrorCaught': LinkCreateUnhandledErrorCaughtAttributesType;
|
|
39
42
|
'track.object.created.linkCreate': ObjectCreatedLinkCreateAttributesType;
|
|
43
|
+
'track.object.createFailed.linkCreate': ObjectCreateFailedLinkCreateAttributesType;
|
|
40
44
|
};
|
|
41
45
|
declare function createEventPayload<K extends keyof AnalyticsEventAttributes>(eventKey: K, attributes: AnalyticsEventAttributes[K]): {
|
|
42
46
|
eventType: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FieldMetaState } from 'react-final-form';
|
|
2
2
|
/**
|
|
3
3
|
* This function checks if there have been changes since last submit
|
|
4
4
|
* to let a Field know if it should hide the error message until
|
|
5
5
|
* the next submit, or if it returns to the previous error state
|
|
6
6
|
*/
|
|
7
|
-
export declare const validateSubmitErrors: (meta:
|
|
7
|
+
export declare const validateSubmitErrors: (meta: FieldMetaState<any>) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CreateField } from './main';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FieldInputProps } from 'react-final-form';
|
|
3
|
+
import { Validator } from '../../common/types';
|
|
4
|
+
type FieldProps = FieldInputProps<any, HTMLElement> & {
|
|
5
|
+
fieldId: string;
|
|
6
|
+
isInvalid: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type CreateFieldProps = {
|
|
9
|
+
id?: string;
|
|
10
|
+
/** Name passed to the <Field>.*/
|
|
11
|
+
name: string;
|
|
12
|
+
label?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Optional text below the textfield explaining any requirements for a valid value.
|
|
15
|
+
* eg. "Must be 4 or more letters"
|
|
16
|
+
*/
|
|
17
|
+
validationHelpText?: string;
|
|
18
|
+
/** Validators for this field */
|
|
19
|
+
validators?: Validator[];
|
|
20
|
+
isRequired?: boolean;
|
|
21
|
+
testId: string;
|
|
22
|
+
children: (fieldProps: FieldProps) => React.ReactNode;
|
|
23
|
+
};
|
|
24
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { CreateFormProps } from './ui/index';
|
|
2
2
|
export type { LinkCreateProps, LinkCreatePlugin, LinkCreateWithModalProps, CreatePayload, } from './common/types';
|
|
3
|
-
export { default, TextField, CreateForm, AsyncSelect, CreateFormLoader, } from './ui/index';
|
|
3
|
+
export { default, TextField, CreateForm, Select, AsyncSelect, CreateFormLoader, FormSpy, } from './ui/index';
|
|
4
4
|
export { useLinkCreateCallback, LinkCreateCallbackProvider, } from './controllers/callback-context';
|
|
5
5
|
export type { Validator, ValidatorMap } from './common/types';
|
|
@@ -3,9 +3,9 @@ import { OptionType } from '@atlaskit/select';
|
|
|
3
3
|
import { AsyncSelectProps } from './types';
|
|
4
4
|
export declare const TEST_ID = "link-create-async-select";
|
|
5
5
|
/**
|
|
6
|
-
* An async select utilising the Atlaskit AsyncSelect and Field
|
|
7
|
-
* Validation is handled by the form
|
|
8
|
-
* the handleSubmit function passed to the form <Form> that
|
|
9
|
-
* of this
|
|
6
|
+
* An async select utilising the Atlaskit AsyncSelect and Field components from
|
|
7
|
+
* `@atlaskit/form`. Validation is handled by the form on form submission. Any
|
|
8
|
+
* errors returned by the handleSubmit function passed to the form <Form> that
|
|
9
|
+
* have a key matching the `name` of this field are shown below the field.
|
|
10
10
|
*/
|
|
11
|
-
export declare function AsyncSelect<T = OptionType>({
|
|
11
|
+
export declare function AsyncSelect<T = OptionType>({ id, name, label, isRequired, validators, validationHelpText, testId, defaultOption: propsDefaultValue, loadOptions, ...restProps }: AsyncSelectProps<T>): jsx.JSX.Element;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { AsyncSelectProps as AKAsyncSelectProps, OptionType } from '@atlaskit/select';
|
|
1
|
+
import { AsyncSelectProps as AKAsyncSelectProps, GroupType, OptionType } from '@atlaskit/select';
|
|
2
2
|
import { Validator } from '../../../common/types';
|
|
3
|
-
export type AsyncSelectProps<T = OptionType> = AKAsyncSelectProps<T> & {
|
|
4
|
-
/** Name passed to the <Field
|
|
3
|
+
export type AsyncSelectProps<T = OptionType> = Omit<AKAsyncSelectProps<T>, 'loadOptions'> & {
|
|
4
|
+
/** Name passed to the <Field> */
|
|
5
5
|
name: string;
|
|
6
6
|
/** This should be properly internationalization-ed */
|
|
7
7
|
label: string;
|
|
8
8
|
/**
|
|
9
|
-
* Optional text below the
|
|
9
|
+
* Optional text below the field explaining any requirements for a valid value.
|
|
10
10
|
* eg. "Must be 4 or more letters"
|
|
11
11
|
*/
|
|
12
12
|
validationHelpText?: string;
|
|
@@ -15,4 +15,9 @@ export type AsyncSelectProps<T = OptionType> = AKAsyncSelectProps<T> & {
|
|
|
15
15
|
isRequired?: boolean;
|
|
16
16
|
/** Validators for this field */
|
|
17
17
|
validators?: Validator[];
|
|
18
|
+
/**
|
|
19
|
+
* Function to options to display in async select.
|
|
20
|
+
* **WARNING** Will refetch if function changes.
|
|
21
|
+
*/
|
|
22
|
+
loadOptions?: (inputValue: string) => Promise<T[] | GroupType<T>[]>;
|
|
18
23
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type FormSpyProps<T> = {
|
|
3
|
+
children: ({ values }: {
|
|
4
|
+
values: T;
|
|
5
|
+
}) => React.ReactNode;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Lightweight wrapper around the react-final-form
|
|
9
|
+
* FormSpy component so that we can control selectively
|
|
10
|
+
* how much of the API we are commited to.
|
|
11
|
+
*/
|
|
12
|
+
export declare const FormSpy: <T extends Record<string, unknown>>({ children, }: FormSpyProps<T>) => JSX.Element;
|
|
@@ -8,6 +8,7 @@ export interface CreateFormProps<FormData> {
|
|
|
8
8
|
onCancel?: () => void;
|
|
9
9
|
isLoading?: boolean;
|
|
10
10
|
hideFooter?: boolean;
|
|
11
|
+
initialValues?: FormData;
|
|
11
12
|
}
|
|
12
13
|
export declare const TEST_ID = "link-create-form";
|
|
13
|
-
export declare const CreateForm: <FormData_1 extends Record<string, any> = {}>({ children, testId, onSubmit, onCancel, isLoading, hideFooter, }: CreateFormProps<FormData_1>) => jsx.JSX.Element;
|
|
14
|
+
export declare const CreateForm: <FormData_1 extends Record<string, any> = {}>({ children, testId, onSubmit, onCancel, isLoading, hideFooter, initialValues, }: CreateFormProps<FormData_1>) => jsx.JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Select } from './main';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
|
+
import { OptionType } from '@atlaskit/select';
|
|
4
|
+
import { SelectProps } from './types';
|
|
5
|
+
export declare const TEST_ID = "link-create-select";
|
|
6
|
+
/**
|
|
7
|
+
* A select utilising the Atlaskit Select and Field components from
|
|
8
|
+
* `@atlaskit/form`. Validation is handled by the form on form submission. Any
|
|
9
|
+
* errors returned by the handleSubmit function passed to the form <Form> that
|
|
10
|
+
* have a key matching the `name` of this field are shown below the field.
|
|
11
|
+
*/
|
|
12
|
+
export declare function Select<T = OptionType>({ id, name, label, isRequired, validators, validationHelpText, testId, ...restProps }: SelectProps<T>): jsx.JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SelectProps as AKSelectProps, OptionType } from '@atlaskit/select';
|
|
2
|
+
import { Validator } from '../../../common/types';
|
|
3
|
+
export type SelectProps<T = OptionType> = AKSelectProps<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 field 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
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
1
2
|
import { jsx } from '@emotion/react';
|
|
2
3
|
import { TextFieldProps } from './types';
|
|
3
4
|
export declare const TEST_ID = "link-create-text-field";
|
|
@@ -7,4 +8,4 @@ export declare const TEST_ID = "link-create-text-field";
|
|
|
7
8
|
* the handleSubmit function passed to the form <Form> that have a key matching the `name`
|
|
8
9
|
* of this text field are shown above the field.
|
|
9
10
|
*/
|
|
10
|
-
export declare function TextField({
|
|
11
|
+
export declare function TextField({ id, name, label, isRequired, validators, validationHelpText, testId, ...restProps }: TextFieldProps): jsx.JSX.Element;
|
|
@@ -3,4 +3,6 @@ export { TextField } from './create-form/textfield';
|
|
|
3
3
|
export { CreateForm } from './create-form/main';
|
|
4
4
|
export { CreateFormLoader } from './create-form/form-loader';
|
|
5
5
|
export type { CreateFormProps } from './create-form/main';
|
|
6
|
+
export { Select } from './create-form/select';
|
|
6
7
|
export { AsyncSelect } from './create-form/async-select';
|
|
8
|
+
export { FormSpy } from './create-form/form-spy';
|
|
@@ -7,8 +7,7 @@ import {
|
|
|
7
7
|
TextField,
|
|
8
8
|
useLinkCreateCallback,
|
|
9
9
|
Validator,
|
|
10
|
-
} from '
|
|
11
|
-
import { OptionsType } from '@atlaskit/select';
|
|
10
|
+
} from '../src';
|
|
12
11
|
|
|
13
12
|
interface pluginProps {
|
|
14
13
|
shouldThrowError?: boolean;
|
|
@@ -41,7 +40,7 @@ export function MockPluginForm({ shouldThrowError }: pluginProps) {
|
|
|
41
40
|
[],
|
|
42
41
|
);
|
|
43
42
|
|
|
44
|
-
const exampleOptions
|
|
43
|
+
const exampleOptions = [
|
|
45
44
|
{ label: 'Option 1', value: 'option-1' },
|
|
46
45
|
{ label: 'Option 2', value: 'option-2' },
|
|
47
46
|
];
|
|
@@ -54,7 +53,7 @@ export function MockPluginForm({ shouldThrowError }: pluginProps) {
|
|
|
54
53
|
return exampleOptions;
|
|
55
54
|
} catch (error) {
|
|
56
55
|
if (error instanceof Error) {
|
|
57
|
-
onFailure && onFailure(error
|
|
56
|
+
onFailure && onFailure(error);
|
|
58
57
|
}
|
|
59
58
|
return [];
|
|
60
59
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/link-create",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "The driver component of meta creation flow",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -46,7 +46,10 @@
|
|
|
46
46
|
"@atlaskit/textfield": "^5.6.0",
|
|
47
47
|
"@atlaskit/tokens": "^1.13.0",
|
|
48
48
|
"@babel/runtime": "^7.0.0",
|
|
49
|
-
"@emotion/react": "^11.7.1"
|
|
49
|
+
"@emotion/react": "^11.7.1",
|
|
50
|
+
"debounce-promise": "^3.1.2",
|
|
51
|
+
"final-form": "^4.20.1",
|
|
52
|
+
"react-final-form": "^6.5.3"
|
|
50
53
|
},
|
|
51
54
|
"peerDependencies": {
|
|
52
55
|
"react": "^16.8.0",
|
|
@@ -54,7 +57,7 @@
|
|
|
54
57
|
},
|
|
55
58
|
"devDependencies": {
|
|
56
59
|
"@af/visual-regression": "*",
|
|
57
|
-
"@atlaskit/link-test-helpers": "^
|
|
60
|
+
"@atlaskit/link-test-helpers": "^5.0.0",
|
|
58
61
|
"@atlaskit/visual-regression": "*",
|
|
59
62
|
"@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
|
|
60
63
|
"@testing-library/react": "^12.1.5",
|
package/report.api.md
CHANGED
|
@@ -18,35 +18,43 @@
|
|
|
18
18
|
/// <reference types="react" />
|
|
19
19
|
|
|
20
20
|
import { AsyncSelectProps as AsyncSelectProps_2 } from '@atlaskit/select';
|
|
21
|
+
import { GroupType } from '@atlaskit/select';
|
|
21
22
|
import { jsx } from '@emotion/react';
|
|
22
23
|
import { MemoExoticComponent } from 'react';
|
|
23
24
|
import { ModalDialogProps } from '@atlaskit/modal-dialog';
|
|
24
25
|
import { OptionType } from '@atlaskit/select';
|
|
25
26
|
import { default as React_2 } from 'react';
|
|
26
27
|
import { ReactNode } from 'react';
|
|
28
|
+
import { SelectProps as SelectProps_2 } from '@atlaskit/select';
|
|
27
29
|
import { SpinnerProps } from '@atlaskit/spinner';
|
|
28
30
|
import { TextFieldProps as TextFieldProps_2 } from '@atlaskit/textfield';
|
|
29
31
|
|
|
30
32
|
// @public
|
|
31
33
|
export function AsyncSelect<T = OptionType>({
|
|
32
|
-
|
|
34
|
+
id,
|
|
33
35
|
name,
|
|
34
|
-
|
|
36
|
+
label,
|
|
35
37
|
isRequired,
|
|
36
|
-
testId,
|
|
37
38
|
validators,
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
validationHelpText,
|
|
40
|
+
testId,
|
|
41
|
+
defaultOption: propsDefaultValue,
|
|
42
|
+
loadOptions,
|
|
43
|
+
...restProps
|
|
40
44
|
}: AsyncSelectProps<T>): jsx.JSX.Element;
|
|
41
45
|
|
|
42
46
|
// @public (undocumented)
|
|
43
|
-
type AsyncSelectProps<T = OptionType> =
|
|
47
|
+
type AsyncSelectProps<T = OptionType> = Omit<
|
|
48
|
+
AsyncSelectProps_2<T>,
|
|
49
|
+
'loadOptions'
|
|
50
|
+
> & {
|
|
44
51
|
name: string;
|
|
45
52
|
label: string;
|
|
46
53
|
validationHelpText?: string;
|
|
47
54
|
testId?: string;
|
|
48
55
|
isRequired?: boolean;
|
|
49
56
|
validators?: Validator[];
|
|
57
|
+
loadOptions?: (inputValue: string) => Promise<GroupType<T>[] | T[]>;
|
|
50
58
|
};
|
|
51
59
|
|
|
52
60
|
// @public (undocumented)
|
|
@@ -63,6 +71,7 @@ export const CreateForm: <FormData_1 extends Record<string, any> = {}>({
|
|
|
63
71
|
onCancel,
|
|
64
72
|
isLoading,
|
|
65
73
|
hideFooter,
|
|
74
|
+
initialValues,
|
|
66
75
|
}: CreateFormProps<FormData_1>) => jsx.JSX.Element;
|
|
67
76
|
|
|
68
77
|
// @public (undocumented)
|
|
@@ -77,6 +86,8 @@ export interface CreateFormProps<FormData> {
|
|
|
77
86
|
// (undocumented)
|
|
78
87
|
hideFooter?: boolean;
|
|
79
88
|
// (undocumented)
|
|
89
|
+
initialValues?: FormData;
|
|
90
|
+
// (undocumented)
|
|
80
91
|
isLoading?: boolean;
|
|
81
92
|
// (undocumented)
|
|
82
93
|
onCancel?: () => void;
|
|
@@ -94,6 +105,16 @@ export type CreatePayload = {
|
|
|
94
105
|
data?: Record<string, unknown>;
|
|
95
106
|
};
|
|
96
107
|
|
|
108
|
+
// @public
|
|
109
|
+
export const FormSpy: <T extends Record<string, unknown>>({
|
|
110
|
+
children,
|
|
111
|
+
}: FormSpyProps<T>) => JSX.Element;
|
|
112
|
+
|
|
113
|
+
// @public (undocumented)
|
|
114
|
+
type FormSpyProps<T> = {
|
|
115
|
+
children: ({ values }: { values: T }) => React_2.ReactNode;
|
|
116
|
+
};
|
|
117
|
+
|
|
97
118
|
// @public (undocumented)
|
|
98
119
|
interface Group {
|
|
99
120
|
icon: string;
|
|
@@ -108,7 +129,7 @@ export const LinkCreateCallbackProvider: React_2.FC<LinkCreateCallbackProviderPr
|
|
|
108
129
|
interface LinkCreateCallbackProviderProps {
|
|
109
130
|
onCancel?: () => void;
|
|
110
131
|
onCreate?: (result: CreatePayload) => Promise<void> | void;
|
|
111
|
-
onFailure?: (
|
|
132
|
+
onFailure?: (error: Error) => void;
|
|
112
133
|
}
|
|
113
134
|
|
|
114
135
|
// @public (undocumented)
|
|
@@ -142,14 +163,36 @@ export interface LinkCreateWithModalProps
|
|
|
142
163
|
}
|
|
143
164
|
|
|
144
165
|
// @public
|
|
145
|
-
export function
|
|
146
|
-
|
|
166
|
+
export function Select<T = OptionType>({
|
|
167
|
+
id,
|
|
147
168
|
name,
|
|
148
|
-
|
|
149
|
-
|
|
169
|
+
label,
|
|
170
|
+
isRequired,
|
|
150
171
|
validators,
|
|
151
|
-
|
|
172
|
+
validationHelpText,
|
|
173
|
+
testId,
|
|
174
|
+
...restProps
|
|
175
|
+
}: SelectProps<T>): jsx.JSX.Element;
|
|
176
|
+
|
|
177
|
+
// @public (undocumented)
|
|
178
|
+
type SelectProps<T = OptionType> = SelectProps_2<T> & {
|
|
179
|
+
name: string;
|
|
180
|
+
label: string;
|
|
181
|
+
validationHelpText?: string;
|
|
182
|
+
testId?: string;
|
|
183
|
+
isRequired?: boolean;
|
|
184
|
+
validators?: Validator[];
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
// @public
|
|
188
|
+
export function TextField({
|
|
189
|
+
id,
|
|
190
|
+
name,
|
|
191
|
+
label,
|
|
152
192
|
isRequired,
|
|
193
|
+
validators,
|
|
194
|
+
validationHelpText,
|
|
195
|
+
testId,
|
|
153
196
|
...restProps
|
|
154
197
|
}: TextFieldProps): jsx.JSX.Element;
|
|
155
198
|
|