@cratis/components 4.42.1 → 4.42.3

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 (197) 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/ChatTopicEmptyMessage.d.ts +9 -0
  14. package/dist/esm/Chat/ChatTopicEmptyMessage.d.ts.map +1 -0
  15. package/dist/esm/Chat/ChatTopicEmptyMessage.js +19 -0
  16. package/dist/esm/Chat/ChatTopicEmptyMessage.js.map +1 -0
  17. package/dist/esm/Chat/ChatTopicList.d.ts +2 -2
  18. package/dist/esm/Chat/ChatTopicList.d.ts.map +1 -1
  19. package/dist/esm/Chat/ChatTopicList.js +5 -20
  20. package/dist/esm/Chat/ChatTopicList.js.map +1 -1
  21. package/dist/esm/Chat/ChatTopicRow.d.ts +22 -0
  22. package/dist/esm/Chat/ChatTopicRow.d.ts.map +1 -0
  23. package/dist/esm/Chat/ChatTopicRow.js +23 -0
  24. package/dist/esm/Chat/ChatTopicRow.js.map +1 -0
  25. package/dist/esm/Chat/ChatTopicStartButton.d.ts +8 -0
  26. package/dist/esm/Chat/ChatTopicStartButton.d.ts.map +1 -0
  27. package/dist/esm/Chat/ChatTopicStartButton.js +7 -0
  28. package/dist/esm/Chat/ChatTopicStartButton.js.map +1 -0
  29. package/dist/esm/CommandDialog/CommandStepperContent.d.ts.map +1 -1
  30. package/dist/esm/CommandDialog/CommandStepperContent.js +31 -119
  31. package/dist/esm/CommandDialog/CommandStepperContent.js.map +1 -1
  32. package/dist/esm/CommandDialog/CommandStepperList.d.ts +19 -0
  33. package/dist/esm/CommandDialog/CommandStepperList.d.ts.map +1 -0
  34. package/dist/esm/CommandDialog/CommandStepperList.js +20 -0
  35. package/dist/esm/CommandDialog/CommandStepperList.js.map +1 -0
  36. package/dist/esm/CommandDialog/CommandStepperNavigation.d.ts +20 -0
  37. package/dist/esm/CommandDialog/CommandStepperNavigation.d.ts.map +1 -0
  38. package/dist/esm/CommandDialog/CommandStepperNavigation.js +15 -0
  39. package/dist/esm/CommandDialog/CommandStepperNavigation.js.map +1 -0
  40. package/dist/esm/CommandDialog/CommandStepperPanels.d.ts +20 -0
  41. package/dist/esm/CommandDialog/CommandStepperPanels.d.ts.map +1 -0
  42. package/dist/esm/CommandDialog/CommandStepperPanels.js +9 -0
  43. package/dist/esm/CommandDialog/CommandStepperPanels.js.map +1 -0
  44. package/dist/esm/CommandDialog/CommandStepperStepParts.d.ts +23 -0
  45. package/dist/esm/CommandDialog/CommandStepperStepParts.d.ts.map +1 -0
  46. package/dist/esm/CommandDialog/CommandStepperStepParts.js +9 -0
  47. package/dist/esm/CommandDialog/CommandStepperStepParts.js.map +1 -0
  48. package/dist/esm/CommandDialog/commandStepperFields.d.ts +6 -0
  49. package/dist/esm/CommandDialog/commandStepperFields.d.ts.map +1 -0
  50. package/dist/esm/CommandDialog/commandStepperFields.js +54 -0
  51. package/dist/esm/CommandDialog/commandStepperFields.js.map +1 -0
  52. package/dist/esm/CommandDialog/joinClassNames.d.ts +3 -0
  53. package/dist/esm/CommandDialog/joinClassNames.d.ts.map +1 -0
  54. package/dist/esm/CommandDialog/joinClassNames.js +4 -0
  55. package/dist/esm/CommandDialog/joinClassNames.js.map +1 -0
  56. package/dist/esm/CommandDialog/resolveStepperLabels.d.ts +20 -0
  57. package/dist/esm/CommandDialog/resolveStepperLabels.d.ts.map +1 -0
  58. package/dist/esm/CommandDialog/resolveStepperLabels.js +8 -0
  59. package/dist/esm/CommandDialog/resolveStepperLabels.js.map +1 -0
  60. package/dist/esm/CommandDialog/useStepValidation.d.ts +7 -0
  61. package/dist/esm/CommandDialog/useStepValidation.d.ts.map +1 -0
  62. package/dist/esm/CommandDialog/useStepValidation.js +14 -0
  63. package/dist/esm/CommandDialog/useStepValidation.js.map +1 -0
  64. package/dist/esm/CommandDialog/useStepperState.d.ts +30 -0
  65. package/dist/esm/CommandDialog/useStepperState.d.ts.map +1 -0
  66. package/dist/esm/CommandDialog/useStepperState.js +37 -0
  67. package/dist/esm/CommandDialog/useStepperState.js.map +1 -0
  68. package/dist/esm/CommandForm/fields/ChipsField.d.ts +1 -1
  69. package/dist/esm/CommandForm/fields/ChipsField.d.ts.map +1 -1
  70. package/dist/esm/CommandForm/fields/ChipsField.js +6 -42
  71. package/dist/esm/CommandForm/fields/ChipsField.js.map +1 -1
  72. package/dist/esm/CommandForm/fields/ChipsInput.d.ts +18 -0
  73. package/dist/esm/CommandForm/fields/ChipsInput.d.ts.map +1 -0
  74. package/dist/esm/CommandForm/fields/ChipsInput.js +12 -0
  75. package/dist/esm/CommandForm/fields/ChipsInput.js.map +1 -0
  76. package/dist/esm/CommandForm/fields/ChipsItem.d.ts +14 -0
  77. package/dist/esm/CommandForm/fields/ChipsItem.d.ts.map +1 -0
  78. package/dist/esm/CommandForm/fields/ChipsItem.js +14 -0
  79. package/dist/esm/CommandForm/fields/ChipsItem.js.map +1 -0
  80. package/dist/esm/CommandForm/fields/ChipsRoot.d.ts +15 -0
  81. package/dist/esm/CommandForm/fields/ChipsRoot.d.ts.map +1 -0
  82. package/dist/esm/CommandForm/fields/ChipsRoot.js +11 -0
  83. package/dist/esm/CommandForm/fields/ChipsRoot.js.map +1 -0
  84. package/dist/esm/CommandForm/fields/PasswordField.d.ts.map +1 -1
  85. package/dist/esm/CommandForm/fields/PasswordField.js +4 -14
  86. package/dist/esm/CommandForm/fields/PasswordField.js.map +1 -1
  87. package/dist/esm/CommandForm/fields/PasswordInput.d.ts +17 -0
  88. package/dist/esm/CommandForm/fields/PasswordInput.d.ts.map +1 -0
  89. package/dist/esm/CommandForm/fields/PasswordInput.js +7 -0
  90. package/dist/esm/CommandForm/fields/PasswordInput.js.map +1 -0
  91. package/dist/esm/CommandForm/fields/PasswordRoot.d.ts +15 -0
  92. package/dist/esm/CommandForm/fields/PasswordRoot.d.ts.map +1 -0
  93. package/dist/esm/CommandForm/fields/PasswordRoot.js +7 -0
  94. package/dist/esm/CommandForm/fields/PasswordRoot.js.map +1 -0
  95. package/dist/esm/CommandForm/fields/PasswordToggle.d.ts +13 -0
  96. package/dist/esm/CommandForm/fields/PasswordToggle.d.ts.map +1 -0
  97. package/dist/esm/CommandForm/fields/PasswordToggle.js +9 -0
  98. package/dist/esm/CommandForm/fields/PasswordToggle.js.map +1 -0
  99. package/dist/esm/CommandForm/fields/useChipsDraft.d.ts +19 -0
  100. package/dist/esm/CommandForm/fields/useChipsDraft.d.ts.map +1 -0
  101. package/dist/esm/CommandForm/fields/useChipsDraft.js +19 -0
  102. package/dist/esm/CommandForm/fields/useChipsDraft.js.map +1 -0
  103. package/dist/esm/Common/CratisComponentsProvider.d.ts.map +1 -1
  104. package/dist/esm/Common/CratisComponentsProvider.js +1 -44
  105. package/dist/esm/Common/CratisComponentsProvider.js.map +1 -1
  106. package/dist/esm/Common/legacyLocaleMessages.d.ts +7 -0
  107. package/dist/esm/Common/legacyLocaleMessages.d.ts.map +1 -0
  108. package/dist/esm/Common/legacyLocaleMessages.js +43 -0
  109. package/dist/esm/Common/legacyLocaleMessages.js.map +1 -0
  110. package/dist/esm/DataTables/DataTableCore.d.ts +1 -1
  111. package/dist/esm/DataTables/DataTableCore.d.ts.map +1 -1
  112. package/dist/esm/DataTables/DataTableCore.js +12 -66
  113. package/dist/esm/DataTables/DataTableCore.js.map +1 -1
  114. package/dist/esm/DataTables/DataTableHead.d.ts +23 -0
  115. package/dist/esm/DataTables/DataTableHead.d.ts.map +1 -0
  116. package/dist/esm/DataTables/DataTableHead.js +12 -0
  117. package/dist/esm/DataTables/DataTableHead.js.map +1 -0
  118. package/dist/esm/DataTables/DataTableRows.d.ts +19 -0
  119. package/dist/esm/DataTables/DataTableRows.d.ts.map +1 -0
  120. package/dist/esm/DataTables/DataTableRows.js +7 -0
  121. package/dist/esm/DataTables/DataTableRows.js.map +1 -0
  122. package/dist/esm/DataTables/DataTableTable.d.ts +20 -0
  123. package/dist/esm/DataTables/DataTableTable.d.ts.map +1 -0
  124. package/dist/esm/DataTables/DataTableTable.js +10 -0
  125. package/dist/esm/DataTables/DataTableTable.js.map +1 -0
  126. package/dist/esm/DataTables/TablePaginatorImplementation.js +1 -1
  127. package/dist/esm/DataTables/useDataTableRows.d.ts +40 -0
  128. package/dist/esm/DataTables/useDataTableRows.d.ts.map +1 -0
  129. package/dist/esm/DataTables/useDataTableRows.js +49 -0
  130. package/dist/esm/DataTables/useDataTableRows.js.map +1 -0
  131. package/dist/esm/Dialogs/DialogImplementation.js +1 -1
  132. package/dist/esm/Dropdown/useDropdownState.js +1 -1
  133. package/dist/esm/Filter/FilterPanel.d.ts +69 -0
  134. package/dist/esm/Filter/FilterPanel.d.ts.map +1 -1
  135. package/dist/esm/Filter/FilterPanel.js +6 -21
  136. package/dist/esm/Filter/FilterPanel.js.map +1 -1
  137. package/dist/esm/Filter/FilterPanelContent.d.ts +14 -0
  138. package/dist/esm/Filter/FilterPanelContent.d.ts.map +1 -0
  139. package/dist/esm/Filter/FilterPanelContent.js +8 -0
  140. package/dist/esm/Filter/FilterPanelContent.js.map +1 -0
  141. package/dist/esm/Filter/usePortalTarget.d.ts +13 -0
  142. package/dist/esm/Filter/usePortalTarget.d.ts.map +1 -0
  143. package/dist/esm/Filter/usePortalTarget.js +24 -0
  144. package/dist/esm/Filter/usePortalTarget.js.map +1 -0
  145. package/dist/esm/Notifications/ToastCloseButton.d.ts +11 -0
  146. package/dist/esm/Notifications/ToastCloseButton.d.ts.map +1 -0
  147. package/dist/esm/Notifications/ToastCloseButton.js +14 -0
  148. package/dist/esm/Notifications/ToastCloseButton.js.map +1 -0
  149. package/dist/esm/Notifications/ToastContent.d.ts +10 -0
  150. package/dist/esm/Notifications/ToastContent.d.ts.map +1 -0
  151. package/dist/esm/Notifications/ToastContent.js +7 -0
  152. package/dist/esm/Notifications/ToastContent.js.map +1 -0
  153. package/dist/esm/Notifications/Toaster.d.ts.map +1 -1
  154. package/dist/esm/Notifications/Toaster.js +8 -17
  155. package/dist/esm/Notifications/Toaster.js.map +1 -1
  156. package/dist/esm/Notifications/useToastAutoDismiss.d.ts +4 -0
  157. package/dist/esm/Notifications/useToastAutoDismiss.d.ts.map +1 -0
  158. package/dist/esm/Notifications/useToastAutoDismiss.js +20 -0
  159. package/dist/esm/Notifications/useToastAutoDismiss.js.map +1 -0
  160. package/dist/esm/PivotViewer/PivotViewer.d.ts +1 -1
  161. package/dist/esm/PivotViewer/PivotViewer.d.ts.map +1 -1
  162. package/dist/esm/PivotViewer/PivotViewer.js +24 -31
  163. package/dist/esm/PivotViewer/PivotViewer.js.map +1 -1
  164. package/dist/esm/PivotViewer/components/PivotViewerContent.d.ts +40 -0
  165. package/dist/esm/PivotViewer/components/PivotViewerContent.d.ts.map +1 -0
  166. package/dist/esm/PivotViewer/components/PivotViewerContent.js +13 -0
  167. package/dist/esm/PivotViewer/components/PivotViewerContent.js.map +1 -0
  168. package/dist/esm/PivotViewer/hooks/usePivotViewerViewState.d.ts +37 -0
  169. package/dist/esm/PivotViewer/hooks/usePivotViewerViewState.d.ts.map +1 -0
  170. package/dist/esm/PivotViewer/hooks/usePivotViewerViewState.js +35 -0
  171. package/dist/esm/PivotViewer/hooks/usePivotViewerViewState.js.map +1 -0
  172. package/dist/esm/TimeMachine/EventCard.d.ts +9 -0
  173. package/dist/esm/TimeMachine/EventCard.d.ts.map +1 -0
  174. package/dist/esm/TimeMachine/EventCard.js +8 -0
  175. package/dist/esm/TimeMachine/EventCard.js.map +1 -0
  176. package/dist/esm/TimeMachine/EventSeparator.d.ts +11 -0
  177. package/dist/esm/TimeMachine/EventSeparator.d.ts.map +1 -0
  178. package/dist/esm/TimeMachine/EventSeparator.js +7 -0
  179. package/dist/esm/TimeMachine/EventSeparator.js.map +1 -0
  180. package/dist/esm/TimeMachine/EventTimelineItem.d.ts +14 -0
  181. package/dist/esm/TimeMachine/EventTimelineItem.d.ts.map +1 -0
  182. package/dist/esm/TimeMachine/EventTimelineItem.js +9 -0
  183. package/dist/esm/TimeMachine/EventTimelineItem.js.map +1 -0
  184. package/dist/esm/TimeMachine/EventsScrollButton.d.ts +10 -0
  185. package/dist/esm/TimeMachine/EventsScrollButton.d.ts.map +1 -0
  186. package/dist/esm/TimeMachine/EventsScrollButton.js +6 -0
  187. package/dist/esm/TimeMachine/EventsScrollButton.js.map +1 -0
  188. package/dist/esm/TimeMachine/EventsView.d.ts +1 -1
  189. package/dist/esm/TimeMachine/EventsView.d.ts.map +1 -1
  190. package/dist/esm/TimeMachine/EventsView.js +6 -39
  191. package/dist/esm/TimeMachine/EventsView.js.map +1 -1
  192. package/dist/esm/TimeMachine/useScrollEdges.d.ts +13 -0
  193. package/dist/esm/TimeMachine/useScrollEdges.d.ts.map +1 -0
  194. package/dist/esm/TimeMachine/useScrollEdges.js +40 -0
  195. package/dist/esm/TimeMachine/useScrollEdges.js.map +1 -0
  196. package/dist/esm/Toolbar/ToolbarFolder.js +1 -1
  197. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatTopicEmptyMessage.js","sources":["../../../Chat/ChatTopicEmptyMessage.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 { ChatTopicListLabels } from './ChatTopicList';\nimport { ChatStatus } from './ChatStatus';\n\ninterface ChatTopicEmptyMessageProps {\n status: ChatStatus;\n labels?: ChatTopicListLabels;\n}\n\nconst StatusText = ({ status, labels }: ChatTopicEmptyMessageProps) => {\n if (status === ChatStatus.Loading) {\n return <span key={status} role='status'>{labels?.loading ?? 'Loading topics…'}</span>;\n }\n if (status === ChatStatus.Failed) {\n return <span key={status} role='alert'>{labels?.failed ?? 'Could not load topics.'}</span>;\n }\n if (status === ChatStatus.Unauthorized) {\n return <span key={status} role='alert'>{labels?.unauthorized ?? 'You are not authorized to view these topics.'}</span>;\n }\n return <>{labels?.empty ?? 'No topics yet. Start the first one!'}</>;\n};\n\nexport const ChatTopicEmptyMessage = (props: ChatTopicEmptyMessageProps) => (\n <p className='cratis-chat-topics__empty'>\n <StatusText {...props} />\n </p>\n);\n"],"names":["_jsx"],"mappings":";;;AAWA,MAAM,UAAU,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,EAA8B,KAAI;AAClE,IAAA,IAAI,MAAM,KAAK,UAAU,CAAC,OAAO,EAAE;AAC/B,QAAA,OAAOA,GAAA,CAAA,MAAA,EAAA,EAAmB,IAAI,EAAC,QAAQ,EAAA,QAAA,EAAE,MAAM,EAAE,OAAO,IAAI,iBAAiB,EAAA,EAA3D,MAAM,CAA6D;IACzF;AACA,IAAA,IAAI,MAAM,KAAK,UAAU,CAAC,MAAM,EAAE;AAC9B,QAAA,OAAOA,GAAA,CAAA,MAAA,EAAA,EAAmB,IAAI,EAAC,OAAO,EAAA,QAAA,EAAE,MAAM,EAAE,MAAM,IAAI,wBAAwB,EAAA,EAAhE,MAAM,CAAkE;IAC9F;AACA,IAAA,IAAI,MAAM,KAAK,UAAU,CAAC,YAAY,EAAE;AACpC,QAAA,OAAOA,GAAA,CAAA,MAAA,EAAA,EAAmB,IAAI,EAAC,OAAO,EAAA,QAAA,EAAE,MAAM,EAAE,YAAY,IAAI,8CAA8C,EAAA,EAA5F,MAAM,CAA8F;IAC1H;AACA,IAAA,OAAOA,0BAAG,MAAM,EAAE,KAAK,IAAI,qCAAqC,GAAI;AACxE,CAAC;MAEY,qBAAqB,GAAG,CAAC,KAAiC,MACnEA,GAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAC,2BAA2B,YACpCA,GAAA,CAAC,UAAU,OAAK,KAAK,EAAA,CAAI,EAAA,CACzB;;"}
