@cratis/components 4.53.0 → 4.55.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.
Files changed (110) hide show
  1. package/compat-manifest.json +13 -13
  2. package/dist/esm/CommandDialog/CommandDialog.d.ts +9 -1
  3. package/dist/esm/CommandDialog/CommandDialog.d.ts.map +1 -1
  4. package/dist/esm/CommandDialog/CommandDialog.js +10 -4
  5. package/dist/esm/CommandDialog/CommandDialog.js.map +1 -1
  6. package/dist/esm/CommandDialog/index.d.ts +1 -0
  7. package/dist/esm/CommandDialog/index.d.ts.map +1 -1
  8. package/dist/esm/CommandDialog/validationFeedback.d.ts +28 -0
  9. package/dist/esm/CommandDialog/validationFeedback.d.ts.map +1 -0
  10. package/dist/esm/CommandDialog/validationFeedback.js +20 -0
  11. package/dist/esm/CommandDialog/validationFeedback.js.map +1 -0
  12. package/dist/esm/Common/CratisComponentsProvider.d.ts +4 -0
  13. package/dist/esm/Common/CratisComponentsProvider.d.ts.map +1 -1
  14. package/dist/esm/Common/CratisComponentsProvider.js.map +1 -1
  15. package/dist/esm/DataTables/DataTableCard.d.ts +4 -0
  16. package/dist/esm/DataTables/DataTableCard.d.ts.map +1 -0
  17. package/dist/esm/DataTables/DataTableCard.js +43 -0
  18. package/dist/esm/DataTables/DataTableCard.js.map +1 -0
  19. package/dist/esm/DataTables/DataTableCardControls.d.ts +6 -0
  20. package/dist/esm/DataTables/DataTableCardControls.d.ts.map +1 -0
  21. package/dist/esm/DataTables/DataTableCardControls.js +27 -0
  22. package/dist/esm/DataTables/DataTableCardControls.js.map +1 -0
  23. package/dist/esm/DataTables/DataTableCards.d.ts +16 -0
  24. package/dist/esm/DataTables/DataTableCards.d.ts.map +1 -0
  25. package/dist/esm/DataTables/DataTableCards.js +40 -0
  26. package/dist/esm/DataTables/DataTableCards.js.map +1 -0
  27. package/dist/esm/DataTables/DataTableCore.d.ts +3 -1
  28. package/dist/esm/DataTables/DataTableCore.d.ts.map +1 -1
  29. package/dist/esm/DataTables/DataTableCore.js +8 -2
  30. package/dist/esm/DataTables/DataTableCore.js.map +1 -1
  31. package/dist/esm/DataTables/DataTableForObservableQuery.d.ts +2 -1
  32. package/dist/esm/DataTables/DataTableForObservableQuery.d.ts.map +1 -1
  33. package/dist/esm/DataTables/DataTableForObservableQuery.js +1 -1
  34. package/dist/esm/DataTables/DataTableForObservableQuery.js.map +1 -1
  35. package/dist/esm/DataTables/DataTableForQuery.d.ts +2 -1
  36. package/dist/esm/DataTables/DataTableForQuery.d.ts.map +1 -1
  37. package/dist/esm/DataTables/DataTableForQuery.js +1 -1
  38. package/dist/esm/DataTables/DataTableForQuery.js.map +1 -1
  39. package/dist/esm/DataTables/DataTableHeaderCell.d.ts +2 -2
  40. package/dist/esm/DataTables/DataTableHeaderCell.d.ts.map +1 -1
  41. package/dist/esm/DataTables/DataTableHeaderCell.js +5 -19
  42. package/dist/esm/DataTables/DataTableHeaderCell.js.map +1 -1
  43. package/dist/esm/DataTables/DataTableHeaderContent.d.ts +11 -0
  44. package/dist/esm/DataTables/DataTableHeaderContent.d.ts.map +1 -0
  45. package/dist/esm/DataTables/DataTableHeaderContent.js +37 -0
  46. package/dist/esm/DataTables/DataTableHeaderContent.js.map +1 -0
  47. package/dist/esm/DataTables/DataTableMessages.d.ts +2 -0
  48. package/dist/esm/DataTables/DataTableMessages.d.ts.map +1 -1
  49. package/dist/esm/DataTables/DataTableMessages.js.map +1 -1
  50. package/dist/esm/DataTables/DataTableMobileLayoutProps.d.ts +8 -0
  51. package/dist/esm/DataTables/DataTableMobileLayoutProps.d.ts.map +1 -0
  52. package/dist/esm/DataTables/DataTableMobileLayoutProps.js +4 -0
  53. package/dist/esm/DataTables/DataTableMobileLayoutProps.js.map +1 -0
  54. package/dist/esm/DataTables/DataTableParts.d.ts +12 -0
  55. package/dist/esm/DataTables/DataTableParts.d.ts.map +1 -1
  56. package/dist/esm/DataTables/DataTableParts.js.map +1 -1
  57. package/dist/esm/DataTables/DataTableRow.d.ts +3 -1
  58. package/dist/esm/DataTables/DataTableRow.d.ts.map +1 -1
  59. package/dist/esm/DataTables/DataTableRow.js +3 -9
  60. package/dist/esm/DataTables/DataTableRow.js.map +1 -1
  61. package/dist/esm/DataTables/DataTableRows.d.ts.map +1 -1
  62. package/dist/esm/DataTables/DataTableRows.js +1 -1
  63. package/dist/esm/DataTables/DataTableRows.js.map +1 -1
  64. package/dist/esm/DataTables/dataTableCellContent.d.ts +5 -0
  65. package/dist/esm/DataTables/dataTableCellContent.d.ts.map +1 -0
  66. package/dist/esm/DataTables/dataTableCellContent.js +11 -0
  67. package/dist/esm/DataTables/dataTableCellContent.js.map +1 -0
  68. package/dist/esm/DataTables/useDataTableMessages.d.ts.map +1 -1
  69. package/dist/esm/DataTables/useDataTableMessages.js +2 -0
  70. package/dist/esm/DataTables/useDataTableMessages.js.map +1 -1
  71. package/dist/esm/DataTables/useDataTablePresentationFocus.d.ts +3 -0
  72. package/dist/esm/DataTables/useDataTablePresentationFocus.d.ts.map +1 -0
  73. package/dist/esm/DataTables/useDataTablePresentationFocus.js +45 -0
  74. package/dist/esm/DataTables/useDataTablePresentationFocus.js.map +1 -0
  75. package/dist/esm/DataTables/useMobileLayout.d.ts +4 -0
  76. package/dist/esm/DataTables/useMobileLayout.d.ts.map +1 -0
  77. package/dist/esm/DataTables/useMobileLayout.js +20 -0
  78. package/dist/esm/DataTables/useMobileLayout.js.map +1 -0
  79. package/dist/esm/DataTables/useRowSelection.d.ts.map +1 -1
  80. package/dist/esm/DataTables/useRowSelection.js +1 -1
  81. package/dist/esm/DataTables/useRowSelection.js.map +1 -1
  82. package/dist/esm/Dialogs/Dialog.d.ts +7 -0
  83. package/dist/esm/Dialogs/Dialog.d.ts.map +1 -1
  84. package/dist/esm/Dialogs/Dialog.js.map +1 -1
  85. package/dist/esm/Dialogs/DialogImplementation.d.ts.map +1 -1
  86. package/dist/esm/Dialogs/DialogImplementation.js +1 -0
  87. package/dist/esm/Dialogs/DialogImplementation.js.map +1 -1
  88. package/dist/esm/Dialogs/DialogRefusalFeedback.d.ts +11 -0
  89. package/dist/esm/Dialogs/DialogRefusalFeedback.d.ts.map +1 -0
  90. package/dist/esm/Dialogs/DialogRefusalFeedback.js +4 -0
  91. package/dist/esm/Dialogs/DialogRefusalFeedback.js.map +1 -0
  92. package/dist/esm/Dialogs/DialogSlotHost.d.ts.map +1 -1
  93. package/dist/esm/Dialogs/DialogSlotHost.js +1 -0
  94. package/dist/esm/Dialogs/DialogSlotHost.js.map +1 -1
  95. package/dist/esm/Dialogs/index.d.ts +1 -0
  96. package/dist/esm/Dialogs/index.d.ts.map +1 -1
  97. package/dist/esm/Dialogs/useDialogFocus.d.ts +5 -2
  98. package/dist/esm/Dialogs/useDialogFocus.d.ts.map +1 -1
  99. package/dist/esm/Dialogs/useDialogFocus.js +14 -7
  100. package/dist/esm/Dialogs/useDialogFocus.js.map +1 -1
  101. package/dist/esm/styles.DataPage.css +66 -0
  102. package/dist/esm/styles.DataTables.css +66 -0
  103. package/dist/esm/styles.SchemaEditor.css +66 -0
  104. package/dist/esm/styles.css +66 -0
  105. package/dist/esm/styles.renderer.builtin.css +66 -0
  106. package/dist/esm/types/parts.d.ts +21 -3
  107. package/dist/esm/types/parts.d.ts.map +1 -1
  108. package/dist/esm/types/parts.js +21 -3
  109. package/dist/esm/types/parts.js.map +1 -1
  110. package/package.json +1 -1
