@atlaskit/link-create 2.14.0 → 2.15.1

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 (233) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/common/constants.js +4 -1
  3. package/dist/cjs/common/ui/error-boundary-modal/index.js +13 -10
  4. package/dist/cjs/common/ui/error-boundary-modal/old/index.js +34 -0
  5. package/dist/cjs/common/ui/error-boundary-ui/error-svg/index.compiled.css +6 -0
  6. package/dist/cjs/common/ui/error-boundary-ui/error-svg/index.js +32 -25
  7. package/dist/cjs/common/ui/error-boundary-ui/error-svg/old/index.js +67 -0
  8. package/dist/cjs/common/ui/icon/index.compiled.css +7 -0
  9. package/dist/cjs/common/ui/icon/index.js +25 -20
  10. package/dist/cjs/common/ui/icon/old/index.js +26 -0
  11. package/dist/cjs/common/ui/message/index.compiled.css +11 -0
  12. package/dist/cjs/common/ui/message/index.js +33 -40
  13. package/dist/cjs/common/ui/message/old/index.js +81 -0
  14. package/dist/cjs/common/ui/modal-hero/index.js +11 -3
  15. package/dist/cjs/common/ui/modal-hero/old/index.js +27 -0
  16. package/dist/cjs/controllers/create-field/main.compiled.css +1 -0
  17. package/dist/cjs/controllers/create-field/main.js +30 -21
  18. package/dist/cjs/controllers/create-field/old/main.js +76 -0
  19. package/dist/cjs/ui/create-form/async-select/main.js +15 -10
  20. package/dist/cjs/ui/create-form/async-select/old/main.js +195 -0
  21. package/dist/cjs/ui/create-form/form-footer/main.compiled.css +5 -0
  22. package/dist/cjs/ui/create-form/form-footer/main.js +28 -28
  23. package/dist/cjs/ui/create-form/form-footer/old/main.js +64 -0
  24. package/dist/cjs/ui/create-form/form-loader/main.compiled.css +4 -0
  25. package/dist/cjs/ui/create-form/form-loader/main.js +22 -21
  26. package/dist/cjs/ui/create-form/form-loader/old/main.js +39 -0
  27. package/dist/cjs/ui/create-form/main.compiled.css +9 -0
  28. package/dist/cjs/ui/create-form/main.js +26 -21
  29. package/dist/cjs/ui/create-form/old/main.js +177 -0
  30. package/dist/cjs/ui/create-form/select/main.js +41 -20
  31. package/dist/cjs/ui/create-form/select/old/main.js +127 -0
  32. package/dist/cjs/ui/create-form/textfield/main.js +14 -13
  33. package/dist/cjs/ui/create-form/textfield/old/main.js +55 -0
  34. package/dist/cjs/ui/create-form/user-picker/main.js +14 -13
  35. package/dist/cjs/ui/create-form/user-picker/old/main.js +72 -0
  36. package/dist/cjs/ui/inline-create/index.js +17 -14
  37. package/dist/cjs/ui/inline-create/main.js +21 -19
  38. package/dist/cjs/ui/inline-create/old/index.js +38 -0
  39. package/dist/cjs/ui/inline-create/old/main.js +120 -0
  40. package/dist/cjs/ui/modal-create/index.js +19 -16
  41. package/dist/cjs/ui/modal-create/main.js +26 -23
  42. package/dist/cjs/ui/modal-create/old/index.js +44 -0
  43. package/dist/cjs/ui/modal-create/old/main.js +164 -0
  44. package/dist/es2019/common/constants.js +4 -1
  45. package/dist/es2019/common/ui/error-boundary-modal/index.js +12 -9
  46. package/dist/es2019/common/ui/error-boundary-modal/old/index.js +26 -0
  47. package/dist/es2019/common/ui/error-boundary-ui/error-svg/index.compiled.css +6 -0
  48. package/dist/es2019/common/ui/error-boundary-ui/error-svg/index.js +24 -23
  49. package/dist/es2019/common/ui/error-boundary-ui/error-svg/old/index.js +58 -0
  50. package/dist/es2019/common/ui/icon/index.compiled.css +7 -0
  51. package/dist/es2019/common/ui/icon/index.js +23 -18
  52. package/dist/es2019/common/ui/icon/old/index.js +18 -0
  53. package/dist/es2019/common/ui/message/index.compiled.css +11 -0
  54. package/dist/es2019/common/ui/message/index.js +30 -39
  55. package/dist/es2019/common/ui/message/old/index.js +74 -0
  56. package/dist/es2019/common/ui/modal-hero/index.js +10 -2
  57. package/dist/es2019/common/ui/modal-hero/old/index.js +19 -0
  58. package/dist/es2019/controllers/create-field/main.compiled.css +1 -0
  59. package/dist/es2019/controllers/create-field/main.js +26 -23
  60. package/dist/es2019/controllers/create-field/old/main.js +74 -0
  61. package/dist/es2019/ui/create-form/async-select/main.js +12 -11
  62. package/dist/es2019/ui/create-form/async-select/old/main.js +137 -0
  63. package/dist/es2019/ui/create-form/form-footer/main.compiled.css +5 -0
  64. package/dist/es2019/ui/create-form/form-footer/main.js +25 -27
  65. package/dist/es2019/ui/create-form/form-footer/old/main.js +57 -0
  66. package/dist/es2019/ui/create-form/form-loader/main.compiled.css +4 -0
  67. package/dist/es2019/ui/create-form/form-loader/main.js +19 -20
  68. package/dist/es2019/ui/create-form/form-loader/old/main.js +31 -0
  69. package/dist/es2019/ui/create-form/main.compiled.css +9 -0
  70. package/dist/es2019/ui/create-form/main.js +23 -23
  71. package/dist/es2019/ui/create-form/old/main.js +145 -0
  72. package/dist/es2019/ui/create-form/select/main.js +42 -22
  73. package/dist/es2019/ui/create-form/select/old/main.js +106 -0
  74. package/dist/es2019/ui/create-form/textfield/main.js +14 -12
  75. package/dist/es2019/ui/create-form/textfield/old/main.js +45 -0
  76. package/dist/es2019/ui/create-form/user-picker/main.js +14 -12
  77. package/dist/es2019/ui/create-form/user-picker/old/main.js +59 -0
  78. package/dist/es2019/ui/inline-create/index.js +14 -13
  79. package/dist/es2019/ui/inline-create/main.js +21 -18
  80. package/dist/es2019/ui/inline-create/old/index.js +30 -0
  81. package/dist/es2019/ui/inline-create/old/main.js +96 -0
  82. package/dist/es2019/ui/modal-create/index.js +16 -15
  83. package/dist/es2019/ui/modal-create/main.js +23 -22
  84. package/dist/es2019/ui/modal-create/old/index.js +36 -0
  85. package/dist/es2019/ui/modal-create/old/main.js +137 -0
  86. package/dist/esm/common/constants.js +4 -1
  87. package/dist/esm/common/ui/error-boundary-modal/index.js +12 -9
  88. package/dist/esm/common/ui/error-boundary-modal/old/index.js +25 -0
  89. package/dist/esm/common/ui/error-boundary-ui/error-svg/index.compiled.css +6 -0
  90. package/dist/esm/common/ui/error-boundary-ui/error-svg/index.js +28 -24
  91. package/dist/esm/common/ui/error-boundary-ui/error-svg/old/index.js +60 -0
  92. package/dist/esm/common/ui/icon/index.compiled.css +7 -0
  93. package/dist/esm/common/ui/icon/index.js +23 -18
  94. package/dist/esm/common/ui/icon/old/index.js +18 -0
  95. package/dist/esm/common/ui/message/index.compiled.css +11 -0
  96. package/dist/esm/common/ui/message/index.js +30 -39
  97. package/dist/esm/common/ui/message/old/index.js +73 -0
  98. package/dist/esm/common/ui/modal-hero/index.js +10 -2
  99. package/dist/esm/common/ui/modal-hero/old/index.js +18 -0
  100. package/dist/esm/controllers/create-field/main.compiled.css +1 -0
  101. package/dist/esm/controllers/create-field/main.js +25 -22
  102. package/dist/esm/controllers/create-field/old/main.js +72 -0
  103. package/dist/esm/ui/create-form/async-select/main.js +12 -11
  104. package/dist/esm/ui/create-form/async-select/old/main.js +188 -0
  105. package/dist/esm/ui/create-form/form-footer/main.compiled.css +5 -0
  106. package/dist/esm/ui/create-form/form-footer/main.js +24 -26
  107. package/dist/esm/ui/create-form/form-footer/old/main.js +56 -0
  108. package/dist/esm/ui/create-form/form-loader/main.compiled.css +4 -0
  109. package/dist/esm/ui/create-form/form-loader/main.js +18 -19
  110. package/dist/esm/ui/create-form/form-loader/old/main.js +31 -0
  111. package/dist/esm/ui/create-form/main.compiled.css +9 -0
  112. package/dist/esm/ui/create-form/main.js +23 -23
  113. package/dist/esm/ui/create-form/old/main.js +174 -0
  114. package/dist/esm/ui/create-form/select/main.js +41 -21
  115. package/dist/esm/ui/create-form/select/old/main.js +117 -0
  116. package/dist/esm/ui/create-form/textfield/main.js +13 -11
  117. package/dist/esm/ui/create-form/textfield/old/main.js +47 -0
  118. package/dist/esm/ui/create-form/user-picker/main.js +13 -11
  119. package/dist/esm/ui/create-form/user-picker/old/main.js +64 -0
  120. package/dist/esm/ui/inline-create/index.js +14 -13
  121. package/dist/esm/ui/inline-create/main.js +21 -18
  122. package/dist/esm/ui/inline-create/old/index.js +30 -0
  123. package/dist/esm/ui/inline-create/old/main.js +112 -0
  124. package/dist/esm/ui/modal-create/index.js +16 -15
  125. package/dist/esm/ui/modal-create/main.js +23 -22
  126. package/dist/esm/ui/modal-create/old/index.js +36 -0
  127. package/dist/esm/ui/modal-create/old/main.js +156 -0
  128. package/dist/types/common/constants.d.ts +3 -0
  129. package/dist/types/common/ui/ModalDialog/index.d.ts +1 -1
  130. package/dist/types/common/ui/confirm-dismiss-dialog/main.d.ts +2 -2
  131. package/dist/types/common/ui/edit-modal/index.d.ts +1 -1
  132. package/dist/types/common/ui/error-boundary/error-boundary-base/index.d.ts +1 -1
  133. package/dist/types/common/ui/error-boundary/index.d.ts +2 -2
  134. package/dist/types/common/ui/error-boundary-modal/index.d.ts +2 -2
  135. package/dist/types/common/ui/error-boundary-modal/old/index.d.ts +11 -0
  136. package/dist/types/common/ui/error-boundary-ui/error-svg/index.d.ts +2 -6
  137. package/dist/types/common/ui/error-boundary-ui/error-svg/old/index.d.ts +7 -0
  138. package/dist/types/common/ui/error-boundary-ui/index.d.ts +2 -2
  139. package/dist/types/common/ui/experience-tracker/index.d.ts +1 -1
  140. package/dist/types/common/ui/icon/index.d.ts +10 -6
  141. package/dist/types/common/ui/icon/old/index.d.ts +7 -0
  142. package/dist/types/common/ui/link-create-content/index.d.ts +2 -2
  143. package/dist/types/common/ui/message/index.d.ts +1 -2
  144. package/dist/types/common/ui/message/old/index.d.ts +15 -0
  145. package/dist/types/common/ui/modal-hero/index.d.ts +4 -2
  146. package/dist/types/common/ui/modal-hero/old/index.d.ts +4 -0
  147. package/dist/types/controllers/callback-context/main.d.ts +2 -2
  148. package/dist/types/controllers/create-field/main.d.ts +2 -2
  149. package/dist/types/controllers/create-field/old/main.d.ts +7 -0
  150. package/dist/types/controllers/edit-post-create-context/index.d.ts +1 -1
  151. package/dist/types/controllers/exit-warning-modal-context/index.d.ts +1 -1
  152. package/dist/types/controllers/form-context/main.d.ts +2 -2
  153. package/dist/types/controllers/plugin-context/index.d.ts +1 -1
  154. package/dist/types/ui/create-form/async-select/main.d.ts +2 -8
  155. package/dist/types/ui/create-form/async-select/old/main.d.ts +11 -0
  156. package/dist/types/ui/create-form/form-footer/edit-button/index.d.ts +2 -2
  157. package/dist/types/ui/create-form/form-footer/main.d.ts +2 -11
  158. package/dist/types/ui/create-form/form-footer/old/main.d.ts +16 -0
  159. package/dist/types/ui/create-form/form-footer/submit-button/index.d.ts +2 -2
  160. package/dist/types/ui/create-form/form-loader/main.d.ts +2 -10
  161. package/dist/types/ui/create-form/form-loader/old/main.d.ts +11 -0
  162. package/dist/types/ui/create-form/form-spy/index.d.ts +1 -1
  163. package/dist/types/ui/create-form/main.d.ts +1 -2
  164. package/dist/types/ui/create-form/old/main.d.ts +54 -0
  165. package/dist/types/ui/create-form/select/main.d.ts +5 -16
  166. package/dist/types/ui/create-form/select/old/main.d.ts +24 -0
  167. package/dist/types/ui/create-form/textfield/main.d.ts +2 -12
  168. package/dist/types/ui/create-form/textfield/old/main.d.ts +14 -0
  169. package/dist/types/ui/create-form/user-picker/main.d.ts +2 -9
  170. package/dist/types/ui/create-form/user-picker/old/main.d.ts +11 -0
  171. package/dist/types/ui/inline-create/index.d.ts +2 -3
  172. package/dist/types/ui/inline-create/inline-analytics/index.d.ts +2 -2
  173. package/dist/types/ui/inline-create/main.d.ts +2 -6
  174. package/dist/types/ui/inline-create/old/index.d.ts +5 -0
  175. package/dist/types/ui/inline-create/old/main.d.ts +8 -0
  176. package/dist/types/ui/modal-create/index.d.ts +2 -3
  177. package/dist/types/ui/modal-create/main.d.ts +2 -2
  178. package/dist/types/ui/modal-create/old/index.d.ts +5 -0
  179. package/dist/types/ui/modal-create/old/main.d.ts +4 -0
  180. package/dist/types-ts4.5/common/constants.d.ts +3 -0
  181. package/dist/types-ts4.5/common/ui/ModalDialog/index.d.ts +1 -1
  182. package/dist/types-ts4.5/common/ui/confirm-dismiss-dialog/main.d.ts +2 -2
  183. package/dist/types-ts4.5/common/ui/edit-modal/index.d.ts +1 -1
  184. package/dist/types-ts4.5/common/ui/error-boundary/error-boundary-base/index.d.ts +1 -1
  185. package/dist/types-ts4.5/common/ui/error-boundary/index.d.ts +2 -2
  186. package/dist/types-ts4.5/common/ui/error-boundary-modal/index.d.ts +2 -2
  187. package/dist/types-ts4.5/common/ui/error-boundary-modal/old/index.d.ts +11 -0
  188. package/dist/types-ts4.5/common/ui/error-boundary-ui/error-svg/index.d.ts +2 -6
  189. package/dist/types-ts4.5/common/ui/error-boundary-ui/error-svg/old/index.d.ts +7 -0
  190. package/dist/types-ts4.5/common/ui/error-boundary-ui/index.d.ts +2 -2
  191. package/dist/types-ts4.5/common/ui/experience-tracker/index.d.ts +1 -1
  192. package/dist/types-ts4.5/common/ui/icon/index.d.ts +10 -6
  193. package/dist/types-ts4.5/common/ui/icon/old/index.d.ts +7 -0
  194. package/dist/types-ts4.5/common/ui/link-create-content/index.d.ts +2 -2
  195. package/dist/types-ts4.5/common/ui/message/index.d.ts +1 -2
  196. package/dist/types-ts4.5/common/ui/message/old/index.d.ts +15 -0
  197. package/dist/types-ts4.5/common/ui/modal-hero/index.d.ts +4 -2
  198. package/dist/types-ts4.5/common/ui/modal-hero/old/index.d.ts +4 -0
  199. package/dist/types-ts4.5/controllers/callback-context/main.d.ts +2 -2
  200. package/dist/types-ts4.5/controllers/create-field/main.d.ts +2 -2
  201. package/dist/types-ts4.5/controllers/create-field/old/main.d.ts +7 -0
  202. package/dist/types-ts4.5/controllers/edit-post-create-context/index.d.ts +1 -1
  203. package/dist/types-ts4.5/controllers/exit-warning-modal-context/index.d.ts +1 -1
  204. package/dist/types-ts4.5/controllers/form-context/main.d.ts +2 -2
  205. package/dist/types-ts4.5/controllers/plugin-context/index.d.ts +1 -1
  206. package/dist/types-ts4.5/ui/create-form/async-select/main.d.ts +2 -8
  207. package/dist/types-ts4.5/ui/create-form/async-select/old/main.d.ts +11 -0
  208. package/dist/types-ts4.5/ui/create-form/form-footer/edit-button/index.d.ts +2 -2
  209. package/dist/types-ts4.5/ui/create-form/form-footer/main.d.ts +2 -11
  210. package/dist/types-ts4.5/ui/create-form/form-footer/old/main.d.ts +16 -0
  211. package/dist/types-ts4.5/ui/create-form/form-footer/submit-button/index.d.ts +2 -2
  212. package/dist/types-ts4.5/ui/create-form/form-loader/main.d.ts +2 -10
  213. package/dist/types-ts4.5/ui/create-form/form-loader/old/main.d.ts +11 -0
  214. package/dist/types-ts4.5/ui/create-form/form-spy/index.d.ts +1 -1
  215. package/dist/types-ts4.5/ui/create-form/main.d.ts +1 -2
  216. package/dist/types-ts4.5/ui/create-form/old/main.d.ts +56 -0
  217. package/dist/types-ts4.5/ui/create-form/select/main.d.ts +5 -16
  218. package/dist/types-ts4.5/ui/create-form/select/old/main.d.ts +24 -0
  219. package/dist/types-ts4.5/ui/create-form/textfield/main.d.ts +2 -12
  220. package/dist/types-ts4.5/ui/create-form/textfield/old/main.d.ts +14 -0
  221. package/dist/types-ts4.5/ui/create-form/user-picker/main.d.ts +2 -9
  222. package/dist/types-ts4.5/ui/create-form/user-picker/old/main.d.ts +11 -0
  223. package/dist/types-ts4.5/ui/inline-create/index.d.ts +2 -3
  224. package/dist/types-ts4.5/ui/inline-create/inline-analytics/index.d.ts +2 -2
  225. package/dist/types-ts4.5/ui/inline-create/main.d.ts +2 -6
  226. package/dist/types-ts4.5/ui/inline-create/old/index.d.ts +5 -0
  227. package/dist/types-ts4.5/ui/inline-create/old/main.d.ts +8 -0
  228. package/dist/types-ts4.5/ui/modal-create/index.d.ts +2 -3
  229. package/dist/types-ts4.5/ui/modal-create/main.d.ts +2 -2
  230. package/dist/types-ts4.5/ui/modal-create/old/index.d.ts +5 -0
  231. package/dist/types-ts4.5/ui/modal-create/old/main.d.ts +4 -0
  232. package/example-helpers/mock-disclaimer.tsx +1 -1
  233. package/package.json +18 -7
