@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
@@ -1 +1 @@
1
- {"version":3,"file":"useRowSelection.js","sources":["../../../DataTables/useRowSelection.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useEffect, useMemo, useRef } from 'react';\nimport type { RowSelection } from './RowSelection';\nimport type { RowSelectionSource } from './RowSelectionSource';\nimport { valueAtPath } from './valueAtPath';\n\n/**\n * Single and multiple row selection by data key, or by object identity without one.\n * @param source The rows and the selection to work with.\n * @returns The selection state and actions.\n */\nexport const useRowSelection = <TData extends object>({\n data,\n visibleRows,\n dataKey,\n selection,\n selectedItems,\n onSelectedItemsChange,\n}: RowSelectionSource<TData>): RowSelection<TData> => {\n const dataKeyIdentity = (row: TData) =>\n String(valueAtPath(row as Record<string, unknown>, dataKey!));\n const dataKeyCounts = useMemo(() => {\n const counts = new Map<string, number>();\n if (!dataKey) return counts;\n for (const row of data) {\n const identity = String(valueAtPath(row as Record<string, unknown>, dataKey));\n counts.set(identity, (counts.get(identity) ?? 0) + 1);\n }\n return counts;\n }, [data, dataKey]);\n const firstLoadedIndexByDataKey = useMemo(() => {\n const indices = new Map<string, number>();\n if (!dataKey) return indices;\n data.forEach((row, loadedIndex) => {\n const identity = String(valueAtPath(row as Record<string, unknown>, dataKey));\n if (!indices.has(identity)) indices.set(identity, loadedIndex);\n });\n return indices;\n }, [data, dataKey]);\n const selectedLoadedIndex = selection ? data.indexOf(selection) : -1;\n const selectedDataKey = selection && dataKey ? dataKeyIdentity(selection) : undefined;\n const isSelectedRow = (row: TData, loadedIndex: number) => {\n if (!selection) return false;\n if (!dataKey) return loadedIndex === selectedLoadedIndex;\n\n const identity = dataKeyIdentity(row);\n if (identity !== selectedDataKey) return false;\n if ((dataKeyCounts.get(identity) ?? 0) <= 1) return true;\n if (selectedLoadedIndex >= 0) return loadedIndex === selectedLoadedIndex;\n return loadedIndex === firstLoadedIndexByDataKey.get(identity);\n };\n\n // Membership is by dataKey when there is one, and by object identity otherwise. A table whose\n // rows are replaced wholesale on every refresh - which is every observable query - keeps its\n // selection only in the first case, which is why dataKey matters here as much as it does for\n // single selection.\n const selectedItemsList = useMemo(() => selectedItems ?? [], [selectedItems]);\n const isRowSelected = (row: TData) =>\n dataKey\n ? selectedItemsList.some(\n (selected) => dataKeyIdentity(selected) === dataKeyIdentity(row),\n )\n : selectedItemsList.includes(row);\n\n const toggleRowSelection = (row: TData) => {\n const next = isRowSelected(row)\n ? selectedItemsList.filter((selected) =>\n dataKey\n ? dataKeyIdentity(selected) !== dataKeyIdentity(row)\n : selected !== row,\n )\n : [...selectedItemsList, row];\n onSelectedItemsChange?.(next);\n };\n\n // Select-all means the rows the user can currently see. A filtered table that silently selected\n // rows hidden behind the filter would act on more than it showed, which is the whole hazard of a\n // bulk action.\n const isVisibleRow = (row: TData) =>\n dataKey\n ? visibleRows.some(\n (visible) => dataKeyIdentity(visible) === dataKeyIdentity(row),\n )\n : visibleRows.includes(row);\n const selectedVisibleCount = visibleRows.filter((row) => isRowSelected(row)).length;\n const allFilteredRowsSelected =\n visibleRows.length > 0 && selectedVisibleCount === visibleRows.length;\n const someFilteredRowsSelected = selectedVisibleCount > 0 && !allFilteredRowsSelected;\n const selectAllRef = useRef<HTMLInputElement>(null);\n useEffect(() => {\n if (selectAllRef.current) {\n selectAllRef.current.indeterminate = someFilteredRowsSelected;\n }\n }, [someFilteredRowsSelected]);\n\n const toggleSelectAll = () => {\n if (allFilteredRowsSelected) {\n onSelectedItemsChange?.(\n selectedItemsList.filter((selected) => !isVisibleRow(selected)),\n );\n return;\n }\n const additions = visibleRows.filter((row) => !isRowSelected(row));\n onSelectedItemsChange?.([...selectedItemsList, ...additions]);\n };\n\n return {\n dataKeyIdentity,\n isSelectedRow,\n isRowSelected,\n toggleRowSelection,\n allFilteredRowsSelected,\n selectAllRef,\n toggleSelectAll,\n };\n};\n"],"names":[],"mappings":";;;AAaO,MAAM,eAAe,GAAG,CAAuB,EAClD,IAAI,EACJ,WAAW,EACX,OAAO,EACP,SAAS,EACT,aAAa,EACb,qBAAqB,GACG,KAAyB;AACjD,IAAA,MAAM,eAAe,GAAG,CAAC,GAAU,KAC/B,MAAM,CAAC,WAAW,CAAC,GAA8B,EAAE,OAAQ,CAAC,CAAC;AACjE,IAAA,MAAM,aAAa,GAAG,OAAO,CAAC,MAAK;AAC/B,QAAA,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB;AACxC,QAAA,IAAI,CAAC,OAAO;AAAE,YAAA,OAAO,MAAM;AAC3B,QAAA,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;YACpB,M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AC,CAAC,GAAG,KAAK,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM;AACnF,IAAA,MAAM,uBAAuB,GACzB,WAAW,CAAC,MAAM,GAAG,CAAC,IAAI,oBAAoB,KAAK,WAAW,CAAC,MAAM;IACzE,MAAM,wBAAwB,GAAG,oBAAoB,GAAG,CAAC,IAAI,CAAC,uBAAuB;AACrF,IAAA,MAAM,YAAY,GAAG,MAAM,CAAmB,IAAI,CAAC;IACnD,SAAS,CAAC,MAAK;AACX,QAAA,IAAI,YAAY,CAAC,OAAO,EAAE;AACtB,YAAA,YAAY,CAAC,OAAO,CAAC,aAAa,GAAG,wBAAwB;QACjE;AACJ,IAAA,CAAC,EAAE,CAAC,wBAAwB,CAAC,CAAC;IAE9B,MAAM,eAAe,GAAG,MAAK;QACzB,IAAI,uBAAuB,EAAE;AACzB,YAAA,qBAAqB,GACjB,iBAAiB,CAAC,MAAM,CAAC,CAAC,QAAQ,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAClE;YACD;QACJ;AACA,QAAA,MAAM,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QAClE,qBAAqB,GAAG,CAAC,GAAG,iBAAiB,EAAE,GAAG,SAAS,CAAC,CAAC;AACjE,IAAA,CAAC;IAED,OAAO;QACH,eAAe;QACf,aAAa;QACb,aAAa;QACb,kBAAkB;QAClB,uBAAuB;QACvB,YAAY;QACZ,eAAe;KAClB;AACL;;"}
1
+ {"version":3,"file":"useRowSelection.js","sources":["../../../DataTables/useRowSelection.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useEffect, useMemo, useRef } from 'react';\nimport type { RowSelection } from './RowSelection';\nimport type { RowSelectionSource } from './RowSelectionSource';\nimport { valueAtPath } from './valueAtPath';\n\n/**\n * Single and multiple row selection by data key, or by object identity without one.\n * @param source The rows and the selection to work with.\n * @returns The selection state and actions.\n */\nexport const useRowSelection = <TData extends object>({\n data,\n visibleRows,\n dataKey,\n selection,\n selectedItems,\n onSelectedItemsChange,\n}: RowSelectionSource<TData>): RowSelection<TData> => {\n const dataKeyIdentity = (row: TData) =>\n String(valueAtPath(row as Record<string, unknown>, dataKey!));\n const dataKeyCounts = useMemo(() => {\n const counts = new Map<string, number>();\n if (!dataKey) return counts;\n for (const row of data) {\n const identity = String(valueAtPath(row as Record<string, unknown>, dataKey));\n counts.set(identity, (counts.get(identity) ?? 0) + 1);\n }\n return counts;\n }, [data, dataKey]);\n const firstLoadedIndexByDataKey = useMemo(() => {\n const indices = new Map<string, number>();\n if (!dataKey) return indices;\n data.forEach((row, loadedIndex) => {\n const identity = String(valueAtPath(row as Record<string, unknown>, dataKey));\n if (!indices.has(identity)) indices.set(identity, loadedIndex);\n });\n return indices;\n }, [data, dataKey]);\n const selectedLoadedIndex = selection ? data.indexOf(selection) : -1;\n const selectedDataKey = selection && dataKey ? dataKeyIdentity(selection) : undefined;\n const isSelectedRow = (row: TData, loadedIndex: number) => {\n if (!selection) return false;\n if (!dataKey) return loadedIndex === selectedLoadedIndex;\n\n const identity = dataKeyIdentity(row);\n if (identity !== selectedDataKey) return false;\n if ((dataKeyCounts.get(identity) ?? 0) <= 1) return true;\n if (selectedLoadedIndex >= 0) return loadedIndex === selectedLoadedIndex;\n return loadedIndex === firstLoadedIndexByDataKey.get(identity);\n };\n\n // Membership is by dataKey when there is one, and by object identity otherwise. A table whose\n // rows are replaced wholesale on every refresh - which is every observable query - keeps its\n // selection only in the first case, which is why dataKey matters here as much as it does for\n // single selection.\n const selectedItemsList = useMemo(() => selectedItems ?? [], [selectedItems]);\n const isRowSelected = (row: TData) =>\n dataKey\n ? selectedItemsList.some(\n (selected) => dataKeyIdentity(selected) === dataKeyIdentity(row),\n )\n : selectedItemsList.includes(row);\n\n const toggleRowSelection = (row: TData) => {\n const next = isRowSelected(row)\n ? selectedItemsList.filter((selected) =>\n dataKey\n ? dataKeyIdentity(selected) !== dataKeyIdentity(row)\n : selected !== row,\n )\n : [...selectedItemsList, row];\n onSelectedItemsChange?.(next);\n };\n\n // Select-all means the rows the user can currently see. A filtered table that silently selected\n // rows hidden behind the filter would act on more than it showed, which is the whole hazard of a\n // bulk action.\n const isVisibleRow = (row: TData) =>\n dataKey\n ? visibleRows.some(\n (visible) => dataKeyIdentity(visible) === dataKeyIdentity(row),\n )\n : visibleRows.includes(row);\n const selectedVisibleCount = visibleRows.filter((row) => isRowSelected(row)).length;\n const allFilteredRowsSelected =\n visibleRows.length > 0 && selectedVisibleCount === visibleRows.length;\n const someFilteredRowsSelected = selectedVisibleCount > 0 && !allFilteredRowsSelected;\n const selectAllRef = useRef<HTMLInputElement>(null);\n // Layout changes replace the input without changing the partial-selection boolean.\n // Reapply after every commit so a newly mounted select-all gets its mixed state too.\n useEffect(() => {\n if (selectAllRef.current) {\n selectAllRef.current.indeterminate = someFilteredRowsSelected;\n }\n });\n\n const toggleSelectAll = () => {\n if (allFilteredRowsSelected) {\n onSelectedItemsChange?.(\n selectedItemsList.filter((selected) => !isVisibleRow(selected)),\n );\n return;\n }\n const additions = visibleRows.filter((row) => !isRowSelected(row));\n onSelectedItemsChange?.([...selectedItemsList, ...additions]);\n };\n\n return {\n dataKeyIdentity,\n isSelectedRow,\n isRowSelected,\n toggleRowSelection,\n allFilteredRowsSelected,\n selectAllRef,\n toggleSelectAll,\n };\n};\n"],"names":[],"mappings":";;;AAaO,MAAM,eAAe,GAAG,CAAuB,EAClD,IAAI,EACJ,WAAW,EACX,OAAO,EACP,SAAS,EACT,aAAa,EACb,qBAAqB,GACG,KAAyB;AACjD,IAAA,MAAM,eAAe,GAAG,CAAC,GAAU,KAC/B,MAAM,CAAC,WAAW,CAAC,GAA8B,EAAE,OAAQ,CAAC,CAAC;AACjE,IAAA,MAAM,aAAa,GAAG,OAAO,CAAC,MAAK;AAC/B,QAAA,MAAM,MAAM,GAAG,IAA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AAe,CAAC,GAAG,CAAC;AAEpE,UAAE,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC;AACnC,IAAA,MAAM,oBAAoB,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM;AACnF,IAAA,MAAM,uBAAuB,GACzB,WAAW,CAAC,MAAM,GAAG,CAAC,IAAI,oBAAoB,KAAK,WAAW,CAAC,MAAM;IACzE,MAAM,wBAAwB,GAAG,oBAAoB,GAAG,CAAC,IAAI,CAAC,uBAAuB;AACrF,IAAA,MAAM,YAAY,GAAG,MAAM,CAAmB,IAAI,CAAC;IAGnD,SAAS,CAAC,MAAK;AACX,QAAA,IAAI,YAAY,CAAC,OAAO,EAAE;AACtB,YAAA,YAAY,CAAC,OAAO,CAAC,aAAa,GAAG,wBAAwB;QACjE;AACJ,IAAA,CAAC,CAAC;IAEF,MAAM,eAAe,GAAG,MAAK;QACzB,IAAI,uBAAuB,EAAE;AACzB,YAAA,qBAAqB,GACjB,iBAAiB,CAAC,MAAM,CAAC,CAAC,QAAQ,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAClE;YACD;QACJ;AACA,QAAA,MAAM,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QAClE,qBAAqB,GAAG,CAAC,GAAG,iBAAiB,EAAE,GAAG,SAAS,CAAC,CAAC;AACjE,IAAA,CAAC;IAED,OAAO;QACH,eAAe;QACf,aAAa;QACb,aAAa;QACb,kBAAkB;QAClB,uBAAuB;QACvB,YAAY;QACZ,eAAe;KAClB;AACL;;"}
@@ -2,6 +2,7 @@ import type { DialogResult, DialogButtons } from '@cratis/arc.react/dialogs';
2
2
  import type { ButtonHTMLAttributes, CSSProperties, HTMLAttributes, ReactNode } from 'react';
