@alepha/ui 0.28.0 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (378) hide show
  1. package/README.md +31 -2
  2. package/dist/components/account/account-connections.d.ts.map +1 -1
  3. package/dist/components/account/account-connections.js +4 -1
  4. package/dist/components/account/account-connections.js.map +1 -1
  5. package/dist/components/account/account-delete-dialog.d.ts.map +1 -1
  6. package/dist/components/account/account-delete-dialog.js +12 -15
  7. package/dist/components/account/account-delete-dialog.js.map +1 -1
  8. package/dist/components/account/account-keys.d.ts.map +1 -1
  9. package/dist/components/account/account-keys.js +22 -28
  10. package/dist/components/account/account-keys.js.map +1 -1
  11. package/dist/components/account/account-mfa-dialog.js +1 -4
  12. package/dist/components/account/account-mfa-dialog.js.map +1 -1
  13. package/dist/components/account/account-password-dialog.d.ts.map +1 -1
  14. package/dist/components/account/account-password-dialog.js +11 -14
  15. package/dist/components/account/account-password-dialog.js.map +1 -1
  16. package/dist/components/account/account-profile.js +3 -2
  17. package/dist/components/account/account-profile.js.map +1 -1
  18. package/dist/components/account/account-router-options.d.ts +38 -0
  19. package/dist/components/account/account-router-options.d.ts.map +1 -1
  20. package/dist/components/account/account-router-options.js.map +1 -1
  21. package/dist/components/account/account-router-page.d.ts +11 -1
  22. package/dist/components/account/account-router-page.d.ts.map +1 -1
  23. package/dist/components/account/account-router-page.js +11 -1
  24. package/dist/components/account/account-router-page.js.map +1 -1
  25. package/dist/components/account/account-router.d.ts +11 -0
  26. package/dist/components/account/account-router.d.ts.map +1 -1
  27. package/dist/components/account/account-router.js +16 -5
  28. package/dist/components/account/account-router.js.map +1 -1
  29. package/dist/components/admin/admin-audits.d.ts.map +1 -1
  30. package/dist/components/admin/admin-audits.js +91 -34
  31. package/dist/components/admin/admin-audits.js.map +1 -1
  32. package/dist/components/admin/admin-files.d.ts.map +1 -1
  33. package/dist/components/admin/admin-files.js +6 -17
  34. package/dist/components/admin/admin-files.js.map +1 -1
  35. package/dist/components/admin/admin-jobs-executions-panel.d.ts.map +1 -1
  36. package/dist/components/admin/admin-jobs-executions-panel.js +39 -8
  37. package/dist/components/admin/admin-jobs-executions-panel.js.map +1 -1
  38. package/dist/components/admin/admin-jobs-payload-dialog.d.ts +19 -0
  39. package/dist/components/admin/admin-jobs-payload-dialog.d.ts.map +1 -0
  40. package/dist/components/admin/admin-jobs-payload-dialog.js +33 -0
  41. package/dist/components/admin/admin-jobs-payload-dialog.js.map +1 -0
  42. package/dist/components/admin/admin-keys.d.ts.map +1 -1
  43. package/dist/components/admin/admin-keys.js +5 -4
  44. package/dist/components/admin/admin-keys.js.map +1 -1
  45. package/dist/components/admin/admin-notifications-channel-label.d.ts +14 -0
  46. package/dist/components/admin/admin-notifications-channel-label.d.ts.map +1 -0
  47. package/dist/components/admin/admin-notifications-channel-label.js +26 -0
  48. package/dist/components/admin/admin-notifications-channel-label.js.map +1 -0
  49. package/dist/components/admin/admin-notifications-preview-body.d.ts.map +1 -1
  50. package/dist/components/admin/admin-notifications-preview-body.js +23 -13
  51. package/dist/components/admin/admin-notifications-preview-body.js.map +1 -1
  52. package/dist/components/admin/admin-notifications.d.ts.map +1 -1
  53. package/dist/components/admin/admin-notifications.js +11 -12
  54. package/dist/components/admin/admin-notifications.js.map +1 -1
  55. package/dist/components/admin/admin-payments.d.ts.map +1 -1
  56. package/dist/components/admin/admin-payments.js +9 -7
  57. package/dist/components/admin/admin-payments.js.map +1 -1
  58. package/dist/components/admin/admin-router-options.d.ts +12 -0
  59. package/dist/components/admin/admin-router-options.d.ts.map +1 -1
  60. package/dist/components/admin/admin-router-options.js.map +1 -1
  61. package/dist/components/admin/admin-router.d.ts +5 -8
  62. package/dist/components/admin/admin-router.d.ts.map +1 -1
  63. package/dist/components/admin/admin-router.js +6 -29
  64. package/dist/components/admin/admin-router.js.map +1 -1
  65. package/dist/components/admin/admin-sessions.d.ts.map +1 -1
  66. package/dist/components/admin/admin-sessions.js +9 -7
  67. package/dist/components/admin/admin-sessions.js.map +1 -1
  68. package/dist/components/admin/admin-user-detail-audits-tab.d.ts.map +1 -1
  69. package/dist/components/admin/admin-user-detail-audits-tab.js +5 -4
  70. package/dist/components/admin/admin-user-detail-audits-tab.js.map +1 -1
  71. package/dist/components/admin/admin-user-detail-sessions-tab.d.ts.map +1 -1
  72. package/dist/components/admin/admin-user-detail-sessions-tab.js +7 -5
  73. package/dist/components/admin/admin-user-detail-sessions-tab.js.map +1 -1
  74. package/dist/components/admin/admin-user-detail.js +3 -2
  75. package/dist/components/admin/admin-user-detail.js.map +1 -1
  76. package/dist/components/admin/admin-users-roles-picker.d.ts.map +1 -1
  77. package/dist/components/admin/admin-users-roles-picker.js.map +1 -1
  78. package/dist/components/admin/admin-users.d.ts.map +1 -1
  79. package/dist/components/admin/admin-users.js +6 -4
  80. package/dist/components/admin/admin-users.js.map +1 -1
  81. package/dist/components/admin/analytics/AnalyticsChartBars.js +2 -1
  82. package/dist/components/admin/analytics/AnalyticsChartBars.js.map +1 -1
  83. package/dist/components/admin/parameter-history-item.d.ts.map +1 -1
  84. package/dist/components/admin/parameter-history-item.js +3 -2
  85. package/dist/components/admin/parameter-history-item.js.map +1 -1
  86. package/dist/components/alepha-table/alepha-table-bulk-menu.js +2 -1
  87. package/dist/components/alepha-table/alepha-table-bulk-menu.js.map +1 -1
  88. package/dist/components/alepha-table/alepha-table-filter-dialog.d.ts +60 -0
  89. package/dist/components/alepha-table/alepha-table-filter-dialog.d.ts.map +1 -0
  90. package/dist/components/alepha-table/alepha-table-filter-dialog.js +88 -0
  91. package/dist/components/alepha-table/alepha-table-filter-dialog.js.map +1 -0
  92. package/dist/components/alepha-table/alepha-table-filter-menu.d.ts +35 -0
  93. package/dist/components/alepha-table/alepha-table-filter-menu.d.ts.map +1 -0
  94. package/dist/components/alepha-table/alepha-table-filter-menu.js +54 -0
  95. package/dist/components/alepha-table/alepha-table-filter-menu.js.map +1 -0
  96. package/dist/components/alepha-table/alepha-table.d.ts +188 -3
  97. package/dist/components/alepha-table/alepha-table.d.ts.map +1 -1
  98. package/dist/components/alepha-table/alepha-table.js +551 -162
  99. package/dist/components/alepha-table/alepha-table.js.map +1 -1
  100. package/dist/components/alepha-table/query-filters.d.ts +73 -0
  101. package/dist/components/alepha-table/query-filters.d.ts.map +1 -0
  102. package/dist/components/alepha-table/query-filters.js +118 -0
  103. package/dist/components/alepha-table/query-filters.js.map +1 -0
  104. package/dist/components/app-actions/app-actions.d.ts +21 -0
  105. package/dist/components/app-actions/app-actions.d.ts.map +1 -1
  106. package/dist/components/app-actions/app-actions.js +11 -5
  107. package/dist/components/app-actions/app-actions.js.map +1 -1
  108. package/dist/components/app-shell/app-shell.d.ts +45 -0
  109. package/dist/components/app-shell/app-shell.d.ts.map +1 -1
  110. package/dist/components/app-shell/app-shell.js +119 -16
  111. package/dist/components/app-shell/app-shell.js.map +1 -1
  112. package/dist/components/auth/auth-register.js +31 -30
  113. package/dist/components/auth/auth-register.js.map +1 -1
  114. package/dist/components/auto-form/auto-form.d.ts.map +1 -1
  115. package/dist/components/auto-form/auto-form.js +68 -30
  116. package/dist/components/auto-form/auto-form.js.map +1 -1
  117. package/dist/components/button-dark/button-dark.d.ts.map +1 -1
  118. package/dist/components/button-dark/button-dark.js +39 -8
  119. package/dist/components/button-dark/button-dark.js.map +1 -1
  120. package/dist/components/button-inbox/button-inbox.d.ts +66 -0
  121. package/dist/components/button-inbox/button-inbox.d.ts.map +1 -0
  122. package/dist/components/button-inbox/button-inbox.js +167 -0
  123. package/dist/components/button-inbox/button-inbox.js.map +1 -0
  124. package/dist/components/button-inbox/inbox-unread-atom.d.ts +22 -0
  125. package/dist/components/button-inbox/inbox-unread-atom.d.ts.map +1 -0
  126. package/dist/components/button-inbox/inbox-unread-atom.js +29 -0
  127. package/dist/components/button-inbox/inbox-unread-atom.js.map +1 -0
  128. package/dist/components/button-theme/button-theme.d.ts +4 -3
  129. package/dist/components/button-theme/button-theme.d.ts.map +1 -1
  130. package/dist/components/button-theme/button-theme.js +8 -25
  131. package/dist/components/button-theme/button-theme.js.map +1 -1
  132. package/dist/components/button-user/button-user.d.ts +19 -0
  133. package/dist/components/button-user/button-user.d.ts.map +1 -1
  134. package/dist/components/button-user/button-user.js +1 -1
  135. package/dist/components/button-user/button-user.js.map +1 -1
  136. package/dist/components/control/control.d.ts +51 -0
  137. package/dist/components/control/control.d.ts.map +1 -1
  138. package/dist/components/control/control.js +49 -5
  139. package/dist/components/control/control.js.map +1 -1
  140. package/dist/components/control-array/control-array.js +2 -1
  141. package/dist/components/control-array/control-array.js.map +1 -1
  142. package/dist/components/control-date/control-date.d.ts +27 -0
  143. package/dist/components/control-date/control-date.d.ts.map +1 -1
  144. package/dist/components/control-date/control-date.js +15 -19
  145. package/dist/components/control-date/control-date.js.map +1 -1
  146. package/dist/components/control-date/date-only.d.ts +18 -0
  147. package/dist/components/control-date/date-only.d.ts.map +1 -0
  148. package/dist/components/control-date/date-only.js +29 -0
  149. package/dist/components/control-date/date-only.js.map +1 -0
  150. package/dist/components/control-date-range/control-date-range.d.ts +56 -0
  151. package/dist/components/control-date-range/control-date-range.d.ts.map +1 -0
  152. package/dist/components/control-date-range/control-date-range.js +148 -0
  153. package/dist/components/control-date-range/control-date-range.js.map +1 -0
  154. package/dist/components/control-object/control-object.js +2 -1
  155. package/dist/components/control-object/control-object.js.map +1 -1
  156. package/dist/components/control-select/control-select.d.ts.map +1 -1
  157. package/dist/components/control-select/control-select.js +177 -37
  158. package/dist/components/control-select/control-select.js.map +1 -1
  159. package/dist/components/control-upload/control-upload.d.ts.map +1 -1
  160. package/dist/components/control-upload/control-upload.js +1 -11
  161. package/dist/components/control-upload/control-upload.js.map +1 -1
  162. package/dist/components/detail/detail-aside.d.ts.map +1 -1
  163. package/dist/components/detail/detail-aside.js +4 -3
  164. package/dist/components/detail/detail-aside.js.map +1 -1
  165. package/dist/components/file-image/file-image.js +2 -1
  166. package/dist/components/file-image/file-image.js.map +1 -1
  167. package/dist/components/markdown-view/SpoilerSpan.d.ts +28 -0
  168. package/dist/components/markdown-view/SpoilerSpan.d.ts.map +1 -0
  169. package/dist/components/markdown-view/SpoilerSpan.js +53 -0
  170. package/dist/components/markdown-view/SpoilerSpan.js.map +1 -0
  171. package/dist/components/markdown-view/diagram/layoutSequence.js +13 -23
  172. package/dist/components/markdown-view/diagram/layoutSequence.js.map +1 -1
  173. package/dist/components/markdown-view/diagram/textMetrics.js +2 -2
  174. package/dist/components/markdown-view/diagram/textMetrics.js.map +1 -1
  175. package/dist/components/markdown-view/markdown-view.css +44 -0
  176. package/dist/components/markdown-view/markdown-view.d.ts +12 -0
  177. package/dist/components/markdown-view/markdown-view.d.ts.map +1 -1
  178. package/dist/components/markdown-view/markdown-view.js +22 -1
  179. package/dist/components/markdown-view/markdown-view.js.map +1 -1
  180. package/dist/components/markdown-view/remarkSpoiler.d.ts +17 -0
  181. package/dist/components/markdown-view/remarkSpoiler.d.ts.map +1 -0
  182. package/dist/components/markdown-view/remarkSpoiler.js +117 -0
  183. package/dist/components/markdown-view/remarkSpoiler.js.map +1 -0
  184. package/dist/components/permission-matrix/permission-matrix-group-rows.d.ts +34 -0
  185. package/dist/components/permission-matrix/permission-matrix-group-rows.d.ts.map +1 -0
  186. package/dist/components/permission-matrix/permission-matrix-group-rows.js +109 -0
  187. package/dist/components/permission-matrix/permission-matrix-group-rows.js.map +1 -0
  188. package/dist/components/permission-matrix/permission-matrix.d.ts +145 -0
  189. package/dist/components/permission-matrix/permission-matrix.d.ts.map +1 -0
  190. package/dist/components/permission-matrix/permission-matrix.js +113 -0
  191. package/dist/components/permission-matrix/permission-matrix.js.map +1 -0
  192. package/dist/components/plate-layout/plate-layout.d.ts +5 -0
  193. package/dist/components/plate-layout/plate-layout.d.ts.map +1 -1
  194. package/dist/components/plate-layout/plate-layout.js +2 -1
  195. package/dist/components/plate-layout/plate-layout.js.map +1 -1
  196. package/dist/components/plate-layout/plate-tab-bar.d.ts +10 -0
  197. package/dist/components/plate-layout/plate-tab-bar.d.ts.map +1 -1
  198. package/dist/components/plate-layout/plate-tab-bar.js +1 -1
  199. package/dist/components/plate-layout/plate-tab-bar.js.map +1 -1
  200. package/dist/components/settings/settings-nav.js +2 -1
  201. package/dist/components/settings/settings-nav.js.map +1 -1
  202. package/dist/components/time-ago/time-ago.d.ts +57 -0
  203. package/dist/components/time-ago/time-ago.d.ts.map +1 -0
  204. package/dist/components/time-ago/time-ago.js +60 -0
  205. package/dist/components/time-ago/time-ago.js.map +1 -0
  206. package/dist/components/tree-view/tree-model.d.ts +128 -0
  207. package/dist/components/tree-view/tree-model.d.ts.map +1 -0
  208. package/dist/components/tree-view/tree-model.js +226 -0
  209. package/dist/components/tree-view/tree-model.js.map +1 -0
  210. package/dist/components/tree-view/tree-view-rename-input.d.ts +31 -0
  211. package/dist/components/tree-view/tree-view-rename-input.d.ts.map +1 -0
  212. package/dist/components/tree-view/tree-view-rename-input.js +68 -0
  213. package/dist/components/tree-view/tree-view-rename-input.js.map +1 -0
  214. package/dist/components/tree-view/tree-view-resizer.d.ts +38 -0
  215. package/dist/components/tree-view/tree-view-resizer.d.ts.map +1 -0
  216. package/dist/components/tree-view/tree-view-resizer.js +73 -0
  217. package/dist/components/tree-view/tree-view-resizer.js.map +1 -0
  218. package/dist/components/tree-view/tree-view-row.d.ts +177 -0
  219. package/dist/components/tree-view/tree-view-row.d.ts.map +1 -0
  220. package/dist/components/tree-view/tree-view-row.js +241 -0
  221. package/dist/components/tree-view/tree-view-row.js.map +1 -0
  222. package/dist/components/tree-view/tree-view.d.ts +186 -0
  223. package/dist/components/tree-view/tree-view.d.ts.map +1 -0
  224. package/dist/components/tree-view/tree-view.js +112 -0
  225. package/dist/components/tree-view/tree-view.js.map +1 -0
  226. package/dist/components/tree-view/use-tree-state.d.ts +79 -0
  227. package/dist/components/tree-view/use-tree-state.d.ts.map +1 -0
  228. package/dist/components/tree-view/use-tree-state.js +93 -0
  229. package/dist/components/tree-view/use-tree-state.js.map +1 -0
  230. package/dist/components/ui/button.d.ts.map +1 -1
  231. package/dist/components/ui/button.js +1 -1
  232. package/dist/components/ui/button.js.map +1 -1
  233. package/dist/components/ui/dropdown-menu.js.map +1 -1
  234. package/dist/components/ui/select.d.ts +7 -0
  235. package/dist/components/ui/select.d.ts.map +1 -1
  236. package/dist/components/ui/select.js +7 -0
  237. package/dist/components/ui/select.js.map +1 -1
  238. package/dist/components/ui/sidebar.js +1 -1
  239. package/dist/components/ui/sidebar.js.map +1 -1
  240. package/dist/components/ui/table.js.map +1 -1
  241. package/dist/components/ui/tooltip.js.map +1 -1
  242. package/dist/lib/i18n-fr.d.ts.map +1 -1
  243. package/dist/lib/i18n-fr.js +31 -47
  244. package/dist/lib/i18n-fr.js.map +1 -1
  245. package/dist/lib/utils.d.ts +22 -2
  246. package/dist/lib/utils.d.ts.map +1 -1
  247. package/dist/lib/utils.js +29 -5
  248. package/dist/lib/utils.js.map +1 -1
  249. package/dist/styles.css +255 -0
  250. package/package.json +13 -14
  251. package/src/components/account/__tests__/account-router.spec.ts +95 -0
  252. package/src/components/account/account-connections.tsx +14 -1
  253. package/src/components/account/account-delete-dialog.tsx +3 -2
  254. package/src/components/account/account-keys.tsx +11 -4
  255. package/src/components/account/account-mfa-dialog.tsx +1 -1
  256. package/src/components/account/account-password-dialog.tsx +3 -2
  257. package/src/components/account/account-profile.tsx +1 -1
  258. package/src/components/account/account-router-options.tsx +45 -0
  259. package/src/components/account/account-router-page.tsx +11 -1
  260. package/src/components/account/account-router.tsx +23 -6
  261. package/src/components/admin/__tests__/admin-jobs-payload-dialog.browser.spec.tsx +68 -0
  262. package/src/components/admin/__tests__/admin-notifications-preview-body.browser.spec.tsx +20 -4
  263. package/src/components/admin/__tests__/admin-status-labels.browser.spec.tsx +0 -31
  264. package/src/components/admin/admin-audits.tsx +99 -5
  265. package/src/components/admin/admin-files.tsx +7 -16
  266. package/src/components/admin/admin-jobs-executions-panel.tsx +152 -114
  267. package/src/components/admin/admin-jobs-payload-dialog.tsx +57 -0
  268. package/src/components/admin/admin-keys.tsx +7 -4
  269. package/src/components/admin/admin-notifications-channel-label.ts +18 -0
  270. package/src/components/admin/admin-notifications-preview-body.tsx +7 -2
  271. package/src/components/admin/admin-notifications.tsx +19 -8
  272. package/src/components/admin/admin-payments.tsx +7 -4
  273. package/src/components/admin/admin-router-options.tsx +12 -0
  274. package/src/components/admin/admin-router.tsx +5 -27
  275. package/src/components/admin/admin-sessions.tsx +10 -6
  276. package/src/components/admin/admin-user-detail-audits-tab.tsx +7 -4
  277. package/src/components/admin/admin-user-detail-sessions-tab.tsx +7 -4
  278. package/src/components/admin/admin-users-roles-picker.tsx +4 -0
  279. package/src/components/admin/admin-users.tsx +6 -3
  280. package/src/components/admin/parameter-history-item.tsx +4 -2
  281. package/src/components/alepha-table/__tests__/alepha-table-default-hidden.browser.spec.tsx +108 -0
  282. package/src/components/alepha-table/__tests__/alepha-table-empty-state.browser.spec.tsx +233 -0
  283. package/src/components/alepha-table/__tests__/alepha-table-persist-facets.browser.spec.tsx +177 -0
  284. package/src/components/alepha-table/__tests__/alepha-table-persisted-filters.browser.spec.tsx +182 -0
  285. package/src/components/alepha-table/__tests__/alepha-table-query-seed.browser.spec.tsx +170 -0
  286. package/src/components/alepha-table/__tests__/alepha-table-row-action-checked.browser.spec.tsx +210 -0
  287. package/src/components/alepha-table/__tests__/alepha-table-row-action-group.browser.spec.tsx +202 -0
  288. package/src/components/alepha-table/__tests__/alepha-table-scope.browser.spec.tsx +161 -0
  289. package/src/components/alepha-table/__tests__/alepha-table-share-filters.browser.spec.tsx +309 -0
  290. package/src/components/alepha-table/__tests__/query-filters.spec.ts +212 -0
  291. package/src/components/alepha-table/alepha-table-filter-dialog.tsx +162 -0
  292. package/src/components/alepha-table/alepha-table-filter-menu.tsx +77 -0
  293. package/src/components/alepha-table/alepha-table.tsx +1113 -207
  294. package/src/components/alepha-table/query-filters.ts +159 -0
  295. package/src/components/app-actions/app-actions.tsx +32 -3
  296. package/src/components/app-shell/__tests__/sidebar-nav-accordion.browser.spec.tsx +163 -0
  297. package/src/components/app-shell/app-shell.tsx +255 -12
  298. package/src/components/auto-form/__tests__/auto-form-settings-card.browser.spec.tsx +1 -1
  299. package/src/components/auto-form/auto-form.tsx +98 -30
  300. package/src/components/button-dark/button-dark.tsx +47 -8
  301. package/src/components/button-inbox/__tests__/button-inbox.browser.spec.tsx +247 -0
  302. package/src/components/button-inbox/button-inbox.tsx +303 -0
  303. package/src/components/button-inbox/inbox-unread-atom.ts +27 -0
  304. package/src/components/button-theme/button-theme.tsx +16 -29
  305. package/src/components/button-user/__tests__/button-user-avatar.browser.spec.tsx +88 -0
  306. package/src/components/button-user/button-user.tsx +24 -1
  307. package/src/components/control/__tests__/control-date-range.browser.spec.tsx +177 -0
  308. package/src/components/control/control.tsx +119 -12
  309. package/src/components/control-date/control-date.tsx +117 -22
  310. package/src/components/control-date/date-only.ts +26 -0
  311. package/src/components/control-date-range/control-date-range.tsx +250 -0
  312. package/src/components/control-select/__tests__/control-select-clear-label.browser.spec.tsx +129 -15
  313. package/src/components/control-select/__tests__/control-select-deselect.browser.spec.tsx +27 -6
  314. package/src/components/control-select/__tests__/control-select-multi.browser.spec.tsx +204 -1
  315. package/src/components/control-select/__tests__/control-select-size-minimal.browser.spec.tsx +77 -1
  316. package/src/components/control-select/control-select.tsx +317 -83
  317. package/src/components/control-upload/control-upload.tsx +1 -10
  318. package/src/components/detail/detail-aside.tsx +30 -6
  319. package/src/components/markdown-view/SpoilerSpan.tsx +66 -0
  320. package/src/components/markdown-view/__tests__/markdown-view-spoiler.browser.spec.tsx +165 -0
  321. package/src/components/markdown-view/diagram/textMetrics.spec.ts +1 -1
  322. package/src/components/markdown-view/diagram/textMetrics.ts +2 -2
  323. package/src/components/markdown-view/markdown-view.css +44 -0
  324. package/src/components/markdown-view/markdown-view.tsx +37 -1
  325. package/src/components/markdown-view/remarkSpoiler.ts +150 -0
  326. package/src/components/permission-matrix/__tests__/permission-matrix.browser.spec.tsx +237 -0
  327. package/src/components/permission-matrix/permission-matrix-group-rows.tsx +240 -0
  328. package/src/components/permission-matrix/permission-matrix.tsx +286 -0
  329. package/src/components/plate-layout/__tests__/plate-layout.browser.spec.tsx +22 -0
  330. package/src/components/plate-layout/plate-layout.tsx +6 -0
  331. package/src/components/plate-layout/plate-tab-bar.tsx +27 -1
  332. package/src/components/time-ago/time-ago.browser.spec.tsx +110 -0
  333. package/src/components/time-ago/time-ago.tsx +80 -0
  334. package/src/components/tree-view/__tests__/tree-model.spec.ts +441 -0
  335. package/src/components/tree-view/__tests__/tree-view-drag.browser.spec.tsx +295 -0
  336. package/src/components/tree-view/__tests__/tree-view-rename.browser.spec.tsx +278 -0
  337. package/src/components/tree-view/__tests__/tree-view-resizer.browser.spec.tsx +112 -0
  338. package/src/components/tree-view/__tests__/tree-view.browser.spec.tsx +260 -0
  339. package/src/components/tree-view/__tests__/use-tree-state.browser.spec.tsx +238 -0
  340. package/src/components/tree-view/tree-model.ts +369 -0
  341. package/src/components/tree-view/tree-view-rename-input.tsx +95 -0
  342. package/src/components/tree-view/tree-view-resizer.tsx +83 -0
  343. package/src/components/tree-view/tree-view-row.tsx +414 -0
  344. package/src/components/tree-view/tree-view.tsx +300 -0
  345. package/src/components/tree-view/use-tree-state.ts +184 -0
  346. package/src/components/ui/button.tsx +79 -1
  347. package/src/components/ui/dropdown-menu.tsx +1 -1
  348. package/src/components/ui/select.tsx +7 -0
  349. package/src/components/ui/table.tsx +1 -1
  350. package/src/components/ui/tooltip.tsx +1 -1
  351. package/src/lib/i18n-fr.ts +34 -51
  352. package/src/lib/utils.ts +32 -4
  353. package/src/styles.css +255 -0
  354. package/dist/components/admin/admin-workflows-execution-sheet.d.ts +0 -11
  355. package/dist/components/admin/admin-workflows-execution-sheet.d.ts.map +0 -1
  356. package/dist/components/admin/admin-workflows-execution-sheet.js +0 -190
  357. package/dist/components/admin/admin-workflows-execution-sheet.js.map +0 -1
  358. package/dist/components/admin/admin-workflows-executions-panel.d.ts +0 -9
  359. package/dist/components/admin/admin-workflows-executions-panel.d.ts.map +0 -1
  360. package/dist/components/admin/admin-workflows-executions-panel.js +0 -121
  361. package/dist/components/admin/admin-workflows-executions-panel.js.map +0 -1
  362. package/dist/components/admin/admin-workflows-status-badge.d.ts +0 -12
  363. package/dist/components/admin/admin-workflows-status-badge.d.ts.map +0 -1
  364. package/dist/components/admin/admin-workflows-status-badge.js +0 -30
  365. package/dist/components/admin/admin-workflows-status-badge.js.map +0 -1
  366. package/dist/components/admin/admin-workflows-status-labels.d.ts +0 -19
  367. package/dist/components/admin/admin-workflows-status-labels.d.ts.map +0 -1
  368. package/dist/components/admin/admin-workflows-status-labels.js +0 -48
  369. package/dist/components/admin/admin-workflows-status-labels.js.map +0 -1
  370. package/dist/components/admin/admin-workflows.d.ts +0 -4
  371. package/dist/components/admin/admin-workflows.d.ts.map +0 -1
  372. package/dist/components/admin/admin-workflows.js +0 -145
  373. package/dist/components/admin/admin-workflows.js.map +0 -1
  374. package/src/components/admin/admin-workflows-execution-sheet.tsx +0 -285
  375. package/src/components/admin/admin-workflows-executions-panel.tsx +0 -169
  376. package/src/components/admin/admin-workflows-status-badge.tsx +0 -41
  377. package/src/components/admin/admin-workflows-status-labels.ts +0 -51
  378. package/src/components/admin/admin-workflows.tsx +0 -209
