@wealth-os/design-system 0.0.0-stage → 0.1.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/LICENSE +201 -0
- package/README.md +81 -2
- package/dist/button-MVZPcSXf.js +41 -0
- package/dist/charts.d.ts +138 -0
- package/dist/charts.js +712 -0
- package/dist/command-menu.d.ts +3 -0
- package/dist/command-menu.js +41 -0
- package/dist/components/advanced-controls.d.ts +138 -0
- package/dist/components/badge.d.ts +9 -0
- package/dist/components/button-group.d.ts +15 -0
- package/dist/components/button.d.ts +11 -0
- package/dist/components/command-menu.d.ts +42 -0
- package/dist/components/data-display.d.ts +100 -0
- package/dist/components/data-table.d.ts +113 -0
- package/dist/components/date-input.d.ts +34 -0
- package/dist/components/date-range-picker.d.ts +21 -0
- package/dist/components/field.d.ts +18 -0
- package/dist/components/financial.d.ts +83 -0
- package/dist/components/form.d.ts +8 -0
- package/dist/components/icon-button.d.ts +11 -0
- package/dist/components/icons.d.ts +9 -0
- package/dist/components/navigation.d.ts +47 -0
- package/dist/components/notice.d.ts +11 -0
- package/dist/components/number-input.d.ts +42 -0
- package/dist/components/overlays.d.ts +91 -0
- package/dist/components/select-menu.d.ts +25 -0
- package/dist/components/select.d.ts +21 -0
- package/dist/components/status-badge.d.ts +9 -0
- package/dist/components/surface.d.ts +15 -0
- package/dist/components/text-input.d.ts +6 -0
- package/dist/components/textarea.d.ts +5 -0
- package/dist/components/validation-message.d.ts +8 -0
- package/dist/data-display-BA7t1E4G.js +278 -0
- package/dist/data-table.d.ts +2 -0
- package/dist/data-table.js +346 -0
- package/dist/financial.d.ts +1 -0
- package/dist/financial.js +178 -0
- package/dist/form-D3G5306m.js +74 -0
- package/dist/forms.d.ts +39 -0
- package/dist/forms.js +32 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +1382 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/navigation.d.ts +3 -0
- package/dist/navigation.js +222 -0
- package/dist/notice-D5u9rkFU.js +49 -0
- package/dist/overlays-9ArfwHJo.js +219 -0
- package/dist/overlays.d.ts +7 -0
- package/dist/overlays.js +2 -0
- package/dist/reset.css +16 -0
- package/dist/styles.css +3 -0
- package/dist/tokens.css +118 -0
- package/dist/utils-CX-Pz5p6.js +8 -0
- package/docs/accessibility.md +128 -0
- package/docs/charts.md +47 -0
- package/docs/components.md +242 -0
- package/docs/data-table.md +87 -0
- package/docs/layout-composition.md +224 -0
- package/docs/tokens.md +94 -0
- package/package.json +116 -4
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
/* empty css */
|
|
2
|
+
import { t as e } from "./utils-CX-Pz5p6.js";
|
|
3
|
+
import { t } from "./button-MVZPcSXf.js";
|
|
4
|
+
import { S as n, b as r, g as ee, h as te, p as ne, s as re, v as i, x as ie } from "./data-display-BA7t1E4G.js";
|
|
5
|
+
import { K as a, X as o, Y as s } from "./overlays-9ArfwHJo.js";
|
|
6
|
+
import * as c from "react";
|
|
7
|
+
import { Fragment as ae, jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
8
|
+
import { columnFilteringFeature as d, columnPinningFeature as f, columnResizingFeature as p, columnSizingFeature as m, columnVisibilityFeature as h, createColumnHelper as g, createCoreRowModel as _, createExpandedRowModel as v, createFilteredRowModel as y, createPaginatedRowModel as b, createSortedRowModel as x, filterFn_includesString as S, globalFilteringFeature as C, rowExpandingFeature as w, rowPaginationFeature as T, rowSelectionFeature as E, rowSortingFeature as D, sortFn_alphanumeric as O, sortFn_text as k, tableFeatures as A, useTable as oe } from "@tanstack/react-table";
|
|
9
|
+
//#region src/components/data-table.tsx
|
|
10
|
+
var se = A({
|
|
11
|
+
rowSortingFeature: D,
|
|
12
|
+
columnFilteringFeature: d,
|
|
13
|
+
globalFilteringFeature: C,
|
|
14
|
+
rowPaginationFeature: T,
|
|
15
|
+
rowSelectionFeature: E,
|
|
16
|
+
columnVisibilityFeature: h,
|
|
17
|
+
columnSizingFeature: m,
|
|
18
|
+
columnResizingFeature: p,
|
|
19
|
+
columnPinningFeature: f,
|
|
20
|
+
rowExpandingFeature: w,
|
|
21
|
+
coreRowModel: _(),
|
|
22
|
+
filteredRowModel: y(),
|
|
23
|
+
sortedRowModel: x(),
|
|
24
|
+
paginatedRowModel: b(),
|
|
25
|
+
expandedRowModel: v(),
|
|
26
|
+
sortFns: {
|
|
27
|
+
alphanumeric: O,
|
|
28
|
+
text: k
|
|
29
|
+
},
|
|
30
|
+
filterFns: { includesString: S }
|
|
31
|
+
});
|
|
32
|
+
function j() {
|
|
33
|
+
return g();
|
|
34
|
+
}
|
|
35
|
+
function M(e) {
|
|
36
|
+
return "columns" in e && Array.isArray(e.columns) ? {
|
|
37
|
+
...e,
|
|
38
|
+
columns: e.columns.map((e) => M(e))
|
|
39
|
+
} : "accessorKey" in e || "accessorFn" in e ? {
|
|
40
|
+
...e,
|
|
41
|
+
filterFn: e.filterFn ?? "includesString"
|
|
42
|
+
} : e;
|
|
43
|
+
}
|
|
44
|
+
function N({ columns: d, data: f, getRowId: p, density: m = "comfortable", caption: h, ariaLabel: g = "Data table", enableSorting: _ = !0, enableFiltering: v = !0, enableGlobalFilter: y = !0, enablePagination: b = !0, enableRowSelection: x = !1, enableColumnVisibility: S = !1, enableColumnResizing: C = !1, enableColumnPinning: w = !1, enableExpanding: T = !1, renderSubComponent: E, loading: D = !1, loadingLabel: O = "Loading data", error: k, emptyState: A, pageSizeOptions: j = [
|
|
45
|
+
10,
|
|
46
|
+
20,
|
|
47
|
+
50
|
|
48
|
+
], manualSorting: N = !1, manualFiltering: ce = !1, manualPagination: le = !1, pageCount: P, rowCount: F, state: ue, initialState: I, onSortingChange: L, onColumnFiltersChange: R, onGlobalFilterChange: z, onPaginationChange: B, onRowSelectionChange: V, onColumnVisibilityChange: H, onColumnSizingChange: U, onColumnPinningChange: W, onExpandedChange: G, className: de, toolbar: K }) {
|
|
49
|
+
let fe = c.useMemo(() => d.map(M), [d]), q = oe({
|
|
50
|
+
features: se,
|
|
51
|
+
columns: fe,
|
|
52
|
+
data: f ?? [],
|
|
53
|
+
...p ? { getRowId: p } : {},
|
|
54
|
+
...I ? { initialState: I } : {},
|
|
55
|
+
...ue ? { state: ue } : {},
|
|
56
|
+
...L ? { onSortingChange: L } : {},
|
|
57
|
+
...R ? { onColumnFiltersChange: R } : {},
|
|
58
|
+
...z ? { onGlobalFilterChange: z } : {},
|
|
59
|
+
...B ? { onPaginationChange: B } : {},
|
|
60
|
+
...V ? { onRowSelectionChange: V } : {},
|
|
61
|
+
...H ? { onColumnVisibilityChange: H } : {},
|
|
62
|
+
...U ? { onColumnSizingChange: U } : {},
|
|
63
|
+
...W ? { onColumnPinningChange: W } : {},
|
|
64
|
+
...G ? { onExpandedChange: G } : {},
|
|
65
|
+
manualSorting: N,
|
|
66
|
+
manualFiltering: ce,
|
|
67
|
+
...P == null ? {} : { pageCount: P },
|
|
68
|
+
...F == null ? {} : { rowCount: F },
|
|
69
|
+
enableRowSelection: x,
|
|
70
|
+
enableSorting: _,
|
|
71
|
+
enableColumnFilters: v,
|
|
72
|
+
enableGlobalFilter: y,
|
|
73
|
+
enableColumnPinning: w,
|
|
74
|
+
enableColumnResizing: C,
|
|
75
|
+
enableExpanding: T,
|
|
76
|
+
getSubRows: (e) => e.subRows,
|
|
77
|
+
getRowCanExpand: () => !!E,
|
|
78
|
+
manualPagination: le || !b
|
|
79
|
+
}), J = q.getRowModel().rows, Y = q.getVisibleLeafColumns(), X = v ? q.getAllLeafColumns().filter((e) => e.getCanFilter()) : [], Z = S ? q.getAllLeafColumns().filter((e) => e.getCanHide()) : [], Q = q.state.columnFilters?.length ?? 0, $ = Object.values(q.state.rowSelection ?? {}).filter(Boolean).length, pe = (e) => e.getIsSorted() === "asc" ? "Sorted ascending" : e.getIsSorted() === "desc" ? "Sorted descending" : "Not sorted";
|
|
80
|
+
return /* @__PURE__ */ u("div", {
|
|
81
|
+
className: e("wos-data-table", de),
|
|
82
|
+
children: [
|
|
83
|
+
(y || X.length > 0 || Z.length > 0 || K) && /* @__PURE__ */ u("div", {
|
|
84
|
+
className: "wos-data-table-toolbar",
|
|
85
|
+
children: [y && /* @__PURE__ */ u("label", {
|
|
86
|
+
className: "wos-data-table-search",
|
|
87
|
+
children: [
|
|
88
|
+
" ",
|
|
89
|
+
/* @__PURE__ */ l("span", {
|
|
90
|
+
className: "sr-only",
|
|
91
|
+
children: "Search all columns"
|
|
92
|
+
}),
|
|
93
|
+
/* @__PURE__ */ l("input", {
|
|
94
|
+
className: "wos-field",
|
|
95
|
+
type: "search",
|
|
96
|
+
value: q.state.globalFilter ?? "",
|
|
97
|
+
onChange: (e) => q.setGlobalFilter(e.target.value),
|
|
98
|
+
placeholder: "Search…"
|
|
99
|
+
})
|
|
100
|
+
]
|
|
101
|
+
}), /* @__PURE__ */ u("div", {
|
|
102
|
+
className: "wos-data-table-tools",
|
|
103
|
+
children: [
|
|
104
|
+
K,
|
|
105
|
+
X.length > 0 && /* @__PURE__ */ u(a, { children: [/* @__PURE__ */ l(o, {
|
|
106
|
+
asChild: !0,
|
|
107
|
+
children: /* @__PURE__ */ u(t, {
|
|
108
|
+
variant: "outline",
|
|
109
|
+
size: "sm",
|
|
110
|
+
"aria-label": Q > 0 ? `Filters, ${Q} active` : "Filters",
|
|
111
|
+
children: ["Filters", Q > 0 && /* @__PURE__ */ l("span", {
|
|
112
|
+
className: "wos-data-table-filter-count",
|
|
113
|
+
"aria-hidden": "true",
|
|
114
|
+
children: Q
|
|
115
|
+
})]
|
|
116
|
+
})
|
|
117
|
+
}), /* @__PURE__ */ u(s, {
|
|
118
|
+
align: "end",
|
|
119
|
+
"aria-label": "Column filters",
|
|
120
|
+
className: "wos-data-table-filter-menu",
|
|
121
|
+
children: [X.map((e) => /* @__PURE__ */ u("label", { children: [/* @__PURE__ */ u("span", {
|
|
122
|
+
className: "type-metadata",
|
|
123
|
+
children: ["Filter ", e.id]
|
|
124
|
+
}), /* @__PURE__ */ l("input", {
|
|
125
|
+
className: "wos-field",
|
|
126
|
+
"aria-label": `Filter ${e.id}`,
|
|
127
|
+
value: e.getFilterValue() ?? "",
|
|
128
|
+
onChange: (t) => e.setFilterValue(t.target.value)
|
|
129
|
+
})] }, e.id)), Q > 0 && /* @__PURE__ */ l(t, {
|
|
130
|
+
variant: "ghost",
|
|
131
|
+
size: "sm",
|
|
132
|
+
className: "wos-data-table-clear-filters",
|
|
133
|
+
onClick: () => q.resetColumnFilters(),
|
|
134
|
+
children: "Clear filters"
|
|
135
|
+
})]
|
|
136
|
+
})] }),
|
|
137
|
+
Z.length > 0 && /* @__PURE__ */ u(a, { children: [/* @__PURE__ */ l(o, {
|
|
138
|
+
asChild: !0,
|
|
139
|
+
children: /* @__PURE__ */ l(t, {
|
|
140
|
+
variant: "outline",
|
|
141
|
+
size: "sm",
|
|
142
|
+
children: "Columns"
|
|
143
|
+
})
|
|
144
|
+
}), /* @__PURE__ */ l(s, {
|
|
145
|
+
align: "end",
|
|
146
|
+
"aria-label": "Visible columns",
|
|
147
|
+
className: "wos-column-menu",
|
|
148
|
+
children: Z.map((e) => /* @__PURE__ */ u("label", { children: [/* @__PURE__ */ l("input", {
|
|
149
|
+
type: "checkbox",
|
|
150
|
+
checked: e.getIsVisible(),
|
|
151
|
+
onChange: e.getToggleVisibilityHandler()
|
|
152
|
+
}), e.id] }, e.id))
|
|
153
|
+
})] })
|
|
154
|
+
]
|
|
155
|
+
})]
|
|
156
|
+
}),
|
|
157
|
+
x && $ > 0 && /* @__PURE__ */ u("div", {
|
|
158
|
+
className: "wos-data-table-selection",
|
|
159
|
+
role: "status",
|
|
160
|
+
children: [
|
|
161
|
+
$,
|
|
162
|
+
" row",
|
|
163
|
+
$ === 1 ? "" : "s",
|
|
164
|
+
" selected"
|
|
165
|
+
]
|
|
166
|
+
}),
|
|
167
|
+
k ? /* @__PURE__ */ l("div", {
|
|
168
|
+
className: "wos-data-table-message",
|
|
169
|
+
role: "alert",
|
|
170
|
+
children: k
|
|
171
|
+
}) : /* @__PURE__ */ u(ae, { children: [/* @__PURE__ */ l("div", {
|
|
172
|
+
className: "wos-data-table-scroller",
|
|
173
|
+
"aria-busy": D || void 0,
|
|
174
|
+
children: D ? /* @__PURE__ */ u("div", {
|
|
175
|
+
role: "status",
|
|
176
|
+
className: "wos-data-table-loading",
|
|
177
|
+
children: [/* @__PURE__ */ l("span", {
|
|
178
|
+
className: "sr-only",
|
|
179
|
+
children: O
|
|
180
|
+
}), Array.from({ length: 4 }, (e, t) => /* @__PURE__ */ l(ne, { height: m === "compact" ? 30 : 42 }, t))]
|
|
181
|
+
}) : /* @__PURE__ */ u(te, {
|
|
182
|
+
density: m,
|
|
183
|
+
"aria-label": g,
|
|
184
|
+
style: {
|
|
185
|
+
width: q.getTotalSize(),
|
|
186
|
+
minWidth: "100%",
|
|
187
|
+
tableLayout: "fixed"
|
|
188
|
+
},
|
|
189
|
+
children: [
|
|
190
|
+
h && /* @__PURE__ */ l("caption", {
|
|
191
|
+
className: "wos-table-caption wos-data-table-caption",
|
|
192
|
+
children: h
|
|
193
|
+
}),
|
|
194
|
+
/* @__PURE__ */ l(ie, { children: q.getHeaderGroups().map((e, t) => /* @__PURE__ */ u(n, { children: [(x || T) && /* @__PURE__ */ l(r, {
|
|
195
|
+
className: "wos-data-table-select-head",
|
|
196
|
+
rowSpan: t === 0 ? q.getHeaderGroups().length : void 0,
|
|
197
|
+
children: x && t === 0 && /* @__PURE__ */ l("input", {
|
|
198
|
+
type: "checkbox",
|
|
199
|
+
"aria-label": "Select rows on this page",
|
|
200
|
+
checked: q.getIsAllPageRowsSelected(),
|
|
201
|
+
ref: (e) => {
|
|
202
|
+
e && (e.indeterminate = q.getIsSomePageRowsSelected());
|
|
203
|
+
},
|
|
204
|
+
onChange: q.getToggleAllPageRowsSelectedHandler()
|
|
205
|
+
})
|
|
206
|
+
}), e.headers.map((e) => /* @__PURE__ */ l(r, {
|
|
207
|
+
scope: "col",
|
|
208
|
+
"aria-sort": e.column.getCanSort() ? e.column.getIsSorted() === "asc" ? "ascending" : e.column.getIsSorted() === "desc" ? "descending" : "none" : void 0,
|
|
209
|
+
style: {
|
|
210
|
+
width: e.getSize(),
|
|
211
|
+
position: e.column.getIsPinned() ? "sticky" : void 0,
|
|
212
|
+
insetInlineStart: e.column.getIsPinned() === "start" ? e.column.getStart("start") : void 0,
|
|
213
|
+
insetInlineEnd: e.column.getIsPinned() === "end" ? e.column.getAfter("end") : void 0
|
|
214
|
+
},
|
|
215
|
+
children: e.isPlaceholder ? null : /* @__PURE__ */ u("div", {
|
|
216
|
+
className: "wos-data-table-heading",
|
|
217
|
+
children: [
|
|
218
|
+
e.column.getCanSort() ? /* @__PURE__ */ u("button", {
|
|
219
|
+
type: "button",
|
|
220
|
+
className: "wos-data-table-sort",
|
|
221
|
+
onClick: () => e.column.toggleSorting(),
|
|
222
|
+
"aria-label": `${String(e.column.columnDef.header ?? e.column.id)}. ${pe(e.column)}. Activate to change sort.`,
|
|
223
|
+
children: [/* @__PURE__ */ l(q.FlexRender, { header: e }), /* @__PURE__ */ l("span", {
|
|
224
|
+
"aria-hidden": "true",
|
|
225
|
+
children: e.column.getIsSorted() === "asc" ? " ↑" : e.column.getIsSorted() === "desc" ? " ↓" : " ↕"
|
|
226
|
+
})]
|
|
227
|
+
}) : /* @__PURE__ */ l(q.FlexRender, { header: e }),
|
|
228
|
+
w && e.column.getCanPin() && /* @__PURE__ */ l("button", {
|
|
229
|
+
className: "wos-data-table-pin",
|
|
230
|
+
type: "button",
|
|
231
|
+
"aria-label": `${e.column.getIsPinned() ? "Unpin" : "Pin"} ${e.column.id} ${e.column.getIsPinned() ? "column" : "column to start"}`,
|
|
232
|
+
onClick: () => e.column.pin(e.column.getIsPinned() !== "start" && "start"),
|
|
233
|
+
children: e.column.getIsPinned() === "start" ? "Unpin" : "Pin"
|
|
234
|
+
}),
|
|
235
|
+
C && e.column.getCanResize() && /* @__PURE__ */ l("button", {
|
|
236
|
+
className: "wos-column-resizer",
|
|
237
|
+
type: "button",
|
|
238
|
+
"aria-label": `Resize ${e.column.id} column`,
|
|
239
|
+
onMouseDown: e.getResizeHandler(),
|
|
240
|
+
onTouchStart: e.getResizeHandler(),
|
|
241
|
+
onKeyDown: (t) => {
|
|
242
|
+
let n = t.key === "ArrowRight" ? 16 : t.key === "ArrowLeft" ? -16 : 0;
|
|
243
|
+
n && (t.preventDefault(), q.setColumnSizing((t) => ({
|
|
244
|
+
...t,
|
|
245
|
+
[e.column.id]: Math.min(e.column.columnDef.maxSize ?? 800, Math.max(e.column.columnDef.minSize ?? 40, e.column.getSize() + n))
|
|
246
|
+
})));
|
|
247
|
+
}
|
|
248
|
+
})
|
|
249
|
+
]
|
|
250
|
+
})
|
|
251
|
+
}, e.id))] }, e.id)) }),
|
|
252
|
+
/* @__PURE__ */ l(ee, { children: J.length === 0 ? /* @__PURE__ */ l(n, { children: /* @__PURE__ */ l(i, {
|
|
253
|
+
colSpan: Y.length + (x || T ? 1 : 0),
|
|
254
|
+
children: A ?? /* @__PURE__ */ l(re, {
|
|
255
|
+
title: "No results",
|
|
256
|
+
description: "Try adjusting your search or filters."
|
|
257
|
+
})
|
|
258
|
+
}) }) : J.map((e) => /* @__PURE__ */ u(c.Fragment, { children: [/* @__PURE__ */ u(n, {
|
|
259
|
+
"data-selected": e.getIsSelected() || void 0,
|
|
260
|
+
"aria-selected": x ? e.getIsSelected() : void 0,
|
|
261
|
+
children: [(x || T) && /* @__PURE__ */ u(i, {
|
|
262
|
+
className: "wos-data-table-select-cell",
|
|
263
|
+
children: [x && /* @__PURE__ */ l("input", {
|
|
264
|
+
type: "checkbox",
|
|
265
|
+
"aria-label": `Select row ${e.id}`,
|
|
266
|
+
checked: e.getIsSelected(),
|
|
267
|
+
disabled: !e.getCanSelect(),
|
|
268
|
+
onChange: e.getToggleSelectedHandler()
|
|
269
|
+
}), T && e.getCanExpand() && /* @__PURE__ */ l("button", {
|
|
270
|
+
type: "button",
|
|
271
|
+
className: "wos-data-table-expand",
|
|
272
|
+
"aria-expanded": e.getIsExpanded(),
|
|
273
|
+
"aria-label": `${e.getIsExpanded() ? "Collapse" : "Expand"} row ${e.id}`,
|
|
274
|
+
onClick: e.getToggleExpandedHandler(),
|
|
275
|
+
children: e.getIsExpanded() ? "−" : "+"
|
|
276
|
+
})]
|
|
277
|
+
}), e.getVisibleCells().map((e) => /* @__PURE__ */ l(i, {
|
|
278
|
+
className: e.column.columnDef.meta?.align === "right" ? "text-right tabular" : void 0,
|
|
279
|
+
style: {
|
|
280
|
+
width: e.column.getSize(),
|
|
281
|
+
position: e.column.getIsPinned() ? "sticky" : void 0,
|
|
282
|
+
insetInlineStart: e.column.getIsPinned() === "start" ? e.column.getStart("start") : void 0,
|
|
283
|
+
insetInlineEnd: e.column.getIsPinned() === "end" ? e.column.getAfter("end") : void 0
|
|
284
|
+
},
|
|
285
|
+
children: /* @__PURE__ */ l(q.FlexRender, { cell: e })
|
|
286
|
+
}, e.id))]
|
|
287
|
+
}), T && e.getIsExpanded() && E && /* @__PURE__ */ l(n, { children: /* @__PURE__ */ l(i, {
|
|
288
|
+
colSpan: Y.length + (x || T ? 1 : 0),
|
|
289
|
+
children: E({ row: e.original })
|
|
290
|
+
}) })] }, e.id)) })
|
|
291
|
+
]
|
|
292
|
+
})
|
|
293
|
+
}), b && !D && /* @__PURE__ */ u("div", {
|
|
294
|
+
className: "wos-data-table-pagination",
|
|
295
|
+
children: [/* @__PURE__ */ u("span", {
|
|
296
|
+
className: "wos-data-table-row-count type-metadata text-muted-foreground",
|
|
297
|
+
children: [q.getRowCount(), " rows"]
|
|
298
|
+
}), /* @__PURE__ */ u("div", {
|
|
299
|
+
className: "wos-data-table-pagination-controls",
|
|
300
|
+
children: [/* @__PURE__ */ u("label", {
|
|
301
|
+
className: "type-metadata",
|
|
302
|
+
children: ["Rows per page ", /* @__PURE__ */ l("select", {
|
|
303
|
+
value: q.state.pagination?.pageSize ?? 10,
|
|
304
|
+
onChange: (e) => q.setPageSize(Number(e.target.value)),
|
|
305
|
+
children: j.map((e) => /* @__PURE__ */ l("option", {
|
|
306
|
+
value: e,
|
|
307
|
+
children: e
|
|
308
|
+
}, e))
|
|
309
|
+
})]
|
|
310
|
+
}), /* @__PURE__ */ u("div", {
|
|
311
|
+
className: "wos-data-table-page-actions",
|
|
312
|
+
children: [
|
|
313
|
+
/* @__PURE__ */ l(t, {
|
|
314
|
+
size: "sm",
|
|
315
|
+
variant: "outline",
|
|
316
|
+
onClick: () => q.previousPage(),
|
|
317
|
+
disabled: !q.getCanPreviousPage(),
|
|
318
|
+
"aria-label": "Previous page",
|
|
319
|
+
children: "Previous"
|
|
320
|
+
}),
|
|
321
|
+
/* @__PURE__ */ u("span", {
|
|
322
|
+
"aria-live": "polite",
|
|
323
|
+
className: "type-metadata",
|
|
324
|
+
children: [
|
|
325
|
+
"Page ",
|
|
326
|
+
(q.state.pagination?.pageIndex ?? 0) + 1,
|
|
327
|
+
q.getPageCount() > 0 ? ` of ${q.getPageCount()}` : ""
|
|
328
|
+
]
|
|
329
|
+
}),
|
|
330
|
+
/* @__PURE__ */ l(t, {
|
|
331
|
+
size: "sm",
|
|
332
|
+
variant: "outline",
|
|
333
|
+
onClick: () => q.nextPage(),
|
|
334
|
+
disabled: !q.getCanNextPage(),
|
|
335
|
+
"aria-label": "Next page",
|
|
336
|
+
children: "Next"
|
|
337
|
+
})
|
|
338
|
+
]
|
|
339
|
+
})]
|
|
340
|
+
})]
|
|
341
|
+
})] })
|
|
342
|
+
]
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
//#endregion
|
|
346
|
+
export { N as DataTable, j as createDataTableColumnHelper };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CurrencyValue, PercentageValue, ShareQuantity, FinancialMetric, EstimateIndicator, AllocationBar, FinancialDataTable, AssumptionNotice, type CurrencyValueProps, type PercentageValueProps, type ShareQuantityProps, type FinancialValueState, type FinancialMetricProps, type EstimateIndicatorProps, type AllocationSegment, type AllocationBarProps, type FinancialDataColumn, type FinancialDataTableProps, type AssumptionNoticeProps, } from "./components/financial";
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { t as e } from "./utils-CX-Pz5p6.js";
|
|
2
|
+
import { n as t, t as n } from "./notice-D5u9rkFU.js";
|
|
3
|
+
import { S as r, b as i, g as a, h as o, v as s, x as c } from "./data-display-BA7t1E4G.js";
|
|
4
|
+
import "react";
|
|
5
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/financial.tsx
|
|
7
|
+
function d({ value: t, formatted: n, currency: r = "USD", locale: i = "en-US", precision: a = "auto", unavailableText: o = "—", className: s, ...c }) {
|
|
8
|
+
let u = n;
|
|
9
|
+
if (u === void 0) {
|
|
10
|
+
if (t == null || !Number.isFinite(t)) u = o;
|
|
11
|
+
else {
|
|
12
|
+
let e = Number.isInteger(Math.round(t * 100) / 100), n = a === "whole" ? 0 : a === "cents" ? 2 : e ? 0 : 2;
|
|
13
|
+
u = new Intl.NumberFormat(i, {
|
|
14
|
+
style: "currency",
|
|
15
|
+
currency: r,
|
|
16
|
+
minimumFractionDigits: n,
|
|
17
|
+
maximumFractionDigits: n
|
|
18
|
+
}).format(t);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return /* @__PURE__ */ l("span", {
|
|
22
|
+
className: e("tabular-nums whitespace-nowrap", s),
|
|
23
|
+
...c,
|
|
24
|
+
children: u
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function f({ value: t, formatted: n, mode: r = "rate", locale: i = "en-US", minimumFractionDigits: a = 0, maximumFractionDigits: o = 2, unavailableText: s = "—", className: c, ...u }) {
|
|
28
|
+
let d = n;
|
|
29
|
+
return d === void 0 && (d = t == null || !Number.isFinite(t) ? s : r === "rate" ? new Intl.NumberFormat(i, {
|
|
30
|
+
style: "percent",
|
|
31
|
+
minimumFractionDigits: a,
|
|
32
|
+
maximumFractionDigits: o
|
|
33
|
+
}).format(t) : `${new Intl.NumberFormat(i, {
|
|
34
|
+
minimumFractionDigits: a,
|
|
35
|
+
maximumFractionDigits: o
|
|
36
|
+
}).format(t)} pp`), /* @__PURE__ */ l("span", {
|
|
37
|
+
className: e("tabular-nums whitespace-nowrap", c),
|
|
38
|
+
...u,
|
|
39
|
+
children: d
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function p({ value: t, formatted: n, locale: r = "en-US", maximumFractionDigits: i = 20, unit: a, unavailableText: o = "—", className: s, ...c }) {
|
|
43
|
+
let u = n;
|
|
44
|
+
return u === void 0 && (u = t == null || !Number.isFinite(t) ? o : `${new Intl.NumberFormat(r, { maximumFractionDigits: i }).format(t)} ${a ?? (t === 1 ? "share" : "shares")}`), /* @__PURE__ */ l("span", {
|
|
45
|
+
className: e("tabular-nums whitespace-nowrap", s),
|
|
46
|
+
...c,
|
|
47
|
+
children: u
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
var m = {
|
|
51
|
+
estimated: "Estimate",
|
|
52
|
+
stale: "Needs update",
|
|
53
|
+
illustrative: "Illustrative",
|
|
54
|
+
unavailable: "Unavailable"
|
|
55
|
+
};
|
|
56
|
+
function h({ state: e, labels: n, className: r, ...i }) {
|
|
57
|
+
return /* @__PURE__ */ l("span", {
|
|
58
|
+
className: r,
|
|
59
|
+
...i,
|
|
60
|
+
children: /* @__PURE__ */ l(t, {
|
|
61
|
+
status: e === "estimated" ? "estimated" : e === "stale" ? "stale" : e === "unavailable" ? "warning" : "neutral",
|
|
62
|
+
children: n?.[e] ?? m[e]
|
|
63
|
+
})
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function g({ label: t, value: n, detail: r, state: i, stateLabel: a, className: o, ...s }) {
|
|
67
|
+
return /* @__PURE__ */ u("section", {
|
|
68
|
+
className: e("wos-financial-metric", o),
|
|
69
|
+
...s,
|
|
70
|
+
children: [
|
|
71
|
+
/* @__PURE__ */ u("div", {
|
|
72
|
+
className: "wos-financial-metric-heading",
|
|
73
|
+
children: [/* @__PURE__ */ l("h3", {
|
|
74
|
+
className: "type-caption text-muted-foreground",
|
|
75
|
+
children: t
|
|
76
|
+
}), i && /* @__PURE__ */ l(h, {
|
|
77
|
+
state: i,
|
|
78
|
+
labels: a ? { [i]: a } : void 0
|
|
79
|
+
})]
|
|
80
|
+
}),
|
|
81
|
+
/* @__PURE__ */ l("div", {
|
|
82
|
+
className: "wos-financial-metric-value",
|
|
83
|
+
children: n
|
|
84
|
+
}),
|
|
85
|
+
r != null && /* @__PURE__ */ l("p", {
|
|
86
|
+
className: "wos-financial-metric-detail",
|
|
87
|
+
children: r
|
|
88
|
+
})
|
|
89
|
+
]
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
var _ = {
|
|
93
|
+
primary: "var(--primary)",
|
|
94
|
+
"chart-2": "var(--chart-2)",
|
|
95
|
+
"chart-3": "var(--chart-3)",
|
|
96
|
+
"chart-4": "var(--chart-4)",
|
|
97
|
+
"chart-5": "var(--chart-5)"
|
|
98
|
+
};
|
|
99
|
+
function v({ label: t, segments: n, showPercentages: r = !0, className: i, ...a }) {
|
|
100
|
+
let o = n.find((e) => !Number.isFinite(e.percentage) || e.percentage < 0 || e.percentage > 100);
|
|
101
|
+
if (o) throw RangeError(`AllocationBar percentage for "${o.label}" must be between 0 and 100.`);
|
|
102
|
+
return /* @__PURE__ */ u("figure", {
|
|
103
|
+
className: e("wos-allocation", i),
|
|
104
|
+
...a,
|
|
105
|
+
children: [
|
|
106
|
+
/* @__PURE__ */ l("figcaption", {
|
|
107
|
+
className: "type-label",
|
|
108
|
+
children: t
|
|
109
|
+
}),
|
|
110
|
+
/* @__PURE__ */ l("div", {
|
|
111
|
+
className: "wos-allocation-bar",
|
|
112
|
+
"aria-hidden": "true",
|
|
113
|
+
children: n.map((e, t) => /* @__PURE__ */ l("span", { style: {
|
|
114
|
+
width: `${e.percentage}%`,
|
|
115
|
+
backgroundColor: _[e.color ?? [
|
|
116
|
+
"primary",
|
|
117
|
+
"chart-2",
|
|
118
|
+
"chart-3",
|
|
119
|
+
"chart-4",
|
|
120
|
+
"chart-5"
|
|
121
|
+
][t % 5]]
|
|
122
|
+
} }, e.id ?? `${e.label}-${t}`))
|
|
123
|
+
}),
|
|
124
|
+
/* @__PURE__ */ l("ul", {
|
|
125
|
+
className: "wos-allocation-legend",
|
|
126
|
+
children: n.map((e, t) => /* @__PURE__ */ u("li", { children: [
|
|
127
|
+
/* @__PURE__ */ l("span", {
|
|
128
|
+
"aria-hidden": "true",
|
|
129
|
+
className: "wos-allocation-swatch",
|
|
130
|
+
style: { backgroundColor: _[e.color ?? [
|
|
131
|
+
"primary",
|
|
132
|
+
"chart-2",
|
|
133
|
+
"chart-3",
|
|
134
|
+
"chart-4",
|
|
135
|
+
"chart-5"
|
|
136
|
+
][t % 5]] }
|
|
137
|
+
}),
|
|
138
|
+
/* @__PURE__ */ l("span", { children: e.label }),
|
|
139
|
+
r && /* @__PURE__ */ u("span", {
|
|
140
|
+
className: "tabular-nums",
|
|
141
|
+
children: [new Intl.NumberFormat("en-US", { maximumFractionDigits: 2 }).format(e.percentage), "%"]
|
|
142
|
+
})
|
|
143
|
+
] }, e.id ?? `${e.label}-${t}`))
|
|
144
|
+
})
|
|
145
|
+
]
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function y({ caption: t, rows: n, columns: d, getRowKey: f, className: p, ...m }) {
|
|
149
|
+
return /* @__PURE__ */ u(o, {
|
|
150
|
+
className: e("wos-financial-table", p),
|
|
151
|
+
...m,
|
|
152
|
+
children: [
|
|
153
|
+
/* @__PURE__ */ l("caption", {
|
|
154
|
+
className: "wos-table-caption",
|
|
155
|
+
children: t
|
|
156
|
+
}),
|
|
157
|
+
/* @__PURE__ */ l(c, { children: /* @__PURE__ */ l(r, { children: d.map((e) => /* @__PURE__ */ l(i, {
|
|
158
|
+
scope: "col",
|
|
159
|
+
className: e.align === "end" ? "text-right" : void 0,
|
|
160
|
+
children: e.header
|
|
161
|
+
}, e.id)) }) }),
|
|
162
|
+
/* @__PURE__ */ l(a, { children: n.map((e, t) => /* @__PURE__ */ l(r, { children: d.map((t) => /* @__PURE__ */ l(s, {
|
|
163
|
+
className: t.align === "end" ? "text-right tabular-nums" : void 0,
|
|
164
|
+
children: t.cell(e)
|
|
165
|
+
}, t.id)) }, f(e, t))) })
|
|
166
|
+
]
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
function b({ variant: t = "warning", title: r = "Planning assumption", className: i, ...a }) {
|
|
170
|
+
return /* @__PURE__ */ l(n, {
|
|
171
|
+
variant: t,
|
|
172
|
+
title: r,
|
|
173
|
+
className: e("wos-assumption-notice", i),
|
|
174
|
+
...a
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
//#endregion
|
|
178
|
+
export { v as AllocationBar, b as AssumptionNotice, d as CurrencyValue, h as EstimateIndicator, y as FinancialDataTable, g as FinancialMetric, f as PercentageValue, p as ShareQuantity };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { t as e } from "./utils-CX-Pz5p6.js";
|
|
2
|
+
import * as t from "react";
|
|
3
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
4
|
+
import * as i from "@radix-ui/react-label";
|
|
5
|
+
//#region src/components/validation-message.tsx
|
|
6
|
+
var a = t.forwardRef(({ variant: t = "error", className: r, children: i, ...a }, o) => /* @__PURE__ */ n("p", {
|
|
7
|
+
...a,
|
|
8
|
+
ref: o,
|
|
9
|
+
"data-variant": t,
|
|
10
|
+
className: e("text-[length:var(--type-size-metadata)] leading-[1.35]", t === "error" ? "text-destructive" : t === "warning" ? "text-warning" : "text-info", r),
|
|
11
|
+
children: i
|
|
12
|
+
}));
|
|
13
|
+
a.displayName = "ValidationMessage";
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/components/field.tsx
|
|
16
|
+
function o({ label: o, help: s, error: c, htmlFor: l, className: u, labelClassName: d, required: f, optional: p, orientation: m = "vertical", children: h }) {
|
|
17
|
+
let g = t.useId();
|
|
18
|
+
if (f && p) throw Error("Field cannot be both required and optional.");
|
|
19
|
+
let _ = t.isValidElement(h) && !!h.props["data-field-container"], v = t.isValidElement(h) && !_ ? h : null;
|
|
20
|
+
if (l && v?.props.id && l !== v.props.id) throw Error(`Field htmlFor ("${l}") must match its child control id ("${v.props.id}").`);
|
|
21
|
+
let y = l ?? v?.props.id ?? g, b = s ? `${y}-help` : void 0, x = c ? `${y}-error` : void 0, S = [
|
|
22
|
+
v?.props["aria-describedby"],
|
|
23
|
+
b,
|
|
24
|
+
x
|
|
25
|
+
].filter(Boolean).join(" ") || void 0, C = v && t.cloneElement(v, {
|
|
26
|
+
id: y,
|
|
27
|
+
"aria-describedby": S,
|
|
28
|
+
"aria-invalid": c ? !0 : v.props["aria-invalid"],
|
|
29
|
+
required: f ?? v.props.required
|
|
30
|
+
});
|
|
31
|
+
return /* @__PURE__ */ r("div", {
|
|
32
|
+
className: e(m === "horizontal" ? "wos-field-horizontal max-[639px]:space-y-1.5" : "space-y-1.5", u),
|
|
33
|
+
children: [/* @__PURE__ */ r(i.Root, {
|
|
34
|
+
htmlFor: y,
|
|
35
|
+
className: e("block text-[length:var(--type-size-label)] font-semibold leading-[1.4] text-secondary-foreground", d),
|
|
36
|
+
children: [
|
|
37
|
+
o,
|
|
38
|
+
f && /* @__PURE__ */ n("span", {
|
|
39
|
+
className: "ml-1 font-normal text-muted-foreground",
|
|
40
|
+
children: "Required"
|
|
41
|
+
}),
|
|
42
|
+
p && /* @__PURE__ */ n("span", {
|
|
43
|
+
className: "ml-1 font-normal text-muted-foreground",
|
|
44
|
+
children: "Optional"
|
|
45
|
+
})
|
|
46
|
+
]
|
|
47
|
+
}), /* @__PURE__ */ r("div", {
|
|
48
|
+
className: "min-w-0 space-y-1.5",
|
|
49
|
+
children: [
|
|
50
|
+
C ?? h,
|
|
51
|
+
s && /* @__PURE__ */ n("p", {
|
|
52
|
+
id: b,
|
|
53
|
+
className: "text-[length:var(--type-size-metadata)] leading-[1.35] text-muted-foreground",
|
|
54
|
+
children: s
|
|
55
|
+
}),
|
|
56
|
+
c && /* @__PURE__ */ n(a, {
|
|
57
|
+
id: x,
|
|
58
|
+
children: c
|
|
59
|
+
})
|
|
60
|
+
]
|
|
61
|
+
})]
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/components/form.tsx
|
|
66
|
+
var s = t.forwardRef(({ className: t, ...r }, i) => /* @__PURE__ */ n("form", {
|
|
67
|
+
ref: i,
|
|
68
|
+
className: e("space-y-4", t),
|
|
69
|
+
...r
|
|
70
|
+
}));
|
|
71
|
+
s.displayName = "Form";
|
|
72
|
+
var c = o;
|
|
73
|
+
//#endregion
|
|
74
|
+
export { a as i, c as n, o as r, s as t };
|
package/dist/forms.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type FieldProps } from "./components/field";
|
|
3
|
+
import { Form } from "./components/form";
|
|
4
|
+
export { Form };
|
|
5
|
+
/** Structural subset of React Hook Form's register result; no RHF runtime enters the package. */
|
|
6
|
+
export type RegisteredFieldProps = {
|
|
7
|
+
name?: string;
|
|
8
|
+
onChange?: React.ChangeEventHandler<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>;
|
|
9
|
+
onBlur?: React.FocusEventHandler<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>;
|
|
10
|
+
ref?: React.Ref<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>;
|
|
11
|
+
};
|
|
12
|
+
export type RegisterField = (name: any, options?: any) => RegisteredFieldProps;
|
|
13
|
+
export interface RHFFieldProps extends Omit<FieldProps, "children"> {
|
|
14
|
+
name: string;
|
|
15
|
+
register: RegisterField;
|
|
16
|
+
rules?: Record<string, unknown>;
|
|
17
|
+
children: React.ReactElement;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Bridges React Hook Form's register(name) result into the existing WealthOS Field.
|
|
21
|
+
* Pass the register function from useForm; this adapter has no runtime RHF import.
|
|
22
|
+
*/
|
|
23
|
+
export declare function RHFField({ name, register, rules, children, ...fieldProps }: RHFFieldProps): React.JSX.Element;
|
|
24
|
+
/** Structural Controller field shape; compatible with React Hook Form's useController field. */
|
|
25
|
+
export interface RHFControllerField {
|
|
26
|
+
name: string;
|
|
27
|
+
value: unknown;
|
|
28
|
+
onChange: (...args: any[]) => void;
|
|
29
|
+
onBlur?: React.FocusEventHandler<HTMLElement>;
|
|
30
|
+
ref?: React.Ref<HTMLElement>;
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Maps a React Hook Form Controller field to controlled WealthOS components.
|
|
35
|
+
* Checkbox and Switch use `rhfControllerProps(field, { valueProp: "checked" })`.
|
|
36
|
+
*/
|
|
37
|
+
export declare function rhfControllerProps(field: RHFControllerField, options?: {
|
|
38
|
+
valueProp?: string;
|
|
39
|
+
}): Record<string, unknown>;
|
package/dist/forms.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { r as e, t } from "./form-D3G5306m.js";
|
|
2
|
+
import * as n from "react";
|
|
3
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
4
|
+
//#region src/forms.tsx
|
|
5
|
+
function i({ name: t, register: i, rules: a, children: o, ...s }) {
|
|
6
|
+
let c = i(t, a), l = n.cloneElement(o, {
|
|
7
|
+
...c,
|
|
8
|
+
name: t
|
|
9
|
+
});
|
|
10
|
+
return /* @__PURE__ */ r(e, {
|
|
11
|
+
...s,
|
|
12
|
+
children: l
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function a(e, t = {}) {
|
|
16
|
+
return {
|
|
17
|
+
[t.valueProp ?? "value"]: e.value,
|
|
18
|
+
name: e.name,
|
|
19
|
+
onChange: (...t) => {
|
|
20
|
+
let n = t[0];
|
|
21
|
+
if (n && typeof n == "object" && "target" in n) {
|
|
22
|
+
let t = n.target;
|
|
23
|
+
e.onChange(t.type === "checkbox" ? t.checked : t.value);
|
|
24
|
+
} else e.onChange(n);
|
|
25
|
+
},
|
|
26
|
+
onBlur: e.onBlur,
|
|
27
|
+
ref: e.ref,
|
|
28
|
+
disabled: e.disabled
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { t as Form, i as RHFField, a as rhfControllerProps };
|