@@ -1,20 +1,15 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- /**
3
- * @jsxRuntime classic
4
- * @jsx jsx
5
- */
6
- import { useEffect, useMemo, useState } from 'react';
7
-
8
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
9
- import { jsx } from '@emotion/react';
2
+ import React, { useEffect, useMemo, useState } from 'react';
10
3
  import debounce from 'debounce-promise';
11
4
  import { useForm } from 'react-final-form';
12
5
  import { useIntl } from 'react-intl-next';
6
+ import { fg } from '@atlaskit/platform-feature-flags';
13
7
  import { AsyncSelect as AkAsyncSelect } from '@atlaskit/select';
14
8
  import messages from '../../../common/messages';
15
9
  import { useLinkCreateCallback } from '../../../controllers/callback-context';
16
10
  import { CreateField } from '../../../controllers/create-field';
17
11
  import { useFormContext } from '../../../controllers/form-context';
12
+ import { AsyncSelectOld } from './old/main';
18
13
  export const TEST_ID = 'link-create-async-select';
19
14
 
20
15
  /**
@@ -23,7 +18,7 @@ export const TEST_ID = 'link-create-async-select';
23
18
  * errors returned by the handleSubmit function passed to the form <Form> that
24
19
  * have a key matching the `name` of this field are shown below the field.
25
20
  */
