@atlaskit/link-create 2.11.5 → 2.12.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 +20 -0
- package/dist/cjs/common/constants.js +1 -1
- package/dist/cjs/common/ui/Button/index.js +1 -1
- package/dist/cjs/common/ui/ModalDialog/index.js +1 -1
- package/dist/cjs/common/ui/error-boundary/error-boundary-base/index.js +1 -1
- package/dist/cjs/common/ui/error-boundary/index.js +1 -1
- package/dist/cjs/common/ui/error-boundary-modal/index.js +1 -1
- package/dist/cjs/common/ui/experience-tracker/index.js +1 -1
- package/dist/cjs/common/ui/link-create-content/index.js +1 -1
- package/dist/cjs/common/ui/message/index.js +81 -0
- package/dist/cjs/common/ui/modal-hero/index.js +1 -1
- package/dist/cjs/common/utils/analytics/context.js +1 -1
- package/dist/cjs/common/utils/locale/fetch-messages-for-locale.js +1 -1
- package/dist/cjs/controllers/callback-context/main.js +1 -1
- package/dist/cjs/controllers/create-field/main.js +31 -10
- package/dist/cjs/controllers/edit-post-create-context/index.js +1 -1
- package/dist/cjs/controllers/exit-warning-modal-context/index.js +1 -1
- package/dist/cjs/controllers/form-context/main.js +1 -1
- package/dist/cjs/controllers/plugin-context/index.js +1 -1
- package/dist/cjs/index.js +8 -1
- package/dist/cjs/ui/create-form/async-select/main.js +13 -1
- package/dist/cjs/ui/create-form/form-footer/main.js +1 -0
- package/dist/cjs/ui/create-form/main.js +9 -4
- package/dist/cjs/ui/create-form/select/main.js +10 -2
- package/dist/cjs/ui/create-form/textfield/main.js +6 -0
- package/dist/cjs/ui/create-form/user-picker/main.js +4 -2
- package/dist/es2019/common/constants.js +1 -1
- package/dist/es2019/common/ui/message/index.js +74 -0
- package/dist/es2019/controllers/create-field/main.js +27 -4
- package/dist/es2019/index.js +2 -1
- package/dist/es2019/ui/create-form/async-select/main.js +12 -0
- package/dist/es2019/ui/create-form/form-footer/main.js +1 -0
- package/dist/es2019/ui/create-form/main.js +8 -3
- package/dist/es2019/ui/create-form/select/main.js +8 -0
- package/dist/es2019/ui/create-form/textfield/main.js +6 -0
- package/dist/es2019/ui/create-form/user-picker/main.js +3 -1
- package/dist/esm/common/constants.js +1 -1
- package/dist/esm/common/ui/error-boundary/error-boundary-base/index.js +1 -1
- package/dist/esm/common/ui/message/index.js +73 -0
- package/dist/esm/controllers/create-field/main.js +25 -3
- package/dist/esm/index.js +2 -1
- package/dist/esm/ui/create-form/async-select/main.js +13 -1
- package/dist/esm/ui/create-form/form-footer/main.js +1 -0
- package/dist/esm/ui/create-form/main.js +9 -4
- package/dist/esm/ui/create-form/select/main.js +9 -1
- package/dist/esm/ui/create-form/textfield/main.js +6 -0
- package/dist/esm/ui/create-form/user-picker/main.js +4 -2
- package/dist/types/common/ui/message/index.d.ts +15 -0
- package/dist/types/controllers/create-field/main.d.ts +0 -4
- package/dist/types/controllers/create-field/types.d.ts +5 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/ui/create-form/select/main.d.ts +1 -1
- package/dist/types-ts4.5/common/ui/message/index.d.ts +15 -0
- package/dist/types-ts4.5/controllers/create-field/main.d.ts +0 -4
- package/dist/types-ts4.5/controllers/create-field/types.d.ts +5 -0
- package/dist/types-ts4.5/index.d.ts +1 -0
- package/dist/types-ts4.5/ui/create-form/select/main.d.ts +1 -1
- package/package.json +13 -14
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
7
|
+
import { css, jsx } from '@emotion/react';
|
|
8
|
+
import SuccessIcon from '@atlaskit/icon/utility/check-circle';
|
|
9
|
+
import ErrorIcon from '@atlaskit/icon/utility/error';
|
|
10
|
+
import { Box, xcss } from '@atlaskit/primitives';
|
|
11
|
+
const messageStyles = xcss({
|
|
12
|
+
display: 'flex',
|
|
13
|
+
justifyContent: 'baseline',
|
|
14
|
+
gap: 'space.050',
|
|
15
|
+
font: "var(--ds-font-body-UNSAFE_small, normal 400 12px/16px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
|
|
16
|
+
marginBlockStart: 'space.050'
|
|
17
|
+
});
|
|
18
|
+
const messageAppearanceStyles = {
|
|
19
|
+
default: xcss({
|
|
20
|
+
color: 'color.text.subtlest'
|
|
21
|
+
}),
|
|
22
|
+
error: xcss({
|
|
23
|
+
color: 'color.text.danger'
|
|
24
|
+
}),
|
|
25
|
+
valid: xcss({
|
|
26
|
+
color: 'color.text.success'
|
|
27
|
+
})
|
|
28
|
+
};
|
|
29
|
+
const iconWrapperStyles = css({
|
|
30
|
+
display: 'flex',
|
|
31
|
+
alignItems: 'center',
|
|
32
|
+
marginInlineStart: "var(--ds-space-025, 2px)",
|
|
33
|
+
marginInlineEnd: "var(--ds-space-025, 2px)"
|
|
34
|
+
});
|
|
35
|
+
const IconWrapper = ({
|
|
36
|
+
children
|
|
37
|
+
}) => {
|
|
38
|
+
return jsx("span", {
|
|
39
|
+
css: iconWrapperStyles
|
|
40
|
+
}, children);
|
|
41
|
+
};
|
|
42
|
+
const messageIcons = {
|
|
43
|
+
error: jsx(ErrorIcon, {
|
|
44
|
+
color: "var(--ds-text-danger, #AE2A19)",
|
|
45
|
+
label: "error"
|
|
46
|
+
}),
|
|
47
|
+
valid: jsx(SuccessIcon, {
|
|
48
|
+
color: "var(--ds-text-success, #216E4E)",
|
|
49
|
+
label: "success"
|
|
50
|
+
})
|
|
51
|
+
};
|
|
52
|
+
export const Message = ({
|
|
53
|
+
children,
|
|
54
|
+
appearance = 'default',
|
|
55
|
+
id,
|
|
56
|
+
testId
|
|
57
|
+
}) => {
|
|
58
|
+
const icon = messageIcons[appearance];
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The wrapping span is necessary to preserve spaces between children.
|
|
62
|
+
* Otherwise the flex layout of the message will remove any whitespace
|
|
63
|
+
* between children.
|
|
64
|
+
*
|
|
65
|
+
* If the child is just a string, this is not required and we can use one
|
|
66
|
+
* less DOM element.
|
|
67
|
+
*/
|
|
68
|
+
const content = typeof children === 'string' ? children : jsx("span", null, children);
|
|
69
|
+
return jsx(Box, {
|
|
70
|
+
xcss: [messageStyles, messageAppearanceStyles[appearance]],
|
|
71
|
+
testId: testId,
|
|
72
|
+
id: id
|
|
73
|
+
}, icon && jsx(IconWrapper, null, icon), content);
|
|
74
|
+
};
|
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
* @jsxRuntime classic
|
|
3
3
|
* @jsx jsx
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
import { Fragment } from 'react';
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
|
|
6
8
|
import { css, jsx } from '@emotion/react';
|
|
7
9
|
import { Field } from 'react-final-form';
|
|
8
10
|
import { ErrorMessage, HelperMessage, Label, RequiredAsterisk } from '@atlaskit/form';
|
|
11
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
|
+
import { Message } from '../../common/ui/message';
|
|
9
13
|
import { shouldShowValidationErrors } from '../../common/utils/form';
|
|
10
14
|
const fieldWrapperStyles = css({
|
|
11
15
|
marginTop: "var(--ds-space-100, 8px)"
|
|
@@ -39,6 +43,10 @@ export function CreateField({
|
|
|
39
43
|
error
|
|
40
44
|
} = meta;
|
|
41
45
|
const hasError = !!submitError || !!error;
|
|
46
|
+
const showErrorMessage = hasError && isInvalid;
|
|
47
|
+
const describedById = `${fieldId}-description`;
|
|
48
|
+
const errorMessageId = `${fieldId}-error`;
|
|
49
|
+
const ariaErrorMessage = showErrorMessage ? errorMessageId : undefined;
|
|
42
50
|
return jsx("div", {
|
|
43
51
|
css: fieldWrapperStyles,
|
|
44
52
|
"data-testid": testId
|
|
@@ -49,11 +57,26 @@ export function CreateField({
|
|
|
49
57
|
}, label, isRequired && jsx(RequiredAsterisk, null)), children({
|
|
50
58
|
...input,
|
|
51
59
|
fieldId,
|
|
52
|
-
isInvalid
|
|
53
|
-
|
|
60
|
+
isInvalid,
|
|
61
|
+
...(fg('linking-platform-create-field-error-association') ? {
|
|
62
|
+
isRequired,
|
|
63
|
+
'aria-errormessage': ariaErrorMessage,
|
|
64
|
+
'aria-describedby': describedById
|
|
65
|
+
} : {})
|
|
66
|
+
}), fg('linking-platform-create-field-error-association') ? jsx("div", {
|
|
67
|
+
id: describedById
|
|
68
|
+
}, !hasError && validationHelpText && jsx(Message, {
|
|
69
|
+
testId: `${testId}-helper-message`
|
|
70
|
+
}, validationHelpText), jsx("div", {
|
|
71
|
+
"aria-live": "polite"
|
|
72
|
+
}, showErrorMessage && jsx(Message, {
|
|
73
|
+
id: errorMessageId,
|
|
74
|
+
appearance: "error",
|
|
75
|
+
testId: `${testId}-error-message`
|
|
76
|
+
}, submitError || error))) : jsx(Fragment, null, !hasError && validationHelpText && jsx(HelperMessage, {
|
|
54
77
|
testId: `${testId}-helper-message`
|
|
55
78
|
}, validationHelpText), hasError && isInvalid && jsx(ErrorMessage, {
|
|
56
79
|
testId: `${testId}-error-message`
|
|
57
|
-
}, submitError || error));
|
|
80
|
+
}, submitError || error)));
|
|
58
81
|
});
|
|
59
82
|
}
|
package/dist/es2019/index.js
CHANGED
|
@@ -2,4 +2,5 @@ export { AsyncSelect, CreateForm, CreateFormLoader, FormSpy, Select, SiteSelect,
|
|
|
2
2
|
export { LinkCreateCallbackProvider, useLinkCreateCallback } from './controllers/callback-context';
|
|
3
3
|
export { ExitWarningModalProvider as LinkCreateExitWarningProvider, useWithExitWarning } from './controllers/exit-warning-modal-context';
|
|
4
4
|
export { FORM_ERROR } from 'final-form';
|
|
5
|
-
export { PageIcon, UrlIcon } from './common/ui/icon';
|
|
5
|
+
export { PageIcon, UrlIcon } from './common/ui/icon';
|
|
6
|
+
export { CreateField } from './controllers/create-field/index';
|
|
@@ -10,6 +10,7 @@ import { jsx } from '@emotion/react';
|
|
|
10
10
|
import debounce from 'debounce-promise';
|
|
11
11
|
import { useForm } from 'react-final-form';
|
|
12
12
|
import { useIntl } from 'react-intl-next';
|
|
13
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
14
|
import { AsyncSelect as AkAsyncSelect } from '@atlaskit/select';
|
|
14
15
|
import messages from '../../../common/messages';
|
|
15
16
|
import { useLinkCreateCallback } from '../../../controllers/callback-context';
|
|
@@ -120,8 +121,19 @@ export function AsyncSelect({
|
|
|
120
121
|
testId: testId
|
|
121
122
|
}, ({
|
|
122
123
|
fieldId,
|
|
124
|
+
isRequired,
|
|
123
125
|
...fieldProps
|
|
124
126
|
}) => {
|
|
127
|
+
if (fg('linking-platform-create-field-error-association')) {
|
|
128
|
+
return jsx(AkAsyncSelect, _extends({
|
|
129
|
+
inputId: fieldId
|
|
130
|
+
}, fieldProps, restProps, {
|
|
131
|
+
required: isRequired,
|
|
132
|
+
loadOptions: debouncedLoadOptions,
|
|
133
|
+
defaultOptions: defaultOptions,
|
|
134
|
+
isLoading: isLoadingDefaultOptions
|
|
135
|
+
}));
|
|
136
|
+
}
|
|
125
137
|
return jsx(AkAsyncSelect, _extends({
|
|
126
138
|
inputId: fieldId
|
|
127
139
|
}, fieldProps, restProps, {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
/**
|
|
2
3
|
* @jsxRuntime classic
|
|
3
4
|
* @jsx jsx
|
|
@@ -10,6 +11,7 @@ import { FORM_ERROR } from 'final-form';
|
|
|
10
11
|
import { Form, FormSpy } from 'react-final-form';
|
|
11
12
|
import { useIntl } from 'react-intl-next';
|
|
12
13
|
import { RequiredAsterisk } from '@atlaskit/form';
|
|
14
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
15
|
import { Box } from '@atlaskit/primitives';
|
|
14
16
|
import { CREATE_FORM_MAX_WIDTH_IN_PX, LINK_CREATE_FORM_POST_CREATE_FIELD } from '../../common/constants';
|
|
15
17
|
import messages from '../../common/messages';
|
|
@@ -108,12 +110,15 @@ export const CreateForm = ({
|
|
|
108
110
|
submitError,
|
|
109
111
|
...formProps
|
|
110
112
|
}) => {
|
|
111
|
-
return jsx("form", {
|
|
113
|
+
return jsx("form", _extends({
|
|
112
114
|
onSubmit: formProps.handleSubmit,
|
|
113
|
-
name: "link-create-form"
|
|
115
|
+
name: "link-create-form"
|
|
116
|
+
}, fg('linking-platform-create-field-error-association') ? {
|
|
117
|
+
noValidate: true
|
|
118
|
+
} : {}, {
|
|
114
119
|
"data-testid": testId,
|
|
115
120
|
css: formStyles
|
|
116
|
-
}, jsx(FormSpy, {
|
|
121
|
+
}), jsx(FormSpy, {
|
|
117
122
|
subscription: {
|
|
118
123
|
modified: true
|
|
119
124
|
},
|
|
@@ -7,6 +7,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
7
7
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
8
8
|
import { jsx } from '@emotion/react';
|
|
9
9
|
import { useIntl } from 'react-intl-next';
|
|
10
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
11
|
import { Inline } from '@atlaskit/primitives';
|
|
11
12
|
import AkSelect, { components } from '@atlaskit/select';
|
|
12
13
|
import { layers } from '@atlaskit/theme/constants';
|
|
@@ -41,8 +42,15 @@ export function Select({
|
|
|
41
42
|
testId: testId
|
|
42
43
|
}, ({
|
|
43
44
|
fieldId,
|
|
45
|
+
isRequired,
|
|
44
46
|
...fieldProps
|
|
45
47
|
}) => {
|
|
48
|
+
if (fg('linking-platform-create-field-error-association')) {
|
|
49
|
+
return jsx(AkSelect, _extends({
|
|
50
|
+
required: isRequired,
|
|
51
|
+
inputId: fieldId
|
|
52
|
+
}, fieldProps, restProps));
|
|
53
|
+
}
|
|
46
54
|
return jsx(AkSelect, _extends({
|
|
47
55
|
inputId: fieldId
|
|
48
56
|
}, fieldProps, restProps));
|
|
@@ -5,6 +5,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
5
5
|
*/
|
|
6
6
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
7
7
|
import { jsx } from '@emotion/react';
|
|
8
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
9
|
import AkTextfield from '@atlaskit/textfield';
|
|
9
10
|
import { CreateField } from '../../../controllers/create-field';
|
|
10
11
|
export const TEST_ID = 'link-create-text-field';
|
|
@@ -38,6 +39,11 @@ export function TextField({
|
|
|
38
39
|
fieldId,
|
|
39
40
|
...fieldProps
|
|
40
41
|
}) => {
|
|
42
|
+
if (fg('linking-platform-create-field-error-association')) {
|
|
43
|
+
return jsx(AkTextfield, _extends({
|
|
44
|
+
id: fieldId
|
|
45
|
+
}, fieldProps, restProps));
|
|
46
|
+
}
|
|
41
47
|
return jsx(AkTextfield, _extends({
|
|
42
48
|
id: fieldId
|
|
43
49
|
}, fieldProps, restProps, {
|
|
@@ -32,6 +32,7 @@ export function UserPicker({
|
|
|
32
32
|
validators: validators
|
|
33
33
|
}, ({
|
|
34
34
|
fieldId,
|
|
35
|
+
isRequired,
|
|
35
36
|
...fieldProps
|
|
36
37
|
}) => {
|
|
37
38
|
return jsx(SmartUserPicker, {
|
|
@@ -50,7 +51,8 @@ export function UserPicker({
|
|
|
50
51
|
debounceTime: DEFAULT_DEBOUNCE_TIME,
|
|
51
52
|
prefetch: true,
|
|
52
53
|
isClearable: false,
|
|
53
|
-
width: UserPickerWidth
|
|
54
|
+
width: UserPickerWidth,
|
|
55
|
+
required: isRequired
|
|
54
56
|
});
|
|
55
57
|
});
|
|
56
58
|
}
|
|
@@ -7,7 +7,7 @@ export var CREATE_FORM_MIN_HEIGHT_IN_PX = '200';
|
|
|
7
7
|
export var LINK_CREATE_FORM_POST_CREATE_FIELD = '__post_create__';
|
|
8
8
|
export var PACKAGE_DATA = {
|
|
9
9
|
packageName: "@atlaskit/link-create" || '',
|
|
10
|
-
packageVersion: "2.
|
|
10
|
+
packageVersion: "2.12.0" || '',
|
|
11
11
|
component: COMPONENT_NAME,
|
|
12
12
|
componentName: COMPONENT_NAME
|
|
13
13
|
};
|
|
@@ -3,7 +3,7 @@ import _createClass from "@babel/runtime/helpers/createClass";
|
|
|
3
3
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
5
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
-
function _createSuper(
|
|
6
|
+
function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
|
|
7
7
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
8
8
|
import { Component } from 'react';
|
|
9
9
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
7
|
+
import { css, jsx } from '@emotion/react';
|
|
8
|
+
import SuccessIcon from '@atlaskit/icon/utility/check-circle';
|
|
9
|
+
import ErrorIcon from '@atlaskit/icon/utility/error';
|
|
10
|
+
import { Box, xcss } from '@atlaskit/primitives';
|
|
11
|
+
var messageStyles = xcss({
|
|
12
|
+
display: 'flex',
|
|
13
|
+
justifyContent: 'baseline',
|
|
14
|
+
gap: 'space.050',
|
|
15
|
+
font: "var(--ds-font-body-UNSAFE_small, normal 400 12px/16px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
|
|
16
|
+
marginBlockStart: 'space.050'
|
|
17
|
+
});
|
|
18
|
+
var messageAppearanceStyles = {
|
|
19
|
+
default: xcss({
|
|
20
|
+
color: 'color.text.subtlest'
|
|
21
|
+
}),
|
|
22
|
+
error: xcss({
|
|
23
|
+
color: 'color.text.danger'
|
|
24
|
+
}),
|
|
25
|
+
valid: xcss({
|
|
26
|
+
color: 'color.text.success'
|
|
27
|
+
})
|
|
28
|
+
};
|
|
29
|
+
var iconWrapperStyles = css({
|
|
30
|
+
display: 'flex',
|
|
31
|
+
alignItems: 'center',
|
|
32
|
+
marginInlineStart: "var(--ds-space-025, 2px)",
|
|
33
|
+
marginInlineEnd: "var(--ds-space-025, 2px)"
|
|
34
|
+
});
|
|
35
|
+
var IconWrapper = function IconWrapper(_ref) {
|
|
36
|
+
var children = _ref.children;
|
|
37
|
+
return jsx("span", {
|
|
38
|
+
css: iconWrapperStyles
|
|
39
|
+
}, children);
|
|
40
|
+
};
|
|
41
|
+
var messageIcons = {
|
|
42
|
+
error: jsx(ErrorIcon, {
|
|
43
|
+
color: "var(--ds-text-danger, #AE2A19)",
|
|
44
|
+
label: "error"
|
|
45
|
+
}),
|
|
46
|
+
valid: jsx(SuccessIcon, {
|
|
47
|
+
color: "var(--ds-text-success, #216E4E)",
|
|
48
|
+
label: "success"
|
|
49
|
+
})
|
|
50
|
+
};
|
|
51
|
+
export var Message = function Message(_ref2) {
|
|
52
|
+
var children = _ref2.children,
|
|
53
|
+
_ref2$appearance = _ref2.appearance,
|
|
54
|
+
appearance = _ref2$appearance === void 0 ? 'default' : _ref2$appearance,
|
|
55
|
+
id = _ref2.id,
|
|
56
|
+
testId = _ref2.testId;
|
|
57
|
+
var icon = messageIcons[appearance];
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The wrapping span is necessary to preserve spaces between children.
|
|
61
|
+
* Otherwise the flex layout of the message will remove any whitespace
|
|
62
|
+
* between children.
|
|
63
|
+
*
|
|
64
|
+
* If the child is just a string, this is not required and we can use one
|
|
65
|
+
* less DOM element.
|
|
66
|
+
*/
|
|
67
|
+
var content = typeof children === 'string' ? children : jsx("span", null, children);
|
|
68
|
+
return jsx(Box, {
|
|
69
|
+
xcss: [messageStyles, messageAppearanceStyles[appearance]],
|
|
70
|
+
testId: testId,
|
|
71
|
+
id: id
|
|
72
|
+
}, icon && jsx(IconWrapper, null, icon), content);
|
|
73
|
+
};
|
|
@@ -5,10 +5,14 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
5
5
|
* @jsxRuntime classic
|
|
6
6
|
* @jsx jsx
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
import { Fragment } from 'react';
|
|
9
|
+
|
|
10
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
|
|
9
11
|
import { css, jsx } from '@emotion/react';
|
|
10
12
|
import { Field } from 'react-final-form';
|
|
11
13
|
import { ErrorMessage, HelperMessage, Label, RequiredAsterisk } from '@atlaskit/form';
|
|
14
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
|
+
import { Message } from '../../common/ui/message';
|
|
12
16
|
import { shouldShowValidationErrors } from '../../common/utils/form';
|
|
13
17
|
var fieldWrapperStyles = css({
|
|
14
18
|
marginTop: "var(--ds-space-100, 8px)"
|
|
@@ -38,6 +42,10 @@ export function CreateField(_ref) {
|
|
|
38
42
|
var submitError = meta.submitError,
|
|
39
43
|
error = meta.error;
|
|
40
44
|
var hasError = !!submitError || !!error;
|
|
45
|
+
var showErrorMessage = hasError && isInvalid;
|
|
46
|
+
var describedById = "".concat(fieldId, "-description");
|
|
47
|
+
var errorMessageId = "".concat(fieldId, "-error");
|
|
48
|
+
var ariaErrorMessage = showErrorMessage ? errorMessageId : undefined;
|
|
41
49
|
return jsx("div", {
|
|
42
50
|
css: fieldWrapperStyles,
|
|
43
51
|
"data-testid": testId
|
|
@@ -48,10 +56,24 @@ export function CreateField(_ref) {
|
|
|
48
56
|
}, label, isRequired && jsx(RequiredAsterisk, null)), children(_objectSpread(_objectSpread({}, input), {}, {
|
|
49
57
|
fieldId: fieldId,
|
|
50
58
|
isInvalid: isInvalid
|
|
51
|
-
}
|
|
59
|
+
}, fg('linking-platform-create-field-error-association') ? {
|
|
60
|
+
isRequired: isRequired,
|
|
61
|
+
'aria-errormessage': ariaErrorMessage,
|
|
62
|
+
'aria-describedby': describedById
|
|
63
|
+
} : {})), fg('linking-platform-create-field-error-association') ? jsx("div", {
|
|
64
|
+
id: describedById
|
|
65
|
+
}, !hasError && validationHelpText && jsx(Message, {
|
|
66
|
+
testId: "".concat(testId, "-helper-message")
|
|
67
|
+
}, validationHelpText), jsx("div", {
|
|
68
|
+
"aria-live": "polite"
|
|
69
|
+
}, showErrorMessage && jsx(Message, {
|
|
70
|
+
id: errorMessageId,
|
|
71
|
+
appearance: "error",
|
|
72
|
+
testId: "".concat(testId, "-error-message")
|
|
73
|
+
}, submitError || error))) : jsx(Fragment, null, !hasError && validationHelpText && jsx(HelperMessage, {
|
|
52
74
|
testId: "".concat(testId, "-helper-message")
|
|
53
75
|
}, validationHelpText), hasError && isInvalid && jsx(ErrorMessage, {
|
|
54
76
|
testId: "".concat(testId, "-error-message")
|
|
55
|
-
}, submitError || error));
|
|
77
|
+
}, submitError || error)));
|
|
56
78
|
});
|
|
57
79
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -2,4 +2,5 @@ export { AsyncSelect, CreateForm, CreateFormLoader, FormSpy, Select, SiteSelect,
|
|
|
2
2
|
export { LinkCreateCallbackProvider, useLinkCreateCallback } from './controllers/callback-context';
|
|
3
3
|
export { ExitWarningModalProvider as LinkCreateExitWarningProvider, useWithExitWarning } from './controllers/exit-warning-modal-context';
|
|
4
4
|
export { FORM_ERROR } from 'final-form';
|
|
5
|
-
export { PageIcon, UrlIcon } from './common/ui/icon';
|
|
5
|
+
export { PageIcon, UrlIcon } from './common/ui/icon';
|
|
6
|
+
export { CreateField } from './controllers/create-field/index';
|
|
@@ -3,7 +3,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
5
5
|
var _excluded = ["id", "name", "label", "isRequired", "validators", "validationHelpText", "testId", "defaultOption", "loadOptions"],
|
|
6
|
-
_excluded2 = ["fieldId"];
|
|
6
|
+
_excluded2 = ["fieldId", "isRequired"];
|
|
7
7
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
8
|
/**
|
|
9
9
|
* @jsxRuntime classic
|
|
@@ -16,6 +16,7 @@ import { jsx } from '@emotion/react';
|
|
|
16
16
|
import debounce from 'debounce-promise';
|
|
17
17
|
import { useForm } from 'react-final-form';
|
|
18
18
|
import { useIntl } from 'react-intl-next';
|
|
19
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
19
20
|
import { AsyncSelect as AkAsyncSelect } from '@atlaskit/select';
|
|
20
21
|
import messages from '../../../common/messages';
|
|
21
22
|
import { useLinkCreateCallback } from '../../../controllers/callback-context';
|
|
@@ -173,7 +174,18 @@ export function AsyncSelect(_ref) {
|
|
|
173
174
|
testId: testId
|
|
174
175
|
}, function (_ref4) {
|
|
175
176
|
var fieldId = _ref4.fieldId,
|
|
177
|
+
isRequired = _ref4.isRequired,
|
|
176
178
|
fieldProps = _objectWithoutProperties(_ref4, _excluded2);
|
|
179
|
+
if (fg('linking-platform-create-field-error-association')) {
|
|
180
|
+
return jsx(AkAsyncSelect, _extends({
|
|
181
|
+
inputId: fieldId
|
|
182
|
+
}, fieldProps, restProps, {
|
|
183
|
+
required: isRequired,
|
|
184
|
+
loadOptions: debouncedLoadOptions,
|
|
185
|
+
defaultOptions: defaultOptions,
|
|
186
|
+
isLoading: isLoadingDefaultOptions
|
|
187
|
+
}));
|
|
188
|
+
}
|
|
177
189
|
return jsx(AkAsyncSelect, _extends({
|
|
178
190
|
inputId: fieldId
|
|
179
191
|
}, fieldProps, restProps, {
|
|
@@ -35,6 +35,7 @@ export function CreateFormFooter(_ref) {
|
|
|
35
35
|
"data-testid": "".concat(testId, "-footer"),
|
|
36
36
|
css: formFooterWrapperStyles
|
|
37
37
|
}, formErrorMessage && jsx("div", {
|
|
38
|
+
role: "alert",
|
|
38
39
|
css: errorStyles,
|
|
39
40
|
"data-testid": "".concat(testId, "-error")
|
|
40
41
|
}, jsx(ErrorIcon, {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
5
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
5
6
|
var _excluded = ["submitError"];
|
|
6
7
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
7
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i :
|
|
8
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
8
9
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
9
10
|
/**
|
|
10
11
|
* @jsxRuntime classic
|
|
@@ -18,6 +19,7 @@ import { FORM_ERROR } from 'final-form';
|
|
|
18
19
|
import { Form, FormSpy } from 'react-final-form';
|
|
19
20
|
import { useIntl } from 'react-intl-next';
|
|
20
21
|
import { RequiredAsterisk } from '@atlaskit/form';
|
|
22
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
21
23
|
import { Box } from '@atlaskit/primitives';
|
|
22
24
|
import { CREATE_FORM_MAX_WIDTH_IN_PX, LINK_CREATE_FORM_POST_CREATE_FIELD } from '../../common/constants';
|
|
23
25
|
import messages from '../../common/messages';
|
|
@@ -135,12 +137,15 @@ export var CreateForm = function CreateForm(_ref) {
|
|
|
135
137
|
}, function (_ref5) {
|
|
136
138
|
var submitError = _ref5.submitError,
|
|
137
139
|
formProps = _objectWithoutProperties(_ref5, _excluded);
|
|
138
|
-
return jsx("form", {
|
|
140
|
+
return jsx("form", _extends({
|
|
139
141
|
onSubmit: formProps.handleSubmit,
|
|
140
|
-
name: "link-create-form"
|
|
142
|
+
name: "link-create-form"
|
|
143
|
+
}, fg('linking-platform-create-field-error-association') ? {
|
|
144
|
+
noValidate: true
|
|
145
|
+
} : {}, {
|
|
141
146
|
"data-testid": testId,
|
|
142
147
|
css: formStyles
|
|
143
|
-
}, jsx(FormSpy, {
|
|
148
|
+
}), jsx(FormSpy, {
|
|
144
149
|
subscription: {
|
|
145
150
|
modified: true
|
|
146
151
|
},
|
|
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
4
|
var _excluded = ["id", "name", "label", "isRequired", "validators", "validationHelpText", "testId"],
|
|
5
|
-
_excluded2 = ["fieldId"],
|
|
5
|
+
_excluded2 = ["fieldId", "isRequired"],
|
|
6
6
|
_excluded3 = ["children"],
|
|
7
7
|
_excluded4 = ["children"];
|
|
8
8
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -15,6 +15,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
15
15
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
16
16
|
import { jsx } from '@emotion/react';
|
|
17
17
|
import { useIntl } from 'react-intl-next';
|
|
18
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
18
19
|
import { Inline } from '@atlaskit/primitives';
|
|
19
20
|
import AkSelect, { components } from '@atlaskit/select';
|
|
20
21
|
import { layers } from '@atlaskit/theme/constants';
|
|
@@ -49,7 +50,14 @@ export function Select(_ref) {
|
|
|
49
50
|
testId: testId
|
|
50
51
|
}, function (_ref2) {
|
|
51
52
|
var fieldId = _ref2.fieldId,
|
|
53
|
+
isRequired = _ref2.isRequired,
|
|
52
54
|
fieldProps = _objectWithoutProperties(_ref2, _excluded2);
|
|
55
|
+
if (fg('linking-platform-create-field-error-association')) {
|
|
56
|
+
return jsx(AkSelect, _extends({
|
|
57
|
+
required: isRequired,
|
|
58
|
+
inputId: fieldId
|
|
59
|
+
}, fieldProps, restProps));
|
|
60
|
+
}
|
|
53
61
|
return jsx(AkSelect, _extends({
|
|
54
62
|
inputId: fieldId
|
|
55
63
|
}, fieldProps, restProps));
|
|
@@ -8,6 +8,7 @@ var _excluded = ["id", "name", "label", "isRequired", "validators", "validationH
|
|
|
8
8
|
*/
|
|
9
9
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
10
10
|
import { jsx } from '@emotion/react';
|
|
11
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
12
|
import AkTextfield from '@atlaskit/textfield';
|
|
12
13
|
import { CreateField } from '../../../controllers/create-field';
|
|
13
14
|
export var TEST_ID = 'link-create-text-field';
|
|
@@ -40,6 +41,11 @@ export function TextField(_ref) {
|
|
|
40
41
|
}, function (_ref2) {
|
|
41
42
|
var fieldId = _ref2.fieldId,
|
|
42
43
|
fieldProps = _objectWithoutProperties(_ref2, _excluded2);
|
|
44
|
+
if (fg('linking-platform-create-field-error-association')) {
|
|
45
|
+
return jsx(AkTextfield, _extends({
|
|
46
|
+
id: fieldId
|
|
47
|
+
}, fieldProps, restProps));
|
|
48
|
+
}
|
|
43
49
|
return jsx(AkTextfield, _extends({
|
|
44
50
|
id: fieldId
|
|
45
51
|
}, fieldProps, restProps, {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["fieldId"];
|
|
3
|
+
var _excluded = ["fieldId", "isRequired"];
|
|
4
4
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
5
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
6
|
/**
|
|
@@ -37,6 +37,7 @@ export function UserPicker(_ref) {
|
|
|
37
37
|
validators: validators
|
|
38
38
|
}, function (_ref2) {
|
|
39
39
|
var fieldId = _ref2.fieldId,
|
|
40
|
+
isRequired = _ref2.isRequired,
|
|
40
41
|
fieldProps = _objectWithoutProperties(_ref2, _excluded);
|
|
41
42
|
return jsx(SmartUserPicker, {
|
|
42
43
|
defaultValue: defaultValue ? _objectSpread(_objectSpread({}, defaultValue), {}, {
|
|
@@ -55,7 +56,8 @@ export function UserPicker(_ref) {
|
|
|
55
56
|
debounceTime: DEFAULT_DEBOUNCE_TIME,
|
|
56
57
|
prefetch: true,
|
|
57
58
|
isClearable: false,
|
|
58
|
-
width: UserPickerWidth
|
|
59
|
+
width: UserPickerWidth,
|
|
60
|
+
required: isRequired
|
|
59
61
|
});
|
|
60
62
|
});
|
|
61
63
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
import { type ReactNode } from 'react';
|
|
6
|
+
import { jsx } from '@emotion/react';
|
|
7
|
+
type MessageAppearance = 'default' | 'error' | 'valid';
|
|
8
|
+
type MessageProps = {
|
|
9
|
+
id?: string;
|
|
10
|
+
appearance?: MessageAppearance;
|
|
11
|
+
testId?: string;
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
};
|
|
14
|
+
export declare const Message: ({ children, appearance, id, testId }: MessageProps) => jsx.JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jsxRuntime classic
|
|
3
|
-
* @jsx jsx
|
|
4
|
-
*/
|
|
5
1
|
import { jsx } from '@emotion/react';
|
|
6
2
|
import { type CreateFieldProps } from './types';
|
|
7
3
|
export declare function CreateField({ id, name, label, isRequired, validators, validationHelpText, testId, children, }: CreateFieldProps): jsx.JSX.Element;
|
|
@@ -4,6 +4,11 @@ import { type Validator } from '../../common/types';
|
|
|
4
4
|
type FieldProps = FieldInputProps<any, HTMLElement> & {
|
|
5
5
|
fieldId: string;
|
|
6
6
|
isInvalid: boolean;
|
|
7
|
+
isRequired?: boolean;
|
|
8
|
+
/** ID to reference an error message for the field */
|
|
9
|
+
'aria-errormessage'?: string;
|
|
10
|
+
/** ID to refer to description for field */
|
|
11
|
+
'aria-describedby'?: string;
|
|
7
12
|
};
|
|
8
13
|
export type CreateFieldProps = {
|
|
9
14
|
id?: string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -6,3 +6,4 @@ export { ExitWarningModalProvider as LinkCreateExitWarningProvider, useWithExitW
|
|
|
6
6
|
export type { Validator, ValidatorMap } from './common/types';
|
|
7
7
|
export { FORM_ERROR } from 'final-form';
|
|
8
8
|
export { PageIcon, UrlIcon } from './common/ui/icon';
|
|
9
|
+
export { CreateField } from './controllers/create-field/index';
|
|
@@ -15,7 +15,7 @@ export declare const TEST_ID = "link-create-select";
|
|
|
15
15
|
*/
|
|
16
16
|
export declare function Select<T = OptionType>({ id, name, label, isRequired, validators, validationHelpText, testId, ...restProps }: SelectProps<T>): jsx.JSX.Element;
|
|
17
17
|
export type SiteSelectProps = {
|
|
18
|
-
testId
|
|
18
|
+
testId?: string;
|
|
19
19
|
options?: SitePickerOptionType[];
|
|
20
20
|
name?: string;
|
|
21
21
|
};
|