@atlaskit/link-create 0.8.1 → 0.9.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 (31) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/common/utils/locale/fetch-messages-for-locale.js +1 -1
  3. package/dist/cjs/ui/create-form/async-select/main.js +8 -2
  4. package/dist/cjs/ui/create-form/main.js +9 -6
  5. package/dist/cjs/ui/create-form/textfield/main.js +13 -4
  6. package/dist/cjs/ui/link-create/main.js +6 -3
  7. package/dist/cjs/version.json +1 -1
  8. package/dist/es2019/common/utils/locale/fetch-messages-for-locale.js +1 -1
  9. package/dist/es2019/ui/create-form/async-select/main.js +5 -2
  10. package/dist/es2019/ui/create-form/main.js +6 -5
  11. package/dist/es2019/ui/create-form/textfield/main.js +9 -2
  12. package/dist/es2019/ui/link-create/main.js +3 -2
  13. package/dist/es2019/version.json +1 -1
  14. package/dist/esm/common/utils/locale/fetch-messages-for-locale.js +1 -1
  15. package/dist/esm/ui/create-form/async-select/main.js +6 -2
  16. package/dist/esm/ui/create-form/main.js +7 -5
  17. package/dist/esm/ui/create-form/textfield/main.js +11 -3
  18. package/dist/esm/ui/link-create/main.js +4 -2
  19. package/dist/esm/version.json +1 -1
  20. package/dist/types/ui/create-form/async-select/main.d.ts +1 -0
  21. package/dist/types/ui/create-form/main.d.ts +1 -0
  22. package/dist/types/ui/create-form/textfield/main.d.ts +2 -1
  23. package/dist/types/ui/link-create/main.d.ts +1 -0
  24. package/dist/types-ts4.5/ui/create-form/async-select/main.d.ts +1 -0
  25. package/dist/types-ts4.5/ui/create-form/main.d.ts +1 -0
  26. package/dist/types-ts4.5/ui/create-form/textfield/main.d.ts +2 -1
  27. package/dist/types-ts4.5/ui/link-create/main.d.ts +1 -0
  28. package/example-helpers/mock-plugin-form.tsx +91 -0
  29. package/package.json +2 -2
  30. package/report.api.md +1 -0
  31. package/tmp/api-report-tmp.d.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/link-create
2
2
 
3
+ ## 0.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`c209f670761`](https://bitbucket.org/atlassian/atlassian-frontend/commits/c209f670761) - Improved testIds
8
+
9
+ ## 0.8.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [`90ad796d91c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/90ad796d91c) - Fix fetching hyphened locales to underscores
14
+
3
15
  ## 0.8.1
4
16
 
5
17
  ### Patch Changes
@@ -25,7 +25,7 @@ var fetchMessagesForLocale = /*#__PURE__*/function () {
25
25
  }).then(function (s) {
26
26
  return _interopRequireWildcard(require(s));
27
27
  });
28
- }( /* webpackChunkName: "@atlaskit-internal_@atlassian/link-create-confluence-i18n-[request]" */"../../../i18n/".concat(locale));
28
+ }( /* webpackChunkName: "@atlaskit-internal_@atlassian/link-create-confluence-i18n-[request]" */"../../../i18n/".concat(locale.replace('-', '_')));
29
29
  case 3:
30
30
  _messages = _context.sent;
31
31
  return _context.abrupt("return", _messages.default);
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.AsyncSelect = AsyncSelect;
8
+ exports.TEST_ID = void 0;
8
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
10
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
11
  var _react = require("react");
@@ -15,18 +16,21 @@ var _form2 = require("../../../common/utils/form");
15
16
  var _formContext = require("../../../controllers/form-context");
16
17
  var _excluded = ["label", "name", "validationHelpText", "isRequired", "testId", "validators", "defaultValue"];
17
18
  /** @jsx jsx */
19
+ var TEST_ID = 'link-create-async-select';
18
20
  /**
19
21
  * An async select utilising the Atlaskit AsyncSelect and Field objects from `@atlaskit/form`.
20
22
  * Validation is handled by the form as it is on form submission. Any errors returned by
21
23
  * the handleSubmit function passed to the form <Form> that have a key matching the `name`
22
24
  * of this text field are shown above the field.
23
25
  */