26
- export function AsyncSelect({
21
+ function AsyncSelectNew({
27
22
  id,
28
23
  name,
29
24
  label,
@@ -111,7 +106,7 @@ export function AsyncSelect({
111
106
  }
112
107
  }, [defaultValue, propsDefaultValue, name, mutators]);
113
108
  const debouncedLoadOptions = useMemo(() => loadOptions ? debounce(loadOptions, 300) : undefined, [loadOptions]);
114
- return jsx(CreateField, {
109
+ return /*#__PURE__*/React.createElement(CreateField, {
115
110
  id: id,
116
111
  name: name,
117
112
  label: label,
@@ -124,7 +119,7 @@ export function AsyncSelect({
124
119
  isRequired,
125
120
  ...fieldProps
126
121
  }) => {
127
- return jsx(AkAsyncSelect, _extends({
122
+ return /*#__PURE__*/React.createElement(AkAsyncSelect, _extends({
128
123
  inputId: fieldId
129
124
  }, fieldProps, restProps, {
130
125
  required: isRequired,
@@ -133,4 +128,10 @@ export function AsyncSelect({
133
128
  isLoading: isLoadingDefaultOptions
134
129
  }));
135
130
  });
131
+ }
132
+ export function AsyncSelect(props) {
133
+ if (fg('platform_bandicoots-link-create-css')) {
134
+ return /*#__PURE__*/React.createElement(AsyncSelectNew, props);
135
+ }
136
+ return /*#__PURE__*/React.createElement(AsyncSelectOld, props);
136
137
  }
@@ -0,0 +1,137 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ /* eslint-disable @atlassian/tangerine/import/no-parent-imports */
3
+ /**
4
+ * @jsxRuntime classic
5
+ * @jsx jsx
6
+ */
7
+ import { useEffect, useMemo, useState } from 'react';
8
+
9
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
10
+ import { jsx } from '@emotion/react';
11
+ import debounce from 'debounce-promise';
12
+ import { useForm } from 'react-final-form';
13
+ import { useIntl } from 'react-intl-next';
14
+ import { AsyncSelect as AkAsyncSelect } from '@atlaskit/select';
15
+ import messages from '../../../../common/messages';
16
+ import { useLinkCreateCallback } from '../../../../controllers/callback-context';
17
+ import { CreateField } from '../../../../controllers/create-field';
18
+ import { useFormContext } from '../../../../controllers/form-context';
19
+ export const TEST_ID = 'link-create-async-select';
20
+
21
+ /**
22
+ * An async select utilising the Atlaskit AsyncSelect and CreateField.
23
+ * Validation is handled by the form on form submission. Any
24
+ * errors returned by the handleSubmit function passed to the form <Form> that
25
+ * have a key matching the `name` of this field are shown below the field.
26
+ */
27
+ export function AsyncSelectOld({
28
+ id,
29
+ name,
30
+ label,
31
+ isRequired,
32
+ validators,
33
+ validationHelpText,
34
+ testId = TEST_ID,
35
+ //@ts-ignore react-select unsupported props
36
+ defaultOption: propsDefaultValue,
37
+ loadOptions: loadOptionsFn,
38
+ ...restProps
39
+ }) {
40
+ const {
41
+ mutators
42
+ } = useForm();
43
+ const {
44
+ onFailure
45
+ } = useLinkCreateCallback();
46
+ const {
47
+ setFormErrorMessage
48
+ } = useFormContext();
49
+ const intl = useIntl();
50
+ const [defaultValue, setDefaultValue] = useState(propsDefaultValue);
51
+ const [isLoadingDefaultOptions, setIsLoadingDefaultOptions] = useState(false);
52
+ const [defaultOptions, setDefaultOptions] = useState([]);
53
+
54
+ /**
55
+ * This binds experience to fail if async fetch ever fails to load
56
+ */
57
+ const loadOptions = useMemo(() => {
58
+ if (loadOptionsFn) {
59
+ return async function (...args) {
60
+ try {
61
+ return await loadOptionsFn(...args);
62
+ } catch (err) {
63
+ onFailure === null || onFailure === void 0 ? void 0 : onFailure(err);
64
+ setFormErrorMessage(intl.formatMessage(messages.genericErrorMessage));
65
+ return [];
66
+ }
67
+ };
68
+ }
69
+ }, [intl, onFailure, loadOptionsFn, setFormErrorMessage]);
70
+ useEffect(() => {
71
+ let current = true;
72
+ const fetch = async (query = '') => {
73
+ if (!loadOptions) {
74
+ return;
75
+ }
76
+ try {
77
+ /**
78
+ * If we are fetching default options, clear the
79
+ * value the user has set
80
+ */
81
+ if (mutators.setField) {
82
+ mutators.setField(name, null);
83
+ }
84
+ setIsLoadingDefaultOptions(true);
85
+ setDefaultOptions([]);
86
+ const options = await loadOptions(query);
87
+ if (current) {
88
+ setDefaultOptions(options);
89
+ setIsLoadingDefaultOptions(false);
90
+ }
91
+ } catch (err) {
92
+ if (current) {
93
+ setIsLoadingDefaultOptions(false);
94
+ }
95
+ }
96
+ };
97
+ fetch();
98
+ return () => {
99
+ current = false;
100
+ };
101
+ }, [loadOptions, setIsLoadingDefaultOptions, setDefaultOptions, mutators, name]);
102
+ useEffect(() => {
103
+ /**
104
+ * Mutate the form state to set a default value for this field
105
+ * if `defaultOption` is a prop and we have not set a value for it yet
106
+ */
107
+ if (!defaultValue && propsDefaultValue) {
108
+ setDefaultValue(propsDefaultValue);
109
+ if (mutators.setField) {
110
+ mutators.setField(name, propsDefaultValue);
111
+ }
112
+ }
113
+ }, [defaultValue, propsDefaultValue, name, mutators]);
114
+ const debouncedLoadOptions = useMemo(() => loadOptions ? debounce(loadOptions, 300) : undefined, [loadOptions]);
115
+ return jsx(CreateField, {
116
+ id: id,
117
+ name: name,
118
+ label: label,
119
+ isRequired: isRequired,
120
+ validators: validators,
121
+ validationHelpText: validationHelpText,
122
+ testId: testId
123
+ }, ({
124
+ fieldId,
125
+ isRequired,
126
+ ...fieldProps
127
+ }) => {
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
+ });
137
+ }
@@ -0,0 +1,5 @@
1
+ ._19pk1ejb{margin-top:var(--ds-space-300,24px)}
2
+ ._1bahesu3{justify-content:flex-end}
3
+ ._1e0c1txw{display:flex}
4
+ ._2hwx1wug{margin-right:auto}
5
+ ._4cvr1h6o{align-items:center}
@@ -1,49 +1,41 @@
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';
1
+ /* main.tsx generated by @compiled/babel-plugin v0.36.0 */
2
+ import "./main.compiled.css";
3
+ import * as React from 'react';
4
+ import { ax, ix } from "@compiled/react/runtime";
7
5
  import { useIntl } from 'react-intl-next';
8
6
  import { ButtonGroup } from '@atlaskit/button';
9
7
  import ErrorIcon from '@atlaskit/icon/core/migration/error';
8
+ import { fg } from '@atlaskit/platform-feature-flags';
10
9
  import { Button } from '../../../common/ui/Button';
11
10
  import { EditButton } from './edit-button';
12
11
  import { messages } from './messages';
12
+ import { CreateFormFooterOld } from './old/main';
13
13
  import { SubmitButton } from './submit-button';
14
- const formFooterWrapperStyles = css({
15
- display: 'flex',
16
- marginTop: "var(--ds-space-300, 24px)",
17
- justifyContent: 'flex-end'
18
- });
19
- const errorStyles = css({
20
- display: 'flex',
21
- alignItems: 'center',
22
- marginRight: 'auto'
23
- });
14
+ const formFooterWrapperStyles = null;
15
+ const errorStyles = null;
24
16
  /**
25
17
  * Footer for the Create Form, used as a wrapper for action buttons
26
18
  * and form error messages. This component is unmounted if
27
19
  * hideFooter is true in the Create Form.
28
20
  */
29
- export function CreateFormFooter({
21
+ const CreateFormFooterNew = ({
30
22
  formErrorMessage,
31
23
  handleCancel,
32
24
  testId
33
- }) {
25
+ }) => {
34
26
  const intl = useIntl();
35
- return jsx("footer", {
27
+ return /*#__PURE__*/React.createElement("footer", {
36
28
  "data-testid": `${testId}-footer`,
37
- css: formFooterWrapperStyles
38
- }, formErrorMessage && jsx("div", {
29
+ className: ax(["_1e0c1txw _19pk1ejb _1bahesu3"])
30
+ }, formErrorMessage && /*#__PURE__*/React.createElement("div", {
39
31
  role: "alert",
40
- css: errorStyles,
41
- "data-testid": `${testId}-error`
42
- }, jsx(ErrorIcon, {
32
+ "data-testid": `${testId}-error`,
33
+ className: ax(["_1e0c1txw _4cvr1h6o _2hwx1wug"])
34
+ }, /*#__PURE__*/React.createElement(ErrorIcon, {
43
35
  label: formErrorMessage,
44
36
  color: "var(--ds-icon-danger, #E34935)",
45
37
  spacing: "spacious"
46
- }), formErrorMessage), jsx(ButtonGroup, null, jsx(Button, {
38
+ }), formErrorMessage), /*#__PURE__*/React.createElement(ButtonGroup, null, /*#__PURE__*/React.createElement(Button, {
47
39
  type: "button",
48
40
  actionSubjectId: "cancel",
49
41
  appearance: "subtle",
@@ -52,5 +44,11 @@ export function CreateFormFooter({
52
44
  handleCancel();
53
45
  },
54
46
  testId: `${testId}-button-cancel`
55
- }, intl.formatMessage(messages.close)), jsx(EditButton, null), jsx(SubmitButton, null)));
56
- }
47
+ }, intl.formatMessage(messages.close)), /*#__PURE__*/React.createElement(EditButton, null), /*#__PURE__*/React.createElement(SubmitButton, null)));
48
+ };
49
+ export const CreateFormFooter = props => {
50
+ if (fg('platform_bandicoots-link-create-css')) {
51
+ return /*#__PURE__*/React.createElement(CreateFormFooterNew, props);
52
+ }
53
+ return /*#__PURE__*/React.createElement(CreateFormFooterOld, props);
54
+ };
@@ -0,0 +1,57 @@
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
+ const formFooterWrapperStyles = css({
16
+ display: 'flex',
17
+ marginTop: "var(--ds-space-300, 24px)",
18
+ justifyContent: 'flex-end'
19
+ });
20
+ const 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({
31
+ formErrorMessage,
32
+ handleCancel,
33
+ testId
34
+ }) {
35
+ const intl = useIntl();
36
+ return jsx("footer", {
37
+ "data-testid": `${testId}-footer`,
38
+ css: formFooterWrapperStyles
39
+ }, formErrorMessage && jsx("div", {
40
+ role: "alert",
41
+ css: errorStyles,
42
+ "data-testid": `${testId}-error`
43
+ }, jsx(ErrorIcon, {
44
+ label: formErrorMessage,
45
+ color: "var(--ds-icon-danger, #E34935)",
46
+ spacing: "spacious"
47
+ }), formErrorMessage), jsx(ButtonGroup, null, jsx(Button, {
48
+ type: "button",
49
+ actionSubjectId: "cancel",
50
+ appearance: "subtle",
51
+ onClick: e => {
52
+ e.stopPropagation();
53
+ handleCancel();
54
+ },
55
+ testId: `${testId}-button-cancel`
56
+ }, intl.formatMessage(messages.close)), jsx(EditButton, null), jsx(SubmitButton, null)));
57
+ }
@@ -0,0 +1,4 @@
1
+ ._1bah1h6o{justify-content:center}
2
+ ._1e0c1txw{display:flex}
3
+ ._1tkeuuw1{min-height:200px}
4
+ ._4cvr1h6o{align-items:center}
@@ -1,31 +1,30 @@
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';
1
+ /* main.tsx generated by @compiled/babel-plugin v0.36.0 */
2
+ import "./main.compiled.css";
3
+ import * as React from 'react';
4
+ import { ax, ix } from "@compiled/react/runtime";
5
+ import { fg } from '@atlaskit/platform-feature-flags';
7
6
  import Spinner from '@atlaskit/spinner';
8
- import { CREATE_FORM_MIN_HEIGHT_IN_PX } from '../../../common/constants';
9
- const 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: `${CREATE_FORM_MIN_HEIGHT_IN_PX}px`
15
- });
7
+ import { CreateFormLoaderOld } from './old/main';
8
+ const formLoaderStyles = null;
16
9
 
17
10
  /**
18
11
  * Wrapper component for the Spinner, shows while the form
19
12
  * performs async functions on load.
20
13
  */
21
- export function CreateFormLoader({
14
+ const CreateFormLoaderNew = ({
22
15
  size = 'large'
23
- }) {
24
- return jsx("div", {
25
- css: formLoaderStyles
26
- }, jsx(Spinner, {
16
+ }) => {
17
+ return /*#__PURE__*/React.createElement("div", {
18
+ className: ax(["_1e0c1txw _4cvr1h6o _1bah1h6o _1tkeuuw1"])
19
+ }, /*#__PURE__*/React.createElement(Spinner, {
27
20
  size: size,
28
21
  interactionName: "load",
29
22
  testId: "link-create-form-loader"
30
23
  }));
31
- }
24
+ };
25
+ export const CreateFormLoader = props => {
26
+ if (fg('platform_bandicoots-link-create-css')) {
27
+ return /*#__PURE__*/React.createElement(CreateFormLoaderNew, props);
28
+ }
29
+ return /*#__PURE__*/React.createElement(CreateFormLoaderOld, props);
30
+ };
@@ -0,0 +1,31 @@
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
+ const 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: `${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({
22
+ size = 'large'
23
+ }) {
24
+ return jsx("div", {
25
+ css: formLoaderStyles
26
+ }, jsx(Spinner, {
27
+ size: size,
28
+ interactionName: "load",
29
+ testId: "link-create-form-loader"
30
+ }));
31
+ }
@@ -0,0 +1,9 @@
1
+ ._18u01wug{margin-left:auto}
2
+ ._19bvidpf{padding-left:0}
3
+ ._19pkze3t{margin-top:var(--ds-space-0,0)}
4
+ ._2hwx1wug{margin-right:auto}
5
+ ._ca0qidpf{padding-top:0}
6
+ ._n3td1ejb{padding-bottom:var(--ds-space-300,24px)}
7
+ ._otyrze3t{margin-bottom:var(--ds-space-0,0)}
8
+ ._p12f1y37{max-width:5in}
9
+ ._u5f3idpf{padding-right:0}
@@ -1,32 +1,26 @@
1
- /**
2
- * @jsxRuntime classic
3
- * @jsx jsx
4
- */
1
+ /* main.tsx generated by @compiled/babel-plugin v0.36.0 */
2
+ import "./main.compiled.css";
3
+ import * as React from 'react';
4
+ import { ax, ix } from "@compiled/react/runtime";
5
5
  import { useCallback } from 'react';
6
-
7
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
8
- import { css, jsx } from '@emotion/react';
9
6
  import { FORM_ERROR } from 'final-form';
10
7
  import { Form, FormSpy } from 'react-final-form';
11
8
  import { useIntl } from 'react-intl-next';
12
9
  import { RequiredAsterisk } from '@atlaskit/form';
13
- import { Box, Text } from '@atlaskit/primitives';
14
- import { CREATE_FORM_MAX_WIDTH_IN_PX, LINK_CREATE_FORM_POST_CREATE_FIELD } from '../../common/constants';
10
+ import { fg } from '@atlaskit/platform-feature-flags';
11
+ import { Box, Text } from '@atlaskit/primitives/compiled';
12
+ import { LINK_CREATE_FORM_POST_CREATE_FIELD } from '../../common/constants';
15
13
  import messages from '../../common/messages';
16
14
  import { useLinkCreateCallback } from '../../controllers/callback-context';
17
15
  import { useExitWarningModal } from '../../controllers/exit-warning-modal-context';
18
16
  import { useFormContext } from '../../controllers/form-context';
19
17
  import { CreateFormFooter } from './form-footer';
20
18
  import { CreateFormLoader } from './form-loader';
21
- const formStyles = css({
22
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
23
- maxWidth: `${CREATE_FORM_MAX_WIDTH_IN_PX}px`,
24
- padding: `0 0 ${"var(--ds-space-300, 24px)"} 0`,
25
- margin: `${"var(--ds-space-0, 0px)"} auto`
26
- });
19
+ import { CreateFormOld } from './old/main';
20
+ const formStyles = null;
27
21
  const RESERVED_FIELDS = [LINK_CREATE_FORM_POST_CREATE_FIELD];
28
22
  export const TEST_ID = 'link-create-form';
29
- export const CreateForm = ({
23
+ const CreateFormNew = ({
30
24
  children,
31
25
  testId = TEST_ID,
32
26
  onSubmit,
@@ -94,9 +88,9 @@ export const CreateForm = ({
94
88
  onCancel && onCancel();
95
89
  }, [onCancel]);
96
90
  if (isLoading) {
97
- return jsx(CreateFormLoader, null);
91
+ return /*#__PURE__*/React.createElement(CreateFormLoader, null);
98
92
  }
99
- return jsx(Form, {
93
+ return /*#__PURE__*/React.createElement(Form, {
100
94
  onSubmit: handleSubmitWithErrorHandling,
101
95
  initialValues: initialValues,
102
96
  mutators: {
@@ -108,13 +102,13 @@ export const CreateForm = ({
108
102
  submitError,
109
103
  ...formProps
110
104
  }) => {
111
- return jsx("form", {
105
+ return /*#__PURE__*/React.createElement("form", {
112
106
  onSubmit: formProps.handleSubmit,
113
107
  name: "link-create-form",
114
108
  noValidate: true,
115
109
  "data-testid": testId,
116
- css: formStyles
117
- }, jsx(FormSpy, {
110
+ className: ax(["_p12f1y37 _ca0qidpf _u5f3idpf _n3td1ejb _19bvidpf _19pkze3t _2hwx1wug _otyrze3t _18u01wug"])
111
+ }, /*#__PURE__*/React.createElement(FormSpy, {
118
112
  subscription: {
119
113
  modified: true
120
114
  },
@@ -127,9 +121,9 @@ export const CreateForm = ({
127
121
  const isModified = Object.values(state.modified).some(value => value);
128
122
  setShouldShowWarning(isModified);
129
123
  }
130
- }), !hideRequiredFieldMessage && jsx(Text, {
124
+ }), !hideRequiredFieldMessage && /*#__PURE__*/React.createElement(Text, {
131
125
  as: "p"
132
- }, intl.formatMessage(messages.requiredFieldInstruction), " ", jsx(RequiredAsterisk, null)), jsx(Box, null, children), !hideFooter && jsx(CreateFormFooter
126
+ }, intl.formatMessage(messages.requiredFieldInstruction), " ", /*#__PURE__*/React.createElement(RequiredAsterisk, null)), /*#__PURE__*/React.createElement(Box, null, children), !hideFooter && /*#__PURE__*/React.createElement(CreateFormFooter
133
127
  /**
134
128
  * We will prefer to render the error message connected to
135
129
  * react final form state (submitError) otherwise we can
@@ -141,4 +135,10 @@ export const CreateForm = ({
141
135
  testId: testId
142
136
  }));
143
137
  });
138
+ };
139
+ export const CreateForm = props => {
140
+ if (fg('platform_bandicoots-link-create-css')) {
141
+ return /*#__PURE__*/React.createElement(CreateFormNew, props);
142
+ }
143
+ return /*#__PURE__*/React.createElement(CreateFormOld, props);
144
144
  };