@cratis/components 4.42.0 → 4.42.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (249) hide show
  1. package/compat-manifest.json +11 -11
  2. package/dist/esm/Canvas/Canvas.d.ts.map +1 -1
  3. package/dist/esm/Canvas/Canvas.js +16 -109
  4. package/dist/esm/Canvas/Canvas.js.map +1 -1
  5. package/dist/esm/Canvas/CanvasWorldLayers.d.ts +22 -0
  6. package/dist/esm/Canvas/CanvasWorldLayers.d.ts.map +1 -0
  7. package/dist/esm/Canvas/CanvasWorldLayers.js +27 -0
  8. package/dist/esm/Canvas/CanvasWorldLayers.js.map +1 -0
  9. package/dist/esm/Canvas/useCanvasSurface.d.ts +57 -0
  10. package/dist/esm/Canvas/useCanvasSurface.d.ts.map +1 -0
  11. package/dist/esm/Canvas/useCanvasSurface.js +112 -0
  12. package/dist/esm/Canvas/useCanvasSurface.js.map +1 -0
  13. package/dist/esm/Chat/ChatSidebar.d.ts +2 -2
  14. package/dist/esm/Chat/ChatSidebar.d.ts.map +1 -1
  15. package/dist/esm/Chat/ChatSidebar.js +21 -101
  16. package/dist/esm/Chat/ChatSidebar.js.map +1 -1
  17. package/dist/esm/Chat/ChatSidebarContent.d.ts +25 -0
  18. package/dist/esm/Chat/ChatSidebarContent.d.ts.map +1 -0
  19. package/dist/esm/Chat/ChatSidebarContent.js +12 -0
  20. package/dist/esm/Chat/ChatSidebarContent.js.map +1 -0
  21. package/dist/esm/Chat/ChatSidebarHeader.d.ts +16 -0
  22. package/dist/esm/Chat/ChatSidebarHeader.d.ts.map +1 -0
  23. package/dist/esm/Chat/ChatSidebarHeader.js +26 -0
  24. package/dist/esm/Chat/ChatSidebarHeader.js.map +1 -0
  25. package/dist/esm/Chat/ChatSidebarShells.d.ts +31 -0
  26. package/dist/esm/Chat/ChatSidebarShells.d.ts.map +1 -0
  27. package/dist/esm/Chat/ChatSidebarShells.js +43 -0
  28. package/dist/esm/Chat/ChatSidebarShells.js.map +1 -0
  29. package/dist/esm/Chat/useNonModalPhase.d.ts +16 -0
  30. package/dist/esm/Chat/useNonModalPhase.d.ts.map +1 -0
  31. package/dist/esm/Chat/useNonModalPhase.js +38 -0
  32. package/dist/esm/Chat/useNonModalPhase.js.map +1 -0
  33. package/dist/esm/Chat/useTopicSelection.d.ts +31 -0
  34. package/dist/esm/Chat/useTopicSelection.d.ts.map +1 -0
  35. package/dist/esm/Chat/useTopicSelection.js +45 -0
  36. package/dist/esm/Chat/useTopicSelection.js.map +1 -0
  37. package/dist/esm/CommandDialog/CommandStepperContent.d.ts.map +1 -1
  38. package/dist/esm/CommandDialog/CommandStepperContent.js +31 -119
  39. package/dist/esm/CommandDialog/CommandStepperContent.js.map +1 -1
  40. package/dist/esm/CommandDialog/CommandStepperList.d.ts +19 -0
  41. package/dist/esm/CommandDialog/CommandStepperList.d.ts.map +1 -0
  42. package/dist/esm/CommandDialog/CommandStepperList.js +20 -0
  43. package/dist/esm/CommandDialog/CommandStepperList.js.map +1 -0
  44. package/dist/esm/CommandDialog/CommandStepperNavigation.d.ts +20 -0
  45. package/dist/esm/CommandDialog/CommandStepperNavigation.d.ts.map +1 -0
  46. package/dist/esm/CommandDialog/CommandStepperNavigation.js +15 -0
  47. package/dist/esm/CommandDialog/CommandStepperNavigation.js.map +1 -0
  48. package/dist/esm/CommandDialog/CommandStepperPanels.d.ts +20 -0
  49. package/dist/esm/CommandDialog/CommandStepperPanels.d.ts.map +1 -0
  50. package/dist/esm/CommandDialog/CommandStepperPanels.js +9 -0
  51. package/dist/esm/CommandDialog/CommandStepperPanels.js.map +1 -0
  52. package/dist/esm/CommandDialog/CommandStepperStepParts.d.ts +23 -0
  53. package/dist/esm/CommandDialog/CommandStepperStepParts.d.ts.map +1 -0
  54. package/dist/esm/CommandDialog/CommandStepperStepParts.js +9 -0
  55. package/dist/esm/CommandDialog/CommandStepperStepParts.js.map +1 -0
  56. package/dist/esm/CommandDialog/commandStepperFields.d.ts +6 -0
  57. package/dist/esm/CommandDialog/commandStepperFields.d.ts.map +1 -0
  58. package/dist/esm/CommandDialog/commandStepperFields.js +54 -0
  59. package/dist/esm/CommandDialog/commandStepperFields.js.map +1 -0
  60. package/dist/esm/CommandDialog/joinClassNames.d.ts +3 -0
  61. package/dist/esm/CommandDialog/joinClassNames.d.ts.map +1 -0
  62. package/dist/esm/CommandDialog/joinClassNames.js +4 -0
  63. package/dist/esm/CommandDialog/joinClassNames.js.map +1 -0
  64. package/dist/esm/CommandDialog/resolveStepperLabels.d.ts +20 -0
  65. package/dist/esm/CommandDialog/resolveStepperLabels.d.ts.map +1 -0
  66. package/dist/esm/CommandDialog/resolveStepperLabels.js +8 -0
  67. package/dist/esm/CommandDialog/resolveStepperLabels.js.map +1 -0
  68. package/dist/esm/CommandDialog/useStepValidation.d.ts +7 -0
  69. package/dist/esm/CommandDialog/useStepValidation.d.ts.map +1 -0
  70. package/dist/esm/CommandDialog/useStepValidation.js +14 -0
  71. package/dist/esm/CommandDialog/useStepValidation.js.map +1 -0
  72. package/dist/esm/CommandDialog/useStepperState.d.ts +30 -0
  73. package/dist/esm/CommandDialog/useStepperState.d.ts.map +1 -0
  74. package/dist/esm/CommandDialog/useStepperState.js +37 -0
  75. package/dist/esm/CommandDialog/useStepperState.js.map +1 -0
  76. package/dist/esm/CommandForm/fields/ChipsField.d.ts +1 -1
  77. package/dist/esm/CommandForm/fields/ChipsField.d.ts.map +1 -1
  78. package/dist/esm/CommandForm/fields/ChipsField.js +7 -39
  79. package/dist/esm/CommandForm/fields/ChipsField.js.map +1 -1
  80. package/dist/esm/CommandForm/fields/ChipsInput.d.ts +18 -0
  81. package/dist/esm/CommandForm/fields/ChipsInput.d.ts.map +1 -0
  82. package/dist/esm/CommandForm/fields/ChipsInput.js +12 -0
  83. package/dist/esm/CommandForm/fields/ChipsInput.js.map +1 -0
  84. package/dist/esm/CommandForm/fields/ChipsItem.d.ts +14 -0
  85. package/dist/esm/CommandForm/fields/ChipsItem.d.ts.map +1 -0
  86. package/dist/esm/CommandForm/fields/ChipsItem.js +14 -0
  87. package/dist/esm/CommandForm/fields/ChipsItem.js.map +1 -0
  88. package/dist/esm/CommandForm/fields/useChipsDraft.d.ts +19 -0
  89. package/dist/esm/CommandForm/fields/useChipsDraft.d.ts.map +1 -0
  90. package/dist/esm/CommandForm/fields/useChipsDraft.js +19 -0
  91. package/dist/esm/CommandForm/fields/useChipsDraft.js.map +1 -0
  92. package/dist/esm/Common/CratisComponentsProvider.d.ts.map +1 -1
  93. package/dist/esm/Common/CratisComponentsProvider.js +1 -44
  94. package/dist/esm/Common/CratisComponentsProvider.js.map +1 -1
  95. package/dist/esm/Common/legacyLocaleMessages.d.ts +7 -0
  96. package/dist/esm/Common/legacyLocaleMessages.d.ts.map +1 -0
  97. package/dist/esm/Common/legacyLocaleMessages.js +43 -0
  98. package/dist/esm/Common/legacyLocaleMessages.js.map +1 -0
  99. package/dist/esm/DataTables/ColumnFilterActions.d.ts +11 -0
  100. package/dist/esm/DataTables/ColumnFilterActions.d.ts.map +1 -0
  101. package/dist/esm/DataTables/ColumnFilterActions.js +8 -0
  102. package/dist/esm/DataTables/ColumnFilterActions.js.map +1 -0
  103. package/dist/esm/DataTables/ColumnFilterMenu.d.ts +1 -1
  104. package/dist/esm/DataTables/ColumnFilterMenu.d.ts.map +1 -1
  105. package/dist/esm/DataTables/ColumnFilterMenu.js +16 -148
  106. package/dist/esm/DataTables/ColumnFilterMenu.js.map +1 -1
  107. package/dist/esm/DataTables/ColumnFilterTrigger.d.ts +12 -0
  108. package/dist/esm/DataTables/ColumnFilterTrigger.d.ts.map +1 -0
  109. package/dist/esm/DataTables/ColumnFilterTrigger.js +9 -0
  110. package/dist/esm/DataTables/ColumnFilterTrigger.js.map +1 -0
  111. package/dist/esm/DataTables/ColumnFilterValueInput.d.ts +24 -0
  112. package/dist/esm/DataTables/ColumnFilterValueInput.d.ts.map +1 -0
  113. package/dist/esm/DataTables/ColumnFilterValueInput.js +39 -0
  114. package/dist/esm/DataTables/ColumnFilterValueInput.js.map +1 -0
  115. package/dist/esm/DataTables/DataTableCore.d.ts +1 -1
  116. package/dist/esm/DataTables/DataTableCore.d.ts.map +1 -1
  117. package/dist/esm/DataTables/DataTableCore.js +12 -66
  118. package/dist/esm/DataTables/DataTableCore.js.map +1 -1
  119. package/dist/esm/DataTables/DataTableHead.d.ts +23 -0
  120. package/dist/esm/DataTables/DataTableHead.d.ts.map +1 -0
  121. package/dist/esm/DataTables/DataTableHead.js +12 -0
  122. package/dist/esm/DataTables/DataTableHead.js.map +1 -0
  123. package/dist/esm/DataTables/DataTableRows.d.ts +19 -0
  124. package/dist/esm/DataTables/DataTableRows.d.ts.map +1 -0
  125. package/dist/esm/DataTables/DataTableRows.js +7 -0
  126. package/dist/esm/DataTables/DataTableRows.js.map +1 -0
  127. package/dist/esm/DataTables/DataTableTable.d.ts +20 -0
  128. package/dist/esm/DataTables/DataTableTable.d.ts.map +1 -0
  129. package/dist/esm/DataTables/DataTableTable.js +10 -0
  130. package/dist/esm/DataTables/DataTableTable.js.map +1 -0
  131. package/dist/esm/DataTables/columnFilterMatchModes.d.ts +10 -0
  132. package/dist/esm/DataTables/columnFilterMatchModes.d.ts.map +1 -0
  133. package/dist/esm/DataTables/columnFilterMatchModes.js +52 -0
  134. package/dist/esm/DataTables/columnFilterMatchModes.js.map +1 -0
  135. package/dist/esm/DataTables/resolveColumnFilterLabels.d.ts +4 -0
  136. package/dist/esm/DataTables/resolveColumnFilterLabels.d.ts.map +1 -0
  137. package/dist/esm/DataTables/resolveColumnFilterLabels.js +20 -0
  138. package/dist/esm/DataTables/resolveColumnFilterLabels.js.map +1 -0
  139. package/dist/esm/DataTables/useColumnFilterDraft.d.ts +13 -0
  140. package/dist/esm/DataTables/useColumnFilterDraft.d.ts.map +1 -0
  141. package/dist/esm/DataTables/useColumnFilterDraft.js +24 -0
  142. package/dist/esm/DataTables/useColumnFilterDraft.js.map +1 -0
  143. package/dist/esm/DataTables/useDataTableRows.d.ts +40 -0
  144. package/dist/esm/DataTables/useDataTableRows.d.ts.map +1 -0
  145. package/dist/esm/DataTables/useDataTableRows.js +49 -0
  146. package/dist/esm/DataTables/useDataTableRows.js.map +1 -0
  147. package/dist/esm/DataTables/useRestoreFocusOnClose.d.ts +7 -0
  148. package/dist/esm/DataTables/useRestoreFocusOnClose.d.ts.map +1 -0
  149. package/dist/esm/DataTables/useRestoreFocusOnClose.js +30 -0
  150. package/dist/esm/DataTables/useRestoreFocusOnClose.js.map +1 -0
  151. package/dist/esm/Dialogs/DialogDocument.d.ts +22 -0
  152. package/dist/esm/Dialogs/DialogDocument.d.ts.map +1 -0
  153. package/dist/esm/Dialogs/DialogDocument.js +24 -0
  154. package/dist/esm/Dialogs/DialogDocument.js.map +1 -0
  155. package/dist/esm/Dialogs/DialogFooter.d.ts +24 -0
  156. package/dist/esm/Dialogs/DialogFooter.d.ts.map +1 -0
  157. package/dist/esm/Dialogs/DialogFooter.js +65 -0
  158. package/dist/esm/Dialogs/DialogFooter.js.map +1 -0
  159. package/dist/esm/Dialogs/DialogHeader.d.ts +31 -0
  160. package/dist/esm/Dialogs/DialogHeader.d.ts.map +1 -0
  161. package/dist/esm/Dialogs/DialogHeader.js +28 -0
  162. package/dist/esm/Dialogs/DialogHeader.js.map +1 -0
  163. package/dist/esm/Dialogs/DialogImplementation.d.ts +1 -2
  164. package/dist/esm/Dialogs/DialogImplementation.d.ts.map +1 -1
  165. package/dist/esm/Dialogs/DialogImplementation.js +88 -189
  166. package/dist/esm/Dialogs/DialogImplementation.js.map +1 -1
  167. package/dist/esm/Dialogs/DialogShells.d.ts +29 -0
  168. package/dist/esm/Dialogs/DialogShells.d.ts.map +1 -0
  169. package/dist/esm/Dialogs/DialogShells.js +36 -0
  170. package/dist/esm/Dialogs/DialogShells.js.map +1 -0
  171. package/dist/esm/Dialogs/dialogPartAttributes.d.ts +19 -0
  172. package/dist/esm/Dialogs/dialogPartAttributes.d.ts.map +1 -0
  173. package/dist/esm/Dialogs/dialogPartAttributes.js +10 -0
  174. package/dist/esm/Dialogs/dialogPartAttributes.js.map +1 -0
  175. package/dist/esm/Dialogs/resolveDialogLabels.d.ts +29 -0
  176. package/dist/esm/Dialogs/resolveDialogLabels.d.ts.map +1 -0
  177. package/dist/esm/Dialogs/resolveDialogLabels.js +11 -0
  178. package/dist/esm/Dialogs/resolveDialogLabels.js.map +1 -0
  179. package/dist/esm/Dialogs/useDialogClose.d.ts +13 -0
  180. package/dist/esm/Dialogs/useDialogClose.d.ts.map +1 -0
  181. package/dist/esm/Dialogs/useDialogClose.js +32 -0
  182. package/dist/esm/Dialogs/useDialogClose.js.map +1 -0
  183. package/dist/esm/Dialogs/useDialogFocus.d.ts +26 -0
  184. package/dist/esm/Dialogs/useDialogFocus.d.ts.map +1 -0
  185. package/dist/esm/Dialogs/useDialogFocus.js +56 -0
  186. package/dist/esm/Dialogs/useDialogFocus.js.map +1 -0
  187. package/dist/esm/Dialogs/useDialogZIndex.d.ts +9 -0
  188. package/dist/esm/Dialogs/useDialogZIndex.d.ts.map +1 -0
  189. package/dist/esm/Dialogs/useDialogZIndex.js +19 -0
  190. package/dist/esm/Dialogs/useDialogZIndex.js.map +1 -0
  191. package/dist/esm/SchemaEditor/ReadOnlyTypeCell.d.ts +6 -0
  192. package/dist/esm/SchemaEditor/ReadOnlyTypeCell.d.ts.map +1 -0
  193. package/dist/esm/SchemaEditor/ReadOnlyTypeCell.js +19 -0
  194. package/dist/esm/SchemaEditor/ReadOnlyTypeCell.js.map +1 -0
  195. package/dist/esm/SchemaEditor/SchemaEditor.d.ts.map +1 -1
  196. package/dist/esm/SchemaEditor/SchemaEditor.js +44 -514
  197. package/dist/esm/SchemaEditor/SchemaEditor.js.map +1 -1
  198. package/dist/esm/SchemaEditor/SchemaEditorNavigation.d.ts +13 -0
  199. package/dist/esm/SchemaEditor/SchemaEditorNavigation.d.ts.map +1 -0
  200. package/dist/esm/SchemaEditor/SchemaEditorNavigation.js +36 -0
  201. package/dist/esm/SchemaEditor/SchemaEditorNavigation.js.map +1 -0
  202. package/dist/esm/SchemaEditor/SchemaEditorTable.d.ts +34 -0
  203. package/dist/esm/SchemaEditor/SchemaEditorTable.d.ts.map +1 -0
  204. package/dist/esm/SchemaEditor/SchemaEditorTable.js +54 -0
  205. package/dist/esm/SchemaEditor/SchemaEditorTable.js.map +1 -0
  206. package/dist/esm/SchemaEditor/TypeCell.d.ts.map +1 -1
  207. package/dist/esm/SchemaEditor/TypeCell.js +14 -80
  208. package/dist/esm/SchemaEditor/TypeCell.js.map +1 -1
  209. package/dist/esm/SchemaEditor/TypeCellActions.d.ts +13 -0
  210. package/dist/esm/SchemaEditor/TypeCellActions.d.ts.map +1 -0
  211. package/dist/esm/SchemaEditor/TypeCellActions.js +19 -0
  212. package/dist/esm/SchemaEditor/TypeCellActions.js.map +1 -0
  213. package/dist/esm/SchemaEditor/resolveTypeChange.d.ts +12 -0
  214. package/dist/esm/SchemaEditor/resolveTypeChange.d.ts.map +1 -0
  215. package/dist/esm/SchemaEditor/resolveTypeChange.js +19 -0
  216. package/dist/esm/SchemaEditor/resolveTypeChange.js.map +1 -0
  217. package/dist/esm/SchemaEditor/schemaDocument.d.ts +20 -0
  218. package/dist/esm/SchemaEditor/schemaDocument.d.ts.map +1 -0
  219. package/dist/esm/SchemaEditor/schemaDocument.js +70 -0
  220. package/dist/esm/SchemaEditor/schemaDocument.js.map +1 -0
  221. package/dist/esm/SchemaEditor/schemaEditorMenu.d.ts +30 -0
  222. package/dist/esm/SchemaEditor/schemaEditorMenu.d.ts.map +1 -0
  223. package/dist/esm/SchemaEditor/schemaEditorMenu.js +51 -0
  224. package/dist/esm/SchemaEditor/schemaEditorMenu.js.map +1 -0
  225. package/dist/esm/SchemaEditor/schemaPropertyEdits.d.ts +33 -0
  226. package/dist/esm/SchemaEditor/schemaPropertyEdits.d.ts.map +1 -0
  227. package/dist/esm/SchemaEditor/schemaPropertyEdits.js +134 -0
  228. package/dist/esm/SchemaEditor/schemaPropertyEdits.js.map +1 -0
  229. package/dist/esm/SchemaEditor/typeOptions.d.ts +11 -0
  230. package/dist/esm/SchemaEditor/typeOptions.d.ts.map +1 -0
  231. package/dist/esm/SchemaEditor/typeOptions.js +20 -0
  232. package/dist/esm/SchemaEditor/typeOptions.js.map +1 -0
  233. package/dist/esm/SchemaEditor/useSchemaDocument.d.ts +26 -0
  234. package/dist/esm/SchemaEditor/useSchemaDocument.d.ts.map +1 -0
  235. package/dist/esm/SchemaEditor/useSchemaDocument.js +65 -0
  236. package/dist/esm/SchemaEditor/useSchemaDocument.js.map +1 -0
  237. package/dist/esm/SchemaEditor/useSchemaEdits.d.ts +29 -0
  238. package/dist/esm/SchemaEditor/useSchemaEdits.d.ts.map +1 -0
  239. package/dist/esm/SchemaEditor/useSchemaEdits.js +50 -0
  240. package/dist/esm/SchemaEditor/useSchemaEdits.js.map +1 -0
  241. package/dist/esm/SchemaEditor/useSchemaNavigation.d.ts +15 -0
  242. package/dist/esm/SchemaEditor/useSchemaNavigation.d.ts.map +1 -0
  243. package/dist/esm/SchemaEditor/useSchemaNavigation.js +24 -0
  244. package/dist/esm/SchemaEditor/useSchemaNavigation.js.map +1 -0
  245. package/dist/esm/SchemaEditor/useSchemaRows.d.ts +17 -0
  246. package/dist/esm/SchemaEditor/useSchemaRows.d.ts.map +1 -0
  247. package/dist/esm/SchemaEditor/useSchemaRows.js +49 -0
  248. package/dist/esm/SchemaEditor/useSchemaRows.js.map +1 -0
  249. package/package.json +1 -1