@@ -1,11 +1,11 @@
1
1
  import { type ReactNode } from 'react';
2
- import { type BuildAvatarUrlParams } from './Kit/Avatar/index.js';
2
+ import type { BuildAvatarUrlParams } from './Kit/Avatar/index.js';
3
3
  import type { ChatAuthor } from './ChatAuthor.js';
4
4
  import { type ChatIdentifier } from './ChatIdentifier.js';
5
5
  import type { ChatTopic } from './ChatTopic.js';
6
6
  import type { ChatTopicAction } from './ChatTopicAction.js';
7
7
  import { ChatStatus } from './ChatStatus.js';
8
- import { type RelativeTimestampLabels } from './relativeTimestamp.js';
8
+ import type { RelativeTimestampLabels } from './relativeTimestamp.js';
9
9
  /** Overrides for every label the {@link ChatTopicList} renders. Any field left unset falls back
10
10
  * to a literal English default. */
11
11
  export interface ChatTopicListLabels {
@@ -1 +1 @@
1
- {"version":3,"file":"ChatTopicList.d.ts","sourceRoot":"","sources":["../../../Chat/ChatTopicList.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAU,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAsB,KAAK,oBAAoB,EAAE,MAAM,uBAAc,CAAC;AAE7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAc,CAAC;AAC/C,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,qBAAkB,CAAC;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAmB,CAAC;AAEzD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAc,CAAC;AAE1C,OAAO,EAAqB,KAAK,uBAAuB,EAAE,MAAM,wBAAqB,CAAC;AAmBtF;oCACoC;A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MAAM,WAAW,kBAAkB,CAAC,MAAM,SAAS,SAAS,GAAG,SAAS;IACpE;;;OAGG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IAEjB,mKAAmK;IACnK,MAAM,CAAC,EAAE,UAAU,CAAC;IAEpB;;;OAGG;IACH,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAEhC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IAErB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,UAAU,CAAC;IAEpD;;;;;OAKG;IACH,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,UAAU,KAAK,SAAS,CAAC;IAE3E;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IAE5C,oFAAoF;IACpF,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,MAAM,CAAC;IAE1D,8FAA8F;IAC9F,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAE7B,0EAA0E;IAC1E,YAAY,CAAC,EAAE,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC;IAEzC,yDAAyD;IACzD,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,SAAS,SAAS,GAAG,SAAS,iIAY/D,kBAAkB,CAAC,MAAM,CAAC,gCAwC5B,CAAC"}
@@ -1,16 +1,15 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import { useRef } from 'react';
3
- import { PersonAvatarCircle } from './Kit/Avatar/PersonAvatarCircle.js';
4
3
  import { ChatAuthorKind } from './Kit/ChatAuthorKind.js';
5
4
  import { chatIdentifierString } from './ChatIdentifier.js';
6
- import { ChatTopicActions } from './ChatTopicActions.js';
5
+ import { ChatTopicEmptyMessage } from './ChatTopicEmptyMessage.js';
6
+ import { ChatTopicRow } from './ChatTopicRow.js';
7
+ import { ChatTopicStartButton } from './ChatTopicStartButton.js';
7
8
  import { ChatStatus } from './ChatStatus.js';
8
9
  import { isTopicUnnamed } from './isTopicUnnamed.js';
9
- import { relativeTimestamp } from './relativeTimestamp.js';
10
10
  import { useTopicActionFocusRecovery } from './useTopicActionFocusRecovery.js';
11
11
  import { topicsByActivity } from './topicsByActivity.js';
12
12
 
13
- const PlusIcon = () => (jsxs("svg", { width: '14', height: '14', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: '2.5', "aria-hidden": 'true', children: [jsx("line", { x1: '12', y1: '5', x2: '12', y2: '19' }), jsx("line", { x1: '5', y1: '12', x2: '19', y2: '12' })] }));
14
13
  const ChatTopicList = ({ topics, status = ChatStatus.Ready, onOpen, onStart, authorOf, renderAvatar, isTopicUnnamed: isTopicUnnamed$1, buildAvatarUrl, labels, topicActions, className, }) => {
15
14
  const unnamed = isTopicUnnamed$1 ?? isTopicUnnamed;
16
15
  const listRef = useRef(null);
@@ -20,22 +19,8 @@ const ChatTopicList = ({ topics, status = ChatStatus.Ready, onOpen, onStart, aut
20
19
  name: chatIdentifierString(authorId),
21
20
  kind: ChatAuthorKind.User,
22
21
  };
23
- return (jsxs("div", { className: `cratis-chat-topics${className ? ` ${className}` : ''}`, "aria-busy": status === ChatStatus.Loading && topics.length > 0 || undefined, children: [onStart && (jsxs("button", { type: 'button', className: 'cratis-chat-topics__start', disabled: status === ChatStatus.Unauthorized, onClick: onStart, children: [jsx(PlusIcon, {}), jsx("span", { children: labels?.newTopic ?? 'New topic' })] })), (topics.length === 0 || status === ChatStatus.Failed || status === ChatStatus.Unauthorized) && (jsx("p", { className: 'cratis-chat-topics__empty', children: status === ChatStatus.Loading ? (jsx("span", { role: 'status', children: labels?.loading ?? 'Loading topics…' }, status)) : status === ChatStatus.Failed ? (jsx("span", { role: 'alert', children: labels?.failed ?? 'Could not load topics.' }, status)) : status === ChatStatus.Unauthorized ? (jsx("span", { role: 'alert', children: labels?.unauthorized ?? 'You are not authorized to view these topics.' }, status)) : (labels?.empty ?? 'No topics yet. Start the first one!') })), jsx("ul", { ref: listRef, className: 'cratis-chat-topics__list', children: status !== ChatStatus.Unauthorized && orderedTopics.map((topic) => {
24
- const starter = topic.startedBy === undefined
25
- ? undefined
26
- : authorFor(topic.startedBy);
27
- const isPending = unnamed(topic);
28
- const activity = topic.lastActivity ?? topic.started;
29
- const topicName = isPending ? (labels?.unnamedTopic ?? 'New topic') : topic.name;
30
- const availableActions = (topicActions ?? []).filter((action) => action.isAvailable?.(topic) ?? true);
31
- const topicButton = (jsxs("button", { type: 'button', className: 'cratis-chat-topics__topic', onClick: () => onOpen(topic), children: [topic.startedBy !== undefined &&
32
- starter &&
33
- (renderAvatar ? (renderAvatar(topic.startedBy, starter)) : (jsx(PersonAvatarCircle, { userId: chatIdentifierString(topic.startedBy), name: starter.name, hasAvatar: starter.hasAvatar ?? false, size: 28, ownerType: starter.kind === ChatAuthorKind.Agent
34
- ? 'Agents'
35
- : 'Users', version: starter.avatarVersion, buildAvatarUrl: buildAvatarUrl }))), jsxs("span", { className: 'cratis-chat-topics__details', children: [jsx("span", { className: `cratis-chat-topics__name${isPending ? ' cratis-chat-topics__name--pending' : ''}`, children: topicName }), starter && (jsx("span", { className: 'cratis-chat-topics__started-by', children: (labels?.startedBy ?? 'Started by {name}').replace('{name}', starter.name) }))] }), activity !== undefined && (jsx("span", { className: 'cratis-chat-topics__activity', children: relativeTimestamp(activity, new Date(), labels?.timestamps) }))] }));
36
- const topicKey = chatIdentifierString(topic.id);
37
- return (jsxs("li", { className: availableActions.length > 0 ? 'cratis-chat-topics__row' : undefined, children: [topicButton, availableActions.length > 0 && (jsx(ChatTopicActions, { topic: topic, topicName: topicName, actions: availableActions, onActionFocus: onActionFocus(topicKey), onActionBlur: onActionBlur }))] }, topicKey));
38
- }) })] }));
22
+ const showMessage = topics.length === 0 || status === ChatStatus.Failed || status === ChatStatus.Unauthorized;
23
+ return (jsxs("div", { className: `cratis-chat-topics${className ? ` ${className}` : ''}`, "aria-busy": status === ChatStatus.Loading && topics.length > 0 || undefined, children: [onStart && jsx(ChatTopicStartButton, { label: labels?.newTopic, disabled: status === ChatStatus.Unauthorized, onStart: onStart }), showMessage && jsx(ChatTopicEmptyMessage, { status: status, labels: labels }), jsx("ul", { ref: listRef, className: 'cratis-chat-topics__list', children: orderedTopics.map((topic) => (jsx(ChatTopicRow, { topic: topic, isPending: unnamed(topic), starter: topic.startedBy === undefined ? undefined : authorFor(topic.startedBy), labels: labels, availableActions: (topicActions ?? []).filter((action) => action.isAvailable?.(topic) ?? true), onOpen: onOpen, renderAvatar: renderAvatar, buildAvatarUrl: buildAvatarUrl, onActionFocus: onActionFocus, onActionBlur: onActionBlur }, chatIdentifierString(topic.id)))) })] }));
39
24
  };
40
25
 
41
26
  export { ChatTopicList };
@@ -1 +1 @@
1
- {"version":3,"file":"ChatTopicList.js","sources":["../../../Chat/ChatTopicList.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 { useRef, type ReactNode } from 'react';\nimport { PersonAvatarCircle, type BuildAvatarUrlParams } from './Kit/Avatar';\nimport { ChatAuthorKind } from './Kit/ChatAuthorKind';\nimport type { ChatAuthor } from './ChatAuthor';\nimport { chatIdentifierString, type ChatIdentifier } from './ChatIdentifier';\nimport type { ChatTopic } from './ChatTopic';\nimport type { ChatTopicAction } from './ChatTopicAction';\nimport { ChatTopicActions } from './ChatTopicActions';\nimport { ChatStatus } from './ChatStatus';\nimport { isTopicUnnamed as defaultIsTopicUnnamed } from './isTopicUnnamed';\nimport { relativeTimestamp, type RelativeTimestampLabels } from './relativeTimestamp';\nimport { useTopicActionFocusRecovery } from './useTopicActionFocusRecovery';\nimport { topicsByActivity } from './topicsByActivity';\n\nconst PlusIcon = () => (\n <svg\n width='14'\n height='14'\n viewBox='0 0 24 24'\n fill='none'\n stroke='currentColor'\n strokeWidth='2.5'\n aria-hidden='true'\n >\n <line x1='12' y1='5' x2='12' y2='19' />\n <line x1='5' y1='12' x2='19' y2='12' />\n </svg>\n);\n\n/** Overrides for every label the {@link ChatTopicList} renders. Any field left unset falls back\n * to a literal English default. */\nexport interface ChatTopicListLabels {\n /** The new-topic button. Defaults to `'New topic'`. */\n newTopic?: string;\n\n /** Placeholder name for a topic that has not been named yet. Defaults to `'New topic'`. */\n unnamedTopic?: string;\n\n /** The started-by line under a topic's name. `{name}` is substituted. Defaults to `'Started by {name}'`. */\n startedBy?: string;\n\n /** Shown while loading without topics. Defaults to `'Loading topics…'`. */\n loading?: string;\n\n /** Shown when loading topics fails, alongside any existing topics. Defaults to `'Could not load topics.'`. */\n failed?: string;\n\n /** Shown when access is denied; replaces any existing topics. Defaults to `'You are not authorized to view these topics.'`. */\n unauthorized?: string;\n\n /** Shown when there are no topics yet. Defaults to `'No topics yet. Start the first one!'`. */\n empty?: string;\n\n /** Overrides for the relative last-activity timestamps. */\n timestamps?: RelativeTimestampLabels;\n}\n\n/**\n * Props for {@link ChatTopicList}.\n * @typeParam TTopic The host's topic type — anything extending {@link ChatTopic}.\n */\nexport interface ChatTopicListProps<TTopic extends ChatTopic = ChatTopic> {\n /**\n * The topics, in any order — the list orders them by most recent activity itself. Hand this\n * the array a live (observable) query delivers and the list re-renders as it changes.\n */\n topics: TTopic[];\n\n /** Query display state. Defaults to {@link ChatStatus.Ready}; existing topics remain visible on loading or failure, and unauthorized disables starting a topic. */\n status?: ChatStatus;\n\n /**\n * Invoked when a topic is picked from the list.\n * @param topic The topic that was picked.\n */\n onOpen: (topic: TTopic) => void;\n\n /**\n * Invoked when a new topic is asked for. Creating the topic is the host's business — the\n * component only raises the intent. Omit to leave the new-topic affordance off.\n */\n onStart?: () => void;\n\n /**\n * Resolves an author id into what it takes to render whoever started a topic. Omit to fall\n * back to rendering the id itself as the name.\n * @param authorId The identifier of the author to resolve.\n * @returns The author.\n */\n authorOf?: (authorId: ChatIdentifier) => ChatAuthor;\n\n /**\n * Renders the avatar for whoever started a topic, replacing the built-in initials circle.\n * @param authorId The identifier of the author.\n * @param author The resolved author, as {@link authorOf} answered.\n * @returns What to render.\n */\n renderAvatar?: (authorId: ChatIdentifier, author: ChatAuthor) => ReactNode;\n\n /**\n * Decides whether a topic counts as unnamed and renders the pending placeholder. Defaults to\n * \"no name, or only whitespace\" — override when the host's backend stores a literal\n * placeholder for unnamed topics instead.\n * @param topic The topic to check.\n * @returns True when the topic has no usable name yet.\n */\n isTopicUnnamed?: (topic: TTopic) => boolean;\n\n /** Builds the avatar image URL for topic starters. Omit to always show initials. */\n buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;\n\n /** Overrides for every label rendered. Unset fields fall back to literal English defaults. */\n labels?: ChatTopicListLabels;\n\n /** The host's actions to offer on each topic where they are available. */\n topicActions?: ChatTopicAction<TTopic>[];\n\n /** Additional class name for the list's root element. */\n className?: string;\n}\n\n/**\n * The topics of a chat, most recently active first — pick one to open its conversation, or start\n * a new one. A topic that has not been named yet renders a placeholder in a pending style: with\n * host-side auto-naming, the name arrives through the data once the host has produced it, and\n * the placeholder simply stops being needed.\n */\nexport const ChatTopicList = <TTopic extends ChatTopic = ChatTopic>({\n topics,\n status = ChatStatus.Ready,\n onOpen,\n onStart,\n authorOf,\n renderAvatar,\n isTopicUnnamed,\n buildAvatarUrl,\n labels,\n topicActions,\n className,\n}: ChatTopicListProps<TTopic>) => {\n const unnamed = isTopicUnnamed ?? defaultIsTopicUnnamed;\n const listRef = useRef<HTMLUListElement>(null);\n const orderedTopics = status === ChatStatus.Unauthorized ? [] : topicsByActivity(topics);\n const { onActionFocus, onActionBlur } = useTopicActionFocusRecovery(\n listRef,\n orderedTopics.map((topic) => chatIdentifierString(topic.id)),\n );\n\n const authorFor = (authorId: ChatIdentifier): ChatAuthor =>\n authorOf?.(authorId) ?? {\n name: chatIdentifierString(authorId),\n kind: ChatAuthorKind.User,\n };\n\n return (\n <div className={`cratis-chat-topics${className ? ` ${className}` : ''}`} aria-busy={status === ChatStatus.Loading && topics.length > 0 || undefined}>\n {onStart && (\n <button\n type='button'\n className='cratis-chat-topics__start'\n disabled={status === ChatStatus.Unauthorized}\n onClick={onStart}\n >\n <PlusIcon />\n <span>{labels?.newTopic ?? 'New topic'}</span>\n </button>\n )}\n {(topics.length === 0 || status === ChatStatus.Failed || status === ChatStatus.Unauthorized) && (\n <p className='cratis-chat-topics__empty'>\n {status === ChatStatus.Loading ? (\n <span key={status} role='status'>{labels?.loading ?? 'Loading topics…'}</span>\n ) : status === ChatStatus.Failed ? (\n <span key={status} role='alert'>{labels?.failed ?? 'Could not load topics.'}</span>\n ) : status === ChatStatus.Unauthorized ? (\n <span key={status} role='alert'>{labels?.unauthorized ?? 'You are not authorized to view these topics.'}</span>\n ) : (\n labels?.empty ?? 'No topics yet. Start the first one!'\n )}\n </p>\n )}\n <ul ref={listRef} className='cratis-chat-topics__list'>\n {status !== ChatStatus.Unauthorized && orderedTopics.map((topic) => {\n const starter =\n topic.startedBy === undefined\n ? undefined\n : authorFor(topic.startedBy);\n const isPending = unnamed(topic);\n const activity = topic.lastActivity ?? topic.started;\n const topicName = isPending ? (labels?.unnamedTopic ?? 'New topic') : topic.name;\n const availableActions = (topicActions ?? []).filter(\n (action) => action.isAvailable?.(topic) ?? true,\n );\n\n const topicButton = (\n <button\n type='button'\n className='cratis-chat-topics__topic'\n onClick={() => onOpen(topic)}\n >\n {topic.startedBy !== undefined &&\n starter &&\n (renderAvatar ? (\n renderAvatar(topic.startedBy, starter)\n ) : (\n <PersonAvatarCircle\n userId={chatIdentifierString(topic.startedBy)}\n name={starter.name}\n hasAvatar={starter.hasAvatar ?? false}\n size={28}\n ownerType={\n starter.kind === ChatAuthorKind.Agent\n ? 'Agents'\n : 'Users'\n }\n version={starter.avatarVersion}\n buildAvatarUrl={buildAvatarUrl}\n />\n ))}\n <span className='cratis-chat-topics__details'>\n <span\n className={`cratis-chat-topics__name${isPending ? ' cratis-chat-topics__name--pending' : ''}`}\n >\n {topicName}\n </span>\n {starter && (\n <span className='cratis-chat-topics__started-by'>\n {(\n labels?.startedBy ?? 'Started by {name}'\n ).replace('{name}', starter.name)}\n </span>\n )}\n </span>\n {activity !== undefined && (\n <span className='cratis-chat-topics__activity'>\n {relativeTimestamp(\n activity,\n new Date(),\n labels?.timestamps,\n )}\n </span>\n )}\n </button>\n );\n\n const topicKey = chatIdentifierString(topic.id);\n // Reuses the message action overlay styling; keyboard focus reveals the controls.\n return (\n <li\n key={topicKey}\n className={availableActions.length > 0 ? 'cratis-chat-topics__row' : undefined}\n >\n {topicButton}\n {availableActions.length > 0 && (\n <ChatTopicActions<TTopic>\n topic={topic}\n topicName={topicName}\n actions={availableActions}\n onActionFocus={onActionFocus(topicKey)}\n onActionBlur={onActionBlur}\n />\n )}\n </li>\n );\n })}\n </ul>\n </div>\n );\n};\n"],"names":["_jsxs","_jsx","isTopicUnnamed","defaultIsTopicUnnamed"],"mappings":";;;;;;;;;;;;AAiBA,MAAM,QAAQ,GAAG,OACbA,IAAA,CAAA,KAAA,EAAA,EACI,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,KAAK,EAAA,aAAA,EACL,MAAM,aAElBC,GAAA,CAAA,MAAA,EAAA,EAAM,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAA,CAAG,EACvCA,GAAA,CAAA,MAAA,EAAA,EAAM,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAA,CAAG,CAAA,EAAA,CACrC,CACT;AAoGM,MAAM,aAAa,GAAG,CAAuC,EAChE,MAAM,EACN,MAAM,GAAG,UAAU,CAAC,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BAAiB,CACd,QAAQ,EACR,IAAI,IAAI,EAAE,EACV,MAAM,EAAE,UAAU,CACrB,EAAA,CACE,CACV,CAAA,EAAA,CACI,CACZ;oBAED,MAAM,QAAQ,GAAG,oBAAoB,CAAC,KAAK,CAAC,EAAE,CAAC;oBAE/C,QACID,IAAA,CAAA,IAAA,EAAA,EAEI,SAAS,EAAE,gBAAgB,CAAC,MAAM,GAAG,CAAC,GAAG,yBAAyB,GAAG,SAAS,EAAA,QAAA,EAAA,CAE7E,WAAW,EACX,gBAAgB,CAAC,MAAM,GAAG,CAAC,KACxBC,GAAA,CAAC,gBAAgB,IACb,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,gBAAgB,EACzB,aAAa,EAAE,aAAa,CAAC,QAAQ,CAAC,EACtC,YAAY,EAAE,YAAY,EAAA,CAC5B,CACL,CAAA,EAAA,EAZI,QAAQ,CAaZ;AAEb,gBAAA,CAAC,CAAC,EAAA,CACD,CAAA,EAAA,CACH;AAEd;;"}
1
+ {"version":3,"file":"ChatTopicList.js","sources":["../../../Chat/ChatTopicList.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 { useRef, type ReactNode } from 'react';\nimport type { BuildAvatarUrlParams } from './Kit/Avatar';\nimport { ChatAuthorKind } from './Kit/ChatAuthorKind';\nimport type { ChatAuthor } from './ChatAuthor';\nimport { chatIdentifierString, type ChatIdentifier } from './ChatIdentifier';\nimport type { ChatTopic } from './ChatTopic';\nimport type { ChatTopicAction } from './ChatTopicAction';\nimport { ChatTopicEmptyMessage } from './ChatTopicEmptyMessage';\nimport { ChatTopicRow } from './ChatTopicRow';\nimport { ChatTopicStartButton } from './ChatTopicStartButton';\nimport { ChatStatus } from './ChatStatus';\nimport { isTopicUnnamed as defaultIsTopicUnnamed } from './isTopicUnnamed';\nimport type { RelativeTimestampLabels } from './relativeTimestamp';\nimport { useTopicActionFocusRecovery } from './useTopicActionFocusRecovery';\nimport { topicsByActivity } from './topicsByActivity';\n\n/** Overrides for every label the {@link ChatTopicList} renders. Any field left unset falls back\n * to a literal English default. */\nexport interface ChatTopicListLabels {\n /** The new-topic button. Defaults to `'New topic'`. */\n newTopic?: string;\n\n /** Placeholder name for a topic that has not been named yet. Defaults to `'New topic'`. */\n unnamedTopic?: string;\n\n /** The started-by line under a topic's name. `{name}` is substituted. Defaults to `'Started by {name}'`. */\n startedBy?: string;\n\n /** Shown while loading without topics. Defaults to `'Loading topics…'`. */\n loading?: string;\n\n /** Shown when loading topics fails, alongside any existing topics. Defaults to `'Could not load topics.'`. */\n failed?: string;\n\n /** Shown when access is denied; replaces any existing topics. Defaults to `'You are not authorized to view these topics.'`. */\n unauthorized?: string;\n\n /** Shown when there are no topics yet. Defaults to `'No topics yet. Start the first one!'`. */\n empty?: string;\n\n /** Overrides for the relative last-activity timestamps. */\n timestamps?: RelativeTimestampLabels;\n}\n\n/**\n * Props for {@link ChatTopicList}.\n * @typeParam TTopic The host's topic type — anything extending {@link ChatTopic}.\n */\nexport interface ChatTopicListProps<TTopic extends ChatTopic = ChatTopic> {\n /**\n * The topics, in any order — the list orders them by most recent activity itself. Hand this\n * the array a live (observable) query delivers and the list re-renders as it changes.\n */\n topics: TTopic[];\n\n /** Query display state. Defaults to {@link ChatStatus.Ready}; existing topics remain visible on loading or failure, and unauthorized disables starting a topic. */\n status?: ChatStatus;\n\n /**\n * Invoked when a topic is picked from the list.\n * @param topic The topic that was picked.\n */\n onOpen: (topic: TTopic) => void;\n\n /**\n * Invoked when a new topic is asked for. Creating the topic is the host's business — the\n * component only raises the intent. Omit to leave the new-topic affordance off.\n */\n onStart?: () => void;\n\n /**\n * Resolves an author id into what it takes to render whoever started a topic. Omit to fall\n * back to rendering the id itself as the name.\n * @param authorId The identifier of the author to resolve.\n * @returns The author.\n */\n authorOf?: (authorId: ChatIdentifier) => ChatAuthor;\n\n /**\n * Renders the avatar for whoever started a topic, replacing the built-in initials circle.\n * @param authorId The identifier of the author.\n * @param author The resolved author, as {@link authorOf} answered.\n * @returns What to render.\n */\n renderAvatar?: (authorId: ChatIdentifier, author: ChatAuthor) => ReactNode;\n\n /**\n * Decides whether a topic counts as unnamed and renders the pending placeholder. Defaults to\n * \"no name, or only whitespace\" — override when the host's backend stores a literal\n * placeholder for unnamed topics instead.\n * @param topic The topic to check.\n * @returns True when the topic has no usable name yet.\n */\n isTopicUnnamed?: (topic: TTopic) => boolean;\n\n /** Builds the avatar image URL for topic starters. Omit to always show initials. */\n buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;\n\n /** Overrides for every label rendered. Unset fields fall back to literal English defaults. */\n labels?: ChatTopicListLabels;\n\n /** The host's actions to offer on each topic where they are available. */\n topicActions?: ChatTopicAction<TTopic>[];\n\n /** Additional class name for the list's root element. */\n className?: string;\n}\n\n/**\n * The topics of a chat, most recently active first — pick one to open its conversation, or start\n * a new one. A topic that has not been named yet renders a placeholder in a pending style: with\n * host-side auto-naming, the name arrives through the data once the host has produced it, and\n * the placeholder simply stops being needed.\n */\nexport const ChatTopicList = <TTopic extends ChatTopic = ChatTopic>({\n topics,\n status = ChatStatus.Ready,\n onOpen,\n onStart,\n authorOf,\n renderAvatar,\n isTopicUnnamed,\n buildAvatarUrl,\n labels,\n topicActions,\n className,\n}: ChatTopicListProps<TTopic>) => {\n const unnamed = isTopicUnnamed ?? defaultIsTopicUnnamed;\n const listRef = useRef<HTMLUListElement>(null);\n const orderedTopics = status === ChatStatus.Unauthorized ? [] : topicsByActivity(topics);\n const { onActionFocus, onActionBlur } = useTopicActionFocusRecovery(\n listRef,\n orderedTopics.map((topic) => chatIdentifierString(topic.id)),\n );\n\n const authorFor = (authorId: ChatIdentifier): ChatAuthor =>\n authorOf?.(authorId) ?? {\n name: chatIdentifierString(authorId),\n kind: ChatAuthorKind.User,\n };\n\n const showMessage = topics.length === 0 || status === ChatStatus.Failed || status === ChatStatus.Unauthorized;\n\n return (\n <div className={`cratis-chat-topics${className ? ` ${className}` : ''}`} aria-busy={status === ChatStatus.Loading && topics.length > 0 || undefined}>\n {onStart && <ChatTopicStartButton label={labels?.newTopic} disabled={status === ChatStatus.Unauthorized} onStart={onStart} />}\n {showMessage && <ChatTopicEmptyMessage status={status} labels={labels} />}\n <ul ref={listRef} className='cratis-chat-topics__list'>\n {orderedTopics.map((topic) => (\n <ChatTopicRow<TTopic>\n key={chatIdentifierString(topic.id)}\n topic={topic}\n isPending={unnamed(topic)}\n starter={topic.startedBy === undefined ? undefined : authorFor(topic.startedBy)}\n labels={labels}\n availableActions={(topicActions ?? []).filter((action) => action.isAvailable?.(topic) ?? true)}\n onOpen={onOpen}\n renderAvatar={renderAvatar}\n buildAvatarUrl={buildAvatarUrl}\n onActionFocus={onActionFocus}\n onActionBlur={onActionBlur}\n />\n ))}\n </ul>\n </div>\n );\n};\n"],"names":["isTopicUnnamed","defaultIsTopicUnnamed","_jsxs","_jsx"],"mappings":";;;;;;;;;;;;AAqHO,MAAM,aAAa,GAAG,CAAuC,EAChE,MAAM,EACN,MAAM,GAAG,UAAU,CAAC,KAAK,EACzB,MAAM,EACN,OAAO,EACP,QAAQ,EACR,YAAY,kBACZA,gBAAc,EACd,cAAc,EACd,MAAM,EACN,YAAY,EACZ,SAAS,GACgB,KAAI;AAC7B,IAAA,MAAM,OAAO,GAAGA,gBAAc,IAAIC,cAAqB;AACvD,IAAA,MAAM,OAAO,GAAG,MAAM,CAAmB,IAAI,CAAC;AAC9C,IAAA,MAAM,aAAa,GAAG,MAAM,KAAK,UAAU,CAAC,YAAY,GAAG,EAAE,GAAG,gBAAgB,CAAC,MAAM,CAAC;IACxF,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,2BAA2B,CAC/D,OAAO,EACP,aAAa,CAAC,GAAG,CAAC,CAAC,KAAK,KAAK,oBAAoB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAC/D;AAED,IAAA,MAAM,SAAS,GAAG,CAAC,QAAwB,KAC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AK,CAAC,IAAI,IAAI,CAAC,EAC9F,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,YAAY,IAVrB,oBAAoB,CAAC,KAAK,CAAC,EAAE,CAAC,CAWrC,CACL,CAAC,EAAA,CACD,CAAA,EAAA,CACH;AAEd;;"}
@@ -0,0 +1,22 @@
1
+ import type { FocusEventHandler, ReactNode } from 'react';
2
+ import { type BuildAvatarUrlParams } from './Kit/Avatar/index.js';
3
+ import type { ChatAuthor } from './ChatAuthor.js';
4
+ import { type ChatIdentifier } from './ChatIdentifier.js';
5
+ import type { ChatTopic } from './ChatTopic.js';
6
+ import type { ChatTopicAction } from './ChatTopicAction.js';
7
+ import type { ChatTopicListLabels } from './ChatTopicList.js';
8
+ interface ChatTopicRowProps<TTopic extends ChatTopic> {
9
+ topic: TTopic;
10
+ isPending: boolean;
11
+ starter?: ChatAuthor;
12
+ labels?: ChatTopicListLabels;
13
+ availableActions: ChatTopicAction<TTopic>[];
14
+ onOpen: (topic: TTopic) => void;
15
+ renderAvatar?: (authorId: ChatIdentifier, author: ChatAuthor) => ReactNode;
16
+ buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;
17
+ onActionFocus: (topicKey: string) => FocusEventHandler<HTMLElement>;
18
+ onActionBlur: FocusEventHandler<HTMLElement>;
19
+ }
20
+ export declare const ChatTopicRow: <TTopic extends ChatTopic>({ topic, isPending, starter, labels, availableActions, onOpen, renderAvatar, buildAvatarUrl, onActionFocus, onActionBlur, }: ChatTopicRowProps<TTopic>) => import("react").JSX.Element;
21
+ export {};
22
+ //# sourceMappingURL=ChatTopicRow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatTopicRow.d.ts","sourceRoot":"","sources":["../../../Chat/ChatTopicRow.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAsB,KAAK,oBAAoB,EAAE,MAAM,uBAAc,CAAC;AAE7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAc,CAAC;AAC/C,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,qBAAkB,CAAC;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAmB,CAAC;AAEzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAiB,CAAC;AA2B3D,UAAU,iBAAiB,CAAC,MAAM,SAAS,SAAS;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,gBAAgB,EAAE,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC;IAC5C,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,UAAU,KAAK,SAAS,CAAC;IAC3E,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,MAAM,CAAC;IAC1D,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,iBAAiB,CAAC,WAAW,CAAC,CAAC;IACpE,YAAY,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAC;CAChD;AAED,eAAO,MAAM,YAAY,GAAI,MAAM,SAAS,SAAS,+HAWlD,iBAAiB,CAAC,MAAM,CAAC,gCA6C3B,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
+ import { PersonAvatarCircle } from './Kit/Avatar/PersonAvatarCircle.js';
3
+ import { ChatAuthorKind } from './Kit/ChatAuthorKind.js';
4
+ import { chatIdentifierString } from './ChatIdentifier.js';
5
+ import { ChatTopicActions } from './ChatTopicActions.js';
6
+ import { relativeTimestamp } from './relativeTimestamp.js';
7
+
8
+ const TopicStarterAvatar = ({ startedBy, starter, renderAvatar, buildAvatarUrl }) => {
9
+ if (renderAvatar) {
10
+ return jsx(Fragment, { children: renderAvatar(startedBy, starter) });
11
+ }
12
+ return (jsx(PersonAvatarCircle, { userId: chatIdentifierString(startedBy), name: starter.name, hasAvatar: starter.hasAvatar ?? false, size: 28, ownerType: starter.kind === ChatAuthorKind.Agent ? 'Agents' : 'Users', version: starter.avatarVersion, buildAvatarUrl: buildAvatarUrl }));
13
+ };
14
+ const ChatTopicRow = ({ topic, isPending, starter, labels, availableActions, onOpen, renderAvatar, buildAvatarUrl, onActionFocus, onActionBlur, }) => {
15
+ const activity = topic.lastActivity ?? topic.started;
16
+ const topicName = isPending ? (labels?.unnamedTopic ?? 'New topic') : topic.name;
17
+ const topicKey = chatIdentifierString(topic.id);
18
+ const hasActions = availableActions.length > 0;
19
+ return (jsxs("li", { className: hasActions ? 'cratis-chat-topics__row' : undefined, children: [jsxs("button", { type: 'button', className: 'cratis-chat-topics__topic', onClick: () => onOpen(topic), children: [topic.startedBy !== undefined && starter && (jsx(TopicStarterAvatar, { startedBy: topic.startedBy, starter: starter, renderAvatar: renderAvatar, buildAvatarUrl: buildAvatarUrl })), jsxs("span", { className: 'cratis-chat-topics__details', children: [jsx("span", { className: `cratis-chat-topics__name${isPending ? ' cratis-chat-topics__name--pending' : ''}`, children: topicName }), starter && (jsx("span", { className: 'cratis-chat-topics__started-by', children: (labels?.startedBy ?? 'Started by {name}').replace('{name}', starter.name) }))] }), activity !== undefined && (jsx("span", { className: 'cratis-chat-topics__activity', children: relativeTimestamp(activity, new Date(), labels?.timestamps) }))] }), hasActions && (jsx(ChatTopicActions, { topic: topic, topicName: topicName, actions: availableActions, onActionFocus: onActionFocus(topicKey), onActionBlur: onActionBlur }))] }));
20
+ };
21
+
22
+ export { ChatTopicRow };
23
+ //# sourceMappingURL=ChatTopicRow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatTopicRow.js","sources":["../../../Chat/ChatTopicRow.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 { FocusEventHandler, ReactNode } from 'react';\nimport { PersonAvatarCircle, type BuildAvatarUrlParams } from './Kit/Avatar';\nimport { ChatAuthorKind } from './Kit/ChatAuthorKind';\nimport type { ChatAuthor } from './ChatAuthor';\nimport { chatIdentifierString, type ChatIdentifier } from './ChatIdentifier';\nimport type { ChatTopic } from './ChatTopic';\nimport type { ChatTopicAction } from './ChatTopicAction';\nimport { ChatTopicActions } from './ChatTopicActions';\nimport type { ChatTopicListLabels } from './ChatTopicList';\nimport { relativeTimestamp } from './relativeTimestamp';\n\ninterface TopicStarterAvatarProps {\n startedBy: ChatIdentifier;\n starter: ChatAuthor;\n renderAvatar?: (authorId: ChatIdentifier, author: ChatAuthor) => ReactNode;\n buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;\n}\n\nconst TopicStarterAvatar = ({ startedBy, starter, renderAvatar, buildAvatarUrl }: TopicStarterAvatarProps) => {\n if (renderAvatar) {\n return <>{renderAvatar(startedBy, starter)}</>;\n }\n return (\n <PersonAvatarCircle\n userId={chatIdentifierString(startedBy)}\n name={starter.name}\n hasAvatar={starter.hasAvatar ?? false}\n size={28}\n ownerType={starter.kind === ChatAuthorKind.Agent ? 'Agents' : 'Users'}\n version={starter.avatarVersion}\n buildAvatarUrl={buildAvatarUrl}\n />\n );\n};\n\ninterface ChatTopicRowProps<TTopic extends ChatTopic> {\n topic: TTopic;\n isPending: boolean;\n starter?: ChatAuthor;\n labels?: ChatTopicListLabels;\n availableActions: ChatTopicAction<TTopic>[];\n onOpen: (topic: TTopic) => void;\n renderAvatar?: (authorId: ChatIdentifier, author: ChatAuthor) => ReactNode;\n buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;\n onActionFocus: (topicKey: string) => FocusEventHandler<HTMLElement>;\n onActionBlur: FocusEventHandler<HTMLElement>;\n}\n\nexport const ChatTopicRow = <TTopic extends ChatTopic>({\n topic,\n isPending,\n starter,\n labels,\n availableActions,\n onOpen,\n renderAvatar,\n buildAvatarUrl,\n onActionFocus,\n onActionBlur,\n}: ChatTopicRowProps<TTopic>) => {\n const activity = topic.lastActivity ?? topic.started;\n const topicName = isPending ? (labels?.unnamedTopic ?? 'New topic') : topic.name;\n const topicKey = chatIdentifierString(topic.id);\n const hasActions = availableActions.length > 0;\n\n // Reuses the message action overlay styling; keyboard focus reveals the controls.\n return (\n <li className={hasActions ? 'cratis-chat-topics__row' : undefined}>\n <button type='button' className='cratis-chat-topics__topic' onClick={() => onOpen(topic)}>\n {topic.startedBy !== undefined && starter && (\n <TopicStarterAvatar\n startedBy={topic.startedBy}\n starter={starter}\n renderAvatar={renderAvatar}\n buildAvatarUrl={buildAvatarUrl}\n />\n )}\n <span className='cratis-chat-topics__details'>\n <span className={`cratis-chat-topics__name${isPending ? ' cratis-chat-topics__name--pending' : ''}`}>\n {topicName}\n </span>\n {starter && (\n <span className='cratis-chat-topics__started-by'>\n {(labels?.startedBy ?? 'Started by {name}').replace('{name}', starter.name)}\n </span>\n )}\n </span>\n {activity !== undefined && (\n <span className='cratis-chat-topics__activity'>\n {relativeTimestamp(activity, new Date(), labels?.timestamps)}\n </span>\n )}\n </button>\n {hasActions && (\n <ChatTopicActions<TTopic>\n topic={topic}\n topicName={topicName}\n actions={availableActions}\n onActionFocus={onActionFocus(topicKey)}\n onActionBlur={onActionBlur}\n />\n )}\n </li>\n );\n};\n"],"names":["_jsx","_Fragment","_jsxs"],"mappings":";;;;;;;AAqBA,MAAM,kBAAkB,GAAG,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAA2B,KAAI;IACzG,IAAI,YAAY,EAAE;QACd,OAAOA,GAAA,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAG,YAA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,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,EAAA,CAChC,CACL,EACDE,IAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,6BAA6B,aACzCF,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAE,CAAA,wBAAA,EAA2B,SAAS,GAAG,oCAAoC,GAAG,EAAE,CAAA,CAAE,YAC9F,SAAS,EAAA,CACP,EACN,OAAO,KACJA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,gCAAgC,YAC3C,CAAC,MAAM,EAAE,SAAS,IAAI,mBAAmB,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,EAAA,CACxE,CACV,IACE,EACN,QAAQ,KAAK,SAAS,KACnBA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,8BAA8B,YACzC,iBAAiB,CAAC,QAAQ,EAAE,IAAI,IAAI,EAAE,EAAE,MAAM,EAAE,UAAU,CAAC,EAAA,CACzD,CACV,CAAA,EAAA,CACI,EACR,UAAU,KACPA,GAAA,CAAC,gBAAgB,IACb,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,gBAAgB,EACzB,aAAa,EAAE,aAAa,CAAC,QAAQ,CAAC,EACtC,YAAY,EAAE,YAAY,GAC5B,CACL,CAAA,EAAA,CACA;AAEb;;"}
@@ -0,0 +1,8 @@
1
+ interface ChatTopicStartButtonProps {
2
+ label?: string;
3
+ disabled: boolean;
4
+ onStart: () => void;
5
+ }
6
+ export declare const ChatTopicStartButton: ({ label, disabled, onStart }: ChatTopicStartButtonProps) => import("react").JSX.Element;
7
+ export {};
8
+ //# sourceMappingURL=ChatTopicStartButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatTopicStartButton.d.ts","sourceRoot":"","sources":["../../../Chat/ChatTopicStartButton.tsx"],"names":[],"mappings":"AAkBA,UAAU,yBAAyB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,eAAO,MAAM,oBAAoB,iCAAkC,yBAAyB,gCAK3F,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+
3
+ const PlusIcon = () => (jsxs("svg", { width: '14', height: '14', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: '2.5', "aria-hidden": 'true', children: [jsx("line", { x1: '12', y1: '5', x2: '12', y2: '19' }), jsx("line", { x1: '5', y1: '12', x2: '19', y2: '12' })] }));
4
+ const ChatTopicStartButton = ({ label, disabled, onStart }) => (jsxs("button", { type: 'button', className: 'cratis-chat-topics__start', disabled: disabled, onClick: onStart, children: [jsx(PlusIcon, {}), jsx("span", { children: label ?? 'New topic' })] }));
5
+
6
+ export { ChatTopicStartButton };
7
+ //# sourceMappingURL=ChatTopicStartButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatTopicStartButton.js","sources":["../../../Chat/ChatTopicStartButton.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\nconst PlusIcon = () => (\n <svg\n width='14'\n height='14'\n viewBox='0 0 24 24'\n fill='none'\n stroke='currentColor'\n strokeWidth='2.5'\n aria-hidden='true'\n >\n <line x1='12' y1='5' x2='12' y2='19' />\n <line x1='5' y1='12' x2='19' y2='12' />\n </svg>\n);\n\ninterface ChatTopicStartButtonProps {\n label?: string;\n disabled: boolean;\n onStart: () => void;\n}\n\nexport const ChatTopicStartButton = ({ label, disabled, onStart }: ChatTopicStartButtonProps) => (\n <button type='button' className='cratis-chat-topics__start' disabled={disabled} onClick={onStart}>\n <PlusIcon />\n <span>{label ?? 'New topic'}</span>\n </button>\n);\n"],"names":["_jsxs","_jsx"],"mappings":";;AAGA,MAAM,QAAQ,GAAG,OACbA,IAAA,CAAA,KAA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C,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,uDAAuD;IACvD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,wCAAwC;IACxC,kBAAkB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,yCAAyC;IACzC,oBAAoB,CAAC,EAAE,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC;IAC3D,6DAA6D;IAC7D,kBAAkB,CAAC,EAAE,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACrD,wDAAwD;IACxD,aAAa,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;IAC/C,8EAA8E;IAC9E,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,4EAA4E;IAC5E,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,0GAA0G;IAC1G,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sHAAsH;IACtH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2GAA2G;IAC3G,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,6CAA6C;IAC7C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,sFAAsF;IACtF,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,wDAAwD;IACxD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,gDAAgD;IAChD,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACzC"}
@@ -1,6 +1,5 @@
1
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
- import React, { useId, useMemo, useEffect } from 'react';
3
- import { Button } from '../Common/Button.js';
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { useId } from 'react';
4
3
  import 'react-aria-components/I18nProvider';
5
4
  import 'react-aria-components';
6
5
  import 'ts-deepmerge';
@@ -8,132 +7,45 @@ import 'react-dom';
8
7
  import { useCratisComponentsConfig } from '../configuration/CratisComponentsContext.js';
9
8
  import '../Notifications/toast.js';
10
9
  import '../renderer/RendererContext.js';
11
- import { CommandFormFieldWrapper } from '@cratis/arc.react/commands';
12
- import { isCommandFormField } from '../CommandForm/commandFormMarkers.js';
13
- import { getStepPanels } from './stepChildren.js';
14
- import { transitionStep } from './transitionStep.js';
10
+ import { CommandStepperList } from './CommandStepperList.js';
11
+ import { CommandStepperPanels } from './CommandStepperPanels.js';
12
+ import { CommandStepperNavigation } from './CommandStepperNavigation.js';
13
+ import { resolveStepperLabels } from './resolveStepperLabels.js';
14
+ import { useStepperState } from './useStepperState.js';
15
+ import { joinClassNames } from './joinClassNames.js';
15
16
 
16
- const getPropertyName = (accessor) => {
17
- if (typeof accessor !== 'function')
18
- return '';
19
- const fnStr = accessor.toString();
20
- const match = fnStr.match(/\.([a-zA-Z_$][a-zA-Z0-9_$]*)/);
21
- return match ? match[1] : '';
22
- };
23
- const extractFieldNamesFromNode = (nodes) => {
24
- const names = [];
25
- React.Children.forEach(nodes, (child) => {
26
- if (!React.isValidElement(child))
27
- return;
28
- const component = child.type;
29
- if (isCommandFormField(component)) {
30
- const fieldProps = child.props;
31
- const name = getPropertyName(fieldProps.value);
32
- if (name)
33
- names.push(name);
34
- }
35
- const childProps = child.props;
36
- if (childProps.children != null) {
37
- names.push(...extractFieldNamesFromNode(childProps.children));
38
- }
39
- });
40
- return names;
41
- };
42
- const processChildren = (nodes) => {
43
- return React.Children.map(nodes, (child) => {
44
- if (!React.isValidElement(child))
45
- return child;
46
- const component = child.type;
47
- if (isCommandFormField(component)) {
48
- return jsx(CommandFormFieldWrapper, { field: child });
49
- }
50
- const childProps = child.props;
51
- if (childProps.children != null) {
52
- return React.cloneElement(child, {
53
- children: processChildren(childProps.children),
54
- });
55
- }
56
- return child;
57
- });
58
- };
59
17
  const CommandStepperContent = ({ activeStep, visitedSteps, children, onActiveStepChange, onVisitedStepsChange, onStepErrorsChange, getFieldError, showNavigation = true, showSubmit = true, nextLabel, previousLabel, okLabel, isBusy = false, isSubmitting = false, disableFieldsWhileSubmitting = false, isSubmitDisabled = false, onSubmit, linear = true, orientation = 'horizontal', headerPosition = 'top', start, end, onChangeStep, pt, }) => {
60
18
  const { messages } = useCratisComponentsConfig();
61
19
  const stepperId = useId();
62
- const resolvedNextLabel = nextLabel ?? messages?.stepper?.next ?? 'Next';
63
- const resolvedPreviousLabel = previousLabel ?? messages?.stepper?.previous ?? 'Previous';
64
- const resolvedOkLabel = okLabel ?? messages?.stepper?.submit ?? 'Submit';
65
- const panels = useMemo(() => getStepPanels(children), [children]);
66
- const stepCount = panels.length;
67
- const currentStep = Math.min(Math.max(activeStep, 0), Math.max(stepCount - 1, 0));
68
- const isLastStep = currentStep >= stepCount - 1;
69
- const isFirstStep = currentStep <= 0;
70
- const stepFieldNames = useMemo(() => panels.map((panel) => extractFieldNamesFromNode(panel.props.children)), [panels]);
71
- const stepErrors = useMemo(() => stepFieldNames.map((fields) => fields.some((fieldName) => !!getFieldError?.(fieldName))), [stepFieldNames, getFieldError]);
72
- useEffect(() => {
73
- onStepErrorsChange?.(stepErrors);
74
- }, [onStepErrorsChange, stepErrors]);
75
- const isCurrentStepInvalid = stepErrors[currentStep] ?? false;
76
- const hasAnyStepErrors = stepErrors.some((hasError) => hasError);
77
- const changeStep = (index, fromHeader = false) => transitionStep({
78
- index,
79
- currentStep,
80
- stepCount,
81
- isCurrentStepInvalid,
82
- linear,
83
- fromHeader,
20
+ const labels = resolveStepperLabels(messages, { nextLabel, previousLabel, okLabel });
21
+ const { panels, currentStep, isFirstStep, isLastStep, stepErrors, isCurrentStepInvalid, hasAnyStepErrors, changeStep, } = useStepperState({
22
+ children,
23
+ activeStep,
84
24
  visitedSteps,
25
+ linear,
26
+ getFieldError,
27
+ onStepErrorsChange,
85
28
  onActiveStepChange,
86
29
  onVisitedStepsChange,
87
30
  onChangeStep,
88
31
  });
89
32
  const isStepperBusy = isBusy || isSubmitting;
90
- const stepperList = (jsx("ol", { ...pt?.list, className: ['cratis-command-stepper__list', pt?.list?.className]
91
- .filter(Boolean)
92
- .join(' '), "data-cratis-part": 'list', "data-part": 'list', "data-busy": isStepperBusy || undefined, "data-invalid": hasAnyStepErrors || undefined, children: panels.map((panel, index) => {
93
- const selected = index === currentStep;
94
- const visited = visitedSteps.has(index);
95
- const invalid = stepErrors[index] ?? false;
96
- const headerDisabled = linear && !selected;
97
- return (jsxs("li", { ...pt?.step, className: ['cratis-command-stepper__step', pt?.step?.className]
98
- .filter(Boolean)
99
- .join(' '), "data-cratis-part": 'step', "data-part": 'step', "data-active": selected || undefined, "data-selected": selected || undefined, "data-visited": visited || undefined, "data-invalid": invalid || undefined, "data-busy": isStepperBusy || undefined, children: [jsxs("button", { ...pt?.header, type: 'button', id: pt?.header?.id ?? `${stepperId}-step-${index}`, className: [
100
- 'cratis-command-stepper__header',
101
- pt?.header?.className,
102
- ]
103
- .filter(Boolean)
104
- .join(' '), "data-cratis-part": 'header', "data-part": 'header', "data-busy": isStepperBusy || undefined, "data-disabled": headerDisabled || undefined, "data-invalid": invalid || undefined, "data-selected": selected || undefined, "data-visited": visited || undefined, disabled: headerDisabled, "aria-current": selected ? 'step' : undefined, onClick: () => changeStep(index, true), children: [jsx("span", { ...pt?.number, className: [
105
- 'cratis-command-stepper__number',
106
- pt?.number?.className,
107
- ]
108
- .filter(Boolean)
109
- .join(' '), style: pt?.number?.style, "data-cratis-part": 'number', "data-part": 'number', "data-busy": isStepperBusy || undefined, "data-invalid": invalid || undefined, "data-selected": selected || undefined, "data-visited": visited || undefined, children: index + 1 }), jsx("span", { ...pt?.title, className: [
110
- 'cratis-command-stepper__title',
111
- pt?.title?.className,
112
- ]
113
- .filter(Boolean)
114
- .join(' '), "data-cratis-part": 'title', "data-part": 'title', "data-busy": isStepperBusy || undefined, "data-invalid": invalid || undefined, "data-selected": selected || undefined, "data-visited": visited || undefined, children: panel.props.header })] }), index < stepCount - 1 && (jsx("span", { ...pt?.separator, className: [
115
- 'cratis-command-stepper__separator',
116
- pt?.separator?.className,
117
- ]
118
- .filter(Boolean)
119
- .join(' '), "data-cratis-part": 'separator', "data-part": 'separator', "data-busy": isStepperBusy || undefined, "data-invalid": invalid || undefined, "data-visited": visited || undefined, "aria-hidden": 'true' }))] }, index));
120
- }) }));
121
- const stepperPanels = (jsx("div", { ...pt?.panels, className: ['cratis-command-stepper__panels', pt?.panels?.className]
122
- .filter(Boolean)
123
- .join(' '), "data-cratis-part": 'panels', "data-part": 'panels', "data-busy": isStepperBusy || undefined, "data-invalid": hasAnyStepErrors || undefined, children: panels.map((panel, index) => (jsx("section", { ...pt?.panel, hidden: index !== currentStep, className: ['cratis-command-stepper__panel', pt?.panel?.className]
124
- .filter(Boolean)
125
- .join(' '), "data-cratis-part": 'panel', "data-part": 'panel', "data-busy": isStepperBusy || undefined, "data-invalid": stepErrors[index] || undefined, "data-selected": index === currentStep || undefined, "data-visited": visitedSteps.has(index) || undefined, "aria-label": String(panel.props.header ?? `Step ${index + 1}`), "aria-labelledby": pt?.panel?.['aria-labelledby'] ?? (pt?.header?.id == null ? `${stepperId}-step-${index}` : undefined), children: disableFieldsWhileSubmitting ? (jsx("fieldset", { disabled: isSubmitting, inert: isSubmitting, style: { display: 'contents' }, children: processChildren(panel.props.children) })) : processChildren(panel.props.children) }, index))) }));
126
- return (jsxs("div", { className: `cratis-command-stepper cratis-command-stepper--${orientation}`, "data-orientation": orientation, children: [start, jsx("div", { ...pt?.root, className: ['cratis-command-stepper__root', pt?.root?.className]
127
- .filter(Boolean)
128
- .join(' '), "data-cratis-part": 'root', "data-cratis-component": 'CommandStepper', "data-part": 'root', "data-value": currentStep, "data-orientation": orientation, "data-busy": isStepperBusy || undefined, "data-invalid": hasAnyStepErrors || undefined, children: headerPosition === 'bottom' ? (jsxs(Fragment, { children: [stepperPanels, stepperList] })) : (jsxs(Fragment, { children: [stepperList, stepperPanels] })) }), end, showNavigation && (jsxs("div", { style: {
129
- display: 'flex',
130
- alignItems: 'center',
131
- width: '100%',
132
- gap: '0.75rem',
133
- }, children: [!isFirstStep && (jsx(Button, { variant: 'outline', onClick: () => changeStep(currentStep - 1), disabled: isBusy, style: { width: 'auto' }, children: jsx("span", { children: resolvedPreviousLabel }) })), jsx("div", { style: { flex: 1 } }), !isLastStep && (jsx(Button, { onClick: () => changeStep(currentStep + 1), disabled: isBusy || isSubmitting || isCurrentStepInvalid, style: { width: 'auto' }, children: jsx("span", { children: resolvedNextLabel }) })), isLastStep && showSubmit && (jsxs(Button, { onClick: () => void onSubmit?.(), disabled: isBusy ||
134
- isSubmitting ||
135
- isSubmitDisabled ||
136
- hasAnyStepErrors, autoFocus: true, style: { width: 'auto' }, children: [isSubmitting && (jsx("span", { className: 'cratis-dialog__spinner', "aria-hidden": 'true' })), jsx("span", { children: resolvedOkLabel })] }))] }))] }));
33
+ const view = {
34
+ panels,
35
+ currentStep,
36
+ visitedSteps,
37
+ stepErrors,
38
+ stepperId,
39
+ isBusy: isStepperBusy,
40
+ hasAnyStepErrors,
41
+ pt,
42
+ };
43
+ const stepperList = (jsx(CommandStepperList, { ...view, linear: linear, onHeaderClick: (index) => changeStep(index, true) }));
44
+ const stepperPanels = (jsx(CommandStepperPanels, { ...view, disableFieldsWhileSubmitting: disableFieldsWhileSubmitting, isSubmitting: isSubmitting }));
45
+ const [first, second] = headerPosition === 'bottom'
46
+ ? [stepperPanels, stepperList]
47
+ : [stepperList, stepperPanels];
48
+ return (jsxs("div", { className: `cratis-command-stepper cratis-command-stepper--${orientation}`, "data-orientation": orientation, children: [start, jsxs("div", { ...pt?.root, className: joinClassNames('cratis-command-stepper__root', pt?.root?.className), "data-cratis-part": 'root', "data-cratis-component": 'CommandStepper', "data-part": 'root', "data-value": currentStep, "data-orientation": orientation, "data-busy": isStepperBusy || undefined, "data-invalid": hasAnyStepErrors || undefined, children: [first, second] }), end, showNavigation && (jsx(CommandStepperNavigation, { isFirstStep: isFirstStep, isLastStep: isLastStep, showSubmit: showSubmit, isBusy: isBusy, isSubmitting: isSubmitting, isSubmitDisabled: isSubmitDisabled, isCurrentStepInvalid: isCurrentStepInvalid, hasAnyStepErrors: hasAnyStepErrors, previousLabel: labels.previous, nextLabel: labels.next, okLabel: labels.ok, onPrevious: () => changeStep(currentStep - 1), onNext: () => changeStep(currentStep + 1), onSubmit: onSubmit }))] }));
137
49
  };
138
50
 
139
51
  export { CommandStepperContent };
@@ -1 +1 @@
1
- {"version":3,"file":"CommandStepperContent.js","sources":["../../../CommandDialog/CommandStepperContent.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 React, { useEffect, useId, useMemo } from 'react';\nimport { Button } from '../Common/Button';\nimport { useCratisComponentsConfig } from '../Common/CratisComponentsProvider';\nimport { CommandFormFieldWrapper } from '@cratis/arc.react/commands';\nimport { isCommandFormField } from '../CommandForm/commandFormMarkers';\nimport type { StepperPanelProps } from './StepperPanel';\nimport { getStepPanels } from './stepChildren';\nimport { transitionStep } from './transitionStep';\nimport type { StepperCustomizationProps } from './CommandStepper';\n\n/**\n * Controlled state and validation props for {@link CommandStepperContent}.\n *\n * @remarks\n * `CommandStepperContent` is a private implementation primitive shared by\n * {@link CommandStepper} and `StepperCommandDialog` — it is deliberately not\n * re-exported from the `./CommandStepper` or `./CommandDialog` package\n * subpaths, so this type is documented for maintainers only.\n */\nexport interface CommandStepperContentProps extends StepperCustomizationProps {\n /** The active step index. */\n activeStep: number;\n /** The indices that have been visited. */\n visitedSteps: Set<number>;\n /** StepperPanel children defining each wizard step. */\n children?: React.ReactNode;\n /** Callback for active step changes. */\n onActiveStepChange?: (stepIndex: number) => void;\n /** Callback for visited step changes. */\n onVisitedStepsChange?: (visitedSteps: Set<number>) => void;\n /** Callback that receives validation state for each step. */\n onStepErrorsChange?: (stepErrors: boolean[]) => void;\n /** Provides validation errors for individual fields. */\n getFieldError?: (fieldName: string) => unknown;\n /** Whether to show built-in previous and next buttons. Defaults to `true`. */\n showNavigation?: boolean;\n /** Whether to show built-in submit on the last step. Defaults to `true`. */\n showSubmit?: boolean;\n /** Label for the next step button. Falls back to the provider's `stepper.next` message, then `'Next'`. */\n nextLabel?: string;\n /** Label for the previous step button. Falls back to the provider's `stepper.previous` message, then `'Previous'`. */\n previousLabel?: string;\n /** Label for the submit button. Falls back to the provider's `stepper.submit` message, then `'Submit'`. */\n okLabel?: string;\n /** Whether navigation controls are busy. */\n isBusy?: boolean;\n /** Whether submit is currently executing. */\n isSubmitting?: boolean;\n /** Locks form fields during a guarded submission without changing unguarded forms. */\n disableFieldsWhileSubmitting?: boolean;\n /** Disables submit regardless of current step state. */\n isSubmitDisabled?: boolean;\n /** Submit callback invoked on the last step. */\n onSubmit?: () => void | Promise<void>;\n}\n\n/** Extracts the property name from an accessor function like `c => c.name`. */\nconst getPropertyName = (accessor: ((obj: unknown) => unknown) | unknown): string => {\n if (typeof accessor !== 'function') return '';\n const fnStr = accessor.toString();\n const match = fnStr.match(/\\.([a-zA-Z_$][a-zA-Z0-9_$]*)/);\n return match ? match[1] : '';\n};\n\n/** Recursively collects all CommandFormField property names from a React node tree. */\nconst extractFieldNamesFromNode = (nodes: React.ReactNode): string[] => {\n const names: string[] = [];\n React.Children.forEach(nodes, (child) => {\n if (!React.isValidElement(child)) return;\n const component = child.type as React.ComponentType<unknown>;\n if (isCommandFormField(component)) {\n const fieldProps = child.props as { value?: (obj: unknown) => unknown };\n const name = getPropertyName(fieldProps.value);\n if (name) names.push(name);\n }\n\n const childProps = child.props as Record<string, unknown>;\n if (childProps.children != null) {\n names.push(\n ...extractFieldNamesFromNode(childProps.children as React.ReactNode),\n );\n }\n });\n return names;\n};\n\nconst processChildren = (nodes: React.ReactNode): React.ReactNode => {\n return React.Children.map(nodes, (child) => {\n if (!React.isValidElement(child)) return child;\n\n const component = child.type as React.ComponentType<unknown>;\n if (isCommandFormField(component)) {\n type FieldElement = Parameters<typeof CommandFormFieldWrapper>[0]['field'];\n // SAFETY: displayName identifies the Arc command field shape before it reaches the wrapper.\n return <CommandFormFieldWrapper field={child as unknown as FieldElement} />;\n }\n\n const childProps = child.props as Record<string, unknown>;\n if (childProps.children != null) {\n return React.cloneElement(\n child as React.ReactElement<Record<string, unknown>>,\n {\n children: processChildren(childProps.children as React.ReactNode),\n },\n );\n }\n\n return child;\n });\n};\n\n/**\n * @internal Renders the visual stepper body — step headers, panels, and the\n * built-in Previous / Next / Submit navigation — without any Arc\n * `CommandForm` wiring. This is a private implementation primitive shared by\n * {@link CommandStepper} and `StepperCommandDialog`; it is intentionally\n * **not** re-exported from the `./CommandStepper` or `./CommandDialog`\n * package subpaths and may change shape without a major version bump.\n */\nexport const CommandStepperContent = ({\n activeStep,\n visitedSteps,\n children,\n onActiveStepChange,\n onVisitedStepsChange,\n onStepErrorsChange,\n getFieldError,\n showNavigation = true,\n showSubmit = true,\n nextLabel,\n previousLabel,\n okLabel,\n isBusy = false,\n isSubmitting = false,\n disableFieldsWhileSubmitting = false,\n isSubmitDisabled = false,\n onSubmit,\n linear = true,\n orientation = 'horizontal',\n headerPosition = 'top',\n start,\n end,\n onChangeStep,\n pt,\n}: CommandStepperContentProps) => {\n const { messages } = useCratisComponentsConfig();\n const stepperId = useId();\n const resolvedNextLabel = nextLabel ?? messages?.stepper?.next ?? 'Next';\n const resolvedPreviousLabel =\n previousLabel ?? messages?.stepper?.previous ?? 'Previous';\n const resolvedOkLabel = okLabel ?? messages?.stepper?.submit ?? 'Submit';\n\n // The steps that actually render. Conditional steps (`{condition && <StepperPanel/>}`)\n // leave falsy children behind, so the count, the per-step validation state and what the\n // Stepper renders are all derived from this one list — they cannot drift apart.\n const panels = useMemo(\n () => getStepPanels(children) as React.ReactElement<StepperPanelProps>[],\n [children],\n );\n const stepCount = panels.length;\n\n // A conditional step can vanish after the user has advanced past it, which leaves the\n // incoming index pointing at a step that is no longer rendered. Clamp it into the set that\n // is, so the panel shown, the validation state read and the buttons offered all belong to a\n // step that exists.\n const currentStep = Math.min(Math.max(activeStep, 0), Math.max(stepCount - 1, 0));\n const isLastStep = currentStep >= stepCount - 1;\n const isFirstStep = currentStep <= 0;\n\n const stepFieldNames = useMemo(\n () => panels.map((panel) => extractFieldNamesFromNode(panel.props.children)),\n [panels],\n );\n\n const stepErrors = useMemo(\n () =>\n stepFieldNames.map((fields) =>\n fields.some((fieldName) => !!getFieldError?.(fieldName)),\n ),\n [stepFieldNames, getFieldError],\n );\n\n useEffect(() => {\n onStepErrorsChange?.(stepErrors);\n }, [onStepErrorsChange, stepErrors]);\n\n const isCurrentStepInvalid = stepErrors[currentStep] ?? false;\n const hasAnyStepErrors = stepErrors.some((hasError) => hasError);\n\n const changeStep = (index: number, fromHeader = false) => transitionStep({\n index,\n currentStep,\n stepCount,\n isCurrentStepInvalid,\n linear,\n fromHeader,\n visitedSteps,\n onActiveStepChange,\n onVisitedStepsChange,\n onChangeStep,\n });\n\n const isStepperBusy = isBusy || isSubmitting;\n\n const stepperList = (\n <ol\n {...pt?.list}\n className={['cratis-command-stepper__list', pt?.list?.className]\n .filter(Boolean)\n .join(' ')}\n data-cratis-part='list'\n data-part='list'\n data-busy={isStepperBusy || undefined}\n data-invalid={hasAnyStepErrors || undefined}\n >\n {panels.map((panel, index) => {\n const selected = index === currentStep;\n const visited = visitedSteps.has(index);\n const invalid = stepErrors[index] ?? false;\n const headerDisabled = linear && !selected;\n\n return (\n <li\n key={index}\n {...pt?.step}\n className={['cratis-command-stepper__step', pt?.step?.className]\n .filter(Boolean)\n .join(' ')}\n data-cratis-part='step'\n data-part='step'\n data-active={selected || undefined}\n data-selected={selected || undefined}\n data-visited={visited || undefined}\n data-invalid={invalid || undefined}\n data-busy={isStepperBusy || undefined}\n >\n <button\n {...pt?.header}\n type='button'\n id={pt?.header?.id ?? `${stepperId}-step-${index}`}\n className={[\n 'cratis-command-stepper__header',\n pt?.header?.className,\n ]\n .filter(Boolean)\n .join(' ')}\n data-cratis-part='header'\n data-part='header'\n data-busy={isStepperBusy || undefined}\n data-disabled={headerDisabled || undefined}\n data-invalid={invalid || undefined}\n data-selected={selected || undefined}\n data-visited={visited || undefined}\n disabled={headerDisabled}\n aria-current={selected ? 'step' : undefined}\n onClick={() => changeStep(index, true)}\n >\n <span\n {...pt?.number}\n className={[\n 'cratis-command-stepper__number',\n pt?.number?.className,\n ]\n .filter(Boolean)\n .join(' ')}\n style={pt?.number?.style}\n data-cratis-part='number'\n data-part='number'\n data-busy={isStepperBusy || undefined}\n data-invalid={invalid || undefined}\n data-selected={selected || undefined}\n data-visited={visited || undefined}\n >\n {index + 1}\n </span>\n <span\n {...pt?.title}\n className={[\n 'cratis-command-stepper__title',\n pt?.title?.className,\n ]\n .filter(Boolean)\n .join(' ')}\n data-cratis-part='title'\n data-part='title'\n data-busy={isStepperBusy || undefined}\n data-invalid={invalid || undefined}\n data-selected={selected || undefined}\n data-visited={visited || undefined}\n >\n {panel.props.header}\n </span>\n </button>\n {index < stepCount - 1 && (\n <span\n {...pt?.separator}\n className={[\n 'cratis-command-stepper__separator',\n pt?.separator?.className,\n ]\n .filter(Boolean)\n .join(' ')}\n data-cratis-part='separator'\n data-part='separator'\n data-busy={isStepperBusy || undefined}\n data-invalid={invalid || undefined}\n data-visited={visited || undefined}\n aria-hidden='true'\n />\n )}\n </li>\n );\n })}\n </ol>\n );\n\n const stepperPanels = (\n <div\n {...pt?.panels}\n className={['cratis-command-stepper__panels', pt?.panels?.className]\n .filter(Boolean)\n .join(' ')}\n data-cratis-part='panels'\n data-part='panels'\n data-busy={isStepperBusy || undefined}\n data-invalid={hasAnyStepErrors || undefined}\n >\n {panels.map((panel, index) => (\n <section\n key={index}\n {...pt?.panel}\n hidden={index !== currentStep}\n className={['cratis-command-stepper__panel', pt?.panel?.className]\n .filter(Boolean)\n .join(' ')}\n data-cratis-part='panel'\n data-part='panel'\n data-busy={isStepperBusy || undefined}\n data-invalid={stepErrors[index] || undefined}\n data-selected={index === currentStep || undefined}\n data-visited={visitedSteps.has(index) || undefined}\n aria-label={String(panel.props.header ?? `Step ${index + 1}`)}\n aria-labelledby={pt?.panel?.['aria-labelledby'] ?? (pt?.header?.id == null ? `${stepperId}-step-${index}` : undefined)}\n >\n {disableFieldsWhileSubmitting ? (\n <fieldset disabled={isSubmitting} inert={isSubmitting} style={{ display: 'contents' }}>\n {processChildren(panel.props.children)}\n </fieldset>\n ) : processChildren(panel.props.children)}\n </section>\n ))}\n </div>\n );\n\n return (\n <div\n className={`cratis-command-stepper cratis-command-stepper--${orientation}`}\n data-orientation={orientation}\n >\n {start}\n <div\n {...pt?.root}\n className={['cratis-command-stepper__root', pt?.root?.className]\n .filter(Boolean)\n .join(' ')}\n data-cratis-part='root'\n data-cratis-component='CommandStepper'\n data-part='root'\n data-value={currentStep}\n data-orientation={orientation}\n data-busy={isStepperBusy || undefined}\n data-invalid={hasAnyStepErrors || undefined}\n >\n {headerPosition === 'bottom' ? (\n <>\n {stepperPanels}\n {stepperList}\n </>\n ) : (\n <>\n {stepperList}\n {stepperPanels}\n </>\n )}\n </div>\n {end}\n\n {showNavigation && (\n <div\n style={{\n display: 'flex',\n alignItems: 'center',\n width: '100%',\n gap: '0.75rem',\n }}\n >\n {!isFirstStep && (\n <Button\n variant='outline'\n onClick={() => changeStep(currentStep - 1)}\n disabled={isBusy}\n style={{ width: 'auto' }}\n >\n <span>{resolvedPreviousLabel}</span>\n </Button>\n )}\n <div style={{ flex: 1 }} />\n {!isLastStep && (\n <Button\n onClick={() => changeStep(currentStep + 1)}\n disabled={isBusy || isSubmitting || isCurrentStepInvalid}\n style={{ width: 'auto' }}\n >\n <span>{resolvedNextLabel}</span>\n </Button>\n )}\n {isLastStep && showSubmit && (\n <Button\n onClick={() => void onSubmit?.()}\n disabled={\n isBusy ||\n isSubmitting ||\n isSubmitDisabled ||\n hasAnyStepErrors\n }\n autoFocus\n style={{ width: 'auto' }}\n >\n {isSubmitting && (\n <span\n className='cratis-dialog__sp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,EAAA,EAAA,QAAA,EAAO,qBAAqB,EAAA,CAAQ,EAAA,CAC/B,CACZ,EACDA,aAAK,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,EAAA,CAAI,EAC1B,CAAC,UAAU,KACRA,GAAA,CAAC,MAAM,EAAA,EACH,OAAO,EAAE,MAAM,UAAU,CAAC,WAAW,GAAG,CAAC,CAAC,EAC1C,QAAQ,EAAE,MAAM,IAAI,YAAY,IAAI,oBAAoB,EACxD,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,YAExBA,GAAA,CAAA,MAAA,EAAA,EAAA,QAAA,EAAO,iBAAiB,EAAA,CAAQ,EAAA,CAC3B,CACZ,EACA,UAAU,IAAI,UAAU,KACrBC,IAAA,CAAC,MAAM,IACH,OAAO,EAAE,MAAM,KAAK,QAAQ,IAAI,EAChC,QAAQ,EACJ,MAAM;4BACN,YAAY;4BACZ,gBAAgB;AAChB,4BAAA,gBAAgB,EAEpB,SAAS,EAAA,IAAA,EACT,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAA,QAAA,EAAA,CAEvB,YAAY,KACTD,GAAA,CAAA,MAAA,EAAA,EACI,SAAS,EAAC,wBAAwB,EAAA,aAAA,EACtB,MAAM,EAAA,CACpB,CACL,EACDA,GAAA,CAAA,MAAA,EAAA,EAAA,QAAA,EAAO,eAAe,EAAA,CAAQ,CAAA,EAAA,CACzB,CACZ,CAAA,EAAA,CACC,CACT,CAAA,EAAA,CACC;AAEd;;"}
1
+ {"version":3,"file":"CommandStepperContent.js","sources":["../../../CommandDialog/CommandStepperContent.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 React, { useId } from 'react';\nimport { useCratisComponentsConfig } from '../Common/CratisComponentsProvider';\nimport type { StepperCustomizationProps } from './CommandStepper';\nimport { CommandStepperList } from './CommandStepperList';\nimport { CommandStepperPanels } from './CommandStepperPanels';\nimport { CommandStepperNavigation } from './CommandStepperNavigation';\nimport { resolveStepperLabels } from './resolveStepperLabels';\nimport { useStepperState } from './useStepperState';\nimport { joinClassNames } from './joinClassNames';\n\n/**\n * Controlled state and validation props for {@link CommandStepperContent}.\n *\n * @remarks\n * `CommandStepperContent` is a private implementation primitive shared by\n * {@link CommandStepper} and `StepperCommandDialog` — it is deliberately not\n * re-exported from the `./CommandStepper` or `./CommandDialog` package\n * subpaths, so this type is documented for maintainers only.\n */\nexport interface CommandStepperContentProps extends StepperCustomizationProps {\n /** The active step index. */\n activeStep: number;\n /** The indices that have been visited. */\n visitedSteps: Set<number>;\n /** StepperPanel children defining each wizard step. */\n children?: React.ReactNode;\n /** Callback for active step changes. */\n onActiveStepChange?: (stepIndex: number) => void;\n /** Callback for visited step changes. */\n onVisitedStepsChange?: (visitedSteps: Set<number>) => void;\n /** Callback that receives validation state for each step. */\n onStepErrorsChange?: (stepErrors: boolean[]) => void;\n /** Provides validation errors for individual fields. */\n getFieldError?: (fieldName: string) => unknown;\n /** Whether to show built-in previous and next buttons. Defaults to `true`. */\n showNavigation?: boolean;\n /** Whether to show built-in submit on the last step. Defaults to `true`. */\n showSubmit?: boolean;\n /** Label for the next step button. Falls back to the provider's `stepper.next` message, then `'Next'`. */\n nextLabel?: string;\n /** Label for the previous step button. Falls back to the provider's `stepper.previous` message, then `'Previous'`. */\n previousLabel?: string;\n /** Label for the submit button. Falls back to the provider's `stepper.submit` message, then `'Submit'`. */\n okLabel?: string;\n /** Whether navigation controls are busy. */\n isBusy?: boolean;\n /** Whether submit is currently executing. */\n isSubmitting?: boolean;\n /** Locks form fields during a guarded submission without changing unguarded forms. */\n disableFieldsWhileSubmitting?: boolean;\n /** Disables submit regardless of current step state. */\n isSubmitDisabled?: boolean;\n /** Submit callback invoked on the last step. */\n onSubmit?: () => void | Promise<void>;\n}\n\n/**\n * @internal Renders the visual stepper body — step headers, panels, and the\n * built-in Previous / Next / Submit navigation — without any Arc\n * `CommandForm` wiring. This is a private implementation primitive shared by\n * {@link CommandStepper} and `StepperCommandDialog`; it is intentionally\n * **not** re-exported from the `./CommandStepper` or `./CommandDialog`\n * package subpaths and may change shape without a major version bump.\n */\nexport const CommandStepperContent = ({\n activeStep,\n visitedSteps,\n children,\n onActiveStepChange,\n onVisitedStepsChange,\n onStepErrorsChange,\n getFieldError,\n showNavigation = true,\n showSubmit = true,\n nextLabel,\n previousLabel,\n okLabel,\n isBusy = false,\n isSubmitting = false,\n disableFieldsWhileSubmitting = false,\n isSubmitDisabled = false,\n onSubmit,\n linear = true,\n orientation = 'horizontal',\n headerPosition = 'top',\n start,\n end,\n onChangeStep,\n pt,\n}: CommandStepperContentProps) => {\n const { messages } = useCratisComponentsConfig();\n const stepperId = useId();\n const labels = resolveStepperLabels(messages, { nextLabel, previousLabel, okLabel });\n\n const {\n panels,\n currentStep,\n isFirstStep,\n isLastStep,\n stepErrors,\n isCurrentStepInvalid,\n hasAnyStepErrors,\n changeStep,\n } = useStepperState({\n children,\n activeStep,\n visitedSteps,\n linear,\n getFieldError,\n onStepErrorsChange,\n onActiveStepChange,\n onVisitedStepsChange,\n onChangeStep,\n });\n const isStepperBusy = isBusy || isSubmitting;\n\n const view = {\n panels,\n currentStep,\n visitedSteps,\n stepErrors,\n stepperId,\n isBusy: isStepperBusy,\n hasAnyStepErrors,\n pt,\n };\n const stepperList = (\n <CommandStepperList\n {...view}\n linear={linear}\n onHeaderClick={(index) => changeStep(index, true)}\n />\n );\n const stepperPanels = (\n <CommandStepperPanels\n {...view}\n disableFieldsWhileSubmitting={disableFieldsWhileSubmitting}\n isSubmitting={isSubmitting}\n />\n );\n\n const [first, second] = headerPosition === 'bottom'\n ? [stepperPanels, stepperList]\n : [stepperList, stepperPanels];\n\n return (\n <div\n className={`cratis-command-stepper cratis-command-stepper--${orientation}`}\n data-orientation={orientation}\n >\n {start}\n <div\n {...pt?.root}\n className={joinClassNames('cratis-command-stepper__root', pt?.root?.className)}\n data-cratis-part='root'\n data-cratis-component='CommandStepper'\n data-part='root'\n data-value={currentStep}\n data-orientation={orientation}\n data-busy={isStepperBusy || undefined}\n data-invalid={hasAnyStepErrors || undefined}\n >\n {first}\n {second}\n </div>\n {end}\n\n {showNavigation && (\n <CommandStepperNavigation\n isFirstStep={isFirstStep}\n isLastStep={isLastStep}\n showSubmit={showSubmit}\n isBusy={isBusy}\n isSubmitting={isSubmitting}\n isSubmitDisabled={isSubmitDisabled}\n isCurrentStepInvalid={isCurrentStepInvalid}\n hasAnyStepErrors={hasAnyStepErrors}\n previousLabel={labels.previous}\n nextLabel={labels.next}\n okLabel={labels.ok}\n onPrevious={() => changeStep(currentStep - 1)}\n onNext={() => changeStep(currentStep + 1)}\n onSubmit={onSubmit}\n />\n )}\n </div>\n );\n};\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;;AAmEO,MAAM,qBAAqB,GAAG,CAAC,EAClC,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,cAAc,GAAG,IAAI,EACrB,UAAU,GAAG,IAAI,EACjB,SAAS,EACT,aAAa,EACb,OAAO,EACP,MAAM,GAAG,KAAK,EACd,YAAY,GAAG,KAAK,EACpB,4BAA4B,GAAG,KAAK,EACpC,gBAAgB,GAAG,KAAK,EACxB,QAAQ,EACR,MAAM,GAAG,IAAI,EACb,WAAW,GAAG,YAAY,EAC1B,cAAc,GAAG,KAAK,EACtB,KAAK,EACL,GAAG,EACH,YAAY,EACZ,EAAE,GACuB,KAAI;AAC7B,IAAA,MAAM,EAAE,QAAQ,EAAE,GAAG,yBAAyB,EAAE;AAChD,IAAA,MAAM,SAAS,GAAG,KAAK,EAAE;AACzB,IAAA,MAAM,MAAM,GAAG,oBAAoB,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC;AAEpF,IAAA,MAAM,EACF,MAAM,EACN,WAAW,EACX,WAAW,EACX,UAAU,EACV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AW,EAAA,WAAA,EAClB,aAAa,IAAI,SAAS,EAAA,cAAA,EACvB,gBAAgB,IAAI,SAAS,EAAA,QAAA,EAAA,CAE1C,KAAK,EACL,MAAM,CAAA,EAAA,CACL,EACL,GAAG,EAEH,cAAc,KACXD,IAAC,wBAAwB,EAAA,EACrB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,YAAY,EAC1B,gBAAgB,EAAE,gBAAgB,EAClC,oBAAoB,EAAE,oBAAoB,EAC1C,gBAAgB,EAAE,gBAAgB,EAClC,aAAa,EAAE,MAAM,CAAC,QAAQ,EAC9B,SAAS,EAAE,MAAM,CAAC,IAAI,EACtB,OAAO,EAAE,MAAM,CAAC,EAAE,EAClB,UAAU,EAAE,MAAM,UAAU,CAAC,WAAW,GAAG,CAAC,CAAC,EAC7C,MAAM,EAAE,MAAM,UAAU,CAAC,WAAW,GAAG,CAAC,CAAC,EACzC,QAAQ,EAAE,QAAQ,EAAA,CACpB,CACL,CAAA,EAAA,CACC;AAEd;;"}
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import type { StepperPanelProps } from './StepperPanel.js';
3
+ import { type StepperPt } from './CommandStepperStepParts.js';
4
+ interface CommandStepperListProps {
5
+ panels: React.ReactElement<StepperPanelProps>[];
6
+ currentStep: number;
7
+ visitedSteps: Set<number>;
8
+ stepErrors: boolean[];
9
+ linear: boolean;
10
+ stepperId: string;
11
+ isBusy: boolean;
12
+ hasAnyStepErrors: boolean;
13
+ pt: StepperPt;
14
+ onHeaderClick: (index: number) => void;
15
+ }
16
+ /** The step header list of the stepper. */
17
+ export declare const CommandStepperList: ({ panels, currentStep, visitedSteps, stepErrors, linear, stepperId, isBusy, hasAnyStepErrors, pt, onHeaderClick, }: CommandStepperListProps) => React.JSX.Element;
18
+ export {};
19
+ //# sourceMappingURL=CommandStepperList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandStepperList.d.ts","sourceRoot":"","sources":["../../../CommandDialog/CommandStepperList.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAgB,CAAC;AAExD,OAAO,EAA4D,KAAK,SAAS,EAAE,MAAM,8BAA2B,CAAC;AAErH,UAAU,uBAAuB;IAC7B,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC,iBAAiB,CAAC,EAAE,CAAC;IAChD,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,UAAU,EAAE,OAAO,EAAE,CAAC;IACtB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,EAAE,EAAE,SAAS,CAAC;IACd,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1C;AA2DD,2CAA2C;AAC3C,eAAO,MAAM,kBAAkB,uHAW5B,uBAAuB,sBA6BzB,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { joinClassNames } from './joinClassNames.js';
3
+ import { StepSeparator, StepNumber, StepTitle } from './CommandStepperStepParts.js';
4
+
5
+ const headerIdOf = (pt, stepperId, index) => pt?.header?.id ?? `${stepperId}-step-${index}`;
6
+ const StepHeader = ({ panel, index, headerDisabled, stepperId, onHeaderClick, ...part }) => {
7
+ const { pt, selected, visited, invalid, isBusy } = part;
8
+ return (jsxs("button", { ...pt?.header, type: 'button', id: headerIdOf(pt, stepperId, index), className: joinClassNames('cratis-command-stepper__header', pt?.header?.className), "data-cratis-part": 'header', "data-part": 'header', "data-busy": isBusy || undefined, "data-disabled": headerDisabled || undefined, "data-invalid": invalid || undefined, "data-selected": selected || undefined, "data-visited": visited || undefined, disabled: headerDisabled, "aria-current": selected ? 'step' : undefined, onClick: () => onHeaderClick(index), children: [jsx(StepNumber, { ...part, index: index }), jsx(StepTitle, { ...part, header: panel.props.header })] }));
9
+ };
10
+ const CommandStepperStep = ({ isLast, ...header }) => {
11
+ const { pt, selected, visited, invalid, isBusy } = header;
12
+ return (jsxs("li", { ...pt?.step, className: joinClassNames('cratis-command-stepper__step', pt?.step?.className), "data-cratis-part": 'step', "data-part": 'step', "data-active": selected || undefined, "data-selected": selected || undefined, "data-visited": visited || undefined, "data-invalid": invalid || undefined, "data-busy": isBusy || undefined, children: [jsx(StepHeader, { ...header }), jsx(StepSeparator, { pt: pt, selected: selected, visited: visited, invalid: invalid, isBusy: isBusy, isLast: isLast })] }));
13
+ };
14
+ const CommandStepperList = ({ panels, currentStep, visitedSteps, stepErrors, linear, stepperId, isBusy, hasAnyStepErrors, pt, onHeaderClick, }) => (jsx("ol", { ...pt?.list, className: joinClassNames('cratis-command-stepper__list', pt?.list?.className), "data-cratis-part": 'list', "data-part": 'list', "data-busy": isBusy || undefined, "data-invalid": hasAnyStepErrors || undefined, children: panels.map((panel, index) => {
15
+ const selected = index === currentStep;
16
+ return (jsx(CommandStepperStep, { panel: panel, index: index, isLast: index >= panels.length - 1, selected: selected, visited: visitedSteps.has(index), invalid: stepErrors[index] ?? false, headerDisabled: linear && !selected, stepperId: stepperId, isBusy: isBusy, pt: pt, onHeaderClick: onHeaderClick }, index));
17
+ }) }));
18
+
19
+ export { CommandStepperList };
20
+ //# sourceMappingURL=CommandStepperList.js.map