@atlaskit/modal-dialog 12.0.2
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 +2111 -0
- package/LICENSE +13 -0
- package/README.md +13 -0
- package/__perf__/default.tsx +42 -0
- package/__perf__/interactions.tsx +136 -0
- package/__perf__/scroll.tsx +98 -0
- package/codemods/12.0.0-lite-mode.ts +51 -0
- package/codemods/__tests__/12.0.0-lite-mode.test.ts +493 -0
- package/codemods/__tests__/handle-prop-spread.tsx +276 -0
- package/codemods/__tests__/inline-WidthNames-declaration.test.ts +260 -0
- package/codemods/__tests__/map-actions-prop.tsx +436 -0
- package/codemods/__tests__/map-body-from-props.test.ts +645 -0
- package/codemods/__tests__/map-container-from-props.test.ts +323 -0
- package/codemods/__tests__/map-footer-from-props.test.ts +544 -0
- package/codemods/__tests__/map-header-from-props.test.ts +559 -0
- package/codemods/__tests__/map-heading-prop.tsx +438 -0
- package/codemods/__tests__/remove-appearance-prop.test.ts +79 -0
- package/codemods/__tests__/remove-component-override-props.test.ts +153 -0
- package/codemods/__tests__/remove-is-chromeless.tsx +182 -0
- package/codemods/__tests__/rename-appearance-type.test.ts +52 -0
- package/codemods/__tests__/rename-inner-component-prop-types.test.ts +82 -0
- package/codemods/__tests__/rename-scrollBehavior-to-shouldScrollInViewport.test.ts +237 -0
- package/codemods/internal/constants.tsx +41 -0
- package/codemods/internal/utils.tsx +223 -0
- package/codemods/migrations/handle-prop-spread.tsx +51 -0
- package/codemods/migrations/inline-WidthNames-declaration.ts +92 -0
- package/codemods/migrations/map-actions-prop.tsx +430 -0
- package/codemods/migrations/map-body-from-props.ts +147 -0
- package/codemods/migrations/map-container-from-props.ts +72 -0
- package/codemods/migrations/map-footer-from-props.ts +107 -0
- package/codemods/migrations/map-header-from-props.ts +101 -0
- package/codemods/migrations/map-heading-prop.tsx +193 -0
- package/codemods/migrations/remove-appearance-prop.ts +27 -0
- package/codemods/migrations/remove-component-override-props.ts +84 -0
- package/codemods/migrations/remove-is-chromeless.tsx +42 -0
- package/codemods/migrations/rename-appearance-type.ts +9 -0
- package/codemods/migrations/rename-inner-component-prop-types.ts +28 -0
- package/codemods/migrations/rename-scrollBehavior-to-shouldScrollInViewport.ts +82 -0
- package/dist/cjs/hooks.js +22 -0
- package/dist/cjs/index.js +63 -0
- package/dist/cjs/internal/components/modal-dialog.js +155 -0
- package/dist/cjs/internal/components/positioner.js +89 -0
- package/dist/cjs/internal/components/scroll-container.js +138 -0
- package/dist/cjs/internal/constants.js +48 -0
- package/dist/cjs/internal/context.js +13 -0
- package/dist/cjs/internal/hooks/use-modal-stack.js +110 -0
- package/dist/cjs/internal/hooks/use-on-motion-finish.js +24 -0
- package/dist/cjs/internal/hooks/use-prevent-programmatic-scroll.js +55 -0
- package/dist/cjs/internal/hooks/use-scroll.js +20 -0
- package/dist/cjs/internal/utils.js +35 -0
- package/dist/cjs/modal-body.js +66 -0
- package/dist/cjs/modal-footer.js +40 -0
- package/dist/cjs/modal-header.js +43 -0
- package/dist/cjs/modal-title.js +108 -0
- package/dist/cjs/modal-transition.js +21 -0
- package/dist/cjs/modal-wrapper.js +126 -0
- package/dist/cjs/types.js +5 -0
- package/dist/cjs/version.json +5 -0
- package/dist/es2019/hooks.js +11 -0
- package/dist/es2019/index.js +7 -0
- package/dist/es2019/internal/components/modal-dialog.js +120 -0
- package/dist/es2019/internal/components/positioner.js +78 -0
- package/dist/es2019/internal/components/scroll-container.js +97 -0
- package/dist/es2019/internal/constants.js +27 -0
- package/dist/es2019/internal/context.js +3 -0
- package/dist/es2019/internal/hooks/use-modal-stack.js +85 -0
- package/dist/es2019/internal/hooks/use-on-motion-finish.js +17 -0
- package/dist/es2019/internal/hooks/use-prevent-programmatic-scroll.js +39 -0
- package/dist/es2019/internal/hooks/use-scroll.js +11 -0
- package/dist/es2019/internal/utils.js +22 -0
- package/dist/es2019/modal-body.js +50 -0
- package/dist/es2019/modal-footer.js +30 -0
- package/dist/es2019/modal-header.js +30 -0
- package/dist/es2019/modal-title.js +94 -0
- package/dist/es2019/modal-transition.js +10 -0
- package/dist/es2019/modal-wrapper.js +88 -0
- package/dist/es2019/types.js +1 -0
- package/dist/es2019/version.json +5 -0
- package/dist/esm/hooks.js +11 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/internal/components/modal-dialog.js +131 -0
- package/dist/esm/internal/components/positioner.js +76 -0
- package/dist/esm/internal/components/scroll-container.js +114 -0
- package/dist/esm/internal/constants.js +27 -0
- package/dist/esm/internal/context.js +3 -0
- package/dist/esm/internal/hooks/use-modal-stack.js +96 -0
- package/dist/esm/internal/hooks/use-on-motion-finish.js +16 -0
- package/dist/esm/internal/hooks/use-prevent-programmatic-scroll.js +44 -0
- package/dist/esm/internal/hooks/use-scroll.js +11 -0
- package/dist/esm/internal/utils.js +22 -0
- package/dist/esm/modal-body.js +49 -0
- package/dist/esm/modal-footer.js +29 -0
- package/dist/esm/modal-header.js +29 -0
- package/dist/esm/modal-title.js +93 -0
- package/dist/esm/modal-transition.js +10 -0
- package/dist/esm/modal-wrapper.js +96 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/version.json +5 -0
- package/dist/types/hooks.d.ts +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/internal/components/modal-dialog.d.ts +3 -0
- package/dist/types/internal/components/positioner.d.ts +10 -0
- package/dist/types/internal/components/scroll-container.d.ts +20 -0
- package/dist/types/internal/constants.d.ts +25 -0
- package/dist/types/internal/context.d.ts +20 -0
- package/dist/types/internal/hooks/use-modal-stack.d.ts +13 -0
- package/dist/types/internal/hooks/use-on-motion-finish.d.ts +4 -0
- package/dist/types/internal/hooks/use-prevent-programmatic-scroll.d.ts +7 -0
- package/dist/types/internal/hooks/use-scroll.d.ts +1 -0
- package/dist/types/internal/utils.d.ts +3 -0
- package/dist/types/modal-body.d.ts +16 -0
- package/dist/types/modal-footer.d.ts +16 -0
- package/dist/types/modal-header.d.ts +16 -0
- package/dist/types/modal-title.d.ts +26 -0
- package/dist/types/modal-transition.d.ts +3 -0
- package/dist/types/modal-wrapper.d.ts +5 -0
- package/dist/types/types.d.ts +90 -0
- package/extract-react-types/modal-attributes.tsx +5 -0
- package/hooks/package.json +7 -0
- package/modal-body/package.json +7 -0
- package/modal-dialog/package.json +7 -0
- package/modal-footer/package.json +7 -0
- package/modal-header/package.json +7 -0
- package/modal-title/package.json +7 -0
- package/modal-transition/package.json +7 -0
- package/package.json +113 -0
- package/types/package.json +7 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { css, jsx } from '@emotion/core';
|
|
3
|
+
import { useModal } from './hooks';
|
|
4
|
+
import { footerItemGap, keylineHeight, padding } from './internal/constants';
|
|
5
|
+
var footerStyles = css({
|
|
6
|
+
display: 'flex',
|
|
7
|
+
padding: padding,
|
|
8
|
+
paddingTop: "".concat(padding - keylineHeight, "px"),
|
|
9
|
+
position: 'relative',
|
|
10
|
+
alignItems: 'center',
|
|
11
|
+
justifyContent: 'flex-end',
|
|
12
|
+
gap: "".concat(footerItemGap, "px")
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
var ModalFooter = function ModalFooter(props) {
|
|
16
|
+
var children = props.children,
|
|
17
|
+
userDefinedTestId = props.testId;
|
|
18
|
+
|
|
19
|
+
var _useModal = useModal(),
|
|
20
|
+
modalTestId = _useModal.testId;
|
|
21
|
+
|
|
22
|
+
var testId = userDefinedTestId || modalTestId && "".concat(modalTestId, "--footer");
|
|
23
|
+
return jsx("div", {
|
|
24
|
+
css: footerStyles,
|
|
25
|
+
"data-testid": testId
|
|
26
|
+
}, children);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default ModalFooter;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { css, jsx } from '@emotion/core';
|
|
4
|
+
import { useModal } from './hooks';
|
|
5
|
+
import { keylineHeight, padding } from './internal/constants';
|
|
6
|
+
var headerStyles = css({
|
|
7
|
+
display: 'flex',
|
|
8
|
+
padding: padding,
|
|
9
|
+
paddingBottom: "".concat(padding - keylineHeight, "px"),
|
|
10
|
+
position: 'relative',
|
|
11
|
+
alignItems: 'center',
|
|
12
|
+
justifyContent: 'space-between'
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
var ModalHeader = function ModalHeader(props) {
|
|
16
|
+
var children = props.children,
|
|
17
|
+
userDefinedTestId = props.testId;
|
|
18
|
+
|
|
19
|
+
var _useModal = useModal(),
|
|
20
|
+
modalTestId = _useModal.testId;
|
|
21
|
+
|
|
22
|
+
var testId = userDefinedTestId || modalTestId && "".concat(modalTestId, "--header");
|
|
23
|
+
return jsx("div", {
|
|
24
|
+
css: headerStyles,
|
|
25
|
+
"data-testid": testId
|
|
26
|
+
}, children);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default ModalHeader;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { css, jsx } from '@emotion/core';
|
|
3
|
+
import ErrorIcon from '@atlaskit/icon/glyph/error';
|
|
4
|
+
import WarningIcon from '@atlaskit/icon/glyph/warning';
|
|
5
|
+
import { useModal } from './hooks';
|
|
6
|
+
import { iconColor, titleIconMargin } from './internal/constants';
|
|
7
|
+
var fontSize = 20;
|
|
8
|
+
var lineHeight = 1;
|
|
9
|
+
var adjustedLineHeight = 1.2;
|
|
10
|
+
var titleStyles = css({
|
|
11
|
+
display: 'flex',
|
|
12
|
+
minWidth: 0,
|
|
13
|
+
margin: 0,
|
|
14
|
+
alignItems: 'center',
|
|
15
|
+
fontSize: "".concat(fontSize, "px"),
|
|
16
|
+
fontStyle: 'inherit',
|
|
17
|
+
fontWeight: 500,
|
|
18
|
+
letterSpacing: "-0.008em",
|
|
19
|
+
lineHeight: lineHeight
|
|
20
|
+
});
|
|
21
|
+
var textStyles = css({
|
|
22
|
+
minWidth: 0,
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* This ensures that the element fills the whole header space
|
|
26
|
+
* and its content does not overflow (since flex items don't
|
|
27
|
+
* shrink past its content size by default). */
|
|
28
|
+
flex: '1 1 auto',
|
|
29
|
+
wordWrap: 'break-word'
|
|
30
|
+
});
|
|
31
|
+
var iconStyles = css({
|
|
32
|
+
marginRight: "".concat(titleIconMargin, "px"),
|
|
33
|
+
|
|
34
|
+
/* Keeps the size of the icon the same, in case the text element grows in width. */
|
|
35
|
+
flex: '0 0 auto'
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* When the title is truncated (not multi-line), we adjust the
|
|
39
|
+
* line height to avoid cropping the descenders. This removes
|
|
40
|
+
* the extra spacing that we get from that adjustment. */
|
|
41
|
+
|
|
42
|
+
var lineHeightOffset = fontSize - fontSize * adjustedLineHeight;
|
|
43
|
+
var truncatedTextStyles = css({
|
|
44
|
+
marginTop: "".concat(lineHeightOffset / 2, "px"),
|
|
45
|
+
marginBottom: "".concat(lineHeightOffset / 2, "px"),
|
|
46
|
+
lineHeight: adjustedLineHeight,
|
|
47
|
+
overflow: 'hidden',
|
|
48
|
+
textOverflow: 'ellipsis',
|
|
49
|
+
whiteSpace: 'nowrap'
|
|
50
|
+
});
|
|
51
|
+
var truncatedTextIconStyles = css({
|
|
52
|
+
marginBottom: "".concat(lineHeightOffset / 2, "px"),
|
|
53
|
+
lineHeight: 1.2
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
var TitleIcon = function TitleIcon(_ref) {
|
|
57
|
+
var appearance = _ref.appearance,
|
|
58
|
+
isMultiline = _ref.isMultiline;
|
|
59
|
+
var Icon = appearance === 'danger' ? ErrorIcon : WarningIcon;
|
|
60
|
+
return jsx("span", {
|
|
61
|
+
css: [iconStyles, !isMultiline && truncatedTextIconStyles]
|
|
62
|
+
}, jsx(Icon, {
|
|
63
|
+
label: "".concat(appearance, " icon"),
|
|
64
|
+
primaryColor: iconColor[appearance]
|
|
65
|
+
}));
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
var ModalTitle = function ModalTitle(props) {
|
|
69
|
+
var appearance = props.appearance,
|
|
70
|
+
children = props.children,
|
|
71
|
+
_props$isMultiline = props.isMultiline,
|
|
72
|
+
isMultiline = _props$isMultiline === void 0 ? true : _props$isMultiline,
|
|
73
|
+
userDefinedTestId = props.testId;
|
|
74
|
+
|
|
75
|
+
var _useModal = useModal(),
|
|
76
|
+
titleId = _useModal.titleId,
|
|
77
|
+
modalTestId = _useModal.testId;
|
|
78
|
+
|
|
79
|
+
var testId = userDefinedTestId || modalTestId && "".concat(modalTestId, "--title");
|
|
80
|
+
return jsx("h1", {
|
|
81
|
+
css: titleStyles,
|
|
82
|
+
"data-testid": testId
|
|
83
|
+
}, appearance && jsx(TitleIcon, {
|
|
84
|
+
appearance: appearance,
|
|
85
|
+
isMultiline: isMultiline
|
|
86
|
+
}), jsx("span", {
|
|
87
|
+
id: titleId,
|
|
88
|
+
css: [textStyles, !isMultiline && truncatedTextStyles],
|
|
89
|
+
"data-testid": testId && "".concat(testId, "-text")
|
|
90
|
+
}, children));
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export default ModalTitle;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ExitingPersistence from '@atlaskit/motion/exiting-persistence';
|
|
3
|
+
|
|
4
|
+
var ModalTransition = function ModalTransition(props) {
|
|
5
|
+
return /*#__PURE__*/React.createElement(ExitingPersistence, {
|
|
6
|
+
appear: true
|
|
7
|
+
}, props.children);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default ModalTransition;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
|
|
4
|
+
/** @jsx jsx */
|
|
5
|
+
import { useCallback } from 'react';
|
|
6
|
+
import { css, jsx } from '@emotion/core';
|
|
7
|
+
import FocusLock from 'react-focus-lock';
|
|
8
|
+
import ScrollLock, { TouchScrollable } from 'react-scrolllock';
|
|
9
|
+
import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next';
|
|
10
|
+
import Blanket from '@atlaskit/blanket';
|
|
11
|
+
import noop from '@atlaskit/ds-lib/noop';
|
|
12
|
+
import useCloseOnEscapePress from '@atlaskit/ds-lib/use-close-on-escape-press';
|
|
13
|
+
import FadeIn from '@atlaskit/motion/fade-in';
|
|
14
|
+
import Portal from '@atlaskit/portal';
|
|
15
|
+
import { layers } from '@atlaskit/theme/constants';
|
|
16
|
+
import ModalDialog from './internal/components/modal-dialog';
|
|
17
|
+
import useModalStack from './internal/hooks/use-modal-stack';
|
|
18
|
+
import usePreventProgrammaticScroll from './internal/hooks/use-prevent-programmatic-scroll';
|
|
19
|
+
var fillScreenStyles = css({
|
|
20
|
+
width: '100vw',
|
|
21
|
+
height: '100vh',
|
|
22
|
+
position: 'fixed',
|
|
23
|
+
top: 0,
|
|
24
|
+
left: 0,
|
|
25
|
+
overflowY: 'auto',
|
|
26
|
+
WebkitOverflowScrolling: 'touch'
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
var ModalWrapper = function ModalWrapper(props) {
|
|
30
|
+
var _props$autoFocus = props.autoFocus,
|
|
31
|
+
autoFocus = _props$autoFocus === void 0 ? true : _props$autoFocus,
|
|
32
|
+
_props$shouldCloseOnE = props.shouldCloseOnEscapePress,
|
|
33
|
+
shouldCloseOnEscapePress = _props$shouldCloseOnE === void 0 ? true : _props$shouldCloseOnE,
|
|
34
|
+
_props$shouldCloseOnO = props.shouldCloseOnOverlayClick,
|
|
35
|
+
shouldCloseOnOverlayClick = _props$shouldCloseOnO === void 0 ? true : _props$shouldCloseOnO,
|
|
36
|
+
_props$shouldScrollIn = props.shouldScrollInViewport,
|
|
37
|
+
shouldScrollInViewport = _props$shouldScrollIn === void 0 ? false : _props$shouldScrollIn,
|
|
38
|
+
stackIndexOverride = props.stackIndex,
|
|
39
|
+
_props$onClose = props.onClose,
|
|
40
|
+
onClose = _props$onClose === void 0 ? noop : _props$onClose,
|
|
41
|
+
_props$onStackChange = props.onStackChange,
|
|
42
|
+
onStackChange = _props$onStackChange === void 0 ? noop : _props$onStackChange,
|
|
43
|
+
isBlanketHidden = props.isBlanketHidden,
|
|
44
|
+
testId = props.testId,
|
|
45
|
+
modalDialogProps = _objectWithoutProperties(props, ["autoFocus", "shouldCloseOnEscapePress", "shouldCloseOnOverlayClick", "shouldScrollInViewport", "stackIndex", "onClose", "onStackChange", "isBlanketHidden", "testId"]);
|
|
46
|
+
|
|
47
|
+
var calculatedStackIndex = useModalStack({
|
|
48
|
+
onStackChange: onStackChange
|
|
49
|
+
});
|
|
50
|
+
var stackIndex = stackIndexOverride || calculatedStackIndex;
|
|
51
|
+
var isForeground = stackIndex === 0; // When a user supplies a ref to focus we skip auto focus via react-focus-lock
|
|
52
|
+
|
|
53
|
+
var autoFocusLock = typeof autoFocus === 'boolean' ? autoFocus : false;
|
|
54
|
+
var onCloseHandler = usePlatformLeafEventHandler({
|
|
55
|
+
fn: onClose,
|
|
56
|
+
action: 'closed',
|
|
57
|
+
componentName: 'modalDialog',
|
|
58
|
+
packageName: "@atlaskit/modal-dialog",
|
|
59
|
+
packageVersion: "12.0.2"
|
|
60
|
+
});
|
|
61
|
+
var onBlanketClicked = useCallback(function (e) {
|
|
62
|
+
if (shouldCloseOnOverlayClick) {
|
|
63
|
+
onCloseHandler(e);
|
|
64
|
+
}
|
|
65
|
+
}, [shouldCloseOnOverlayClick, onCloseHandler]);
|
|
66
|
+
usePreventProgrammaticScroll();
|
|
67
|
+
useCloseOnEscapePress({
|
|
68
|
+
onClose: onCloseHandler,
|
|
69
|
+
isDisabled: !shouldCloseOnEscapePress || !isForeground
|
|
70
|
+
});
|
|
71
|
+
var modalDialogWithBlanket = jsx(Blanket, {
|
|
72
|
+
isTinted: !isBlanketHidden,
|
|
73
|
+
onBlanketClicked: onBlanketClicked,
|
|
74
|
+
testId: testId && "".concat(testId, "--blanket")
|
|
75
|
+
}, jsx(ModalDialog, _extends({
|
|
76
|
+
testId: testId,
|
|
77
|
+
autoFocus: autoFocus,
|
|
78
|
+
stackIndex: stackIndex,
|
|
79
|
+
onClose: onCloseHandler,
|
|
80
|
+
shouldScrollInViewport: shouldScrollInViewport
|
|
81
|
+
}, modalDialogProps)));
|
|
82
|
+
return jsx(Portal, {
|
|
83
|
+
zIndex: layers.modal()
|
|
84
|
+
}, jsx(FadeIn, null, function (fadeInProps) {
|
|
85
|
+
return jsx("div", _extends({}, fadeInProps, {
|
|
86
|
+
css: fillScreenStyles,
|
|
87
|
+
"aria-hidden": !isForeground
|
|
88
|
+
}), jsx(FocusLock, {
|
|
89
|
+
autoFocus: autoFocusLock,
|
|
90
|
+
disabled: !isForeground,
|
|
91
|
+
returnFocus: true
|
|
92
|
+
}, jsx(ScrollLock, null), shouldScrollInViewport ? jsx(TouchScrollable, null, modalDialogWithBlanket) : modalDialogWithBlanket));
|
|
93
|
+
}));
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export default ModalWrapper;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useModal: () => import("./internal/context").ModalAttributes;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default } from './modal-wrapper';
|
|
2
|
+
export { default as ModalTransition } from './modal-transition';
|
|
3
|
+
export type { KeyboardOrMouseEvent, Appearance, ModalAttributes, ModalDialogProps, ModalHeaderProps, ModalTitleProps, ModalBodyProps, ModalFooterProps, OnCloseHandler, OnCloseCompleteHandler, OnOpenCompleteHandler, OnStackChangeHandler, } from './types';
|
|
4
|
+
export { default as ModalHeader } from './modal-header';
|
|
5
|
+
export { default as ModalTitle } from './modal-title';
|
|
6
|
+
export { default as ModalBody } from './modal-body';
|
|
7
|
+
export { default as ModalFooter } from './modal-footer';
|
|
8
|
+
export { useModal } from './hooks';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
interface PositionerProps {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
stackIndex: number;
|
|
6
|
+
shouldScrollInViewport: boolean;
|
|
7
|
+
testId?: string;
|
|
8
|
+
}
|
|
9
|
+
declare const Positioner: (props: PositionerProps) => JSX.Element;
|
|
10
|
+
export default Positioner;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
interface ScrollContainerProps {
|
|
4
|
+
/**
|
|
5
|
+
* Children of the body within modal dialog.
|
|
6
|
+
*/
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* A `testId` prop is provided for specified elements,
|
|
10
|
+
* which is a unique string that appears as a data attribute `data-testid` in the rendered code,
|
|
11
|
+
* serving as a hook for automated tests.
|
|
12
|
+
*/
|
|
13
|
+
testId?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A container that shows top and bottom keylines when the
|
|
17
|
+
* content overflows into the scrollable element.
|
|
18
|
+
*/
|
|
19
|
+
declare const ScrollContainer: React.ForwardRefExoticComponent<ScrollContainerProps & React.RefAttributes<HTMLElement | null>>;
|
|
20
|
+
export default ScrollContainer;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Appearance } from '../types';
|
|
2
|
+
export declare type WidthNames = 'small' | 'medium' | 'large' | 'x-large';
|
|
3
|
+
interface Width {
|
|
4
|
+
values: string[];
|
|
5
|
+
widths: {
|
|
6
|
+
[index in WidthNames]: number;
|
|
7
|
+
};
|
|
8
|
+
defaultValue: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const width: Width;
|
|
11
|
+
export declare const gutter = 60;
|
|
12
|
+
export declare const borderRadius: number;
|
|
13
|
+
export declare const verticalOffset: number;
|
|
14
|
+
export declare const padding: number;
|
|
15
|
+
export declare const footerItemGap: number;
|
|
16
|
+
export declare const titleIconMargin: number;
|
|
17
|
+
export declare const keylineHeight = 2;
|
|
18
|
+
export declare const keylineColor = "#EBECF0";
|
|
19
|
+
export declare const textColor: string;
|
|
20
|
+
export declare const focusOutlineColor = "#172B4D";
|
|
21
|
+
declare type IconColor = {
|
|
22
|
+
[key in Appearance]: string;
|
|
23
|
+
};
|
|
24
|
+
export declare const iconColor: IconColor;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ModalDialogProps, OnCloseHandler } from '../types';
|
|
3
|
+
export declare type ModalAttributes = {
|
|
4
|
+
/**
|
|
5
|
+
* Test id passed to the modal dialog.
|
|
6
|
+
*/
|
|
7
|
+
testId?: ModalDialogProps['testId'];
|
|
8
|
+
/**
|
|
9
|
+
* Id referenced by the modal dialog's `aria-labelledby` attribute.
|
|
10
|
+
* This id should be assigned to the modal title element.
|
|
11
|
+
*/
|
|
12
|
+
titleId: string;
|
|
13
|
+
/**
|
|
14
|
+
* Callback function called when the modal dialog is requesting to be closed,
|
|
15
|
+
* wrapped in modal dialog's analytic event context.
|
|
16
|
+
*/
|
|
17
|
+
onClose?: OnCloseHandler;
|
|
18
|
+
};
|
|
19
|
+
export declare const ModalContext: import("react").Context<ModalAttributes | null>;
|
|
20
|
+
export declare const ScrollContext: import("react").Context<boolean | null>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface ModalStackOpts {
|
|
2
|
+
/**
|
|
3
|
+
* Fired when the modal dialog stack has changed.
|
|
4
|
+
*/
|
|
5
|
+
onStackChange: (newStackIndex: number) => void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Returns the position of the calling modal dialog in the modal dialog stack.
|
|
9
|
+
* Stack index of `0` is the highest position in the stack,
|
|
10
|
+
* with every higher number being behind in the stack.
|
|
11
|
+
*/
|
|
12
|
+
export default function useModalStack({ onStackChange, }: ModalStackOpts): number;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import type { Transition } from '@atlaskit/motion/types';
|
|
3
|
+
import { ModalDialogProps } from '../../types';
|
|
4
|
+
export default function useOnMotionFinish({ onOpenComplete, onCloseComplete, }: Pick<ModalDialogProps, 'onOpenComplete' | 'onCloseComplete'>): [RefObject<HTMLElement>, (state: Transition) => void];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prevents programatic scrolling of the viewport with `scrollIntoView`.
|
|
3
|
+
* Should be used in conjunction with a scroll lock to prevent a user from scrolling.
|
|
4
|
+
*
|
|
5
|
+
* @returns scroll top offset of the viewport
|
|
6
|
+
*/
|
|
7
|
+
export default function usePreventProgrammaticScroll(): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useScroll(): boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export interface ModalBodyProps {
|
|
4
|
+
/**
|
|
5
|
+
* Children of modal dialog footer.
|
|
6
|
+
*/
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* A `testId` prop is provided for specified elements,
|
|
10
|
+
* which is a unique string that appears as a data attribute `data-testid` in the rendered code,
|
|
11
|
+
* serving as a hook for automated tests.
|
|
12
|
+
*/
|
|
13
|
+
testId?: string;
|
|
14
|
+
}
|
|
15
|
+
declare const ModalBody: (props: ModalBodyProps) => JSX.Element;
|
|
16
|
+
export default ModalBody;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
export interface ModalFooterProps {
|
|
4
|
+
/**
|
|
5
|
+
* Children of modal dialog footer.
|
|
6
|
+
*/
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* A `testId` prop is provided for specified elements,
|
|
10
|
+
* which is a unique string that appears as a data attribute `data-testid` in the rendered code,
|
|
11
|
+
* serving as a hook for automated tests.
|
|
12
|
+
*/
|
|
13
|
+
testId?: string;
|
|
14
|
+
}
|
|
15
|
+
declare const ModalFooter: (props: ModalFooterProps) => JSX.Element;
|
|
16
|
+
export default ModalFooter;
|