@eifi1/ui-kit 0.11.0 → 0.13.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 (397) hide show
  1. package/README.md +59 -34
  2. package/dist/chart.d.ts +3 -1
  3. package/dist/chart.js +2 -0
  4. package/dist/chart.js.map +1 -1
  5. package/dist/components/account-settings-labels.d.ts +105 -0
  6. package/dist/components/account-settings-labels.js +81 -0
  7. package/dist/components/account-settings-labels.js.map +1 -0
  8. package/dist/components/account-settings.d.ts +36 -52
  9. package/dist/components/account-settings.js +44 -8
  10. package/dist/components/account-settings.js.map +1 -1
  11. package/dist/components/amount-input.d.ts +40 -4
  12. package/dist/components/amount-input.js +50 -12
  13. package/dist/components/amount-input.js.map +1 -1
  14. package/dist/components/authed-image.d.ts +68 -0
  15. package/dist/components/authed-image.js +117 -0
  16. package/dist/components/authed-image.js.map +1 -0
  17. package/dist/components/breadcrumbs.d.ts +2 -1
  18. package/dist/components/breadcrumbs.js +5 -2
  19. package/dist/components/breadcrumbs.js.map +1 -1
  20. package/dist/components/bulk-action-bar.d.ts +10 -2
  21. package/dist/components/bulk-action-bar.js.map +1 -1
  22. package/dist/components/button-group.d.ts +51 -2
  23. package/dist/components/button-group.js +5 -1
  24. package/dist/components/button-group.js.map +1 -1
  25. package/dist/components/calculator.d.ts +15 -4
  26. package/dist/components/calendar-heatmap.d.ts +41 -3
  27. package/dist/components/calendar-heatmap.js +48 -7
  28. package/dist/components/calendar-heatmap.js.map +1 -1
  29. package/dist/components/chart.js +14 -8
  30. package/dist/components/chart.js.map +1 -1
  31. package/dist/components/chip.d.ts +2 -1
  32. package/dist/components/chip.js +26 -18
  33. package/dist/components/chip.js.map +1 -1
  34. package/dist/components/choice-card.d.ts +35 -3
  35. package/dist/components/choice-card.js +83 -25
  36. package/dist/components/choice-card.js.map +1 -1
  37. package/dist/components/combobox-core.d.ts +3 -1
  38. package/dist/components/combobox-core.js +18 -5
  39. package/dist/components/combobox-core.js.map +1 -1
  40. package/dist/components/combobox.d.ts +2 -2
  41. package/dist/components/combobox.js +31 -9
  42. package/dist/components/combobox.js.map +1 -1
  43. package/dist/components/copy-button.d.ts +51 -70
  44. package/dist/components/copy-button.js +1 -1
  45. package/dist/components/copy-button.js.map +1 -1
  46. package/dist/components/data-table-cells.d.ts +63 -0
  47. package/dist/components/data-table-cells.js +64 -0
  48. package/dist/components/data-table-cells.js.map +1 -0
  49. package/dist/components/data-table-filter-popover.d.ts +1 -1
  50. package/dist/components/data-table-filter-popover.js +8 -1
  51. package/dist/components/data-table-filter-popover.js.map +1 -1
  52. package/dist/components/data-table-filters.d.ts +1 -1
  53. package/dist/components/data-table-filters.js +31 -1
  54. package/dist/components/data-table-filters.js.map +1 -1
  55. package/dist/components/data-table-labels.d.ts +13 -0
  56. package/dist/components/data-table-labels.js +8 -1
  57. package/dist/components/data-table-labels.js.map +1 -1
  58. package/dist/components/data-table.d.ts +1 -1
  59. package/dist/components/data-table.js +125 -27
  60. package/dist/components/data-table.js.map +1 -1
  61. package/dist/components/date-picker.d.ts +3 -1
  62. package/dist/components/date-picker.js +15 -2
  63. package/dist/components/date-picker.js.map +1 -1
  64. package/dist/components/description-list.d.ts +23 -3
  65. package/dist/components/description-list.js +23 -3
  66. package/dist/components/description-list.js.map +1 -1
  67. package/dist/components/dialog-frame.d.ts +1 -0
  68. package/dist/components/entity-combobox.d.ts +1 -1
  69. package/dist/components/entity-combobox.js +40 -20
  70. package/dist/components/entity-combobox.js.map +1 -1
  71. package/dist/components/error-boundary.d.ts +281 -0
  72. package/dist/components/error-boundary.js +302 -0
  73. package/dist/components/error-boundary.js.map +1 -0
  74. package/dist/components/field-sync.js +90 -83
  75. package/dist/components/field-sync.js.map +1 -1
  76. package/dist/components/field.d.ts +30 -4
  77. package/dist/components/field.js +40 -17
  78. package/dist/components/field.js.map +1 -1
  79. package/dist/components/file-button.d.ts +50 -208
  80. package/dist/components/file-dropzone.d.ts +49 -2
  81. package/dist/components/floating-panel.d.ts +13 -4
  82. package/dist/components/floating-panel.js +7 -3
  83. package/dist/components/floating-panel.js.map +1 -1
  84. package/dist/components/form-actions.d.ts +53 -0
  85. package/dist/components/form-actions.js +98 -0
  86. package/dist/components/form-actions.js.map +1 -0
  87. package/dist/components/full-bleed-dialog.js +4 -0
  88. package/dist/components/full-bleed-dialog.js.map +1 -1
  89. package/dist/components/hover-menu.js +64 -56
  90. package/dist/components/hover-menu.js.map +1 -1
  91. package/dist/components/image-grid.d.ts +67 -0
  92. package/dist/components/image-grid.js +112 -0
  93. package/dist/components/image-grid.js.map +1 -0
  94. package/dist/components/lightbox.d.ts +104 -0
  95. package/dist/components/lightbox.js +229 -0
  96. package/dist/components/lightbox.js.map +1 -0
  97. package/dist/components/line-items.d.ts +114 -0
  98. package/dist/components/line-items.js +238 -0
  99. package/dist/components/line-items.js.map +1 -0
  100. package/dist/components/list.d.ts +37 -4
  101. package/dist/components/list.js +35 -14
  102. package/dist/components/list.js.map +1 -1
  103. package/dist/components/loading-state.d.ts +24 -0
  104. package/dist/components/loading-state.js +32 -0
  105. package/dist/components/loading-state.js.map +1 -0
  106. package/dist/components/menu-item.d.ts +2 -1
  107. package/dist/components/menu-item.js +5 -1
  108. package/dist/components/menu-item.js.map +1 -1
  109. package/dist/components/mini-calendar.d.ts +13 -1
  110. package/dist/components/mini-calendar.js +46 -2
  111. package/dist/components/mini-calendar.js.map +1 -1
  112. package/dist/components/modal.d.ts +20 -1
  113. package/dist/components/modal.js +26 -2
  114. package/dist/components/modal.js.map +1 -1
  115. package/dist/components/month-picker.d.ts +21 -1
  116. package/dist/components/month-picker.js +139 -26
  117. package/dist/components/month-picker.js.map +1 -1
  118. package/dist/components/multi-entity-combobox.d.ts +1 -1
  119. package/dist/components/multi-entity-combobox.js +42 -20
  120. package/dist/components/multi-entity-combobox.js.map +1 -1
  121. package/dist/components/nav-pills.d.ts +2 -1
  122. package/dist/components/nav-pills.js +5 -1
  123. package/dist/components/nav-pills.js.map +1 -1
  124. package/dist/components/number-field.d.ts +24 -5
  125. package/dist/components/number-field.js +5 -7
  126. package/dist/components/number-field.js.map +1 -1
  127. package/dist/components/number-input.d.ts +25 -5
  128. package/dist/components/number-input.js +7 -1
  129. package/dist/components/number-input.js.map +1 -1
  130. package/dist/components/numpad-sheet.d.ts +20 -5
  131. package/dist/components/numpad-sheet.js +3 -2
  132. package/dist/components/numpad-sheet.js.map +1 -1
  133. package/dist/components/page-header.d.ts +35 -6
  134. package/dist/components/page-header.js +7 -1
  135. package/dist/components/page-header.js.map +1 -1
  136. package/dist/components/passkeys-setting.d.ts +67 -0
  137. package/dist/components/passkeys-setting.js +214 -0
  138. package/dist/components/passkeys-setting.js.map +1 -0
  139. package/dist/components/picker-sheet.js +5 -1
  140. package/dist/components/picker-sheet.js.map +1 -1
  141. package/dist/components/pie-chart-labels.d.ts +20 -0
  142. package/dist/components/pie-chart-labels.js +12 -0
  143. package/dist/components/pie-chart-labels.js.map +1 -0
  144. package/dist/components/pie-chart.d.ts +101 -0
  145. package/dist/components/pie-chart.js +283 -0
  146. package/dist/components/pie-chart.js.map +1 -0
  147. package/dist/components/popover.js +3 -0
  148. package/dist/components/popover.js.map +1 -1
  149. package/dist/components/progress-bar.d.ts +44 -3
  150. package/dist/components/progress-bar.js +58 -22
  151. package/dist/components/progress-bar.js.map +1 -1
  152. package/dist/components/qr-code.d.ts +34 -0
  153. package/dist/components/qr-code.js +57 -0
  154. package/dist/components/qr-code.js.map +1 -0
  155. package/dist/components/search-field.d.ts +15 -3
  156. package/dist/components/search-field.js +5 -1
  157. package/dist/components/search-field.js.map +1 -1
  158. package/dist/components/settings-fields.d.ts +49 -1
  159. package/dist/components/signed-amount.d.ts +122 -0
  160. package/dist/components/signed-amount.js +152 -0
  161. package/dist/components/signed-amount.js.map +1 -0
  162. package/dist/components/skeleton.d.ts +10 -3
  163. package/dist/components/skeleton.js +12 -2
  164. package/dist/components/skeleton.js.map +1 -1
  165. package/dist/components/stat-tile.d.ts +2 -1
  166. package/dist/components/stat-tile.js +6 -3
  167. package/dist/components/stat-tile.js.map +1 -1
  168. package/dist/components/swipeable-row.js +4 -3
  169. package/dist/components/swipeable-row.js.map +1 -1
  170. package/dist/components/table.d.ts +39 -5
  171. package/dist/components/table.js +45 -11
  172. package/dist/components/table.js.map +1 -1
  173. package/dist/components/text-link.d.ts +238 -0
  174. package/dist/components/text-link.js +144 -0
  175. package/dist/components/text-link.js.map +1 -0
  176. package/dist/components/text.d.ts +26 -2
  177. package/dist/components/text.js +16 -2
  178. package/dist/components/text.js.map +1 -1
  179. package/dist/components/time-input.d.ts +49 -1
  180. package/dist/components/toggle-group.d.ts +35 -0
  181. package/dist/components/toggle-group.js +43 -14
  182. package/dist/components/toggle-group.js.map +1 -1
  183. package/dist/components/toggle-legend.d.ts +53 -3
  184. package/dist/components/toggle-legend.js +54 -1
  185. package/dist/components/toggle-legend.js.map +1 -1
  186. package/dist/components/tooltip.d.ts +51 -1
  187. package/dist/components/tooltip.js +59 -35
  188. package/dist/components/tooltip.js.map +1 -1
  189. package/dist/components/ui.d.ts +51 -779
  190. package/dist/components/ui.js +364 -34
  191. package/dist/components/ui.js.map +1 -1
  192. package/dist/components/use-table-state.d.ts +3 -52
  193. package/dist/components/use-table-state.js +128 -30
  194. package/dist/components/use-table-state.js.map +1 -1
  195. package/dist/{data-table-filters-Dh9uF_S-.d.ts → data-table-Drun8Fk9.d.ts} +305 -61
  196. package/dist/data-table.d.ts +2 -1
  197. package/dist/data-table.js +5 -1
  198. package/dist/data-table.js.map +1 -1
  199. package/dist/feedback/feedback-attachment.js +4 -6
  200. package/dist/feedback/feedback-attachment.js.map +1 -1
  201. package/dist/feedback/feedback-dialog.d.ts +26 -3
  202. package/dist/feedback/feedback-dialog.js +21 -5
  203. package/dist/feedback/feedback-dialog.js.map +1 -1
  204. package/dist/feedback/feedback-inbox.js +86 -75
  205. package/dist/feedback/feedback-inbox.js.map +1 -1
  206. package/dist/feedback/feedback-thread.d.ts +173 -0
  207. package/dist/feedback/feedback-thread.js +264 -0
  208. package/dist/feedback/feedback-thread.js.map +1 -0
  209. package/dist/feedback.d.ts +2 -1
  210. package/dist/feedback.js +1 -0
  211. package/dist/feedback.js.map +1 -1
  212. package/dist/hooks/use-authed-src.d.ts +71 -0
  213. package/dist/hooks/use-authed-src.js +63 -0
  214. package/dist/hooks/use-authed-src.js.map +1 -0
  215. package/dist/hooks/use-file-drop.d.ts +49 -2
  216. package/dist/hooks/use-hotkey.d.ts +59 -0
  217. package/dist/hooks/use-hotkey.js +105 -0
  218. package/dist/hooks/use-hotkey.js.map +1 -0
  219. package/dist/hooks/use-search-param-state.d.ts +83 -0
  220. package/dist/hooks/use-search-param-state.js +94 -0
  221. package/dist/hooks/use-search-param-state.js.map +1 -0
  222. package/dist/i18n/defaults.d.ts +15 -4
  223. package/dist/i18n/defaults.js +31 -1
  224. package/dist/i18n/defaults.js.map +1 -1
  225. package/dist/i18n/kit-labels.d.ts +46 -312
  226. package/dist/i18n/kit-labels.js +20 -5
  227. package/dist/i18n/kit-labels.js.map +1 -1
  228. package/dist/i18n/locales/de-CH-informal.d.ts +15 -4
  229. package/dist/i18n/locales/de-CH.d.ts +15 -4
  230. package/dist/i18n/locales/de-informal.d.ts +15 -4
  231. package/dist/i18n/locales/de.d.ts +15 -4
  232. package/dist/i18n/locales/de.js +164 -3
  233. package/dist/i18n/locales/de.js.map +1 -1
  234. package/dist/i18n/locales/es.d.ts +15 -4
  235. package/dist/i18n/locales/es.js +161 -3
  236. package/dist/i18n/locales/es.js.map +1 -1
  237. package/dist/i18n/locales/fr.d.ts +15 -4
  238. package/dist/i18n/locales/fr.js +161 -3
  239. package/dist/i18n/locales/fr.js.map +1 -1
  240. package/dist/i18n/locales/hu.d.ts +15 -4
  241. package/dist/i18n/locales/hu.js +161 -3
  242. package/dist/i18n/locales/hu.js.map +1 -1
  243. package/dist/i18n/locales/it.d.ts +15 -4
  244. package/dist/i18n/locales/it.js +161 -3
  245. package/dist/i18n/locales/it.js.map +1 -1
  246. package/dist/i18n/locales/zh.d.ts +15 -4
  247. package/dist/i18n/locales/zh.js +161 -3
  248. package/dist/i18n/locales/zh.js.map +1 -1
  249. package/dist/index.d.ts +39 -19
  250. package/dist/index.js +40 -1
  251. package/dist/index.js.map +1 -1
  252. package/dist/kit-labels-Mz8zZHIF.d.ts +1744 -0
  253. package/dist/lib/format.d.ts +162 -0
  254. package/dist/lib/format.js +151 -0
  255. package/dist/lib/format.js.map +1 -0
  256. package/dist/lib/qr-encode.d.ts +44 -0
  257. package/dist/lib/qr-encode.js +338 -0
  258. package/dist/lib/qr-encode.js.map +1 -0
  259. package/dist/rhf/fields.d.ts +283 -0
  260. package/dist/rhf/fields.js +631 -0
  261. package/dist/rhf/fields.js.map +1 -0
  262. package/dist/rhf/form.d.ts +49 -1
  263. package/dist/rhf/line-items.d.ts +31 -0
  264. package/dist/rhf/line-items.js +59 -0
  265. package/dist/rhf/line-items.js.map +1 -0
  266. package/dist/rhf.d.ts +61 -1
  267. package/dist/rhf.js +2 -0
  268. package/dist/rhf.js.map +1 -1
  269. package/dist/search/command-palette.js +20 -14
  270. package/dist/search/command-palette.js.map +1 -1
  271. package/dist/shell/app-shell.d.ts +99 -2
  272. package/dist/shell/app-shell.js +120 -57
  273. package/dist/shell/app-shell.js.map +1 -1
  274. package/dist/shell/auth-layout.d.ts +74 -0
  275. package/dist/shell/auth-layout.js +97 -0
  276. package/dist/shell/auth-layout.js.map +1 -0
  277. package/dist/shell/top-bar-brand.d.ts +81 -0
  278. package/dist/shell/top-bar-brand.js +47 -0
  279. package/dist/shell/top-bar-brand.js.map +1 -0
  280. package/dist/shell/topbar-action-menu.d.ts +21 -4
  281. package/dist/shell/topbar-action-menu.js +18 -2
  282. package/dist/shell/topbar-action-menu.js.map +1 -1
  283. package/dist/shell.d.ts +56 -1
  284. package/dist/shell.js +2 -0
  285. package/dist/shell.js.map +1 -1
  286. package/dist/tour/tour.js +10 -4
  287. package/dist/tour/tour.js.map +1 -1
  288. package/dist/wizard/stepper-nav.d.ts +48 -1
  289. package/dist/wizard/use-wizard.js +4 -2
  290. package/dist/wizard/use-wizard.js.map +1 -1
  291. package/dist/wizard/wizard-context.d.ts +24 -1
  292. package/dist/wizard/wizard-context.js +19 -2
  293. package/dist/wizard/wizard-context.js.map +1 -1
  294. package/dist/wizard/wizard-step.d.ts +30 -5
  295. package/dist/wizard/wizard-step.js +34 -3
  296. package/dist/wizard/wizard-step.js.map +1 -1
  297. package/dist/wizard.d.ts +50 -3
  298. package/package.json +6 -6
  299. package/src/chart.ts +4 -0
  300. package/src/components/account-settings-labels.ts +190 -0
  301. package/src/components/account-settings.tsx +110 -63
  302. package/src/components/amount-input.tsx +109 -10
  303. package/src/components/authed-image.tsx +190 -0
  304. package/src/components/breadcrumbs.tsx +8 -2
  305. package/src/components/bulk-action-bar.tsx +16 -3
  306. package/src/components/button-group.tsx +7 -2
  307. package/src/components/calendar-heatmap.tsx +105 -10
  308. package/src/components/chart.tsx +19 -8
  309. package/src/components/chip.tsx +14 -4
  310. package/src/components/choice-card.tsx +136 -25
  311. package/src/components/combobox-core.tsx +33 -9
  312. package/src/components/combobox.tsx +33 -9
  313. package/src/components/copy-button.tsx +3 -2
  314. package/src/components/data-table-cells.tsx +119 -0
  315. package/src/components/data-table-filter-popover.tsx +13 -5
  316. package/src/components/data-table-filters.ts +77 -0
  317. package/src/components/data-table-labels.ts +23 -0
  318. package/src/components/data-table.tsx +230 -13
  319. package/src/components/date-picker.tsx +19 -3
  320. package/src/components/description-list.tsx +52 -3
  321. package/src/components/entity-combobox.tsx +25 -7
  322. package/src/components/error-boundary.tsx +640 -0
  323. package/src/components/field-sync.tsx +48 -40
  324. package/src/components/field.tsx +56 -5
  325. package/src/components/floating-panel.tsx +20 -7
  326. package/src/components/form-actions.tsx +191 -0
  327. package/src/components/full-bleed-dialog.tsx +4 -0
  328. package/src/components/hover-menu.tsx +26 -17
  329. package/src/components/image-grid.tsx +181 -0
  330. package/src/components/lightbox.tsx +374 -0
  331. package/src/components/line-items.tsx +385 -0
  332. package/src/components/list.tsx +82 -19
  333. package/src/components/loading-state.tsx +47 -0
  334. package/src/components/menu-item.tsx +7 -2
  335. package/src/components/mini-calendar.tsx +72 -3
  336. package/src/components/modal.tsx +65 -3
  337. package/src/components/month-picker.tsx +181 -26
  338. package/src/components/multi-entity-combobox.tsx +27 -7
  339. package/src/components/nav-pills.tsx +8 -1
  340. package/src/components/number-field.tsx +15 -10
  341. package/src/components/number-input.tsx +17 -1
  342. package/src/components/numpad-sheet.tsx +6 -1
  343. package/src/components/page-header.tsx +42 -5
  344. package/src/components/passkeys-setting.tsx +331 -0
  345. package/src/components/picker-sheet.tsx +10 -1
  346. package/src/components/pie-chart-labels.ts +32 -0
  347. package/src/components/pie-chart.tsx +479 -0
  348. package/src/components/popover.tsx +3 -0
  349. package/src/components/progress-bar.tsx +129 -19
  350. package/src/components/qr-code.tsx +83 -0
  351. package/src/components/search-field.tsx +20 -4
  352. package/src/components/signed-amount.tsx +295 -0
  353. package/src/components/skeleton.tsx +21 -3
  354. package/src/components/stat-tile.tsx +11 -3
  355. package/src/components/swipeable-row.tsx +7 -7
  356. package/src/components/table.tsx +102 -13
  357. package/src/components/text-link.tsx +356 -0
  358. package/src/components/text.tsx +46 -2
  359. package/src/components/toggle-group.tsx +93 -20
  360. package/src/components/toggle-legend.tsx +108 -2
  361. package/src/components/tooltip.tsx +79 -8
  362. package/src/components/ui.tsx +707 -49
  363. package/src/components/use-table-state.ts +265 -33
  364. package/src/data-table.ts +10 -0
  365. package/src/feedback/feedback-attachment.tsx +10 -7
  366. package/src/feedback/feedback-dialog.tsx +49 -7
  367. package/src/feedback/feedback-inbox.tsx +7 -0
  368. package/src/feedback/feedback-thread.tsx +510 -0
  369. package/src/feedback.ts +1 -0
  370. package/src/hooks/use-authed-src.ts +161 -0
  371. package/src/hooks/use-hotkey.ts +172 -0
  372. package/src/hooks/use-search-param-state.ts +187 -0
  373. package/src/i18n/defaults.ts +30 -0
  374. package/src/i18n/kit-labels.tsx +118 -8
  375. package/src/i18n/locales/de.ts +161 -0
  376. package/src/i18n/locales/es.ts +158 -0
  377. package/src/i18n/locales/fr.ts +161 -0
  378. package/src/i18n/locales/hu.ts +159 -0
  379. package/src/i18n/locales/it.ts +159 -0
  380. package/src/i18n/locales/zh.ts +158 -0
  381. package/src/index.ts +59 -0
  382. package/src/lib/format.ts +348 -0
  383. package/src/lib/qr-encode.ts +420 -0
  384. package/src/rhf/fields.tsx +1135 -0
  385. package/src/rhf/line-items.tsx +130 -0
  386. package/src/rhf.ts +6 -0
  387. package/src/search/command-palette.tsx +29 -19
  388. package/src/shell/app-shell.tsx +153 -3
  389. package/src/shell/auth-layout.tsx +190 -0
  390. package/src/shell/top-bar-brand.tsx +76 -0
  391. package/src/shell/topbar-action-menu.tsx +32 -4
  392. package/src/shell.ts +2 -0
  393. package/src/tour/tour.tsx +16 -5
  394. package/src/wizard/use-wizard.ts +8 -4
  395. package/src/wizard/wizard-context.tsx +41 -1
  396. package/src/wizard/wizard-step.tsx +75 -6
  397. package/tokens.css +12 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/wizard/use-wizard.ts"],"sourcesContent":["/**\n * The multi-step wizard state machine: step index, completed/skipped sets,\n * per-step async validators, collected data, field errors, submit and the\n * cancel-confirm gate.\n *\n * Domain-free, and router-free on request. By default it mirrors the active step\n * to `?step=N`, so it must be mounted inside a react-router context — the same\n * requirement `DataTable` already carries. `urlSync: false` keeps the step in\n * memory and needs no router; `urlSync: { param }` renames the param. It only ever\n * WRITES that param (see the note on `initialStep` below for why it deliberately\n * does not read it back), and removes it when the wizard is left through the kit\n * (see `UseWizardOptions.urlSync`).\n *\n * The committing step is the last one unless a step says `commits: true`; the\n * steps after that one are post-commit steps (see `WizardStepConfig.commits`).\n */\nimport { useCallback, useEffect, useReducer, useRef, useState } from \"react\";\nimport { useSearchParams } from \"react-router\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport { DEFAULT_WIZARD_LABELS } from \"./types\";\nimport { toast } from \"../components/toast\";\nimport type {\n FieldErrors,\n StepStatus,\n UseWizardOptions,\n UseWizardReturn,\n ValidateResult,\n WizardStepConfig,\n} from \"./types\";\n\ninterface WizardState<TData> {\n currentStepIndex: number;\n completedSteps: Set<number>;\n skippedSteps: Set<number>;\n data: TData;\n isSubmitting: boolean;\n isValidating: boolean;\n error: string | null;\n fieldErrors: FieldErrors;\n showCancelDialog: boolean;\n /** The step whose `onComplete` resolved, or null before any commit. */\n committedStepIndex: number | null;\n}\n\n/** Past the commit: the active step comes after the step that committed. Moves to\n * that step or any before it are refused from here. */\nfunction isAfterCommit(state: { currentStepIndex: number; committedStepIndex: number | null }) {\n return state.committedStepIndex !== null && state.currentStepIndex > state.committedStepIndex;\n}\n\n/** Whether `index` is on the far side of a commit the wizard has already moved past. */\nfunction crossesCommit(\n state: { currentStepIndex: number; committedStepIndex: number | null },\n index: number,\n) {\n return isAfterCommit(state) && index <= (state.committedStepIndex as number);\n}\n\ntype WizardAction<TData> =\n // `from` is the step the move was decided ON. A move whose step is no longer the\n // current one is stale — see `goNext` — and is dropped rather than applied relative\n // to wherever the wizard has got to since.\n | { type: \"GO_NEXT\"; from: number }\n | { type: \"GO_BACK\" }\n | { type: \"GO_TO_STEP\"; index: number }\n | { type: \"SKIP\"; from: number }\n | { type: \"UPDATE_DATA\"; partial: Partial<TData> }\n | { type: \"COMMITTED\"; from: number }\n | { type: \"SET_SUBMITTING\"; value: boolean }\n | { type: \"SET_VALIDATING\"; value: boolean }\n | { type: \"SET_ERROR\"; error: string | null }\n | { type: \"SET_FIELD_ERRORS\"; errors: FieldErrors }\n | { type: \"SHOW_CANCEL_DIALOG\"; show: boolean };\n\nfunction createReducer<TData>(stepCount: number) {\n return function reducer(\n state: WizardState<TData>,\n action: WizardAction<TData>,\n ): WizardState<TData> {\n switch (action.type) {\n case \"GO_NEXT\": {\n if (action.from !== state.currentStepIndex) return state;\n const completed = new Set(state.completedSteps);\n completed.add(state.currentStepIndex);\n const nextIndex = Math.min(state.currentStepIndex + 1, stepCount - 1);\n return { ...state, currentStepIndex: nextIndex, completedSteps: completed, fieldErrors: {} };\n }\n case \"GO_BACK\": {\n const prevIndex = Math.max(state.currentStepIndex - 1, 0);\n if (crossesCommit(state, prevIndex)) return state;\n return { ...state, currentStepIndex: prevIndex, fieldErrors: {} };\n }\n case \"GO_TO_STEP\": {\n if (action.index < 0 || action.index >= stepCount) return state;\n if (crossesCommit(state, action.index)) return state;\n if (!state.completedSteps.has(action.index) && action.index > state.currentStepIndex) {\n return state;\n }\n return { ...state, currentStepIndex: action.index };\n }\n case \"SKIP\": {\n if (action.from !== state.currentStepIndex) return state;\n const skipped = new Set(state.skippedSteps);\n skipped.add(state.currentStepIndex);\n const nextIndex = Math.min(state.currentStepIndex + 1, stepCount - 1);\n return { ...state, currentStepIndex: nextIndex, skippedSteps: skipped };\n }\n case \"UPDATE_DATA\": {\n // Clear error for any field that is now being edited (so typing makes\n // the red message disappear).\n const nextErrors = { ...state.fieldErrors };\n for (const key of Object.keys(action.partial)) {\n delete nextErrors[key];\n }\n return { ...state, data: { ...state.data, ...action.partial }, fieldErrors: nextErrors };\n }\n case \"COMMITTED\": {\n // Recorded whatever step committed, so `wizard.committed` reads true after any\n // successful Finish. Only a commit with steps after it MOVES: the default\n // last-step commit stays where it is and looks exactly as it did before 0.8.\n const committed = { ...state, committedStepIndex: action.from };\n if (action.from !== state.currentStepIndex || action.from >= stepCount - 1) {\n return committed;\n }\n const completed = new Set(state.completedSteps);\n completed.add(action.from);\n return {\n ...committed,\n currentStepIndex: action.from + 1,\n completedSteps: completed,\n fieldErrors: {},\n };\n }\n case \"SET_SUBMITTING\":\n return { ...state, isSubmitting: action.value };\n case \"SET_VALIDATING\":\n return { ...state, isValidating: action.value };\n case \"SET_ERROR\":\n return { ...state, error: action.error };\n case \"SET_FIELD_ERRORS\":\n return { ...state, fieldErrors: action.errors };\n case \"SHOW_CANCEL_DIALOG\":\n return { ...state, showCancelDialog: action.show };\n default:\n return state;\n }\n };\n}\n\nexport function useWizard<TData extends Record<string, unknown>>(\n options: UseWizardOptions<TData>,\n): UseWizardReturn<TData> {\n const {\n steps,\n initialData,\n onComplete,\n onCancel,\n onExit,\n onDone,\n cancellable = true,\n confirmCancel: askBeforeCancel = true,\n urlSync = true,\n missingRequiredMessage,\n onValidationFailed,\n } = options;\n const stepsRef = useRef<WizardStepConfig[]>(steps);\n stepsRef.current = steps;\n // A hook, not a component, but it produces two sentences of its own — the\n // \"fill in the required fields\" toast and the fallback submit error — and both\n // reach the user. So it reads the provider like any component does; only the two\n // strings are depended on below, so the callbacks stay stable across renders.\n // The `??` is for the type only: both keys are optional on `WizardLabels` (see\n // there), and the merge never replaces a default with `undefined`.\n const wizardLabels = useKitLabels(\"wizard\", DEFAULT_WIZARD_LABELS, {\n missingRequired: missingRequiredMessage,\n });\n const missingRequired = wizardLabels.missingRequired ?? DEFAULT_WIZARD_LABELS.missingRequired;\n const genericError = wizardLabels.genericError ?? DEFAULT_WIZARD_LABELS.genericError;\n\n // Validators registered by the CURRENT step's mounted components (RHF steps\n // register via `useRhfWizardStep` through the wizard context). Only the active\n // step's validators are present — each unregisters on unmount. `goNext` and\n // `finish` run them (via `runStepValidators`) alongside the step config's own\n // `validate`.\n const validatorsRef = useRef(\n new Map<symbol, () => ValidateResult | Promise<ValidateResult>>(),\n );\n const registerStepValidate = useCallback(\n (fn: () => ValidateResult | Promise<ValidateResult>) => {\n const token = Symbol();\n validatorsRef.current.set(token, fn);\n return () => {\n validatorsRef.current.delete(token);\n };\n },\n [],\n );\n\n // Chosen once, at mount: a hook may not be called conditionally, but it may be\n // chosen once and then called unconditionally on every render — which is what\n // makes `urlSync: false` work with no router above the wizard at all.\n const [useStepUrl] = useState(() => (urlSync === false ? useNoStepUrl : useSearchParamStepUrl));\n const [urlParam] = useState(() =>\n typeof urlSync === \"object\" && urlSync.param ? urlSync.param : \"step\",\n );\n // The wizard's entered `data` and `completedSteps` are NOT persisted across a\n // reload / deep-link (the reducer re-inits to empty defaults on every mount).\n // Restoring a later step index from `?step=N` would therefore leave the wizard\n // on (or past) the last step with an EMPTY data set, letting Finish submit an\n // empty payload. Always start at step 0 so a reload re-runs the wizard from a\n // valid state instead of losing the entered data silently.\n const initialStep = 0;\n\n const reducer = createReducer<TData>(steps.length);\n const [state, dispatch] = useReducer(reducer, {\n currentStepIndex: initialStep,\n completedSteps: new Set<number>(),\n skippedSteps: new Set<number>(),\n data: (initialData ?? {}) as TData,\n isSubmitting: false,\n isValidating: false,\n error: null,\n fieldErrors: {},\n showCancelDialog: false,\n committedStepIndex: null,\n });\n\n // A mounted step can DISABLE forward navigation (Next/Skip) while its own\n // state is invalid (e.g. tenant shares != 100%). Defaults to false, so\n // wizards that never call setNextBlocked behave exactly as before.\n const [nextBlocked, setNextBlockedState] = useState(false);\n const setNextBlocked = useCallback(\n (blocked: boolean) => setNextBlockedState(blocked),\n [],\n );\n\n // Sync step index to URL (a no-op under `urlSync: false`). `clearStepUrl` drops\n // the param when the wizard is left through the kit, and stops the sync writing\n // it back.\n const clearStepUrl = useStepUrl(urlParam, state.currentStepIndex);\n\n // `steps`, not `stepsRef.current`: during render the two are the same array, and\n // reading a ref in render is what the hooks linter (rightly) objects to.\n const currentStep = steps[state.currentStepIndex];\n const isFirstStep = state.currentStepIndex === 0;\n const isLastStep = state.currentStepIndex === steps.length - 1;\n // The step whose forward button commits: the first one flagged `commits`, else the\n // last — which is every wizard written before the flag existed.\n const flagged = steps.findIndex((s) => s.commits);\n const commitStepIndex = flagged === -1 ? steps.length - 1 : flagged;\n const isCommitStep = state.currentStepIndex === commitStepIndex;\n const afterCommit = isAfterCommit(state);\n // Finish is only valid once every step before the committing one has actually\n // been walked through (completed or skipped). Guards against a restored/last-step\n // index submitting a payload built from empty defaults.\n const canFinish = steps.every(\n (_, index) =>\n index >= commitStepIndex ||\n state.completedSteps.has(index) ||\n state.skippedSteps.has(index),\n );\n const canGoBack =\n (!isFirstStep || onExit !== undefined) &&\n !crossesCommit(state, state.currentStepIndex - 1);\n const canCancel = cancellable && !afterCommit;\n const canDone = isLastStep && afterCommit && onDone !== undefined;\n\n // Runs the active step's config `validate` plus every validator its mounted\n // components registered (RHF steps via useRhfWizardStep), AND-combining the\n // results and merging any per-field errors. Returns `true` when the step\n // passes (or registered no validators). Shared by `goNext` and `finish` so a\n // form-bearing last step is validated (and its values flushed) on Finish too.\n const runStepValidators = useCallback(async (): Promise<boolean> => {\n const step = stepsRef.current[state.currentStepIndex];\n const validators = [...validatorsRef.current.values()];\n if (step.validate) validators.push(step.validate);\n if (validators.length === 0) return true;\n let ok = true;\n let errors: FieldErrors = {};\n try {\n for (const validate of validators) {\n const result = await validate();\n const vOk = typeof result === \"boolean\" ? result : result.ok;\n if (!vOk) {\n ok = false;\n if (typeof result !== \"boolean\" && result.errors) {\n errors = { ...errors, ...result.errors };\n }\n }\n }\n } catch (err) {\n // FALL THROUGH, do not return. A bare `return false` here blocked Next while\n // skipping the `if (!ok)` block below — the only thing that shows a message,\n // and whose own comment is \"say something anyway, so the user is not left with\n // a Next button that silently does nothing\". So a validator that threw (an\n // async one whose request rejected, a null dereference in a field rule)\n // produced exactly the outcome that block was written to prevent: no field\n // errors, no toast, `onValidationFailed` never called, nothing in the console.\n //\n // The step still must not advance; `ok = false` is what says so. Whatever\n // partial `errors` the loop had collected before the throw are kept — they are\n // real, and an empty set is what routes this to the generic message.\n console.error(\"[wizard] a step validator threw\", err);\n ok = false;\n }\n if (!ok) {\n dispatch({ type: \"SET_FIELD_ERRORS\", errors });\n if (Object.keys(errors).length === 0) {\n // No per-field detail (e.g. an RHF step surfacing its own inline\n // message) — say something anyway, so the user is not left with a Next\n // button that silently does nothing.\n const message = missingRequired;\n if (onValidationFailed) {\n onValidationFailed(message);\n } else {\n // The kit's `toast` loads sonner (an optional peer) lazily, so an app\n // that never trips this never has to install it.\n toast.error(message);\n }\n }\n return false;\n }\n return true;\n }, [state.currentStepIndex, missingRequired, onValidationFailed]);\n\n /**\n * One forward move at a time. A double-click on Next used to validate the CURRENT\n * step twice and then advance twice — the second GO_NEXT landing on a step whose\n * own validators never ran, so a required field two steps in could be walked past.\n * Two layers, because either alone leaves a gap:\n *\n * - this ref refuses a second `goNext`/`skip`/`finish` while one is in flight,\n * which covers an async validator (a server check) of any length;\n * - the `from` on each action drops a move decided on a step that is no longer\n * current, which covers the click that arrives after the first move resolved\n * but before React re-rendered — its closure still holds the old step index.\n */\n const advancingRef = useRef(false);\n\n const goNext = useCallback(async () => {\n if (advancingRef.current) return;\n advancingRef.current = true;\n const from = state.currentStepIndex;\n // Pending state for the chrome (spinner, aria-busy). The ref above is still what\n // refuses the second click: state would only be seen after a re-render.\n dispatch({ type: \"SET_VALIDATING\", value: true });\n try {\n if (await runStepValidators()) {\n dispatch({ type: \"GO_NEXT\", from });\n }\n } finally {\n dispatch({ type: \"SET_VALIDATING\", value: false });\n advancingRef.current = false;\n }\n }, [runStepValidators, state.currentStepIndex]);\n\n // Read by `goBack`, which must not move while `onComplete` runs: the commit was\n // decided on the data of the step the user is on, and Back mid-commit would show a\n // step whose edits can no longer reach it. The chrome disables the button too; this\n // covers an app calling `goBack` itself.\n const submittingRef = useRef(false);\n\n const goBack = useCallback(() => {\n if (submittingRef.current) return;\n if (state.currentStepIndex === 0 && onExit) {\n clearStepUrl();\n onExit();\n return;\n }\n // On step 0 with no `onExit` this stays the no-op move (clearing field errors) it\n // always was.\n dispatch({ type: \"GO_BACK\" });\n }, [state.currentStepIndex, onExit, clearStepUrl]);\n\n const goToStep = useCallback((index: number) => {\n dispatch({ type: \"GO_TO_STEP\", index });\n }, []);\n\n const canGoToStep = useCallback(\n (index: number) =>\n index >= 0 &&\n index < steps.length &&\n (index <= state.currentStepIndex || state.completedSteps.has(index)) &&\n !crossesCommit(state, index),\n [steps.length, state],\n );\n\n const skip = useCallback(() => {\n // Not while Next is validating: the skip would land first and the pending GO_NEXT\n // would then be stale anyway — but the user asked for one move, not a race.\n if (advancingRef.current) return;\n dispatch({ type: \"SKIP\", from: state.currentStepIndex });\n }, [state.currentStepIndex]);\n\n const confirmCancel = useCallback(() => {\n dispatch({ type: \"SHOW_CANCEL_DIALOG\", show: false });\n clearStepUrl();\n onCancel?.();\n }, [onCancel, clearStepUrl]);\n\n const cancel = useCallback(() => {\n if (!askBeforeCancel) {\n confirmCancel();\n return;\n }\n dispatch({ type: \"SHOW_CANCEL_DIALOG\", show: true });\n }, [askBeforeCancel, confirmCancel]);\n\n const done = useCallback(() => {\n clearStepUrl();\n onDone?.();\n }, [onDone, clearStepUrl]);\n\n const dismissCancel = useCallback(() => {\n dispatch({ type: \"SHOW_CANCEL_DIALOG\", show: false });\n }, []);\n\n const updateData = useCallback((partial: Partial<TData>) => {\n dispatch({ type: \"UPDATE_DATA\", partial });\n }, []);\n\n const clearError = useCallback(() => {\n dispatch({ type: \"SET_ERROR\", error: null });\n }, []);\n\n const clearFieldErrors = useCallback(() => {\n dispatch({ type: \"SET_FIELD_ERRORS\", errors: {} });\n }, []);\n\n const finish = useCallback(async () => {\n if (!onComplete || !canFinish) return;\n // A commit with steps after it happens once: those steps exist because the\n // data has been written. (A last-step commit keeps its old behaviour — the app\n // may retry Finish after `onComplete` resolved, as it always could.)\n if (commitStepIndex < steps.length - 1 && state.committedStepIndex !== null) return;\n // The same re-entry guard as `goNext`: a double-click on Finish would otherwise\n // validate twice and call `onComplete` twice — `isSubmitting` is only set once\n // validation has passed, too late to stop the second click.\n if (advancingRef.current) return;\n advancingRef.current = true;\n const from = state.currentStepIndex;\n try {\n // Validate the (possibly form-bearing) committing step before submitting,\n // matching the Next gate — review-only steps register no validators and pass\n // through.\n dispatch({ type: \"SET_VALIDATING\", value: true });\n let valid: boolean;\n try {\n valid = await runStepValidators();\n } finally {\n dispatch({ type: \"SET_VALIDATING\", value: false });\n }\n if (!valid) return;\n submittingRef.current = true;\n dispatch({ type: \"SET_SUBMITTING\", value: true });\n dispatch({ type: \"SET_ERROR\", error: null });\n try {\n await onComplete(state.data);\n dispatch({ type: \"COMMITTED\", from });\n } catch (err) {\n const message = err instanceof Error && err.message ? err.message : genericError;\n dispatch({ type: \"SET_ERROR\", error: message });\n } finally {\n submittingRef.current = false;\n dispatch({ type: \"SET_SUBMITTING\", value: false });\n }\n } finally {\n advancingRef.current = false;\n }\n }, [\n onComplete,\n canFinish,\n commitStepIndex,\n steps.length,\n state.committedStepIndex,\n state.currentStepIndex,\n state.data,\n runStepValidators,\n genericError,\n ]);\n\n const stepStatus = useCallback(\n (index: number): StepStatus => {\n if (index === state.currentStepIndex) return \"active\";\n if (state.skippedSteps.has(index)) return \"skipped\";\n if (state.completedSteps.has(index)) return \"completed\";\n return \"upcoming\";\n },\n [state.currentStepIndex, state.completedSteps, state.skippedSteps],\n );\n\n return {\n currentStepIndex: state.currentStepIndex,\n currentStep,\n steps,\n isFirstStep,\n isLastStep,\n canFinish,\n commitStepIndex,\n isCommitStep,\n committed: state.committedStepIndex !== null,\n canGoBack,\n canCancel,\n canDone,\n canGoToStep,\n goNext,\n goBack,\n goToStep,\n skip,\n cancel,\n finish,\n done,\n registerStepValidate,\n nextBlocked,\n setNextBlocked,\n stepStatus,\n completedSteps: state.completedSteps,\n data: state.data,\n updateData,\n isSubmitting: state.isSubmitting,\n isValidating: state.isValidating,\n error: state.error,\n clearError,\n fieldErrors: state.fieldErrors,\n clearFieldErrors,\n showCancelDialog: state.showCancelDialog,\n confirmCancel,\n dismissCancel,\n };\n}\n\n/**\n * `urlSync: true` / `{ param }`: mirror the active step to `?<param>=N`, and hand back\n * the function that removes it again. Once removed it stays removed — the sync effect\n * re-runs whenever react-router hands out a new setter (every search change), and\n * without the latch it would write the param straight back after the exit cleared it.\n */\nfunction useSearchParamStepUrl(param: string, index: number): () => void {\n const [, setUrlParams] = useSearchParams();\n const leftRef = useRef(false);\n useEffect(() => {\n if (leftRef.current) return;\n setUrlParams((prev) => {\n prev.set(param, String(index));\n return prev;\n }, { replace: true });\n }, [param, index, setUrlParams]);\n return useCallback(() => {\n if (leftRef.current) return;\n leftRef.current = true;\n setUrlParams((prev) => {\n prev.delete(param);\n return prev;\n }, { replace: true });\n }, [param, setUrlParams]);\n}\n\n/** `urlSync: false`: the step lives in the reducer only. Touches no router context. */\nfunction useNoStepUrl(_param: string, _index: number): () => void {\n return noop;\n}\n\nfunction noop() {}\n"],"mappings":";AAgBA,SAAS,aAAa,WAAW,YAAY,QAAQ,gBAAgB;AACrE,SAAS,uBAAuB;AAChC,SAAS,oBAAoB;AAC7B,SAAS,6BAA6B;AACtC,SAAS,aAAa;AA0BtB,SAAS,cAAc,OAAwE;AAC7F,SAAO,MAAM,uBAAuB,QAAQ,MAAM,mBAAmB,MAAM;AAC7E;AAGA,SAAS,cACP,OACA,OACA;AACA,SAAO,cAAc,KAAK,KAAK,SAAU,MAAM;AACjD;AAkBA,SAAS,cAAqB,WAAmB;AAC/C,SAAO,SAAS,QACd,OACA,QACoB;AACpB,YAAQ,OAAO,MAAM;AAAA,MACnB,KAAK,WAAW;AACd,YAAI,OAAO,SAAS,MAAM,iBAAkB,QAAO;AACnD,cAAM,YAAY,IAAI,IAAI,MAAM,cAAc;AAC9C,kBAAU,IAAI,MAAM,gBAAgB;AACpC,cAAM,YAAY,KAAK,IAAI,MAAM,mBAAmB,GAAG,YAAY,CAAC;AACpE,eAAO,EAAE,GAAG,OAAO,kBAAkB,WAAW,gBAAgB,WAAW,aAAa,CAAC,EAAE;AAAA,MAC7F;AAAA,MACA,KAAK,WAAW;AACd,cAAM,YAAY,KAAK,IAAI,MAAM,mBAAmB,GAAG,CAAC;AACxD,YAAI,cAAc,OAAO,SAAS,EAAG,QAAO;AAC5C,eAAO,EAAE,GAAG,OAAO,kBAAkB,WAAW,aAAa,CAAC,EAAE;AAAA,MAClE;AAAA,MACA,KAAK,cAAc;AACjB,YAAI,OAAO,QAAQ,KAAK,OAAO,SAAS,UAAW,QAAO;AAC1D,YAAI,cAAc,OAAO,OAAO,KAAK,EAAG,QAAO;AAC/C,YAAI,CAAC,MAAM,eAAe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;AACvB,QAAI,QAAQ,QAAS;AACrB,YAAQ,UAAU;AAClB,iBAAa,CAAC,SAAS;AACrB,WAAK,OAAO,KAAK;AACjB,aAAO;AAAA,IACT,GAAG,EAAE,SAAS,KAAK,CAAC;AAAA,EACtB,GAAG,CAAC,OAAO,YAAY,CAAC;AAC1B;AAGA,SAAS,aAAa,QAAgB,QAA4B;AAChE,SAAO;AACT;AAEA,SAAS,OAAO;AAAC;","names":[]}
