@atlaskit/link-create 0.8.2 → 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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
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
+
3
9
  ## 0.8.2
4
10
 
5
11
  ### Patch Changes
@@ -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.2",
3
+ "version": "0.9.0",
4
4
  "sideEffects": false
5
5
  }
@@ -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.2",
3
+ "version": "0.9.0",
4
4
  "sideEffects": false
5
5
  }
@@ -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.2",
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/link-create",
3
- "version": "0.8.2",
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,
@@ -0,0 +1,136 @@
1
+ ## API Report File for "@atlaskit/link-create"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ /// <reference types="react" />
8
+
9
+ import { AsyncSelectProps as AsyncSelectProps_2 } from '@atlaskit/select';
10
+ import { jsx } from '@emotion/react';
11
+ import { MemoExoticComponent } from 'react';
12
+ import { ModalDialogProps } from '@atlaskit/modal-dialog';
13
+ import { OptionType } from '@atlaskit/select';
14
+ import { default as React_2 } from 'react';
15
+ import { ReactNode } from 'react';
16
+ import { SpinnerProps } from '@atlaskit/spinner';
17
+ import { TextFieldProps as TextFieldProps_2 } from '@atlaskit/textfield';
18
+
19
+ // @public
20
+ export function AsyncSelect<T = OptionType>({ label, name, validationHelpText, isRequired, testId, validators, defaultValue, ...rest }: AsyncSelectProps<T>): jsx.JSX.Element;
21
+
22
+ // @public (undocumented)
23
+ type AsyncSelectProps<T = OptionType> = AsyncSelectProps_2<T> & {
24
+ name: string;
25
+ label: string;
26
+ validationHelpText?: string;
27
+ testId?: string;
28
+ isRequired?: boolean;
29
+ validators?: Validator[];
30
+ };
31
+
32
+ // @public (undocumented)
33
+ const ComposedLinkCreate: MemoExoticComponent<(props: LinkCreateWithModalProps) => jsx.JSX.Element>;
34
+ export default ComposedLinkCreate;
35
+
36
+ // @public (undocumented)
37
+ export const CreateForm: <FormData_1 extends Record<string, any> = {}>({ children, testId, onSubmit, onCancel, isLoading, hideFooter, }: CreateFormProps<FormData_1>) => jsx.JSX.Element;
38
+
39
+ // @public (undocumented)
40
+ export function CreateFormLoader({ size }: Partial<SpinnerProps>): jsx.JSX.Element;
41
+
42
+ // @public (undocumented)
43
+ export interface CreateFormProps<FormData> {
44
+ // (undocumented)
45
+ children: ReactNode;
46
+ // (undocumented)
47
+ hideFooter?: boolean;
48
+ // (undocumented)
49
+ isLoading?: boolean;
50
+ // (undocumented)
51
+ onCancel?: () => void;
52
+ // (undocumented)
53
+ onSubmit: (data: FormData) => void;
54
+ // (undocumented)
55
+ testId?: string;
56
+ }
57
+
58
+ // @public
59
+ export type CreatePayload = {
60
+ url: string;
61
+ objectId: string;
62
+ objectType: string;
63
+ data?: Record<string, unknown>;
64
+ };
65
+
66
+ // @public (undocumented)
67
+ interface Group {
68
+ icon: string;
69
+ key: string;
70
+ label: string;
71
+ }
72
+
73
+ // @public (undocumented)
74
+ export const LinkCreateCallbackProvider: React_2.FC<LinkCreateCallbackProviderProps>;
75
+
76
+ // @public (undocumented)
77
+ interface LinkCreateCallbackProviderProps {
78
+ onCancel?: () => void;
79
+ onCreate?: (result: CreatePayload) => Promise<void> | void;
80
+ onFailure?: (errorMessage: string) => void;
81
+ }
82
+
83
+ // @public (undocumented)
84
+ export interface LinkCreatePlugin {
85
+ form: ReactNode;
86
+ group: Group;
87
+ icon: string;
88
+ key: string;
89
+ label: string;
90
+ }
91
+
92
+ // @public (undocumented)
93
+ export interface LinkCreateProps {
94
+ entityKey: string;
95
+ groupKey?: string;
96
+ onCancel?: () => void;
97
+ onCreate?: (payload: CreatePayload) => Promise<void> | void;
98
+ onFailure?: (error: unknown) => void;
99
+ // (undocumented)
100
+ plugins: LinkCreatePlugin[];
101
+ testId?: string;
102
+ triggeredFrom?: string;
103
+ }
104
+
105
+ // @public (undocumented)
106
+ export interface LinkCreateWithModalProps extends LinkCreateProps, Partial<Pick<ModalDialogProps, 'onCloseComplete' | 'onOpenComplete'>> {
107
+ active?: boolean;
108
+ modalTitle?: string;
109
+ }
110
+
111
+ // @public
112
+ export function TextField({ label, name, testId, validationHelpText, validators, defaultValue, isRequired, ...restProps }: TextFieldProps): jsx.JSX.Element;
113
+
114
+ // @public (undocumented)
115
+ type TextFieldProps = Omit<TextFieldProps_2, 'name'> & {
116
+ name: string;
117
+ label?: string;
118
+ validationHelpText?: string;
119
+ validators?: Validator[];
120
+ };
121
+
122
+ // @public (undocumented)
123
+ export const useLinkCreateCallback: () => LinkCreateCallbackProviderProps;
124
+
125
+ // @public (undocumented)
126
+ export type Validator = {
127
+ isValid: (val: unknown) => boolean;
128
+ errorMessage: string;
129
+ };
130
+
131
+ // @public
132
+ export type ValidatorMap = Record<string, Validator[]>;
133
+
134
+ // (No @packageDocumentation comment for this package)
135
+
136
+ ```