@atlaskit/modal-dialog 12.4.6 → 12.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/hooks.js +0 -6
  3. package/dist/cjs/index.js +0 -8
  4. package/dist/cjs/internal/components/modal-dialog.js +22 -42
  5. package/dist/cjs/internal/components/positioner.js +9 -16
  6. package/dist/cjs/internal/components/scroll-container.js +18 -43
  7. package/dist/cjs/internal/constants.js +0 -3
  8. package/dist/cjs/internal/context.js +1 -2
  9. package/dist/cjs/internal/hooks/use-modal-stack.js +12 -26
  10. package/dist/cjs/internal/hooks/use-on-motion-finish.js +1 -4
  11. package/dist/cjs/internal/hooks/use-prevent-programmatic-scroll.js +4 -12
  12. package/dist/cjs/internal/hooks/use-scroll.js +0 -5
  13. package/dist/cjs/internal/utils.js +0 -9
  14. package/dist/cjs/modal-body.js +5 -17
  15. package/dist/cjs/modal-footer.js +3 -10
  16. package/dist/cjs/modal-header.js +3 -12
  17. package/dist/cjs/modal-title.js +10 -23
  18. package/dist/cjs/modal-transition.js +0 -5
  19. package/dist/cjs/modal-wrapper.js +24 -45
  20. package/dist/cjs/version.json +1 -1
  21. package/dist/es2019/hooks.js +0 -2
  22. package/dist/es2019/internal/components/modal-dialog.js +4 -6
  23. package/dist/es2019/internal/components/positioner.js +6 -7
  24. package/dist/es2019/internal/components/scroll-container.js +2 -6
  25. package/dist/es2019/internal/hooks/use-modal-stack.js +9 -12
  26. package/dist/es2019/internal/hooks/use-on-motion-finish.js +0 -1
  27. package/dist/es2019/internal/hooks/use-prevent-programmatic-scroll.js +2 -4
  28. package/dist/es2019/internal/hooks/use-scroll.js +2 -3
  29. package/dist/es2019/internal/utils.js +0 -4
  30. package/dist/es2019/modal-body.js +3 -4
  31. package/dist/es2019/modal-footer.js +1 -2
  32. package/dist/es2019/modal-header.js +0 -2
  33. package/dist/es2019/modal-title.js +3 -7
  34. package/dist/es2019/modal-transition.js +1 -2
  35. package/dist/es2019/modal-wrapper.js +5 -7
  36. package/dist/es2019/version.json +1 -1
  37. package/dist/esm/hooks.js +0 -2
  38. package/dist/esm/internal/components/modal-dialog.js +21 -25
  39. package/dist/esm/internal/components/positioner.js +9 -10
  40. package/dist/esm/internal/components/scroll-container.js +18 -28
  41. package/dist/esm/internal/hooks/use-modal-stack.js +13 -19
  42. package/dist/esm/internal/hooks/use-on-motion-finish.js +1 -2
  43. package/dist/esm/internal/hooks/use-prevent-programmatic-scroll.js +5 -8
  44. package/dist/esm/internal/hooks/use-scroll.js +2 -3
  45. package/dist/esm/internal/utils.js +0 -4
  46. package/dist/esm/modal-body.js +5 -8
  47. package/dist/esm/modal-footer.js +3 -6
  48. package/dist/esm/modal-header.js +2 -6
  49. package/dist/esm/modal-title.js +10 -16
  50. package/dist/esm/modal-transition.js +1 -2
  51. package/dist/esm/modal-wrapper.js +24 -26
  52. package/dist/esm/version.json +1 -1
  53. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/modal-dialog
2
2
 