1
+ {"version":3,"sources":["../../src/wizard/use-wizard.ts"],"sourcesContent":["/**\n * The multi-step wizard state machine: step index, completed/skipped sets,\n * per-step async validators, collected data, field errors, submit and the\n * cancel-confirm gate.\n *\n * Domain-free, and router-free on request. By default it mirrors the active step\n * to `?step=N`, so it must be mounted inside a react-router context — the same\n * requirement `DataTable` already carries. `urlSync: false` keeps the step in\n * memory and needs no router; `urlSync: { param }` renames the param. It only ever\n * WRITES that param (see the note on `initialStep` below for why it deliberately\n * does not read it back), and removes it when the wizard is left through the kit\n * (see `UseWizardOptions.urlSync`).\n *\n * The committing step is the last one unless a step says `commits: true`; the\n * steps after that one are post-commit steps (see `WizardStepConfig.commits`).\n */\nimport { useCallback, useEffect, useLayoutEffect, useReducer, useRef, useState } from \"react\";\nimport { useSearchParams } from \"react-router\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport { DEFAULT_WIZARD_LABELS } from \"./types\";\nimport { toast } from \"../components/toast\";\nimport type {\n FieldErrors,\n StepStatus,\n UseWizardOptions,\n UseWizardReturn,\n ValidateResult,\n WizardStepConfig,\n} from \"./types\";\n\ninterface WizardState<TData> {\n currentStepIndex: number;\n completedSteps: Set<number>;\n skippedSteps: Set<number>;\n data: TData;\n isSubmitting: boolean;\n isValidating: boolean;\n error: string | null;\n fieldErrors: FieldErrors;\n showCancelDialog: boolean;\n /** The step whose `onComplete` resolved, or null before any commit. */\n committedStepIndex: number | null;\n}\n\n/** Past the commit: the active step comes after the step that committed. Moves to\n * that step or any before it are refused from here. */\nfunction isAfterCommit(state: { currentStepIndex: number; committedStepIndex: number | null }) {\n return state.committedStepIndex !== null && state.currentStepIndex > state.committedStepIndex;\n}\n\n/** Whether `index` is on the far side of a commit the wizard has already moved past. */\nfunction crossesCommit(\n state: { currentStepIndex: number; committedStepIndex: number | null },\n index: number,\n) {\n return isAfterCommit(state) && index <= (state.committedStepIndex as number);\n}\n\ntype WizardAction<TData> =\n // `from` is the step the move was decided ON. A move whose step is no longer the\n // current one is stale — see `goNext` — and is dropped rather than applied relative\n // to wherever the wizard has got to since.\n | { type: \"GO_NEXT\"; from: number }\n | { type: \"GO_BACK\" }\n | { type: \"GO_TO_STEP\"; index: number }\n | { type: \"SKIP\"; from: number }\n | { type: \"UPDATE_DATA\"; partial: Partial<TData> }\n | { type: \"COMMITTED\"; from: number }\n | { type: \"SET_SUBMITTING\"; value: boolean }\n | { type: \"SET_VALIDATING\"; value: boolean }\n | { type: \"SET_ERROR\"; error: string | null }\n | { type: \"SET_FIELD_ERRORS\"; errors: FieldErrors }\n | { type: \"SHOW_CANCEL_DIALOG\"; show: boolean };\n\nfunction createReducer<TData>(stepCount: number) {\n return function reducer(\n state: WizardState<TData>,\n action: WizardAction<TData>,\n ): WizardState<TData> {\n switch (action.type) {\n case \"GO_NEXT\": {\n if (action.from !== state.currentStepIndex) return state;\n const completed = new Set(state.completedSteps);\n completed.add(state.currentStepIndex);\n const nextIndex = Math.min(state.currentStepIndex + 1, stepCount - 1);\n return { ...state, currentStepIndex: nextIndex, completedSteps: completed, fieldErrors: {} };\n }\n case \"GO_BACK\": {\n const prevIndex = Math.max(state.currentStepIndex - 1, 0);\n if (crossesCommit(state, prevIndex)) return state;\n return { ...state, currentStepIndex: prevIndex, fieldErrors: {} };\n }\n case \"GO_TO_STEP\": {\n if (action.index < 0 || action.index >= stepCount) return state;\n if (crossesCommit(state, action.index)) return state;\n if (!state.completedSteps.has(action.index) && action.index > state.currentStepIndex) {\n return state;\n }\n return { ...state, currentStepIndex: action.index };\n }\n case \"SKIP\": {\n if (action.from !== state.currentStepIndex) return state;\n const skipped = new Set(state.skippedSteps);\n skipped.add(state.currentStepIndex);\n const nextIndex = Math.min(state.currentStepIndex + 1, stepCount - 1);\n return { ...state, currentStepIndex: nextIndex, skippedSteps: skipped };\n }\n case \"UPDATE_DATA\": {\n // Clear error for any field that is now being edited (so typing makes\n // the red message disappear).\n const nextErrors = { ...state.fieldErrors };\n for (const key of Object.keys(action.partial)) {\n delete nextErrors[key];\n }\n return { ...state, data: { ...state.data, ...action.partial }, fieldErrors: nextErrors };\n }\n case \"COMMITTED\": {\n // Recorded whatever step committed, so `wizard.committed` reads true after any\n // successful Finish. Only a commit with steps after it MOVES: the default\n // last-step commit stays where it is and looks exactly as it did before 0.8.\n const committed = { ...state, committedStepIndex: action.from };\n if (action.from !== state.currentStepIndex || action.from >= stepCount - 1) {\n return committed;\n }\n const completed = new Set(state.completedSteps);\n completed.add(action.from);\n return {\n ...committed,\n currentStepIndex: action.from + 1,\n completedSteps: completed,\n fieldErrors: {},\n };\n }\n case \"SET_SUBMITTING\":\n return { ...state, isSubmitting: action.value };\n case \"SET_VALIDATING\":\n return { ...state, isValidating: action.value };\n case \"SET_ERROR\":\n return { ...state, error: action.error };\n case \"SET_FIELD_ERRORS\":\n return { ...state, fieldErrors: action.errors };\n case \"SHOW_CANCEL_DIALOG\":\n return { ...state, showCancelDialog: action.show };\n default:\n return state;\n }\n };\n}\n\nexport function useWizard<TData extends Record<string, unknown>>(\n options: UseWizardOptions<TData>,\n): UseWizardReturn<TData> {\n const {\n steps,\n initialData,\n onComplete,\n onCancel,\n onExit,\n onDone,\n cancellable = true,\n confirmCancel: askBeforeCancel = true,\n urlSync = true,\n missingRequiredMessage,\n onValidationFailed,\n } = options;\n // The latest `steps`, for the stable callbacks below. Synced after commit (before\n // paint, and before any handler can run) rather than written during render.\n const stepsRef = useRef<WizardStepConfig[]>(steps);\n useLayoutEffect(() => {\n stepsRef.current = steps;\n }, [steps]);\n // A hook, not a component, but it produces two sentences of its own — the\n // \"fill in the required fields\" toast and the fallback submit error — and both\n // reach the user. So it reads the provider like any component does; only the two\n // strings are depended on below, so the callbacks stay stable across renders.\n // The `??` is for the type only: both keys are optional on `WizardLabels` (see\n // there), and the merge never replaces a default with `undefined`.\n const wizardLabels = useKitLabels(\"wizard\", DEFAULT_WIZARD_LABELS, {\n missingRequired: missingRequiredMessage,\n });\n const missingRequired = wizardLabels.missingRequired ?? DEFAULT_WIZARD_LABELS.missingRequired;\n const genericError = wizardLabels.genericError ?? DEFAULT_WIZARD_LABELS.genericError;\n\n // Validators registered by the CURRENT step's mounted components (RHF steps\n // register via `useRhfWizardStep` through the wizard context). Only the active\n // step's validators are present — each unregisters on unmount. `goNext` and\n // `finish` run them (via `runStepValidators`) alongside the step config's own\n // `validate`.\n const validatorsRef = useRef(\n new Map<symbol, () => ValidateResult | Promise<ValidateResult>>(),\n );\n const registerStepValidate = useCallback(\n (fn: () => ValidateResult | Promise<ValidateResult>) => {\n const token = Symbol();\n validatorsRef.current.set(token, fn);\n return () => {\n validatorsRef.current.delete(token);\n };\n },\n [],\n );\n\n // Chosen once, at mount: a hook may not be called conditionally, but it may be\n // chosen once and then called unconditionally on every render — which is what\n // makes `urlSync: false` work with no router above the wizard at all.\n const [useStepUrl] = useState(() => (urlSync === false ? useNoStepUrl : useSearchParamStepUrl));\n const [urlParam] = useState(() =>\n typeof urlSync === \"object\" && urlSync.param ? urlSync.param : \"step\",\n );\n // The wizard's entered `data` and `completedSteps` are NOT persisted across a\n // reload / deep-link (the reducer re-inits to empty defaults on every mount).\n // Restoring a later step index from `?step=N` would therefore leave the wizard\n // on (or past) the last step with an EMPTY data set, letting Finish submit an\n // empty payload. Always start at step 0 so a reload re-runs the wizard from a\n // valid state instead of losing the entered data silently.\n const initialStep = 0;\n\n const reducer = createReducer<TData>(steps.length);\n const [state, dispatch] = useReducer(reducer, {\n currentStepIndex: initialStep,\n completedSteps: new Set<number>(),\n skippedSteps: new Set<number>(),\n data: (initialData ?? {}) as TData,\n isSubmitting: false,\n isValidating: false,\n error: null,\n fieldErrors: {},\n showCancelDialog: false,\n committedStepIndex: null,\n });\n\n // A mounted step can DISABLE forward navigation (Next/Skip) while its own\n // state is invalid (e.g. tenant shares != 100%). Defaults to false, so\n // wizards that never call setNextBlocked behave exactly as before.\n const [nextBlocked, setNextBlockedState] = useState(false);\n const setNextBlocked = useCallback(\n (blocked: boolean) => setNextBlockedState(blocked),\n [],\n );\n\n // Sync step index to URL (a no-op under `urlSync: false`). `clearStepUrl` drops\n // the param when the wizard is left through the kit, and stops the sync writing\n // it back.\n const clearStepUrl = useStepUrl(urlParam, state.currentStepIndex);\n\n // `steps`, not `stepsRef.current`: reading a ref in render is what the hooks\n // linter (rightly) objects to, and the ref only catches up after the commit.\n const currentStep = steps[state.currentStepIndex];\n const isFirstStep = state.currentStepIndex === 0;\n const isLastStep = state.currentStepIndex === steps.length - 1;\n // The step whose forward button commits: the first one flagged `commits`, else the\n // last — which is every wizard written before the flag existed.\n const flagged = steps.findIndex((s) => s.commits);\n const commitStepIndex = flagged === -1 ? steps.length - 1 : flagged;\n const isCommitStep = state.currentStepIndex === commitStepIndex;\n const afterCommit = isAfterCommit(state);\n // Finish is only valid once every step before the committing one has actually\n // been walked through (completed or skipped). Guards against a restored/last-step\n // index submitting a payload built from empty defaults.\n const canFinish = steps.every(\n (_, index) =>\n index >= commitStepIndex ||\n state.completedSteps.has(index) ||\n state.skippedSteps.has(index),\n );\n const canGoBack =\n (!isFirstStep || onExit !== undefined) &&\n !crossesCommit(state, state.currentStepIndex - 1);\n const canCancel = cancellable && !afterCommit;\n const canDone = isLastStep && afterCommit && onDone !== undefined;\n\n // Runs the active step's config `validate` plus every validator its mounted\n // components registered (RHF steps via useRhfWizardStep), AND-combining the\n // results and merging any per-field errors. Returns `true` when the step\n // passes (or registered no validators). Shared by `goNext` and `finish` so a\n // form-bearing last step is validated (and its values flushed) on Finish too.\n const runStepValidators = useCallback(async (): Promise<boolean> => {\n const step = stepsRef.current[state.currentStepIndex];\n const validators = [...validatorsRef.current.values()];\n if (step.validate) validators.push(step.validate);\n if (validators.length === 0) return true;\n let ok = true;\n let errors: FieldErrors = {};\n try {\n for (const validate of validators) {\n const result = await validate();\n const vOk = typeof result === \"boolean\" ? result : result.ok;\n if (!vOk) {\n ok = false;\n if (typeof result !== \"boolean\" && result.errors) {\n errors = { ...errors, ...result.errors };\n }\n }\n }\n } catch (err) {\n // FALL THROUGH, do not return. A bare `return false` here blocked Next while\n // skipping the `if (!ok)` block below — the only thing that shows a message,\n // and whose own comment is \"say something anyway, so the user is not left with\n // a Next button that silently does nothing\". So a validator that threw (an\n // async one whose request rejected, a null dereference in a field rule)\n // produced exactly the outcome that block was written to prevent: no field\n // errors, no toast, `onValidationFailed` never called, nothing in the console.\n //\n // The step still must not advance; `ok = false` is what says so. Whatever\n // partial `errors` the loop had collected before the throw are kept — they are\n // real, and an empty set is what routes this to the generic message.\n console.error(\"[wizard] a step validator threw\", err);\n ok = false;\n }\n if (!ok) {\n dispatch({ type: \"SET_FIELD_ERRORS\", errors });\n if (Object.keys(errors).length === 0) {\n // No per-field detail (e.g. an RHF step surfacing its own inline\n // message) — say something anyway, so the user is not left with a Next\n // button that silently does nothing.\n const message = missingRequired;\n if (onValidationFailed) {\n onValidationFailed(message);\n } else {\n // The kit's `toast` loads sonner (an optional peer) lazily, so an app\n // that never trips this never has to install it.\n toast.error(message);\n }\n }\n return false;\n }\n return true;\n }, [state.currentStepIndex, missingRequired, onValidationFailed]);\n\n /**\n * One forward move at a time. A double-click on Next used to validate the CURRENT\n * step twice and then advance twice — the second GO_NEXT landing on a step whose\n * own validators never ran, so a required field two steps in could be walked past.\n * Two layers, because either alone leaves a gap:\n *\n * - this ref refuses a second `goNext`/`skip`/`finish` while one is in flight,\n * which covers an async validator (a server check) of any length;\n * - the `from` on each action drops a move decided on a step that is no longer\n * current, which covers the click that arrives after the first move resolved\n * but before React re-rendered — its closure still holds the old step index.\n */\n const advancingRef = useRef(false);\n\n const goNext = useCallback(async () => {\n if (advancingRef.current) return;\n advancingRef.current = true;\n const from = state.currentStepIndex;\n // Pending state for the chrome (spinner, aria-busy). The ref above is still what\n // refuses the second click: state would only be seen after a re-render.\n dispatch({ type: \"SET_VALIDATING\", value: true });\n try {\n if (await runStepValidators()) {\n dispatch({ type: \"GO_NEXT\", from });\n }\n } finally {\n dispatch({ type: \"SET_VALIDATING\", value: false });\n advancingRef.current = false;\n }\n }, [runStepValidators, state.currentStepIndex]);\n\n // Read by `goBack`, which must not move while `onComplete` runs: the commit was\n // decided on the data of the step the user is on, and Back mid-commit would show a\n // step whose edits can no longer reach it. The chrome disables the button too; this\n // covers an app calling `goBack` itself.\n const submittingRef = useRef(false);\n\n const goBack = useCallback(() => {\n if (submittingRef.current) return;\n if (state.currentStepIndex === 0 && onExit) {\n clearStepUrl();\n onExit();\n return;\n }\n // On step 0 with no `onExit` this stays the no-op move (clearing field errors) it\n // always was.\n dispatch({ type: \"GO_BACK\" });\n }, [state.currentStepIndex, onExit, clearStepUrl]);\n\n const goToStep = useCallback((index: number) => {\n dispatch({ type: \"GO_TO_STEP\", index });\n }, []);\n\n const canGoToStep = useCallback(\n (index: number) =>\n index >= 0 &&\n index < steps.length &&\n (index <= state.currentStepIndex || state.completedSteps.has(index)) &&\n !crossesCommit(state, index),\n [steps.length, state],\n );\n\n const skip = useCallback(() => {\n // Not while Next is validating: the skip would land first and the pending GO_NEXT\n // would then be stale anyway — but the user asked for one move, not a race.\n if (advancingRef.current) return;\n dispatch({ type: \"SKIP\", from: state.currentStepIndex });\n }, [state.currentStepIndex]);\n\n const confirmCancel = useCallback(() => {\n dispatch({ type: \"SHOW_CANCEL_DIALOG\", show: false });\n clearStepUrl();\n onCancel?.();\n }, [onCancel, clearStepUrl]);\n\n const cancel = useCallback(() => {\n if (!askBeforeCancel) {\n confirmCancel();\n return;\n }\n dispatch({ type: \"SHOW_CANCEL_DIALOG\", show: true });\n }, [askBeforeCancel, confirmCancel]);\n\n const done = useCallback(() => {\n clearStepUrl();\n onDone?.();\n }, [onDone, clearStepUrl]);\n\n const dismissCancel = useCallback(() => {\n dispatch({ type: \"SHOW_CANCEL_DIALOG\", show: false });\n }, []);\n\n const updateData = useCallback((partial: Partial<TData>) => {\n dispatch({ type: \"UPDATE_DATA\", partial });\n }, []);\n\n const clearError = useCallback(() => {\n dispatch({ type: \"SET_ERROR\", error: null });\n }, []);\n\n const clearFieldErrors = useCallback(() => {\n dispatch({ type: \"SET_FIELD_ERRORS\", errors: {} });\n }, []);\n\n const finish = useCallback(async () => {\n if (!onComplete || !canFinish) return;\n // A commit with steps after it happens once: those steps exist because the\n // data has been written. (A last-step commit keeps its old behaviour — the app\n // may retry Finish after `onComplete` resolved, as it always could.)\n if (commitStepIndex < steps.length - 1 && state.committedStepIndex !== null) return;\n // The same re-entry guard as `goNext`: a double-click on Finish would otherwise\n // validate twice and call `onComplete` twice — `isSubmitting` is only set once\n // validation has passed, too late to stop the second click.\n if (advancingRef.current) return;\n advancingRef.current = true;\n const from = state.currentStepIndex;\n try {\n // Validate the (possibly form-bearing) committing step before submitting,\n // matching the Next gate — review-only steps register no validators and pass\n // through.\n dispatch({ type: \"SET_VALIDATING\", value: true });\n let valid: boolean;\n try {\n valid = await runStepValidators();\n } finally {\n dispatch({ type: \"SET_VALIDATING\", value: false });\n }\n if (!valid) return;\n submittingRef.current = true;\n dispatch({ type: \"SET_SUBMITTING\", value: true });\n dispatch({ type: \"SET_ERROR\", error: null });\n try {\n await onComplete(state.data);\n dispatch({ type: \"COMMITTED\", from });\n } catch (err) {\n const message = err instanceof Error && err.message ? err.message : genericError;\n dispatch({ type: \"SET_ERROR\", error: message });\n } finally {\n submittingRef.current = false;\n dispatch({ type: \"SET_SUBMITTING\", value: false });\n }\n } finally {\n advancingRef.current = false;\n }\n }, [\n onComplete,\n canFinish,\n commitStepIndex,\n steps.length,\n state.committedStepIndex,\n state.currentStepIndex,\n state.data,\n runStepValidators,\n genericError,\n ]);\n\n const stepStatus = useCallback(\n (index: number): StepStatus => {\n if (index === state.currentStepIndex) return \"active\";\n if (state.skippedSteps.has(index)) return \"skipped\";\n if (state.completedSteps.has(index)) return \"completed\";\n return \"upcoming\";\n },\n [state.currentStepIndex, state.completedSteps, state.skippedSteps],\n );\n\n return {\n currentStepIndex: state.currentStepIndex,\n currentStep,\n steps,\n isFirstStep,\n isLastStep,\n canFinish,\n commitStepIndex,\n isCommitStep,\n committed: state.committedStepIndex !== null,\n canGoBack,\n canCancel,\n canDone,\n canGoToStep,\n goNext,\n goBack,\n goToStep,\n skip,\n cancel,\n finish,\n done,\n registerStepValidate,\n nextBlocked,\n setNextBlocked,\n stepStatus,\n completedSteps: state.completedSteps,\n data: state.data,\n updateData,\n isSubmitting: state.isSubmitting,\n isValidating: state.isValidating,\n error: state.error,\n clearError,\n fieldErrors: state.fieldErrors,\n clearFieldErrors,\n showCancelDialog: state.showCancelDialog,\n confirmCancel,\n dismissCancel,\n };\n}\n\n/**\n * `urlSync: true` / `{ param }`: mirror the active step to `?<param>=N`, and hand back\n * the function that removes it again. Once removed it stays removed — the sync effect\n * re-runs whenever react-router hands out a new setter (every search change), and\n * without the latch it would write the param straight back after the exit cleared it.\n */\nfunction useSearchParamStepUrl(param: string, index: number): () => void {\n const [, setUrlParams] = useSearchParams();\n const leftRef = useRef(false);\n useEffect(() => {\n if (leftRef.current) return;\n setUrlParams((prev) => {\n prev.set(param, String(index));\n return prev;\n }, { replace: true });\n }, [param, index, setUrlParams]);\n return useCallback(() => {\n if (leftRef.current) return;\n leftRef.current = true;\n setUrlParams((prev) => {\n prev.delete(param);\n return prev;\n }, { replace: true });\n }, [param, setUrlParams]);\n}\n\n/** `urlSync: false`: the step lives in the reducer only. Touches no router context. */\nfunction useNoStepUrl(_param: string, _index: number): () => void {\n return noop;\n}\n\nfunction noop() {}\n"],"mappings":";AAgBA,SAAS,aAAa,WAAW,iBAAiB,YAAY,QAAQ,gBAAgB;AACtF,SAAS,uBAAuB;AAChC,SAAS,oBAAoB;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E,SAAO;AACT;AAEA,SAAS,OAAO;AAAC;","names":[]}
@@ -21,5 +21,28 @@ declare function useWizardContext(): WizardContextValue;
21
21
  * `@eifi1/ui-kit/rhf`, whose returned `validate` a custom nav can call itself.