@@ -0,0 +1,66 @@
1
+ import * as React from "react";
2
+
3
+ void React;
4
+
5
+ import { useState } from "react";
6
+
7
+ export interface SpoilerSpanProps {
8
+ children?: React.ReactNode;
9
+ }
10
+
11
+ /**
12
+ * A `||spoiler||`, hidden until the reader asks for it.
13
+ *
14
+ * ## ⚠️ It is not a security feature
15
+ *
16
+ * The text is in the DOM from the first paint - hidden by a colour, not by an
17
+ * absence. It is also in the raw markdown, in a folio export, in `folio_get`
18
+ * over MCP and in any search snippet. It hides a plot point from a reader's
19
+ * eye and nothing more, and must never be described as a way to store a
20
+ * secret.
21
+ *
22
+ * ## Reachable without a mouse
23
+ *
24
+ * `role="button"` with a `tabIndex`, Enter and Space, and an `aria-label`
25
+ * naming what it is: a screen reader that met a bare `<span>` here would
26
+ * simply read the hidden text aloud, which is not a failure of privacy (see
27
+ * above) but is a failure to say that the author meant it to be covered.
28
+ *
29
+ * Once revealed it stays revealed. Re-hiding on blur would make the thing
30
+ * unreadable with a keyboard, since moving on to read what is around it is
31
+ * exactly what a reader does next.
32
+ */
33
+ export const SpoilerSpan = (props: SpoilerSpanProps) => {
34
+ const [revealed, setRevealed] = useState(false);
35
+
36
+ if (revealed) {
37
+ return (
38
+ <span data-spoiler="revealed" className="rounded-[3px] px-0.5">
39
+ {props.children}
40
+ </span>
41
+ );
42
+ }
43
+
44
+ return (
45
+ <span
46
+ data-spoiler="hidden"
47
+ role="button"
48
+ tabIndex={0}
49
+ aria-expanded={false}
50
+ aria-label="Hidden text, activate to reveal"
51
+ className="rounded-[3px] px-0.5"
52
+ onClick={() => setRevealed(true)}
53
+ onKeyDown={(event) => {
54
+ // Enter and Space, because `role="button"` promises both and a `span`
55
+ // delivers neither on its own. `preventDefault` on Space stops the
56
+ // page scrolling out from under the reader who just pressed it.
57
+ if (event.key === "Enter" || event.key === " ") {
58
+ event.preventDefault();
59
+ setRevealed(true);
60
+ }
61
+ }}
62
+ >
63
+ {props.children}
64
+ </span>
65
+ );
66
+ };
@@ -0,0 +1,165 @@
1
+ import { fireEvent, render } from "@testing-library/react";
2
+ import { describe, expect, it } from "vitest";
3
+
4
+ import { MarkdownView } from "../markdown-view.tsx";
5
+
6
+ /**
7
+ * `||spoiler||`, and the ten cases the plugin was prototyped against.
8
+ *
9
+ * The interesting half is what must NOT become a spoiler: a table's pipes, a
10
+ * code span, a fence, and an unterminated marker. The naive implementation -
11
+ * split one text node on `/\|\|([\s\S]+?)\|\|/` - passes every case here
12
+ * except one, "inline markdown inside the spoiler", because once emphasis has
13
+ * split the paragraph the opening marker and its closer live in different
14
+ * mdast siblings. That case is the reason the plugin walks siblings.
15
+ */
16
+ const hidden = (container: HTMLElement) => [
17
+ ...container.querySelectorAll('[data-spoiler="hidden"]'),
18
+ ];
19
+
20
+ const covered = (container: HTMLElement) =>
21
+ hidden(container).map((node) => node.textContent);
22
+
23
+ describe("MarkdownView - spoilers", () => {
24
+ it("wraps only the marked words, leaving the rest of the line alone", () => {
25
+ const { container } = render(
26
+ <MarkdownView content="a ||so secret password|| b" />,
27
+ );
28
+
29
+ expect(covered(container)).toEqual(["so secret password"]);
30
+ expect(container.textContent).toBe("a so secret password b");
31
+ });
32
+
33
+ it("keeps inline markdown inside the spoiler", () => {
34
+ const { container } = render(
35
+ <MarkdownView content="||a **bold** word||" />,
36
+ );
37
+
38
+ const box = hidden(container)[0];
39
+ expect(box?.textContent).toBe("a bold word");
40
+ expect(box?.querySelector("strong")?.textContent).toBe("bold");
41
+ });
42
+
43
+ it("keeps a link inside the spoiler", () => {
44
+ const { container } = render(
45
+ <MarkdownView content="||see [docs](/d) now||" />,
46
+ );
47
+
48
+ const box = hidden(container)[0];
49
+ expect(box?.textContent).toBe("see docs now");
50
+ expect(box?.querySelector("a")?.getAttribute("href")).toBe("/d");
51
+ });
52
+
53
+ /**
54
+ * ⚠️ The pipes of a GFM table are the case that would break every document
55
+ * in the app at once. They survive because `remarkGfm` runs first: by the
56
+ * time the spoiler walk sees the tree, `| a | b |` is a row with cells and
57
+ * the pipes are structure rather than text.
58
+ */
59
+ it("leaves a GFM table's pipes alone", () => {
60
+ const { container } = render(
61
+ <MarkdownView content={"| a | b |\n| - | - |\n| 1 | 2 |"} />,
62
+ );
63
+
64
+ expect(hidden(container)).toHaveLength(0);
65
+ expect(container.querySelectorAll("td")).toHaveLength(2);
66
+ });
67
+
68
+ it("keeps a code span literal", () => {
69
+ const { container } = render(<MarkdownView content="a `||x||` b" />);
70
+
71
+ expect(hidden(container)).toHaveLength(0);
72
+ expect(container.querySelector("code")?.textContent).toBe("||x||");
73
+ });
74
+
75
+ it("keeps a fenced block literal", () => {
76
+ const { container } = render(
77
+ <MarkdownView content={"```\n||nope||\n```"} />,
78
+ );
79
+
80
+ expect(hidden(container)).toHaveLength(0);
81
+ expect(container.querySelector("pre")?.textContent).toContain("||nope||");
82
+ });
83
+
84
+ it("covers two spoilers on one line, independently", () => {
85
+ const { container } = render(
86
+ <MarkdownView content="||one|| between ||two||" />,
87
+ );
88
+
89
+ expect(covered(container)).toEqual(["one", "two"]);
90
+ expect(container.textContent).toBe("one between two");
91
+ });
92
+
93
+ it("works inside a heading and inside a list item", () => {
94
+ const { container } = render(
95
+ <MarkdownView content={"# a ||b|| c\n\n- d ||e|| f"} />,
96
+ );
97
+
98
+ expect(container.querySelector("h1")?.textContent).toBe("a b c");
99
+ expect(container.querySelector("li")?.textContent).toBe("d e f");
100
+ expect(covered(container)).toEqual(["b", "e"]);
101
+ });
102
+
103
+ /**
104
+ * The failure mode a lazy regex has and a reader cannot explain: the rest
105
+ * of the paragraph disappears behind a box that was never closed.
106
+ */
107
+ it("renders an unterminated marker literally", () => {
108
+ const { container } = render(
109
+ <MarkdownView content="a ||b and then some more text" />,
110
+ );
111
+
112
+ expect(hidden(container)).toHaveLength(0);
113
+ expect(container.textContent).toBe("a ||b and then some more text");
114
+ });
115
+
116
+ it("does not let a pair cross a paragraph break", () => {
117
+ const { container } = render(<MarkdownView content={"a ||b\n\nc|| d"} />);
118
+
119
+ expect(hidden(container)).toHaveLength(0);
120
+ expect(container.querySelectorAll("p")).toHaveLength(2);
121
+ });
122
+
123
+ it("reveals on click, and stays revealed", () => {
124
+ const { container } = render(<MarkdownView content="a ||secret|| b" />);
125
+
126
+ fireEvent.click(hidden(container)[0]!);
127
+
128
+ expect(hidden(container)).toHaveLength(0);
129
+ const shown = container.querySelector('[data-spoiler="revealed"]');
130
+ expect(shown?.textContent).toBe("secret");
131
+ });
132
+
133
+ it.each(["Enter", " "])("reveals on %s", (key) => {
134
+ const { container } = render(<MarkdownView content="a ||secret|| b" />);
135
+
136
+ fireEvent.keyDown(hidden(container)[0]!, { key });
137
+
138
+ expect(hidden(container)).toHaveLength(0);
139
+ expect(
140
+ container.querySelector('[data-spoiler="revealed"]')?.textContent,
141
+ ).toBe("secret");
142
+ });
143
+
144
+ it("is announced as something a reader has to activate", () => {
145
+ const { container } = render(<MarkdownView content="a ||secret|| b" />);
146
+
147
+ const box = hidden(container)[0]!;
148
+ expect(box.getAttribute("role")).toBe("button");
149
+ expect(box.getAttribute("tabindex")).toBe("0");
150
+ expect(box.getAttribute("aria-expanded")).toBe("false");
151
+ expect(box.getAttribute("aria-label")).toBeTruthy();
152
+ });
153
+
154
+ /**
155
+ * ⚠️ Pinned deliberately, because it is the thing the feature must never be
156
+ * mistaken for: the text is in the DOM from the first paint. Anything that
157
+ * made this assertion fail - rendering the covered text as dots, dropping
158
+ * it until revealed - would be a change of contract, not a fix.
159
+ */
160
+ it("has the covered text in the DOM before it is revealed", () => {
161
+ const { container } = render(<MarkdownView content="a ||secret|| b" />);
162
+
163
+ expect(container.textContent).toContain("secret");
164
+ });
165
+ });
@@ -44,7 +44,7 @@ describe("measureLine", () => {
44
44
  ["the quick brown fox", 121.393],
45
45
  ])("is within 5%% of Chromium's own measurement of %s", (text, browser) => {
46
46
  // Measured in Chromium against the real Inter woff2 by
47
- // scripts/measure-font.mjs, in the same run that generated the table.
47
+ // scripts/measure-font.ts, in the same run that generated the table.
48
48
  // The gap is rounding the ratios to three decimals, and 5% off on a box
49
49
  // width is invisible in a boxes-and-arrows diagram.
50
50
  const error = Math.abs(measureLine(text, 13) - browser) / browser;
@@ -44,12 +44,12 @@ export const MAX_LABEL_LINES = 8;
44
44
  *
45
45
  * ## How this was produced, and how to reproduce it
46
46
  *
47
- * `scripts/measure-font.mjs` loads the real `@fontsource-variable/inter`
47
+ * `scripts/measure-font.ts` loads the real `@fontsource-variable/inter`
48
48
  * woff2 into Chromium via Playwright, waits for `document.fonts.ready` and
49
49
  * calls `canvas.measureText` on every character below, then buckets them by
50
50
  * rounded ratio. Run it from the repo root and paste the output back here:
51
51
  *
52
- * node packages/@alepha/ui/scripts/measure-font.mjs
52
+ * node packages/@alepha/ui/scripts/measure-font.ts
53
53
  *
54
54
  * The numbers are NOT magic and NOT hand-tuned. If the pinned face or size
55
55
  * ever changes, regenerate rather than nudging a value.
@@ -177,3 +177,47 @@
177
177
  )
178
178
  right center / 18px 100% no-repeat scroll;
179
179
  }
