@atlaskit/link-create 0.5.7 → 0.7.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 +12 -0
- package/dist/cjs/common/constants.js +1 -1
- package/dist/cjs/controllers/form-context/index.js +6 -0
- package/dist/cjs/controllers/form-context/main.js +8 -2
- package/dist/cjs/ui/create-form/main.js +1 -1
- package/dist/cjs/ui/create-form/textfield/main.js +5 -2
- package/dist/cjs/ui/{error-boundary → link-create/error-boundary}/index.js +2 -2
- package/dist/cjs/ui/link-create/index.js +13 -0
- package/dist/cjs/ui/link-create/main.js +99 -0
- package/dist/cjs/ui/link-create/track-mount/index.js +31 -0
- package/dist/cjs/ui/main.js +4 -84
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/common/constants.js +1 -1
- package/dist/es2019/controllers/form-context/index.js +1 -1
- package/dist/es2019/controllers/form-context/main.js +4 -1
- package/dist/es2019/ui/create-form/main.js +2 -2
- package/dist/es2019/ui/create-form/textfield/main.js +4 -1
- package/dist/es2019/ui/{error-boundary → link-create/error-boundary}/index.js +2 -2
- package/dist/es2019/ui/link-create/index.js +1 -0
- package/dist/es2019/ui/link-create/main.js +69 -0
- package/dist/es2019/ui/link-create/track-mount/index.js +24 -0
- package/dist/es2019/ui/main.js +5 -67
- package/dist/es2019/version.json +1 -1
- package/dist/esm/common/constants.js +1 -1
- package/dist/esm/controllers/form-context/index.js +1 -1
- package/dist/esm/controllers/form-context/main.js +6 -1
- package/dist/esm/ui/create-form/main.js +2 -2
- package/dist/esm/ui/create-form/textfield/main.js +5 -2
- package/dist/esm/ui/{error-boundary → link-create/error-boundary}/index.js +2 -2
- package/dist/esm/ui/link-create/index.js +1 -0
- package/dist/esm/ui/link-create/main.js +88 -0
- package/dist/esm/ui/link-create/track-mount/index.js +23 -0
- package/dist/esm/ui/main.js +7 -84
- package/dist/esm/version.json +1 -1
- package/dist/types/common/constants.d.ts +1 -1
- package/dist/types/common/types.d.ts +12 -4
- package/dist/types/controllers/form-context/index.d.ts +1 -1
- package/dist/types/controllers/form-context/main.d.ts +2 -1
- package/dist/types/index.d.ts +1 -2
- package/dist/types/ui/create-form/textfield/main.d.ts +1 -1
- package/dist/types/ui/create-form/textfield/types.d.ts +1 -1
- package/dist/types/ui/link-create/index.d.ts +1 -0
- package/dist/types/ui/link-create/main.d.ts +4 -0
- package/dist/types/ui/link-create/track-mount/index.d.ts +5 -0
- package/dist/types/ui/main.d.ts +2 -2
- package/dist/types-ts4.5/common/constants.d.ts +1 -1
- package/dist/types-ts4.5/common/types.d.ts +12 -4
- package/dist/types-ts4.5/controllers/form-context/index.d.ts +1 -1
- package/dist/types-ts4.5/controllers/form-context/main.d.ts +2 -1
- package/dist/types-ts4.5/index.d.ts +1 -2
- package/dist/types-ts4.5/ui/create-form/textfield/main.d.ts +1 -1
- package/dist/types-ts4.5/ui/create-form/textfield/types.d.ts +1 -1
- package/dist/types-ts4.5/ui/link-create/index.d.ts +1 -0
- package/dist/types-ts4.5/ui/link-create/main.d.ts +4 -0
- package/dist/types-ts4.5/ui/link-create/track-mount/index.d.ts +5 -0
- package/dist/types-ts4.5/ui/main.d.ts +2 -2
- package/package.json +5 -5
- package/report.api.md +9 -7
- package/tmp/api-report-tmp.d.ts +7 -8
- package/dist/cjs/ui/types.js +0 -5
- package/dist/es2019/ui/types.js +0 -1
- package/dist/esm/ui/types.js +0 -1
- package/dist/types/ui/types.d.ts +0 -6
- package/dist/types-ts4.5/ui/types.d.ts +0 -6
- /package/dist/cjs/ui/{error-boundary → link-create/error-boundary}/error-boundary-base/index.js +0 -0
- /package/dist/cjs/ui/{error-boundary → link-create/error-boundary}/error-boundary-ui/error-svg/index.js +0 -0
- /package/dist/cjs/ui/{error-boundary → link-create/error-boundary}/error-boundary-ui/index.js +0 -0
- /package/dist/cjs/ui/{error-boundary → link-create/error-boundary}/error-boundary-ui/messages.js +0 -0
- /package/dist/cjs/ui/{messages.js → link-create/messages.js} +0 -0
- /package/dist/es2019/ui/{error-boundary → link-create/error-boundary}/error-boundary-base/index.js +0 -0
- /package/dist/es2019/ui/{error-boundary → link-create/error-boundary}/error-boundary-ui/error-svg/index.js +0 -0
- /package/dist/es2019/ui/{error-boundary → link-create/error-boundary}/error-boundary-ui/index.js +0 -0
- /package/dist/es2019/ui/{error-boundary → link-create/error-boundary}/error-boundary-ui/messages.js +0 -0
- /package/dist/es2019/ui/{messages.js → link-create/messages.js} +0 -0
- /package/dist/esm/ui/{error-boundary → link-create/error-boundary}/error-boundary-base/index.js +0 -0
- /package/dist/esm/ui/{error-boundary → link-create/error-boundary}/error-boundary-ui/error-svg/index.js +0 -0
- /package/dist/esm/ui/{error-boundary → link-create/error-boundary}/error-boundary-ui/index.js +0 -0
- /package/dist/esm/ui/{error-boundary → link-create/error-boundary}/error-boundary-ui/messages.js +0 -0
- /package/dist/esm/ui/{messages.js → link-create/messages.js} +0 -0
- /package/dist/types/ui/{error-boundary → link-create/error-boundary}/error-boundary-base/index.d.ts +0 -0
- /package/dist/types/ui/{error-boundary → link-create/error-boundary}/error-boundary-ui/error-svg/index.d.ts +0 -0
- /package/dist/types/ui/{error-boundary → link-create/error-boundary}/error-boundary-ui/index.d.ts +0 -0
- /package/dist/types/ui/{error-boundary → link-create/error-boundary}/error-boundary-ui/messages.d.ts +0 -0
- /package/dist/types/ui/{error-boundary → link-create/error-boundary}/index.d.ts +0 -0
- /package/dist/types/ui/{messages.d.ts → link-create/messages.d.ts} +0 -0
- /package/dist/types-ts4.5/ui/{error-boundary → link-create/error-boundary}/error-boundary-base/index.d.ts +0 -0
- /package/dist/types-ts4.5/ui/{error-boundary → link-create/error-boundary}/error-boundary-ui/error-svg/index.d.ts +0 -0
- /package/dist/types-ts4.5/ui/{error-boundary → link-create/error-boundary}/error-boundary-ui/index.d.ts +0 -0
- /package/dist/types-ts4.5/ui/{error-boundary → link-create/error-boundary}/error-boundary-ui/messages.d.ts +0 -0
- /package/dist/types-ts4.5/ui/{error-boundary → link-create/error-boundary}/index.d.ts +0 -0
- /package/dist/types-ts4.5/ui/{messages.d.ts → link-create/messages.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/link-create
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`eb070266532`](https://bitbucket.org/atlassian/atlassian-frontend/commits/eb070266532) - Expose Modal callbacks and Add modalTitle to the linkCreate Props
|
|
8
|
+
|
|
9
|
+
## 0.6.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`ac3927f0650`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ac3927f0650) - Make modal 480px wide, Update TextField to take isRequired prop w/o default browser validation, remove extra internal spacing in the create form
|
|
14
|
+
|
|
3
15
|
## 0.5.7
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -8,7 +8,7 @@ var ANALYTICS_CHANNEL = 'media';
|
|
|
8
8
|
exports.ANALYTICS_CHANNEL = ANALYTICS_CHANNEL;
|
|
9
9
|
var COMPONENT_NAME = 'linkCreate';
|
|
10
10
|
exports.COMPONENT_NAME = COMPONENT_NAME;
|
|
11
|
-
var CREATE_FORM_MAX_WIDTH_IN_PX = '
|
|
11
|
+
var CREATE_FORM_MAX_WIDTH_IN_PX = '480';
|
|
12
12
|
exports.CREATE_FORM_MAX_WIDTH_IN_PX = CREATE_FORM_MAX_WIDTH_IN_PX;
|
|
13
13
|
var CREATE_FORM_MIN_HEIGHT_IN_PX = '200';
|
|
14
14
|
exports.CREATE_FORM_MIN_HEIGHT_IN_PX = CREATE_FORM_MIN_HEIGHT_IN_PX;
|
|
@@ -15,4 +15,10 @@ Object.defineProperty(exports, "useFormContext", {
|
|
|
15
15
|
return _main.useFormContext;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
+
Object.defineProperty(exports, "withLinkCreateFormContext", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _main.withLinkCreateFormContext;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
18
24
|
var _main = require("./main");
|
|
@@ -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.useFormContext = exports.FormContextProvider = exports.FormContext = void 0;
|
|
8
|
+
exports.withLinkCreateFormContext = exports.useFormContext = exports.FormContextProvider = exports.FormContext = void 0;
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
@@ -61,4 +61,10 @@ exports.FormContextProvider = FormContextProvider;
|
|
|
61
61
|
var useFormContext = function useFormContext() {
|
|
62
62
|
return (0, _react.useContext)(FormContext);
|
|
63
63
|
};
|
|
64
|
-
exports.useFormContext = useFormContext;
|
|
64
|
+
exports.useFormContext = useFormContext;
|
|
65
|
+
var withLinkCreateFormContext = function withLinkCreateFormContext(WrappedComponent) {
|
|
66
|
+
return function (props) {
|
|
67
|
+
return /*#__PURE__*/_react.default.createElement(FormContextProvider, null, /*#__PURE__*/_react.default.createElement(WrappedComponent, props));
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
exports.withLinkCreateFormContext = withLinkCreateFormContext;
|
|
@@ -96,7 +96,7 @@ var CreateForm = function CreateForm(_ref) {
|
|
|
96
96
|
name: "confluence-creation-form",
|
|
97
97
|
"data-testid": testId,
|
|
98
98
|
css: formStyles
|
|
99
|
-
}), (0, _react2.jsx)(
|
|
99
|
+
}), (0, _react2.jsx)("div", null, children), !hideFooter && (0, _react2.jsx)(_form.FormFooter, null, formErrorMessage && (0, _react2.jsx)("div", {
|
|
100
100
|
css: errorStyles,
|
|
101
101
|
"data-testid": "link-create-form-error"
|
|
102
102
|
}, (0, _react2.jsx)(_error.default, {
|
|
@@ -13,7 +13,7 @@ var _form = require("@atlaskit/form");
|
|
|
13
13
|
var _textfield = _interopRequireDefault(require("@atlaskit/textfield"));
|
|
14
14
|
var _form2 = require("../../../common/utils/form");
|
|
15
15
|
var _formContext = require("../../../controllers/form-context");
|
|
16
|
-
var _excluded = ["label", "name", "validationHelpText", "validators", "defaultValue"];
|
|
16
|
+
var _excluded = ["label", "name", "validationHelpText", "validators", "defaultValue", "isRequired"];
|
|
17
17
|
/** @jsx jsx */
|
|
18
18
|
/**
|
|
19
19
|
* A text field utilising the Atlaskit Textfield and Field objects from `@atlaskit/form`.
|
|
@@ -28,6 +28,7 @@ function TextField(_ref) {
|
|
|
28
28
|
validationHelpText = _ref.validationHelpText,
|
|
29
29
|
validators = _ref.validators,
|
|
30
30
|
defaultValue = _ref.defaultValue,
|
|
31
|
+
isRequired = _ref.isRequired,
|
|
31
32
|
restProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
32
33
|
var _useFormContext = (0, _formContext.useFormContext)(),
|
|
33
34
|
assignValidator = _useFormContext.assignValidator;
|
|
@@ -47,6 +48,7 @@ function TextField(_ref) {
|
|
|
47
48
|
(0, _react2.jsx)(_form.Field, {
|
|
48
49
|
name: name,
|
|
49
50
|
label: label,
|
|
51
|
+
isRequired: isRequired,
|
|
50
52
|
defaultValue: defaultValue !== null && defaultValue !== void 0 ? defaultValue : ''
|
|
51
53
|
}, function (_ref2) {
|
|
52
54
|
var fieldProps = _ref2.fieldProps,
|
|
@@ -54,7 +56,8 @@ function TextField(_ref) {
|
|
|
54
56
|
error = _ref2.error;
|
|
55
57
|
var isInvalid = (0, _form2.validateSubmitErrors)(meta);
|
|
56
58
|
return (0, _react2.jsx)(_react.Fragment, null, (0, _react2.jsx)(_textfield.default, (0, _extends2.default)({}, fieldProps, restProps, {
|
|
57
|
-
isInvalid: isInvalid
|
|
59
|
+
isInvalid: isInvalid,
|
|
60
|
+
isRequired: false // Remove the default browser validation
|
|
58
61
|
})), !error && validationHelpText && (0, _react2.jsx)(_form.HelperMessage, null, validationHelpText), error && isInvalid && (0, _react2.jsx)(_form.ErrorMessage, {
|
|
59
62
|
testId: "".concat(restProps.testId, "-error-message")
|
|
60
63
|
}, error));
|
|
@@ -8,8 +8,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.ErrorBoundary = void 0;
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
11
|
-
var _constants = require("
|
|
12
|
-
var _analytics = _interopRequireDefault(require("
|
|
11
|
+
var _constants = require("../../../common/constants");
|
|
12
|
+
var _analytics = _interopRequireDefault(require("../../../common/utils/analytics/analytics.codegen"));
|
|
13
13
|
var _errorBoundaryBase = require("./error-boundary-base");
|
|
14
14
|
var _errorBoundaryUi = require("./error-boundary-ui");
|
|
15
15
|
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); }
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(exports, "default", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _main.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
var _main = _interopRequireDefault(require("./main"));
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
10
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
12
|
+
var _react = require("react");
|
|
13
|
+
var _react2 = require("@emotion/react");
|
|
14
|
+
var _reactIntlNext = require("react-intl-next");
|
|
15
|
+
var _modalDialog = _interopRequireWildcard(require("@atlaskit/modal-dialog"));
|
|
16
|
+
var _constants = require("../../common/constants");
|
|
17
|
+
var _callbackContext = require("../../controllers/callback-context");
|
|
18
|
+
var _formContext = require("../../controllers/form-context");
|
|
19
|
+
var _errorBoundary = require("./error-boundary");
|
|
20
|
+
var _messages = require("./messages");
|
|
21
|
+
var _trackMount = _interopRequireDefault(require("./track-mount"));
|
|
22
|
+
var _excluded = ["testId", "onCreate", "onFailure", "onCancel"],
|
|
23
|
+
_excluded2 = ["active", "modalTitle", "onOpenComplete", "onCloseComplete"];
|
|
24
|
+
/** @jsx jsx */
|
|
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
|
+
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 LinkCreateContent = function LinkCreateContent(_ref) {
|
|
28
|
+
var plugins = _ref.plugins,
|
|
29
|
+
entityKey = _ref.entityKey;
|
|
30
|
+
var chosenOne = plugins.find(function (plugin) {
|
|
31
|
+
return plugin.key === entityKey;
|
|
32
|
+
});
|
|
33
|
+
if (!chosenOne) {
|
|
34
|
+
throw new Error('Make sure you specified a valid entityKey');
|
|
35
|
+
}
|
|
36
|
+
return (0, _react2.jsx)(_react.Fragment, null, chosenOne.form);
|
|
37
|
+
};
|
|
38
|
+
var LinkCreate = (0, _formContext.withLinkCreateFormContext)(function (_ref2) {
|
|
39
|
+
var testId = _ref2.testId,
|
|
40
|
+
onCreate = _ref2.onCreate,
|
|
41
|
+
onFailure = _ref2.onFailure,
|
|
42
|
+
onCancel = _ref2.onCancel,
|
|
43
|
+
restProps = (0, _objectWithoutProperties2.default)(_ref2, _excluded);
|
|
44
|
+
var _useFormContext = (0, _formContext.useFormContext)(),
|
|
45
|
+
setFormErrorMessage = _useFormContext.setFormErrorMessage;
|
|
46
|
+
var handleCreate = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
47
|
+
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(result) {
|
|
48
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
49
|
+
while (1) switch (_context.prev = _context.next) {
|
|
50
|
+
case 0:
|
|
51
|
+
// Reset the form error message
|
|
52
|
+
setFormErrorMessage(undefined);
|
|
53
|
+
if (!onCreate) {
|
|
54
|
+
_context.next = 4;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
_context.next = 4;
|
|
58
|
+
return onCreate(result.url);
|
|
59
|
+
case 4:
|
|
60
|
+
case "end":
|
|
61
|
+
return _context.stop();
|
|
62
|
+
}
|
|
63
|
+
}, _callee);
|
|
64
|
+
}));
|
|
65
|
+
return function (_x) {
|
|
66
|
+
return _ref3.apply(this, arguments);
|
|
67
|
+
};
|
|
68
|
+
}(), [onCreate, setFormErrorMessage]);
|
|
69
|
+
var handleFailure = (0, _react.useCallback)(function (errorMessage) {
|
|
70
|
+
// Set the form error message
|
|
71
|
+
setFormErrorMessage(errorMessage);
|
|
72
|
+
onFailure && onFailure(errorMessage);
|
|
73
|
+
}, [onFailure, setFormErrorMessage]);
|
|
74
|
+
return (0, _react2.jsx)("div", {
|
|
75
|
+
"data-testid": testId
|
|
76
|
+
}, (0, _react2.jsx)(_errorBoundary.ErrorBoundary, null, (0, _react2.jsx)(_callbackContext.LinkCreateCallbackProvider, {
|
|
77
|
+
onCreate: handleCreate,
|
|
78
|
+
onFailure: handleFailure,
|
|
79
|
+
onCancel: onCancel
|
|
80
|
+
}, (0, _react2.jsx)(_trackMount.default, null), (0, _react2.jsx)(LinkCreateContent, restProps))));
|
|
81
|
+
});
|
|
82
|
+
var LinkCreateWithModal = function LinkCreateWithModal(_ref4) {
|
|
83
|
+
var active = _ref4.active,
|
|
84
|
+
modalTitle = _ref4.modalTitle,
|
|
85
|
+
onOpenComplete = _ref4.onOpenComplete,
|
|
86
|
+
onCloseComplete = _ref4.onCloseComplete,
|
|
87
|
+
createProps = (0, _objectWithoutProperties2.default)(_ref4, _excluded2);
|
|
88
|
+
var intl = (0, _reactIntlNext.useIntl)();
|
|
89
|
+
return (0, _react2.jsx)(_modalDialog.ModalTransition, null, !!active && (0, _react2.jsx)(_modalDialog.default, {
|
|
90
|
+
testId: createProps.testId && "".concat(createProps.testId, "--modal"),
|
|
91
|
+
onClose: createProps.onCancel,
|
|
92
|
+
shouldScrollInViewport: true,
|
|
93
|
+
onOpenComplete: onOpenComplete,
|
|
94
|
+
onCloseComplete: onCloseComplete,
|
|
95
|
+
width: "".concat(_constants.CREATE_FORM_MAX_WIDTH_IN_PX, "px")
|
|
96
|
+
}, (0, _react2.jsx)(_modalDialog.ModalHeader, null, (0, _react2.jsx)(_modalDialog.ModalTitle, null, modalTitle || intl.formatMessage(_messages.messages.heading))), (0, _react2.jsx)(_modalDialog.ModalBody, null, (0, _react2.jsx)(LinkCreate, createProps))));
|
|
97
|
+
};
|
|
98
|
+
var _default = LinkCreateWithModal;
|
|
99
|
+
exports.default = _default;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
10
|
+
var _constants = require("../../../common/constants");
|
|
11
|
+
var _analytics = _interopRequireDefault(require("../../../common/utils/analytics/analytics.codegen"));
|
|
12
|
+
/** @jsx jsx */
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Analytics tracking for component mount (and unmount)
|
|
16
|
+
*/
|
|
17
|
+
function TrackMount() {
|
|
18
|
+
var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
|
|
19
|
+
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
20
|
+
(0, _react.useLayoutEffect)(function () {
|
|
21
|
+
// Anything in here is fired on component mount.
|
|
22
|
+
createAnalyticsEvent((0, _analytics.default)('screen.linkCreateScreen.viewed', {})).fire(_constants.ANALYTICS_CHANNEL);
|
|
23
|
+
return function () {
|
|
24
|
+
// Anything in here is fired on component unmount.
|
|
25
|
+
createAnalyticsEvent((0, _analytics.default)('ui.modalDialog.closed.linkCreate', {})).fire(_constants.ANALYTICS_CHANNEL);
|
|
26
|
+
};
|
|
27
|
+
}, [createAnalyticsEvent]);
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
var _default = TrackMount;
|
|
31
|
+
exports.default = _default;
|
package/dist/cjs/ui/main.js
CHANGED
|
@@ -1,104 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = exports.PACKAGE_DATA = void 0;
|
|
9
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
10
8
|
var _objectDestructuringEmpty2 = _interopRequireDefault(require("@babel/runtime/helpers/objectDestructuringEmpty"));
|
|
11
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
10
|
var _react = require("react");
|
|
14
11
|
var _react2 = require("@emotion/react");
|
|
15
|
-
var _reactIntlNext = require("react-intl-next");
|
|
16
12
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
17
|
-
var _modalDialog = _interopRequireWildcard(require("@atlaskit/modal-dialog"));
|
|
18
13
|
var _constants = require("../common/constants");
|
|
19
14
|
var _analytics = require("../common/utils/analytics");
|
|
20
|
-
var _analytics2 = _interopRequireDefault(require("../common/utils/analytics/analytics.codegen"));
|
|
21
|
-
var _callbackContext = require("../controllers/callback-context");
|
|
22
|
-
var _formContext = require("../controllers/form-context");
|
|
23
15
|
var _version = require("../version.json");
|
|
24
|
-
var
|
|
25
|
-
var _messages = require("./messages");
|
|
26
|
-
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); }
|
|
27
|
-
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; }
|
|
16
|
+
var _linkCreate = _interopRequireDefault(require("./link-create"));
|
|
28
17
|
/** @jsx jsx */
|
|
29
18
|
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
onCreate = _ref.onCreate,
|
|
34
|
-
onFailure = _ref.onFailure,
|
|
35
|
-
onCancel = _ref.onCancel;
|
|
36
|
-
var chosenOne = plugins.find(function (plugin) {
|
|
37
|
-
return plugin.key === entityKey;
|
|
38
|
-
});
|
|
39
|
-
var _useFormContext = (0, _formContext.useFormContext)(),
|
|
40
|
-
setFormErrorMessage = _useFormContext.setFormErrorMessage;
|
|
41
|
-
if (!chosenOne) {
|
|
42
|
-
throw new Error('Make sure you specified a valid entityKey');
|
|
43
|
-
}
|
|
44
|
-
var handleCreate = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
45
|
-
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(result) {
|
|
46
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
47
|
-
while (1) switch (_context.prev = _context.next) {
|
|
48
|
-
case 0:
|
|
49
|
-
// Reset the form error message
|
|
50
|
-
setFormErrorMessage(undefined);
|
|
51
|
-
if (!onCreate) {
|
|
52
|
-
_context.next = 4;
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
_context.next = 4;
|
|
56
|
-
return onCreate(result.url);
|
|
57
|
-
case 4:
|
|
58
|
-
case "end":
|
|
59
|
-
return _context.stop();
|
|
60
|
-
}
|
|
61
|
-
}, _callee);
|
|
62
|
-
}));
|
|
63
|
-
return function (_x) {
|
|
64
|
-
return _ref2.apply(this, arguments);
|
|
65
|
-
};
|
|
66
|
-
}(), [onCreate, setFormErrorMessage]);
|
|
67
|
-
var handleFailure = (0, _react.useCallback)(function (errorMessage) {
|
|
68
|
-
// Set the form error message
|
|
69
|
-
setFormErrorMessage(errorMessage);
|
|
70
|
-
onFailure && onFailure(errorMessage);
|
|
71
|
-
}, [onFailure, setFormErrorMessage]);
|
|
72
|
-
return (0, _react2.jsx)(_callbackContext.LinkCreateCallbackProvider, {
|
|
73
|
-
onCreate: handleCreate,
|
|
74
|
-
onFailure: handleFailure,
|
|
75
|
-
onCancel: onCancel
|
|
76
|
-
}, chosenOne.form);
|
|
77
|
-
};
|
|
78
|
-
var LinkCreateWithModal = function LinkCreateWithModal(props) {
|
|
79
|
-
var testId = props.testId,
|
|
80
|
-
onCancel = props.onCancel,
|
|
81
|
-
active = props.active;
|
|
82
|
-
var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
|
|
83
|
-
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
84
|
-
var intl = (0, _reactIntlNext.useIntl)();
|
|
85
|
-
var handleOpenComplete = (0, _react.useCallback)(function () {
|
|
86
|
-
createAnalyticsEvent((0, _analytics2.default)('screen.linkCreateScreen.viewed', {})).fire(_constants.ANALYTICS_CHANNEL);
|
|
87
|
-
}, [createAnalyticsEvent]);
|
|
88
|
-
var handleCloseComplete = (0, _react.useCallback)(function () {
|
|
89
|
-
createAnalyticsEvent((0, _analytics2.default)('ui.modalDialog.closed.linkCreate', {})).fire(_constants.ANALYTICS_CHANNEL);
|
|
90
|
-
}, [createAnalyticsEvent]);
|
|
91
|
-
return (0, _react2.jsx)(_modalDialog.ModalTransition, null, !!active && (0, _react2.jsx)(_modalDialog.default, {
|
|
92
|
-
onClose: onCancel,
|
|
93
|
-
testId: testId,
|
|
94
|
-
shouldScrollInViewport: true,
|
|
95
|
-
onOpenComplete: handleOpenComplete,
|
|
96
|
-
onCloseComplete: handleCloseComplete
|
|
97
|
-
}, (0, _react2.jsx)(_modalDialog.ModalHeader, null, (0, _react2.jsx)(_modalDialog.ModalTitle, null, intl.formatMessage(_messages.messages.heading))), (0, _react2.jsx)(_modalDialog.ModalBody, null, (0, _react2.jsx)(_errorBoundary.ErrorBoundary, null, (0, _react2.jsx)(_formContext.FormContextProvider, null, (0, _react2.jsx)(LinkCreate, props))))));
|
|
98
|
-
};
|
|
99
|
-
var LinkCreateWithAnalyticsContext = (0, _analytics.withLinkCreateAnalyticsContext)( /*#__PURE__*/(0, _react.memo)(function (_ref3) {
|
|
100
|
-
var props = (0, _extends2.default)({}, ((0, _objectDestructuringEmpty2.default)(_ref3), _ref3));
|
|
101
|
-
return (0, _react2.jsx)(LinkCreateWithModal, props);
|
|
19
|
+
var LinkCreateWithAnalyticsContext = (0, _analytics.withLinkCreateAnalyticsContext)( /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
20
|
+
var props = (0, _extends2.default)({}, ((0, _objectDestructuringEmpty2.default)(_ref), _ref));
|
|
21
|
+
return (0, _react2.jsx)(_linkCreate.default, props);
|
|
102
22
|
}));
|
|
103
23
|
var PACKAGE_DATA = {
|
|
104
24
|
packageName: _version.name,
|
package/dist/cjs/version.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { FormContextProvider, useFormContext } from './main';
|
|
1
|
+
export { FormContextProvider, useFormContext, withLinkCreateFormContext } from './main';
|
|
@@ -37,4 +37,7 @@ const FormContextProvider = ({
|
|
|
37
37
|
}, children);
|
|
38
38
|
};
|
|
39
39
|
const useFormContext = () => useContext(FormContext);
|
|
40
|
-
export { FormContextProvider, useFormContext };
|
|
40
|
+
export { FormContextProvider, useFormContext };
|
|
41
|
+
export const withLinkCreateFormContext = WrappedComponent => {
|
|
42
|
+
return props => /*#__PURE__*/React.createElement(FormContextProvider, null, /*#__PURE__*/React.createElement(WrappedComponent, props));
|
|
43
|
+
};
|
|
@@ -7,7 +7,7 @@ import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
|
7
7
|
import { ButtonGroup } from '@atlaskit/button';
|
|
8
8
|
import LoadingButton from '@atlaskit/button/loading-button';
|
|
9
9
|
import Button from '@atlaskit/button/standard-button';
|
|
10
|
-
import Form, { FormFooter
|
|
10
|
+
import Form, { FormFooter } from '@atlaskit/form';
|
|
11
11
|
import ErrorIcon from '@atlaskit/icon/glyph/error';
|
|
12
12
|
import { ANALYTICS_CHANNEL, CREATE_FORM_MAX_WIDTH_IN_PX } from '../../common/constants';
|
|
13
13
|
import createEventPayload from '../../common/utils/analytics/analytics.codegen';
|
|
@@ -69,7 +69,7 @@ export const CreateForm = ({
|
|
|
69
69
|
name: "confluence-creation-form",
|
|
70
70
|
"data-testid": testId,
|
|
71
71
|
css: formStyles
|
|
72
|
-
}), jsx(
|
|
72
|
+
}), jsx("div", null, children), !hideFooter && jsx(FormFooter, null, formErrorMessage && jsx("div", {
|
|
73
73
|
css: errorStyles,
|
|
74
74
|
"data-testid": "link-create-form-error"
|
|
75
75
|
}, jsx(ErrorIcon, {
|
|
@@ -19,6 +19,7 @@ export function TextField({
|
|
|
19
19
|
validationHelpText,
|
|
20
20
|
validators,
|
|
21
21
|
defaultValue,
|
|
22
|
+
isRequired,
|
|
22
23
|
...restProps
|
|
23
24
|
}) {
|
|
24
25
|
const {
|
|
@@ -40,6 +41,7 @@ export function TextField({
|
|
|
40
41
|
jsx(Field, {
|
|
41
42
|
name: name,
|
|
42
43
|
label: label,
|
|
44
|
+
isRequired: isRequired,
|
|
43
45
|
defaultValue: defaultValue !== null && defaultValue !== void 0 ? defaultValue : ''
|
|
44
46
|
}, ({
|
|
45
47
|
fieldProps,
|
|
@@ -48,7 +50,8 @@ export function TextField({
|
|
|
48
50
|
}) => {
|
|
49
51
|
const isInvalid = validateSubmitErrors(meta);
|
|
50
52
|
return jsx(Fragment, null, jsx(AkTextfield, _extends({}, fieldProps, restProps, {
|
|
51
|
-
isInvalid: isInvalid
|
|
53
|
+
isInvalid: isInvalid,
|
|
54
|
+
isRequired: false // Remove the default browser validation
|
|
52
55
|
})), !error && validationHelpText && jsx(HelperMessage, null, validationHelpText), error && isInvalid && jsx(ErrorMessage, {
|
|
53
56
|
testId: `${restProps.testId}-error-message`
|
|
54
57
|
}, error));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
3
|
-
import { ANALYTICS_CHANNEL } from '
|
|
4
|
-
import createEventPayload from '
|
|
3
|
+
import { ANALYTICS_CHANNEL } from '../../../common/constants';
|
|
4
|
+
import createEventPayload from '../../../common/utils/analytics/analytics.codegen';
|
|
5
5
|
import { BaseErrorBoundary } from './error-boundary-base';
|
|
6
6
|
import { ErrorBoundaryUI } from './error-boundary-ui';
|
|
7
7
|
export const ErrorBoundary = ({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './main';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { Fragment, useCallback } from 'react';
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
import { useIntl } from 'react-intl-next';
|
|
5
|
+
import Modal, { ModalBody, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
|
|
6
|
+
import { CREATE_FORM_MAX_WIDTH_IN_PX } from '../../common/constants';
|
|
7
|
+
import { LinkCreateCallbackProvider } from '../../controllers/callback-context';
|
|
8
|
+
import { useFormContext, withLinkCreateFormContext } from '../../controllers/form-context';
|
|
9
|
+
import { ErrorBoundary } from './error-boundary';
|
|
10
|
+
import { messages } from './messages';
|
|
11
|
+
import TrackMount from './track-mount';
|
|
12
|
+
const LinkCreateContent = ({
|
|
13
|
+
plugins,
|
|
14
|
+
entityKey
|
|
15
|
+
}) => {
|
|
16
|
+
const chosenOne = plugins.find(plugin => plugin.key === entityKey);
|
|
17
|
+
if (!chosenOne) {
|
|
18
|
+
throw new Error('Make sure you specified a valid entityKey');
|
|
19
|
+
}
|
|
20
|
+
return jsx(Fragment, null, chosenOne.form);
|
|
21
|
+
};
|
|
22
|
+
const LinkCreate = withLinkCreateFormContext(({
|
|
23
|
+
testId,
|
|
24
|
+
onCreate,
|
|
25
|
+
onFailure,
|
|
26
|
+
onCancel,
|
|
27
|
+
...restProps
|
|
28
|
+
}) => {
|
|
29
|
+
const {
|
|
30
|
+
setFormErrorMessage
|
|
31
|
+
} = useFormContext();
|
|
32
|
+
const handleCreate = useCallback(async result => {
|
|
33
|
+
// Reset the form error message
|
|
34
|
+
setFormErrorMessage(undefined);
|
|
35
|
+
if (onCreate) {
|
|
36
|
+
await onCreate(result.url);
|
|
37
|
+
}
|
|
38
|
+
}, [onCreate, setFormErrorMessage]);
|
|
39
|
+
const handleFailure = useCallback(errorMessage => {
|
|
40
|
+
// Set the form error message
|
|
41
|
+
setFormErrorMessage(errorMessage);
|
|
42
|
+
onFailure && onFailure(errorMessage);
|
|
43
|
+
}, [onFailure, setFormErrorMessage]);
|
|
44
|
+
return jsx("div", {
|
|
45
|
+
"data-testid": testId
|
|
46
|
+
}, jsx(ErrorBoundary, null, jsx(LinkCreateCallbackProvider, {
|
|
47
|
+
onCreate: handleCreate,
|
|
48
|
+
onFailure: handleFailure,
|
|
49
|
+
onCancel: onCancel
|
|
50
|
+
}, jsx(TrackMount, null), jsx(LinkCreateContent, restProps))));
|
|
51
|
+
});
|
|
52
|
+
const LinkCreateWithModal = ({
|
|
53
|
+
active,
|
|
54
|
+
modalTitle,
|
|
55
|
+
onOpenComplete,
|
|
56
|
+
onCloseComplete,
|
|
57
|
+
...createProps
|
|
58
|
+
}) => {
|
|
59
|
+
const intl = useIntl();
|
|
60
|
+
return jsx(ModalTransition, null, !!active && jsx(Modal, {
|
|
61
|
+
testId: createProps.testId && `${createProps.testId}--modal`,
|
|
62
|
+
onClose: createProps.onCancel,
|
|
63
|
+
shouldScrollInViewport: true,
|
|
64
|
+
onOpenComplete: onOpenComplete,
|
|
65
|
+
onCloseComplete: onCloseComplete,
|
|
66
|
+
width: `${CREATE_FORM_MAX_WIDTH_IN_PX}px`
|
|
67
|
+
}, jsx(ModalHeader, null, jsx(ModalTitle, null, modalTitle || intl.formatMessage(messages.heading))), jsx(ModalBody, null, jsx(LinkCreate, createProps))));
|
|
68
|
+
};
|
|
69
|
+
export default LinkCreateWithModal;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { useLayoutEffect } from 'react';
|
|
3
|
+
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
4
|
+
import { ANALYTICS_CHANNEL } from '../../../common/constants';
|
|
5
|
+
import createEventPayload from '../../../common/utils/analytics/analytics.codegen';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Analytics tracking for component mount (and unmount)
|
|
9
|
+
*/
|
|
10
|
+
function TrackMount() {
|
|
11
|
+
const {
|
|
12
|
+
createAnalyticsEvent
|
|
13
|
+
} = useAnalyticsEvents();
|
|
14
|
+
useLayoutEffect(() => {
|
|
15
|
+
// Anything in here is fired on component mount.
|
|
16
|
+
createAnalyticsEvent(createEventPayload('screen.linkCreateScreen.viewed', {})).fire(ANALYTICS_CHANNEL);
|
|
17
|
+
return () => {
|
|
18
|
+
// Anything in here is fired on component unmount.
|
|
19
|
+
createAnalyticsEvent(createEventPayload('ui.modalDialog.closed.linkCreate', {})).fire(ANALYTICS_CHANNEL);
|
|
20
|
+
};
|
|
21
|
+
}, [createAnalyticsEvent]);
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
export default TrackMount;
|
package/dist/es2019/ui/main.js
CHANGED
|
@@ -1,77 +1,15 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import { memo
|
|
2
|
+
import { memo } from 'react';
|
|
3
3
|
import { jsx } from '@emotion/react';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import Modal, { ModalBody, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
|
|
7
|
-
import { ANALYTICS_CHANNEL, COMPONENT_NAME } from '../common/constants';
|
|
4
|
+
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
5
|
+
import { COMPONENT_NAME } from '../common/constants';
|
|
8
6
|
import { withLinkCreateAnalyticsContext } from '../common/utils/analytics';
|
|
9
|
-
import createEventPayload from '../common/utils/analytics/analytics.codegen';
|
|
10
|
-
import { LinkCreateCallbackProvider } from '../controllers/callback-context';
|
|
11
|
-
import { FormContextProvider, useFormContext } from '../controllers/form-context';
|
|
12
7
|
import { name as packageName, version as packageVersion } from '../version.json';
|
|
13
|
-
import
|
|
14
|
-
import { messages } from './messages';
|
|
15
|
-
const LinkCreate = ({
|
|
16
|
-
plugins,
|
|
17
|
-
entityKey,
|
|
18
|
-
onCreate,
|
|
19
|
-
onFailure,
|
|
20
|
-
onCancel
|
|
21
|
-
}) => {
|
|
22
|
-
const chosenOne = plugins.find(plugin => plugin.key === entityKey);
|
|
23
|
-
const {
|
|
24
|
-
setFormErrorMessage
|
|
25
|
-
} = useFormContext();
|
|
26
|
-
if (!chosenOne) {
|
|
27
|
-
throw new Error('Make sure you specified a valid entityKey');
|
|
28
|
-
}
|
|
29
|
-
const handleCreate = useCallback(async result => {
|
|
30
|
-
// Reset the form error message
|
|
31
|
-
setFormErrorMessage(undefined);
|
|
32
|
-
if (onCreate) {
|
|
33
|
-
await onCreate(result.url);
|
|
34
|
-
}
|
|
35
|
-
}, [onCreate, setFormErrorMessage]);
|
|
36
|
-
const handleFailure = useCallback(errorMessage => {
|
|
37
|
-
// Set the form error message
|
|
38
|
-
setFormErrorMessage(errorMessage);
|
|
39
|
-
onFailure && onFailure(errorMessage);
|
|
40
|
-
}, [onFailure, setFormErrorMessage]);
|
|
41
|
-
return jsx(LinkCreateCallbackProvider, {
|
|
42
|
-
onCreate: handleCreate,
|
|
43
|
-
onFailure: handleFailure,
|
|
44
|
-
onCancel: onCancel
|
|
45
|
-
}, chosenOne.form);
|
|
46
|
-
};
|
|
47
|
-
const LinkCreateWithModal = props => {
|
|
48
|
-
const {
|
|
49
|
-
testId,
|
|
50
|
-
onCancel,
|
|
51
|
-
active
|
|
52
|
-
} = props;
|
|
53
|
-
const {
|
|
54
|
-
createAnalyticsEvent
|
|
55
|
-
} = useAnalyticsEvents();
|
|
56
|
-
const intl = useIntl();
|
|
57
|
-
const handleOpenComplete = useCallback(() => {
|
|
58
|
-
createAnalyticsEvent(createEventPayload('screen.linkCreateScreen.viewed', {})).fire(ANALYTICS_CHANNEL);
|
|
59
|
-
}, [createAnalyticsEvent]);
|
|
60
|
-
const handleCloseComplete = useCallback(() => {
|
|
61
|
-
createAnalyticsEvent(createEventPayload('ui.modalDialog.closed.linkCreate', {})).fire(ANALYTICS_CHANNEL);
|
|
62
|
-
}, [createAnalyticsEvent]);
|
|
63
|
-
return jsx(ModalTransition, null, !!active && jsx(Modal, {
|
|
64
|
-
onClose: onCancel,
|
|
65
|
-
testId: testId,
|
|
66
|
-
shouldScrollInViewport: true,
|
|
67
|
-
onOpenComplete: handleOpenComplete,
|
|
68
|
-
onCloseComplete: handleCloseComplete
|
|
69
|
-
}, jsx(ModalHeader, null, jsx(ModalTitle, null, intl.formatMessage(messages.heading))), jsx(ModalBody, null, jsx(ErrorBoundary, null, jsx(FormContextProvider, null, jsx(LinkCreate, props))))));
|
|
70
|
-
};
|
|
8
|
+
import LinkCreate from './link-create';
|
|
71
9
|
const LinkCreateWithAnalyticsContext = withLinkCreateAnalyticsContext( /*#__PURE__*/memo(({
|
|
72
10
|
...props
|
|
73
11
|
}) => {
|
|
74
|
-
return jsx(
|
|
12
|
+
return jsx(LinkCreate, props);
|
|
75
13
|
}));
|
|
76
14
|
export const PACKAGE_DATA = {
|
|
77
15
|
packageName,
|
package/dist/es2019/version.json
CHANGED