22
22
  */
23
23
  declare function useOptionalWizardContext(): WizardContextValue | null;
24
+ /**
25
+ * Registers a plain validator for the mounted step — the counterpart to
26
+ * `useRhfWizardStep` (in `@eifi1/ui-kit/rhf`) for a step that gates on its own state
27
+ * (a hand-managed list of lines, a sum that has to balance) rather than a form.
28
+ *
29
+ * ```tsx
30
+ * useWizardStepValidate(() => ({ ok: lines.length >= 2, errors: { lines: t("…") } }));
31
+ * ```
32
+ *
33
+ * Next (and Finish) run it with the step's other validators; a `false` or a result
34
+ * with `ok: false` keeps the wizard where it is. `validate` is read through a ref, so
35
+ * an inline closure over the latest state registers exactly once. Throws outside a
36
+ * `<StepperNav>`, like {@link useWizardContext}: a validator with nothing to run it is
37
+ * a bug to hear about.
38
+ */
39
+ declare function useWizardStepValidate(validate: () => ValidateResult | Promise<ValidateResult>): void;
40
+ /**
41
+ * Disables the wizard's Next and Skip while `blocked` holds (tenant shares that do not
42
+ * add up to 100 %). Unlike {@link useWizardStepValidate}, which answers a click, this
43
+ * greys the button out before one. The gate is lifted again when the step unmounts, so
44
+ * the next step starts unblocked.
45
+ */
46
+ declare function useWizardNextGate(blocked: boolean): void;
24
47
 