3
+ ## 12.4.8
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 12.4.7
10
+
11
+ ### Patch Changes
12
+
13
+ - [`18aeca8c199`](https://bitbucket.org/atlassian/atlassian-frontend/commits/18aeca8c199) - Internal change to update token references. There is no expected behaviour or visual change.
14
+
3
15
  ## 12.4.6
4
16
 
5
17
  ### Patch Changes
package/dist/cjs/hooks.js CHANGED
@@ -4,19 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.useModal = void 0;
7
-
8
7
  var _react = require("react");
9
-
10
8
  var _context = require("./internal/context");
11
-
12
9
  var useModal = function useModal() {
13
10
  var modalContext = (0, _react.useContext)(_context.ModalContext);
14
-
15
11
  if (modalContext == null) {
16
12
  throw Error('@atlaskit/modal-dialog: Modal context unavailable – this component needs to be a child of ModalDialog.');
17
13
  }
18
-
19
14
  return modalContext;
20
15
  };
21
-
22
16
  exports.useModal = useModal;
package/dist/cjs/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -47,17 +46,10 @@ Object.defineProperty(exports, "useModal", {
47
46
  return _hooks.useModal;
48
47
  }
49
48
  });
50
-
51
49
  var _modalWrapper = _interopRequireDefault(require("./modal-wrapper"));
52
-
53
50
  var _modalTransition = _interopRequireDefault(require("./modal-transition"));
54
-
55
51
  var _modalHeader = _interopRequireDefault(require("./modal-header"));
56
-
57
52
  var _modalTitle = _interopRequireDefault(require("./modal-title"));
58
-
59
53
  var _modalBody = _interopRequireDefault(require("./modal-body"));
60
-
61
54
  var _modalFooter = _interopRequireDefault(require("./modal-footer"));
62
-
63
55
  var _hooks = require("./hooks");
@@ -1,45 +1,28 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
-
12
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
-
14
10
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
15
-
16
11
  var _react = require("react");
17
-
18
12
  var _react2 = require("@emotion/react");
19
-
20
13
  var _reactUid = require("react-uid");
21
-
22
14
  var _mergeRefs = _interopRequireDefault(require("@atlaskit/ds-lib/merge-refs"));
23
-
24
15
  var _useAutoFocus = _interopRequireDefault(require("@atlaskit/ds-lib/use-auto-focus"));
25
-
26
16
  var _focusRing = _interopRequireDefault(require("@atlaskit/focus-ring"));
27
-
28
17
  var _fadeIn = _interopRequireDefault(require("@atlaskit/motion/fade-in"));
29
-
30
18
  var _colors = require("@atlaskit/theme/colors");
31
-
32
19
  var _constants = require("../constants");
33
-
34
20
  var _context = require("../context");
35
-
36
21
  var _useOnMotionFinish3 = _interopRequireDefault(require("../hooks/use-on-motion-finish"));
37
-
38
22
  var _utils = require("../utils");
39
-
40
23
  var _positioner = _interopRequireDefault(require("./positioner"));
41
-
42
24
  /** @jsx jsx */