26
+ exports.TEST_ID = TEST_ID;
24
27
  function AsyncSelect(_ref) {
25
28
  var label = _ref.label,
26
29
  name = _ref.name,
27
30
  validationHelpText = _ref.validationHelpText,
28
31
  isRequired = _ref.isRequired,
29
- testId = _ref.testId,
32
+ _ref$testId = _ref.testId,
33
+ testId = _ref$testId === void 0 ? TEST_ID : _ref$testId,
30
34
  validators = _ref.validators,
31
35
  defaultValue = _ref.defaultValue,
32
36
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
@@ -51,7 +55,9 @@ function AsyncSelect(_ref) {
51
55
  var isInvalid = (0, _form2.validateSubmitErrors)(meta);
52
56
  return (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)(_select.AsyncSelect, (0, _extends2.default)({}, fieldProps, rest, {
53
57
  isInvalid: isInvalid
54
- })), !error && validationHelpText && (0, _react2.jsx)(_form.HelperMessage, null, validationHelpText), isInvalid && (0, _react2.jsx)(_form.ErrorMessage, {
58
+ })), !error && validationHelpText && (0, _react2.jsx)(_form.HelperMessage, {
59
+ testId: "".concat(testId, "-helper-message")
60
+ }, validationHelpText), isInvalid && (0, _react2.jsx)(_form.ErrorMessage, {
55
61
  testId: "".concat(testId, "-error-message")
56
62
  }, error));
57
63
  }));
@@ -5,7 +5,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.CreateForm = void 0;
8
+ exports.TEST_ID = exports.CreateForm = void 0;
9
9
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
10
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
11
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
@@ -38,9 +38,12 @@ var errorStyles = (0, _react2.css)({
38
38
  alignItems: 'center',
39
39
  marginRight: 'auto'
40
40
  });
41
+ var TEST_ID = 'link-create-form';
42
+ exports.TEST_ID = TEST_ID;
41
43
  var CreateForm = function CreateForm(_ref) {
42
44
  var children = _ref.children,
43
- testId = _ref.testId,
45
+ _ref$testId = _ref.testId,
46
+ testId = _ref$testId === void 0 ? TEST_ID : _ref$testId,
44
47
  onSubmit = _ref.onSubmit,
45
48
  onCancel = _ref.onCancel,
46
49
  isLoading = _ref.isLoading,
@@ -93,12 +96,12 @@ var CreateForm = function CreateForm(_ref) {
93
96
  var formProps = _ref3.formProps,
94
97
  submitting = _ref3.submitting;
95
98
  return (0, _react2.jsx)("form", (0, _extends2.default)({}, formProps, {
96
- name: "confluence-creation-form",
99
+ name: "link-create-form",
97
100
  "data-testid": testId,
98
101
  css: formStyles
99
102
  }), (0, _react2.jsx)("div", null, children), !hideFooter && (0, _react2.jsx)(_form.FormFooter, null, formErrorMessage && (0, _react2.jsx)("div", {
100
103
  css: errorStyles,
101
- "data-testid": "link-create-form-error"
104
+ "data-testid": "".concat(testId, "-error")
102
105
  }, (0, _react2.jsx)(_error.default, {
103
106
  label: formErrorMessage,
104
107
  primaryColor: "var(--ds-icon-danger, #E34935)"
@@ -106,12 +109,12 @@ var CreateForm = function CreateForm(_ref) {
106
109
  type: "button",
107
110
  appearance: "subtle",
108
111
  onClick: handleCancel,
109
- testId: 'close-button'
112
+ testId: "".concat(testId, "-button-cancel")
110
113
  }, intl.formatMessage(_messages.messages.close)), (0, _react2.jsx)(_loadingButton.default, {
111
114
  type: "submit",
112
115
  appearance: "primary",
113
116
  isLoading: submitting,
114
- testId: 'create-button'
117
+ testId: "".concat(testId, "-button-submit")
115
118
  }, intl.formatMessage(_messages.messages.create)))));
116
119
  });
117
120
  };
@@ -4,6 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
+ exports.TEST_ID = void 0;
7
8
  exports.TextField = TextField;
8
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
10
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
@@ -13,18 +14,22 @@ var _form = require("@atlaskit/form");
13
14
  var _textfield = _interopRequireDefault(require("@atlaskit/textfield"));
14
15
  var _form2 = require("../../../common/utils/form");
15
16
  var _formContext = require("../../../controllers/form-context");
16
- var _excluded = ["label", "name", "validationHelpText", "validators", "defaultValue", "isRequired"];
17
+ var _excluded = ["label", "name", "testId", "validationHelpText", "validators", "defaultValue", "isRequired"];
17
18
  /** @jsx jsx */
19
+ var TEST_ID = 'link-create-text-field';
20
+
18
21
  /**
19
22
  * A text field utilising the Atlaskit Textfield and Field objects from `@atlaskit/form`.
20
23
  * Validation is handled by the form as it is on form submission. Any errors returned by
21
24
  * the handleSubmit function passed to the form <Form> that have a key matching the `name`
22
25
  * of this text field are shown above the field.
23
26
  */
