@booki-aui/react 0.0.0-stage → 0.2.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 (320) hide show
  1. package/CHANGELOG.md +122 -0
  2. package/LICENSE +21 -0
  3. package/README.md +16 -2
  4. package/dist/access.d.ts +43 -0
  5. package/dist/access.js +15 -0
  6. package/dist/access.js.map +1 -0
  7. package/dist/account-picker.d.ts +40 -0
  8. package/dist/account-picker.js +25 -0
  9. package/dist/account-picker.js.map +1 -0
  10. package/dist/accounting-period-select.d.ts +34 -0
  11. package/dist/accounting-period-select.js +23 -0
  12. package/dist/accounting-period-select.js.map +1 -0
  13. package/dist/activity-timeline.d.ts +37 -0
  14. package/dist/activity-timeline.js +19 -0
  15. package/dist/activity-timeline.js.map +1 -0
  16. package/dist/aged-balances.d.ts +62 -0
  17. package/dist/aged-balances.js +31 -0
  18. package/dist/aged-balances.js.map +1 -0
  19. package/dist/agent-cursor.d.ts +34 -0
  20. package/dist/agent-cursor.js +14 -0
  21. package/dist/agent-cursor.js.map +1 -0
  22. package/dist/agent-presence.d.ts +110 -0
  23. package/dist/agent-presence.js +15 -0
  24. package/dist/agent-presence.js.map +1 -0
  25. package/dist/aging-chart.d.ts +41 -0
  26. package/dist/aging-chart.js +19 -0
  27. package/dist/aging-chart.js.map +1 -0
  28. package/dist/amount-field.d.ts +46 -0
  29. package/dist/amount-field.js +19 -0
  30. package/dist/amount-field.js.map +1 -0
  31. package/dist/amount-input.d.ts +18 -0
  32. package/dist/amount-input.js +12 -0
  33. package/dist/amount-input.js.map +1 -0
  34. package/dist/approval-chain.d.ts +36 -0
  35. package/dist/approval-chain.js +22 -0
  36. package/dist/approval-chain.js.map +1 -0
  37. package/dist/approval-gate.d.ts +19 -0
  38. package/dist/approval-gate.js +10 -0
  39. package/dist/approval-gate.js.map +1 -0
  40. package/dist/attestation-status.d.ts +31 -0
  41. package/dist/attestation-status.js +22 -0
  42. package/dist/attestation-status.js.map +1 -0
  43. package/dist/audit-findings.d.ts +40 -0
  44. package/dist/audit-findings.js +28 -0
  45. package/dist/audit-findings.js.map +1 -0
  46. package/dist/audit-trail.d.ts +22 -0
  47. package/dist/audit-trail.js +10 -0
  48. package/dist/audit-trail.js.map +1 -0
  49. package/dist/audit-workpaper.d.ts +56 -0
  50. package/dist/audit-workpaper.js +35 -0
  51. package/dist/audit-workpaper.js.map +1 -0
  52. package/dist/bank-account-input.d.ts +36 -0
  53. package/dist/bank-account-input.js +22 -0
  54. package/dist/bank-account-input.js.map +1 -0
  55. package/dist/bank-reconciliation.d.ts +38 -0
  56. package/dist/bank-reconciliation.js +20 -0
  57. package/dist/bank-reconciliation.js.map +1 -0
  58. package/dist/bar-chart.d.ts +38 -0
  59. package/dist/bar-chart.js +19 -0
  60. package/dist/bar-chart.js.map +1 -0
  61. package/dist/booki-agent.d.ts +153 -0
  62. package/dist/booki-agent.js +27 -0
  63. package/dist/booki-agent.js.map +1 -0
  64. package/dist/cashflow-waterfall.d.ts +36 -0
  65. package/dist/cashflow-waterfall.js +17 -0
  66. package/dist/cashflow-waterfall.js.map +1 -0
  67. package/dist/change-details-CWpEgc80.d.ts +14 -0
  68. package/dist/chunk-2HM7YSBC.js +92 -0
  69. package/dist/chunk-2HM7YSBC.js.map +1 -0
  70. package/dist/chunk-35QKOOAI.js +27 -0
  71. package/dist/chunk-35QKOOAI.js.map +1 -0
  72. package/dist/chunk-37GDU76M.js +86 -0
  73. package/dist/chunk-37GDU76M.js.map +1 -0
  74. package/dist/chunk-4EVVT6ME.js +136 -0
  75. package/dist/chunk-4EVVT6ME.js.map +1 -0
  76. package/dist/chunk-4GQUOBOG.js +132 -0
  77. package/dist/chunk-4GQUOBOG.js.map +1 -0
  78. package/dist/chunk-4KWEZTO5.js +86 -0
  79. package/dist/chunk-4KWEZTO5.js.map +1 -0
  80. package/dist/chunk-4WC76FUE.js +242 -0
  81. package/dist/chunk-4WC76FUE.js.map +1 -0
  82. package/dist/chunk-62G3T2AA.js +230 -0
  83. package/dist/chunk-62G3T2AA.js.map +1 -0
  84. package/dist/chunk-663UXACN.js +334 -0
  85. package/dist/chunk-663UXACN.js.map +1 -0
  86. package/dist/chunk-6CVPNV7N.js +106 -0
  87. package/dist/chunk-6CVPNV7N.js.map +1 -0
  88. package/dist/chunk-6HWFMC7V.js +140 -0
  89. package/dist/chunk-6HWFMC7V.js.map +1 -0
  90. package/dist/chunk-7MYFKLPB.js +301 -0
  91. package/dist/chunk-7MYFKLPB.js.map +1 -0
  92. package/dist/chunk-7YTOVA5F.js +312 -0
  93. package/dist/chunk-7YTOVA5F.js.map +1 -0
  94. package/dist/chunk-AIGQPM4Y.js +311 -0
  95. package/dist/chunk-AIGQPM4Y.js.map +1 -0
  96. package/dist/chunk-AKC6N4QO.js +414 -0
  97. package/dist/chunk-AKC6N4QO.js.map +1 -0
  98. package/dist/chunk-BZIOOU4I.js +421 -0
  99. package/dist/chunk-BZIOOU4I.js.map +1 -0
  100. package/dist/chunk-CDTDN4LY.js +212 -0
  101. package/dist/chunk-CDTDN4LY.js.map +1 -0
  102. package/dist/chunk-EDWQSKY7.js +161 -0
  103. package/dist/chunk-EDWQSKY7.js.map +1 -0
  104. package/dist/chunk-EKIWL37F.js +488 -0
  105. package/dist/chunk-EKIWL37F.js.map +1 -0
  106. package/dist/chunk-F3C77WLR.js +116 -0
  107. package/dist/chunk-F3C77WLR.js.map +1 -0
  108. package/dist/chunk-FBV7BFEQ.js +84 -0
  109. package/dist/chunk-FBV7BFEQ.js.map +1 -0
  110. package/dist/chunk-GVP2N3K6.js +89 -0
  111. package/dist/chunk-GVP2N3K6.js.map +1 -0
  112. package/dist/chunk-HKYEHBQT.js +19 -0
  113. package/dist/chunk-HKYEHBQT.js.map +1 -0
  114. package/dist/chunk-HQYIFZZT.js +169 -0
  115. package/dist/chunk-HQYIFZZT.js.map +1 -0
  116. package/dist/chunk-HT6HGOLM.js +151 -0
  117. package/dist/chunk-HT6HGOLM.js.map +1 -0
  118. package/dist/chunk-ISPUO3AQ.js +244 -0
  119. package/dist/chunk-ISPUO3AQ.js.map +1 -0
  120. package/dist/chunk-JPUVGWLO.js +207 -0
  121. package/dist/chunk-JPUVGWLO.js.map +1 -0
  122. package/dist/chunk-JWFGUI7A.js +73 -0
  123. package/dist/chunk-JWFGUI7A.js.map +1 -0
  124. package/dist/chunk-K72VT6RJ.js +57 -0
  125. package/dist/chunk-K72VT6RJ.js.map +1 -0
  126. package/dist/chunk-KLDUGI7L.js +150 -0
  127. package/dist/chunk-KLDUGI7L.js.map +1 -0
  128. package/dist/chunk-M2WLQIFE.js +40 -0
  129. package/dist/chunk-M2WLQIFE.js.map +1 -0
  130. package/dist/chunk-M3MCIKF2.js +143 -0
  131. package/dist/chunk-M3MCIKF2.js.map +1 -0
  132. package/dist/chunk-MBLQSZHE.js +77 -0
  133. package/dist/chunk-MBLQSZHE.js.map +1 -0
  134. package/dist/chunk-N7GIVDUU.js +191 -0
  135. package/dist/chunk-N7GIVDUU.js.map +1 -0
  136. package/dist/chunk-NMHTPP6I.js +62 -0
  137. package/dist/chunk-NMHTPP6I.js.map +1 -0
  138. package/dist/chunk-NNP6GNEW.js +65 -0
  139. package/dist/chunk-NNP6GNEW.js.map +1 -0
  140. package/dist/chunk-OTD7VUEC.js +35 -0
  141. package/dist/chunk-OTD7VUEC.js.map +1 -0
  142. package/dist/chunk-OXHKA3UZ.js +30 -0
  143. package/dist/chunk-OXHKA3UZ.js.map +1 -0
  144. package/dist/chunk-OYERLEER.js +21 -0
  145. package/dist/chunk-OYERLEER.js.map +1 -0
  146. package/dist/chunk-PFY3VJ2T.js +231 -0
  147. package/dist/chunk-PFY3VJ2T.js.map +1 -0
  148. package/dist/chunk-PUMSFFEU.js +228 -0
  149. package/dist/chunk-PUMSFFEU.js.map +1 -0
  150. package/dist/chunk-QE7KUQOI.js +84 -0
  151. package/dist/chunk-QE7KUQOI.js.map +1 -0
  152. package/dist/chunk-QGT7VI6I.js +35 -0
  153. package/dist/chunk-QGT7VI6I.js.map +1 -0
  154. package/dist/chunk-QGYS5HS3.js +214 -0
  155. package/dist/chunk-QGYS5HS3.js.map +1 -0
  156. package/dist/chunk-QPSBRSBH.js +167 -0
  157. package/dist/chunk-QPSBRSBH.js.map +1 -0
  158. package/dist/chunk-ROXGVKR2.js +59 -0
  159. package/dist/chunk-ROXGVKR2.js.map +1 -0
  160. package/dist/chunk-RPONJDFZ.js +310 -0
  161. package/dist/chunk-RPONJDFZ.js.map +1 -0
  162. package/dist/chunk-RTCKV4H2.js +65 -0
  163. package/dist/chunk-RTCKV4H2.js.map +1 -0
  164. package/dist/chunk-SHZFZRHV.js +259 -0
  165. package/dist/chunk-SHZFZRHV.js.map +1 -0
  166. package/dist/chunk-SOXPKIQK.js +91 -0
  167. package/dist/chunk-SOXPKIQK.js.map +1 -0
  168. package/dist/chunk-SR2HEE4U.js +76 -0
  169. package/dist/chunk-SR2HEE4U.js.map +1 -0
  170. package/dist/chunk-SX3U6DRW.js +462 -0
  171. package/dist/chunk-SX3U6DRW.js.map +1 -0
  172. package/dist/chunk-T4U2CT35.js +175 -0
  173. package/dist/chunk-T4U2CT35.js.map +1 -0
  174. package/dist/chunk-TSX6BD72.js +251 -0
  175. package/dist/chunk-TSX6BD72.js.map +1 -0
  176. package/dist/chunk-U6PR3V2Q.js +123 -0
  177. package/dist/chunk-U6PR3V2Q.js.map +1 -0
  178. package/dist/chunk-U7NPK4WO.js +135 -0
  179. package/dist/chunk-U7NPK4WO.js.map +1 -0
  180. package/dist/chunk-W6TKXS75.js +55 -0
  181. package/dist/chunk-W6TKXS75.js.map +1 -0
  182. package/dist/chunk-WDME4U42.js +14 -0
  183. package/dist/chunk-WDME4U42.js.map +1 -0
  184. package/dist/chunk-WS2YJSNS.js +62 -0
  185. package/dist/chunk-WS2YJSNS.js.map +1 -0
  186. package/dist/chunk-Y5EYY6WJ.js +174 -0
  187. package/dist/chunk-Y5EYY6WJ.js.map +1 -0
  188. package/dist/chunk-YBMO3W5O.js +191 -0
  189. package/dist/chunk-YBMO3W5O.js.map +1 -0
  190. package/dist/chunk-YOOWFGCU.js +90 -0
  191. package/dist/chunk-YOOWFGCU.js.map +1 -0
  192. package/dist/chunk-ZKNVWQDU.js +230 -0
  193. package/dist/chunk-ZKNVWQDU.js.map +1 -0
  194. package/dist/chunk-ZYLWSGWQ.js +29 -0
  195. package/dist/chunk-ZYLWSGWQ.js.map +1 -0
  196. package/dist/chunk-ZYPW7GCI.js +82 -0
  197. package/dist/chunk-ZYPW7GCI.js.map +1 -0
  198. package/dist/client-requests.d.ts +40 -0
  199. package/dist/client-requests.js +25 -0
  200. package/dist/client-requests.js.map +1 -0
  201. package/dist/close-checklist.d.ts +34 -0
  202. package/dist/close-checklist.js +22 -0
  203. package/dist/close-checklist.js.map +1 -0
  204. package/dist/confirm-dialog.d.ts +43 -0
  205. package/dist/confirm-dialog.js +10 -0
  206. package/dist/confirm-dialog.js.map +1 -0
  207. package/dist/country-toggle.d.ts +16 -0
  208. package/dist/country-toggle.js +10 -0
  209. package/dist/country-toggle.js.map +1 -0
  210. package/dist/currency-select.d.ts +32 -0
  211. package/dist/currency-select.js +23 -0
  212. package/dist/currency-select.js.map +1 -0
  213. package/dist/data-table.d.ts +77 -0
  214. package/dist/data-table.js +30 -0
  215. package/dist/data-table.js.map +1 -0
  216. package/dist/deal-pipeline.d.ts +46 -0
  217. package/dist/deal-pipeline.js +25 -0
  218. package/dist/deal-pipeline.js.map +1 -0
  219. package/dist/document-signoff.d.ts +45 -0
  220. package/dist/document-signoff.js +21 -0
  221. package/dist/document-signoff.js.map +1 -0
  222. package/dist/evidence-list.d.ts +35 -0
  223. package/dist/evidence-list.js +21 -0
  224. package/dist/evidence-list.js.map +1 -0
  225. package/dist/exception-banner.d.ts +15 -0
  226. package/dist/exception-banner.js +10 -0
  227. package/dist/exception-banner.js.map +1 -0
  228. package/dist/expense-claim.d.ts +43 -0
  229. package/dist/expense-claim.js +31 -0
  230. package/dist/expense-claim.js.map +1 -0
  231. package/dist/financial-date-field.d.ts +27 -0
  232. package/dist/financial-date-field.js +17 -0
  233. package/dist/financial-date-field.js.map +1 -0
  234. package/dist/fixed-asset-register.d.ts +59 -0
  235. package/dist/fixed-asset-register.js +31 -0
  236. package/dist/fixed-asset-register.js.map +1 -0
  237. package/dist/forecast-chart.d.ts +38 -0
  238. package/dist/forecast-chart.js +19 -0
  239. package/dist/forecast-chart.js.map +1 -0
  240. package/dist/form-props-Ct7zeZBH.d.ts +25 -0
  241. package/dist/funnel-chart.d.ts +27 -0
  242. package/dist/funnel-chart.js +17 -0
  243. package/dist/funnel-chart.js.map +1 -0
  244. package/dist/iban-input.d.ts +27 -0
  245. package/dist/iban-input.js +16 -0
  246. package/dist/iban-input.js.map +1 -0
  247. package/dist/index.d.ts +644 -0
  248. package/dist/index.js +1082 -0
  249. package/dist/index.js.map +1 -0
  250. package/dist/invoice-editor.d.ts +38 -0
  251. package/dist/invoice-editor.js +26 -0
  252. package/dist/invoice-editor.js.map +1 -0
  253. package/dist/invoice-number-input.d.ts +25 -0
  254. package/dist/invoice-number-input.js +17 -0
  255. package/dist/invoice-number-input.js.map +1 -0
  256. package/dist/kpi-stat.d.ts +34 -0
  257. package/dist/kpi-stat.js +15 -0
  258. package/dist/kpi-stat.js.map +1 -0
  259. package/dist/ledger-table.d.ts +85 -0
  260. package/dist/ledger-table.js +41 -0
  261. package/dist/ledger-table.js.map +1 -0
  262. package/dist/locale.d.ts +22 -0
  263. package/dist/locale.js +13 -0
  264. package/dist/locale.js.map +1 -0
  265. package/dist/money-amount.d.ts +15 -0
  266. package/dist/money-amount.js +10 -0
  267. package/dist/money-amount.js.map +1 -0
  268. package/dist/organization-number-input.d.ts +25 -0
  269. package/dist/organization-number-input.js +17 -0
  270. package/dist/organization-number-input.js.map +1 -0
  271. package/dist/payment-batch.d.ts +58 -0
  272. package/dist/payment-batch.js +31 -0
  273. package/dist/payment-batch.js.map +1 -0
  274. package/dist/payment-confirm.d.ts +19 -0
  275. package/dist/payment-confirm.js +11 -0
  276. package/dist/payment-confirm.js.map +1 -0
  277. package/dist/payment-reference-input.d.ts +27 -0
  278. package/dist/payment-reference-input.js +17 -0
  279. package/dist/payment-reference-input.js.map +1 -0
  280. package/dist/period-lock.d.ts +28 -0
  281. package/dist/period-lock.js +18 -0
  282. package/dist/period-lock.js.map +1 -0
  283. package/dist/recurring-revenue.d.ts +37 -0
  284. package/dist/recurring-revenue.js +18 -0
  285. package/dist/recurring-revenue.js.map +1 -0
  286. package/dist/sca-prompt.d.ts +16 -0
  287. package/dist/sca-prompt.js +10 -0
  288. package/dist/sca-prompt.js.map +1 -0
  289. package/dist/sheet-stack.d.ts +34 -0
  290. package/dist/sheet-stack.js +20 -0
  291. package/dist/sheet-stack.js.map +1 -0
  292. package/dist/stage-duration.d.ts +33 -0
  293. package/dist/stage-duration.js +16 -0
  294. package/dist/stage-duration.js.map +1 -0
  295. package/dist/supplier-invoice-inbox.d.ts +66 -0
  296. package/dist/supplier-invoice-inbox.js +38 -0
  297. package/dist/supplier-invoice-inbox.js.map +1 -0
  298. package/dist/tax-code-select.d.ts +33 -0
  299. package/dist/tax-code-select.js +23 -0
  300. package/dist/tax-code-select.js.map +1 -0
  301. package/dist/text-link.d.ts +33 -0
  302. package/dist/text-link.js +13 -0
  303. package/dist/text-link.js.map +1 -0
  304. package/dist/toasts.d.ts +53 -0
  305. package/dist/toasts.js +17 -0
  306. package/dist/toasts.js.map +1 -0
  307. package/dist/trend-chart.d.ts +43 -0
  308. package/dist/trend-chart.js +19 -0
  309. package/dist/trend-chart.js.map +1 -0
  310. package/dist/vat-return.d.ts +54 -0
  311. package/dist/vat-return.js +23 -0
  312. package/dist/vat-return.js.map +1 -0
  313. package/dist/voucher-composer.d.ts +69 -0
  314. package/dist/voucher-composer.js +15 -0
  315. package/dist/voucher-composer.js.map +1 -0
  316. package/dist/voucher-lines.d.ts +11 -0
  317. package/dist/voucher-lines.js +10 -0
  318. package/dist/voucher-lines.js.map +1 -0
  319. package/docs/llms.txt +214 -0
  320. package/package.json +308 -3
