@manakind/ui-core 0.8.0 → 0.9.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/dialog/dialog.d.ts
CHANGED
|
@@ -25,8 +25,8 @@ export interface DialogProps {
|
|
|
25
25
|
actions?: ReactNode;
|
|
26
26
|
/**
|
|
27
27
|
* The one element that opens the dialog, such as a `Button`. Focus returns
|
|
28
|
-
* to it when the dialog closes
|
|
29
|
-
* `open` from elsewhere.
|
|
28
|
+
* to it when the dialog closes, unless `finalFocusRef` names another
|
|
29
|
+
* element. Leave it out to open the dialog with `open` from elsewhere.
|
|
30
30
|
*/
|
|
31
31
|
trigger?: ReactElement;
|
|
32
32
|
/** Controlled open state. Pair with `onOpenChange`. */
|
|
@@ -54,6 +54,19 @@ export interface DialogProps {
|
|
|
54
54
|
* destructive action.
|
|
55
55
|
*/
|
|
56
56
|
initialFocusRef?: RefObject<HTMLElement | null>;
|
|
57
|
+
/**
|
|
58
|
+
* Where focus lands when the dialog closes, in place of the trigger. Use it
|
|
59
|
+
* when the confirmed action removes the trigger, such as a row's Remove
|
|
60
|
+
* button: focus would return to an element that is about to unmount and
|
|
61
|
+
* fall to the page body. Point it at something that stays, such as the
|
|
62
|
+
* list's heading, which needs `tabIndex={-1}` to take focus.
|
|
63
|
+
*
|
|
64
|
+
* The ref is read as the dialog closes, however it closes. Fill it in the
|
|
65
|
+
* committing action, so Cancel and Escape still return focus to the
|
|
66
|
+
* trigger, which is still there. While the ref holds no element, focus
|
|
67
|
+
* returns to the trigger as usual.
|
|
68
|
+
*/
|
|
69
|
+
finalFocusRef?: RefObject<HTMLElement | null>;
|
|
57
70
|
/** Accessible name of the close button. Translate it with the rest of the UI. */
|
|
58
71
|
closeLabel?: string;
|
|
59
72
|
/**
|
|
@@ -68,8 +81,8 @@ export interface DialogProps {
|
|
|
68
81
|
/**
|
|
69
82
|
* A modal dialog: a raised panel over a dimmed page, built on Ark UI.
|
|
70
83
|
*
|
|
71
|
-
* Ark owns the behaviour: the focus trap, focus returning to the trigger
|
|
72
|
-
* Escape, the page's scroll lock, `aria-modal`, and the title and
|
|
84
|
+
* Ark owns the behaviour: the focus trap, focus returning to the trigger
|
|
85
|
+
* (or to `finalFocusRef`), Escape, the page's scroll lock, `aria-modal`, and the title and
|
|
73
86
|
* description wiring. This wrapper adds the `ds-` classes, the
|
|
74
87
|
* `--ds-dialog-*` bindings, and a slot API in place of Ark's anatomy.
|
|
75
88
|
*
|
|
@@ -100,5 +113,5 @@ export interface DialogProps {
|
|
|
100
113
|
* dialog portals into its panel (see `PortalContainerContext`) and opens at
|
|
101
114
|
* 60, above it. Nothing is mounted while the dialog is closed.
|
|
102
115
|
*/
|
|
103
|
-
export declare function Dialog({ title, description, children, actions, trigger, open, defaultOpen, onOpenChange, role, initialFocusRef, closeLabel, closeIcon, className, }: DialogProps): import("react/jsx-runtime").JSX.Element;
|
|
116
|
+
export declare function Dialog({ title, description, children, actions, trigger, open, defaultOpen, onOpenChange, role, initialFocusRef, finalFocusRef, closeLabel, closeIcon, className, }: DialogProps): import("react/jsx-runtime").JSX.Element;
|
|
104
117
|
//# sourceMappingURL=dialog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../src/dialog/dialog.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,cAAc,CAAC;AAItB,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,aAAa,CAAC;AAElD,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,KAAK,EAAE,SAAS,CAAC;IACjB;;;;OAIG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,SA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W,CAAC,EAAE,SAAS,CAAC;IACxB,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;;OAIG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,uDAAuD;IACvD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,4CAA4C;IAC5C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAChD;;;;;;;;;;;OAWG;IACH,aAAa,CAAC,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAC9C,iFAAiF;IACjF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,MAAM,CAAC,EACrB,KAAK,EACL,WAAW,EACX,QAAQ,EACR,OAAO,EACP,OAAO,EACP,IAAI,EACJ,WAAW,EACX,YAAY,EACZ,IAAe,EACf,eAAe,EACf,aAAa,EACb,UAAoB,EACpB,SAAiB,EACjB,SAAS,GACV,EAAE,WAAW,2CAyDb"}
|
package/dist/dialog/dialog.js
CHANGED
|
@@ -10,8 +10,8 @@ import { Cross } from '../fallback-glyphs';
|
|
|
10
10
|
/**
|
|
11
11
|
* A modal dialog: a raised panel over a dimmed page, built on Ark UI.
|
|
12
12
|
*
|
|
13
|
-
* Ark owns the behaviour: the focus trap, focus returning to the trigger
|
|
14
|
-
* Escape, the page's scroll lock, `aria-modal`, and the title and
|
|
13
|
+
* Ark owns the behaviour: the focus trap, focus returning to the trigger
|
|
14
|
+
* (or to `finalFocusRef`), Escape, the page's scroll lock, `aria-modal`, and the title and
|
|
15
15
|
* description wiring. This wrapper adds the `ds-` classes, the
|
|
16
16
|
* `--ds-dialog-*` bindings, and a slot API in place of Ark's anatomy.
|
|
17
17
|
*
|
|
@@ -42,7 +42,7 @@ import { Cross } from '../fallback-glyphs';
|
|
|
42
42
|
* dialog portals into its panel (see `PortalContainerContext`) and opens at
|
|
43
43
|
* 60, above it. Nothing is mounted while the dialog is closed.
|
|
44
44
|
*/
|
|
45
|
-
export function Dialog({ title, description, children, actions, trigger, open, defaultOpen, onOpenChange, role = 'dialog', initialFocusRef, closeLabel = 'Close', closeIcon = Cross, className, }) {
|
|
45
|
+
export function Dialog({ title, description, children, actions, trigger, open, defaultOpen, onOpenChange, role = 'dialog', initialFocusRef, finalFocusRef, closeLabel = 'Close', closeIcon = Cross, className, }) {
|
|
46
46
|
const dismissible = role === 'dialog';
|
|
47
47
|
const panelRef = useRef(null);
|
|
48
48
|
const handleOpenChange = (details) => onOpenChange?.(details.open);
|
|
@@ -50,7 +50,8 @@ export function Dialog({ title, description, children, actions, trigger, open, d
|
|
|
50
50
|
// reads undefined as "the first focusable element" and, given null, fails
|
|
51
51
|
// to start at all, leaving the page reachable by Tab.
|
|
52
52
|
const initialFocusEl = (() => initialFocusRef?.current ?? undefined);
|
|
53
|
-
|
|
53
|
+
const finalFocusEl = () => finalFocusRef?.current ?? null;
|
|
54
|
+
return (_jsxs(ArkDialog.Root, { open: open, defaultOpen: defaultOpen, onOpenChange: handleOpenChange, role: role, closeOnInteractOutside: dismissible, initialFocusEl: initialFocusEl, finalFocusEl: finalFocusEl, lazyMount: true, unmountOnExit: true, children: [trigger && _jsx(ArkDialog.Trigger, { asChild: true, children: trigger }), _jsxs(Portal, { children: [_jsx(ArkDialog.Backdrop, { className: "ds-dialog__backdrop" }), _jsx(ArkDialog.Positioner, { className: "ds-dialog__positioner", children: _jsx(ArkDialog.Content, { ref: panelRef, className: cx('ds-dialog', className), children: _jsxs(PortalContainerContext.Provider, { value: panelRef, children: [_jsxs("div", { className: "ds-dialog__header", children: [_jsxs("div", { className: "ds-dialog__heading", children: [_jsx(ArkDialog.Title, { className: "ds-dialog__title", children: title }), description && (_jsx(ArkDialog.Description, { className: "ds-dialog__description", children: description }))] }), dismissible && (_jsx(ArkDialog.CloseTrigger, { asChild: true, children: _jsx(IconButton, { icon: closeIcon, "aria-label": closeLabel, variant: "tertiary", size: "sm", className: "ds-dialog__close" }) }))] }), children && _jsx(DialogBody, { children: children }), actions && _jsx("div", { className: "ds-dialog__actions", children: actions })] }) }) })] })] }));
|
|
54
55
|
}
|
|
55
56
|
/**
|
|
56
57
|
* The scrolling body. While its content overflows it joins the tab order, so
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/dialog/dialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAIL,WAAW,EACX,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/dialog/dialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CA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