@kanzo-tech/ui 0.10.0 → 0.11.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/dist/charts/chart-stat.d.ts +12 -10
- package/dist/charts/chart-stat.d.ts.map +1 -1
- package/dist/charts/chart-stat.js +21 -16
- package/dist/charts/chart-stat.js.map +1 -1
- package/dist/guard-corpus.d.ts.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +312 -295
- package/dist/index.js.map +1 -1
- package/dist/layouts/empty.d.ts +54 -0
- package/dist/layouts/empty.d.ts.map +1 -0
- package/dist/layouts/empty.js +99 -0
- package/dist/layouts/empty.js.map +1 -0
- package/dist/layouts/gated.d.ts +24 -0
- package/dist/layouts/gated.d.ts.map +1 -0
- package/dist/layouts/gated.js +46 -0
- package/dist/layouts/gated.js.map +1 -0
- package/dist/layouts/section.d.ts +30 -5
- package/dist/layouts/section.d.ts.map +1 -1
- package/dist/layouts/section.js +71 -53
- package/dist/layouts/section.js.map +1 -1
- package/dist/simples/field.d.ts +7 -1
- package/dist/simples/field.d.ts.map +1 -1
- package/dist/simples/field.js +55 -47
- package/dist/simples/field.js.map +1 -1
- package/dist/simples/floating-panel.js +1 -1
- package/dist/simples/floating-panel.js.map +1 -1
- package/dist/simples/stat.d.ts +45 -0
- package/dist/simples/stat.d.ts.map +1 -0
- package/dist/simples/stat.js +155 -0
- package/dist/simples/stat.js.map +1 -0
- package/dist/table/actions-column.d.ts +20 -0
- package/dist/table/actions-column.d.ts.map +1 -0
- package/dist/table/actions-column.js +38 -0
- package/dist/table/actions-column.js.map +1 -0
- package/dist/table/data-table-content.d.ts.map +1 -1
- package/dist/table/data-table-content.js +31 -20
- package/dist/table/data-table-content.js.map +1 -1
- package/dist/table.d.ts +2 -0
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +13 -11
- package/dist/table.js.map +1 -1
- package/package.json +5 -5
- package/dist/simples/stat-tile.d.ts +0 -31
- package/dist/simples/stat-tile.d.ts.map +0 -1
- package/dist/simples/stat-tile.js +0 -64
- package/dist/simples/stat-tile.js.map +0 -1
package/dist/simples/field.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as o, jsxs as f } from "react/jsx-runtime";
|
|
2
2
|
import { ark as d } from "@ark-ui/react/factory";
|
|
3
3
|
import { useFieldContext as m, Field as i } from "@ark-ui/react/field";
|
|
4
4
|
import { Fieldset as n } from "@ark-ui/react/fieldset";
|
|
5
5
|
import { tv as u } from "tailwind-variants";
|
|
6
6
|
import { cn as r } from "../lib/cn.js";
|
|
7
7
|
import { Separator as p } from "./separator.js";
|
|
8
|
-
const
|
|
8
|
+
const w = m, g = u({
|
|
9
9
|
base: [
|
|
10
10
|
"group/field",
|
|
11
11
|
"w-full",
|
|
@@ -43,19 +43,19 @@ const k = m, g = u({
|
|
|
43
43
|
reverse: !1
|
|
44
44
|
}
|
|
45
45
|
}), y = (a) => {
|
|
46
|
-
const { orientation: t = "vertical", reverse: e = !1, className:
|
|
47
|
-
return /* @__PURE__ */
|
|
46
|
+
const { orientation: t = "vertical", reverse: e = !1, className: l, slot: s, ...c } = a;
|
|
47
|
+
return /* @__PURE__ */ o(
|
|
48
48
|
i.Root,
|
|
49
49
|
{
|
|
50
|
-
className: r(g({ orientation: t, reverse: e }),
|
|
50
|
+
className: r(g({ orientation: t, reverse: e }), l),
|
|
51
51
|
"data-orientation": t,
|
|
52
52
|
...c,
|
|
53
53
|
"data-slot": s ?? "field"
|
|
54
54
|
}
|
|
55
55
|
);
|
|
56
56
|
}, S = (a) => {
|
|
57
|
-
const { className: t, slot: e, ...
|
|
58
|
-
return /* @__PURE__ */
|
|
57
|
+
const { className: t, slot: e, ...l } = a;
|
|
58
|
+
return /* @__PURE__ */ o(
|
|
59
59
|
n.Root,
|
|
60
60
|
{
|
|
61
61
|
className: r(
|
|
@@ -65,13 +65,13 @@ const k = m, g = u({
|
|
|
65
65
|
"dark:data-invalid:text-destructive-foreground",
|
|
66
66
|
t
|
|
67
67
|
),
|
|
68
|
-
...
|
|
68
|
+
...l,
|
|
69
69
|
"data-slot": e ?? "field-set"
|
|
70
70
|
}
|
|
71
71
|
);
|
|
72
72
|
}, T = (a) => {
|
|
73
|
-
const { variant: t = "legend", className: e, slot:
|
|
74
|
-
return /* @__PURE__ */
|
|
73
|
+
const { variant: t = "legend", className: e, slot: l, ...s } = a;
|
|
74
|
+
return /* @__PURE__ */ o(
|
|
75
75
|
n.Legend,
|
|
76
76
|
{
|
|
77
77
|
className: r(
|
|
@@ -82,12 +82,12 @@ const k = m, g = u({
|
|
|
82
82
|
),
|
|
83
83
|
"data-variant": t,
|
|
84
84
|
...s,
|
|
85
|
-
"data-slot":
|
|
85
|
+
"data-slot": l ?? "field-legend"
|
|
86
86
|
}
|
|
87
87
|
);
|
|
88
88
|
}, E = (a) => {
|
|
89
|
-
const { className: t, slot: e, ...
|
|
90
|
-
return /* @__PURE__ */
|
|
89
|
+
const { className: t, slot: e, ...l } = a;
|
|
90
|
+
return /* @__PURE__ */ o(
|
|
91
91
|
d.div,
|
|
92
92
|
{
|
|
93
93
|
className: r(
|
|
@@ -97,13 +97,13 @@ const k = m, g = u({
|
|
|
97
97
|
"*:data-[slot=field-group]:gap-4",
|
|
98
98
|
t
|
|
99
99
|
),
|
|
100
|
-
...
|
|
100
|
+
...l,
|
|
101
101
|
"data-slot": e ?? "field-group"
|
|
102
102
|
}
|
|
103
103
|
);
|
|
104
104
|
}, H = (a) => {
|
|
105
|
-
const { className: t, slot: e, ...
|
|
106
|
-
return /* @__PURE__ */
|
|
105
|
+
const { className: t, slot: e, ...l } = a;
|
|
106
|
+
return /* @__PURE__ */ o(
|
|
107
107
|
d.div,
|
|
108
108
|
{
|
|
109
109
|
className: r(
|
|
@@ -112,13 +112,13 @@ const k = m, g = u({
|
|
|
112
112
|
"leading-snug",
|
|
113
113
|
t
|
|
114
114
|
),
|
|
115
|
-
...
|
|
115
|
+
...l,
|
|
116
116
|
"data-slot": e ?? "field-content"
|
|
117
117
|
}
|
|
118
118
|
);
|
|
119
119
|
}, L = (a) => {
|
|
120
|
-
const { className: t, slot: e, ...
|
|
121
|
-
return /* @__PURE__ */
|
|
120
|
+
const { className: t, slot: e, ...l } = a;
|
|
121
|
+
return /* @__PURE__ */ o(
|
|
122
122
|
i.Label,
|
|
123
123
|
{
|
|
124
124
|
className: r(
|
|
@@ -131,13 +131,13 @@ const k = m, g = u({
|
|
|
131
131
|
"dark:has-data-[state=checked]:bg-primary/10",
|
|
132
132
|
t
|
|
133
133
|
),
|
|
134
|
-
...
|
|
134
|
+
...l,
|
|
135
135
|
"data-slot": e ?? "field-label"
|
|
136
136
|
}
|
|
137
137
|
);
|
|
138
138
|
}, R = (a) => {
|
|
139
|
-
const { className: t, children: e, slot:
|
|
140
|
-
return /* @__PURE__ */
|
|
139
|
+
const { className: t, children: e, slot: l, fallback: s, ...c } = a;
|
|
140
|
+
return /* @__PURE__ */ o(
|
|
141
141
|
i.RequiredIndicator,
|
|
142
142
|
{
|
|
143
143
|
"aria-hidden": !0,
|
|
@@ -145,14 +145,22 @@ const k = m, g = u({
|
|
|
145
145
|
"select-none text-destructive-foreground text-sm",
|
|
146
146
|
t
|
|
147
147
|
),
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
fallback: s == null ? null : /* @__PURE__ */ o(
|
|
149
|
+
"span",
|
|
150
|
+
{
|
|
151
|
+
className: "select-none font-normal text-muted-foreground text-sm",
|
|
152
|
+
"data-slot": "field-optional-indicator",
|
|
153
|
+
children: s
|
|
154
|
+
}
|
|
155
|
+
),
|
|
156
|
+
...c,
|
|
157
|
+
"data-slot": l ?? "field-required-indicator",
|
|
150
158
|
children: e ?? "*"
|
|
151
159
|
}
|
|
152
160
|
);
|
|
153
161
|
}, q = (a) => {
|
|
154
|
-
const { className: t, slot: e, ...
|
|
155
|
-
return /* @__PURE__ */
|
|
162
|
+
const { className: t, slot: e, ...l } = a;
|
|
163
|
+
return /* @__PURE__ */ o(
|
|
156
164
|
d.div,
|
|
157
165
|
{
|
|
158
166
|
className: r(
|
|
@@ -162,13 +170,13 @@ const k = m, g = u({
|
|
|
162
170
|
"group-data-[disabled=true]/field:opacity-64",
|
|
163
171
|
t
|
|
164
172
|
),
|
|
165
|
-
...
|
|
173
|
+
...l,
|
|
166
174
|
"data-slot": e ?? "field-title"
|
|
167
175
|
}
|
|
168
176
|
);
|
|
169
177
|
}, z = (a) => {
|
|
170
|
-
const { className: t, slot: e, ...
|
|
171
|
-
return /* @__PURE__ */
|
|
178
|
+
const { className: t, slot: e, ...l } = a;
|
|
179
|
+
return /* @__PURE__ */ o(
|
|
172
180
|
d.p,
|
|
173
181
|
{
|
|
174
182
|
className: r(
|
|
@@ -181,12 +189,12 @@ const k = m, g = u({
|
|
|
181
189
|
"[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4",
|
|
182
190
|
t
|
|
183
191
|
),
|
|
184
|
-
...
|
|
192
|
+
...l,
|
|
185
193
|
"data-slot": e ?? "field-description"
|
|
186
194
|
}
|
|
187
195
|
);
|
|
188
196
|
}, j = (a) => {
|
|
189
|
-
const { className: t, children: e, slot:
|
|
197
|
+
const { className: t, children: e, slot: l, ...s } = a;
|
|
190
198
|
return /* @__PURE__ */ f(
|
|
191
199
|
d.div,
|
|
192
200
|
{
|
|
@@ -199,10 +207,10 @@ const k = m, g = u({
|
|
|
199
207
|
),
|
|
200
208
|
"data-content": !!e,
|
|
201
209
|
...s,
|
|
202
|
-
"data-slot":
|
|
210
|
+
"data-slot": l ?? "field-separator",
|
|
203
211
|
children: [
|
|
204
|
-
/* @__PURE__ */
|
|
205
|
-
!!e && /* @__PURE__ */
|
|
212
|
+
/* @__PURE__ */ o(p, { className: "absolute inset-0 top-1/2" }),
|
|
213
|
+
!!e && /* @__PURE__ */ o(
|
|
206
214
|
"span",
|
|
207
215
|
{
|
|
208
216
|
className: r(
|
|
@@ -219,48 +227,48 @@ const k = m, g = u({
|
|
|
219
227
|
}
|
|
220
228
|
);
|
|
221
229
|
}, C = (a) => {
|
|
222
|
-
const { className: t, slot: e, ...
|
|
223
|
-
return /* @__PURE__ */
|
|
230
|
+
const { className: t, slot: e, ...l } = a;
|
|
231
|
+
return /* @__PURE__ */ o(
|
|
224
232
|
i.HelperText,
|
|
225
233
|
{
|
|
226
234
|
className: r("text-muted-foreground text-sm", t),
|
|
227
|
-
...
|
|
235
|
+
...l,
|
|
228
236
|
"data-slot": e ?? "field-helper"
|
|
229
237
|
}
|
|
230
238
|
);
|
|
231
239
|
}, I = (a) => {
|
|
232
|
-
const { className: t, slot: e, ...
|
|
233
|
-
return /* @__PURE__ */
|
|
240
|
+
const { className: t, slot: e, ...l } = a;
|
|
241
|
+
return /* @__PURE__ */ o(
|
|
234
242
|
i.ErrorText,
|
|
235
243
|
{
|
|
236
244
|
className: r(
|
|
237
245
|
"font-normal text-destructive-foreground text-sm",
|
|
238
246
|
t
|
|
239
247
|
),
|
|
240
|
-
...
|
|
248
|
+
...l,
|
|
241
249
|
"data-slot": e ?? "field-error"
|
|
242
250
|
}
|
|
243
251
|
);
|
|
244
252
|
}, V = (a) => {
|
|
245
|
-
const { className: t, slot: e, ...
|
|
246
|
-
return /* @__PURE__ */
|
|
253
|
+
const { className: t, slot: e, ...l } = a;
|
|
254
|
+
return /* @__PURE__ */ o(
|
|
247
255
|
n.HelperText,
|
|
248
256
|
{
|
|
249
257
|
className: r("text-muted-foreground text-sm", t),
|
|
250
|
-
...
|
|
258
|
+
...l,
|
|
251
259
|
"data-slot": e ?? "field-set-helper"
|
|
252
260
|
}
|
|
253
261
|
);
|
|
254
262
|
}, D = (a) => {
|
|
255
|
-
const { className: t, slot: e, ...
|
|
256
|
-
return /* @__PURE__ */
|
|
263
|
+
const { className: t, slot: e, ...l } = a;
|
|
264
|
+
return /* @__PURE__ */ o(
|
|
257
265
|
n.ErrorText,
|
|
258
266
|
{
|
|
259
267
|
className: r(
|
|
260
268
|
"font-normal text-destructive-foreground text-sm",
|
|
261
269
|
t
|
|
262
270
|
),
|
|
263
|
-
...
|
|
271
|
+
...l,
|
|
264
272
|
"data-slot": e ?? "field-set-error"
|
|
265
273
|
}
|
|
266
274
|
);
|
|
@@ -280,6 +288,6 @@ export {
|
|
|
280
288
|
D as FieldSetError,
|
|
281
289
|
V as FieldSetHelper,
|
|
282
290
|
q as FieldTitle,
|
|
283
|
-
|
|
291
|
+
w as useField
|
|
284
292
|
};
|
|
285
293
|
//# sourceMappingURL=field.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.js","sources":["../../src/simples/field.tsx"],"sourcesContent":["import { ark } from \"@ark-ui/react/factory\";\nimport {\n Field as ArkField,\n useFieldContext as useArkFieldContext,\n} from \"@ark-ui/react/field\";\nimport { Fieldset as ArkFieldset } from \"@ark-ui/react/fieldset\";\nimport type React from \"react\";\nimport { tv, type VariantProps } from \"tailwind-variants\";\nimport { cn } from \"../lib/cn\";\nimport { Separator } from \"./separator\";\n\nexport const useField = useArkFieldContext;\n\nconst fieldVariants = tv({\n base: [\n \"group/field\",\n \"w-full\",\n \"flex gap-2\",\n \"data-invalid:text-destructive-foreground\",\n \"dark:data-invalid:text-destructive-foreground\",\n ],\n variants: {\n orientation: {\n vertical: [\"flex-col *:w-full [&>.sr-only]:w-auto\"],\n horizontal: [\n \"flex-row items-center\",\n \"*:data-[slot=field-label]:flex-auto\",\n \"has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px\",\n ],\n responsive: [\n \"flex-col *:w-full [&>.sr-only]:w-auto\",\n \"@md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto\",\n \"@md/field-group:*:data-[slot=field-label]:flex-auto\",\n \"@md/field-group:has-[>[data-slot=field-content]]:items-start\",\n \"@md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px\",\n ],\n },\n reverse: {\n true: [\n \"data-[orientation=horizontal]:flex-row-reverse\",\n \"data-[orientation=vertical]:flex-col-reverse\",\n \"data-[orientation=responsive]:flex-col-reverse\",\n \"data-[orientation=responsive]:@md/field-group:flex-row-reverse\",\n ],\n },\n },\n defaultVariants: {\n orientation: \"vertical\",\n reverse: false,\n },\n});\n\ninterface FieldProps\n extends React.ComponentProps<typeof ArkField.Root>,\n VariantProps<typeof fieldVariants> {}\n\nexport const Field = (props: FieldProps) => {\n const { orientation = \"vertical\", reverse = false, className, slot, ...rest } = props;\n\n return (\n <ArkField.Root\n className={cn(fieldVariants({ orientation, reverse }), className)}\n data-orientation={orientation}\n {...rest}\n data-slot={slot ?? \"field\"}\n />\n );\n};\n\nexport const FieldSet = (\n props: React.ComponentProps<typeof ArkFieldset.Root>\n) => {\n const { className, slot, ...rest } = props;\n\n return (\n <ArkFieldset.Root\n className={cn(\n \"flex flex-col gap-6\",\n \"has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3\",\n \"data-invalid:text-destructive-foreground\",\n \"dark:data-invalid:text-destructive-foreground\",\n className\n )}\n {...rest}\n data-slot={slot ?? \"field-set\"}\n />\n );\n};\n\ninterface FieldLegendProps\n extends React.ComponentProps<typeof ArkFieldset.Legend> {\n /**\n * The variant of the legend.\n */\n variant?: \"legend\" | \"label\";\n}\n\nexport const FieldLegend = (props: FieldLegendProps) => {\n const { variant = \"legend\", className, slot, ...rest } = props;\n\n return (\n <ArkFieldset.Legend\n className={cn(\n \"mb-3 font-medium\",\n \"data-[variant=legend]:text-base\",\n \"data-[variant=label]:text-sm\",\n className\n )}\n data-variant={variant}\n {...rest}\n data-slot={slot ?? \"field-legend\"}\n />\n );\n};\n\nexport const FieldGroup = (props: React.ComponentProps<typeof ark.div>) => {\n const { className, slot, ...rest } = props;\n\n return (\n <ark.div\n className={cn(\n \"group/field-group @container/field-group\",\n \"flex w-full flex-col gap-4\",\n \"data-[data-slot=checkbox-group]:gap-3\",\n \"*:data-[slot=field-group]:gap-4\",\n className\n )}\n {...rest}\n data-slot={slot ?? \"field-group\"}\n />\n );\n};\n\nexport const FieldContent = (props: React.ComponentProps<typeof ark.div>) => {\n const { className, slot, ...rest } = props;\n\n return (\n <ark.div\n className={cn(\n \"group/field-content\",\n \"flex flex-1 flex-col gap-1.5\",\n \"leading-snug\",\n className\n )}\n {...rest}\n data-slot={slot ?? \"field-content\"}\n />\n );\n};\n\nexport const FieldLabel = (\n props: React.ComponentProps<typeof ArkField.Label>\n) => {\n const { className, slot, ...rest } = props;\n\n return (\n <ArkField.Label\n className={cn(\n \"group/field-label peer/field-label\",\n \"select-none font-medium text-sm leading-snug\",\n \"flex w-fit gap-1\",\n \"has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-xl has-[>[data-slot=field]]:border *:data-[slot=field]:p-2.5\",\n \"has-data-[state=checked]:border-primary has-data-[state=checked]:bg-primary/5\",\n \"group-data-disabled/field:opacity-64\",\n \"dark:has-data-[state=checked]:bg-primary/10\",\n className\n )}\n {...rest}\n data-slot={slot ?? \"field-label\"}\n />\n );\n};\n\nexport const FieldRequiredIndicator = (\n props: React.ComponentProps<typeof ark.span>\n) => {\n const { className, children, slot, ...rest } = props;\n\n return (\n <ArkField.RequiredIndicator\n aria-hidden\n className={cn(\n \"select-none text-destructive-foreground text-sm\",\n className\n )}\n {...rest}\n data-slot={slot ?? \"field-required-indicator\"}\n >\n {children ?? \"*\"}\n </ArkField.RequiredIndicator>\n );\n};\n\nexport const FieldTitle = (props: React.ComponentProps<typeof ark.div>) => {\n const { className, slot, ...rest } = props;\n\n return (\n <ark.div\n className={cn(\n \"w-fit\",\n \"flex items-center gap-2\",\n \"font-medium text-sm leading-snug\",\n \"group-data-[disabled=true]/field:opacity-64\",\n className\n )}\n {...rest}\n data-slot={slot ?? \"field-title\"}\n />\n );\n};\n\nexport const FieldDescription = (props: React.ComponentProps<typeof ark.p>) => {\n const { className, slot, ...rest } = props;\n\n return (\n <ark.p\n className={cn(\n \"pointer-events-none\",\n \"font-normal text-muted-foreground text-sm leading-normal\",\n \"group-has-data-[orientation=horizontal]/field:text-balance\",\n \"@md/field-group:group-data-[orientation=responsive]/field:text-balance\",\n \"nth-last-2:-mt-1 last:mt-0 [[data-variant=legend]+&]:-mt-1.5\",\n \"in-[[data-slot=field]:has([data-slot=radio-group-item])]:ms-6 in-[[data-slot=field]:has([data-slot=radio-group-item])]:-mt-1.5!\",\n \"[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4\",\n className\n )}\n {...rest}\n data-slot={slot ?? \"field-description\"}\n />\n );\n};\n\nexport const FieldSeparator = (props: React.ComponentProps<typeof ark.div>) => {\n const { className, children, slot, ...rest } = props;\n\n return (\n <ark.div\n className={cn(\n \"relative\",\n \"h-5\",\n \"-my-2 group-data-[variant=outline]/field-group:-mb-2\",\n \"text-sm\",\n className\n )}\n data-content={!!children}\n {...rest}\n data-slot={slot ?? \"field-separator\"}\n >\n <Separator className=\"absolute inset-0 top-1/2\" />\n\n {!!children && (\n <span\n className={cn(\n \"relative block\",\n \"w-fit\",\n \"mx-auto px-2\",\n \"bg-background\",\n \"text-muted-foreground text-sm\"\n )}\n >\n {children}\n </span>\n )}\n </ark.div>\n );\n};\n\nexport const FieldHelper = (\n props: React.ComponentProps<typeof ArkField.HelperText>\n) => {\n const { className, slot, ...rest } = props;\n\n return (\n <ArkField.HelperText\n className={cn(\"text-muted-foreground text-sm\", className)}\n {...rest}\n data-slot={slot ?? \"field-helper\"}\n />\n );\n};\n\nexport const FieldError = (\n props: React.ComponentProps<typeof ArkField.ErrorText>\n) => {\n const { className, slot, ...rest } = props;\n\n return (\n <ArkField.ErrorText\n className={cn(\n \"font-normal text-destructive-foreground text-sm\",\n className\n )}\n {...rest}\n data-slot={slot ?? \"field-error\"}\n />\n );\n};\n\n// The two below look like copies of the two above and are not: these are the fieldset machine's\n// message parts, describing the whole `FieldSet`, while `FieldHelper` / `FieldError` come from the\n// field machine and describe one control. Same typography, different scope — and a `FieldSet` needs\n// its own, because a group-level message wired to a single field is announced on the wrong control.\n\nexport const FieldSetHelper = (\n props: React.ComponentProps<typeof ArkFieldset.HelperText>\n) => {\n const { className, slot, ...rest } = props;\n\n return (\n <ArkFieldset.HelperText\n className={cn(\"text-muted-foreground text-sm\", className)}\n {...rest}\n data-slot={slot ?? \"field-set-helper\"}\n />\n );\n};\n\nexport const FieldSetError = (\n props: React.ComponentProps<typeof ArkFieldset.ErrorText>\n) => {\n const { className, slot, ...rest } = props;\n\n return (\n <ArkFieldset.ErrorText\n className={cn(\n \"font-normal text-destructive-foreground text-sm\",\n className\n )}\n {...rest}\n data-slot={slot ?? \"field-set-error\"}\n />\n );\n};\n"],"names":["useField","useArkFieldContext","fieldVariants","tv","Field","props","orientation","reverse","className","slot","rest","jsx","ArkField","cn","FieldSet","ArkFieldset","FieldLegend","variant","FieldGroup","ark","FieldContent","FieldLabel","FieldRequiredIndicator","children","FieldTitle","FieldDescription","FieldSeparator","jsxs","Separator","FieldHelper","FieldError","FieldSetHelper","FieldSetError"],"mappings":";;;;;;;AAWO,MAAMA,IAAWC,GAElBC,IAAgBC,EAAG;AAAA,EACvB,MAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAAA,EAEF,UAAU;AAAA,IACR,aAAa;AAAA,MACX,UAAU,CAAC,uCAAuC;AAAA,MAClD,YAAY;AAAA,QACV;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,MAEF,YAAY;AAAA,QACV;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,IACF;AAAA,IAEF,SAAS;AAAA,MACP,MAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,IACF;AAAA,EACF;AAAA,EAEF,iBAAiB;AAAA,IACf,aAAa;AAAA,IACb,SAAS;AAAA,EAAA;AAEb,CAAC,GAMYC,IAAQ,CA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;AAGzB,GAEaqB,IAAa,CACxBzB,MACG;AACH,QAAM,EAAE,WAAAG,GAAW,MAAAC,GAAM,GAAGC,MAASL;AAErC,SACE,gBAAAM;AAAA,IAACC,EAAS;AAAA,IAAT;AAAA,MACC,WAAWC;AAAA,QACT;AAAA,QACAL;AAAA,MAAA;AAAA,MAED,GAAGE;AAAA,MACJ,aAAWD,KAAQ;AAAA,IAAA;AAAA,EAAA;AAGzB,GAOasB,IAAiB,CAC5B1B,MACG;AACH,QAAM,EAAE,WAAAG,GAAW,MAAAC,GAAM,GAAGC,MAASL;AAErC,SACE,gBAAAM;AAAA,IAACI,EAAY;AAAA,IAAZ;AAAA,MACC,WAAWF,EAAG,iCAAiCL,CAAS;AAAA,MACvD,GAAGE;AAAA,MACJ,aAAWD,KAAQ;AAAA,IAAA;AAAA,EAAA;AAGzB,GAEauB,IAAgB,CAC3B3B,MACG;AACH,QAAM,EAAE,WAAAG,GAAW,MAAAC,GAAM,GAAGC,MAASL;AAErC,SACE,gBAAAM;AAAA,IAACI,EAAY;AAAA,IAAZ;AAAA,MACC,WAAWF;AAAA,QACT;AAAA,QACAL;AAAA,MAAA;AAAA,MAED,GAAGE;AAAA,MACJ,aAAWD,KAAQ;AAAA,IAAA;AAAA,EAAA;AAGzB;"}
|
|
1
|
+
{"version":3,"file":"field.js","sources":["../../src/simples/field.tsx"],"sourcesContent":["import { ark } from \"@ark-ui/react/factory\";\nimport {\n Field as ArkField,\n useFieldContext as useArkFieldContext,\n} from \"@ark-ui/react/field\";\nimport { Fieldset as ArkFieldset } from \"@ark-ui/react/fieldset\";\nimport type React from \"react\";\nimport { tv, type VariantProps } from \"tailwind-variants\";\nimport { cn } from \"../lib/cn\";\nimport { Separator } from \"./separator\";\n\nexport const useField = useArkFieldContext;\n\nconst fieldVariants = tv({\n base: [\n \"group/field\",\n \"w-full\",\n \"flex gap-2\",\n \"data-invalid:text-destructive-foreground\",\n \"dark:data-invalid:text-destructive-foreground\",\n ],\n variants: {\n orientation: {\n vertical: [\"flex-col *:w-full [&>.sr-only]:w-auto\"],\n horizontal: [\n \"flex-row items-center\",\n \"*:data-[slot=field-label]:flex-auto\",\n \"has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px\",\n ],\n responsive: [\n \"flex-col *:w-full [&>.sr-only]:w-auto\",\n \"@md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto\",\n \"@md/field-group:*:data-[slot=field-label]:flex-auto\",\n \"@md/field-group:has-[>[data-slot=field-content]]:items-start\",\n \"@md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px\",\n ],\n },\n reverse: {\n true: [\n \"data-[orientation=horizontal]:flex-row-reverse\",\n \"data-[orientation=vertical]:flex-col-reverse\",\n \"data-[orientation=responsive]:flex-col-reverse\",\n \"data-[orientation=responsive]:@md/field-group:flex-row-reverse\",\n ],\n },\n },\n defaultVariants: {\n orientation: \"vertical\",\n reverse: false,\n },\n});\n\ninterface FieldProps\n extends React.ComponentProps<typeof ArkField.Root>,\n VariantProps<typeof fieldVariants> {}\n\nexport const Field = (props: FieldProps) => {\n const { orientation = \"vertical\", reverse = false, className, slot, ...rest } = props;\n\n return (\n <ArkField.Root\n className={cn(fieldVariants({ orientation, reverse }), className)}\n data-orientation={orientation}\n {...rest}\n data-slot={slot ?? \"field\"}\n />\n );\n};\n\nexport const FieldSet = (\n props: React.ComponentProps<typeof ArkFieldset.Root>\n) => {\n const { className, slot, ...rest } = props;\n\n return (\n <ArkFieldset.Root\n className={cn(\n \"flex flex-col gap-6\",\n \"has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3\",\n \"data-invalid:text-destructive-foreground\",\n \"dark:data-invalid:text-destructive-foreground\",\n className\n )}\n {...rest}\n data-slot={slot ?? \"field-set\"}\n />\n );\n};\n\ninterface FieldLegendProps\n extends React.ComponentProps<typeof ArkFieldset.Legend> {\n /**\n * The variant of the legend.\n */\n variant?: \"legend\" | \"label\";\n}\n\nexport const FieldLegend = (props: FieldLegendProps) => {\n const { variant = \"legend\", className, slot, ...rest } = props;\n\n return (\n <ArkFieldset.Legend\n className={cn(\n \"mb-3 font-medium\",\n \"data-[variant=legend]:text-base\",\n \"data-[variant=label]:text-sm\",\n className\n )}\n data-variant={variant}\n {...rest}\n data-slot={slot ?? \"field-legend\"}\n />\n );\n};\n\nexport const FieldGroup = (props: React.ComponentProps<typeof ark.div>) => {\n const { className, slot, ...rest } = props;\n\n return (\n <ark.div\n className={cn(\n \"group/field-group @container/field-group\",\n \"flex w-full flex-col gap-4\",\n \"data-[data-slot=checkbox-group]:gap-3\",\n \"*:data-[slot=field-group]:gap-4\",\n className\n )}\n {...rest}\n data-slot={slot ?? \"field-group\"}\n />\n );\n};\n\nexport const FieldContent = (props: React.ComponentProps<typeof ark.div>) => {\n const { className, slot, ...rest } = props;\n\n return (\n <ark.div\n className={cn(\n \"group/field-content\",\n \"flex flex-1 flex-col gap-1.5\",\n \"leading-snug\",\n className\n )}\n {...rest}\n data-slot={slot ?? \"field-content\"}\n />\n );\n};\n\nexport const FieldLabel = (\n props: React.ComponentProps<typeof ArkField.Label>\n) => {\n const { className, slot, ...rest } = props;\n\n return (\n <ArkField.Label\n className={cn(\n \"group/field-label peer/field-label\",\n \"select-none font-medium text-sm leading-snug\",\n \"flex w-fit gap-1\",\n \"has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-xl has-[>[data-slot=field]]:border *:data-[slot=field]:p-2.5\",\n \"has-data-[state=checked]:border-primary has-data-[state=checked]:bg-primary/5\",\n \"group-data-disabled/field:opacity-64\",\n \"dark:has-data-[state=checked]:bg-primary/10\",\n className\n )}\n {...rest}\n data-slot={slot ?? \"field-label\"}\n />\n );\n};\n\n/**\n * The `*` of a required field and, through Ark's `fallback`, what an optional one says instead —\n * one part, so a form marks one of the two and never both. The asterisk is hidden from assistive\n * tech because the control's `required` already announces it; the fallback is not, because nothing\n * else says a field is optional. Its text is the host's: this library ships no product copy.\n */\nexport const FieldRequiredIndicator = (\n props: React.ComponentProps<typeof ArkField.RequiredIndicator>\n) => {\n const { className, children, slot, fallback, ...rest } = props;\n\n return (\n <ArkField.RequiredIndicator\n aria-hidden\n className={cn(\n \"select-none text-destructive-foreground text-sm\",\n className\n )}\n fallback={\n fallback == null ? null : (\n <span\n className=\"select-none font-normal text-muted-foreground text-sm\"\n data-slot=\"field-optional-indicator\"\n >\n {fallback}\n </span>\n )\n }\n {...rest}\n data-slot={slot ?? \"field-required-indicator\"}\n >\n {children ?? \"*\"}\n </ArkField.RequiredIndicator>\n );\n};\n\nexport const FieldTitle = (props: React.ComponentProps<typeof ark.div>) => {\n const { className, slot, ...rest } = props;\n\n return (\n <ark.div\n className={cn(\n \"w-fit\",\n \"flex items-center gap-2\",\n \"font-medium text-sm leading-snug\",\n \"group-data-[disabled=true]/field:opacity-64\",\n className\n )}\n {...rest}\n data-slot={slot ?? \"field-title\"}\n />\n );\n};\n\nexport const FieldDescription = (props: React.ComponentProps<typeof ark.p>) => {\n const { className, slot, ...rest } = props;\n\n return (\n <ark.p\n className={cn(\n \"pointer-events-none\",\n \"font-normal text-muted-foreground text-sm leading-normal\",\n \"group-has-data-[orientation=horizontal]/field:text-balance\",\n \"@md/field-group:group-data-[orientation=responsive]/field:text-balance\",\n \"nth-last-2:-mt-1 last:mt-0 [[data-variant=legend]+&]:-mt-1.5\",\n \"in-[[data-slot=field]:has([data-slot=radio-group-item])]:ms-6 in-[[data-slot=field]:has([data-slot=radio-group-item])]:-mt-1.5!\",\n \"[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4\",\n className\n )}\n {...rest}\n data-slot={slot ?? \"field-description\"}\n />\n );\n};\n\nexport const FieldSeparator = (props: React.ComponentProps<typeof ark.div>) => {\n const { className, children, slot, ...rest } = props;\n\n return (\n <ark.div\n className={cn(\n \"relative\",\n \"h-5\",\n \"-my-2 group-data-[variant=outline]/field-group:-mb-2\",\n \"text-sm\",\n className\n )}\n data-content={!!children}\n {...rest}\n data-slot={slot ?? \"field-separator\"}\n >\n <Separator className=\"absolute inset-0 top-1/2\" />\n\n {!!children && (\n <span\n className={cn(\n \"relative block\",\n \"w-fit\",\n \"mx-auto px-2\",\n \"bg-background\",\n \"text-muted-foreground text-sm\"\n )}\n >\n {children}\n </span>\n )}\n </ark.div>\n );\n};\n\nexport const FieldHelper = (\n props: React.ComponentProps<typeof ArkField.HelperText>\n) => {\n const { className, slot, ...rest } = props;\n\n return (\n <ArkField.HelperText\n className={cn(\"text-muted-foreground text-sm\", className)}\n {...rest}\n data-slot={slot ?? \"field-helper\"}\n />\n );\n};\n\nexport const FieldError = (\n props: React.ComponentProps<typeof ArkField.ErrorText>\n) => {\n const { className, slot, ...rest } = props;\n\n return (\n <ArkField.ErrorText\n className={cn(\n \"font-normal text-destructive-foreground text-sm\",\n className\n )}\n {...rest}\n data-slot={slot ?? \"field-error\"}\n />\n );\n};\n\n// The two below look like copies of the two above and are not: these are the fieldset machine's\n// message parts, describing the whole `FieldSet`, while `FieldHelper` / `FieldError` come from the\n// field machine and describe one control. Same typography, different scope — and a `FieldSet` needs\n// its own, because a group-level message wired to a single field is announced on the wrong control.\n\nexport const FieldSetHelper = (\n props: React.ComponentProps<typeof ArkFieldset.HelperText>\n) => {\n const { className, slot, ...rest } = props;\n\n return (\n <ArkFieldset.HelperText\n className={cn(\"text-muted-foreground text-sm\", className)}\n {...rest}\n data-slot={slot ?? \"field-set-helper\"}\n />\n );\n};\n\nexport const FieldSetError = (\n props: React.ComponentProps<typeof ArkFieldset.ErrorText>\n) => {\n const { className, slot, ...rest } = props;\n\n return (\n <ArkFieldset.ErrorText\n className={cn(\n \"font-normal text-destructive-foreground text-sm\",\n className\n )}\n {...rest}\n data-slot={slot ?? \"field-set-error\"}\n />\n );\n};\n"],"names":["useField","useArkFieldContext","fieldVariants","tv","Field","props","orientation","reverse","className","slot","rest","jsx","ArkField","cn","FieldSet","ArkFieldset","FieldLegend","variant","FieldGroup","ark","FieldContent","FieldLabel","FieldRequiredIndicator","children","fallback","FieldTitle","FieldDescription","FieldSeparator","jsxs","Separator","FieldHelper","FieldError","FieldSetHelper","FieldSetError"],"mappings":";;;;;;;AAWO,MAAMA,IAAWC,GAElBC,IAAgBC,EAAG;AAAA,EACvB,MAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAAA,EAEF,UAAU;AAAA,IACR,aAAa;AAAA,MACX,UAAU,CAAC,uCAAuC;AAAA,MAClD,YAAY;AAAA,QACV;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,MAEF,YAAY;AAAA,QACV;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,IACF;AAAA,IAEF,SAAS;AAAA,MACP,MAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,IACF;AAAA,EACF;AAAA,EAEF,iBAAiB;AAAA,IACf,aAAa;AAAA,IACb,SAAS;AAAA,EAAA;AAEb,CAAC,GAMYC,IAAQ,CAACC,MAAsB;AAC1C,QAAM,EAAE,aAAAC,IAAc,YAAY,SAAAC,IAAU,IAAO,WAAAC,GAAW,MAAAC,GAAM,GAAGC,EAAA,IAASL;AAEhF,SACE,gBAAAM;AAAA,IAACC,EAAS;AAAA,IAAT;AAAA,MACC,WAAWC,EAAGX,EAAc,EAAE,aAAAI,GAAa,SAAAC,EAAA,CAAS,GAAGC,CAAS;AAAA,MAChE,oBAAkBF;AAAA,MACjB,GAAGI;AAAA,MACJ,aAAWD,KAAQ;AAAA,IAAA;AAAA,EAAA;AAGzB,GAEaK,IAAW,CACtBT,MACG;AACH,QAAM,EAAE,WAAAG,GAAW,MAAAC,GAAM,GAAGC,MAASL;AAErC,SACE,gBAAAM;AAAA,IAACI,EAAY;AAAA,IAAZ;AAAA,MACC,WAAWF;AAAA,QACT;AAAA,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;AAErC,SACE,gBAAAM;AAAA,IAACI,EAAY;AAAA,IAAZ;AAAA,MACC,WAAWF,EAAG,iCAAiCL,CAAS;AAAA,MACvD,GAAGE;AAAA,MACJ,aAAWD,KAAQ;AAAA,IAAA;AAAA,EAAA;AAGzB,GAEawB,IAAgB,CAC3B5B,MACG;AACH,QAAM,EAAE,WAAAG,GAAW,MAAAC,GAAM,GAAGC,MAASL;AAErC,SACE,gBAAAM;AAAA,IAACI,EAAY;AAAA,IAAZ;AAAA,MACC,WAAWF;AAAA,QACT;AAAA,QACAL;AAAA,MAAA;AAAA,MAED,GAAGE;AAAA,MACJ,aAAWD,KAAQ;AAAA,IAAA;AAAA,EAAA;AAGzB;"}
|
|
@@ -43,7 +43,7 @@ function D({
|
|
|
43
43
|
"flex overflow-hidden",
|
|
44
44
|
// `Popover`'s surface, at `Popover`'s radius and its shadow token. This was `rounded-lg`
|
|
45
45
|
// and a flat `shadow-lg` — a step below every panel here and a different lift from the one
|
|
46
|
-
// the floating surfaces share.
|
|
46
|
+
// the floating surfaces share. No Shark file, so no guard, and
|
|
47
47
|
// `shark-parity.test.ts` reads names rather than classes.
|
|
48
48
|
//
|
|
49
49
|
// The `/95` and the blur stay: this panel floats over content a reader is still looking at,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floating-panel.js","sources":["../../src/simples/floating-panel.tsx"],"sourcesContent":["\"use client\";\n\nimport React from \"react\";\nimport { cn } from \"../lib/cn.js\";\n\n/**\n * FloatingPanel — a glass surface meant to float over other content (a canvas, a map, a graph),\n * with an optional drag-to-resize edge. It owns the surface (elevated `--popover` tint, blur,\n * border, shadow, rounded) and the resize behaviour; the CALLER owns where it floats (position it\n * with `className`, e.g. `absolute inset-y-2 end-2`) and what it holds.\n *\n * <div className=\"relative\">\n * <Canvas />\n * <FloatingPanel className=\"absolute inset-y-2 end-2\" defaultWidth={360}>\n * <FloatingPanelResizeHandle side=\"start\" />\n * <div className=\"min-w-0 flex-1\">…</div>\n * </FloatingPanel>\n * </div>\n *\n * Width is controllable (`width` + `onWidthChange`) or uncontrolled (`defaultWidth`), clamped to\n * `minWidth`/`maxWidth`. Drop a {@link FloatingPanelResizeHandle} inside to expose a drag edge;\n * omit it for a fixed-width panel.\n */\n\ninterface FloatingPanelContextValue {\n startResize: (event: React.PointerEvent, direction: 1 | -1) => void;\n}\n\nconst FloatingPanelContext = React.createContext<FloatingPanelContextValue | null>(null);\n\nexport interface FloatingPanelProps extends React.ComponentProps<\"div\"> {\n /** Controlled width in px. Omit to run uncontrolled from `defaultWidth`. */\n width?: number;\n /** Initial width when uncontrolled. @default 320 */\n defaultWidth?: number;\n /** Called with the clamped width on every resize step. */\n onWidthChange?: (width: number) => void;\n /** @default 240 */\n minWidth?: number;\n /** @default 640 */\n maxWidth?: number;\n}\n\nexport function FloatingPanel({\n width: controlledWidth,\n defaultWidth = 320,\n onWidthChange,\n minWidth = 240,\n maxWidth = 640,\n className,\n style,\n children,\n slot,\n ...rest\n}: FloatingPanelProps) {\n const [uncontrolledWidth, setUncontrolledWidth] = React.useState(defaultWidth);\n const width = controlledWidth ?? uncontrolledWidth;\n\n // The latest width, read inside the long-lived pointer handlers without re-binding them.\n const widthRef = React.useRef(width);\n widthRef.current = width;\n\n const setWidth = React.useCallback(\n (next: number) => {\n const clamped = Math.max(minWidth, Math.min(maxWidth, next));\n if (controlledWidth == null) setUncontrolledWidth(clamped);\n onWidthChange?.(clamped);\n },\n [controlledWidth, minWidth, maxWidth, onWidthChange],\n );\n\n const dragRef = React.useRef<{ startX: number; startWidth: number; direction: 1 | -1 } | null>(null);\n\n const startResize = React.useCallback(\n (event: React.PointerEvent, direction: 1 | -1) => {\n event.preventDefault();\n dragRef.current = { startX: event.clientX, startWidth: widthRef.current, direction };\n const onMove = (moveEvent: PointerEvent) => {\n const drag = dragRef.current;\n if (!drag) return;\n // A start-edge handle grows the panel as the pointer moves left (direction -1); an\n // end-edge handle grows it moving right (direction 1).\n setWidth(drag.startWidth + (moveEvent.clientX - drag.startX) * drag.direction);\n };\n const onUp = () => {\n dragRef.current = null;\n document.removeEventListener(\"pointermove\", onMove);\n document.removeEventListener(\"pointerup\", onUp);\n };\n document.addEventListener(\"pointermove\", onMove);\n document.addEventListener(\"pointerup\", onUp);\n },\n [setWidth],\n );\n\n const context = React.useMemo<FloatingPanelContextValue>(() => ({ startResize }), [startResize]);\n\n return (\n <div\n className={cn(\n \"flex overflow-hidden\",\n // `Popover`'s surface, at `Popover`'s radius and its shadow token. This was `rounded-lg`\n // and a flat `shadow-lg` — a step below every panel here and a different lift from the one\n // the floating surfaces share.
|
|
1
|
+
{"version":3,"file":"floating-panel.js","sources":["../../src/simples/floating-panel.tsx"],"sourcesContent":["\"use client\";\n\nimport React from \"react\";\nimport { cn } from \"../lib/cn.js\";\n\n/**\n * FloatingPanel — a glass surface meant to float over other content (a canvas, a map, a graph),\n * with an optional drag-to-resize edge. It owns the surface (elevated `--popover` tint, blur,\n * border, shadow, rounded) and the resize behaviour; the CALLER owns where it floats (position it\n * with `className`, e.g. `absolute inset-y-2 end-2`) and what it holds.\n *\n * <div className=\"relative\">\n * <Canvas />\n * <FloatingPanel className=\"absolute inset-y-2 end-2\" defaultWidth={360}>\n * <FloatingPanelResizeHandle side=\"start\" />\n * <div className=\"min-w-0 flex-1\">…</div>\n * </FloatingPanel>\n * </div>\n *\n * Width is controllable (`width` + `onWidthChange`) or uncontrolled (`defaultWidth`), clamped to\n * `minWidth`/`maxWidth`. Drop a {@link FloatingPanelResizeHandle} inside to expose a drag edge;\n * omit it for a fixed-width panel.\n */\n\ninterface FloatingPanelContextValue {\n startResize: (event: React.PointerEvent, direction: 1 | -1) => void;\n}\n\nconst FloatingPanelContext = React.createContext<FloatingPanelContextValue | null>(null);\n\nexport interface FloatingPanelProps extends React.ComponentProps<\"div\"> {\n /** Controlled width in px. Omit to run uncontrolled from `defaultWidth`. */\n width?: number;\n /** Initial width when uncontrolled. @default 320 */\n defaultWidth?: number;\n /** Called with the clamped width on every resize step. */\n onWidthChange?: (width: number) => void;\n /** @default 240 */\n minWidth?: number;\n /** @default 640 */\n maxWidth?: number;\n}\n\nexport function FloatingPanel({\n width: controlledWidth,\n defaultWidth = 320,\n onWidthChange,\n minWidth = 240,\n maxWidth = 640,\n className,\n style,\n children,\n slot,\n ...rest\n}: FloatingPanelProps) {\n const [uncontrolledWidth, setUncontrolledWidth] = React.useState(defaultWidth);\n const width = controlledWidth ?? uncontrolledWidth;\n\n // The latest width, read inside the long-lived pointer handlers without re-binding them.\n const widthRef = React.useRef(width);\n widthRef.current = width;\n\n const setWidth = React.useCallback(\n (next: number) => {\n const clamped = Math.max(minWidth, Math.min(maxWidth, next));\n if (controlledWidth == null) setUncontrolledWidth(clamped);\n onWidthChange?.(clamped);\n },\n [controlledWidth, minWidth, maxWidth, onWidthChange],\n );\n\n const dragRef = React.useRef<{ startX: number; startWidth: number; direction: 1 | -1 } | null>(null);\n\n const startResize = React.useCallback(\n (event: React.PointerEvent, direction: 1 | -1) => {\n event.preventDefault();\n dragRef.current = { startX: event.clientX, startWidth: widthRef.current, direction };\n const onMove = (moveEvent: PointerEvent) => {\n const drag = dragRef.current;\n if (!drag) return;\n // A start-edge handle grows the panel as the pointer moves left (direction -1); an\n // end-edge handle grows it moving right (direction 1).\n setWidth(drag.startWidth + (moveEvent.clientX - drag.startX) * drag.direction);\n };\n const onUp = () => {\n dragRef.current = null;\n document.removeEventListener(\"pointermove\", onMove);\n document.removeEventListener(\"pointerup\", onUp);\n };\n document.addEventListener(\"pointermove\", onMove);\n document.addEventListener(\"pointerup\", onUp);\n },\n [setWidth],\n );\n\n const context = React.useMemo<FloatingPanelContextValue>(() => ({ startResize }), [startResize]);\n\n return (\n <div\n className={cn(\n \"flex overflow-hidden\",\n // `Popover`'s surface, at `Popover`'s radius and its shadow token. This was `rounded-lg`\n // and a flat `shadow-lg` — a step below every panel here and a different lift from the one\n // the floating surfaces share. No Shark file, so no guard, and\n // `shark-parity.test.ts` reads names rather than classes.\n //\n // The `/95` and the blur stay: this panel floats over content a reader is still looking at,\n // which a popover does not. It is the one place the translucency is the point.\n \"rounded-xl border bg-popover/95 text-popover-foreground shadow-lg/5 backdrop-blur-sm\",\n className,\n )}\n style={{ width, ...style }}\n {...rest}\n data-slot={slot ?? \"floating-panel\"}\n >\n <FloatingPanelContext.Provider value={context}>{children}</FloatingPanelContext.Provider>\n </div>\n );\n}\n\nexport interface FloatingPanelResizeHandleProps extends React.ComponentProps<\"div\"> {\n /**\n * Which edge the handle sits on. `\"start\"` (the default) puts it at the leading edge and\n * renders first; `\"end\"` puts it at the trailing edge and renders last. It only affects the\n * drag direction and flex order — position the panel itself with the parent's `className`.\n * @default \"start\"\n */\n side?: \"start\" | \"end\";\n}\n\nexport function FloatingPanelResizeHandle({\n side = \"start\",\n className,\n slot,\n ...rest\n}: FloatingPanelResizeHandleProps) {\n const context = React.useContext(FloatingPanelContext);\n\n return (\n <div\n aria-orientation=\"vertical\"\n className={cn(\n \"w-1.5 shrink-0 cursor-col-resize touch-none transition-colors\",\n // The handle's backdrop is not unknown — it is the panel it lives in, `bg-popover`. So the\n // ladder can be named: rest is the panel surface, hover is step 4 and active is step 5.\n // Measured over popover, rest→hover is ΔE 6.02 in light and 3.95 in dark and hover→active\n // 3.96 and 4.61; the dilution gave 5.11/4.38 and 4.87/4.18 for the same two moves, so this\n // is not a visibility fix — it is the same three steps written with their names.\n \"hover:bg-secondary active:bg-accent\",\n side === \"end\" && \"order-last\",\n className,\n )}\n data-side={side}\n onPointerDown={(event) => context?.startResize(event, side === \"start\" ? -1 : 1)}\n role=\"separator\"\n {...rest}\n data-slot={slot ?? \"floating-panel-resize-handle\"}\n />\n );\n}\n"],"names":[],"mappings":";;;;AA4BA;AAeO;AAAuB;AACrB;AACQ;AACf;AACW;AACA;AACX;AACA;AACA;AACA;AAEF;AACE;AAKA;AAEA;AAAuB;AAEnB;AACA;AACgB;AAClB;AACmD;AAK3B;AAEtB;AAEA;AACE;AACA;AAG6E;AAG7E;AAE8C;AAEhD;AAC2C;AAC7C;AACS;AAKX;AACE;AAAC;AAAA;AACY;AACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA;AACA;AAAA;AAEiB;AACf;AACe;AAEsC;AAAA;AAG/D;AAYO;AAAmC;AACjC;AACP;AACA;AAEF;AACE;AAEA;AACE;AAAC;AAAA;AACkB;AACN;AACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA;AACkB;AAClB;AAAA;AAES;AACmE;AACzE;AACD;AACe;AAAA;AAGzB;;;;;"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ark } from '@ark-ui/react/factory';
|
|
2
|
+
import { Card } from './card';
|
|
3
|
+
export interface StatRootProps extends React.ComponentProps<typeof Card> {
|
|
4
|
+
/** The status family, written to `data-variant` and read by `StatIndicator`. */
|
|
5
|
+
variant?: "default" | "success" | "info" | "warning" | "destructive";
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* One dashboard number. A `Card`, so `asChild` makes the anchor *be* the tile — one tab stop, and
|
|
9
|
+
* the router seam. The link styles key on the element (`[a&]`, as `Badge` does) rather than on a
|
|
10
|
+
* prop, so they cannot disagree with what was rendered.
|
|
11
|
+
*/
|
|
12
|
+
export declare const StatRoot: (props: StatRootProps) => import("react").JSX.Element;
|
|
13
|
+
export declare const StatIndicator: (props: React.ComponentProps<typeof ark.div>) => import("react").JSX.Element;
|
|
14
|
+
/** Sentence case, no trailing colon. */
|
|
15
|
+
export declare const StatLabel: (props: React.ComponentProps<typeof ark.span>) => import("react").JSX.Element;
|
|
16
|
+
export interface StatValueProps extends React.ComponentProps<typeof ark.div> {
|
|
17
|
+
/** Swaps the figure for a skeleton of its size, so the tile does not jump when it lands. */
|
|
18
|
+
loading?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The figure, as the host formats it — `FormatNumber` with `notation="compact"` is the dashboard
|
|
22
|
+
* reading. Proportional figures on purpose: a lone headline number is not a column to align.
|
|
23
|
+
*/
|
|
24
|
+
export declare const StatValue: (props: StatValueProps) => import("react").JSX.Element;
|
|
25
|
+
export interface StatDeltaProps extends React.ComponentProps<typeof ark.div> {
|
|
26
|
+
/** Signed change. Its sign draws the direction icon; with `goodWhenUp`, it picks the colour. */
|
|
27
|
+
value: number;
|
|
28
|
+
/**
|
|
29
|
+
* Against the magnitude, before the comparison — `"%"`, `"pp"`, `"ms"`. "+8.2 vs last week" is a
|
|
30
|
+
* different claim from "+8.2% vs last week".
|
|
31
|
+
*/
|
|
32
|
+
unit?: string;
|
|
33
|
+
/** Whether a rise is good. Two more failed runs and two more members are both `+2`. @default true */
|
|
34
|
+
goodWhenUp?: boolean;
|
|
35
|
+
}
|
|
36
|
+
/** The comparison period is the children: `<StatDelta value={4.2} unit="%">vs last month</StatDelta>`. */
|
|
37
|
+
export declare const StatDelta: (props: StatDeltaProps) => import("react").JSX.Element;
|
|
38
|
+
export interface StatTrendProps extends Omit<React.ComponentProps<typeof ark.svg>, "values"> {
|
|
39
|
+
/** About a dozen points, oldest first. Fewer than two draws nothing. */
|
|
40
|
+
values: readonly number[];
|
|
41
|
+
}
|
|
42
|
+
/** A sparkline with its last value marked — unlabelled, because a reader who needs the values needs a chart. */
|
|
43
|
+
export declare const StatTrend: (props: StatTrendProps) => import("react").JSX.Element | null;
|
|
44
|
+
export declare const StatDescription: (props: React.ComponentProps<typeof ark.p>) => import("react").JSX.Element;
|
|
45
|
+
//# sourceMappingURL=stat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stat.d.ts","sourceRoot":"","sources":["../../src/simples/stat.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAK5C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,MAAM,WAAW,aAAc,SAAQ,KAAK,CAAC,cAAc,CAAC,OAAO,IAAI,CAAC;IACtE,gFAAgF;IAChF,OAAO,CA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AC,gCAUxE,CAAC"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { jsxs as v, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { ark as d } from "@ark-ui/react/factory";
|
|
3
|
+
import { FormatNumber as w } from "@ark-ui/react/format";
|
|
4
|
+
import { MinusIcon as k, TrendingDownIcon as S, TrendingUpIcon as y } from "lucide-react";
|
|
5
|
+
import { tv as D } from "tailwind-variants";
|
|
6
|
+
import { cn as i } from "../lib/cn.js";
|
|
7
|
+
import { Card as I } from "./card.js";
|
|
8
|
+
import { Skeleton as _ } from "./skeleton.js";
|
|
9
|
+
const V = (a) => {
|
|
10
|
+
const { variant: t = "default", className: s, slot: e, ...n } = a;
|
|
11
|
+
return /* @__PURE__ */ o(
|
|
12
|
+
I,
|
|
13
|
+
{
|
|
14
|
+
className: i(
|
|
15
|
+
"group/stat [--space:--spacing(4)] px-(--space)",
|
|
16
|
+
// Indicator and label share the first row; the value and the trend share the second.
|
|
17
|
+
"grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-0 gap-y-1",
|
|
18
|
+
"outline-none transition-colors focus-visible:ring-[3px] focus-visible:ring-ring",
|
|
19
|
+
"[a&]:hover:border-primary/40",
|
|
20
|
+
s
|
|
21
|
+
),
|
|
22
|
+
"data-variant": t,
|
|
23
|
+
...n,
|
|
24
|
+
slot: e ?? "stat-root"
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
}, W = (a) => {
|
|
28
|
+
const { className: t, slot: s, ...e } = a;
|
|
29
|
+
return /* @__PURE__ */ o(
|
|
30
|
+
d.div,
|
|
31
|
+
{
|
|
32
|
+
"aria-hidden": !0,
|
|
33
|
+
className: i(
|
|
34
|
+
"col-start-1 me-2 shrink-0 rounded-full p-1.5 [&_svg]:size-3.5",
|
|
35
|
+
// The soft status pair `Badge` measured: step-11 ink on a 7% wash.
|
|
36
|
+
"bg-muted text-muted-foreground",
|
|
37
|
+
"group-data-[variant=success]/stat:bg-success/7 group-data-[variant=success]/stat:text-success-foreground",
|
|
38
|
+
"group-data-[variant=info]/stat:bg-info/7 group-data-[variant=info]/stat:text-info-foreground",
|
|
39
|
+
"group-data-[variant=warning]/stat:bg-warning/7 group-data-[variant=warning]/stat:text-warning-foreground",
|
|
40
|
+
"group-data-[variant=destructive]/stat:bg-destructive/7 group-data-[variant=destructive]/stat:text-destructive-foreground",
|
|
41
|
+
t
|
|
42
|
+
),
|
|
43
|
+
...e,
|
|
44
|
+
"data-slot": s ?? "stat-indicator"
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
}, B = (a) => {
|
|
48
|
+
const { className: t, slot: s, ...e } = a;
|
|
49
|
+
return /* @__PURE__ */ o(
|
|
50
|
+
d.span,
|
|
51
|
+
{
|
|
52
|
+
className: i(
|
|
53
|
+
"col-start-2 col-end-[-1] truncate font-medium text-muted-foreground text-sm",
|
|
54
|
+
t
|
|
55
|
+
),
|
|
56
|
+
...e,
|
|
57
|
+
"data-slot": s ?? "stat-label"
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
}, R = (a) => {
|
|
61
|
+
const { loading: t = !1, className: s, children: e, slot: n, ...r } = a;
|
|
62
|
+
return /* @__PURE__ */ o(
|
|
63
|
+
d.div,
|
|
64
|
+
{
|
|
65
|
+
"aria-busy": t || void 0,
|
|
66
|
+
className: i(
|
|
67
|
+
"col-start-1 col-end-3 pt-2 font-semibold text-2xl text-foreground leading-none tracking-tight",
|
|
68
|
+
s
|
|
69
|
+
),
|
|
70
|
+
...r,
|
|
71
|
+
"data-slot": n ?? "stat-value",
|
|
72
|
+
children: t ? /* @__PURE__ */ o(_, { className: "h-6 w-20" }) : e
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
}, $ = D({
|
|
76
|
+
base: "col-span-full flex items-center gap-1 font-medium text-xs [&_svg]:size-3.5 [&_svg]:shrink-0",
|
|
77
|
+
variants: {
|
|
78
|
+
// Step-11 ink: a delta is 12px text and owes 4.5:1, which the step-9 fill does not reach.
|
|
79
|
+
tone: {
|
|
80
|
+
good: "text-success-foreground",
|
|
81
|
+
bad: "text-destructive-foreground",
|
|
82
|
+
flat: "text-muted-foreground"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}), X = (a) => {
|
|
86
|
+
const { value: t, unit: s, goodWhenUp: e = !0, className: n, children: r, slot: c, ...m } = a, l = t > 0 ? "up" : t < 0 ? "down" : "flat", g = l === "flat" ? "flat" : l === "up" === e ? "good" : "bad", u = { up: y, down: S, flat: k }[l];
|
|
87
|
+
return /* @__PURE__ */ v(
|
|
88
|
+
d.div,
|
|
89
|
+
{
|
|
90
|
+
className: i($({ tone: g }), n),
|
|
91
|
+
"data-direction": l,
|
|
92
|
+
...m,
|
|
93
|
+
"data-slot": c ?? "stat-delta",
|
|
94
|
+
children: [
|
|
95
|
+
/* @__PURE__ */ o(u, { "aria-hidden": !0 }),
|
|
96
|
+
/* @__PURE__ */ v("span", { children: [
|
|
97
|
+
/* @__PURE__ */ o(w, { maximumFractionDigits: 1, signDisplay: "exceptZero", value: t }),
|
|
98
|
+
s
|
|
99
|
+
] }),
|
|
100
|
+
r != null && /* @__PURE__ */ o("span", { className: "font-normal text-muted-foreground", children: r })
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
}, Y = (a) => {
|
|
105
|
+
const { values: t, className: s, slot: e, ...n } = a;
|
|
106
|
+
if (t.length < 2) return null;
|
|
107
|
+
const r = 72, c = 22, m = Math.min(...t), l = Math.max(...t) - m || 1, g = r / (t.length - 1), u = t.map((p, f) => [f * g, c - (p - m) / l * c]), x = u.map(([p, f], b) => `${b ? "L" : "M"}${p.toFixed(1)},${f.toFixed(1)}`).join(" "), [h, N] = u[u.length - 1] ?? [0, 0];
|
|
108
|
+
return /* @__PURE__ */ v(
|
|
109
|
+
d.svg,
|
|
110
|
+
{
|
|
111
|
+
"aria-hidden": !0,
|
|
112
|
+
className: i("col-start-3 ms-3 self-end overflow-visible", s),
|
|
113
|
+
height: c,
|
|
114
|
+
viewBox: `0 0 ${r} ${c}`,
|
|
115
|
+
width: r,
|
|
116
|
+
...n,
|
|
117
|
+
"data-slot": e ?? "stat-trend",
|
|
118
|
+
children: [
|
|
119
|
+
/* @__PURE__ */ o(
|
|
120
|
+
"path",
|
|
121
|
+
{
|
|
122
|
+
className: "text-muted-foreground",
|
|
123
|
+
d: x,
|
|
124
|
+
fill: "none",
|
|
125
|
+
stroke: "currentColor",
|
|
126
|
+
strokeLinecap: "round",
|
|
127
|
+
strokeLinejoin: "round",
|
|
128
|
+
strokeWidth: 1.5
|
|
129
|
+
}
|
|
130
|
+
),
|
|
131
|
+
/* @__PURE__ */ o("circle", { className: "fill-primary", cx: h, cy: N, r: 2.5 })
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
}, Z = (a) => {
|
|
136
|
+
const { className: t, slot: s, ...e } = a;
|
|
137
|
+
return /* @__PURE__ */ o(
|
|
138
|
+
d.p,
|
|
139
|
+
{
|
|
140
|
+
className: i("col-span-full text-muted-foreground text-sm", t),
|
|
141
|
+
...e,
|
|
142
|
+
"data-slot": s ?? "stat-description"
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
};
|
|
146
|
+
export {
|
|
147
|
+
X as StatDelta,
|
|
148
|
+
Z as StatDescription,
|
|
149
|
+
W as StatIndicator,
|
|
150
|
+
B as StatLabel,
|
|
151
|
+
V as StatRoot,
|
|
152
|
+
Y as StatTrend,
|
|
153
|
+
R as StatValue
|
|
154
|
+
};
|
|
155
|
+
//# sourceMappingURL=stat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stat.js","sources":["../../src/simples/stat.tsx"],"sourcesContent":["import { ark } from \"@ark-ui/react/factory\";\nimport { FormatNumber } from \"@ark-ui/react/format\";\nimport { MinusIcon, TrendingDownIcon, TrendingUpIcon } from \"lucide-react\";\nimport { tv } from \"tailwind-variants\";\nimport { cn } from \"../lib/cn\";\nimport { Card } from \"./card\";\nimport { Skeleton } from \"./skeleton\";\n\nexport interface StatRootProps extends React.ComponentProps<typeof Card> {\n /** The status family, written to `data-variant` and read by `StatIndicator`. */\n variant?: \"default\" | \"success\" | \"info\" | \"warning\" | \"destructive\";\n}\n\n/**\n * One dashboard number. A `Card`, so `asChild` makes the anchor *be* the tile — one tab stop, and\n * the router seam. The link styles key on the element (`[a&]`, as `Badge` does) rather than on a\n * prop, so they cannot disagree with what was rendered.\n */\nexport const StatRoot = (props: StatRootProps) => {\n const { variant = \"default\", className, slot, ...rest } = props;\n\n return (\n <Card\n className={cn(\n \"group/stat [--space:--spacing(4)] px-(--space)\",\n // Indicator and label share the first row; the value and the trend share the second.\n \"grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-0 gap-y-1\",\n \"outline-none transition-colors focus-visible:ring-[3px] focus-visible:ring-ring\",\n \"[a&]:hover:border-primary/40\",\n className\n )}\n data-variant={variant}\n {...rest}\n slot={slot ?? \"stat-root\"}\n />\n );\n};\n\nexport const StatIndicator = (props: React.ComponentProps<typeof ark.div>) => {\n const { className, slot, ...rest } = props;\n\n return (\n <ark.div\n aria-hidden\n className={cn(\n \"col-start-1 me-2 shrink-0 rounded-full p-1.5 [&_svg]:size-3.5\",\n // The soft status pair `Badge` measured: step-11 ink on a 7% wash.\n \"bg-muted text-muted-foreground\",\n \"group-data-[variant=success]/stat:bg-success/7 group-data-[variant=success]/stat:text-success-foreground\",\n \"group-data-[variant=info]/stat:bg-info/7 group-data-[variant=info]/stat:text-info-foreground\",\n \"group-data-[variant=warning]/stat:bg-warning/7 group-data-[variant=warning]/stat:text-warning-foreground\",\n \"group-data-[variant=destructive]/stat:bg-destructive/7 group-data-[variant=destructive]/stat:text-destructive-foreground\",\n className\n )}\n {...rest}\n data-slot={slot ?? \"stat-indicator\"}\n />\n );\n};\n\n/** Sentence case, no trailing colon. */\nexport const StatLabel = (props: React.ComponentProps<typeof ark.span>) => {\n const { className, slot, ...rest } = props;\n\n return (\n <ark.span\n className={cn(\n \"col-start-2 col-end-[-1] truncate font-medium text-muted-foreground text-sm\",\n className\n )}\n {...rest}\n data-slot={slot ?? \"stat-label\"}\n />\n );\n};\n\nexport interface StatValueProps extends React.ComponentProps<typeof ark.div> {\n /** Swaps the figure for a skeleton of its size, so the tile does not jump when it lands. */\n loading?: boolean;\n}\n\n/**\n * The figure, as the host formats it — `FormatNumber` with `notation=\"compact\"` is the dashboard\n * reading. Proportional figures on purpose: a lone headline number is not a column to align.\n */\nexport const StatValue = (props: StatValueProps) => {\n const { loading = false, className, children, slot, ...rest } = props;\n\n return (\n <ark.div\n aria-busy={loading || undefined}\n className={cn(\n \"col-start-1 col-end-3 pt-2 font-semibold text-2xl text-foreground leading-none tracking-tight\",\n className\n )}\n {...rest}\n data-slot={slot ?? \"stat-value\"}\n >\n {loading ? <Skeleton className=\"h-6 w-20\" /> : children}\n </ark.div>\n );\n};\n\nconst statDeltaVariants = tv({\n base: \"col-span-full flex items-center gap-1 font-medium text-xs [&_svg]:size-3.5 [&_svg]:shrink-0\",\n variants: {\n // Step-11 ink: a delta is 12px text and owes 4.5:1, which the step-9 fill does not reach.\n tone: {\n good: \"text-success-foreground\",\n bad: \"text-destructive-foreground\",\n flat: \"text-muted-foreground\",\n },\n },\n});\n\nexport interface StatDeltaProps extends React.ComponentProps<typeof ark.div> {\n /** Signed change. Its sign draws the direction icon; with `goodWhenUp`, it picks the colour. */\n value: number;\n /**\n * Against the magnitude, before the comparison — `\"%\"`, `\"pp\"`, `\"ms\"`. \"+8.2 vs last week\" is a\n * different claim from \"+8.2% vs last week\".\n */\n unit?: string;\n /** Whether a rise is good. Two more failed runs and two more members are both `+2`. @default true */\n goodWhenUp?: boolean;\n}\n\n/** The comparison period is the children: `<StatDelta value={4.2} unit=\"%\">vs last month</StatDelta>`. */\nexport const StatDelta = (props: StatDeltaProps) => {\n const { value, unit, goodWhenUp = true, className, children, slot, ...rest } = props;\n const direction = value > 0 ? \"up\" : value < 0 ? \"down\" : \"flat\";\n const tone = direction === \"flat\" ? \"flat\" : (direction === \"up\") === goodWhenUp ? \"good\" : \"bad\";\n // Never colour alone: the icon carries the direction and the sign carries it in text.\n const Icon = { up: TrendingUpIcon, down: TrendingDownIcon, flat: MinusIcon }[direction];\n\n return (\n <ark.div\n className={cn(statDeltaVariants({ tone }), className)}\n data-direction={direction}\n {...rest}\n data-slot={slot ?? \"stat-delta\"}\n >\n <Icon aria-hidden />\n <span>\n <FormatNumber maximumFractionDigits={1} signDisplay=\"exceptZero\" value={value} />\n {unit}\n </span>\n {children != null && <span className=\"font-normal text-muted-foreground\">{children}</span>}\n </ark.div>\n );\n};\n\n// `values` is also an SVG animation attribute, meaningless on an `<svg>`; the series takes the name.\nexport interface StatTrendProps extends Omit<React.ComponentProps<typeof ark.svg>, \"values\"> {\n /** About a dozen points, oldest first. Fewer than two draws nothing. */\n values: readonly number[];\n}\n\n/** A sparkline with its last value marked — unlabelled, because a reader who needs the values needs a chart. */\nexport const StatTrend = (props: StatTrendProps) => {\n const { values, className, slot, ...rest } = props;\n if (values.length < 2) return null;\n\n const w = 72;\n const h = 22;\n const min = Math.min(...values);\n const range = Math.max(...values) - min || 1;\n const step = w / (values.length - 1);\n const points = values.map((v, i) => [i * step, h - ((v - min) / range) * h] as const);\n const d = points.map(([x, y], i) => `${i ? \"L\" : \"M\"}${x.toFixed(1)},${y.toFixed(1)}`).join(\" \");\n const [lastX, lastY] = points[points.length - 1] ?? [0, 0];\n\n return (\n <ark.svg\n aria-hidden\n className={cn(\"col-start-3 ms-3 self-end overflow-visible\", className)}\n height={h}\n viewBox={`0 0 ${w} ${h}`}\n width={w}\n {...rest}\n data-slot={slot ?? \"stat-trend\"}\n >\n {/* A 1.5px trend line is a graphical object carrying information, so it owes 3:1. Diluted it\n measured 2.91:1 on the light page (3.33–3.35 in dark); step 11 solid is 9.19 and 8.52. */}\n <path\n className=\"text-muted-foreground\"\n d={d}\n fill=\"none\"\n stroke=\"currentColor\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={1.5}\n />\n <circle className=\"fill-primary\" cx={lastX} cy={lastY} r={2.5} />\n </ark.svg>\n );\n};\n\nexport const StatDescription = (props: React.ComponentProps<typeof ark.p>) => {\n const { className, slot, ...rest } = props;\n\n return (\n <ark.p\n className={cn(\"col-span-full text-muted-foreground text-sm\", className)}\n {...rest}\n data-slot={slot ?? \"stat-description\"}\n />\n );\n};\n"],"names":["StatRoot","props","variant","className","slot","rest","jsx","Card","cn","StatIndicator","ark","StatLabel","StatValue","loading","children","Skeleton","statDeltaVariants","tv","StatDelta","value","unit","goodWhenUp","direction","tone","Icon","TrendingUpIcon","TrendingDownIcon","MinusIcon","jsxs","FormatNumber","StatTrend","values","w","h","min","range","step","points","v","i","d","x","y","lastX","lastY","StatDescription"],"mappings":";;;;;;;;AAkBO,MAAMA,IAAW,CAACC,MAAyB;AAChD,QAAM,EAAE,SAAAC,IAAU,WAAW,WAAAC,GAAW,MAAAC,GAAM,GAAGC,MAASJ;AAE1D,SACE,gBAAAK;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,WAAWC;AAAA,QACT;AAAA;AAAA,QAEA;AAAA,QACA;AAAA,QACA;AAAA,QACAL;AAAA,MAAA;AAAA,MAEF,gBAAcD;AAAA,MACb,GAAGG;AAAA,MACJ,MAAMD,KAAQ;AAAA,IAAA;AAAA,EAAA;AAGpB,GAEaK,IAAgB,CAACR,MAAgD;AAC5E,QAAM,EAAE,WAAAE,GAAW,MAAAC,GAAM,GAAGC,MAASJ;AAErC,SACE,gBAAAK;AAAA,IAACI,EAAI;AAAA,IAAJ;AAAA,MACC,eAAW;AAAA,MACX,WAAWF;AAAA,QACT;AAAA;AAAA,QAEA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACAL;AAAA,MAAA;AAAA,MAED,GAAGE;AAAA,MACJ,aAAWD,KAAQ;AAAA,IAAA;AAAA,EAAA;AAGzB,GAGaO,IAAY,CAACV,MAA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CL,CAAS;AAAA,MACrE,QAAQ8B;AAAA,MACR,SAAS,OAAOD,CAAC,IAAIC,CAAC;AAAA,MACtB,OAAOD;AAAA,MACN,GAAG3B;AAAA,MACJ,aAAWD,KAAQ;AAAA,MAInB,UAAA;AAAA,QAAA,gBAAAE;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAU;AAAA,YACV,GAAAkC;AAAA,YACA,MAAK;AAAA,YACL,QAAO;AAAA,YACP,eAAc;AAAA,YACd,gBAAe;AAAA,YACf,aAAa;AAAA,UAAA;AAAA,QAAA;AAAA,QAEf,gBAAAlC,EAAC,YAAO,WAAU,gBAAe,IAAIqC,GAAO,IAAIC,GAAO,GAAG,IAAA,CAAK;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGrE,GAEaC,IAAkB,CAAC5C,MAA8C;AAC5E,QAAM,EAAE,WAAAE,GAAW,MAAAC,GAAM,GAAGC,MAASJ;AAErC,SACE,gBAAAK;AAAA,IAACI,EAAI;AAAA,IAAJ;AAAA,MACC,WAAWF,EAAG,+CAA+CL,CAAS;AAAA,MACrE,GAAGE;AAAA,MACJ,aAAWD,KAAQ;AAAA,IAAA;AAAA,EAAA;AAGzB;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ColumnDef, Row } from '@tanstack/react-table';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
export interface ActionsColumnOptions<TData> {
|
|
4
|
+
/** Visually hidden header text, so the column is not an empty `<th>`. Default "Actions". */
|
|
5
|
+
headerLabel?: string;
|
|
6
|
+
/** Column id. Default "actions". */
|
|
7
|
+
id?: string;
|
|
8
|
+
/** aria-label for a row's trigger. It names the row — the icon has no text to borrow. */
|
|
9
|
+
label: (row: Row<TData>) => string;
|
|
10
|
+
/** The row's menu items — `MenuItem`, `MenuSeparator`, `MenuGroup`. `null` renders no trigger. */
|
|
11
|
+
menu: (row: Row<TData>) => ReactNode;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A trailing row-menu column. A row with nothing permitted gets no trigger rather than an empty
|
|
15
|
+
* menu. The trigger and the menu both stop click propagation so neither fires
|
|
16
|
+
* `DataTableContent`'s `onRowClick` — the menu too, because a portal's events bubble through the
|
|
17
|
+
* React tree to the row regardless of where the DOM put them.
|
|
18
|
+
*/
|
|
19
|
+
export declare function actionsColumn<TData>(options: ActionsColumnOptions<TData>): ColumnDef<TData, unknown>;
|
|
20
|
+
//# sourceMappingURL=actions-column.d.ts.map
|