24
-
27
+ exports.TEST_ID = TEST_ID;
25
28
  function TextField(_ref) {
26
29
  var label = _ref.label,
27
30
  name = _ref.name,
31
+ _ref$testId = _ref.testId,
32
+ testId = _ref$testId === void 0 ? TEST_ID : _ref$testId,
28
33
  validationHelpText = _ref.validationHelpText,
29
34
  validators = _ref.validators,
30
35
  defaultValue = _ref.defaultValue,
@@ -45,6 +50,7 @@ function TextField(_ref) {
45
50
  * `value` will be populated again in `fieldProps` which cause the TextField to be changed
46
51
  * to a controlled component and raise a warning from React.
47
52
  */
53
+
48
54
  (0, _react2.jsx)(_form.Field, {
49
55
  name: name,
50
56
  label: label,
@@ -56,10 +62,13 @@ function TextField(_ref) {
56
62
  error = _ref2.error;
57
63
  var isInvalid = (0, _form2.validateSubmitErrors)(meta);
58
64
  return (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)(_textfield.default, (0, _extends2.default)({}, fieldProps, restProps, {
65
+ testId: testId,
59
66
  isInvalid: isInvalid,
60
67
  isRequired: false // Remove the default browser validation
61
- })), !error && validationHelpText && (0, _react2.jsx)(_form.HelperMessage, null, validationHelpText), error && isInvalid && (0, _react2.jsx)(_form.ErrorMessage, {
62
- testId: "".concat(restProps.testId, "-error-message")
68
+ })), !error && validationHelpText && (0, _react2.jsx)(_form.HelperMessage, {
69
+ testId: "".concat(testId, "-helper-message")
70
+ }, validationHelpText), error && isInvalid && (0, _react2.jsx)(_form.ErrorMessage, {
71
+ testId: "".concat(testId, "-error-message")
63
72
  }, error));
64
73
  })
65
74
  );
@@ -5,7 +5,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.default = void 0;
8
+ exports.default = exports.TEST_ID = void 0;
9
9
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
10
10
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
11
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
@@ -24,6 +24,8 @@ var _excluded = ["testId", "onCreate", "onFailure", "onCancel"],
24
24
  /** @jsx jsx */
