@atlaskit/link-create 3.1.0 → 4.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.
Files changed (166) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/common/constants.js +1 -1
  3. package/dist/cjs/common/ui/error-boundary-modal/index.js +1 -9
  4. package/dist/cjs/common/ui/error-boundary-ui/error-svg/index.js +1 -10
  5. package/dist/cjs/common/ui/icon/index.js +1 -9
  6. package/dist/cjs/common/ui/message/index.js +1 -9
  7. package/dist/cjs/common/ui/modal-hero/index.js +1 -9
  8. package/dist/cjs/controllers/create-field/main.js +1 -9
  9. package/dist/cjs/ui/create-form/async-select/main.js +1 -9
  10. package/dist/cjs/ui/create-form/form-footer/main.js +1 -9
  11. package/dist/cjs/ui/create-form/form-loader/main.js +1 -9
  12. package/dist/cjs/ui/create-form/main.js +1 -9
  13. package/dist/cjs/ui/create-form/select/main.js +7 -33
  14. package/dist/cjs/ui/create-form/textfield/main.js +1 -9
  15. package/dist/cjs/ui/create-form/user-picker/main.js +1 -9
  16. package/dist/cjs/ui/inline-create/index.js +1 -9
  17. package/dist/cjs/ui/inline-create/main.js +1 -9
  18. package/dist/cjs/ui/modal-create/index.js +1 -9
  19. package/dist/cjs/ui/modal-create/main.js +1 -9
  20. package/dist/es2019/common/constants.js +1 -1
  21. package/dist/es2019/common/ui/error-boundary-modal/index.js +1 -9
  22. package/dist/es2019/common/ui/error-boundary-ui/error-svg/index.js +1 -9
  23. package/dist/es2019/common/ui/icon/index.js +1 -9
  24. package/dist/es2019/common/ui/message/index.js +1 -9
  25. package/dist/es2019/common/ui/modal-hero/index.js +1 -9
  26. package/dist/es2019/controllers/create-field/main.js +1 -9
  27. package/dist/es2019/ui/create-form/async-select/main.js +1 -9
  28. package/dist/es2019/ui/create-form/form-footer/main.js +1 -9
  29. package/dist/es2019/ui/create-form/form-loader/main.js +1 -9
  30. package/dist/es2019/ui/create-form/main.js +1 -9
  31. package/dist/es2019/ui/create-form/select/main.js +8 -34
  32. package/dist/es2019/ui/create-form/textfield/main.js +1 -9
  33. package/dist/es2019/ui/create-form/user-picker/main.js +1 -9
  34. package/dist/es2019/ui/inline-create/index.js +1 -9
  35. package/dist/es2019/ui/inline-create/main.js +1 -9
  36. package/dist/es2019/ui/modal-create/index.js +1 -9
  37. package/dist/es2019/ui/modal-create/main.js +1 -9
  38. package/dist/esm/common/constants.js +1 -1
  39. package/dist/esm/common/ui/error-boundary-modal/index.js +1 -9
  40. package/dist/esm/common/ui/error-boundary-ui/error-svg/index.js +1 -9
  41. package/dist/esm/common/ui/icon/index.js +1 -9
  42. package/dist/esm/common/ui/message/index.js +1 -9
  43. package/dist/esm/common/ui/modal-hero/index.js +1 -9
  44. package/dist/esm/controllers/create-field/main.js +1 -9
  45. package/dist/esm/ui/create-form/async-select/main.js +1 -9
  46. package/dist/esm/ui/create-form/form-footer/main.js +1 -9
  47. package/dist/esm/ui/create-form/form-loader/main.js +1 -9
  48. package/dist/esm/ui/create-form/main.js +1 -9
  49. package/dist/esm/ui/create-form/select/main.js +7 -33
  50. package/dist/esm/ui/create-form/textfield/main.js +1 -9
  51. package/dist/esm/ui/create-form/user-picker/main.js +1 -9
  52. package/dist/esm/ui/inline-create/index.js +1 -9
  53. package/dist/esm/ui/inline-create/main.js +1 -9
  54. package/dist/esm/ui/modal-create/index.js +1 -9
  55. package/dist/esm/ui/modal-create/main.js +1 -9
  56. package/dist/types/common/ui/error-boundary-modal/index.d.ts +2 -2
  57. package/dist/types/common/ui/icon/index.d.ts +1 -1
  58. package/dist/types/common/ui/message/index.d.ts +1 -1
  59. package/dist/types/common/ui/modal-hero/index.d.ts +1 -1
  60. package/dist/types/controllers/create-field/main.d.ts +1 -1
  61. package/dist/types/ui/create-form/async-select/main.d.ts +8 -2
  62. package/dist/types/ui/create-form/form-footer/main.d.ts +6 -1
  63. package/dist/types/ui/create-form/form-loader/main.d.ts +5 -1
  64. package/dist/types/ui/create-form/main.d.ts +1 -1
  65. package/dist/types/ui/create-form/select/main.d.ts +11 -5
  66. package/dist/types/ui/create-form/textfield/main.d.ts +8 -2
  67. package/dist/types/ui/create-form/user-picker/main.d.ts +5 -2
  68. package/dist/types-ts4.5/common/ui/error-boundary-modal/index.d.ts +2 -2
  69. package/dist/types-ts4.5/common/ui/icon/index.d.ts +1 -1
  70. package/dist/types-ts4.5/common/ui/message/index.d.ts +1 -1
  71. package/dist/types-ts4.5/common/ui/modal-hero/index.d.ts +1 -1
  72. package/dist/types-ts4.5/controllers/create-field/main.d.ts +1 -1
  73. package/dist/types-ts4.5/ui/create-form/async-select/main.d.ts +8 -2
  74. package/dist/types-ts4.5/ui/create-form/form-footer/main.d.ts +6 -1
  75. package/dist/types-ts4.5/ui/create-form/form-loader/main.d.ts +5 -1
  76. package/dist/types-ts4.5/ui/create-form/main.d.ts +1 -1
  77. package/dist/types-ts4.5/ui/create-form/select/main.d.ts +11 -5
  78. package/dist/types-ts4.5/ui/create-form/textfield/main.d.ts +8 -2
  79. package/dist/types-ts4.5/ui/create-form/user-picker/main.d.ts +5 -2
  80. package/package.json +2 -10
  81. package/report.api.md +1 -1
  82. package/dist/cjs/common/ui/error-boundary-modal/old/index.js +0 -34
  83. package/dist/cjs/common/ui/error-boundary-ui/error-svg/old/index.js +0 -67
  84. package/dist/cjs/common/ui/icon/old/index.js +0 -26
  85. package/dist/cjs/common/ui/message/old/index.js +0 -81
  86. package/dist/cjs/common/ui/modal-hero/old/index.js +0 -27
  87. package/dist/cjs/controllers/create-field/old/main.js +0 -76
  88. package/dist/cjs/ui/create-form/async-select/old/main.js +0 -195
  89. package/dist/cjs/ui/create-form/form-footer/old/main.js +0 -64
  90. package/dist/cjs/ui/create-form/form-loader/old/main.js +0 -39
  91. package/dist/cjs/ui/create-form/old/main.js +0 -177
  92. package/dist/cjs/ui/create-form/select/old/main.js +0 -127
  93. package/dist/cjs/ui/create-form/textfield/old/main.js +0 -55
  94. package/dist/cjs/ui/create-form/user-picker/old/main.js +0 -72
  95. package/dist/cjs/ui/inline-create/old/index.js +0 -38
  96. package/dist/cjs/ui/inline-create/old/main.js +0 -120
  97. package/dist/cjs/ui/modal-create/old/index.js +0 -44
  98. package/dist/cjs/ui/modal-create/old/main.js +0 -164
  99. package/dist/es2019/common/ui/error-boundary-modal/old/index.js +0 -26
  100. package/dist/es2019/common/ui/error-boundary-ui/error-svg/old/index.js +0 -58
  101. package/dist/es2019/common/ui/icon/old/index.js +0 -18
  102. package/dist/es2019/common/ui/message/old/index.js +0 -74
  103. package/dist/es2019/common/ui/modal-hero/old/index.js +0 -19
  104. package/dist/es2019/controllers/create-field/old/main.js +0 -74
  105. package/dist/es2019/ui/create-form/async-select/old/main.js +0 -137
  106. package/dist/es2019/ui/create-form/form-footer/old/main.js +0 -57
  107. package/dist/es2019/ui/create-form/form-loader/old/main.js +0 -31
  108. package/dist/es2019/ui/create-form/old/main.js +0 -145
  109. package/dist/es2019/ui/create-form/select/old/main.js +0 -106
  110. package/dist/es2019/ui/create-form/textfield/old/main.js +0 -45
  111. package/dist/es2019/ui/create-form/user-picker/old/main.js +0 -59
  112. package/dist/es2019/ui/inline-create/old/index.js +0 -30
  113. package/dist/es2019/ui/inline-create/old/main.js +0 -96
  114. package/dist/es2019/ui/modal-create/old/index.js +0 -36
  115. package/dist/es2019/ui/modal-create/old/main.js +0 -137
  116. package/dist/esm/common/ui/error-boundary-modal/old/index.js +0 -25
  117. package/dist/esm/common/ui/error-boundary-ui/error-svg/old/index.js +0 -60
  118. package/dist/esm/common/ui/icon/old/index.js +0 -18
  119. package/dist/esm/common/ui/message/old/index.js +0 -73
  120. package/dist/esm/common/ui/modal-hero/old/index.js +0 -18
  121. package/dist/esm/controllers/create-field/old/main.js +0 -72
  122. package/dist/esm/ui/create-form/async-select/old/main.js +0 -188
  123. package/dist/esm/ui/create-form/form-footer/old/main.js +0 -56
  124. package/dist/esm/ui/create-form/form-loader/old/main.js +0 -31
  125. package/dist/esm/ui/create-form/old/main.js +0 -174
  126. package/dist/esm/ui/create-form/select/old/main.js +0 -117
  127. package/dist/esm/ui/create-form/textfield/old/main.js +0 -47
  128. package/dist/esm/ui/create-form/user-picker/old/main.js +0 -64
  129. package/dist/esm/ui/inline-create/old/index.js +0 -30
  130. package/dist/esm/ui/inline-create/old/main.js +0 -112
  131. package/dist/esm/ui/modal-create/old/index.js +0 -36
  132. package/dist/esm/ui/modal-create/old/main.js +0 -156
  133. package/dist/types/common/ui/error-boundary-modal/old/index.d.ts +0 -11
  134. package/dist/types/common/ui/error-boundary-ui/error-svg/old/index.d.ts +0 -7
  135. package/dist/types/common/ui/icon/old/index.d.ts +0 -7
  136. package/dist/types/common/ui/message/old/index.d.ts +0 -15
  137. package/dist/types/common/ui/modal-hero/old/index.d.ts +0 -4
  138. package/dist/types/controllers/create-field/old/main.d.ts +0 -7
  139. package/dist/types/ui/create-form/async-select/old/main.d.ts +0 -11
  140. package/dist/types/ui/create-form/form-footer/old/main.d.ts +0 -16
  141. package/dist/types/ui/create-form/form-loader/old/main.d.ts +0 -11
  142. package/dist/types/ui/create-form/old/main.d.ts +0 -54
  143. package/dist/types/ui/create-form/select/old/main.d.ts +0 -24
  144. package/dist/types/ui/create-form/textfield/old/main.d.ts +0 -14
  145. package/dist/types/ui/create-form/user-picker/old/main.d.ts +0 -11
  146. package/dist/types/ui/inline-create/old/index.d.ts +0 -5
  147. package/dist/types/ui/inline-create/old/main.d.ts +0 -8
  148. package/dist/types/ui/modal-create/old/index.d.ts +0 -5
  149. package/dist/types/ui/modal-create/old/main.d.ts +0 -4
  150. package/dist/types-ts4.5/common/ui/error-boundary-modal/old/index.d.ts +0 -11
  151. package/dist/types-ts4.5/common/ui/error-boundary-ui/error-svg/old/index.d.ts +0 -7
  152. package/dist/types-ts4.5/common/ui/icon/old/index.d.ts +0 -7
  153. package/dist/types-ts4.5/common/ui/message/old/index.d.ts +0 -15
  154. package/dist/types-ts4.5/common/ui/modal-hero/old/index.d.ts +0 -4
  155. package/dist/types-ts4.5/controllers/create-field/old/main.d.ts +0 -7
  156. package/dist/types-ts4.5/ui/create-form/async-select/old/main.d.ts +0 -11
  157. package/dist/types-ts4.5/ui/create-form/form-footer/old/main.d.ts +0 -16
  158. package/dist/types-ts4.5/ui/create-form/form-loader/old/main.d.ts +0 -11
  159. package/dist/types-ts4.5/ui/create-form/old/main.d.ts +0 -56
  160. package/dist/types-ts4.5/ui/create-form/select/old/main.d.ts +0 -24
  161. package/dist/types-ts4.5/ui/create-form/textfield/old/main.d.ts +0 -14
  162. package/dist/types-ts4.5/ui/create-form/user-picker/old/main.d.ts +0 -11
  163. package/dist/types-ts4.5/ui/inline-create/old/index.d.ts +0 -5
  164. package/dist/types-ts4.5/ui/inline-create/old/main.d.ts +0 -8
  165. package/dist/types-ts4.5/ui/modal-create/old/index.d.ts +0 -5
  166. package/dist/types-ts4.5/ui/modal-create/old/main.d.ts +0 -4
