@atlaskit/link-create 0.8.1 → 0.8.2

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/link-create
2
2
 
3
+ ## 0.8.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`90ad796d91c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/90ad796d91c) - Fix fetching hyphened locales to underscores
8
+
3
9
  ## 0.8.1
4
10
 
5
11
  ### Patch Changes
@@ -25,7 +25,7 @@ var fetchMessagesForLocale = /*#__PURE__*/function () {
25
25
  }).then(function (s) {
26
26
  return _interopRequireWildcard(require(s));
27
27
  });
28
- }( /* webpackChunkName: "@atlaskit-internal_@atlassian/link-create-confluence-i18n-[request]" */"../../../i18n/".concat(locale));
28
+ }( /* webpackChunkName: "@atlaskit-internal_@atlassian/link-create-confluence-i18n-[request]" */"../../../i18n/".concat(locale.replace('-', '_')));
29
29
  case 3:
30
30
  _messages = _context.sent;
31
31
  return _context.abrupt("return", _messages.default);
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-create",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "sideEffects": false
5
5
  }
@@ -1,7 +1,7 @@
1
1
  import messages from '../../../i18n/en';
2
2
  export const fetchMessagesForLocale = async locale => {
3
3
  try {
4
- const messages = await import( /* webpackChunkName: "@atlaskit-internal_@atlassian/link-create-confluence-i18n-[request]" */`../../../i18n/${locale}`);
4
+ const messages = await import( /* webpackChunkName: "@atlaskit-internal_@atlassian/link-create-confluence-i18n-[request]" */`../../../i18n/${locale.replace('-', '_')}`);
5
5
  return messages.default;
6
6
  } catch (e) {
7
7
  // ignore
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-create",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "sideEffects": false
5
5
  }
@@ -9,7 +9,7 @@ export var fetchMessagesForLocale = /*#__PURE__*/function () {
9
9
  case 0:
10
10
  _context.prev = 0;
11
11
  _context.next = 3;
12
- return import( /* webpackChunkName: "@atlaskit-internal_@atlassian/link-create-confluence-i18n-[request]" */"../../../i18n/".concat(locale));
12
+ return import( /* webpackChunkName: "@atlaskit-internal_@atlassian/link-create-confluence-i18n-[request]" */"../../../i18n/".concat(locale.replace('-', '_')));
13
13
  case 3:
14
14
  _messages = _context.sent;
15
15
  return _context.abrupt("return", _messages.default);
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-create",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "sideEffects": false
5
5
  }
@@ -0,0 +1,91 @@
1
+ import React, { useMemo } from 'react';
2
+
3
+ import {
4
+ AsyncSelect,
5
+ CreateForm,
6
+ CreateFormProps,
7
+ TextField,
8
+ useLinkCreateCallback,
9
+ Validator,
10
+ } from '@atlaskit/link-create';
11
+ import { OptionsType } from '@atlaskit/select';
12
+
13
+ interface pluginProps {
14
+ shouldThrowError?: boolean;
15
+ }
16
+
17
+ export function MockPluginForm({ shouldThrowError }: pluginProps) {
18
+ const { onCreate, onFailure, onCancel } = useLinkCreateCallback();
19
+
20
+ type MockOptions = {
21
+ label: string;
22
+ value: string;
23
+ };
24
+
25
+ const mockHandleSubmit = async () => {
26
+ if (onCreate) {
27
+ await onCreate({
28
+ url: 'https://atlassian.com/product/new-object-id',
29
+ objectId: 'new-object-id',
30
+ objectType: 'object-type',
31
+ data: {},
32
+ });
33
+ }
34
+ };
35
+
36
+ const mockValidator: Validator = useMemo(
37
+ () => ({
38
+ isValid: (val: unknown) => !!val,
39
+ errorMessage: 'Validation Error: You need to provide a value.',
40
+ }),
41
+ [],
42
+ );
43
+
44
+ const exampleOptions: OptionsType<MockOptions> = [
45
+ { label: 'Option 1', value: 'option-1' },
46
+ { label: 'Option 2', value: 'option-2' },
47
+ ];
48
+
49
+ const mockLoadOptions = async () => {
50
+ try {
51
+ if (shouldThrowError) {
52
+ throw new Error('This is an error message.');
53
+ }
54
+ return exampleOptions;
55
+ } catch (error) {
56
+ if (error instanceof Error) {
57
+ onFailure && onFailure(error.message);
58
+ }
59
+ return [];
60
+ }
61
+ };
62
+
63
+ return (
64
+ <div>
65
+ This is a mocked plugin.
66
+ <CreateForm<CreateFormProps<FormData>>
67
+ onSubmit={mockHandleSubmit}
68
+ onCancel={onCancel}
69
+ >
70
+ <TextField
71
+ name={'textField-name'}
72
+ label={'Enter some Text'}
73
+ placeholder={'Type something here...'}
74
+ validators={[mockValidator]}
75
+ autoFocus
76
+ maxLength={255}
77
+ />
78
+ <AsyncSelect<MockOptions>
79
+ isRequired
80
+ isSearchable
81
+ name={'asyncSelect-name'}
82
+ label={'Select an Option'}
83
+ validators={[mockValidator]}
84
+ defaultOptions={true}
85
+ defaultOption={mockLoadOptions}
86
+ loadOptions={mockLoadOptions}
87
+ ></AsyncSelect>
88
+ </CreateForm>
89
+ </div>
90
+ );
91
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/link-create",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "description": "The driver component of meta creation flow",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -1,136 +0,0 @@
1
- ## API Report File for "@atlaskit/link-create"
2
-
3
- > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
-
5
- ```ts
6
-
7
- /// <reference types="react" />
8
-
9
- import { AsyncSelectProps as AsyncSelectProps_2 } from '@atlaskit/select';
10
- import { jsx } from '@emotion/react';
11
- import { MemoExoticComponent } from 'react';
12
- import { ModalDialogProps } from '@atlaskit/modal-dialog';
13
- import { OptionType } from '@atlaskit/select';
14
- import { default as React_2 } from 'react';
15
- import { ReactNode } from 'react';
16
- import { SpinnerProps } from '@atlaskit/spinner';
17
- import { TextFieldProps as TextFieldProps_2 } from '@atlaskit/textfield';
18
-
19
- // @public
20
- export function AsyncSelect<T = OptionType>({ label, name, validationHelpText, isRequired, testId, validators, defaultValue, ...rest }: AsyncSelectProps<T>): jsx.JSX.Element;
21
-
22
- // @public (undocumented)
23
- type AsyncSelectProps<T = OptionType> = AsyncSelectProps_2<T> & {
24
- name: string;
25
- label: string;
26
- validationHelpText?: string;
27
- testId?: string;
28
- isRequired?: boolean;
29
- validators?: Validator[];
30
- };
31
-
32
- // @public (undocumented)
33
- const ComposedLinkCreate: MemoExoticComponent<(props: LinkCreateWithModalProps) => jsx.JSX.Element>;
34
- export default ComposedLinkCreate;
35
-
36
- // @public (undocumented)
37
- export const CreateForm: <FormData_1 extends Record<string, any> = {}>({ children, testId, onSubmit, onCancel, isLoading, hideFooter, }: CreateFormProps<FormData_1>) => jsx.JSX.Element;
38
-
39
- // @public (undocumented)
40
- export function CreateFormLoader({ size }: Partial<SpinnerProps>): jsx.JSX.Element;
41
-
42
- // @public (undocumented)
43
- export interface CreateFormProps<FormData> {
44
- // (undocumented)
45
- children: ReactNode;
46
- // (undocumented)
47
- hideFooter?: boolean;
48
- // (undocumented)
49
- isLoading?: boolean;
50
- // (undocumented)
51
- onCancel?: () => void;
52
- // (undocumented)
53
- onSubmit: (data: FormData) => void;
54
- // (undocumented)
55
- testId?: string;
56
- }
57
-
58
- // @public
59
- export type CreatePayload = {
60
- url: string;
61
- objectId: string;
62
- objectType: string;
63
- data?: Record<string, unknown>;
64
- };
65
-
66
- // @public (undocumented)
67
- interface Group {
68
- icon: string;
69
- key: string;
70
- label: string;
71
- }
72
-
73
- // @public (undocumented)
74
- export const LinkCreateCallbackProvider: React_2.FC<LinkCreateCallbackProviderProps>;
75
-
76
- // @public (undocumented)
77
- interface LinkCreateCallbackProviderProps {
78
- onCancel?: () => void;
79
- onCreate?: (result: CreatePayload) => Promise<void> | void;
80
- onFailure?: (errorMessage: string) => void;
81
- }
82
-
83
- // @public (undocumented)
84
- export interface LinkCreatePlugin {
85
- form: ReactNode;
86
- group: Group;
87
- icon: string;
88
- key: string;
89
- label: string;
90
- }
91
-
92
- // @public (undocumented)
93
- export interface LinkCreateProps {
94
- entityKey: string;
95
- groupKey?: string;
96
- onCancel?: () => void;
97
- onCreate?: (payload: CreatePayload) => Promise<void> | void;
98
- onFailure?: (error: unknown) => void;
99
- // (undocumented)
100
- plugins: LinkCreatePlugin[];
101
- testId?: string;
102
- triggeredFrom?: string;
103
- }
104
-
105
- // @public (undocumented)
106
- export interface LinkCreateWithModalProps extends LinkCreateProps, Partial<Pick<ModalDialogProps, 'onCloseComplete' | 'onOpenComplete'>> {
107
- active?: boolean;
108
- modalTitle?: string;
109
- }
110
-
111
- // @public
112
- export function TextField({ label, name, validationHelpText, validators, defaultValue, isRequired, ...restProps }: TextFieldProps): jsx.JSX.Element;
113
-
114
- // @public (undocumented)
115
- type TextFieldProps = Omit<TextFieldProps_2, 'name'> & {
116
- name: string;
117
- label?: string;
118
- validationHelpText?: string;
119
- validators?: Validator[];
120
- };
121
-
122
- // @public (undocumented)
123
- export const useLinkCreateCallback: () => LinkCreateCallbackProviderProps;
124
-
125
- // @public (undocumented)
126
- export type Validator = {
127
- isValid: (val: unknown) => boolean;
128
- errorMessage: string;
129
- };
130
-
131
- // @public
132
- export type ValidatorMap = Record<string, Validator[]>;
133
-
134
- // (No @packageDocumentation comment for this package)
135
-
136
- ```