@@ -70,7 +70,7 @@
70
70
  {
71
71
  "name": "@cratis/components",
72
72
  "role": "core",
73
- "version": "4.53.0",
73
+ "version": "4.55.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.53.0",
97
+ "version": "4.55.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.53.0",
110
+ "version": "4.55.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.53.0",
121
+ "version": "4.55.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.53.0",
127
+ "@cratis/components": "4.55.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.53.0",
137
+ "version": "4.55.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.53.0",
143
+ "@cratis/components": "4.55.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.53.0",
193
+ "version": "4.55.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.53.0",
199
+ "@cratis/components": "4.55.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.53.0",
261
+ "version": "4.55.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.53.0",
267
+ "@cratis/components": "4.55.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.53.0",
309
+ "version": "4.55.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.53.0",
315
+ "@cratis/components": "4.55.0",
316
316
  "@digdir/designsystemet-css": ">=1.24 <2",
317
317
  "@digdir/designsystemet-react": ">=1.24 <2",
318
318
  "react": "^19.0.0",
@@ -3,6 +3,7 @@ import React from 'react';
3
3
  import { type CommandFormProps } from '@cratis/arc.react/commands';
4
4
  import type { BeforeExecuteCallback } from './applyBeforeExecute.js';
5
5
  import type { ConfirmBeforeExecute } from './confirmBeforeExecute.js';
6
+ import { type ValidationAnnouncement } from './validationFeedback.js';
6
7
  /**
7
8
  * Props for {@link CommandDialog}. Combines the props of a `CommandForm`
8
9
  * (`command`, `initialValues`, `onSuccess`, `onValidationFailure`, `onFailed`,
@@ -13,7 +14,7 @@ import type { ConfirmBeforeExecute } from './confirmBeforeExecute.js';
13
14
  * @typeParam TCommand - The command record type (must extend `object`).
14
15
  * @typeParam TResponse - The response payload type returned by a successful command. Defaults to `object`.
15
16
  */
16
- export interface CommandDialogProps<TCommand extends object, TResponse = object> extends Omit<CommandFormProps<TCommand, TResponse>, 'children' | 'onBeforeExecute'>, Omit<DialogProps, 'children' | 'isBusy' | 'isCommandDialog'> {
17
+ export interface CommandDialogProps<TCommand extends object, TResponse = object> extends Omit<CommandFormProps<TCommand, TResponse>, 'children' | 'onBeforeExecute'>, Omit<DialogProps, 'children' | 'isBusy' | 'isCommandDialog' | 'refusalFeedback'> {
17
18
  /**
18
19
  * A transformer invoked with the current command values immediately before
19
20
  * the command executes on confirm. It **must return** the values to run with
@@ -37,6 +38,13 @@ export interface CommandDialogProps<TCommand extends object, TResponse = object>
37
38
  * Unlike `onConfirm`, this runs before execution, not after success.
38
39
  */
39
40
  confirmBeforeExecute?: ConfirmBeforeExecute<TCommand>;
41
+ /**
42
+ * Builds the text announced in the dialog's live region when submit is blocked by
43
+ * validation results. Receives every validation result; use it to localize the
44
+ * announcement. Defaults to an English summary with the number of problems and the
45
+ * first message. Focus moves to the first invalid field either way.
46
+ */
47
+ validationAnnouncement?: ValidationAnnouncement;
40
48
  /**
41
49
  * Form fields and arbitrary content for the dialog body. Children that are
42
50
  * `CommandFormField` instances are automatically wrapped so they bind to
@@ -1 +1 @@
1
- {"version":3,"file":"CommandDialog.d.ts","sourceRoot":"","sources":["../../../CommandDialog/CommandDialog.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,sBAAmB,CAAC;AAC7D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAKH,KAAK,gBAAgB,EACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAsB,CAAC;AAClE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAAwB,CAAC;AAQnE;;;;;;;;;GASG;AACH,MAAM,WAAW,kBAAkB,CAAC,QAAQ,SAAS,MAAM,EAAE,SAAS,GAAG,MAAM,CAC3E,SACI,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,UAAU,GAAG,iBAAiB,CAAC,EAC3E,IAAI,CAAC,WAAW,EAAE,UAAU,GAAG,QAAQ,GAAG,iBAAiB,CAAC;IAChE;;;;;;;;;;;;OAYG;IACH,eAAe,CAAC,EAAE,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IAElD;;;;;;;OAOG;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,GAAG,iBAAiB,GAAG,iBAAiB,CAAC;IACpF;;;;;;;;;;;;OAYG;IACH,eAAe,CAAC,EAAE,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IAElD;;;;;;;OAOG;IACH,oBAAoB,CAAC,EAAE,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAEtD;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;IAEhD;;;;OAIG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC9B;AAgID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoHG;AACH,QAAA,MAAM,sBAAsB;KAAI,QAAQ,SAAS,MAAM,WAAW,SAAS,kBAChE,kBAAkB,CAAC,QAAQ,EAAE,SAAS,CAAC;;CA8FjD,CAAC;AAEF,QAAA,MAAM,0BAA0B,iBAAkB;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,sBAE9E,CAAC;AAKF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,+BAAyB,CAAC"}
@@ -6,12 +6,17 @@ import { CommandForm, useCommandFormContext, useCommandInstance, CommandFormFiel
6
6
  import { useCommandExecution } from './useCommandExecution.js';
7
7
  import { markAsCommandFormColumn, isCommandFormField } from '../CommandForm/commandFormMarkers.js';
8
8
  import { CommandOverlayContext } from '../CommandForm/commandOverlayContext.js';
9
+ import { validationRefusalFeedback } from './validationFeedback.js';
9
10
 
10
- const CommandDialogWrapper = ({ isValid, onClose, onConfirm, onSuccess, onValidationFailure, onFailed, onException, onUnauthorized, onBeforeExecute, confirmBeforeExecute, children, ...dialogProps }) => {
11
+ const CommandDialogWrapper = ({ isValid, onClose, onConfirm, onSuccess, onValidationFailure, onFailed, onException, onUnauthorized, onBeforeExecute, confirmBeforeExecute, validationAnnouncement, children, ...dialogProps }) => {
11
12
  const { setCommandValues, setCommandResult, isValid: isCommandFormValid, } = useCommandFormContext();
12
13
  const commandInstance = useCommandInstance();
13
14
  const submission = useCommandExecution(commandInstance, setCommandValues, onBeforeExecute, confirmBeforeExecute, onException);
15
+ const bodyRef = React.useRef(null);
16
+ const refusedValidation = React.useRef([]);
17
+ const refusalFeedback = () => validationRefusalFeedback(refusedValidation.current, bodyRef.current, validationAnnouncement);
14
18
  const handleConfirm = async () => {
19
+ refusedValidation.current = [];
15
20
  const result = await submission.run();
16
21
  if (!result)
17
22
  return false;
@@ -24,6 +29,7 @@ const CommandDialogWrapper = ({ isValid, onClose, onConfirm, onSuccess, onValida
24
29
  await onUnauthorized?.();
25
30
  if (!result.isValid) {
26
31
  await onValidationFailure?.(result.validationResults);
32
+ refusedValidation.current = result.validationResults ?? [];
27
33
  }
28
34
  if (submission.isMounted())
29
35
  setCommandResult(result);
@@ -59,10 +65,10 @@ const CommandDialogWrapper = ({ isValid, onClose, onConfirm, onSuccess, onValida
59
65
  };
60
66
  const processedChildren = processChildren(children);
61
67
  const isDialogValid = isValid !== false && isCommandFormValid;
62
- return (jsx(Dialog, { ...dialogProps, onClose: onClose, onConfirm: handleConfirm, isValid: isDialogValid, isBusy: submission.isSubmitting, isCommandDialog: true, children: jsx("div", { style: { display: 'flex', flexDirection: 'column', width: '100%' }, children: processedChildren }) }));
68
+ return (jsx(Dialog, { ...dialogProps, onClose: onClose, onConfirm: handleConfirm, isValid: isDialogValid, isBusy: submission.isSubmitting, isCommandDialog: true, refusalFeedback: refusalFeedback, children: jsx("div", { ref: bodyRef, style: { display: 'flex', flexDirection: 'column', width: '100%' }, children: processedChildren }) }));
63
69
  };
64
70
  const CommandDialogComponent = (props) => {
65
- const { title, subtitle, placement, closeIcon, headerActions, hideGlobalHeaderActions, sliceLocation, visible, width, style, contentStyle, resizable, buttons = DialogButtons.OkCancel, initialFocus, okLabel, cancelLabel, yesLabel, noLabel, dismissable, dismissOnOutsideClick, closeOnEscape, showCloseButton, closeAriaLabel, isValid, onClose, onConfirm, onCancel, onBeforeExecute, confirmBeforeExecute, className, pt, ptOptions, unstyled, children, ...commandFormProps } = props;
71
+ const { title, subtitle, placement, closeIcon, headerActions, hideGlobalHeaderActions, sliceLocation, visible, width, style, contentStyle, resizable, buttons = DialogButtons.OkCancel, initialFocus, okLabel, cancelLabel, yesLabel, noLabel, dismissable, dismissOnOutsideClick, closeOnEscape, showCloseButton, closeAriaLabel, isValid, onClose, onConfirm, onCancel, onBeforeExecute, confirmBeforeExecute, validationAnnouncement, className, pt, ptOptions, unstyled, children, ...commandFormProps } = props;
66
72
  const dialogProps = {
67
73
  title,
68
74
  subtitle,
@@ -96,7 +102,7 @@ const CommandDialogComponent = (props) => {
96
102
  ptOptions,
97
103
  unstyled,
98
104
  };
99
- return (jsx(CommandForm, { ...commandFormProps, children: jsx(CommandOverlayContext.Provider, { value: commandFormProps.currentValues, children: jsx(CommandDialogWrapper, { ...dialogProps, onSuccess: props.onSuccess, onValidationFailure: props.onValidationFailure, onFailed: props.onFailed, onException: props.onException, onUnauthorized: props.onUnauthorized, onBeforeExecute: onBeforeExecute, confirmBeforeExecute: confirmBeforeExecute, children: children }) }) }));
105
+ return (jsx(CommandForm, { ...commandFormProps, children: jsx(CommandOverlayContext.Provider, { value: commandFormProps.currentValues, children: jsx(CommandDialogWrapper, { ...dialogProps, onSuccess: props.onSuccess, onValidationFailure: props.onValidationFailure, onFailed: props.onFailed, onException: props.onException, onUnauthorized: props.onUnauthorized, onBeforeExecute: onBeforeExecute, confirmBeforeExecute: confirmBeforeExecute, validationAnnouncement: validationAnnouncement, children: children }) }) }));
100
106
  };
101
107
  const CommandDialogColumnWrapper = ({ children }) => (jsx(CommandForm.Column, { children: children }));
102
108
  markAsCommandFormColumn(CommandDialogColumnWrapper);
@@ -1 +1 @@
1
- {"version":3,"file":"CommandDialog.js","sources":["../../../CommandDialog/CommandDialog.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DialogButtons, DialogResult } from '@cratis/arc.react/dialogs';\nimport { Dialog, type DialogProps } from '../Dialogs/Dialog';\nimport React from 'react';\nimport {\n CommandForm,\n CommandFormFieldWrapper,\n useCommandFormContext,\n useCommandInstance,\n type CommandFormProps,\n} from '@cratis/arc.react/commands';\nimport type { BeforeExecuteCallback } from './applyBeforeExecute';\nimport type { ConfirmBeforeExecute } from './confirmBeforeExecute';\nimport { useCommandExecution } from './useCommandExecution';\nimport {\n isCommandFormField,\n markAsCommandFormColumn,\n} from '../CommandForm/commandFormMarkers';\nimport { CommandOverlayContext } from '../CommandForm/commandOverlayContext';\n\n/**\n * Props for {@link CommandDialog}. Combines the props of a `CommandForm`\n * (`command`, `initialValues`, `onSuccess`, `onValidationFailure`, `onFailed`,\n * `onBeforeExecute`, etc.) with the props of a {@link Dialog} (`title`,\n * `buttons`, `width`, `pt`, `unstyled`, …). Dialog presentation props\n * such as `subtitle`, `placement`, and `closeIcon` are forwarded to the dialog.\n *\n * @typeParam TCommand - The command record type (must extend `object`).\n * @typeParam TResponse - The response payload type returned by a successful command. Defaults to `object`.\n */\nexport interface CommandDialogProps<TCommand extends object, TResponse = object>\n extends\n Omit<CommandFormProps<TCommand, TResponse>, 'children' | 'onBeforeExecute'>,\n Omit<DialogProps, 'children' | 'isBusy' | 'isCommandDialog'> {\n /**\n * A transformer invoked with the current command values immediately before\n * the command executes on confirm. It **must return** the values to run with\n * (mutated or not) — a callback that returns nothing does not execute the\n * command with `undefined`; the current values are kept and a warning is\n * logged. May be async.\n *\n * ⚠️ It runs **only on submit**, after the form has already been validated,\n * so a value produced here can never satisfy required-field validation — the\n * submit button stays disabled if a required value is only seeded here. Seed\n * required values through `initialValues`; reserve `onBeforeExecute` for\n * transforms that do not affect validity (for example a generated id).\n */\n onBeforeExecute?: BeforeExecuteCallback<TCommand>;\n\n /**\n * Ask whether to run the command after validation and `onBeforeExecute`.\n * Receives the transformed values. Only `true` executes; all other outcomes\n * keep the dialog open. May return a promise (for example from a confirmation dialog).\n * If command values change while confirmation is pending, execution is skipped\n * and the dialog stays open; confirm the new values again.\n * Unlike `onConfirm`, this runs before execution, not after success.\n */\n confirmBeforeExecute?: ConfirmBeforeExecute<TCommand>;\n\n /**\n * Form fields and arbitrary content for the dialog body. Children that are\n * `CommandFormField` instances are automatically wrapped so they bind to\n * the command instance.\n */\n children?: React.ReactNode;\n}\n\n// Requiring each key here makes a newly added Dialog prop fail compilation until it is routed.\ntype ForwardedDialogProps = Omit<DialogProps, 'children' | 'isBusy' | 'isCommandDialog'> &\n Record<keyof Omit<DialogProps, 'children' | 'isBusy' | 'isCommandDialog'>, unknown>;\n\nconst CommandDialogWrapper = <TCommand extends object, TResponse = object>({\n isValid,\n onClose,\n onConfirm,\n onSuccess,\n onValidationFailure,\n onFailed,\n onException,\n onUnauthorized,\n onBeforeExecute,\n confirmBeforeExecute,\n children,\n ...dialogProps\n}: Omit<DialogProps, 'isBusy'> & {\n onSuccess?: CommandFormProps<TCommand, TResponse>['onSuccess'];\n onValidationFailure?: CommandFormProps<TCommand, TResponse>['onValidationFailure'];\n onFailed?: CommandFormProps<TCommand, TResponse>['onFailed'];\n onException?: CommandFormProps<TCommand, TResponse>['onException'];\n onUnauthorized?: CommandFormProps<TCommand, TResponse>['onUnauthorized'];\n onBeforeExecute?: BeforeExecuteCallback<TCommand>;\n confirmBeforeExecute?: ConfirmBeforeExecute<TCommand>;\n}) => {\n const {\n setCommandValues,\n setCommandResult,\n isValid: isCommandFormValid,\n } = useCommandFormContext<TCommand>();\n const commandInstance = useCommandInstance<TCommand>();\n const submission = useCommandExecution<TCommand, TResponse>(\n commandInstance, setCommandValues, onBeforeExecute, confirmBeforeExecute, onException,\n );\n\n const handleConfirm = async () => {\n const result = await submission.run();\n if (!result) return false;\n\n if (!result.isSuccess) {\n await onFailed?.(result);\n if (result.hasExceptions) {\n await onException?.(result.exceptionMessages, result.exceptionStackTrace);\n }\n if (!result.isAuthorized) await onUnauthorized?.();\n if (!result.isValid) {\n await onValidationFailure?.(result.validationResults);\n }\n if (submission.isMounted()) setCommandResult(result);\n return false;\n }\n\n await onSuccess?.(result.response as TResponse);\n if (onConfirm) {\n const closeResult = await onConfirm();\n return closeResult === true;\n }\n if (onClose) {\n const closeResult = await onClose(DialogResult.Ok);\n return closeResult !== false;\n }\n return true;\n };\n\n const processChildren = (nodes: React.ReactNode): React.ReactNode => {\n return React.Children.map(nodes, (child) => {\n if (!React.isValidElement(child)) return child;\n\n const component = child.type as React.ComponentType<unknown>;\n if (isCommandFormField(component)) {\n type FieldElement = Parameters<\n typeof CommandFormFieldWrapper\n >[0]['field'];\n // SAFETY: isCommandFormField guards that child.type is a command form field component.\n return (\n <CommandFormFieldWrapper field={child as unknown as FieldElement} />\n );\n }\n\n const childProps = child.props as Record<string, unknown>;\n // A function child is a render prop, not a node: mapping it would replace the\n // function with its mapped result and break the component that calls it.\n if (childProps.children != null && typeof childProps.children !== 'function') {\n return React.cloneElement(\n child as React.ReactElement<Record<string, unknown>>,\n {\n children: processChildren(childProps.children as React.ReactNode),\n },\n );\n }\n\n return child;\n });\n };\n\n const processedChildren = processChildren(children);\n const isDialogValid = isValid !== false && isCommandFormValid;\n\n return (\n <Dialog\n {...dialogProps}\n onClose={onClose}\n onConfirm={handleConfirm}\n isValid={isDialogValid}\n isBusy={submission.isSubmitting}\n isCommandDialog\n >\n <div style={{ display: 'flex', flexDirection: 'column', width: '100%' }}>\n {processedChildren}\n </div>\n </Dialog>\n );\n};\n\n/**\n * A {@link Dialog} that hosts a Cratis Arc `CommandForm`, runs the bound\n * command on confirm, and only closes when the command succeeds. This is\n * the standard pattern for \"user fills in a form, clicks OK, command runs\n * server-side, dialog dismisses\" — `CommandDialog` collapses about thirty\n * lines of orchestration into the props on a single component.\n *\n * ## Where `TCommand` comes from\n *\n * `TCommand` is an auto-generated TypeScript class produced by the Arc proxy\n * generator from a C# `[Command]` record. `dotnet build` writes a `.ts` file\n * per command with the right property types and a typed `execute()` method;\n * importing the class is all the connection-to-the-backend you need. The\n * class also exposes a `.use()` hook for direct (non-dialog) usage and a\n * `useWithChangeTracking()` variant.\n *\n * ## What happens on confirm\n *\n * 1. If `onBeforeExecute` is supplied, it transforms the command values.\n * Used for generated IDs (`Guid.create()`) that the user did not type in.\n * 2. The command's `execute()` runs through Arc's command pipeline. The\n * backend handler returns either a typed response (mapped to `TResponse`)\n * or a `ValidationResult[]`.\n * 3. On `IsSuccess: true`, `onSuccess(response)` fires and the dialog closes\n * through the dialog host context.\n * 4. On a validation failure, `onValidationFailure(errors)` fires and the\n * form's per-field error display is updated. The dialog stays open.\n * 5. On a domain or transport failure, `onFailed(result)` fires. The dialog\n * stays open and the `CommandResult` is set on the form context so the\n * UI can surface the error to the user.\n *\n * Throughout, the dialog is in the `isBusy` state — the confirm button keeps\n * focus but is `aria-disabled` and ignores activation, the other action\n * buttons are disabled, and the confirm button shows a spinner.\n *\n * ## Destructive commands and initial focus\n *\n * The confirm button is focused when the dialog opens, and a focused native\n * button fires `click` from the `keydown` of `Enter`. A command whose form\n * has required fields is protected from a held or double-tapped `Enter` for\n * free, because `isCommandFormValid` keeps confirm disabled until something\n * is filled in. A command that takes **no** input — the typical \"delete\n * this, permanently\" command — has no such gate, so its confirm button is\n * armed the instant the dialog appears.\n *\n * Pass `initialFocus` (forwarded straight to {@link Dialog}) for those:\n *\n * ```tsx\n * <CommandDialog<DeletePerson>\n * command={DeletePerson}\n * title=\"Delete personal data?\"\n * okLabel=\"Delete\"\n * initialFocus={DialogInitialFocus.Cancel}\n * onSuccess={() => closeDialog(DialogResult.Ok)}>\n * This cannot be undone.\n * </CommandDialog>\n * ```\n *\n * Everything else — the footer, the close (X), `Escape`, and the confirm\n * wiring that runs the command — is untouched.\n *\n * ## Field binding\n *\n * Children that are `CommandFormField` instances (`InputTextField`,\n * `NumberField`, `DropdownField`, every `@cratis/components/CommandForm/fields`\n * widget) bind to a property on the command via the `value` accessor:\n *\n * ```tsx\n * <InputTextField value={c => c.name} title=\"Name\" />\n * ```\n *\n * The accessor's argument is the command instance — TypeScript infers\n * `c.name` is a string and the field type-checks against that. Arbitrary\n * non-field children (custom layout, additional text, decorative elements)\n * are rendered as plain content.\n *\n * ## Typed dialog host usage\n *\n * Combine with `useDialog<CommandResult<TResponse>>()` from\n * `@cratis/arc.react/dialogs` to get a fully-typed result at the call site:\n *\n * ```tsx\n * import { useDialog, DialogResult } from '@cratis/arc.react/dialogs';\n * import { CommandDialog } from '@cratis/components/CommandDialog';\n * import { RegisterAuthor } from './RegisterAuthor'; // proxy from C#\n *\n * type RegisterAuthorResponse = { authorId: string };\n *\n * const RegisterAuthorDialog = () => {\n * const { closeDialog } = useDialogContext<CommandResult<RegisterAuthorResponse>>();\n * return (\n * <CommandDialog<RegisterAuthor, RegisterAuthorResponse>\n * command={RegisterAuthor}\n * title=\"Register author\"\n * okLabel=\"Register\"\n * onSuccess={(response) => closeDialog(DialogResult.Ok)}\n * onCancel={() => closeDialog(DialogResult.Cancelled)}>\n * <InputTextField value={c => c.name} title=\"Name\" />\n * <InputTextField value={c => c.email} title=\"Email\" />\n * </CommandDialog>\n * );\n * };\n * ```\n *\n * ## What's special vs. raw Dialog + CommandForm\n *\n * - Confirm wiring (`onConfirm` → `commandInstance.execute()`) is handled\n * internally; you only supply `onSuccess` / `onValidationFailure` / `onFailed`.\n * - The dialog's `isBusy` state tracks the in-flight command without manual\n * `useState`.\n * - Field error propagation from `CommandResult.validationResults` to the\n * form context is automatic.\n *\n * @typeParam TCommand - The command class (proxy generated from C# `[Command]`).\n * @typeParam TResponse - The success payload type returned by the command's `Handle()` method on the backend.\n * @param props - {@link CommandDialogProps}.\n */\nconst CommandDialogComponent = <TCommand extends object = object, TResponse = object>(\n props: CommandDialogProps<TCommand, TResponse>,\n) => {\n const {\n title,\n subtitle,\n placement,\n closeIcon,\n headerActions,\n hideGlobalHeaderActions,\n sliceLocation,\n visible,\n width,\n style,\n contentStyle,\n resizable,\n buttons = DialogButtons.OkCancel,\n initialFocus,\n okLabel,\n cancelLabel,\n yesLabel,\n noLabel,\n dismissable,\n dismissOnOutsideClick,\n closeOnEscape,\n showCloseButton,\n closeAriaLabel,\n isValid,\n onClose,\n onConfirm,\n onCancel,\n onBeforeExecute,\n confirmBeforeExecute,\n className,\n pt,\n ptOptions,\n unstyled,\n children,\n ...commandFormProps\n } = props;\n\n const dialogProps = {\n title,\n subtitle,\n placement,\n closeIcon,\n headerActions,\n hideGlobalHeaderActions,\n sliceLocation,\n visible,\n width,\n style,\n contentStyle,\n resizable,\n buttons,\n initialFocus,\n okLabel,\n cancelLabel,\n yesLabel,\n noLabel,\n dismissable,\n dismissOnOutsideClick,\n closeOnEscape,\n showCloseButton,\n closeAriaLabel,\n isValid,\n onClose,\n onConfirm,\n onCancel,\n className,\n pt,\n ptOptions,\n unstyled,\n } satisfies ForwardedDialogProps;\n\n return (\n <CommandForm<TCommand, TResponse> {...commandFormProps}>\n <CommandOverlayContext.Provider value={commandFormProps.currentValues}>\n <CommandDialogWrapper<TCommand, TResponse>\n {...dialogProps}\n onSuccess={props.onSuccess}\n onValidationFailure={props.onValidationFailure}\n onFailed={props.onFailed}\n onException={props.onException}\n onUnauthorized={props.onUnauthorized}\n onBeforeExecute={onBeforeExecute}\n confirmBeforeExecute={confirmBeforeExecute}\n >\n {children}\n </CommandDialogWrapper>\n </CommandOverlayContext.Provider>\n </CommandForm>\n );\n};\n\nconst CommandDialogColumnWrapper = ({ children }: { children: React.ReactNode }) => (\n <CommandForm.Column>{children}</CommandForm.Column>\n);\nmarkAsCommandFormColumn(CommandDialogColumnWrapper);\n\nCommandDialogComponent.Column = CommandDialogColumnWrapper;\n\n/**\n * A {@link Dialog} that hosts a Cratis Arc `CommandForm`, runs the bound\n * command on confirm, and only closes when the command succeeds. This is\n * the standard pattern for \"user fills in a form, clicks OK, command runs\n * server-side, dialog dismisses\" — `CommandDialog` collapses about thirty\n * lines of orchestration into the props on a single component.\n *\n * See {@link CommandDialogComponent} for full documentation.\n *\n * @typeParam TCommand - The command class (proxy generated from C# `[Command]`).\n * @typeParam TResponse - The success payload type returned by the command's `Handle()` method on the backend.\n */\nexport const CommandDialog = CommandDialogComponent;\n"],"names":["_jsx"],"mappings":";;;;;;;;;AAyEA,MAAM,oBAAoB,GAAG,CAA8C,EACvE,OAAO,EACP,OAAO,EACP,SAAS,EACT,SAAS,EACT,mBAAmB,EACnB,QAAQ,EACR,WAAW,EACX,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,QAAQ,EACR,GAAG,WAAW,EASjB,KAAI;AACD,IAAA,MAAM,EACF,gBAAgB,EAChB,gBAAgB,EAChB,OAAO,EAAE,kBAAkB,GAC9B,GAAG,qBAAqB,EAAY;AACrC,IAAA,MAAM,eAAe,GAAG,kBAAkB,EAAY;AACtD,IAAA,MAAM,UAAU,GAAG,mBAAmB,CAClC,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,oBAAoB,EAAE,WAAW,CACxF;AAED,IAAA,MAAM,aAAa,GAAG,YAAW;AAC7B,QAAA,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,GAAG,EAAE;AACrC,QAAA,IAAI,CAAC,MAAM;AAAE,YAAA,OAAO,KAAK;AAEzB,QAAA,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE;AACnB,YAAA,MAAM,QAAQ,GAAG,MAAM,CAAC;AACxB,YAAA,IAAI,MAAM,CAAC,aAAa,EAAE;gBACtB,MAAM,WAAW,GAAG,MAAM,CAAC,iBAAiB,EAAE,MAAM,CAAC,mBAAmB,CAAC;YAC7E;YACA,IAAI,CAAC,MAAM,CAAC,YAAY;gBAAE,MAAM,cAAc,IAAI;AAClD,YAAA,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;AACjB,gBAAA,MAAM,mBAAmB,GAAG,MAAM,CAAC,iBAAiB,CAAC;YACzD;YACA,IAAI,UAAU,CAAC,SAAS,EAAE;gBAAE,gBAAgB,CAAC,MAAM,CAAC;AACp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T,QAAQ;KACoB;AAEhC,IAAA,QACIA,GAAA,CAAC,WAAW,EAAA,EAAA,GAA0B,gBAAgB,EAAA,QAAA,EAClDA,GAAA,CAAC,qBAAqB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,gBAAgB,CAAC,aAAa,EAAA,QAAA,EACjEA,GAAA,CAAC,oBAAoB,EAAA,EAAA,GACb,WAAW,EACf,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,mBAAmB,EAAE,KAAK,CAAC,mBAAmB,EAC9C,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,cAAc,EAAE,KAAK,CAAC,cAAc,EACpC,eAAe,EAAE,eAAe,EAChC,oBAAoB,EAAE,oBAAoB,EAAA,QAAA,EAEzC,QAAQ,EAAA,CACU,EAAA,CACM,EAAA,CACvB;AAEtB,CAAC;AAED,MAAM,0BAA0B,GAAG,CAAC,EAAE,QAAQ,EAAiC,MAC3EA,GAAA,CAAC,WAAW,CAAC,MAAM,cAAE,QAAQ,EAAA,CAAsB,CACtD;AACD,uBAAuB,CAAC,0BAA0B,CAAC;AAEnD,sBAAsB,CAAC,MAAM,GAAG,0BAA0B;AAcnD,MAAM,aAAa,GAAG;;"}
1
+ {"version":3,"file":"CommandDialog.js","sources":["../../../CommandDialog/CommandDialog.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DialogButtons, DialogResult } from '@cratis/arc.react/dialogs';\nimport { Dialog, type DialogProps } from '../Dialogs/Dialog';\nimport React from 'react';\nimport {\n CommandForm,\n CommandFormFieldWrapper,\n useCommandFormContext,\n useCommandInstance,\n type CommandFormProps,\n} from '@cratis/arc.react/commands';\nimport type { BeforeExecuteCallback } from './applyBeforeExecute';\nimport type { ConfirmBeforeExecute } from './confirmBeforeExecute';\nimport { useCommandExecution } from './useCommandExecution';\nimport {\n isCommandFormField,\n markAsCommandFormColumn,\n} from '../CommandForm/commandFormMarkers';\nimport { CommandOverlayContext } from '../CommandForm/commandOverlayContext';\nimport {\n validationRefusalFeedback,\n type CommandValidationResults,\n type ValidationAnnouncement,\n} from './validationFeedback';\n\n/**\n * Props for {@link CommandDialog}. Combines the props of a `CommandForm`\n * (`command`, `initialValues`, `onSuccess`, `onValidationFailure`, `onFailed`,\n * `onBeforeExecute`, etc.) with the props of a {@link Dialog} (`title`,\n * `buttons`, `width`, `pt`, `unstyled`, …). Dialog presentation props\n * such as `subtitle`, `placement`, and `closeIcon` are forwarded to the dialog.\n *\n * @typeParam TCommand - The command record type (must extend `object`).\n * @typeParam TResponse - The response payload type returned by a successful command. Defaults to `object`.\n */\nexport interface CommandDialogProps<TCommand extends object, TResponse = object>\n extends\n Omit<CommandFormProps<TCommand, TResponse>, 'children' | 'onBeforeExecute'>,\n Omit<DialogProps, 'children' | 'isBusy' | 'isCommandDialog' | 'refusalFeedback'> {\n /**\n * A transformer invoked with the current command values immediately before\n * the command executes on confirm. It **must return** the values to run with\n * (mutated or not) — a callback that returns nothing does not execute the\n * command with `undefined`; the current values are kept and a warning is\n * logged. May be async.\n *\n * ⚠️ It runs **only on submit**, after the form has already been validated,\n * so a value produced here can never satisfy required-field validation — the\n * submit button stays disabled if a required value is only seeded here. Seed\n * required values through `initialValues`; reserve `onBeforeExecute` for\n * transforms that do not affect validity (for example a generated id).\n */\n onBeforeExecute?: BeforeExecuteCallback<TCommand>;\n\n /**\n * Ask whether to run the command after validation and `onBeforeExecute`.\n * Receives the transformed values. Only `true` executes; all other outcomes\n * keep the dialog open. May return a promise (for example from a confirmation dialog).\n * If command values change while confirmation is pending, execution is skipped\n * and the dialog stays open; confirm the new values again.\n * Unlike `onConfirm`, this runs before execution, not after success.\n */\n confirmBeforeExecute?: ConfirmBeforeExecute<TCommand>;\n\n /**\n * Builds the text announced in the dialog's live region when submit is blocked by\n * validation results. Receives every validation result; use it to localize the\n * announcement. Defaults to an English summary with the number of problems and the\n * first message. Focus moves to the first invalid field either way.\n */\n validationAnnouncement?: ValidationAnnouncement;\n\n /**\n * Form fields and arbitrary content for the dialog body. Children that are\n * `CommandFormField` instances are automatically wrapped so they bind to\n * the command instance.\n */\n children?: React.ReactNode;\n}\n\n// Requiring each key here makes a newly added Dialog prop fail compilation until it is routed.\ntype CommandDialogOwnedProps = 'children' | 'isBusy' | 'isCommandDialog' | 'refusalFeedback';\ntype ForwardedDialogProps = Omit<DialogProps, CommandDialogOwnedProps> &\n Record<keyof Omit<DialogProps, CommandDialogOwnedProps>, unknown>;\n\nconst CommandDialogWrapper = <TCommand extends object, TResponse = object>({\n isValid,\n onClose,\n onConfirm,\n onSuccess,\n onValidationFailure,\n onFailed,\n onException,\n onUnauthorized,\n onBeforeExecute,\n confirmBeforeExecute,\n validationAnnouncement,\n children,\n ...dialogProps\n}: Omit<DialogProps, 'isBusy' | 'refusalFeedback'> & {\n onSuccess?: CommandFormProps<TCommand, TResponse>['onSuccess'];\n onValidationFailure?: CommandFormProps<TCommand, TResponse>['onValidationFailure'];\n onFailed?: CommandFormProps<TCommand, TResponse>['onFailed'];\n onException?: CommandFormProps<TCommand, TResponse>['onException'];\n onUnauthorized?: CommandFormProps<TCommand, TResponse>['onUnauthorized'];\n onBeforeExecute?: BeforeExecuteCallback<TCommand>;\n confirmBeforeExecute?: ConfirmBeforeExecute<TCommand>;\n validationAnnouncement?: ValidationAnnouncement;\n}) => {\n const {\n setCommandValues,\n setCommandResult,\n isValid: isCommandFormValid,\n } = useCommandFormContext<TCommand>();\n const commandInstance = useCommandInstance<TCommand>();\n const submission = useCommandExecution<TCommand, TResponse>(\n commandInstance, setCommandValues, onBeforeExecute, confirmBeforeExecute, onException,\n );\n\n const bodyRef = React.useRef<HTMLDivElement>(null);\n const refusedValidation = React.useRef<CommandValidationResults>([]);\n const refusalFeedback = () =>\n validationRefusalFeedback(refusedValidation.current, bodyRef.current, validationAnnouncement);\n\n const handleConfirm = async () => {\n refusedValidation.current = [];\n const result = await submission.run();\n if (!result) return false;\n\n if (!result.isSuccess) {\n await onFailed?.(result);\n if (result.hasExceptions) {\n await onException?.(result.exceptionMessages, result.exceptionStackTrace);\n }\n if (!result.isAuthorized) await onUnauthorized?.();\n if (!result.isValid) {\n await onValidationFailure?.(result.validationResults);\n refusedValidation.current = result.validationResults ?? [];\n }\n if (submission.isMounted()) setCommandResult(result);\n return false;\n }\n\n await onSuccess?.(result.response as TResponse);\n if (onConfirm) {\n const closeResult = await onConfirm();\n return closeResult === true;\n }\n if (onClose) {\n const closeResult = await onClose(DialogResult.Ok);\n return closeResult !== false;\n }\n return true;\n };\n\n const processChildren = (nodes: React.ReactNode): React.ReactNode => {\n return React.Children.map(nodes, (child) => {\n if (!React.isValidElement(child)) return child;\n\n const component = child.type as React.ComponentType<unknown>;\n if (isCommandFormField(component)) {\n type FieldElement = Parameters<\n typeof CommandFormFieldWrapper\n >[0]['field'];\n // SAFETY: isCommandFormField guards that child.type is a command form field component.\n return (\n <CommandFormFieldWrapper field={child as unknown as FieldElement} />\n );\n }\n\n const childProps = child.props as Record<string, unknown>;\n // A function child is a render prop, not a node: mapping it would replace the\n // function with its mapped result and break the component that calls it.\n if (childProps.children != null && typeof childProps.children !== 'function') {\n return React.cloneElement(\n child as React.ReactElement<Record<string, unknown>>,\n {\n children: processChildren(childProps.children as React.ReactNode),\n },\n );\n }\n\n return child;\n });\n };\n\n const processedChildren = processChildren(children);\n const isDialogValid = isValid !== false && isCommandFormValid;\n\n return (\n <Dialog\n {...dialogProps}\n onClose={onClose}\n onConfirm={handleConfirm}\n isValid={isDialogValid}\n isBusy={submission.isSubmitting}\n isCommandDialog\n refusalFeedback={refusalFeedback}\n >\n <div ref={bodyRef} style={{ display: 'flex', flexDirection: 'column', width: '100%' }}>\n {processedChildren}\n </div>\n </Dialog>\n );\n};\n\n/**\n * A {@link Dialog} that hosts a Cratis Arc `CommandForm`, runs the bound\n * command on confirm, and only closes when the command succeeds. This is\n * the standard pattern for \"user fills in a form, clicks OK, command runs\n * server-side, dialog dismisses\" — `CommandDialog` collapses about thirty\n * lines of orchestration into the props on a single component.\n *\n * ## Where `TCommand` comes from\n *\n * `TCommand` is an auto-generated TypeScript class produced by the Arc proxy\n * generator from a C# `[Command]` record. `dotnet build` writes a `.ts` file\n * per command with the right property types and a typed `execute()` method;\n * importing the class is all the connection-to-the-backend you need. The\n * class also exposes a `.use()` hook for direct (non-dialog) usage and a\n * `useWithChangeTracking()` variant.\n *\n * ## What happens on confirm\n *\n * 1. If `onBeforeExecute` is supplied, it transforms the command values.\n * Used for generated IDs (`Guid.create()`) that the user did not type in.\n * 2. The command's `execute()` runs through Arc's command pipeline. The\n * backend handler returns either a typed response (mapped to `TResponse`)\n * or a `ValidationResult[]`.\n * 3. On `IsSuccess: true`, `onSuccess(response)` fires and the dialog closes\n * through the dialog host context.\n * 4. On a validation failure, `onValidationFailure(errors)` fires and the\n * form's per-field error display is updated. The dialog stays open.\n * 5. On a domain or transport failure, `onFailed(result)` fires. The dialog\n * stays open and the `CommandResult` is set on the form context so the\n * UI can surface the error to the user.\n *\n * Throughout, the dialog is in the `isBusy` state — the confirm button keeps\n * focus but is `aria-disabled` and ignores activation, the other action\n * buttons are disabled, and the confirm button shows a spinner.\n *\n * ## Destructive commands and initial focus\n *\n * The confirm button is focused when the dialog opens, and a focused native\n * button fires `click` from the `keydown` of `Enter`. A command whose form\n * has required fields is protected from a held or double-tapped `Enter` for\n * free, because `isCommandFormValid` keeps confirm disabled until something\n * is filled in. A command that takes **no** input — the typical \"delete\n * this, permanently\" command — has no such gate, so its confirm button is\n * armed the instant the dialog appears.\n *\n * Pass `initialFocus` (forwarded straight to {@link Dialog}) for those:\n *\n * ```tsx\n * <CommandDialog<DeletePerson>\n * command={DeletePerson}\n * title=\"Delete personal data?\"\n * okLabel=\"Delete\"\n * initialFocus={DialogInitialFocus.Cancel}\n * onSuccess={() => closeDialog(DialogResult.Ok)}>\n * This cannot be undone.\n * </CommandDialog>\n * ```\n *\n * Everything else — the footer, the close (X), `Escape`, and the confirm\n * wiring that runs the command — is untouched.\n *\n * ## Field binding\n *\n * Children that are `CommandFormField` instances (`InputTextField`,\n * `NumberField`, `DropdownField`, every `@cratis/components/CommandForm/fields`\n * widget) bind to a property on the command via the `value` accessor:\n *\n * ```tsx\n * <InputTextField value={c => c.name} title=\"Name\" />\n * ```\n *\n * The accessor's argument is the command instance — TypeScript infers\n * `c.name` is a string and the field type-checks against that. Arbitrary\n * non-field children (custom layout, additional text, decorative elements)\n * are rendered as plain content.\n *\n * ## Typed dialog host usage\n *\n * Combine with `useDialog<CommandResult<TResponse>>()` from\n * `@cratis/arc.react/dialogs` to get a fully-typed result at the call site:\n *\n * ```tsx\n * import { useDialog, DialogResult } from '@cratis/arc.react/dialogs';\n * import { CommandDialog } from '@cratis/components/CommandDialog';\n * import { RegisterAuthor } from './RegisterAuthor'; // proxy from C#\n *\n * type RegisterAuthorResponse = { authorId: string };\n *\n * const RegisterAuthorDialog = () => {\n * const { closeDialog } = useDialogContext<CommandResult<RegisterAuthorResponse>>();\n * return (\n * <CommandDialog<RegisterAuthor, RegisterAuthorResponse>\n * command={RegisterAuthor}\n * title=\"Register author\"\n * okLabel=\"Register\"\n * onSuccess={(response) => closeDialog(DialogResult.Ok)}\n * onCancel={() => closeDialog(DialogResult.Cancelled)}>\n * <InputTextField value={c => c.name} title=\"Name\" />\n * <InputTextField value={c => c.email} title=\"Email\" />\n * </CommandDialog>\n * );\n * };\n * ```\n *\n * ## What's special vs. raw Dialog + CommandForm\n *\n * - Confirm wiring (`onConfirm` → `commandInstance.execute()`) is handled\n * internally; you only supply `onSuccess` / `onValidationFailure` / `onFailed`.\n * - The dialog's `isBusy` state tracks the in-flight command without manual\n * `useState`.\n * - Field error propagation from `CommandResult.validationResults` to the\n * form context is automatic.\n *\n * @typeParam TCommand - The command class (proxy generated from C# `[Command]`).\n * @typeParam TResponse - The success payload type returned by the command's `Handle()` method on the backend.\n * @param props - {@link CommandDialogProps}.\n */\nconst CommandDialogComponent = <TCommand extends object = object, TResponse = object>(\n props: CommandDialogProps<TCommand, TResponse>,\n) => {\n const {\n title,\n subtitle,\n placement,\n closeIcon,\n headerActions,\n hideGlobalHeaderActions,\n sliceLocation,\n visible,\n width,\n style,\n contentStyle,\n resizable,\n buttons = DialogButtons.OkCancel,\n initialFocus,\n okLabel,\n cancelLabel,\n yesLabel,\n noLabel,\n dismissable,\n dismissOnOutsideClick,\n closeOnEscape,\n showCloseButton,\n closeAriaLabel,\n isValid,\n onClose,\n onConfirm,\n onCancel,\n onBeforeExecute,\n confirmBeforeExecute,\n validationAnnouncement,\n className,\n pt,\n ptOptions,\n unstyled,\n children,\n ...commandFormProps\n } = props;\n\n const dialogProps = {\n title,\n subtitle,\n placement,\n closeIcon,\n headerActions,\n hideGlobalHeaderActions,\n sliceLocation,\n visible,\n width,\n style,\n contentStyle,\n resizable,\n buttons,\n initialFocus,\n okLabel,\n cancelLabel,\n yesLabel,\n noLabel,\n dismissable,\n dismissOnOutsideClick,\n closeOnEscape,\n showCloseButton,\n closeAriaLabel,\n isValid,\n onClose,\n onConfirm,\n onCancel,\n className,\n pt,\n ptOptions,\n unstyled,\n } satisfies ForwardedDialogProps;\n\n return (\n <CommandForm<TCommand, TResponse> {...commandFormProps}>\n <CommandOverlayContext.Provider value={commandFormProps.currentValues}>\n <CommandDialogWrapper<TCommand, TResponse>\n {...dialogProps}\n onSuccess={props.onSuccess}\n onValidationFailure={props.onValidationFailure}\n onFailed={props.onFailed}\n onException={props.onException}\n onUnauthorized={props.onUnauthorized}\n onBeforeExecute={onBeforeExecute}\n confirmBeforeExecute={confirmBeforeExecute}\n validationAnnouncement={validationAnnouncement}\n >\n {children}\n </CommandDialogWrapper>\n </CommandOverlayContext.Provider>\n </CommandForm>\n );\n};\n\nconst CommandDialogColumnWrapper = ({ children }: { children: React.ReactNode }) => (\n <CommandForm.Column>{children}</CommandForm.Column>\n);\nmarkAsCommandFormColumn(CommandDialogColumnWrapper);\n\nCommandDialogComponent.Column = CommandDialogColumnWrapper;\n\n/**\n * A {@link Dialog} that hosts a Cratis Arc `CommandForm`, runs the bound\n * command on confirm, and only closes when the command succeeds. This is\n * the standard pattern for \"user fills in a form, clicks OK, command runs\n * server-side, dialog dismisses\" — `CommandDialog` collapses about thirty\n * lines of orchestration into the props on a single component.\n *\n * See {@link CommandDialogComponent} for full documentation.\n *\n * @typeParam TCommand - The command class (proxy generated from C# `[Command]`).\n * @typeParam TResponse - The success payload type returned by the command's `Handle()` method on the backend.\n */\nexport const CommandDialog = CommandDialogComponent;\n"],"names":["_jsx"],"mappings":";;;;;;;;;;AAuFA,MAAM,oBAAoB,GAAG,CAA8C,EACvE,OAAO,EACP,OAAO,EACP,SAAS,EACT,SAAS,EACT,mBAAmB,EACnB,QAAQ,EACR,WAAW,EACX,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACtB,QAAQ,EACR,GAAG,WAAW,EAUjB,KAAI;AACD,IAAA,MAAM,EACF,gBAAgB,EAChB,gBAAgB,EAChB,OAAO,EAAE,kBAAkB,GAC9B,GAAG,qBAAqB,EAAY;AACrC,IAAA,MAAM,eAAe,GAAG,kBAAkB,EAAY;AACtD,IAAA,MAAM,UAAU,GAAG,mBAAmB,CAClC,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,oBAAoB,EAAE,WAAW,CACxF;IAED,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAiB,IAAI,CAAC;IAClD,MAAM,iBAAiB,GAAG,KAAK,CAAC,MAAM,CAA2B,EAAE,CAAC;AACpE,IAAA,MAAM,eAAe,GAAG,MACpB,yBAAyB,CAAC,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,sBAAsB,CAAC;AAEjG,IAAA,MAAM,aAAa,GAAG,YAAW;AAC7B,QAAA,iBAAiB,CAAC,OAAO,GAAG,EAAE;AAC9B,QAAA,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,GAAG,EAAE;AACrC,QAA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,EAAA,CACvB;AAEtB,CAAC;AAED,MAAM,0BAA0B,GAAG,CAAC,EAAE,QAAQ,EAAiC,MAC3EA,GAAA,CAAC,WAAW,CAAC,MAAM,cAAE,QAAQ,EAAA,CAAsB,CACtD;AACD,uBAAuB,CAAC,0BAA0B,CAAC;AAEnD,sBAAsB,CAAC,MAAM,GAAG,0BAA0B;AAcnD,MAAM,aAAa,GAAG;;"}
@@ -4,4 +4,5 @@ export * from './CommandDialog.js';
4
4
  export * from './CommandStepper.js';
5
5
  export * from './StepperCommandDialog.js';
6
6
  export * from './StepperPanel.js';
7
+ export type { CommandValidationResults, ValidationAnnouncement } from './validationFeedback.js';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../CommandDialog/index.ts"],"names":[],"mappings":"AAGA,cAAc,yBAAsB,CAAC;AACrC,YAAY,EAAE,oBAAoB,EAAE,MAAM,2BAAwB,CAAC;AACnE,cAAc,oBAAiB,CAAC;AAChC,cAAc,qBAAkB,CAAC;AACjC,cAAc,2BAAwB,CAAC;AACvC,cAAc,mBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../CommandDialog/index.ts"],"names":[],"mappings":"AAGA,cAAc,yBAAsB,CAAC;AACrC,YAAY,EAAE,oBAAoB,EAAE,MAAM,2BAAwB,CAAC;AACnE,cAAc,oBAAiB,CAAC;AAChC,cAAc,qBAAkB,CAAC;AACjC,cAAc,2BAAwB,CAAC;AACvC,cAAc,mBAAgB,CAAC;AAC/B,YAAY,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,yBAAsB,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { CommandFormProps } from '@cratis/arc.react/commands';
2
+ import type { DialogRefusalFeedback } from '../Dialogs/DialogRefusalFeedback.js';
3
+ /** The validation results a refused command reports. */
4
+ export type CommandValidationResults = Parameters<NonNullable<CommandFormProps<object, object>['onValidationFailure']>>[0];
5
+ /** Builds the live-region text announced when submit is blocked by validation. */
6
+ export type ValidationAnnouncement = (results: CommandValidationResults) => string;
7
+ /**
8
+ * The built-in English announcement: how many problems there are and the first one.
9
+ * @param results The validation results, at least one.
10
+ * @returns The text to announce.
11
+ */
12
+ export declare const defaultValidationAnnouncement: ValidationAnnouncement;
13
+ /**
14
+ * Finds the first invalid field in a container: the first element marked `aria-invalid="true"`,
15
+ * or its first focusable descendant when the marked element is a wrapper.
16
+ * @param container The element holding the fields.
17
+ * @returns The element to focus, or `undefined` when there is none.
18
+ */
19
+ export declare const firstInvalidField: (container: HTMLElement | null) => HTMLElement | undefined;
20
+ /**
21
+ * Describes a refusal caused by validation: the announcement and the field to focus.
22
+ * @param results The validation results of the refused command; empty when it was not refused by validation.
23
+ * @param container The element holding the fields.
24
+ * @param announce Builds the announcement text.
25
+ * @returns The feedback, or `undefined` to keep the dialog's generic refusal behavior.
26
+ */
27
+ export declare const validationRefusalFeedback: (results: CommandValidationResults, container: HTMLElement | null, announce?: ValidationAnnouncement) => DialogRefusalFeedback | undefined;
28
+ //# sourceMappingURL=validationFeedback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validationFeedback.d.ts","sourceRoot":"","sources":["../../../CommandDialog/validationFeedback.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qCAAkC,CAAC;AAE9E,wDAAwD;AACxD,MAAM,MAAM,wBAAwB,GAAG,UAAU,CAC7C,WAAW,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,qBAAqB,CAAC,CAAC,CACvE,CAAC,CAAC,CAAC,CAAC;AAEL,kFAAkF;AAClF,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,EAAE,wBAAwB,KAAK,MAAM,CAAC;AAEnF;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,EAAE,sBAGkC,CAAC;AAK/E;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,cAAe,WAAW,GAAG,IAAI,KAAG,WAAW,GAAG,SAK/E,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,YACzB,wBAAwB,aACtB,WAAW,GAAG,IAAI,aACnB,sBAAsB,KACjC,qBAAqB,GAAG,SAG1B,CAAC"}
@@ -0,0 +1,20 @@
1
+ const defaultValidationAnnouncement = (results) => results.length === 1
2
+ ? `There is 1 problem. ${results[0].message}`
3
+ : `There are ${results.length} problems. First: ${results[0].message}`;
4
+ const focusableSelector = 'input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex="-1"])';
5
+ const firstInvalidField = (container) => {
6
+ const invalid = container?.querySelector('[aria-invalid="true"]');
7
+ if (!invalid)
8
+ return undefined;
9
+ if (invalid.matches(focusableSelector))
10
+ return invalid;
11
+ return invalid.querySelector(focusableSelector) ?? undefined;
12
+ };
13
+ const validationRefusalFeedback = (results, container, announce = defaultValidationAnnouncement) => {
14
+ if (results.length === 0)
15
+ return undefined;
16
+ return { message: announce(results), focus: firstInvalidField(container) };
17
+ };
18
+
19
+ export { defaultValidationAnnouncement, firstInvalidField, validationRefusalFeedback };
20
+ //# sourceMappingURL=validationFeedback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validationFeedback.js","sources":["../../../CommandDialog/validationFeedback.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 { CommandFormProps } from '@cratis/arc.react/commands';\nimport type { DialogRefusalFeedback } from '../Dialogs/DialogRefusalFeedback';\n\n/** The validation results a refused command reports. */\nexport type CommandValidationResults = Parameters<\n NonNullable<CommandFormProps<object, object>['onValidationFailure']>\n>[0];\n\n/** Builds the live-region text announced when submit is blocked by validation. */\nexport type ValidationAnnouncement = (results: CommandValidationResults) => string;\n\n/**\n * The built-in English announcement: how many problems there are and the first one.\n * @param results The validation results, at least one.\n * @returns The text to announce.\n */\nexport const defaultValidationAnnouncement: ValidationAnnouncement = (results) =>\n results.length === 1\n ? `There is 1 problem. ${results[0].message}`\n : `There are ${results.length} problems. First: ${results[0].message}`;\n\nconst focusableSelector =\n 'input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\n/**\n * Finds the first invalid field in a container: the first element marked `aria-invalid=\"true\"`,\n * or its first focusable descendant when the marked element is a wrapper.\n * @param container The element holding the fields.\n * @returns The element to focus, or `undefined` when there is none.\n */\nexport const firstInvalidField = (container: HTMLElement | null): HTMLElement | undefined => {\n const invalid = container?.querySelector<HTMLElement>('[aria-invalid=\"true\"]');\n if (!invalid) return undefined;\n if (invalid.matches(focusableSelector)) return invalid;\n return invalid.querySelector<HTMLElement>(focusableSelector) ?? undefined;\n};\n\n/**\n * Describes a refusal caused by validation: the announcement and the field to focus.\n * @param results The validation results of the refused command; empty when it was not refused by validation.\n * @param container The element holding the fields.\n * @param announce Builds the announcement text.\n * @returns The feedback, or `undefined` to keep the dialog's generic refusal behavior.\n */\nexport const validationRefusalFeedback = (\n results: CommandValidationResults,\n container: HTMLElement | null,\n announce: ValidationAnnouncement = defaultValidationAnnouncement,\n): DialogRefusalFeedback | undefined => {\n if (results.length === 0) return undefined;\n return { message: announce(results), focus: firstInvalidField(container) };\n};\n"],"names":[],"mappings":"AAmBO,MAAM,6BAA6B,GAA2B,CAAC,OAAO,KACzE,OAAO,CAAC,MAAM,KAAK;MACb,uBAAuB,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAA;AAC3C,MAAE,CAAA,UAAA,EAAa,OAAO,CAAC,MAAM,CAAA,kBAAA,EAAqB,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO;AAE5E,MAAM,iBAAiB,GACnB,kIAAkI;AAQ/H,MAAM,iBAAiB,GAAG,CAAC,SAA6B,KAA6B;IACxF,MAAM,OAAO,GAAG,SAAS,EAAE,aAAa,CAAc,uBAAuB,CAAC;AAC9E,IAAA,IAAI,CAAC,OAAO;AAAE,QAAA,OAAO,SAAS;AAC9B,IAAA,IAAI,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC;AAAE,QAAA,OAAO,OAAO;IACtD,OAAO,OAAO,CAAC,aAAa,CAAc,iBAAiB,CAAC,IAAI,SAAS;AAC7E;AASO,MAAM,yBAAyB,GAAG,CACrC,OAAiC,EACjC,SAA6B,EAC7B,QAAA,GAAmC,6BAA6B,KAC7B;AACnC,IAAA,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;AAAE,QAAA,OAAO,SAAS;AAC1C,IAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,iBAAiB,CAAC,SAAS,CAAC,EAAE;AAC9E;;"}
@@ -94,6 +94,10 @@ export interface CratisDataTableMessages {
94
94
  selectRow?: string;
95
95
  /** Accessible name for the select-all control in a multiple-selection header. */
96
96
  selectAllRows?: string;
97
+ /** Audible ascending sort direction in card controls. Defaults to 'Ascending'. */
98
+ sortAscending?: string;
99
+ /** Audible descending sort direction in card controls. Defaults to 'Descending'. */
100
+ sortDescending?: string;
97
101
  /** Placeholder for the loaded-page search input. */
98
102
  search?: string;
99
103
  /** Accessible name for the loaded-page search input. */
@@ -1 +1 @@
1
- {"version":3,"file":"CratisComponentsProvider.d.ts","sourceRoot":"","sources":["../../../Common/CratisComponentsProvider.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAW,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAIhD,OAAO,EAAW,KAAK,YAAY,EAAE,MAAM,6BAA0B,CAAC;AAEtE,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,yBAAsB,CAAC;AACpF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mCAAgC,CAAC;AAG/E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,iDAA8C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SAAS,CAAC;CACvB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,UAC7B,sBAAsB,GAAG,SAAS,KAC1C,sBAIF,CAAC;AAWF,8EAA8E;AAC9E,eAAO,MAAM,wBAAwB,kIAUlC,6BAA6B,gCA+B/B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"CratisComponentsProvider.js","sources":["../../../Common/CratisComponentsProvider.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 { useMemo, type ReactNode } from 'react';\nimport { I18nProvider } from 'react-aria-components/I18nProvider';\nimport { RouterProvider } from 'react-aria-components';\nimport { merge } from 'ts-deepmerge';\nimport { Toaster, type ToasterProps } from '../Notifications/Toaster';\nimport { unstable_RendererRoot } from '../renderer/RendererContext';\nimport type { CratisRendererSetup, unstable_UiLibrary } from '../renderer/manifest';\nimport type { CratisOverlayEnvironment } from '../renderer/overlayEnvironment';\nimport { CratisComponentsContext } from '../configuration/CratisComponentsContext';\nimport { cratisDefaults } from '../configuration/CratisComponentsDefaults';\nimport type { DialogHeaderActionsRenderer } from '../configuration/DialogHeaderActionsRenderer';\nimport { withLegacyLocaleMessages } from './legacyLocaleMessages';\n\nconst RendererRoot = unstable_RendererRoot;\n\nexport { cratisDefaults } from '../configuration/CratisComponentsDefaults';\nexport { useCratisComponentsConfig } from '../configuration/CratisComponentsContext';\n\n/** Localizable labels owned by the Cratis paginator. */\nexport interface CratisPaginatorMessages {\n /** Pagination navigation-region name. */\n navigation?: string;\n /** First-page action label. */\n first?: string;\n /** Previous-page action label. */\n previous?: string;\n /** Next-page action label. */\n next?: string;\n /** Last-page action label. */\n last?: string;\n /** Builds a numbered page button's accessible name from its one-based page number. */\n page?: (page: number) => string;\n /** Accessible name for the numbered-page group. */\n pages?: string;\n /** Builds the visible range text from the one-based start, the clamped end and the total. Defaults to `start–end of total`. */\n range?: (start: number, end: number, total: number) => string;\n}\n\n/** Localizable labels owned by the Cratis date picker composition. */\nexport interface CratisDatePickerMessages {\n /** Today action label. */\n today?: string;\n /** Clear action label. */\n clear?: string;\n /** Calendar-trigger label. */\n openCalendar?: string;\n /** Previous-month action label. */\n previousMonth?: string;\n /** Next-month action label. */\n nextMonth?: string;\n /**\n * Accessible name for the segmented date input when neither an explicit\n * `aria-label` nor a `placeholder` is supplied. Previously an orphaned\n * `'Date'` literal with no override path.\n */\n label?: string;\n}\n\n/** Localizable labels owned by the Cratis {@link Dropdown} composition. */\nexport interface CratisDropdownMessages {\n /** Accessible name for the options-popover trigger. */\n showOptions?: string;\n /** Accessible name for the clear-selection action. */\n clearSelection?: string;\n}\n\n/**\n * Localizable action and dismissal labels shared by every Cratis-owned dialog\n * surface — {@link Dialog}, {@link CommandDialog}, and {@link StepperCommandDialog}.\n */\nexport interface CratisDialogMessages {\n /** Primary confirmation label (the `Ok` action in `DialogButtons.Ok*`). */\n ok?: string;\n /** Cancellation label (the `Cancel` action, and the Stepper footer Cancel). */\n cancel?: string;\n /** Affirmative label (the `Yes` action in `DialogButtons.YesNo*`). */\n yes?: string;\n /** Negative label (the `No` action in `DialogButtons.YesNo*`). */\n no?: string;\n /** Accessible name for the header close (×) action. */\n close?: string;\n /**\n * Polite announcement made when a confirm is refused and the dialog stays open\n * (validation failure or business rule). Defaults to\n * 'The action was not completed. Review the dialog and try again.'\n */\n refused?: string;\n}\n\n/** Localizable navigation labels owned by {@link CommandStepper} / {@link StepperCommandDialog}. */\nexport interface CratisStepperMessages {\n /** Advance-to-next-step action label. */\n next?: string;\n /** Return-to-previous-step action label. */\n previous?: string;\n /** Final-step submit action label. */\n submit?: string;\n}\n\n/** Localizable labels owned by the Cratis {@link Toaster}. */\nexport interface CratisNotificationsMessages {\n /** Accessible name for a toast's dismiss action. */\n dismiss?: string;\n /** Accessible name for the toast region landmark. */\n region?: string;\n}\n\n/** Localizable labels owned by the Cratis {@link DataTableCore} composition. */\nexport interface CratisDataTableMessages {\n /** Accessible name for a single-selection row control. */\n selectRow?: string;\n /** Accessible name for the select-all control in a multiple-selection header. */\n selectAllRows?: string;\n /** Placeholder for the loaded-page search input. */\n search?: string;\n /** Accessible name for the loaded-page search input. */\n searchAriaLabel?: string;\n /** Message shown while loading an empty table. */\n loading?: string;\n /** Message shown when a query fails. */\n failed?: string;\n /** Message shown when a query denies access. */\n unauthorized?: string;\n /** Message shown when a search or filter leaves no rows on the loaded page. */\n filteredEmpty?: string;\n /** Message shown when a search or filter leaves no rows in server mode. */\n filteredEmptyServer?: string;\n}\n\n/** Localizable accessible names for the Cratis filter panel and its searches. */\nexport interface CratisFilterMessages {\n /** FilterPanel dialog name. Defaults to 'Filters'. */\n label?: string;\n /**\n * Search-input name for FilterPanel, its option groups, and standalone CheckboxListFilter.\n * Unset by default so an effective search placeholder retains precedence over 'Search'.\n * PivotViewer supplies group-specific names instead of using this shared name for its groups.\n */\n searchAriaLabel?: string;\n}\n\n/** Localizable labels owned by the Cratis column-filter popup. */\nexport interface CratisColumnFilterMessages {\n /** Builds the filter-trigger accessible name from the effective field. */\n filterTriggerAriaLabel?: (field: string) => string;\n /** Builds the value-control accessible name from the effective field. */\n valueAriaLabel?: (field: string) => string;\n /** Accessible name for the match-mode selector. */\n matchModeAriaLabel?: string;\n /** Localizes a match mode while retaining its default label as fallback input. */\n matchModeLabel?: (mode: string, defaultLabel: string) => string;\n /** Clear action label. */\n clear?: string;\n /** Apply action label. */\n apply?: string;\n /** Boolean true option label. */\n true?: string;\n /** Boolean false option label. */\n false?: string;\n}\n\n/** Localizable labels owned by the Cratis {@link Toolbar} composition. */\nexport interface CratisToolbarMessages {\n /** Accessible toolbar name used when neither `aria-label` nor `aria-labelledby` is supplied. */\n label?: string;\n /** Accessible name of the close button in a drawer {@link ToolbarFolder}. Defaults to 'Close'. */\n closeDrawer?: string;\n}\n\n/** Components-owned message groups. */\nexport interface CratisComponentsMessages {\n /** Paginator labels. */\n paginator?: CratisPaginatorMessages;\n /** Date-picker labels. */\n datePicker?: CratisDatePickerMessages;\n /** Dropdown labels. */\n dropdown?: CratisDropdownMessages;\n /** Dialog action/dismissal labels shared by Dialog, CommandDialog, and StepperCommandDialog. */\n dialog?: CratisDialogMessages;\n /** Stepper navigation labels shared by CommandStepper and StepperCommandDialog. */\n stepper?: CratisStepperMessages;\n /** Toaster labels. */\n notifications?: CratisNotificationsMessages;\n /** DataTable search, selection, and query-state messages. */\n dataTable?: CratisDataTableMessages;\n /** FilterPanel dialog and search-input accessible names. */\n filter?: CratisFilterMessages;\n /** Column-filter popup labels and match-mode copy. */\n columnFilter?: CratisColumnFilterMessages;\n /** Toolbar accessible-name fallback. */\n toolbar?: CratisToolbarMessages;\n}\n\n/**\n * Components-owned icon vocabulary. Every name is a concept the library draws in more than one\n * place; registering one replaces that concept's built-in glyph everywhere it is drawn, without\n * touching the surrounding element, its part, or its accessible name.\n *\n * Resolution per site is `per-component prop → provider icon → built-in glyph`: a named prop such\n * as `Dialog`'s `closeIcon` means \"this one call site\" and keeps winning, while the provider\n * replaces the built-in default for the whole product. Registering nothing renders exactly what the\n * library renders today, because the built-in glyph stays at its call site and is never part of\n * {@link cratisDefaults}.\n *\n * A name registered as `null` draws no glyph while the button, its part, and its accessible name\n * remain — the same meaning `closeIcon={null}` already has.\n */\nexport interface CratisComponentsIcons {\n /** Dismissal mark. Drawn by `Dialog`'s header close, `Toaster`'s dismiss, `ChatSidebar`, the `Chat` panel, and the PivotViewer detail panel. Defaults to `×`. */\n close?: ReactNode;\n /** Remove-this-value mark. Drawn by `TagGroup`'s tag remove, `Chip`'s remove control, and `CommandForm`'s chips field. Defaults to `×`. */\n remove?: ReactNode;\n /** Expand/collapse chevron on a closed-by-default surface. Drawn by `Dropdown`'s trigger and `ComboBox`'s trigger. Defaults to `⌄` (`▾` in `ComboBox`). */\n expand?: ReactNode;\n /** Ascending sort indicator. Drawn by `DataTableCore`'s sortable column header. Defaults to `▲`. */\n sortAscending?: ReactNode;\n /** Descending sort indicator. Drawn by `DataTableCore`'s sortable column header. Defaults to `▼`. */\n sortDescending?: ReactNode;\n /** Step-backwards mark. Drawn by `TablePaginator`'s previous page and the date picker's previous month. Defaults to `‹`. */\n previous?: ReactNode;\n /** Step-forwards mark. Drawn by `TablePaginator`'s next page and the date picker's next month. Defaults to `›`. */\n next?: ReactNode;\n /** Clear-the-current-value mark. Drawn by `Dropdown`'s clear-selection action and the PivotViewer filter panel's clear action. Defaults to `×`. */\n clear?: ReactNode;\n}\n\ninterface LegacyLocaleMessages {\n today?: string;\n clear?: string;\n aria?: {\n navigation?: string;\n firstPageLabel?: string;\n prevPageLabel?: string;\n nextPageLabel?: string;\n lastPageLabel?: string;\n };\n [message: string]: unknown;\n}\n\n/** Application routing callbacks used by Components links. */\nexport interface CratisComponentsRouter {\n /** Navigate to the original link destination for an ordinary same-origin activation. */\n navigate: (href: string) => void;\n /** Resolve a destination to the rendered href, for example to include a router basename. */\n useHref?: (href: string) => string;\n}\n\n/** Renderer-independent application configuration for Components. */\nexport interface CratisComponentsConfig {\n /** Optional client-side router. Omit to retain native or inherited routing behavior. */\n router?: CratisComponentsRouter;\n /** BCP 47 locale used by React Aria for dates, numbers, and interaction announcements. */\n locale?: string;\n /** Cratis-owned labels not supplied by the platform's internationalization APIs. */\n messages?: CratisComponentsMessages;\n /** Cratis-owned icon vocabulary replacing the built-in glyphs the library draws. */\n icons?: CratisComponentsIcons;\n /**\n * App-wide dialog header actions, set through the provider's `dialogHeaderActions` prop. Read by\n * `Dialog`, `CommandDialog` and `StepperCommandDialog`.\n */\n dialogHeaderActions?: DialogHeaderActionsRenderer;\n /**\n * @deprecated Use {@link messages}; React Aria supplies its own locale data.\n */\n locales?: Record<string, LegacyLocaleMessages>;\n}\n\n/** Props for the application-root Components provider. */\nexport interface CratisComponentsProviderProps {\n /** Locale and Components-owned messages. */\n value?: CratisComponentsConfig;\n /**\n * Registers header actions once for every dialog. The renderer receives each dialog's\n * `DialogHeaderContext`, and may return `null` to hide itself for that dialog. The result\n * renders before the close button, next to any per-dialog `headerActions`; a dialog opts out\n * with `hideGlobalHeaderActions`.\n */\n dialogHeaderActions?: DialogHeaderActionsRenderer;\n /** Mounts the global toaster with defaults or explicit options. */\n toaster?: boolean | ToasterProps;\n /**\n * Selects one stable presentation library. The broader generic manifest and ordered,\n * last-wins composition form remain experimental.\n */\n library?: unstable_UiLibrary | readonly unstable_UiLibrary[];\n /** Experimental profile-promise behavior. Defaults to strict. */\n libraryMode?: 'strict' | 'degrade';\n /** Terminal slot fallback behavior. Defaults to the built-in Core implementation. */\n rendererFallback?: 'core' | 'throw';\n /** Host environment for overlay portal containers. */\n overlayEnvironment?: CratisOverlayEnvironment;\n /**\n * Non-secret renderer setup attestations. Values are booleans so credentials and license\n * tokens never cross the Components provider boundary.\n */\n rendererSetup?: CratisRendererSetup;\n /** Application content. */\n children: ReactNode;\n}\n\n/**\n * Deep-merges consumer configuration over {@link cratisDefaults}.\n *\n * `icons` merges by name only. An icon value is an opaque node — often a React element — so it is\n * carried over by identity instead of being deep-merged into, while a partial map still leaves every\n * unregistered name to its built-in glyph.\n */\nexport const mergeCratisComponentsConfig = (\n value: CratisComponentsConfig | undefined,\n): CratisComponentsConfig => {\n const { icons, ...rest } = value ?? {};\n const merged = merge(cratisDefaults, rest) as CratisComponentsConfig;\n return icons ? { ...merged, icons: { ...cratisDefaults.icons, ...icons } } : merged;\n};\n\nconst validLocale = (locale: string | undefined) => {\n if (!locale) return 'en-US';\n try {\n return new Intl.Locale(locale).toString();\n } catch {\n return 'en-US';\n }\n};\n\n/** Application root for locale, labels, and the optional app-wide toaster. */\nexport const CratisComponentsProvider = ({\n value,\n dialogHeaderActions,\n toaster,\n library,\n libraryMode,\n rendererFallback,\n overlayEnvironment,\n rendererSetup,\n children,\n}: CratisComponentsProviderProps) => {\n const resolved = useMemo(() => {\n const config = withLegacyLocaleMessages(mergeCratisComponentsConfig(value), value?.messages);\n const headerActions = dialogHeaderActions ?? value?.dialogHeaderActions;\n return headerActions ? { ...config, dialogHeaderActions: headerActions } : config;\n }, [value, dialogHeaderActions]);\n\n const content = (\n <I18nProvider locale={validLocale(resolved.locale)}>\n {children}\n {toaster && <Toaster {...(typeof toaster === 'object' ? toaster : {})} />}\n </I18nProvider>\n );\n\n return (\n <RendererRoot\n library={library}\n libraryMode={libraryMode}\n rendererFallback={rendererFallback}\n overlayEnvironment={overlayEnvironment}\n rendererSetup={rendererSetup}\n >\n <CratisComponentsContext.Provider value={resolved}>\n {resolved.router ? (\n <RouterProvider navigate={resolved.router.navigate} useHref={resolved.router.useHref}>\n {content}\n </RouterProvider>\n ) : content}\n </CratisComponentsContext.Provider>\n </RendererRoot>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;AAgBA,MAAM,YAAY,GAAG,qBAAqB;AAuSnC,MAAM,2BAA2B,GAAG,CACvC,KAAyC,KACjB;IACxB,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,IAAI,EAAE;IACtC,MAAM,MAAM,GAAG,KAAK,CAAC,cAAc,EAAE,IAAI,CAA2B;IACpE,OAAO,KAAK,GAAG,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,EAAE,GAAG,cAAc,CAAC,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,MAAM;AACvF;AAEA,MAAM,WAAW,GAAG,CAAC,MAA0B,KAAI;AAC/C,IAAA,IAAI,CAAC,MAAM;AAAE,QAAA,OAAO,OAAO;AAC3B,IAAA,IAAI;QACA,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE;IAC7C;AAAE,IAAA,MAAM;AACJ,QAAA,OAAO,OAAO;IAClB;AACJ,CAAC;AAGM,MAAM,wBAAwB,GAAG,CAAC,EACrC,KAAK,EACL,mBAAmB,EACnB,OAAO,EACP,OAAO,EACP,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,QAAQ,GACoB,KAAI;AAChC,IAAA,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAK;AAC1B,QAAA,MAAM,MAAM,GAAG,wBAAwB,CAAC,2BAA2B,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC;AAC5F,QAAA,MAAM,aAAa,GAAG,mBAAmB,IAAI,KAAK,EAAE,mBAAmB;AACvE,QAAA,OAAO,aAAa,GAAG,EAAE,GAAG,MAAM,EAAE,mBAAmB,EAAE,aAAa,EAAE,GAAG,MAAM;AACrF,IAAA,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,CAAC,CAAC;AAEhC,IAAA,MAAM,OAAO,IACTA,IAAA,CAAC,YAAY,IAAC,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAA,QAAA,EAAA,CAC7C,QAAQ,EACR,OAAO,IAAIC,GAAA,CAAC,OAAO,QAAM,OAAO,OAAO,KAAK,QAAQ,GAAG,OAAO,GAAG,EAAE,CAAC,EAAA,CAAI,CAAA,EAAA,CAC9D,CAClB;AAED,IAAA,QACIA,GAAA,CAAC,YAAY,EAAA,EACT,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,WAAW,EACxB,gBAAgB,EAAE,gBAAgB,EAClC,kBAAkB,EAAE,kBAAkB,EACtC,aAAa,EAAE,aAAa,EAAA,QAAA,EAE5BA,GAAA,CAAC,uBAAuB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,QAAQ,EAAA,QAAA,EAC5C,QAAQ,CAAC,MAAM,IACZA,IAAC,cAAc,EAAA,EAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,OAAO,YAC/E,OAAO,EAAA,CACK,IACjB,OAAO,EAAA,CACoB,EAAA,CACxB;AAEvB;;"}
1
+ {"version":3,"file":"CratisComponentsProvider.js","sources":["../../../Common/CratisComponentsProvider.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 { useMemo, type ReactNode } from 'react';\nimport { I18nProvider } from 'react-aria-components/I18nProvider';\nimport { RouterProvider } from 'react-aria-components';\nimport { merge } from 'ts-deepmerge';\nimport { Toaster, type ToasterProps } from '../Notifications/Toaster';\nimport { unstable_RendererRoot } from '../renderer/RendererContext';\nimport type { CratisRendererSetup, unstable_UiLibrary } from '../renderer/manifest';\nimport type { CratisOverlayEnvironment } from '../renderer/overlayEnvironment';\nimport { CratisComponentsContext } from '../configuration/CratisComponentsContext';\nimport { cratisDefaults } from '../configuration/CratisComponentsDefaults';\nimport type { DialogHeaderActionsRenderer } from '../configuration/DialogHeaderActionsRenderer';\nimport { withLegacyLocaleMessages } from './legacyLocaleMessages';\n\nconst RendererRoot = unstable_RendererRoot;\n\nexport { cratisDefaults } from '../configuration/CratisComponentsDefaults';\nexport { useCratisComponentsConfig } from '../configuration/CratisComponentsContext';\n\n/** Localizable labels owned by the Cratis paginator. */\nexport interface CratisPaginatorMessages {\n /** Pagination navigation-region name. */\n navigation?: string;\n /** First-page action label. */\n first?: string;\n /** Previous-page action label. */\n previous?: string;\n /** Next-page action label. */\n next?: string;\n /** Last-page action label. */\n last?: string;\n /** Builds a numbered page button's accessible name from its one-based page number. */\n page?: (page: number) => string;\n /** Accessible name for the numbered-page group. */\n pages?: string;\n /** Builds the visible range text from the one-based start, the clamped end and the total. Defaults to `start–end of total`. */\n range?: (start: number, end: number, total: number) => string;\n}\n\n/** Localizable labels owned by the Cratis date picker composition. */\nexport interface CratisDatePickerMessages {\n /** Today action label. */\n today?: string;\n /** Clear action label. */\n clear?: string;\n /** Calendar-trigger label. */\n openCalendar?: string;\n /** Previous-month action label. */\n previousMonth?: string;\n /** Next-month action label. */\n nextMonth?: string;\n /**\n * Accessible name for the segmented date input when neither an explicit\n * `aria-label` nor a `placeholder` is supplied. Previously an orphaned\n * `'Date'` literal with no override path.\n */\n label?: string;\n}\n\n/** Localizable labels owned by the Cratis {@link Dropdown} composition. */\nexport interface CratisDropdownMessages {\n /** Accessible name for the options-popover trigger. */\n showOptions?: string;\n /** Accessible name for the clear-selection action. */\n clearSelection?: string;\n}\n\n/**\n * Localizable action and dismissal labels shared by every Cratis-owned dialog\n * surface — {@link Dialog}, {@link CommandDialog}, and {@link StepperCommandDialog}.\n */\nexport interface CratisDialogMessages {\n /** Primary confirmation label (the `Ok` action in `DialogButtons.Ok*`). */\n ok?: string;\n /** Cancellation label (the `Cancel` action, and the Stepper footer Cancel). */\n cancel?: string;\n /** Affirmative label (the `Yes` action in `DialogButtons.YesNo*`). */\n yes?: string;\n /** Negative label (the `No` action in `DialogButtons.YesNo*`). */\n no?: string;\n /** Accessible name for the header close (×) action. */\n close?: string;\n /**\n * Polite announcement made when a confirm is refused and the dialog stays open\n * (validation failure or business rule). Defaults to\n * 'The action was not completed. Review the dialog and try again.'\n */\n refused?: string;\n}\n\n/** Localizable navigation labels owned by {@link CommandStepper} / {@link StepperCommandDialog}. */\nexport interface CratisStepperMessages {\n /** Advance-to-next-step action label. */\n next?: string;\n /** Return-to-previous-step action label. */\n previous?: string;\n /** Final-step submit action label. */\n submit?: string;\n}\n\n/** Localizable labels owned by the Cratis {@link Toaster}. */\nexport interface CratisNotificationsMessages {\n /** Accessible name for a toast's dismiss action. */\n dismiss?: string;\n /** Accessible name for the toast region landmark. */\n region?: string;\n}\n\n/** Localizable labels owned by the Cratis {@link DataTableCore} composition. */\nexport interface CratisDataTableMessages {\n /** Accessible name for a single-selection row control. */\n selectRow?: string;\n /** Accessible name for the select-all control in a multiple-selection header. */\n selectAllRows?: string;\n /** Audible ascending sort direction in card controls. Defaults to 'Ascending'. */\n sortAscending?: string;\n /** Audible descending sort direction in card controls. Defaults to 'Descending'. */\n sortDescending?: string;\n /** Placeholder for the loaded-page search input. */\n search?: string;\n /** Accessible name for the loaded-page search input. */\n searchAriaLabel?: string;\n /** Message shown while loading an empty table. */\n loading?: string;\n /** Message shown when a query fails. */\n failed?: string;\n /** Message shown when a query denies access. */\n unauthorized?: string;\n /** Message shown when a search or filter leaves no rows on the loaded page. */\n filteredEmpty?: string;\n /** Message shown when a search or filter leaves no rows in server mode. */\n filteredEmptyServer?: string;\n}\n\n/** Localizable accessible names for the Cratis filter panel and its searches. */\nexport interface CratisFilterMessages {\n /** FilterPanel dialog name. Defaults to 'Filters'. */\n label?: string;\n /**\n * Search-input name for FilterPanel, its option groups, and standalone CheckboxListFilter.\n * Unset by default so an effective search placeholder retains precedence over 'Search'.\n * PivotViewer supplies group-specific names instead of using this shared name for its groups.\n */\n searchAriaLabel?: string;\n}\n\n/** Localizable labels owned by the Cratis column-filter popup. */\nexport interface CratisColumnFilterMessages {\n /** Builds the filter-trigger accessible name from the effective field. */\n filterTriggerAriaLabel?: (field: string) => string;\n /** Builds the value-control accessible name from the effective field. */\n valueAriaLabel?: (field: string) => string;\n /** Accessible name for the match-mode selector. */\n matchModeAriaLabel?: string;\n /** Localizes a match mode while retaining its default label as fallback input. */\n matchModeLabel?: (mode: string, defaultLabel: string) => string;\n /** Clear action label. */\n clear?: string;\n /** Apply action label. */\n apply?: string;\n /** Boolean true option label. */\n true?: string;\n /** Boolean false option label. */\n false?: string;\n}\n\n/** Localizable labels owned by the Cratis {@link Toolbar} composition. */\nexport interface CratisToolbarMessages {\n /** Accessible toolbar name used when neither `aria-label` nor `aria-labelledby` is supplied. */\n label?: string;\n /** Accessible name of the close button in a drawer {@link ToolbarFolder}. Defaults to 'Close'. */\n closeDrawer?: string;\n}\n\n/** Components-owned message groups. */\nexport interface CratisComponentsMessages {\n /** Paginator labels. */\n paginator?: CratisPaginatorMessages;\n /** Date-picker labels. */\n datePicker?: CratisDatePickerMessages;\n /** Dropdown labels. */\n dropdown?: CratisDropdownMessages;\n /** Dialog action/dismissal labels shared by Dialog, CommandDialog, and StepperCommandDialog. */\n dialog?: CratisDialogMessages;\n /** Stepper navigation labels shared by CommandStepper and StepperCommandDialog. */\n stepper?: CratisStepperMessages;\n /** Toaster labels. */\n notifications?: CratisNotificationsMessages;\n /** DataTable search, selection, and query-state messages. */\n dataTable?: CratisDataTableMessages;\n /** FilterPanel dialog and search-input accessible names. */\n filter?: CratisFilterMessages;\n /** Column-filter popup labels and match-mode copy. */\n columnFilter?: CratisColumnFilterMessages;\n /** Toolbar accessible-name fallback. */\n toolbar?: CratisToolbarMessages;\n}\n\n/**\n * Components-owned icon vocabulary. Every name is a concept the library draws in more than one\n * place; registering one replaces that concept's built-in glyph everywhere it is drawn, without\n * touching the surrounding element, its part, or its accessible name.\n *\n * Resolution per site is `per-component prop → provider icon → built-in glyph`: a named prop such\n * as `Dialog`'s `closeIcon` means \"this one call site\" and keeps winning, while the provider\n * replaces the built-in default for the whole product. Registering nothing renders exactly what the\n * library renders today, because the built-in glyph stays at its call site and is never part of\n * {@link cratisDefaults}.\n *\n * A name registered as `null` draws no glyph while the button, its part, and its accessible name\n * remain — the same meaning `closeIcon={null}` already has.\n */\nexport interface CratisComponentsIcons {\n /** Dismissal mark. Drawn by `Dialog`'s header close, `Toaster`'s dismiss, `ChatSidebar`, the `Chat` panel, and the PivotViewer detail panel. Defaults to `×`. */\n close?: ReactNode;\n /** Remove-this-value mark. Drawn by `TagGroup`'s tag remove, `Chip`'s remove control, and `CommandForm`'s chips field. Defaults to `×`. */\n remove?: ReactNode;\n /** Expand/collapse chevron on a closed-by-default surface. Drawn by `Dropdown`'s trigger and `ComboBox`'s trigger. Defaults to `⌄` (`▾` in `ComboBox`). */\n expand?: ReactNode;\n /** Ascending sort indicator. Drawn by `DataTableCore`'s sortable column header. Defaults to `▲`. */\n sortAscending?: ReactNode;\n /** Descending sort indicator. Drawn by `DataTableCore`'s sortable column header. Defaults to `▼`. */\n sortDescending?: ReactNode;\n /** Step-backwards mark. Drawn by `TablePaginator`'s previous page and the date picker's previous month. Defaults to `‹`. */\n previous?: ReactNode;\n /** Step-forwards mark. Drawn by `TablePaginator`'s next page and the date picker's next month. Defaults to `›`. */\n next?: ReactNode;\n /** Clear-the-current-value mark. Drawn by `Dropdown`'s clear-selection action and the PivotViewer filter panel's clear action. Defaults to `×`. */\n clear?: ReactNode;\n}\n\ninterface LegacyLocaleMessages {\n today?: string;\n clear?: string;\n aria?: {\n navigation?: string;\n firstPageLabel?: string;\n prevPageLabel?: string;\n nextPageLabel?: string;\n lastPageLabel?: string;\n };\n [message: string]: unknown;\n}\n\n/** Application routing callbacks used by Components links. */\nexport interface CratisComponentsRouter {\n /** Navigate to the original link destination for an ordinary same-origin activation. */\n navigate: (href: string) => void;\n /** Resolve a destination to the rendered href, for example to include a router basename. */\n useHref?: (href: string) => string;\n}\n\n/** Renderer-independent application configuration for Components. */\nexport interface CratisComponentsConfig {\n /** Optional client-side router. Omit to retain native or inherited routing behavior. */\n router?: CratisComponentsRouter;\n /** BCP 47 locale used by React Aria for dates, numbers, and interaction announcements. */\n locale?: string;\n /** Cratis-owned labels not supplied by the platform's internationalization APIs. */\n messages?: CratisComponentsMessages;\n /** Cratis-owned icon vocabulary replacing the built-in glyphs the library draws. */\n icons?: CratisComponentsIcons;\n /**\n * App-wide dialog header actions, set through the provider's `dialogHeaderActions` prop. Read by\n * `Dialog`, `CommandDialog` and `StepperCommandDialog`.\n */\n dialogHeaderActions?: DialogHeaderActionsRenderer;\n /**\n * @deprecated Use {@link messages}; React Aria supplies its own locale data.\n */\n locales?: Record<string, LegacyLocaleMessages>;\n}\n\n/** Props for the application-root Components provider. */\nexport interface CratisComponentsProviderProps {\n /** Locale and Components-owned messages. */\n value?: CratisComponentsConfig;\n /**\n * Registers header actions once for every dialog. The renderer receives each dialog's\n * `DialogHeaderContext`, and may return `null` to hide itself for that dialog. The result\n * renders before the close button, next to any per-dialog `headerActions`; a dialog opts out\n * with `hideGlobalHeaderActions`.\n */\n dialogHeaderActions?: DialogHeaderActionsRenderer;\n /** Mounts the global toaster with defaults or explicit options. */\n toaster?: boolean | ToasterProps;\n /**\n * Selects one stable presentation library. The broader generic manifest and ordered,\n * last-wins composition form remain experimental.\n */\n library?: unstable_UiLibrary | readonly unstable_UiLibrary[];\n /** Experimental profile-promise behavior. Defaults to strict. */\n libraryMode?: 'strict' | 'degrade';\n /** Terminal slot fallback behavior. Defaults to the built-in Core implementation. */\n rendererFallback?: 'core' | 'throw';\n /** Host environment for overlay portal containers. */\n overlayEnvironment?: CratisOverlayEnvironment;\n /**\n * Non-secret renderer setup attestations. Values are booleans so credentials and license\n * tokens never cross the Components provider boundary.\n */\n rendererSetup?: CratisRendererSetup;\n /** Application content. */\n children: ReactNode;\n}\n\n/**\n * Deep-merges consumer configuration over {@link cratisDefaults}.\n *\n * `icons` merges by name only. An icon value is an opaque node — often a React element — so it is\n * carried over by identity instead of being deep-merged into, while a partial map still leaves every\n * unregistered name to its built-in glyph.\n */\nexport const mergeCratisComponentsConfig = (\n value: CratisComponentsConfig | undefined,\n): CratisComponentsConfig => {\n const { icons, ...rest } = value ?? {};\n const merged = merge(cratisDefaults, rest) as CratisComponentsConfig;\n return icons ? { ...merged, icons: { ...cratisDefaults.icons, ...icons } } : merged;\n};\n\nconst validLocale = (locale: string | undefined) => {\n if (!locale) return 'en-US';\n try {\n return new Intl.Locale(locale).toString();\n } catch {\n return 'en-US';\n }\n};\n\n/** Application root for locale, labels, and the optional app-wide toaster. */\nexport const CratisComponentsProvider = ({\n value,\n dialogHeaderActions,\n toaster,\n library,\n libraryMode,\n rendererFallback,\n overlayEnvironment,\n rendererSetup,\n children,\n}: CratisComponentsProviderProps) => {\n const resolved = useMemo(() => {\n const config = withLegacyLocaleMessages(mergeCratisComponentsConfig(value), value?.messages);\n const headerActions = dialogHeaderActions ?? value?.dialogHeaderActions;\n return headerActions ? { ...config, dialogHeaderActions: headerActions } : config;\n }, [value, dialogHeaderActions]);\n\n const content = (\n <I18nProvider locale={validLocale(resolved.locale)}>\n {children}\n {toaster && <Toaster {...(typeof toaster === 'object' ? toaster : {})} />}\n </I18nProvider>\n );\n\n return (\n <RendererRoot\n library={library}\n libraryMode={libraryMode}\n rendererFallback={rendererFallback}\n overlayEnvironment={overlayEnvironment}\n rendererSetup={rendererSetup}\n >\n <CratisComponentsContext.Provider value={resolved}>\n {resolved.router ? (\n <RouterProvider navigate={resolved.router.navigate} useHref={resolved.router.useHref}>\n {content}\n </RouterProvider>\n ) : content}\n </CratisComponentsContext.Provider>\n </RendererRoot>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;AAgBA,MAAM,YAAY,GAAG,qBAAqB;AA2SnC,MAAM,2BAA2B,GAAG,CACvC,KAAyC,KACjB;IACxB,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,IAAI,EAAE;IACtC,MAAM,MAAM,GAAG,KAAK,CAAC,cAAc,EAAE,IAAI,CAA2B;IACpE,OAAO,KAAK,GAAG,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,EAAE,GAAG,cAAc,CAAC,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,MAAM;AACvF;AAEA,MAAM,WAAW,GAAG,CAAC,MAA0B,KAAI;AAC/C,IAAA,IAAI,CAAC,MAAM;AAAE,QAAA,OAAO,OAAO;AAC3B,IAAA,IAAI;QACA,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE;IAC7C;AAAE,IAAA,MAAM;AACJ,QAAA,OAAO,OAAO;IAClB;AACJ,CAAC;AAGM,MAAM,wBAAwB,GAAG,CAAC,EACrC,KAAK,EACL,mBAAmB,EACnB,OAAO,EACP,OAAO,EACP,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,QAAQ,GACoB,KAAI;AAChC,IAAA,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAK;AAC1B,QAAA,MAAM,MAAM,GAAG,wBAAwB,CAAC,2BAA2B,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC;AAC5F,QAAA,MAAM,aAAa,GAAG,mBAAmB,IAAI,KAAK,EAAE,mBAAmB;AACvE,QAAA,OAAO,aAAa,GAAG,EAAE,GAAG,MAAM,EAAE,mBAAmB,EAAE,aAAa,EAAE,GAAG,MAAM;AACrF,IAAA,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,CAAC,CAAC;AAEhC,IAAA,MAAM,OAAO,IACTA,IAAA,CAAC,YAAY,IAAC,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAA,QAAA,EAAA,CAC7C,QAAQ,EACR,OAAO,IAAIC,GAAA,CAAC,OAAO,QAAM,OAAO,OAAO,KAAK,QAAQ,GAAG,OAAO,GAAG,EAAE,CAAC,EAAA,CAAI,CAAA,EAAA,CAC9D,CAClB;AAED,IAAA,QACIA,GAAA,CAAC,YAAY,EAAA,EACT,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,WAAW,EACxB,gBAAgB,EAAE,gBAAgB,EAClC,kBAAkB,EAAE,kBAAkB,EACtC,aAAa,EAAE,aAAa,EAAA,QAAA,EAE5BA,GAAA,CAAC,uBAAuB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,QAAQ,EAAA,QAAA,EAC5C,QAAQ,CAAC,MAAM,IACZA,IAAC,cAAc,EAAA,EAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,OAAO,YAC/E,OAAO,EAAA,CACK,IACjB,OAAO,EAAA,CACoB,EAAA,CACxB;AAEvB;;"}
@@ -0,0 +1,4 @@
1
+ import type { DataTableRowProps } from './DataTableRow.js';
2
+ /** One semantic card for the same processed row and activation callbacks as the table. */
3
+ export declare const DataTableCard: <TData extends object>(props: DataTableRowProps<TData>) => import("react").JSX.Element;
4
+ //# sourceMappingURL=DataTableCard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataTableCard.d.ts","sourceRoot":"","sources":["../../../DataTables/DataTableCard.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAgB,CAAC;AAsDxD,0FAA0F;AAC1F,eAAO,MAAM,aAAa,GAAI,KAAK,SAAS,MAAM,SAAS,iBAAiB,CAAC,KAAK,CAAC,gCAalF,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { classNames } from '../ClassNames/classNames.js';
3
+ import { dataTableCellContent } from './dataTableCellContent.js';
4
+
5
+ const interactiveDescendant = 'a, button, input, select, textarea, label, summary, [contenteditable]:not([contenteditable="false"]), [role="button"], [role="link"], [tabindex]';
6
+ const hasInteractiveTarget = (event) => {
7
+ const target = event.target;
8
+ if (!(target instanceof Element))
9
+ return false;
10
+ if (target.hasAttribute('data-cratis-card-selection'))
11
+ return false;
12
+ const interactive = target.closest(interactiveDescendant);
13
+ return !!interactive && interactive !== event.currentTarget;
14
+ };
15
+ const activateOnClick = (event, props) => {
16
+ props.parts?.card?.onClick?.(event);
17
+ if (!event.defaultPrevented && !hasInteractiveTarget(event))
18
+ props.onActivate(event);
19
+ };
20
+ const activateOnKey = (event, props) => {
21
+ props.parts?.card?.onKeyDown?.(event);
22
+ if (event.defaultPrevented || event.target !== event.currentTarget)
23
+ return;
24
+ if (event.key !== 'Enter' && event.key !== ' ')
25
+ return;
26
+ event.preventDefault();
27
+ props.onActivate(event);
28
+ };
29
+ const CardSelection = (props) => {
30
+ const { selectionMode, selectionGroupName, resolvedSelectionAriaLabel, isSelected, isRowSelected, onToggleSelection } = props;
31
+ if (!selectionMode)
32
+ return null;
33
+ const multiple = selectionMode === 'multiple';
34
+ return jsx("input", { type: multiple ? 'checkbox' : 'radio', name: multiple ? undefined : selectionGroupName, "aria-label": resolvedSelectionAriaLabel, checked: multiple ? isRowSelected : isSelected, readOnly: !multiple, tabIndex: multiple ? undefined : -1, "data-cratis-card-selection": multiple ? undefined : 'single', onChange: multiple ? onToggleSelection : undefined });
35
+ };
36
+ const CardFields = ({ columns, row, parts: pt }) => (jsx("dl", { children: columns.filter(column => !column.props.selectionMode).map((column, index) => (jsxs("div", { className: 'cratis-datatable__card-field', children: [jsx("dt", { ...pt?.cardLabel, className: classNames('cratis-datatable__card-label', pt?.cardLabel?.className), "data-cratis-component": 'DataTableCore', "data-cratis-part": 'card-label', children: column.props.header ?? column.props.field ?? '' }), jsx("dd", { ...pt?.cardValue, style: { ...pt?.cardValue?.style, ...column.props.style, ...column.props.bodyStyle }, className: classNames('cratis-datatable__card-value', pt?.cardValue?.className, column.props.bodyClassName ?? column.props.className), "data-cratis-component": 'DataTableCore', "data-cratis-part": 'card-value', children: dataTableCellContent(column.props, row) })] }, index))) }));
37
+ const DataTableCard = (props) => {
38
+ const { row, rowKey, parts: pt, isSelected, isInteractive, isRowSelected, rowClassName } = props;
39
+ return (jsxs("li", { ...pt?.card, tabIndex: isInteractive ? 0 : pt?.card?.tabIndex, className: classNames('cratis-datatable__card', pt?.card?.className, rowClassName?.(row)), "data-cratis-component": 'DataTableCore', "data-cratis-part": 'card', "data-datatable-row-key": rowKey, "data-selected": isSelected || isRowSelected || undefined, "data-interactive": isInteractive || undefined, onClick: event => activateOnClick(event, props), onKeyDown: event => activateOnKey(event, props), children: [jsx(CardSelection, { ...props }), jsx(CardFields, { ...props })] }));
40
+ };
41
+
42
+ export { DataTableCard };
43
+ //# sourceMappingURL=DataTableCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataTableCard.js","sources":["../../../DataTables/DataTableCard.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 { KeyboardEvent, MouseEvent } from 'react';\nimport { classNames } from '../ClassNames/classNames';\nimport type { DataTableRowProps } from './DataTableRow';\nimport { dataTableCellContent } from './dataTableCellContent';\n\nconst interactiveDescendant = 'a, button, input, select, textarea, label, summary, [contenteditable]:not([contenteditable=\"false\"]), [role=\"button\"], [role=\"link\"], [tabindex]';\n\nconst hasInteractiveTarget = (event: MouseEvent<HTMLLIElement>) => {\n const target = event.target;\n if (!(target instanceof Element)) return false;\n if (target.hasAttribute('data-cratis-card-selection')) return false;\n const interactive = target.closest(interactiveDescendant);\n return !!interactive && interactive !== event.currentTarget;\n};\n\nconst activateOnClick = <TData extends object>(event: MouseEvent<HTMLLIElement>, props: DataTableRowProps<TData>) => {\n props.parts?.card?.onClick?.(event);\n if (!event.defaultPrevented && !hasInteractiveTarget(event)) props.onActivate(event);\n};\n\nconst activateOnKey = <TData extends object>(event: KeyboardEvent<HTMLLIElement>, props: DataTableRowProps<TData>) => {\n props.parts?.card?.onKeyDown?.(event);\n if (event.defaultPrevented || event.target !== event.currentTarget) return;\n if (event.key !== 'Enter' && event.key !== ' ') return;\n event.preventDefault();\n props.onActivate(event);\n};\n\nconst CardSelection = <TData extends object>(props: DataTableRowProps<TData>) => {\n const { selectionMode, selectionGroupName, resolvedSelectionAriaLabel, isSelected, isRowSelected, onToggleSelection } = props;\n if (!selectionMode) return null;\n const multiple = selectionMode === 'multiple';\n return <input type={multiple ? 'checkbox' : 'radio'} name={multiple ? undefined : selectionGroupName}\n aria-label={resolvedSelectionAriaLabel} checked={multiple ? isRowSelected : isSelected}\n readOnly={!multiple} tabIndex={multiple ? undefined : -1}\n data-cratis-card-selection={multiple ? undefined : 'single'}\n onChange={multiple ? onToggleSelection : undefined} />;\n};\n\nconst CardFields = <TData extends object>({ columns, row, parts: pt }: DataTableRowProps<TData>) => (\n <dl>\n {columns.filter(column => !column.props.selectionMode).map((column, index) => (\n <div key={index} className='cratis-datatable__card-field'>\n <dt {...pt?.cardLabel} className={classNames('cratis-datatable__card-label', pt?.cardLabel?.className)} data-cratis-component='DataTableCore' data-cratis-part='card-label'>\n {column.props.header ?? column.props.field ?? ''}\n </dt>\n <dd {...pt?.cardValue} style={{ ...pt?.cardValue?.style, ...column.props.style, ...column.props.bodyStyle }}\n className={classNames('cratis-datatable__card-value', pt?.cardValue?.className, column.props.bodyClassName ?? column.props.className)}\n data-cratis-component='DataTableCore' data-cratis-part='card-value'>\n {dataTableCellContent(column.props, row)}\n </dd>\n </div>\n ))}\n </dl>\n);\n\n/** One semantic card for the same processed row and activation callbacks as the table. */\nexport const DataTableCard = <TData extends object>(props: DataTableRowProps<TData>) => {\n const { row, rowKey, parts: pt, isSelected, isInteractive, isRowSelected, rowClassName } = props;\n return (\n <li {...pt?.card}\n tabIndex={isInteractive ? 0 : pt?.card?.tabIndex}\n className={classNames('cratis-datatable__card', pt?.card?.className, rowClassName?.(row))}\n data-cratis-component='DataTableCore' data-cratis-part='card' data-datatable-row-key={rowKey}\n data-selected={isSelected || isRowSelected || undefined} data-interactive={isInteractive || undefined}\n onClick={event => activateOnClick(event, props)} onKeyDown={event => activateOnKey(event, props)}>\n <CardSelection {...props} />\n <CardFields {...props} />\n </li>\n );\n};\n"],"names":["_jsx","_jsxs"],"mappings":";;;;AAQA,MAAM,qBAAqB,GAAG,kJAAkJ;AAEhL,MAAM,oBAAoB,GAAG,CAAC,KAAgC,KAAI;AAC9D,IAAA,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM;AAC3B,IAAA,IAAI,EAAE,MAAM,YAAY,OAAO,CAAC;AAAE,QAAA,OAAO,KAAK;AAC9C,IAAA,IAAI,MAAM,CAAC,YAAY,CAAC,4BAA4B,CAAC;AAAE,QAAA,OAAO,KAAK;IACnE,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,qBAAqB,CAAC;IACzD,OAAO,CAAC,CAAC,WAAW,IAAI,WAAW,KAAK,KAAK,CAAC,aAAa;AAC/D,CAAC;AAED,MAAM,eAAe,GAAG,CAAuB,KAAgC,EAAE,KAA+B,KAAI;IAChH,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,GAAG,KAAK,CAAC;IACnC,IAAI,CAAC,KAAK,CAAC,gBAAgB,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC;AAAE,QAAA,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC;AACxF,CAAC;AAED,MAAM,aAAa,GAAG,CAAuB,KAAmC,EAAE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QAAQ,EAChD,SAAS,EAAE,UAAU,CAAC,wBAAwB,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,GAAG,GAAG,CAAC,CAAC,EAAA,uBAAA,EACnE,eAAe,EAAA,kBAAA,EAAkB,MAAM,EAAA,wBAAA,EAAyB,MAAM,EAAA,eAAA,EAC7E,UAAU,IAAI,aAAa,IAAI,SAAS,EAAA,kBAAA,EAAoB,aAAa,IAAI,SAAS,EACrG,OAAO,EAAE,KAAK,IAAI,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,SAAS,EAAE,KAAK,IAAI,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,aAChGD,GAAA,CAAC,aAAa,OAAK,KAAK,EAAA,CAAI,EAC5BA,GAAA,CAAC,UAAU,OAAK,KAAK,EAAA,CAAI,CAAA,EAAA,CACxB;AAEb;;"}
@@ -0,0 +1,6 @@
1
+ import type { DataTableHeadProps } from './DataTableHead.js';
2
+ /** The one reachable set of column and select-all controls while the table is unmounted. */
3
+ export declare const DataTableCardControls: ({ columns, parts: pt, messages, selection, selectionMode, ...controls }: DataTableHeadProps & {
4
+ selectionMode?: 'single' | 'multiple';
5
+ }) => import("react").JSX.Element;
6
+ //# sourceMappingURL=DataTableCardControls.d.ts.map