180
+
181
+ /*
182
+ * Discord-style `||spoilers||`.
183
+ *
184
+ * ⚠️ Not a security feature. The text is in the DOM from the first paint -
185
+ * this covers it, it does not withhold it - and it is in the raw markdown, in
186
+ * an export, over MCP and in any search snippet too. See `SpoilerSpan`.
187
+ *
188
+ * Both states are painted from `--foreground` through `color-mix`, so the
189
+ * dark theme needs no second block: the token already flips, and a hidden
190
+ * spoiler is a strong wash of it while a revealed one is the faint wash every
191
+ * other inline surface here uses.
192
+ *
193
+ * The hidden state sets the text to `transparent` rather than hiding it,
194
+ * which is what keeps the line's metrics: a `display: none` would reflow the
195
+ * paragraph on reveal and move the sentence out from under the reader who
196
+ * just clicked it. `user-select: none` stops a drag-select from lifting the
197
+ * covered text out through the clipboard by accident.
198
+ */
199
+ [data-slot="markdown-view"] [data-spoiler="hidden"] {
200
+ background-color: color-mix(in oklab, var(--foreground) 82%, transparent);
201
+ color: transparent;
202
+ user-select: none;
203
+ transition: background-color 120ms ease;
204
+ }
205
+
206
+ [data-slot="markdown-view"] [data-spoiler="hidden"]:hover {
207
+ background-color: color-mix(in oklab, var(--foreground) 70%, transparent);
208
+ }
209
+
210
+ /*
211
+ * A visible focus ring, because the hidden state has nothing else to show
212
+ * one against: the box IS the content, so the browser's default outline on a
213
+ * `color: transparent` span is the only thing telling a keyboard reader where
214
+ * they are.
215
+ */
216
+ [data-slot="markdown-view"] [data-spoiler="hidden"]:focus-visible {
217
+ outline: 2px solid var(--ring);
218
+ outline-offset: 1px;
219
+ }
220
+
221
+ [data-slot="markdown-view"] [data-spoiler="revealed"] {
222
+ background-color: color-mix(in oklab, var(--foreground) 8%, transparent);
223
+ }
@@ -9,6 +9,8 @@ import rehypeHighlight from "rehype-highlight";
9
9
  import remarkGfm from "remark-gfm";