@@ -0,0 +1,20 @@
1
+ const labelKeys = [
2
+ 'filterTriggerAriaLabel',
3
+ 'valueAriaLabel',
4
+ 'matchModeAriaLabel',
5
+ 'matchModeLabel',
6
+ 'clear',
7
+ 'apply',
8
+ 'true',
9
+ 'false',
10
+ ];
11
+ const resolveColumnFilterLabels = (labels, providerMessages, defaults) => {
12
+ const resolved = {};
13
+ for (const key of labelKeys) {
14
+ resolved[key] = labels?.[key] ?? providerMessages?.[key] ?? defaults[key];
15
+ }
16
+ return resolved;
17
+ };
18
+
19
+ export { resolveColumnFilterLabels };
20
+ //# sourceMappingURL=resolveColumnFilterLabels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveColumnFilterLabels.js","sources":["../../../DataTables/resolveColumnFilterLabels.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { ColumnFilterMenuLabels } from './ColumnFilterMenu';\n\nconst labelKeys: (keyof ColumnFilterMenuLabels)[] = [\n 'filterTriggerAriaLabel',\n 'valueAriaLabel',\n 'matchModeAriaLabel',\n 'matchModeLabel',\n 'clear',\n 'apply',\n 'true',\n 'false',\n];\n\n/** Each label comes from the explicit labels, else the provider messages, else the defaults. */\nexport const resolveColumnFilterLabels = (\n labels: Partial<ColumnFilterMenuLabels> | undefined,\n providerMessages: Partial<ColumnFilterMenuLabels> | undefined,\n defaults: ColumnFilterMenuLabels,\n): ColumnFilterMenuLabels => {\n const resolved: Record<string, unknown> = {};\n for (const key of labelKeys) {\n resolved[key] = labels?.[key] ?? providerMessages?.[key] ?? defaults[key];\n }\n return resolved as unknown as ColumnFilterMenuLabels;\n};\n"],"names":[],"mappings":"AAKA,MAAM,SAAS,GAAqC;IAChD,wBAAwB;IACxB,gBAAgB;IAChB,oBAAoB;IACpB,gBAAgB;IAChB,OAAO;IACP,OAAO;IACP,MAAM;IACN,OAAO;CACV;AAGM,MAAM,yBAAyB,GAAG,CACrC,MAAmD,EACnD,gBAA6D,EAC7D,QAAgC,KACR;IACxB,MAAM,QAAQ,GAA4B,EAAE;AAC5C,IAAA,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE;QACzB,QAAQ,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,GAAG,CAAC,IAAI,gBAAgB,GAAG,GAAG,CAAC,IAAI,QAAQ,CAAC,GAAG,CAAC;IAC7E;AACA,IAAA,OAAO,QAA6C;AACxD;;"}
@@ -0,0 +1,13 @@
1
+ import { type SyntheticEvent } from 'react';
2
+ import type { ColumnFilterDataType } from './ColumnFilterMenu.js';
3
+ import type { DataTableFilterConstraint, DataTableFilterMatchMode as FilterMatchMode } from './DataTableFilterMeta.js';
4
+ /** Holds the draft value and match mode of a column filter and the apply/clear actions over it. */
5
+ export declare const useColumnFilterDraft: (dataType: ColumnFilterDataType, constraint: DataTableFilterConstraint | undefined, onApply: (constraint: DataTableFilterConstraint) => void, onClear: () => void) => {
6
+ draftValue: unknown;
7
+ draftMode: FilterMatchMode;
8
+ setDraftValue: import("react").Dispatch<unknown>;
9
+ setDraftMode: import("react").Dispatch<import("react").SetStateAction<FilterMatchMode>>;
10
+ apply: (event?: SyntheticEvent) => void;
11
+ clear: (event?: SyntheticEvent) => void;
12
+ };
13
+ //# sourceMappingURL=useColumnFilterDraft.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useColumnFilterDraft.d.ts","sourceRoot":"","sources":["../../../DataTables/useColumnFilterDraft.ts"],"names":[],"mappings":"AAGA,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAoB,CAAC;AAE/D,OAAO,KAAK,EACR,yBAAyB,EACzB,wBAAwB,IAAI,eAAe,EAC9C,MAAM,0BAAuB,CAAC;AAE/B,mGAAmG;AACnG,eAAO,MAAM,oBAAoB,aACnB,oBAAoB,cAClB,yBAAyB,GAAG,SAAS,WACxC,CAAC,UAAU,EAAE,yBAAyB,KAAK,IAAI,WAC/C,MAAM,IAAI;;;;;oBAiBI,cAAc;oBALd,cAAc;CAWxC,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { useState, useEffect } from 'react';
2
+ import { defaultModeFor } from './columnFilterMatchModes.js';
3
+
4
+ const useColumnFilterDraft = (dataType, constraint, onApply, onClear) => {
5
+ const [draftValue, setDraftValue] = useState(constraint?.value ?? null);
6
+ const [draftMode, setDraftMode] = useState(constraint?.matchMode ?? defaultModeFor(dataType));
7
+ useEffect(() => {
8
+ setDraftValue(constraint?.value ?? null);
9
+ setDraftMode(constraint?.matchMode ?? defaultModeFor(dataType));
10
+ }, [constraint, dataType]);
11
+ const clear = (event) => {
12
+ setDraftValue(null);
13
+ onClear();
14
+ event?.preventDefault();
15
+ };
16
+ const apply = (event) => {
17
+ onApply({ value: draftValue, matchMode: draftMode });
18
+ event?.preventDefault();
19
+ };
20
+ return { draftValue, draftMode, setDraftValue, setDraftMode, apply, clear };
21
+ };
22
+
23
+ export { useColumnFilterDraft };
24
+ //# sourceMappingURL=useColumnFilterDraft.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useColumnFilterDraft.js","sources":["../../../DataTables/useColumnFilterDraft.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, useState, type SyntheticEvent } from 'react';\nimport type { ColumnFilterDataType } from './ColumnFilterMenu';\nimport { defaultModeFor } from './columnFilterMatchModes';\nimport type {\n DataTableFilterConstraint,\n DataTableFilterMatchMode as FilterMatchMode,\n} from './DataTableFilterMeta';\n\n/** Holds the draft value and match mode of a column filter and the apply/clear actions over it. */\nexport const useColumnFilterDraft = (\n dataType: ColumnFilterDataType,\n constraint: DataTableFilterConstraint | undefined,\n onApply: (constraint: DataTableFilterConstraint) => void,\n onClear: () => void,\n) => {\n const [draftValue, setDraftValue] = useState<unknown>(constraint?.value ?? null);\n const [draftMode, setDraftMode] = useState<FilterMatchMode>(\n constraint?.matchMode ?? defaultModeFor(dataType),\n );\n\n useEffect(() => {\n setDraftValue(constraint?.value ?? null);\n setDraftMode(constraint?.matchMode ?? defaultModeFor(dataType));\n }, [constraint, dataType]);\n\n const clear = (event?: SyntheticEvent) => {\n setDraftValue(null);\n onClear();\n event?.preventDefault();\n };\n const apply = (event?: SyntheticEvent) => {\n onApply({ value: draftValue, matchMode: draftMode });\n event?.preventDefault();\n };\n\n return { draftValue, draftMode, setDraftValue, setDraftMode, apply, clear };\n};\n"],"names":[],"mappings":";;;AAYO,MAAM,oBAAoB,GAAG,CAChC,QAA8B,EAC9B,UAAiD,EACjD,OAAwD,EACxD,OAAmB,KACnB;AACA,IAAA,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAU,UAAU,EAAE,KAAK,IAAI,IAAI,CAAC;AAChF,IAAA,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CACtC,UAAU,EAAE,SAAS,IAAI,cAAc,CAAC,QAAQ,CAAC,CACpD;IAED,SAAS,CAAC,MAAK;AACX,QAAA,aAAa,CAAC,UAAU,EAAE,KAAK,IAAI,IAAI,CAAC;QACxC,YAAY,CAAC,UAAU,EAAE,SAAS,IAAI,cAAc,CAAC,QAAQ,CAAC,CAAC;AACnE,IAAA,CAAC,EAAE,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AAE1B,IAAA,MAAM,KAAK,GAAG,CAAC,KAAsB,KAAI;QACrC,aAAa,CAAC,IAAI,CAAC;AACnB,QAAA,OAAO,EAAE;QACT,KAAK,EAAE,cAAc,EAAE;AAC3B,IAAA,CAAC;AACD,IAAA,MAAM,KAAK,GAAG,CAAC,KAAsB,KAAI;QACrC,OAAO,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;QACpD,KAAK,EAAE,cAAc,EAAE;AAC3B,IAAA,CAAC;AAED,IAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE;AAC/E;;"}
@@ -0,0 +1,40 @@
1
+ import { type SyntheticEvent } from 'react';
2
+ import type { DataTableFilterMeta } from './DataTableFilterMeta.js';
3
+ import type { DataTableRowClickEvent } from './DataTableRowClickEvent.js';
4
+ import { DataTableRowProcessing } from './DataTableRowProcessing.js';
5
+ import type { DataTableSelectionChangeEvent } from './DataTableSelectionChangeEvent.js';
6
+ import type { DataTableSort } from './DataTableSort.js';
7
+ import type { ProcessedRow } from './ProcessedRow.js';
8
+ import type { RowSelection } from './RowSelection.js';
9
+ /** What {@link useDataTableRows} needs from the table. */
10
+ export interface DataTableRowsSource<TData extends object> {
11
+ data: TData[];
12
+ dataKey?: string;
13
+ filters: DataTableFilterMeta;
14
+ globalFilter: string;
15
+ globalFilterFields?: string[];
16
+ sort: DataTableSort | null;
17
+ rowProcessing: DataTableRowProcessing;
18
+ selectionMode?: 'single' | 'multiple';
19
+ selection?: TData | null;
20
+ selectedItems?: TData[];
21
+ onSelectedItemsChange?: (items: TData[]) => void;
22
+ onSelectionChange?: (event: DataTableSelectionChangeEvent<TData>) => void;
23
+ onRowClick?: (event: DataTableRowClickEvent<TData>) => void;
24
+ }
25
+ /** The processed rows with their keys, selection and activation. */
26
+ export interface DataTableRowsState<TData extends object> extends RowSelection<TData> {
27
+ filteredRows: ProcessedRow<TData>[];
28
+ rowKeys: string[];
29
+ /** Whether a search or filter is active, so an empty result is a filtered one. */
30
+ isFiltered: boolean;
31
+ isInteractive: boolean;
32
+ activateRow: (row: TData, index: number, originalEvent: SyntheticEvent) => void;
33
+ }
34
+ /**
35
+ * Filters, sorts, keys and selects the rows of a DataTable.
36
+ * @param source The rows and the table state to work with.
37
+ * @returns The rows to show and the actions on them.
38
+ */
39
+ export declare const useDataTableRows: <TData extends object>({ data, dataKey, filters, globalFilter, globalFilterFields, sort, rowProcessing, selectionMode, selection, selectedItems, onSelectedItemsChange, onSelectionChange, onRowClick, }: DataTableRowsSource<TData>) => DataTableRowsState<TData>;
40
+ //# sourceMappingURL=useDataTableRows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDataTableRows.d.ts","sourceRoot":"","sources":["../../../DataTables/useDataTableRows.ts"],"names":[],"mappings":"AAGA,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAAuB,CAAC;AACjE,OAAO,K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AAE,CAAC;IAClB,kFAAkF;IAClF,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,KAAK,IAAI,CAAC;CACnF;AAED;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,KAAK,SAAS,MAAM,qLAclD,mBAAmB,CAAC,KAAK,CAAC,KAAG,kBAAkB,CAAC,KAAK,CA8CvD,CAAC"}
@@ -0,0 +1,49 @@
1
+ import { useMemo } from 'react';
2
+ import { DataTableRowProcessing } from './DataTableRowProcessing.js';
3
+ import { dataTableRowKeys } from './dataTableRowKeys.js';
4
+ import { isFilterEntryActive } from './matchesFilterEntry.js';
5
+ import { processRows } from './processRows.js';
6
+ import { useRowSelection } from './useRowSelection.js';
7
+
8
+ const useDataTableRows = ({ data, dataKey, filters, globalFilter, globalFilterFields, sort, rowProcessing, selectionMode, selection, selectedItems, onSelectedItemsChange, onSelectionChange, onRowClick, }) => {
9
+ const isServerMode = rowProcessing === DataTableRowProcessing.None;
10
+ const hasActiveFilter = (globalFilter.trim() !== '' && !!globalFilterFields?.length) ||
11
+ Object.values(filters).some(isFilterEntryActive);
12
+ const filteredRows = useMemo(() => processRows(data, {
13
+ filters,
14
+ globalFilter,
15
+ globalFilterFields,
16
+ sort,
17
+ rowProcessing,
18
+ }), [data, filters, globalFilter, globalFilterFields, sort, rowProcessing]);
19
+ const rowKeys = useMemo(() => dataTableRowKeys(data, dataKey), [data, dataKey]);
20
+ const rowSelection = useRowSelection({
21
+ data,
22
+ visibleRows: filteredRows.map(({ row }) => row),
23
+ dataKey,
24
+ selection,
25
+ selectedItems,
26
+ onSelectedItemsChange,
27
+ });
28
+ const isInteractive = Boolean(onRowClick) || selectionMode === 'single' || selectionMode === 'multiple';
29
+ const activateRow = (row, index, originalEvent) => {
30
+ onRowClick?.({ data: row, index });
31
+ if (selectionMode === 'single') {
32
+ onSelectionChange?.({ value: row, originalEvent });
33
+ }
34
+ if (selectionMode === 'multiple') {
35
+ rowSelection.toggleRowSelection(row);
36
+ }
37
+ };
38
+ return {
39
+ ...rowSelection,
40
+ filteredRows,
41
+ rowKeys,
42
+ isFiltered: hasActiveFilter && (isServerMode || data.length > 0),
43
+ isInteractive,
44
+ activateRow,
45
+ };
46
+ };
47
+
48
+ export { useDataTableRows };
49
+ //# sourceMappingURL=useDataTableRows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDataTableRows.js","sources":["../../../DataTables/useDataTableRows.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 { useMemo, type SyntheticEvent } from 'react';\nimport type { DataTableFilterMeta } from './DataTableFilterMeta';\nimport type { DataTableRowClickEvent } from './DataTableRowClickEvent';\nimport { DataTableRowProcessing } from './DataTableRowProcessing';\nimport type { DataTableSelectionChangeEvent } from './DataTableSelectionChangeEvent';\nimport type { DataTableSort } from './DataTableSort';\nimport { dataTableRowKeys } from './dataTableRowKeys';\nimport { isFilterEntryActive } from './matchesFilterEntry';\nimport type { ProcessedRow } from './ProcessedRow';\nimport { processRows } from './processRows';\nimport type { RowSelection } from './RowSelection';\nimport { useRowSelection } from './useRowSelection';\n\n/** What {@link useDataTableRows} needs from the table. */\nexport interface DataTableRowsSource<TData extends object> {\n data: TData[];\n dataKey?: string;\n filters: DataTableFilterMeta;\n globalFilter: string;\n globalFilterFields?: string[];\n sort: DataTableSort | null;\n rowProcessing: DataTableRowProcessing;\n selectionMode?: 'single' | 'multiple';\n selection?: TData | null;\n selectedItems?: TData[];\n onSelectedItemsChange?: (items: TData[]) => void;\n onSelectionChange?: (event: DataTableSelectionChangeEvent<TData>) => void;\n onRowClick?: (event: DataTableRowClickEvent<TData>) => void;\n}\n\n/** The processed rows with their keys, selection and activation. */\nexport interface DataTableRowsState<TData extends object> extends RowSelection<TData> {\n filteredRows: ProcessedRow<TData>[];\n rowKeys: string[];\n /** Whether a search or filter is active, so an empty result is a filtered one. */\n isFiltered: boolean;\n isInteractive: boolean;\n activateRow: (row: TData, index: number, originalEvent: SyntheticEvent) => void;\n}\n\n/**\n * Filters, sorts, keys and selects the rows of a DataTable.\n * @param source The rows and the table state to work with.\n * @returns The rows to show and the actions on them.\n */\nexport const useDataTableRows = <TData extends object>({\n data,\n dataKey,\n filters,\n globalFilter,\n globalFilterFields,\n sort,\n rowProcessing,\n selectionMode,\n selection,\n selectedItems,\n onSelectedItemsChange,\n onSelectionChange,\n onRowClick,\n}: DataTableRowsSource<TData>): DataTableRowsState<TData> => {\n const isServerMode = rowProcessing === DataTableRowProcessing.None;\n const hasActiveFilter =\n (globalFilter.trim() !== '' && !!globalFilterFields?.length) ||\n Object.values(filters).some(isFilterEntryActive);\n const filteredRows = useMemo(\n () =>\n processRows(data, {\n filters,\n globalFilter,\n globalFilterFields,\n sort,\n rowProcessing,\n }),\n [data, filters, globalFilter, globalFilterFields, sort, rowProcessing],\n );\n const rowKeys = useMemo(() => dataTableRowKeys(data, dataKey), [data, dataKey]);\n const rowSelection = useRowSelection({\n data,\n visibleRows: filteredRows.map(({ row }) => row),\n dataKey,\n selection,\n selectedItems,\n onSelectedItemsChange,\n });\n const isInteractive =\n Boolean(onRowClick) || selectionMode === 'single' || selectionMode === 'multiple';\n\n const activateRow = (row: TData, index: number, originalEvent: SyntheticEvent) => {\n onRowClick?.({ data: row, index });\n if (selectionMode === 'single') {\n onSelectionChange?.({ value: row, originalEvent });\n }\n if (selectionMode === 'multiple') {\n rowSelection.toggleRowSelection(row);\n }\n };\n\n return {\n ...rowSelection,\n filteredRows,\n rowKeys,\n isFiltered: hasActiveFilter && (isServerMode || data.length > 0),\n isInteractive,\n activateRow,\n };\n};\n"],"names":[],"mappings":";;;;;;;AAgDO,MAAM,gBAAgB,GAAG,CAAuB,EACnD,IAAI,EACJ,OAAO,EACP,OAAO,EACP,YAAY,EACZ,kBAAkB,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EAAE,GAAG,EAAE,aAAa,EAAE,CAAC;QACtD;AACA,QAAA,IAAI,aAAa,KAAK,UAAU,EAAE;AAC9B,YAAA,YAAY,CAAC,kBAAkB,CAAC,GAAG,CAAC;QACxC;AACJ,IAAA,CAAC;IAED,OAAO;AACH,QAAA,GAAG,YAAY;QACf,YAAY;QACZ,OAAO;QACP,UAAU,EAAE,eAAe,KAAK,YAAY,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChE,aAAa;QACb,WAAW;KACd;AACL;;"}
@@ -0,0 +1,7 @@
1
+ import { type RefObject } from 'react';
2
+ /**
3
+ * Restores focus to the trigger when the popover closes, but only when the close actually dropped focus.
4
+ * Returns the ref callback that captures the popover element.
5
+ */
6
+ export declare const useRestoreFocusOnClose: (isOpen: boolean, triggerRef: RefObject<HTMLElement | null>) => (element: HTMLElement | null) => void;
7
+ //# sourceMappingURL=useRestoreFocusOnClose.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRestoreFocusOnClose.d.ts","sourceRoot":"","sources":["../../../DataTables/useRestoreFocusOnClose.ts"],"names":[],"mappings":"AAGA,OAAO,EAAkC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAavE;;;GAGG;AACH,eAAO,MAAM,sBAAsB,WAAY,OAAO,cAAc,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,eAKhD,WAAW,GAAG,IAAI,SA2BlE,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { useRef, useCallback, useEffect } from 'react';
2
+
3
+ const focusWasDropped = (trigger, popover) => {
4
+ const ownerDocument = trigger.ownerDocument;
5
+ const focusedElement = ownerDocument.activeElement;
6
+ return (!focusedElement ||
7
+ focusedElement === ownerDocument.body ||
8
+ !focusedElement.isConnected ||
9
+ popover?.contains(focusedElement) === true);
10
+ };
11
+ const useRestoreFocusOnClose = (isOpen, triggerRef) => {
12
+ const popoverRef = useRef(null);
13
+ const capturePopover = useCallback((element) => {
14
+ if (element)
15
+ popoverRef.current = element;
16
+ }, []);
17
+ useEffect(() => {
18
+ if (!isOpen)
19
+ return;
20
+ return () => {
21
+ const trigger = triggerRef.current;
22
+ if (trigger && focusWasDropped(trigger, popoverRef.current))
23
+ trigger.focus();
24
+ };
25
+ }, [isOpen, triggerRef]);
26
+ return capturePopover;
27
+ };
28
+
29
+ export { useRestoreFocusOnClose };
30
+ //# sourceMappingURL=useRestoreFocusOnClose.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRestoreFocusOnClose.js","sources":["../../../DataTables/useRestoreFocusOnClose.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 { useCallback, useEffect, useRef, type RefObject } from 'react';\n\nconst focusWasDropped = (trigger: HTMLElement, popover: HTMLElement | null): boolean => {\n const ownerDocument = trigger.ownerDocument;\n const focusedElement = ownerDocument.activeElement;\n return (\n !focusedElement ||\n focusedElement === ownerDocument.body ||\n !focusedElement.isConnected ||\n popover?.contains(focusedElement) === true\n );\n};\n\n/**\n * Restores focus to the trigger when the popover closes, but only when the close actually dropped focus.\n * Returns the ref callback that captures the popover element.\n */\nexport const useRestoreFocusOnClose = (isOpen: boolean, triggerRef: RefObject<HTMLElement | null>) => {\n const popoverRef = useRef<HTMLElement | null>(null);\n // Sticky on purpose: React detaches the popover's ref during the same commit that closes the\n // menu, before the effect cleanup below runs, so the last element we saw is the only handle we\n // still have on the popover that is going away.\n const capturePopover = useCallback((element: HTMLElement | null) => {\n if (element) popoverRef.current = element;\n }, []);\n\n // React Aria's FocusScope already draws that distinction - at teardown it asks whether the\n // active element is still inside the dying scope or has already fallen to `document.body`, and\n // it leaves focus alone otherwise. Its weakness is only the timing: it defers the real restore\n // to a `requestAnimationFrame` that re-tests `activeElement === body`, which lands a frame after\n // focus has visibly left the trigger's neighborhood and silently does nothing if anything else\n // claims focus first. We keep its question and drop its delay: the same predicate is evaluated\n // synchronously in this cleanup, so the restore happens in the commit that closed the menu.\n //\n // \"Dropped\" has to be read at the moment this cleanup runs, while the popover is still exiting.\n // Focus is typically still on the popover's own content (its value input), which is about to be\n // removed - that is a drop in progress, not a destination. So a drop is: nothing focused, the\n // body, a node already detached from the document, or anything inside this menu's own popover.\n // Focus anywhere else is somewhere the user deliberately went, such as another column's filter\n // trigger, and must be left alone.\n useEffect(() => {\n if (!isOpen) return;\n return () => {\n const trigger = triggerRef.current;\n if (trigger && focusWasDropped(trigger, popoverRef.current)) trigger.focus();\n };\n }, [isOpen, triggerRef]);\n\n return capturePopover;\n};\n"],"names":[],"mappings":";;AAKA,MAAM,eAAe,GAAG,CAAC,OAAoB,EAAE,OAA2B,KAAa;AACnF,IAAA,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa;AAC3C,IAAA,MAAM,cAAc,GAAG,aAAa,CAAC,aAAa;IAClD,QACI,CAAC,cAAc;QACf,cAAc,KAAK,aAAa,CAAC,IAAI;QACrC,CAAC,cAAc,CAAC,WAAW;QAC3B,OAAO,EAAE,QAAQ,CAAC,cAAc,CAAC,KAAK,IAAI;AAElD,CAAC;MAMY,sBAAsB,GAAG,CAAC,MAAe,EAAE,UAAyC,KAAI;AACjG,IAAA,MAAM,UAAU,GAAG,MAAM,CAAqB,IAAI,CAAC;AAInD,IAAA,MAAM,cAAc,GAAG,WAAW,CAAC,CAAC,OAA2B,KAAI;AAC/D,QAAA,IAAI,OAAO;AAAE,YAAA,UAAU,CAAC,OAAO,GAAG,OAAO;IAC7C,CAAC,EAAE,EAAE,CAAC;IAgBN,SAAS,CAAC,MAAK;AACX,QAAA,IAAI,CAAC,MAAM;YAAE;AACb,QAAA,OAAO,MAAK;AACR,YAAA,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO;YAClC,IAAI,OAAO,IAAI,eAAe,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC;gBAAE,OAAO,CAAC,KAAK,EAAE;AAChF,QAAA,CAAC;AACL,IAAA,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAExB,IAAA,OAAO,cAAc;AACzB;;"}
@@ -0,0 +1,22 @@
1
+ import type React from 'react';
2
+ import { type DialogFooterProps } from './DialogFooter.js';
3
+ import { type DialogHeaderProps } from './DialogHeader.js';
4
+ interface Announcement {
5
+ key: number;
6
+ text: string;
7
+ }
8
+ /** Props of the dialog document. */
9
+ export interface DialogDocumentProps {
10
+ header: DialogHeaderProps;
11
+ /** The footer, or null when the dialog has no footer. */
12
+ footer: DialogFooterProps | null;
13
+ stackZIndex: string;
14
+ visible: boolean;
15
+ contentStyle: React.CSSProperties | undefined;
16
+ announcement: Announcement | null;
17
+ children: React.ReactNode;
18
+ }
19
+ /** The accessible dialog document: header, content, footer and the status live region. */
20
+ export declare const DialogDocument: ({ header, footer, stackZIndex, visible, contentStyle, announcement, children, }: DialogDocumentProps) => React.JSX.Element;
21
+ export {};
22
+ //# sourceMappingURL=DialogDocument.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialogDocument.d.ts","sourceRoot":"","sources":["../../../Dialogs/DialogDocument.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAgB,KAAK,iBAAiB,EAAE,MAAM,mBAAgB,CAAC;AACtE,OAAO,EAAgB,KAAK,iBAAiB,EAAE,MAAM,mBAAgB,CAAC;AAgBtE,UAAU,YAAY;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CAChB;AA4CD,oCAAoC;AACpC,MAAM,WAAW,mBAAmB;IAChC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,yDAAyD;IACzD,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,KAAK,CAAC,aAAa,GAAG,SAAS,CAAC;IAC9C,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC7B;AAED,0FAA0F;AAC1F,eAAO,MAAM,cAAc,oFAQxB,mBAAmB,sBAgBrB,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
+ import { Dialog } from 'react-aria-components/Dialog';
3
+ import { classNames } from '../ClassNames/classNames.js';
4
+ import { DialogStackContext } from '../renderer/DialogStackContext.js';
5
+ import { DialogFooter } from './DialogFooter.js';
6
+ import { DialogHeader } from './DialogHeader.js';
7
+
8
+ const visuallyHidden = {
9
+ position: 'absolute',
10
+ width: 1,
11
+ height: 1,
12
+ margin: -1,
13
+ padding: 0,
14
+ overflow: 'hidden',
15
+ clipPath: 'inset(50%)',
16
+ whiteSpace: 'nowrap',
17
+ border: 0,
18
+ };
19
+ const DialogContent = ({ visible, isBusy, contentStyle, pt, children }) => (jsx("div", { ...pt?.content, className: classNames('cratis-dialog__content', pt?.content?.className), style: { ...pt?.content?.style, ...contentStyle }, "data-cratis-part": 'content', "data-open": visible || undefined, "data-busy": isBusy || undefined, children: jsx("fieldset", { className: 'cratis-dialog__busy-scope', "data-cratis-part": 'busy-scope', "data-busy": isBusy || undefined, disabled: isBusy, inert: isBusy, "aria-busy": isBusy || undefined, children: children }) }));
20
+ const LiveRegion = ({ announcement }) => (jsx("div", { className: 'cratis-dialog__live-region', style: visuallyHidden, role: 'status', "aria-live": 'polite', "aria-atomic": 'true', children: announcement && jsx("span", { children: announcement.text }, announcement.key) }));
21
+ const DialogDocument = ({ header, footer, stackZIndex, visible, contentStyle, announcement, children, }) => (jsx(DialogStackContext.Provider, { value: stackZIndex, children: jsx(Dialog, { className: 'cratis-dialog__document', "aria-describedby": header.hasSubtitle ? header.subtitleId : undefined, children: jsxs(Fragment, { children: [jsx(DialogHeader, { ...header }), jsx(DialogContent, { visible: visible, isBusy: header.isBusy, contentStyle: contentStyle, pt: header.pt, children: children }), footer && jsx(DialogFooter, { ...footer }), jsx(LiveRegion, { announcement: announcement })] }) }) }));
22
+
23
+ export { DialogDocument };
24
+ //# sourceMappingURL=DialogDocument.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialogDocument.js","sources":["../../../Dialogs/DialogDocument.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Dialog as AriaDialog } from 'react-aria-components/Dialog';\nimport type React from 'react';\nimport { classNames } from '../ClassNames/classNames';\nimport { DialogStackContext } from '../renderer/DialogStackContext';\nimport { DialogFooter, type DialogFooterProps } from './DialogFooter';\nimport { DialogHeader, type DialogHeaderProps } from './DialogHeader';\nimport type { DialogParts } from './Dialog';\n\n// Inline rather than in Dialog.css: the packed aggregate stylesheet has a reviewed size budget.\nconst visuallyHidden: React.CSSProperties = {\n position: 'absolute',\n width: 1,\n height: 1,\n margin: -1,\n padding: 0,\n overflow: 'hidden',\n clipPath: 'inset(50%)',\n whiteSpace: 'nowrap',\n border: 0,\n};\n\ninterface Announcement {\n key: number;\n text: string;\n}\n\ninterface DialogContentProps {\n visible: boolean;\n isBusy: boolean;\n contentStyle: React.CSSProperties | undefined;\n pt: DialogParts | undefined;\n children: React.ReactNode;\n}\n\nconst DialogContent = ({ visible, isBusy, contentStyle, pt, children }: DialogContentProps) => (\n <div\n {...pt?.content}\n className={classNames('cratis-dialog__content', pt?.content?.className)}\n style={{ ...pt?.content?.style, ...contentStyle }}\n data-cratis-part='content'\n data-open={visible || undefined}\n data-busy={isBusy || undefined}\n >\n <fieldset\n className='cratis-dialog__busy-scope'\n data-cratis-part='busy-scope'\n data-busy={isBusy || undefined}\n disabled={isBusy}\n inert={isBusy}\n aria-busy={isBusy || undefined}\n >\n {children}\n </fieldset>\n </div>\n);\n\nconst LiveRegion = ({ announcement }: { announcement: Announcement | null }) => (\n <div\n className='cratis-dialog__live-region'\n style={visuallyHidden}\n role='status'\n aria-live='polite'\n aria-atomic='true'\n >\n {announcement && <span key={announcement.key}>{announcement.text}</span>}\n </div>\n);\n\n/** Props of the dialog document. */\nexport interface DialogDocumentProps {\n header: DialogHeaderProps;\n /** The footer, or null when the dialog has no footer. */\n footer: DialogFooterProps | null;\n stackZIndex: string;\n visible: boolean;\n contentStyle: React.CSSProperties | undefined;\n announcement: Announcement | null;\n children: React.ReactNode;\n}\n\n/** The accessible dialog document: header, content, footer and the status live region. */\nexport const DialogDocument = ({\n header,\n footer,\n stackZIndex,\n visible,\n contentStyle,\n announcement,\n children,\n}: DialogDocumentProps) => (\n <DialogStackContext.Provider value={stackZIndex}>\n <AriaDialog\n className='cratis-dialog__document'\n aria-describedby={header.hasSubtitle ? header.subtitleId : undefined}\n >\n <>\n <DialogHeader {...header} />\n <DialogContent visible={visible} isBusy={header.isBusy} contentStyle={contentStyle} pt={header.pt}>\n {children}\n </DialogContent>\n {footer && <DialogFooter {...footer} />}\n <LiveRegion announcement={announcement} />\n </>\n </AriaDialog>\n </DialogStackContext.Provider>\n);\n"],"names":["_jsx","AriaDialog","_jsxs","_Fragment"],"mappings":";;;;;;;AAYA,MAAM,cAAc,GAAwB;AACxC,IAAA,QAAQ,EAAE,UAAU;AACpB,IAAA,KAAK,EAAE,CAAC;AACR,IAAA,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,EAAE;AACV,IAAA,OAAO,EAAE,CAAC;AACV,IAAA,QAAQ,EAAE,QAAQ;AAClB,IAAA,QAAQ,EAAE,YAAY;AACtB,IAAA,UAAU,EAAE,QAAQ;AACpB,IAAA,MAAM,EAAE,CAAC;CACZ;AAeD,MAAM,aAAa,GAAG,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,QAAQ,EAAsB,MACtFA,GAAA,CAAA,KAAA,EAAA,EAAA,GACQ,EAAE,EAAE,OAAO,EACf,SAAS,EAAE,UAAU,CAAC,wBAAwB,EAAE,EAAE,EAAE,OAAO,EAAE,SAAS,CAAC,EACvE,KAAK,EAAE,EAAE,GAAG,EAA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AY,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAA,QAAA,EAC5F,QAAQ,EAAA,CACG,EACf,MAAM,IAAIA,GAAA,CAAC,YAAY,EAAA,EAAA,GAAK,MAAM,EAAA,CAAI,EACvCA,GAAA,CAAC,UAAU,EAAA,EAAC,YAAY,EAAE,YAAY,GAAI,CAAA,EAAA,CAC3C,EAAA,CACM,EAAA,CACa;;"}
@@ -0,0 +1,24 @@
1
+ import { DialogResult } from '@cratis/arc.react/dialogs';
2
+ import type React from 'react';
3
+ import type { DialogParts, DialogProps } from './Dialog.js';
4
+ import type { DialogLabels } from './resolveDialogLabels.js';
5
+ interface FocusFlags {
6
+ confirm: boolean;
7
+ dismissing: boolean;
8
+ }
9
+ /** Props of the dialog footer. */
10
+ export interface DialogFooterProps {
11
+ buttons: NonNullable<DialogProps['buttons']>;
12
+ labels: DialogLabels;
13
+ focus: FocusFlags;
14
+ isBusy: boolean;
15
+ isValid: boolean;
16
+ pt: DialogParts | undefined;
17
+ confirmRef: React.RefObject<HTMLButtonElement | null>;
18
+ cancelRef: React.RefObject<HTMLButtonElement | null>;
19
+ onResult: (result: DialogResult) => void;
20
+ }
21
+ /** The dialog footer holding either the predefined buttons or a custom footer. */
22
+ export declare const DialogFooter: (props: DialogFooterProps) => React.JSX.Element;
23
+ export {};
24
+ //# sourceMappingURL=DialogFooter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialogFooter.d.ts","sourceRoot":"","sources":["../../../Dialogs/DialogFooter.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAiB,MAAM,2BAA2B,CAAC;AACxE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAU,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAAuB,CAAC;AAS1D,UAAU,UAAU;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;CACvB;AA8GD,kCAAkC;AAClC,MAAM,WAAW,iBAAiB;IAC9B,OAAO,EAAE,WAAW,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC;IAC7C,MAAM,EAAE,YAAY,CAAC;IACrB,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,EAAE,EAAE,WAAW,GAAG,SAAS,CAAC;IAC5B,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;IACtD,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;IACrD,QAAQ,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;CAC5C;AA4BD,kFAAkF;AAClF,eAAO,MAAM,YAAY,UAAW,iBAAiB,sBAyBpD,CAAC"}
@@ -0,0 +1,65 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { DialogButtons, DialogResult } from '@cratis/arc.react/dialogs';
3
+ import { classNames } from '../ClassNames/classNames.js';
4
+
5
+ const footerButtonsFor = (buttons, labels, focus) => {
6
+ const primary = (result, label) => ({ result, label, primary: true, focused: focus.confirm });
7
+ const secondary = (result, label, focused = focus.dismissing) => ({
8
+ result,
9
+ label,
10
+ primary: false,
11
+ focused,
12
+ });
13
+ switch (buttons) {
14
+ case DialogButtons.Ok:
15
+ return [primary(DialogResult.Ok, labels.ok)];
16
+ case DialogButtons.OkCancel:
17
+ return [primary(DialogResult.Ok, labels.ok), secondary(DialogResult.Cancelled, labels.cancel)];
18
+ case DialogButtons.YesNo:
19
+ return [primary(DialogResult.Yes, labels.yes), secondary(DialogResult.No, labels.no)];
20
+ case DialogButtons.YesNoCancel:
21
+ return [
22
+ primary(DialogResult.Yes, labels.yes),
23
+ secondary(DialogResult.No, labels.no, false),
24
+ secondary(DialogResult.Cancelled, labels.cancel),
25
+ ];
26
+ default:
27
+ return [];
28
+ }
29
+ };
30
+ const isActivationKey = (key) => key === 'Enter' || key === ' ';
31
+ const suppressRepeatedActivation = (event) => {
32
+ if (event.repeat && isActivationKey(event.key))
33
+ event.preventDefault();
34
+ };
35
+ const buttonAttributes = (kind, part) => ({
36
+ ...part,
37
+ type: 'button',
38
+ className: classNames('cratis-dialog__button', `cratis-dialog__button--${kind}`, part?.className),
39
+ });
40
+ const primaryAria = (isBusy) => ({
41
+ 'aria-disabled': isBusy || undefined,
42
+ 'aria-busy': isBusy || undefined,
43
+ });
44
+ const activate = (isBusy, onResult, result) => () => {
45
+ if (!isBusy)
46
+ onResult(result);
47
+ };
48
+ const PrimaryButton = ({ button, isBusy, isValid, pt, confirmRef, onResult }) => {
49
+ const isDisabled = !isValid || isBusy;
50
+ return (jsxs("button", { ...buttonAttributes('primary', pt?.confirm), ...primaryAria(isBusy), "data-cratis-part": 'confirm', "data-disabled": isDisabled || undefined, "data-busy": isBusy || undefined, ref: confirmRef, onClick: activate(isBusy, onResult, button.result), onKeyDown: suppressRepeatedActivation, disabled: !isValid, autoFocus: button.focused, children: [isBusy && jsx("span", { className: 'cratis-dialog__spinner', "aria-hidden": 'true' }), jsx("span", { children: button.label })] }));
51
+ };
52
+ const SecondaryButton = ({ button, isBusy, pt, cancelRef, onResult }) => (jsx("button", { ...buttonAttributes('secondary', pt?.cancel), "data-cratis-part": 'cancel', "data-disabled": isBusy || undefined, "data-busy": isBusy || undefined, ref: button.focused ? cancelRef : undefined, onClick: activate(isBusy, onResult, button.result), disabled: isBusy, autoFocus: button.focused, children: jsx("span", { children: button.label }) }));
53
+ const FooterButtons = ({ buttons, labels, focus, isBusy, isValid, pt, confirmRef, cancelRef, onResult }) => {
54
+ if (typeof buttons !== 'number')
55
+ return buttons;
56
+ return footerButtonsFor(buttons, labels, focus).map((button) => button.primary ? (jsx(PrimaryButton, { button: button, isBusy: isBusy, isValid: isValid, pt: pt, confirmRef: confirmRef, onResult: onResult }, `${button.result}-${button.label}`)) : (jsx(SecondaryButton, { button: button, isBusy: isBusy, pt: pt, cancelRef: cancelRef, onResult: onResult }, `${button.result}-${button.label}`)));
57
+ };
58
+ const DialogFooter = (props) => {
59
+ const { buttons, isBusy, pt } = props;
60
+ const isFooterScopeBusy = isBusy && typeof buttons !== 'number';
61
+ return (jsx("footer", { ...pt?.footer, className: classNames('cratis-dialog__footer', pt?.footer?.className), style: pt?.footer?.style, "data-cratis-part": 'footer', children: jsx("fieldset", { className: 'cratis-dialog__busy-scope cratis-dialog__busy-scope--footer', "data-cratis-part": 'busy-scope', "data-busy": isBusy || undefined, disabled: isFooterScopeBusy, inert: isFooterScopeBusy, "aria-busy": isBusy || undefined, children: jsx(FooterButtons, { ...props }) }) }));
62
+ };
63
+
64
+ export { DialogFooter };
65
+ //# sourceMappingURL=DialogFooter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialogFooter.js","sources":["../../../Dialogs/DialogFooter.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 type React from 'react';\nimport { classNames } from '../ClassNames/classNames';\nimport type { DialogParts, DialogProps } from './Dialog';\nimport type { DialogLabels } from './resolveDialogLabels';\n\ninterface FooterButton {\n result: DialogResult;\n label: string;\n primary: boolean;\n focused: boolean;\n}\n\ninterface FocusFlags {\n confirm: boolean;\n dismissing: boolean;\n}\n\n/**\n * Describes the predefined footer buttons of a button set.\n * @param buttons The dialog's predefined button set.\n * @param labels The resolved labels.\n * @param focus Which button kind receives the initial focus.\n * @returns The buttons in display order; empty for an unknown set.\n */\nconst footerButtonsFor = (buttons: DialogButtons, labels: DialogLabels, focus: FocusFlags): FooterButton[] => {\n const primary = (result: DialogResult, label: string): FooterButton => ({ result, label, primary: true, focused: focus.confirm });\n const secondary = (result: DialogResult, label: string, focused = focus.dismissing): FooterButton => ({\n result,\n label,\n primary: false,\n focused,\n });\n\n switch (buttons) {\n case DialogButtons.Ok:\n return [primary(DialogResult.Ok, labels.ok)];\n case DialogButtons.OkCancel:\n return [primary(DialogResult.Ok, labels.ok), secondary(DialogResult.Cancelled, labels.cancel)];\n case DialogButtons.YesNo:\n return [primary(DialogResult.Yes, labels.yes), secondary(DialogResult.No, labels.no)];\n case DialogButtons.YesNoCancel:\n return [\n primary(DialogResult.Yes, labels.yes),\n secondary(DialogResult.No, labels.no, false),\n secondary(DialogResult.Cancelled, labels.cancel),\n ];\n default:\n return [];\n }\n};\n\ninterface ButtonProps {\n button: FooterButton;\n isBusy: boolean;\n pt: DialogParts | undefined;\n onResult: (result: DialogResult) => void;\n}\n\ninterface PrimaryButtonProps extends ButtonProps {\n isValid: boolean;\n confirmRef: React.RefObject<HTMLButtonElement | null>;\n}\n\ninterface SecondaryButtonProps extends ButtonProps {\n cancelRef: React.RefObject<HTMLButtonElement | null>;\n}\n\nconst isActivationKey = (key: string) => key === 'Enter' || key === ' ';\n\n// A held key must not re-submit when focus returns after a refusal.\nconst suppressRepeatedActivation = (event: React.KeyboardEvent) => {\n if (event.repeat && isActivationKey(event.key)) event.preventDefault();\n};\n\nconst buttonAttributes = (kind: 'primary' | 'secondary', part: DialogParts['confirm']) => ({\n ...part,\n type: 'button' as const,\n className: classNames('cratis-dialog__button', `cratis-dialog__button--${kind}`, part?.className),\n});\n\nconst primaryAria = (isBusy: boolean) => ({\n 'aria-disabled': isBusy || undefined,\n 'aria-busy': isBusy || undefined,\n});\n\nconst activate = (isBusy: boolean, onResult: (result: DialogResult) => void, result: DialogResult) => () => {\n if (!isBusy) onResult(result);\n};\n\nconst PrimaryButton = ({ button, isBusy, isValid, pt, confirmRef, onResult }: PrimaryButtonProps) => {\n const isDisabled = !isValid || isBusy;\n return (\n <button\n {...buttonAttributes('primary', pt?.confirm)}\n {...primaryAria(isBusy)}\n data-cratis-part='confirm'\n data-disabled={isDisabled || undefined}\n data-busy={isBusy || undefined}\n ref={confirmRef}\n onClick={activate(isBusy, onResult, button.result)}\n onKeyDown={suppressRepeatedActivation}\n disabled={!isValid}\n autoFocus={button.focused}\n >\n {isBusy && <span className='cratis-dialog__spinner' aria-hidden='true' />}\n <span>{button.label}</span>\n </button>\n );\n};\n\nconst SecondaryButton = ({ button, isBusy, pt, cancelRef, onResult }: SecondaryButtonProps) => (\n <button\n {...buttonAttributes('secondary', pt?.cancel)}\n data-cratis-part='cancel'\n data-disabled={isBusy || undefined}\n data-busy={isBusy || undefined}\n ref={button.focused ? cancelRef : undefined}\n onClick={activate(isBusy, onResult, button.result)}\n disabled={isBusy}\n autoFocus={button.focused}\n >\n <span>{button.label}</span>\n </button>\n);\n\n/** Props of the dialog footer. */\nexport interface DialogFooterProps {\n buttons: NonNullable<DialogProps['buttons']>;\n labels: DialogLabels;\n focus: FocusFlags;\n isBusy: boolean;\n isValid: boolean;\n pt: DialogParts | undefined;\n confirmRef: React.RefObject<HTMLButtonElement | null>;\n cancelRef: React.RefObject<HTMLButtonElement | null>;\n onResult: (result: DialogResult) => void;\n}\n\nconst FooterButtons = ({ buttons, labels, focus, isBusy, isValid, pt, confirmRef, cancelRef, onResult }: DialogFooterProps) => {\n if (typeof buttons !== 'number') return buttons;\n return footerButtonsFor(buttons, labels, focus).map((button) =>\n button.primary ? (\n <PrimaryButton\n key={`${button.result}-${button.label}`}\n button={button}\n isBusy={isBusy}\n isValid={isValid}\n pt={pt}\n confirmRef={confirmRef}\n onResult={onResult}\n />\n ) : (\n <SecondaryButton\n key={`${button.result}-${button.label}`}\n button={button}\n isBusy={isBusy}\n pt={pt}\n cancelRef={cancelRef}\n onResult={onResult}\n />\n ),\n );\n};\n\n/** The dialog footer holding either the predefined buttons or a custom footer. */\nexport const DialogFooter = (props: DialogFooterProps) => {\n const { buttons, isBusy, pt } = props;\n // The predefined footer keeps the confirm button focusable while busy, so only a custom\n // footer needs the whole scope disabled; predefined secondary buttons disable themselves.\n const isFooterScopeBusy = isBusy && typeof buttons !== 'number';\n\n return (\n <footer\n {...pt?.footer}\n className={classNames('cratis-dialog__footer', pt?.footer?.className)}\n style={pt?.footer?.style}\n data-cratis-part='footer'\n >\n <fieldset\n className='cratis-dialog__busy-scope cratis-dialog__busy-scope--footer'\n data-cratis-part='busy-scope'\n data-busy={isBusy || undefined}\n disabled={isFooterScopeBusy}\n inert={isFooterScopeBusy}\n aria-busy={isBusy || undefined}\n >\n <FooterButtons {...props} />\n </fieldset>\n </footer>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;AA4BA,MAAM,gBAAgB,GAAG,CAAC,OAAsB,EAAE,MAAoB,EAAE,KAAiB,KAAoB;IACzG,MAAM,OAAO,GAAG,CAAC,MAAoB,EAAE,KAAa,MAAoB,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;AACjI,IAAA,MAAM,SAAS,GAAG,CAAC,MAAoB,EAAE,KAAa,EAAE,OAAO,GAAG,KAAK,CAAC,UAAU,MAAoB;QAClG,MAAM;QACN,KAAK;AACL,QAAA,OAAO,EAAE,KAAK;QACd,OAAO;AACV,KAAA,CAAC;IAEF,QAAQ,OAAO;QACX,KAAK,aAAa,CAAC,EAAE;AACjB,YAAA,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;QAChD,KAAK,aAAa,CAAC,QAAQ;YACvB,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC,EAAE,SAAS,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QAClG,KAAK,aAAa,CAAC,KAAK;YACpB,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,YAAY,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC,C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MAAM,EAAE,KAAK,EAAA,kBAAA,EACP,QAAQ,EAAA,QAAA,EAEzBA,GAAA,CAAA,UAAA,EAAA,EACI,SAAS,EAAC,6DAA6D,EAAA,kBAAA,EACtD,YAAY,EAAA,WAAA,EAClB,MAAM,IAAI,SAAS,EAC9B,QAAQ,EAAE,iBAAiB,EAC3B,KAAK,EAAE,iBAAiB,EAAA,WAAA,EACb,MAAM,IAAI,SAAS,EAAA,QAAA,EAE9BA,GAAA,CAAC,aAAa,EAAA,EAAA,GAAK,KAAK,EAAA,CAAI,EAAA,CACrB,EAAA,CACN;AAEjB;;"}
@@ -0,0 +1,31 @@
1
+ import type React from 'react';
2
+ import type { DialogHeaderActionsRenderer } from '../configuration/DialogHeaderActionsRenderer.js';
3
+ import type { DialogParts, DialogProps } from './Dialog.js';
4
+ interface HeaderActionsProps {
5
+ dialogId: string;
6
+ title: DialogProps['title'];
7
+ headerActions: DialogProps['headerActions'];
8
+ globalHeaderActions: DialogHeaderActionsRenderer | undefined;
9
+ hideGlobalHeaderActions: boolean;
10
+ isCommandDialog: boolean;
11
+ sliceLocation: DialogProps['sliceLocation'];
12
+ showsCloseButton: boolean;
13
+ pt: DialogParts | undefined;
14
+ }
15
+ /** Props of the dialog header. */
16
+ export interface DialogHeaderProps extends HeaderActionsProps {
17
+ subtitle: DialogProps['subtitle'];
18
+ subtitleId: string;
19
+ hasSubtitle: boolean;
20
+ hasHeaderActions: boolean;
21
+ focusesTitle: boolean;
22
+ titleRef: React.Ref<HTMLHeadingElement>;
23
+ isBusy: boolean;
24
+ closeAriaLabel: string;
25
+ closeIcon: React.ReactNode;
26
+ onClose: () => void;
27
+ }
28
+ /** The dialog header: title, subtitle, header actions and the close button. */
29
+ export declare const DialogHeader: (props: DialogHeaderProps) => React.JSX.Element;
30
+ export {};
31
+ //# sourceMappingURL=DialogHeader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialogHeader.d.ts","sourceRoot":"","sources":["../../../Dialogs/DialogHeader.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,iDAA8C,CAAC;AAEhG,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAU,CAAC;AAgBzD,UAAU,kBAAkB;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC5B,aAAa,EAAE,WAAW,CAAC,eAAe,CAAC,CAAC;IAC5C,mBAAmB,EAAE,2BAA2B,GAAG,SAAS,CAAC;IAC7D,uBAAuB,EAAE,OAAO,CAAC;IACjC,eAAe,EAAE,OAAO,CAAC;IACzB,aAAa,EAAE,WAAW,CAAC,eAAe,CAAC,CAAC;IAC5C,gBAAgB,EAAE,OAAO,CAAC;IAC1B,EAAE,EAAE,WAAW,GAAG,SAAS,CAAC;CAC/B;AAyFD,kCAAkC;AAClC,MAAM,WAAW,iBAAkB,SAAQ,kBAAkB;IACzD,QAAQ,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,KAAK,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IACxC,MAAM,EAAE,OAAO,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,OAAO,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,+EAA+E;AAC/E,eAAO,MAAM,YAAY,UAAW,iBAAiB,sBAwBpD,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { Heading } from 'react-aria-components/Dialog';
3
+ import { dialogPartAttributes } from './dialogPartAttributes.js';
4
+ import { DialogGlobalHeaderActions } from './DialogGlobalHeaderActions.js';
5
+
6
+ const headerActionsStyle = (hasCloseButton, style) => ({
7
+ display: 'inline-flex',
8
+ gridColumn: 2,
9
+ gridRow: 1,
10
+ justifySelf: 'end',
11
+ alignItems: 'center',
12
+ gap: '0.25rem',
13
+ marginInlineEnd: hasCloseButton ? '2.25rem' : undefined,
14
+ ...style,
15
+ });
16
+ const HeaderActions = ({ dialogId, title, headerActions, globalHeaderActions, hideGlobalHeaderActions, isCommandDialog, sliceLocation, showsCloseButton, pt, }) => (jsxs("div", { ...dialogPartAttributes(pt?.headerActions, 'cratis-dialog__header-actions', headerActionsStyle(showsCloseButton, pt?.headerActions?.style)), "data-cratis-part": 'header-actions', children: [headerActions, globalHeaderActions && !hideGlobalHeaderActions && (jsx(DialogGlobalHeaderActions, { render: globalHeaderActions, context: { dialogId, title, isCommandDialog, sliceLocation } }))] }));
17
+ const closeButtonStyle = (hasHeaderActions, style) => hasHeaderActions ? { justifySelf: 'end', ...style } : style;
18
+ const CloseButton = ({ isBusy, hasHeaderActions, ariaLabel, icon, pt, onClose }) => (jsx("button", { type: 'button', ...dialogPartAttributes(pt?.close, 'cratis-dialog__close', closeButtonStyle(hasHeaderActions, pt?.close?.style)), disabled: isBusy, "data-cratis-part": 'close', "data-disabled": isBusy || undefined, "data-busy": isBusy || undefined, "aria-label": ariaLabel, onClick: onClose, children: jsx("span", { "aria-hidden": 'true', children: icon }) }));
19
+ const Title = ({ title, focusesTitle, titleRef, pt }) => (jsx(Heading, { ...dialogPartAttributes(pt?.title, 'cratis-dialog__title'), slot: 'title', tabIndex: focusesTitle ? -1 : undefined, ref: titleRef, "data-cratis-part": 'title', children: title }));
20
+ const Subtitle = ({ subtitle, subtitleId, pt }) => (jsx("p", { ...dialogPartAttributes(pt?.subtitle, 'cratis-dialog__subtitle'), id: subtitleId, "data-cratis-part": 'subtitle', children: subtitle }));
21
+ const DialogHeader = (props) => {
22
+ const { pt, title, subtitle, subtitleId, hasSubtitle, hasHeaderActions, focusesTitle, titleRef } = props;
23
+ const { showsCloseButton, isBusy, closeAriaLabel, closeIcon, onClose } = props;
24
+ return (jsxs("header", { ...dialogPartAttributes(pt?.header, 'cratis-dialog__header'), "data-cratis-part": 'header', children: [jsx(Title, { title: title, focusesTitle: focusesTitle, titleRef: titleRef, pt: pt }), hasSubtitle && jsx(Subtitle, { subtitle: subtitle, subtitleId: subtitleId, pt: pt }), hasHeaderActions && jsx(HeaderActions, { ...props }), showsCloseButton && (jsx(CloseButton, { isBusy: isBusy, hasHeaderActions: hasHeaderActions, ariaLabel: closeAriaLabel, icon: closeIcon, pt: pt, onClose: onClose }))] }));
25
+ };
26
+
27
+ export { DialogHeader };
28
+ //# sourceMappingURL=DialogHeader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialogHeader.js","sources":["../../../Dialogs/DialogHeader.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Heading } from 'react-aria-components/Dialog';\nimport type React from 'react';\nimport { dialogPartAttributes } from './dialogPartAttributes';\nimport type { DialogHeaderActionsRenderer } from '../configuration/DialogHeaderActionsRenderer';\nimport { DialogGlobalHeaderActions } from './DialogGlobalHeaderActions';\nimport type { DialogParts, DialogProps } from './Dialog';\n\n// Header actions sit in the close button's grid column, to its left. Inline rather than in Dialog.css:\n// the packed aggregate stylesheet has a reviewed size budget.\nconst headerActionsStyle = (hasCloseButton: boolean, style: React.CSSProperties | undefined): React.CSSProperties => ({\n display: 'inline-flex',\n gridColumn: 2,\n gridRow: 1,\n justifySelf: 'end',\n alignItems: 'center',\n gap: '0.25rem',\n marginInlineEnd: hasCloseButton ? '2.25rem' : undefined,\n ...style,\n});\n\n\ninterface HeaderActionsProps {\n dialogId: string;\n title: DialogProps['title'];\n headerActions: DialogProps['headerActions'];\n globalHeaderActions: DialogHeaderActionsRenderer | undefined;\n hideGlobalHeaderActions: boolean;\n isCommandDialog: boolean;\n sliceLocation: DialogProps['sliceLocation'];\n showsCloseButton: boolean;\n pt: DialogParts | undefined;\n}\n\nconst HeaderActions = ({\n dialogId,\n title,\n headerActions,\n globalHeaderActions,\n hideGlobalHeaderActions,\n isCommandDialog,\n sliceLocation,\n showsCloseButton,\n pt,\n}: HeaderActionsProps) => (\n <div\n {...dialogPartAttributes(pt?.headerActions, 'cratis-dialog__header-actions', headerActionsStyle(showsCloseButton, pt?.headerActions?.style))}\n data-cratis-part='header-actions'\n >\n {headerActions}\n {globalHeaderActions && !hideGlobalHeaderActions && (\n <DialogGlobalHeaderActions\n render={globalHeaderActions}\n context={{ dialogId, title, isCommandDialog, sliceLocation }}\n />\n )}\n </div>\n);\n\nconst closeButtonStyle = (hasHeaderActions: boolean, style: React.CSSProperties | undefined) =>\n hasHeaderActions ? { justifySelf: 'end' as const, ...style } : style;\n\ninterface CloseButtonProps {\n isBusy: boolean;\n hasHeaderActions: boolean;\n ariaLabel: string;\n icon: React.ReactNode;\n pt: DialogParts | undefined;\n onClose: () => void;\n}\n\nconst CloseButton = ({ isBusy, hasHeaderActions, ariaLabel, icon, pt, onClose }: CloseButtonProps) => (\n <button\n type='button'\n {...dialogPartAttributes(pt?.close, 'cratis-dialog__close', closeButtonStyle(hasHeaderActions, pt?.close?.style))}\n disabled={isBusy}\n data-cratis-part='close'\n data-disabled={isBusy || undefined}\n data-busy={isBusy || undefined}\n aria-label={ariaLabel}\n onClick={onClose}\n >\n <span aria-hidden='true'>{icon}</span>\n </button>\n);\n\ninterface TitleProps {\n title: DialogProps['title'];\n focusesTitle: boolean;\n titleRef: React.Ref<HTMLHeadingElement>;\n pt: DialogParts | undefined;\n}\n\nconst Title = ({ title, focusesTitle, titleRef, pt }: TitleProps) => (\n <Heading\n {...dialogPartAttributes(pt?.title, 'cratis-dialog__title')}\n slot='title'\n tabIndex={focusesTitle ? -1 : undefined}\n ref={titleRef}\n data-cratis-part='title'\n >\n {title}\n </Heading>\n);\n\ninterface SubtitleProps {\n subtitle: DialogProps['subtitle'];\n subtitleId: string;\n pt: DialogParts | undefined;\n}\n\nconst Subtitle = ({ subtitle, subtitleId, pt }: SubtitleProps) => (\n <p\n {...dialogPartAttributes(pt?.subtitle, 'cratis-dialog__subtitle')}\n id={subtitleId}\n data-cratis-part='subtitle'\n >\n {subtitle}\n </p>\n);\n\n/** Props of the dialog header. */\nexport interface DialogHeaderProps extends HeaderActionsProps {\n subtitle: DialogProps['subtitle'];\n subtitleId: string;\n hasSubtitle: boolean;\n hasHeaderActions: boolean;\n focusesTitle: boolean;\n titleRef: React.Ref<HTMLHeadingElement>;\n isBusy: boolean;\n closeAriaLabel: string;\n closeIcon: React.ReactNode;\n onClose: () => void;\n}\n\n/** The dialog header: title, subtitle, header actions and the close button. */\nexport const DialogHeader = (props: DialogHeaderProps) => {\n const { pt, title, subtitle, subtitleId, hasSubtitle, hasHeaderActions, focusesTitle, titleRef } = props;\n const { showsCloseButton, isBusy, closeAriaLabel, closeIcon, onClose } = props;\n\n return (\n <header\n {...dialogPartAttributes(pt?.header, 'cratis-dialog__header')}\n data-cratis-part='header'\n >\n <Title title={title} focusesTitle={focusesTitle} titleRef={titleRef} pt={pt} />\n {hasSubtitle && <Subtitle subtitle={subtitle} subtitleId={subtitleId} pt={pt} />}\n {hasHeaderActions && <HeaderActions {...props} />}\n {showsCloseButton && (\n <CloseButton\n isBusy={isBusy}\n hasHeaderActions={hasHeaderActions}\n ariaLabel={closeAriaLabel}\n icon={closeIcon}\n pt={pt}\n onClose={onClose}\n />\n )}\n </header>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;AAYA,MAAM,kBAAkB,GAAG,CAAC,cAAuB,EAAE,KAAsC,MAA2B;AAClH,IAAA,OAAO,EAAE,aAAa;AACtB,IAAA,UAAU,EAAE,CAAC;AACb,IAAA,OAAO,EAAE,CAAC;AACV,IAAA,WAAW,EAAE,KAAK;AAClB,IAAA,UAAU,EAAE,QAAQ;AACpB,IAAA,GAAG,EAAE,SAAS;IACd,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AAE,EAAE,EAAE,GAAI,EAC9E,WAAW,IAAIA,GAAA,CAAC,QAAQ,IAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,GAAI,EAC/E,gBAAgB,IAAIA,GAAA,CAAC,aAAa,OAAK,KAAK,EAAA,CAAI,EAChD,gBAAgB,KACbA,GAAA,CAAC,WAAW,IACR,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,cAAc,EACzB,IAAI,EAAE,SAAS,EACf,EAAE,EAAE,EAAE,EACN,OAAO,EAAE,OAAO,GAClB,CACL,CAAA,EAAA,CACI;AAEjB;;"}
@@ -1,8 +1,7 @@
1
- import type React from 'react';
2
1
  import type { DialogProps } from './Dialog.js';
3
2
  /**
4
3
  * A modal dialog with Arc host integration, typed footer actions, busy/validity
5
4
  * state, controlled dismissal, and stable Cratis-owned styling parts.
6
5
  */
7
- export declare const DialogImplementation: (incomingProps: DialogProps) => React.JSX.Element | null;
6
+ export declare const DialogImplementation: (incomingProps: DialogProps) => import("react").JSX.Element;
8
7
  //# sourceMappingURL=DialogImplementation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DialogImplementation.d.ts","sourceRoot":"","sources":["../../../Dialogs/DialogImplementation.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAU,CAAC;AAiD5C;;;GAGG;AACH,eAAO,MAAM,oBAAoB,kBAAmB,WAAW,6BAghB9D,CAAC"}
1
+ {"version":3,"file":"DialogImplementation.d.ts","sourceRoot":"","sources":["../../../Dialogs/DialogImplementation.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAU,CAAC;AAuC5C;;;GAGG;AACH,eAAO,MAAM,oBAAoB,kBAAmB,WAAW,gCA0H9D,CAAC"}