@cratis/components 4.46.0 → 4.48.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/compat-manifest.json +13 -13
- package/dist/esm/Dialogs/Dialog.d.ts.map +1 -1
- package/dist/esm/Dialogs/Dialog.js +5 -1
- package/dist/esm/Dialogs/Dialog.js.map +1 -1
- package/dist/esm/Dialogs/DialogDocument.d.ts +20 -3
- package/dist/esm/Dialogs/DialogDocument.d.ts.map +1 -1
- package/dist/esm/Dialogs/DialogDocument.js +7 -3
- package/dist/esm/Dialogs/DialogDocument.js.map +1 -1
- package/dist/esm/Dialogs/DialogHeader.d.ts +4 -2
- package/dist/esm/Dialogs/DialogHeader.d.ts.map +1 -1
- package/dist/esm/Dialogs/DialogHeader.js +1 -1
- package/dist/esm/Dialogs/DialogHeader.js.map +1 -1
- package/dist/esm/Dialogs/DialogHost.d.ts +72 -0
- package/dist/esm/Dialogs/DialogHost.d.ts.map +1 -0
- package/dist/esm/Dialogs/DialogHost.js +4 -0
- package/dist/esm/Dialogs/DialogHost.js.map +1 -0
- package/dist/esm/Dialogs/DialogImplementation.d.ts.map +1 -1
- package/dist/esm/Dialogs/DialogImplementation.js +3 -14
- package/dist/esm/Dialogs/DialogImplementation.js.map +1 -1
- package/dist/esm/Dialogs/DialogSlotHost.d.ts +29 -0
- package/dist/esm/Dialogs/DialogSlotHost.d.ts.map +1 -0
- package/dist/esm/Dialogs/DialogSlotHost.js +92 -0
- package/dist/esm/Dialogs/DialogSlotHost.js.map +1 -0
- package/dist/esm/Dialogs/dialogBehavior.d.ts +14 -0
- package/dist/esm/Dialogs/dialogBehavior.d.ts.map +1 -0
- package/dist/esm/Dialogs/dialogBehavior.js +19 -0
- package/dist/esm/Dialogs/dialogBehavior.js.map +1 -0
- package/dist/esm/Dialogs/index.d.ts +1 -0
- package/dist/esm/Dialogs/index.d.ts.map +1 -1
- package/dist/esm/Dialogs/useDialogFocus.d.ts.map +1 -1
- package/dist/esm/Dialogs/useDialogFocus.js +5 -5
- package/dist/esm/Dialogs/useDialogFocus.js.map +1 -1
- package/dist/esm/Filter/useResolvedAnchor.d.ts.map +1 -1
- package/dist/esm/Filter/useResolvedAnchor.js +2 -1
- package/dist/esm/Filter/useResolvedAnchor.js.map +1 -1
- package/dist/esm/renderer/DialogStackContext.d.ts +15 -0
- package/dist/esm/renderer/DialogStackContext.d.ts.map +1 -1
- package/dist/esm/renderer/DialogStackContext.js +2 -1
- package/dist/esm/renderer/DialogStackContext.js.map +1 -1
- package/dist/esm/renderer/OverlayContainerScope.d.ts +36 -0
- package/dist/esm/renderer/OverlayContainerScope.d.ts.map +1 -0
- package/dist/esm/renderer/OverlayContainerScope.js +45 -0
- package/dist/esm/renderer/OverlayContainerScope.js.map +1 -0
- package/dist/esm/renderer/coreSlots.d.ts +2 -1
- package/dist/esm/renderer/coreSlots.d.ts.map +1 -1
- package/dist/esm/renderer/coreSlots.js.map +1 -1
- package/dist/esm/renderer/index.d.ts +4 -3
- package/dist/esm/renderer/index.d.ts.map +1 -1
- package/dist/esm/renderer/index.js +1 -0
- package/dist/esm/renderer/index.js.map +1 -1
- package/dist/esm/renderer/presentation.d.ts +9 -1
- package/dist/esm/renderer/presentation.d.ts.map +1 -1
- package/dist/esm/renderer/presentation.js +1 -0
- package/dist/esm/renderer/presentation.js.map +1 -1
- package/dist/esm/renderer/useOverlayHost.d.ts +15 -0
- package/dist/esm/renderer/useOverlayHost.d.ts.map +1 -0
- package/dist/esm/renderer/useOverlayHost.js +23 -0
- package/dist/esm/renderer/useOverlayHost.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ComponentType } from 'react';
|
|
2
|
+
import type { DialogProps } from './Dialog.js';
|
|
3
|
+
import type { CratisDialogHost, CratisDialogSlotProps } from './DialogHost.js';
|
|
4
|
+
/**
|
|
5
|
+
* Builds the Components-owned host of one adapter-rendered dialog: its stack tier, the dialog
|
|
6
|
+
* result flow, the footer and header actions, initial focus and the refused-confirmation
|
|
7
|
+
* announcement, plus the overlay container its descendants portal through.
|
|
8
|
+
* @param props The dialog's public props.
|
|
9
|
+
* @returns The host handed to the adapter and the overlay container for its descendants.
|
|
10
|
+
*/
|
|
11
|
+
export declare const useDialogHost: (props: DialogProps) => {
|
|
12
|
+
host: CratisDialogHost;
|
|
13
|
+
overlayContainer: import("../renderer/OverlayContainerScope.js").OverlayContainer;
|
|
14
|
+
visible: boolean;
|
|
15
|
+
};
|
|
16
|
+
/** Props of {@link DialogSlotHost}. */
|
|
17
|
+
export interface DialogSlotHostProps {
|
|
18
|
+
/** The adapter's dialog implementation. */
|
|
19
|
+
readonly render: ComponentType<CratisDialogSlotProps>;
|
|
20
|
+
/** The dialog's public props. */
|
|
21
|
+
readonly props: DialogProps;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Renders an adapter-owned dialog with its Components-owned host. Descendants read this dialog's
|
|
25
|
+
* stack tier, see it as their overlay host, and portal through the overlay element the adapter
|
|
26
|
+
* registered.
|
|
27
|
+
*/
|
|
28
|
+
export declare const DialogSlotHost: ({ render, props }: DialogSlotHostProps) => import("react").JSX.Element;
|
|
29
|
+
//# sourceMappingURL=DialogSlotHost.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DialogSlotHost.d.ts","sourceRoot":"","sources":["../../../Dialogs/DialogSlotHost.tsx"],"names":[],"mappings":"AAIA,OAAO,EAA0E,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAMnH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAU,CAAC;AAK5C,OAAO,KAAK,EAA6B,gBAAgB,EAA6B,qBAAqB,EAAE,MAAM,iBAAc,CAAC;AAgDlI;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,UAAW,WAAW;;;;CA8D/C,CAAC;AAEF,uCAAuC;AACvC,MAAM,WAAW,mBAAmB;IAChC,2CAA2C;IAC3C,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,qBAAqB,CAAC,CAAC;IACtD,iCAAiC;IACjC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC/B;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,sBAAuB,mBAAmB,gCAkBpE,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { DialogButtons, DialogResult } from '@cratis/arc.react/dialogs';
|
|
3
|
+
import { createContext, useMemo, createElement, use, useId, useState, useEffect } from 'react';
|
|
4
|
+
import 'react-aria-components/I18nProvider';
|
|
5
|
+
import 'react-aria-components';
|
|
6
|
+
import 'ts-deepmerge';
|
|
7
|
+
import 'react-dom';
|
|
8
|
+
import { useCratisComponentsConfig } from '../configuration/CratisComponentsContext.js';
|
|
9
|
+
import '../Notifications/toast.js';
|
|
10
|
+
import { useCratisIcon } from '../configuration/useCratisIcon.js';
|
|
11
|
+
import '../renderer/RendererContext.js';
|
|
12
|
+
import { DIALOG_ZINDEX_TOKEN } from '../renderer/dialogStack.js';
|
|
13
|
+
import { DialogStackContext, OverlayHostContext } from '../renderer/DialogStackContext.js';
|
|
14
|
+
import { OverlayContainerScope, useOverlayContainer } from '../renderer/OverlayContainerScope.js';
|
|
15
|
+
import { resolveInitialFocus, dismissalFor } from './dialogBehavior.js';
|
|
16
|
+
import { LiveRegion, DialogContent } from './DialogDocument.js';
|
|
17
|
+
import { DialogFooter } from './DialogFooter.js';
|
|
18
|
+
import { HeaderActions } from './DialogHeader.js';
|
|
19
|
+
import { DialogInitialFocus } from './DialogInitialFocus.js';
|
|
20
|
+
import { resolveDialogLabels } from './resolveDialogLabels.js';
|
|
21
|
+
import { useDialogClose } from './useDialogClose.js';
|
|
22
|
+
import { useDialogFocus } from './useDialogFocus.js';
|
|
23
|
+
import { useDialogZIndex } from './useDialogZIndex.js';
|
|
24
|
+
|
|
25
|
+
const useHeaderActions = (props, dialogId, showsCloseButton) => {
|
|
26
|
+
const { dialogHeaderActions } = useCratisComponentsConfig();
|
|
27
|
+
const { headerActions, hideGlobalHeaderActions = false } = props;
|
|
28
|
+
const hasHeaderActions = headerActions != null || (dialogHeaderActions !== undefined && !hideGlobalHeaderActions);
|
|
29
|
+
if (!hasHeaderActions)
|
|
30
|
+
return null;
|
|
31
|
+
return (jsx(HeaderActions, { dialogId: dialogId, title: props.title, headerActions: headerActions, globalHeaderActions: dialogHeaderActions, hideGlobalHeaderActions: hideGlobalHeaderActions, isCommandDialog: props.isCommandDialog ?? false, sliceLocation: props.sliceLocation, showsCloseButton: showsCloseButton, pt: props.pt }));
|
|
32
|
+
};
|
|
33
|
+
const DescendantsMayOpenContext = createContext(true);
|
|
34
|
+
const useDescendantsMayOpen = (visible) => {
|
|
35
|
+
const [opened, setOpened] = useState(false);
|
|
36
|
+
useEffect(() => setOpened(visible), [visible]);
|
|
37
|
+
return visible && opened;
|
|
38
|
+
};
|
|
39
|
+
const mayDismiss = ({ visible, isBusy, dismissal }, source) => visible && !isBusy && dismissal[source];
|
|
40
|
+
const useDialogHost = (props) => {
|
|
41
|
+
const { isBusy = false, buttons = DialogButtons.OkCancel, subtitle } = props;
|
|
42
|
+
const visible = (props.visible ?? true) && use(DescendantsMayOpenContext);
|
|
43
|
+
const { messages } = useCratisComponentsConfig();
|
|
44
|
+
const icon = useCratisIcon();
|
|
45
|
+
const id = useId();
|
|
46
|
+
const subtitleId = useId();
|
|
47
|
+
const labels = resolveDialogLabels(props, messages?.dialog);
|
|
48
|
+
const initialFocus = resolveInitialFocus(props.initialFocus ?? DialogInitialFocus.Confirm, buttons);
|
|
49
|
+
const { allowsOutsideDismissal, allowsEscapeDismissal, showsCloseButton } = dismissalFor(props, isBusy);
|
|
50
|
+
const dismissal = { outside: allowsOutsideDismissal, escape: allowsEscapeDismissal, closeButton: showsCloseButton };
|
|
51
|
+
const zIndex = useDialogZIndex(visible) ?? DIALOG_ZINDEX_TOKEN;
|
|
52
|
+
const overlayContainer = useOverlayContainer(visible);
|
|
53
|
+
const { titleRef, confirmRef, cancelRef, announcement, onRefused } = useDialogFocus({
|
|
54
|
+
visible,
|
|
55
|
+
isBusy,
|
|
56
|
+
initialFocus,
|
|
57
|
+
refusedMessage: labels.refused,
|
|
58
|
+
});
|
|
59
|
+
const handleClose = useDialogClose(props, onRefused);
|
|
60
|
+
const host = {
|
|
61
|
+
id,
|
|
62
|
+
zIndex,
|
|
63
|
+
dismissal,
|
|
64
|
+
closeAriaLabel: labels.closeAria,
|
|
65
|
+
closeIcon: icon('close', '×', props.closeIcon),
|
|
66
|
+
subtitleId,
|
|
67
|
+
hasSubtitle: subtitle !== undefined && subtitle !== null && subtitle !== false,
|
|
68
|
+
titleRef,
|
|
69
|
+
content: (jsx(DialogContent, { visible: visible, isBusy: isBusy, contentStyle: props.contentStyle, pt: props.pt, children: props.children })),
|
|
70
|
+
headerActions: useHeaderActions(props, id, showsCloseButton),
|
|
71
|
+
footer: buttons === null ? null : (jsx(DialogFooter, { buttons: buttons, labels: labels, focus: {
|
|
72
|
+
confirm: initialFocus === DialogInitialFocus.Confirm,
|
|
73
|
+
dismissing: initialFocus === DialogInitialFocus.Cancel,
|
|
74
|
+
}, isBusy: isBusy, isValid: props.isValid !== false, pt: props.pt, confirmRef: confirmRef, cancelRef: cancelRef, onResult: (result) => void handleClose(result) })),
|
|
75
|
+
liveRegion: jsx(LiveRegion, { announcement: announcement }),
|
|
76
|
+
dismiss: (source) => {
|
|
77
|
+
if (mayDismiss({ visible, isBusy, dismissal }, source))
|
|
78
|
+
void handleClose(DialogResult.Cancelled);
|
|
79
|
+
},
|
|
80
|
+
registerOverlayContainer: overlayContainer.register,
|
|
81
|
+
};
|
|
82
|
+
return { host, overlayContainer, visible };
|
|
83
|
+
};
|
|
84
|
+
const DialogSlotHost = ({ render, props }) => {
|
|
85
|
+
const { host, overlayContainer, visible } = useDialogHost(props);
|
|
86
|
+
const descendantsMayOpen = useDescendantsMayOpen(visible);
|
|
87
|
+
const overlayHost = useMemo(() => ({ id: host.id, open: visible, stackZIndex: host.zIndex }), [host.id, visible, host.zIndex]);
|
|
88
|
+
return (jsx(DialogStackContext, { value: host.zIndex, children: jsx(OverlayHostContext, { value: overlayHost, children: jsx(DescendantsMayOpenContext, { value: descendantsMayOpen, children: jsx(OverlayContainerScope, { host: overlayContainer, children: createElement(render, { ...props, visible, host }) }) }) }) }));
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export { DialogSlotHost, useDialogHost };
|
|
92
|
+
//# sourceMappingURL=DialogSlotHost.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DialogSlotHost.js","sources":["../../../Dialogs/DialogSlotHost.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DialogButtons, DialogResult } from '@cratis/arc.react/dialogs';\nimport { createContext, createElement, use, useEffect, useId, useMemo, useState, type ComponentType } from 'react';\nimport { useCratisComponentsConfig } from '../Common/CratisComponentsProvider';\nimport { useCratisIcon } from '../configuration/useCratisIcon';\nimport { DIALOG_ZINDEX_TOKEN } from '../renderer/dialogStack';\nimport { DialogStackContext, OverlayHostContext } from '../renderer/DialogStackContext';\nimport { OverlayContainerScope, useOverlayContainer } from '../renderer/OverlayContainerScope';\nimport type { DialogProps } from './Dialog';\nimport { dismissalFor, resolveInitialFocus } from './dialogBehavior';\nimport { DialogContent, LiveRegion } from './DialogDocument';\nimport { DialogFooter } from './DialogFooter';\nimport { HeaderActions } from './DialogHeader';\nimport type { CratisDialogDismissSource, CratisDialogHost, CratisDialogHostDismissal, CratisDialogSlotProps } from './DialogHost';\nimport { DialogInitialFocus } from './DialogInitialFocus';\nimport { resolveDialogLabels } from './resolveDialogLabels';\nimport { useDialogClose } from './useDialogClose';\nimport { useDialogFocus } from './useDialogFocus';\nimport { useDialogZIndex } from './useDialogZIndex';\n\nconst useHeaderActions = (props: DialogProps, dialogId: string, showsCloseButton: boolean) => {\n const { dialogHeaderActions } = useCratisComponentsConfig();\n const { headerActions, hideGlobalHeaderActions = false } = props;\n const hasHeaderActions =\n headerActions != null || (dialogHeaderActions !== undefined && !hideGlobalHeaderActions);\n if (!hasHeaderActions) return null;\n return (\n <HeaderActions\n dialogId={dialogId}\n title={props.title}\n headerActions={headerActions}\n globalHeaderActions={dialogHeaderActions}\n hideGlobalHeaderActions={hideGlobalHeaderActions}\n isCommandDialog={props.isCommandDialog ?? false}\n sliceLocation={props.sliceLocation}\n showsCloseButton={showsCloseButton}\n pt={props.pt}\n />\n );\n};\n\n// Whether the adapter dialogs rendered inside may open: false until the nearest adapter dialog has\n// committed its own open state, so modals open parent-first, and false as soon as it hides.\nconst DescendantsMayOpenContext = createContext(true);\n\n// Passive effects run children-first, so this runs after the adapter dialog below opened itself.\nconst useDescendantsMayOpen = (visible: boolean) => {\n const [opened, setOpened] = useState(false);\n useEffect(() => setOpened(visible), [visible]);\n return visible && opened;\n};\n\ninterface DismissGuard {\n readonly visible: boolean;\n readonly isBusy: boolean;\n readonly dismissal: CratisDialogHostDismissal;\n}\n\nconst mayDismiss = ({ visible, isBusy, dismissal }: DismissGuard, source: CratisDialogDismissSource) =>\n visible && !isBusy && dismissal[source];\n\n/**\n * Builds the Components-owned host of one adapter-rendered dialog: its stack tier, the dialog\n * result flow, the footer and header actions, initial focus and the refused-confirmation\n * announcement, plus the overlay container its descendants portal through.\n * @param props The dialog's public props.\n * @returns The host handed to the adapter and the overlay container for its descendants.\n */\nexport const useDialogHost = (props: DialogProps) => {\n const { isBusy = false, buttons = DialogButtons.OkCancel, subtitle } = props;\n // A dialog nested in a hidden or still-opening adapter dialog stays closed until its parent is open.\n const visible = (props.visible ?? true) && use(DescendantsMayOpenContext);\n const { messages } = useCratisComponentsConfig();\n const icon = useCratisIcon();\n const id = useId();\n const subtitleId = useId();\n const labels = resolveDialogLabels(props, messages?.dialog);\n const initialFocus = resolveInitialFocus(props.initialFocus ?? DialogInitialFocus.Confirm, buttons);\n const { allowsOutsideDismissal, allowsEscapeDismissal, showsCloseButton } = dismissalFor(props, isBusy);\n const dismissal = { outside: allowsOutsideDismissal, escape: allowsEscapeDismissal, closeButton: showsCloseButton };\n const zIndex = useDialogZIndex(visible) ?? DIALOG_ZINDEX_TOKEN;\n const overlayContainer = useOverlayContainer(visible);\n const { titleRef, confirmRef, cancelRef, announcement, onRefused } = useDialogFocus({\n visible,\n isBusy,\n initialFocus,\n refusedMessage: labels.refused,\n });\n const handleClose = useDialogClose(props, onRefused);\n\n const host: CratisDialogHost = {\n id,\n zIndex,\n dismissal,\n closeAriaLabel: labels.closeAria,\n closeIcon: icon('close', '×', props.closeIcon),\n subtitleId,\n hasSubtitle: subtitle !== undefined && subtitle !== null && subtitle !== false,\n titleRef,\n content: (\n <DialogContent visible={visible} isBusy={isBusy} contentStyle={props.contentStyle} pt={props.pt}>\n {props.children}\n </DialogContent>\n ),\n headerActions: useHeaderActions(props, id, showsCloseButton),\n footer:\n buttons === null ? null : (\n <DialogFooter\n buttons={buttons}\n labels={labels}\n focus={{\n confirm: initialFocus === DialogInitialFocus.Confirm,\n dismissing: initialFocus === DialogInitialFocus.Cancel,\n }}\n isBusy={isBusy}\n isValid={props.isValid !== false}\n pt={props.pt}\n confirmRef={confirmRef}\n cancelRef={cancelRef}\n onResult={(result) => void handleClose(result)}\n />\n ),\n liveRegion: <LiveRegion announcement={announcement} />,\n dismiss: (source) => {\n if (mayDismiss({ visible, isBusy, dismissal }, source)) void handleClose(DialogResult.Cancelled);\n },\n registerOverlayContainer: overlayContainer.register,\n };\n\n return { host, overlayContainer, visible };\n};\n\n/** Props of {@link DialogSlotHost}. */\nexport interface DialogSlotHostProps {\n /** The adapter's dialog implementation. */\n readonly render: ComponentType<CratisDialogSlotProps>;\n /** The dialog's public props. */\n readonly props: DialogProps;\n}\n\n/**\n * Renders an adapter-owned dialog with its Components-owned host. Descendants read this dialog's\n * stack tier, see it as their overlay host, and portal through the overlay element the adapter\n * registered.\n */\nexport const DialogSlotHost = ({ render, props }: DialogSlotHostProps) => {\n const { host, overlayContainer, visible } = useDialogHost(props);\n const descendantsMayOpen = useDescendantsMayOpen(visible);\n const overlayHost = useMemo(\n () => ({ id: host.id, open: visible, stackZIndex: host.zIndex }),\n [host.id, visible, host.zIndex],\n );\n return (\n <DialogStackContext value={host.zIndex}>\n <OverlayHostContext value={overlayHost}>\n <DescendantsMayOpenContext value={descendantsMayOpen}>\n <OverlayContainerScope host={overlayContainer}>\n {createElement(render, { ...props, visible, host })}\n </OverlayContainerScope>\n </DescendantsMayOpenContext>\n </OverlayHostContext>\n </DialogStackContext>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAM,gBAAgB,GAAG,CAAC,KAAkB,EAAE,QAAgB,EAAE,gBAAyB,KAAI;AACzF,IAAA,MAAM,EAAE,mBAAmB,EAAE,GAAG,yBAAyB,EAAE;IAC3D,MAAM,EAAE,aAAa,EAAE,uBAAuB,GAAG,KAAK,EAAE,GAAG,KAAK;AAChE,IAAA,MAAM,gBAAgB,GAClB,aAAa,IAAI,IAAI,KAAK,mBAAmB,KAAK,SAAS,IAAI,CAAC,uBAAuB,CAAC;AAC5F,IAAA,IAAI,CAAC,gBAAgB;AAAE,QAAA,OAAO,IAAI;IAClC,QACIA,IAAC,aAAa,EAAA,EACV,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,aAAa,EAAE,aAAa,EAC5B,mBAAmB,EAAE,mBAAmB,EACxC,uBAAuB,EAAE,uBAAuB,EAChD,eAAe,EAAE,KAAK,CAAC,eAAe,IAAI,KAAK,EAC/C,aAAa,EAAE,KAAK,CAAC,aAAa,EAClC,gBAAgB,EAAE,gBAAgB,EAClC,EAAE,EAAE,KAAK,CAAC,EAAE,EAAA,CACd;AAEV,CAAC;AAID,MAAM,yBAAyB,GAAG,aAAa,CAAC,IAAI,CAAC;AAGrD,MAAM,qBAAqB,GAAG,CAA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,EAAE,kBAAkB,EAAA,QAAA,EAChDA,IAAC,qBAAqB,EAAA,EAAC,IAAI,EAAE,gBAAgB,YACxC,aAAa,CAAC,MAAM,EAAE,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,GAC/B,EAAA,CACA,EAAA,CACX,EAAA,CACJ;AAE7B;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DialogInitialFocus } from './DialogInitialFocus.js';
|
|
2
|
+
import type { DialogProps } from './Dialog.js';
|
|
3
|
+
/**
|
|
4
|
+
* Resolves the initial focus target. A cancel-focused dialog without a dismissing button falls back
|
|
5
|
+
* to focusing the content.
|
|
6
|
+
*/
|
|
7
|
+
export declare const resolveInitialFocus: (initialFocus: DialogInitialFocus, buttons: DialogProps['buttons']) => DialogInitialFocus;
|
|
8
|
+
/** Resolves the dismissal paths of a dialog from its public props. */
|
|
9
|
+
export declare const dismissalFor: (props: DialogProps, isBusy: boolean) => {
|
|
10
|
+
allowsOutsideDismissal: boolean;
|
|
11
|
+
allowsEscapeDismissal: boolean;
|
|
12
|
+
showsCloseButton: boolean;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=dialogBehavior.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialogBehavior.d.ts","sourceRoot":"","sources":["../../../Dialogs/dialogBehavior.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAU,CAAC;AAG5C;;;GAGG;AACH,eAAO,MAAM,mBAAmB,iBAAkB,kBAAkB,WAAW,WAAW,CAAC,SAAS,CAAC,uBAGpG,CAAC;AAEF,sEAAsE;AACtE,eAAO,MAAM,YAAY,UAAW,WAAW,UAAU,OAAO;;;;CAS1D,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DialogButtons } from '@cratis/arc.react/dialogs';
|
|
2
|
+
import { DialogInitialFocus } from './DialogInitialFocus.js';
|
|
3
|
+
import { resolveDialogDismissal } from './resolveDialogDismissal.js';
|
|
4
|
+
|
|
5
|
+
const resolveInitialFocus = (initialFocus, buttons) => {
|
|
6
|
+
const hasDismissingButton = typeof buttons === 'number' && buttons !== DialogButtons.Ok;
|
|
7
|
+
return initialFocus === DialogInitialFocus.Cancel && !hasDismissingButton ? DialogInitialFocus.Content : initialFocus;
|
|
8
|
+
};
|
|
9
|
+
const dismissalFor = (props, isBusy) => resolveDialogDismissal({
|
|
10
|
+
buttons: props.buttons === undefined ? DialogButtons.OkCancel : props.buttons,
|
|
11
|
+
dismissable: props.dismissable,
|
|
12
|
+
dismissOnOutsideClick: props.dismissOnOutsideClick,
|
|
13
|
+
closeOnEscape: props.closeOnEscape,
|
|
14
|
+
showCloseButton: props.showCloseButton,
|
|
15
|
+
isBusy,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export { dismissalFor, resolveInitialFocus };
|
|
19
|
+
//# sourceMappingURL=dialogBehavior.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialogBehavior.js","sources":["../../../Dialogs/dialogBehavior.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DialogButtons } from '@cratis/arc.react/dialogs';\nimport { DialogInitialFocus } from './DialogInitialFocus';\nimport type { DialogProps } from './Dialog';\nimport { resolveDialogDismissal } from './resolveDialogDismissal';\n\n/**\n * Resolves the initial focus target. A cancel-focused dialog without a dismissing button falls back\n * to focusing the content.\n */\nexport const resolveInitialFocus = (initialFocus: DialogInitialFocus, buttons: DialogProps['buttons']) => {\n const hasDismissingButton = typeof buttons === 'number' && buttons !== DialogButtons.Ok;\n return initialFocus === DialogInitialFocus.Cancel && !hasDismissingButton ? DialogInitialFocus.Content : initialFocus;\n};\n\n/** Resolves the dismissal paths of a dialog from its public props. */\nexport const dismissalFor = (props: DialogProps, isBusy: boolean) =>\n resolveDialogDismissal({\n // An explicit null (no footer) must stay null; only an omitted set defaults.\n buttons: props.buttons === undefined ? DialogButtons.OkCancel : props.buttons,\n dismissable: props.dismissable,\n dismissOnOutsideClick: props.dismissOnOutsideClick,\n closeOnEscape: props.closeOnEscape,\n showCloseButton: props.showCloseButton,\n isBusy,\n });\n"],"names":[],"mappings":";;;;MAYa,mBAAmB,GAAG,CAAC,YAAgC,EAAE,OAA+B,KAAI;AACrG,IAAA,MAAM,mBAAmB,GAAG,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,aAAa,CAAC,EAAE;AACvF,IAAA,OAAO,YAAY,KAAK,kBAAkB,CAAC,MAAM,IAAI,CAAC,mBAAmB,GAAG,kBAAkB,CAAC,OAAO,GAAG,YAAY;AACzH;AAGO,MAAM,YAAY,GAAG,CAAC,KAAkB,EAAE,MAAe,KAC5D,sBAAsB,CAAC;AAEnB,IAAA,OAAO,EAAE,KAAK,CAAC,OAAO,KAAK,SAAS,GAAG,aAAa,CAAC,QAAQ,GAAG,KAAK,CAAC,OAAO;IAC7E,WAAW,EAAE,KAAK,CAAC,WAAW;IAC9B,qBAAqB,EAAE,KAAK,CAAC,qBAAqB;IAClD,aAAa,EAAE,KAAK,CAAC,aAAa;IAClC,eAAe,EAAE,KAAK,CAAC,eAAe;IACtC,MAAM;AACT,CAAA;;"}
|
|
@@ -2,6 +2,7 @@ export * from './BusyIndicatorDialog.js';
|
|
|
2
2
|
export * from './ConfirmationDialog.js';
|
|
3
3
|
export * from './Dialog.js';
|
|
4
4
|
export * from './DialogInitialFocus.js';
|
|
5
|
+
export type { CratisDialogDismissSource, CratisDialogHost, CratisDialogHostDismissal, CratisDialogSlotProps, } from './DialogHost.js';
|
|
5
6
|
export type { DialogHeaderContext } from '../configuration/DialogHeaderContext.js';
|
|
6
7
|
export type { DialogHeaderActionsRenderer } from '../configuration/DialogHeaderActionsRenderer.js';
|
|
7
8
|
export type { DialogSliceLocation } from '../configuration/DialogSliceLocation.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../Dialogs/index.ts"],"names":[],"mappings":"AAGA,cAAc,0BAAuB,CAAC;AACtC,cAAc,yBAAsB,CAAC;AACrC,cAAc,aAAU,CAAC;AACzB,cAAc,yBAAsB,CAAC;AACrC,YAAY,EAAE,mBAAmB,EAAE,MAAM,yCAAsC,CAAC;AAChF,YAAY,EAAE,2BAA2B,EAAE,MAAM,iDAA8C,CAAC;AAChG,YAAY,EAAE,mBAAmB,EAAE,MAAM,yCAAsC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../Dialogs/index.ts"],"names":[],"mappings":"AAGA,cAAc,0BAAuB,CAAC;AACtC,cAAc,yBAAsB,CAAC;AACrC,cAAc,aAAU,CAAC;AACzB,cAAc,yBAAsB,CAAC;AACrC,YAAY,EACR,yBAAyB,EACzB,gBAAgB,EAChB,yBAAyB,EACzB,qBAAqB,GACxB,MAAM,iBAAc,CAAC;AACtB,YAAY,EAAE,mBAAmB,EAAE,MAAM,yCAAsC,CAAC;AAChF,YAAY,EAAE,2BAA2B,EAAE,MAAM,iDAA8C,CAAC;AAChG,YAAY,EAAE,mBAAmB,EAAE,MAAM,yCAAsC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDialogFocus.d.ts","sourceRoot":"","sources":["../../../Dialogs/useDialogFocus.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAsB,CAAC;AAE1D,UAAU,kBAAkB;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,kBAAkB,CAAC;IACjC,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED,UAAU,YAAY;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CAChB;AAQD;;;;;GAKG;AACH,eAAO,MAAM,cAAc,sDAAuD,kBAAkB;;;;;;
|
|
1
|
+
{"version":3,"file":"useDialogFocus.d.ts","sourceRoot":"","sources":["../../../Dialogs/useDialogFocus.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAsB,CAAC;AAE1D,UAAU,kBAAkB;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,kBAAkB,CAAC;IACjC,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED,UAAU,YAAY;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CAChB;AAQD;;;;;GAKG;AACH,eAAO,MAAM,cAAc,sDAAuD,kBAAkB;;;;;;CAgDnG,CAAC"}
|
|
@@ -17,12 +17,12 @@ const useDialogFocus = ({ visible, isBusy, initialFocus, refusedMessage }) => {
|
|
|
17
17
|
useEffect(() => {
|
|
18
18
|
if (!visible)
|
|
19
19
|
return;
|
|
20
|
-
const
|
|
21
|
-
? confirmRef.current
|
|
20
|
+
const focusTarget = initialFocus === DialogInitialFocus.Confirm
|
|
21
|
+
? () => confirmRef.current?.focus()
|
|
22
22
|
: initialFocus === DialogInitialFocus.Cancel
|
|
23
|
-
? cancelRef.current
|
|
24
|
-
: titleRef.current;
|
|
25
|
-
const frame = requestAnimationFrame(
|
|
23
|
+
? () => cancelRef.current?.focus()
|
|
24
|
+
: () => focusTitle(titleRef.current);
|
|
25
|
+
const frame = requestAnimationFrame(focusTarget);
|
|
26
26
|
return () => cancelAnimationFrame(frame);
|
|
27
27
|
}, [initialFocus, visible]);
|
|
28
28
|
useEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDialogFocus.js","sources":["../../../Dialogs/useDialogFocus.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useEffect, useRef, useState } from 'react';\nimport { DialogInitialFocus } from './DialogInitialFocus';\n\ninterface DialogFocusOptions {\n visible: boolean;\n isBusy: boolean;\n initialFocus: DialogInitialFocus;\n refusedMessage: string;\n}\n\ninterface Announcement {\n key: number;\n text: string;\n}\n\nconst focusTitle = (title: HTMLHeadingElement | null) => {\n if (!title) return;\n title.tabIndex = -1;\n title.focus();\n};\n\n/**\n * Owns the dialog's focus behavior: initial focus, keeping focus off `<body>` while work is in\n * flight, and returning focus and announcing the outcome after a refused confirm.\n * @param options The dialog's visibility, busy state, resolved initial focus and refusal message.\n * @returns The refs to attach to title and buttons, the live-region announcement and a refusal notifier.\n */\nexport const useDialogFocus = ({ visible, isBusy, initialFocus, refusedMessage }: DialogFocusOptions) => {\n const titleRef = useRef<HTMLHeadingElement>(null);\n const confirmRef = useRef<HTMLButtonElement>(null);\n const cancelRef = useRef<HTMLButtonElement>(null);\n const [refusals, setRefusals] = useState(0);\n const handledRefusals = useRef(0);\n const [announcement, setAnnouncement] = useState<Announcement | null>(null);\n\n useEffect(() => {\n if (!visible) return;\n const
|
|
1
|
+
{"version":3,"file":"useDialogFocus.js","sources":["../../../Dialogs/useDialogFocus.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useEffect, useRef, useState } from 'react';\nimport { DialogInitialFocus } from './DialogInitialFocus';\n\ninterface DialogFocusOptions {\n visible: boolean;\n isBusy: boolean;\n initialFocus: DialogInitialFocus;\n refusedMessage: string;\n}\n\ninterface Announcement {\n key: number;\n text: string;\n}\n\nconst focusTitle = (title: HTMLHeadingElement | null) => {\n if (!title) return;\n title.tabIndex = -1;\n title.focus();\n};\n\n/**\n * Owns the dialog's focus behavior: initial focus, keeping focus off `<body>` while work is in\n * flight, and returning focus and announcing the outcome after a refused confirm.\n * @param options The dialog's visibility, busy state, resolved initial focus and refusal message.\n * @returns The refs to attach to title and buttons, the live-region announcement and a refusal notifier.\n */\nexport const useDialogFocus = ({ visible, isBusy, initialFocus, refusedMessage }: DialogFocusOptions) => {\n const titleRef = useRef<HTMLHeadingElement>(null);\n const confirmRef = useRef<HTMLButtonElement>(null);\n const cancelRef = useRef<HTMLButtonElement>(null);\n const [refusals, setRefusals] = useState(0);\n const handledRefusals = useRef(0);\n const [announcement, setAnnouncement] = useState<Announcement | null>(null);\n\n useEffect(() => {\n if (!visible) return;\n // The title is a heading, so it is made programmatically focusable before it takes focus.\n const focusTarget =\n initialFocus === DialogInitialFocus.Confirm\n ? () => confirmRef.current?.focus()\n : initialFocus === DialogInitialFocus.Cancel\n ? () => cancelRef.current?.focus()\n : () => focusTitle(titleRef.current);\n const frame = requestAnimationFrame(focusTarget);\n return () => cancelAnimationFrame(frame);\n }, [initialFocus, visible]);\n\n // Keyboard focus must never be stranded on <body> while work is in flight: the confirm\n // button stays focusable (aria-disabled), and a focus held by a now-inert field moves to it.\n useEffect(() => {\n if (!visible || !isBusy) return;\n setAnnouncement(null);\n const active = document.activeElement;\n if (active && active !== document.body) return;\n if (confirmRef.current) confirmRef.current.focus();\n else focusTitle(titleRef.current);\n }, [isBusy, visible]);\n\n // A refused confirm (the dialog stays open) returns focus to the confirm button, or to the\n // title when confirm is not enabled, and announces the outcome through the live region.\n useEffect(() => {\n // Each refusal is handled once: a later busy-to-idle change, such as a successful retry,\n // must neither move focus nor announce the earlier refusal again.\n if (refusals === handledRefusals.current || isBusy) return;\n handledRefusals.current = refusals;\n const confirm = confirmRef.current;\n if (confirm && !confirm.disabled) confirm.focus();\n else focusTitle(titleRef.current);\n setAnnouncement({ key: refusals, text: refusedMessage });\n }, [refusals, isBusy, refusedMessage]);\n\n const onRefused = () => setRefusals((count) => count + 1);\n\n return { titleRef, confirmRef, cancelRef, announcement, onRefused };\n};\n"],"names":[],"mappings":";;;AAkBA,MAAM,UAAU,GAAG,CAAC,KAAgC,KAAI;AACpD,IAAA,IAAI,CAAC,KAAK;QAAE;AACZ,IAAA,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AI,UAAU,CAAC,OAAO;AAAE,YAAA,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE;;AAC7C,YAAA,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC;AACrC,IAAA,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAIrB,SAAS,CAAC,MAAK;AAGX,QAAA,IAAI,QAAQ,KAAK,eAAe,CAAC,OAAO,IAAI,MAAM;YAAE;AACpD,QAAA,eAAe,CAAC,OAAO,GAAG,QAAQ;AAClC,QAAA,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO;AAClC,QAAA,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ;YAAE,OAAO,CAAC,KAAK,EAAE;;AAC5C,YAAA,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC;QACjC,eAAe,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;IAC5D,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC;AAEtC,IAAA,MAAM,SAAS,GAAG,MAAM,WAAW,CAAC,CAAC,KAAK,KAAK,KAAK,GAAG,CAAC,CAAC;IAEzD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE;AACvE;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useResolvedAnchor.d.ts","sourceRoot":"","sources":["../../../Filter/useResolvedAnchor.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"useResolvedAnchor.d.ts","sourceRoot":"","sources":["../../../Filter/useResolvedAnchor.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvC,0EAA0E;AAC1E,MAAM,WAAW,cAAc;IAC3B,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACjC,SAAS,EAAE,WAAW,GAAG,IAAI,CAAC;CACjC;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,GAAG,cAAc,GAAG,IAAI,CAYvG"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { useState, useLayoutEffect } from 'react';
|
|
2
2
|
|
|
3
|
+
const MODAL_ROOT_SELECTOR = '[data-cratis-dialog-id]';
|
|
3
4
|
function useResolvedAnchor(anchorRef) {
|
|
4
5
|
const [resolvedAnchor, setResolvedAnchor] = useState(null);
|
|
5
6
|
useLayoutEffect(() => {
|
|
6
7
|
const anchor = anchorRef.current;
|
|
7
|
-
const modalRoot = anchor?.closest(
|
|
8
|
+
const modalRoot = anchor?.closest(MODAL_ROOT_SELECTOR) ?? null;
|
|
8
9
|
setResolvedAnchor((previous) => previous?.anchor === anchor && previous.modalRoot === modalRoot
|
|
9
10
|
? previous
|
|
10
11
|
: { anchor, modalRoot });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useResolvedAnchor.js","sources":["../../../Filter/useResolvedAnchor.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useLayoutEffect, useState } from 'react';\nimport type { RefObject } from 'react';\n\n/** The anchor element and the Cratis Dialog (if any) that contains it. */\nexport interface ResolvedAnchor {\n anchor: HTMLButtonElement | null;\n modalRoot: HTMLElement | null;\n}\n\n/**\n * Resolves the anchor element and its enclosing modal after commit.\n *\n * Refs attach during commit, after render. Resolving the modal before mounting any open\n * panel keeps its first portal from landing in a shared root hidden by the modal.\n *\n * @param anchorRef - The anchor button's ref.\n * @returns The resolved anchor, or null before the first commit.\n */\nexport function useResolvedAnchor(anchorRef: RefObject<HTMLButtonElement | null>): ResolvedAnchor | null {\n const [resolvedAnchor, setResolvedAnchor] = useState<ResolvedAnchor | null>(null);\n // Ref attachment/identity can change on any commit; the state updater bails out if unchanged.\n // eslint-disable-next-line @eslint-react/exhaustive-deps\n useLayoutEffect(() => {\n const anchor = anchorRef.current;\n const modalRoot = anchor?.closest<HTMLElement>(
|
|
1
|
+
{"version":3,"file":"useResolvedAnchor.js","sources":["../../../Filter/useResolvedAnchor.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useLayoutEffect, useState } from 'react';\nimport type { RefObject } from 'react';\n\n// Every dialog shell, built-in or adapter-rendered, marks its root with the dialog's id.\nconst MODAL_ROOT_SELECTOR = '[data-cratis-dialog-id]';\n\n/** The anchor element and the Cratis Dialog (if any) that contains it. */\nexport interface ResolvedAnchor {\n anchor: HTMLButtonElement | null;\n modalRoot: HTMLElement | null;\n}\n\n/**\n * Resolves the anchor element and its enclosing modal after commit.\n *\n * Refs attach during commit, after render. Resolving the modal before mounting any open\n * panel keeps its first portal from landing in a shared root hidden by the modal.\n *\n * @param anchorRef - The anchor button's ref.\n * @returns The resolved anchor, or null before the first commit.\n */\nexport function useResolvedAnchor(anchorRef: RefObject<HTMLButtonElement | null>): ResolvedAnchor | null {\n const [resolvedAnchor, setResolvedAnchor] = useState<ResolvedAnchor | null>(null);\n // Ref attachment/identity can change on any commit; the state updater bails out if unchanged.\n // eslint-disable-next-line @eslint-react/exhaustive-deps\n useLayoutEffect(() => {\n const anchor = anchorRef.current;\n const modalRoot = anchor?.closest<HTMLElement>(MODAL_ROOT_SELECTOR) ?? null;\n setResolvedAnchor((previous) => previous?.anchor === anchor && previous.modalRoot === modalRoot\n ? previous\n : { anchor, modalRoot });\n });\n return resolvedAnchor;\n}\n"],"names":[],"mappings":";;AAOA,MAAM,mBAAmB,GAAG,yBAAyB;AAiB/C,SAAU,iBAAiB,CAAC,SAA8C,EAAA;IAC5E,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAwB,IAAI,CAAC;IAGjF,eAAe,CAAC,MAAK;AACjB,QAAA,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO;QAChC,MAAM,SAAS,GAAG,MAAM,EAAE,OAAO,CAAc,mBAAmB,CAAC,IAAI,IAAI;AAC3E,QAAA,iBAAiB,CAAC,CAAC,QAAQ,KAAK,QAAQ,EAAE,MAAM,KAAK,MAAM,IAAI,QAAQ,CAAC,SAAS,KAAK;AAClF,cAAE;AACF,cAAE,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AAChC,IAAA,CAAC,CAAC;AACF,IAAA,OAAO,cAAc;AACzB;;"}
|
|
@@ -9,6 +9,21 @@
|
|
|
9
9
|
* its own stacking order. Compose onto it with `zIndexAboveDialog` rather than doing arithmetic.
|
|
10
10
|
*/
|
|
11
11
|
export declare const DialogStackContext: import("react").Context<string | null>;
|
|
12
|
+
/**
|
|
13
|
+
* The overlay host an overlay-producing descendant opened in. Unlike {@link DialogStackContext}, it
|
|
14
|
+
* carries the host's identity and whether it is still open, so a descendant can tell a closed host
|
|
15
|
+
* from an open one even though both resolve to the same z-index token.
|
|
16
|
+
*/
|
|
17
|
+
export interface OverlayHostState {
|
|
18
|
+
/** Unique per host instance, so a reused stacking tier can never alias two hosts. */
|
|
19
|
+
readonly id: string;
|
|
20
|
+
/** False from the moment the host starts closing, while its children are still mounted. */
|
|
21
|
+
readonly open: boolean;
|
|
22
|
+
/** The host's resolved z-index, as a CSS expression. */
|
|
23
|
+
readonly stackZIndex: string;
|
|
24
|
+
}
|
|
25
|
+
/** The nearest ancestor overlay host, or `null` when rendered outside any host. */
|
|
26
|
+
export declare const OverlayHostContext: import("react").Context<OverlayHostState | null>;
|
|
12
27
|
/** Reads the nearest ancestor dialog's resolved z-index. `null` when not nested in a dialog. */
|
|
13
28
|
export declare const useNearestDialogZIndex: () => string | null;
|
|
14
29
|
//# sourceMappingURL=DialogStackContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogStackContext.d.ts","sourceRoot":"","sources":["../../../renderer/DialogStackContext.ts"],"names":[],"mappings":"AAKA;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,wCAAqC,CAAC;AAErE,gGAAgG;AAChG,eAAO,MAAM,sBAAsB,QAAO,MAAM,GAAG,IAAsC,CAAC"}
|
|
1
|
+
{"version":3,"file":"DialogStackContext.d.ts","sourceRoot":"","sources":["../../../renderer/DialogStackContext.ts"],"names":[],"mappings":"AAKA;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,wCAAqC,CAAC;AAErE;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC7B,qFAAqF;IACrF,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,2FAA2F;IAC3F,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,wDAAwD;IACxD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAChC;AAED,mFAAmF;AACnF,eAAO,MAAM,kBAAkB,kDAA+C,CAAC;AAE/E,gGAAgG;AAChG,eAAO,MAAM,sBAAsB,QAAO,MAAM,GAAG,IAAsC,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { createContext, useContext } from 'react';
|
|
2
2
|
|
|
3
3
|
const DialogStackContext = createContext(null);
|
|
4
|
+
const OverlayHostContext = createContext(null);
|
|
4
5
|
const useNearestDialogZIndex = () => useContext(DialogStackContext);
|
|
5
6
|
|
|
6
|
-
export { DialogStackContext, useNearestDialogZIndex };
|
|
7
|
+
export { DialogStackContext, OverlayHostContext, useNearestDialogZIndex };
|
|
7
8
|
//# sourceMappingURL=DialogStackContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogStackContext.js","sources":["../../../renderer/DialogStackContext.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { createContext, useContext } from 'react';\n\n/**\n * The resolved z-index of the nearest ancestor {@link DialogImplementation}, or `null` when\n * rendered outside any dialog. Overlay-producing descendants (dropdown popovers, date-picker\n * popovers, tooltips, filter menus) read this to stack themselves above their owning dialog instead\n * of relying on the static overlay token, which does not account for dialog nesting depth.\n *\n * This is a CSS expression rather than a number - it stays relative to the `--cratis-z-index-dialog`\n * token so an application that retunes that token keeps its dialogs, and everything they host, in\n * its own stacking order. Compose onto it with `zIndexAboveDialog` rather than doing arithmetic.\n */\nexport const DialogStackContext = createContext<string | null>(null);\n\n/** Reads the nearest ancestor dialog's resolved z-index. `null` when not nested in a dialog. */\nexport const useNearestDialogZIndex = (): string | null => useContext(DialogStackContext);\n"],"names":[],"mappings":";;MAea,kBAAkB,GAAG,aAAa,CAAgB,IAAI;
|
|
1
|
+
{"version":3,"file":"DialogStackContext.js","sources":["../../../renderer/DialogStackContext.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { createContext, useContext } from 'react';\n\n/**\n * The resolved z-index of the nearest ancestor {@link DialogImplementation}, or `null` when\n * rendered outside any dialog. Overlay-producing descendants (dropdown popovers, date-picker\n * popovers, tooltips, filter menus) read this to stack themselves above their owning dialog instead\n * of relying on the static overlay token, which does not account for dialog nesting depth.\n *\n * This is a CSS expression rather than a number - it stays relative to the `--cratis-z-index-dialog`\n * token so an application that retunes that token keeps its dialogs, and everything they host, in\n * its own stacking order. Compose onto it with `zIndexAboveDialog` rather than doing arithmetic.\n */\nexport const DialogStackContext = createContext<string | null>(null);\n\n/**\n * The overlay host an overlay-producing descendant opened in. Unlike {@link DialogStackContext}, it\n * carries the host's identity and whether it is still open, so a descendant can tell a closed host\n * from an open one even though both resolve to the same z-index token.\n */\nexport interface OverlayHostState {\n /** Unique per host instance, so a reused stacking tier can never alias two hosts. */\n readonly id: string;\n /** False from the moment the host starts closing, while its children are still mounted. */\n readonly open: boolean;\n /** The host's resolved z-index, as a CSS expression. */\n readonly stackZIndex: string;\n}\n\n/** The nearest ancestor overlay host, or `null` when rendered outside any host. */\nexport const OverlayHostContext = createContext<OverlayHostState | null>(null);\n\n/** Reads the nearest ancestor dialog's resolved z-index. `null` when not nested in a dialog. */\nexport const useNearestDialogZIndex = (): string | null => useContext(DialogStackContext);\n"],"names":[],"mappings":";;MAea,kBAAkB,GAAG,aAAa,CAAgB,IAAI;MAiBtD,kBAAkB,GAAG,aAAa,CAA0B,IAAI;AAGtE,MAAM,sBAAsB,GAAG,MAAqB,UAAU,CAAC,kBAAkB;;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { CratisOverlayEnvironment } from './overlayEnvironment.js';
|
|
3
|
+
/** One overlay container: the element it registered and the registration callback it hands out. */
|
|
4
|
+
export interface OverlayContainer {
|
|
5
|
+
/** Overlay environment its descendants portal through. */
|
|
6
|
+
readonly environment: CratisOverlayEnvironment;
|
|
7
|
+
/**
|
|
8
|
+
* Registers the element descendant overlays portal into, or clears it with `null`. The callback
|
|
9
|
+
* is bound to one open session of one host: once the host closes it is replaced, so a stale
|
|
10
|
+
* callback can never re-register an element on a host that has since reopened.
|
|
11
|
+
*/
|
|
12
|
+
readonly register: (element: HTMLElement | null) => void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Creates the overlay container for one atomic overlay, such as an adapter dialog rendered in the
|
|
16
|
+
* browser top layer. While the host is open and an element is registered, its descendants portal
|
|
17
|
+
* into that element, so they stay visible and interactive above the host; before registration they
|
|
18
|
+
* keep the surrounding environment. While the host is closed its descendants get no container, so
|
|
19
|
+
* an overlay left open inside it never escapes into the surrounding page. The registration lives in
|
|
20
|
+
* this hook only: it is dropped when the host closes or unmounts and never leaks to another host.
|
|
21
|
+
* @param open Whether the host is currently open.
|
|
22
|
+
* @returns The host's overlay environment and registration callback.
|
|
23
|
+
*/
|
|
24
|
+
export declare const useOverlayContainer: (open: boolean) => OverlayContainer;
|
|
25
|
+
/** Props for {@link OverlayContainerScope}. */
|
|
26
|
+
export interface OverlayContainerScopeProps {
|
|
27
|
+
/** The overlay container whose environment the children portal through. */
|
|
28
|
+
readonly host: OverlayContainer;
|
|
29
|
+
readonly children: ReactNode;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Provides an overlay container's environment to its descendants, keeping every other renderer setting
|
|
33
|
+
* of the surrounding provider. Without a surrounding renderer the children render unchanged.
|
|
34
|
+
*/
|
|
35
|
+
export declare const OverlayContainerScope: ({ host, children }: OverlayContainerScopeProps) => string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | Iterable<ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | null | undefined> | null | undefined;
|
|
36
|
+
//# sourceMappingURL=OverlayContainerScope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OverlayContainerScope.d.ts","sourceRoot":"","sources":["../../../renderer/OverlayContainerScope.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yBAAsB,CAAC;AAMrE,mGAAmG;AACnG,MAAM,WAAW,gBAAgB;IAC7B,0DAA0D;IAC1D,QAAQ,CAAC,WAAW,EAAE,wBAAwB,CAAC;IAC/C;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;CAC5D;AASD;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,SAAU,OAAO,KAAG,gBAsCnD,CAAC;AAEF,+CAA+C;AAC/C,MAAM,WAAW,0BAA0B;IACvC,2EAA2E;IAC3E,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;CAChC;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,uBAAwB,0BAA0B,gUAQnF,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { use, useMemo, useState, useCallback } from 'react';
|
|
3
|
+
import { unstable_RendererContext, unstable_useOverlayEnvironment } from './RendererContext.js';
|
|
4
|
+
|
|
5
|
+
const closedSession = Object.freeze({ id: -1, element: null });
|
|
6
|
+
const useOverlayContainer = (open) => {
|
|
7
|
+
const parent = unstable_useOverlayEnvironment();
|
|
8
|
+
const [sessionCount, setSessionCount] = useState(0);
|
|
9
|
+
const [openedFor, setOpenedFor] = useState(open);
|
|
10
|
+
const [session, setSession] = useState(closedSession);
|
|
11
|
+
if (open !== openedFor) {
|
|
12
|
+
setOpenedFor(open);
|
|
13
|
+
if (open)
|
|
14
|
+
setSessionCount((count) => count + 1);
|
|
15
|
+
setSession(closedSession);
|
|
16
|
+
}
|
|
17
|
+
const register = useCallback((element) => setSession((current) => {
|
|
18
|
+
if (current.id > sessionCount)
|
|
19
|
+
return current;
|
|
20
|
+
if (!open)
|
|
21
|
+
return closedSession;
|
|
22
|
+
if (element === null)
|
|
23
|
+
return current.id === sessionCount ? closedSession : current;
|
|
24
|
+
return { id: sessionCount, element };
|
|
25
|
+
}), [open, sessionCount]);
|
|
26
|
+
const element = open && session.id === sessionCount ? session.element : null;
|
|
27
|
+
const environment = useMemo(() => Object.freeze({
|
|
28
|
+
getContainer: () => {
|
|
29
|
+
if (!open)
|
|
30
|
+
return null;
|
|
31
|
+
return element?.isConnected ? element : parent.getContainer();
|
|
32
|
+
},
|
|
33
|
+
}), [element, open, parent]);
|
|
34
|
+
return useMemo(() => ({ environment, register }), [environment, register]);
|
|
35
|
+
};
|
|
36
|
+
const OverlayContainerScope = ({ host, children }) => {
|
|
37
|
+
const parent = use(unstable_RendererContext);
|
|
38
|
+
const value = useMemo(() => (parent ? Object.freeze({ ...parent, overlayEnvironment: host.environment }) : undefined), [host.environment, parent]);
|
|
39
|
+
if (!value)
|
|
40
|
+
return children;
|
|
41
|
+
return jsx(unstable_RendererContext, { value: value, children: children });
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export { OverlayContainerScope, useOverlayContainer };
|
|
45
|
+
//# sourceMappingURL=OverlayContainerScope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OverlayContainerScope.js","sources":["../../../renderer/OverlayContainerScope.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { use, useCallback, useMemo, useState, type ReactNode } from 'react';\nimport type { CratisOverlayEnvironment } from './overlayEnvironment';\nimport {\n unstable_RendererContext as RendererContext,\n unstable_useOverlayEnvironment,\n} from './RendererContext';\n\n/** One overlay container: the element it registered and the registration callback it hands out. */\nexport interface OverlayContainer {\n /** Overlay environment its descendants portal through. */\n readonly environment: CratisOverlayEnvironment;\n /**\n * Registers the element descendant overlays portal into, or clears it with `null`. The callback\n * is bound to one open session of one host: once the host closes it is replaced, so a stale\n * callback can never re-register an element on a host that has since reopened.\n */\n readonly register: (element: HTMLElement | null) => void;\n}\n\ninterface Session {\n readonly id: number;\n readonly element: HTMLElement | null;\n}\n\nconst closedSession: Session = Object.freeze({ id: -1, element: null });\n\n/**\n * Creates the overlay container for one atomic overlay, such as an adapter dialog rendered in the\n * browser top layer. While the host is open and an element is registered, its descendants portal\n * into that element, so they stay visible and interactive above the host; before registration they\n * keep the surrounding environment. While the host is closed its descendants get no container, so\n * an overlay left open inside it never escapes into the surrounding page. The registration lives in\n * this hook only: it is dropped when the host closes or unmounts and never leaks to another host.\n * @param open Whether the host is currently open.\n * @returns The host's overlay environment and registration callback.\n */\nexport const useOverlayContainer = (open: boolean): OverlayContainer => {\n const parent = unstable_useOverlayEnvironment();\n const [sessionCount, setSessionCount] = useState(0);\n const [openedFor, setOpenedFor] = useState(open);\n const [session, setSession] = useState<Session>(closedSession);\n\n // A host that opens again starts a new session; closing drops the registered element.\n if (open !== openedFor) {\n setOpenedFor(open);\n if (open) setSessionCount((count) => count + 1);\n setSession(closedSession);\n }\n\n const register = useCallback(\n (element: HTMLElement | null) =>\n setSession((current) => {\n // A callback from an earlier session never touches a newer session's registration.\n if (current.id > sessionCount) return current;\n if (!open) return closedSession;\n if (element === null) return current.id === sessionCount ? closedSession : current;\n return { id: sessionCount, element };\n }),\n [open, sessionCount],\n );\n\n const element = open && session.id === sessionCount ? session.element : null;\n const environment = useMemo<CratisOverlayEnvironment>(\n () =>\n Object.freeze({\n getContainer: () => {\n if (!open) return null;\n return element?.isConnected ? element : parent.getContainer();\n },\n }),\n [element, open, parent],\n );\n\n return useMemo(() => ({ environment, register }), [environment, register]);\n};\n\n/** Props for {@link OverlayContainerScope}. */\nexport interface OverlayContainerScopeProps {\n /** The overlay container whose environment the children portal through. */\n readonly host: OverlayContainer;\n readonly children: ReactNode;\n}\n\n/**\n * Provides an overlay container's environment to its descendants, keeping every other renderer setting\n * of the surrounding provider. Without a surrounding renderer the children render unchanged.\n */\nexport const OverlayContainerScope = ({ host, children }: OverlayContainerScopeProps) => {\n const parent = use(RendererContext);\n const value = useMemo(\n () => (parent ? Object.freeze({ ...parent, overlayEnvironment: host.environment }) : undefined),\n [host.environment, parent],\n );\n if (!value) return children;\n return <RendererContext value={value}>{children}</RendererContext>;\n};\n"],"names":["RendererContext","_jsx"],"mappings":";;;;AA2BA,MAAM,aAAa,GAAY,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAYhE,MAAM,mBAAmB,GAAG,CAAC,IAAa,KAAsB;AACnE,IAAA,MAAM,MAAM,GAAG,8BAA8B,EAAE;IAC/C,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;IACnD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC;IAChD,MAAM,CAAC,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AAM,qBAAqB,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAA8B,KAAI;AACpF,IAAA,MAAM,MAAM,GAAG,GAAG,CAACA,wBAAe,CAAC;AACnC,IAAA,MAAM,KAAK,GAAG,OAAO,CACjB,OAAO,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,EAAE,kBAAkB,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,SAAS,CAAC,EAC/F,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAC7B;AACD,IAAA,IAAI,CAAC,KAAK;AAAE,QAAA,OAAO,QAAQ;IAC3B,OAAOC,GAAA,CAACD,wBAAe,EAAA,EAAC,KAAK,EAAE,KAAK,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAmB;AACtE;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ComponentType } from 'react';
|
|
2
|
+
import type { CratisDialogSlotProps } from '../Dialogs/DialogHost.js';
|
|
2
3
|
import type { unstable_BehaviorMode } from './slots.js';
|
|
3
4
|
/**
|
|
4
5
|
* Complete Core slot inventory for renderer ABI proof and conformance tests only.
|
|
@@ -65,7 +66,7 @@ export declare const unstable_coreSlots: Readonly<{
|
|
|
65
66
|
'dialogs.dialog': Readonly<{
|
|
66
67
|
mode: unstable_BehaviorMode;
|
|
67
68
|
fidelity: 'native';
|
|
68
|
-
render: ComponentType<
|
|
69
|
+
render: ComponentType<CratisDialogSlotProps>;
|
|
69
70
|
}>;
|
|
70
71
|
'display.datePicker': Readonly<{
|
|
71
72
|
mode: unstable_BehaviorMode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreSlots.d.ts","sourceRoot":"","sources":["../../../renderer/coreSlots.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"coreSlots.d.ts","sourceRoot":"","sources":["../../../renderer/coreSlots.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAa3C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAAuB,CAAC;AAGnE,OAAO,KAAK,EACR,qBAAqB,EAExB,MAAM,YAAS,CAAC;AAOjB;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;;kBARM,QAAQ;;;;;kBAAR,QAAQ;;;;;kBAAR,QAAQ;;;;;kBAAR,QAAQ;;;;;kBAAR,QAAQ;;;;;kBAAR,QAAQ;;;;;kBAAR,QAAQ;;;;;kBAAR,QAAQ;;;;;kBAAR,QAAQ;;;;;kBAAR,QAAQ;;;;;kBAAR,QAAQ;;;;;kBAAR,QAAQ;;;;;kBAAR,QAAQ;;;;;kBAAR,QAAQ;;;EA0BhB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreSlots.js","sources":["../../../renderer/coreSlots.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { ComponentType } from 'react';\nimport { ButtonImplementation } from '../Common/ButtonImplementation';\nimport { CheckboxImplementation } from '../Common/CheckboxImplementation';\nimport { DatePickerInputImplementation } from '../Common/DatePickerInputImplementation';\nimport { IconButtonImplementation } from '../Common/IconButtonImplementation';\nimport { RadioImplementation } from '../Common/RadioImplementation';\nimport { SurfaceImplementation } from '../Common/SurfaceImplementation';\nimport { SwitchImplementation } from '../Common/SwitchImplementation';\nimport { TextAreaImplementation } from '../Common/TextAreaImplementation';\nimport { TextInputImplementation } from '../Common/TextInputImplementation';\nimport { TooltipImplementation } from '../Common/TooltipImplementation';\nimport { TablePaginatorImplementation } from '../DataTables/TablePaginatorImplementation';\nimport { ProgressBarImplementation } from '../Display/ProgressBarImplementation';\nimport { DialogImplementation } from '../Dialogs/DialogImplementation';\nimport { DropdownImplementation } from '../Dropdown/DropdownImplementation';\nimport type {\n unstable_BehaviorMode,\n unstable_SlotMap,\n} from './slots';\n\nconst nativeDeclaration = <Props>(\n mode: unstable_BehaviorMode,\n render: ComponentType<Props>,\n) => Object.freeze({ mode, fidelity: 'native' as const, render });\n\n/**\n * Complete Core slot inventory for renderer ABI proof and conformance tests only.\n *\n * Every facade owns its local Core declaration, so neither the setup-only provider nor the public\n * renderer barrel may import this private all-family table.\n */\nexport const unstable_coreSlots = Object.freeze({\n 'common.button': nativeDeclaration('presentation', ButtonImplementation),\n 'common.iconButton': nativeDeclaration(\n 'presentation',\n IconButtonImplementation,\n ),\n 'common.textInput': nativeDeclaration('presentation', TextInputImplementation),\n 'common.textArea': nativeDeclaration('presentation', TextAreaImplementation),\n 'common.checkbox': nativeDeclaration('presentation', CheckboxImplementation),\n 'common.radio': nativeDeclaration('presentation', RadioImplementation),\n 'common.switch': nativeDeclaration('presentation', SwitchImplementation),\n 'common.progress': nativeDeclaration('presentation', ProgressBarImplementation),\n 'common.surface': nativeDeclaration('presentation', SurfaceImplementation),\n 'common.tooltip': nativeDeclaration('atomic', TooltipImplementation),\n 'dropdown.select': nativeDeclaration('atomic', DropdownImplementation),\n 'dialogs.dialog': nativeDeclaration('atomic', DialogImplementation),\n 'display.datePicker': nativeDeclaration('atomic', DatePickerInputImplementation),\n 'datatables.paginator': nativeDeclaration('atomic', TablePaginatorImplementation),\n}) satisfies unstable_SlotMap;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"coreSlots.js","sources":["../../../renderer/coreSlots.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { ComponentType } from 'react';\nimport { ButtonImplementation } from '../Common/ButtonImplementation';\nimport { CheckboxImplementation } from '../Common/CheckboxImplementation';\nimport { DatePickerInputImplementation } from '../Common/DatePickerInputImplementation';\nimport { IconButtonImplementation } from '../Common/IconButtonImplementation';\nimport { RadioImplementation } from '../Common/RadioImplementation';\nimport { SurfaceImplementation } from '../Common/SurfaceImplementation';\nimport { SwitchImplementation } from '../Common/SwitchImplementation';\nimport { TextAreaImplementation } from '../Common/TextAreaImplementation';\nimport { TextInputImplementation } from '../Common/TextInputImplementation';\nimport { TooltipImplementation } from '../Common/TooltipImplementation';\nimport { TablePaginatorImplementation } from '../DataTables/TablePaginatorImplementation';\nimport { ProgressBarImplementation } from '../Display/ProgressBarImplementation';\nimport type { CratisDialogSlotProps } from '../Dialogs/DialogHost';\nimport { DialogImplementation } from '../Dialogs/DialogImplementation';\nimport { DropdownImplementation } from '../Dropdown/DropdownImplementation';\nimport type {\n unstable_BehaviorMode,\n unstable_SlotMap,\n} from './slots';\n\nconst nativeDeclaration = <Props>(\n mode: unstable_BehaviorMode,\n render: ComponentType<Props>,\n) => Object.freeze({ mode, fidelity: 'native' as const, render });\n\n/**\n * Complete Core slot inventory for renderer ABI proof and conformance tests only.\n *\n * Every facade owns its local Core declaration, so neither the setup-only provider nor the public\n * renderer barrel may import this private all-family table.\n */\nexport const unstable_coreSlots = Object.freeze({\n 'common.button': nativeDeclaration('presentation', ButtonImplementation),\n 'common.iconButton': nativeDeclaration(\n 'presentation',\n IconButtonImplementation,\n ),\n 'common.textInput': nativeDeclaration('presentation', TextInputImplementation),\n 'common.textArea': nativeDeclaration('presentation', TextAreaImplementation),\n 'common.checkbox': nativeDeclaration('presentation', CheckboxImplementation),\n 'common.radio': nativeDeclaration('presentation', RadioImplementation),\n 'common.switch': nativeDeclaration('presentation', SwitchImplementation),\n 'common.progress': nativeDeclaration('presentation', ProgressBarImplementation),\n 'common.surface': nativeDeclaration('presentation', SurfaceImplementation),\n 'common.tooltip': nativeDeclaration('atomic', TooltipImplementation),\n 'dropdown.select': nativeDeclaration('atomic', DropdownImplementation),\n 'dialogs.dialog': nativeDeclaration<CratisDialogSlotProps>('atomic', DialogImplementation),\n 'display.datePicker': nativeDeclaration('atomic', DatePickerInputImplementation),\n 'datatables.paginator': nativeDeclaration('atomic', TablePaginator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|
|
@@ -10,7 +10,7 @@ import type { TextInputProps } from '../Common/TextInput.js';
|
|
|
10
10
|
import type { TooltipProps } from '../Common/Tooltip.js';
|
|
11
11
|
import type { TablePaginatorProps } from '../DataTables/TablePaginator.js';
|
|
12
12
|
import type { ProgressBarProps } from '../Display/ProgressBar.js';
|
|
13
|
-
import type {
|
|
13
|
+
import type { CratisDialogSlotProps } from '../Dialogs/DialogHost.js';
|
|
14
14
|
import type { DropdownProps } from '../Dropdown/Dropdown.js';
|
|
15
15
|
/** Core-owned slot contracts loaded only by the renderer subpath. */
|
|
16
16
|
declare module './slots.js' {
|
|
@@ -37,8 +37,8 @@ declare module './slots.js' {
|
|
|
37
37
|
'common.tooltip': TooltipProps;
|
|
38
38
|
/** Interaction-heavy select/dropdown contract. */
|
|
39
39
|
'dropdown.select': DropdownProps<unknown>;
|
|
40
|
-
/** Interaction-heavy modal dialog contract. */
|
|
41
|
-
'dialogs.dialog':
|
|
40
|
+
/** Interaction-heavy modal dialog contract: the public props plus the Components-owned host. */
|
|
41
|
+
'dialogs.dialog': CratisDialogSlotProps;
|
|
42
42
|
/** Interaction-heavy date-picker contract. */
|
|
43
43
|
'display.datePicker': DatePickerInputProps;
|
|
44
44
|
/** Interaction-heavy, composite-adjacent table paginator contract. */
|
|
@@ -56,6 +56,7 @@ export { unstable_CRATIS_UI_ABI_VERSION, unstable_composeUiLibraries, unstable_d
|
|
|
56
56
|
export { unstable_defaultOverlayEnvironment, type CratisOverlayEnvironment, type unstable_CratisOverlayEnvironment, } from './overlayEnvironment.js';
|
|
57
57
|
export { CRATIS_PRESENTATION_ABI_VERSION, CRATIS_PRESENTATION_PROFILE, cratisPresentationSlotIds, definePresentationUiLibrary, type CratisPresentationCapabilities, type CratisPresentationCapabilityId, type CratisPresentationSlotDeclaration, type CratisPresentationSlotId, type CratisPresentationSlotMap, type CratisPresentationSlots, type CratisPresentationUiLibrary, cratisAtomicSlotIds, type CratisAtomicSlotDeclaration, type CratisAtomicSlotId, type CratisAtomicSlotMap, type CratisAtomicSlots, } from './presentation.js';
|
|
58
58
|
export { unstable_useCapability, unstable_useOverlayEnvironment, unstable_useRendererId, } from './RendererContext.js';
|
|
59
|
+
export { unstable_useOverlayHost, type unstable_OverlayHost } from './useOverlayHost.js';
|
|
59
60
|
export { unstable_RendererScope, type unstable_RendererScopeProps, } from './RendererScope.js';
|
|
60
61
|
export type { unstable_BehaviorMode, unstable_CratisSlots, unstable_Fidelity, unstable_SlotDeclaration, unstable_SlotId, unstable_SlotMap, } from './slots.js';
|
|
61
62
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../renderer/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAA8B,CAAC;AACxE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../ren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AAsB,EACtB,8BAA8B,EAC9B,sBAAsB,GACzB,MAAM,sBAAmB,CAAC;AAC3B,OAAO,EAAE,uBAAuB,EAAE,KAAK,oBAAoB,EAAE,MAAM,qBAAkB,CAAC;AACtF,OAAO,EACH,sBAAsB,EACtB,KAAK,2BAA2B,GACnC,MAAM,oBAAiB,CAAC;AACzB,YAAY,EACR,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,wBAAwB,EACxB,eAAe,EACf,gBAAgB,GACnB,MAAM,YAAS,CAAC"}
|
|
@@ -3,5 +3,6 @@ export { unstable_CRATIS_UI_ABI_VERSION, unstable_composeUiLibraries, unstable_d
|
|
|
3
3
|
export { unstable_defaultOverlayEnvironment } from './overlayEnvironment.js';
|
|
4
4
|
export { CRATIS_PRESENTATION_ABI_VERSION, CRATIS_PRESENTATION_PROFILE, cratisAtomicSlotIds, cratisPresentationSlotIds, definePresentationUiLibrary } from './presentation.js';
|
|
5
5
|
export { unstable_useCapability, unstable_useOverlayEnvironment, unstable_useRendererId } from './RendererContext.js';
|
|
6
|
+
export { unstable_useOverlayHost } from './useOverlayHost.js';
|
|
6
7
|
export { unstable_RendererScope } from './RendererScope.js';
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -10,6 +10,7 @@ import type { TextAreaProps } from '../Common/TextArea.js';
|
|
|
10
10
|
import type { TextInputProps } from '../Common/TextInput.js';
|
|
11
11
|
import type { TooltipProps } from '../Common/Tooltip.js';
|
|
12
12
|
import type { TablePaginatorProps } from '../DataTables/TablePaginator.js';
|
|
13
|
+
import type { CratisDialogSlotProps } from '../Dialogs/DialogHost.js';
|
|
13
14
|
import type { DropdownProps } from '../Dropdown/Dropdown.js';
|
|
14
15
|
import type { ProgressBarProps } from '../Display/ProgressBar.js';
|
|
15
16
|
import type { CratisPresentationUiLibraryProviderProps } from './manifest.js';
|
|
@@ -60,7 +61,7 @@ export type CratisPresentationSlotMap = {
|
|
|
60
61
|
* implement any of them through {@link CratisPresentationUiLibrary.atomicSlots}; new ids are only
|
|
61
62
|
* ever appended.
|
|
62
63
|
*/
|
|
63
|
-
export declare const cratisAtomicSlotIds: readonly ["datatables.paginator", "common.tooltip", "dropdown.select", "display.datePicker"];
|
|
64
|
+
export declare const cratisAtomicSlotIds: readonly ["datatables.paginator", "common.tooltip", "dropdown.select", "display.datePicker", "dialogs.dialog"];
|
|
64
65
|
/** Identifier of one stable atomic slot. */
|
|
65
66
|
export type CratisAtomicSlotId = (typeof cratisAtomicSlotIds)[number];
|
|
66
67
|
/** Exact public component prop contracts covered by the stable atomic slots. */
|
|
@@ -86,6 +87,13 @@ export interface CratisAtomicSlots {
|
|
|
86
87
|
* `DatePickerInputPassThrough` parts and no ref. Calendar library values stay inside the adapter.
|
|
87
88
|
*/
|
|
88
89
|
readonly 'display.datePicker': DatePickerInputProps;
|
|
90
|
+
/**
|
|
91
|
+
* Dialog contract: the public `DialogProps` plus a `host` prop (`CratisDialogHost`). Components
|
|
92
|
+
* keeps the dialog stack, the result flow, the footer and header actions, busy and validity,
|
|
93
|
+
* initial focus and the descendants' overlay environment. The adapter owns the modal shell:
|
|
94
|
+
* focus trap, Escape, outside press, scroll lock and focus restoration. There is no ref.
|
|
95
|
+
*/
|
|
96
|
+
readonly 'dialogs.dialog': CratisDialogSlotProps;
|
|
89
97
|
}
|
|
90
98
|
/** One stable, adapter-owned atomic slot declaration. */
|
|
91
99
|
export interface CratisAtomicSlotDeclaration<SlotId extends CratisAtomicSlotId> {
|