@jobber/components 6.41.0 → 6.42.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/dist/Combobox/components/ComboboxContent/index.cjs +1 -0
- package/dist/Combobox/components/ComboboxContent/index.mjs +1 -0
- package/dist/Combobox/hooks/useComboboxAccessibility.d.ts +2 -0
- package/dist/Combobox/index.cjs +1 -0
- package/dist/Combobox/index.mjs +1 -0
- package/dist/ComboboxContent-cjs.js +33 -3726
- package/dist/ComboboxContent-es.js +28 -3703
- package/dist/ConfirmationModal/index.cjs +14 -2
- package/dist/ConfirmationModal/index.mjs +14 -2
- package/dist/ConfirmationModal-cjs.js +2 -2
- package/dist/ConfirmationModal-es.js +1 -1
- package/dist/DataList/components/DataListFilters/components/DataListSort/index.cjs +1 -0
- package/dist/DataList/components/DataListFilters/components/DataListSort/index.mjs +1 -0
- package/dist/DataList/components/DataListFilters/index.cjs +1 -0
- package/dist/DataList/components/DataListFilters/index.mjs +1 -0
- package/dist/DataList/index.cjs +1 -0
- package/dist/DataList/index.mjs +1 -0
- package/dist/FormatFile/index.cjs +14 -2
- package/dist/FormatFile/index.mjs +14 -2
- package/dist/Gallery/index.cjs +4 -1
- package/dist/Gallery/index.mjs +4 -1
- package/dist/Heading/Heading.d.ts +1 -1
- package/dist/Heading/index.d.ts +1 -0
- package/dist/Modal/Modal.d.ts +2 -21
- package/dist/Modal/Modal.rebuilt.d.ts +10 -0
- package/dist/Modal/Modal.types.d.ts +118 -0
- package/dist/Modal/ModalContext.rebuilt.d.ts +15 -0
- package/dist/Modal/index.cjs +213 -12
- package/dist/Modal/index.d.ts +15 -1
- package/dist/Modal/index.mjs +214 -11
- package/dist/Modal/useModal.d.ts +35 -0
- package/dist/Modal/useModalStyles.d.ts +10 -0
- package/dist/floating-ui.react-cjs.js +5610 -0
- package/dist/floating-ui.react-es.js +5574 -0
- package/dist/index.cjs +5 -2
- package/dist/index.mjs +2 -1
- package/dist/styles.css +156 -0
- package/dist/utils/meta/meta.json +6 -1
- package/package.json +2 -2
- package/dist/Modal-cjs.js +0 -63
- package/dist/Modal-es.js +0 -61
package/dist/Modal/index.cjs
CHANGED
|
@@ -1,22 +1,223 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('react');
|
|
5
|
-
require('
|
|
6
|
-
require('
|
|
7
|
-
require('
|
|
8
|
-
require('../
|
|
9
|
-
require('../
|
|
10
|
-
require('../
|
|
11
|
-
require('../
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var ReactDOM = require('react-dom');
|
|
5
|
+
var classnames = require('classnames');
|
|
6
|
+
var framerMotion = require('framer-motion');
|
|
7
|
+
var useRefocusOnActivator = require('../useRefocusOnActivator-cjs.js');
|
|
8
|
+
var useOnKeyDown = require('../useOnKeyDown-cjs.js');
|
|
9
|
+
var useFocusTrap = require('../useFocusTrap-cjs.js');
|
|
10
|
+
var Heading = require('../Heading-cjs.js');
|
|
11
|
+
var Button = require('../Button-cjs.js');
|
|
12
|
+
var ButtonDismiss = require('../ButtonDismiss-cjs.js');
|
|
13
|
+
var AtlantisPortalContent = require('../AtlantisPortalContent-cjs.js');
|
|
14
|
+
var noop = require('../noop-cjs.js');
|
|
15
|
+
var floatingUi_react = require('../floating-ui.react-cjs.js');
|
|
12
16
|
require('../Typography-cjs.js');
|
|
13
|
-
require('../Button-cjs.js');
|
|
14
17
|
require('react-router-dom');
|
|
15
18
|
require('../tslib.es6-cjs.js');
|
|
16
19
|
require('../Icon-cjs.js');
|
|
17
20
|
require('@jobber/design');
|
|
18
|
-
require('../
|
|
21
|
+
require('../AtlantisThemeContext-cjs.js');
|
|
22
|
+
require('../_commonjsHelpers-cjs.js');
|
|
23
|
+
require('../identity-cjs.js');
|
|
24
|
+
require('../isTypedArray-cjs.js');
|
|
25
|
+
require('../isObjectLike-cjs.js');
|
|
26
|
+
require('../_baseAssignValue-cjs.js');
|
|
27
|
+
require('../_baseFor-cjs.js');
|
|
28
|
+
require('../keysIn-cjs.js');
|
|
29
|
+
require('../_isIterateeCall-cjs.js');
|
|
30
|
+
require('../_setToString-cjs.js');
|
|
19
31
|
|
|
32
|
+
var styles$1 = {"container":"y3M-9xoEnk0-","overlay":"zkyJp1mib-U-","modal":"gMPgiggaud8-","header":"_5sBzUnyOqD0-","closeButton":"_4gw63G7IYG0-","actionBar":"cwVJrrJkNDg-","leftAction":"MkD4pNUKeAA-","rightAction":"C-yC8JKpQLg-","spinning":"_7hYqr6OrfHs-"};
|
|
20
33
|
|
|
34
|
+
var sizes = {"small":"BSZvIAUzFEU-","large":"-ydIALYVvGg-","spinning":"_10FfgKITqY0-"};
|
|
21
35
|
|
|
22
|
-
|
|
36
|
+
const ModalLegacy = ({ open = false, title, size, dismissible = true, children, primaryAction, secondaryAction, tertiaryAction, onRequestClose, }) => {
|
|
37
|
+
const modalClassName = classnames(styles$1.modal, size && sizes[size]);
|
|
38
|
+
useRefocusOnActivator.useRefocusOnActivator_2(open);
|
|
39
|
+
const modalRef = useFocusTrap.useFocusTrap_2(open);
|
|
40
|
+
useOnKeyDown.useOnKeyDown_2(handleRequestClose, "Escape");
|
|
41
|
+
const template = (React.createElement(AtlantisPortalContent.AtlantisPortalContent, null,
|
|
42
|
+
React.createElement(framerMotion.AnimatePresence, null, open && (React.createElement("div", { ref: modalRef, role: "dialog", className: styles$1.container, tabIndex: 0 },
|
|
43
|
+
React.createElement(framerMotion.motion.div, { key: styles$1.overlay, className: styles$1.overlay, onClick: onRequestClose, initial: { opacity: 0 }, animate: { opacity: 0.8 }, exit: { opacity: 0 }, transition: { duration: 0.2 } }),
|
|
44
|
+
React.createElement(framerMotion.motion.div, { key: styles$1.modal, className: modalClassName, initial: { scale: 0.9, opacity: 0 }, animate: { scale: 1, opacity: 1 }, exit: { scale: 0.9, opacity: 0 }, transition: {
|
|
45
|
+
duration: 0.2,
|
|
46
|
+
ease: "easeInOut",
|
|
47
|
+
} },
|
|
48
|
+
title != undefined && (React.createElement(Header, { title: title, dismissible: dismissible, onRequestClose: onRequestClose })),
|
|
49
|
+
children,
|
|
50
|
+
React.createElement(Actions, { primary: primaryAction, secondary: secondaryAction, tertiary: tertiaryAction })))))));
|
|
51
|
+
return (globalThis === null || globalThis === void 0 ? void 0 : globalThis.document)
|
|
52
|
+
? ReactDOM.createPortal(template, document.body)
|
|
53
|
+
: template;
|
|
54
|
+
function handleRequestClose() {
|
|
55
|
+
if (open && onRequestClose) {
|
|
56
|
+
onRequestClose();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
function Header({ title, dismissible, onRequestClose }) {
|
|
61
|
+
return (React.createElement("div", { className: styles$1.header, "data-testid": "modal-header" },
|
|
62
|
+
React.createElement(Heading.Heading, { level: 2 }, title),
|
|
63
|
+
dismissible && (React.createElement("div", { className: styles$1.closeButton },
|
|
64
|
+
React.createElement(ButtonDismiss.ButtonDismiss, { onClick: onRequestClose, ariaLabel: "Close modal" })))));
|
|
65
|
+
}
|
|
66
|
+
function Actions({ primary, secondary, tertiary }) {
|
|
67
|
+
const shouldShow = primary != undefined || secondary != undefined || tertiary != undefined;
|
|
68
|
+
if (secondary != undefined) {
|
|
69
|
+
secondary = Object.assign({ type: "primary", variation: "subtle" }, secondary);
|
|
70
|
+
}
|
|
71
|
+
if (tertiary != undefined) {
|
|
72
|
+
tertiary = Object.assign({ type: "secondary", variation: "destructive" }, tertiary);
|
|
73
|
+
}
|
|
74
|
+
return (React.createElement(React.Fragment, null, shouldShow && (React.createElement("div", { className: styles$1.actionBar },
|
|
75
|
+
React.createElement("div", { className: styles$1.rightAction },
|
|
76
|
+
primary && React.createElement(Button.Button, Object.assign({}, primary)),
|
|
77
|
+
secondary && React.createElement(Button.Button, Object.assign({}, secondary))),
|
|
78
|
+
tertiary && (React.createElement("div", { className: styles$1.leftAction },
|
|
79
|
+
React.createElement(Button.Button, Object.assign({}, tertiary))))))));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function useModal({ open, activatorRef: refProp, onRequestClose, }) {
|
|
83
|
+
const nodeId = floatingUi_react.useFloatingNodeId();
|
|
84
|
+
const defaultActivatorRef = React.useRef(null);
|
|
85
|
+
const activatorRef = refProp !== null && refProp !== void 0 ? refProp : defaultActivatorRef;
|
|
86
|
+
const { refs: floatingRefs, context: floatingContext } = floatingUi_react.useFloating({
|
|
87
|
+
elements: { reference: activatorRef === null || activatorRef === void 0 ? void 0 : activatorRef.current },
|
|
88
|
+
nodeId,
|
|
89
|
+
onOpenChange: (newOpen) => {
|
|
90
|
+
if (!newOpen) {
|
|
91
|
+
onRequestClose === null || onRequestClose === void 0 ? void 0 : onRequestClose();
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
open: open,
|
|
95
|
+
});
|
|
96
|
+
const click = floatingUi_react.useClick(floatingContext);
|
|
97
|
+
const dismiss = floatingUi_react.useDismiss(floatingContext, {
|
|
98
|
+
outsidePressEvent: "click",
|
|
99
|
+
escapeKey: true,
|
|
100
|
+
bubbles: true,
|
|
101
|
+
});
|
|
102
|
+
const role = floatingUi_react.useRole(floatingContext);
|
|
103
|
+
floatingUi_react.useInteractions([click, dismiss, role]);
|
|
104
|
+
const parentId = floatingUi_react.useFloatingParentNodeId();
|
|
105
|
+
return {
|
|
106
|
+
floatingRefs,
|
|
107
|
+
floatingContext,
|
|
108
|
+
nodeId,
|
|
109
|
+
activatorRef,
|
|
110
|
+
parentId,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const ModalContext = React.createContext({
|
|
115
|
+
open: false,
|
|
116
|
+
onRequestClose: noop.noop,
|
|
117
|
+
activatorRef: { current: null },
|
|
118
|
+
floatingRefs: null,
|
|
119
|
+
floatingContext: {},
|
|
120
|
+
size: undefined,
|
|
121
|
+
floatingNodeId: undefined,
|
|
122
|
+
dismissible: true,
|
|
123
|
+
});
|
|
124
|
+
function ModalProvider({ children, open = false, size, onRequestClose = noop.noop, activatorRef: refProp, dismissible = true, modalLabelledBy = "ATL-Modal-Header", }) {
|
|
125
|
+
const { floatingRefs, floatingContext, nodeId, activatorRef, parentId } = useModal({
|
|
126
|
+
open,
|
|
127
|
+
activatorRef: refProp,
|
|
128
|
+
onRequestClose,
|
|
129
|
+
});
|
|
130
|
+
const content = (React.createElement(ModalContext.Provider, { value: {
|
|
131
|
+
onRequestClose,
|
|
132
|
+
activatorRef,
|
|
133
|
+
floatingRefs,
|
|
134
|
+
floatingContext,
|
|
135
|
+
size,
|
|
136
|
+
open,
|
|
137
|
+
floatingNodeId: nodeId,
|
|
138
|
+
dismissible,
|
|
139
|
+
modalLabelledBy,
|
|
140
|
+
} }, children));
|
|
141
|
+
if (parentId) {
|
|
142
|
+
return content;
|
|
143
|
+
}
|
|
144
|
+
return React.createElement(floatingUi_react.FloatingTree, null, content);
|
|
145
|
+
}
|
|
146
|
+
function useModalContext() {
|
|
147
|
+
return React.useContext(ModalContext);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
var styles = {"overlay":"cRhQeXmZobs-","modal":"OiqCKNmbHZ0-","header":"GDWGHwmjgAc-","closeButton":"KJlGo4z-E6Q-","actionBar":"ZGrhWCAymCw-","leftAction":"hOiEWds2Vq8-","rightAction":"K31NzxPZP9s-","spinning":"SKeimJFlB-g-"};
|
|
151
|
+
|
|
152
|
+
function useModalStyles(size) {
|
|
153
|
+
return {
|
|
154
|
+
modal: classnames(styles.modal, size && sizes[size]),
|
|
155
|
+
overlay: styles.overlay,
|
|
156
|
+
header: styles.header,
|
|
157
|
+
dismissButton: styles.closeButton,
|
|
158
|
+
actionBar: styles.actionBar,
|
|
159
|
+
leftAction: styles.leftAction,
|
|
160
|
+
rightAction: styles.rightAction,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const AnimatedOverlay = framerMotion.motion(floatingUi_react.FloatingOverlay);
|
|
165
|
+
function ModalHeader({ title, children }) {
|
|
166
|
+
const { header, dismissButton } = useModalStyles();
|
|
167
|
+
const { dismissible, onRequestClose, modalLabelledBy } = useModalContext();
|
|
168
|
+
if (children) {
|
|
169
|
+
return React.createElement(React.Fragment, null, children);
|
|
170
|
+
}
|
|
171
|
+
return (React.createElement("div", { className: header, "data-testid": "ATL-Modal-Header", id: modalLabelledBy },
|
|
172
|
+
React.createElement(Heading.Heading, { level: 2 }, title),
|
|
173
|
+
dismissible && (React.createElement("div", { className: dismissButton },
|
|
174
|
+
React.createElement(ButtonDismiss.ButtonDismiss, { onClick: onRequestClose, ariaLabel: "Close modal" })))));
|
|
175
|
+
}
|
|
176
|
+
function ModalActions({ primary, secondary, tertiary, }) {
|
|
177
|
+
const { actionBar, rightAction, leftAction } = useModalStyles();
|
|
178
|
+
const shouldShow = primary != undefined || secondary != undefined || tertiary != undefined;
|
|
179
|
+
return (React.createElement(React.Fragment, null, shouldShow && (React.createElement("div", { className: actionBar, "data-testid": "ATL-Modal-Actions" },
|
|
180
|
+
React.createElement("div", { className: rightAction },
|
|
181
|
+
primary && React.createElement(Button.Button, Object.assign({}, primary)),
|
|
182
|
+
secondary && (React.createElement(Button.Button, Object.assign({}, secondary, { type: "primary", variation: "subtle" })))),
|
|
183
|
+
tertiary && (React.createElement("div", { className: leftAction },
|
|
184
|
+
React.createElement(Button.Button, Object.assign({}, tertiary, { type: "secondary", variation: "destructive" }))))))));
|
|
185
|
+
}
|
|
186
|
+
function ModalActivator({ children }) {
|
|
187
|
+
const { activatorRef } = useModalContext();
|
|
188
|
+
return (React.createElement("span", { ref: activatorRef, style: { display: "contents" } }, children));
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Background overlay for the modal. Used in the ModalContent.
|
|
192
|
+
*/
|
|
193
|
+
function ModalOverlay({ children }) {
|
|
194
|
+
const { size } = useModalContext();
|
|
195
|
+
const { overlay } = useModalStyles(size);
|
|
196
|
+
return (React.createElement(AnimatedOverlay, { className: overlay, initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, transition: { duration: 0.2 }, "data-testid": "ATL-Modal-Overlay" }, children));
|
|
197
|
+
}
|
|
198
|
+
function ModalContent({ children }) {
|
|
199
|
+
const { open, floatingContext, activatorRef, floatingRefs, size, floatingNodeId, modalLabelledBy, } = useModalContext();
|
|
200
|
+
const { modal } = useModalStyles(size);
|
|
201
|
+
return (React.createElement(framerMotion.AnimatePresence, null, open && (React.createElement(floatingUi_react.FloatingNode, { id: floatingNodeId },
|
|
202
|
+
React.createElement(floatingUi_react.FloatingPortal, null,
|
|
203
|
+
React.createElement(AtlantisPortalContent.AtlantisPortalContent, null,
|
|
204
|
+
React.createElement(ModalOverlay, null,
|
|
205
|
+
React.createElement(floatingUi_react.FloatingFocusManager, { context: floatingContext, returnFocus: (activatorRef === null || activatorRef === void 0 ? void 0 : activatorRef.current) ? activatorRef : true, initialFocus: floatingRefs === null || floatingRefs === void 0 ? void 0 : floatingRefs.floating },
|
|
206
|
+
React.createElement(framerMotion.motion.div, { "data-floating-ui-focusable": true, "aria-labelledby": modalLabelledBy, className: modal, initial: { scale: 0.9, opacity: 0 }, animate: { scale: 1, opacity: 0.8 }, exit: { scale: 0.9, opacity: 0 }, transition: {
|
|
207
|
+
duration: 0.2,
|
|
208
|
+
ease: "easeInOut",
|
|
209
|
+
}, ref: floatingRefs === null || floatingRefs === void 0 ? void 0 : floatingRefs.setFloating, role: "dialog", tabIndex: -1 }, children)))))))));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function Modal(props) {
|
|
213
|
+
return React.createElement(ModalLegacy, Object.assign({}, props));
|
|
214
|
+
}
|
|
215
|
+
Modal.Header = ModalHeader;
|
|
216
|
+
Modal.Actions = ModalActions;
|
|
217
|
+
Modal.Activator = ModalActivator;
|
|
218
|
+
Modal.Provider = ModalProvider;
|
|
219
|
+
Modal.Content = ModalContent;
|
|
220
|
+
|
|
221
|
+
exports.Modal = Modal;
|
|
222
|
+
exports.useModalContext = useModalContext;
|
|
223
|
+
exports.useModalStyles = useModalStyles;
|
package/dist/Modal/index.d.ts
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import { ModalProvider } from "./ModalContext.rebuilt";
|
|
2
|
+
import { ModalActions, ModalActivator, ModalContent, ModalHeader } from "./Modal.rebuilt";
|
|
3
|
+
import { ModalLegacyProps } from "./Modal.types";
|
|
4
|
+
export type { ModalLegacyProps as ModalProps } from "./Modal.types";
|
|
5
|
+
declare function Modal(props: ModalLegacyProps): JSX.Element;
|
|
6
|
+
declare namespace Modal {
|
|
7
|
+
var Header: typeof ModalHeader;
|
|
8
|
+
var Actions: typeof ModalActions;
|
|
9
|
+
var Activator: typeof ModalActivator;
|
|
10
|
+
var Provider: typeof ModalProvider;
|
|
11
|
+
var Content: typeof ModalContent;
|
|
12
|
+
}
|
|
13
|
+
export { useModalContext } from "./ModalContext.rebuilt";
|
|
14
|
+
export { useModalStyles } from "./useModalStyles";
|
|
15
|
+
export { Modal };
|
package/dist/Modal/index.mjs
CHANGED
|
@@ -1,16 +1,219 @@
|
|
|
1
|
-
|
|
2
|
-
import 'react';
|
|
3
|
-
import '
|
|
4
|
-
import '
|
|
5
|
-
import '
|
|
6
|
-
import '../
|
|
7
|
-
import '../
|
|
8
|
-
import '../
|
|
9
|
-
import '../
|
|
1
|
+
import React__default, { useRef, createContext, useContext } from 'react';
|
|
2
|
+
import ReactDOM__default from 'react-dom';
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
import { AnimatePresence, motion } from 'framer-motion';
|
|
5
|
+
import { u as useRefocusOnActivator_2 } from '../useRefocusOnActivator-es.js';
|
|
6
|
+
import { u as useOnKeyDown_2 } from '../useOnKeyDown-es.js';
|
|
7
|
+
import { u as useFocusTrap_2 } from '../useFocusTrap-es.js';
|
|
8
|
+
import { H as Heading } from '../Heading-es.js';
|
|
9
|
+
import { B as Button } from '../Button-es.js';
|
|
10
|
+
import { B as ButtonDismiss } from '../ButtonDismiss-es.js';
|
|
11
|
+
import { A as AtlantisPortalContent } from '../AtlantisPortalContent-es.js';
|
|
12
|
+
import { n as noop } from '../noop-es.js';
|
|
13
|
+
import { a as useFloatingNodeId, b as useFloating, i as useClick, e as useDismiss, j as useRole, f as useInteractions, u as useFloatingParentNodeId, h as FloatingTree, k as FloatingOverlay, F as FloatingNode, g as FloatingPortal, l as FloatingFocusManager } from '../floating-ui.react-es.js';
|
|
10
14
|
import '../Typography-es.js';
|
|
11
|
-
import '../Button-es.js';
|
|
12
15
|
import 'react-router-dom';
|
|
13
16
|
import '../tslib.es6-es.js';
|
|
14
17
|
import '../Icon-es.js';
|
|
15
18
|
import '@jobber/design';
|
|
16
|
-
import '../
|
|
19
|
+
import '../AtlantisThemeContext-es.js';
|
|
20
|
+
import '../_commonjsHelpers-es.js';
|
|
21
|
+
import '../identity-es.js';
|
|
22
|
+
import '../isTypedArray-es.js';
|
|
23
|
+
import '../isObjectLike-es.js';
|
|
24
|
+
import '../_baseAssignValue-es.js';
|
|
25
|
+
import '../_baseFor-es.js';
|
|
26
|
+
import '../keysIn-es.js';
|
|
27
|
+
import '../_isIterateeCall-es.js';
|
|
28
|
+
import '../_setToString-es.js';
|
|
29
|
+
|
|
30
|
+
var styles$1 = {"container":"y3M-9xoEnk0-","overlay":"zkyJp1mib-U-","modal":"gMPgiggaud8-","header":"_5sBzUnyOqD0-","closeButton":"_4gw63G7IYG0-","actionBar":"cwVJrrJkNDg-","leftAction":"MkD4pNUKeAA-","rightAction":"C-yC8JKpQLg-","spinning":"_7hYqr6OrfHs-"};
|
|
31
|
+
|
|
32
|
+
var sizes = {"small":"BSZvIAUzFEU-","large":"-ydIALYVvGg-","spinning":"_10FfgKITqY0-"};
|
|
33
|
+
|
|
34
|
+
const ModalLegacy = ({ open = false, title, size, dismissible = true, children, primaryAction, secondaryAction, tertiaryAction, onRequestClose, }) => {
|
|
35
|
+
const modalClassName = classnames(styles$1.modal, size && sizes[size]);
|
|
36
|
+
useRefocusOnActivator_2(open);
|
|
37
|
+
const modalRef = useFocusTrap_2(open);
|
|
38
|
+
useOnKeyDown_2(handleRequestClose, "Escape");
|
|
39
|
+
const template = (React__default.createElement(AtlantisPortalContent, null,
|
|
40
|
+
React__default.createElement(AnimatePresence, null, open && (React__default.createElement("div", { ref: modalRef, role: "dialog", className: styles$1.container, tabIndex: 0 },
|
|
41
|
+
React__default.createElement(motion.div, { key: styles$1.overlay, className: styles$1.overlay, onClick: onRequestClose, initial: { opacity: 0 }, animate: { opacity: 0.8 }, exit: { opacity: 0 }, transition: { duration: 0.2 } }),
|
|
42
|
+
React__default.createElement(motion.div, { key: styles$1.modal, className: modalClassName, initial: { scale: 0.9, opacity: 0 }, animate: { scale: 1, opacity: 1 }, exit: { scale: 0.9, opacity: 0 }, transition: {
|
|
43
|
+
duration: 0.2,
|
|
44
|
+
ease: "easeInOut",
|
|
45
|
+
} },
|
|
46
|
+
title != undefined && (React__default.createElement(Header, { title: title, dismissible: dismissible, onRequestClose: onRequestClose })),
|
|
47
|
+
children,
|
|
48
|
+
React__default.createElement(Actions, { primary: primaryAction, secondary: secondaryAction, tertiary: tertiaryAction })))))));
|
|
49
|
+
return (globalThis === null || globalThis === void 0 ? void 0 : globalThis.document)
|
|
50
|
+
? ReactDOM__default.createPortal(template, document.body)
|
|
51
|
+
: template;
|
|
52
|
+
function handleRequestClose() {
|
|
53
|
+
if (open && onRequestClose) {
|
|
54
|
+
onRequestClose();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
function Header({ title, dismissible, onRequestClose }) {
|
|
59
|
+
return (React__default.createElement("div", { className: styles$1.header, "data-testid": "modal-header" },
|
|
60
|
+
React__default.createElement(Heading, { level: 2 }, title),
|
|
61
|
+
dismissible && (React__default.createElement("div", { className: styles$1.closeButton },
|
|
62
|
+
React__default.createElement(ButtonDismiss, { onClick: onRequestClose, ariaLabel: "Close modal" })))));
|
|
63
|
+
}
|
|
64
|
+
function Actions({ primary, secondary, tertiary }) {
|
|
65
|
+
const shouldShow = primary != undefined || secondary != undefined || tertiary != undefined;
|
|
66
|
+
if (secondary != undefined) {
|
|
67
|
+
secondary = Object.assign({ type: "primary", variation: "subtle" }, secondary);
|
|
68
|
+
}
|
|
69
|
+
if (tertiary != undefined) {
|
|
70
|
+
tertiary = Object.assign({ type: "secondary", variation: "destructive" }, tertiary);
|
|
71
|
+
}
|
|
72
|
+
return (React__default.createElement(React__default.Fragment, null, shouldShow && (React__default.createElement("div", { className: styles$1.actionBar },
|
|
73
|
+
React__default.createElement("div", { className: styles$1.rightAction },
|
|
74
|
+
primary && React__default.createElement(Button, Object.assign({}, primary)),
|
|
75
|
+
secondary && React__default.createElement(Button, Object.assign({}, secondary))),
|
|
76
|
+
tertiary && (React__default.createElement("div", { className: styles$1.leftAction },
|
|
77
|
+
React__default.createElement(Button, Object.assign({}, tertiary))))))));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function useModal({ open, activatorRef: refProp, onRequestClose, }) {
|
|
81
|
+
const nodeId = useFloatingNodeId();
|
|
82
|
+
const defaultActivatorRef = useRef(null);
|
|
83
|
+
const activatorRef = refProp !== null && refProp !== void 0 ? refProp : defaultActivatorRef;
|
|
84
|
+
const { refs: floatingRefs, context: floatingContext } = useFloating({
|
|
85
|
+
elements: { reference: activatorRef === null || activatorRef === void 0 ? void 0 : activatorRef.current },
|
|
86
|
+
nodeId,
|
|
87
|
+
onOpenChange: (newOpen) => {
|
|
88
|
+
if (!newOpen) {
|
|
89
|
+
onRequestClose === null || onRequestClose === void 0 ? void 0 : onRequestClose();
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
open: open,
|
|
93
|
+
});
|
|
94
|
+
const click = useClick(floatingContext);
|
|
95
|
+
const dismiss = useDismiss(floatingContext, {
|
|
96
|
+
outsidePressEvent: "click",
|
|
97
|
+
escapeKey: true,
|
|
98
|
+
bubbles: true,
|
|
99
|
+
});
|
|
100
|
+
const role = useRole(floatingContext);
|
|
101
|
+
useInteractions([click, dismiss, role]);
|
|
102
|
+
const parentId = useFloatingParentNodeId();
|
|
103
|
+
return {
|
|
104
|
+
floatingRefs,
|
|
105
|
+
floatingContext,
|
|
106
|
+
nodeId,
|
|
107
|
+
activatorRef,
|
|
108
|
+
parentId,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const ModalContext = createContext({
|
|
113
|
+
open: false,
|
|
114
|
+
onRequestClose: noop,
|
|
115
|
+
activatorRef: { current: null },
|
|
116
|
+
floatingRefs: null,
|
|
117
|
+
floatingContext: {},
|
|
118
|
+
size: undefined,
|
|
119
|
+
floatingNodeId: undefined,
|
|
120
|
+
dismissible: true,
|
|
121
|
+
});
|
|
122
|
+
function ModalProvider({ children, open = false, size, onRequestClose = noop, activatorRef: refProp, dismissible = true, modalLabelledBy = "ATL-Modal-Header", }) {
|
|
123
|
+
const { floatingRefs, floatingContext, nodeId, activatorRef, parentId } = useModal({
|
|
124
|
+
open,
|
|
125
|
+
activatorRef: refProp,
|
|
126
|
+
onRequestClose,
|
|
127
|
+
});
|
|
128
|
+
const content = (React__default.createElement(ModalContext.Provider, { value: {
|
|
129
|
+
onRequestClose,
|
|
130
|
+
activatorRef,
|
|
131
|
+
floatingRefs,
|
|
132
|
+
floatingContext,
|
|
133
|
+
size,
|
|
134
|
+
open,
|
|
135
|
+
floatingNodeId: nodeId,
|
|
136
|
+
dismissible,
|
|
137
|
+
modalLabelledBy,
|
|
138
|
+
} }, children));
|
|
139
|
+
if (parentId) {
|
|
140
|
+
return content;
|
|
141
|
+
}
|
|
142
|
+
return React__default.createElement(FloatingTree, null, content);
|
|
143
|
+
}
|
|
144
|
+
function useModalContext() {
|
|
145
|
+
return useContext(ModalContext);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
var styles = {"overlay":"cRhQeXmZobs-","modal":"OiqCKNmbHZ0-","header":"GDWGHwmjgAc-","closeButton":"KJlGo4z-E6Q-","actionBar":"ZGrhWCAymCw-","leftAction":"hOiEWds2Vq8-","rightAction":"K31NzxPZP9s-","spinning":"SKeimJFlB-g-"};
|
|
149
|
+
|
|
150
|
+
function useModalStyles(size) {
|
|
151
|
+
return {
|
|
152
|
+
modal: classnames(styles.modal, size && sizes[size]),
|
|
153
|
+
overlay: styles.overlay,
|
|
154
|
+
header: styles.header,
|
|
155
|
+
dismissButton: styles.closeButton,
|
|
156
|
+
actionBar: styles.actionBar,
|
|
157
|
+
leftAction: styles.leftAction,
|
|
158
|
+
rightAction: styles.rightAction,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const AnimatedOverlay = motion(FloatingOverlay);
|
|
163
|
+
function ModalHeader({ title, children }) {
|
|
164
|
+
const { header, dismissButton } = useModalStyles();
|
|
165
|
+
const { dismissible, onRequestClose, modalLabelledBy } = useModalContext();
|
|
166
|
+
if (children) {
|
|
167
|
+
return React__default.createElement(React__default.Fragment, null, children);
|
|
168
|
+
}
|
|
169
|
+
return (React__default.createElement("div", { className: header, "data-testid": "ATL-Modal-Header", id: modalLabelledBy },
|
|
170
|
+
React__default.createElement(Heading, { level: 2 }, title),
|
|
171
|
+
dismissible && (React__default.createElement("div", { className: dismissButton },
|
|
172
|
+
React__default.createElement(ButtonDismiss, { onClick: onRequestClose, ariaLabel: "Close modal" })))));
|
|
173
|
+
}
|
|
174
|
+
function ModalActions({ primary, secondary, tertiary, }) {
|
|
175
|
+
const { actionBar, rightAction, leftAction } = useModalStyles();
|
|
176
|
+
const shouldShow = primary != undefined || secondary != undefined || tertiary != undefined;
|
|
177
|
+
return (React__default.createElement(React__default.Fragment, null, shouldShow && (React__default.createElement("div", { className: actionBar, "data-testid": "ATL-Modal-Actions" },
|
|
178
|
+
React__default.createElement("div", { className: rightAction },
|
|
179
|
+
primary && React__default.createElement(Button, Object.assign({}, primary)),
|
|
180
|
+
secondary && (React__default.createElement(Button, Object.assign({}, secondary, { type: "primary", variation: "subtle" })))),
|
|
181
|
+
tertiary && (React__default.createElement("div", { className: leftAction },
|
|
182
|
+
React__default.createElement(Button, Object.assign({}, tertiary, { type: "secondary", variation: "destructive" }))))))));
|
|
183
|
+
}
|
|
184
|
+
function ModalActivator({ children }) {
|
|
185
|
+
const { activatorRef } = useModalContext();
|
|
186
|
+
return (React__default.createElement("span", { ref: activatorRef, style: { display: "contents" } }, children));
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Background overlay for the modal. Used in the ModalContent.
|
|
190
|
+
*/
|
|
191
|
+
function ModalOverlay({ children }) {
|
|
192
|
+
const { size } = useModalContext();
|
|
193
|
+
const { overlay } = useModalStyles(size);
|
|
194
|
+
return (React__default.createElement(AnimatedOverlay, { className: overlay, initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, transition: { duration: 0.2 }, "data-testid": "ATL-Modal-Overlay" }, children));
|
|
195
|
+
}
|
|
196
|
+
function ModalContent({ children }) {
|
|
197
|
+
const { open, floatingContext, activatorRef, floatingRefs, size, floatingNodeId, modalLabelledBy, } = useModalContext();
|
|
198
|
+
const { modal } = useModalStyles(size);
|
|
199
|
+
return (React__default.createElement(AnimatePresence, null, open && (React__default.createElement(FloatingNode, { id: floatingNodeId },
|
|
200
|
+
React__default.createElement(FloatingPortal, null,
|
|
201
|
+
React__default.createElement(AtlantisPortalContent, null,
|
|
202
|
+
React__default.createElement(ModalOverlay, null,
|
|
203
|
+
React__default.createElement(FloatingFocusManager, { context: floatingContext, returnFocus: (activatorRef === null || activatorRef === void 0 ? void 0 : activatorRef.current) ? activatorRef : true, initialFocus: floatingRefs === null || floatingRefs === void 0 ? void 0 : floatingRefs.floating },
|
|
204
|
+
React__default.createElement(motion.div, { "data-floating-ui-focusable": true, "aria-labelledby": modalLabelledBy, className: modal, initial: { scale: 0.9, opacity: 0 }, animate: { scale: 1, opacity: 0.8 }, exit: { scale: 0.9, opacity: 0 }, transition: {
|
|
205
|
+
duration: 0.2,
|
|
206
|
+
ease: "easeInOut",
|
|
207
|
+
}, ref: floatingRefs === null || floatingRefs === void 0 ? void 0 : floatingRefs.setFloating, role: "dialog", tabIndex: -1 }, children)))))))));
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function Modal(props) {
|
|
211
|
+
return React__default.createElement(ModalLegacy, Object.assign({}, props));
|
|
212
|
+
}
|
|
213
|
+
Modal.Header = ModalHeader;
|
|
214
|
+
Modal.Actions = ModalActions;
|
|
215
|
+
Modal.Activator = ModalActivator;
|
|
216
|
+
Modal.Provider = ModalProvider;
|
|
217
|
+
Modal.Content = ModalContent;
|
|
218
|
+
|
|
219
|
+
export { Modal, useModalContext, useModalStyles };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
interface UseModalProps {
|
|
2
|
+
open: boolean;
|
|
3
|
+
activatorRef?: React.RefObject<HTMLElement | null> | null;
|
|
4
|
+
onRequestClose: () => void;
|
|
5
|
+
}
|
|
6
|
+
export declare function useModal({ open, activatorRef: refProp, onRequestClose, }: UseModalProps): {
|
|
7
|
+
floatingRefs: {
|
|
8
|
+
reference: import("react").MutableRefObject<import("@floating-ui/react-dom").ReferenceType | null>;
|
|
9
|
+
floating: React.MutableRefObject<HTMLElement | null>;
|
|
10
|
+
setReference: (node: import("@floating-ui/react-dom").ReferenceType | null) => void;
|
|
11
|
+
setFloating: (node: HTMLElement | null) => void;
|
|
12
|
+
} & import("@floating-ui/react").ExtendedRefs<import("@floating-ui/react").ReferenceType>;
|
|
13
|
+
floatingContext: {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
placement: import("@floating-ui/utils").Placement;
|
|
17
|
+
strategy: import("@floating-ui/utils").Strategy;
|
|
18
|
+
update: () => void;
|
|
19
|
+
middlewareData: import("@floating-ui/core").MiddlewareData;
|
|
20
|
+
isPositioned: boolean;
|
|
21
|
+
floatingStyles: React.CSSProperties;
|
|
22
|
+
open: boolean;
|
|
23
|
+
onOpenChange: (open: boolean, event?: Event, reason?: import("@floating-ui/react").OpenChangeReason) => void;
|
|
24
|
+
events: import("@floating-ui/react").FloatingEvents;
|
|
25
|
+
dataRef: React.MutableRefObject<import("@floating-ui/react").ContextData>;
|
|
26
|
+
nodeId: string | undefined;
|
|
27
|
+
floatingId: string | undefined;
|
|
28
|
+
refs: import("@floating-ui/react").ExtendedRefs<import("@floating-ui/react").ReferenceType>;
|
|
29
|
+
elements: import("@floating-ui/react").ExtendedElements<import("@floating-ui/react").ReferenceType>;
|
|
30
|
+
};
|
|
31
|
+
nodeId: string | undefined;
|
|
32
|
+
activatorRef: import("react").RefObject<HTMLElement | null>;
|
|
33
|
+
parentId: string | null;
|
|
34
|
+
};
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import sizes from "./ModalSizes.module.css";
|
|
2
|
+
export declare function useModalStyles(size?: keyof typeof sizes): {
|
|
3
|
+
modal: string;
|
|
4
|
+
overlay: string;
|
|
5
|
+
header: string;
|
|
6
|
+
dismissButton: string;
|
|
7
|
+
actionBar: string;
|
|
8
|
+
leftAction: string;
|
|
9
|
+
rightAction: string;
|
|
10
|
+
};
|