3
3
  import type { DialogSliceLocation } from '../configuration/DialogSliceLocation.js';
4
4
  import type { DialogInitialFocus } from './DialogInitialFocus.js';
5
+ import type { DialogRefusalFeedback } from './DialogRefusalFeedback.js';
5
6
  /** Callback handling a typed dialog result; return `false` to keep the dialog open. */
6
7
  export type CloseDialog = (result: DialogResult) => boolean | void | Promise<boolean> | Promise<void>;
7
8
  /** Confirmation callback; return `true` to permit host closure. */
@@ -74,6 +75,12 @@ export interface DialogProps {
74
75
  * dialog from a plain one. Defaults to `false`.
75
76
  */
76
77
  isCommandDialog?: boolean;
78
+ /**
79
+ * Read when a confirm is refused, to replace the generic announcement and focus target with
80
+ * feedback about this refusal. Used by `CommandDialog` to announce validation failures and focus
81
+ * the first invalid field. Returning `undefined` keeps the default behavior.
82
+ */
83
+ refusalFeedback?: () => DialogRefusalFeedback | undefined;
77
84
  /**
78
85
  * Glyph for the header close button. Names this one dialog and wins over the provider's
79
86
  * `icons.close`; defaults to a multiplication sign when neither is set.
@@ -1 +1 @@
1
- {"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../../Dialogs/Dialog.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,KAAK,EACR,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,SAAS,EACZ,MAAM,OAAO,CAAC;AAIf,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yCAAsC,CAAC;AAChF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAsB,CAAC;AAI/D,uFAAuF;AACvF,MAAM,MAAM,WAAW,GAAG,CACtB,MAAM,EAAE,YAAY,KACnB,OAAO,GAAG,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAEvD,mEAAmE;AACnE,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,GAAG,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AACtF,mEAAm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AC;IACpB,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,mCAAmC;IACnC,YAAY,CAAC,EAAE,aAAa,CAAC;IAC7B;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,iEAAiE;IACjE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wEAAwE;IACxE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,8FAA8F;IAC9F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0GAA0G;IAC1G,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iGAAiG;IACjG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8FAA8F;IAC9F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yHAAyH;IACzH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kGAAkG;IAClG,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,4FAA4F;IAC5F,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,iGAAiG;IACjG,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,EAAE,CAAC,EAAE,WAAW,CAAC;IACjB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAUD;;;GAGG;AACH,eAAO,MAAM,MAAM,UAAW,WAAW,+FAKxC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Dialog.js","sources":["../../../Dialogs/Dialog.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { DialogResult, DialogButtons } from '@cratis/arc.react/dialogs';\nimport type {\n ButtonHTMLAttributes,\n CSSProperties,\n HTMLAttributes,\n ReactNode,\n} from 'react';\nimport { unstable_useSlot } from '../renderer/RendererContext';\nimport { renderSlot } from '../renderer/renderSlot';\nimport type { unstable_SlotDeclaration } from '../renderer/slots';\nimport type { DialogSliceLocation } from '../configuration/DialogSliceLocation';\nimport type { DialogInitialFocus } from './DialogInitialFocus';\nimport { DialogImplementation } from './DialogImplementation';\nimport { DialogSlotHost } from './DialogSlotHost';\n\n/** Callback handling a typed dialog result; return `false` to keep the dialog open. */\nexport type CloseDialog = (\n result: DialogResult,\n) => boolean | void | Promise<boolean> | Promise<void>;\n\n/** Confirmation callback; return `true` to permit host closure. */\nexport type ConfirmCallback = () => boolean | void | Promise<boolean> | Promise<void>;\n/** Cancellation callback; return `true` to permit host closure. */\nexport type CancelCallback = () => boolean | void | Promise<boolean> | Promise<void>;\n\ntype DialogPartAttributes<TElement> = HTMLAttributes<TElement> & {\n [attribute: `data-${string}`]: string | number | boolean | undefined;\n};\n\ntype DialogButtonAttributes = Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n 'onClick' | 'value'\n>;\n\n/**\n * Where a {@link Dialog} sits in the viewport. `center` is the classic modal; `start` and `end`\n * make it a full-height side sheet against the inline-start or inline-end edge.\n */\nexport type DialogPlacement = 'center' | 'start' | 'end';\n\n/** Stable Cratis-owned parts for styling a {@link Dialog}. */\nexport interface DialogParts {\n /** Viewport backdrop and dismissal surface. */\n backdrop?: DialogPartAttributes<HTMLDivElement>;\n /** Viewport positioning wrapper. */\n positioner?: DialogPartAttributes<HTMLDivElement>;\n /** Modal root. */\n root?: DialogPartAttributes<HTMLDivElement>;\n /** Header containing title and optional close action. */\n header?: DialogPartAttributes<HTMLElement>;\n /** Dialog heading. */\n title?: DialogPartAttributes<HTMLHeadingElement>;\n /** Secondary line under the heading, rendered only when `subtitle` is set. */\n subtitle?: DialogPartAttributes<HTMLParagraphElement>;\n /** Region before the close button holding per-dialog and app-wide header actions. */\n headerActions?: DialogPartAttributes<HTMLDivElement>;\n /** Header close button. */\n close?: DialogButtonAttributes;\n /** Dialog content region. */\n content?: DialogPartAttributes<HTMLDivElement>;\n /** Footer action region. */\n footer?: DialogPartAttributes<HTMLElement>;\n /** Primary confirmation button. */\n confirm?: DialogButtonAttributes;\n /** Secondary dismissal button(s). */\n cancel?: DialogButtonAttributes;\n}\n\n/** Props for {@link Dialog}. */\nexport interface DialogProps {\n /** Dialog heading. */\n title: string;\n /**\n * Secondary line under the heading — a reference, a status, a short summary. Announced as the\n * dialog's description.\n */\n subtitle?: ReactNode;\n /**\n * Viewport placement. `center` (default) is a modal; `start` and `end` render a full-height\n * side sheet against that inline edge, sliding in from it. Dismissal, focus and busy behavior\n * are identical across placements.\n */\n placement?: DialogPlacement;\n /**\n * Actions rendered in the header before the close button, in a `header-actions` part. Use it\n * for a help, feedback or copy-link action that belongs to this dialog. Rendered next to the\n * app-wide actions registered on `CratisComponentsProvider`.\n */\n headerActions?: ReactNode;\n /** Suppresses the app-wide header actions registered on `CratisComponentsProvider` for this dialog. */\n hideGlobalHeaderActions?: boolean;\n /** Where this dialog's opener sits in the application. Passed to app-wide header actions as `sliceLocation`. */\n sliceLocation?: DialogSliceLocation;\n /**\n * Set by `CommandDialog` and `StepperCommandDialog` so app-wide header actions can tell a command\n * dialog from a plain one. Defaults to `false`.\n */\n isCommandDialog?: boolean;\n /**\n * Glyph for the header close button. Names this one dialog and wins over the provider's\n * `icons.close`; defaults to a multiplication sign when neither is set.\n */\n closeIcon?: ReactNode;\n /** Controlled open state. Defaults to `true`. */\n visible?: boolean;\n /** Combined result callback used when a dedicated confirm/cancel callback is absent. */\n onClose?: CloseDialog;\n /** Invoked by primary confirmation actions. */\n onConfirm?: ConfirmCallback;\n /** Invoked by cancellation actions. */\n onCancel?: CancelCallback;\n /** Predefined Arc buttons, custom footer content, or `null` for no footer. */\n buttons?: DialogButtons | ReactNode;\n /** Initial focus target. Defaults to the confirmation action. */\n initialFocus?: DialogInitialFocus;\n /** Dialog body content. */\n children: ReactNode;\n /** CSS width. Defaults to `450px`. */\n width?: string;\n /** Modal-root inline style. */\n style?: CSSProperties;\n /** Content-region inline style. */\n contentStyle?: CSSProperties;\n /**\n * @deprecated The Cratis dialog is viewport-bounded rather than resizable. Remove this prop.\n */\n resizable?: boolean;\n /** Whether the primary action is enabled. Defaults to `true`. */\n isValid?: boolean;\n /** Disables every action and dismissal path while work is in flight. */\n isBusy?: boolean;\n /** Label for the Ok action. Falls back to the provider's `dialog.ok` message, then `'Ok'`. */\n okLabel?: string;\n /** Label for the Cancel action. Falls back to the provider's `dialog.cancel` message, then `'Cancel'`. */\n cancelLabel?: string;\n /** Label for the Yes action. Falls back to the provider's `dialog.yes` message, then `'Yes'`. */\n yesLabel?: string;\n /** Label for the No action. Falls back to the provider's `dialog.no` message, then `'No'`. */\n noLabel?: string;\n /** Accessible label for the header close button. Falls back to the provider's `dialog.close` message, then `'Close'`. */\n closeAriaLabel?: string;\n /**\n * Combined default for header, Escape, and backdrop dismissal. Defaults to true\n * for predefined buttons and false for custom/no footer. Independent props override it.\n */\n dismissable?: boolean;\n /** Whether outside clicks dismiss the dialog. Falls back to `dismissable`; blocked while busy. */\n dismissOnOutsideClick?: boolean;\n /** Whether Escape dismisses the dialog. Falls back to `dismissable`; blocked while busy. */\n closeOnEscape?: boolean;\n /** Whether to show the header close button. Falls back to `dismissable`; disabled while busy. */\n showCloseButton?: boolean;\n /** Extra class name for the modal root. */\n className?: string;\n /** Cratis-owned per-part attributes. */\n pt?: DialogParts;\n /**\n * @deprecated Cratis parts always merge. Remove this renderer-era option.\n */\n ptOptions?: object;\n /**\n * @deprecated Components always uses consumer-owned CSS. Customize through `pt` and CSS instead.\n */\n unstyled?: boolean;\n}\n\nconst coreDialogDeclaration = Object.freeze({\n mode: 'atomic',\n fidelity: 'native',\n render: DialogImplementation,\n}) satisfies unstable_SlotDeclaration<'dialogs.dialog'>;\n\nconst slotHostDeclaration = Object.freeze({ render: DialogSlotHost });\n\n/**\n * A modal dialog with Arc host integration, typed footer actions, busy/validity\n * state, controlled dismissal, and stable Cratis-owned styling parts.\n */\nexport const Dialog = (props: DialogProps) => {\n const declaration = unstable_useSlot('dialogs.dialog', coreDialogDeclaration);\n if (declaration.render === DialogImplementation) return renderSlot(coreDialogDeclaration, props);\n // An adapter dialog receives the public props plus its Components-owned host.\n return renderSlot(slotHostDeclaration, { render: declaration.render, props });\n};\n"],"names":[],"mappings":";;;;;AAyKA,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC;AACxC,IAAA,IAAI,EAAE,QAAQ;AACd,IAAA,QAAQ,EAAE,QAAQ;AAClB,IAAA,MAAM,EAAE,oBAAoB;AAC/B,CAAA,CAAsD;AAEvD,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;AAM9D,MAAM,MAAM,GAAG,CAAC,KAAkB,KAAI;IACzC,MAAM,WAAW,GAAG,gBAAgB,CAAC,gBAAgB,EAAE,qBAAqB,CAAC;AAC7E,IAAA,IAAI,WAAW,CAAC,MAAM,KAAK,oBAAoB;AAAE,QAAA,OAAO,UAAU,CAAC,qBAAqB,EAAE,KAAK,CAAC;AAEhG,IAAA,OAAO,UAAU,CAAC,mBAAmB,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC;AACjF;;"}
1
+ {"version":3,"file":"Dialog.js","sources":["../../../Dialogs/Dialog.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { DialogResult, DialogButtons } from '@cratis/arc.react/dialogs';\nimport type {\n ButtonHTMLAttributes,\n CSSProperties,\n HTMLAttributes,\n ReactNode,\n} from 'react';\nimport { unstable_useSlot } from '../renderer/RendererContext';\nimport { renderSlot } from '../renderer/renderSlot';\nimport type { unstable_SlotDeclaration } from '../renderer/slots';\nimport type { DialogSliceLocation } from '../configuration/DialogSliceLocation';\nimport type { DialogInitialFocus } from './DialogInitialFocus';\nimport type { DialogRefusalFeedback } from './DialogRefusalFeedback';\nimport { DialogImplementation } from './DialogImplementation';\nimport { DialogSlotHost } from './DialogSlotHost';\n\n/** Callback handling a typed dialog result; return `false` to keep the dialog open. */\nexport type CloseDialog = (\n result: DialogResult,\n) => boolean | void | Promise<boolean> | Promise<void>;\n\n/** Confirmation callback; return `true` to permit host closure. */\nexport type ConfirmCallback = () => boolean | void | Promise<boolean> | Promise<void>;\n/** Cancellation callback; return `true` to permit host closure. */\nexport type CancelCallback = () => boolean | void | Promise<boolean> | Promise<void>;\n\ntype DialogPartAttributes<TElement> = HTMLAttributes<TElement> & {\n [attribute: `data-${string}`]: string | number | boolean | undefined;\n};\n\ntype DialogButtonAttributes = Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n 'onClick' | 'value'\n>;\n\n/**\n * Where a {@link Dialog} sits in the viewport. `center` is the classic modal; `start` and `end`\n * make it a full-height side sheet against the inline-start or inline-end edge.\n */\nexport type DialogPlacement = 'center' | 'start' | 'end';\n\n/** Stable Cratis-owned parts for styling a {@link Dialog}. */\nexport interface DialogParts {\n /** Viewport backdrop and dismissal surface. */\n backdrop?: DialogPartAttributes<HTMLDivElement>;\n /** Viewport positioning wrapper. */\n positioner?: DialogPartAttributes<HTMLDivElement>;\n /** Modal root. */\n root?: DialogPartAttributes<HTMLDivElement>;\n /** Header containing title and optional close action. */\n header?: DialogPartAttributes<HTMLElement>;\n /** Dialog heading. */\n title?: DialogPartAttributes<HTMLHeadingElement>;\n /** Secondary line under the heading, rendered only when `subtitle` is set. */\n subtitle?: DialogPartAttributes<HTMLParagraphElement>;\n /** Region before the close button holding per-dialog and app-wide header actions. */\n headerActions?: DialogPartAttributes<HTMLDivElement>;\n /** Header close button. */\n close?: DialogButtonAttributes;\n /** Dialog content region. */\n content?: DialogPartAttributes<HTMLDivElement>;\n /** Footer action region. */\n footer?: DialogPartAttributes<HTMLElement>;\n /** Primary confirmation button. */\n confirm?: DialogButtonAttributes;\n /** Secondary dismissal button(s). */\n cancel?: DialogButtonAttributes;\n}\n\n/** Props for {@link Dialog}. */\nexport interface DialogProps {\n /** Dialog heading. */\n title: string;\n /**\n * Secondary line under the heading — a reference, a status, a short summary. Announced as the\n * dialog's description.\n */\n subtitle?: ReactNode;\n /**\n * Viewport placement. `center` (default) is a modal; `start` and `end` render a full-height\n * side sheet against that inline edge, sliding in from it. Dismissal, focus and busy behavior\n * are identical across placements.\n */\n placement?: DialogPlacement;\n /**\n * Actions rendered in the header before the close button, in a `header-actions` part. Use it\n * for a help, feedback or copy-link action that belongs to this dialog. Rendered next to the\n * app-wide actions registered on `CratisComponentsProvider`.\n */\n headerActions?: ReactNode;\n /** Suppresses the app-wide header actions registered on `CratisComponentsProvider` for this dialog. */\n hideGlobalHeaderActions?: boolean;\n /** Where this dialog's opener sits in the application. Passed to app-wide header actions as `sliceLocation`. */\n sliceLocation?: DialogSliceLocation;\n /**\n * Set by `CommandDialog` and `StepperCommandDialog` so app-wide header actions can tell a command\n * dialog from a plain one. Defaults to `false`.\n */\n isCommandDialog?: boolean;\n /**\n * Read when a confirm is refused, to replace the generic announcement and focus target with\n * feedback about this refusal. Used by `CommandDialog` to announce validation failures and focus\n * the first invalid field. Returning `undefined` keeps the default behavior.\n */\n refusalFeedback?: () => DialogRefusalFeedback | undefined;\n /**\n * Glyph for the header close button. Names this one dialog and wins over the provider's\n * `icons.close`; defaults to a multiplication sign when neither is set.\n */\n closeIcon?: ReactNode;\n /** Controlled open state. Defaults to `true`. */\n visible?: boolean;\n /** Combined result callback used when a dedicated confirm/cancel callback is absent. */\n onClose?: CloseDialog;\n /** Invoked by primary confirmation actions. */\n onConfirm?: ConfirmCallback;\n /** Invoked by cancellation actions. */\n onCancel?: CancelCallback;\n /** Predefined Arc buttons, custom footer content, or `null` for no footer. */\n buttons?: DialogButtons | ReactNode;\n /** Initial focus target. Defaults to the confirmation action. */\n initialFocus?: DialogInitialFocus;\n /** Dialog body content. */\n children: ReactNode;\n /** CSS width. Defaults to `450px`. */\n width?: string;\n /** Modal-root inline style. */\n style?: CSSProperties;\n /** Content-region inline style. */\n contentStyle?: CSSProperties;\n /**\n * @deprecated The Cratis dialog is viewport-bounded rather than resizable. Remove this prop.\n */\n resizable?: boolean;\n /** Whether the primary action is enabled. Defaults to `true`. */\n isValid?: boolean;\n /** Disables every action and dismissal path while work is in flight. */\n isBusy?: boolean;\n /** Label for the Ok action. Falls back to the provider's `dialog.ok` message, then `'Ok'`. */\n okLabel?: string;\n /** Label for the Cancel action. Falls back to the provider's `dialog.cancel` message, then `'Cancel'`. */\n cancelLabel?: string;\n /** Label for the Yes action. Falls back to the provider's `dialog.yes` message, then `'Yes'`. */\n yesLabel?: string;\n /** Label for the No action. Falls back to the provider's `dialog.no` message, then `'No'`. */\n noLabel?: string;\n /** Accessible label for the header close button. Falls back to the provider's `dialog.close` message, then `'Close'`. */\n closeAriaLabel?: string;\n /**\n * Combined default for header, Escape, and backdrop dismissal. Defaults to true\n * for predefined buttons and false for custom/no footer. Independent props override it.\n */\n dismissable?: boolean;\n /** Whether outside clicks dismiss the dialog. Falls back to `dismissable`; blocked while busy. */\n dismissOnOutsideClick?: boolean;\n /** Whether Escape dismisses the dialog. Falls back to `dismissable`; blocked while busy. */\n closeOnEscape?: boolean;\n /** Whether to show the header close button. Falls back to `dismissable`; disabled while busy. */\n showCloseButton?: boolean;\n /** Extra class name for the modal root. */\n className?: string;\n /** Cratis-owned per-part attributes. */\n pt?: DialogParts;\n /**\n * @deprecated Cratis parts always merge. Remove this renderer-era option.\n */\n ptOptions?: object;\n /**\n * @deprecated Components always uses consumer-owned CSS. Customize through `pt` and CSS instead.\n */\n unstyled?: boolean;\n}\n\nconst coreDialogDeclaration = Object.freeze({\n mode: 'atomic',\n fidelity: 'native',\n render: DialogImplementation,\n}) satisfies unstable_SlotDeclaration<'dialogs.dialog'>;\n\nconst slotHostDeclaration = Object.freeze({ render: DialogSlotHost });\n\n/**\n * A modal dialog with Arc host integration, typed footer actions, busy/validity\n * state, controlled dismissal, and stable Cratis-owned styling parts.\n */\nexport const Dialog = (props: DialogProps) => {\n const declaration = unstable_useSlot('dialogs.dialog', coreDialogDeclaration);\n if (declaration.render === DialogImplementation) return renderSlot(coreDialogDeclaration, props);\n // An adapter dialog receives the public props plus its Components-owned host.\n return renderSlot(slotHostDeclaration, { render: declaration.render, props });\n};\n"],"names":[],"mappings":";;;;;AAgLA,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC;AACxC,IAAA,IAAI,EAAE,QAAQ;AACd,IAAA,QAAQ,EAAE,QAAQ;AAClB,IAAA,MAAM,EAAE,oBAAoB;AAC/B,CAAA,CAAsD;AAEvD,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;AAM9D,MAAM,MAAM,GAAG,CAAC,KAAkB,KAAI;IACzC,MAAM,WAAW,GAAG,gBAAgB,CAAC,gBAAgB,EAAE,qBAAqB,CAAC;AAC7E,IAAA,IAAI,WAAW,CAAC,MAAM,KAAK,oBAAoB;AAAE,QAAA,OAAO,UAAU,CAAC,qBAAqB,EAAE,KAAK,CAAC;AAEhG,IAAA,OAAO,UAAU,CAAC,mBAAmB,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC;AACjF;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"DialogImplementation.d.ts","sourceRoot":"","sources":["../../../Dialogs/DialogImplementation.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAU,CAAC;AAsB5C;;;GAGG;AACH,eAAO,MAAM,oBAAoB,kBAAmB,WAAW,gCA4H9D,CAAC"}
1
+ {"version":3,"file":"DialogImplementation.d.ts","sourceRoot":"","sources":["../../../Dialogs/DialogImplementation.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAU,CAAC;AAsB5C;;;GAGG;AACH,eAAO,MAAM,oBAAoB,kBAAmB,WAAW,gCA6H9D,CAAC"}
@@ -48,6 +48,7 @@ const DialogImplementation = (incomingProps) => {
48
48
  isBusy,
49
49
  initialFocus: resolvedInitialFocus,
50
50
  refusedMessage: labels.refused,
51
+ refusalFeedback: props.refusalFeedback,
51
52
  });
52
53
  const handleClose = useDialogClose(props, onRefused);
53
54
  const dialogDocument = (jsx(DialogDocument, { stackZIndex: resolvedZIndex ?? DIALOG_ZINDEX_TOKEN, hostId: hostId, visible: visible, contentStyle: props.contentStyle, announcement: announcement, header: {
@@ -1 +1 @@
1
- {"version":3,"file":"DialogImplementation.js","sources":["../../../Dialogs/DialogImplementation.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DialogResult, DialogButtons } from '@cratis/arc.react/dialogs';\nimport { useId, useSyncExternalStore } from 'react';\nimport { unstable_useOverlayEnvironment } from '../renderer/RendererContext';\nimport { DialogInitialFocus } from './DialogInitialFocus';\nimport type { DialogProps } from './Dialog';\nimport { dismissalFor, resolveInitialFocus } from './dialogBehavior';\nimport { useCratisComponentsConfig } from '../Common/CratisComponentsProvider';\nimport { useCratisIcon } from '../configuration/useCratisIcon';\nimport { DIALOG_ZINDEX_TOKEN } from '../renderer/dialogStack';\nimport { useComponentPresentation } from '../configuration/identity/useComponentPresentation';\nimport { dialogDescriptor } from './dialogDescriptor';\nimport { DialogDocument } from './DialogDocument';\nimport { DialogModalShell, DialogServerShell } from './DialogShells';\nimport { resolveDialogLabels } from './resolveDialogLabels';\nimport { useDialogClose } from './useDialogClose';\nimport { useDialogFocus } from './useDialogFocus';\nimport { useDialogZIndex } from './useDialogZIndex';\n\nconst subscribeToBrowserEnvironment = () => () => undefined;\nconst useIsBrowser = () =>\n useSyncExternalStore(\n subscribeToBrowserEnvironment,\n () => true,\n () => false,\n );\n\n/**\n * A modal dialog with Arc host integration, typed footer actions, busy/validity\n * state, controlled dismissal, and stable Cratis-owned styling parts.\n */\nexport const DialogImplementation = (incomingProps: DialogProps) => {\n const [props, marker] = useComponentPresentation(dialogDescriptor, incomingProps);\n const {\n title,\n subtitle,\n placement = 'center',\n closeIcon,\n headerActions,\n hideGlobalHeaderActions = false,\n sliceLocation,\n isCommandDialog = false,\n visible = true,\n buttons = DialogButtons.OkCancel,\n initialFocus = DialogInitialFocus.Confirm,\n children,\n width = '450px',\n isValid,\n isBusy = false,\n pt,\n } = props;\n const { messages, dialogHeaderActions } = useCratisComponentsConfig();\n const dialogId = useId();\n const subtitleId = useId();\n const hostId = useId();\n const labels = resolveDialogLabels(props, messages?.dialog);\n const icon = useCratisIcon();\n const isBrowser = useIsBrowser();\n const overlayEnvironment = unstable_useOverlayEnvironment();\n\n const hasHeaderActions =\n headerActions != null || (dialogHeaderActions !== undefined && !hideGlobalHeaderActions);\n const hasSubtitle = subtitle !== undefined && subtitle !== null && subtitle !== false;\n const resolvedInitialFocus = resolveInitialFocus(initialFocus, buttons);\n const focus = {\n confirm: resolvedInitialFocus === DialogInitialFocus.Confirm,\n dismissing: resolvedInitialFocus === DialogInitialFocus.Cancel,\n };\n const { allowsOutsideDismissal, allowsEscapeDismissal, showsCloseButton } = dismissalFor(props, isBusy);\n\n const resolvedZIndex = useDialogZIndex(visible);\n const { titleRef, confirmRef, cancelRef, announcement, onRefused } = useDialogFocus({\n visible,\n isBusy,\n initialFocus: resolvedInitialFocus,\n refusedMessage: labels.refused,\n });\n const handleClose = useDialogClose(props, onRefused);\n\n const dialogDocument = (\n <DialogDocument\n stackZIndex={resolvedZIndex ?? DIALOG_ZINDEX_TOKEN}\n hostId={hostId}\n visible={visible}\n contentStyle={props.contentStyle}\n announcement={announcement}\n header={{\n dialogId,\n title,\n subtitle,\n subtitleId,\n hasSubtitle,\n hasHeaderActions,\n headerActions,\n globalHeaderActions: dialogHeaderActions,\n hideGlobalHeaderActions,\n isCommandDialog,\n sliceLocation,\n showsCloseButton,\n focusesTitle: resolvedInitialFocus === DialogInitialFocus.Content,\n titleRef,\n isBusy,\n closeAriaLabel: labels.closeAria,\n closeIcon: icon('close', '×', closeIcon),\n onClose: () => void handleClose(DialogResult.Cancelled),\n pt,\n }}\n footer={\n buttons === null\n ? null\n : {\n buttons,\n labels,\n focus,\n isBusy,\n isValid: isValid !== false,\n pt,\n confirmRef,\n cancelRef,\n onResult: (result) => void handleClose(result),\n }\n }\n >\n {children}\n </DialogDocument>\n );\n\n const shell = {\n placement,\n visible,\n isBusy,\n zIndex: resolvedZIndex,\n width,\n style: props.style,\n className: props.className,\n dialogId,\n marker,\n pt,\n children: dialogDocument,\n };\n\n // useSyncExternalStore supplies the server snapshot during hydration, so this\n // fallback is identical on the server and on the client's first render. React\n // switches to the portaled React Aria modal only after hydration completes.\n if (!isBrowser) return <DialogServerShell {...shell} />;\n\n return (\n <DialogModalShell\n {...shell}\n portalContainer={overlayEnvironment.getContainer}\n allowsOutsideDismissal={allowsOutsideDismissal}\n allowsEscapeDismissal={allowsEscapeDismissal}\n onDismiss={() => void handleClose(DialogResult.Cancelled)}\n />\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,6BAA6B,GAAG,MAAM,MAAM,SAAS;AAC3D,MAAM,YAAY,GAAG,MACjB,oBAAoB,CAChB,6BAA6B,EAC7B,MAAM,IAAI,EACV,MAAM,KAAK,CACd;AAME,MAAM,oBAAoB,GAAG,CAAC,aAA0B,KAAI;AAC/D,IAAA,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,wBAAwB,CAAC,gBAAgB,EAAE,aAAa,CAAC;IACjF,MAAM,EACF,KAAK,EACL,QAAQ,EACR,SAAS,GAAG,QAAQ,EACpB,SAAS,EACT,aAAa,EACb,uBAAuB,GAAG,KAAK,EAC/B,aAAa,EACb,eAAe,GAAG,KAAK,EACvB,OAAO,GAAG,IAAI,EACd,OAAO,GAAG,aAAa,CA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,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,QAAQ;QACR,MAAM;QACN,EAAE;AACF,QAAA,QAAQ,EAAE,cAAc;KAC3B;AAKD,IAAA,IAAI,CAAC,SAAS;AAAE,QAAA,OAAOA,GAAA,CAAC,iBAAiB,EAAA,EAAA,GAAK,KAAK,GAAI;AAEvD,IAAA,QACIA,GAAA,CAAC,gBAAgB,EAAA,EAAA,GACT,KAAK,EACT,eAAe,EAAE,kBAAkB,CAAC,YAAY,EAChD,sBAAsB,EAAE,sBAAsB,EAC9C,qBAAqB,EAAE,qBAAqB,EAC5C,SAAS,EAAE,MAAM,KAAK,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,EAAA,CAC3D;AAEV;;"}
1
+ {"version":3,"file":"DialogImplementation.js","sources":["../../../Dialogs/DialogImplementation.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DialogResult, DialogButtons } from '@cratis/arc.react/dialogs';\nimport { useId, useSyncExternalStore } from 'react';\nimport { unstable_useOverlayEnvironment } from '../renderer/RendererContext';\nimport { DialogInitialFocus } from './DialogInitialFocus';\nimport type { DialogProps } from './Dialog';\nimport { dismissalFor, resolveInitialFocus } from './dialogBehavior';\nimport { useCratisComponentsConfig } from '../Common/CratisComponentsProvider';\nimport { useCratisIcon } from '../configuration/useCratisIcon';\nimport { DIALOG_ZINDEX_TOKEN } from '../renderer/dialogStack';\nimport { useComponentPresentation } from '../configuration/identity/useComponentPresentation';\nimport { dialogDescriptor } from './dialogDescriptor';\nimport { DialogDocument } from './DialogDocument';\nimport { DialogModalShell, DialogServerShell } from './DialogShells';\nimport { resolveDialogLabels } from './resolveDialogLabels';\nimport { useDialogClose } from './useDialogClose';\nimport { useDialogFocus } from './useDialogFocus';\nimport { useDialogZIndex } from './useDialogZIndex';\n\nconst subscribeToBrowserEnvironment = () => () => undefined;\nconst useIsBrowser = () =>\n useSyncExternalStore(\n subscribeToBrowserEnvironment,\n () => true,\n () => false,\n );\n\n/**\n * A modal dialog with Arc host integration, typed footer actions, busy/validity\n * state, controlled dismissal, and stable Cratis-owned styling parts.\n */\nexport const DialogImplementation = (incomingProps: DialogProps) => {\n const [props, marker] = useComponentPresentation(dialogDescriptor, incomingProps);\n const {\n title,\n subtitle,\n placement = 'center',\n closeIcon,\n headerActions,\n hideGlobalHeaderActions = false,\n sliceLocation,\n isCommandDialog = false,\n visible = true,\n buttons = DialogButtons.OkCancel,\n initialFocus = DialogInitialFocus.Confirm,\n children,\n width = '450px',\n isValid,\n isBusy = false,\n pt,\n } = props;\n const { messages, dialogHeaderActions } = useCratisComponentsConfig();\n const dialogId = useId();\n const subtitleId = useId();\n const hostId = useId();\n const labels = resolveDialogLabels(props, messages?.dialog);\n const icon = useCratisIcon();\n const isBrowser = useIsBrowser();\n const overlayEnvironment = unstable_useOverlayEnvironment();\n\n const hasHeaderActions =\n headerActions != null || (dialogHeaderActions !== undefined && !hideGlobalHeaderActions);\n const hasSubtitle = subtitle !== undefined && subtitle !== null && subtitle !== false;\n const resolvedInitialFocus = resolveInitialFocus(initialFocus, buttons);\n const focus = {\n confirm: resolvedInitialFocus === DialogInitialFocus.Confirm,\n dismissing: resolvedInitialFocus === DialogInitialFocus.Cancel,\n };\n const { allowsOutsideDismissal, allowsEscapeDismissal, showsCloseButton } = dismissalFor(props, isBusy);\n\n const resolvedZIndex = useDialogZIndex(visible);\n const { titleRef, confirmRef, cancelRef, announcement, onRefused } = useDialogFocus({\n visible,\n isBusy,\n initialFocus: resolvedInitialFocus,\n refusedMessage: labels.refused,\n refusalFeedback: props.refusalFeedback,\n });\n const handleClose = useDialogClose(props, onRefused);\n\n const dialogDocument = (\n <DialogDocument\n stackZIndex={resolvedZIndex ?? DIALOG_ZINDEX_TOKEN}\n hostId={hostId}\n visible={visible}\n contentStyle={props.contentStyle}\n announcement={announcement}\n header={{\n dialogId,\n title,\n subtitle,\n subtitleId,\n hasSubtitle,\n hasHeaderActions,\n headerActions,\n globalHeaderActions: dialogHeaderActions,\n hideGlobalHeaderActions,\n isCommandDialog,\n sliceLocation,\n showsCloseButton,\n focusesTitle: resolvedInitialFocus === DialogInitialFocus.Content,\n titleRef,\n isBusy,\n closeAriaLabel: labels.closeAria,\n closeIcon: icon('close', '×', closeIcon),\n onClose: () => void handleClose(DialogResult.Cancelled),\n pt,\n }}\n footer={\n buttons === null\n ? null\n : {\n buttons,\n labels,\n focus,\n isBusy,\n isValid: isValid !== false,\n pt,\n confirmRef,\n cancelRef,\n onResult: (result) => void handleClose(result),\n }\n }\n >\n {children}\n </DialogDocument>\n );\n\n const shell = {\n placement,\n visible,\n isBusy,\n zIndex: resolvedZIndex,\n width,\n style: props.style,\n className: props.className,\n dialogId,\n marker,\n pt,\n children: dialogDocument,\n };\n\n // useSyncExternalStore supplies the server snapshot during hydration, so this\n // fallback is identical on the server and on the client's first render. React\n // switches to the portaled React Aria modal only after hydration completes.\n if (!isBrowser) return <DialogServerShell {...shell} />;\n\n return (\n <DialogModalShell\n {...shell}\n portalContainer={overlayEnvironment.getContainer}\n allowsOutsideDismissal={allowsOutsideDismissal}\n allowsEscapeDismissal={allowsEscapeDismissal}\n onDismiss={() => void handleClose(DialogResult.Cancelled)}\n />\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,6BAA6B,GAAG,MAAM,MAAM,SAAS;AAC3D,MAAM,YAAY,GAAG,MACjB,oBAAoB,CAChB,6BAA6B,EAC7B,MAAM,IAAI,EACV,MAAM,KAAK,CACd;AAME,MAAM,oBAAoB,GAAG,CAAC,aAA0B,KAAI;AAC/D,IAAA,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,wBAAwB,CAAC,gBAAgB,EAAE,aAAa,CAAC;IACjF,MAAM,EACF,KAAK,EACL,QAAQ,EACR,SAAS,GAAG,QAAQ,EACpB,SAAS,EACT,aAAa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,EAAA,QAAA,EAGV,QAAQ,EAAA,CACI,CACpB;AAED,IAAA,MAAM,KAAK,GAAG;QACV,SAAS;QACT,OAAO;QACP,MAAM;AACN,QAAA,MAAM,EAAE,cAAc;QACtB,KAAK;QACL,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,QAAQ;QACR,MAAM;QACN,EAAE;AACF,QAAA,QAAQ,EAAE,cAAc;KAC3B;AAKD,IAAA,IAAI,CAAC,SAAS;AAAE,QAAA,OAAOA,GAAA,CAAC,iBAAiB,EAAA,EAAA,GAAK,KAAK,GAAI;AAEvD,IAAA,QACIA,GAAA,CAAC,gBAAgB,EAAA,EAAA,GACT,KAAK,EACT,eAAe,EAAE,kBAAkB,CAAC,YAAY,EAChD,sBAAsB,EAAE,sBAAsB,EAC9C,qBAAqB,EAAE,qBAAqB,EAC5C,SAAS,EAAE,MAAM,KAAK,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,EAAA,CAC3D;AAEV;;"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * What a dialog does after a refused confirm, in place of its defaults. Read at the moment the
3
+ * refusal is handled, so it can describe the outcome of the confirm that was just refused.
4
+ */
5
+ export interface DialogRefusalFeedback {
6
+ /** Text for the live region. Defaults to the dialog's generic refusal message. */
7
+ message?: string;
8
+ /** Element to move focus to. Defaults to the confirm button, or the title when confirm is not enabled. */
9
+ focus?: HTMLElement | null;
10
+ }
11
+ //# sourceMappingURL=DialogRefusalFeedback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialogRefusalFeedback.d.ts","sourceRoot":"","sources":["../../../Dialogs/DialogRefusalFeedback.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IAClC,kFAAkF;IAClF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0GAA0G;IAC1G,KAAK,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CAC9B"}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+ export {};
4
+ //# sourceMappingURL=DialogRefusalFeedback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialogRefusalFeedback.js","sourceRoot":"","sources":["../../../Dialogs/DialogRefusalFeedback.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * What a dialog does after a refused confirm, in place of its defaults. Read at the moment the\n * refusal is handled, so it can describe the outcome of the confirm that was just refused.\n */\nexport interface DialogRefusalFeedback {\n /** Text for the live region. Defaults to the dialog's generic refusal message. */\n message?: string;\n /** Element to move focus to. Defaults to the confirm button, or the title when confirm is not enabled. */\n focus?: HTMLElement | null;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"DialogSlotHost.d.ts","sourceRoot":"","sources":["../../../Dialogs/DialogSlotHost.tsx"],"names":[],"mappings":"AAIA,OAAO,EAA0E,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAMnH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAU,CAAC;AAK5C,OAAO,KAAK,EAA6B,gBAAgB,EAA6B,qBAAqB,EAAE,MAAM,iBAAc,CAAC;AAgDlI;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,UAAW,WAAW;;;;CA8D/C,CAAC;AAEF,uCAAuC;AACvC,MAAM,WAAW,mBAAmB;IAChC,2CAA2C;IAC3C,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,qBAAqB,CAAC,CAAC;IACtD,iCAAiC;IACjC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC/B;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,sBAAuB,mBAAmB,gCAkBpE,CAAC"}
1
+ {"version":3,"file":"DialogSlotHost.d.ts","sourceRoot":"","sources":["../../../Dialogs/DialogSlotHost.tsx"],"names":[],"mappings":"AAIA,OAAO,EAA0E,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAMnH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAU,CAAC;AAK5C,OAAO,KAAK,EAA6B,gBAAgB,EAA6B,qBAAqB,EAAE,MAAM,iBAAc,CAAC;AAgDlI;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,UAAW,WAAW;;;;CA+D/C,CAAC;AAEF,uCAAuC;AACvC,MAAM,WAAW,mBAAmB;IAChC,2CAA2C;IAC3C,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,qBAAqB,CAAC,CAAC;IACtD,iCAAiC;IACjC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC/B;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,sBAAuB,mBAAmB,gCAkBpE,CAAC"}
@@ -55,6 +55,7 @@ const useDialogHost = (props) => {
55
55
  isBusy,
56
56
  initialFocus,
57
57
  refusedMessage: labels.refused,
58
+ refusalFeedback: props.refusalFeedback,
58
59
  });
59
60
  const handleClose = useDialogClose(props, onRefused);
60
61
  const host = {
@@ -1 +1 @@
1
- {"version":3,"file":"DialogSlotHost.js","sources":["../../../Dialogs/DialogSlotHost.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DialogButtons, DialogResult } from '@cratis/arc.react/dialogs';\nimport { createContext, createElement, use, useEffect, useId, useMemo, useState, type ComponentType } from 'react';\nimport { useCratisComponentsConfig } from '../Common/CratisComponentsProvider';\nimport { useCratisIcon } from '../configuration/useCratisIcon';\nimport { DIALOG_ZINDEX_TOKEN } from '../renderer/dialogStack';\nimport { DialogStackContext, OverlayHostContext } from '../renderer/DialogStackContext';\nimport { OverlayContainerScope, useOverlayContainer } from '../renderer/OverlayContainerScope';\nimport type { DialogProps } from './Dialog';\nimport { dismissalFor, resolveInitialFocus } from './dialogBehavior';\nimport { DialogContent, LiveRegion } from './DialogDocument';\nimport { DialogFooter } from './DialogFooter';\nimport { HeaderActions } from './DialogHeader';\nimport type { CratisDialogDismissSource, CratisDialogHost, CratisDialogHostDismissal, CratisDialogSlotProps } from './DialogHost';\nimport { DialogInitialFocus } from './DialogInitialFocus';\nimport { resolveDialogLabels } from './resolveDialogLabels';\nimport { useDialogClose } from './useDialogClose';\nimport { useDialogFocus } from './useDialogFocus';\nimport { useDialogZIndex } from './useDialogZIndex';\n\nconst useHeaderActions = (props: DialogProps, dialogId: string, showsCloseButton: boolean) => {\n const { dialogHeaderActions } = useCratisComponentsConfig();\n const { headerActions, hideGlobalHeaderActions = false } = props;\n const hasHeaderActions =\n headerActions != null || (dialogHeaderActions !== undefined && !hideGlobalHeaderActions);\n if (!hasHeaderActions) return null;\n return (\n <HeaderActions\n dialogId={dialogId}\n title={props.title}\n headerActions={headerActions}\n globalHeaderActions={dialogHeaderActions}\n hideGlobalHeaderActions={hideGlobalHeaderActions}\n isCommandDialog={props.isCommandDialog ?? false}\n sliceLocation={props.sliceLocation}\n showsCloseButton={showsCloseButton}\n pt={props.pt}\n />\n );\n};\n\n// Whether the adapter dialogs rendered inside may open: false until the nearest adapter dialog has\n// committed its own open state, so modals open parent-first, and false as soon as it hides.\nconst DescendantsMayOpenContext = createContext(true);\n\n// Passive effects run children-first, so this runs after the adapter dialog below opened itself.\nconst useDescendantsMayOpen = (visible: boolean) => {\n const [opened, setOpened] = useState(false);\n useEffect(() => setOpened(visible), [visible]);\n return visible && opened;\n};\n\ninterface DismissGuard {\n readonly visible: boolean;\n readonly isBusy: boolean;\n readonly dismissal: CratisDialogHostDismissal;\n}\n\nconst mayDismiss = ({ visible, isBusy, dismissal }: DismissGuard, source: CratisDialogDismissSource) =>\n visible && !isBusy && dismissal[source];\n\n/**\n * Builds the Components-owned host of one adapter-rendered dialog: its stack tier, the dialog\n * result flow, the footer and header actions, initial focus and the refused-confirmation\n * announcement, plus the overlay container its descendants portal through.\n * @param props The dialog's public props.\n * @returns The host handed to the adapter and the overlay container for its descendants.\n */\nexport const useDialogHost = (props: DialogProps) => {\n const { isBusy = false, buttons = DialogButtons.OkCancel, subtitle } = props;\n // A dialog nested in a hidden or still-opening adapter dialog stays closed until its parent is open.\n const visible = (props.visible ?? true) && use(DescendantsMayOpenContext);\n const { messages } = useCratisComponentsConfig();\n const icon = useCratisIcon();\n const id = useId();\n const subtitleId = useId();\n const labels = resolveDialogLabels(props, messages?.dialog);\n const initialFocus = resolveInitialFocus(props.initialFocus ?? DialogInitialFocus.Confirm, buttons);\n const { allowsOutsideDismissal, allowsEscapeDismissal, showsCloseButton } = dismissalFor(props, isBusy);\n const dismissal = { outside: allowsOutsideDismissal, escape: allowsEscapeDismissal, closeButton: showsCloseButton };\n const zIndex = useDialogZIndex(visible) ?? DIALOG_ZINDEX_TOKEN;\n const overlayContainer = useOverlayContainer(visible);\n const { titleRef, confirmRef, cancelRef, announcement, onRefused } = useDialogFocus({\n visible,\n isBusy,\n initialFocus,\n refusedMessage: labels.refused,\n });\n const handleClose = useDialogClose(props, onRefused);\n\n const host: CratisDialogHost = {\n id,\n zIndex,\n dismissal,\n closeAriaLabel: labels.closeAria,\n closeIcon: icon('close', '×', props.closeIcon),\n subtitleId,\n hasSubtitle: subtitle !== undefined && subtitle !== null && subtitle !== false,\n titleRef,\n content: (\n <DialogContent visible={visible} isBusy={isBusy} contentStyle={props.contentStyle} pt={props.pt}>\n {props.children}\n </DialogContent>\n ),\n headerActions: useHeaderActions(props, id, showsCloseButton),\n footer:\n buttons === null ? null : (\n <DialogFooter\n buttons={buttons}\n labels={labels}\n focus={{\n confirm: initialFocus === DialogInitialFocus.Confirm,\n dismissing: initialFocus === DialogInitialFocus.Cancel,\n }}\n isBusy={isBusy}\n isValid={props.isValid !== false}\n pt={props.pt}\n confirmRef={confirmRef}\n cancelRef={cancelRef}\n onResult={(result) => void handleClose(result)}\n />\n ),\n liveRegion: <LiveRegion announcement={announcement} />,\n dismiss: (source) => {\n if (mayDismiss({ visible, isBusy, dismissal }, source)) void handleClose(DialogResult.Cancelled);\n },\n registerOverlayContainer: overlayContainer.register,\n };\n\n return { host, overlayContainer, visible };\n};\n\n/** Props of {@link DialogSlotHost}. */\nexport interface DialogSlotHostProps {\n /** The adapter's dialog implementation. */\n readonly render: ComponentType<CratisDialogSlotProps>;\n /** The dialog's public props. */\n readonly props: DialogProps;\n}\n\n/**\n * Renders an adapter-owned dialog with its Components-owned host. Descendants read this dialog's\n * stack tier, see it as their overlay host, and portal through the overlay element the adapter\n * registered.\n */\nexport const DialogSlotHost = ({ render, props }: DialogSlotHostProps) => {\n const { host, overlayContainer, visible } = useDialogHost(props);\n const descendantsMayOpen = useDescendantsMayOpen(visible);\n const overlayHost = useMemo(\n () => ({ id: host.id, open: visible, stackZIndex: host.zIndex }),\n [host.id, visible, host.zIndex],\n );\n return (\n <DialogStackContext value={host.zIndex}>\n <OverlayHostContext value={overlayHost}>\n <DescendantsMayOpenContext value={descendantsMayOpen}>\n <OverlayContainerScope host={overlayContainer}>\n {createElement(render, { ...props, visible, host })}\n </OverlayContainerScope>\n </DescendantsMayOpenContext>\n </OverlayHostContext>\n </DialogStackContext>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAM,gBAAgB,GAAG,CAAC,KAAkB,EAAE,QAAgB,EAAE,gBAAyB,KAAI;AACzF,IAAA,MAAM,EAAE,mBAAmB,EAAE,GAAG,yBAAyB,EAAE;IAC3D,MAAM,EAAE,aAAa,EAAE,uBAAuB,GAAG,KAAK,EAAE,GAAG,KAAK;AAChE,IAAA,MAAM,gBAAgB,GAClB,aAAa,IAAI,IAAI,KAAK,mBAAmB,KAAK,SAAS,IAAI,CAAC,uBAAuB,CAAC;AAC5F,IAAA,IAAI,CAAC,gBAAgB;AAAE,QAAA,OAAO,IAAI;IAClC,QACIA,IAAC,aAAa,EAAA,EACV,QAAQ,EAAE,QAAQ,EAClB,K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AE,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,EAChE,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAClC;IACD,QACIA,IAAC,kBAAkB,EAAA,EAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAA,QAAA,EAClCA,GAAA,CAAC,kBAAkB,EAAA,EAAC,KAAK,EAAE,WAAW,EAAA,QAAA,EAClCA,IAAC,yBAAyB,EAAA,EAAC,KAAK,EAAE,kBAAkB,EAAA,QAAA,EAChDA,IAAC,qBAAqB,EAAA,EAAC,IAAI,EAAE,gBAAgB,YACxC,aAAa,CAAC,MAAM,EAAE,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,GAC/B,EAAA,CACA,EAAA,CACX,EAAA,CACJ;AAE7B;;"}
1
+ {"version":3,"file":"DialogSlotHost.js","sources":["../../../Dialogs/DialogSlotHost.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DialogButtons, DialogResult } from '@cratis/arc.react/dialogs';\nimport { createContext, createElement, use, useEffect, useId, useMemo, useState, type ComponentType } from 'react';\nimport { useCratisComponentsConfig } from '../Common/CratisComponentsProvider';\nimport { useCratisIcon } from '../configuration/useCratisIcon';\nimport { DIALOG_ZINDEX_TOKEN } from '../renderer/dialogStack';\nimport { DialogStackContext, OverlayHostContext } from '../renderer/DialogStackContext';\nimport { OverlayContainerScope, useOverlayContainer } from '../renderer/OverlayContainerScope';\nimport type { DialogProps } from './Dialog';\nimport { dismissalFor, resolveInitialFocus } from './dialogBehavior';\nimport { DialogContent, LiveRegion } from './DialogDocument';\nimport { DialogFooter } from './DialogFooter';\nimport { HeaderActions } from './DialogHeader';\nimport type { CratisDialogDismissSource, CratisDialogHost, CratisDialogHostDismissal, CratisDialogSlotProps } from './DialogHost';\nimport { DialogInitialFocus } from './DialogInitialFocus';\nimport { resolveDialogLabels } from './resolveDialogLabels';\nimport { useDialogClose } from './useDialogClose';\nimport { useDialogFocus } from './useDialogFocus';\nimport { useDialogZIndex } from './useDialogZIndex';\n\nconst useHeaderActions = (props: DialogProps, dialogId: string, showsCloseButton: boolean) => {\n const { dialogHeaderActions } = useCratisComponentsConfig();\n const { headerActions, hideGlobalHeaderActions = false } = props;\n const hasHeaderActions =\n headerActions != null || (dialogHeaderActions !== undefined && !hideGlobalHeaderActions);\n if (!hasHeaderActions) return null;\n return (\n <HeaderActions\n dialogId={dialogId}\n title={props.title}\n headerActions={headerActions}\n globalHeaderActions={dialogHeaderActions}\n hideGlobalHeaderActions={hideGlobalHeaderActions}\n isCommandDialog={props.isCommandDialog ?? false}\n sliceLocation={props.sliceLocation}\n showsCloseButton={showsCloseButton}\n pt={props.pt}\n />\n );\n};\n\n// Whether the adapter dialogs rendered inside may open: false until the nearest adapter dialog has\n// committed its own open state, so modals open parent-first, and false as soon as it hides.\nconst DescendantsMayOpenContext = createContext(true);\n\n// Passive effects run children-first, so this runs after the adapter dialog below opened itself.\nconst useDescendantsMayOpen = (visible: boolean) => {\n const [opened, setOpened] = useState(false);\n useEffect(() => setOpened(visible), [visible]);\n return visible && opened;\n};\n\ninterface DismissGuard {\n readonly visible: boolean;\n readonly isBusy: boolean;\n readonly dismissal: CratisDialogHostDismissal;\n}\n\nconst mayDismiss = ({ visible, isBusy, dismissal }: DismissGuard, source: CratisDialogDismissSource) =>\n visible && !isBusy && dismissal[source];\n\n/**\n * Builds the Components-owned host of one adapter-rendered dialog: its stack tier, the dialog\n * result flow, the footer and header actions, initial focus and the refused-confirmation\n * announcement, plus the overlay container its descendants portal through.\n * @param props The dialog's public props.\n * @returns The host handed to the adapter and the overlay container for its descendants.\n */\nexport const useDialogHost = (props: DialogProps) => {\n const { isBusy = false, buttons = DialogButtons.OkCancel, subtitle } = props;\n // A dialog nested in a hidden or still-opening adapter dialog stays closed until its parent is open.\n const visible = (props.visible ?? true) && use(DescendantsMayOpenContext);\n const { messages } = useCratisComponentsConfig();\n const icon = useCratisIcon();\n const id = useId();\n const subtitleId = useId();\n const labels = resolveDialogLabels(props, messages?.dialog);\n const initialFocus = resolveInitialFocus(props.initialFocus ?? DialogInitialFocus.Confirm, buttons);\n const { allowsOutsideDismissal, allowsEscapeDismissal, showsCloseButton } = dismissalFor(props, isBusy);\n const dismissal = { outside: allowsOutsideDismissal, escape: allowsEscapeDismissal, closeButton: showsCloseButton };\n const zIndex = useDialogZIndex(visible) ?? DIALOG_ZINDEX_TOKEN;\n const overlayContainer = useOverlayContainer(visible);\n const { titleRef, confirmRef, cancelRef, announcement, onRefused } = useDialogFocus({\n visible,\n isBusy,\n initialFocus,\n refusedMessage: labels.refused,\n refusalFeedback: props.refusalFeedback,\n });\n const handleClose = useDialogClose(props, onRefused);\n\n const host: CratisDialogHost = {\n id,\n zIndex,\n dismissal,\n closeAriaLabel: labels.closeAria,\n closeIcon: icon('close', '×', props.closeIcon),\n subtitleId,\n hasSubtitle: subtitle !== undefined && subtitle !== null && subtitle !== false,\n titleRef,\n content: (\n <DialogContent visible={visible} isBusy={isBusy} contentStyle={props.contentStyle} pt={props.pt}>\n {props.children}\n </DialogContent>\n ),\n headerActions: useHeaderActions(props, id, showsCloseButton),\n footer:\n buttons === null ? null : (\n <DialogFooter\n buttons={buttons}\n labels={labels}\n focus={{\n confirm: initialFocus === DialogInitialFocus.Confirm,\n dismissing: initialFocus === DialogInitialFocus.Cancel,\n }}\n isBusy={isBusy}\n isValid={props.isValid !== false}\n pt={props.pt}\n confirmRef={confirmRef}\n cancelRef={cancelRef}\n onResult={(result) => void handleClose(result)}\n />\n ),\n liveRegion: <LiveRegion announcement={announcement} />,\n dismiss: (source) => {\n if (mayDismiss({ visible, isBusy, dismissal }, source)) void handleClose(DialogResult.Cancelled);\n },\n registerOverlayContainer: overlayContainer.register,\n };\n\n return { host, overlayContainer, visible };\n};\n\n/** Props of {@link DialogSlotHost}. */\nexport interface DialogSlotHostProps {\n /** The adapter's dialog implementation. */\n readonly render: ComponentType<CratisDialogSlotProps>;\n /** The dialog's public props. */\n readonly props: DialogProps;\n}\n\n/**\n * Renders an adapter-owned dialog with its Components-owned host. Descendants read this dialog's\n * stack tier, see it as their overlay host, and portal through the overlay element the adapter\n * registered.\n */\nexport const DialogSlotHost = ({ render, props }: DialogSlotHostProps) => {\n const { host, overlayContainer, visible } = useDialogHost(props);\n const descendantsMayOpen = useDescendantsMayOpen(visible);\n const overlayHost = useMemo(\n () => ({ id: host.id, open: visible, stackZIndex: host.zIndex }),\n [host.id, visible, host.zIndex],\n );\n return (\n <DialogStackContext value={host.zIndex}>\n <OverlayHostContext value={overlayHost}>\n <DescendantsMayOpenContext value={descendantsMayOpen}>\n <OverlayContainerScope host={overlayContainer}>\n {createElement(render, { ...props, visible, host })}\n </OverlayContainerScope>\n </DescendantsMayOpenContext>\n </OverlayHostContext>\n </DialogStackContext>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAM,gBAAgB,GAAG,CAAC,KAAkB,EAAE,QAAgB,EAAE,gBAAyB,KAAI;AACzF,IAAA,MAAM,EAAE,mBAAmB,EAAE,GAAG,yBAAyB,EAAE;IAC3D,MAAM,EAAE,aAAa,EAAE,uBAAuB,GAAG,KAAK,EAAE,GAAG,KAAK;AAChE,IAAA,MAAM,gBAAgB,GAClB,aAAa,IAAI,IAAI,KAAK,mBAAmB,KAAK,SAAS,IAAI,CAAC,uBAAuB,CAAC;AAC5F,IAAA,IAAI,CAAC,gBAAgB;AAAE,QAAA,OAAO,IAAI;IAClC,QACIA,IAAC,aAAa,EAAA,EACV,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,aAAa,EAAE,aAAa,EAC5B,mBAAmB,EAAE,mBAAmB,EACxC,uBAAuB,EAAE,uBAAuB,EAChD,eAAe,EAAE,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,CAAC,EAChE,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAClC;IACD,QACIA,IAAC,kBAAkB,EAAA,EAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAA,QAAA,EAClCA,GAAA,CAAC,kBAAkB,EAAA,EAAC,KAAK,EAAE,WAAW,EAAA,QAAA,EAClCA,IAAC,yBAAyB,EAAA,EAAC,KAAK,EAAE,kBAAkB,EAAA,QAAA,EAChDA,IAAC,qBAAqB,EAAA,EAAC,IAAI,EAAE,gBAAgB,YACxC,aAAa,CAAC,MAAM,EAAE,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,GAC/B,EAAA,CACA,EAAA,CACX,EAAA,CACJ;AAE7B;;"}
@@ -2,6 +2,7 @@ export * from './BusyIndicatorDialog.js';
2
2
  export * from './ConfirmationDialog.js';
3
3
  export * from './Dialog.js';
4
4
  export * from './DialogInitialFocus.js';
5
+ export type { DialogRefusalFeedback } from './DialogRefusalFeedback.js';
5
6
  export type { CratisDialogDismissSource, CratisDialogHost, CratisDialogHostDismissal, CratisDialogSlotProps, } from './DialogHost.js';
6
7
  export type { DialogHeaderContext } from '../configuration/DialogHeaderContext.js';
7
8
  export type { DialogHeaderActionsRenderer } from '../configuration/DialogHeaderActionsRenderer.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../Dialogs/index.ts"],"names":[],"mappings":"AAGA,cAAc,0BAAuB,CAAC;AACtC,cAAc,yBAAsB,CAAC;AACrC,cAAc,aAAU,CAAC;AACzB,cAAc,yBAAsB,CAAC;AACrC,YAAY,EACR,yBAAyB,EACzB,gBAAgB,EAChB,yBAAyB,EACzB,qBAAqB,GACxB,MAAM,iBAAc,CAAC;AACtB,YAAY,EAAE,mBAAmB,EAAE,MAAM,yCAAsC,CAAC;AAChF,YAAY,EAAE,2BAA2B,EAAE,MAAM,iDAA8C,CAAC;AAChG,YAAY,EAAE,mBAAmB,EAAE,MAAM,yCAAsC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../Dialogs/index.ts"],"names":[],"mappings":"AAGA,cAAc,0BAAuB,CAAC;AACtC,cAAc,yBAAsB,CAAC;AACrC,cAAc,aAAU,CAAC;AACzB,cAAc,yBAAsB,CAAC;AACrC,YAAY,EAAE,qBAAqB,EAAE,MAAM,4BAAyB,CAAC;AACrE,YAAY,EACR,yBAAyB,EACzB,gBAAgB,EAChB,yBAAyB,EACzB,qBAAqB,GACxB,MAAM,iBAAc,CAAC;AACtB,YAAY,EAAE,mBAAmB,EAAE,MAAM,yCAAsC,CAAC;AAChF,YAAY,EAAE,2BAA2B,EAAE,MAAM,iDAA8C,CAAC;AAChG,YAAY,EAAE,mBAAmB,EAAE,MAAM,yCAAsC,CAAC"}
@@ -1,9 +1,11 @@
1
1
  import { DialogInitialFocus } from './DialogInitialFocus.js';
2
+ import type { DialogRefusalFeedback } from './DialogRefusalFeedback.js';
2
3
  interface DialogFocusOptions {
3
4
  visible: boolean;
4
5
  isBusy: boolean;
5
6
  initialFocus: DialogInitialFocus;
6
7
  refusedMessage: string;
8
+ refusalFeedback?: () => DialogRefusalFeedback | undefined;
7
9
  }
8
10
  interface Announcement {
9
11
  key: number;
@@ -12,10 +14,11 @@ interface Announcement {
12
14
  /**
13
15
  * Owns the dialog's focus behavior: initial focus, keeping focus off `<body>` while work is in
14
16
  * flight, and returning focus and announcing the outcome after a refused confirm.
15
- * @param options The dialog's visibility, busy state, resolved initial focus and refusal message.
17
+ * @param options The dialog's visibility, busy state, resolved initial focus, refusal message and
18
+ * optional refusal feedback that replaces the announced text and focus target.
16
19
  * @returns The refs to attach to title and buttons, the live-region announcement and a refusal notifier.
17
20
  */
18
- export declare const useDialogFocus: ({ visible, isBusy, initialFocus, refusedMessage }: DialogFocusOptions) => {
21
+ export declare const useDialogFocus: ({ visible, isBusy, initialFocus, refusedMessage, refusalFeedback, }: DialogFocusOptions) => {
19
22
  titleRef: import("react").RefObject<HTMLHeadingElement | null>;
20
23
  confirmRef: import("react").RefObject<HTMLButtonElement | null>;
21
24
  cancelRef: import("react").RefObject<HTMLButtonElement | null>;
@@ -1 +1 @@
1
- {"version":3,"file":"useDialogFocus.d.ts","sourceRoot":"","sources":["../../../Dialogs/useDialogFocus.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAsB,CAAC;AAE1D,UAAU,kBAAkB;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,kBAAkB,CAAC;IACjC,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED,UAAU,YAAY;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CAChB;AAQD;;;;;GAKG;AACH,eAAO,MAAM,cAAc,sDAAuD,kBAAkB;;;;;;CAgDnG,CAAC"}
1
+ {"version":3,"file":"useDialogFocus.d.ts","sourceRoot":"","sources":["../../../Dialogs/useDialogFocus.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAAyB,CAAC;AAErE,UAAU,kBAAkB;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,kBAAkB,CAAC;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,qBAAqB,GAAG,SAAS,CAAC;CAC7D;AAED,UAAU,YAAY;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CAChB;AAmBD;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,wEAMxB,kBAAkB;;;;;;CAmDpB,CAAC"}
@@ -7,13 +7,23 @@ const focusTitle = (title) => {
7
7
  title.tabIndex = -1;
8
8
  title.focus();
9
9
  };
10
- const useDialogFocus = ({ visible, isBusy, initialFocus, refusedMessage }) => {
10
+ const focusAfterRefusal = (target, confirm, title) => {
11
+ if (target)
12
+ target.focus();
13
+ else if (confirm && !confirm.disabled)
14
+ confirm.focus();
15
+ else
16
+ focusTitle(title);
17
+ };
18
+ const useDialogFocus = ({ visible, isBusy, initialFocus, refusedMessage, refusalFeedback, }) => {
11
19
  const titleRef = useRef(null);
12
20
  const confirmRef = useRef(null);
13
21
  const cancelRef = useRef(null);
14
22
  const [refusals, setRefusals] = useState(0);
15
23
  const handledRefusals = useRef(0);
16
24
  const [announcement, setAnnouncement] = useState(null);
25
+ const refusalFeedbackRef = useRef(refusalFeedback);
26
+ refusalFeedbackRef.current = refusalFeedback;
17
27
  useEffect(() => {
18
28
  if (!visible)
19
29
  return;
@@ -41,12 +51,9 @@ const useDialogFocus = ({ visible, isBusy, initialFocus, refusedMessage }) => {
41
51
  if (refusals === handledRefusals.current || isBusy)
42
52
  return;
43
53
  handledRefusals.current = refusals;
44
- const confirm = confirmRef.current;
45
- if (confirm && !confirm.disabled)
46
- confirm.focus();
47
- else
48
- focusTitle(titleRef.current);
49
- setAnnouncement({ key: refusals, text: refusedMessage });
54
+ const feedback = refusalFeedbackRef.current?.();
55
+ focusAfterRefusal(feedback?.focus, confirmRef.current, titleRef.current);
56
+ setAnnouncement({ key: refusals, text: feedback?.message ?? refusedMessage });
50
57
  }, [refusals, isBusy, refusedMessage]);
51
58
  const onRefused = () => setRefusals((count) => count + 1);
52
59
  return { titleRef, confirmRef, cancelRef, announcement, onRefused };
@@ -1 +1 @@
1
- {"version":3,"file":"useDialogFocus.js","sources":["../../../Dialogs/useDialogFocus.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useEffect, useRef, useState } from 'react';\nimport { DialogInitialFocus } from './DialogInitialFocus';\n\ninterface DialogFocusOptions {\n visible: boolean;\n isBusy: boolean;\n initialFocus: DialogInitialFocus;\n refusedMessage: string;\n}\n\ninterface Announcement {\n key: number;\n text: string;\n}\n\nconst focusTitle = (title: HTMLHeadingElement | null) => {\n if (!title) return;\n title.tabIndex = -1;\n title.focus();\n};\n\n/**\n * Owns the dialog's focus behavior: initial focus, keeping focus off `<body>` while work is in\n * flight, and returning focus and announcing the outcome after a refused confirm.\n * @param options The dialog's visibility, busy state, resolved initial focus and refusal message.\n * @returns The refs to attach to title and buttons, the live-region announcement and a refusal notifier.\n */\nexport const useDialogFocus = ({ visible, isBusy, initialFocus, refusedMessage }: DialogFocusOptions) => {\n const titleRef = useRef<HTMLHeadingElement>(null);\n const confirmRef = useRef<HTMLButtonElement>(null);\n const cancelRef = useRef<HTMLButtonElement>(null);\n const [refusals, setRefusals] = useState(0);\n const handledRefusals = useRef(0);\n const [announcement, setAnnouncement] = useState<Announcement | null>(null);\n\n useEffect(() => {\n if (!visible) return;\n // The title is a heading, so it is made programmatically focusable before it takes focus.\n const focusTarget =\n initialFocus === DialogInitialFocus.Confirm\n ? () => confirmRef.current?.focus()\n : initialFocus === DialogInitialFocus.Cancel\n ? () => cancelRef.current?.focus()\n : () => focusTitle(titleRef.current);\n const frame = requestAnimationFrame(focusTarget);\n return () => cancelAnimationFrame(frame);\n }, [initialFocus, visible]);\n\n // Keyboard focus must never be stranded on <body> while work is in flight: the confirm\n // button stays focusable (aria-disabled), and a focus held by a now-inert field moves to it.\n useEffect(() => {\n if (!visible || !isBusy) return;\n setAnnouncement(null);\n const active = document.activeElement;\n if (active && active !== document.body) return;\n if (confirmRef.current) confirmRef.current.focus();\n else focusTitle(titleRef.current);\n }, [isBusy, visible]);\n\n // A refused confirm (the dialog stays open) returns focus to the confirm button, or to the\n // title when confirm is not enabled, and announces the outcome through the live region.\n useEffect(() => {\n // Each refusal is handled once: a later busy-to-idle change, such as a successful retry,\n // must neither move focus nor announce the earlier refusal again.\n if (refusals === handledRefusals.current || isBusy) return;\n handledRefusals.current = refusals;\n const confirm = confirmRef.current;\n if (confirm && !confirm.disabled) confirm.focus();\n else focusTitle(titleRef.current);\n setAnnouncement({ key: refusals, text: refusedMessage });\n }, [refusals, isBusy, refusedMessage]);\n\n const onRefused = () => setRefusals((count) => count + 1);\n\n return { titleRef, confirmRef, cancelRef, announcement, onRefused };\n};\n"],"names":[],"mappings":";;;AAkBA,MAAM,UAAU,GAAG,CAAC,KAAgC,KAAI;AACpD,IAAA,IAAI,CAAC,KAAK;QAAE;AACZ,IAAA,KAAK,CAAC,QAAQ,GAAG,EAAE;IACnB,KAAK,CAAC,KAAK,EAAE;AACjB,CAAC;AAQM,MAAM,cAAc,GAAG,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,EAAsB,KAAI;AACpG,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAqB,IAAI,CAAC;AACjD,IAAA,MAAM,UAAU,GAAG,MAAM,CAAoB,IAAI,CAAC;AAClD,IAAA,MAAM,SAAS,GAAG,MAAM,CAAoB,IAAI,CAAC;IACjD,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;AAC3C,IAAA,MAAM,eAAe,GAAG,MAAM,CAAC,CAAC,CAAC;IACjC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAsB,IAAI,CAAC;IAE3E,SAAS,CAAC,MAAK;AACX,QAAA,IAAI,CAAC,OAAO;YAAE;AAEd,QAAA,MAAM,WAAW,GACb,YAAY,KAAK,kBAAkB,CAAC;cAC9B,MAAM,UAAU,CAAC,OAAO,EAAE,KAAK;AACjC,cAAE,YAAY,KAAK,kBAAkB,CAAC;kBAClC,MAAM,SAAS,CAAC,OAAO,EAAE,KAAK;kBAC9B,MAAM,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC;AAC9C,QAAA,MAAM,KAAK,GAAG,qBAAqB,CAAC,WAAW,CAAC;AAChD,QAAA,OAAO,MAAM,oBAAoB,CAAC,KAAK,CAA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ed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useEffect, useRef, useState } from 'react';\nimport { DialogInitialFocus } from './DialogInitialFocus';\nimport type { DialogRefusalFeedback } from './DialogRefusalFeedback';\n\ninterface DialogFocusOptions {\n visible: boolean;\n isBusy: boolean;\n initialFocus: DialogInitialFocus;\n refusedMessage: string;\n refusalFeedback?: () => DialogRefusalFeedback | undefined;\n}\n\ninterface Announcement {\n key: number;\n text: string;\n}\n\nconst focusTitle = (title: HTMLHeadingElement | null) => {\n if (!title) return;\n title.tabIndex = -1;\n title.focus();\n};\n\n// After a refusal, focus goes to the feedback's target, else the enabled confirm button, else the title.\nconst focusAfterRefusal = (\n target: HTMLElement | null | undefined,\n confirm: HTMLButtonElement | null,\n title: HTMLHeadingElement | null,\n) => {\n if (target) target.focus();\n else if (confirm && !confirm.disabled) confirm.focus();\n else focusTitle(title);\n};\n\n/**\n * Owns the dialog's focus behavior: initial focus, keeping focus off `<body>` while work is in\n * flight, and returning focus and announcing the outcome after a refused confirm.\n * @param options The dialog's visibility, busy state, resolved initial focus, refusal message and\n * optional refusal feedback that replaces the announced text and focus target.\n * @returns The refs to attach to title and buttons, the live-region announcement and a refusal notifier.\n */\nexport const useDialogFocus = ({\n visible,\n isBusy,\n initialFocus,\n refusedMessage,\n refusalFeedback,\n}: DialogFocusOptions) => {\n const titleRef = useRef<HTMLHeadingElement>(null);\n const confirmRef = useRef<HTMLButtonElement>(null);\n const cancelRef = useRef<HTMLButtonElement>(null);\n const [refusals, setRefusals] = useState(0);\n const handledRefusals = useRef(0);\n const [announcement, setAnnouncement] = useState<Announcement | null>(null);\n // Held in a ref so a new callback identity each render does not re-run the refusal effect.\n const refusalFeedbackRef = useRef(refusalFeedback);\n refusalFeedbackRef.current = refusalFeedback;\n\n useEffect(() => {\n if (!visible) return;\n // The title is a heading, so it is made programmatically focusable before it takes focus.\n const focusTarget =\n initialFocus === DialogInitialFocus.Confirm\n ? () => confirmRef.current?.focus()\n : initialFocus === DialogInitialFocus.Cancel\n ? () => cancelRef.current?.focus()\n : () => focusTitle(titleRef.current);\n const frame = requestAnimationFrame(focusTarget);\n return () => cancelAnimationFrame(frame);\n }, [initialFocus, visible]);\n\n // Keyboard focus must never be stranded on <body> while work is in flight: the confirm\n // button stays focusable (aria-disabled), and a focus held by a now-inert field moves to it.\n useEffect(() => {\n if (!visible || !isBusy) return;\n setAnnouncement(null);\n const active = document.activeElement;\n if (active && active !== document.body) return;\n if (confirmRef.current) confirmRef.current.focus();\n else focusTitle(titleRef.current);\n }, [isBusy, visible]);\n\n // A refused confirm (the dialog stays open) returns focus to the confirm button, or to the\n // title when confirm is not enabled, and announces the outcome through the live region.\n // Refusal feedback, when given, replaces the focus target and the announced text.\n useEffect(() => {\n // Each refusal is handled once: a later busy-to-idle change, such as a successful retry,\n // must neither move focus nor announce the earlier refusal again.\n if (refusals === handledRefusals.current || isBusy) return;\n handledRefusals.current = refusals;\n const feedback = refusalFeedbackRef.current?.();\n focusAfterRefusal(feedback?.focus, confirmRef.current, titleRef.current);\n setAnnouncement({ key: refusals, text: feedback?.message ?? refusedMessage });\n }, [refusals, isBusy, refusedMessage]);\n\n const onRefused = () => setRefusals((count) => count + 1);\n\n return { titleRef, confirmRef, cancelRef, announcement, onRefused };\n};\n"],"names":[],"mappings":";;;AAoBA,MAAM,UAAU,GAAG,CAAC,KAAgC,KAAI;AACpD,IAAA,IAAI,CAAC,KAAK;QAAE;AACZ,IAAA,KAAK,CAAC,QAAQ,GAAG,EAAE;IACnB,KAAK,CAAC,KAAK,EAAE;AACjB,CAAC;AAGD,MAAM,iBAAiB,GAAG,CACtB,MAAsC,EACtC,OAAiC,EACjC,KAAgC,KAChC;AACA,IAAA,IAAI,MAAM;QAAE,MAAM,CAAC,KAAK,EAAE;AACrB,SAAA,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ;QAAE,OAAO,CAAC,KAAK,EAAE;;QACjD,UAAU,CAAC,KAAK,CAAC;AAC1B,CAAC;AASM,MAA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CAAC,IAAI;YAAE;QACxC,IAAI,UAAU,CAAC,OAAO;AAAE,YAAA,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE;;AAC7C,YAAA,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC;AACrC,IAAA,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAKrB,SAAS,CAAC,MAAK;AAGX,QAAA,IAAI,QAAQ,KAAK,eAAe,CAAC,OAAO,IAAI,MAAM;YAAE;AACpD,QAAA,eAAe,CAAC,OAAO,GAAG,QAAQ;AAClC,QAAA,MAAM,QAAQ,GAAG,kBAAkB,CAAC,OAAO,IAAI;AAC/C,QAAA,iBAAiB,CAAC,QAAQ,EAAE,KAAK,EAAE,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC;AACxE,QAAA,eAAe,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,IAAI,cAAc,EAAE,CAAC;IACjF,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC;AAEtC,IAAA,MAAM,SAAS,GAAG,MAAM,WAAW,CAAC,CAAC,KAAK,KAAK,KAAK,GAAG,CAAC,CAAC;IAEzD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE;AACvE;;"}
@@ -1517,6 +1517,72 @@
1517
1517
  text-align: center;
1518
1518
  }
1519
1519
 
1520
+ .cratis-datatable__cards {
1521
+ display: grid;
1522
+ gap: 1rem;
1523
+ padding: 0.5rem;
1524
+ margin: 0;
1525
+ list-style: none;
1526
+ }
1527
+ .cratis-datatable__card {
1528
+ min-width: 0;
1529
+ padding: 1rem;
1530
+ border: 1px solid var(--cratis-surface-border);
1531
+ border-radius: var(--cratis-border-radius);
1532
+ background: var(--cratis-surface-card);
1533
+ overflow-wrap: anywhere;
1534
+ }
1535
+ .cratis-datatable__card[data-interactive='true']:hover {
1536
+ background: var(--cratis-surface-hover);
1537
+ }
1538
+ .cratis-datatable__card[data-selected='true'] {
1539
+ background: var(--cratis-highlight-bg);
1540
+ color: var(--cratis-highlight-text-color);
1541
+ }
1542
+ .cratis-datatable__card:focus-visible {
1543
+ outline: var(--cratis-focus-outline);
1544
+ outline-offset: var(--cratis-focus-outline-offset);
1545
+ box-shadow: var(--cratis-focus-ring);
1546
+ }
1547
+ .cratis-datatable__card dl {
1548
+ display: grid;
1549
+ gap: 0.75rem;
1550
+ margin: 0;
1551
+ }
1552
+ .cratis-datatable__card-field {
1553
+ min-width: 0;
1554
+ }
1555
+ .cratis-datatable__card-label {
1556
+ font-size: var(--cratis-font-size-sm);
1557
+ font-weight: var(--cratis-type-weight-bold);
1558
+ }
1559
+ .cratis-datatable__card-value {
1560
+ min-width: 0;
1561
+ margin: 0;
1562
+ }
1563
+ .cratis-datatable__card-controls {
1564
+ display: flex;
1565
+ flex-wrap: wrap;
1566
+ align-items: center;
1567
+ gap: 1rem;
1568
+ padding: 0.5rem;
1569
+ }
1570
+ .cratis-datatable__card-status {
1571
+ padding: 2rem 1rem;
1572
+ color: var(--cratis-text-color-secondary);
1573
+ text-align: center;
1574
+ }
1575
+ @media (forced-colors: active) {
1576
+ .cratis-datatable__card {
1577
+ border-color: CanvasText;
1578
+ }
1579
+ .cratis-datatable__card[data-selected='true'],
1580
+ .cratis-datatable__card:focus-visible {
1581
+ outline: 2px solid Highlight;
1582
+ box-shadow: none;
1583
+ }
1584
+ }
1585
+
1520
1586
  @media (prefers-reduced-motion: reduce) {
1521
1587
  .cratis-datatable__row {
1522
1588
  transition: none;
@@ -1316,6 +1316,72 @@
1316
1316
  text-align: center;
1317
1317
  }
1318
1318
 
1319
+ .cratis-datatable__cards {
1320
+ display: grid;
1321
+ gap: 1rem;
1322
+ padding: 0.5rem;
1323
+ margin: 0;
1324
+ list-style: none;
1325
+ }
1326
+ .cratis-datatable__card {
1327
+ min-width: 0;
1328
+ padding: 1rem;
1329
+ border: 1px solid var(--cratis-surface-border);
1330
+ border-radius: var(--cratis-border-radius);
1331
+ background: var(--cratis-surface-card);
1332
+ overflow-wrap: anywhere;
1333
+ }
1334
+ .cratis-datatable__card[data-interactive='true']:hover {
1335
+ background: var(--cratis-surface-hover);
1336
+ }
1337
+ .cratis-datatable__card[data-selected='true'] {
1338
+ background: var(--cratis-highlight-bg);
1339
+ color: var(--cratis-highlight-text-color);
1340
+ }
1341
+ .cratis-datatable__card:focus-visible {
1342
+ outline: var(--cratis-focus-outline);
1343
+ outline-offset: var(--cratis-focus-outline-offset);
1344
+ box-shadow: var(--cratis-focus-ring);
1345
+ }
1346
+ .cratis-datatable__card dl {
1347
+ display: grid;
1348
+ gap: 0.75rem;
1349
+ margin: 0;
1350
+ }
1351
+ .cratis-datatable__card-field {
1352
+ min-width: 0;
1353
+ }
1354
+ .cratis-datatable__card-label {
1355
+ font-size: var(--cratis-font-size-sm);
1356
+ font-weight: var(--cratis-type-weight-bold);
1357
+ }
1358
+ .cratis-datatable__card-value {
1359
+ min-width: 0;
1360
+ margin: 0;
1361
+ }
1362
+ .cratis-datatable__card-controls {
1363
+ display: flex;
1364
+ flex-wrap: wrap;
1365
+ align-items: center;
1366
+ gap: 1rem;
1367
+ padding: 0.5rem;
1368
+ }
1369
+ .cratis-datatable__card-status {
1370
+ padding: 2rem 1rem;
1371
+ color: var(--cratis-text-color-secondary);
1372
+ text-align: center;
1373
+ }
1374
+ @media (forced-colors: active) {
1375
+ .cratis-datatable__card {
1376
+ border-color: CanvasText;
1377
+ }
1378
+ .cratis-datatable__card[data-selected='true'],
1379
+ .cratis-datatable__card:focus-visible {
1380
+ outline: 2px solid Highlight;
1381
+ box-shadow: none;
1382
+ }
1383
+ }
1384
+
1319
1385
  @media (prefers-reduced-motion: reduce) {
1320
1386
  .cratis-datatable__row {
1321
1387
  transition: none;