@dapplelight/signet-ui 0.2.1 → 0.3.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/README.md +325 -5
- package/dist/behaviors/index.d.ts +16 -0
- package/dist/behaviors/index.d.ts.map +1 -0
- package/dist/behaviors/index.js +27 -0
- package/dist/behaviors/index.js.map +1 -0
- package/dist/components/domain/amount.d.ts +27 -0
- package/dist/components/domain/amount.d.ts.map +1 -0
- package/dist/components/domain/amount.js +108 -0
- package/dist/components/domain/amount.js.map +1 -0
- package/dist/components/domain/csv-import.d.ts +81 -0
- package/dist/components/domain/csv-import.d.ts.map +1 -0
- package/dist/components/domain/csv-import.js +177 -0
- package/dist/components/domain/csv-import.js.map +1 -0
- package/dist/components/domain/job-runs.d.ts +27 -0
- package/dist/components/domain/job-runs.d.ts.map +1 -0
- package/dist/components/domain/job-runs.js +55 -0
- package/dist/components/domain/job-runs.js.map +1 -0
- package/dist/components/domain/kanban.d.ts +50 -0
- package/dist/components/domain/kanban.d.ts.map +1 -0
- package/dist/components/domain/kanban.js +279 -0
- package/dist/components/domain/kanban.js.map +1 -0
- package/dist/components/domain/upload.d.ts +21 -0
- package/dist/components/domain/upload.d.ts.map +1 -0
- package/dist/components/domain/upload.js +106 -0
- package/dist/components/domain/upload.js.map +1 -0
- package/dist/components/screens/abuse-screens.d.ts +101 -0
- package/dist/components/screens/abuse-screens.d.ts.map +1 -0
- package/dist/components/screens/abuse-screens.js +163 -0
- package/dist/components/screens/abuse-screens.js.map +1 -0
- package/dist/components/screens/account-screens.d.ts +120 -0
- package/dist/components/screens/account-screens.d.ts.map +1 -0
- package/dist/components/screens/account-screens.js +177 -0
- package/dist/components/screens/account-screens.js.map +1 -0
- package/dist/components/screens/admin-screens.d.ts +269 -0
- package/dist/components/screens/admin-screens.d.ts.map +1 -0
- package/dist/components/screens/admin-screens.js +781 -0
- package/dist/components/screens/admin-screens.js.map +1 -0
- package/dist/components/screens/api-screens.d.ts +113 -0
- package/dist/components/screens/api-screens.d.ts.map +1 -0
- package/dist/components/screens/api-screens.js +127 -0
- package/dist/components/screens/api-screens.js.map +1 -0
- package/dist/components/screens/auth-screens.d.ts +117 -0
- package/dist/components/screens/auth-screens.d.ts.map +1 -0
- package/dist/components/screens/auth-screens.js +164 -0
- package/dist/components/screens/auth-screens.js.map +1 -0
- package/dist/components/screens/billing-screens.d.ts +163 -0
- package/dist/components/screens/billing-screens.d.ts.map +1 -0
- package/dist/components/screens/billing-screens.js +255 -0
- package/dist/components/screens/billing-screens.js.map +1 -0
- package/dist/components/screens/collab-screens.d.ts +150 -0
- package/dist/components/screens/collab-screens.d.ts.map +1 -0
- package/dist/components/screens/collab-screens.js +287 -0
- package/dist/components/screens/collab-screens.js.map +1 -0
- package/dist/components/screens/experiment-screens.d.ts +177 -0
- package/dist/components/screens/experiment-screens.d.ts.map +1 -0
- package/dist/components/screens/experiment-screens.js +275 -0
- package/dist/components/screens/experiment-screens.js.map +1 -0
- package/dist/components/screens/funnel-screens.d.ts +131 -0
- package/dist/components/screens/funnel-screens.d.ts.map +1 -0
- package/dist/components/screens/funnel-screens.js +197 -0
- package/dist/components/screens/funnel-screens.js.map +1 -0
- package/dist/components/screens/growth-screens.d.ts +174 -0
- package/dist/components/screens/growth-screens.d.ts.map +1 -0
- package/dist/components/screens/growth-screens.js +285 -0
- package/dist/components/screens/growth-screens.js.map +1 -0
- package/dist/components/screens/monetisation-screens.d.ts +192 -0
- package/dist/components/screens/monetisation-screens.d.ts.map +1 -0
- package/dist/components/screens/monetisation-screens.js +217 -0
- package/dist/components/screens/monetisation-screens.js.map +1 -0
- package/dist/components/screens/notification-screens.d.ts +92 -0
- package/dist/components/screens/notification-screens.d.ts.map +1 -0
- package/dist/components/screens/notification-screens.js +141 -0
- package/dist/components/screens/notification-screens.js.map +1 -0
- package/dist/components/screens/org-screens.d.ts +135 -0
- package/dist/components/screens/org-screens.d.ts.map +1 -0
- package/dist/components/screens/org-screens.js +237 -0
- package/dist/components/screens/org-screens.js.map +1 -0
- package/dist/components/screens/privacy-screens.d.ts +74 -0
- package/dist/components/screens/privacy-screens.d.ts.map +1 -0
- package/dist/components/screens/privacy-screens.js +127 -0
- package/dist/components/screens/privacy-screens.js.map +1 -0
- package/dist/components/screens/realtime-screens.d.ts +53 -0
- package/dist/components/screens/realtime-screens.d.ts.map +1 -0
- package/dist/components/screens/realtime-screens.js +55 -0
- package/dist/components/screens/realtime-screens.js.map +1 -0
- package/dist/components/screens/status-screens.d.ts +139 -0
- package/dist/components/screens/status-screens.d.ts.map +1 -0
- package/dist/components/screens/status-screens.js +219 -0
- package/dist/components/screens/status-screens.js.map +1 -0
- package/dist/components/screens/subscription-charts.d.ts +113 -0
- package/dist/components/screens/subscription-charts.d.ts.map +1 -0
- package/dist/components/screens/subscription-charts.js +158 -0
- package/dist/components/screens/subscription-charts.js.map +1 -0
- package/dist/components/screens/workflow-screens.d.ts +97 -0
- package/dist/components/screens/workflow-screens.d.ts.map +1 -0
- package/dist/components/screens/workflow-screens.js +181 -0
- package/dist/components/screens/workflow-screens.js.map +1 -0
- package/dist/components/ui/alert-dialog.d.ts +18 -0
- package/dist/components/ui/alert-dialog.d.ts.map +1 -0
- package/dist/components/ui/alert-dialog.js +34 -0
- package/dist/components/ui/alert-dialog.js.map +1 -0
- package/dist/components/ui/avatar.d.ts +12 -0
- package/dist/components/ui/avatar.d.ts.map +1 -0
- package/dist/components/ui/avatar.js +31 -0
- package/dist/components/ui/avatar.js.map +1 -0
- package/dist/components/ui/breadcrumb.d.ts +14 -0
- package/dist/components/ui/breadcrumb.d.ts.map +1 -0
- package/dist/components/ui/breadcrumb.js +38 -0
- package/dist/components/ui/breadcrumb.js.map +1 -0
- package/dist/components/ui/chart.d.ts +4 -3
- package/dist/components/ui/chart.d.ts.map +1 -1
- package/dist/components/ui/chart.js +99 -1
- package/dist/components/ui/chart.js.map +1 -1
- package/dist/components/ui/command.d.ts +29 -0
- package/dist/components/ui/command.d.ts.map +1 -0
- package/dist/components/ui/command.js +50 -0
- package/dist/components/ui/command.js.map +1 -0
- package/dist/components/ui/data-grid.d.ts +73 -0
- package/dist/components/ui/data-grid.d.ts.map +1 -0
- package/dist/components/ui/data-grid.js +612 -0
- package/dist/components/ui/data-grid.js.map +1 -0
- package/dist/components/ui/field.d.ts +15 -0
- package/dist/components/ui/field.d.ts.map +1 -0
- package/dist/components/ui/field.js +36 -0
- package/dist/components/ui/field.js.map +1 -0
- package/dist/components/ui/metric-headline.d.ts +59 -0
- package/dist/components/ui/metric-headline.d.ts.map +1 -0
- package/dist/components/ui/metric-headline.js +54 -0
- package/dist/components/ui/metric-headline.js.map +1 -0
- package/dist/components/ui/radio-group.d.ts +6 -0
- package/dist/components/ui/radio-group.d.ts.map +1 -0
- package/dist/components/ui/radio-group.js +12 -0
- package/dist/components/ui/radio-group.js.map +1 -0
- package/dist/components/ui/rich-text-editor.d.ts +52 -0
- package/dist/components/ui/rich-text-editor.d.ts.map +1 -0
- package/dist/components/ui/rich-text-editor.js +669 -0
- package/dist/components/ui/rich-text-editor.js.map +1 -0
- package/dist/components/ui/sidebar.d.ts +45 -0
- package/dist/components/ui/sidebar.d.ts.map +1 -0
- package/dist/components/ui/sidebar.js +86 -0
- package/dist/components/ui/sidebar.js.map +1 -0
- package/dist/components/ui/spinner.d.ts +4 -0
- package/dist/components/ui/spinner.d.ts.map +1 -0
- package/dist/components/ui/spinner.js +8 -0
- package/dist/components/ui/spinner.js.map +1 -0
- package/dist/components/ui/stepper.d.ts +17 -0
- package/dist/components/ui/stepper.d.ts.map +1 -0
- package/dist/components/ui/stepper.js +17 -0
- package/dist/components/ui/stepper.js.map +1 -0
- package/dist/components/ui/tabs.js +1 -1
- package/dist/components/ui/tabs.js.map +1 -1
- package/dist/components/ui/timeline.d.ts +11 -0
- package/dist/components/ui/timeline.d.ts.map +1 -0
- package/dist/components/ui/timeline.js +27 -0
- package/dist/components/ui/timeline.js.map +1 -0
- package/dist/components/ui/toast.d.ts +47 -0
- package/dist/components/ui/toast.d.ts.map +1 -0
- package/dist/components/ui/toast.js +49 -0
- package/dist/components/ui/toast.js.map +1 -0
- package/dist/hooks/use-channel.d.ts +96 -0
- package/dist/hooks/use-channel.d.ts.map +1 -0
- package/dist/hooks/use-channel.js +242 -0
- package/dist/hooks/use-channel.js.map +1 -0
- package/dist/hooks/use-copy.d.ts +5 -0
- package/dist/hooks/use-copy.d.ts.map +1 -0
- package/dist/hooks/use-copy.js +22 -0
- package/dist/hooks/use-copy.js.map +1 -0
- package/dist/hooks/use-debounce.d.ts +2 -0
- package/dist/hooks/use-debounce.d.ts.map +1 -0
- package/dist/hooks/use-debounce.js +11 -0
- package/dist/hooks/use-debounce.js.map +1 -0
- package/dist/hooks/use-intersection.d.ts +9 -0
- package/dist/hooks/use-intersection.d.ts.map +1 -0
- package/dist/hooks/use-intersection.js +29 -0
- package/dist/hooks/use-intersection.js.map +1 -0
- package/dist/hooks/use-local-storage.d.ts +2 -0
- package/dist/hooks/use-local-storage.d.ts.map +1 -0
- package/dist/hooks/use-local-storage.js +59 -0
- package/dist/hooks/use-local-storage.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/csv.d.ts +8 -0
- package/dist/lib/csv.d.ts.map +1 -0
- package/dist/lib/csv.js +77 -0
- package/dist/lib/csv.js.map +1 -0
- package/package.json +209 -8
package/README.md
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
# @dapplelight/signet-ui
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
52 React components on Tailwind v4, in the shadcn style, styled only through
|
|
6
6
|
[Signet theme tokens](https://www.npmjs.com/package/@dapplelight/signet-tokens).
|
|
7
7
|
Swap the theme file and every component changes; no component is edited.
|
|
8
8
|
|
|
9
9
|
Part of [Signet](https://github.com/dapplelight/signet). Docs:
|
|
10
|
-
https://dapplelight.
|
|
10
|
+
https://signet.dapplelight.in/
|
|
11
11
|
|
|
12
12
|
## Install
|
|
13
13
|
|
|
@@ -35,12 +35,332 @@ few more. recharts, TanStack Hotkeys and the Markdown stack are optional.
|
|
|
35
35
|
|
|
36
36
|
## What is in it
|
|
37
37
|
|
|
38
|
-
- The shadcn set: button, input, dialog,
|
|
39
|
-
|
|
38
|
+
- The shadcn set: button, input, dialog, drawer, popover, select, tabs, table
|
|
39
|
+
and the rest. There is no `sheet` component: use `drawer` or
|
|
40
|
+
`responsive-sheet` for sheets.
|
|
40
41
|
- Extras: a virtualised `data-table`, `combobox`, `stat-strip`,
|
|
41
42
|
`responsive-sheet`, `markdown` (safe by default), `emoji-picker`.
|
|
43
|
+
- Basics on UI SDK behaviours (see below): `toast`, `alert-dialog`, `field`,
|
|
44
|
+
`avatar`, `radio-group`, `command` (with a ⌘K `CommandDialog`), `timeline`,
|
|
45
|
+
`stepper`, `sidebar`, `breadcrumb`, `spinner`. `toast` has sonner's API
|
|
46
|
+
(`toast()`, `toast.success()`, `<Toaster position closeButton />`), so the
|
|
47
|
+
`create-signet-app` template's sonner Toaster can be swapped for it by
|
|
48
|
+
changing two imports.
|
|
42
49
|
- `domain/` components that carry product vocabulary, such as `trend-chip`,
|
|
43
|
-
kept out of the main barrel.
|
|
50
|
+
kept out of the main barrel. `domain/job-runs` is a table of background-job
|
|
51
|
+
runs (status, attempts, error, retry and cancel) on `data-table`; it takes
|
|
52
|
+
plain rows such as signet-server's `jobs.status(id)` and callbacks.
|
|
53
|
+
`domain/upload` is a drag-and-drop uploader with per-file progress (XHR to
|
|
54
|
+
a presigned URL), retry, and size/type hints; `getTarget` and `onUploaded`
|
|
55
|
+
talk to your server.
|
|
56
|
+
`domain/amount` formats money: the locale's grouping (₹12,50,000 in
|
|
57
|
+
en-IN), the currency's own decimals, minor units and bigints exactly,
|
|
58
|
+
compact lakh/crore ("₹12.5L", "₹1.2Cr"), a sign, and `tone` colours from
|
|
59
|
+
the theme's `--money-*` slots (falling back to the status accents), with a
|
|
60
|
+
class per part (`currency`, `integer`, `fraction`…). `domain/kanban` is a
|
|
61
|
+
board whose cards move between columns by pointer drag or keyboard (Space
|
|
62
|
+
picks up, arrows move, Space drops, Escape cancels), announced in a live
|
|
63
|
+
region; the board is a plain `{ column: ids[] }` object.
|
|
64
|
+
- Hooks, one subpath each: `hooks/use-media-query`, `hooks/use-debounce`,
|
|
65
|
+
`hooks/use-local-storage` (JSON, SSR-safe, synced across tabs),
|
|
66
|
+
`hooks/use-copy` (clipboard with a `copied` flag) and
|
|
67
|
+
`hooks/use-intersection` (on screen or not, for lazy loading).
|
|
68
|
+
- `screens/` ready screens, out of the barrel: `auth-screens` (sign in / up
|
|
69
|
+
by email or phone code, OAuth, verify, session expired), `account-screens`
|
|
70
|
+
(profile, devices, API keys), `notification-screens` (inbox, preferences)
|
|
71
|
+
and `privacy-screens` (DPDP consents, export and erasure requests). Plain
|
|
72
|
+
data in, callbacks out, shaped like signet-server and signet-db; wire them
|
|
73
|
+
through `createRpcClient`. Strings come from `DEFAULT_*_LABELS` and the
|
|
74
|
+
`labels` prop; parts take `className`, composites `classNames`. Demo:
|
|
75
|
+
`screens-user.html` in the showcase (linked from its header).
|
|
76
|
+
- `screens/admin-screens`: `AdminScreen`, an admin panel generated from
|
|
77
|
+
signet-db's `defineAdmin` metadata over signet-server's `adminRoutes`
|
|
78
|
+
(`createAdminApi({ baseUrl: "/admin" })`): table list, server sort,
|
|
79
|
+
filters, search and cursor pages, deleted rows, a record form built from the
|
|
80
|
+
column types, create, bulk delete, row actions and the audit trail. Every
|
|
81
|
+
part is exported (`AdminPanel`, `AdminTable`, `AdminRecordSheet`…) with
|
|
82
|
+
`useAdmin()` for your own.
|
|
83
|
+
- `screens/billing-screens`: `BillingScreen` and `Paywall` on signet-db
|
|
84
|
+
entitlements and signet-payments: plan picker (web and store plans,
|
|
85
|
+
monthly / yearly), current plan with `currentPeriodEnd` and source, restore
|
|
86
|
+
purchases, usage meters, GST invoice links and a wallet balance.
|
|
87
|
+
`plansFromEntitlements(definePlans(...), display)` builds the plan list.
|
|
88
|
+
- `screens/monetisation-screens`: `RemotePaywall` renders the server's
|
|
89
|
+
offering (signet-db `createOfferings`: copy, plans shown, highlighted plan
|
|
90
|
+
and badge, trial text, button text, prices per store) on the `Paywall`
|
|
91
|
+
parts and hands the matching product to your checkout;
|
|
92
|
+
`plansFromOffering(offering, source, display)` is the plan list it uses.
|
|
93
|
+
`CustomerCenter` is the self-serve page on signet-db `createCustomers`:
|
|
94
|
+
plan and renewal date, cancel with the retention offer first, a store
|
|
95
|
+
manage link instead for App Store and Google Play, refund request and
|
|
96
|
+
contact support. `CustomerTimeline` is the admin view of one customer's
|
|
97
|
+
purchases, renewals, refunds, cancellations, billing issues and grace
|
|
98
|
+
periods across stores and web, with ledger totals.
|
|
99
|
+
- `screens/experiment-screens`: `ExperimentList` and `ExperimentResults`,
|
|
100
|
+
the admin readout of a signet-db experiment (exposures, conversions, rate,
|
|
101
|
+
lift and p-value per variant against the control) with start, stop and
|
|
102
|
+
roll out a winner, over signet-server's `experimentAdminRoutes`.
|
|
103
|
+
`ExperimentForm` creates and edits one (key, variants with weights, a
|
|
104
|
+
JSON value or, with `offerings`, an offering and version per variant,
|
|
105
|
+
goal event, audience, start and stop). `PricingExperimentResults` is a
|
|
106
|
+
pricing experiment's readout from `GET /pricing/:experiment`: per variant
|
|
107
|
+
the offering, conversion with lift and p-value, trial conversion, revenue
|
|
108
|
+
per exposed user and an LTV marked as an estimate, with one-click rollout.
|
|
109
|
+
- `screens/status-screens`: `StatusPage`, the public status page from
|
|
110
|
+
signet-db's `status.summary()`: overall status, a maintenance notice,
|
|
111
|
+
components and recent incidents with their updates. `StatusAdmin` is the
|
|
112
|
+
admin screen over `statusAdminRoutes`: the maintenance switch with message
|
|
113
|
+
and until, component statuses, and incidents opened, updated and resolved
|
|
114
|
+
(updates are append-only); its parts (`MaintenanceForm`,
|
|
115
|
+
`ComponentStatusList`, `IncidentForm`, `IncidentUpdateForm`) are exported.
|
|
116
|
+
periods across stores and web, with ledger totals. `RemotePaywall` shows
|
|
117
|
+
the customer's best offer (free trial, intro or win-back, from
|
|
118
|
+
`customers.withOffers`), passes it to `onPurchase`, and calls
|
|
119
|
+
`onImpression` once per offering version for paywall conversion;
|
|
120
|
+
`PromotionalGrantForm` grants a plan for some days from admin.
|
|
121
|
+
- `screens/funnel-screens`: `WebFunnel` walks a web-to-app funnel from
|
|
122
|
+
signet-server's funnel routes (questions, then `RemotePaywall` with the
|
|
123
|
+
URL discount priced in, then email and code) and hands the checkout to
|
|
124
|
+
you; `ExpressCheckout` mounts Stripe's Express Checkout Element (Apple Pay,
|
|
125
|
+
Google Pay) and Payment Element with Stripe.js loaded at runtime (nothing
|
|
126
|
+
bundled); `FunnelRedemption` waits for the webhook, then offers "Open the
|
|
127
|
+
app" and the code to paste. Fetch `GET /sessions/:id` from the same site with
|
|
128
|
+
`credentials: "include"`: only the checkout's browser (HttpOnly cookie) gets the
|
|
129
|
+
link; anyone else sees "paid, we emailed you the link".
|
|
130
|
+
- `screens/subscription-charts`: `SubscriptionCharts` on signet-db
|
|
131
|
+
`createCharts`: MRR per currency (and a converted total), active
|
|
132
|
+
subscribers and trials, new versus renewal revenue and refunds, churn and
|
|
133
|
+
trial conversions, paywall views against conversions, with filters by
|
|
134
|
+
store, plan, country and offering, saved audiences and a CSV link. Needs
|
|
135
|
+
recharts (optional peer), so it is its own export path.
|
|
136
|
+
- `screens/growth-screens`: `WaitlistJoin` (with the place in line),
|
|
137
|
+
`InviteAccept`, `ReferralCard`, `OnboardingChecklist`, `FeedbackWidget` /
|
|
138
|
+
`FeedbackForm` and `WhatsNew`, shaped like signet-db's growth results.
|
|
139
|
+
- `screens/workflow-screens`: `WorkflowRunTimeline` (run status, who or
|
|
140
|
+
what it is waiting on, every step with retries and decisions, cancel) and
|
|
141
|
+
`ApprovalInboxCard` (approve / reject with a reason), shaped like
|
|
142
|
+
signet-db's `wf.get(id)` and `wf.pendingApprovals(user)`.
|
|
143
|
+
Demo for these four: `screens-ops.html` in the showcase (`?screen=`,
|
|
144
|
+
`?theme=`, `?dark=1`).
|
|
145
|
+
- `screens/org-screens`: `OrgSwitcher`, `MembersList` (roles, remove, leave,
|
|
146
|
+
pending invites), `InviteDialog` (one-time link with Copy),
|
|
147
|
+
`AcceptInvitePage` (a page around `InviteAccept`) and `OrgSettings` (name,
|
|
148
|
+
theme, brand colour with a `buildTheme` preview), shaped like
|
|
149
|
+
signet-server's `orgRoutes` responses. Demo: `screens-orgs.html`.
|
|
150
|
+
- `screens/collab-screens`: `CommentThreads` (threads, replies, edit with
|
|
151
|
+
an "edited" marker, delete, a composer), `MentionTextarea` (type `@` for a
|
|
152
|
+
member picker; the body stores `@[Name](user:<id>)`, so a rename never
|
|
153
|
+
breaks a mention), `ActivityFeed` ("Asha changed status to Done", comments,
|
|
154
|
+
Load more) and `VersionHistory` (versions, a field diff, Restore, Undo with
|
|
155
|
+
the server's conflict message), shaped like signet-db's `createCollab` and
|
|
156
|
+
signet-server's `collabRoutes`. Demo: `screens-collab.html`.
|
|
157
|
+
- `screens/abuse-screens`: `CaptchaWidget` (loads Cloudflare Turnstile or
|
|
158
|
+
hCaptcha and reports the token for signet-server's `requireCaptcha`;
|
|
159
|
+
`provider="test"` reports the test token with no script) and
|
|
160
|
+
`AiSpendAdmin` (spend against caps today and this month, top users and
|
|
161
|
+
orgs, set and remove caps), shaped like signet-server's
|
|
162
|
+
`aiSpendAdminRoutes`.
|
|
163
|
+
- Real-time: `hooks/use-channel` and `screens/realtime-screens`, see
|
|
164
|
+
[Real-time](#real-time). Demo: `screens-realtime.html`.
|
|
165
|
+
- Data editing: `domain/csv-import`, `components/data-grid` and
|
|
166
|
+
`components/rich-text-editor`, see [Data editing](#data-editing).
|
|
167
|
+
|
|
168
|
+
### Real-time
|
|
169
|
+
|
|
170
|
+
On signet-server's realtime hub (`@dapplelight/signet-server/realtime`).
|
|
171
|
+
`hooks/use-channel` has `createRealtimeClient` (reconnects with backoff,
|
|
172
|
+
rejoins resuming from the last event, pings on the hub's heartbeat, drops
|
|
173
|
+
duplicate events, applies shared state by version), `useChannel(client,
|
|
174
|
+
channel, { onEvent })` (presence, shared state, `set`, `setTyping`,
|
|
175
|
+
`setEditing`, and `stale` / `conflict` flags with `acknowledge`),
|
|
176
|
+
`usePresence` and `useRecordChanges`. `screens/realtime-screens` has
|
|
177
|
+
`AvatarStack`, `EditingBadge`, `TypingIndicator` (a polite live region) and
|
|
178
|
+
`RecordChangedBanner` ("this record changed, reload?"); strings come from
|
|
179
|
+
`DEFAULT_REALTIME_LABELS` and the `labels` prop.
|
|
180
|
+
|
|
181
|
+
```tsx
|
|
182
|
+
const live = createRealtimeClient({ url: `/realtime?org=${orgId}` })
|
|
183
|
+
function Doc({ id, me }) {
|
|
184
|
+
const ch = useChannel(live, `record:docs:${id}`)
|
|
185
|
+
const { changed, change, dismiss } = useRecordChanges(live, `record:docs:${id}`, { selfId: me })
|
|
186
|
+
return (<>
|
|
187
|
+
<RecordChangedBanner changed={changed} by={change?.data?.name} onReload={() => { refetch(); dismiss() }} />
|
|
188
|
+
<AvatarStack members={ch.members} selfId={me} />
|
|
189
|
+
<EditingBadge members={ch.members} selfId={me} field="title" />
|
|
190
|
+
<input onFocus={() => ch.setEditing("title")} onBlur={() => ch.setEditing(null)} onInput={() => ch.setTyping(true)} />
|
|
191
|
+
<TypingIndicator members={ch.members} selfId={me} />
|
|
192
|
+
</>)
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
A user removed from the org or whose session expired is not reconnected
|
|
197
|
+
(close codes 4003 and 4001); anything else reconnects with backoff.
|
|
198
|
+
|
|
199
|
+
### Data editing
|
|
200
|
+
|
|
201
|
+
Three pieces for editing data in a product, all on theme tokens, with
|
|
202
|
+
`DEFAULT_*_LABELS` + `labels` for every string, `className` plus
|
|
203
|
+
`classNames` per part, `data-slot` and state attributes on every part, and
|
|
204
|
+
copy-in with `signet add data-grid`, `signet add rich-text-editor` or
|
|
205
|
+
`signet add csv-import`.
|
|
206
|
+
|
|
207
|
+
- `domain/csv-import`: `CsvImport` takes a file or pasted text, parses it
|
|
208
|
+
(RFC 4180: quoted fields, `""`, line breaks inside quotes, CRLF, a BOM; the
|
|
209
|
+
separator is detected), matches columns to `fields` by name, key or alias,
|
|
210
|
+
validates every row with your zod schema (or anything with `safeParse`),
|
|
211
|
+
shows errors per cell with a "rows with errors" filter and a download of
|
|
212
|
+
them, and passes the valid rows to `onImport`. Return signet-db's
|
|
213
|
+
`bulkInsert` report and its errors land on the right line and field.
|
|
214
|
+
`parseCsv`, `toCsv`, `autoMatch` and `validateRows` are exported for your
|
|
215
|
+
own flow.
|
|
216
|
+
- `components/data-grid`: `DataGrid` is an editable grid on the same
|
|
217
|
+
react-table core and Table parts as `DataTable`: text, number, select, date
|
|
218
|
+
and checkbox cells; one tab stop with arrows, Home/End, PageUp/PageDown,
|
|
219
|
+
Ctrl+arrows, Enter or F2 or typing to edit, Enter/Tab to save and move,
|
|
220
|
+
Escape to cancel; Shift+arrows select a range, Ctrl+C copies it as TSV,
|
|
221
|
+
Ctrl+V pastes a TSV block (or fills the range with one value), Delete
|
|
222
|
+
clears it; Shift+Space or the checkbox column selects rows; header sort
|
|
223
|
+
and keyboard column resize; rows are virtualised (10k+). `onChange` gets
|
|
224
|
+
every edit, paste and clear as a batch; the grid shows the new values at
|
|
225
|
+
once, and a throw (or returned failures) puts them back with the error on
|
|
226
|
+
each cell (`aria-invalid`, `data-error`) and in a live region. It is a
|
|
227
|
+
`role="grid"` with `aria-rowcount`, `aria-rowindex`, `aria-colindex`,
|
|
228
|
+
`aria-selected` and `aria-sort`.
|
|
229
|
+
- `components/rich-text-editor`: `RichTextEditor` is built on Tiptap v3
|
|
230
|
+
(optional peers: `bun add @tiptap/react @tiptap/pm @tiptap/starter-kit
|
|
231
|
+
@tiptap/extension-mention @tiptap/extension-link`; like `chart`, it is not
|
|
232
|
+
in the barrel, so apps without Tiptap are unaffected). Bold, italic, inline
|
|
233
|
+
code, links, two heading levels, bulleted and numbered lists
|
|
234
|
+
(Mod+B/I/E/K), a WAI-ARIA toolbar, and `@` mentions through Tiptap's
|
|
235
|
+
suggestion API with `onMentionSearch`, the same people search
|
|
236
|
+
`MentionTextarea` uses. The value is markdown written by walking the
|
|
237
|
+
editor's HTML through an allowlist, and pasted HTML goes through the same
|
|
238
|
+
allowlist, so pasted scripts, handlers, styles and `javascript:` links
|
|
239
|
+
never reach it; mentions are stored as
|
|
240
|
+
`@[Name](user:<id>)`, so signet-db's `createCollab` parses and notifies
|
|
241
|
+
them as it does for comments. `RichTextContent` and `richTextToHtml`
|
|
242
|
+
render stored markdown as HTML that is safe by construction. On the
|
|
243
|
+
server, pass bodies through signet-server's `sanitizeMarkdown`.
|
|
244
|
+
|
|
245
|
+
```tsx
|
|
246
|
+
const schema = z.object({ name: z.string().min(1), email: z.email(), plan: z.enum(["free", "pro"]) })
|
|
247
|
+
<CsvImport
|
|
248
|
+
fields={[{ key: "name", required: true }, { key: "email", aliases: ["E-mail"] }, { key: "plan" }]}
|
|
249
|
+
schema={schema}
|
|
250
|
+
onImport={(rows) => api.post("/customers/import", { rows })} // returns bulkInsert's report
|
|
251
|
+
/>
|
|
252
|
+
|
|
253
|
+
<DataGrid
|
|
254
|
+
aria-label="Customers"
|
|
255
|
+
rows={rows}
|
|
256
|
+
getRowId={(r) => r.id}
|
|
257
|
+
selectable
|
|
258
|
+
columns={[
|
|
259
|
+
{ id: "name", header: "Name" },
|
|
260
|
+
{ id: "seats", header: "Seats", type: "number" },
|
|
261
|
+
{ id: "plan", header: "Plan", type: "select", options: [{ value: "free", label: "Free" }, { value: "pro", label: "Pro" }] },
|
|
262
|
+
{ id: "renews", header: "Renews", type: "date" },
|
|
263
|
+
{ id: "active", header: "Active", type: "checkbox" },
|
|
264
|
+
]}
|
|
265
|
+
onChange={async (changes) => {
|
|
266
|
+
await api.patch("/customers", { changes }) // a throw reverts and marks the cells
|
|
267
|
+
setRows((all) => applyChanges(all, changes))
|
|
268
|
+
}}
|
|
269
|
+
/>
|
|
270
|
+
|
|
271
|
+
<RichTextEditor aria-label="Note" value={body} onValueChange={setBody} onMentionSearch={(q) => api.get(`/mentions?q=${q}`)} />
|
|
272
|
+
<RichTextContent value={body} />
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
Demo: `data-edit.html` in the showcase.
|
|
276
|
+
|
|
277
|
+
## Behaviours and recipes
|
|
278
|
+
|
|
279
|
+
The basics are built from behaviours: keyboard, focus, selection, dismissal
|
|
280
|
+
and the ARIA they need. [UI SDK](https://ui-sdk.dev) (`@ui-sdk/core` and
|
|
281
|
+
`@ui-sdk/react`, pinned to an exact beta) implements them inside this package;
|
|
282
|
+
nothing from it appears in signet-ui's exports, so it can be replaced here
|
|
283
|
+
without an app changing. Each component's source starts with its recipe:
|
|
284
|
+
|
|
285
|
+
| Component | Recipe |
|
|
286
|
+
|---|---|
|
|
287
|
+
| `toast` | live-region + timers + swipe + dismiss + shortcut (F6) |
|
|
288
|
+
| `alert-dialog` | popup + focus-trap + dismiss |
|
|
289
|
+
| `field` | field-wiring (label names, description and error describe, aria-invalid) |
|
|
290
|
+
| `avatar` | image-loading |
|
|
291
|
+
| `radio-group` | selection + roving-focus |
|
|
292
|
+
| `command` | selection + typeahead + filter; `CommandDialog` adds popup + focus-trap + dismiss + shortcut + controllable-state |
|
|
293
|
+
| `timeline` | roving-focus |
|
|
294
|
+
| `stepper` | roving-focus + status |
|
|
295
|
+
| `sidebar` | disclosure + controllable-state + shortcut; on phones the Drawer's popup + focus-trap + dismiss + swipe |
|
|
296
|
+
| `breadcrumb` | landmark |
|
|
297
|
+
| `spinner` | live-region |
|
|
298
|
+
| `screens/billing-screens` | selection + roving-focus + controllable-state + live-region |
|
|
299
|
+
| `screens/monetisation-screens` | selection + roving-focus + controllable-state + live-region |
|
|
300
|
+
| `screens/experiment-screens` | selection + live-region + field-wiring |
|
|
301
|
+
| `screens/status-screens` | live-region + field-wiring + roving-focus (timeline) |
|
|
302
|
+
| `screens/funnel-screens` | selection + controllable-state + live-region |
|
|
303
|
+
| `screens/subscription-charts` | field-wiring (labelled filters) + controllable-state (filters) |
|
|
304
|
+
| `screens/growth-screens` | selection + roving-focus + controllable-state + popup + dismiss + live-region + field-wiring |
|
|
305
|
+
| `screens/workflow-screens` | roving-focus (timeline) + live-region + field-wiring |
|
|
306
|
+
| `screens/org-screens` | popup + dismiss + live-region + field-wiring + controllable-state |
|
|
307
|
+
| `screens/collab-screens` | combobox (mention picker: aria-activedescendant, arrows, Enter/Tab, Escape) + live-region |
|
|
308
|
+
| `domain/amount` | money-format + tone (colour from the `--money-*` slots) |
|
|
309
|
+
| `domain/kanban` | controllable-state + live-region + drag + keyboard-move |
|
|
310
|
+
| `screens/admin-screens` | selection + controllable-state + popup + focus-trap + dismiss + roving-focus (tabs) + field-wiring |
|
|
311
|
+
|
|
312
|
+
`@dapplelight/signet-ui/behaviors` exports the behaviours a new component
|
|
313
|
+
needs directly, with Signet's own types: `useShortcut(keys, handler)` and
|
|
314
|
+
`useShortcutLabel(keys)` ("mod+k" is ⌘ on Apple platforms, Ctrl elsewhere),
|
|
315
|
+
`useControllableState({ value, defaultValue, onChange })`, and
|
|
316
|
+
`matchScore(text, query)`, the fuzzy score Command ranks by.
|
|
317
|
+
|
|
318
|
+
`Field` takes a TanStack Form field's `state.meta.errors` as `errors`, the same
|
|
319
|
+
shape `@dapplelight/signet-lib/form` reads. `Command` takes `filter={false}`
|
|
320
|
+
with your own results, so a `@dapplelight/signet-lib/search` result list can
|
|
321
|
+
drive it.
|
|
322
|
+
|
|
323
|
+
## Customising
|
|
324
|
+
|
|
325
|
+
Every basic follows the same contract, and a new component should too:
|
|
326
|
+
|
|
327
|
+
- **Tokens only.** Colours, radii and type come from theme utilities
|
|
328
|
+
(`bg-popover`, `text-text-muted`, `border-border`, `rounded-lg`); never a hex
|
|
329
|
+
value or a stock palette colour.
|
|
330
|
+
- **`className` on every part**, merged over the defaults with `cn`
|
|
331
|
+
(tailwind-merge), so a later class wins. Composite components take
|
|
332
|
+
`classNames` per part (`Toaster`, `Stepper`) or a named class prop
|
|
333
|
+
(`backdropClassName`, `wrapperClassName`, `contentClassName`).
|
|
334
|
+
- **State as `data-*`.** Style any state from CSS: `data-open`,
|
|
335
|
+
`data-highlighted`, `data-checked`, `data-disabled`, `data-invalid`,
|
|
336
|
+
`data-complete` / `data-current` / `data-upcoming`, `data-state`.
|
|
337
|
+
- **All text overridable** for translation: `label`, `closeLabel`, `title`,
|
|
338
|
+
`description`, `aria-label` have English defaults and are props.
|
|
339
|
+
- **Parts are exported** one by one (`SidebarHeader`, `CommandItem`…), and
|
|
340
|
+
`render` swaps a part's element (`render={<Button variant="destructive" />}`,
|
|
341
|
+
`render={<Link to="/" />}`).
|
|
342
|
+
- **Controlled or not.** Stateful parts take `open` / `value` with
|
|
343
|
+
`onOpenChange` / `onValueChange`, or `defaultOpen` / `defaultValue`.
|
|
344
|
+
|
|
345
|
+
## Build a new component
|
|
346
|
+
|
|
347
|
+
When signet-ui has no component for a need, build it in this package from
|
|
348
|
+
`signet-ui/behaviors` and theme tokens, the way `sidebar` and `stepper` are:
|
|
349
|
+
|
|
350
|
+
1. Write its recipe first: which behaviours it needs (popup, dismiss,
|
|
351
|
+
focus-trap, selection, roving-focus, typeahead, filter, shortcut,
|
|
352
|
+
controllable-state, live-region). Put it as the `// Recipe:` line at the
|
|
353
|
+
top of the file; signet-mcp's `compose_component` reads it.
|
|
354
|
+
2. Reuse a signet-ui part that already has the behaviour (Drawer and Dialog
|
|
355
|
+
for popups, Timeline for roving focus over a list, Command for filtering)
|
|
356
|
+
before reaching for a new one. Take state and shortcuts from
|
|
357
|
+
`signet-ui/behaviors`. Import `@ui-sdk/*` only inside this package, never
|
|
358
|
+
in its exported types.
|
|
359
|
+
3. Style with token utilities and the customising contract above.
|
|
360
|
+
4. Add keyboard, focus and ARIA tests to `test/basics.tsx`; the tokens package
|
|
361
|
+
test compiles every theme against the new classes. Export it in
|
|
362
|
+
`package.json` and add a demo to `apps/showcase`. The MCP index and
|
|
363
|
+
API.md regenerate on their own (see CONTRIBUTING.md).
|
|
44
364
|
|
|
45
365
|
The full export list is in
|
|
46
366
|
[API.md](https://github.com/dapplelight/signet/blob/main/API.md).
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface ShortcutOptions {
|
|
2
|
+
enabled?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare function useShortcut(keys: string | null | undefined, handler: (event: KeyboardEvent) => void, { enabled }?: ShortcutOptions): void;
|
|
5
|
+
export declare function useShortcutLabel(keys: string): {
|
|
6
|
+
text: string;
|
|
7
|
+
ariaKeyShortcuts: string;
|
|
8
|
+
};
|
|
9
|
+
export interface ControllableStateOptions<T> {
|
|
10
|
+
value?: T;
|
|
11
|
+
defaultValue: T;
|
|
12
|
+
onChange?: (value: T) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare function useControllableState<T>({ value, defaultValue, onChange, }: ControllableStateOptions<T>): [T, (next: T) => void];
|
|
15
|
+
export declare function matchScore(text: string, query: string): number;
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/behaviors/index.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,eAAe;IAE9B,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAQD,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC/B,OAAO,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,EACvC,EAAE,OAAc,EAAE,GAAE,eAAoB,GACvC,IAAI,CAEN;AAMD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAA;CAAE,CAGzF;AAED,MAAM,WAAW,wBAAwB,CAAC,CAAC;IAEzC,KAAK,CAAC,EAAE,CAAC,CAAA;IACT,YAAY,EAAE,CAAC,CAAA;IACf,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAA;CAC9B;AAMD,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,EACtC,KAAK,EACL,YAAY,EACZ,QAAQ,GACT,EAAE,wBAAwB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC,CAatD;AAOD,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAE9D"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { fuzzyScore } from "@ui-sdk/core/text-match";
|
|
3
|
+
import { useShortcut as useSdkShortcut, useShortcutHint } from "@ui-sdk/react/shortcuts";
|
|
4
|
+
import { useCallback, useRef, useState } from "react";
|
|
5
|
+
export function useShortcut(keys, handler, { enabled = true } = {}) {
|
|
6
|
+
useSdkShortcut(enabled ? keys : null, handler);
|
|
7
|
+
}
|
|
8
|
+
export function useShortcutLabel(keys) {
|
|
9
|
+
const { text, ariaKeyshortcuts } = useShortcutHint(keys);
|
|
10
|
+
return { text, ariaKeyShortcuts: ariaKeyshortcuts };
|
|
11
|
+
}
|
|
12
|
+
export function useControllableState({ value, defaultValue, onChange, }) {
|
|
13
|
+
const [own, setOwn] = useState(defaultValue);
|
|
14
|
+
const controlled = value !== undefined;
|
|
15
|
+
const onChangeRef = useRef(onChange);
|
|
16
|
+
onChangeRef.current = onChange;
|
|
17
|
+
const set = useCallback((next) => {
|
|
18
|
+
if (!controlled)
|
|
19
|
+
setOwn(next);
|
|
20
|
+
onChangeRef.current?.(next);
|
|
21
|
+
}, [controlled]);
|
|
22
|
+
return [controlled ? value : own, set];
|
|
23
|
+
}
|
|
24
|
+
export function matchScore(text, query) {
|
|
25
|
+
return fuzzyScore(text, query);
|
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AI,CAAC,CAAA;IAC7B,CAAC,EACD,CAAC,UAAU,CAAC,CACb,CAAA;IACD,OAAO,CAAC,UAAU,CAAC,CAAC,CAAE,KAAW,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;AAC/C,CAAC;AAOD,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,KAAa;IACpD,OAAO,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AAChC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
type AmountValue = number | string | bigint;
|
|
3
|
+
type AmountTone = "credit" | "debit" | "transfer";
|
|
4
|
+
type AmountPart = "sign" | "currency" | "integer" | "fraction" | "compact";
|
|
5
|
+
interface AmountProps extends Omit<React.ComponentProps<"data">, "children" | "value"> {
|
|
6
|
+
value: AmountValue;
|
|
7
|
+
currency?: string;
|
|
8
|
+
locale?: string;
|
|
9
|
+
minorUnits?: boolean;
|
|
10
|
+
notation?: "standard" | "whole" | "compact";
|
|
11
|
+
decimals?: number;
|
|
12
|
+
tone?: AmountTone | "auto";
|
|
13
|
+
signDisplay?: Intl.NumberFormatOptions["signDisplay"];
|
|
14
|
+
classNames?: Partial<Record<AmountPart, string>>;
|
|
15
|
+
render?: React.ReactElement<Record<string, unknown>>;
|
|
16
|
+
}
|
|
17
|
+
declare function formatAmount(value: AmountValue, { currency, locale, minorUnits, notation, decimals, signDisplay, }?: Pick<AmountProps, "currency" | "locale" | "minorUnits" | "notation" | "decimals" | "signDisplay">): {
|
|
18
|
+
parts: {
|
|
19
|
+
type: AmountPart | "literal";
|
|
20
|
+
value: string;
|
|
21
|
+
}[];
|
|
22
|
+
major: string;
|
|
23
|
+
sign: number;
|
|
24
|
+
};
|
|
25
|
+
declare function Amount({ value, currency, locale, minorUnits, notation, decimals, tone, signDisplay, classNames, render, className, title, ...props }: AmountProps): React.JSX.Element;
|
|
26
|
+
export { Amount, type AmountPart, type AmountProps, type AmountTone, type AmountValue, formatAmount, };
|
|
27
|
+
//# sourceMappingURL=amount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amount.d.ts","sourceRoot":"","sources":["../../../src/components/domain/amount.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAA;AAKnC,KAAK,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;AAE3C,KAAK,UAAU,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,CAAA;AAEjD,KAAK,UAAU,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAA;AAE1E,UAAU,WAAY,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC;IACpF,KAAK,EAAE,WAAW,CAAA;IAElB,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf,UAAU,CAAC,EAAE,OAAO,CAAA;IAKpB,QAAQ,CAAC,EAAE,UAAU,GAAG,OAAO,GAAG,SAAS,CAAA;IAE3C,QAAQ,CAAC,EAAE,MAAM,CAAA;IAMjB,IAAI,CAAC,EAAE,UAAU,GAAG,MAAM,CAAA;IAK1B,WAAW,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAA;IAErD,UAAU,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAA;IAEhD,MAAM,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CACrD;AAwCD,iBAAS,YAAY,CACnB,KAAK,EAAE,WAAW,EAClB,EACE,QAAgB,EAChB,MAAgB,EAChB,UAAkB,EAClB,QAAqB,EACrB,QAAQ,EACR,WAAoB,GACrB,GAAE,IAAI,CACL,WAAW,EACX,UAAU,GAAG,QAAQ,GAAG,YAAY,GAAG,UAAU,GAAG,UAAU,GAAG,aAAa,CAC1E,GACL;IAAE,KAAK,EAAE;QAAE,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CA0C3F;AAQD,iBAAS,MAAM,CAAC,EACd,KAAK,EACL,QAAQ,EACR,MAAM,EACN,UAAU,EACV,QAAqB,EACrB,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,UAAe,EACf,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,KAAK,EACT,EAAE,WAAW,qBA4Cb;AAED,OAAO,EACL,MAAM,EACN,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,YAAY,GACb,CAAA"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cloneElement } from "react";
|
|
3
|
+
import { cn } from "../../lib/utils.js";
|
|
4
|
+
const TONE_CLASS = {
|
|
5
|
+
credit: "text-[color:var(--money-credit,var(--color-accent-green))]",
|
|
6
|
+
debit: "text-[color:var(--money-debit,var(--color-text-primary))]",
|
|
7
|
+
transfer: "text-[color:var(--money-transfer,var(--color-text-muted))]",
|
|
8
|
+
};
|
|
9
|
+
const PART_OF = {
|
|
10
|
+
minusSign: "sign",
|
|
11
|
+
plusSign: "sign",
|
|
12
|
+
currency: "currency",
|
|
13
|
+
integer: "integer",
|
|
14
|
+
group: "integer",
|
|
15
|
+
decimal: "fraction",
|
|
16
|
+
fraction: "fraction",
|
|
17
|
+
compact: "compact",
|
|
18
|
+
};
|
|
19
|
+
const LAKH_CRORE = /^(en-IN|hi|bn|ta|te|mr|gu|kn|ml|pa|or|as)\b/;
|
|
20
|
+
function toMajor(v, digits, minor) {
|
|
21
|
+
if (typeof v === "bigint") {
|
|
22
|
+
if (!minor || digits === 0)
|
|
23
|
+
return v.toString();
|
|
24
|
+
const neg = v < 0n;
|
|
25
|
+
const s = (neg ? -v : v).toString().padStart(digits + 1, "0");
|
|
26
|
+
return `${neg ? "-" : ""}${s.slice(0, -digits)}.${s.slice(-digits)}`;
|
|
27
|
+
}
|
|
28
|
+
const n = typeof v === "string" ? Number.parseFloat(v) : v;
|
|
29
|
+
if (!Number.isFinite(n))
|
|
30
|
+
return 0;
|
|
31
|
+
return minor ? n / 10 ** digits : n;
|
|
32
|
+
}
|
|
33
|
+
function formatAmount(value, { currency = "INR", locale = "en-IN", minorUnits = false, notation = "standard", decimals, signDisplay = "auto", } = {}) {
|
|
34
|
+
const digits = new Intl.NumberFormat(locale, { style: "currency", currency }).resolvedOptions()
|
|
35
|
+
.maximumFractionDigits ?? 2;
|
|
36
|
+
const major = toMajor(value, digits, minorUnits);
|
|
37
|
+
const n = Number(major);
|
|
38
|
+
const base = { style: "currency", currency, signDisplay };
|
|
39
|
+
let raw;
|
|
40
|
+
if (notation === "compact" && LAKH_CRORE.test(locale) && Math.abs(n) >= 1e5) {
|
|
41
|
+
const [scale, suffix] = Math.abs(n) >= 1e7 ? [1e7, "Cr"] : [1e5, "L"];
|
|
42
|
+
raw = [
|
|
43
|
+
...new Intl.NumberFormat(locale, {
|
|
44
|
+
...base,
|
|
45
|
+
minimumFractionDigits: 0,
|
|
46
|
+
maximumFractionDigits: decimals ?? 1,
|
|
47
|
+
}).formatToParts(n / scale),
|
|
48
|
+
{ type: "compact", value: suffix },
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
else if (notation === "compact" && !LAKH_CRORE.test(locale)) {
|
|
52
|
+
raw = new Intl.NumberFormat(locale, {
|
|
53
|
+
...base,
|
|
54
|
+
notation: "compact",
|
|
55
|
+
maximumFractionDigits: decimals ?? 1,
|
|
56
|
+
}).formatToParts(n);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
const d = notation === "standard" ? (decimals ?? digits) : 0;
|
|
60
|
+
raw = new Intl.NumberFormat(locale, {
|
|
61
|
+
...base,
|
|
62
|
+
minimumFractionDigits: d,
|
|
63
|
+
maximumFractionDigits: d,
|
|
64
|
+
}).formatToParts(major);
|
|
65
|
+
}
|
|
66
|
+
const parts = [];
|
|
67
|
+
for (const p of raw) {
|
|
68
|
+
const type = PART_OF[p.type] ?? "literal";
|
|
69
|
+
const last = parts[parts.length - 1];
|
|
70
|
+
if (last && last.type === type && type !== "literal")
|
|
71
|
+
last.value += p.value;
|
|
72
|
+
else
|
|
73
|
+
parts.push({ type, value: p.value });
|
|
74
|
+
}
|
|
75
|
+
return { parts, major: String(major), sign: Math.sign(n) || 0 };
|
|
76
|
+
}
|
|
77
|
+
function Amount({ value, currency, locale, minorUnits, notation = "standard", decimals, tone, signDisplay, classNames = {}, render, className, title, ...props }) {
|
|
78
|
+
const { parts, major, sign } = formatAmount(value, {
|
|
79
|
+
currency,
|
|
80
|
+
locale,
|
|
81
|
+
minorUnits,
|
|
82
|
+
notation,
|
|
83
|
+
decimals,
|
|
84
|
+
signDisplay: signDisplay ?? (tone === "auto" ? "exceptZero" : "auto"),
|
|
85
|
+
});
|
|
86
|
+
const resolved = tone === "auto" ? (sign > 0 ? "credit" : sign < 0 ? "debit" : undefined) : tone;
|
|
87
|
+
const children = parts.map((p, i) => p.type === "literal" ? (p.value) : (_jsx("span", { "data-part": p.type, className: classNames[p.type], children: p.value }, i)));
|
|
88
|
+
const merged = {
|
|
89
|
+
"data-slot": "amount",
|
|
90
|
+
"data-tone": resolved,
|
|
91
|
+
"data-sign": sign > 0 ? "positive" : sign < 0 ? "negative" : "zero",
|
|
92
|
+
value: major,
|
|
93
|
+
title: title ??
|
|
94
|
+
(notation === "compact"
|
|
95
|
+
? formatAmount(value, { currency, locale, minorUnits })
|
|
96
|
+
.parts.map((p) => p.value)
|
|
97
|
+
.join("")
|
|
98
|
+
: undefined),
|
|
99
|
+
className: cn("whitespace-nowrap tabular-nums", resolved && TONE_CLASS[resolved], className),
|
|
100
|
+
...props,
|
|
101
|
+
};
|
|
102
|
+
if (render) {
|
|
103
|
+
return cloneElement(render, { ...merged, className: cn(merged.className, render.props.className) }, children);
|
|
104
|
+
}
|
|
105
|
+
return _jsx("data", { ...merged, children: children });
|
|
106
|
+
}
|
|
107
|
+
export { Amount, formatAmount, };
|
|
108
|
+
//# sourceMappingURL=amount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amount.js","sourceRoot":"","sources":["../../../src/components/domain/amount.tsx"],"names":[],"mappings":";AASA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AACpC,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAA;AAyCvC,MAAM,UAAU,GAA+B;IAC7C,MAAM,EAAE,4DAA4D;IACpE,KAAK,EAAE,2DAA2D;IAClE,QAAQ,EAAE,4DAA4D;CACvE,CAAA;AAED,MAAM,OAAO,GAAwE;IACnF,SAAS,EAAE,MAAM;IACjB,QAAQ,EAAE,MAAM;IAChB,QAAQ,EAAE,UAAU;IACpB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,SAAS;IAChB,OAAO,EAAE,UAAU;IACnB,QAAQ,EAAE,UAAU;IACpB,OAAO,EAAE,SAAS;CACnB,CAAA;AAGD,MAAM,UAAU,GAAG,6CAA6C,CAAA;AAGhE,SAAS,OAAO,CAAC,CAAc,EAAE,MAAc,EAAE,KAAc;IAC7D,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,IAAI,CAAC,KAAK,IAAI,MAAM,KAAK,CAAC;YAAE,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAA;QAC/C,MAAM,GAAG,GAAG,CAAC,GAAG,EAAE,CAAA;QAClB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EA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M,CAAC,KAAK,CAAC,SAAmB,CAAC,EAAE,EAChF,QAAQ,CACT,CAAA;IACH,CAAC;IACD,OAAO,kBAAU,MAAM,YAAG,QAAQ,GAAQ,CAAA;AAC5C,CAAC;AAED,OAAO,EACL,MAAM,EAKN,YAAY,GACb,CAAA"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import { csvField, detectDelimiter, parseCsv, toCsv } from "../../lib/csv.js";
|
|
3
|
+
export { csvField, detectDelimiter, parseCsv, toCsv };
|
|
4
|
+
export type CsvField = {
|
|
5
|
+
key: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
aliases?: string[];
|
|
8
|
+
required?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type CsvSchema<T> = {
|
|
11
|
+
safeParse(value: unknown): {
|
|
12
|
+
success: true;
|
|
13
|
+
data: T;
|
|
14
|
+
} | {
|
|
15
|
+
success: false;
|
|
16
|
+
error: {
|
|
17
|
+
issues: ReadonlyArray<{
|
|
18
|
+
path: ReadonlyArray<PropertyKey>;
|
|
19
|
+
message: string;
|
|
20
|
+
}>;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export type CsvMapping = Record<string, number | null>;
|
|
25
|
+
export type CsvRowResult<T> = {
|
|
26
|
+
line: number;
|
|
27
|
+
input: Record<string, string>;
|
|
28
|
+
data?: T;
|
|
29
|
+
errors: Record<string, string>;
|
|
30
|
+
};
|
|
31
|
+
export type CsvImportReport = {
|
|
32
|
+
inserted: number;
|
|
33
|
+
skipped?: number;
|
|
34
|
+
errors?: ReadonlyArray<{
|
|
35
|
+
row: number;
|
|
36
|
+
field?: string;
|
|
37
|
+
message: string;
|
|
38
|
+
}>;
|
|
39
|
+
};
|
|
40
|
+
export declare function autoMatch(headers: readonly string[], fields: readonly CsvField[]): CsvMapping;
|
|
41
|
+
export declare function validateRows<T>(rows: readonly (readonly string[])[], fields: readonly CsvField[], mapping: CsvMapping, schema?: CsvSchema<T>): CsvRowResult<T>[];
|
|
42
|
+
export declare const DEFAULT_CSV_IMPORT_LABELS: {
|
|
43
|
+
title: string;
|
|
44
|
+
file: string;
|
|
45
|
+
paste: string;
|
|
46
|
+
pastePlaceholder: string;
|
|
47
|
+
next: string;
|
|
48
|
+
back: string;
|
|
49
|
+
empty: string;
|
|
50
|
+
mapTitle: string;
|
|
51
|
+
column: string;
|
|
52
|
+
field: string;
|
|
53
|
+
none: string;
|
|
54
|
+
required: string;
|
|
55
|
+
missing: (labels: string) => string;
|
|
56
|
+
reviewTitle: string;
|
|
57
|
+
summary: (valid: number, invalid: number) => string;
|
|
58
|
+
onlyErrors: string;
|
|
59
|
+
line: string;
|
|
60
|
+
showing: (shown: number, total: number) => string;
|
|
61
|
+
import: (n: number) => string;
|
|
62
|
+
importing: string;
|
|
63
|
+
failed: string;
|
|
64
|
+
done: (r: CsvImportReport) => string;
|
|
65
|
+
downloadErrors: string;
|
|
66
|
+
again: string;
|
|
67
|
+
};
|
|
68
|
+
export type CsvImportLabels = typeof DEFAULT_CSV_IMPORT_LABELS;
|
|
69
|
+
type Part = "root" | "title" | "source" | "mapping" | "review" | "table" | "cell" | "error" | "actions" | "status";
|
|
70
|
+
export type CsvImportProps<T> = Omit<React.ComponentProps<"section">, "children"> & {
|
|
71
|
+
fields: readonly CsvField[];
|
|
72
|
+
schema?: CsvSchema<T>;
|
|
73
|
+
onImport: (rows: T[]) => Promise<CsvImportReport | undefined> | CsvImportReport | undefined;
|
|
74
|
+
delimiter?: string;
|
|
75
|
+
previewRows?: number;
|
|
76
|
+
maxBytes?: number;
|
|
77
|
+
labels?: Partial<CsvImportLabels>;
|
|
78
|
+
classNames?: Partial<Record<Part, string>>;
|
|
79
|
+
};
|
|
80
|
+
export declare function CsvImport<T = Record<string, string>>({ fields, schema, onImport, delimiter, previewRows, maxBytes, labels: labelsProp, classNames, className, ...props }: CsvImportProps<T>): React.JSX.Element;
|
|
81
|
+
//# sourceMappingURL=csv-import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