@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
package/compat-manifest.json
CHANGED
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
{
|
|
71
71
|
"name": "@cratis/components",
|
|
72
72
|
"role": "core",
|
|
73
|
-
"version": "4.
|
|
73
|
+
"version": "4.48.0",
|
|
74
74
|
"releaseMajorRange": ">=4 <5",
|
|
75
75
|
"independentRelease": false,
|
|
76
76
|
"private": false,
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
{
|
|
95
95
|
"name": "@cratis/eslint-plugin-components",
|
|
96
96
|
"role": "eslint",
|
|
97
|
-
"version": "4.
|
|
97
|
+
"version": "4.48.0",
|
|
98
98
|
"releaseMajorRange": ">=4 <5",
|
|
99
99
|
"independentRelease": false,
|
|
100
100
|
"private": false,
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
{
|
|
108
108
|
"name": "@cratis/components.migrator",
|
|
109
109
|
"role": "migrator",
|
|
110
|
-
"version": "4.
|
|
110
|
+
"version": "4.48.0",
|
|
111
111
|
"releaseMajorRange": ">=4 <5",
|
|
112
112
|
"independentRelease": false,
|
|
113
113
|
"private": false,
|
|
@@ -118,13 +118,13 @@
|
|
|
118
118
|
{
|
|
119
119
|
"name": "@cratis/components.conformance",
|
|
120
120
|
"role": "conformance",
|
|
121
|
-
"version": "4.
|
|
121
|
+
"version": "4.48.0",
|
|
122
122
|
"releaseMajorRange": ">=4 <5",
|
|
123
123
|
"independentRelease": false,
|
|
124
124
|
"private": false,
|
|
125
125
|
"packageAccess": "public",
|
|
126
126
|
"peerDependencies": {
|
|
127
|
-
"@cratis/components": "4.
|
|
127
|
+
"@cratis/components": "4.48.0",
|
|
128
128
|
"react": "^19.0.0",
|
|
129
129
|
"react-dom": "^19.0.0"
|
|
130
130
|
},
|
|
@@ -134,13 +134,13 @@
|
|
|
134
134
|
{
|
|
135
135
|
"name": "@cratis/components.mui",
|
|
136
136
|
"role": "renderer-adapter",
|
|
137
|
-
"version": "4.
|
|
137
|
+
"version": "4.48.0",
|
|
138
138
|
"releaseMajorRange": ">=4 <5",
|
|
139
139
|
"independentRelease": false,
|
|
140
140
|
"private": false,
|
|
141
141
|
"packageAccess": "public",
|
|
142
142
|
"peerDependencies": {
|
|
143
|
-
"@cratis/components": "4.
|
|
143
|
+
"@cratis/components": "4.48.0",
|
|
144
144
|
"@emotion/react": ">=11.5 <12",
|
|
145
145
|
"@emotion/styled": ">=11.11 <12",
|
|
146
146
|
"@mui/material": ">=9 <10",
|
|
@@ -190,13 +190,13 @@
|
|
|
190
190
|
{
|
|
191
191
|
"name": "@cratis/components.primereact",
|
|
192
192
|
"role": "renderer-adapter",
|
|
193
|
-
"version": "4.
|
|
193
|
+
"version": "4.48.0",
|
|
194
194
|
"releaseMajorRange": ">=4 <5",
|
|
195
195
|
"independentRelease": false,
|
|
196
196
|
"private": false,
|
|
197
197
|
"packageAccess": "public",
|
|
198
198
|
"peerDependencies": {
|
|
199
|
-
"@cratis/components": "4.
|
|
199
|
+
"@cratis/components": "4.48.0",
|
|
200
200
|
"@primereact/core": ">=11 <12",
|
|
201
201
|
"@primereact/ui": ">=11 <12",
|
|
202
202
|
"@primeuix/themes": ">=3 <4",
|
|
@@ -258,13 +258,13 @@
|
|
|
258
258
|
{
|
|
259
259
|
"name": "@cratis/components.primereact10",
|
|
260
260
|
"role": "renderer-adapter",
|
|
261
|
-
"version": "4.
|
|
261
|
+
"version": "4.48.0",
|
|
262
262
|
"releaseMajorRange": ">=4 <5",
|
|
263
263
|
"independentRelease": false,
|
|
264
264
|
"private": false,
|
|
265
265
|
"packageAccess": "public",
|
|
266
266
|
"peerDependencies": {
|
|
267
|
-
"@cratis/components": "4.
|
|
267
|
+
"@cratis/components": "4.48.0",
|
|
268
268
|
"primereact": ">=10.9.9 <11",
|
|
269
269
|
"react": "^19.0.0",
|
|
270
270
|
"react-dom": "^19.0.0"
|
|
@@ -306,13 +306,13 @@
|
|
|
306
306
|
{
|
|
307
307
|
"name": "@cratis/components.designsystemet",
|
|
308
308
|
"role": "renderer-adapter",
|
|
309
|
-
"version": "4.
|
|
309
|
+
"version": "4.48.0",
|
|
310
310
|
"releaseMajorRange": ">=4 <5",
|
|
311
311
|
"independentRelease": false,
|
|
312
312
|
"private": false,
|
|
313
313
|
"packageAccess": "public",
|
|
314
314
|
"peerDependencies": {
|
|
315
|
-
"@cratis/components": "4.
|
|
315
|
+
"@cratis/components": "4.48.0",
|
|
316
316
|
"@digdir/designsystemet-css": ">=1.24 <2",
|
|
317
317
|
"@digdir/designsystemet-react": ">=1.24 <2",
|
|
318
318
|
"react": "^19.0.0",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../../Dialogs/Dialog.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,KAAK,EACR,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,SAAS,EACZ,MAAM,OAAO,CAAC;AAIf,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yCAAsC,CAAC;AAChF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../../Dialogs/Dialog.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,KAAK,EACR,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,SAAS,EACZ,MAAM,OAAO,CAAC;AAIf,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yCAAsC,CAAC;AAChF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAsB,CAAC;AAI/D,uFAAuF;AACvF,MAAM,MAAM,WAAW,GAAG,CACtB,MAAM,EAAE,YAAY,KACnB,OAAO,GAAG,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAEvD,mEAAmE;AACnE,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,GAAG,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AACtF,mEAAmE;AACnE,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,GAAG,IAAI,GAAG,OA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0G;IAC1G,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iGAAiG;IACjG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8FAA8F;IAC9F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yHAAyH;IACzH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kGAAkG;IAClG,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,4FAA4F;IAC5F,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,iGAAiG;IACjG,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,EAAE,CAAC,EAAE,WAAW,CAAC;IACjB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAUD;;;GAGG;AACH,eAAO,MAAM,MAAM,UAAW,WAAW,+FAKxC,CAAC"}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { unstable_useSlot } from '../renderer/RendererContext.js';
|
|
2
2
|
import { renderSlot } from '../renderer/renderSlot.js';
|
|
3
3
|
import { DialogImplementation } from './DialogImplementation.js';
|
|
4
|
+
import { DialogSlotHost } from './DialogSlotHost.js';
|
|
4
5
|
|
|
5
6
|
const coreDialogDeclaration = Object.freeze({
|
|
6
7
|
mode: 'atomic',
|
|
7
8
|
fidelity: 'native',
|
|
8
9
|
render: DialogImplementation,
|
|
9
10
|
});
|
|
11
|
+
const slotHostDeclaration = Object.freeze({ render: DialogSlotHost });
|
|
10
12
|
const Dialog = (props) => {
|
|
11
13
|
const declaration = unstable_useSlot('dialogs.dialog', coreDialogDeclaration);
|
|
12
|
-
|
|
14
|
+
if (declaration.render === DialogImplementation)
|
|
15
|
+
return renderSlot(coreDialogDeclaration, props);
|
|
16
|
+
return renderSlot(slotHostDeclaration, { render: declaration.render, props });
|
|
13
17
|
};
|
|
14
18
|
|
|
15
19
|
export { Dialog };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","sources":["../../../Dialogs/Dialog.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 type { DialogResult, DialogButtons } from '@cratis/arc.react/dialogs';\nimport type {\n ButtonHTMLAttributes,\n CSSProperties,\n HTMLAttributes,\n ReactNode,\n} from 'react';\nimport { unstable_useSlot } from '../renderer/RendererContext';\nimport { renderSlot } from '../renderer/renderSlot';\nimport type { unstable_SlotDeclaration } from '../renderer/slots';\nimport type { DialogSliceLocation } from '../configuration/DialogSliceLocation';\nimport type { DialogInitialFocus } from './DialogInitialFocus';\nimport { DialogImplementation } from './DialogImplementation';\n\n/** Callback handling a typed dialog result; return `false` to keep the dialog open. */\nexport type CloseDialog = (\n result: DialogResult,\n) => boolean | void | Promise<boolean> | Promise<void>;\n\n/** Confirmation callback; return `true` to permit host closure. */\nexport type ConfirmCallback = () => boolean | void | Promise<boolean> | Promise<void>;\n/** Cancellation callback; return `true` to permit host closure. */\nexport type CancelCallback = () => boolean | void | Promise<boolean> | Promise<void>;\n\ntype DialogPartAttributes<TElement> = HTMLAttributes<TElement> & {\n [attribute: `data-${string}`]: string | number | boolean | undefined;\n};\n\ntype DialogButtonAttributes = Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n 'onClick' | 'value'\n>;\n\n/**\n * Where a {@link Dialog} sits in the viewport. `center` is the classic modal; `start` and `end`\n * make it a full-height side sheet against the inline-start or inline-end edge.\n */\nexport type DialogPlacement = 'center' | 'start' | 'end';\n\n/** Stable Cratis-owned parts for styling a {@link Dialog}. */\nexport interface DialogParts {\n /** Viewport backdrop and dismissal surface. */\n backdrop?: DialogPartAttributes<HTMLDivElement>;\n /** Viewport positioning wrapper. */\n positioner?: DialogPartAttributes<HTMLDivElement>;\n /** Modal root. */\n root?: DialogPartAttributes<HTMLDivElement>;\n /** Header containing title and optional close action. */\n header?: DialogPartAttributes<HTMLElement>;\n /** Dialog heading. */\n title?: DialogPartAttributes<HTMLHeadingElement>;\n /** Secondary line under the heading, rendered only when `subtitle` is set. */\n subtitle?: DialogPartAttributes<HTMLParagraphElement>;\n /** Region before the close button holding per-dialog and app-wide header actions. */\n headerActions?: DialogPartAttributes<HTMLDivElement>;\n /** Header close button. */\n close?: DialogButtonAttributes;\n /** Dialog content region. */\n content?: DialogPartAttributes<HTMLDivElement>;\n /** Footer action region. */\n footer?: DialogPartAttributes<HTMLElement>;\n /** Primary confirmation button. */\n confirm?: DialogButtonAttributes;\n /** Secondary dismissal button(s). */\n cancel?: DialogButtonAttributes;\n}\n\n/** Props for {@link Dialog}. */\nexport interface DialogProps {\n /** Dialog heading. */\n title: string;\n /**\n * Secondary line under the heading — a reference, a status, a short summary. Announced as the\n * dialog's description.\n */\n subtitle?: ReactNode;\n /**\n * Viewport placement. `center` (default) is a modal; `start` and `end` render a full-height\n * side sheet against that inline edge, sliding in from it. Dismissal, focus and busy behavior\n * are identical across placements.\n */\n placement?: DialogPlacement;\n /**\n * Actions rendered in the header before the close button, in a `header-actions` part. Use it\n * for a help, feedback or copy-link action that belongs to this dialog. Rendered next to the\n * app-wide actions registered on `CratisComponentsProvider`.\n */\n headerActions?: ReactNode;\n /** Suppresses the app-wide header actions registered on `CratisComponentsProvider` for this dialog. */\n hideGlobalHeaderActions?: boolean;\n /** Where this dialog's opener sits in the application. Passed to app-wide header actions as `sliceLocation`. */\n sliceLocation?: DialogSliceLocation;\n /**\n * Set by `CommandDialog` and `StepperCommandDialog` so app-wide header actions can tell a command\n * dialog from a plain one. Defaults to `false`.\n */\n isCommandDialog?: boolean;\n /**\n * Glyph for the header close button. Names this one dialog and wins over the provider's\n * `icons.close`; defaults to a multiplication sign when neither is set.\n */\n closeIcon?: ReactNode;\n /** Controlled open state. Defaults to `true`. */\n visible?: boolean;\n /** Combined result callback used when a dedicated confirm/cancel callback is absent. */\n onClose?: CloseDialog;\n /** Invoked by primary confirmation actions. */\n onConfirm?: ConfirmCallback;\n /** Invoked by cancellation actions. */\n onCancel?: CancelCallback;\n /** Predefined Arc buttons, custom footer content, or `null` for no footer. */\n buttons?: DialogButtons | ReactNode;\n /** Initial focus target. Defaults to the confirmation action. */\n initialFocus?: DialogInitialFocus;\n /** Dialog body content. */\n children: ReactNode;\n /** CSS width. Defaults to `450px`. */\n width?: string;\n /** Modal-root inline style. */\n style?: CSSProperties;\n /** Content-region inline style. */\n contentStyle?: CSSProperties;\n /**\n * @deprecated The Cratis dialog is viewport-bounded rather than resizable. Remove this prop.\n */\n resizable?: boolean;\n /** Whether the primary action is enabled. Defaults to `true`. */\n isValid?: boolean;\n /** Disables every action and dismissal path while work is in flight. */\n isBusy?: boolean;\n /** Label for the Ok action. Falls back to the provider's `dialog.ok` message, then `'Ok'`. */\n okLabel?: string;\n /** Label for the Cancel action. Falls back to the provider's `dialog.cancel` message, then `'Cancel'`. */\n cancelLabel?: string;\n /** Label for the Yes action. Falls back to the provider's `dialog.yes` message, then `'Yes'`. */\n yesLabel?: string;\n /** Label for the No action. Falls back to the provider's `dialog.no` message, then `'No'`. */\n noLabel?: string;\n /** Accessible label for the header close button. Falls back to the provider's `dialog.close` message, then `'Close'`. */\n closeAriaLabel?: string;\n /**\n * Combined default for header, Escape, and backdrop dismissal. Defaults to true\n * for predefined buttons and false for custom/no footer. Independent props override it.\n */\n dismissable?: boolean;\n /** Whether outside clicks dismiss the dialog. Falls back to `dismissable`; blocked while busy. */\n dismissOnOutsideClick?: boolean;\n /** Whether Escape dismisses the dialog. Falls back to `dismissable`; blocked while busy. */\n closeOnEscape?: boolean;\n /** Whether to show the header close button. Falls back to `dismissable`; disabled while busy. */\n showCloseButton?: boolean;\n /** Extra class name for the modal root. */\n className?: string;\n /** Cratis-owned per-part attributes. */\n pt?: DialogParts;\n /**\n * @deprecated Cratis parts always merge. Remove this renderer-era option.\n */\n ptOptions?: object;\n /**\n * @deprecated Components always uses consumer-owned CSS. Customize through `pt` and CSS instead.\n */\n unstyled?: boolean;\n}\n\nconst coreDialogDeclaration = Object.freeze({\n mode: 'atomic',\n fidelity: 'native',\n render: DialogImplementation,\n}) satisfies unstable_SlotDeclaration<'dialogs.dialog'>;\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 Dialog = (props: DialogProps) => {\n const declaration = unstable_useSlot('dialogs.dialog', coreDialogDeclaration);\n return renderSlot(declaration, props);\n};\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Dialog.js","sources":["../../../Dialogs/Dialog.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 type { DialogResult, DialogButtons } from '@cratis/arc.react/dialogs';\nimport type {\n ButtonHTMLAttributes,\n CSSProperties,\n HTMLAttributes,\n ReactNode,\n} from 'react';\nimport { unstable_useSlot } from '../renderer/RendererContext';\nimport { renderSlot } from '../renderer/renderSlot';\nimport type { unstable_SlotDeclaration } from '../renderer/slots';\nimport type { DialogSliceLocation } from '../configuration/DialogSliceLocation';\nimport type { DialogInitialFocus } from './DialogInitialFocus';\nimport { DialogImplementation } from './DialogImplementation';\nimport { DialogSlotHost } from './DialogSlotHost';\n\n/** Callback handling a typed dialog result; return `false` to keep the dialog open. */\nexport type CloseDialog = (\n result: DialogResult,\n) => boolean | void | Promise<boolean> | Promise<void>;\n\n/** Confirmation callback; return `true` to permit host closure. */\nexport type ConfirmCallback = () => boolean | void | Promise<boolean> | Promise<void>;\n/** Cancellation callback; return `true` to permit host closure. */\nexport type CancelCallback = () => boolean | void | Promise<boolean> | Promise<void>;\n\ntype DialogPartAttributes<TElement> = HTMLAttributes<TElement> & {\n [attribute: `data-${string}`]: string | number | boolean | undefined;\n};\n\ntype DialogButtonAttributes = Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n 'onClick' | 'value'\n>;\n\n/**\n * Where a {@link Dialog} sits in the viewport. `center` is the classic modal; `start` and `end`\n * make it a full-height side sheet against the inline-start or inline-end edge.\n */\nexport type DialogPlacement = 'center' | 'start' | 'end';\n\n/** Stable Cratis-owned parts for styling a {@link Dialog}. */\nexport interface DialogParts {\n /** Viewport backdrop and dismissal surface. */\n backdrop?: DialogPartAttributes<HTMLDivElement>;\n /** Viewport positioning wrapper. */\n positioner?: DialogPartAttributes<HTMLDivElement>;\n /** Modal root. */\n root?: DialogPartAttributes<HTMLDivElement>;\n /** Header containing title and optional close action. */\n header?: DialogPartAttributes<HTMLElement>;\n /** Dialog heading. */\n title?: DialogPartAttributes<HTMLHeadingElement>;\n /** Secondary line under the heading, rendered only when `subtitle` is set. */\n subtitle?: DialogPartAttributes<HTMLParagraphElement>;\n /** Region before the close button holding per-dialog and app-wide header actions. */\n headerActions?: DialogPartAttributes<HTMLDivElement>;\n /** Header close button. */\n close?: DialogButtonAttributes;\n /** Dialog content region. */\n content?: DialogPartAttributes<HTMLDivElement>;\n /** Footer action region. */\n footer?: DialogPartAttributes<HTMLElement>;\n /** Primary confirmation button. */\n confirm?: DialogButtonAttributes;\n /** Secondary dismissal button(s). */\n cancel?: DialogButtonAttributes;\n}\n\n/** Props for {@link Dialog}. */\nexport interface DialogProps {\n /** Dialog heading. */\n title: string;\n /**\n * Secondary line under the heading — a reference, a status, a short summary. Announced as the\n * dialog's description.\n */\n subtitle?: ReactNode;\n /**\n * Viewport placement. `center` (default) is a modal; `start` and `end` render a full-height\n * side sheet against that inline edge, sliding in from it. Dismissal, focus and busy behavior\n * are identical across placements.\n */\n placement?: DialogPlacement;\n /**\n * Actions rendered in the header before the close button, in a `header-actions` part. Use it\n * for a help, feedback or copy-link action that belongs to this dialog. Rendered next to the\n * app-wide actions registered on `CratisComponentsProvider`.\n */\n headerActions?: ReactNode;\n /** Suppresses the app-wide header actions registered on `CratisComponentsProvider` for this dialog. */\n hideGlobalHeaderActions?: boolean;\n /** Where this dialog's opener sits in the application. Passed to app-wide header actions as `sliceLocation`. */\n sliceLocation?: DialogSliceLocation;\n /**\n * Set by `CommandDialog` and `StepperCommandDialog` so app-wide header actions can tell a command\n * dialog from a plain one. Defaults to `false`.\n */\n isCommandDialog?: boolean;\n /**\n * Glyph for the header close button. Names this one dialog and wins over the provider's\n * `icons.close`; defaults to a multiplication sign when neither is set.\n */\n closeIcon?: ReactNode;\n /** Controlled open state. Defaults to `true`. */\n visible?: boolean;\n /** Combined result callback used when a dedicated confirm/cancel callback is absent. */\n onClose?: CloseDialog;\n /** Invoked by primary confirmation actions. */\n onConfirm?: ConfirmCallback;\n /** Invoked by cancellation actions. */\n onCancel?: CancelCallback;\n /** Predefined Arc buttons, custom footer content, or `null` for no footer. */\n buttons?: DialogButtons | ReactNode;\n /** Initial focus target. Defaults to the confirmation action. */\n initialFocus?: DialogInitialFocus;\n /** Dialog body content. */\n children: ReactNode;\n /** CSS width. Defaults to `450px`. */\n width?: string;\n /** Modal-root inline style. */\n style?: CSSProperties;\n /** Content-region inline style. */\n contentStyle?: CSSProperties;\n /**\n * @deprecated The Cratis dialog is viewport-bounded rather than resizable. Remove this prop.\n */\n resizable?: boolean;\n /** Whether the primary action is enabled. Defaults to `true`. */\n isValid?: boolean;\n /** Disables every action and dismissal path while work is in flight. */\n isBusy?: boolean;\n /** Label for the Ok action. Falls back to the provider's `dialog.ok` message, then `'Ok'`. */\n okLabel?: string;\n /** Label for the Cancel action. Falls back to the provider's `dialog.cancel` message, then `'Cancel'`. */\n cancelLabel?: string;\n /** Label for the Yes action. Falls back to the provider's `dialog.yes` message, then `'Yes'`. */\n yesLabel?: string;\n /** Label for the No action. Falls back to the provider's `dialog.no` message, then `'No'`. */\n noLabel?: string;\n /** Accessible label for the header close button. Falls back to the provider's `dialog.close` message, then `'Close'`. */\n closeAriaLabel?: string;\n /**\n * Combined default for header, Escape, and backdrop dismissal. Defaults to true\n * for predefined buttons and false for custom/no footer. Independent props override it.\n */\n dismissable?: boolean;\n /** Whether outside clicks dismiss the dialog. Falls back to `dismissable`; blocked while busy. */\n dismissOnOutsideClick?: boolean;\n /** Whether Escape dismisses the dialog. Falls back to `dismissable`; blocked while busy. */\n closeOnEscape?: boolean;\n /** Whether to show the header close button. Falls back to `dismissable`; disabled while busy. */\n showCloseButton?: boolean;\n /** Extra class name for the modal root. */\n className?: string;\n /** Cratis-owned per-part attributes. */\n pt?: DialogParts;\n /**\n * @deprecated Cratis parts always merge. Remove this renderer-era option.\n */\n ptOptions?: object;\n /**\n * @deprecated Components always uses consumer-owned CSS. Customize through `pt` and CSS instead.\n */\n unstyled?: boolean;\n}\n\nconst coreDialogDeclaration = Object.freeze({\n mode: 'atomic',\n fidelity: 'native',\n render: DialogImplementation,\n}) satisfies unstable_SlotDeclaration<'dialogs.dialog'>;\n\nconst slotHostDeclaration = Object.freeze({ render: DialogSlotHost });\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 Dialog = (props: DialogProps) => {\n const declaration = unstable_useSlot('dialogs.dialog', coreDialogDeclaration);\n if (declaration.render === DialogImplementation) return renderSlot(coreDialogDeclaration, props);\n // An adapter dialog receives the public props plus its Components-owned host.\n return renderSlot(slotHostDeclaration, { render: declaration.render, props });\n};\n"],"names":[],"mappings":";;;;;AAyKA,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC;AACxC,IAAA,IAAI,EAAE,QAAQ;AACd,IAAA,QAAQ,EAAE,QAAQ;AAClB,IAAA,MAAM,EAAE,oBAAoB;AAC/B,CAAA,CAAsD;AAEvD,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;AAM9D,MAAM,MAAM,GAAG,CAAC,KAAkB,KAAI;IACzC,MAAM,WAAW,GAAG,gBAAgB,CAAC,gBAAgB,EAAE,qBAAqB,CAAC;AAC7E,IAAA,IAAI,WAAW,CAAC,MAAM,KAAK,oBAAoB;AAAE,QAAA,OAAO,UAAU,CAAC,qBAAqB,EAAE,KAAK,CAAC;AAEhG,IAAA,OAAO,UAAU,CAAC,mBAAmB,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC;AACjF;;"}
|
|
@@ -1,22 +1,39 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
import { type DialogFooterProps } from './DialogFooter.js';
|
|
3
3
|
import { type DialogHeaderProps } from './DialogHeader.js';
|
|
4
|
-
|
|
4
|
+
import type { DialogParts } from './Dialog.js';
|
|
5
|
+
/** One refused-confirmation announcement. */
|
|
6
|
+
export interface Announcement {
|
|
5
7
|
key: number;
|
|
6
8
|
text: string;
|
|
7
9
|
}
|
|
10
|
+
/** Props of the content region. */
|
|
11
|
+
export interface DialogContentProps {
|
|
12
|
+
visible: boolean;
|
|
13
|
+
isBusy: boolean;
|
|
14
|
+
contentStyle: React.CSSProperties | undefined;
|
|
15
|
+
pt: DialogParts | undefined;
|
|
16
|
+
children: React.ReactNode;
|
|
17
|
+
}
|
|
18
|
+
/** The `content` part: the dialog body inside a busy scope that is disabled and inert while busy. */
|
|
19
|
+
export declare const DialogContent: ({ visible, isBusy, contentStyle, pt, children }: DialogContentProps) => React.JSX.Element;
|
|
20
|
+
/** The polite live region announcing refused confirmations. */
|
|
21
|
+
export declare const LiveRegion: ({ announcement }: {
|
|
22
|
+
announcement: Announcement | null;
|
|
23
|
+
}) => React.JSX.Element;
|
|
8
24
|
/** Props of the dialog document. */
|
|
9
25
|
export interface DialogDocumentProps {
|
|
10
26
|
header: DialogHeaderProps;
|
|
11
27
|
/** The footer, or null when the dialog has no footer. */
|
|
12
28
|
footer: DialogFooterProps | null;
|
|
13
29
|
stackZIndex: string;
|
|
30
|
+
/** Identity of this dialog instance, published to descendants as their overlay host. */
|
|
31
|
+
hostId: string;
|
|
14
32
|
visible: boolean;
|
|
15
33
|
contentStyle: React.CSSProperties | undefined;
|
|
16
34
|
announcement: Announcement | null;
|
|
17
35
|
children: React.ReactNode;
|
|
18
36
|
}
|
|
19
37
|
/** The accessible dialog document: header, content, footer and the status live region. */
|
|
20
|
-
export declare const DialogDocument: ({ header, footer, stackZIndex, visible, contentStyle, announcement, children, }: DialogDocumentProps) => React.JSX.Element;
|
|
21
|
-
export {};
|
|
38
|
+
export declare const DialogDocument: ({ header, footer, stackZIndex, hostId, visible, contentStyle, announcement, children, }: DialogDocumentProps) => React.JSX.Element;
|
|
22
39
|
//# sourceMappingURL=DialogDocument.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogDocument.d.ts","sourceRoot":"","sources":["../../../Dialogs/DialogDocument.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DialogDocument.d.ts","sourceRoot":"","sources":["../../../Dialogs/DialogDocument.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAgB,KAAK,iBAAiB,EAAE,MAAM,mBAAgB,CAAC;AACtE,OAAO,EAAgB,KAAK,iBAAiB,EAAE,MAAM,mBAAgB,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAU,CAAC;AAe5C,6CAA6C;AAC7C,MAAM,WAAW,YAAY;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,mCAAmC;AACnC,MAAM,WAAW,kBAAkB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,KAAK,CAAC,aAAa,GAAG,SAAS,CAAC;IAC9C,EAAE,EAAE,WAAW,GAAG,SAAS,CAAC;IAC5B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC7B;AAED,qGAAqG;AACrG,eAAO,MAAM,aAAa,oDAAqD,kBAAkB,sBAoBhG,CAAC;AAEF,+DAA+D;AAC/D,eAAO,MAAM,UAAU,qBAAsB;IAAE,YAAY,EAAE,YAAY,GAAG,IAAI,CAAA;CAAE,sBAUjF,CAAC;AAEF,oCAAoC;AACpC,MAAM,WAAW,mBAAmB;IAChC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,yDAAyD;IACzD,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,wFAAwF;IACxF,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,KAAK,CAAC,aAAa,GAAG,SAAS,CAAC;IAC9C,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC7B;AAED,0FAA0F;AAC1F,eAAO,MAAM,cAAc,4FASxB,mBAAmB,sBAqBrB,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { Dialog } from 'react-aria-components/Dialog';
|
|
3
|
+
import { useMemo } from 'react';
|
|
3
4
|
import { classNames } from '../ClassNames/classNames.js';
|
|
4
|
-
import { DialogStackContext } from '../renderer/DialogStackContext.js';
|
|
5
|
+
import { DialogStackContext, OverlayHostContext } from '../renderer/DialogStackContext.js';
|
|
5
6
|
import { DialogFooter } from './DialogFooter.js';
|
|
6
7
|
import { DialogHeader } from './DialogHeader.js';
|
|
7
8
|
|
|
@@ -18,7 +19,10 @@ const visuallyHidden = {
|
|
|
18
19
|
};
|
|
19
20
|
const DialogContent = ({ visible, isBusy, contentStyle, pt, children }) => (jsx("div", { ...pt?.content, className: classNames('cratis-dialog__content', pt?.content?.className), style: { ...pt?.content?.style, ...contentStyle }, "data-cratis-part": 'content', "data-open": visible || undefined, "data-busy": isBusy || undefined, children: jsx("fieldset", { className: 'cratis-dialog__busy-scope', "data-cratis-part": 'busy-scope', "data-busy": isBusy || undefined, disabled: isBusy, inert: isBusy, "aria-busy": isBusy || undefined, children: children }) }));
|
|
20
21
|
const LiveRegion = ({ announcement }) => (jsx("div", { className: 'cratis-dialog__live-region', style: visuallyHidden, role: 'status', "aria-live": 'polite', "aria-atomic": 'true', children: announcement && jsx("span", { children: announcement.text }, announcement.key) }));
|
|
21
|
-
const DialogDocument = ({ header, footer, stackZIndex, visible, contentStyle, announcement, children, }) =>
|
|
22
|
+
const DialogDocument = ({ header, footer, stackZIndex, hostId, visible, contentStyle, announcement, children, }) => {
|
|
23
|
+
const host = useMemo(() => ({ id: hostId, open: visible, stackZIndex }), [hostId, visible, stackZIndex]);
|
|
24
|
+
return (jsx(DialogStackContext.Provider, { value: stackZIndex, children: jsx(OverlayHostContext.Provider, { value: host, children: jsx(Dialog, { className: 'cratis-dialog__document', "aria-describedby": header.hasSubtitle ? header.subtitleId : undefined, children: jsxs(Fragment, { children: [jsx(DialogHeader, { ...header }), jsx(DialogContent, { visible: visible, isBusy: header.isBusy, contentStyle: contentStyle, pt: header.pt, children: children }), footer && jsx(DialogFooter, { ...footer }), jsx(LiveRegion, { announcement: announcement })] }) }) }) }));
|
|
25
|
+
};
|
|
22
26
|
|
|
23
|
-
export { DialogDocument };
|
|
27
|
+
export { DialogContent, DialogDocument, LiveRegion };
|
|
24
28
|
//# sourceMappingURL=DialogDocument.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogDocument.js","sources":["../../../Dialogs/DialogDocument.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 { Dialog as AriaDialog } from 'react-aria-components/Dialog';\nimport type React from 'react';\nimport { classNames } from '../ClassNames/classNames';\nimport { DialogStackContext } from '../renderer/DialogStackContext';\nimport { DialogFooter, type DialogFooterProps } from './DialogFooter';\nimport { DialogHeader, type DialogHeaderProps } from './DialogHeader';\nimport type { DialogParts } from './Dialog';\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\
|
|
1
|
+
{"version":3,"file":"DialogDocument.js","sources":["../../../Dialogs/DialogDocument.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 { Dialog as AriaDialog } from 'react-aria-components/Dialog';\nimport { useMemo } from 'react';\nimport type React from 'react';\nimport { classNames } from '../ClassNames/classNames';\nimport { DialogStackContext, OverlayHostContext } from '../renderer/DialogStackContext';\nimport { DialogFooter, type DialogFooterProps } from './DialogFooter';\nimport { DialogHeader, type DialogHeaderProps } from './DialogHeader';\nimport type { DialogParts } from './Dialog';\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/** One refused-confirmation announcement. */\nexport interface Announcement {\n key: number;\n text: string;\n}\n\n/** Props of the content region. */\nexport interface DialogContentProps {\n visible: boolean;\n isBusy: boolean;\n contentStyle: React.CSSProperties | undefined;\n pt: DialogParts | undefined;\n children: React.ReactNode;\n}\n\n/** The `content` part: the dialog body inside a busy scope that is disabled and inert while busy. */\nexport const DialogContent = ({ visible, isBusy, contentStyle, pt, children }: DialogContentProps) => (\n <div\n {...pt?.content}\n className={classNames('cratis-dialog__content', pt?.content?.className)}\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);\n\n/** The polite live region announcing refused confirmations. */\nexport const LiveRegion = ({ announcement }: { announcement: Announcement | null }) => (\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\n/** Props of the dialog document. */\nexport interface DialogDocumentProps {\n header: DialogHeaderProps;\n /** The footer, or null when the dialog has no footer. */\n footer: DialogFooterProps | null;\n stackZIndex: string;\n /** Identity of this dialog instance, published to descendants as their overlay host. */\n hostId: string;\n visible: boolean;\n contentStyle: React.CSSProperties | undefined;\n announcement: Announcement | null;\n children: React.ReactNode;\n}\n\n/** The accessible dialog document: header, content, footer and the status live region. */\nexport const DialogDocument = ({\n header,\n footer,\n stackZIndex,\n hostId,\n visible,\n contentStyle,\n announcement,\n children,\n}: DialogDocumentProps) => {\n const host = useMemo(() => ({ id: hostId, open: visible, stackZIndex }), [hostId, visible, stackZIndex]);\n return (\n <DialogStackContext.Provider value={stackZIndex}>\n <OverlayHostContext.Provider value={host}>\n <AriaDialog\n className='cratis-dialog__document'\n aria-describedby={header.hasSubtitle ? header.subtitleId : undefined}\n >\n <>\n <DialogHeader {...header} />\n <DialogContent visible={visible} isBusy={header.isBusy} contentStyle={contentStyle} pt={header.pt}>\n {children}\n </DialogContent>\n {footer && <DialogFooter {...footer} />}\n <LiveRegion announcement={announcement} />\n </>\n </AriaDialog>\n </OverlayHostContext.Provider>\n </DialogStackContext.Provider>\n );\n};\n"],"names":["_jsx","AriaDialog","_jsxs"],"mappings":";;;;;;;;AAaA,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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,GAAG,OAAO,CAAC,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;IACxG,QACIA,IAAC,kBAAkB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,WAAW,EAAA,QAAA,EAC3CA,IAAC,kBAAkB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,IAAI,EAAA,QAAA,EACpCA,IAACC,MAAU,EAAA,EACP,SAAS,EAAC,yBAAyB,sBACjB,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,UAAU,GAAG,SAAS,EAAA,QAAA,EAEpEC,4BACIF,GAAA,CAAC,YAAY,OAAK,MAAM,EAAA,CAAI,EAC5BA,GAAA,CAAC,aAAa,IAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAA,QAAA,EAC5F,QAAQ,EAAA,CACG,EACf,MAAM,IAAIA,GAAA,CAAC,YAAY,EAAA,EAAA,GAAK,MAAM,GAAI,EACvCA,GAAA,CAAC,UAAU,EAAA,EAAC,YAAY,EAAE,YAAY,EAAA,CAAI,IAC3C,EAAA,CACM,EAAA,CACa,EAAA,CACJ;AAEtC;;"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
import type { DialogHeaderActionsRenderer } from '../configuration/DialogHeaderActionsRenderer.js';
|
|
3
3
|
import type { DialogParts, DialogProps } from './Dialog.js';
|
|
4
|
-
|
|
4
|
+
/** Props of the header actions region. */
|
|
5
|
+
export interface HeaderActionsProps {
|
|
5
6
|
dialogId: string;
|
|
6
7
|
title: DialogProps['title'];
|
|
7
8
|
headerActions: DialogProps['headerActions'];
|
|
@@ -12,6 +13,8 @@ interface HeaderActionsProps {
|
|
|
12
13
|
showsCloseButton: boolean;
|
|
13
14
|
pt: DialogParts | undefined;
|
|
14
15
|
}
|
|
16
|
+
/** The `header-actions` part: per-dialog actions followed by the app-wide ones. */
|
|
17
|
+
export declare const HeaderActions: ({ dialogId, title, headerActions, globalHeaderActions, hideGlobalHeaderActions, isCommandDialog, sliceLocation, showsCloseButton, pt, }: HeaderActionsProps) => React.JSX.Element;
|
|
15
18
|
/** Props of the dialog header. */
|
|
16
19
|
export interface DialogHeaderProps extends HeaderActionsProps {
|
|
17
20
|
subtitle: DialogProps['subtitle'];
|
|
@@ -27,5 +30,4 @@ export interface DialogHeaderProps extends HeaderActionsProps {
|
|
|
27
30
|
}
|
|
28
31
|
/** The dialog header: title, subtitle, header actions and the close button. */
|
|
29
32
|
export declare const DialogHeader: (props: DialogHeaderProps) => React.JSX.Element;
|
|
30
|
-
export {};
|
|
31
33
|
//# sourceMappingURL=DialogHeader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogHeader.d.ts","sourceRoot":"","sources":["../../../Dialogs/DialogHeader.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,iDAA8C,CAAC;AAEhG,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAU,CAAC;AAgBzD,
|
|
1
|
+
{"version":3,"file":"DialogHeader.d.ts","sourceRoot":"","sources":["../../../Dialogs/DialogHeader.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,iDAA8C,CAAC;AAEhG,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAU,CAAC;AAgBzD,0CAA0C;AAC1C,MAAM,WAAW,kBAAkB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC5B,aAAa,EAAE,WAAW,CAAC,eAAe,CAAC,CAAC;IAC5C,mBAAmB,EAAE,2BAA2B,GAAG,SAAS,CAAC;IAC7D,uBAAuB,EAAE,OAAO,CAAC;IACjC,eAAe,EAAE,OAAO,CAAC;IACzB,aAAa,EAAE,WAAW,CAAC,eAAe,CAAC,CAAC;IAC5C,gBAAgB,EAAE,OAAO,CAAC;IAC1B,EAAE,EAAE,WAAW,GAAG,SAAS,CAAC;CAC/B;AAED,mFAAmF;AACnF,eAAO,MAAM,aAAa,4IAUvB,kBAAkB,sBAapB,CAAC;AAgEF,kCAAkC;AAClC,MAAM,WAAW,iBAAkB,SAAQ,kBAAkB;IACzD,QAAQ,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,KAAK,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IACxC,MAAM,EAAE,OAAO,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,OAAO,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,+EAA+E;AAC/E,eAAO,MAAM,YAAY,UAAW,iBAAiB,sBAwBpD,CAAC"}
|
|
@@ -24,5 +24,5 @@ const DialogHeader = (props) => {
|
|
|
24
24
|
return (jsxs("header", { ...dialogPartAttributes(pt?.header, 'cratis-dialog__header'), "data-cratis-part": 'header', children: [jsx(Title, { title: title, focusesTitle: focusesTitle, titleRef: titleRef, pt: pt }), hasSubtitle && jsx(Subtitle, { subtitle: subtitle, subtitleId: subtitleId, pt: pt }), hasHeaderActions && jsx(HeaderActions, { ...props }), showsCloseButton && (jsx(CloseButton, { isBusy: isBusy, hasHeaderActions: hasHeaderActions, ariaLabel: closeAriaLabel, icon: closeIcon, pt: pt, onClose: onClose }))] }));
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
export { DialogHeader };
|
|
27
|
+
export { DialogHeader, HeaderActions };
|
|
28
28
|
//# sourceMappingURL=DialogHeader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogHeader.js","sources":["../../../Dialogs/DialogHeader.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 { Heading } from 'react-aria-components/Dialog';\nimport type React from 'react';\nimport { dialogPartAttributes } from './dialogPartAttributes';\nimport type { DialogHeaderActionsRenderer } from '../configuration/DialogHeaderActionsRenderer';\nimport { DialogGlobalHeaderActions } from './DialogGlobalHeaderActions';\nimport type { DialogParts, DialogProps } from './Dialog';\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, style: React.CSSProperties | undefined): 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 ...style,\n});\n\n\
|
|
1
|
+
{"version":3,"file":"DialogHeader.js","sources":["../../../Dialogs/DialogHeader.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 { Heading } from 'react-aria-components/Dialog';\nimport type React from 'react';\nimport { dialogPartAttributes } from './dialogPartAttributes';\nimport type { DialogHeaderActionsRenderer } from '../configuration/DialogHeaderActionsRenderer';\nimport { DialogGlobalHeaderActions } from './DialogGlobalHeaderActions';\nimport type { DialogParts, DialogProps } from './Dialog';\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, style: React.CSSProperties | undefined): 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 ...style,\n});\n\n\n/** Props of the header actions region. */\nexport interface HeaderActionsProps {\n dialogId: string;\n title: DialogProps['title'];\n headerActions: DialogProps['headerActions'];\n globalHeaderActions: DialogHeaderActionsRenderer | undefined;\n hideGlobalHeaderActions: boolean;\n isCommandDialog: boolean;\n sliceLocation: DialogProps['sliceLocation'];\n showsCloseButton: boolean;\n pt: DialogParts | undefined;\n}\n\n/** The `header-actions` part: per-dialog actions followed by the app-wide ones. */\nexport const HeaderActions = ({\n dialogId,\n title,\n headerActions,\n globalHeaderActions,\n hideGlobalHeaderActions,\n isCommandDialog,\n sliceLocation,\n showsCloseButton,\n pt,\n}: HeaderActionsProps) => (\n <div\n {...dialogPartAttributes(pt?.headerActions, 'cratis-dialog__header-actions', headerActionsStyle(showsCloseButton, pt?.headerActions?.style))}\n data-cratis-part='header-actions'\n >\n {headerActions}\n {globalHeaderActions && !hideGlobalHeaderActions && (\n <DialogGlobalHeaderActions\n render={globalHeaderActions}\n context={{ dialogId, title, isCommandDialog, sliceLocation }}\n />\n )}\n </div>\n);\n\nconst closeButtonStyle = (hasHeaderActions: boolean, style: React.CSSProperties | undefined) =>\n hasHeaderActions ? { justifySelf: 'end' as const, ...style } : style;\n\ninterface CloseButtonProps {\n isBusy: boolean;\n hasHeaderActions: boolean;\n ariaLabel: string;\n icon: React.ReactNode;\n pt: DialogParts | undefined;\n onClose: () => void;\n}\n\nconst CloseButton = ({ isBusy, hasHeaderActions, ariaLabel, icon, pt, onClose }: CloseButtonProps) => (\n <button\n type='button'\n {...dialogPartAttributes(pt?.close, 'cratis-dialog__close', closeButtonStyle(hasHeaderActions, pt?.close?.style))}\n disabled={isBusy}\n data-cratis-part='close'\n data-disabled={isBusy || undefined}\n data-busy={isBusy || undefined}\n aria-label={ariaLabel}\n onClick={onClose}\n >\n <span aria-hidden='true'>{icon}</span>\n </button>\n);\n\ninterface TitleProps {\n title: DialogProps['title'];\n focusesTitle: boolean;\n titleRef: React.Ref<HTMLHeadingElement>;\n pt: DialogParts | undefined;\n}\n\nconst Title = ({ title, focusesTitle, titleRef, pt }: TitleProps) => (\n <Heading\n {...dialogPartAttributes(pt?.title, 'cratis-dialog__title')}\n slot='title'\n tabIndex={focusesTitle ? -1 : undefined}\n ref={titleRef}\n data-cratis-part='title'\n >\n {title}\n </Heading>\n);\n\ninterface SubtitleProps {\n subtitle: DialogProps['subtitle'];\n subtitleId: string;\n pt: DialogParts | undefined;\n}\n\nconst Subtitle = ({ subtitle, subtitleId, pt }: SubtitleProps) => (\n <p\n {...dialogPartAttributes(pt?.subtitle, 'cratis-dialog__subtitle')}\n id={subtitleId}\n data-cratis-part='subtitle'\n >\n {subtitle}\n </p>\n);\n\n/** Props of the dialog header. */\nexport interface DialogHeaderProps extends HeaderActionsProps {\n subtitle: DialogProps['subtitle'];\n subtitleId: string;\n hasSubtitle: boolean;\n hasHeaderActions: boolean;\n focusesTitle: boolean;\n titleRef: React.Ref<HTMLHeadingElement>;\n isBusy: boolean;\n closeAriaLabel: string;\n closeIcon: React.ReactNode;\n onClose: () => void;\n}\n\n/** The dialog header: title, subtitle, header actions and the close button. */\nexport const DialogHeader = (props: DialogHeaderProps) => {\n const { pt, title, subtitle, subtitleId, hasSubtitle, hasHeaderActions, focusesTitle, titleRef } = props;\n const { showsCloseButton, isBusy, closeAriaLabel, closeIcon, onClose } = props;\n\n return (\n <header\n {...dialogPartAttributes(pt?.header, 'cratis-dialog__header')}\n data-cratis-part='header'\n >\n <Title title={title} focusesTitle={focusesTitle} titleRef={titleRef} pt={pt} />\n {hasSubtitle && <Subtitle subtitle={subtitle} subtitleId={subtitleId} pt={pt} />}\n {hasHeaderActions && <HeaderActions {...props} />}\n {showsCloseButton && (\n <CloseButton\n isBusy={isBusy}\n hasHeaderActions={hasHe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AAE,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,KAAK;AACxG,IAAA,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,KAAK;IAE9E,QACID,oBACQ,oBAAoB,CAAC,EAAE,EAAE,MAAM,EAAE,uBAAuB,CAAC,sBAC5C,QAAQ,EAAA,QAAA,EAAA,CAEzBC,IAAC,KAAK,EAAA,EAAC,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,GAAI,EAC9E,WAAW,IAAIA,GAAA,CAAC,QAAQ,IAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,GAAI,EAC/E,gBAAgB,IAAIA,GAAA,CAAC,aAAa,OAAK,KAAK,EAAA,CAAI,EAChD,gBAAgB,KACbA,GAAA,CAAC,WAAW,IACR,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,cAAc,EACzB,IAAI,EAAE,SAAS,EACf,EAAE,EAAE,EAAE,EACN,OAAO,EAAE,OAAO,GAClB,CACL,CAAA,EAAA,CACI;AAEjB;;"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { ReactNode, Ref } from 'react';
|
|
2
|
+
import type { DialogProps } from './Dialog.js';
|
|
3
|
+
/** Which dismissal paths are currently allowed. Every path is blocked while the dialog is busy. */
|
|
4
|
+
export interface CratisDialogHostDismissal {
|
|
5
|
+
/** Whether a pointer press outside the dialog dismisses it. */
|
|
6
|
+
readonly outside: boolean;
|
|
7
|
+
/** Whether Escape dismisses the dialog. */
|
|
8
|
+
readonly escape: boolean;
|
|
9
|
+
/** Whether the header close button is shown. */
|
|
10
|
+
readonly closeButton: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** The user gesture an adapter reports when it asks Components to dismiss the dialog. */
|
|
13
|
+
export type CratisDialogDismissSource = keyof CratisDialogHostDismissal;
|
|
14
|
+
/**
|
|
15
|
+
* What Components keeps owning for an adapter-rendered dialog. Each mounted dialog gets its own
|
|
16
|
+
* host; nothing in it is shared with, or outlives, that dialog.
|
|
17
|
+
*
|
|
18
|
+
* Components owns the dialog stack, the Arc dialog result, the footer actions, the header actions,
|
|
19
|
+
* the busy and validity rules, initial focus, the refused-confirmation announcement, and the overlay
|
|
20
|
+
* environment of the dialog's descendants. The adapter owns the modal shell: the focus trap,
|
|
21
|
+
* Escape, outside press, scroll lock and focus restoration.
|
|
22
|
+
*/
|
|
23
|
+
export interface CratisDialogHost {
|
|
24
|
+
/**
|
|
25
|
+
* Identity of this host. Stable for the dialog's lifetime and distinct for every dialog. Render it
|
|
26
|
+
* as `data-cratis-dialog-id` on the dialog's root element: descendants such as FilterPanel find
|
|
27
|
+
* their enclosing modal through that attribute, as they do for the built-in shell.
|
|
28
|
+
*/
|
|
29
|
+
readonly id: string;
|
|
30
|
+
/**
|
|
31
|
+
* Stacking expression of this dialog's tier. Use it for a z-index based modal; a browser
|
|
32
|
+
* top-layer `<dialog>` is ordered by `showModal()` and can ignore it.
|
|
33
|
+
*/
|
|
34
|
+
readonly zIndex: string;
|
|
35
|
+
/** The dismissal paths the adapter must honor. */
|
|
36
|
+
readonly dismissal: CratisDialogHostDismissal;
|
|
37
|
+
/** Accessible label for the header close button. */
|
|
38
|
+
readonly closeAriaLabel: string;
|
|
39
|
+
/** Glyph for the header close button. */
|
|
40
|
+
readonly closeIcon: ReactNode;
|
|
41
|
+
/** Id the adapter gives the subtitle element; the dialog is described by it when present. */
|
|
42
|
+
readonly subtitleId: string;
|
|
43
|
+
/** Whether a subtitle is rendered. */
|
|
44
|
+
readonly hasSubtitle: boolean;
|
|
45
|
+
/** Ref for the title heading, which receives focus when initial focus is the content. */
|
|
46
|
+
readonly titleRef: Ref<HTMLHeadingElement>;
|
|
47
|
+
/** The dialog's children as the `content` part, disabled and inert while the dialog is busy. */
|
|
48
|
+
readonly content: ReactNode;
|
|
49
|
+
/** The per-dialog and app-wide header actions as the `header-actions` part, or `null`. */
|
|
50
|
+
readonly headerActions: ReactNode;
|
|
51
|
+
/** The footer actions as the `footer` part, or `null` when the dialog has no footer. */
|
|
52
|
+
readonly footer: ReactNode;
|
|
53
|
+
/** The polite live region announcing refused confirmations. Render it inside the dialog. */
|
|
54
|
+
readonly liveRegion: ReactNode;
|
|
55
|
+
/**
|
|
56
|
+
* Closes through the dialog's cancel path for a user dismissal from `source`. Components ignores
|
|
57
|
+
* the request while the dialog is hidden or busy, or when `host.dismissal` blocks that source.
|
|
58
|
+
*/
|
|
59
|
+
dismiss(source: CratisDialogDismissSource): void;
|
|
60
|
+
/**
|
|
61
|
+
* Registers the element the dialog's descendant overlays portal into, or clears it with `null`.
|
|
62
|
+
* A top-layer `<dialog>` registers an element inside itself so popovers, tooltips and nested
|
|
63
|
+
* dialogs stay above it and interactive. Pass it as a ref callback.
|
|
64
|
+
*/
|
|
65
|
+
registerOverlayContainer(element: HTMLElement | null): void;
|
|
66
|
+
}
|
|
67
|
+
/** Props an adapter-rendered `dialogs.dialog` receives: the public props plus its {@link CratisDialogHost}. */
|
|
68
|
+
export type CratisDialogSlotProps = DialogProps & {
|
|
69
|
+
/** The Components-owned part of this dialog. */
|
|
70
|
+
readonly host: CratisDialogHost;
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=DialogHost.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DialogHost.d.ts","sourceRoot":"","sources":["../../../Dialogs/DialogHost.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAU,CAAC;AAE5C,mGAAmG;AACnG,MAAM,WAAW,yBAAyB;IACtC,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,E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AAC,IAAI,EAAE,gBAAgB,CAAC;CACnC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DialogHost.js","sourceRoot":"","sources":["../../../Dialogs/DialogHost.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","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 { ReactNode, Ref } from 'react';\nimport type { DialogProps } from './Dialog';\n\n/** Which dismissal paths are currently allowed. Every path is blocked while the dialog is busy. */\nexport interface CratisDialogHostDismissal {\n /** Whether a pointer press outside the dialog dismisses it. */\n readonly outside: boolean;\n /** Whether Escape dismisses the dialog. */\n readonly escape: boolean;\n /** Whether the header close button is shown. */\n readonly closeButton: boolean;\n}\n\n/** The user gesture an adapter reports when it asks Components to dismiss the dialog. */\nexport type CratisDialogDismissSource = keyof CratisDialogHostDismissal;\n\n/**\n * What Components keeps owning for an adapter-rendered dialog. Each mounted dialog gets its own\n * host; nothing in it is shared with, or outlives, that dialog.\n *\n * Components owns the dialog stack, the Arc dialog result, the footer actions, the header actions,\n * the busy and validity rules, initial focus, the refused-confirmation announcement, and the overlay\n * environment of the dialog's descendants. The adapter owns the modal shell: the focus trap,\n * Escape, outside press, scroll lock and focus restoration.\n */\nexport interface CratisDialogHost {\n /**\n * Identity of this host. Stable for the dialog's lifetime and distinct for every dialog. Render it\n * as `data-cratis-dialog-id` on the dialog's root element: descendants such as FilterPanel find\n * their enclosing modal through that attribute, as they do for the built-in shell.\n */\n readonly id: string;\n /**\n * Stacking expression of this dialog's tier. Use it for a z-index based modal; a browser\n * top-layer `<dialog>` is ordered by `showModal()` and can ignore it.\n */\n readonly zIndex: string;\n /** The dismissal paths the adapter must honor. */\n readonly dismissal: CratisDialogHostDismissal;\n /** Accessible label for the header close button. */\n readonly closeAriaLabel: string;\n /** Glyph for the header close button. */\n readonly closeIcon: ReactNode;\n /** Id the adapter gives the subtitle element; the dialog is described by it when present. */\n readonly subtitleId: string;\n /** Whether a subtitle is rendered. */\n readonly hasSubtitle: boolean;\n /** Ref for the title heading, which receives focus when initial focus is the content. */\n readonly titleRef: Ref<HTMLHeadingElement>;\n /** The dialog's children as the `content` part, disabled and inert while the dialog is busy. */\n readonly content: ReactNode;\n /** The per-dialog and app-wide header actions as the `header-actions` part, or `null`. */\n readonly headerActions: ReactNode;\n /** The footer actions as the `footer` part, or `null` when the dialog has no footer. */\n readonly footer: ReactNode;\n /** The polite live region announcing refused confirmations. Render it inside the dialog. */\n readonly liveRegion: ReactNode;\n /**\n * Closes through the dialog's cancel path for a user dismissal from `source`. Components ignores\n * the request while the dialog is hidden or busy, or when `host.dismissal` blocks that source.\n */\n dismiss(source: CratisDialogDismissSource): void;\n /**\n * Registers the element the dialog's descendant overlays portal into, or clears it with `null`.\n * A top-layer `<dialog>` registers an element inside itself so popovers, tooltips and nested\n * dialogs stay above it and interactive. Pass it as a ref callback.\n */\n registerOverlayContainer(element: HTMLElement | null): void;\n}\n\n/** Props an adapter-rendered `dialogs.dialog` receives: the public props plus its {@link CratisDialogHost}. */\nexport type CratisDialogSlotProps = DialogProps & {\n /** The Components-owned part of this dialog. */\n readonly host: CratisDialogHost;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogImplementation.d.ts","sourceRoot":"","sources":["../../../Dialogs/DialogImplementation.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"DialogImplementation.d.ts","sourceRoot":"","sources":["../../../Dialogs/DialogImplementation.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAU,CAAC;AAsB5C;;;GAGG;AACH,eAAO,MAAM,oBAAoB,kBAAmB,WAAW,gCA4H9D,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { DialogButtons, DialogResult } from '@cratis/arc.react/dialogs';
|
|
|
3
3
|
import { useId, useSyncExternalStore } from 'react';
|
|
4
4
|
import { unstable_useOverlayEnvironment } from '../renderer/RendererContext.js';
|
|
5
5
|
import { DialogInitialFocus } from './DialogInitialFocus.js';
|
|
6
|
-
import {
|
|
6
|
+
import { resolveInitialFocus, dismissalFor } from './dialogBehavior.js';
|
|
7
7
|
import 'react-aria-components/I18nProvider';
|
|
8
8
|
import 'react-aria-components';
|
|
9
9
|
import 'ts-deepmerge';
|
|
@@ -23,24 +23,13 @@ import { useDialogZIndex } from './useDialogZIndex.js';
|
|
|
23
23
|
|
|
24
24
|
const subscribeToBrowserEnvironment = () => () => undefined;
|
|
25
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
|
-
});
|
|
38
26
|
const DialogImplementation = (incomingProps) => {
|
|
39
27
|
const [props, marker] = useComponentPresentation(dialogDescriptor, incomingProps);
|
|
40
28
|
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;
|
|
41
29
|
const { messages, dialogHeaderActions } = useCratisComponentsConfig();
|
|
42
30
|
const dialogId = useId();
|
|
43
31
|
const subtitleId = useId();
|
|
32
|
+
const hostId = useId();
|
|
44
33
|
const labels = resolveDialogLabels(props, messages?.dialog);
|
|
45
34
|
const icon = useCratisIcon();
|
|
46
35
|
const isBrowser = useIsBrowser();
|
|
@@ -61,7 +50,7 @@ const DialogImplementation = (incomingProps) => {
|
|
|
61
50
|
refusedMessage: labels.refused,
|
|
62
51
|
});
|
|
63
52
|
const handleClose = useDialogClose(props, onRefused);
|
|
64
|
-
const dialogDocument = (jsx(DialogDocument, { stackZIndex: resolvedZIndex ?? DIALOG_ZINDEX_TOKEN, visible: visible, contentStyle: props.contentStyle, announcement: announcement, header: {
|
|
53
|
+
const dialogDocument = (jsx(DialogDocument, { stackZIndex: resolvedZIndex ?? DIALOG_ZINDEX_TOKEN, hostId: hostId, visible: visible, contentStyle: props.contentStyle, announcement: announcement, header: {
|
|
65
54
|
dialogId,
|
|
66
55
|
title,
|
|
67
56
|
subtitle,
|
|
@@ -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 } 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,KAAK,CAAC,aAAa;IAClC,eAAe,EAAE,KAAK,CAAC,eAAe;IACtC,MAAM;AACT,CAAA,CAAC;AAMC,MAAM,oBAAoB,GAAG,CAAC,aAA0B,KAAI;AAC/D,IAAA,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,wBAAwB,CAAC,gBAAgB,EAAE,aAAa,CAAC;IACjF,MAAM,EACF,KAAK,EACL,QAAQ,EACR,SAAS,GAAG,QAAQ,EACpB,SAAS,EACT,aAAa,EACb,uBAAuB,GAAG,KAAK,EAC/B,aAAa,EACb,eAAe,GAAG,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AK,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;;"}
|
|
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 { dismissalFor, resolveInitialFocus } from './dialogBehavior';\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/**\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 hostId = 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 hostId={hostId}\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;AAME,MAAM,oBAAoB,GAAG,CAAC,aAA0B,KAAI;AAC/D,IAAA,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,wBAAwB,CAAC,gBAAgB,EAAE,aAAa,CAAC;IACjF,MAAM,EACF,KAAK,EACL,QAAQ,EACR,SAAS,GAAG,QAAQ,EACpB,SAAS,EACT,aAAa,EACb,uBAAuB,GAAG,KAAK,EAC/B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