@cratis/components 4.42.0 → 4.42.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compat-manifest.json +11 -11
- package/dist/esm/Canvas/Canvas.d.ts.map +1 -1
- package/dist/esm/Canvas/Canvas.js +16 -109
- package/dist/esm/Canvas/Canvas.js.map +1 -1
- package/dist/esm/Canvas/CanvasWorldLayers.d.ts +22 -0
- package/dist/esm/Canvas/CanvasWorldLayers.d.ts.map +1 -0
- package/dist/esm/Canvas/CanvasWorldLayers.js +27 -0
- package/dist/esm/Canvas/CanvasWorldLayers.js.map +1 -0
- package/dist/esm/Canvas/useCanvasSurface.d.ts +57 -0
- package/dist/esm/Canvas/useCanvasSurface.d.ts.map +1 -0
- package/dist/esm/Canvas/useCanvasSurface.js +112 -0
- package/dist/esm/Canvas/useCanvasSurface.js.map +1 -0
- package/dist/esm/Chat/ChatSidebar.d.ts +2 -2
- package/dist/esm/Chat/ChatSidebar.d.ts.map +1 -1
- package/dist/esm/Chat/ChatSidebar.js +21 -101
- package/dist/esm/Chat/ChatSidebar.js.map +1 -1
- package/dist/esm/Chat/ChatSidebarContent.d.ts +25 -0
- package/dist/esm/Chat/ChatSidebarContent.d.ts.map +1 -0
- package/dist/esm/Chat/ChatSidebarContent.js +12 -0
- package/dist/esm/Chat/ChatSidebarContent.js.map +1 -0
- package/dist/esm/Chat/ChatSidebarHeader.d.ts +16 -0
- package/dist/esm/Chat/ChatSidebarHeader.d.ts.map +1 -0
- package/dist/esm/Chat/ChatSidebarHeader.js +26 -0
- package/dist/esm/Chat/ChatSidebarHeader.js.map +1 -0
- package/dist/esm/Chat/ChatSidebarShells.d.ts +31 -0
- package/dist/esm/Chat/ChatSidebarShells.d.ts.map +1 -0
- package/dist/esm/Chat/ChatSidebarShells.js +43 -0
- package/dist/esm/Chat/ChatSidebarShells.js.map +1 -0
- package/dist/esm/Chat/useNonModalPhase.d.ts +16 -0
- package/dist/esm/Chat/useNonModalPhase.d.ts.map +1 -0
- package/dist/esm/Chat/useNonModalPhase.js +38 -0
- package/dist/esm/Chat/useNonModalPhase.js.map +1 -0
- package/dist/esm/Chat/useTopicSelection.d.ts +31 -0
- package/dist/esm/Chat/useTopicSelection.d.ts.map +1 -0
- package/dist/esm/Chat/useTopicSelection.js +45 -0
- package/dist/esm/Chat/useTopicSelection.js.map +1 -0
- package/dist/esm/CommandDialog/CommandStepperContent.d.ts.map +1 -1
- package/dist/esm/CommandDialog/CommandStepperContent.js +31 -119
- package/dist/esm/CommandDialog/CommandStepperContent.js.map +1 -1
- package/dist/esm/CommandDialog/CommandStepperList.d.ts +19 -0
- package/dist/esm/CommandDialog/CommandStepperList.d.ts.map +1 -0
- package/dist/esm/CommandDialog/CommandStepperList.js +20 -0
- package/dist/esm/CommandDialog/CommandStepperList.js.map +1 -0
- package/dist/esm/CommandDialog/CommandStepperNavigation.d.ts +20 -0
- package/dist/esm/CommandDialog/CommandStepperNavigation.d.ts.map +1 -0
- package/dist/esm/CommandDialog/CommandStepperNavigation.js +15 -0
- package/dist/esm/CommandDialog/CommandStepperNavigation.js.map +1 -0
- package/dist/esm/CommandDialog/CommandStepperPanels.d.ts +20 -0
- package/dist/esm/CommandDialog/CommandStepperPanels.d.ts.map +1 -0
- package/dist/esm/CommandDialog/CommandStepperPanels.js +9 -0
- package/dist/esm/CommandDialog/CommandStepperPanels.js.map +1 -0
- package/dist/esm/CommandDialog/CommandStepperStepParts.d.ts +23 -0
- package/dist/esm/CommandDialog/CommandStepperStepParts.d.ts.map +1 -0
- package/dist/esm/CommandDialog/CommandStepperStepParts.js +9 -0
- package/dist/esm/CommandDialog/CommandStepperStepParts.js.map +1 -0
- package/dist/esm/CommandDialog/commandStepperFields.d.ts +6 -0
- package/dist/esm/CommandDialog/commandStepperFields.d.ts.map +1 -0
- package/dist/esm/CommandDialog/commandStepperFields.js +54 -0
- package/dist/esm/CommandDialog/commandStepperFields.js.map +1 -0
- package/dist/esm/CommandDialog/joinClassNames.d.ts +3 -0
- package/dist/esm/CommandDialog/joinClassNames.d.ts.map +1 -0
- package/dist/esm/CommandDialog/joinClassNames.js +4 -0
- package/dist/esm/CommandDialog/joinClassNames.js.map +1 -0
- package/dist/esm/CommandDialog/resolveStepperLabels.d.ts +20 -0
- package/dist/esm/CommandDialog/resolveStepperLabels.d.ts.map +1 -0
- package/dist/esm/CommandDialog/resolveStepperLabels.js +8 -0
- package/dist/esm/CommandDialog/resolveStepperLabels.js.map +1 -0
- package/dist/esm/CommandDialog/useStepValidation.d.ts +7 -0
- package/dist/esm/CommandDialog/useStepValidation.d.ts.map +1 -0
- package/dist/esm/CommandDialog/useStepValidation.js +14 -0
- package/dist/esm/CommandDialog/useStepValidation.js.map +1 -0
- package/dist/esm/CommandDialog/useStepperState.d.ts +30 -0
- package/dist/esm/CommandDialog/useStepperState.d.ts.map +1 -0
- package/dist/esm/CommandDialog/useStepperState.js +37 -0
- package/dist/esm/CommandDialog/useStepperState.js.map +1 -0
- package/dist/esm/CommandForm/fields/ChipsField.d.ts +1 -1
- package/dist/esm/CommandForm/fields/ChipsField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/ChipsField.js +7 -39
- package/dist/esm/CommandForm/fields/ChipsField.js.map +1 -1
- package/dist/esm/CommandForm/fields/ChipsInput.d.ts +18 -0
- package/dist/esm/CommandForm/fields/ChipsInput.d.ts.map +1 -0
- package/dist/esm/CommandForm/fields/ChipsInput.js +12 -0
- package/dist/esm/CommandForm/fields/ChipsInput.js.map +1 -0
- package/dist/esm/CommandForm/fields/ChipsItem.d.ts +14 -0
- package/dist/esm/CommandForm/fields/ChipsItem.d.ts.map +1 -0
- package/dist/esm/CommandForm/fields/ChipsItem.js +14 -0
- package/dist/esm/CommandForm/fields/ChipsItem.js.map +1 -0
- package/dist/esm/CommandForm/fields/useChipsDraft.d.ts +19 -0
- package/dist/esm/CommandForm/fields/useChipsDraft.d.ts.map +1 -0
- package/dist/esm/CommandForm/fields/useChipsDraft.js +19 -0
- package/dist/esm/CommandForm/fields/useChipsDraft.js.map +1 -0
- package/dist/esm/Common/CratisComponentsProvider.d.ts.map +1 -1
- package/dist/esm/Common/CratisComponentsProvider.js +1 -44
- package/dist/esm/Common/CratisComponentsProvider.js.map +1 -1
- package/dist/esm/Common/legacyLocaleMessages.d.ts +7 -0
- package/dist/esm/Common/legacyLocaleMessages.d.ts.map +1 -0
- package/dist/esm/Common/legacyLocaleMessages.js +43 -0
- package/dist/esm/Common/legacyLocaleMessages.js.map +1 -0
- package/dist/esm/DataTables/ColumnFilterActions.d.ts +11 -0
- package/dist/esm/DataTables/ColumnFilterActions.d.ts.map +1 -0
- package/dist/esm/DataTables/ColumnFilterActions.js +8 -0
- package/dist/esm/DataTables/ColumnFilterActions.js.map +1 -0
- package/dist/esm/DataTables/ColumnFilterMenu.d.ts +1 -1
- package/dist/esm/DataTables/ColumnFilterMenu.d.ts.map +1 -1
- package/dist/esm/DataTables/ColumnFilterMenu.js +16 -148
- package/dist/esm/DataTables/ColumnFilterMenu.js.map +1 -1
- package/dist/esm/DataTables/ColumnFilterTrigger.d.ts +12 -0
- package/dist/esm/DataTables/ColumnFilterTrigger.d.ts.map +1 -0
- package/dist/esm/DataTables/ColumnFilterTrigger.js +9 -0
- package/dist/esm/DataTables/ColumnFilterTrigger.js.map +1 -0
- package/dist/esm/DataTables/ColumnFilterValueInput.d.ts +24 -0
- package/dist/esm/DataTables/ColumnFilterValueInput.d.ts.map +1 -0
- package/dist/esm/DataTables/ColumnFilterValueInput.js +39 -0
- package/dist/esm/DataTables/ColumnFilterValueInput.js.map +1 -0
- package/dist/esm/DataTables/DataTableCore.d.ts +1 -1
- package/dist/esm/DataTables/DataTableCore.d.ts.map +1 -1
- package/dist/esm/DataTables/DataTableCore.js +12 -66
- package/dist/esm/DataTables/DataTableCore.js.map +1 -1
- package/dist/esm/DataTables/DataTableHead.d.ts +23 -0
- package/dist/esm/DataTables/DataTableHead.d.ts.map +1 -0
- package/dist/esm/DataTables/DataTableHead.js +12 -0
- package/dist/esm/DataTables/DataTableHead.js.map +1 -0
- package/dist/esm/DataTables/DataTableRows.d.ts +19 -0
- package/dist/esm/DataTables/DataTableRows.d.ts.map +1 -0
- package/dist/esm/DataTables/DataTableRows.js +7 -0
- package/dist/esm/DataTables/DataTableRows.js.map +1 -0
- package/dist/esm/DataTables/DataTableTable.d.ts +20 -0
- package/dist/esm/DataTables/DataTableTable.d.ts.map +1 -0
- package/dist/esm/DataTables/DataTableTable.js +10 -0
- package/dist/esm/DataTables/DataTableTable.js.map +1 -0
- package/dist/esm/DataTables/columnFilterMatchModes.d.ts +10 -0
- package/dist/esm/DataTables/columnFilterMatchModes.d.ts.map +1 -0
- package/dist/esm/DataTables/columnFilterMatchModes.js +52 -0
- package/dist/esm/DataTables/columnFilterMatchModes.js.map +1 -0
- package/dist/esm/DataTables/resolveColumnFilterLabels.d.ts +4 -0
- package/dist/esm/DataTables/resolveColumnFilterLabels.d.ts.map +1 -0
- package/dist/esm/DataTables/resolveColumnFilterLabels.js +20 -0
- package/dist/esm/DataTables/resolveColumnFilterLabels.js.map +1 -0
- package/dist/esm/DataTables/useColumnFilterDraft.d.ts +13 -0
- package/dist/esm/DataTables/useColumnFilterDraft.d.ts.map +1 -0
- package/dist/esm/DataTables/useColumnFilterDraft.js +24 -0
- package/dist/esm/DataTables/useColumnFilterDraft.js.map +1 -0
- package/dist/esm/DataTables/useDataTableRows.d.ts +40 -0
- package/dist/esm/DataTables/useDataTableRows.d.ts.map +1 -0
- package/dist/esm/DataTables/useDataTableRows.js +49 -0
- package/dist/esm/DataTables/useDataTableRows.js.map +1 -0
- package/dist/esm/DataTables/useRestoreFocusOnClose.d.ts +7 -0
- package/dist/esm/DataTables/useRestoreFocusOnClose.d.ts.map +1 -0
- package/dist/esm/DataTables/useRestoreFocusOnClose.js +30 -0
- package/dist/esm/DataTables/useRestoreFocusOnClose.js.map +1 -0
- package/dist/esm/Dialogs/DialogDocument.d.ts +22 -0
- package/dist/esm/Dialogs/DialogDocument.d.ts.map +1 -0
- package/dist/esm/Dialogs/DialogDocument.js +24 -0
- package/dist/esm/Dialogs/DialogDocument.js.map +1 -0
- package/dist/esm/Dialogs/DialogFooter.d.ts +24 -0
- package/dist/esm/Dialogs/DialogFooter.d.ts.map +1 -0
- package/dist/esm/Dialogs/DialogFooter.js +65 -0
- package/dist/esm/Dialogs/DialogFooter.js.map +1 -0
- package/dist/esm/Dialogs/DialogHeader.d.ts +31 -0
- package/dist/esm/Dialogs/DialogHeader.d.ts.map +1 -0
- package/dist/esm/Dialogs/DialogHeader.js +28 -0
- package/dist/esm/Dialogs/DialogHeader.js.map +1 -0
- package/dist/esm/Dialogs/DialogImplementation.d.ts +1 -2
- package/dist/esm/Dialogs/DialogImplementation.d.ts.map +1 -1
- package/dist/esm/Dialogs/DialogImplementation.js +88 -189
- package/dist/esm/Dialogs/DialogImplementation.js.map +1 -1
- package/dist/esm/Dialogs/DialogShells.d.ts +29 -0
- package/dist/esm/Dialogs/DialogShells.d.ts.map +1 -0
- package/dist/esm/Dialogs/DialogShells.js +36 -0
- package/dist/esm/Dialogs/DialogShells.js.map +1 -0
- package/dist/esm/Dialogs/dialogPartAttributes.d.ts +19 -0
- package/dist/esm/Dialogs/dialogPartAttributes.d.ts.map +1 -0
- package/dist/esm/Dialogs/dialogPartAttributes.js +10 -0
- package/dist/esm/Dialogs/dialogPartAttributes.js.map +1 -0
- package/dist/esm/Dialogs/resolveDialogLabels.d.ts +29 -0
- package/dist/esm/Dialogs/resolveDialogLabels.d.ts.map +1 -0
- package/dist/esm/Dialogs/resolveDialogLabels.js +11 -0
- package/dist/esm/Dialogs/resolveDialogLabels.js.map +1 -0
- package/dist/esm/Dialogs/useDialogClose.d.ts +13 -0
- package/dist/esm/Dialogs/useDialogClose.d.ts.map +1 -0
- package/dist/esm/Dialogs/useDialogClose.js +32 -0
- package/dist/esm/Dialogs/useDialogClose.js.map +1 -0
- package/dist/esm/Dialogs/useDialogFocus.d.ts +26 -0
- package/dist/esm/Dialogs/useDialogFocus.d.ts.map +1 -0
- package/dist/esm/Dialogs/useDialogFocus.js +56 -0
- package/dist/esm/Dialogs/useDialogFocus.js.map +1 -0
- package/dist/esm/Dialogs/useDialogZIndex.d.ts +9 -0
- package/dist/esm/Dialogs/useDialogZIndex.d.ts.map +1 -0
- package/dist/esm/Dialogs/useDialogZIndex.js +19 -0
- package/dist/esm/Dialogs/useDialogZIndex.js.map +1 -0
- package/dist/esm/SchemaEditor/ReadOnlyTypeCell.d.ts +6 -0
- package/dist/esm/SchemaEditor/ReadOnlyTypeCell.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/ReadOnlyTypeCell.js +19 -0
- package/dist/esm/SchemaEditor/ReadOnlyTypeCell.js.map +1 -0
- package/dist/esm/SchemaEditor/SchemaEditor.d.ts.map +1 -1
- package/dist/esm/SchemaEditor/SchemaEditor.js +44 -514
- package/dist/esm/SchemaEditor/SchemaEditor.js.map +1 -1
- package/dist/esm/SchemaEditor/SchemaEditorNavigation.d.ts +13 -0
- package/dist/esm/SchemaEditor/SchemaEditorNavigation.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/SchemaEditorNavigation.js +36 -0
- package/dist/esm/SchemaEditor/SchemaEditorNavigation.js.map +1 -0
- package/dist/esm/SchemaEditor/SchemaEditorTable.d.ts +34 -0
- package/dist/esm/SchemaEditor/SchemaEditorTable.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/SchemaEditorTable.js +54 -0
- package/dist/esm/SchemaEditor/SchemaEditorTable.js.map +1 -0
- package/dist/esm/SchemaEditor/TypeCell.d.ts.map +1 -1
- package/dist/esm/SchemaEditor/TypeCell.js +14 -80
- package/dist/esm/SchemaEditor/TypeCell.js.map +1 -1
- package/dist/esm/SchemaEditor/TypeCellActions.d.ts +13 -0
- package/dist/esm/SchemaEditor/TypeCellActions.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/TypeCellActions.js +19 -0
- package/dist/esm/SchemaEditor/TypeCellActions.js.map +1 -0
- package/dist/esm/SchemaEditor/resolveTypeChange.d.ts +12 -0
- package/dist/esm/SchemaEditor/resolveTypeChange.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/resolveTypeChange.js +19 -0
- package/dist/esm/SchemaEditor/resolveTypeChange.js.map +1 -0
- package/dist/esm/SchemaEditor/schemaDocument.d.ts +20 -0
- package/dist/esm/SchemaEditor/schemaDocument.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/schemaDocument.js +70 -0
- package/dist/esm/SchemaEditor/schemaDocument.js.map +1 -0
- package/dist/esm/SchemaEditor/schemaEditorMenu.d.ts +30 -0
- package/dist/esm/SchemaEditor/schemaEditorMenu.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/schemaEditorMenu.js +51 -0
- package/dist/esm/SchemaEditor/schemaEditorMenu.js.map +1 -0
- package/dist/esm/SchemaEditor/schemaPropertyEdits.d.ts +33 -0
- package/dist/esm/SchemaEditor/schemaPropertyEdits.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/schemaPropertyEdits.js +134 -0
- package/dist/esm/SchemaEditor/schemaPropertyEdits.js.map +1 -0
- package/dist/esm/SchemaEditor/typeOptions.d.ts +11 -0
- package/dist/esm/SchemaEditor/typeOptions.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/typeOptions.js +20 -0
- package/dist/esm/SchemaEditor/typeOptions.js.map +1 -0
- package/dist/esm/SchemaEditor/useSchemaDocument.d.ts +26 -0
- package/dist/esm/SchemaEditor/useSchemaDocument.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/useSchemaDocument.js +65 -0
- package/dist/esm/SchemaEditor/useSchemaDocument.js.map +1 -0
- package/dist/esm/SchemaEditor/useSchemaEdits.d.ts +29 -0
- package/dist/esm/SchemaEditor/useSchemaEdits.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/useSchemaEdits.js +50 -0
- package/dist/esm/SchemaEditor/useSchemaEdits.js.map +1 -0
- package/dist/esm/SchemaEditor/useSchemaNavigation.d.ts +15 -0
- package/dist/esm/SchemaEditor/useSchemaNavigation.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/useSchemaNavigation.js +24 -0
- package/dist/esm/SchemaEditor/useSchemaNavigation.js.map +1 -0
- package/dist/esm/SchemaEditor/useSchemaRows.d.ts +17 -0
- package/dist/esm/SchemaEditor/useSchemaRows.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/useSchemaRows.js +49 -0
- package/dist/esm/SchemaEditor/useSchemaRows.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import { DialogButtons,
|
|
3
|
-
import {
|
|
4
|
-
import { ModalOverlay, Modal } from 'react-aria-components/Modal';
|
|
5
|
-
import { UNSAFE_PortalProvider } from 'react-aria';
|
|
6
|
-
import { useId, useRef, useState, useLayoutEffect, useEffect, useSyncExternalStore } from 'react';
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { DialogButtons, DialogResult } from '@cratis/arc.react/dialogs';
|
|
3
|
+
import { useId, useSyncExternalStore } from 'react';
|
|
7
4
|
import { unstable_useOverlayEnvironment } from '../renderer/RendererContext.js';
|
|
8
5
|
import { DialogInitialFocus } from './DialogInitialFocus.js';
|
|
9
6
|
import { resolveDialogDismissal } from './resolveDialogDismissal.js';
|
|
@@ -14,203 +11,105 @@ import 'react-dom';
|
|
|
14
11
|
import { useCratisComponentsConfig } from '../configuration/CratisComponentsContext.js';
|
|
15
12
|
import { useCratisIcon } from '../configuration/useCratisIcon.js';
|
|
16
13
|
import '../Notifications/toast.js';
|
|
17
|
-
import {
|
|
18
|
-
import { openDialogTier, closeDialogTier, DIALOG_ZINDEX_TOKEN, dialogZIndexForTier } from '../renderer/dialogStack.js';
|
|
19
|
-
import { DialogStackContext } from '../renderer/DialogStackContext.js';
|
|
20
|
-
import { DialogGlobalHeaderActions } from './DialogGlobalHeaderActions.js';
|
|
14
|
+
import { DIALOG_ZINDEX_TOKEN } from '../renderer/dialogStack.js';
|
|
21
15
|
import { useComponentPresentation } from '../configuration/identity/useComponentPresentation.js';
|
|
22
16
|
import { dialogDescriptor } from './dialogDescriptor.js';
|
|
17
|
+
import { DialogDocument } from './DialogDocument.js';
|
|
18
|
+
import { DialogServerShell, DialogModalShell } from './DialogShells.js';
|
|
19
|
+
import { resolveDialogLabels } from './resolveDialogLabels.js';
|
|
20
|
+
import { useDialogClose } from './useDialogClose.js';
|
|
21
|
+
import { useDialogFocus } from './useDialogFocus.js';
|
|
22
|
+
import { useDialogZIndex } from './useDialogZIndex.js';
|
|
23
23
|
|
|
24
|
-
const visuallyHidden = {
|
|
25
|
-
position: 'absolute',
|
|
26
|
-
width: 1,
|
|
27
|
-
height: 1,
|
|
28
|
-
margin: -1,
|
|
29
|
-
padding: 0,
|
|
30
|
-
overflow: 'hidden',
|
|
31
|
-
clipPath: 'inset(50%)',
|
|
32
|
-
whiteSpace: 'nowrap',
|
|
33
|
-
border: 0,
|
|
34
|
-
};
|
|
35
|
-
const headerActionsStyle = (hasCloseButton) => ({
|
|
36
|
-
display: 'inline-flex',
|
|
37
|
-
gridColumn: 2,
|
|
38
|
-
gridRow: 1,
|
|
39
|
-
justifySelf: 'end',
|
|
40
|
-
alignItems: 'center',
|
|
41
|
-
gap: '0.25rem',
|
|
42
|
-
marginInlineEnd: hasCloseButton ? '2.25rem' : undefined,
|
|
43
|
-
});
|
|
44
24
|
const subscribeToBrowserEnvironment = () => () => undefined;
|
|
45
25
|
const useIsBrowser = () => useSyncExternalStore(subscribeToBrowserEnvironment, () => true, () => false);
|
|
26
|
+
const resolveInitialFocus = (initialFocus, buttons) => {
|
|
27
|
+
const hasDismissingButton = typeof buttons === 'number' && buttons !== DialogButtons.Ok;
|
|
28
|
+
return initialFocus === DialogInitialFocus.Cancel && !hasDismissingButton ? DialogInitialFocus.Content : initialFocus;
|
|
29
|
+
};
|
|
30
|
+
const dismissalFor = (props, isBusy) => resolveDialogDismissal({
|
|
31
|
+
buttons: props.buttons === undefined ? DialogButtons.OkCancel : props.buttons,
|
|
32
|
+
dismissable: props.dismissable,
|
|
33
|
+
dismissOnOutsideClick: props.dismissOnOutsideClick,
|
|
34
|
+
closeOnEscape: props.closeOnEscape,
|
|
35
|
+
showCloseButton: props.showCloseButton,
|
|
36
|
+
isBusy,
|
|
37
|
+
});
|
|
46
38
|
const DialogImplementation = (incomingProps) => {
|
|
47
39
|
const [props, marker] = useComponentPresentation(dialogDescriptor, incomingProps);
|
|
48
|
-
const { title, subtitle, placement = 'center', closeIcon, headerActions, hideGlobalHeaderActions = false, sliceLocation, isCommandDialog = false, visible = true,
|
|
49
|
-
const overlayEnvironment = unstable_useOverlayEnvironment();
|
|
40
|
+
const { title, subtitle, placement = 'center', closeIcon, headerActions, hideGlobalHeaderActions = false, sliceLocation, isCommandDialog = false, visible = true, buttons = DialogButtons.OkCancel, initialFocus = DialogInitialFocus.Confirm, children, width = '450px', isValid, isBusy = false, pt, } = props;
|
|
50
41
|
const { messages, dialogHeaderActions } = useCratisComponentsConfig();
|
|
51
42
|
const dialogId = useId();
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
const resolvedCancelLabel = cancelLabel ?? dialogMessages?.cancel ?? 'Cancel';
|
|
55
|
-
const resolvedYesLabel = yesLabel ?? dialogMessages?.yes ?? 'Yes';
|
|
56
|
-
const resolvedNoLabel = noLabel ?? dialogMessages?.no ?? 'No';
|
|
57
|
-
const resolvedCloseAriaLabel = closeAriaLabel ?? dialogMessages?.close ?? 'Close';
|
|
58
|
-
const resolvedRefusedMessage = dialogMessages?.refused ??
|
|
59
|
-
'The action was not completed. Review the dialog and try again.';
|
|
43
|
+
const subtitleId = useId();
|
|
44
|
+
const labels = resolveDialogLabels(props, messages?.dialog);
|
|
60
45
|
const icon = useCratisIcon();
|
|
61
|
-
const resolvedCloseIcon = icon('close', '×', closeIcon);
|
|
62
|
-
let contextCloseDialog;
|
|
63
|
-
try {
|
|
64
|
-
const context = useDialogContext();
|
|
65
|
-
contextCloseDialog = context?.closeDialog;
|
|
66
|
-
}
|
|
67
|
-
catch {
|
|
68
|
-
contextCloseDialog = undefined;
|
|
69
|
-
}
|
|
70
|
-
const hasHeaderActions = headerActions != null || (dialogHeaderActions !== undefined && !hideGlobalHeaderActions);
|
|
71
46
|
const isBrowser = useIsBrowser();
|
|
72
|
-
const
|
|
47
|
+
const overlayEnvironment = unstable_useOverlayEnvironment();
|
|
48
|
+
const hasHeaderActions = headerActions != null || (dialogHeaderActions !== undefined && !hideGlobalHeaderActions);
|
|
73
49
|
const hasSubtitle = subtitle !== undefined && subtitle !== null && subtitle !== false;
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const handledRefusals = useRef(0);
|
|
79
|
-
const [announcement, setAnnouncement] = useState(null);
|
|
80
|
-
const isDialogValid = isValid !== false;
|
|
81
|
-
const hasDismissingButton = typeof buttons === 'number' && buttons !== DialogButtons.Ok;
|
|
82
|
-
const resolvedInitialFocus = initialFocus === DialogInitialFocus.Cancel && !hasDismissingButton
|
|
83
|
-
? DialogInitialFocus.Content
|
|
84
|
-
: initialFocus;
|
|
85
|
-
const focusesConfirmButton = resolvedInitialFocus === DialogInitialFocus.Confirm;
|
|
86
|
-
const focusesDismissingButton = resolvedInitialFocus === DialogInitialFocus.Cancel;
|
|
87
|
-
const focusesTitle = resolvedInitialFocus === DialogInitialFocus.Content;
|
|
88
|
-
const { allowsOutsideDismissal, allowsEscapeDismissal, showsCloseButton } = resolveDialogDismissal({
|
|
89
|
-
buttons, dismissable, dismissOnOutsideClick, closeOnEscape, showCloseButton, isBusy,
|
|
90
|
-
});
|
|
91
|
-
const [dialogTier, setDialogTier] = useState(null);
|
|
92
|
-
useLayoutEffect(() => {
|
|
93
|
-
if (!visible) {
|
|
94
|
-
setDialogTier(null);
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
const tier = openDialogTier();
|
|
98
|
-
setDialogTier(tier);
|
|
99
|
-
return () => closeDialogTier(tier);
|
|
100
|
-
}, [visible]);
|
|
101
|
-
const resolvedZIndex = dialogTier === null ? undefined : dialogZIndexForTier(dialogTier);
|
|
102
|
-
useEffect(() => {
|
|
103
|
-
if (!visible)
|
|
104
|
-
return;
|
|
105
|
-
const target = focusesConfirmButton
|
|
106
|
-
? confirmRef.current
|
|
107
|
-
: focusesDismissingButton
|
|
108
|
-
? cancelRef.current
|
|
109
|
-
: titleRef.current;
|
|
110
|
-
const frame = requestAnimationFrame(() => target?.focus());
|
|
111
|
-
return () => cancelAnimationFrame(frame);
|
|
112
|
-
}, [focusesConfirmButton, focusesDismissingButton, visible]);
|
|
113
|
-
useEffect(() => {
|
|
114
|
-
if (!visible || !isBusy)
|
|
115
|
-
return;
|
|
116
|
-
setAnnouncement(null);
|
|
117
|
-
const active = document.activeElement;
|
|
118
|
-
if (active && active !== document.body)
|
|
119
|
-
return;
|
|
120
|
-
if (confirmRef.current) {
|
|
121
|
-
confirmRef.current.focus();
|
|
122
|
-
}
|
|
123
|
-
else if (titleRef.current) {
|
|
124
|
-
titleRef.current.tabIndex = -1;
|
|
125
|
-
titleRef.current.focus();
|
|
126
|
-
}
|
|
127
|
-
}, [isBusy, visible]);
|
|
128
|
-
useEffect(() => {
|
|
129
|
-
if (refusals === handledRefusals.current || isBusy)
|
|
130
|
-
return;
|
|
131
|
-
handledRefusals.current = refusals;
|
|
132
|
-
const confirm = confirmRef.current;
|
|
133
|
-
if (confirm && !confirm.disabled) {
|
|
134
|
-
confirm.focus();
|
|
135
|
-
}
|
|
136
|
-
else if (titleRef.current) {
|
|
137
|
-
titleRef.current.tabIndex = -1;
|
|
138
|
-
titleRef.current.focus();
|
|
139
|
-
}
|
|
140
|
-
setAnnouncement({ key: refusals, text: resolvedRefusedMessage });
|
|
141
|
-
}, [refusals, isBusy, resolvedRefusedMessage]);
|
|
142
|
-
const handleClose = async (result) => {
|
|
143
|
-
let shouldCloseThroughContext = true;
|
|
144
|
-
const isConfirming = result === DialogResult.Ok || result === DialogResult.Yes;
|
|
145
|
-
if (result === DialogResult.Ok || result === DialogResult.Yes) {
|
|
146
|
-
if (onConfirm) {
|
|
147
|
-
const closeResult = await onConfirm();
|
|
148
|
-
shouldCloseThroughContext = closeResult === true;
|
|
149
|
-
}
|
|
150
|
-
else if (onClose) {
|
|
151
|
-
const closeResult = await onClose(result);
|
|
152
|
-
shouldCloseThroughContext = closeResult !== false;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
else if (onCancel) {
|
|
156
|
-
const closeResult = await onCancel();
|
|
157
|
-
shouldCloseThroughContext = closeResult === true;
|
|
158
|
-
}
|
|
159
|
-
else if (onClose) {
|
|
160
|
-
const closeResult = await onClose(result);
|
|
161
|
-
shouldCloseThroughContext = closeResult !== false;
|
|
162
|
-
}
|
|
163
|
-
if (shouldCloseThroughContext)
|
|
164
|
-
contextCloseDialog?.(result);
|
|
165
|
-
else if (isConfirming)
|
|
166
|
-
setRefusals((count) => count + 1);
|
|
50
|
+
const resolvedInitialFocus = resolveInitialFocus(initialFocus, buttons);
|
|
51
|
+
const focus = {
|
|
52
|
+
confirm: resolvedInitialFocus === DialogInitialFocus.Confirm,
|
|
53
|
+
dismissing: resolvedInitialFocus === DialogInitialFocus.Cancel,
|
|
167
54
|
};
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
55
|
+
const { allowsOutsideDismissal, allowsEscapeDismissal, showsCloseButton } = dismissalFor(props, isBusy);
|
|
56
|
+
const resolvedZIndex = useDialogZIndex(visible);
|
|
57
|
+
const { titleRef, confirmRef, cancelRef, announcement, onRefused } = useDialogFocus({
|
|
58
|
+
visible,
|
|
59
|
+
isBusy,
|
|
60
|
+
initialFocus: resolvedInitialFocus,
|
|
61
|
+
refusedMessage: labels.refused,
|
|
62
|
+
});
|
|
63
|
+
const handleClose = useDialogClose(props, onRefused);
|
|
64
|
+
const dialogDocument = (jsx(DialogDocument, { stackZIndex: resolvedZIndex ?? DIALOG_ZINDEX_TOKEN, visible: visible, contentStyle: props.contentStyle, announcement: announcement, header: {
|
|
65
|
+
dialogId,
|
|
66
|
+
title,
|
|
67
|
+
subtitle,
|
|
68
|
+
subtitleId,
|
|
69
|
+
hasSubtitle,
|
|
70
|
+
hasHeaderActions,
|
|
71
|
+
headerActions,
|
|
72
|
+
globalHeaderActions: dialogHeaderActions,
|
|
73
|
+
hideGlobalHeaderActions,
|
|
74
|
+
isCommandDialog,
|
|
75
|
+
sliceLocation,
|
|
76
|
+
showsCloseButton,
|
|
77
|
+
focusesTitle: resolvedInitialFocus === DialogInitialFocus.Content,
|
|
78
|
+
titleRef,
|
|
79
|
+
isBusy,
|
|
80
|
+
closeAriaLabel: labels.closeAria,
|
|
81
|
+
closeIcon: icon('close', '×', closeIcon),
|
|
82
|
+
onClose: () => void handleClose(DialogResult.Cancelled),
|
|
83
|
+
pt,
|
|
84
|
+
}, footer: buttons === null
|
|
85
|
+
? null
|
|
86
|
+
: {
|
|
87
|
+
buttons,
|
|
88
|
+
labels,
|
|
89
|
+
focus,
|
|
90
|
+
isBusy,
|
|
91
|
+
isValid: isValid !== false,
|
|
92
|
+
pt,
|
|
93
|
+
confirmRef,
|
|
94
|
+
cancelRef,
|
|
95
|
+
onResult: (result) => void handleClose(result),
|
|
96
|
+
}, children: children }));
|
|
97
|
+
const shell = {
|
|
98
|
+
placement,
|
|
99
|
+
visible,
|
|
100
|
+
isBusy,
|
|
101
|
+
zIndex: resolvedZIndex,
|
|
102
|
+
width,
|
|
103
|
+
style: props.style,
|
|
104
|
+
className: props.className,
|
|
105
|
+
dialogId,
|
|
106
|
+
marker,
|
|
107
|
+
pt,
|
|
108
|
+
children: dialogDocument,
|
|
196
109
|
};
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
if (!visible)
|
|
201
|
-
return null;
|
|
202
|
-
return (jsx("div", { ...pt?.backdrop, className: classNames('cratis-dialog__backdrop', pt?.backdrop?.className), style: {
|
|
203
|
-
zIndex: resolvedZIndex ?? DIALOG_ZINDEX_TOKEN,
|
|
204
|
-
...pt?.backdrop?.style,
|
|
205
|
-
}, "data-cratis-part": 'backdrop', "data-placement": placement, "data-open": visible || undefined, "data-busy": isBusy || undefined, children: jsx("div", { ...pt?.positioner, className: classNames('cratis-dialog__positioner', pt?.positioner?.className), style: pt?.positioner?.style, "data-cratis-part": 'positioner', "data-placement": placement, "data-open": visible || undefined, "data-busy": isBusy || undefined, children: jsx("section", { ...pt?.root, className: classNames('cratis-dialog', pt?.root?.className, className), style: dialogStyle, "data-cratis-part": 'root', ...marker, "data-cratis-dialog-id": dialogId, "data-placement": placement, "data-open": visible || undefined, "data-busy": isBusy || undefined, children: dialogDocument }) }) }));
|
|
206
|
-
}
|
|
207
|
-
return (jsx(UNSAFE_PortalProvider, { getContainer: overlayEnvironment.getContainer, children: jsx(ModalOverlay, { ...pt?.backdrop, isOpen: visible, onOpenChange: (open) => {
|
|
208
|
-
if (!open && !isBusy)
|
|
209
|
-
void handleClose(DialogResult.Cancelled);
|
|
210
|
-
}, isDismissable: allowsOutsideDismissal, isKeyboardDismissDisabled: !allowsEscapeDismissal, className: classNames('cratis-dialog__backdrop', pt?.backdrop?.className), style: {
|
|
211
|
-
zIndex: resolvedZIndex ?? DIALOG_ZINDEX_TOKEN,
|
|
212
|
-
...pt?.backdrop?.style,
|
|
213
|
-
}, "data-cratis-part": 'backdrop', "data-placement": placement, "data-open": visible || undefined, "data-busy": isBusy || undefined, children: jsx("div", { ...pt?.positioner, className: classNames('cratis-dialog__positioner', pt?.positioner?.className), style: pt?.positioner?.style, "data-cratis-part": 'positioner', "data-placement": placement, "data-open": visible || undefined, "data-busy": isBusy || undefined, children: jsx(Modal, { ...pt?.root, className: classNames('cratis-dialog', pt?.root?.className, className), style: dialogStyle, "data-cratis-part": 'root', ...marker, "data-cratis-dialog-id": dialogId, "data-placement": placement, "data-open": visible || undefined, "data-busy": isBusy || undefined, children: dialogDocument }) }) }) }));
|
|
110
|
+
if (!isBrowser)
|
|
111
|
+
return jsx(DialogServerShell, { ...shell });
|
|
112
|
+
return (jsx(DialogModalShell, { ...shell, portalContainer: overlayEnvironment.getContainer, allowsOutsideDismissal: allowsOutsideDismissal, allowsEscapeDismissal: allowsEscapeDismissal, onDismiss: () => void handleClose(DialogResult.Cancelled) }));
|
|
214
113
|
};
|
|
215
114
|
|
|
216
115
|
export { DialogImplementation };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogImplementation.js","sources":["../../../Dialogs/DialogImplementation.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 { DialogResult, DialogButtons, useDialogContext } from '@cratis/arc.react/dialogs';\nimport { Dialog as AriaDialog, Heading } from 'react-aria-components/Dialog';\nimport { Modal, ModalOverlay } from 'react-aria-components/Modal';\nimport { UNSAFE_PortalProvider } from 'react-aria';\nimport type React from 'react';\nimport { useEffect, useId, useLayoutEffect, useRef, useState, useSyncExternalStore } from 'react';\nimport { unstable_useOverlayEnvironment } from '../renderer/RendererContext';\nimport { DialogInitialFocus } from './DialogInitialFocus';\nimport type { DialogProps } from './Dialog';\nimport { resolveDialogDismissal } from './resolveDialogDismissal';\nimport { useCratisComponentsConfig } from '../Common/CratisComponentsProvider';\nimport { useCratisIcon } from '../configuration/useCratisIcon';\nimport {\n DIALOG_ZINDEX_TOKEN,\n closeDialogTier,\n dialogZIndexForTier,\n openDialogTier,\n} from '../renderer/dialogStack';\nimport { DialogStackContext } from '../renderer/DialogStackContext';\nimport { classNames } from '../ClassNames/classNames';\nimport { DialogGlobalHeaderActions } from './DialogGlobalHeaderActions';\nimport { useComponentPresentation } from '../configuration/identity/useComponentPresentation';\nimport { dialogDescriptor } from './dialogDescriptor';\n\n// Inline rather than in Dialog.css: the packed aggregate stylesheet has a reviewed size budget.\nconst visuallyHidden: React.CSSProperties = {\n position: 'absolute',\n width: 1,\n height: 1,\n margin: -1,\n padding: 0,\n overflow: 'hidden',\n clipPath: 'inset(50%)',\n whiteSpace: 'nowrap',\n border: 0,\n};\n\n// Header actions sit in the close button's grid column, to its left. Inline rather than in Dialog.css:\n// the packed aggregate stylesheet has a reviewed size budget.\nconst headerActionsStyle = (hasCloseButton: boolean): React.CSSProperties => ({\n display: 'inline-flex',\n gridColumn: 2,\n gridRow: 1,\n justifySelf: 'end',\n alignItems: 'center',\n gap: '0.25rem',\n marginInlineEnd: hasCloseButton ? '2.25rem' : undefined,\n});\n\nconst subscribeToBrowserEnvironment = () => () => undefined;\nconst useIsBrowser = () =>\n useSyncExternalStore(\n subscribeToBrowserEnvironment,\n () => true,\n () => false,\n );\n\n/**\n * A modal dialog with Arc host integration, typed footer actions, busy/validity\n * state, controlled dismissal, and stable Cratis-owned styling parts.\n */\nexport const DialogImplementation = (incomingProps: DialogProps) => {\n const [props, marker] = useComponentPresentation(dialogDescriptor, incomingProps);\n const {\n title,\n subtitle,\n placement = 'center',\n closeIcon,\n headerActions,\n hideGlobalHeaderActions = false,\n sliceLocation,\n isCommandDialog = false,\n visible = true,\n onClose,\n onConfirm,\n onCancel,\n buttons = DialogButtons.OkCancel,\n initialFocus = DialogInitialFocus.Confirm,\n children,\n width = '450px',\n style,\n contentStyle,\n isValid,\n isBusy = false,\n okLabel,\n cancelLabel,\n yesLabel,\n noLabel,\n closeAriaLabel,\n dismissable,\n dismissOnOutsideClick,\n closeOnEscape,\n showCloseButton,\n className,\n pt,\n } = props;\n const overlayEnvironment = unstable_useOverlayEnvironment();\n const { messages, dialogHeaderActions } = useCratisComponentsConfig();\n const dialogId = useId();\n const dialogMessages = messages?.dialog;\n const resolvedOkLabel = okLabel ?? dialogMessages?.ok ?? 'Ok';\n const resolvedCancelLabel = cancelLabel ?? dialogMessages?.cancel ?? 'Cancel';\n const resolvedYesLabel = yesLabel ?? dialogMessages?.yes ?? 'Yes';\n const resolvedNoLabel = noLabel ?? dialogMessages?.no ?? 'No';\n const resolvedCloseAriaLabel = closeAriaLabel ?? dialogMessages?.close ?? 'Close';\n const resolvedRefusedMessage =\n dialogMessages?.refused ??\n 'The action was not completed. Review the dialog and try again.';\n const icon = useCratisIcon();\n const resolvedCloseIcon = icon('close', '×', closeIcon);\n let contextCloseDialog: ((result: DialogResult) => void) | undefined;\n try {\n const context = useDialogContext();\n contextCloseDialog = context?.closeDialog;\n } catch {\n contextCloseDialog = undefined;\n }\n\n const hasHeaderActions =\n headerActions != null || (dialogHeaderActions !== undefined && !hideGlobalHeaderActions);\n const isBrowser = useIsBrowser();\n const subtitleId = useId();\n const hasSubtitle = subtitle !== undefined && subtitle !== null && subtitle !== false;\n const titleRef = useRef<HTMLHeadingElement>(null);\n const confirmRef = useRef<HTMLButtonElement>(null);\n const cancelRef = useRef<HTMLButtonElement>(null);\n\n const [refusals, setRefusals] = useState(0);\n const handledRefusals = useRef(0);\n const [announcement, setAnnouncement] = useState<{ key: number; text: string } | null>(null);\n const isDialogValid = isValid !== false;\n const hasDismissingButton =\n typeof buttons === 'number' && buttons !== DialogButtons.Ok;\n const resolvedInitialFocus =\n initialFocus === DialogInitialFocus.Cancel && !hasDismissingButton\n ? DialogInitialFocus.Content\n : initialFocus;\n const focusesConfirmButton = resolvedInitialFocus === DialogInitialFocus.Confirm;\n const focusesDismissingButton = resolvedInitialFocus === DialogInitialFocus.Cancel;\n const focusesTitle = resolvedInitialFocus === DialogInitialFocus.Content;\n const { allowsOutsideDismissal, allowsEscapeDismissal, showsCloseButton } = resolveDialogDismissal({\n buttons, dismissable, dismissOnOutsideClick, closeOnEscape, showCloseButton, isBusy,\n });\n\n // Assigns this dialog a strictly increasing tier for as long as it is visible, so a second\n // dialog opened while this one is still open - from anywhere, not necessarily as a React\n // child of this one - stacks above it rather than colliding on the same static z-index.\n const [dialogTier, setDialogTier] = useState<number | null>(null);\n useLayoutEffect(() => {\n if (!visible) {\n setDialogTier(null);\n return;\n }\n const tier = openDialogTier();\n setDialogTier(tier);\n return () => closeDialogTier(tier);\n }, [visible]);\n const resolvedZIndex = dialogTier === null ? undefined : dialogZIndexForTier(dialogTier);\n\n useEffect(() => {\n if (!visible) return;\n const target = focusesConfirmButton\n ? confirmRef.current\n : focusesDismissingButton\n ? cancelRef.current\n : titleRef.current;\n const frame = requestAnimationFrame(() => target?.focus());\n return () => cancelAnimationFrame(frame);\n }, [focusesConfirmButton, focusesDismissingButton, 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) {\n confirmRef.current.focus();\n } else if (titleRef.current) {\n titleRef.current.tabIndex = -1;\n titleRef.current.focus();\n }\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) {\n confirm.focus();\n } else if (titleRef.current) {\n titleRef.current.tabIndex = -1;\n titleRef.current.focus();\n }\n setAnnouncement({ key: refusals, text: resolvedRefusedMessage });\n }, [refusals, isBusy, resolvedRefusedMessage]);\n\n const handleClose = async (result: DialogResult) => {\n let shouldCloseThroughContext = true;\n const isConfirming = result === DialogResult.Ok || result === DialogResult.Yes;\n\n if (result === DialogResult.Ok || result === DialogResult.Yes) {\n if (onConfirm) {\n const closeResult = await onConfirm();\n shouldCloseThroughContext = closeResult === true;\n } else if (onClose) {\n const closeResult = await onClose(result);\n shouldCloseThroughContext = closeResult !== false;\n }\n } else if (onCancel) {\n const closeResult = await onCancel();\n shouldCloseThroughContext = closeResult === true;\n } else if (onClose) {\n const closeResult = await onClose(result);\n shouldCloseThroughContext = closeResult !== false;\n }\n\n if (shouldCloseThroughContext) contextCloseDialog?.(result);\n else if (isConfirming) setRefusals((count) => count + 1);\n };\n\n const footerButton = (\n result: DialogResult,\n label: string,\n primary: boolean,\n focused: boolean,\n ) => (\n <button\n key={`${result}-${label}`}\n {...(primary ? pt?.confirm : pt?.cancel)}\n type='button'\n className={classNames(\n 'cratis-dialog__button',\n primary\n ? 'cratis-dialog__button--primary'\n : 'cratis-dialog__button--secondary',\n primary ? pt?.confirm?.className : pt?.cancel?.className,\n )}\n data-cratis-part={primary ? 'confirm' : 'cancel'}\n data-disabled={(primary ? !isDialogValid || isBusy : isBusy) || undefined}\n data-busy={isBusy || undefined}\n ref={primary ? confirmRef : focused ? cancelRef : undefined}\n onClick={() => {\n if (isBusy) return;\n void handleClose(result);\n }}\n onKeyDown={\n primary\n ? (event) => {\n // A held key must not re-submit when focus returns after a refusal.\n if (event.repeat && (event.key === 'Enter' || event.key === ' '))\n event.preventDefault();\n }\n : undefined\n }\n disabled={primary ? !isDialogValid : isBusy}\n autoFocus={focused}\n aria-disabled={primary && isBusy ? true : undefined}\n aria-busy={primary && isBusy ? true : undefined}\n >\n {primary && isBusy && (\n <span className='cratis-dialog__spinner' aria-hidden='true' />\n )}\n <span>{label}</span>\n </button>\n );\n\n // The predefined footer keeps the confirm button focusable while busy, so only a custom\n // footer needs the whole scope disabled; predefined secondary buttons disable themselves.\n const isFooterScopeBusy = isBusy && typeof buttons !== 'number';\n\n const predefinedFooter = () => {\n if (typeof buttons !== 'number') return buttons;\n\n switch (buttons) {\n case DialogButtons.Ok:\n return footerButton(\n DialogResult.Ok,\n resolvedOkLabel,\n true,\n focusesConfirmButton,\n );\n case DialogButtons.OkCancel:\n return (\n <>\n {footerButton(\n DialogResult.Ok,\n resolvedOkLabel,\n true,\n focusesConfirmButton,\n )}\n {footerButton(\n DialogResult.Cancelled,\n resolvedCancelLabel,\n false,\n focusesDismissingButton,\n )}\n </>\n );\n case DialogButtons.YesNo:\n return (\n <>\n {footerButton(\n DialogResult.Yes,\n resolvedYesLabel,\n true,\n focusesConfirmButton,\n )}\n {footerButton(\n DialogResult.No,\n resolvedNoLabel,\n false,\n focusesDismissingButton,\n )}\n </>\n );\n case DialogButtons.YesNoCancel:\n return (\n <>\n {footerButton(\n DialogResult.Yes,\n resolvedYesLabel,\n true,\n focusesConfirmButton,\n )}\n {footerButton(DialogResult.No, resolvedNoLabel, false, false)}\n {footerButton(\n DialogResult.Cancelled,\n resolvedCancelLabel,\n false,\n focusesDismissingButton,\n )}\n </>\n );\n default:\n return null;\n }\n };\n\n const dialogDocument = (\n <DialogStackContext.Provider value={resolvedZIndex ?? DIALOG_ZINDEX_TOKEN}>\n <AriaDialog\n className='cratis-dialog__document'\n aria-describedby={hasSubtitle ? subtitleId : undefined}\n >\n <>\n <header\n {...pt?.header}\n className={classNames('cratis-dialog__header', pt?.header?.className)}\n style={pt?.header?.style}\n data-cratis-part='header'\n >\n <Heading\n {...pt?.title}\n slot='title'\n tabIndex={focusesTitle ? -1 : undefined}\n ref={titleRef}\n className={classNames(\n 'cratis-dialog__title',\n pt?.title?.className,\n )}\n style={pt?.title?.style}\n data-cratis-part='title'\n >\n {title}\n </Heading>\n {hasSubtitle && (\n <p\n {...pt?.subtitle}\n id={subtitleId}\n className={classNames(\n 'cratis-dialog__subtitle',\n pt?.subtitle?.className,\n )}\n style={pt?.subtitle?.style}\n data-cratis-part='subtitle'\n >\n {subtitle}\n </p>\n )}\n {hasHeaderActions && (\n <div\n {...pt?.headerActions}\n className={classNames(\n 'cratis-dialog__header-actions',\n pt?.headerActions?.className,\n )}\n style={{ ...headerActionsStyle(showsCloseButton), ...pt?.headerActions?.style }}\n data-cratis-part='header-actions'\n >\n {headerActions}\n {dialogHeaderActions && !hideGlobalHeaderActions && (\n <DialogGlobalHeaderActions\n render={dialogHeaderActions}\n context={{ dialogId, title, isCommandDialog, sliceLocation }}\n />\n )}\n </div>\n )}\n {showsCloseButton && (\n <button\n {...pt?.close}\n type='button'\n disabled={isBusy}\n className={classNames(\n 'cratis-dialog__close',\n pt?.close?.className,\n )}\n style={hasHeaderActions ? { justifySelf: 'end', ...pt?.close?.style } : pt?.close?.style}\n data-cratis-part='close'\n data-disabled={isBusy || undefined}\n data-busy={isBusy || undefined}\n aria-label={resolvedCloseAriaLabel}\n onClick={() => void handleClose(DialogResult.Cancelled)}\n >\n <span aria-hidden='true'>{resolvedCloseIcon}</span>\n </button>\n )}\n </header>\n <div\n {...pt?.content}\n className={classNames(\n 'cratis-dialog__content',\n pt?.content?.className,\n )}\n style={{ ...pt?.content?.style, ...contentStyle }}\n data-cratis-part='content'\n data-open={visible || undefined}\n data-busy={isBusy || undefined}\n >\n <fieldset\n className='cratis-dialog__busy-scope'\n data-cratis-part='busy-scope'\n data-busy={isBusy || undefined}\n disabled={isBusy}\n inert={isBusy}\n aria-busy={isBusy || undefined}\n >\n {children}\n </fieldset>\n </div>\n {buttons !== null && (\n <footer\n {...pt?.footer}\n className={classNames(\n 'cratis-dialog__footer',\n pt?.footer?.className,\n )}\n style={pt?.footer?.style}\n data-cratis-part='footer'\n >\n <fieldset\n className='cratis-dialog__busy-scope cratis-dialog__busy-scope--footer'\n data-cratis-part='busy-scope'\n data-busy={isBusy || undefined}\n disabled={isFooterScopeBusy}\n inert={isFooterScopeBusy}\n aria-busy={isBusy || undefined}\n >\n {predefinedFooter()}\n </fieldset>\n </footer>\n )}\n <div\n className='cratis-dialog__live-region'\n style={visuallyHidden}\n role='status'\n aria-live='polite'\n aria-atomic='true'\n >\n {announcement && <span key={announcement.key}>{announcement.text}</span>}\n </div>\n </>\n </AriaDialog>\n </DialogStackContext.Provider>\n );\n\n const dialogStyle = { width, ...pt?.root?.style, ...style };\n\n // useSyncExternalStore supplies the server snapshot during hydration, so this\n // fallback is identical on the server and on the client's first render. React\n // switches to the portaled React Aria modal only after hydration completes.\n if (!isBrowser) {\n if (!visible) return null;\n return (\n <div\n {...pt?.backdrop}\n className={classNames('cratis-dialog__backdrop', pt?.backdrop?.className)}\n style={{\n zIndex: resolvedZIndex ?? DIALOG_ZINDEX_TOKEN,\n ...pt?.backdrop?.style,\n }}\n data-cratis-part='backdrop'\n data-placement={placement}\n data-open={visible || undefined}\n data-busy={isBusy || undefined}\n >\n <div\n {...pt?.positioner}\n className={classNames(\n 'cratis-dialog__positioner',\n pt?.positioner?.className,\n )}\n style={pt?.positioner?.style}\n data-cratis-part='positioner'\n data-placement={placement}\n data-open={visible || undefined}\n data-busy={isBusy || undefined}\n >\n <section\n {...pt?.root}\n className={classNames(\n 'cratis-dialog',\n pt?.root?.className,\n className,\n )}\n style={dialogStyle}\n data-cratis-part='root'\n {...marker}\n data-cratis-dialog-id={dialogId}\n data-placement={placement}\n data-open={visible || undefined}\n data-busy={isBusy || undefined}\n >\n {dialogDocument}\n </section>\n </div>\n </div>\n );\n }\n\n return (\n <UNSAFE_PortalProvider getContainer={overlayEnvironment.getContainer}>\n <ModalOverlay\n {...pt?.backdrop}\n isOpen={visible}\n onOpenChange={(open) => {\n if (!open && !isBusy) void handleClose(DialogResult.Cancelled);\n }}\n isDismissable={allowsOutsideDismissal}\n isKeyboardDismissDisabled={!allowsEscapeDismissal}\n className={classNames('cratis-dialog__backdrop', pt?.backdrop?.className)}\n style={{\n zIndex: resolvedZIndex ?? DIALOG_ZINDEX_TOKEN,\n ...pt?.backdrop?.style,\n }}\n data-cratis-part='backdrop'\n data-placement={placement}\n data-open={visible || undefined}\n data-busy={isBusy || undefined}\n >\n <div\n {...pt?.positioner}\n className={classNames(\n 'cratis-dialog__positioner',\n pt?.positioner?.className,\n )}\n style={pt?.positioner?.style}\n data-cratis-part='positioner'\n data-placement={placement}\n data-open={visible || undefined}\n data-busy={isBusy || undefined}\n >\n <Modal\n {...pt?.root}\n className={classNames(\n 'cratis-dialog',\n pt?.root?.className,\n className,\n )}\n style={dialogStyle}\n data-cratis-part='root'\n {...marker}\n data-cratis-dialog-id={dialogId}\n data-placement={placement}\n data-open={visible || undefined}\n data-busy={isBusy || undefined}\n >\n {dialogDocument}\n </Modal>\n </div>\n </ModalOverlay>\n </UNSAFE_PortalProvider>\n );\n};\n"],"names":["_jsxs","_jsx","_Fragment","AriaDialog"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAM,cAAc,GAAwB;AACxC,IAAA,QAAQ,EAAE,UAAU;AACpB,IAAA,KAAK,EAAE,CAAC;AACR,IAAA,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,EAAE;AACV,IAAA,OAAO,EAAE,CAAC;AACV,IAAA,QAAQ,EAAE,QAAQ;AAClB,IAAA,QAAQ,EAAE,YAAY;AACtB,IAAA,UAAU,EAAE,QAAQ;AACpB,IAAA,MAAM,EAAE,CAAC;CACZ;AAID,MAAM,kBAAkB,GAAG,CAAC,cAAuB,MAA2B;AAC1E,IAAA,OAAO,EAAE,aAAa;AACtB,IAAA,UAAU,EAAE,CAAC;AACb,IAAA,OAAO,EAAE,CAAC;AACV,IAAA,WAAW,EAAE,KAAK;AAClB,IAAA,UAAU,EAAE,QAAQ;AACpB,IAAA,GAAG,EAAE,SAAS;IACd,eAAe,EAAE,cAAc,GAAG,SAAS,GAAG,SAAS;AAC1D,CAAA,CAAC;AAEF,MAAM,6BAA6B,GAAG,MAAM,MAAM,SAAS;AAC3D,MAAM,YAAY,GAAG,MACjB,oBAAoB,CAChB,6BAA6B,EAC7B,MAAM,IAAI,EACV,MAAM,KAAK,CACd;AAME,MAAM,oBAAoB,GAAG,CAAC,aAA0B,KAAI;AAC/D,IAAA,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,wBAAwB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B,EACjD,SAAS,EAAE,UAAU,CAAC,yBAAyB,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,CAAC,EACzE,KAAK,EAAE;gBACH,MAAM,EAAE,cAAc,IAAI,mBAAmB;AAC7C,gBAAA,GAAG,EAAE,EAAE,QAAQ,EAAE,KAAK;aACzB,EAAA,kBAAA,EACgB,UAAU,oBACX,SAAS,EAAA,WAAA,EACd,OAAO,IAAI,SAAS,eACpB,MAAM,IAAI,SAAS,EAAA,QAAA,EAE9BA,GAAA,CAAA,KAAA,EAAA,EAAA,GACQ,EAAE,EAAE,UAAU,EAClB,SAAS,EAAE,UAAU,CACjB,2BAA2B,EAC3B,EAAE,EAAE,UAAU,EAAE,SAAS,CAC5B,EACD,KAAK,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,EAAA,kBAAA,EACX,YAAY,oBACb,SAAS,EAAA,WAAA,EACd,OAAO,IAAI,SAAS,EAAA,WAAA,EACpB,MAAM,IAAI,SAAS,YAE9BA,GAAA,CAAC,KAAK,OACE,EAAE,EAAE,IAAI,EACZ,SAAS,EAAE,UAAU,CACjB,eAAe,EACf,EAAE,EAAE,IAAI,EAAE,SAAS,EACnB,SAAS,CACZ,EACD,KAAK,EAAE,WAAW,EAAA,kBAAA,EACD,MAAM,KACnB,MAAM,EAAA,uBAAA,EACa,QAAQ,EAAA,gBAAA,EACf,SAAS,EAAA,WAAA,EACd,OAAO,IAAI,SAAS,eACpB,MAAM,IAAI,SAAS,EAAA,QAAA,EAE7B,cAAc,GACX,EAAA,CACN,EAAA,CACK,EAAA,CACK;AAEhC;;"}
|
|
1
|
+
{"version":3,"file":"DialogImplementation.js","sources":["../../../Dialogs/DialogImplementation.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 { DialogResult, DialogButtons } from '@cratis/arc.react/dialogs';\nimport { useId, useSyncExternalStore } from 'react';\nimport { unstable_useOverlayEnvironment } from '../renderer/RendererContext';\nimport { DialogInitialFocus } from './DialogInitialFocus';\nimport type { DialogProps } from './Dialog';\nimport { resolveDialogDismissal } from './resolveDialogDismissal';\nimport { useCratisComponentsConfig } from '../Common/CratisComponentsProvider';\nimport { useCratisIcon } from '../configuration/useCratisIcon';\nimport { DIALOG_ZINDEX_TOKEN } from '../renderer/dialogStack';\nimport { useComponentPresentation } from '../configuration/identity/useComponentPresentation';\nimport { dialogDescriptor } from './dialogDescriptor';\nimport { DialogDocument } from './DialogDocument';\nimport { DialogModalShell, DialogServerShell } from './DialogShells';\nimport { resolveDialogLabels } from './resolveDialogLabels';\nimport { useDialogClose } from './useDialogClose';\nimport { useDialogFocus } from './useDialogFocus';\nimport { useDialogZIndex } from './useDialogZIndex';\n\nconst subscribeToBrowserEnvironment = () => () => undefined;\nconst useIsBrowser = () =>\n useSyncExternalStore(\n subscribeToBrowserEnvironment,\n () => true,\n () => false,\n );\n\n// A cancel-focused dialog without a dismissing button falls back to focusing the content.\nconst 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\nconst 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\n/**\n * A modal dialog with Arc host integration, typed footer actions, busy/validity\n * state, controlled dismissal, and stable Cratis-owned styling parts.\n */\nexport const DialogImplementation = (incomingProps: DialogProps) => {\n const [props, marker] = useComponentPresentation(dialogDescriptor, incomingProps);\n const {\n title,\n subtitle,\n placement = 'center',\n closeIcon,\n headerActions,\n hideGlobalHeaderActions = false,\n sliceLocation,\n isCommandDialog = false,\n visible = true,\n buttons = DialogButtons.OkCancel,\n initialFocus = DialogInitialFocus.Confirm,\n children,\n width = '450px',\n isValid,\n isBusy = false,\n pt,\n } = props;\n const { messages, dialogHeaderActions } = useCratisComponentsConfig();\n const dialogId = useId();\n const subtitleId = useId();\n const labels = resolveDialogLabels(props, messages?.dialog);\n const icon = useCratisIcon();\n const isBrowser = useIsBrowser();\n const overlayEnvironment = unstable_useOverlayEnvironment();\n\n const hasHeaderActions =\n headerActions != null || (dialogHeaderActions !== undefined && !hideGlobalHeaderActions);\n const hasSubtitle = subtitle !== undefined && subtitle !== null && subtitle !== false;\n const resolvedInitialFocus = resolveInitialFocus(initialFocus, buttons);\n const focus = {\n confirm: resolvedInitialFocus === DialogInitialFocus.Confirm,\n dismissing: resolvedInitialFocus === DialogInitialFocus.Cancel,\n };\n const { allowsOutsideDismissal, allowsEscapeDismissal, showsCloseButton } = dismissalFor(props, isBusy);\n\n const resolvedZIndex = useDialogZIndex(visible);\n const { titleRef, confirmRef, cancelRef, announcement, onRefused } = useDialogFocus({\n visible,\n isBusy,\n initialFocus: resolvedInitialFocus,\n refusedMessage: labels.refused,\n });\n const handleClose = useDialogClose(props, onRefused);\n\n const dialogDocument = (\n <DialogDocument\n stackZIndex={resolvedZIndex ?? DIALOG_ZINDEX_TOKEN}\n visible={visible}\n contentStyle={props.contentStyle}\n announcement={announcement}\n header={{\n dialogId,\n title,\n subtitle,\n subtitleId,\n hasSubtitle,\n hasHeaderActions,\n headerActions,\n globalHeaderActions: dialogHeaderActions,\n hideGlobalHeaderActions,\n isCommandDialog,\n sliceLocation,\n showsCloseButton,\n focusesTitle: resolvedInitialFocus === DialogInitialFocus.Content,\n titleRef,\n isBusy,\n closeAriaLabel: labels.closeAria,\n closeIcon: icon('close', '×', closeIcon),\n onClose: () => void handleClose(DialogResult.Cancelled),\n pt,\n }}\n footer={\n buttons === null\n ? null\n : {\n buttons,\n labels,\n focus,\n isBusy,\n isValid: isValid !== false,\n pt,\n confirmRef,\n cancelRef,\n onResult: (result) => void handleClose(result),\n }\n }\n >\n {children}\n </DialogDocument>\n );\n\n const shell = {\n placement,\n visible,\n isBusy,\n zIndex: resolvedZIndex,\n width,\n style: props.style,\n className: props.className,\n dialogId,\n marker,\n pt,\n children: dialogDocument,\n };\n\n // useSyncExternalStore supplies the server snapshot during hydration, so this\n // fallback is identical on the server and on the client's first render. React\n // switches to the portaled React Aria modal only after hydration completes.\n if (!isBrowser) return <DialogServerShell {...shell} />;\n\n return (\n <DialogModalShell\n {...shell}\n portalContainer={overlayEnvironment.getContainer}\n allowsOutsideDismissal={allowsOutsideDismissal}\n allowsEscapeDismissal={allowsEscapeDismissal}\n onDismiss={() => void handleClose(DialogResult.Cancelled)}\n />\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,6BAA6B,GAAG,MAAM,MAAM,SAAS;AAC3D,MAAM,YAAY,GAAG,MACjB,oBAAoB,CAChB,6BAA6B,EAC7B,MAAM,IAAI,EACV,MAAM,KAAK,CACd;AAGL,MAAM,mBAAmB,GAAG,CAAC,YAAgC,EAAE,OAA+B,KAAI;AAC9F,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,CAAC;AAED,MAAM,YAAY,GAAG,CAAC,KAAkB,EAAE,MAAe,KACrD,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,KA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gBACI,OAAO;gBACP,MAAM;gBACN,KAAK;gBACL,MAAM;gBACN,OAAO,EAAE,OAAO,KAAK,KAAK;gBAC1B,EAAE;gBACF,UAAU;gBACV,SAAS;gBACT,QAAQ,EAAE,CAAC,MAAM,KAAK,KAAK,WAAW,CAAC,MAAM,CAAC;aACjD,EAAA,QAAA,EAGV,QAAQ,EAAA,CACI,CACpB;AAED,IAAA,MAAM,KAAK,GAAG;QACV,SAAS;QACT,OAAO;QACP,MAAM;AACN,QAAA,MAAM,EAAE,cAAc;QACtB,KAAK;QACL,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,QAAQ;QACR,MAAM;QACN,EAAE;AACF,QAAA,QAAQ,EAAE,cAAc;KAC3B;AAKD,IAAA,IAAI,CAAC,SAAS;AAAE,QAAA,OAAOA,GAAA,CAAC,iBAAiB,EAAA,EAAA,GAAK,KAAK,GAAI;AAEvD,IAAA,QACIA,GAAA,CAAC,gBAAgB,EAAA,EAAA,GACT,KAAK,EACT,eAAe,EAAE,kBAAkB,CAAC,YAAY,EAChD,sBAAsB,EAAE,sBAAsB,EAC9C,qBAAqB,EAAE,qBAAqB,EAC5C,SAAS,EAAE,MAAM,KAAK,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,EAAA,CAC3D;AAEV;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { ComponentMarkerAttributes } from '../configuration/identity/ComponentMarkerAttributes.js';
|
|
3
|
+
import type { DialogParts, DialogProps } from './Dialog.js';
|
|
4
|
+
/** What every dialog shell needs to render the backdrop, positioner and root parts. */
|
|
5
|
+
export interface DialogShellProps {
|
|
6
|
+
placement: NonNullable<DialogProps['placement']>;
|
|
7
|
+
visible: boolean;
|
|
8
|
+
isBusy: boolean;
|
|
9
|
+
zIndex: string | undefined;
|
|
10
|
+
width: string;
|
|
11
|
+
style: React.CSSProperties | undefined;
|
|
12
|
+
className: string | undefined;
|
|
13
|
+
dialogId: string;
|
|
14
|
+
marker: ComponentMarkerAttributes;
|
|
15
|
+
pt: DialogParts | undefined;
|
|
16
|
+
children: React.ReactNode;
|
|
17
|
+
}
|
|
18
|
+
interface ModalShellProps extends DialogShellProps {
|
|
19
|
+
portalContainer: () => HTMLElement | null;
|
|
20
|
+
allowsOutsideDismissal: boolean;
|
|
21
|
+
allowsEscapeDismissal: boolean;
|
|
22
|
+
onDismiss: () => void;
|
|
23
|
+
}
|
|
24
|
+
/** The server and first-hydration shell, identical on both so hydration matches. */
|
|
25
|
+
export declare const DialogServerShell: (shell: DialogShellProps) => React.JSX.Element | null;
|
|
26
|
+
/** The portaled React Aria modal shell used once the client has hydrated. */
|
|
27
|
+
export declare const DialogModalShell: (props: ModalShellProps) => React.JSX.Element;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=DialogShells.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DialogShells.d.ts","sourceRoot":"","sources":["../../../Dialogs/DialogShells.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,wDAAqD,CAAC;AACrG,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAU,CAAC;AAEzD,uFAAuF;AACvF,MAAM,WAAW,gBAAgB;IAC7B,SAAS,EAAE,WAAW,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC;IACjD,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,KAAK,CAAC,aAAa,GAAG,SAAS,CAAC;IACvC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,yBAAyB,CAAC;IAClC,EAAE,EAAE,WAAW,GAAG,SAAS,CAAC;IAC5B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC7B;AAED,UAAU,eAAgB,SAAQ,gBAAgB;IAC9C,eAAe,EAAE,MAAM,WAAW,GAAG,IAAI,CAAC;IAC1C,sBAAsB,EAAE,OAAO,CAAC;IAChC,qBAAqB,EAAE,OAAO,CAAC;IAC/B,SAAS,EAAE,MAAM,IAAI,CAAC;CACzB;AAwDD,oFAAoF;AACpF,eAAO,MAAM,iBAAiB,UAAW,gBAAgB,6BAC6B,CAAC;AAEvF,6EAA6E;AAC7E,eAAO,MAAM,gBAAgB,UAAW,eAAe,sBAgBtD,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Modal, ModalOverlay } from 'react-aria-components/Modal';
|
|
3
|
+
import { UNSAFE_PortalProvider } from 'react-aria';
|
|
4
|
+
import { dialogPartAttributes } from './dialogPartAttributes.js';
|
|
5
|
+
import { DIALOG_ZINDEX_TOKEN } from '../renderer/dialogStack.js';
|
|
6
|
+
|
|
7
|
+
const backdropStyle = ({ zIndex, pt }) => ({
|
|
8
|
+
zIndex: zIndex ?? DIALOG_ZINDEX_TOKEN,
|
|
9
|
+
...pt?.backdrop?.style,
|
|
10
|
+
});
|
|
11
|
+
const rootStyle = ({ width, pt, style }) => ({
|
|
12
|
+
width,
|
|
13
|
+
...pt?.root?.style,
|
|
14
|
+
...style,
|
|
15
|
+
});
|
|
16
|
+
const ShellLayers = ({ shell, Backdrop, backdropProps, Root }) => {
|
|
17
|
+
const { pt, placement, visible, isBusy, className, dialogId, marker, children } = shell;
|
|
18
|
+
return (jsx(Backdrop, { ...dialogPartAttributes(pt?.backdrop, 'cratis-dialog__backdrop', backdropStyle(shell)), ...backdropProps, "data-cratis-part": 'backdrop', "data-placement": placement, "data-open": visible || undefined, "data-busy": isBusy || undefined, children: jsx("div", { ...dialogPartAttributes(pt?.positioner, 'cratis-dialog__positioner'), "data-cratis-part": 'positioner', "data-placement": placement, "data-open": visible || undefined, "data-busy": isBusy || undefined, children: jsx(Root, { ...dialogPartAttributes(pt?.root, 'cratis-dialog', rootStyle(shell), className), "data-cratis-part": 'root', ...marker, "data-cratis-dialog-id": dialogId, "data-placement": placement, "data-open": visible || undefined, "data-busy": isBusy || undefined, children: children }) }) }));
|
|
19
|
+
};
|
|
20
|
+
const DialogServerShell = (shell) => shell.visible ? jsx(ShellLayers, { shell: shell, Backdrop: 'div', Root: 'section' }) : null;
|
|
21
|
+
const DialogModalShell = (props) => {
|
|
22
|
+
const { visible, isBusy } = props;
|
|
23
|
+
const backdropProps = {
|
|
24
|
+
isOpen: visible,
|
|
25
|
+
onOpenChange: (open) => {
|
|
26
|
+
if (!open && !isBusy)
|
|
27
|
+
props.onDismiss();
|
|
28
|
+
},
|
|
29
|
+
isDismissable: props.allowsOutsideDismissal,
|
|
30
|
+
isKeyboardDismissDisabled: !props.allowsEscapeDismissal,
|
|
31
|
+
};
|
|
32
|
+
return (jsx(UNSAFE_PortalProvider, { getContainer: props.portalContainer, children: jsx(ShellLayers, { shell: props, Backdrop: ModalOverlay, backdropProps: backdropProps, Root: Modal }) }));
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export { DialogModalShell, DialogServerShell };
|
|
36
|
+
//# sourceMappingURL=DialogShells.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DialogShells.js","sources":["../../../Dialogs/DialogShells.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 { Modal, ModalOverlay } from 'react-aria-components/Modal';\nimport { UNSAFE_PortalProvider } from 'react-aria';\nimport type React from 'react';\nimport { dialogPartAttributes } from './dialogPartAttributes';\nimport { DIALOG_ZINDEX_TOKEN } from '../renderer/dialogStack';\nimport type { ComponentMarkerAttributes } from '../configuration/identity/ComponentMarkerAttributes';\nimport type { DialogParts, DialogProps } from './Dialog';\n\n/** What every dialog shell needs to render the backdrop, positioner and root parts. */\nexport interface DialogShellProps {\n placement: NonNullable<DialogProps['placement']>;\n visible: boolean;\n isBusy: boolean;\n zIndex: string | undefined;\n width: string;\n style: React.CSSProperties | undefined;\n className: string | undefined;\n dialogId: string;\n marker: ComponentMarkerAttributes;\n pt: DialogParts | undefined;\n children: React.ReactNode;\n}\n\ninterface ModalShellProps extends DialogShellProps {\n portalContainer: () => HTMLElement | null;\n allowsOutsideDismissal: boolean;\n allowsEscapeDismissal: boolean;\n onDismiss: () => void;\n}\n\nconst backdropStyle = ({ zIndex, pt }: DialogShellProps): React.CSSProperties => ({\n zIndex: zIndex ?? DIALOG_ZINDEX_TOKEN,\n ...pt?.backdrop?.style,\n});\n\nconst rootStyle = ({ width, pt, style }: DialogShellProps): React.CSSProperties => ({\n width,\n ...pt?.root?.style,\n ...style,\n});\n\ninterface ShellLayersProps {\n shell: DialogShellProps;\n Backdrop: React.ElementType;\n backdropProps?: object;\n Root: React.ElementType;\n}\n\n/** The backdrop, positioner and root parts shared by the server and the modal shell. */\nconst ShellLayers = ({ shell, Backdrop, backdropProps, Root }: ShellLayersProps) => {\n const { pt, placement, visible, isBusy, className, dialogId, marker, children } = shell;\n\n return (\n <Backdrop\n {...dialogPartAttributes(pt?.backdrop, 'cratis-dialog__backdrop', backdropStyle(shell))}\n {...backdropProps}\n data-cratis-part='backdrop'\n data-placement={placement}\n data-open={visible || undefined}\n data-busy={isBusy || undefined}\n >\n <div\n {...dialogPartAttributes(pt?.positioner, 'cratis-dialog__positioner')}\n data-cratis-part='positioner'\n data-placement={placement}\n data-open={visible || undefined}\n data-busy={isBusy || undefined}\n >\n <Root\n {...dialogPartAttributes(pt?.root, 'cratis-dialog', rootStyle(shell), className)}\n data-cratis-part='root'\n {...marker}\n data-cratis-dialog-id={dialogId}\n data-placement={placement}\n data-open={visible || undefined}\n data-busy={isBusy || undefined}\n >\n {children}\n </Root>\n </div>\n </Backdrop>\n );\n};\n\n/** The server and first-hydration shell, identical on both so hydration matches. */\nexport const DialogServerShell = (shell: DialogShellProps) =>\n shell.visible ? <ShellLayers shell={shell} Backdrop='div' Root='section' /> : null;\n\n/** The portaled React Aria modal shell used once the client has hydrated. */\nexport const DialogModalShell = (props: ModalShellProps) => {\n const { visible, isBusy } = props;\n const backdropProps = {\n isOpen: visible,\n onOpenChange: (open: boolean) => {\n if (!open && !isBusy) props.onDismiss();\n },\n isDismissable: props.allowsOutsideDismissal,\n isKeyboardDismissDisabled: !props.allowsEscapeDismissal,\n };\n\n return (\n <UNSAFE_PortalProvider getContainer={props.portalContainer}>\n <ShellLayers shell={props} Backdrop={ModalOverlay} backdropProps={backdropProps} Root={Modal} />\n </UNSAFE_PortalProvider>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;AAiCA,MAAM,aAAa,GAAG,CAAC,EAAE,MAAM,EAAE,EAAE,EAAoB,MAA2B;IAC9E,MAAM,EAAE,MAAM,IAAI,mBAAmB;AACrC,IAAA,GAAG,EAAE,EAAE,QAAQ,EAAE,KAAK;AACzB,CAAA,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAoB,MAA2B;IAChF,KAAK;AACL,IAAA,GAAG,EAAE,EAAE,IAAI,EAAE,KAAK;AAClB,IAAA,GAAG,KAAK;AACX,CAAA,CAAC;AAUF,MAAM,WAAW,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAoB,KAAI;AAC/E,IAAA,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK;IAEvF,QACIA,IAAC,QAAQ,EAAA,EAAA,GACD,oBAAoB,CAAC,EAAE,EAAE,QAAQ,EAAE,yBAAyB,EAAE,aAAa,CAAC,KAAK,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AAA,yBAAyB,EAAE,CAAC,KAAK,CAAC,qBAAqB;KAC1D;AAED,IAAA,QACIA,GAAA,CAAC,qBAAqB,EAAA,EAAC,YAAY,EAAE,KAAK,CAAC,eAAe,EAAA,QAAA,EACtDA,GAAA,CAAC,WAAW,IAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,IAAI,EAAE,KAAK,EAAA,CAAI,EAAA,CAC5E;AAEhC;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
interface PartAttributes {
|
|
3
|
+
className?: string;
|
|
4
|
+
style?: React.CSSProperties;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Merges a consumer's `pt` part attributes over a dialog part's own class and style.
|
|
8
|
+
* @param part The consumer's attributes for the part, when any.
|
|
9
|
+
* @param className The part's own class name.
|
|
10
|
+
* @param style A style that replaces the consumer's, when the part computes one.
|
|
11
|
+
* @param extraClassName A trailing class name, such as the host's `className`.
|
|
12
|
+
* @returns The attributes to spread onto the part element.
|
|
13
|
+
*/
|
|
14
|
+
export declare const dialogPartAttributes: <T extends PartAttributes>(part: T | undefined, className: string, style?: React.CSSProperties, extraClassName?: string) => {
|
|
15
|
+
className: string;
|
|
16
|
+
style: React.CSSProperties | undefined;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=dialogPartAttributes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialogPartAttributes.d.ts","sourceRoot":"","sources":["../../../Dialogs/dialogPartAttributes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,UAAU,cAAc;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC/B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAAS,cAAc,QACnD,CAAC,GAAG,SAAS,aACR,MAAM,UACT,KAAK,CAAC,aAAa,mBACV,MAAM;;;CAKzB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { classNames } from '../ClassNames/classNames.js';
|
|
2
|
+
|
|
3
|
+
const dialogPartAttributes = (part, className, style, extraClassName) => ({
|
|
4
|
+
...part,
|
|
5
|
+
className: classNames(className, part?.className, extraClassName),
|
|
6
|
+
style: style ?? part?.style,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export { dialogPartAttributes };
|
|
10
|
+
//# sourceMappingURL=dialogPartAttributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialogPartAttributes.js","sources":["../../../Dialogs/dialogPartAttributes.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 React from 'react';\nimport { classNames } from '../ClassNames/classNames';\n\ninterface PartAttributes {\n className?: string;\n style?: React.CSSProperties;\n}\n\n/**\n * Merges a consumer's `pt` part attributes over a dialog part's own class and style.\n * @param part The consumer's attributes for the part, when any.\n * @param className The part's own class name.\n * @param style A style that replaces the consumer's, when the part computes one.\n * @param extraClassName A trailing class name, such as the host's `className`.\n * @returns The attributes to spread onto the part element.\n */\nexport const dialogPartAttributes = <T extends PartAttributes>(\n part: T | undefined,\n className: string,\n style?: React.CSSProperties,\n extraClassName?: string,\n) => ({\n ...part,\n className: classNames(className, part?.className, extraClassName),\n style: style ?? part?.style,\n});\n"],"names":[],"mappings":";;AAmBO,MAAM,oBAAoB,GAAG,CAChC,IAAmB,EACnB,SAAiB,EACjB,KAA2B,EAC3B,cAAuB,MACrB;AACF,IAAA,GAAG,IAAI;IACP,SAAS,EAAE,UAAU,CAAC,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,cAAc,CAAC;AACjE,IAAA,KAAK,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK;AAC9B,CAAA;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { DialogProps } from './Dialog.js';
|
|
2
|
+
/** The configured dialog messages, as supplied by the Cratis components configuration. */
|
|
3
|
+
export interface DialogMessages {
|
|
4
|
+
ok?: string;
|
|
5
|
+
cancel?: string;
|
|
6
|
+
yes?: string;
|
|
7
|
+
no?: string;
|
|
8
|
+
close?: string;
|
|
9
|
+
refused?: string;
|
|
10
|
+
}
|
|
11
|
+
/** The fully resolved, user-visible dialog texts. */
|
|
12
|
+
export interface DialogLabels {
|
|
13
|
+
ok: string;
|
|
14
|
+
cancel: string;
|
|
15
|
+
yes: string;
|
|
16
|
+
no: string;
|
|
17
|
+
closeAria: string;
|
|
18
|
+
refused: string;
|
|
19
|
+
}
|
|
20
|
+
type LabelProps = Pick<DialogProps, 'okLabel' | 'cancelLabel' | 'yesLabel' | 'noLabel' | 'closeAriaLabel'>;
|
|
21
|
+
/**
|
|
22
|
+
* Resolves each label from the explicit prop, then the configured messages, then the built-in default.
|
|
23
|
+
* @param props The dialog's label props.
|
|
24
|
+
* @param messages The configured dialog messages, when any.
|
|
25
|
+
* @returns The resolved labels.
|
|
26
|
+
*/
|
|
27
|
+
export declare const resolveDialogLabels: (props: LabelProps, messages?: DialogMessages) => DialogLabels;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=resolveDialogLabels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveDialogLabels.d.ts","sourceRoot":"","sources":["../../../Dialogs/resolveDialogLabels.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAU,CAAC;AAE5C,0FAA0F;AAC1F,MAAM,WAAW,cAAc;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,qDAAqD;AACrD,MAAM,WAAW,YAAY;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,KAAK,UAAU,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,GAAG,aAAa,GAAG,UAAU,GAAG,SAAS,GAAG,gBAAgB,CAAC,CAAC;AAE3G;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,UAAW,UAAU,aAAa,cAAc,KAAG,YAOjF,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const resolveDialogLabels = (props, messages) => ({
|
|
2
|
+
ok: props.okLabel ?? messages?.ok ?? 'Ok',
|
|
3
|
+
cancel: props.cancelLabel ?? messages?.cancel ?? 'Cancel',
|
|
4
|
+
yes: props.yesLabel ?? messages?.yes ?? 'Yes',
|
|
5
|
+
no: props.noLabel ?? messages?.no ?? 'No',
|
|
6
|
+
closeAria: props.closeAriaLabel ?? messages?.close ?? 'Close',
|
|
7
|
+
refused: messages?.refused ?? 'The action was not completed. Review the dialog and try again.',
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export { resolveDialogLabels };
|
|
11
|
+
//# sourceMappingURL=resolveDialogLabels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveDialogLabels.js","sources":["../../../Dialogs/resolveDialogLabels.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 { DialogProps } from './Dialog';\n\n/** The configured dialog messages, as supplied by the Cratis components configuration. */\nexport interface DialogMessages {\n ok?: string;\n cancel?: string;\n yes?: string;\n no?: string;\n close?: string;\n refused?: string;\n}\n\n/** The fully resolved, user-visible dialog texts. */\nexport interface DialogLabels {\n ok: string;\n cancel: string;\n yes: string;\n no: string;\n closeAria: string;\n refused: string;\n}\n\ntype LabelProps = Pick<DialogProps, 'okLabel' | 'cancelLabel' | 'yesLabel' | 'noLabel' | 'closeAriaLabel'>;\n\n/**\n * Resolves each label from the explicit prop, then the configured messages, then the built-in default.\n * @param props The dialog's label props.\n * @param messages The configured dialog messages, when any.\n * @returns The resolved labels.\n */\nexport const resolveDialogLabels = (props: LabelProps, messages?: DialogMessages): DialogLabels => ({\n ok: props.okLabel ?? messages?.ok ?? 'Ok',\n cancel: props.cancelLabel ?? messages?.cancel ?? 'Cancel',\n yes: props.yesLabel ?? messages?.yes ?? 'Yes',\n no: props.noLabel ?? messages?.no ?? 'No',\n closeAria: props.closeAriaLabel ?? messages?.close ?? 'Close',\n refused: messages?.refused ?? 'The action was not completed. Review the dialog and try again.',\n});\n"],"names":[],"mappings":"AAiCO,MAAM,mBAAmB,GAAG,CAAC,KAAiB,EAAE,QAAyB,MAAoB;IAChG,EAAE,EAAE,KAAK,CAAC,OAAO,IAAI,QAAQ,EAAE,EAAE,IAAI,IAAI;IACzC,MAAM,EAAE,KAAK,CAAC,WAAW,IAAI,QAAQ,EAAE,MAAM,IAAI,QAAQ;IACzD,GAAG,EAAE,KAAK,CAAC,QAAQ,IAAI,QAAQ,EAAE,GAAG,IAAI,KAAK;IAC7C,EAAE,EAAE,KAAK,CAAC,OAAO,IAAI,QAAQ,EAAE,EAAE,IAAI,IAAI;IACzC,SAAS,EAAE,KAAK,CAAC,cAAc,IAAI,QAAQ,EAAE,KAAK,IAAI,OAAO;AAC7D,IAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,IAAI,gEAAgE;AACjG,CAAA;;"}
|