@atlaskit/link-create 2.4.0 → 2.5.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/common/ui/error-boundary-modal/index.js +1 -0
- package/dist/cjs/common/ui/error-boundary-ui/error-svg/index.js +1 -0
- package/dist/cjs/controllers/create-field/main.js +1 -1
- package/dist/cjs/controllers/exit-warning-modal-context/index.js +41 -4
- package/dist/cjs/index.js +13 -0
- package/dist/cjs/ui/create-form/async-select/main.js +1 -0
- package/dist/cjs/ui/create-form/form-footer/main.js +1 -0
- package/dist/cjs/ui/create-form/form-loader/main.js +2 -0
- package/dist/cjs/ui/create-form/main.js +2 -1
- package/dist/cjs/ui/create-form/select/main.js +1 -0
- package/dist/cjs/ui/create-form/textfield/main.js +1 -0
- package/dist/cjs/ui/create-form/user-picker/main.js +1 -0
- package/dist/cjs/ui/inline-create/index.js +2 -0
- package/dist/cjs/ui/inline-create/main.js +19 -29
- package/dist/cjs/ui/modal-create/index.js +2 -0
- package/dist/cjs/ui/modal-create/main.js +9 -17
- package/dist/es2019/common/constants.js +1 -1
- package/dist/es2019/common/ui/error-boundary-modal/index.js +1 -0
- package/dist/es2019/common/ui/error-boundary-ui/error-svg/index.js +1 -0
- package/dist/es2019/controllers/create-field/main.js +1 -0
- package/dist/es2019/controllers/exit-warning-modal-context/index.js +30 -4
- package/dist/es2019/index.js +1 -0
- package/dist/es2019/ui/create-form/async-select/main.js +2 -0
- package/dist/es2019/ui/create-form/form-footer/main.js +1 -0
- package/dist/es2019/ui/create-form/form-loader/main.js +2 -0
- package/dist/es2019/ui/create-form/main.js +3 -0
- package/dist/es2019/ui/create-form/select/main.js +1 -0
- package/dist/es2019/ui/create-form/textfield/main.js +1 -0
- package/dist/es2019/ui/create-form/user-picker/main.js +1 -0
- package/dist/es2019/ui/inline-create/index.js +2 -0
- package/dist/es2019/ui/inline-create/main.js +9 -15
- package/dist/es2019/ui/modal-create/index.js +2 -0
- package/dist/es2019/ui/modal-create/main.js +9 -13
- package/dist/esm/common/constants.js +1 -1
- package/dist/esm/common/ui/error-boundary-modal/index.js +1 -0
- package/dist/esm/common/ui/error-boundary-ui/error-svg/index.js +1 -0
- package/dist/esm/controllers/create-field/main.js +1 -0
- package/dist/esm/controllers/exit-warning-modal-context/index.js +40 -4
- package/dist/esm/index.js +1 -0
- package/dist/esm/ui/create-form/async-select/main.js +2 -0
- package/dist/esm/ui/create-form/form-footer/main.js +1 -0
- package/dist/esm/ui/create-form/form-loader/main.js +2 -0
- package/dist/esm/ui/create-form/main.js +3 -0
- package/dist/esm/ui/create-form/select/main.js +1 -0
- package/dist/esm/ui/create-form/textfield/main.js +1 -0
- package/dist/esm/ui/create-form/user-picker/main.js +1 -0
- package/dist/esm/ui/inline-create/index.js +2 -0
- package/dist/esm/ui/inline-create/main.js +10 -20
- package/dist/esm/ui/modal-create/index.js +2 -0
- package/dist/esm/ui/modal-create/main.js +10 -18
- package/dist/types/controllers/exit-warning-modal-context/index.d.ts +4 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/ui/inline-create/main.d.ts +1 -0
- package/dist/types-ts4.5/controllers/exit-warning-modal-context/index.d.ts +4 -0
- package/dist/types-ts4.5/index.d.ts +1 -0
- package/dist/types-ts4.5/ui/inline-create/main.d.ts +1 -0
- package/package.json +120 -118
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/link-create
|
|
2
2
|
|
|
3
|
+
## 2.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#110690](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/110690)
|
|
8
|
+
[`667a03a09590c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/667a03a09590c) -
|
|
9
|
+
Refactor and export exit warning modal provider to support inline create
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 2.4.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -13,7 +13,7 @@ var CREATE_FORM_MIN_HEIGHT_IN_PX = exports.CREATE_FORM_MIN_HEIGHT_IN_PX = '200';
|
|
|
13
13
|
var LINK_CREATE_FORM_POST_CREATE_FIELD = exports.LINK_CREATE_FORM_POST_CREATE_FIELD = '__post_create__';
|
|
14
14
|
var PACKAGE_DATA = exports.PACKAGE_DATA = {
|
|
15
15
|
packageName: "@atlaskit/link-create" || '',
|
|
16
|
-
packageVersion: "2.
|
|
16
|
+
packageVersion: "2.5.0" || '',
|
|
17
17
|
component: COMPONENT_NAME,
|
|
18
18
|
componentName: COMPONENT_NAME
|
|
19
19
|
};
|
|
@@ -12,6 +12,7 @@ var _errorBoundaryUi = require("../error-boundary-ui");
|
|
|
12
12
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
13
13
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
14
|
/** @jsx jsx */
|
|
15
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* ErrorBoundaryModal props are the same as those passed to LinkCreate, which
|
|
@@ -7,6 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
var _react = require("@emotion/react");
|
|
8
8
|
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
9
9
|
/** @jsx jsx */
|
|
10
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
10
11
|
|
|
11
12
|
var WIDTH = 82;
|
|
12
13
|
var errorStyles = (0, _react.css)({
|
|
@@ -11,7 +11,7 @@ var _reactFinalForm = require("react-final-form");
|
|
|
11
11
|
var _form = require("@atlaskit/form");
|
|
12
12
|
var _form2 = require("../../common/utils/form");
|
|
13
13
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /** @jsx jsx */
|
|
14
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /** @jsx jsx */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
15
15
|
var fieldWrapperStyles = (0, _react.css)({
|
|
16
16
|
marginTop: "var(--ds-space-100, 8px)"
|
|
17
17
|
});
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
|
-
exports.useExitWarningModal = exports.ExitWarningModalProvider = void 0;
|
|
8
|
+
exports.useWithExitWarning = exports.useExitWarningModal = exports.ExitWarningModalProvider = void 0;
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
8
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
11
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
10
12
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -12,10 +14,23 @@ var ExitWarningModalContext = /*#__PURE__*/(0, _react.createContext)({
|
|
|
12
14
|
getShouldShowWarning: function getShouldShowWarning() {
|
|
13
15
|
return false;
|
|
14
16
|
},
|
|
15
|
-
setShouldShowWarning: function setShouldShowWarning() {}
|
|
17
|
+
setShouldShowWarning: function setShouldShowWarning() {},
|
|
18
|
+
showExitWarning: false,
|
|
19
|
+
setShowExitWarning: function setShowExitWarning() {
|
|
20
|
+
return false;
|
|
21
|
+
},
|
|
22
|
+
withExitWarning: function withExitWarning() {
|
|
23
|
+
return function () {
|
|
24
|
+
return false;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
16
27
|
});
|
|
17
28
|
var ExitWarningModalProvider = exports.ExitWarningModalProvider = function ExitWarningModalProvider(_ref) {
|
|
18
29
|
var children = _ref.children;
|
|
30
|
+
var _useState = (0, _react.useState)(false),
|
|
31
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
32
|
+
showExitWarning = _useState2[0],
|
|
33
|
+
setShowExitWarning = _useState2[1];
|
|
19
34
|
var shouldShowWarning = (0, _react.useRef)(false);
|
|
20
35
|
var getShouldShowWarning = (0, _react.useCallback)(function () {
|
|
21
36
|
return shouldShowWarning.current;
|
|
@@ -23,12 +38,26 @@ var ExitWarningModalProvider = exports.ExitWarningModalProvider = function ExitW
|
|
|
23
38
|
var setShouldShowWarning = (0, _react.useCallback)(function (show) {
|
|
24
39
|
shouldShowWarning.current = show;
|
|
25
40
|
}, []);
|
|
41
|
+
var withExitWarning = (0, _react.useCallback)(function (callback) {
|
|
42
|
+
return function () {
|
|
43
|
+
if (shouldShowWarning.current && !showExitWarning) {
|
|
44
|
+
setShowExitWarning(true);
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
setShowExitWarning(false);
|
|
48
|
+
callback === null || callback === void 0 || callback(true);
|
|
49
|
+
return true;
|
|
50
|
+
};
|
|
51
|
+
}, [showExitWarning]);
|
|
26
52
|
var value = (0, _react.useMemo)(function () {
|
|
27
53
|
return {
|
|
28
54
|
getShouldShowWarning: getShouldShowWarning,
|
|
29
|
-
setShouldShowWarning: setShouldShowWarning
|
|
55
|
+
setShouldShowWarning: setShouldShowWarning,
|
|
56
|
+
showExitWarning: showExitWarning,
|
|
57
|
+
setShowExitWarning: setShowExitWarning,
|
|
58
|
+
withExitWarning: withExitWarning
|
|
30
59
|
};
|
|
31
|
-
}, [getShouldShowWarning, setShouldShowWarning]);
|
|
60
|
+
}, [getShouldShowWarning, setShouldShowWarning, showExitWarning, setShowExitWarning, withExitWarning]);
|
|
32
61
|
return /*#__PURE__*/_react.default.createElement(ExitWarningModalContext.Provider, {
|
|
33
62
|
value: value
|
|
34
63
|
}, children);
|
|
@@ -39,4 +68,12 @@ var useExitWarningModal = exports.useExitWarningModal = function useExitWarningM
|
|
|
39
68
|
throw new Error('useExitWarningModal used outside of ExitWarningModalProvider');
|
|
40
69
|
}
|
|
41
70
|
return value;
|
|
71
|
+
};
|
|
72
|
+
var useWithExitWarning = exports.useWithExitWarning = function useWithExitWarning() {
|
|
73
|
+
var value = (0, _react.useContext)(ExitWarningModalContext);
|
|
74
|
+
if (!value) {
|
|
75
|
+
throw new Error('useWithExitWarning used outside of ExitWarningModalProvider');
|
|
76
|
+
}
|
|
77
|
+
var withExitWarning = value.withExitWarning;
|
|
78
|
+
return withExitWarning;
|
|
42
79
|
};
|
package/dist/cjs/index.js
CHANGED
|
@@ -40,6 +40,12 @@ Object.defineProperty(exports, "LinkCreateCallbackProvider", {
|
|
|
40
40
|
return _callbackContext.LinkCreateCallbackProvider;
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
|
+
Object.defineProperty(exports, "LinkCreateExitWarningProvider", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function get() {
|
|
46
|
+
return _exitWarningModalContext.ExitWarningModalProvider;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
43
49
|
Object.defineProperty(exports, "Select", {
|
|
44
50
|
enumerable: true,
|
|
45
51
|
get: function get() {
|
|
@@ -70,8 +76,15 @@ Object.defineProperty(exports, "useLinkCreateCallback", {
|
|
|
70
76
|
return _callbackContext.useLinkCreateCallback;
|
|
71
77
|
}
|
|
72
78
|
});
|
|
79
|
+
Object.defineProperty(exports, "useWithExitWarning", {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
get: function get() {
|
|
82
|
+
return _exitWarningModalContext.useWithExitWarning;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
73
85
|
var _index = _interopRequireWildcard(require("./ui/index"));
|
|
74
86
|
var _callbackContext = require("./controllers/callback-context");
|
|
87
|
+
var _exitWarningModalContext = require("./controllers/exit-warning-modal-context");
|
|
75
88
|
var _finalForm = require("final-form");
|
|
76
89
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
77
90
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -24,6 +24,7 @@ var _formContext = require("../../../controllers/form-context");
|
|
|
24
24
|
var _excluded = ["id", "name", "label", "isRequired", "validators", "validationHelpText", "testId", "defaultOption", "loadOptions"],
|
|
25
25
|
_excluded2 = ["fieldId"];
|
|
26
26
|
/** @jsx jsx */
|
|
27
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
27
28
|
var TEST_ID = exports.TEST_ID = 'link-create-async-select';
|
|
28
29
|
|
|
29
30
|
/**
|
|
@@ -14,6 +14,7 @@ var _editButton = require("./edit-button");
|
|
|
14
14
|
var _messages = require("./messages");
|
|
15
15
|
var _submitButton = require("./submit-button");
|
|
16
16
|
/** @jsx jsx */
|
|
17
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
17
18
|
|
|
18
19
|
var formFooterWrapperStyles = (0, _react.css)({
|
|
19
20
|
display: 'flex',
|
|
@@ -9,11 +9,13 @@ var _react = require("@emotion/react");
|
|
|
9
9
|
var _spinner = _interopRequireDefault(require("@atlaskit/spinner"));
|
|
10
10
|
var _constants = require("../../../common/constants");
|
|
11
11
|
/** @jsx jsx */
|
|
12
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
12
13
|
|
|
13
14
|
var formLoaderStyles = (0, _react.css)({
|
|
14
15
|
display: "flex",
|
|
15
16
|
alignItems: "center",
|
|
16
17
|
justifyContent: "center",
|
|
18
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
17
19
|
minHeight: "".concat(_constants.CREATE_FORM_MIN_HEIGHT_IN_PX, "px")
|
|
18
20
|
});
|
|
19
21
|
|
|
@@ -26,8 +26,9 @@ var _formFooter = require("./form-footer");
|
|
|
26
26
|
var _formLoader = require("./form-loader");
|
|
27
27
|
var _excluded = ["submitError"];
|
|
28
28
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
29
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /** @jsx jsx */
|
|
29
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /** @jsx jsx */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
30
30
|
var formStyles = (0, _react2.css)({
|
|
31
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
31
32
|
maxWidth: "".concat(_constants.CREATE_FORM_MAX_WIDTH_IN_PX, "px"),
|
|
32
33
|
padding: "0 0 ".concat("var(--ds-space-300, 24px)", " 0"),
|
|
33
34
|
margin: "var(--ds-space-0, 0px)".concat(" auto")
|
|
@@ -14,6 +14,7 @@ var _createField = require("../../../controllers/create-field");
|
|
|
14
14
|
var _excluded = ["id", "name", "label", "isRequired", "validators", "validationHelpText", "testId"],
|
|
15
15
|
_excluded2 = ["fieldId"];
|
|
16
16
|
/** @jsx jsx */
|
|
17
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
17
18
|
var TEST_ID = exports.TEST_ID = 'link-create-select';
|
|
18
19
|
/**
|
|
19
20
|
* A select component utilising the Atlaskit Select and CreateField.
|
|
@@ -14,6 +14,7 @@ var _createField = require("../../../controllers/create-field");
|
|
|
14
14
|
var _excluded = ["id", "name", "label", "isRequired", "validators", "validationHelpText", "testId"],
|
|
15
15
|
_excluded2 = ["fieldId"];
|
|
16
16
|
/** @jsx jsx */
|
|
17
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
17
18
|
var TEST_ID = exports.TEST_ID = 'link-create-text-field';
|
|
18
19
|
|
|
19
20
|
/**
|
|
@@ -12,6 +12,7 @@ var _smartUserPicker = _interopRequireDefault(require("@atlaskit/smart-user-pick
|
|
|
12
12
|
var _createField = require("../../../controllers/create-field");
|
|
13
13
|
var _excluded = ["fieldId"];
|
|
14
14
|
/** @jsx jsx */
|
|
15
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
15
16
|
var TEST_ID = exports.TEST_ID = 'link-create-user-picker';
|
|
16
17
|
var DEFAULT_DEBOUNCE_TIME = 400;
|
|
17
18
|
var UserPickerWidth = '100%';
|
|
@@ -18,6 +18,8 @@ var _en = _interopRequireDefault(require("../../i18n/en"));
|
|
|
18
18
|
var _main = _interopRequireDefault(require("./main"));
|
|
19
19
|
/** @jsx jsx */
|
|
20
20
|
|
|
21
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
22
|
+
|
|
21
23
|
var LinkCreateWithAnalyticsContext = (0, _analytics.withLinkCreateAnalyticsContext)( /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
22
24
|
return (0, _react2.jsx)(_experienceTracker.Experience, null, (0, _react2.jsx)(_errorBoundary.ErrorBoundary, null, (0, _react2.jsx)(_main.default, props)));
|
|
23
25
|
}));
|
|
@@ -8,9 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
|
-
var
|
|
12
|
-
var _react = require("react");
|
|
13
|
-
var _react2 = require("@emotion/react");
|
|
11
|
+
var _react = require("@emotion/react");
|
|
14
12
|
var _primitives = require("@atlaskit/primitives");
|
|
15
13
|
var _constants = require("../../common/constants");
|
|
16
14
|
var _confirmDismissDialog = require("../../common/ui/confirm-dismiss-dialog");
|
|
@@ -24,6 +22,7 @@ var _formContext = require("../../controllers/form-context");
|
|
|
24
22
|
var _pluginContext = require("../../controllers/plugin-context");
|
|
25
23
|
var _inlineAnalytics = require("./inline-analytics");
|
|
26
24
|
/** @jsx jsx */
|
|
25
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
27
26
|
|
|
28
27
|
var InlineCreateContent = function InlineCreateContent(_ref) {
|
|
29
28
|
var onCreate = _ref.onCreate,
|
|
@@ -35,61 +34,52 @@ var InlineCreateContent = function InlineCreateContent(_ref) {
|
|
|
35
34
|
_ref$testId = _ref.testId,
|
|
36
35
|
testId = _ref$testId === void 0 ? _constants.DEFAULT_TEST_ID : _ref$testId;
|
|
37
36
|
var _useExitWarningModal = (0, _exitWarningModalContext.useExitWarningModal)(),
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
showExitWarning = _useState2[0],
|
|
42
|
-
setShowExitWarning = _useState2[1];
|
|
37
|
+
withExitWarning = _useExitWarningModal.withExitWarning,
|
|
38
|
+
showExitWarning = _useExitWarningModal.showExitWarning,
|
|
39
|
+
setShowExitWarning = _useExitWarningModal.setShowExitWarning;
|
|
43
40
|
var _useEditPostCreateMod = (0, _editPostCreateContext.useEditPostCreateModal)(),
|
|
44
41
|
editViewPayload = _useEditPostCreateMod.editViewPayload;
|
|
45
42
|
var _useLinkCreatePlugins = (0, _pluginContext.useLinkCreatePlugins)(),
|
|
46
43
|
activePlugin = _useLinkCreatePlugins.activePlugin;
|
|
47
|
-
var
|
|
48
|
-
if (getShouldShowWarning() && !showExitWarning) {
|
|
49
|
-
setShowExitWarning(true);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
onCancel === null || onCancel === void 0 || onCancel();
|
|
53
|
-
}, [onCancel, getShouldShowWarning, showExitWarning]);
|
|
54
|
-
var handleCloseExitWarning = (0, _react.useCallback)(function () {
|
|
44
|
+
var handleCloseExitWarning = function handleCloseExitWarning() {
|
|
55
45
|
return setShowExitWarning(false);
|
|
56
|
-
}
|
|
57
|
-
return (0,
|
|
46
|
+
};
|
|
47
|
+
return (0, _react.jsx)(_callbackContext.LinkCreateCallbackProvider, {
|
|
58
48
|
onCreate: onCreate,
|
|
59
49
|
onFailure: onFailure,
|
|
60
|
-
onCancel:
|
|
61
|
-
}, (0,
|
|
50
|
+
onCancel: withExitWarning(onCancel)
|
|
51
|
+
}, (0, _react.jsx)(_errorBoundary.ErrorBoundary, null, (0, _react.jsx)(_inlineAnalytics.InlineAnalytics, {
|
|
62
52
|
screen: _constants.SCREEN_ID
|
|
63
|
-
}, (0,
|
|
53
|
+
}, (0, _react.jsx)(_primitives.Box, {
|
|
64
54
|
testId: testId
|
|
65
|
-
}, (0,
|
|
55
|
+
}, (0, _react.jsx)(_linkCreateContent.LinkCreateContent, {
|
|
66
56
|
plugins: plugins,
|
|
67
57
|
entityKey: entityKey
|
|
68
|
-
})))), onComplete && (0,
|
|
58
|
+
})))), onComplete && (0, _react.jsx)(_editModal.EditModal, {
|
|
69
59
|
onClose: onComplete,
|
|
70
60
|
editViewPayload: editViewPayload,
|
|
71
61
|
activePlugin: activePlugin
|
|
72
|
-
}), (0,
|
|
62
|
+
}), (0, _react.jsx)(_confirmDismissDialog.ConfirmDismissDialog, {
|
|
73
63
|
active: showExitWarning,
|
|
74
64
|
onClose: handleCloseExitWarning,
|
|
75
65
|
onCancel: onCancel
|
|
76
66
|
}));
|
|
77
67
|
};
|
|
78
68
|
var InlineCreate = function InlineCreate(props) {
|
|
79
|
-
return (0,
|
|
69
|
+
return (0, _react.jsx)(_pluginContext.LinkCreatePluginsProvider, {
|
|
80
70
|
plugins: props.plugins,
|
|
81
71
|
entityKey: props.entityKey
|
|
82
72
|
}, function (pluginsProvider) {
|
|
83
|
-
return (0,
|
|
73
|
+
return (0, _react.jsx)(_editPostCreateContext.EditPostCreateModalProvider, {
|
|
84
74
|
active: true
|
|
85
75
|
}, function (_ref2) {
|
|
86
76
|
var _pluginsProvider$acti;
|
|
87
77
|
var setEditViewPayload = _ref2.setEditViewPayload,
|
|
88
78
|
shouldActivateEditView = _ref2.shouldActivateEditView,
|
|
89
79
|
enableEditView = _ref2.enableEditView;
|
|
90
|
-
return (0,
|
|
80
|
+
return (0, _react.jsx)(_formContext.FormContextProvider, {
|
|
91
81
|
enableEditView: pluginsProvider !== null && pluginsProvider !== void 0 && (_pluginsProvider$acti = pluginsProvider.activePlugin) !== null && _pluginsProvider$acti !== void 0 && _pluginsProvider$acti.editView && props !== null && props !== void 0 && props.onComplete ? enableEditView : undefined
|
|
92
|
-
}, (0,
|
|
82
|
+
}, (0, _react.jsx)(InlineCreateContent, (0, _extends2.default)({}, props, {
|
|
93
83
|
onCreate: ( /*#__PURE__*/function () {
|
|
94
84
|
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(payload) {
|
|
95
85
|
var _props$onCreate;
|
|
@@ -119,7 +109,7 @@ var InlineCreate = function InlineCreate(props) {
|
|
|
119
109
|
return _ref3.apply(this, arguments);
|
|
120
110
|
};
|
|
121
111
|
}())
|
|
122
|
-
})))
|
|
112
|
+
})));
|
|
123
113
|
});
|
|
124
114
|
});
|
|
125
115
|
};
|
|
@@ -19,6 +19,8 @@ var _en = _interopRequireDefault(require("../../i18n/en"));
|
|
|
19
19
|
var _main = _interopRequireDefault(require("./main"));
|
|
20
20
|
/** @jsx jsx */
|
|
21
21
|
|
|
22
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
23
|
+
|
|
22
24
|
var LinkCreateWithAnalyticsContext = (0, _analytics.withLinkCreateAnalyticsContext)( /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
23
25
|
return (0, _react2.jsx)(_experienceTracker.Experience, null, (0, _react2.jsx)(_errorBoundary.ErrorBoundary, {
|
|
24
26
|
errorComponent: (0, _react2.jsx)(_errorBoundaryModal.ErrorBoundaryModal, {
|
|
@@ -8,7 +8,6 @@ exports.default = void 0;
|
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
11
|
var _react = require("react");
|
|
13
12
|
var _react2 = require("@emotion/react");
|
|
14
13
|
var _reactIntlNext = require("react-intl-next");
|
|
@@ -29,6 +28,8 @@ var _pluginContext = require("../../controllers/plugin-context");
|
|
|
29
28
|
var _messages = require("./messages");
|
|
30
29
|
/** @jsx jsx */
|
|
31
30
|
|
|
31
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
32
|
+
|
|
32
33
|
var LinkCreateWithModal = function LinkCreateWithModal(_ref) {
|
|
33
34
|
var active = _ref.active,
|
|
34
35
|
modalTitle = _ref.modalTitle,
|
|
@@ -45,33 +46,24 @@ var LinkCreateWithModal = function LinkCreateWithModal(_ref) {
|
|
|
45
46
|
modalHero = _ref.modalHero;
|
|
46
47
|
var intl = (0, _reactIntlNext.useIntl)();
|
|
47
48
|
var _useExitWarningModal = (0, _exitWarningModalContext.useExitWarningModal)(),
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
showExitWarning = _useState2[0],
|
|
52
|
-
setShowExitWarning = _useState2[1];
|
|
49
|
+
withExitWarning = _useExitWarningModal.withExitWarning,
|
|
50
|
+
showExitWarning = _useExitWarningModal.showExitWarning,
|
|
51
|
+
setShowExitWarning = _useExitWarningModal.setShowExitWarning;
|
|
53
52
|
var _useEditPostCreateMod = (0, _editPostCreateContext.useEditPostCreateModal)(),
|
|
54
53
|
editViewPayload = _useEditPostCreateMod.editViewPayload;
|
|
55
54
|
var _useLinkCreatePlugins = (0, _pluginContext.useLinkCreatePlugins)(),
|
|
56
55
|
activePlugin = _useLinkCreatePlugins.activePlugin;
|
|
57
|
-
var
|
|
58
|
-
if (getShouldShowWarning() && !showExitWarning) {
|
|
59
|
-
setShowExitWarning(true);
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
onCancel === null || onCancel === void 0 || onCancel();
|
|
63
|
-
}, [onCancel, getShouldShowWarning, showExitWarning]);
|
|
64
|
-
var handleCloseExitWarning = (0, _react.useCallback)(function () {
|
|
56
|
+
var handleCloseExitWarning = function handleCloseExitWarning() {
|
|
65
57
|
return setShowExitWarning(false);
|
|
66
|
-
}
|
|
58
|
+
};
|
|
67
59
|
return (0, _react2.jsx)(_callbackContext.LinkCreateCallbackProvider, {
|
|
68
60
|
onCreate: onCreate,
|
|
69
61
|
onFailure: onFailure,
|
|
70
|
-
onCancel:
|
|
62
|
+
onCancel: withExitWarning(onCancel)
|
|
71
63
|
}, (0, _react2.jsx)(_modalDialog.ModalTransition, null, active && (0, _react2.jsx)(_ModalDialog.Modal, {
|
|
72
64
|
testId: "link-create-modal",
|
|
73
65
|
screen: _constants.SCREEN_ID,
|
|
74
|
-
onClose:
|
|
66
|
+
onClose: withExitWarning(onCancel),
|
|
75
67
|
shouldScrollInViewport: true,
|
|
76
68
|
onOpenComplete: onOpenComplete,
|
|
77
69
|
onCloseComplete: onCloseComplete,
|
|
@@ -7,7 +7,7 @@ export const CREATE_FORM_MIN_HEIGHT_IN_PX = '200';
|
|
|
7
7
|
export const LINK_CREATE_FORM_POST_CREATE_FIELD = '__post_create__';
|
|
8
8
|
export const PACKAGE_DATA = {
|
|
9
9
|
packageName: "@atlaskit/link-create" || '',
|
|
10
|
-
packageVersion: "2.
|
|
10
|
+
packageVersion: "2.5.0" || '',
|
|
11
11
|
component: COMPONENT_NAME,
|
|
12
12
|
componentName: COMPONENT_NAME
|
|
13
13
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
2
3
|
import { jsx } from '@emotion/react';
|
|
3
4
|
import Modal, { ModalBody, ModalTransition } from '@atlaskit/modal-dialog';
|
|
4
5
|
import { CREATE_FORM_MAX_WIDTH_IN_PX } from '../../constants';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
3
4
|
import { css, jsx } from '@emotion/react';
|
|
4
5
|
const WIDTH = 82;
|
|
5
6
|
const errorStyles = css({
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
2
3
|
import { css, jsx } from '@emotion/react';
|
|
3
4
|
import { Field } from 'react-final-form';
|
|
4
5
|
import { ErrorMessage, HelperMessage, Label, RequiredAsterisk } from '@atlaskit/form';
|
|
@@ -1,20 +1,36 @@
|
|
|
1
|
-
import React, { createContext, useCallback, useContext, useMemo, useRef } from 'react';
|
|
1
|
+
import React, { createContext, useCallback, useContext, useMemo, useRef, useState } from 'react';
|
|
2
2
|
const ExitWarningModalContext = /*#__PURE__*/createContext({
|
|
3
3
|
getShouldShowWarning: () => false,
|
|
4
|
-
setShouldShowWarning: () => {}
|
|
4
|
+
setShouldShowWarning: () => {},
|
|
5
|
+
showExitWarning: false,
|
|
6
|
+
setShowExitWarning: () => false,
|
|
7
|
+
withExitWarning: () => () => false
|
|
5
8
|
});
|
|
6
9
|
export const ExitWarningModalProvider = ({
|
|
7
10
|
children
|
|
8
11
|
}) => {
|
|
12
|
+
const [showExitWarning, setShowExitWarning] = useState(false);
|
|
9
13
|
const shouldShowWarning = useRef(false);
|
|
10
14
|
const getShouldShowWarning = useCallback(() => shouldShowWarning.current, []);
|
|
11
15
|
const setShouldShowWarning = useCallback(show => {
|
|
12
16
|
shouldShowWarning.current = show;
|
|
13
17
|
}, []);
|
|
18
|
+
const withExitWarning = useCallback(callback => () => {
|
|
19
|
+
if (shouldShowWarning.current && !showExitWarning) {
|
|
20
|
+
setShowExitWarning(true);
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
setShowExitWarning(false);
|
|
24
|
+
callback === null || callback === void 0 ? void 0 : callback(true);
|
|
25
|
+
return true;
|
|
26
|
+
}, [showExitWarning]);
|
|
14
27
|
const value = useMemo(() => ({
|
|
15
28
|
getShouldShowWarning,
|
|
16
|
-
setShouldShowWarning
|
|
17
|
-
|
|
29
|
+
setShouldShowWarning,
|
|
30
|
+
showExitWarning,
|
|
31
|
+
setShowExitWarning,
|
|
32
|
+
withExitWarning
|
|
33
|
+
}), [getShouldShowWarning, setShouldShowWarning, showExitWarning, setShowExitWarning, withExitWarning]);
|
|
18
34
|
return /*#__PURE__*/React.createElement(ExitWarningModalContext.Provider, {
|
|
19
35
|
value: value
|
|
20
36
|
}, children);
|
|
@@ -25,4 +41,14 @@ export const useExitWarningModal = () => {
|
|
|
25
41
|
throw new Error('useExitWarningModal used outside of ExitWarningModalProvider');
|
|
26
42
|
}
|
|
27
43
|
return value;
|
|
44
|
+
};
|
|
45
|
+
export const useWithExitWarning = () => {
|
|
46
|
+
const value = useContext(ExitWarningModalContext);
|
|
47
|
+
if (!value) {
|
|
48
|
+
throw new Error('useWithExitWarning used outside of ExitWarningModalProvider');
|
|
49
|
+
}
|
|
50
|
+
const {
|
|
51
|
+
withExitWarning
|
|
52
|
+
} = value;
|
|
53
|
+
return withExitWarning;
|
|
28
54
|
};
|
package/dist/es2019/index.js
CHANGED
|
@@ -3,4 +3,5 @@ export { default, TextField, CreateForm, Select, AsyncSelect, CreateFormLoader,
|
|
|
3
3
|
//InlineCreate,
|
|
4
4
|
UserPicker } from './ui/index';
|
|
5
5
|
export { useLinkCreateCallback, LinkCreateCallbackProvider } from './controllers/callback-context';
|
|
6
|
+
export { ExitWarningModalProvider as LinkCreateExitWarningProvider, useWithExitWarning } from './controllers/exit-warning-modal-context';
|
|
6
7
|
export { FORM_ERROR } from 'final-form';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
/** @jsx jsx */
|
|
3
3
|
import { useEffect, useMemo, useState } from 'react';
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
4
6
|
import { jsx } from '@emotion/react';
|
|
5
7
|
import debounce from 'debounce-promise';
|
|
6
8
|
import { useForm } from 'react-final-form';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
2
3
|
import { css, jsx } from '@emotion/react';
|
|
3
4
|
import Spinner from '@atlaskit/spinner';
|
|
4
5
|
import { CREATE_FORM_MIN_HEIGHT_IN_PX } from '../../../common/constants';
|
|
@@ -6,6 +7,7 @@ const formLoaderStyles = css({
|
|
|
6
7
|
display: `flex`,
|
|
7
8
|
alignItems: `center`,
|
|
8
9
|
justifyContent: `center`,
|
|
10
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
9
11
|
minHeight: `${CREATE_FORM_MIN_HEIGHT_IN_PX}px`
|
|
10
12
|
});
|
|
11
13
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
3
5
|
import { css, jsx } from '@emotion/react';
|
|
4
6
|
import { FORM_ERROR } from 'final-form';
|
|
5
7
|
import { Form, FormSpy } from 'react-final-form';
|
|
@@ -14,6 +16,7 @@ import { useFormContext } from '../../controllers/form-context';
|
|
|
14
16
|
import { CreateFormFooter } from './form-footer';
|
|
15
17
|
import { CreateFormLoader } from './form-loader';
|
|
16
18
|
const formStyles = css({
|
|
19
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
17
20
|
maxWidth: `${CREATE_FORM_MAX_WIDTH_IN_PX}px`,
|
|
18
21
|
padding: `0 0 ${"var(--ds-space-300, 24px)"} 0`,
|
|
19
22
|
margin: `${"var(--ds-space-0, 0px)"} auto`
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
/** @jsx jsx */
|
|
3
3
|
|
|
4
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
4
5
|
import { jsx } from '@emotion/react';
|
|
5
6
|
import AkSelect from '@atlaskit/select';
|
|
6
7
|
import { CreateField } from '../../../controllers/create-field';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
3
4
|
import { jsx } from '@emotion/react';
|
|
4
5
|
import AkTextfield from '@atlaskit/textfield';
|
|
5
6
|
import { CreateField } from '../../../controllers/create-field';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
2
3
|
import { jsx } from '@emotion/react';
|
|
3
4
|
import SmartUserPicker from '@atlaskit/smart-user-picker';
|
|
4
5
|
import { CreateField } from '../../../controllers/create-field';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { memo } from 'react';
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
3
5
|
import { jsx } from '@emotion/react';
|
|
4
6
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
5
7
|
import { IntlMessagesProvider } from '@atlaskit/intl-messages-provider';
|