25
+
43
26
  var dialogStyles = (0, _react2.css)({
44
27
  display: 'flex',
45
28
  width: '100%',
@@ -61,7 +44,6 @@ var dialogStyles = (0, _react2.css)({
61
44
  borderRadius: _constants.borderRadius,
62
45
  boxShadow: "var(--ds-shadow-overlay, ".concat("0 0 0 1px ".concat(_colors.N30A, ", 0 2px 1px ").concat(_colors.N30A, ", 0 0 20px -6px ").concat(_colors.N60A), ")")
63
46
  },
64
-
65
47
  /**
66
48
  * This is to support scrolling if the modal's children are wrapped in
67
49
  * a form.
@@ -91,33 +73,31 @@ var bodyScrollStyles = (0, _react2.css)({
91
73
  maxHeight: 'inherit'
92
74
  }
93
75
  });
94
-
95
76
  var ModalDialog = function ModalDialog(props) {
96
77
  var _props$width = props.width,
97
- width = _props$width === void 0 ? 'medium' : _props$width,
98
- _props$shouldScrollIn = props.shouldScrollInViewport,
99
- shouldScrollInViewport = _props$shouldScrollIn === void 0 ? false : _props$shouldScrollIn,
100
- autoFocus = props.autoFocus,
101
- stackIndex = props.stackIndex,
102
- onClose = props.onClose,
103
- onCloseComplete = props.onCloseComplete,
104
- onOpenComplete = props.onOpenComplete,
105
- height = props.height,
106
- children = props.children,
107
- testId = props.testId;
78
+ width = _props$width === void 0 ? 'medium' : _props$width,
79
+ _props$shouldScrollIn = props.shouldScrollInViewport,
80
+ shouldScrollInViewport = _props$shouldScrollIn === void 0 ? false : _props$shouldScrollIn,
81
+ autoFocus = props.autoFocus,
82
+ stackIndex = props.stackIndex,
83
+ onClose = props.onClose,
84
+ onCloseComplete = props.onCloseComplete,
85
+ onOpenComplete = props.onOpenComplete,
86
+ height = props.height,
87
+ children = props.children,
88
+ testId = props.testId;
108
89
  var id = (0, _reactUid.useUID)();
109
90
  var titleId = "modal-dialog-title-".concat(id);
110
- (0, _useAutoFocus.default)((0, _typeof2.default)(autoFocus) === 'object' ? autoFocus : undefined, // When a user supplies a ref to focus we enable this hook
91
+ (0, _useAutoFocus.default)((0, _typeof2.default)(autoFocus) === 'object' ? autoFocus : undefined,
92
+ // When a user supplies a ref to focus we enable this hook
111
93
  (0, _typeof2.default)(autoFocus) === 'object');
112
-
113
94
  var _useOnMotionFinish = (0, _useOnMotionFinish3.default)({
114
- onOpenComplete: onOpenComplete,
115
- onCloseComplete: onCloseComplete
116
- }),
117
- _useOnMotionFinish2 = (0, _slicedToArray2.default)(_useOnMotionFinish, 2),
118
- motionRef = _useOnMotionFinish2[0],
119
- onMotionFinish = _useOnMotionFinish2[1];
120
-
95
+ onOpenComplete: onOpenComplete,
96
+ onCloseComplete: onCloseComplete
97
+ }),
98
+ _useOnMotionFinish2 = (0, _slicedToArray2.default)(_useOnMotionFinish, 2),
99
+ motionRef = _useOnMotionFinish2[0],
100
+ onMotionFinish = _useOnMotionFinish2[1];
121
101
  var modalDialogContext = (0, _react.useMemo)(function () {
122
102
  return {
123
103
  testId: testId,
@@ -152,8 +132,8 @@ var ModalDialog = function ModalDialog(props) {
152
132
  "aria-modal": true
153
133
  }), children));
154
134
  }))));
155
- }; // eslint-disable-next-line @repo/internal/react/require-jsdoc
156
-
135
+ };
157
136
 
137
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
158
138
  var _default = ModalDialog;
159
139
  exports.default = _default;
@@ -4,21 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _react = require("@emotion/react");
9
-
10
8
  var _curves = require("@atlaskit/motion/curves");
11
-
12
9
  var _durations = require("@atlaskit/motion/durations");
13
-
14
10
  var _constants = require("@atlaskit/theme/constants");
15
-
16
11
  var _constants2 = require("../constants");
17
-
18
12
  /** @jsx jsx */
13
+
19
14
  var maxWidthDimensions = "calc(100vw - ".concat(_constants2.gutter * 2, "px)");
20
- var maxHeightDimensions = "calc(100vh - ".concat(_constants2.gutter * 2 - 1, "px)"); // Flex and min-content are set to constrain the height of the body and support multi-column scrolling experiences
15
+ var maxHeightDimensions = "calc(100vh - ".concat(_constants2.gutter * 2 - 1, "px)");
21
16
 
17
+ // Flex and min-content are set to constrain the height of the body and support multi-column scrolling experiences
22
18
  var positionerStyles = (0, _react.css)({
23
19
  display: 'flex',
24
20
  width: '100%',
@@ -55,7 +51,6 @@ var stackTransitionStyles = (0, _react.css)({
55
51
  transitionDuration: "".concat(_durations.mediumDurationMs, "ms"),
56
52
  transitionProperty: 'transform',
57
53
  transitionTimingFunction: _curves.easeInOut,
58
-
59
54
  /**
60
55
  * Duplicated from @atlaskit/motion/accessibility
61
56
  * because @repo/internal/styles/consistent-style-ordering
@@ -72,23 +67,21 @@ var stackTransformStyles = (0, _react.css)({
72
67
  var stackIdleStyles = (0, _react.css)({
73
68
  transform: 'none'
74
69
  });
75
-
76
70
  var Positioner = function Positioner(props) {
77
71
  var children = props.children,
78
- stackIndex = props.stackIndex,
79
- shouldScrollInViewport = props.shouldScrollInViewport,
80
- testId = props.testId;
72
+ stackIndex = props.stackIndex,
73
+ shouldScrollInViewport = props.shouldScrollInViewport,
74
+ testId = props.testId;
81
75
  return (0, _react.jsx)("div", {
82
76
  style: {
83
77
  '--modal-dialog-translate-y': "".concat(stackIndex * (_constants2.verticalOffset / 2), "px")
84
78
  },
85
- css: [positionerStyles, stackTransitionStyles,
86
- /* We only want to apply transform on modals shifting to the back of the stack. */
79
+ css: [positionerStyles, stackTransitionStyles, /* We only want to apply transform on modals shifting to the back of the stack. */
87
80
  stackIndex > 0 ? stackTransformStyles : stackIdleStyles, shouldScrollInViewport ? viewportScrollStyles : bodyScrollStyles],
88
81
  "data-testid": testId && "".concat(testId, "--positioner")
89
82
  }, children);
90
- }; // eslint-disable-next-line @repo/internal/react/require-jsdoc
91
-
83
+ };
92
84
 
85
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
93
86
  var _default = Positioner;
94
87
  exports.default = _default;
@@ -1,45 +1,29 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  var _typeof = require("@babel/runtime/helpers/typeof");
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
8
  exports.default = void 0;
11
-
12
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
-
14
10
  var _react = _interopRequireWildcard(require("react"));
15
-
16
11
  var _react2 = require("@emotion/react");
17
-
18
12
  var _bindEventListener = require("bind-event-listener");
19
-
20
13
  var _rafSchd = _interopRequireDefault(require("raf-schd"));
21
-
22
14
  var _mergeRefs = _interopRequireDefault(require("@atlaskit/ds-lib/merge-refs"));
23
-
24
15
  var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
25
-
26
16
  var _useLazyCallback = _interopRequireDefault(require("@atlaskit/ds-lib/use-lazy-callback"));
27
-
28
17
  var _useStateRef3 = _interopRequireDefault(require("@atlaskit/ds-lib/use-state-ref"));
29
-
30
18
  var _focusRing = _interopRequireDefault(require("@atlaskit/focus-ring"));
31
-
32
19
  var _constants = require("../constants");
33
-
34
20
  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); }
35
-
36
21
  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; }