25
25
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
26
26
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
27
+ var TEST_ID = 'link-create';
28
+ exports.TEST_ID = TEST_ID;
27
29
  var LinkCreateContent = function LinkCreateContent(_ref) {
28
30
  var plugins = _ref.plugins,
29
31
  entityKey = _ref.entityKey;
@@ -36,7 +38,8 @@ var LinkCreateContent = function LinkCreateContent(_ref) {
36
38
  return (0, _react2.jsx)(_react.Fragment, null, chosenOne.form);
37
39
  };
38
40
  var LinkCreate = (0, _formContext.withLinkCreateFormContext)(function (_ref2) {
39
- var testId = _ref2.testId,
41
+ var _ref2$testId = _ref2.testId,
42
+ testId = _ref2$testId === void 0 ? TEST_ID : _ref2$testId,
40
43
  onCreate = _ref2.onCreate,
41
44
  onFailure = _ref2.onFailure,
42
45
  onCancel = _ref2.onCancel,
@@ -87,7 +90,7 @@ var LinkCreateWithModal = function LinkCreateWithModal(_ref4) {
87
90
  createProps = (0, _objectWithoutProperties2.default)(_ref4, _excluded2);
88
91
  var intl = (0, _reactIntlNext.useIntl)();
89
92
  return (0, _react2.jsx)(_modalDialog.ModalTransition, null, !!active && (0, _react2.jsx)(_modalDialog.default, {
90
- testId: createProps.testId && "".concat(createProps.testId, "--modal"),
93
+ testId: "link-create-modal",
91
94
  onClose: createProps.onCancel,
92
95
  shouldScrollInViewport: true,
93
96
  onOpenComplete: onOpenComplete,
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-create",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,7 +1,7 @@
1
1
  import messages from '../../../i18n/en';
2
2
  export const fetchMessagesForLocale = async locale => {
3
3
  try {
4
- const messages = await import( /* webpackChunkName: "@atlaskit-internal_@atlassian/link-create-confluence-i18n-[request]" */`../../../i18n/${locale}`);
4
+ const messages = await import( /* webpackChunkName: "@atlaskit-internal_@atlassian/link-create-confluence-i18n-[request]" */`../../../i18n/${locale.replace('-', '_')}`);
5
5
  return messages.default;
6
6
  } catch (e) {
7
7
  // ignore
@@ -6,6 +6,7 @@ import { ErrorMessage, Field, HelperMessage } from '@atlaskit/form';
6
6
  import { AsyncSelect as AkAsyncSelect } from '@atlaskit/select';
7
7
  import { validateSubmitErrors } from '../../../common/utils/form';
8
8
  import { useFormContext } from '../../../controllers/form-context';
9
+ export const TEST_ID = 'link-create-async-select';
9
10
  /**
10
11
  * An async select utilising the Atlaskit AsyncSelect and Field objects from `@atlaskit/form`.
11
12
  * Validation is handled by the form as it is on form submission. Any errors returned by
@@ -17,7 +18,7 @@ export function AsyncSelect({
17
18
  name,
18
19
  validationHelpText,
19
20
  isRequired,
20
- testId,
21
+ testId = TEST_ID,
21
22
  validators,
22
23
  defaultValue,
23
24
  ...rest
@@ -45,7 +46,9 @@ export function AsyncSelect({
45
46
  const isInvalid = validateSubmitErrors(meta);
46
47
  return jsx(Fragment, null, jsx(AkAsyncSelect, _extends({}, fieldProps, rest, {
47
48
  isInvalid: isInvalid
48
- })), !error && validationHelpText && jsx(HelperMessage, null, validationHelpText), isInvalid && jsx(ErrorMessage, {
49
+ })), !error && validationHelpText && jsx(HelperMessage, {
50
+ testId: `${testId}-helper-message`
51
+ }, validationHelpText), isInvalid && jsx(ErrorMessage, {
49
52
  testId: `${testId}-error-message`
50
53
  }, error));
51
54
  }));
@@ -25,9 +25,10 @@ const errorStyles = css({
25
25
  alignItems: 'center',
26
26
  marginRight: 'auto'
27
27
  });
28
+ export const TEST_ID = 'link-create-form';
28
29
  export const CreateForm = ({
29
30
  children,
30
- testId,
31
+ testId = TEST_ID,
31
32
  onSubmit,
32
33
  onCancel,
33
34
  isLoading,
@@ -66,12 +67,12 @@ export const CreateForm = ({
66
67
  formProps,
67
68
  submitting
68
69
  }) => jsx("form", _extends({}, formProps, {
69
- name: "confluence-creation-form",
70
+ name: "link-create-form",
70
71
  "data-testid": testId,
71
72
  css: formStyles
72
73
  }), jsx("div", null, children), !hideFooter && jsx(FormFooter, null, formErrorMessage && jsx("div", {
73
74
  css: errorStyles,
74
- "data-testid": "link-create-form-error"
75
+ "data-testid": `${testId}-error`
75
76
  }, jsx(ErrorIcon, {
76
77
  label: formErrorMessage,
77
78
  primaryColor: "var(--ds-icon-danger, #E34935)"
@@ -79,11 +80,11 @@ export const CreateForm = ({
79
80
  type: "button",
80
81
  appearance: "subtle",
81
82
  onClick: handleCancel,
82
- testId: 'close-button'
83
+ testId: `${testId}-button-cancel`
83
84
  }, intl.formatMessage(messages.close)), jsx(LoadingButton, {
84
85
  type: "submit",
85
86
  appearance: "primary",
86
87
  isLoading: submitting,
87
- testId: 'create-button'
88
+ testId: `${testId}-button-submit`
88
89
  }, intl.formatMessage(messages.create))))));
89
90
  };
@@ -6,6 +6,8 @@ import { ErrorMessage, Field, HelperMessage } from '@atlaskit/form';
6
6
  import AkTextfield from '@atlaskit/textfield';
7
7
  import { validateSubmitErrors } from '../../../common/utils/form';
8
8
  import { useFormContext } from '../../../controllers/form-context';
9
+ export const TEST_ID = 'link-create-text-field';
10
+
9
11
  /**
10
12
  * A text field utilising the Atlaskit Textfield and Field objects from `@atlaskit/form`.
11
13
  * Validation is handled by the form as it is on form submission. Any errors returned by
@@ -16,6 +18,7 @@ import { useFormContext } from '../../../controllers/form-context';
16
18
  export function TextField({
17
19
  label,
18
20
  name,
21
+ testId = TEST_ID,
19
22
  validationHelpText,
20
23
  validators,
21
24
  defaultValue,
@@ -38,6 +41,7 @@ export function TextField({
38
41
  * `value` will be populated again in `fieldProps` which cause the TextField to be changed
39
42
  * to a controlled component and raise a warning from React.
40
43
  */
44
+
41
45
  jsx(Field, {
42
46
  name: name,
43
47
  label: label,
@@ -50,10 +54,13 @@ export function TextField({
50
54
  }) => {
51
55
  const isInvalid = validateSubmitErrors(meta);
52
56
  return jsx(Fragment, null, jsx(AkTextfield, _extends({}, fieldProps, restProps, {
57
+ testId: testId,
53
58
  isInvalid: isInvalid,
54
59
  isRequired: false // Remove the default browser validation
55
- })), !error && validationHelpText && jsx(HelperMessage, null, validationHelpText), error && isInvalid && jsx(ErrorMessage, {
56
- testId: `${restProps.testId}-error-message`
60
+ })), !error && validationHelpText && jsx(HelperMessage, {
61
+ testId: `${testId}-helper-message`
62
+ }, validationHelpText), error && isInvalid && jsx(ErrorMessage, {
63
+ testId: `${testId}-error-message`
57
64
  }, error));
58
65
  })
59
66
  );
@@ -9,6 +9,7 @@ import { useFormContext, withLinkCreateFormContext } from '../../controllers/for
9
9
  import { ErrorBoundary } from './error-boundary';
10
10
  import { messages } from './messages';
11
11
  import TrackMount from './track-mount';
12
+ export const TEST_ID = 'link-create';
12
13
  const LinkCreateContent = ({
13
14
  plugins,
14
15
  entityKey
@@ -20,7 +21,7 @@ const LinkCreateContent = ({
20
21
  return jsx(Fragment, null, chosenOne.form);
21
22
  };
22
23
  const LinkCreate = withLinkCreateFormContext(({
23
- testId,
24
+ testId = TEST_ID,
24
25
  onCreate,
25
26
  onFailure,
26
27
  onCancel,
@@ -58,7 +59,7 @@ const LinkCreateWithModal = ({
58
59
  }) => {
59
60
  const intl = useIntl();
60
61
  return jsx(ModalTransition, null, !!active && jsx(Modal, {
61
- testId: createProps.testId && `${createProps.testId}--modal`,
62
+ testId: "link-create-modal",
62
63
  onClose: createProps.onCancel,
63
64
  shouldScrollInViewport: true,
64
65
  onOpenComplete: onOpenComplete,
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-create",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "sideEffects": false
5
5
  }
@@ -9,7 +9,7 @@ export var fetchMessagesForLocale = /*#__PURE__*/function () {
9
9
  case 0:
10
10
  _context.prev = 0;
11
11
  _context.next = 3;
12
- return import( /* webpackChunkName: "@atlaskit-internal_@atlassian/link-create-confluence-i18n-[request]" */"../../../i18n/".concat(locale));
12
+ return import( /* webpackChunkName: "@atlaskit-internal_@atlassian/link-create-confluence-i18n-[request]" */"../../../i18n/".concat(locale.replace('-', '_')));
13
13
  case 3:
14
14
  _messages = _context.sent;
15
15
  return _context.abrupt("return", _messages.default);
@@ -8,6 +8,7 @@ import { ErrorMessage, Field, HelperMessage } from '@atlaskit/form';
8
8
  import { AsyncSelect as AkAsyncSelect } from '@atlaskit/select';
9
9
  import { validateSubmitErrors } from '../../../common/utils/form';
10
10
  import { useFormContext } from '../../../controllers/form-context';
11
+ export var TEST_ID = 'link-create-async-select';
11
12
  /**
12
13
  * An async select utilising the Atlaskit AsyncSelect and Field objects from `@atlaskit/form`.
13
14
  * Validation is handled by the form as it is on form submission. Any errors returned by
@@ -19,7 +20,8 @@ export function AsyncSelect(_ref) {
19
20
  name = _ref.name,
20
21
  validationHelpText = _ref.validationHelpText,
21
22
  isRequired = _ref.isRequired,
22
- testId = _ref.testId,
23
+ _ref$testId = _ref.testId,
24
+ testId = _ref$testId === void 0 ? TEST_ID : _ref$testId,
23
25
  validators = _ref.validators,
24
26
  defaultValue = _ref.defaultValue,
25
27
  rest = _objectWithoutProperties(_ref, _excluded);
@@ -44,7 +46,9 @@ export function AsyncSelect(_ref) {
44
46
  var isInvalid = validateSubmitErrors(meta);
45
47
  return jsx(Fragment, null, jsx(AkAsyncSelect, _extends({}, fieldProps, rest, {
46
48
  isInvalid: isInvalid
47
- })), !error && validationHelpText && jsx(HelperMessage, null, validationHelpText), isInvalid && jsx(ErrorMessage, {
49
+ })), !error && validationHelpText && jsx(HelperMessage, {
50
+ testId: "".concat(testId, "-helper-message")
51
+ }, validationHelpText), isInvalid && jsx(ErrorMessage, {
48
52
  testId: "".concat(testId, "-error-message")
49
53
  }, error));
50
54
  }));
@@ -27,9 +27,11 @@ var errorStyles = css({
27
27
  alignItems: 'center',
28
28
  marginRight: 'auto'
29
29
  });
30
+ export var TEST_ID = 'link-create-form';
30
31
  export var CreateForm = function CreateForm(_ref) {
31
32
  var children = _ref.children,
32
- testId = _ref.testId,
33
+ _ref$testId = _ref.testId,
34
+ testId = _ref$testId === void 0 ? TEST_ID : _ref$testId,
33
35
  onSubmit = _ref.onSubmit,
34
36
  onCancel = _ref.onCancel,
35
37
  isLoading = _ref.isLoading,
@@ -82,12 +84,12 @@ export var CreateForm = function CreateForm(_ref) {
82
84
  var formProps = _ref3.formProps,
83
85
  submitting = _ref3.submitting;
84
86
  return jsx("form", _extends({}, formProps, {
85
- name: "confluence-creation-form",
87
+ name: "link-create-form",
86
88
  "data-testid": testId,
87
89
  css: formStyles
88
90
  }), jsx("div", null, children), !hideFooter && jsx(FormFooter, null, formErrorMessage && jsx("div", {
89
91
  css: errorStyles,
90
- "data-testid": "link-create-form-error"
92
+ "data-testid": "".concat(testId, "-error")
91
93
  }, jsx(ErrorIcon, {
92
94
  label: formErrorMessage,
93
95
  primaryColor: "var(--ds-icon-danger, #E34935)"
@@ -95,12 +97,12 @@ export var CreateForm = function CreateForm(_ref) {
95
97
  type: "button",
96
98
  appearance: "subtle",
97
99
  onClick: handleCancel,
98
- testId: 'close-button'
100
+ testId: "".concat(testId, "-button-cancel")
99
101
  }, intl.formatMessage(messages.close)), jsx(LoadingButton, {
100
102
  type: "submit",
101
103
  appearance: "primary",
102
104
  isLoading: submitting,
103
- testId: 'create-button'
105
+ testId: "".concat(testId, "-button-submit")
104
106
  }, intl.formatMessage(messages.create)))));
105
107
  });
106
108
  };
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["label", "name", "validationHelpText", "validators", "defaultValue", "isRequired"];
3
+ var _excluded = ["label", "name", "testId", "validationHelpText", "validators", "defaultValue", "isRequired"];
4
4
  /** @jsx jsx */
5
5
  import { Fragment, useEffect } from 'react';
6
6
  import { jsx } from '@emotion/react';
@@ -8,6 +8,8 @@ import { ErrorMessage, Field, HelperMessage } from '@atlaskit/form';
8
8
  import AkTextfield from '@atlaskit/textfield';
9
9
  import { validateSubmitErrors } from '../../../common/utils/form';
10
10
  import { useFormContext } from '../../../controllers/form-context';
11
+ export var TEST_ID = 'link-create-text-field';
12
+
11
13
  /**
12
14
  * A text field utilising the Atlaskit Textfield and Field objects from `@atlaskit/form`.
13
15
  * Validation is handled by the form as it is on form submission. Any errors returned by
@@ -18,6 +20,8 @@ import { useFormContext } from '../../../controllers/form-context';
18
20
  export function TextField(_ref) {
19
21
  var label = _ref.label,
20
22
  name = _ref.name,
23
+ _ref$testId = _ref.testId,
24
+ testId = _ref$testId === void 0 ? TEST_ID : _ref$testId,
21
25
  validationHelpText = _ref.validationHelpText,
22
26
  validators = _ref.validators,
23
27
  defaultValue = _ref.defaultValue,
@@ -38,6 +42,7 @@ export function TextField(_ref) {
38
42
  * `value` will be populated again in `fieldProps` which cause the TextField to be changed
39
43
  * to a controlled component and raise a warning from React.
40
44
  */
45
+
41
46
  jsx(Field, {
42
47
  name: name,
43
48
  label: label,
@@ -49,10 +54,13 @@ export function TextField(_ref) {
49
54
  error = _ref2.error;
50
55
  var isInvalid = validateSubmitErrors(meta);
51
56
  return jsx(Fragment, null, jsx(AkTextfield, _extends({}, fieldProps, restProps, {
57
+ testId: testId,
52
58
  isInvalid: isInvalid,
53
59
  isRequired: false // Remove the default browser validation
54
- })), !error && validationHelpText && jsx(HelperMessage, null, validationHelpText), error && isInvalid && jsx(ErrorMessage, {
55
- testId: "".concat(restProps.testId, "-error-message")
60
+ })), !error && validationHelpText && jsx(HelperMessage, {
61
+ testId: "".concat(testId, "-helper-message")
62
+ }, validationHelpText), error && isInvalid && jsx(ErrorMessage, {
63
+ testId: "".concat(testId, "-error-message")
56
64
  }, error));
57
65
  })
58
66
  );
@@ -14,6 +14,7 @@ import { useFormContext, withLinkCreateFormContext } from '../../controllers/for
14
14
  import { ErrorBoundary } from './error-boundary';
15
15
  import { messages } from './messages';
16
16
  import TrackMount from './track-mount';
17
+ export var TEST_ID = 'link-create';
17
18
  var LinkCreateContent = function LinkCreateContent(_ref) {
18
19
  var plugins = _ref.plugins,
19
20
  entityKey = _ref.entityKey;
@@ -26,7 +27,8 @@ var LinkCreateContent = function LinkCreateContent(_ref) {
26
27
  return jsx(Fragment, null, chosenOne.form);
27
28
  };
28
29
  var LinkCreate = withLinkCreateFormContext(function (_ref2) {
29
- var testId = _ref2.testId,
30
+ var _ref2$testId = _ref2.testId,
31
+ testId = _ref2$testId === void 0 ? TEST_ID : _ref2$testId,
30
32
  onCreate = _ref2.onCreate,
31
33
  onFailure = _ref2.onFailure,
32
34
  onCancel = _ref2.onCancel,
@@ -77,7 +79,7 @@ var LinkCreateWithModal = function LinkCreateWithModal(_ref4) {
77
79
  createProps = _objectWithoutProperties(_ref4, _excluded2);
78
80
  var intl = useIntl();
79
81
  return jsx(ModalTransition, null, !!active && jsx(Modal, {
80
- testId: createProps.testId && "".concat(createProps.testId, "--modal"),
82
+ testId: "link-create-modal",
81
83
  onClose: createProps.onCancel,
82
84
  shouldScrollInViewport: true,
83
85
  onOpenComplete: onOpenComplete,
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/link-create",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,6 +1,7 @@
1
1
  import { jsx } from '@emotion/react';
2
2
  import { OptionType } from '@atlaskit/select';
3
3
  import { AsyncSelectProps } from './types';
4
+ export declare const TEST_ID = "link-create-async-select";
4
5
  /**
5
6
  * An async select utilising the Atlaskit AsyncSelect and Field objects from `@atlaskit/form`.
6
7
  * Validation is handled by the form as it is on form submission. Any errors returned by
@@ -9,4 +9,5 @@ export interface CreateFormProps<FormData> {
9
9
  isLoading?: boolean;
10
10
  hideFooter?: boolean;
11
11
  }
12
+ export declare const TEST_ID = "link-create-form";
12
13
  export declare const CreateForm: <FormData_1 extends Record<string, any> = {}>({ children, testId, onSubmit, onCancel, isLoading, hideFooter, }: CreateFormProps<FormData_1>) => jsx.JSX.Element;
@@ -1,9 +1,10 @@
1
1
  import { jsx } from '@emotion/react';
2
2
  import { TextFieldProps } from './types';
3
+ export declare const TEST_ID = "link-create-text-field";
3
4
  /**
4
5
  * A text field utilising the Atlaskit Textfield and Field objects from `@atlaskit/form`.
5
6
  * Validation is handled by the form as it is on form submission. Any errors returned by
6
7
  * the handleSubmit function passed to the form <Form> that have a key matching the `name`
7
8
  * of this text field are shown above the field.
8
9
  */
9
- export declare function TextField({ label, name, validationHelpText, validators, defaultValue, isRequired, ...restProps }: TextFieldProps): jsx.JSX.Element;
10
+ export declare function TextField({ label, name, testId, validationHelpText, validators, defaultValue, isRequired, ...restProps }: TextFieldProps): jsx.JSX.Element;
@@ -1,4 +1,5 @@
1
1
  import { jsx } from '@emotion/react';
2
2
  import { LinkCreateWithModalProps } from '../../common/types';
3
+ export declare const TEST_ID = "link-create";
3
4
  declare const LinkCreateWithModal: ({ active, modalTitle, onOpenComplete, onCloseComplete, ...createProps }: LinkCreateWithModalProps) => jsx.JSX.Element;
4
5
  export default LinkCreateWithModal;
@@ -1,6 +1,7 @@
1
1
  import { jsx } from '@emotion/react';
2
2
  import { OptionType } from '@atlaskit/select';
3
3
  import { AsyncSelectProps } from './types';
4
+ export declare const TEST_ID = "link-create-async-select";
4
5
  /**
5
6
  * An async select utilising the Atlaskit AsyncSelect and Field objects from `@atlaskit/form`.
6
7
  * Validation is handled by the form as it is on form submission. Any errors returned by
@@ -9,4 +9,5 @@ export interface CreateFormProps<FormData> {
9
9
  isLoading?: boolean;
10
10
  hideFooter?: boolean;
11
11
  }
12
+ export declare const TEST_ID = "link-create-form";
12
13
  export declare const CreateForm: <FormData_1 extends Record<string, any> = {}>({ children, testId, onSubmit, onCancel, isLoading, hideFooter, }: CreateFormProps<FormData_1>) => jsx.JSX.Element;
@@ -1,9 +1,10 @@
1
1
  import { jsx } from '@emotion/react';
2
2
  import { TextFieldProps } from './types';
3
+ export declare const TEST_ID = "link-create-text-field";
3
4
  /**
4
5
  * A text field utilising the Atlaskit Textfield and Field objects from `@atlaskit/form`.
5
6
  * Validation is handled by the form as it is on form submission. Any errors returned by
6
7
  * the handleSubmit function passed to the form <Form> that have a key matching the `name`
7
8
  * of this text field are shown above the field.
8
9
  */
9
- export declare function TextField({ label, name, validationHelpText, validators, defaultValue, isRequired, ...restProps }: TextFieldProps): jsx.JSX.Element;
10
+ export declare function TextField({ label, name, testId, validationHelpText, validators, defaultValue, isRequired, ...restProps }: TextFieldProps): jsx.JSX.Element;
@@ -1,4 +1,5 @@
1
1
  import { jsx } from '@emotion/react';
2
2
  import { LinkCreateWithModalProps } from '../../common/types';
3
+ export declare const TEST_ID = "link-create";
3
4
  declare const LinkCreateWithModal: ({ active, modalTitle, onOpenComplete, onCloseComplete, ...createProps }: LinkCreateWithModalProps) => jsx.JSX.Element;
4
5
  export default LinkCreateWithModal;
@@ -0,0 +1,91 @@
1
+ import React, { useMemo } from 'react';
2
+
3
+ import {
4
+ AsyncSelect,
5
+ CreateForm,
6
+ CreateFormProps,
7
+ TextField,
8
+ useLinkCreateCallback,
9
+ Validator,
10
+ } from '@atlaskit/link-create';
11
+ import { OptionsType } from '@atlaskit/select';
12
+
13
+ interface pluginProps {
14
+ shouldThrowError?: boolean;
15
+ }
16
+
17
+ export function MockPluginForm({ shouldThrowError }: pluginProps) {
18
+ const { onCreate, onFailure, onCancel } = useLinkCreateCallback();
19
+
20
+ type MockOptions = {
21
+ label: string;
22
+ value: string;
23
+ };
24
+
25
+ const mockHandleSubmit = async () => {
26
+ if (onCreate) {
27
+ await onCreate({
28
+ url: 'https://atlassian.com/product/new-object-id',
29
+ objectId: 'new-object-id',
30
+ objectType: 'object-type',
31
+ data: {},
32
+ });
33
+ }
34
+ };
35
+
36
+ const mockValidator: Validator = useMemo(
37
+ () => ({
38
+ isValid: (val: unknown) => !!val,
39
+ errorMessage: 'Validation Error: You need to provide a value.',
40
+ }),
41
+ [],
42
+ );
43
+
44
+ const exampleOptions: OptionsType<MockOptions> = [
45
+ { label: 'Option 1', value: 'option-1' },
46
+ { label: 'Option 2', value: 'option-2' },
47
+ ];
48
+
49
+ const mockLoadOptions = async () => {
50
+ try {
51
+ if (shouldThrowError) {
52
+ throw new Error('This is an error message.');
53
+ }
54
+ return exampleOptions;
55
+ } catch (error) {
56
+ if (error instanceof Error) {
57
+ onFailure && onFailure(error.message);
58
+ }
59
+ return [];
60
+ }
61
+ };
62
+
63
+ return (
64
+ <div>
65
+ This is a mocked plugin.
66
+ <CreateForm<CreateFormProps<FormData>>
67
+ onSubmit={mockHandleSubmit}
68
+ onCancel={onCancel}
69
+ >
70
+ <TextField
71
+ name={'textField-name'}
72
+ label={'Enter some Text'}
73
+ placeholder={'Type something here...'}
74
+ validators={[mockValidator]}
75
+ autoFocus
76
+ maxLength={255}
77
+ />
78
+ <AsyncSelect<MockOptions>
79
+ isRequired
80
+ isSearchable
81
+ name={'asyncSelect-name'}
82
+ label={'Select an Option'}
83
+ validators={[mockValidator]}
84
+ defaultOptions={true}
85
+ defaultOption={mockLoadOptions}
86
+ loadOptions={mockLoadOptions}
87
+ ></AsyncSelect>
88
+ </CreateForm>
89
+ </div>
90
+ );
91
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/link-create",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "description": "The driver component of meta creation flow",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -44,7 +44,7 @@
44
44
  "@atlaskit/select": "^16.5.0",
45
45
  "@atlaskit/spinner": "^15.4.0",
46
46
  "@atlaskit/textfield": "^5.6.0",
47
- "@atlaskit/tokens": "^1.11.0",
47
+ "@atlaskit/tokens": "^1.12.0",
48
48
  "@babel/runtime": "^7.0.0",
49
49
  "@emotion/react": "^11.7.1"
50
50
  },
package/report.api.md CHANGED
@@ -145,6 +145,7 @@ export interface LinkCreateWithModalProps
145
145
  export function TextField({
146
146
  label,
147
147
  name,
148
+ testId,
148
149
  validationHelpText,
149
150
  validators,
150
151
  defaultValue,
@@ -109,7 +109,7 @@ export interface LinkCreateWithModalProps extends LinkCreateProps, Partial<Pick<
109
109
  }
110
110
 
111
111
  // @public
112
- export function TextField({ label, name, validationHelpText, validators, defaultValue, isRequired, ...restProps }: TextFieldProps): jsx.JSX.Element;
112
+ export function TextField({ label, name, testId, validationHelpText, validators, defaultValue, isRequired, ...restProps }: TextFieldProps): jsx.JSX.Element;
113
113
 
114
114
  // @public (undocumented)
115
115
  type TextFieldProps = Omit<TextFieldProps_2, 'name'> & {