@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.
- package/CHANGELOG.md +122 -0
- package/LICENSE +21 -0
- package/README.md +16 -2
- package/dist/access.d.ts +43 -0
- package/dist/access.js +15 -0
- package/dist/access.js.map +1 -0
- package/dist/account-picker.d.ts +40 -0
- package/dist/account-picker.js +25 -0
- package/dist/account-picker.js.map +1 -0
- package/dist/accounting-period-select.d.ts +34 -0
- package/dist/accounting-period-select.js +23 -0
- package/dist/accounting-period-select.js.map +1 -0
- package/dist/activity-timeline.d.ts +37 -0
- package/dist/activity-timeline.js +19 -0
- package/dist/activity-timeline.js.map +1 -0
- package/dist/aged-balances.d.ts +62 -0
- package/dist/aged-balances.js +31 -0
- package/dist/aged-balances.js.map +1 -0
- package/dist/agent-cursor.d.ts +34 -0
- package/dist/agent-cursor.js +14 -0
- package/dist/agent-cursor.js.map +1 -0
- package/dist/agent-presence.d.ts +110 -0
- package/dist/agent-presence.js +15 -0
- package/dist/agent-presence.js.map +1 -0
- package/dist/aging-chart.d.ts +41 -0
- package/dist/aging-chart.js +19 -0
- package/dist/aging-chart.js.map +1 -0
- package/dist/amount-field.d.ts +46 -0
- package/dist/amount-field.js +19 -0
- package/dist/amount-field.js.map +1 -0
- package/dist/amount-input.d.ts +18 -0
- package/dist/amount-input.js +12 -0
- package/dist/amount-input.js.map +1 -0
- package/dist/approval-chain.d.ts +36 -0
- package/dist/approval-chain.js +22 -0
- package/dist/approval-chain.js.map +1 -0
- package/dist/approval-gate.d.ts +19 -0
- package/dist/approval-gate.js +10 -0
- package/dist/approval-gate.js.map +1 -0
- package/dist/attestation-status.d.ts +31 -0
- package/dist/attestation-status.js +22 -0
- package/dist/attestation-status.js.map +1 -0
- package/dist/audit-findings.d.ts +40 -0
- package/dist/audit-findings.js +28 -0
- package/dist/audit-findings.js.map +1 -0
- package/dist/audit-trail.d.ts +22 -0
- package/dist/audit-trail.js +10 -0
- package/dist/audit-trail.js.map +1 -0
- package/dist/audit-workpaper.d.ts +56 -0
- package/dist/audit-workpaper.js +35 -0
- package/dist/audit-workpaper.js.map +1 -0
- package/dist/bank-account-input.d.ts +36 -0
- package/dist/bank-account-input.js +22 -0
- package/dist/bank-account-input.js.map +1 -0
- package/dist/bank-reconciliation.d.ts +38 -0
- package/dist/bank-reconciliation.js +20 -0
- package/dist/bank-reconciliation.js.map +1 -0
- package/dist/bar-chart.d.ts +38 -0
- package/dist/bar-chart.js +19 -0
- package/dist/bar-chart.js.map +1 -0
- package/dist/booki-agent.d.ts +153 -0
- package/dist/booki-agent.js +27 -0
- package/dist/booki-agent.js.map +1 -0
- package/dist/cashflow-waterfall.d.ts +36 -0
- package/dist/cashflow-waterfall.js +17 -0
- package/dist/cashflow-waterfall.js.map +1 -0
- package/dist/change-details-CWpEgc80.d.ts +14 -0
- package/dist/chunk-2HM7YSBC.js +92 -0
- package/dist/chunk-2HM7YSBC.js.map +1 -0
- package/dist/chunk-35QKOOAI.js +27 -0
- package/dist/chunk-35QKOOAI.js.map +1 -0
- package/dist/chunk-37GDU76M.js +86 -0
- package/dist/chunk-37GDU76M.js.map +1 -0
- package/dist/chunk-4EVVT6ME.js +136 -0
- package/dist/chunk-4EVVT6ME.js.map +1 -0
- package/dist/chunk-4GQUOBOG.js +132 -0
- package/dist/chunk-4GQUOBOG.js.map +1 -0
- package/dist/chunk-4KWEZTO5.js +86 -0
- package/dist/chunk-4KWEZTO5.js.map +1 -0
- package/dist/chunk-4WC76FUE.js +242 -0
- package/dist/chunk-4WC76FUE.js.map +1 -0
- package/dist/chunk-62G3T2AA.js +230 -0
- package/dist/chunk-62G3T2AA.js.map +1 -0
- package/dist/chunk-663UXACN.js +334 -0
- package/dist/chunk-663UXACN.js.map +1 -0
- package/dist/chunk-6CVPNV7N.js +106 -0
- package/dist/chunk-6CVPNV7N.js.map +1 -0
- package/dist/chunk-6HWFMC7V.js +140 -0
- package/dist/chunk-6HWFMC7V.js.map +1 -0
- package/dist/chunk-7MYFKLPB.js +301 -0
- package/dist/chunk-7MYFKLPB.js.map +1 -0
- package/dist/chunk-7YTOVA5F.js +312 -0
- package/dist/chunk-7YTOVA5F.js.map +1 -0
- package/dist/chunk-AIGQPM4Y.js +311 -0
- package/dist/chunk-AIGQPM4Y.js.map +1 -0
- package/dist/chunk-AKC6N4QO.js +414 -0
- package/dist/chunk-AKC6N4QO.js.map +1 -0
- package/dist/chunk-BZIOOU4I.js +421 -0
- package/dist/chunk-BZIOOU4I.js.map +1 -0
- package/dist/chunk-CDTDN4LY.js +212 -0
- package/dist/chunk-CDTDN4LY.js.map +1 -0
- package/dist/chunk-EDWQSKY7.js +161 -0
- package/dist/chunk-EDWQSKY7.js.map +1 -0
- package/dist/chunk-EKIWL37F.js +488 -0
- package/dist/chunk-EKIWL37F.js.map +1 -0
- package/dist/chunk-F3C77WLR.js +116 -0
- package/dist/chunk-F3C77WLR.js.map +1 -0
- package/dist/chunk-FBV7BFEQ.js +84 -0
- package/dist/chunk-FBV7BFEQ.js.map +1 -0
- package/dist/chunk-GVP2N3K6.js +89 -0
- package/dist/chunk-GVP2N3K6.js.map +1 -0
- package/dist/chunk-HKYEHBQT.js +19 -0
- package/dist/chunk-HKYEHBQT.js.map +1 -0
- package/dist/chunk-HQYIFZZT.js +169 -0
- package/dist/chunk-HQYIFZZT.js.map +1 -0
- package/dist/chunk-HT6HGOLM.js +151 -0
- package/dist/chunk-HT6HGOLM.js.map +1 -0
- package/dist/chunk-ISPUO3AQ.js +244 -0
- package/dist/chunk-ISPUO3AQ.js.map +1 -0
- package/dist/chunk-JPUVGWLO.js +207 -0
- package/dist/chunk-JPUVGWLO.js.map +1 -0
- package/dist/chunk-JWFGUI7A.js +73 -0
- package/dist/chunk-JWFGUI7A.js.map +1 -0
- package/dist/chunk-K72VT6RJ.js +57 -0
- package/dist/chunk-K72VT6RJ.js.map +1 -0
- package/dist/chunk-KLDUGI7L.js +150 -0
- package/dist/chunk-KLDUGI7L.js.map +1 -0
- package/dist/chunk-M2WLQIFE.js +40 -0
- package/dist/chunk-M2WLQIFE.js.map +1 -0
- package/dist/chunk-M3MCIKF2.js +143 -0
- package/dist/chunk-M3MCIKF2.js.map +1 -0
- package/dist/chunk-MBLQSZHE.js +77 -0
- package/dist/chunk-MBLQSZHE.js.map +1 -0
- package/dist/chunk-N7GIVDUU.js +191 -0
- package/dist/chunk-N7GIVDUU.js.map +1 -0
- package/dist/chunk-NMHTPP6I.js +62 -0
- package/dist/chunk-NMHTPP6I.js.map +1 -0
- package/dist/chunk-NNP6GNEW.js +65 -0
- package/dist/chunk-NNP6GNEW.js.map +1 -0
- package/dist/chunk-OTD7VUEC.js +35 -0
- package/dist/chunk-OTD7VUEC.js.map +1 -0
- package/dist/chunk-OXHKA3UZ.js +30 -0
- package/dist/chunk-OXHKA3UZ.js.map +1 -0
- package/dist/chunk-OYERLEER.js +21 -0
- package/dist/chunk-OYERLEER.js.map +1 -0
- package/dist/chunk-PFY3VJ2T.js +231 -0
- package/dist/chunk-PFY3VJ2T.js.map +1 -0
- package/dist/chunk-PUMSFFEU.js +228 -0
- package/dist/chunk-PUMSFFEU.js.map +1 -0
- package/dist/chunk-QE7KUQOI.js +84 -0
- package/dist/chunk-QE7KUQOI.js.map +1 -0
- package/dist/chunk-QGT7VI6I.js +35 -0
- package/dist/chunk-QGT7VI6I.js.map +1 -0
- package/dist/chunk-QGYS5HS3.js +214 -0
- package/dist/chunk-QGYS5HS3.js.map +1 -0
- package/dist/chunk-QPSBRSBH.js +167 -0
- package/dist/chunk-QPSBRSBH.js.map +1 -0
- package/dist/chunk-ROXGVKR2.js +59 -0
- package/dist/chunk-ROXGVKR2.js.map +1 -0
- package/dist/chunk-RPONJDFZ.js +310 -0
- package/dist/chunk-RPONJDFZ.js.map +1 -0
- package/dist/chunk-RTCKV4H2.js +65 -0
- package/dist/chunk-RTCKV4H2.js.map +1 -0
- package/dist/chunk-SHZFZRHV.js +259 -0
- package/dist/chunk-SHZFZRHV.js.map +1 -0
- package/dist/chunk-SOXPKIQK.js +91 -0
- package/dist/chunk-SOXPKIQK.js.map +1 -0
- package/dist/chunk-SR2HEE4U.js +76 -0
- package/dist/chunk-SR2HEE4U.js.map +1 -0
- package/dist/chunk-SX3U6DRW.js +462 -0
- package/dist/chunk-SX3U6DRW.js.map +1 -0
- package/dist/chunk-T4U2CT35.js +175 -0
- package/dist/chunk-T4U2CT35.js.map +1 -0
- package/dist/chunk-TSX6BD72.js +251 -0
- package/dist/chunk-TSX6BD72.js.map +1 -0
- package/dist/chunk-U6PR3V2Q.js +123 -0
- package/dist/chunk-U6PR3V2Q.js.map +1 -0
- package/dist/chunk-U7NPK4WO.js +135 -0
- package/dist/chunk-U7NPK4WO.js.map +1 -0
- package/dist/chunk-W6TKXS75.js +55 -0
- package/dist/chunk-W6TKXS75.js.map +1 -0
- package/dist/chunk-WDME4U42.js +14 -0
- package/dist/chunk-WDME4U42.js.map +1 -0
- package/dist/chunk-WS2YJSNS.js +62 -0
- package/dist/chunk-WS2YJSNS.js.map +1 -0
- package/dist/chunk-Y5EYY6WJ.js +174 -0
- package/dist/chunk-Y5EYY6WJ.js.map +1 -0
- package/dist/chunk-YBMO3W5O.js +191 -0
- package/dist/chunk-YBMO3W5O.js.map +1 -0
- package/dist/chunk-YOOWFGCU.js +90 -0
- package/dist/chunk-YOOWFGCU.js.map +1 -0
- package/dist/chunk-ZKNVWQDU.js +230 -0
- package/dist/chunk-ZKNVWQDU.js.map +1 -0
- package/dist/chunk-ZYLWSGWQ.js +29 -0
- package/dist/chunk-ZYLWSGWQ.js.map +1 -0
- package/dist/chunk-ZYPW7GCI.js +82 -0
- package/dist/chunk-ZYPW7GCI.js.map +1 -0
- package/dist/client-requests.d.ts +40 -0
- package/dist/client-requests.js +25 -0
- package/dist/client-requests.js.map +1 -0
- package/dist/close-checklist.d.ts +34 -0
- package/dist/close-checklist.js +22 -0
- package/dist/close-checklist.js.map +1 -0
- package/dist/confirm-dialog.d.ts +43 -0
- package/dist/confirm-dialog.js +10 -0
- package/dist/confirm-dialog.js.map +1 -0
- package/dist/country-toggle.d.ts +16 -0
- package/dist/country-toggle.js +10 -0
- package/dist/country-toggle.js.map +1 -0
- package/dist/currency-select.d.ts +32 -0
- package/dist/currency-select.js +23 -0
- package/dist/currency-select.js.map +1 -0
- package/dist/data-table.d.ts +77 -0
- package/dist/data-table.js +30 -0
- package/dist/data-table.js.map +1 -0
- package/dist/deal-pipeline.d.ts +46 -0
- package/dist/deal-pipeline.js +25 -0
- package/dist/deal-pipeline.js.map +1 -0
- package/dist/document-signoff.d.ts +45 -0
- package/dist/document-signoff.js +21 -0
- package/dist/document-signoff.js.map +1 -0
- package/dist/evidence-list.d.ts +35 -0
- package/dist/evidence-list.js +21 -0
- package/dist/evidence-list.js.map +1 -0
- package/dist/exception-banner.d.ts +15 -0
- package/dist/exception-banner.js +10 -0
- package/dist/exception-banner.js.map +1 -0
- package/dist/expense-claim.d.ts +43 -0
- package/dist/expense-claim.js +31 -0
- package/dist/expense-claim.js.map +1 -0
- package/dist/financial-date-field.d.ts +27 -0
- package/dist/financial-date-field.js +17 -0
- package/dist/financial-date-field.js.map +1 -0
- package/dist/fixed-asset-register.d.ts +59 -0
- package/dist/fixed-asset-register.js +31 -0
- package/dist/fixed-asset-register.js.map +1 -0
- package/dist/forecast-chart.d.ts +38 -0
- package/dist/forecast-chart.js +19 -0
- package/dist/forecast-chart.js.map +1 -0
- package/dist/form-props-Ct7zeZBH.d.ts +25 -0
- package/dist/funnel-chart.d.ts +27 -0
- package/dist/funnel-chart.js +17 -0
- package/dist/funnel-chart.js.map +1 -0
- package/dist/iban-input.d.ts +27 -0
- package/dist/iban-input.js +16 -0
- package/dist/iban-input.js.map +1 -0
- package/dist/index.d.ts +644 -0
- package/dist/index.js +1082 -0
- package/dist/index.js.map +1 -0
- package/dist/invoice-editor.d.ts +38 -0
- package/dist/invoice-editor.js +26 -0
- package/dist/invoice-editor.js.map +1 -0
- package/dist/invoice-number-input.d.ts +25 -0
- package/dist/invoice-number-input.js +17 -0
- package/dist/invoice-number-input.js.map +1 -0
- package/dist/kpi-stat.d.ts +34 -0
- package/dist/kpi-stat.js +15 -0
- package/dist/kpi-stat.js.map +1 -0
- package/dist/ledger-table.d.ts +85 -0
- package/dist/ledger-table.js +41 -0
- package/dist/ledger-table.js.map +1 -0
- package/dist/locale.d.ts +22 -0
- package/dist/locale.js +13 -0
- package/dist/locale.js.map +1 -0
- package/dist/money-amount.d.ts +15 -0
- package/dist/money-amount.js +10 -0
- package/dist/money-amount.js.map +1 -0
- package/dist/organization-number-input.d.ts +25 -0
- package/dist/organization-number-input.js +17 -0
- package/dist/organization-number-input.js.map +1 -0
- package/dist/payment-batch.d.ts +58 -0
- package/dist/payment-batch.js +31 -0
- package/dist/payment-batch.js.map +1 -0
- package/dist/payment-confirm.d.ts +19 -0
- package/dist/payment-confirm.js +11 -0
- package/dist/payment-confirm.js.map +1 -0
- package/dist/payment-reference-input.d.ts +27 -0
- package/dist/payment-reference-input.js +17 -0
- package/dist/payment-reference-input.js.map +1 -0
- package/dist/period-lock.d.ts +28 -0
- package/dist/period-lock.js +18 -0
- package/dist/period-lock.js.map +1 -0
- package/dist/recurring-revenue.d.ts +37 -0
- package/dist/recurring-revenue.js +18 -0
- package/dist/recurring-revenue.js.map +1 -0
- package/dist/sca-prompt.d.ts +16 -0
- package/dist/sca-prompt.js +10 -0
- package/dist/sca-prompt.js.map +1 -0
- package/dist/sheet-stack.d.ts +34 -0
- package/dist/sheet-stack.js +20 -0
- package/dist/sheet-stack.js.map +1 -0
- package/dist/stage-duration.d.ts +33 -0
- package/dist/stage-duration.js +16 -0
- package/dist/stage-duration.js.map +1 -0
- package/dist/supplier-invoice-inbox.d.ts +66 -0
- package/dist/supplier-invoice-inbox.js +38 -0
- package/dist/supplier-invoice-inbox.js.map +1 -0
- package/dist/tax-code-select.d.ts +33 -0
- package/dist/tax-code-select.js +23 -0
- package/dist/tax-code-select.js.map +1 -0
- package/dist/text-link.d.ts +33 -0
- package/dist/text-link.js +13 -0
- package/dist/text-link.js.map +1 -0
- package/dist/toasts.d.ts +53 -0
- package/dist/toasts.js +17 -0
- package/dist/toasts.js.map +1 -0
- package/dist/trend-chart.d.ts +43 -0
- package/dist/trend-chart.js +19 -0
- package/dist/trend-chart.js.map +1 -0
- package/dist/vat-return.d.ts +54 -0
- package/dist/vat-return.js +23 -0
- package/dist/vat-return.js.map +1 -0
- package/dist/voucher-composer.d.ts +69 -0
- package/dist/voucher-composer.js +15 -0
- package/dist/voucher-composer.js.map +1 -0
- package/dist/voucher-lines.d.ts +11 -0
- package/dist/voucher-lines.js +10 -0
- package/dist/voucher-lines.js.map +1 -0
- package/docs/llms.txt +214 -0
- package/package.json +308 -3
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useWorkflowCopy
|
|
4
|
+
} from "./chunk-U7NPK4WO.js";
|
|
5
|
+
import {
|
|
6
|
+
useAccessFor
|
|
7
|
+
} from "./chunk-K72VT6RJ.js";
|
|
8
|
+
import {
|
|
9
|
+
useSay
|
|
10
|
+
} from "./chunk-GVP2N3K6.js";
|
|
11
|
+
|
|
12
|
+
// src/close-checklist.tsx
|
|
13
|
+
import { closeBlockers } from "@booki-aui/core/close";
|
|
14
|
+
import { createParts } from "@ui-sdk/react/primitive";
|
|
15
|
+
import { closeChecklist } from "@booki-aui/primitives/close-checklist";
|
|
16
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
17
|
+
var TAGS = {
|
|
18
|
+
root: "div",
|
|
19
|
+
complete: "button",
|
|
20
|
+
signOff: "button",
|
|
21
|
+
reopen: "button"
|
|
22
|
+
};
|
|
23
|
+
var parts = createParts(closeChecklist, TAGS);
|
|
24
|
+
var CloseChecklistRoot = parts.Root;
|
|
25
|
+
var CloseChecklistComplete = parts.Complete;
|
|
26
|
+
var CloseChecklistSignOff = parts.SignOff;
|
|
27
|
+
var CloseChecklistReopen = parts.Reopen;
|
|
28
|
+
function CloseChecklist({
|
|
29
|
+
tasks,
|
|
30
|
+
defaultTasks,
|
|
31
|
+
actor,
|
|
32
|
+
agentActor,
|
|
33
|
+
onTasksChange,
|
|
34
|
+
nameOf = (id) => id,
|
|
35
|
+
className,
|
|
36
|
+
"aria-label": ariaLabel
|
|
37
|
+
}) {
|
|
38
|
+
const copy = useWorkflowCopy();
|
|
39
|
+
const say = useSay();
|
|
40
|
+
const access = useAccessFor({ signOff: "close.sign-off" }, actor);
|
|
41
|
+
return /* @__PURE__ */ jsx(
|
|
42
|
+
CloseChecklistRoot,
|
|
43
|
+
{
|
|
44
|
+
tasks,
|
|
45
|
+
defaultTasks,
|
|
46
|
+
actor: access.actor,
|
|
47
|
+
denied: access.denied,
|
|
48
|
+
agentActor,
|
|
49
|
+
onTasksChange,
|
|
50
|
+
className,
|
|
51
|
+
"aria-label": ariaLabel ?? copy.closeChecklist,
|
|
52
|
+
children: (state) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
53
|
+
/* @__PURE__ */ jsxs("p", { "data-slot": "close-checklist-status", role: "status", children: [
|
|
54
|
+
state.summary.readyToClose ? copy.readyToClose : copy.notReadyToClose,
|
|
55
|
+
" \xB7 ",
|
|
56
|
+
state.summary.total - state.summary.open,
|
|
57
|
+
"/",
|
|
58
|
+
state.summary.total
|
|
59
|
+
] }),
|
|
60
|
+
/* @__PURE__ */ jsx("ul", { "data-slot": "close-checklist-tasks", children: state.tasks.map((task) => {
|
|
61
|
+
const blockers = task.status === "open" ? closeBlockers(state.tasks, task.id) : [];
|
|
62
|
+
return /* @__PURE__ */ jsxs("li", { "data-status": task.status, "data-blocked": blockers.length > 0 ? "" : void 0, children: [
|
|
63
|
+
/* @__PURE__ */ jsx("span", { "data-slot": "close-checklist-title", children: task.title }),
|
|
64
|
+
/* @__PURE__ */ jsxs("span", { "data-slot": "close-checklist-detail", children: [
|
|
65
|
+
task.status === "open" ? blockers.length > 0 ? `${copy.waitsFor}: ${blockers.map((b) => b.title).join(", ")}` : copy.open : null,
|
|
66
|
+
task.status !== "open" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
67
|
+
copy.done,
|
|
68
|
+
task.doneBy ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
69
|
+
" ",
|
|
70
|
+
copy.doneBy,
|
|
71
|
+
" ",
|
|
72
|
+
nameOf(task.doneBy)
|
|
73
|
+
] }) : null,
|
|
74
|
+
task.status === "signed" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
75
|
+
" ",
|
|
76
|
+
"\xB7 ",
|
|
77
|
+
copy.signed,
|
|
78
|
+
task.signedBy ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
79
|
+
" ",
|
|
80
|
+
copy.doneBy,
|
|
81
|
+
" ",
|
|
82
|
+
nameOf(task.signedBy)
|
|
83
|
+
] }) : null
|
|
84
|
+
] }) : null
|
|
85
|
+
] }) : null
|
|
86
|
+
] }),
|
|
87
|
+
/* @__PURE__ */ jsxs("span", { "data-slot": "close-checklist-actions", children: [
|
|
88
|
+
task.status === "open" ? /* @__PURE__ */ jsx(
|
|
89
|
+
CloseChecklistComplete,
|
|
90
|
+
{
|
|
91
|
+
value: task.id,
|
|
92
|
+
disabled: blockers.length > 0,
|
|
93
|
+
"aria-label": `${copy.markDone}: ${task.title}`,
|
|
94
|
+
children: copy.markDone
|
|
95
|
+
}
|
|
96
|
+
) : null,
|
|
97
|
+
task.status === "done" && task.needsSignOff ? /* @__PURE__ */ jsx(CloseChecklistSignOff, { value: task.id, "aria-label": `${copy.signOff}: ${task.title}`, children: copy.signOff }) : null,
|
|
98
|
+
task.status !== "open" ? /* @__PURE__ */ jsx(CloseChecklistReopen, { value: task.id, "aria-label": `${copy.reopen}: ${task.title}`, children: copy.reopen }) : null
|
|
99
|
+
] })
|
|
100
|
+
] }, task.id);
|
|
101
|
+
}) }),
|
|
102
|
+
state.refusal ? /* @__PURE__ */ jsx("p", { "data-slot": "close-checklist-error", role: "alert", children: say(state.refusal) }) : null
|
|
103
|
+
] })
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export {
|
|
109
|
+
closeChecklist,
|
|
110
|
+
CloseChecklistRoot,
|
|
111
|
+
CloseChecklistComplete,
|
|
112
|
+
CloseChecklistSignOff,
|
|
113
|
+
CloseChecklistReopen,
|
|
114
|
+
CloseChecklist
|
|
115
|
+
};
|
|
116
|
+
//# sourceMappingURL=chunk-F3C77WLR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/close-checklist.tsx"],"sourcesContent":["import { closeBlockers, type CloseSummary, type CloseTask } from \"@booki-aui/core/close\";\nimport type { BookiChangeDetails } from \"./change-details.js\";\nimport { createParts, type Parts } from \"@ui-sdk/react/primitive\";\nimport type { ReactNode } from \"react\";\nimport { useAccessFor } from \"./access.js\";\nimport { useWorkflowCopy } from \"./workflow-copy.js\";\nimport { useSay } from \"./say.js\";\nimport { closeChecklist } from \"@booki-aui/primitives/close-checklist\";\n\nconst TAGS = {\n root: \"div\",\n complete: \"button\",\n signOff: \"button\",\n reopen: \"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 closeChecklist, typeof TAGS> = createParts(closeChecklist, TAGS);\nconst CloseChecklistRoot: (typeof parts)[\"Root\"] = parts.Root;\nconst CloseChecklistComplete: (typeof parts)[\"Complete\"] = parts.Complete;\nconst CloseChecklistSignOff: (typeof parts)[\"SignOff\"] = parts.SignOff;\nconst CloseChecklistReopen: (typeof parts)[\"Reopen\"] = parts.Reopen;\n\nexport type CloseChecklistProps = {\n tasks?: CloseTask[];\n defaultTasks?: CloseTask[];\n actor?: string;\n agentActor?: string;\n onTasksChange?: (tasks: CloseTask[], details: BookiChangeDetails) => void;\n nameOf?: (id: string) => ReactNode;\n className?: string;\n \"aria-label\"?: string;\n};\n\ntype RootState = { tasks: CloseTask[]; refusal: string; summary: CloseSummary };\n\n/** Composed checklist: every task, what it waits for, who did it, and its buttons. */\nfunction CloseChecklist({\n tasks,\n defaultTasks,\n actor,\n agentActor,\n onTasksChange,\n nameOf = (id) => id,\n className,\n \"aria-label\": ariaLabel,\n}: CloseChecklistProps) {\n const copy = useWorkflowCopy();\n const say = useSay();\n const access = useAccessFor({ signOff: \"close.sign-off\" }, actor);\n return (\n <CloseChecklistRoot\n tasks={tasks}\n defaultTasks={defaultTasks}\n actor={access.actor}\n denied={access.denied}\n agentActor={agentActor}\n onTasksChange={onTasksChange}\n className={className}\n aria-label={ariaLabel ?? copy.closeChecklist}\n >\n {(state: RootState) => (\n <>\n <p data-slot=\"close-checklist-status\" role=\"status\">\n {state.summary.readyToClose ? copy.readyToClose : copy.notReadyToClose}\n {\" · \"}\n {state.summary.total - state.summary.open}/{state.summary.total}\n </p>\n <ul data-slot=\"close-checklist-tasks\">\n {state.tasks.map((task) => {\n const blockers = task.status === \"open\" ? closeBlockers(state.tasks, task.id) : [];\n return (\n <li key={task.id} data-status={task.status} data-blocked={blockers.length > 0 ? \"\" : undefined}>\n <span data-slot=\"close-checklist-title\">{task.title}</span>\n <span data-slot=\"close-checklist-detail\">\n {task.status === \"open\"\n ? blockers.length > 0\n ? `${copy.waitsFor}: ${blockers.map((b) => b.title).join(\", \")}`\n : copy.open\n : null}\n {task.status !== \"open\" ? (\n <>\n {copy.done}\n {task.doneBy ? (\n <>\n {\" \"}\n {copy.doneBy} {nameOf(task.doneBy)}\n </>\n ) : null}\n {task.status === \"signed\" ? (\n <>\n {\" \"}\n · {copy.signed}\n {task.signedBy ? (\n <>\n {\" \"}\n {copy.doneBy} {nameOf(task.signedBy)}\n </>\n ) : null}\n </>\n ) : null}\n </>\n ) : null}\n </span>\n <span data-slot=\"close-checklist-actions\">\n {task.status === \"open\" ? (\n <CloseChecklistComplete\n value={task.id}\n disabled={blockers.length > 0}\n aria-label={`${copy.markDone}: ${task.title}`}\n >\n {copy.markDone}\n </CloseChecklistComplete>\n ) : null}\n {task.status === \"done\" && task.needsSignOff ? (\n <CloseChecklistSignOff value={task.id} aria-label={`${copy.signOff}: ${task.title}`}>\n {copy.signOff}\n </CloseChecklistSignOff>\n ) : null}\n {task.status !== \"open\" ? (\n <CloseChecklistReopen value={task.id} aria-label={`${copy.reopen}: ${task.title}`}>\n {copy.reopen}\n </CloseChecklistReopen>\n ) : null}\n </span>\n </li>\n );\n })}\n </ul>\n {state.refusal ? (\n <p data-slot=\"close-checklist-error\" role=\"alert\">\n {say(state.refusal)}\n </p>\n ) : null}\n </>\n )}\n </CloseChecklistRoot>\n );\n}\n\nexport {\n CloseChecklist,\n CloseChecklistComplete,\n CloseChecklistReopen,\n CloseChecklistRoot,\n CloseChecklistSignOff,\n closeChecklist,\n};\nexport type { CloseTask };\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,qBAAwD;AAEjE,SAAS,mBAA+B;AAKxC,SAAS,sBAAsB;AAuDrB,SAqBgB,UAXR,KAVR;AArDV,IAAM,OAAO;AAAA,EACX,MAAM;AAAA,EACN,UAAU;AAAA,EACV,SAAS;AAAA,EACT,QAAQ;AACV;AAEA,IAAM,QAAmD,YAAY,gBAAgB,IAAI;AACzF,IAAM,qBAA6C,MAAM;AACzD,IAAM,yBAAqD,MAAM;AACjE,IAAM,wBAAmD,MAAM;AAC/D,IAAM,uBAAiD,MAAM;AAgB7D,SAAS,eAAe;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS,CAAC,OAAO;AAAA,EACjB;AAAA,EACA,cAAc;AAChB,GAAwB;AACtB,QAAM,OAAO,gBAAgB;AAC7B,QAAM,MAAM,OAAO;AACnB,QAAM,SAAS,aAAa,EAAE,SAAS,iBAAiB,GAAG,KAAK;AAChE,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA,OAAO,OAAO;AAAA,MACd,QAAQ,OAAO;AAAA,MACf;AAAA,MACA;AAAA,MACA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AAU,SAAS,SAAS;AAAA,kBAC5B,cAAY,GAAG,KAAK,QAAQ,KAAK,KAAK,KAAK;AAAA,kBAE1C,eAAK;AAAA;AAAA,cACR,IACE;AAAA,cACH,KAAK,WAAW,UAAU,KAAK,eAC9B,oBAAC,yBAAsB,OAAO,KAAK,IAAI,cAAY,GAAG,KAAK,OAAO,KAAK,KAAK,KAAK,IAC9E,eAAK,SACR,IACE;AAAA,cACH,KAAK,WAAW,SACf,oBAAC,wBAAqB,OAAO,KAAK,IAAI,cAAY,GAAG,KAAK,MAAM,KAAK,KAAK,KAAK,IAC5E,eAAK,QACR,IACE;AAAA,eACN;AAAA,eApDO,KAAK,EAqDd;AAAA,QAEJ,CAAC,GACH;AAAA,QACC,MAAM,UACL,oBAAC,OAAE,aAAU,yBAAwB,MAAK,SACvC,cAAI,MAAM,OAAO,GACpB,IACE;AAAA,SACN;AAAA;AAAA,EAEJ;AAEJ;","names":[]}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
FormValue
|
|
4
|
+
} from "./chunk-OYERLEER.js";
|
|
5
|
+
import {
|
|
6
|
+
useBookiLocaleOptional
|
|
7
|
+
} from "./chunk-GVP2N3K6.js";
|
|
8
|
+
|
|
9
|
+
// src/payment-reference-input.tsx
|
|
10
|
+
import { isValidKid } from "@booki-aui/core/kid";
|
|
11
|
+
import { Field, FieldDescription, FieldError, FieldLabel } from "@ui-sdk/react/field";
|
|
12
|
+
import { createParts } from "@ui-sdk/react/primitive";
|
|
13
|
+
import { paymentReference } from "@booki-aui/primitives/payment-reference-input";
|
|
14
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
+
var TAGS = {
|
|
16
|
+
root: "div",
|
|
17
|
+
input: "input"
|
|
18
|
+
};
|
|
19
|
+
var parts = createParts(paymentReference, TAGS);
|
|
20
|
+
var PaymentReferenceRoot = parts.Root;
|
|
21
|
+
var PaymentReferenceField = parts.Input;
|
|
22
|
+
function kidInvalid(kind, value) {
|
|
23
|
+
return kind === "kid" && value.length >= 4 && !isValidKid(value, 10);
|
|
24
|
+
}
|
|
25
|
+
function PaymentReferenceInput({
|
|
26
|
+
value,
|
|
27
|
+
defaultValue,
|
|
28
|
+
onValueChange,
|
|
29
|
+
secretReference,
|
|
30
|
+
required,
|
|
31
|
+
name,
|
|
32
|
+
id,
|
|
33
|
+
disabled,
|
|
34
|
+
readOnly,
|
|
35
|
+
className,
|
|
36
|
+
...props
|
|
37
|
+
}) {
|
|
38
|
+
const { profile } = useBookiLocaleOptional();
|
|
39
|
+
const kind = profile.paymentReference.kind;
|
|
40
|
+
return /* @__PURE__ */ jsx(
|
|
41
|
+
PaymentReferenceRoot,
|
|
42
|
+
{
|
|
43
|
+
kind,
|
|
44
|
+
...value !== void 0 ? { value } : { defaultValue },
|
|
45
|
+
label: profile.paymentReference.label,
|
|
46
|
+
description: profile.paymentReference.description,
|
|
47
|
+
onValueChange,
|
|
48
|
+
secretReference,
|
|
49
|
+
disabled,
|
|
50
|
+
readOnly,
|
|
51
|
+
className,
|
|
52
|
+
"aria-label": profile.paymentReference.label,
|
|
53
|
+
...props,
|
|
54
|
+
children: (state) => {
|
|
55
|
+
const invalid = kidInvalid(state.kind, state.value);
|
|
56
|
+
return /* @__PURE__ */ jsxs(Field, { invalid, children: [
|
|
57
|
+
/* @__PURE__ */ jsx(FieldLabel, { children: profile.paymentReference.label }),
|
|
58
|
+
/* @__PURE__ */ jsxs(FieldDescription, { children: [
|
|
59
|
+
profile.paymentReference.description,
|
|
60
|
+
kind === "kid" ? " (mod 10)" : ""
|
|
61
|
+
] }),
|
|
62
|
+
/* @__PURE__ */ jsx(
|
|
63
|
+
PaymentReferenceField,
|
|
64
|
+
{
|
|
65
|
+
id,
|
|
66
|
+
required,
|
|
67
|
+
placeholder: kind === "kid" ? "12345678903" : "INV-1001"
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
invalid ? /* @__PURE__ */ jsx(FieldError, { children: "Ugyldig KID" }) : null,
|
|
71
|
+
/* @__PURE__ */ jsx(FormValue, { name, value: state.value, disabled })
|
|
72
|
+
] });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export {
|
|
79
|
+
paymentReference,
|
|
80
|
+
PaymentReferenceRoot,
|
|
81
|
+
PaymentReferenceField,
|
|
82
|
+
PaymentReferenceInput
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=chunk-FBV7BFEQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/payment-reference-input.tsx"],"sourcesContent":["import { isValidKid } from \"@booki-aui/core/kid\";\nimport { Field, FieldDescription, FieldError, FieldLabel } from \"@ui-sdk/react/field\";\nimport { createParts, type Parts } from \"@ui-sdk/react/primitive\";\nimport type { ComponentProps } from \"react\";\nimport { FormValue, type BookiFormProps } from \"./form-props.js\";\nimport { useBookiLocaleOptional } from \"./locale.js\";\nimport { type RefKind, paymentReference } from \"@booki-aui/primitives/payment-reference-input\";\n\nconst TAGS = {\n root: \"div\",\n input: \"input\",\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 paymentReference, typeof TAGS> = createParts(paymentReference, TAGS);\n\nconst PaymentReferenceRoot: (typeof parts)[\"Root\"] = parts.Root;\nconst PaymentReferenceField: (typeof parts)[\"Input\"] = parts.Input;\n\nexport type PaymentReferenceInputProps = {\n /** Controlled value. Omit it (and use `defaultValue`) to let the field hold its own state. */\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n /** A memo or invoice reference reads \"[redacted]\" to an agent too. A KID always does. */\n secretReference?: boolean;\n required?: boolean;\n className?: string;\n} & Omit<BookiFormProps, \"required\"> &\n Omit<ComponentProps<\"div\">, \"onChange\" | \"defaultValue\" | \"children\" | \"id\">;\n\nfunction kidInvalid(kind: RefKind, value: string): boolean {\n return kind === \"kid\" && value.length >= 4 && !isValidKid(value, 10);\n}\n\nfunction PaymentReferenceInput({\n value,\n defaultValue,\n onValueChange,\n secretReference,\n required,\n name,\n id,\n disabled,\n readOnly,\n className,\n ...props\n}: PaymentReferenceInputProps) {\n const { profile } = useBookiLocaleOptional();\n const kind = profile.paymentReference.kind;\n\n return (\n <PaymentReferenceRoot\n kind={kind}\n {...(value !== undefined ? { value } : { defaultValue })}\n label={profile.paymentReference.label}\n description={profile.paymentReference.description}\n onValueChange={onValueChange}\n secretReference={secretReference}\n disabled={disabled}\n readOnly={readOnly}\n className={className}\n aria-label={profile.paymentReference.label}\n {...props}\n >\n {(state: { kind: RefKind; value: string }) => {\n // Invalid display follows the primitive's state, so it works\n // uncontrolled and for agent writes, not only for the prop.\n const invalid = kidInvalid(state.kind, state.value);\n return (\n <Field invalid={invalid}>\n <FieldLabel>{profile.paymentReference.label}</FieldLabel>\n <FieldDescription>\n {profile.paymentReference.description}\n {kind === \"kid\" ? \" (mod 10)\" : \"\"}\n </FieldDescription>\n <PaymentReferenceField\n id={id}\n required={required}\n placeholder={kind === \"kid\" ? \"12345678903\" : \"INV-1001\"}\n />\n {invalid ? <FieldError>Ugyldig KID</FieldError> : null}\n <FormValue name={name} value={state.value} disabled={disabled} />\n </Field>\n );\n }}\n </PaymentReferenceRoot>\n );\n}\n\nexport { PaymentReferenceInput, PaymentReferenceRoot, PaymentReferenceField, paymentReference };\n"],"mappings":";;;;;;;;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,OAAO,kBAAkB,YAAY,kBAAkB;AAChE,SAAS,mBAA+B;AAIxC,SAAuB,wBAAwB;AAgEnC,cACA,YADA;AA9DZ,IAAM,OAAO;AAAA,EACX,MAAM;AAAA,EACN,OAAO;AACT;AAEA,IAAM,QAAqD,YAAY,kBAAkB,IAAI;AAE7F,IAAM,uBAA+C,MAAM;AAC3D,IAAM,wBAAiD,MAAM;AAc7D,SAAS,WAAW,MAAe,OAAwB;AACzD,SAAO,SAAS,SAAS,MAAM,UAAU,KAAK,CAAC,WAAW,OAAO,EAAE;AACrE;AAEA,SAAS,sBAAsB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAA+B;AAC7B,QAAM,EAAE,QAAQ,IAAI,uBAAuB;AAC3C,QAAM,OAAO,QAAQ,iBAAiB;AAEtC,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACC,GAAI,UAAU,SAAY,EAAE,MAAM,IAAI,EAAE,aAAa;AAAA,MACtD,OAAO,QAAQ,iBAAiB;AAAA,MAChC,aAAa,QAAQ,iBAAiB;AAAA,MACtC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAY,QAAQ,iBAAiB;AAAA,MACpC,GAAG;AAAA,MAEH,WAAC,UAA4C;AAG5C,cAAM,UAAU,WAAW,MAAM,MAAM,MAAM,KAAK;AAClD,eACE,qBAAC,SAAM,SACL;AAAA,8BAAC,cAAY,kBAAQ,iBAAiB,OAAM;AAAA,UAC5C,qBAAC,oBACE;AAAA,oBAAQ,iBAAiB;AAAA,YACzB,SAAS,QAAQ,cAAc;AAAA,aAClC;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACC;AAAA,cACA;AAAA,cACA,aAAa,SAAS,QAAQ,gBAAgB;AAAA;AAAA,UAChD;AAAA,UACC,UAAU,oBAAC,cAAW,yBAAW,IAAgB;AAAA,UAClD,oBAAC,aAAU,MAAY,OAAO,MAAM,OAAO,UAAoB;AAAA,WACjE;AAAA,MAEJ;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/locale.tsx
|
|
4
|
+
import { getBookiProfile } from "@booki-aui/core/locale";
|
|
5
|
+
import { createContext, useCallback, useContext, useEffect as useEffect2, useMemo, useState as useState2 } from "react";
|
|
6
|
+
|
|
7
|
+
// src/say.ts
|
|
8
|
+
import { useEffect, useState } from "react";
|
|
9
|
+
var loaded = null;
|
|
10
|
+
var loading = null;
|
|
11
|
+
function loadLocalize() {
|
|
12
|
+
loading ??= import("@booki-aui/core/messages").then((module) => loaded = module.localize);
|
|
13
|
+
return loading;
|
|
14
|
+
}
|
|
15
|
+
function preloadNorwegian() {
|
|
16
|
+
return loadLocalize();
|
|
17
|
+
}
|
|
18
|
+
function useSay() {
|
|
19
|
+
const { country } = useBookiLocaleOptional();
|
|
20
|
+
const norwegian = country === "NO";
|
|
21
|
+
const [localize, setLocalize] = useState(() => loaded);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (!norwegian || localize) return;
|
|
24
|
+
let live = true;
|
|
25
|
+
void loadLocalize().then((next) => {
|
|
26
|
+
if (live) setLocalize(() => next);
|
|
27
|
+
});
|
|
28
|
+
return () => {
|
|
29
|
+
live = false;
|
|
30
|
+
};
|
|
31
|
+
}, [norwegian, localize]);
|
|
32
|
+
return (text) => norwegian && localize ? localize(text, "nb") : text;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// src/locale.tsx
|
|
36
|
+
import { jsx } from "react/jsx-runtime";
|
|
37
|
+
var BookiLocaleContext = createContext(null);
|
|
38
|
+
function BookiLocaleProvider({
|
|
39
|
+
children,
|
|
40
|
+
defaultCountry = "NO",
|
|
41
|
+
country: controlled,
|
|
42
|
+
onCountryChange,
|
|
43
|
+
profiles
|
|
44
|
+
}) {
|
|
45
|
+
const [uncontrolled, setUncontrolled] = useState2(defaultCountry);
|
|
46
|
+
const country = controlled ?? uncontrolled;
|
|
47
|
+
useEffect2(() => {
|
|
48
|
+
if (country === "NO") void preloadNorwegian();
|
|
49
|
+
}, [country]);
|
|
50
|
+
const setCountry = useCallback(
|
|
51
|
+
(next) => {
|
|
52
|
+
if (controlled === void 0) setUncontrolled(next);
|
|
53
|
+
onCountryChange?.(next);
|
|
54
|
+
},
|
|
55
|
+
[controlled, onCountryChange]
|
|
56
|
+
);
|
|
57
|
+
const value = useMemo(
|
|
58
|
+
() => ({
|
|
59
|
+
country,
|
|
60
|
+
profile: getBookiProfile(country, profiles),
|
|
61
|
+
setCountry
|
|
62
|
+
}),
|
|
63
|
+
[country, setCountry, profiles]
|
|
64
|
+
);
|
|
65
|
+
return /* @__PURE__ */ jsx(BookiLocaleContext.Provider, { value, children });
|
|
66
|
+
}
|
|
67
|
+
function useBookiLocale() {
|
|
68
|
+
const ctx = useContext(BookiLocaleContext);
|
|
69
|
+
if (!ctx) {
|
|
70
|
+
throw new Error("useBookiLocale must be used within BookiLocaleProvider");
|
|
71
|
+
}
|
|
72
|
+
return ctx;
|
|
73
|
+
}
|
|
74
|
+
function useBookiLocaleOptional() {
|
|
75
|
+
const ctx = useContext(BookiLocaleContext);
|
|
76
|
+
return ctx ?? {
|
|
77
|
+
country: "NO",
|
|
78
|
+
profile: getBookiProfile("NO"),
|
|
79
|
+
setCountry: () => void 0
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export {
|
|
84
|
+
useSay,
|
|
85
|
+
BookiLocaleProvider,
|
|
86
|
+
useBookiLocale,
|
|
87
|
+
useBookiLocaleOptional
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=chunk-GVP2N3K6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/locale.tsx","../src/say.ts"],"sourcesContent":["import { getBookiProfile, type CountryCode, type BookiLocaleProfile } from \"@booki-aui/core/locale\";\nimport { createContext, useCallback, useContext, useEffect, useMemo, useState, type ReactNode } from \"react\";\nimport { preloadNorwegian } from \"./say.js\";\n\nexport type BookiLocaleContextValue = {\n country: CountryCode;\n profile: BookiLocaleProfile;\n setCountry: (country: CountryCode) => void;\n};\n\nconst BookiLocaleContext = createContext<BookiLocaleContextValue | null>(null);\n\nexport type BookiLocaleProviderProps = {\n children: ReactNode;\n defaultCountry?: CountryCode;\n country?: CountryCode;\n onCountryChange?: (country: CountryCode) => void;\n /** Profiles for countries Booki does not ship, by code. See `defineProfile`. */\n profiles?: Record<string, BookiLocaleProfile>;\n};\n\nfunction BookiLocaleProvider({\n children,\n defaultCountry = \"NO\",\n country: controlled,\n onCountryChange,\n profiles,\n}: BookiLocaleProviderProps) {\n const [uncontrolled, setUncontrolled] = useState<CountryCode>(defaultCountry);\n const country = controlled ?? uncontrolled;\n // Norwegian refusals read from a catalogue fetched on demand: start it now.\n useEffect(() => {\n if (country === \"NO\") void preloadNorwegian();\n }, [country]);\n\n const setCountry = useCallback(\n (next: CountryCode) => {\n if (controlled === undefined) setUncontrolled(next);\n onCountryChange?.(next);\n },\n [controlled, onCountryChange],\n );\n\n const value = useMemo<BookiLocaleContextValue>(\n () => ({\n country,\n profile: getBookiProfile(country, profiles),\n setCountry,\n }),\n [country, setCountry, profiles],\n );\n\n return <BookiLocaleContext.Provider value={value}>{children}</BookiLocaleContext.Provider>;\n}\n\nfunction useBookiLocale(): BookiLocaleContextValue {\n const ctx = useContext(BookiLocaleContext);\n if (!ctx) {\n throw new Error(\"useBookiLocale must be used within BookiLocaleProvider\");\n }\n return ctx;\n}\n\nfunction useBookiLocaleOptional(): BookiLocaleContextValue {\n const ctx = useContext(BookiLocaleContext);\n return (\n ctx ?? {\n country: \"NO\",\n profile: getBookiProfile(\"NO\"),\n setCountry: () => undefined,\n }\n );\n}\n\nexport { BookiLocaleProvider, useBookiLocale, useBookiLocaleOptional };\n","import { useEffect, useState } from \"react\";\nimport { useBookiLocaleOptional } from \"./locale.js\";\n\ntype Localize = typeof import(\"@booki-aui/core/messages\").localize;\n\n// The Norwegian catalogue loads the first time a Norwegian screen needs it, so\n// an English page never downloads it. English needs no catalogue: core's\n// sentences are English already.\nlet loaded: Localize | null = null;\nlet loading: Promise<Localize> | null = null;\n\nfunction loadLocalize(): Promise<Localize> {\n loading ??= import(\"@booki-aui/core/messages\").then((module) => (loaded = module.localize));\n return loading;\n}\n\n/** Starts loading the Norwegian catalogue ahead of the first refusal. */\nexport function preloadNorwegian(): Promise<unknown> {\n return loadLocalize();\n}\n\n/**\n * Turns a refusal or an issue from `@booki-aui/core` into the person's language.\n * State keeps the English sentence, which is what an agent reads; only what\n * the screen shows is translated. Text it does not know comes back unchanged.\n * In Norwegian, the first render after the page opens may show English for\n * the moment the catalogue takes to load.\n */\nexport function useSay(): (text: string) => string {\n const { country } = useBookiLocaleOptional();\n const norwegian = country === \"NO\";\n const [localize, setLocalize] = useState<Localize | null>(() => loaded);\n useEffect(() => {\n if (!norwegian || localize) return;\n let live = true;\n void loadLocalize().then((next) => {\n if (live) setLocalize(() => next);\n });\n return () => {\n live = false;\n };\n }, [norwegian, localize]);\n return (text: string) => (norwegian && localize ? localize(text, \"nb\") : text);\n}\n"],"mappings":";;;AAAA,SAAS,uBAAkE;AAC3E,SAAS,eAAe,aAAa,YAAY,aAAAA,YAAW,SAAS,YAAAC,iBAAgC;;;ACDrG,SAAS,WAAW,gBAAgB;AAQpC,IAAI,SAA0B;AAC9B,IAAI,UAAoC;AAExC,SAAS,eAAkC;AACzC,cAAY,OAAO,0BAA0B,EAAE,KAAK,CAAC,WAAY,SAAS,OAAO,QAAS;AAC1F,SAAO;AACT;AAGO,SAAS,mBAAqC;AACnD,SAAO,aAAa;AACtB;AASO,SAAS,SAAmC;AACjD,QAAM,EAAE,QAAQ,IAAI,uBAAuB;AAC3C,QAAM,YAAY,YAAY;AAC9B,QAAM,CAAC,UAAU,WAAW,IAAI,SAA0B,MAAM,MAAM;AACtE,YAAU,MAAM;AACd,QAAI,CAAC,aAAa,SAAU;AAC5B,QAAI,OAAO;AACX,SAAK,aAAa,EAAE,KAAK,CAAC,SAAS;AACjC,UAAI,KAAM,aAAY,MAAM,IAAI;AAAA,IAClC,CAAC;AACD,WAAO,MAAM;AACX,aAAO;AAAA,IACT;AAAA,EACF,GAAG,CAAC,WAAW,QAAQ,CAAC;AACxB,SAAO,CAAC,SAAkB,aAAa,WAAW,SAAS,MAAM,IAAI,IAAI;AAC3E;;;ADSS;AA1CT,IAAM,qBAAqB,cAA8C,IAAI;AAW7E,SAAS,oBAAoB;AAAA,EAC3B;AAAA,EACA,iBAAiB;AAAA,EACjB,SAAS;AAAA,EACT;AAAA,EACA;AACF,GAA6B;AAC3B,QAAM,CAAC,cAAc,eAAe,IAAIC,UAAsB,cAAc;AAC5E,QAAM,UAAU,cAAc;AAE9B,EAAAC,WAAU,MAAM;AACd,QAAI,YAAY,KAAM,MAAK,iBAAiB;AAAA,EAC9C,GAAG,CAAC,OAAO,CAAC;AAEZ,QAAM,aAAa;AAAA,IACjB,CAAC,SAAsB;AACrB,UAAI,eAAe,OAAW,iBAAgB,IAAI;AAClD,wBAAkB,IAAI;AAAA,IACxB;AAAA,IACA,CAAC,YAAY,eAAe;AAAA,EAC9B;AAEA,QAAM,QAAQ;AAAA,IACZ,OAAO;AAAA,MACL;AAAA,MACA,SAAS,gBAAgB,SAAS,QAAQ;AAAA,MAC1C;AAAA,IACF;AAAA,IACA,CAAC,SAAS,YAAY,QAAQ;AAAA,EAChC;AAEA,SAAO,oBAAC,mBAAmB,UAAnB,EAA4B,OAAe,UAAS;AAC9D;AAEA,SAAS,iBAA0C;AACjD,QAAM,MAAM,WAAW,kBAAkB;AACzC,MAAI,CAAC,KAAK;AACR,UAAM,IAAI,MAAM,wDAAwD;AAAA,EAC1E;AACA,SAAO;AACT;AAEA,SAAS,yBAAkD;AACzD,QAAM,MAAM,WAAW,kBAAkB;AACzC,SACE,OAAO;AAAA,IACL,SAAS;AAAA,IACT,SAAS,gBAAgB,IAAI;AAAA,IAC7B,YAAY,MAAM;AAAA,EACpB;AAEJ;","names":["useEffect","useState","useState","useEffect"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
__reExport
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=chunk-HKYEHBQT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
chart_math_exports
|
|
4
|
+
} from "./chunk-WDME4U42.js";
|
|
5
|
+
import {
|
|
6
|
+
useBookiLocaleOptional,
|
|
7
|
+
useSay
|
|
8
|
+
} from "./chunk-GVP2N3K6.js";
|
|
9
|
+
|
|
10
|
+
// src/funnel-chart.tsx
|
|
11
|
+
import { formatMoney } from "@booki-aui/core/money";
|
|
12
|
+
import { createParts } from "@ui-sdk/react/primitive";
|
|
13
|
+
import {
|
|
14
|
+
derive,
|
|
15
|
+
funnelChart
|
|
16
|
+
} from "@booki-aui/primitives/funnel-chart";
|
|
17
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
18
|
+
var TAGS = { root: "div", step: "button" };
|
|
19
|
+
var parts = createParts(funnelChart, TAGS);
|
|
20
|
+
var FunnelChartRoot = parts.Root;
|
|
21
|
+
var FunnelChartStep = parts.Step;
|
|
22
|
+
var COPY = {
|
|
23
|
+
EN: {
|
|
24
|
+
funnel: "Conversion",
|
|
25
|
+
fromStart: "of the start",
|
|
26
|
+
fromBefore: "from the step before",
|
|
27
|
+
lost: "lost",
|
|
28
|
+
biggest: "Biggest drop",
|
|
29
|
+
table: "Show as table",
|
|
30
|
+
step: "Step",
|
|
31
|
+
count: "Reached",
|
|
32
|
+
conversion: "Step conversion",
|
|
33
|
+
overall: "Overall",
|
|
34
|
+
value: "Value",
|
|
35
|
+
none: "No steps to show yet."
|
|
36
|
+
},
|
|
37
|
+
NO: {
|
|
38
|
+
funnel: "Konvertering",
|
|
39
|
+
fromStart: "av starten",
|
|
40
|
+
fromBefore: "fra steget f\xF8r",
|
|
41
|
+
lost: "tapt",
|
|
42
|
+
biggest: "St\xF8rste frafall",
|
|
43
|
+
table: "Vis som tabell",
|
|
44
|
+
step: "Steg",
|
|
45
|
+
count: "N\xE5dde",
|
|
46
|
+
conversion: "Konvertering fra steget f\xF8r",
|
|
47
|
+
overall: "Samlet",
|
|
48
|
+
value: "Verdi",
|
|
49
|
+
none: "Ingen steg \xE5 vise enn\xE5."
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
function FunnelChart({
|
|
53
|
+
steps,
|
|
54
|
+
currency,
|
|
55
|
+
drill,
|
|
56
|
+
defaultDrill,
|
|
57
|
+
onDrill,
|
|
58
|
+
title,
|
|
59
|
+
className,
|
|
60
|
+
"aria-label": ariaLabel
|
|
61
|
+
}) {
|
|
62
|
+
const { country, profile } = useBookiLocaleOptional();
|
|
63
|
+
const say = useSay();
|
|
64
|
+
const copy = COPY[country === "NO" ? "NO" : "EN"];
|
|
65
|
+
const code = currency ?? profile.currency;
|
|
66
|
+
const locale = profile.locale;
|
|
67
|
+
const count = (n) => new Intl.NumberFormat(locale).format(n);
|
|
68
|
+
const pct = (value) => (0, chart_math_exports.formatPercent)(value, locale);
|
|
69
|
+
const fmt = (minor) => formatMoney({ minor, currency: code }, { locale, trimZeroFraction: true });
|
|
70
|
+
return /* @__PURE__ */ jsx(
|
|
71
|
+
FunnelChartRoot,
|
|
72
|
+
{
|
|
73
|
+
steps,
|
|
74
|
+
currency: code,
|
|
75
|
+
drill,
|
|
76
|
+
defaultDrill,
|
|
77
|
+
onDrillChange: (next, details) => {
|
|
78
|
+
if (next !== null) onDrill?.(next, details);
|
|
79
|
+
},
|
|
80
|
+
className,
|
|
81
|
+
"aria-label": ariaLabel ?? title ?? copy.funnel,
|
|
82
|
+
children: (state) => {
|
|
83
|
+
const view = derive({ steps, currency: code }, state.drill);
|
|
84
|
+
const top = Math.max(1, view.steps[0]?.count ?? 1);
|
|
85
|
+
const biggest = view.steps.find((step) => step.id === view.biggestDropId);
|
|
86
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
87
|
+
title ? /* @__PURE__ */ jsx("h3", { "data-slot": "funnel-chart-title", children: title }) : null,
|
|
88
|
+
view.steps.length === 0 ? /* @__PURE__ */ jsx("p", { "data-slot": "funnel-chart-empty", children: copy.none }) : /* @__PURE__ */ jsx("ol", { "data-slot": "funnel-chart-steps", children: view.steps.map((step) => /* @__PURE__ */ jsxs(
|
|
89
|
+
"li",
|
|
90
|
+
{
|
|
91
|
+
"data-slot": "funnel-chart-row",
|
|
92
|
+
"data-biggest": step.id === view.biggestDropId ? "" : void 0,
|
|
93
|
+
children: [
|
|
94
|
+
/* @__PURE__ */ jsxs(
|
|
95
|
+
FunnelChartStep,
|
|
96
|
+
{
|
|
97
|
+
value: step.id,
|
|
98
|
+
"aria-label": `${step.label}: ${count(step.count)}, ${pct(step.overallConversionPct)} ${copy.fromStart}`,
|
|
99
|
+
children: [
|
|
100
|
+
/* @__PURE__ */ jsx("span", { "data-slot": "funnel-chart-label", children: step.label }),
|
|
101
|
+
/* @__PURE__ */ jsx("span", { "data-slot": "funnel-chart-track", children: /* @__PURE__ */ jsx(
|
|
102
|
+
"span",
|
|
103
|
+
{
|
|
104
|
+
"data-slot": "funnel-chart-bar",
|
|
105
|
+
style: { width: `${Math.max(2, step.count / top * 100)}%` }
|
|
106
|
+
}
|
|
107
|
+
) }),
|
|
108
|
+
/* @__PURE__ */ jsx("span", { "data-slot": "funnel-chart-count", children: count(step.count) }),
|
|
109
|
+
/* @__PURE__ */ jsx("span", { "data-slot": "funnel-chart-rate", children: pct(step.overallConversionPct) })
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
),
|
|
113
|
+
step.stepConversionPct !== null ? /* @__PURE__ */ jsxs("p", { "data-slot": "funnel-chart-between", children: [
|
|
114
|
+
pct(step.stepConversionPct),
|
|
115
|
+
" ",
|
|
116
|
+
copy.fromBefore,
|
|
117
|
+
" \xB7 ",
|
|
118
|
+
count(step.dropOff),
|
|
119
|
+
" ",
|
|
120
|
+
copy.lost
|
|
121
|
+
] }) : null
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
step.id
|
|
125
|
+
)) }),
|
|
126
|
+
biggest ? /* @__PURE__ */ jsxs("p", { "data-slot": "funnel-chart-summary", role: "status", children: [
|
|
127
|
+
copy.biggest,
|
|
128
|
+
": ",
|
|
129
|
+
biggest.label,
|
|
130
|
+
" (",
|
|
131
|
+
count(biggest.dropOff),
|
|
132
|
+
" ",
|
|
133
|
+
copy.lost,
|
|
134
|
+
")"
|
|
135
|
+
] }) : null,
|
|
136
|
+
view.issues.length ? /* @__PURE__ */ jsx("ul", { "data-slot": "funnel-chart-issues", children: view.issues.map((issue) => /* @__PURE__ */ jsx("li", { children: say(issue) }, issue)) }) : null,
|
|
137
|
+
view.steps.length ? /* @__PURE__ */ jsxs("details", { "data-slot": "funnel-chart-table", children: [
|
|
138
|
+
/* @__PURE__ */ jsx("summary", { children: copy.table }),
|
|
139
|
+
/* @__PURE__ */ jsxs("table", { children: [
|
|
140
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
141
|
+
/* @__PURE__ */ jsx("th", { scope: "col", children: copy.step }),
|
|
142
|
+
/* @__PURE__ */ jsx("th", { scope: "col", "data-align": "end", children: copy.count }),
|
|
143
|
+
/* @__PURE__ */ jsx("th", { scope: "col", "data-align": "end", children: copy.conversion }),
|
|
144
|
+
/* @__PURE__ */ jsx("th", { scope: "col", "data-align": "end", children: copy.overall }),
|
|
145
|
+
view.steps.some((step) => step.valueMinor !== void 0) ? /* @__PURE__ */ jsx("th", { scope: "col", "data-align": "end", children: copy.value }) : null
|
|
146
|
+
] }) }),
|
|
147
|
+
/* @__PURE__ */ jsx("tbody", { children: view.steps.map((step) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
148
|
+
/* @__PURE__ */ jsx("th", { scope: "row", children: step.label }),
|
|
149
|
+
/* @__PURE__ */ jsx("td", { "data-align": "end", children: count(step.count) }),
|
|
150
|
+
/* @__PURE__ */ jsx("td", { "data-align": "end", children: step.stepConversionPct === null ? "" : pct(step.stepConversionPct) }),
|
|
151
|
+
/* @__PURE__ */ jsx("td", { "data-align": "end", children: pct(step.overallConversionPct) }),
|
|
152
|
+
view.steps.some((s) => s.valueMinor !== void 0) ? /* @__PURE__ */ jsx("td", { "data-align": "end", children: step.valueMinor === void 0 ? "" : fmt(step.valueMinor) }) : null
|
|
153
|
+
] }, step.id)) })
|
|
154
|
+
] })
|
|
155
|
+
] }) : null,
|
|
156
|
+
state.refusal ? /* @__PURE__ */ jsx("p", { "data-slot": "funnel-chart-error", role: "alert", children: say(state.refusal) }) : null
|
|
157
|
+
] });
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export {
|
|
164
|
+
funnelChart,
|
|
165
|
+
FunnelChartRoot,
|
|
166
|
+
FunnelChartStep,
|
|
167
|
+
FunnelChart
|
|
168
|
+
};
|
|
169
|
+
//# sourceMappingURL=chunk-HQYIFZZT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/funnel-chart.tsx"],"sourcesContent":["import { formatMoney } from \"@booki-aui/core/money\";\nimport { createParts, type Parts } from \"@ui-sdk/react/primitive\";\nimport { formatPercent } from \"./chart-math.js\";\nimport { useBookiLocaleOptional } from \"./locale.js\";\nimport { useSay } from \"./say.js\";\nimport {\n derive,\n funnelChart,\n type Details,\n type FunnelStep,\n type FunnelStepInput,\n} from \"@booki-aui/primitives/funnel-chart\";\n\nconst TAGS = { root: \"div\", step: \"button\" } as const;\n// Typed by name, so the declarations refer to the definition instead of spelling it out per part.\nconst parts: Parts<typeof funnelChart, typeof TAGS> = createParts(funnelChart, TAGS);\nconst FunnelChartRoot: (typeof parts)[\"Root\"] = parts.Root;\nconst FunnelChartStep: (typeof parts)[\"Step\"] = parts.Step;\n\nconst COPY = {\n EN: {\n funnel: \"Conversion\",\n fromStart: \"of the start\",\n fromBefore: \"from the step before\",\n lost: \"lost\",\n biggest: \"Biggest drop\",\n table: \"Show as table\",\n step: \"Step\",\n count: \"Reached\",\n conversion: \"Step conversion\",\n overall: \"Overall\",\n value: \"Value\",\n none: \"No steps to show yet.\",\n },\n NO: {\n funnel: \"Konvertering\",\n fromStart: \"av starten\",\n fromBefore: \"fra steget før\",\n lost: \"tapt\",\n biggest: \"Største frafall\",\n table: \"Vis som tabell\",\n step: \"Steg\",\n count: \"Nådde\",\n conversion: \"Konvertering fra steget før\",\n overall: \"Samlet\",\n value: \"Verdi\",\n none: \"Ingen steg å vise ennå.\",\n },\n} as const;\n\nexport type FunnelChartProps = {\n steps: FunnelStepInput[];\n /** The currency of `valueMinor`. Defaults to the locale profile's. */\n currency?: string;\n drill?: string | null;\n defaultDrill?: string | null;\n onDrill?: (id: string, details: Details) => void;\n title?: string;\n className?: string;\n \"aria-label\"?: string;\n};\n\ntype RootState = { drill: string | null; refusal: string };\n\n/** Composed funnel: a bar per step, narrowing with the records that reached it, its conversion and what was lost. */\nfunction FunnelChart({\n steps,\n currency,\n drill,\n defaultDrill,\n onDrill,\n title,\n className,\n \"aria-label\": ariaLabel,\n}: FunnelChartProps) {\n const { country, profile } = useBookiLocaleOptional();\n const say = useSay();\n const copy = COPY[country === \"NO\" ? \"NO\" : \"EN\"];\n const code = currency ?? profile.currency;\n const locale = profile.locale;\n const count = (n: number) => new Intl.NumberFormat(locale).format(n);\n const pct = (value: number | null) => formatPercent(value, locale);\n const fmt = (minor: number) => formatMoney({ minor, currency: code }, { locale, trimZeroFraction: true });\n return (\n <FunnelChartRoot\n steps={steps}\n currency={code}\n drill={drill}\n defaultDrill={defaultDrill}\n onDrillChange={(next: string | null, details: Details) => {\n if (next !== null) onDrill?.(next, details);\n }}\n className={className}\n aria-label={ariaLabel ?? title ?? copy.funnel}\n >\n {(state: RootState) => {\n const view = derive({ steps, currency: code }, state.drill);\n const top = Math.max(1, view.steps[0]?.count ?? 1);\n const biggest = view.steps.find((step) => step.id === view.biggestDropId);\n return (\n <>\n {title ? <h3 data-slot=\"funnel-chart-title\">{title}</h3> : null}\n {view.steps.length === 0 ? (\n <p data-slot=\"funnel-chart-empty\">{copy.none}</p>\n ) : (\n <ol data-slot=\"funnel-chart-steps\">\n {view.steps.map((step: FunnelStep) => (\n <li\n key={step.id}\n data-slot=\"funnel-chart-row\"\n data-biggest={step.id === view.biggestDropId ? \"\" : undefined}\n >\n <FunnelChartStep\n value={step.id}\n aria-label={`${step.label}: ${count(step.count)}, ${pct(step.overallConversionPct)} ${copy.fromStart}`}\n >\n <span data-slot=\"funnel-chart-label\">{step.label}</span>\n <span data-slot=\"funnel-chart-track\">\n <span\n data-slot=\"funnel-chart-bar\"\n style={{ width: `${Math.max(2, (step.count / top) * 100)}%` }}\n />\n </span>\n <span data-slot=\"funnel-chart-count\">{count(step.count)}</span>\n <span data-slot=\"funnel-chart-rate\">{pct(step.overallConversionPct)}</span>\n </FunnelChartStep>\n {step.stepConversionPct !== null ? (\n <p data-slot=\"funnel-chart-between\">\n {pct(step.stepConversionPct)} {copy.fromBefore} · {count(step.dropOff)} {copy.lost}\n </p>\n ) : null}\n </li>\n ))}\n </ol>\n )}\n {biggest ? (\n <p data-slot=\"funnel-chart-summary\" role=\"status\">\n {copy.biggest}: {biggest.label} ({count(biggest.dropOff)} {copy.lost})\n </p>\n ) : null}\n {view.issues.length ? (\n <ul data-slot=\"funnel-chart-issues\">\n {view.issues.map((issue) => (\n <li key={issue}>{say(issue)}</li>\n ))}\n </ul>\n ) : null}\n {view.steps.length ? (\n <details data-slot=\"funnel-chart-table\">\n <summary>{copy.table}</summary>\n <table>\n <thead>\n <tr>\n <th scope=\"col\">{copy.step}</th>\n <th scope=\"col\" data-align=\"end\">\n {copy.count}\n </th>\n <th scope=\"col\" data-align=\"end\">\n {copy.conversion}\n </th>\n <th scope=\"col\" data-align=\"end\">\n {copy.overall}\n </th>\n {view.steps.some((step) => step.valueMinor !== undefined) ? (\n <th scope=\"col\" data-align=\"end\">\n {copy.value}\n </th>\n ) : null}\n </tr>\n </thead>\n <tbody>\n {view.steps.map((step) => (\n <tr key={step.id}>\n <th scope=\"row\">{step.label}</th>\n <td data-align=\"end\">{count(step.count)}</td>\n <td data-align=\"end\">{step.stepConversionPct === null ? \"\" : pct(step.stepConversionPct)}</td>\n <td data-align=\"end\">{pct(step.overallConversionPct)}</td>\n {view.steps.some((s) => s.valueMinor !== undefined) ? (\n <td data-align=\"end\">{step.valueMinor === undefined ? \"\" : fmt(step.valueMinor)}</td>\n ) : null}\n </tr>\n ))}\n </tbody>\n </table>\n </details>\n ) : null}\n {state.refusal ? (\n <p data-slot=\"funnel-chart-error\" role=\"alert\">\n {say(state.refusal)}\n </p>\n ) : null}\n </>\n );\n }}\n </FunnelChartRoot>\n );\n}\n\nexport { FunnelChart, FunnelChartRoot, FunnelChartStep, funnelChart };\nexport type { FunnelStep, FunnelStepInput };\n"],"mappings":";;;;;;;;;;AAAA,SAAS,mBAAmB;AAC5B,SAAS,mBAA+B;AAIxC;AAAA,EACE;AAAA,EACA;AAAA,OAIK;AAyFG,mBACW,KAWD,YAZV;AAvFV,IAAM,OAAO,EAAE,MAAM,OAAO,MAAM,SAAS;AAE3C,IAAM,QAAgD,YAAY,aAAa,IAAI;AACnF,IAAM,kBAA0C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