@jobber/components 8.25.0 → 8.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Dialog/Dialog.d.ts +47 -3
- package/dist/Dialog/Dialog.types.d.ts +1 -15
- package/dist/Dialog/DialogBottomSheet.d.ts +12 -13
- package/dist/Dialog/DialogModal.d.ts +11 -11
- package/dist/Dialog/dialogComposableShared.d.ts +13 -3
- package/dist/dialogReturnFocus-cjs.js +57 -31
- package/dist/dialogReturnFocus-es.js +59 -33
- package/dist/docs/Dialog/Dialog.md +953 -0
- package/dist/docs/index.md +1 -0
- package/package.json +7 -2
package/dist/Dialog/Dialog.d.ts
CHANGED
|
@@ -1,3 +1,47 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { DialogBodyProps, DialogCloseProps, DialogContentProps, DialogFooterProps, DialogHandle, DialogHeaderProps, DialogRootProps, DialogScrollAreaProps, DialogTitleProps, DialogTriggerProps } from "./Dialog.types";
|
|
3
|
+
import { DialogActions } from "./dialogComposableShared";
|
|
4
|
+
/**
|
|
5
|
+
* The Dialog root is a centered modal on
|
|
6
|
+
* desktop, a bottom sheet on mobile. Compose it with `Dialog.Trigger`,
|
|
7
|
+
* `Dialog.Content`, and the layout parts.
|
|
8
|
+
*/
|
|
9
|
+
export declare function Dialog<Payload = unknown>({ onRequestClose, size, type, finalFocus, children, onOpenChange, ...rest }: DialogRootProps<Payload>): React.JSX.Element;
|
|
10
|
+
export declare namespace Dialog {
|
|
11
|
+
var Trigger: typeof DialogTrigger;
|
|
12
|
+
var Content: typeof DialogContent;
|
|
13
|
+
var Header: typeof DialogHeader;
|
|
14
|
+
var Title: typeof DialogTitle;
|
|
15
|
+
var Close: typeof DialogClose;
|
|
16
|
+
var Body: typeof DialogBody;
|
|
17
|
+
var Footer: typeof DialogFooter;
|
|
18
|
+
var Actions: typeof DialogActions;
|
|
19
|
+
var ScrollArea: typeof DialogScrollArea;
|
|
20
|
+
var createHandle: <Payload = unknown>() => DialogHandle<Payload>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Opens the dialog. Accepts an Atlantis `<Button>` (via `children` or `render`)
|
|
24
|
+
* or links a detached `Dialog` through a matching `handle`.
|
|
25
|
+
*/
|
|
26
|
+
declare function DialogTrigger<Payload = unknown>(props: DialogTriggerProps<Payload>): React.JSX.Element;
|
|
27
|
+
/**
|
|
28
|
+
* The dialog popup surface. Holds the `Header`, `Body`, and `Footer`; renders as a
|
|
29
|
+
* centered modal on desktop and a bottom sheet on mobile.
|
|
30
|
+
*/
|
|
31
|
+
declare function DialogContent(props: DialogContentProps): React.JSX.Element;
|
|
32
|
+
/** Layout-only header row — typically a `Dialog.Title` and a `Dialog.Close`. */
|
|
33
|
+
declare function DialogHeader(props: DialogHeaderProps): React.JSX.Element;
|
|
34
|
+
/** The dialog's accessible title; wired to `aria-labelledby`. */
|
|
35
|
+
declare function DialogTitle(props: DialogTitleProps): React.JSX.Element;
|
|
36
|
+
/** A dismiss button that closes the dialog. */
|
|
37
|
+
declare function DialogClose(props: DialogCloseProps): React.JSX.Element;
|
|
38
|
+
/** The dialog body; wired to `aria-describedby`. */
|
|
39
|
+
declare function DialogBody(props: DialogBodyProps): React.JSX.Element;
|
|
40
|
+
/** Footer region for actions or supporting content. */
|
|
41
|
+
declare function DialogFooter(props: DialogFooterProps): React.JSX.Element;
|
|
42
|
+
/**
|
|
43
|
+
* Advanced scroll region. Delegates to the shell: the modal uses a native
|
|
44
|
+
* scrollbar; the sheet uses the BottomSheet primitive's scroll area (with fade).
|
|
45
|
+
*/
|
|
46
|
+
declare function DialogScrollArea(props: DialogScrollAreaProps): React.JSX.Element;
|
|
47
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CSSProperties, ComponentPropsWithRef, ComponentPropsWithoutRef,
|
|
1
|
+
import type { CSSProperties, ComponentPropsWithRef, ComponentPropsWithoutRef, ReactElement, ReactNode } from "react";
|
|
2
2
|
import type { Dialog as BaseDialog } from "../unstyledPrimitives";
|
|
3
3
|
import type { ButtonProps } from "../Button";
|
|
4
4
|
type BaseUIPropsToExclude = "render" | "className" | "style" | "ref" | "children";
|
|
@@ -162,20 +162,6 @@ export interface DialogContextValue {
|
|
|
162
162
|
export interface DialogProviderProps extends DialogContextValue {
|
|
163
163
|
readonly children: ReactNode;
|
|
164
164
|
}
|
|
165
|
-
/** The assembled `Dialog` component: a root with the parts attached. */
|
|
166
|
-
export interface DialogComponent {
|
|
167
|
-
<Payload = unknown>(props: DialogRootProps<Payload>): ReactElement;
|
|
168
|
-
Trigger: <Payload = unknown>(props: DialogTriggerProps<Payload>) => ReactElement;
|
|
169
|
-
Content: FunctionComponent<DialogContentProps>;
|
|
170
|
-
Header: FunctionComponent<DialogHeaderProps>;
|
|
171
|
-
Title: FunctionComponent<DialogTitleProps>;
|
|
172
|
-
Close: FunctionComponent<DialogCloseProps>;
|
|
173
|
-
Body: FunctionComponent<DialogBodyProps>;
|
|
174
|
-
Footer: FunctionComponent<DialogFooterProps>;
|
|
175
|
-
Actions: FunctionComponent<DialogActionsProps>;
|
|
176
|
-
ScrollArea: FunctionComponent<DialogScrollAreaProps>;
|
|
177
|
-
createHandle: <Payload = unknown>() => DialogHandle<Payload>;
|
|
178
|
-
}
|
|
179
165
|
export type DialogActionsAlign = "left" | "right" | "fullWidth";
|
|
180
166
|
interface DialogActionsBaseProps extends DialogBaseProps, Omit<ComponentPropsWithoutRef<"div">, "className" | "style" | "children"> {
|
|
181
167
|
/** Primary action (right). */
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { DialogBodyProps, DialogCloseProps, DialogContentProps, DialogScrollAreaProps, DialogShellRootProps, DialogTitleProps, DialogTriggerProps } from "./Dialog.types";
|
|
3
3
|
import { SharedDialogFooter, SharedDialogHeader } from "./dialogComposableShared";
|
|
4
|
-
declare function
|
|
4
|
+
export declare function DialogBottomSheet(props: DialogShellRootProps): React.JSX.Element;
|
|
5
|
+
export declare namespace DialogBottomSheet {
|
|
6
|
+
var Trigger: typeof DialogBottomSheetTrigger;
|
|
7
|
+
var Content: typeof DialogBottomSheetContent;
|
|
8
|
+
var Header: typeof SharedDialogHeader;
|
|
9
|
+
var Title: typeof DialogBottomSheetTitle;
|
|
10
|
+
var Close: typeof DialogBottomSheetClose;
|
|
11
|
+
var Body: typeof DialogBottomSheetBody;
|
|
12
|
+
var Footer: typeof SharedDialogFooter;
|
|
13
|
+
var ScrollArea: typeof DialogBottomSheetScrollArea;
|
|
14
|
+
}
|
|
5
15
|
declare function DialogBottomSheetTrigger<Payload = unknown>(props: DialogTriggerProps<Payload>): React.JSX.Element;
|
|
6
|
-
declare function DialogBottomSheetContent({ children, className, style, ...rest }: DialogContentProps): React.JSX.Element;
|
|
16
|
+
declare function DialogBottomSheetContent({ children, className, style, render, ...rest }: DialogContentProps): React.JSX.Element;
|
|
7
17
|
declare function DialogBottomSheetTitle({ children, ...rest }: DialogTitleProps): React.JSX.Element;
|
|
8
18
|
declare function DialogBottomSheetClose({ children, render, ...rest }: DialogCloseProps): React.JSX.Element;
|
|
9
19
|
/**
|
|
@@ -14,15 +24,4 @@ declare function DialogBottomSheetClose({ children, render, ...rest }: DialogClo
|
|
|
14
24
|
*/
|
|
15
25
|
declare function DialogBottomSheetScrollArea({ children, className, style, }: DialogScrollAreaProps): React.JSX.Element;
|
|
16
26
|
declare function DialogBottomSheetBody({ children, fullBleed, className, style, ...rest }: DialogBodyProps): React.JSX.Element;
|
|
17
|
-
/** Mobile shell: a bottom sheet built on the BottomSheet/Drawer primitives. */
|
|
18
|
-
export declare const DialogBottomSheet: typeof DialogBottomSheetRoot & {
|
|
19
|
-
Trigger: typeof DialogBottomSheetTrigger;
|
|
20
|
-
Content: typeof DialogBottomSheetContent;
|
|
21
|
-
Header: typeof SharedDialogHeader;
|
|
22
|
-
Title: typeof DialogBottomSheetTitle;
|
|
23
|
-
Close: typeof DialogBottomSheetClose;
|
|
24
|
-
Body: typeof DialogBottomSheetBody;
|
|
25
|
-
Footer: typeof SharedDialogFooter;
|
|
26
|
-
ScrollArea: typeof DialogBottomSheetScrollArea;
|
|
27
|
-
};
|
|
28
27
|
export {};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { DialogBodyProps, DialogCloseProps, DialogContentProps, DialogShellRootProps, DialogTitleProps, DialogTriggerProps } from "./Dialog.types";
|
|
3
3
|
import { DialogScrollArea, SharedDialogFooter, SharedDialogHeader } from "./dialogComposableShared";
|
|
4
|
-
declare function
|
|
4
|
+
export declare function DialogModal(props: DialogShellRootProps): React.JSX.Element;
|
|
5
|
+
export declare namespace DialogModal {
|
|
6
|
+
var Trigger: typeof DialogModalTrigger;
|
|
7
|
+
var Content: typeof DialogModalContent;
|
|
8
|
+
var Header: typeof SharedDialogHeader;
|
|
9
|
+
var Title: typeof DialogModalTitle;
|
|
10
|
+
var Close: typeof DialogModalClose;
|
|
11
|
+
var Body: typeof DialogModalBody;
|
|
12
|
+
var Footer: typeof SharedDialogFooter;
|
|
13
|
+
var ScrollArea: typeof DialogScrollArea;
|
|
14
|
+
}
|
|
5
15
|
declare function DialogModalTrigger<Payload = unknown>({ children, render, handle, payload, className, style, ...rest }: DialogTriggerProps<Payload>): React.JSX.Element;
|
|
6
16
|
declare function DialogModalContent({ children, className, style, ...rest }: DialogContentProps): React.JSX.Element;
|
|
7
17
|
declare function DialogModalTitle({ children, ...rest }: DialogTitleProps): React.JSX.Element;
|
|
8
18
|
declare function DialogModalClose({ children, render, ...rest }: DialogCloseProps): React.JSX.Element;
|
|
9
19
|
declare function DialogModalBody({ children, fullBleed, className, style, ...rest }: DialogBodyProps): React.JSX.Element;
|
|
10
|
-
export declare const DialogModal: typeof DialogModalRoot & {
|
|
11
|
-
Trigger: typeof DialogModalTrigger;
|
|
12
|
-
Content: typeof DialogModalContent;
|
|
13
|
-
Header: typeof SharedDialogHeader;
|
|
14
|
-
Title: typeof DialogModalTitle;
|
|
15
|
-
Close: typeof DialogModalClose;
|
|
16
|
-
Body: typeof DialogModalBody;
|
|
17
|
-
Footer: typeof SharedDialogFooter;
|
|
18
|
-
ScrollArea: typeof DialogScrollArea;
|
|
19
|
-
};
|
|
20
20
|
export {};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
1
2
|
import React from "react";
|
|
2
|
-
import type { DialogActionsProps, DialogCloseRender, DialogContextValue, DialogFooterProps, DialogHeaderProps, DialogProviderProps, DialogScrollAreaProps, DialogTriggerRender } from "./Dialog.types";
|
|
3
|
+
import type { DialogActionsProps, DialogCloseRender, DialogContentProps, DialogContextValue, DialogFooterProps, DialogHeaderProps, DialogProviderProps, DialogScrollAreaProps, DialogTriggerRender } from "./Dialog.types";
|
|
4
|
+
import { type Drawer as BaseDrawer } from "../unstyledPrimitives";
|
|
3
5
|
/**
|
|
4
6
|
* Resolves the trigger element for `Dialog.Trigger`. Copied from Menu's
|
|
5
7
|
* `resolveMenuTriggerRender` so an Atlantis `<Button>` works as a trigger via
|
|
@@ -9,7 +11,7 @@ import type { DialogActionsProps, DialogCloseRender, DialogContextValue, DialogF
|
|
|
9
11
|
export declare function resolveComposableTriggerRender({ children, render, }: {
|
|
10
12
|
readonly children?: React.ReactNode;
|
|
11
13
|
readonly render?: DialogTriggerRender;
|
|
12
|
-
}):
|
|
14
|
+
}): ReactElement<unknown, string | React.JSXElementConstructor<any>> | ((props: React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>) => React.JSX.Element);
|
|
13
15
|
/**
|
|
14
16
|
* Resolves the dismiss element for `Dialog.Close`, mirroring
|
|
15
17
|
* `resolveComposableTriggerRender` so a custom render works in both shells.
|
|
@@ -20,7 +22,15 @@ export declare function resolveComposableTriggerRender({ children, render, }: {
|
|
|
20
22
|
export declare function resolveComposableCloseRender({ children, render, }: {
|
|
21
23
|
readonly children?: React.ReactNode;
|
|
22
24
|
readonly render?: DialogCloseRender;
|
|
23
|
-
}):
|
|
25
|
+
}): ReactElement<unknown, string | React.JSXElementConstructor<any>> | ((props: React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>) => React.JSX.Element);
|
|
26
|
+
/**
|
|
27
|
+
* Adapts a `Dialog.Content` `render` for the bottom sheet's drawer popup. A
|
|
28
|
+
* render element passes through; a render function is wrapped to receive the
|
|
29
|
+
* drawer's state re-shaped as the dialog popup's state (e.g. `nestedDrawerOpen`
|
|
30
|
+
* becomes `nestedDialogOpen`), so `render` sees the same shape as the desktop
|
|
31
|
+
* dialog.
|
|
32
|
+
*/
|
|
33
|
+
export declare function resolveBottomSheetContentRender(render: DialogContentProps["render"]): React.ComponentProps<typeof BaseDrawer.Popup>["render"];
|
|
24
34
|
/** Supplies the static config (type/size/isMobile/finalFocus) to the parts. */
|
|
25
35
|
export declare function DialogProvider({ children, type, size, isMobile, finalFocus, }: DialogProviderProps): React.JSX.Element;
|
|
26
36
|
/** Reads the Dialog config; throws if a part is used outside `<Dialog>`. */
|
|
@@ -7,10 +7,10 @@ var classnames = require('classnames');
|
|
|
7
7
|
var buttonRenderAdapter = require('./buttonRenderAdapter-cjs.js');
|
|
8
8
|
var Button = require('./Button-cjs.js');
|
|
9
9
|
var ScrollAreaViewport = require('./ScrollAreaViewport-cjs.js');
|
|
10
|
+
var useRenderElement = require('./useRenderElement-cjs.js');
|
|
10
11
|
var Heading = require('./Heading-cjs.js');
|
|
11
12
|
var BottomSheet = require('./BottomSheet-cjs.js');
|
|
12
13
|
var DrawerTitle = require('./DrawerTitle-cjs.js');
|
|
13
|
-
var useRenderElement = require('./useRenderElement-cjs.js');
|
|
14
14
|
var DrawerDescription = require('./DrawerDescription-cjs.js');
|
|
15
15
|
|
|
16
16
|
// Copied from Menu's constant so the two surfaces agree on what "mobile" means.
|
|
@@ -81,6 +81,24 @@ function resolveComposableCloseRender({ children, render, }) {
|
|
|
81
81
|
return buttonRenderAdapter.renderAtlantisButtonTarget(React.createElement(Button.Button, { type: "tertiary", variation: "subtle", ariaLabel: "Close dialog" },
|
|
82
82
|
React.createElement(Button.Button.Icon, { name: "remove" })));
|
|
83
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Adapts a `Dialog.Content` `render` for the bottom sheet's drawer popup. A
|
|
86
|
+
* render element passes through; a render function is wrapped to receive the
|
|
87
|
+
* drawer's state re-shaped as the dialog popup's state (e.g. `nestedDrawerOpen`
|
|
88
|
+
* becomes `nestedDialogOpen`), so `render` sees the same shape as the desktop
|
|
89
|
+
* dialog.
|
|
90
|
+
*/
|
|
91
|
+
function resolveBottomSheetContentRender(render) {
|
|
92
|
+
if (typeof render !== "function") {
|
|
93
|
+
return render;
|
|
94
|
+
}
|
|
95
|
+
return (props, drawerState) => render(props, {
|
|
96
|
+
open: drawerState.open,
|
|
97
|
+
transitionStatus: drawerState.transitionStatus,
|
|
98
|
+
nested: drawerState.nested,
|
|
99
|
+
nestedDialogOpen: drawerState.nestedDrawerOpen,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
84
102
|
const DialogContext = React.createContext({
|
|
85
103
|
type: "dialog",
|
|
86
104
|
size: "base",
|
|
@@ -134,15 +152,26 @@ function SharedDialogFooter(_a) {
|
|
|
134
152
|
const sticky = !useInsideDialogScrollArea();
|
|
135
153
|
return (React.createElement("div", Object.assign({}, rest, { className: classnames(styles.footer, className), style: style, "data-sticky": sticky || undefined, "data-testid": "ATL-Dialog-Footer" }), children));
|
|
136
154
|
}
|
|
155
|
+
function renderActionButton(action, defaults) {
|
|
156
|
+
if (!action)
|
|
157
|
+
return null;
|
|
158
|
+
return React.isValidElement(action) ? (action) : (React.createElement(Button.Button, Object.assign({}, useRenderElement.mergeProps(defaults, action))));
|
|
159
|
+
}
|
|
137
160
|
/**
|
|
138
161
|
* The action-button layout: tertiary on the left, primary/secondary grouped on
|
|
139
162
|
* the right. Drop it inside a `Dialog.Footer`.
|
|
140
163
|
*/
|
|
141
164
|
function DialogActions(_a) {
|
|
142
165
|
var { primary, secondary, tertiary, align = "right", className, style } = _a, rest = tslib_es6.__rest(_a, ["primary", "secondary", "tertiary", "align", "className", "style"]);
|
|
143
|
-
const
|
|
144
|
-
const
|
|
145
|
-
|
|
166
|
+
const primaryAction = renderActionButton(primary, { type: "primary" });
|
|
167
|
+
const secondaryAction = renderActionButton(secondary, {
|
|
168
|
+
type: "primary",
|
|
169
|
+
variation: "subtle",
|
|
170
|
+
});
|
|
171
|
+
const tertiaryAction = renderActionButton(tertiary, {
|
|
172
|
+
type: "secondary",
|
|
173
|
+
variation: "destructive",
|
|
174
|
+
});
|
|
146
175
|
return (React.createElement("div", Object.assign({}, rest, { className: classnames(actionsStyles.actions, [actionsStyles[`align-${align}`]], className), style: style, "data-testid": "ATL-Dialog-Actions" }),
|
|
147
176
|
tertiary && (React.createElement("div", { className: actionsStyles.leftActions }, tertiaryAction)),
|
|
148
177
|
React.createElement("div", { className: classnames(actionsStyles.buttonGroup, actionsStyles[`align-${align}`]) },
|
|
@@ -150,20 +179,23 @@ function DialogActions(_a) {
|
|
|
150
179
|
primary && primaryAction)));
|
|
151
180
|
}
|
|
152
181
|
|
|
153
|
-
function
|
|
182
|
+
function DialogBottomSheet(props) {
|
|
154
183
|
return (React.createElement(BottomSheet.BottomSheet.Root, Object.assign({}, props)));
|
|
155
184
|
}
|
|
156
185
|
function DialogBottomSheetTrigger(props) {
|
|
157
186
|
return (React.createElement(BottomSheet.BottomSheet.Trigger, Object.assign({}, props)));
|
|
158
187
|
}
|
|
159
188
|
function DialogBottomSheetContent(_a) {
|
|
160
|
-
var { children, className, style } = _a, rest = tslib_es6.__rest(_a, ["children", "className", "style"]);
|
|
189
|
+
var { children, className, style, render } = _a, rest = tslib_es6.__rest(_a, ["children", "className", "style", "render"]);
|
|
161
190
|
const { type, size, finalFocus } = useDialogContext();
|
|
162
191
|
return (
|
|
163
192
|
// Opt-out of the BottomSheet's built-in scroll area.
|
|
164
193
|
// Dialog will handle the scroll area itself.
|
|
165
194
|
React.createElement(BottomSheet.BottomSheetScrollAreaContext.Provider, { value: false },
|
|
166
|
-
React.createElement(BottomSheet.BottomSheet.Popup, Object.assign({}, rest, {
|
|
195
|
+
React.createElement(BottomSheet.BottomSheet.Popup, Object.assign({}, rest, {
|
|
196
|
+
// The bottom sheet is backed by a drawer popup, so re-shape its state
|
|
197
|
+
// into the dialog popup state the consumer's `render` is typed against.
|
|
198
|
+
render: resolveBottomSheetContentRender(render), className: classnames(styles.sheetSurface, className), style: style, role: type, finalFocus: finalFocus, "data-dialog-variant": "sheet", "data-size": size }), children)));
|
|
167
199
|
}
|
|
168
200
|
function DialogBottomSheetTitle(_a) {
|
|
169
201
|
var { children } = _a, rest = tslib_es6.__rest(_a, ["children"]);
|
|
@@ -194,18 +226,16 @@ function DialogBottomSheetBody(_a) {
|
|
|
194
226
|
return insideScrollArea ? (content) : (React.createElement(DialogBottomSheetScrollArea, null, content));
|
|
195
227
|
}
|
|
196
228
|
/** Mobile shell: a bottom sheet built on the BottomSheet/Drawer primitives. */
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
ScrollArea: DialogBottomSheetScrollArea,
|
|
206
|
-
});
|
|
229
|
+
DialogBottomSheet.Trigger = DialogBottomSheetTrigger;
|
|
230
|
+
DialogBottomSheet.Content = DialogBottomSheetContent;
|
|
231
|
+
DialogBottomSheet.Header = SharedDialogHeader;
|
|
232
|
+
DialogBottomSheet.Title = DialogBottomSheetTitle;
|
|
233
|
+
DialogBottomSheet.Close = DialogBottomSheetClose;
|
|
234
|
+
DialogBottomSheet.Body = DialogBottomSheetBody;
|
|
235
|
+
DialogBottomSheet.Footer = SharedDialogFooter;
|
|
236
|
+
DialogBottomSheet.ScrollArea = DialogBottomSheetScrollArea;
|
|
207
237
|
|
|
208
|
-
function
|
|
238
|
+
function DialogModal(props) {
|
|
209
239
|
return React.createElement(ScrollAreaViewport.DialogRoot, Object.assign({}, props));
|
|
210
240
|
}
|
|
211
241
|
function DialogModalTrigger(_a) {
|
|
@@ -238,17 +268,14 @@ function DialogModalBody(_a) {
|
|
|
238
268
|
const content = (React.createElement(DrawerDescription.DialogDescription, { render: descriptionProps => (React.createElement("div", Object.assign({}, rest, descriptionProps, { className: classnames(styles.body, { [styles.fullBleed]: fullBleed }, className), style: style }), children)) }));
|
|
239
269
|
return insideScrollArea ? (content) : (React.createElement(DialogScrollArea$1, null, content));
|
|
240
270
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
// The modal keeps the plain native-scrollbar scroll region.
|
|
250
|
-
ScrollArea: DialogScrollArea$1,
|
|
251
|
-
});
|
|
271
|
+
DialogModal.Trigger = DialogModalTrigger;
|
|
272
|
+
DialogModal.Content = DialogModalContent;
|
|
273
|
+
DialogModal.Header = SharedDialogHeader;
|
|
274
|
+
DialogModal.Title = DialogModalTitle;
|
|
275
|
+
DialogModal.Close = DialogModalClose;
|
|
276
|
+
DialogModal.Body = DialogModalBody;
|
|
277
|
+
DialogModal.Footer = SharedDialogFooter;
|
|
278
|
+
DialogModal.ScrollArea = DialogScrollArea$1;
|
|
252
279
|
|
|
253
280
|
/**
|
|
254
281
|
* Creates a handle that opens/closes a `Dialog` from detached triggers (e.g. an
|
|
@@ -273,7 +300,7 @@ function useDialogShell() {
|
|
|
273
300
|
* desktop, a bottom sheet on mobile. Compose it with `Dialog.Trigger`,
|
|
274
301
|
* `Dialog.Content`, and the layout parts.
|
|
275
302
|
*/
|
|
276
|
-
function
|
|
303
|
+
function Dialog(_a) {
|
|
277
304
|
var { onRequestClose, size = "base", type = "dialog", finalFocus, children, onOpenChange } = _a, rest = tslib_es6.__rest(_a, ["onRequestClose", "size", "type", "finalFocus", "children", "onOpenChange"]);
|
|
278
305
|
function handleOpenChange(nextOpen, eventDetails) {
|
|
279
306
|
if (!nextOpen) {
|
|
@@ -339,7 +366,6 @@ function DialogScrollArea(props) {
|
|
|
339
366
|
const Shell = useDialogShell();
|
|
340
367
|
return React.createElement(Shell.ScrollArea, Object.assign({}, props));
|
|
341
368
|
}
|
|
342
|
-
const Dialog = DialogRoot;
|
|
343
369
|
Dialog.Trigger = DialogTrigger;
|
|
344
370
|
Dialog.Content = DialogContent;
|
|
345
371
|
Dialog.Header = DialogHeader;
|
|
@@ -4,11 +4,11 @@ import { useWindowDimensions } from '@jobber/hooks';
|
|
|
4
4
|
import classnames from 'classnames';
|
|
5
5
|
import { n as normalizeBaseUiButtonProps, i as isAtlantisButtonRenderTarget, s as stripNativeTypeFromButtonRenderTarget, r as renderAtlantisButtonTarget } from './buttonRenderAdapter-es.js';
|
|
6
6
|
import { B as Button } from './Button-es.js';
|
|
7
|
-
import { S as ScrollAreaRoot, e as ScrollAreaViewport, g as DialogRoot
|
|
7
|
+
import { S as ScrollAreaRoot, e as ScrollAreaViewport, g as DialogRoot, h as DialogTrigger$1, i as DialogPortal } from './ScrollAreaViewport-es.js';
|
|
8
|
+
import { m as mergeProps } from './useRenderElement-es.js';
|
|
8
9
|
import { H as Heading } from './Heading-es.js';
|
|
9
10
|
import { a as BottomSheet, B as BottomSheetScrollAreaContext } from './BottomSheet-es.js';
|
|
10
11
|
import { D as DrawerTitle, a as DrawerClose, b as DialogTitle$1, c as DialogClose$1 } from './DrawerTitle-es.js';
|
|
11
|
-
import { m as mergeProps } from './useRenderElement-es.js';
|
|
12
12
|
import { D as DrawerDescription, a as DialogBackdrop, b as DialogViewport, c as DialogPopup, d as DialogDescription, e as createDialogHandle } from './DrawerDescription-es.js';
|
|
13
13
|
|
|
14
14
|
// Copied from Menu's constant so the two surfaces agree on what "mobile" means.
|
|
@@ -79,6 +79,24 @@ function resolveComposableCloseRender({ children, render, }) {
|
|
|
79
79
|
return renderAtlantisButtonTarget(React__default.createElement(Button, { type: "tertiary", variation: "subtle", ariaLabel: "Close dialog" },
|
|
80
80
|
React__default.createElement(Button.Icon, { name: "remove" })));
|
|
81
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Adapts a `Dialog.Content` `render` for the bottom sheet's drawer popup. A
|
|
84
|
+
* render element passes through; a render function is wrapped to receive the
|
|
85
|
+
* drawer's state re-shaped as the dialog popup's state (e.g. `nestedDrawerOpen`
|
|
86
|
+
* becomes `nestedDialogOpen`), so `render` sees the same shape as the desktop
|
|
87
|
+
* dialog.
|
|
88
|
+
*/
|
|
89
|
+
function resolveBottomSheetContentRender(render) {
|
|
90
|
+
if (typeof render !== "function") {
|
|
91
|
+
return render;
|
|
92
|
+
}
|
|
93
|
+
return (props, drawerState) => render(props, {
|
|
94
|
+
open: drawerState.open,
|
|
95
|
+
transitionStatus: drawerState.transitionStatus,
|
|
96
|
+
nested: drawerState.nested,
|
|
97
|
+
nestedDialogOpen: drawerState.nestedDrawerOpen,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
82
100
|
const DialogContext = React__default.createContext({
|
|
83
101
|
type: "dialog",
|
|
84
102
|
size: "base",
|
|
@@ -132,15 +150,26 @@ function SharedDialogFooter(_a) {
|
|
|
132
150
|
const sticky = !useInsideDialogScrollArea();
|
|
133
151
|
return (React__default.createElement("div", Object.assign({}, rest, { className: classnames(styles.footer, className), style: style, "data-sticky": sticky || undefined, "data-testid": "ATL-Dialog-Footer" }), children));
|
|
134
152
|
}
|
|
153
|
+
function renderActionButton(action, defaults) {
|
|
154
|
+
if (!action)
|
|
155
|
+
return null;
|
|
156
|
+
return isValidElement(action) ? (action) : (React__default.createElement(Button, Object.assign({}, mergeProps(defaults, action))));
|
|
157
|
+
}
|
|
135
158
|
/**
|
|
136
159
|
* The action-button layout: tertiary on the left, primary/secondary grouped on
|
|
137
160
|
* the right. Drop it inside a `Dialog.Footer`.
|
|
138
161
|
*/
|
|
139
162
|
function DialogActions(_a) {
|
|
140
163
|
var { primary, secondary, tertiary, align = "right", className, style } = _a, rest = __rest(_a, ["primary", "secondary", "tertiary", "align", "className", "style"]);
|
|
141
|
-
const
|
|
142
|
-
const
|
|
143
|
-
|
|
164
|
+
const primaryAction = renderActionButton(primary, { type: "primary" });
|
|
165
|
+
const secondaryAction = renderActionButton(secondary, {
|
|
166
|
+
type: "primary",
|
|
167
|
+
variation: "subtle",
|
|
168
|
+
});
|
|
169
|
+
const tertiaryAction = renderActionButton(tertiary, {
|
|
170
|
+
type: "secondary",
|
|
171
|
+
variation: "destructive",
|
|
172
|
+
});
|
|
144
173
|
return (React__default.createElement("div", Object.assign({}, rest, { className: classnames(actionsStyles.actions, [actionsStyles[`align-${align}`]], className), style: style, "data-testid": "ATL-Dialog-Actions" }),
|
|
145
174
|
tertiary && (React__default.createElement("div", { className: actionsStyles.leftActions }, tertiaryAction)),
|
|
146
175
|
React__default.createElement("div", { className: classnames(actionsStyles.buttonGroup, actionsStyles[`align-${align}`]) },
|
|
@@ -148,20 +177,23 @@ function DialogActions(_a) {
|
|
|
148
177
|
primary && primaryAction)));
|
|
149
178
|
}
|
|
150
179
|
|
|
151
|
-
function
|
|
180
|
+
function DialogBottomSheet(props) {
|
|
152
181
|
return (React__default.createElement(BottomSheet.Root, Object.assign({}, props)));
|
|
153
182
|
}
|
|
154
183
|
function DialogBottomSheetTrigger(props) {
|
|
155
184
|
return (React__default.createElement(BottomSheet.Trigger, Object.assign({}, props)));
|
|
156
185
|
}
|
|
157
186
|
function DialogBottomSheetContent(_a) {
|
|
158
|
-
var { children, className, style } = _a, rest = __rest(_a, ["children", "className", "style"]);
|
|
187
|
+
var { children, className, style, render } = _a, rest = __rest(_a, ["children", "className", "style", "render"]);
|
|
159
188
|
const { type, size, finalFocus } = useDialogContext();
|
|
160
189
|
return (
|
|
161
190
|
// Opt-out of the BottomSheet's built-in scroll area.
|
|
162
191
|
// Dialog will handle the scroll area itself.
|
|
163
192
|
React__default.createElement(BottomSheetScrollAreaContext.Provider, { value: false },
|
|
164
|
-
React__default.createElement(BottomSheet.Popup, Object.assign({}, rest, {
|
|
193
|
+
React__default.createElement(BottomSheet.Popup, Object.assign({}, rest, {
|
|
194
|
+
// The bottom sheet is backed by a drawer popup, so re-shape its state
|
|
195
|
+
// into the dialog popup state the consumer's `render` is typed against.
|
|
196
|
+
render: resolveBottomSheetContentRender(render), className: classnames(styles.sheetSurface, className), style: style, role: type, finalFocus: finalFocus, "data-dialog-variant": "sheet", "data-size": size }), children)));
|
|
165
197
|
}
|
|
166
198
|
function DialogBottomSheetTitle(_a) {
|
|
167
199
|
var { children } = _a, rest = __rest(_a, ["children"]);
|
|
@@ -192,19 +224,17 @@ function DialogBottomSheetBody(_a) {
|
|
|
192
224
|
return insideScrollArea ? (content) : (React__default.createElement(DialogBottomSheetScrollArea, null, content));
|
|
193
225
|
}
|
|
194
226
|
/** Mobile shell: a bottom sheet built on the BottomSheet/Drawer primitives. */
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
ScrollArea: DialogBottomSheetScrollArea,
|
|
204
|
-
});
|
|
227
|
+
DialogBottomSheet.Trigger = DialogBottomSheetTrigger;
|
|
228
|
+
DialogBottomSheet.Content = DialogBottomSheetContent;
|
|
229
|
+
DialogBottomSheet.Header = SharedDialogHeader;
|
|
230
|
+
DialogBottomSheet.Title = DialogBottomSheetTitle;
|
|
231
|
+
DialogBottomSheet.Close = DialogBottomSheetClose;
|
|
232
|
+
DialogBottomSheet.Body = DialogBottomSheetBody;
|
|
233
|
+
DialogBottomSheet.Footer = SharedDialogFooter;
|
|
234
|
+
DialogBottomSheet.ScrollArea = DialogBottomSheetScrollArea;
|
|
205
235
|
|
|
206
|
-
function
|
|
207
|
-
return React__default.createElement(DialogRoot
|
|
236
|
+
function DialogModal(props) {
|
|
237
|
+
return React__default.createElement(DialogRoot, Object.assign({}, props));
|
|
208
238
|
}
|
|
209
239
|
function DialogModalTrigger(_a) {
|
|
210
240
|
var { children, render, handle, payload, className, style } = _a, rest = __rest(_a, ["children", "render", "handle", "payload", "className", "style"]);
|
|
@@ -236,17 +266,14 @@ function DialogModalBody(_a) {
|
|
|
236
266
|
const content = (React__default.createElement(DialogDescription, { render: descriptionProps => (React__default.createElement("div", Object.assign({}, rest, descriptionProps, { className: classnames(styles.body, { [styles.fullBleed]: fullBleed }, className), style: style }), children)) }));
|
|
237
267
|
return insideScrollArea ? (content) : (React__default.createElement(DialogScrollArea$1, null, content));
|
|
238
268
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
// The modal keeps the plain native-scrollbar scroll region.
|
|
248
|
-
ScrollArea: DialogScrollArea$1,
|
|
249
|
-
});
|
|
269
|
+
DialogModal.Trigger = DialogModalTrigger;
|
|
270
|
+
DialogModal.Content = DialogModalContent;
|
|
271
|
+
DialogModal.Header = SharedDialogHeader;
|
|
272
|
+
DialogModal.Title = DialogModalTitle;
|
|
273
|
+
DialogModal.Close = DialogModalClose;
|
|
274
|
+
DialogModal.Body = DialogModalBody;
|
|
275
|
+
DialogModal.Footer = SharedDialogFooter;
|
|
276
|
+
DialogModal.ScrollArea = DialogScrollArea$1;
|
|
250
277
|
|
|
251
278
|
/**
|
|
252
279
|
* Creates a handle that opens/closes a `Dialog` from detached triggers (e.g. an
|
|
@@ -271,7 +298,7 @@ function useDialogShell() {
|
|
|
271
298
|
* desktop, a bottom sheet on mobile. Compose it with `Dialog.Trigger`,
|
|
272
299
|
* `Dialog.Content`, and the layout parts.
|
|
273
300
|
*/
|
|
274
|
-
function
|
|
301
|
+
function Dialog(_a) {
|
|
275
302
|
var { onRequestClose, size = "base", type = "dialog", finalFocus, children, onOpenChange } = _a, rest = __rest(_a, ["onRequestClose", "size", "type", "finalFocus", "children", "onOpenChange"]);
|
|
276
303
|
function handleOpenChange(nextOpen, eventDetails) {
|
|
277
304
|
if (!nextOpen) {
|
|
@@ -337,7 +364,6 @@ function DialogScrollArea(props) {
|
|
|
337
364
|
const Shell = useDialogShell();
|
|
338
365
|
return React__default.createElement(Shell.ScrollArea, Object.assign({}, props));
|
|
339
366
|
}
|
|
340
|
-
const Dialog = DialogRoot;
|
|
341
367
|
Dialog.Trigger = DialogTrigger;
|
|
342
368
|
Dialog.Content = DialogContent;
|
|
343
369
|
Dialog.Header = DialogHeader;
|