@atlaskit/link-create 0.6.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/controllers/form-context/index.js +6 -0
- package/dist/cjs/controllers/form-context/main.js +8 -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 -85
- package/dist/cjs/version.json +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/{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 -68
- package/dist/es2019/version.json +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/{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 -85
- package/dist/esm/version.json +1 -1
- package/dist/types/common/types.d.ts +24 -5
- package/dist/types/controllers/callback-context/main.d.ts +2 -5
- 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/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/types.d.ts +24 -5
- package/dist/types-ts4.5/controllers/callback-context/main.d.ts +2 -5
- 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/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 +9 -9
- package/report.api.md +17 -12
- package/tmp/api-report-tmp.d.ts +15 -12
- 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.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`41d73aab05c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/41d73aab05c) - EDM-6938: pass spaceName into onCreate submit for confluence-create and pass as optional meta data into link-create."
|
|
8
|
+
|
|
9
|
+
## 0.7.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`eb070266532`](https://bitbucket.org/atlassian/atlassian-frontend/commits/eb070266532) - Expose Modal callbacks and Add modalTitle to the linkCreate Props
|
|
14
|
+
|
|
3
15
|
## 0.6.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -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;
|
|
@@ -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);
|
|
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
|
+
onCancel: onCancel,
|
|
78
|
+
onCreate: handleCreate,
|
|
79
|
+
onFailure: handleFailure
|
|
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,105 +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
|
-
width: "".concat(_constants.CREATE_FORM_MAX_WIDTH_IN_PX, "px")
|
|
98
|
-
}, (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))))));
|
|
99
|
-
};
|
|
100
|
-
var LinkCreateWithAnalyticsContext = (0, _analytics.withLinkCreateAnalyticsContext)( /*#__PURE__*/(0, _react.memo)(function (_ref3) {
|
|
101
|
-
var props = (0, _extends2.default)({}, ((0, _objectDestructuringEmpty2.default)(_ref3), _ref3));
|
|
102
|
-
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);
|
|
103
22
|
}));
|
|
104
23
|
var PACKAGE_DATA = {
|
|
105
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
|
+
};
|
|
@@ -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);
|
|
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
|
+
onCancel: onCancel,
|
|
48
|
+
onCreate: handleCreate,
|
|
49
|
+
onFailure: handleFailure
|
|
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,78 +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, CREATE_FORM_MAX_WIDTH_IN_PX } 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
|
-
width: `${CREATE_FORM_MAX_WIDTH_IN_PX}px`
|
|
70
|
-
}, jsx(ModalHeader, null, jsx(ModalTitle, null, intl.formatMessage(messages.heading))), jsx(ModalBody, null, jsx(ErrorBoundary, null, jsx(FormContextProvider, null, jsx(LinkCreate, props))))));
|
|
71
|
-
};
|
|
8
|
+
import LinkCreate from './link-create';
|
|
72
9
|
const LinkCreateWithAnalyticsContext = withLinkCreateAnalyticsContext( /*#__PURE__*/memo(({
|
|
73
10
|
...props
|
|
74
11
|
}) => {
|
|
75
|
-
return jsx(
|
|
12
|
+
return jsx(LinkCreate, props);
|
|
76
13
|
}));
|
|
77
14
|
export const PACKAGE_DATA = {
|
|
78
15
|
packageName,
|
package/dist/es2019/version.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { FormContextProvider, useFormContext } from './main';
|
|
1
|
+
export { FormContextProvider, useFormContext, withLinkCreateFormContext } from './main';
|
|
@@ -49,4 +49,9 @@ var FormContextProvider = function FormContextProvider(_ref) {
|
|
|
49
49
|
var useFormContext = function useFormContext() {
|
|
50
50
|
return useContext(FormContext);
|
|
51
51
|
};
|
|
52
|
-
export { FormContextProvider, useFormContext };
|
|
52
|
+
export { FormContextProvider, useFormContext };
|
|
53
|
+
export var withLinkCreateFormContext = function withLinkCreateFormContext(WrappedComponent) {
|
|
54
|
+
return function (props) {
|
|
55
|
+
return /*#__PURE__*/React.createElement(FormContextProvider, null, /*#__PURE__*/React.createElement(WrappedComponent, props));
|
|
56
|
+
};
|
|
57
|
+
};
|
|
@@ -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 var ErrorBoundary = function ErrorBoundary(_ref) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './main';
|