@@ -0,0 +1,86 @@
1
+ "use client";
2
+ import {
3
+ useBookiLocaleOptional
4
+ } from "./chunk-GVP2N3K6.js";
5
+
6
+ // src/attestation-status.tsx
7
+ import { createParts } from "@ui-sdk/react/primitive";
8
+ import { useState } from "react";
9
+ import {
10
+ statusLabelFor,
11
+ attestationStatus
12
+ } from "@booki-aui/primitives/attestation-status";
13
+ import { jsx, jsxs } from "react/jsx-runtime";
14
+ var TAGS = {
15
+ root: "div",
16
+ badge: "span",
17
+ approve: "button",
18
+ reject: "button",
19
+ escalate: "button"
20
+ };
21
+ var parts = createParts(attestationStatus, TAGS);
22
+ var AttestationStatusRoot = parts.Root;
23
+ var AttestationStatusBadge = parts.Badge;
24
+ var AttestationStatusApprove = parts.Approve;
25
+ var AttestationStatusReject = parts.Reject;
26
+ var AttestationStatusEscalate = parts.Escalate;
27
+ function AttestationStatus({
28
+ value,
29
+ defaultValue = "pending",
30
+ onValueChange,
31
+ onApprove,
32
+ onReject,
33
+ onEscalate,
34
+ showActions = true,
35
+ className
36
+ }) {
37
+ const { profile } = useBookiLocaleOptional();
38
+ const [internal, setInternal] = useState(value ?? defaultValue);
39
+ const current = value ?? internal;
40
+ const labels = {
41
+ pendingLabel: profile.copy.attestationPending,
42
+ approvedLabel: profile.copy.attestationApproved,
43
+ rejectedLabel: profile.copy.attestationRejected,
44
+ escalatedLabel: profile.copy.attestationEscalated
45
+ };
46
+ return /* @__PURE__ */ jsxs(
47
+ AttestationStatusRoot,
48
+ {
49
+ value,
50
+ defaultValue,
51
+ label: profile.copy.attestation,
52
+ pendingLabel: labels.pendingLabel,
53
+ approvedLabel: labels.approvedLabel,
54
+ rejectedLabel: labels.rejectedLabel,
55
+ escalatedLabel: labels.escalatedLabel,
56
+ onValueChange: (next) => {
57
+ setInternal(next);
58
+ onValueChange?.(next);
59
+ },
60
+ onApprove,
61
+ onReject,
62
+ onEscalate,
63
+ className,
64
+ "aria-label": profile.copy.attestation,
65
+ children: [
66
+ /* @__PURE__ */ jsx(AttestationStatusBadge, { children: statusLabelFor(current, labels) }),
67
+ showActions ? /* @__PURE__ */ jsxs("div", { "data-slot": "attestation-status-actions", children: [
68
+ /* @__PURE__ */ jsx(AttestationStatusApprove, { children: profile.copy.approve }),
69
+ /* @__PURE__ */ jsx(AttestationStatusReject, { children: profile.copy.reject }),
70
+ /* @__PURE__ */ jsx(AttestationStatusEscalate, { children: profile.copy.escalate })
71
+ ] }) : null
72
+ ]
73
+ }
74
+ );
75
+ }
76
+
77
+ export {
78
+ attestationStatus,
79
+ AttestationStatusRoot,
80
+ AttestationStatusBadge,
81
+ AttestationStatusApprove,
82
+ AttestationStatusReject,
83
+ AttestationStatusEscalate,
84
+ AttestationStatus
85
+ };
86
+ //# sourceMappingURL=chunk-37GDU76M.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/attestation-status.tsx"],"sourcesContent":["import { createParts, type Parts } from \"@ui-sdk/react/primitive\";\nimport { useState } from \"react\";\nimport { useBookiLocaleOptional } from \"./locale.js\";\nimport {\n type AttestationStatusValue,\n statusLabelFor,\n attestationStatus,\n} from \"@booki-aui/primitives/attestation-status\";\n\nconst TAGS = {\n root: \"div\",\n badge: \"span\",\n approve: \"button\",\n reject: \"button\",\n escalate: \"button\",\n} as const;\n// Typed by name, so the declarations refer to the definition instead of spelling it out per part.\nconst parts: Parts<typeof attestationStatus, typeof TAGS> = createParts(attestationStatus, TAGS);\n\nconst AttestationStatusRoot: (typeof parts)[\"Root\"] = parts.Root;\nconst AttestationStatusBadge: (typeof parts)[\"Badge\"] = parts.Badge;\nconst AttestationStatusApprove: (typeof parts)[\"Approve\"] = parts.Approve;\nconst AttestationStatusReject: (typeof parts)[\"Reject\"] = parts.Reject;\nconst AttestationStatusEscalate: (typeof parts)[\"Escalate\"] = parts.Escalate;\n\nexport type AttestationStatusProps = {\n value?: AttestationStatusValue;\n defaultValue?: AttestationStatusValue;\n onValueChange?: (value: AttestationStatusValue) => void;\n onApprove?: () => void;\n onReject?: () => void;\n onEscalate?: () => void;\n showActions?: boolean;\n className?: string;\n};\n\nfunction AttestationStatus({\n value,\n defaultValue = \"pending\",\n onValueChange,\n onApprove,\n onReject,\n onEscalate,\n showActions = true,\n className,\n}: AttestationStatusProps) {\n const { profile } = useBookiLocaleOptional();\n const [internal, setInternal] = useState<AttestationStatusValue>(value ?? defaultValue);\n const current = value ?? internal;\n const labels = {\n pendingLabel: profile.copy.attestationPending,\n approvedLabel: profile.copy.attestationApproved,\n rejectedLabel: profile.copy.attestationRejected,\n escalatedLabel: profile.copy.attestationEscalated,\n };\n\n return (\n <AttestationStatusRoot\n value={value}\n defaultValue={defaultValue}\n label={profile.copy.attestation}\n pendingLabel={labels.pendingLabel}\n approvedLabel={labels.approvedLabel}\n rejectedLabel={labels.rejectedLabel}\n escalatedLabel={labels.escalatedLabel}\n onValueChange={(next) => {\n setInternal(next);\n onValueChange?.(next);\n }}\n onApprove={onApprove}\n onReject={onReject}\n onEscalate={onEscalate}\n className={className}\n aria-label={profile.copy.attestation}\n >\n <AttestationStatusBadge>{statusLabelFor(current, labels)}</AttestationStatusBadge>\n {showActions ? (\n <div data-slot=\"attestation-status-actions\">\n <AttestationStatusApprove>{profile.copy.approve}</AttestationStatusApprove>\n <AttestationStatusReject>{profile.copy.reject}</AttestationStatusReject>\n <AttestationStatusEscalate>{profile.copy.escalate}</AttestationStatusEscalate>\n </div>\n ) : null}\n </AttestationStatusRoot>\n );\n}\n\nexport {\n AttestationStatus,\n AttestationStatusRoot,\n AttestationStatusBadge,\n AttestationStatusApprove,\n AttestationStatusReject,\n AttestationStatusEscalate,\n attestationStatus,\n};\n\nexport { type AttestationStatusValue } from \"@booki-aui/primitives/attestation-status\";\n"],"mappings":";;;;;;AAAA,SAAS,mBAA+B;AACxC,SAAS,gBAAgB;AAEzB;AAAA,EAEE;AAAA,EACA;AAAA,OACK;AAoED,cAEE,YAFF;AAlEN,IAAM,OAAO;AAAA,EACX,MAAM;A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K,UAAS;AAAA,WACpD,IACE;AAAA;AAAA;AAAA,EACN;AAEJ;","names":[]}
@@ -0,0 +1,136 @@
1
+ "use client";
2
+ import {
3
+ useBookiLocaleOptional
4
+ } from "./chunk-GVP2N3K6.js";
5
+
6
+ // src/sheet-stack.tsx
7
+ import { createParts } from "@ui-sdk/react/primitive";
8
+ import { useEffect, useId, useRef, useState } from "react";
9
+ import { sheetStack } from "@booki-aui/primitives/sheet-stack";
10
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
11
+ var TAGS = {
12
+ root: "div",
13
+ back: "button",
14
+ crumb: "button",
15
+ close: "button"
16
+ };
17
+ var parts = createParts(sheetStack, TAGS);
18
+ var SheetStackRoot = parts.Root;
19
+ var SheetStackBack = parts.Back;
20
+ var SheetStackCrumb = parts.Crumb;
21
+ var SheetStackClose = parts.Close;
22
+ var COPY = {
23
+ EN: { label: "Open sheets", trail: "Where you are", backTo: "Back to", close: "Close the top sheet" },
24
+ NO: { label: "\xC5pne sider", trail: "Hvor du er", backTo: "Tilbake til", close: "Lukk \xF8verste side" }
25
+ };
26
+ function useWidth() {
27
+ const ref = useRef(null);
28
+ const [width, setWidth] = useState(void 0);
29
+ useEffect(() => {
30
+ const node = ref.current;
31
+ if (!node) return;
32
+ const now = Math.round(node.getBoundingClientRect().width);
33
+ if (now > 0) setWidth(now);
34
+ if (typeof ResizeObserver === "undefined") return;
35
+ const observer = new ResizeObserver(([entry]) => setWidth(Math.round(entry?.contentRect.width ?? 0)));
36
+ observer.observe(node);
37
+ return () => observer.disconnect();
38
+ }, []);
39
+ return [ref, width];
40
+ }
41
+ function useFocusTop(ref) {
42
+ const last = useRef(null);
43
+ useEffect(() => {
44
+ const frame = ref.current;
45
+ if (!frame) return;
46
+ const read = () => frame.querySelector('[data-slot="sheet-stack-sheet"][data-top] [data-slot="sheet-stack-title"]');
47
+ last.current = read()?.id ?? null;
48
+ const observer = new MutationObserver(() => {
49
+ const title = read();
50
+ const id = title?.id ?? null;
51
+ if (id === last.current) return;
52
+ last.current = id;
53
+ const active = document.activeElement;
54
+ if (title && (active === null || active === document.body || frame.contains(active)))
55
+ title.focus({ preventScroll: true });
56
+ });
57
+ observer.observe(frame, { subtree: true, attributes: true, attributeFilter: ["data-top"], childList: true });
58
+ return () => observer.disconnect();
59
+ }, [ref]);
60
+ }
61
+ function SheetStack({
62
+ sheets,
63
+ defaultSheets,
64
+ onSheetsChange,
65
+ dock,
66
+ renderSheet,
67
+ className,
68
+ "aria-label": ariaLabel
69
+ }) {
70
+ const { country } = useBookiLocaleOptional();
71
+ const copy = COPY[country === "NO" ? "NO" : "EN"];
72
+ const [ref, width] = useWidth();
73
+ const baseId = useId();
74
+ useFocusTop(ref);
75
+ return /* @__PURE__ */ jsx("div", { ref, "data-slot": "sheet-stack-frame", className, children: /* @__PURE__ */ jsx(
76
+ SheetStackRoot,
77
+ {
78
+ sheets,
79
+ defaultSheets,
80
+ onSheetsChange,
81
+ width,
82
+ dock,
83
+ "aria-label": ariaLabel ?? copy.label,
84
+ children: (state) => /* @__PURE__ */ jsxs(Fragment, { children: [
85
+ /* @__PURE__ */ jsxs("nav", { "data-slot": "sheet-stack-trail", "aria-label": copy.trail, children: [
86
+ /* @__PURE__ */ jsx("ol", { children: state.sheets.map(
87
+ (sheet, i) => i === state.sheets.length - 1 ? /* @__PURE__ */ jsx("li", { "aria-current": "page", children: sheet.title }, sheet.key) : /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(SheetStackCrumb, { value: sheet.key, children: sheet.title }) }, sheet.key)
88
+ ) }),
89
+ state.sheets.length > 1 ? /* @__PURE__ */ jsx(SheetStackClose, { "aria-label": copy.close, children: /* @__PURE__ */ jsx("kbd", { children: "Esc" }) }) : null
90
+ ] }),
91
+ /* @__PURE__ */ jsx("div", { "data-slot": "sheet-stack-stage", "data-docked": state.docked ? "" : void 0, children: state.sheets.map((sheet, i) => {
92
+ const place = state.placements[i];
93
+ if (!place) return null;
94
+ const titleId = `${baseId}-${i}-title`;
95
+ return /* @__PURE__ */ jsxs(
96
+ "section",
97
+ {
98
+ "data-slot": "sheet-stack-sheet",
99
+ "data-top": place.top ? "" : void 0,
100
+ "data-covered": place.covered ? "" : void 0,
101
+ "data-overlapped": place.overlapped ? "" : void 0,
102
+ "aria-labelledby": titleId,
103
+ style: { width: place.width, transform: `translateX(${place.x}px)`, zIndex: i + 1 },
104
+ children: [
105
+ !place.top && (place.covered || place.overlapped) ? /* @__PURE__ */ jsx(
106
+ SheetStackBack,
107
+ {
108
+ value: sheet.key,
109
+ "data-spine": place.covered ? "" : void 0,
110
+ "aria-label": `${copy.backTo} ${sheet.title}`,
111
+ children: place.covered ? /* @__PURE__ */ jsx("span", { "data-slot": "sheet-stack-spine-title", children: sheet.title }) : null
112
+ }
113
+ ) : null,
114
+ /* @__PURE__ */ jsxs("div", { "data-slot": "sheet-stack-content", inert: !place.top, children: [
115
+ /* @__PURE__ */ jsx("h2", { id: titleId, "data-slot": "sheet-stack-title", tabIndex: -1, children: sheet.title }),
116
+ renderSheet(sheet, place)
117
+ ] })
118
+ ]
119
+ },
120
+ sheet.key
121
+ );
122
+ }) })
123
+ ] })
124
+ }
125
+ ) });
126
+ }
127
+
128
+ export {
129
+ sheetStack,
130
+ SheetStackRoot,
131
+ SheetStackBack,
132
+ SheetStackCrumb,
133
+ SheetStackClose,
134
+ SheetStack
135
+ };
136
+ //# sourceMappingURL=chunk-4EVVT6ME.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/sheet-stack.tsx"],"sourcesContent":["import type { SheetPlacement, StackSheet } from \"@booki-aui/core/sheet-stack\";\nimport type { BookiChangeDetails } from \"./change-details.js\";\nimport { createParts, type Parts } from \"@ui-sdk/react/primitive\";\nimport { useEffect, useId, useRef, useState, type ReactNode } from \"react\";\nimport { useBookiLocaleOptional } from \"./locale.js\";\nimport { sheetStack } from \"@booki-aui/primitives/sheet-stack\";\n\nconst TAGS = {\n root: \"div\",\n back: \"button\",\n crumb: \"button\",\n close: \"button\",\n} as const;\n// Typed by name, so the declarations refer to the definition instead of spelling it out per part.\nconst parts: Parts<typeof sheetStack, typeof TAGS> = createParts(sheetStack, TAGS);\nconst SheetStackRoot: (typeof parts)[\"Root\"] = parts.Root;\nconst SheetStackBack: (typeof parts)[\"Back\"] = parts.Back;\nconst SheetStackCrumb: (typeof parts)[\"Crumb\"] = parts.Crumb;\nconst SheetStackClose: (typeof parts)[\"Close\"] = parts.Close;\n\nconst COPY = {\n EN: { label: \"Open sheets\", trail: \"Where you are\", backTo: \"Back to\", close: \"Close the top sheet\" },\n NO: { label: \"Åpne sider\", trail: \"Hvor du er\", backTo: \"Tilbake til\", close: \"Lukk øverste side\" },\n} as const;\n\nexport type SheetStackProps = {\n sheets?: StackSheet[];\n defaultSheets?: StackSheet[];\n onSheetsChange?: (sheets: StackSheet[], details: BookiChangeDetails) => void;\n /** The person's choice for a sheet that may dock. Default \"beside\". */\n dock?: \"beside\" | \"over\";\n /** What each sheet shows. Only the top sheet takes input; the rest are inert. */\n renderSheet: (sheet: StackSheet, place: SheetPlacement) => ReactNode;\n className?: string;\n \"aria-label\"?: string;\n};\n\ntype RootState = { sheets: StackSheet[]; placements: SheetPlacement[]; docked: boolean };\n\n/** Follows the stack's width, so the layout follows the window. */\nfunction useWidth() {\n const ref = useRef<HTMLDivElement | null>(null);\n const [width, setWidth] = useState<number | undefined>(undefined);\n useEffect(() => {\n const node = ref.current;\n if (!node) return;\n // Measure at once: an observer reports only when the page renders, which a\n // background tab may not do yet.\n const now = Math.round(node.getBoundingClientRect().width);\n if (now > 0) setWidth(now);\n if (typeof ResizeObserver === \"undefined\") return;\n const observer = new ResizeObserver(([entry]) => setWidth(Math.round(entry?.contentRect.width ?? 0)));\n observer.observe(node);\n return () => observer.disconnect();\n }, []);\n return [ref, width] as const;\n}\n\n/**\n * A page and the sheets opened from it, stacked. The top sheet takes input;\n * a sheet behind it shows a readable strip, or a spine with its title, that\n * goes back to it. A trail above names the whole chain, and Escape closes the\n * top sheet. The app decides what opens (append to `sheets`); going back is\n * the control's, for a person or an agent.\n */\n/**\n * When the top sheet changes (one opens, or a person goes back), focus moves\n * to its title, so a keyboard or screen-reader user lands where the work is.\n * Not on first render: opening a page does not steal focus.\n */\nfunction useFocusTop(ref: { current: HTMLElement | null }) {\n const last = useRef<string | null>(null);\n useEffect(() => {\n const frame = ref.current;\n if (!frame) return;\n const read = () =>\n frame.querySelector<HTMLElement>('[data-slot=\"sheet-stack-sheet\"][data-top] [data-slot=\"sheet-stack-title\"]');\n last.current = read()?.id ?? null;\n const observer = new MutationObserver(() => {\n const title = read();\n const id = title?.id ?? null;\n if (id === last.current) return;\n last.current = id;\n // Only when the person was working in the stack (or focus fell to the\n // page as a pressed button left): an agent opening a sheet elsewhere does\n // not pull focus away from what the person is typing.\n const active = document.activeElement;\n if (title && (active === null || active === document.body || frame.contains(active)))\n title.focus({ preventScroll: true });\n });\n observer.observe(frame, { subtree: true, attributes: true, attributeFilter: [\"data-top\"], childList: true });\n return () => observer.disconnect();\n }, [ref]);\n}\n\nfunction SheetStack({\n sheets,\n defaultSheets,\n onSheetsChange,\n dock,\n renderSheet,\n className,\n \"aria-label\": ariaLabel,\n}: SheetStackProps) {\n const { country } = useBookiLocaleOptional();\n const copy = COPY[country === \"NO\" ? \"NO\" : \"EN\"];\n const [ref, width] = useWidth();\n const baseId = useId();\n useFocusTop(ref);\n return (\n <div ref={ref} data-slot=\"sheet-stack-frame\" className={className}>\n <SheetStackRoot\n sheets={sheets}\n defaultSheets={defaultSheets}\n onSheetsChange={onSheetsChange}\n width={width}\n dock={dock}\n aria-label={ariaLabel ?? copy.label}\n >\n {(state: RootState) => (\n <>\n <nav data-slot=\"sheet-stack-trail\" aria-label={copy.trail}>\n <ol>\n {state.sheets.map((sheet, i) =>\n i === state.sheets.length - 1 ? (\n <li key={sheet.key} aria-current=\"page\">\n {sheet.title}\n </li>\n ) : (\n <li key={sheet.key}>\n <SheetStackCrumb value={sheet.key}>{sheet.title}</SheetStackCrumb>\n </li>\n ),\n )}\n </ol>\n {state.sheets.length > 1 ? (\n <SheetStackClose aria-label={copy.close}>\n <kbd>Esc</kbd>\n </SheetStackClose>\n ) : null}\n </nav>\n <div data-slot=\"sheet-stack-stage\" data-docked={state.docked ? \"\" : undefined}>\n {state.sheets.map((sheet, i) => {\n const place = state.placements[i];\n if (!place) return null;\n const titleId = `${baseId}-${i}-title`;\n return (\n <section\n key={sheet.key}\n data-slot=\"sheet-stack-sheet\"\n data-top={place.top ? \"\" : undefined}\n data-covered={place.covered ? \"\" : undefined}\n data-overlapped={place.overlapped ? \"\" : undefined}\n aria-labelledby={titleId}\n style={{ width: place.width, transform: `translateX(${place.x}px)`, zIndex: i + 1 }}\n >\n {!place.top && (place.covered || place.overlapped) ? (\n <SheetStackBack\n value={sheet.key}\n data-spine={place.covered ? \"\" : undefined}\n aria-label={`${copy.backTo} ${sheet.title}`}\n >\n {place.covered ? <span data-slot=\"sheet-stack-spine-title\">{sheet.title}</span> : null}\n </SheetStackBack>\n ) : null}\n <div data-slot=\"sheet-stack-content\" inert={!place.top}>\n <h2 id={titleId} data-slot=\"sheet-stack-title\" tabIndex={-1}>\n {sheet.title}\n </h2>\n {renderSheet(sheet, place)}\n </div>\n </section>\n );\n })}\n </div>\n </>\n )}\n </SheetStackRoot>\n </div>\n );\n}\n\nexport { SheetStack, SheetStackBack, SheetStackClose, SheetStackCrumb, SheetStackRoot, sheetStack };\nexport type { SheetPlacement, StackSheet };\n"],"mappings":";;;;;;AAEA,SAAS,mBAA+B;AACxC,SAAS,WAAW,OAAO,QAAQ,gBAAgC;AAEnE,SAAS,kBAAkB;AAmHjB,mBAKU,KAJR,YADF;AAjHV,IAAM,OAAO;AAAA,EACX,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AACT;AAEA,IAAM,QAA+C,YAAY,YAAY,IAAI;AACjF,IAAM,iBAAyC,MAAM;AACrD,IAAM,iBAAyC,MAAM;AACrD,IAAM,kBAA2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ACnB,gBAAM,UAAU,GAAG,MAAM,IAAI,CAAC;AAC9B,iBACE;AAAA,YAAC;AAAA;AAAA,cAEC,aAAU;AAAA,cACV,YAAU,MAAM,MAAM,KAAK;AAAA,cAC3B,gBAAc,MAAM,UAAU,KAAK;AAAA,cACnC,mBAAiB,MAAM,aAAa,KAAK;AAAA,cACzC,mBAAiB;AAAA,cACjB,OAAO,EAAE,OAAO,MAAM,OAAO,WAAW,cAAc,MAAM,CAAC,OAAO,QAAQ,IAAI,EAAE;AAAA,cAEjF;AAAA,iBAAC,MAAM,QAAQ,MAAM,WAAW,MAAM,cACrC;AAAA,kBAAC;AAAA;AAAA,oBACC,OAAO,MAAM;AAAA,oBACb,cAAY,MAAM,UAAU,KAAK;AAAA,oBACjC,cAAY,GAAG,KAAK,MAAM,IAAI,MAAM,KAAK;AAAA,oBAExC,gBAAM,UAAU,oBAAC,UAAK,aAAU,2BAA2B,gBAAM,OAAM,IAAU;AAAA;AAAA,gBACpF,IACE;AAAA,gBACJ,qBAAC,SAAI,aAAU,uBAAsB,OAAO,CAAC,MAAM,KACjD;AAAA,sCAAC,QAAG,IAAI,SAAS,aAAU,qBAAoB,UAAU,IACtD,gBAAM,OACT;AAAA,kBACC,YAAY,OAAO,KAAK;AAAA,mBAC3B;AAAA;AAAA;AAAA,YAtBK,MAAM;AAAA,UAuBb;AAAA,QAEJ,CAAC,GACH;AAAA,SACF;AAAA;AAAA,EAEJ,GACF;AAEJ;","names":[]}
@@ -0,0 +1,132 @@
1
+ "use client";
2
+ import {
3
+ createBookiHistory
4
+ } from "./chunk-SHZFZRHV.js";
5
+ import {
6
+ useBookiLocaleOptional
7
+ } from "./chunk-GVP2N3K6.js";
8
+
9
+ // src/toasts.tsx
10
+ import {
11
+ Toast,
12
+ ToastAction,
13
+ ToastClose,
14
+ ToastDescription,
15
+ ToastRegion,
16
+ ToastTitle,
17
+ createToaster,
18
+ toast
19
+ } from "@ui-sdk/react/toast";
20
+ import { useEffect, useLayoutEffect, useRef } from "react";
21
+ import { formatMoney, money } from "@booki-aui/core/money";
22
+ import { jsx, jsxs } from "react/jsx-runtime";
23
+ var COPY = {
24
+ EN: {
25
+ region: "Notifications",
26
+ close: "Dismiss",
27
+ agent: "Agent",
28
+ undo: "Undo",
29
+ pending: "Still working",
30
+ set: (label, value) => `Set ${label} to ${value}`,
31
+ hidden: "a hidden value",
32
+ empty: "empty",
33
+ later: "Later changes came after this one; undo those first."
34
+ },
35
+ NO: {
36
+ region: "Varsler",
37
+ close: "Lukk",
38
+ agent: "Agent",
39
+ undo: "Angre",
40
+ pending: "Arbeider fortsatt",
41
+ set: (label, value) => `Satte ${label} til ${value}`,
42
+ hidden: "en skjult verdi",
43
+ empty: "tom",
44
+ later: "Det er gjort endringer etter denne; angre dem f\xF8rst."
45
+ }
46
+ };
47
+ function BookiToasts({ toaster, side = "bottom", align = "end", className }) {
48
+ const { country } = useBookiLocaleOptional();
49
+ const copy = COPY[country === "NO" ? "NO" : "EN"];
50
+ return /* @__PURE__ */ jsx(
51
+ ToastRegion,
52
+ {
53
+ toaster,
54
+ side,
55
+ align,
56
+ "aria-label": copy.region,
57
+ pendingAnnouncement: copy.pending,
58
+ className,
59
+ "data-booki": "",
60
+ "data-booki-toasts": "",
61
+ "data-agent-hidden": "",
62
+ children: (item) => {
63
+ const agent = item.data?.agent === true;
64
+ return /* @__PURE__ */ jsxs(Toast, { "data-booki-toast": "", "data-agent": agent ? "" : void 0, children: [
65
+ /* @__PURE__ */ jsxs("div", { "data-booki-toast": "text", children: [
66
+ agent ? /* @__PURE__ */ jsx("span", { "data-booki-toast": "agent", children: copy.agent }) : null,
67
+ /* @__PURE__ */ jsx(ToastTitle, { "data-booki-toast": "title" }),
68
+ /* @__PURE__ */ jsx(ToastDescription, { "data-booki-toast": "description" })
69
+ ] }),
70
+ /* @__PURE__ */ jsx(ToastAction, { "data-booki-toast": "action" }),
71
+ /* @__PURE__ */ jsx(ToastClose, { "data-booki-toast": "close", "aria-label": copy.close, children: "\xD7" })
72
+ ] });
73
+ }
74
+ }
75
+ );
76
+ }
77
+ function useAgentToasts(agent, options = {}) {
78
+ const { country, profile } = useBookiLocaleOptional();
79
+ const copy = COPY[country === "NO" ? "NO" : "EN"];
80
+ const latest = useRef({ copy, options, profile });
81
+ useLayoutEffect(() => {
82
+ latest.current = { copy, options, profile };
83
+ });
84
+ useEffect(() => {
85
+ if (!agent) return;
86
+ const own = latest.current.options.history ? null : createBookiHistory(agent);
87
+ const history = latest.current.options.history ?? own;
88
+ const toasted = /* @__PURE__ */ new Map();
89
+ for (const entry of history.entries()) toasted.set(entry.id, JSON.stringify(entry.value));
90
+ const unsubscribe = history.subscribe(() => {
91
+ const { copy: words, options: now, profile: locale } = latest.current;
92
+ for (const entry of history.entries()) {
93
+ if (entry.source !== "agent" || entry.reverted) continue;
94
+ const seen = JSON.stringify(entry.value);
95
+ if (toasted.get(entry.id) === seen) continue;
96
+ toasted.set(entry.id, seen);
97
+ const value = entry.redacted ? words.hidden : entry.key === "minor" && typeof entry.value === "number" ? formatMoney(money(entry.value, locale.currency), { locale: locale.locale }) : entry.value === "" || entry.value === null || entry.value === void 0 ? words.empty : typeof entry.value === "object" ? JSON.stringify(entry.value).slice(0, 80) : String(entry.value);
98
+ (now.toaster ?? toast)({
99
+ // The same id updates the receipt in place when the agent changes the field again.
100
+ id: `agent-${entry.id}`,
101
+ title: words.set(entry.label, value),
102
+ data: { agent: true },
103
+ duration: now.duration ?? 6e3,
104
+ ...entry.redacted ? {} : {
105
+ action: {
106
+ label: words.undo,
107
+ onAction: () => {
108
+ const entries = history.entries();
109
+ const index = entries.findIndex((item) => item.id === entry.id);
110
+ if (index < 0) return void 0;
111
+ if (index !== history.position() - 1) return Promise.reject(new Error(words.later));
112
+ return history.seek(index);
113
+ }
114
+ }
115
+ }
116
+ });
117
+ }
118
+ });
119
+ return () => {
120
+ unsubscribe();
121
+ own?.destroy();
122
+ };
123
+ }, [agent]);
124
+ }
125
+
126
+ export {
127
+ createToaster,
128
+ toast,
129
+ BookiToasts,
130
+ useAgentToasts
131
+ };
132
+ //# sourceMappingURL=chunk-4GQUOBOG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/toasts.tsx"],"sourcesContent":["import {\n Toast,\n ToastAction,\n ToastClose,\n ToastDescription,\n ToastRegion,\n ToastTitle,\n createToaster,\n toast,\n} from \"@ui-sdk/react/toast\";\nimport { useEffect, useLayoutEffect, useRef } from \"react\";\nimport type { AgentBridge } from \"./booki-agent.js\";\nimport { formatMoney, money } from \"@booki-aui/core/money\";\nimport { createBookiHistory } from \"./booki-agent.js\";\nimport { useBookiLocaleOptional } from \"./locale.js\";\n\nconst COPY = {\n EN: {\n region: \"Notifications\",\n close: \"Dismiss\",\n agent: \"Agent\",\n undo: \"Undo\",\n pending: \"Still working\",\n set: (label: string, value: string) => `Set ${label} to ${value}`,\n hidden: \"a hidden value\",\n empty: \"empty\",\n later: \"Later changes came after this one; undo those first.\",\n },\n NO: {\n region: \"Varsler\",\n close: \"Lukk\",\n agent: \"Agent\",\n undo: \"Angre\",\n pending: \"Arbeider fortsatt\",\n set: (label: string, value: string) => `Satte ${label} til ${value}`,\n hidden: \"en skjult verdi\",\n empty: \"tom\",\n later: \"Det er gjort endringer etter denne; angre dem først.\",\n },\n} as const;\n\n/** What a Booki toast carries beyond its text. */\nexport type BookiToastData = {\n /** Something an agent did: the toast wears the agent's mark. */\n agent?: boolean;\n};\n\n/** Any toaster from `createToaster()`, as the region takes it. */\ntype Toaster = NonNullable<Parameters<typeof ToastRegion>[0][\"toaster\"]>;\n\nexport type BookiToastsProps = {\n /** The queue to show. Default: the shared `toast()`. */\n toaster?: Toaster;\n side?: \"top\" | \"bottom\";\n align?: \"start\" | \"center\" | \"end\";\n className?: string;\n};\n\n/**\n * Where receipts land: \"Voucher 1042 posted\", \"Payment run sent\". Put it once\n * near the root. A toast an agent caused carries the agent's mark, in words\n * and in its colour. Timers pause while the pointer or focus is on them and\n * while the page is hidden; F6 moves focus to them and back.\n */\nfunction BookiToasts({ toaster, side = \"bottom\", align = \"end\", className }: BookiToastsProps) {\n const { country } = useBookiLocaleOptional();\n const copy = COPY[country === \"NO\" ? \"NO\" : \"EN\"];\n return (\n <ToastRegion\n toaster={toaster}\n side={side}\n align={align}\n aria-label={copy.region}\n pendingAnnouncement={copy.pending}\n className={className}\n data-booki=\"\"\n data-booki-toasts=\"\"\n // Receipts are the person's: an agent must not read them or press Undo on them.\n data-agent-hidden=\"\"\n >\n {(item) => {\n const agent = (item.data as BookiToastData | undefined)?.agent === true;\n return (\n <Toast data-booki-toast=\"\" data-agent={agent ? \"\" : undefined}>\n <div data-booki-toast=\"text\">\n {agent ? <span data-booki-toast=\"agent\">{copy.agent}</span> : null}\n <ToastTitle data-booki-toast=\"title\" />\n <ToastDescription data-booki-toast=\"description\" />\n </div>\n <ToastAction data-booki-toast=\"action\" />\n <ToastClose data-booki-toast=\"close\" aria-label={copy.close}>\n ×\n </ToastClose>\n </Toast>\n );\n }}\n </ToastRegion>\n );\n}\n\nexport type AgentToastOptions = {\n /** The queue to use. Default: the shared `toast()`. */\n toaster?: Toaster;\n /**\n * The history to describe and undo from. Default: one this hook records\n * with `createBookiHistory`. Undo puts the page back to just before that\n * change, so later changes are undone with it.\n */\n history?: ReturnType<typeof createBookiHistory>;\n /** How long each receipt shows, in ms. Default 6000. */\n duration?: number;\n};\n\n/**\n * A receipt for every change an agent makes on the page: \"Agent set Amount\n * to 1 250,00\", with Undo. A person sees what the agent did as it happens,\n * not only in the audit trail. Redacted changes (bank details) are described\n * without their value and cannot be undone.\n */\nfunction useAgentToasts(agent: AgentBridge | null | undefined, options: AgentToastOptions = {}) {\n const { country, profile } = useBookiLocaleOptional();\n const copy = COPY[country === \"NO\" ? \"NO\" : \"EN\"];\n const latest = useRef({ copy, options, profile });\n // The subscription reads the newest copy and options; write them after render, not during it.\n useLayoutEffect(() => {\n latest.current = { copy, options, profile };\n });\n useEffect(() => {\n if (!agent) return;\n const own = latest.current.options.history ? null : createBookiHistory(agent);\n const history = latest.current.options.history ?? own!;\n // By entry id and the value toasted: the history folds repeated changes to\n // one field into one entry and drops undone ones, so its length is no guide.\n const toasted = new Map<string, string>();\n for (const entry of history.entries()) toasted.set(entry.id, JSON.stringify(entry.value));\n const unsubscribe = history.subscribe(() => {\n const { copy: words, options: now, profile: locale } = latest.current;\n for (const entry of history.entries()) {\n if (entry.source !== \"agent\" || entry.reverted) continue;\n const seen = JSON.stringify(entry.value);\n if (toasted.get(entry.id) === seen) continue;\n toasted.set(entry.id, seen);\n const value = entry.redacted\n ? words.hidden\n : entry.key === \"minor\" && typeof entry.value === \"number\"\n ? formatMoney(money(entry.value, locale.currency), { locale: locale.locale })\n : entry.value === \"\" || entry.value === null || entry.value === undefined\n ? words.empty\n : typeof entry.value === \"object\"\n ? JSON.stringify(entry.value).slice(0, 80)\n : String(entry.value);\n (now.toaster ?? toast)({\n // The same id updates the receipt in place when the agent changes the field again.\n id: `agent-${entry.id}`,\n title: words.set(entry.label, value),\n data: { agent: true } satisfies BookiToastData,\n duration: now.duration ?? 6000,\n ...(entry.redacted\n ? {}\n : {\n action: {\n label: words.undo,\n onAction: () => {\n const entries = history.entries();\n const index = entries.findIndex((item) => item.id === entry.id);\n if (index < 0) return undefined;\n // Going back past later changes would undo a person's work too: only the latest change undoes.\n if (index !== history.position() - 1) return Promise.reject(new Error(words.later));\n return history.seek(index);\n },\n },\n }),\n });\n }\n });\n return () => {\n unsubscribe();\n own?.destroy();\n };\n }, [agent]);\n}\n\nexport { BookiToasts, createToaster, toast, useAgentToasts };\n"],"mappings":";;;;;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,WAAW,iBAAiB,cAAc;AAEnD,SAAS,aAAa,aAAa;AAwEvB,SACW,KADX;AApEZ,IAAM,OAAO;AAAA,EACX,IAAI;AAAA,IACF,QAAQ;AAAA,IACR,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AAAA;AAAA,UAErB,IAAI,SAAS,MAAM,EAAE;AAAA,UACrB,OAAO,MAAM,IAAI,MAAM,OAAO,KAAK;AAAA,UACnC,MAAM,EAAE,OAAO,KAAK;AAAA,UACpB,UAAU,IAAI,YAAY;AAAA,UAC1B,GAAI,MAAM,WACN,CAAC,IACD;AAAA,YACE,QAAQ;AAAA,cACN,OAAO,MAAM;AAAA,cACb,UAAU,MAAM;AACd,sBAAM,UAAU,QAAQ,QAAQ;AAChC,sBAAM,QAAQ,QAAQ,UAAU,CAAC,SAAS,KAAK,OAAO,MAAM,EAAE;AAC9D,oBAAI,QAAQ,EAAG,QAAO;AAEtB,oBAAI,UAAU,QAAQ,SAAS,IAAI,EAAG,QAAO,QAAQ,OAAO,IAAI,MAAM,MAAM,KAAK,CAAC;AAClF,uBAAO,QAAQ,KAAK,KAAK;AAAA,cAC3B;AAAA,YACF;AAAA,UACF;AAAA,QACN,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AACD,WAAO,MAAM;AACX,kBAAY;AACZ,WAAK,QAAQ;AAAA,IACf;AAAA,EACF,GAAG,CAAC,KAAK,CAAC;AACZ;","names":[]}
@@ -0,0 +1,86 @@
1
+ "use client";
2
+ import {
3
+ FormValue
4
+ } from "./chunk-OYERLEER.js";
5
+ import {
6
+ useBookiLocaleOptional
7
+ } from "./chunk-GVP2N3K6.js";
8
+
9
+ // src/accounting-period-select.tsx
10
+ import { createParts } from "@ui-sdk/react/primitive";
11
+ import { useId, useState } from "react";
12
+ import { localToday } from "@booki-aui/core/financial-date";
13
+ import { buildItems, accountingPeriod } from "@booki-aui/primitives/accounting-period-select";
14
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
15
+ var TAGS = {
16
+ root: "div",
17
+ trigger: "button",
18
+ list: "div",
19
+ option: "div",
20
+ select: "select"
21
+ };
22
+ var parts = createParts(accountingPeriod, TAGS);
23
+ var AccountingPeriodRoot = parts.Root;
24
+ var AccountingPeriodTrigger = parts.Trigger;
25
+ var AccountingPeriodList = parts.List;
26
+ var AccountingPeriodOption = parts.Option;
27
+ var AccountingPeriodControl = parts.Select;
28
+ function AccountingPeriodSelect({
29
+ value,
30
+ defaultValue,
31
+ year,
32
+ granularity: granularityProp,
33
+ onValueChange,
34
+ name,
35
+ id,
36
+ disabled,
37
+ readOnly,
38
+ required,
39
+ className,
40
+ ...props
41
+ }) {
42
+ const { profile } = useBookiLocaleOptional();
43
+ const granularity = granularityProp ?? profile.period.defaultGranularity;
44
+ const [thisYear] = useState(() => Number(localToday().slice(0, 4)));
45
+ const resolvedYear = year ?? thisYear;
46
+ const items = buildItems(resolvedYear, granularity, profile.locale);
47
+ const labelId = useId();
48
+ return /* @__PURE__ */ jsx(
49
+ AccountingPeriodRoot,
50
+ {
51
+ value,
52
+ defaultValue,
53
+ year: resolvedYear,
54
+ granularity,
55
+ locale: profile.locale,
56
+ label: profile.period.label,
57
+ onValueChange,
58
+ disabled,
59
+ readOnly,
60
+ className,
61
+ "aria-label": profile.period.label,
62
+ ...props,
63
+ children: (state) => /* @__PURE__ */ jsxs(Fragment, { children: [
64
+ /* @__PURE__ */ jsx("span", { "data-slot": "accounting-period-label", id: labelId, children: profile.copy.period }),
65
+ /* @__PURE__ */ jsx(AccountingPeriodTrigger, { id, "aria-required": required || void 0, "aria-labelledby": labelId, children: (trigger) => /* @__PURE__ */ jsx("span", { "data-slot": "accounting-period-value", children: trigger.text || "\u2013" }) }),
66
+ /* @__PURE__ */ jsx(AccountingPeriodList, { children: items.map((item) => /* @__PURE__ */ jsx(AccountingPeriodOption, { value: item.value, label: item.label, children: item.label }, item.value)) }),
67
+ /* @__PURE__ */ jsxs(AccountingPeriodControl, { tabIndex: -1, children: [
68
+ state.value === "" ? /* @__PURE__ */ jsx("option", { value: "", children: "\u2013" }) : null,
69
+ items.map((item) => /* @__PURE__ */ jsx("option", { value: item.value, children: item.label }, item.value))
70
+ ] }),
71
+ /* @__PURE__ */ jsx(FormValue, { name, value: state.value, disabled })
72
+ ] })
73
+ }
74
+ );
75
+ }
76
+
77
+ export {
78
+ accountingPeriod,
79
+ AccountingPeriodRoot,
80
+ AccountingPeriodTrigger,
81
+ AccountingPeriodList,
82
+ AccountingPeriodOption,
83
+ AccountingPeriodControl,
84
+ AccountingPeriodSelect
85
+ };
86
+ //# sourceMappingURL=chunk-4KWEZTO5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/accounting-period-select.tsx"],"sourcesContent":["import { type PeriodGranularity } from \"@booki-aui/core/period\";\nimport { createParts, type Parts } from \"@ui-sdk/react/primitive\";\nimport { useId, useState, type ComponentProps } from \"react\";\nimport { localToday } from \"@booki-aui/core/financial-date\";\nimport { FormValue, type BookiFormProps } from \"./form-props.js\";\nimport { useBookiLocaleOptional } from \"./locale.js\";\nimport { buildItems, accountingPeriod } from \"@booki-aui/primitives/accounting-period-select\";\n\nconst TAGS = {\n root: \"div\",\n trigger: \"button\",\n list: \"div\",\n option: \"div\",\n select: \"select\",\n} as const;\n// Typed by name, so the declarations refer to the definition instead of spelling it out per part.\nconst parts: Parts<typeof accountingPeriod, typeof TAGS> = createParts(accountingPeriod, TAGS);\n\nconst AccountingPeriodRoot: (typeof parts)[\"Root\"] = parts.Root;\n/** The select-only combobox a person opens. */\nconst AccountingPeriodTrigger: (typeof parts)[\"Trigger\"] = parts.Trigger;\nconst AccountingPeriodList: (typeof parts)[\"List\"] = parts.List;\nconst AccountingPeriodOption: (typeof parts)[\"Option\"] = parts.Option;\n/** The native `<select>` fallback, shown by @booki-aui/styles on touch screens. */\nconst AccountingPeriodControl: (typeof parts)[\"Select\"] = parts.Select;\n\nexport type AccountingPeriodSelectProps = {\n value?: string;\n defaultValue?: string;\n year?: number;\n granularity?: PeriodGranularity;\n onValueChange?: (code: string) => void;\n className?: string;\n} & BookiFormProps &\n Omit<ComponentProps<\"div\">, \"onChange\" | \"defaultValue\" | \"children\" | \"id\">;\n\nfunction AccountingPeriodSelect({\n value,\n defaultValue,\n year,\n granularity: granularityProp,\n onValueChange,\n name,\n id,\n disabled,\n readOnly,\n required,\n className,\n ...props\n}: AccountingPeriodSelectProps) {\n const { profile } = useBookiLocaleOptional();\n const granularity = granularityProp ?? profile.period.defaultGranularity;\n // This year, read once: a render that reads the clock can disagree with the last one.\n const [thisYear] = useState(() => Number(localToday().slice(0, 4)));\n const resolvedYear = year ?? thisYear;\n const items = buildItems(resolvedYear, granularity, profile.locale);\n const labelId = useId();\n\n return (\n <AccountingPeriodRoot\n value={value}\n defaultValue={defaultValue}\n year={resolvedYear}\n granularity={granularity}\n locale={profile.locale}\n label={profile.period.label}\n onValueChange={onValueChange}\n disabled={disabled}\n readOnly={readOnly}\n className={className}\n aria-label={profile.period.label}\n {...props}\n >\n {(state: { value: string }) => (\n <>\n <span data-slot=\"accounting-period-label\" id={labelId}>\n {profile.copy.period}\n </span>\n <AccountingPeriodTrigger id={id} aria-required={required || undefined} aria-labelledby={labelId}>\n {(trigger: { text: string }) => <span data-slot=\"accounting-period-value\">{trigger.text || \"–\"}</span>}\n </AccountingPeriodTrigger>\n <AccountingPeriodList>\n {items.map((item) => (\n <AccountingPeriodOption key={item.value} value={item.value} label={item.label}>\n {item.label}\n </AccountingPeriodOption>\n ))}\n </AccountingPeriodList>\n <AccountingPeriodControl tabIndex={-1}>\n {state.value === \"\" ? <option value=\"\">–</option> : null}\n {items.map((item) => (\n <option key={item.value} value={item.value}>\n {item.label}\n </option>\n ))}\n </AccountingPeriodControl>\n <FormValue name={name} value={state.value} disabled={disabled} />\n </>\n )}\n </AccountingPeriodRoot>\n );\n}\n\nexport {\n AccountingPeriodSelect,\n AccountingPeriodRoot,\n AccountingPeriodTrigger,\n AccountingPeriodList,\n AccountingPeriodOption,\n AccountingPeriodControl,\n accountingPeriod,\n};\n"],"mappings":";;;;;;;;;AACA,SAAS,mBAA+B;AACxC,SAAS,OAAO,gBAAqC;AACrD,SAAS,kBAAkB;AAG3B,SAAS,YAAY,wBAAwB;AAoErC,mBACE,KAaA,YAdF;AAlER,IAAM,O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