37
-
38
22
  /** @jsx jsx */
23
+
39
24
  var baseStyles = (0, _react2.css)({
40
25
  display: 'inherit',
41
- // TODO Delete this comment after verifying spacing token -> previous value `0`
42
- margin: "var(--ds-scale-0, 0px)",
26
+ margin: "var(--ds-space-0, 0px)",
43
27
  flex: 'inherit',
44
28
  flexDirection: 'inherit',
45
29
  flexGrow: 1,
@@ -56,38 +40,32 @@ var topKeylineStyles = (0, _react2.css)({
56
40
  var bottomKeylineStyles = (0, _react2.css)({
57
41
  borderBottom: "".concat(_constants.keylineHeight, "px solid ").concat(_constants.keylineColor)
58
42
  });
59
-
60
43
  /**
61
44
  * A container that shows top and bottom keylines when the
62
45
  * content overflows into the scrollable element.
63
46
  */
64
47
  var ScrollContainer = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
65
48
  var testId = props.testId,
66
- children = props.children;
67
-
49
+ children = props.children;
68
50
  var _useStateRef = (0, _useStateRef3.default)({
69
- previous: false,
70
- next: false
71
- }),
72
- _useStateRef2 = (0, _slicedToArray2.default)(_useStateRef, 2),
73
- hasSiblings = _useStateRef2[0],
74
- setSiblings = _useStateRef2[1];
75
-
51
+ previous: false,
52
+ next: false
53
+ }),
54
+ _useStateRef2 = (0, _slicedToArray2.default)(_useStateRef, 2),
55
+ hasSiblings = _useStateRef2[0],
56
+ setSiblings = _useStateRef2[1];
76
57
  var _useState = (0, _react.useState)(false),
77
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
78
- showContentFocus = _useState2[0],
79
- setContentFocus = _useState2[1];
80
-
58
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
59
+ showContentFocus = _useState2[0],
60
+ setContentFocus = _useState2[1];
81
61
  var _useState3 = (0, _react.useState)(false),
82
- _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
83
- showTopKeyline = _useState4[0],
84
- setTopKeyline = _useState4[1];
85
-
62
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
63
+ showTopKeyline = _useState4[0],
64
+ setTopKeyline = _useState4[1];
86
65
  var _useState5 = (0, _react.useState)(false),
87
- _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
88
- showBottomKeyline = _useState6[0],
89
- setBottomKeyline = _useState6[1];
90
-
66
+ _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
67
+ showBottomKeyline = _useState6[0],
68
+ setBottomKeyline = _useState6[1];
91
69
  var scrollableRef = (0, _react.useRef)(null);
92
70
  var setLazySiblings = (0, _useLazyCallback.default)(setSiblings);
93
71
  var setLazyContentFocus = (0, _useLazyCallback.default)((0, _rafSchd.default)(function () {
@@ -96,14 +74,11 @@ var ScrollContainer = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
96
74
  }));
97
75
  var setLazyKeylines = (0, _useLazyCallback.default)((0, _rafSchd.default)(function () {
98
76
  var target = scrollableRef.current;
99
-
100
77
  if (target) {
101
78
  var scrollableDistance = target.scrollHeight - target.clientHeight;
102
-
103
79
  if (hasSiblings.current.previous) {
104
80
  setTopKeyline(target.scrollTop > _constants.keylineHeight);
105
81
  }
106
-
107
82
  if (hasSiblings.current.next) {
108
83
  setBottomKeyline(target.scrollTop <= scrollableDistance - _constants.keylineHeight);
109
84
  }
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.width = exports.verticalOffset = exports.titleIconMargin = exports.textColor = exports.padding = exports.keylineHeight = exports.keylineColor = exports.iconColor = exports.gutter = exports.footerItemGap = exports.borderRadius = void 0;
7
-
8
7
  var _colors = require("@atlaskit/theme/colors");
9
-
10
8
  var _constants = require("@atlaskit/theme/constants");
11
-
12
9
  var width = {
13
10
  values: ['small', 'medium', 'large', 'x-large'],
14
11
  widths: {
@@ -4,10 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.ScrollContext = exports.ModalContext = void 0;
7
-
8
7
  var _react = require("react");
9
-
10
8
  /* eslint-disable @repo/internal/react/require-jsdoc */
9
+
11
10
  var ModalContext = /*#__PURE__*/(0, _react.createContext)(null);
12
11
  exports.ModalContext = ModalContext;
13
12
  var ScrollContext = /*#__PURE__*/(0, _react.createContext)(null);
@@ -1,24 +1,16 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = useModalStack;
9
-
10
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
-
12
9
  var _react = require("react");
13
-
14
10
  var _useLazyCallback = _interopRequireDefault(require("@atlaskit/ds-lib/use-lazy-callback"));
15
-
16
11
  var _usePreviousValue = _interopRequireDefault(require("@atlaskit/ds-lib/use-previous-value"));
17
-
18
12
  var _useStateRef3 = _interopRequireDefault(require("@atlaskit/ds-lib/use-state-ref"));
19
-
20
13
  var _exitingPersistence = require("@atlaskit/motion/exiting-persistence");
21
-
22
14
  /**
23
15
  * ________________________________________________
24
16
  * | MAJOR VERSIONS WILL NOT KNOW ABOUT EACH OTHER! |
@@ -31,7 +23,6 @@ var _exitingPersistence = require("@atlaskit/motion/exiting-persistence");
31
23
  * E.g. V11 won't know about any from V12.
32
24
  */
33
25
  var modalStackRegister = [];
34
-
35
26
  /**
36
27
  * Returns the position of the calling modal dialog in the modal dialog stack.
37
28
  * Stack index of `0` is the highest position in the stack,
@@ -39,23 +30,22 @@ var modalStackRegister = [];
39
30
  */
40
31
  function useModalStack(_ref) {
41
32
  var onStackChange = _ref.onStackChange;
42
-
43
33
  var _useExitingPersistenc = (0, _exitingPersistence.useExitingPersistence)(),
44
- isExiting = _useExitingPersistenc.isExiting;
45
-
34
+ isExiting = _useExitingPersistenc.isExiting;
46
35
  var _useStateRef = (0, _useStateRef3.default)(0),
47
- _useStateRef2 = (0, _slicedToArray2.default)(_useStateRef, 2),
48
- stackIndexRef = _useStateRef2[0],
49
- setStackIndex = _useStateRef2[1];
50
-
36
+ _useStateRef2 = (0, _slicedToArray2.default)(_useStateRef, 2),
37
+ stackIndexRef = _useStateRef2[0],
38
+ setStackIndex = _useStateRef2[1];
51
39
  var currentStackIndex = stackIndexRef.current;
52
- var previousStackIndex = (0, _usePreviousValue.default)(stackIndexRef.current); // We want to ensure this function **never changes** during the lifecycle of this component.
53
- // This is why it's assigned to a ref and not in a useMemo/useCallback.
40
+ var previousStackIndex = (0, _usePreviousValue.default)(stackIndexRef.current);
54
41
 
42
+ // We want to ensure this function **never changes** during the lifecycle of this component.
43
+ // This is why it's assigned to a ref and not in a useMemo/useCallback.
55
44
  var updateStack = (0, _useLazyCallback.default)(function () {
56
- var newStackIndex = modalStackRegister.indexOf(updateStack); // We access the stack index ref instead of state because this closure will always only
57
- // have the initial state and not any of the later values.
45
+ var newStackIndex = modalStackRegister.indexOf(updateStack);
58
46
 
47
+ // We access the stack index ref instead of state because this closure will always only
48
+ // have the initial state and not any of the later values.
59
49
  if (stackIndexRef.current !== newStackIndex) {
60
50
  setStackIndex(newStackIndex);
61
51
  stackIndexRef.current = newStackIndex;
@@ -63,22 +53,20 @@ function useModalStack(_ref) {
63
53
  });
64
54
  (0, _react.useEffect)(function () {
65
55
  var currentStackIndex = modalStackRegister.indexOf(updateStack);
66
-
67
56
  if (!isExiting && currentStackIndex === -1) {
68
57
  // We are opening the modal dialog.
69
58
  // Add ourselves to the modal stack register!
70
59
  modalStackRegister.unshift(updateStack);
71
60
  }
72
-
73
61
  if (isExiting && currentStackIndex !== -1) {
74
62
  // We are closing the modal dialog using a wrapping modal transition component.
75
63
  // Remove ourselves from the modal stack register!
76
64
  // NOTE: Modal dialogs that don't have a wrapping modal transition component won't flow through here!
77
65
  // For that scenario we cleanup when the component unmounts.
78
66
  modalStackRegister.splice(currentStackIndex, 1);
79
- } // Fire all registered modal dialogs to update their position in the stack.
80
-
67
+ }
81
68
 
69
+ // Fire all registered modal dialogs to update their position in the stack.
82
70
  modalStackRegister.forEach(function (cb) {
83
71
  return cb();
84
72
  });
@@ -87,7 +75,6 @@ function useModalStack(_ref) {
87
75
  return function () {
88
76
  // Final cleanup just in case this modal dialog did not have a wrapping modal transition.
89
77
  var currentStackIndex = modalStackRegister.indexOf(updateStack);
90
-
91
78
  if (currentStackIndex !== -1) {
92
79
  modalStackRegister.splice(currentStackIndex, 1);
93
80
  modalStackRegister.forEach(function (cb) {
@@ -101,7 +88,6 @@ function useModalStack(_ref) {
101
88
  // Initial case that we don't need to notify about.
102
89
  return;
103
90
  }
104
-
105
91
  if (previousStackIndex !== currentStackIndex) {
106
92
  onStackChange(currentStackIndex);
107
93
  }
@@ -4,19 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = useOnMotionFinish;
7
-
8
7
  var _react = require("react");
9
-
10
8
  // eslint-disable-next-line @repo/internal/react/require-jsdoc
11
9
  function useOnMotionFinish(_ref) {
12
10
  var onOpenComplete = _ref.onOpenComplete,
13
- onCloseComplete = _ref.onCloseComplete;
11
+ onCloseComplete = _ref.onCloseComplete;
14
12
  var motionRef = (0, _react.useRef)(null);
15
13
  var onMotionFinish = (0, _react.useCallback)(function (state) {
16
14
  if (state === 'entering' && onOpenComplete) {
17
15
  onOpenComplete(motionRef.current, true);
18
16
  }
19
-
20
17
  if (state === 'exiting' && onCloseComplete) {
21
18
  onCloseComplete(motionRef.current);
22
19
  }
@@ -1,18 +1,13 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = usePreventProgrammaticScroll;
9
-
10
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
-
12
9
  var _react = require("react");
13
-
14
10
  var _bindEventListener = require("bind-event-listener");
15
-
16
11
  /**
17
12
  * Returns how far the body is scrolled from the top of the viewport.
18
13
  *
@@ -25,23 +20,20 @@ var _bindEventListener = require("bind-event-listener");
25
20
  */
26
21
  function getScrollDistance() {
27
22
  var _document$documentEle, _document$body;
28
-
29
23
  return window.pageYOffset || ((_document$documentEle = document.documentElement) === null || _document$documentEle === void 0 ? void 0 : _document$documentEle.scrollTop) || ((_document$body = document.body) === null || _document$body === void 0 ? void 0 : _document$body.scrollTop) || 0;
30
24
  }
25
+
31
26
  /**
32
27
  * Prevents programatic scrolling of the viewport with `scrollIntoView`.
33
28
  * Should be used in conjunction with a scroll lock to prevent a user from scrolling.
34
29
  *
35
30
  * @returns scroll top offset of the viewport
36
31
  */
37
-
38
-
39
32
  function usePreventProgrammaticScroll() {
40
33
  var _useState = (0, _react.useState)(0),
41
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
42
- scrollTopOffset = _useState2[0],
43
- setScrollTopOffset = _useState2[1];
44
-
34
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
35
+ scrollTopOffset = _useState2[0],
36
+ setScrollTopOffset = _useState2[1];
45
37
  (0, _react.useLayoutEffect)(function () {
46
38
  setScrollTopOffset(getScrollDistance());
47
39
  }, []);
@@ -4,18 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = useScroll;
7
-
8
7
  var _react = require("react");
9
-
10
8
  var _context = require("../context");
11
-
12
9
  // eslint-disable-next-line @repo/internal/react/require-jsdoc
13
10
  function useScroll() {
14
11
  var shouldScrollInViewport = (0, _react.useContext)(_context.ScrollContext);
15
-
16
12
  if (shouldScrollInViewport == null) {
17
13
  throw Error('@atlaskit/modal-dialog: Scroll context unavailable – this component needs to be a child of ModalDialog.');
18
14
  }
19
-
20
15
  return shouldScrollInViewport;
21
16
  }
@@ -4,32 +4,23 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.dialogWidth = exports.dialogHeight = void 0;
7
-
8
7
  var _constants = require("./constants");
9
-
10
8
  var dialogWidth = function dialogWidth(input) {
11
9
  if (!input) {
12
10
  return 'auto';
13
11
  }
14
-
15
12
  var isWidthName = _constants.width.values.indexOf(input.toString()) !== -1;
16
13
  var widthName = isWidthName && input;
17
-
18
14
  if (widthName) {
19
15
  return "".concat(_constants.width.widths[widthName], "px");
20
16
  }
21
-
22
17
  return typeof input === 'number' ? "".concat(input, "px") : input;
23
18
  };
24
-
25
19
  exports.dialogWidth = dialogWidth;
26
-
27
20
  var dialogHeight = function dialogHeight(input) {
28
21
  if (!input) {
29
22
  return 'auto';
30
23
  }
31
-
32
24
  return typeof input === 'number' ? "".concat(input, "px") : input;
33
25
  };
34
-
35
26
  exports.dialogHeight = dialogHeight;