25
- export { WizardContextProvider, type WizardContextValue, useOptionalWizardContext, useWizardContext };
48
+ export { WizardContextProvider, type WizardContextValue, useOptionalWizardContext, useWizardContext, useWizardNextGate, useWizardStepValidate };
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { createContext, useContext } from "react";
2
+ import { createContext, useContext, useEffect, useRef } from "react";
3
3
  const WizardContext = createContext(null);
4
4
  const WizardContextProvider = WizardContext.Provider;
5
5
  function useWizardContext() {
@@ -12,9 +12,26 @@ function useWizardContext() {
12
12
  function useOptionalWizardContext() {
13
13
  return useContext(WizardContext);
14
14
  }
15
+ function useWizardStepValidate(validate) {
16
+ const { registerStepValidate } = useWizardContext();
17
+ const ref = useRef(validate);
18
+ useEffect(() => {
19
+ ref.current = validate;
20
+ });
21
+ useEffect(() => registerStepValidate(() => ref.current()), [registerStepValidate]);
22
+ }
23
+ function useWizardNextGate(blocked) {
24
+ const { setNextBlocked } = useWizardContext();
25
+ useEffect(() => {
26
+ setNextBlocked(blocked);
27
+ return () => setNextBlocked(false);
28
+ }, [blocked, setNextBlocked]);
29
+ }
15
30
  export {
16
31
  WizardContextProvider,
17
32
  useOptionalWizardContext,
18
- useWizardContext
33
+ useWizardContext,
34
+ useWizardNextGate,
35
+ useWizardStepValidate
19
36
  };
20
37
  //# sourceMappingURL=wizard-context.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/wizard/wizard-context.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { ValidateResult } from \"./types\";\n\nexport interface WizardContextValue {\n /**\n * Register a validator for the currently-mounted step. Returns an unregister\n * fn (call it in a useEffect cleanup). `goNext` runs every registered\n * validator for the active step (plus the step config's own `validate`),\n * AND-combining the results — this replaces the per-page `useRef` +\n * `validate: () => ref.current?.()` bridge each RHF step used to wire.\n */\n registerStepValidate: (\n fn: () => ValidateResult | Promise<ValidateResult>,\n ) => () => void;\n /** Lets the mounted step disable Next/Skip (e.g. invalid tenant shares). */\n setNextBlocked: (blocked: boolean) => void;\n}\n\nconst WizardContext = createContext<WizardContextValue | null>(null);\n\nexport const WizardContextProvider = WizardContext.Provider;\n\nexport function useWizardContext(): WizardContextValue {\n const ctx = useContext(WizardContext);\n if (!ctx) {\n throw new Error(\"useWizardContext must be used within a <StepperNav>\");\n }\n return ctx;\n}\n\n/**\n * The wizard context, or `null` outside a `<StepperNav>`. For a hook that registers\n * with the wizard when there is one and works without it — `useRhfWizardStep` in\n * `@eifi1/ui-kit/rhf`, whose returned `validate` a custom nav can call itself.\n */\nexport function useOptionalWizardContext(): WizardContextValue | null {\n return useContext(WizardContext);\n}\n"],"mappings":";AAAA,SAAS,eAAe,kBAAkB;AAkB1C,MAAM,gBAAgB,cAAyC,IAAI;AAE5D,MAAM,wBAAwB,cAAc;AAE5C,SAAS,mBAAuC;AACrD,QAAM,MAAM,WAAW,aAAa;AACpC,MAAI,CAAC,KAAK;AACR,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACvE;AACA,SAAO;AACT;AAOO,SAAS,2BAAsD;AACpE,SAAO,WAAW,aAAa;AACjC;","names":[]}
1
+ {"version":3,"sources":["../../src/wizard/wizard-context.tsx"],"sourcesContent":["import { createContext, useContext, useEffect, useRef } from \"react\";\nimport type { ValidateResult } from \"./types\";\n\nexport interface WizardContextValue {\n /**\n * Register a validator for the currently-mounted step. Returns an unregister\n * fn (call it in a useEffect cleanup). `goNext` runs every registered\n * validator for the active step (plus the step config's own `validate`),\n * AND-combining the results — this replaces the per-page `useRef` +\n * `validate: () => ref.current?.()` bridge each RHF step used to wire.\n */\n registerStepValidate: (\n fn: () => ValidateResult | Promise<ValidateResult>,\n ) => () => void;\n /** Lets the mounted step disable Next/Skip (e.g. invalid tenant shares). */\n setNextBlocked: (blocked: boolean) => void;\n}\n\nconst WizardContext = createContext<WizardContextValue | null>(null);\n\nexport const WizardContextProvider = WizardContext.Provider;\n\nexport function useWizardContext(): WizardContextValue {\n const ctx = useContext(WizardContext);\n if (!ctx) {\n throw new Error(\"useWizardContext must be used within a <StepperNav>\");\n }\n return ctx;\n}\n\n/**\n * The wizard context, or `null` outside a `<StepperNav>`. For a hook that registers\n * with the wizard when there is one and works without it — `useRhfWizardStep` in\n * `@eifi1/ui-kit/rhf`, whose returned `validate` a custom nav can call itself.\n */\nexport function useOptionalWizardContext(): WizardContextValue | null {\n return useContext(WizardContext);\n}\n\n/**\n * Registers a plain validator for the mounted step — the counterpart to\n * `useRhfWizardStep` (in `@eifi1/ui-kit/rhf`) for a step that gates on its own state\n * (a hand-managed list of lines, a sum that has to balance) rather than a form.\n *\n * ```tsx\n * useWizardStepValidate(() => ({ ok: lines.length >= 2, errors: { lines: t(\"…\") } }));\n * ```\n *\n * Next (and Finish) run it with the step's other validators; a `false` or a result\n * with `ok: false` keeps the wizard where it is. `validate` is read through a ref, so\n * an inline closure over the latest state registers exactly once. Throws outside a\n * `<StepperNav>`, like {@link useWizardContext}: a validator with nothing to run it is\n * a bug to hear about.\n */\nexport function useWizardStepValidate(\n validate: () => ValidateResult | Promise<ValidateResult>,\n): void {\n const { registerStepValidate } = useWizardContext();\n const ref = useRef(validate);\n useEffect(() => {\n ref.current = validate;\n });\n useEffect(() => registerStepValidate(() => ref.current()), [registerStepValidate]);\n}\n\n/**\n * Disables the wizard's Next and Skip while `blocked` holds (tenant shares that do not\n * add up to 100 %). Unlike {@link useWizardStepValidate}, which answers a click, this\n * greys the button out before one. The gate is lifted again when the step unmounts, so\n * the next step starts unblocked.\n */\nexport function useWizardNextGate(blocked: boolean): void {\n const { setNextBlocked } = useWizardContext();\n useEffect(() => {\n setNextBlocked(blocked);\n return () => setNextBlocked(false);\n }, [blocked, setNextBlocked]);\n}\n"],"mappings":";AAAA,SAAS,eAAe,YAAY,WAAW,cAAc;AAkB7D,MAAM,gBAAgB,cAAyC,IAAI;AAE5D,MAAM,wBAAwB,cAAc;AAE5C,SAAS,mBAAuC;AACrD,QAAM,MAAM,WAAW,aAAa;AACpC,MAAI,CAAC,KAAK;AACR,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACvE;AACA,SAAO;AACT;AAOO,SAAS,2BAAsD;AACpE,SAAO,WAAW,aAAa;AACjC;AAiBO,SAAS,sBACd,UACM;AACN,QAAM,EAAE,qBAAqB,IAAI,iBAAiB;AAClD,QAAM,MAAM,OAAO,QAAQ;AAC3B,YAAU,MAAM;AACd,QAAI,UAAU;AAAA,EAChB,CAAC;AACD,YAAU,MAAM,qBAAqB,MAAM,IAAI,QAAQ,CAAC,GAAG,CAAC,oBAAoB,CAAC;AACnF;AAQO,SAAS,kBAAkB,SAAwB;AACxD,QAAM,EAAE,eAAe,IAAI,iBAAiB;AAC5C,YAAU,MAAM;AACd,mBAAe,OAAO;AACtB,WAAO,MAAM,eAAe,KAAK;AAAA,EACnC,GAAG,CAAC,SAAS,cAAc,CAAC;AAC9B;","names":[]}
@@ -1,11 +1,36 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
3
 
4
- /** The vertical rhythm one wizard step's content sits on. A component rather
5
- * than a class string so every step in every app spaces its fields the same. */
6
- declare function WizardStep({ children, className, }: {
4
+ interface WizardStepProps {
7
5
  children: ReactNode;
8
6
  className?: string;
9
- }): react.JSX.Element;
7
+ /**
8
+ * The step's heading ("Choose a unit"), drawn in the one style every step shares.
9
+ * kastlan's steps each hand-wrote `<h3 className="text-lg font-semibold">` (about
10
+ * sixteen of them: lease-picker-step, lease-unit-step, …), and a hand-written
11
+ * heading is one that drifts — a size here, a colour there. Omitted: no heading.
12
+ */
13
+ title?: ReactNode;
14
+ /** The line under the title: what the step asks for, or why. Rendered only with a
15
+ * `title` or on its own when there is none. */
16
+ description?: ReactNode;
17
+ /**
18
+ * Controls for the step as a whole, at the end of the header row beside the title —
19
+ * kastlan 43: the buildings step's "Add building" had nowhere to go but UNDER the
20
+ * list it adds to, where it falls below the fold once there are three buildings.
21
+ * A header action is where every other kit surface (`PageHeader`, `Card`) puts it.
22
+ *
23
+ * Wraps under the title on a narrow screen rather than squeezing it. Renders the
24
+ * header on its own if there is no `title` either.
25
+ */
26
+ actions?: ReactNode;
27
+ /** The heading's level. Default 3: the page has its `h1` and the wizard's own
28
+ * chrome sits at `h2` (the review step, the cancel dialog), so a step is under it. */
29
+ headingLevel?: 2 | 3 | 4;
30
+ }
31
+ /** The vertical rhythm one wizard step's content sits on. A component rather
32
+ * than a class string so every step in every app spaces its fields the same —
33
+ * and, with `title` / `description`, heads them the same. */
34
+ declare function WizardStep({ children, className, title, description, headingLevel, actions, }: WizardStepProps): react.JSX.Element;
10
35
 
11
- export { WizardStep };
36
+ export { WizardStep, type WizardStepProps };
@@ -1,11 +1,42 @@
1
1
  "use client";
2
- import { jsx } from "react/jsx-runtime";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import { cn } from "../lib/cn.js";
4
+ const HEADING = { 2: "h2", 3: "h3", 4: "h4" };
4
5
  function WizardStep({
5
6
  children,
6
- className
7
+ className,
8
+ title,
9
+ description,
10
+ headingLevel = 3,
11
+ actions
7
12
  }) {
8
- return /* @__PURE__ */ jsx("div", { className: cn("space-y-6", className), children });
13
+ const hasTitle = title !== void 0 && title !== null && title !== false && title !== "";
14
+ const hasDescription = description !== void 0 && description !== null && description !== false && description !== "";
15
+ const hasActions = actions !== void 0 && actions !== null && actions !== false && actions !== "";
16
+ const Heading = HEADING[headingLevel];
17
+ const heading = /* @__PURE__ */ jsxs(Fragment, { children: [
18
+ hasTitle && /* @__PURE__ */ jsx(Heading, { className: "text-lg font-semibold text-[var(--text-primary)]", children: title }),
19
+ hasDescription && /* @__PURE__ */ jsx("p", { className: "text-sm text-[var(--text-muted)]", children: description })
20
+ ] });
21
+ return /* @__PURE__ */ jsxs("div", { className: cn("space-y-6", className), children: [
22
+ hasActions ? (
23
+ // One row: the text takes the room, the actions keep their width at the end
24
+ // and wrap below it when there is not enough — `basis-64` is the width the
25
+ // title asks for before that happens (a zero basis would never wrap and
26
+ // squeeze the title to a word a line instead). `items-start` so a two-line
27
+ // description does not pull the button down to its middle; `ms-auto` keeps
28
+ // the actions at the end with no title, and when they wrap.
29
+ /* @__PURE__ */ jsxs("div", { "data-slot": "wizard-step-header", className: "flex flex-wrap items-start justify-between gap-x-4 gap-y-2", children: [
30
+ (hasTitle || hasDescription) && /* @__PURE__ */ jsx("div", { className: "min-w-0 grow basis-64 space-y-1", children: heading }),
31
+ /* @__PURE__ */ jsx("div", { "data-slot": "wizard-step-actions", className: "ms-auto flex shrink-0 flex-wrap items-center gap-2", children: actions })
32
+ ] })
33
+ ) : (
34
+ // Without actions the header is exactly what it was, so a step that passes
35
+ // none renders as before.
36
+ (hasTitle || hasDescription) && /* @__PURE__ */ jsx("div", { "data-slot": "wizard-step-header", className: "space-y-1", children: heading })
37
+ ),
38
+ children
39
+ ] });
9
40
  }
10
41
  export {
11
42
  WizardStep
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/wizard/wizard-step.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\n\n/** The vertical rhythm one wizard step's content sits on. A component rather\n * than a class string so every step in every app spaces its fields the same. */\nexport function WizardStep({\n children,\n className,\n}: {\n children: ReactNode;\n className?: string;\n}) {\n return <div className={cn(\"space-y-6\", className)}>{children}</div>;\n}\n"],"mappings":";AAYS;AAXT,SAAS,UAAU;AAIZ,SAAS,WAAW;AAAA,EACzB;AAAA,EACA;AACF,GAGG;AACD,SAAO,oBAAC,SAAI,WAAW,GAAG,aAAa,SAAS,GAAI,UAAS;AAC/D;","names":[]}
1
+ {"version":3,"sources":["../../src/wizard/wizard-step.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\n\nexport interface WizardStepProps {\n children: ReactNode;\n className?: string;\n /**\n * The step's heading (\"Choose a unit\"), drawn in the one style every step shares.\n * kastlan's steps each hand-wrote `<h3 className=\"text-lg font-semibold\">` (about\n * sixteen of them: lease-picker-step, lease-unit-step, …), and a hand-written\n * heading is one that drifts — a size here, a colour there. Omitted: no heading.\n */\n title?: ReactNode;\n /** The line under the title: what the step asks for, or why. Rendered only with a\n * `title` or on its own when there is none. */\n description?: ReactNode;\n /**\n * Controls for the step as a whole, at the end of the header row beside the title —\n * kastlan 43: the buildings step's \"Add building\" had nowhere to go but UNDER the\n * list it adds to, where it falls below the fold once there are three buildings.\n * A header action is where every other kit surface (`PageHeader`, `Card`) puts it.\n *\n * Wraps under the title on a narrow screen rather than squeezing it. Renders the\n * header on its own if there is no `title` either.\n */\n actions?: ReactNode;\n /** The heading's level. Default 3: the page has its `h1` and the wizard's own\n * chrome sits at `h2` (the review step, the cancel dialog), so a step is under it. */\n headingLevel?: 2 | 3 | 4;\n}\n\nconst HEADING = { 2: \"h2\", 3: \"h3\", 4: \"h4\" } as const;\n\n/** The vertical rhythm one wizard step's content sits on. A component rather\n * than a class string so every step in every app spaces its fields the same —\n * and, with `title` / `description`, heads them the same. */\nexport function WizardStep({\n children,\n className,\n title,\n description,\n headingLevel = 3,\n actions,\n}: WizardStepProps) {\n const hasTitle = title !== undefined && title !== null && title !== false && title !== \"\";\n const hasDescription =\n description !== undefined && description !== null && description !== false && description !== \"\";\n const hasActions = actions !== undefined && actions !== null && actions !== false && actions !== \"\";\n const Heading = HEADING[headingLevel];\n const heading = (\n <>\n {hasTitle && <Heading className=\"text-lg font-semibold text-[var(--text-primary)]\">{title}</Heading>}\n {hasDescription && <p className=\"text-sm text-[var(--text-muted)]\">{description}</p>}\n </>\n );\n return (\n <div className={cn(\"space-y-6\", className)}>\n {hasActions ? (\n // One row: the text takes the room, the actions keep their width at the end\n // and wrap below it when there is not enough — `basis-64` is the width the\n // title asks for before that happens (a zero basis would never wrap and\n // squeeze the title to a word a line instead). `items-start` so a two-line\n // description does not pull the button down to its middle; `ms-auto` keeps\n // the actions at the end with no title, and when they wrap.\n <div data-slot=\"wizard-step-header\" className=\"flex flex-wrap items-start justify-between gap-x-4 gap-y-2\">\n {(hasTitle || hasDescription) && <div className=\"min-w-0 grow basis-64 space-y-1\">{heading}</div>}\n <div data-slot=\"wizard-step-actions\" className=\"ms-auto flex shrink-0 flex-wrap items-center gap-2\">\n {actions}\n </div>\n </div>\n ) : (\n // Without actions the header is exactly what it was, so a step that passes\n // none renders as before.\n (hasTitle || hasDescription) && (\n <div data-slot=\"wizard-step-header\" className=\"space-y-1\">\n {heading}\n </div>\n )\n )}\n {children}\n </div>\n );\n}\n"],"mappings":";AAkDI,mBACe,KADf;AAjDJ,SAAS,UAAU;AA8BnB,MAAM,UAAU,EAAE,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK;AAKrC,SAAS,WAAW;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,EACf;AACF,GAAoB;AAClB,QAAM,WAAW,UAAU,UAAa,UAAU,QAAQ,UAAU,SAAS,UAAU;AACvF,QAAM,iBACJ,gBAAgB,UAAa,gBAAgB,QAAQ,gBAAgB,SAAS,gBAAgB;AAChG,QAAM,aAAa,YAAY,UAAa,YAAY,QAAQ,YAAY,SAAS,YAAY;AACjG,QAAM,UAAU,QAAQ,YAAY;AACpC,QAAM,UACJ,iCACG;AAAA,gBAAY,oBAAC,WAAQ,WAAU,oDAAoD,iBAAM;AAAA,IACzF,kBAAkB,oBAAC,OAAE,WAAU,oCAAoC,uBAAY;AAAA,KAClF;AAEF,SACE,qBAAC,SAAI,WAAW,GAAG,aAAa,SAAS,GACtC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAOC,qBAAC,SAAI,aAAU,sBAAqB,WAAU,8DAC1C;AAAA,qBAAY,mBAAmB,oBAAC,SAAI,WAAU,mCAAmC,mBAAQ;AAAA,QAC3F,oBAAC,SAAI,aAAU,uBAAsB,WAAU,sDAC5C,mBACH;AAAA,SACF;AAAA;AAAA;AAAA;AAAA,OAIC,YAAY,mBACX,oBAAC,SAAI,aAAU,sBAAqB,WAAU,aAC3C,mBACH;AAAA;AAAA,IAGH;AAAA,KACH;AAEJ;","names":[]}
package/dist/wizard.d.ts CHANGED
@@ -1,12 +1,59 @@
1
1
  export { DEFAULT_WIZARD_LABELS, FieldErrors, StepStatus, SummaryItem, SummarySection, UseWizardOptions, UseWizardReturn, ValidateResult, WizardLabels, WizardStepConfig, WizardUrlSync, resolveWizardLabels } from './wizard/types.js';
2
2
  export { useWizard } from './wizard/use-wizard.js';
3
- export { WizardContextProvider, WizardContextValue, useOptionalWizardContext, useWizardContext } from './wizard/wizard-context.js';
3
+ export { WizardContextProvider, WizardContextValue, useOptionalWizardContext, useWizardContext, useWizardNextGate, useWizardStepValidate } from './wizard/wizard-context.js';
4
4
  export { RequiredFieldSpec, requiredFieldsValidator } from './wizard/validation.js';
5
- export { WizardStep } from './wizard/wizard-step.js';
5
+ export { WizardStep, WizardStepProps } from './wizard/wizard-step.js';
6
6
  export { WizardSummary } from './wizard/wizard-summary.js';
7
7
  export { StepperNav } from './wizard/stepper-nav.js';
8
8
  import 'react';
9
- import './components/ui.js';
9
+ import './kit-labels-Mz8zZHIF.js';
10
+ import './components/data-table-labels.js';
11
+ import './components/mini-calendar.js';
12
+ import './components/calendar-heatmap.js';
13
+ import './components/popover.js';
14
+ import './components/chip.js';
15
+ import 'lucide-react';
16
+ import './components/field-sync.js';
10
17
  import './components/tooltip.js';
11
18
  import './hooks/use-anchored-rect.js';
12
19
  import './lib/clipping.js';
20
+ import './tour/tour.js';
21
+ import './search/command-palette.js';
22
+ import './search/global-search.js';
23
+ import './search/search-index.js';
24
+ import './components/month-picker.js';
25
+ import './components/page-contents.js';
26
+ import './components/series-chart-labels.js';
27
+ import './components/pie-chart-labels.js';
28
+ import './components/sparkline.js';
29
+ import './components/stat-tile.js';
30
+ import './components/signature-pad.js';
31
+ import './components/password-strength.js';
32
+ import './components/danger-confirm.js';
33
+ import './components/swatch-picker.js';
34
+ import './components/tile-radio.js';
35
+ import './components/icon-picker.js';
36
+ import './components/dialog-frame.js';
37
+ import './components/modal.js';
38
+ import './hooks/use-search-param-state.js';
39
+ import './components/measured-grid.js';
40
+ import './feedback/feedback-attachment.js';
41
+ import './feedback/feedback-dialog.js';
42
+ import './feedback/feedback-thread.js';
43
+ import './feedback/feedback-inbox.js';
44
+ import './components/account-settings-labels.js';
45
+ import './components/confirm-dialog.js';
46
+ import './components/floating-panel.js';
47
+ import './components/bulk-action-bar.js';
48
+ import './components/list.js';
49
+ import './components/breadcrumbs.js';
50
+ import './components/toast.js';
51
+ import './components/description-list.js';
52
+ import './components/line-items.js';
53
+ import './components/progress-bar.js';
54
+ import './components/signed-amount.js';
55
+ import './components/error-boundary.js';
56
+ import './components/authed-image.js';
57
+ import './hooks/use-authed-src.js';
58
+ import './components/image-grid.js';
59
+ import './components/lightbox.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eifi1/ui-kit",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "type": "module",
5
5
  "description": "App-agnostic shared design system: domain-free React components, theme and tokens.",
6
6
  "_sideEffects": "The barrel (src/index.ts) re-exports EVERY component, including components/chart, which statically imports recharts. Without this field a bundler must assume each of those modules has side effects, so it cannot drop the unused ones: importing a Button from '@eifi1/ui-kit' dragged all 433KB of recharts into the consumer's ENTRY chunk, and Keksdose was preloading it on every page load, login included. Nothing in src/ imports for side effects (no bare imports, no CSS imports from JS, no module-level global writes) — the token stylesheet is its own './tokens.css' export — so this is safe. CSS is still listed so any future stylesheet survives. Re-checked when `flag-icons` left `dependencies` and tsup started emitting a `\"use client\"` banner: neither touches this. The flag stylesheet was never imported from JS in the first place (that was the finding), and a directive prologue is a string literal every bundler lifts out before it decides whether a module is inert.",
@@ -68,23 +68,23 @@
68
68
  "LICENSE"
69
69
  ],
70
70
  "scripts": {
71
- "typecheck": "tsc --noEmit",
72
- "lint": "eslint .",
71
+ "typecheck": "tsc --noEmit && tsc -p tsconfig.node.json",
72
+ "lint": "eslint . --max-warnings 0",
73
73
  "check:tokens": "node scripts/check-token-discipline.mjs",
74
74
  "test:coverage": "vitest run --coverage",
75
75
  "check:graph": "node scripts/check-module-graph.mjs",
76
- "check:package": "node scripts/verify-package.mjs",
76
+ "check:package": "node scripts/verify-package.mjs --quiet",
77
77
  "check:tailwind": "node scripts/check-tailwind-scan.mjs",
78
78
  "check:security": "npm audit --audit-level=high",
79
79
  "check:commits": "node scripts/check-commit-range.cjs",
80
80
  "check": "npm run typecheck && npm run lint && npm run check:tokens && npm run test:coverage && npm run build && npm run check:graph && npm run check:package && npm run build:showcase && npm run check:tailwind && npm run check:security && npm run check:commits",
81
81
  "test": "vitest run",
82
82
  "test:watch": "vitest",
83
- "build": "tsup && node scripts/fix-esm-extensions.mjs",
83
+ "build": "node scripts/tsup-quiet.mjs && node scripts/fix-esm-extensions.mjs",
84
84
  "verify:package": "npm run build && node scripts/verify-package.mjs",
85
85
  "dev": "tsup --watch",
86
86
  "dev:showcase": "vite --config showcase/vite.config.ts",
87
- "build:showcase": "vite build --config showcase/vite.config.ts",
87
+ "build:showcase": "vite build --config showcase/vite.config.ts --logLevel warn",
88
88
  "preview:showcase": "vite preview --config showcase/vite.config.ts",
89
89
  "prepublishOnly": "npm run build",
90
90
  "release": "commit-and-tag-version",
package/src/chart.ts CHANGED
@@ -20,3 +20,7 @@ export * from "./components/chart-zoom";
20
20
  export * from "./components/toggle-legend";
21
21
  export * from "./components/facing-pair";
22
22
  export * from "./components/series-chart-labels";
23
+
24
+ // The part-to-whole chart (donut / pie) — moved here from kastlan's dashboard and reports.
25
+ export * from "./components/pie-chart";
26
+ export * from "./components/pie-chart-labels";