10
10
 
11
11
  import { DiagramErrorBoundary } from "./diagram/DiagramErrorBoundary.tsx";
12
+ import { remarkSpoiler } from "./remarkSpoiler.ts";
13
+ import { SpoilerSpan } from "./SpoilerSpan.tsx";
12
14
 
13
15
  /**
14
16
  * Both parsers, both layouts (`graphre` for the flowchart, arithmetic for
@@ -77,6 +79,18 @@ export interface MarkdownViewProps {
77
79
  * invalid mermaid, and a red box in the middle of a document is worse than
78
80
  * a grey fence. See `packages/@alepha/ui/DOC.md` for the full table.
79
81
  *
82
+ * ## Spoilers
83
+ *
84
+ * `||text||` renders as a covered box that reveals on click, on Enter or on
85
+ * Space, Discord's syntax and Discord's behaviour. Inline markdown inside it
86
+ * survives, a code span or a fence keeps its pipes literally, and an
87
+ * unterminated `||` renders as the two characters the author typed rather
88
+ * than swallowing the rest of the paragraph.
89
+ *
90
+ * ⚠️ **It is not a security feature.** The text is in the DOM from the first
91
+ * paint, in the raw markdown, in an export, over MCP and in any search
92
+ * snippet. It hides a plot point from a reader's eye and nothing more.
93
+ *
80
94
  * ## Raw HTML
81
95
  *
82
96
  * No raw HTML is ever rendered as markup: react-markdown's default is to
@@ -101,7 +115,11 @@ export const MarkdownView = (props: MarkdownViewProps) => {
101
115
  className={`max-w-none text-sm leading-relaxed ${props.className ?? ""}`}
102
116
  >
103
117
  <ReactMarkdown
104
- remarkPlugins={[remarkGfm]}
118
+ // ⚠️ `remarkSpoiler` runs AFTER `remarkGfm`, and the order is
119
+ // load-bearing: by then a `| a | b |` row is a table with cells, so
120
+ // the pipes are structure and the spoiler walk never sees them as
121
+ // text. Reversed, every two-column table would be a spoiler.
122
+ remarkPlugins={[remarkGfm, remarkSpoiler]}
105
123
  rehypePlugins={[
106
124
  // `plainText` claims the fence BEFORE highlighting runs: hljs would
107
125
  // otherwise tokenise the diagram source, and the fallback would be a
@@ -175,6 +193,24 @@ export const MarkdownView = (props: MarkdownViewProps) => {
175
193
  </DiagramErrorBoundary>
176
194
  );
177
195
  },
196
+ // The only `<span>` this renderer ever produces is a spoiler's, and
197
+ // the only thing that marks one is the `data-spoiler` property
198
+ // `remarkSpoiler` puts there.
199
+ //
200
+ // ⚠️ The cast is not laziness: react-markdown types a span's props
201
+ // as `HTMLAttributes<HTMLSpanElement>`, which PERMITS writing a
202
+ // `data-*` attribute in JSX and does not declare one for reading.
203
+ // The alternative - a custom `hName` with its own `components` key -
204
+ // needs a cast into `components`, whose type is keyed on intrinsic
205
+ // elements, so it buys nothing (the same note `mermaidSource`
206
+ // already carries).
207
+ span: ({ children, ...rest }) => {
208
+ const marked = (rest as { "data-spoiler"?: unknown })[
209
+ "data-spoiler"
210
+ ];
211
+ if (marked) return <SpoilerSpan>{children}</SpoilerSpan>;
212
+ return <span {...rest}>{children}</span>;
213
+ },
178
214
  blockquote: ({ children }) => (
179
215
  <blockquote className="border-muted-foreground/30 my-3 border-l-2 pl-4 italic">
180
216
  {children}
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Discord's `||spoiler||`, as a remark plugin.
3
+ *
4
+ * Rewrites every `||…||` pair in the tree into one node that
5
+ * `mdast-util-to-hast` renders as `<span data-spoiler="true">`, which
6
+ * `MarkdownView` then maps onto `SpoilerSpan`. Everything between the markers
7
+ * keeps its own markup: `||see [the docs](/d) **now**||` hides a link and a
8
+ * bold word, not the text of them.
9
+ *
10
+ * ## ⚠️ It has to span SIBLINGS, not split one text node
11
+ *
12
+ * The obvious version splits a text node on `/\|\|([\s\S]+?)\|\|/` and fails on
13
+ * exactly one case - markdown INSIDE the spoiler. Once emphasis has split the
14
+ * paragraph, the opening `||` and its closer live in different mdast siblings,
15
+ * so no regex over a single node can see both. This walk opens a collector on
16
+ * the first marker, pushes the following siblings into it, and closes on the
17
+ * next one.
18
+ *
19
+ * That shape is also what makes two things true for free rather than by a
20
+ * special case that could rot:
21
+ *
22
+ * - **`code` and `inlineCode` stay literal.** Both carry a `value` and no
23
+ * `children`, so a text walk cannot reach inside them. `` `||x||` `` and a
24
+ * fenced block are structurally out of range.
25
+ * - **A pair cannot cross a paragraph break.** Each parent's children are
26
+ * processed on their own, and the collector is discarded at the end of the
27
+ * list, so an unterminated `||` puts its literal text back and gives up.
28
+ *
29
+ * GFM table pipes are untouched for the same reason: by the time this runs,
30
+ * `remark-gfm` has already turned `| a | b |` into rows and cells, and the
31
+ * pipes are structure rather than text.
32
+ *
33
+ * ## ⚠️ It is not a security feature, and must never be presented as one
34
+ *
35
+ * The text sits in the DOM, in the raw markdown, in a folio export, in
36
+ * `folio_get` over MCP and in any search snippet. It hides a plot point from a
37
+ * reader's eye and nothing more.
38
+ *
39
+ * No new dependency: the walk is a plain recursion, so `unist-util-visit`
40
+ * never enters `package.json` and `check:deps` stays quiet.
41
+ */
42
+ const MARKER = "||";
43
+
44
+ /**
45
+ * The subset of a mdast node this walk touches.
46
+ *
47
+ * Declared here rather than imported from `mdast`: the plugin needs "has
48
+ * children" and "is a text node with a value", and nothing else. Taking the
49
+ * real union would pull `@types/mdast` into this package's direct types for a
50
+ * pair of structural checks.
51
+ */
52
+ interface SpoilerNode {
53
+ type: string;
54
+ value?: string;
55
+ children?: SpoilerNode[];
56
+ data?: Record<string, unknown>;
57
+ }
58
+
59
+ export const remarkSpoiler = () => (tree: SpoilerNode) => {
60
+ walk(tree);
61
+ };
62
+
63
+ /**
64
+ * Rewrite this node's children, then descend into whatever survives.
65
+ */
66
+ const walk = (node: SpoilerNode): void => {
67
+ if (!node.children) return;
68
+ node.children = rewrite(node.children);
69
+ for (const child of node.children) {
70
+ walk(child);
71
+ }
72
+ };
73
+
74
+ /**
75
+ * One sibling list, with every `||…||` pair folded into a spoiler node.
76
+ */
77
+ const rewrite = (children: SpoilerNode[]): SpoilerNode[] => {
78
+ // Nothing to do unless a marker is actually present at this level. The
79
+ // common case is every paragraph in every document, so it is worth the
80
+ // scan: without it, each one is rebuilt into a new array for nothing.
81
+ if (
82
+ !children.some(
83
+ (child) => child.type === "text" && child.value?.includes(MARKER),
84
+ )
85
+ ) {
86
+ return children;
87
+ }
88
+
89
+ const out: SpoilerNode[] = [];
90
+ let open: SpoilerNode[] | undefined;
91
+ const target = () => open ?? out;
92
+
93
+ const push = (child: SpoilerNode) => {
94
+ target().push(child);
95
+ };
96
+
97
+ const text = (value: string) => {
98
+ if (value) push({ type: "text", value });
99
+ };
100
+
101
+ const toggle = () => {
102
+ if (open) {
103
+ out.push(spoiler(open));
104
+ open = undefined;
105
+ return;
106
+ }
107
+ open = [];
108
+ };
109
+
110
+ for (const child of children) {
111
+ if (child.type !== "text" || !child.value?.includes(MARKER)) {
112
+ push(child);
113
+ continue;
114
+ }
115
+
116
+ // `split` gives one more segment than there are markers, so segment 0 is
117
+ // whatever preceded the first one and every later segment is preceded by
118
+ // a toggle.
119
+ const segments = child.value.split(MARKER);
120
+ text(segments[0]!);
121
+ for (const segment of segments.slice(1)) {
122
+ toggle();
123
+ text(segment);
124
+ }
125
+ }
126
+
127
+ if (open) {
128
+ // Unterminated: the marker was never a spoiler, so it goes back as the
129
+ // two characters the author typed, followed by everything that had been
130
+ // collected behind it. Swallowing the rest of the paragraph instead is
131
+ // what a lazy regex does, and it is the failure a reader cannot explain.
132
+ out.push({ type: "text", value: MARKER }, ...open);
133
+ }
134
+
135
+ return out;
136
+ };
137
+
138
+ /**
139
+ * One spoiler, as the node `mdast-util-to-hast` turns into a `<span>`.
140
+ *
141
+ * `hName` / `hProperties` are the documented way to place an element the
142
+ * markdown AST has no type for: the default unknown-node handler builds a
143
+ * `div` from the children and `applyData` then renames it and merges the
144
+ * properties, so nothing invalid is ever produced inside a paragraph.
145
+ */
146
+ const spoiler = (children: SpoilerNode[]): SpoilerNode => ({
147
+ type: "spoiler",
148
+ children,
149
+ data: { hName: "span", hProperties: { "data-spoiler": "true" } },
150
+ });