@@ -1,188 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
- var _excluded = ["id", "name", "label", "isRequired", "validators", "validationHelpText", "testId", "defaultOption", "loadOptions"],
6
- _excluded2 = ["fieldId", "isRequired"];
7
- import _regeneratorRuntime from "@babel/runtime/regenerator";
8
- /* eslint-disable @atlassian/tangerine/import/no-parent-imports */
9
- /**
10
- * @jsxRuntime classic
11
- * @jsx jsx
12
- */
13
- import { useEffect, useMemo, useState } from 'react';
14
-
15
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
16
- import { jsx } from '@emotion/react';
17
- import debounce from 'debounce-promise';
18
- import { useForm } from 'react-final-form';
19
- import { useIntl } from 'react-intl-next';
20
- import { AsyncSelect as AkAsyncSelect } from '@atlaskit/select';
21
- import messages from '../../../../common/messages';
22
- import { useLinkCreateCallback } from '../../../../controllers/callback-context';
23
- import { CreateField } from '../../../../controllers/create-field';
24
- import { useFormContext } from '../../../../controllers/form-context';
25
- export var TEST_ID = 'link-create-async-select';
26
-
27
- /**
28
- * An async select utilising the Atlaskit AsyncSelect and CreateField.
29
- * Validation is handled by the form on form submission. Any
30
- * errors returned by the handleSubmit function passed to the form <Form> that
31
- * have a key matching the `name` of this field are shown below the field.
32
- */
33
- export function AsyncSelectOld(_ref) {
34
- var id = _ref.id,
35
- name = _ref.name,
36
- label = _ref.label,
37
- isRequired = _ref.isRequired,
38
- validators = _ref.validators,
39
- validationHelpText = _ref.validationHelpText,
40
- _ref$testId = _ref.testId,
41
- testId = _ref$testId === void 0 ? TEST_ID : _ref$testId,
42
- propsDefaultValue = _ref.defaultOption,
43
- loadOptionsFn = _ref.loadOptions,
44
- restProps = _objectWithoutProperties(_ref, _excluded);
45
- var _useForm = useForm(),
46
- mutators = _useForm.mutators;
47
- var _useLinkCreateCallbac = useLinkCreateCallback(),
48
- onFailure = _useLinkCreateCallbac.onFailure;
49
- var _useFormContext = useFormContext(),
50
- setFormErrorMessage = _useFormContext.setFormErrorMessage;
51
- var intl = useIntl();
52
- var _useState = useState(propsDefaultValue),
53
- _useState2 = _slicedToArray(_useState, 2),
54
- defaultValue = _useState2[0],
55
- setDefaultValue = _useState2[1];
56
- var _useState3 = useState(false),
57
- _useState4 = _slicedToArray(_useState3, 2),
58
- isLoadingDefaultOptions = _useState4[0],
59
- setIsLoadingDefaultOptions = _useState4[1];
60
- var _useState5 = useState([]),
61
- _useState6 = _slicedToArray(_useState5, 2),
62
- defaultOptions = _useState6[0],
63
- setDefaultOptions = _useState6[1];
64
-
65
- /**
66
- * This binds experience to fail if async fetch ever fails to load
67
- */
68
- var loadOptions = useMemo(function () {
69
- if (loadOptionsFn) {
70
- return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
71
- var _args = arguments;
72
- return _regeneratorRuntime.wrap(function _callee$(_context) {
73
- while (1) switch (_context.prev = _context.next) {
74
- case 0:
75
- _context.prev = 0;
76
- _context.next = 3;
77
- return loadOptionsFn.apply(void 0, _args);
78
- case 3:
79
- return _context.abrupt("return", _context.sent);
80
- case 6:
81
- _context.prev = 6;
82
- _context.t0 = _context["catch"](0);
83
- onFailure === null || onFailure === void 0 || onFailure(_context.t0);
84
- setFormErrorMessage(intl.formatMessage(messages.genericErrorMessage));
85
- return _context.abrupt("return", []);
86
- case 11:
87
- case "end":
88
- return _context.stop();
89
- }
90
- }, _callee, null, [[0, 6]]);
91
- }));
92
- }
93
- }, [intl, onFailure, loadOptionsFn, setFormErrorMessage]);
94
- useEffect(function () {
95
- var current = true;
96
- var fetch = /*#__PURE__*/function () {
97
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
98
- var query,
99
- options,
100
- _args2 = arguments;
101
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
102
- while (1) switch (_context2.prev = _context2.next) {
103
- case 0:
104
- query = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : '';
105
- if (loadOptions) {
106
- _context2.next = 3;
107
- break;
108
- }
109
- return _context2.abrupt("return");
110
- case 3:
111
- _context2.prev = 3;
112
- /**
113
- * If we are fetching default options, clear the
114
- * value the user has set
115
- */
116
- if (mutators.setField) {
117
- mutators.setField(name, null);
118
- }
119
- setIsLoadingDefaultOptions(true);
120
- setDefaultOptions([]);
121
- _context2.next = 9;
122
- return loadOptions(query);
123
- case 9:
124
- options = _context2.sent;
125
- if (current) {
126
- setDefaultOptions(options);
127
- setIsLoadingDefaultOptions(false);
128
- }
129
- _context2.next = 16;
130
- break;
131
- case 13:
132
- _context2.prev = 13;
133
- _context2.t0 = _context2["catch"](3);
134
- if (current) {
135
- setIsLoadingDefaultOptions(false);
136
- }
137
- case 16:
138
- case "end":
139
- return _context2.stop();
140
- }
141
- }, _callee2, null, [[3, 13]]);
142
- }));
143
- return function fetch() {
144
- return _ref3.apply(this, arguments);
145
- };
146
- }();
147
- fetch();
148
- return function () {
149
- current = false;
150
- };
151
- }, [loadOptions, setIsLoadingDefaultOptions, setDefaultOptions, mutators, name]);
152
- useEffect(function () {
153
- /**
154
- * Mutate the form state to set a default value for this field
155
- * if `defaultOption` is a prop and we have not set a value for it yet
156
- */
157
- if (!defaultValue && propsDefaultValue) {
158
- setDefaultValue(propsDefaultValue);
159
- if (mutators.setField) {
160
- mutators.setField(name, propsDefaultValue);
161
- }
162
- }
163
- }, [defaultValue, propsDefaultValue, name, mutators]);
164
- var debouncedLoadOptions = useMemo(function () {
165
- return loadOptions ? debounce(loadOptions, 300) : undefined;
166
- }, [loadOptions]);
167
- return jsx(CreateField, {
168
- id: id,
169
- name: name,
170
- label: label,
171
- isRequired: isRequired,
172
- validators: validators,
173
- validationHelpText: validationHelpText,
174
- testId: testId
175
- }, function (_ref4) {
176
- var fieldId = _ref4.fieldId,
177
- isRequired = _ref4.isRequired,
178
- fieldProps = _objectWithoutProperties(_ref4, _excluded2);
179
- return jsx(AkAsyncSelect, _extends({
180
- inputId: fieldId
181
- }, fieldProps, restProps, {
182
- required: isRequired,
183
- loadOptions: debouncedLoadOptions,
184
- defaultOptions: defaultOptions,
185
- isLoading: isLoadingDefaultOptions
186
- }));
187
- });
188
- }
@@ -1,56 +0,0 @@
1
- /* eslint-disable @atlassian/tangerine/import/no-parent-imports */
2
- /**
3
- * @jsxRuntime classic
4
- * @jsx jsx
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 { useIntl } from 'react-intl-next';
9
- import { ButtonGroup } from '@atlaskit/button';
10
- import ErrorIcon from '@atlaskit/icon/core/migration/error';
11
- import { Button } from '../../../../common/ui/Button';
12
- import { EditButton } from '../edit-button';
13
- import { messages } from '../messages';
14
- import { SubmitButton } from '../submit-button';
15
- var formFooterWrapperStyles = css({
16
- display: 'flex',
17
- marginTop: "var(--ds-space-300, 24px)",
18
- justifyContent: 'flex-end'
19
- });
20
- var errorStyles = css({
21
- display: 'flex',
22
- alignItems: 'center',
23
- marginRight: 'auto'
24
- });
25
- /**
26
- * Footer for the Create Form, used as a wrapper for action buttons
27
- * and form error messages. This component is unmounted if
28
- * hideFooter is true in the Create Form.
29
- */
30
- export function CreateFormFooterOld(_ref) {
31
- var formErrorMessage = _ref.formErrorMessage,
32
- handleCancel = _ref.handleCancel,
33
- testId = _ref.testId;
34
- var intl = useIntl();
35
- return jsx("footer", {
36
- "data-testid": "".concat(testId, "-footer"),
37
- css: formFooterWrapperStyles
38
- }, formErrorMessage && jsx("div", {
39
- role: "alert",
40
- css: errorStyles,
41
- "data-testid": "".concat(testId, "-error")
42
- }, jsx(ErrorIcon, {
43
- label: formErrorMessage,
44
- color: "var(--ds-icon-danger, #E34935)",
45
- spacing: "spacious"
46
- }), formErrorMessage), jsx(ButtonGroup, null, jsx(Button, {
47
- type: "button",
48
- actionSubjectId: "cancel",
49
- appearance: "subtle",
50
- onClick: function onClick(e) {
51
- e.stopPropagation();
52
- handleCancel();
53
- },
54
- testId: "".concat(testId, "-button-cancel")
55
- }, intl.formatMessage(messages.close)), jsx(EditButton, null), jsx(SubmitButton, null)));
56
- }
@@ -1,31 +0,0 @@
1
- /**
2
- * @jsxRuntime classic
3
- * @jsx jsx
4
- */
5
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
6
- import { css, jsx } from '@emotion/react';
7
- import Spinner from '@atlaskit/spinner';
8
- import { CREATE_FORM_MIN_HEIGHT_IN_PX } from '../../../../common/constants';
9
- var formLoaderStyles = css({
10
- display: "flex",
11
- alignItems: "center",
12
- justifyContent: "center",
13
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
14
- minHeight: "".concat(CREATE_FORM_MIN_HEIGHT_IN_PX, "px")
15
- });
16
-
17
- /**
18
- * Wrapper component for the Spinner, shows while the form
19
- * performs async functions on load.
20
- */
21
- export function CreateFormLoaderOld(_ref) {
22
- var _ref$size = _ref.size,
23
- size = _ref$size === void 0 ? 'large' : _ref$size;
24
- return jsx("div", {
25
- css: formLoaderStyles
26
- }, jsx(Spinner, {
27
- size: size,
28
- interactionName: "load",
29
- testId: "link-create-form-loader"
30
- }));
31
- }
@@ -1,174 +0,0 @@
1
- import _typeof from "@babel/runtime/helpers/typeof";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
5
- var _excluded = ["submitError"];
6
- import _regeneratorRuntime from "@babel/runtime/regenerator";
7
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
8
- 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
- /* eslint-disable @atlassian/tangerine/import/no-parent-imports */
10
- /**
11
- * @jsxRuntime classic
12
- * @jsx jsx
13
- */
14
- import { useCallback } from 'react';
15
-
16
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
17
- import { css, jsx } from '@emotion/react';
18
- import { FORM_ERROR } from 'final-form';
19
- import { Form, FormSpy } from 'react-final-form';
20
- import { useIntl } from 'react-intl-next';
21
- import { RequiredAsterisk } from '@atlaskit/form';
22
- import { Box, Text } from '@atlaskit/primitives';
23
- import { CREATE_FORM_MAX_WIDTH_IN_PX, LINK_CREATE_FORM_POST_CREATE_FIELD } from '../../../common/constants';
24
- import messages from '../../../common/messages';
25
- import { useLinkCreateCallback } from '../../../controllers/callback-context';
26
- import { useExitWarningModal } from '../../../controllers/exit-warning-modal-context';
27
- import { useFormContext } from '../../../controllers/form-context';
28
- import { CreateFormFooter } from '../form-footer';
29
- import { CreateFormLoader } from '../form-loader';
30
- var formStyles = css({
31
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
32
- maxWidth: "".concat(CREATE_FORM_MAX_WIDTH_IN_PX, "px"),
33
- padding: "0 0 ".concat("var(--ds-space-300, 24px)", " 0"),
34
- margin: "var(--ds-space-0, 0px)".concat(" auto")
35
- });
36
- var RESERVED_FIELDS = [LINK_CREATE_FORM_POST_CREATE_FIELD];
37
- export var TEST_ID = 'link-create-form';
38
- export var CreateFormOld = function CreateFormOld(_ref) {
39
- var children = _ref.children,
40
- _ref$testId = _ref.testId,
41
- testId = _ref$testId === void 0 ? TEST_ID : _ref$testId,
42
- onSubmit = _ref.onSubmit,
43
- onCancel = _ref.onCancel,
44
- isLoading = _ref.isLoading,
45
- hideFooter = _ref.hideFooter,
46
- hideRequiredFieldMessage = _ref.hideRequiredFieldMessage,
47
- initialValues = _ref.initialValues;
48
- var _useFormContext = useFormContext(),
49
- setFormErrorMessage = _useFormContext.setFormErrorMessage,
50
- formErrorMessage = _useFormContext.formErrorMessage,
51
- enableEditView = _useFormContext.enableEditView;
52
- var intl = useIntl();
53
- var _useExitWarningModal = useExitWarningModal(),
54
- setShouldShowWarning = _useExitWarningModal.setShouldShowWarning;
55
- var _useLinkCreateCallbac = useLinkCreateCallback(),
56
- onFailure = _useLinkCreateCallbac.onFailure;
57
- var handleSubmit = useCallback( /*#__PURE__*/function () {
58
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(data) {
59
- var shouldEnableEditView, formData;
60
- return _regeneratorRuntime.wrap(function _callee$(_context) {
61
- while (1) switch (_context.prev = _context.next) {
62
- case 0:
63
- shouldEnableEditView = data[LINK_CREATE_FORM_POST_CREATE_FIELD], formData = _objectWithoutProperties(data, [LINK_CREATE_FORM_POST_CREATE_FIELD].map(_toPropertyKey));
64
- /**
65
- * If form has post-create field set to trigger post-create edit
66
- * send this to the form context so we know what to do next
67
- * if submission is successful
68
- */
69
- enableEditView === null || enableEditView === void 0 || enableEditView(!!shouldEnableEditView);
70
-
71
- /**
72
- * This is the onSubmit handler provided by the plugin
73
- * It will be async, and it will likely involve awaiting `onCreate` (the adopters handler)
74
- */
75
- return _context.abrupt("return", onSubmit(formData));
76
- case 3:
77
- case "end":
78
- return _context.stop();
79
- }
80
- }, _callee);
81
- }));
82
- return function (_x) {
83
- return _ref2.apply(this, arguments);
84
- };
85
- }(), [onSubmit, enableEditView]);
86
- var handleSubmitWithErrorHandling = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
87
- var _args2 = arguments;
88
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
89
- while (1) switch (_context2.prev = _context2.next) {
90
- case 0:
91
- _context2.prev = 0;
92
- /**
93
- * Clear any error message that may have been set by async select fields
94
- * This will immediately remove any indication of an error, but the form likely will fail to submit,
95
- * it will be likely a 400 because the user probably could not set all fields anyway
96
- */
97
- setFormErrorMessage();
98
- _context2.next = 4;
99
- return handleSubmit.apply(void 0, _args2);
100
- case 4:
101
- return _context2.abrupt("return", _context2.sent);
102
- case 7:
103
- _context2.prev = 7;
104
- _context2.t0 = _context2["catch"](0);
105
- /**
106
- * Notify link create of failed experience
107
- */
108
- onFailure === null || onFailure === void 0 || onFailure(_context2.t0);
109
-
110
- /**
111
- * Return a generic message for react final form to render
112
- */
113
- return _context2.abrupt("return", _defineProperty({}, FORM_ERROR, intl.formatMessage(messages.genericErrorMessage)));
114
- case 11:
115
- case "end":
116
- return _context2.stop();
117
- }
118
- }, _callee2, null, [[0, 7]]);
119
- })), [handleSubmit, setFormErrorMessage, intl, onFailure]);
120
- var handleCancel = useCallback(function () {
121
- onCancel && onCancel();
122
- }, [onCancel]);
123
- if (isLoading) {
124
- return jsx(CreateFormLoader, null);
125
- }
126
- return jsx(Form, {
127
- onSubmit: handleSubmitWithErrorHandling,
128
- initialValues: initialValues,
129
- mutators: {
130
- setField: function setField(args, state, tools) {
131
- tools.changeValue(state, args[0].toString(), function () {
132
- return args[1];
133
- });
134
- }
135
- }
136
- }, function (_ref5) {
137
- var submitError = _ref5.submitError,
138
- formProps = _objectWithoutProperties(_ref5, _excluded);
139
- return jsx("form", {
140
- onSubmit: formProps.handleSubmit,
141
- name: "link-create-form",
142
- noValidate: true,
143
- "data-testid": testId,
144
- css: formStyles
145
- }, jsx(FormSpy, {
146
- subscription: {
147
- modified: true
148
- },
149
- onChange: function onChange(state) {
150
- // determine if any of the fields have been modified
151
- if (!state.modified) {
152
- setShouldShowWarning(false);
153
- return;
154
- }
155
- var isModified = Object.values(state.modified).some(function (value) {
156
- return value;
157
- });
158
- setShouldShowWarning(isModified);
159
- }
160
- }), !hideRequiredFieldMessage && jsx(Text, {
161
- as: "p"
162
- }, intl.formatMessage(messages.requiredFieldInstruction), " ", jsx(RequiredAsterisk, null)), jsx(Box, null, children), !hideFooter && jsx(CreateFormFooter
163
- /**
164
- * We will prefer to render the error message connected to
165
- * react final form state (submitError) otherwise we can
166
- * default to the `formErrorMessage` that we sometimes use with our own
167
- * "form context" (only currently used for AsyncSelect field reporting failed loading)
168
- */, {
169
- formErrorMessage: submitError || formErrorMessage,
170
- handleCancel: handleCancel,
171
- testId: testId
172
- }));
173
- });
174
- };
@@ -1,117 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _extends from "@babel/runtime/helpers/extends";
3
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["id", "name", "label", "isRequired", "validators", "validationHelpText", "testId"],
5
- _excluded2 = ["fieldId", "isRequired"],
6
- _excluded3 = ["children"],
7
- _excluded4 = ["children"];
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; }
9
- 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; }
10
- /* eslint-disable @atlassian/tangerine/import/no-parent-imports */
11
- /**
12
- * @jsxRuntime classic
13
- * @jsx jsx
14
- */
15
-
16
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
17
- import { jsx } from '@emotion/react';
18
- import { useIntl } from 'react-intl-next';
19
- import { Inline } from '@atlaskit/primitives';
20
- import AkSelect, { components } from '@atlaskit/select';
21
- import { layers } from '@atlaskit/theme/constants';
22
- import { UrlIcon } from '../../../../common/ui/icon';
23
- import { CreateField } from '../../../../controllers/create-field';
24
- import { messages } from '../messages';
25
- export var TEST_ID = 'link-create-select';
26
-
27
- /**
28
- * A select component utilising the Atlaskit Select and CreateField.
29
- * Validation is handled by the form on form submission. Any
30
- * errors returned by the handleSubmit function passed to the form <Form> that
31
- * have a key matching the `name` of this field are shown below the field.
32
- */
33
- export function SelectOld(_ref) {
34
- var id = _ref.id,
35
- name = _ref.name,
36
- label = _ref.label,
37
- isRequired = _ref.isRequired,
38
- validators = _ref.validators,
39
- validationHelpText = _ref.validationHelpText,
40
- _ref$testId = _ref.testId,
41
- testId = _ref$testId === void 0 ? TEST_ID : _ref$testId,
42
- restProps = _objectWithoutProperties(_ref, _excluded);
43
- return jsx(CreateField, {
44
- id: id,
45
- name: name,
46
- label: label,
47
- isRequired: isRequired,
48
- validators: validators,
49
- validationHelpText: validationHelpText,
50
- testId: testId
51
- }, function (_ref2) {
52
- var fieldId = _ref2.fieldId,
53
- isRequired = _ref2.isRequired,
54
- fieldProps = _objectWithoutProperties(_ref2, _excluded2);
55
- return jsx(AkSelect, _extends({
56
- required: isRequired,
57
- inputId: fieldId
58
- }, fieldProps, restProps));
59
- });
60
- }
61
- export var SiteSelectOld = function SiteSelectOld(_ref3) {
62
- var options = _ref3.options,
63
- name = _ref3.name,
64
- testId = _ref3.testId;
65
- var intl = useIntl();
66
- var siteTestId = testId ? testId : 'link-create-site-picker';
67
- return jsx(SelectOld, {
68
- isRequired: true,
69
- isSearchable: true,
70
- name: name !== null && name !== void 0 ? name : 'site',
71
- options: options,
72
- label: intl.formatMessage(messages.siteLabel),
73
- components: {
74
- Option: SitePickerOptionOld,
75
- SingleValue: SitePickerSingleValueOld
76
- },
77
- testId: siteTestId,
78
- styles: {
79
- menuPortal: function menuPortal(base) {
80
- return _objectSpread(_objectSpread({}, base), {}, {
81
- zIndex: layers.modal()
82
- });
83
- },
84
- option: function option(base) {
85
- return _objectSpread(_objectSpread({}, base), {}, {
86
- display: 'flex',
87
- alignItems: 'center',
88
- cursor: 'pointer'
89
- });
90
- }
91
- }
92
- });
93
- };
94
- var SiteRow = function SiteRow(_ref4) {
95
- var avatarUrl = _ref4.avatarUrl,
96
- children = _ref4.children;
97
- return jsx(Inline, {
98
- space: "space.100",
99
- alignBlock: "center"
100
- }, avatarUrl ? jsx(UrlIcon, {
101
- url: avatarUrl
102
- }) : null, children);
103
- };
104
- export var SitePickerOptionOld = function SitePickerOptionOld(_ref5) {
105
- var children = _ref5.children,
106
- props = _objectWithoutProperties(_ref5, _excluded3);
107
- return jsx(components.Option, props, jsx(SiteRow, {
108
- avatarUrl: props.data.value.avatarUrl
109
- }, children));
110
- };
111
- export var SitePickerSingleValueOld = function SitePickerSingleValueOld(_ref6) {
112
- var children = _ref6.children,
113
- props = _objectWithoutProperties(_ref6, _excluded4);
114
- return jsx(components.SingleValue, props, jsx(SiteRow, {
115
- avatarUrl: props.data.value.avatarUrl
116
- }, children));
117
- };
@@ -1,47 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["id", "name", "label", "isRequired", "validators", "validationHelpText", "testId"],
4
- _excluded2 = ["fieldId"];
5
- /* eslint-disable @atlassian/tangerine/import/no-parent-imports */
6
- /**
7
- * @jsxRuntime classic
8
- * @jsx jsx
9
- */
10
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
11
- import { jsx } from '@emotion/react';
12
- import AkTextfield from '@atlaskit/textfield';
13
- import { CreateField } from '../../../../controllers/create-field';
14
- export var TEST_ID = 'link-create-text-field';
15
-
16
- /**
17
- * A text field utilising the Atlaskit Textfield and CreateField.
18
- * Validation is handled by the form as it is on form submission. Any errors returned by
19
- * the handleSubmit function passed to the form <Form> that have a key matching the `name`
20
- * of this text field are shown above the field.
21
- */
22
- export function TextFieldOld(_ref) {
23
- var id = _ref.id,
24
- name = _ref.name,
25
- label = _ref.label,
26
- isRequired = _ref.isRequired,
27
- validators = _ref.validators,
28
- validationHelpText = _ref.validationHelpText,
29
- _ref$testId = _ref.testId,
30
- testId = _ref$testId === void 0 ? TEST_ID : _ref$testId,
31
- restProps = _objectWithoutProperties(_ref, _excluded);
32
- return jsx(CreateField, {
33
- id: id,
34
- name: name,
35
- label: label,
36
- isRequired: isRequired,
37
- validators: validators,
38
- validationHelpText: validationHelpText,
39
- testId: testId
40
- }, function (_ref2) {
41
- var fieldId = _ref2.fieldId,
42
- fieldProps = _objectWithoutProperties(_ref2, _excluded2);
43
- return jsx(AkTextfield, _extends({
44
- id: fieldId
45
- }, fieldProps, restProps));
46
- });
47
- }
@@ -1,64 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["fieldId", "isRequired"];
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
- 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
- /* eslint-disable @atlassian/tangerine/import/no-parent-imports */
7
- /**
8
- * @jsxRuntime classic
9
- * @jsx jsx
10
- */
11
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
12
- import { jsx } from '@emotion/react';
13
- import SmartUserPicker from '@atlaskit/smart-user-picker';
14
- import { CreateField } from '../../../../controllers/create-field';
15
- export var TEST_ID = 'link-create-user-picker';
16
- var DEFAULT_DEBOUNCE_TIME = 400;
17
- var UserPickerWidth = '100%';
18
-
19
- /**
20
- * A user picker utilising the SmartUserPicker.
21
- */
22
-
23
- export function UserPickerOld(_ref) {
24
- var productKey = _ref.productKey,
25
- siteId = _ref.siteId,
26
- name = _ref.name,
27
- label = _ref.label,
28
- placeholder = _ref.placeholder,
29
- validators = _ref.validators,
30
- _ref$testId = _ref.testId,
31
- testId = _ref$testId === void 0 ? TEST_ID : _ref$testId,
32
- defaultValue = _ref.defaultValue;
33
- return jsx(CreateField, {
34
- name: name,
35
- label: label,
36
- isRequired: true,
37
- testId: testId,
38
- validators: validators
39
- }, function (_ref2) {
40
- var fieldId = _ref2.fieldId,
41
- isRequired = _ref2.isRequired,
42
- fieldProps = _objectWithoutProperties(_ref2, _excluded);
43
- return jsx(SmartUserPicker, {
44
- defaultValue: defaultValue ? _objectSpread(_objectSpread({}, defaultValue), {}, {
45
- type: 'user'
46
- }) : undefined,
47
- placeholder: placeholder,
48
- onChange: function onChange(value) {
49
- return fieldProps.onChange(value);
50
- },
51
- subtle: true,
52
- isMulti: false,
53
- productKey: productKey,
54
- siteId: siteId,
55
- fieldId: fieldId,
56
- inputId: fieldId,
57
- debounceTime: DEFAULT_DEBOUNCE_TIME,
58
- prefetch: true,
59
- isClearable: false,
60
- width: UserPickerWidth,
61
- required: isRequired
62
- });
63
- });
64
- }