@kanzo-tech/ui 0.10.0 → 0.12.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/composites/language-picker.d.ts +44 -0
- package/dist/composites/language-picker.d.ts.map +1 -0
- package/dist/composites/language-picker.js +163 -0
- package/dist/composites/language-picker.js.map +1 -0
- package/dist/guard-corpus.d.ts.map +1 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +693 -667
- 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/lib/use-async-collection.d.ts +57 -0
- package/dist/lib/use-async-collection.d.ts.map +1 -0
- package/dist/lib/use-async-collection.js +43 -0
- package/dist/lib/use-async-collection.js.map +1 -0
- package/dist/lib/use-debounced-commit.d.ts +28 -0
- package/dist/lib/use-debounced-commit.d.ts.map +1 -0
- package/dist/lib/use-debounced-commit.js +26 -0
- package/dist/lib/use-debounced-commit.js.map +1 -0
- package/dist/shark-parity.divergences.d.ts.map +1 -1
- package/dist/simples/date-picker.d.ts.map +1 -1
- package/dist/simples/date-picker.js +66 -60
- package/dist/simples/date-picker.js.map +1 -1
- package/dist/simples/field.d.ts +42 -3
- package/dist/simples/field.d.ts.map +1 -1
- package/dist/simples/field.js +143 -105
- 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/locale.d.ts +4 -0
- package/dist/simples/locale.d.ts.map +1 -0
- package/dist/simples/locale.js +8 -0
- package/dist/simples/locale.js.map +1 -0
- package/dist/simples/segment-group.d.ts.map +1 -1
- package/dist/simples/segment-group.js +67 -61
- package/dist/simples/segment-group.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 r, jsxs as u } 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
|
-
import { tv as
|
|
6
|
-
import { cn as
|
|
5
|
+
import { tv as f } from "tailwind-variants";
|
|
6
|
+
import { cn as l } from "../lib/cn.js";
|
|
7
7
|
import { Separator as p } from "./separator.js";
|
|
8
|
-
const
|
|
8
|
+
const V = m, g = f({
|
|
9
9
|
base: [
|
|
10
10
|
"group/field",
|
|
11
11
|
"w-full",
|
|
@@ -42,86 +42,102 @@ const k = m, g = u({
|
|
|
42
42
|
orientation: "vertical",
|
|
43
43
|
reverse: !1
|
|
44
44
|
}
|
|
45
|
-
}),
|
|
46
|
-
const { orientation:
|
|
47
|
-
return /* @__PURE__ */
|
|
45
|
+
}), H = (a) => {
|
|
46
|
+
const { orientation: e = "vertical", reverse: t = !1, className: o, slot: s, ...c } = a;
|
|
47
|
+
return /* @__PURE__ */ r(
|
|
48
48
|
i.Root,
|
|
49
49
|
{
|
|
50
|
-
className:
|
|
51
|
-
"data-orientation":
|
|
50
|
+
className: l(g({ orientation: e, reverse: t }), o),
|
|
51
|
+
"data-orientation": e,
|
|
52
52
|
...c,
|
|
53
53
|
"data-slot": s ?? "field"
|
|
54
54
|
}
|
|
55
55
|
);
|
|
56
56
|
}, S = (a) => {
|
|
57
|
-
const { className:
|
|
58
|
-
return /* @__PURE__ */
|
|
57
|
+
const { className: e, slot: t, ...o } = a;
|
|
58
|
+
return /* @__PURE__ */ r(
|
|
59
59
|
n.Root,
|
|
60
60
|
{
|
|
61
|
-
className:
|
|
61
|
+
className: l(
|
|
62
62
|
"flex flex-col gap-6",
|
|
63
63
|
"has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",
|
|
64
64
|
"data-invalid:text-destructive-foreground",
|
|
65
65
|
"dark:data-invalid:text-destructive-foreground",
|
|
66
|
-
|
|
66
|
+
e
|
|
67
67
|
),
|
|
68
68
|
...o,
|
|
69
|
-
"data-slot":
|
|
69
|
+
"data-slot": t ?? "field-set"
|
|
70
70
|
}
|
|
71
71
|
);
|
|
72
72
|
}, T = (a) => {
|
|
73
|
-
const { variant:
|
|
74
|
-
return /* @__PURE__ */
|
|
73
|
+
const { variant: e = "legend", className: t, slot: o, ...s } = a;
|
|
74
|
+
return /* @__PURE__ */ r(
|
|
75
75
|
n.Legend,
|
|
76
76
|
{
|
|
77
|
-
className:
|
|
77
|
+
className: l(
|
|
78
78
|
"mb-3 font-medium",
|
|
79
79
|
"data-[variant=legend]:text-base",
|
|
80
80
|
"data-[variant=label]:text-sm",
|
|
81
|
-
|
|
81
|
+
t
|
|
82
82
|
),
|
|
83
|
-
"data-variant":
|
|
83
|
+
"data-variant": e,
|
|
84
84
|
...s,
|
|
85
85
|
"data-slot": o ?? "field-legend"
|
|
86
86
|
}
|
|
87
87
|
);
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
}, x = f({
|
|
89
|
+
base: [
|
|
90
|
+
"group/field-group @container/field-group",
|
|
91
|
+
"w-full gap-4",
|
|
92
|
+
"data-[data-slot=checkbox-group]:gap-3",
|
|
93
|
+
"*:data-[slot=field-group]:gap-4"
|
|
94
|
+
],
|
|
95
|
+
variants: {
|
|
96
|
+
// A closed set of counts, each a whole class, so a caller overrides one per breakpoint with a
|
|
97
|
+
// class of its own — `columns={1} className="sm:grid-cols-2"`. It was a `--columns` custom
|
|
98
|
+
// property written to `style`, as `RadioGroup` does, and an inline property beats every class,
|
|
99
|
+
// so that override was the one thing it could not express.
|
|
100
|
+
columns: {
|
|
101
|
+
stack: "flex flex-col",
|
|
102
|
+
1: "grid grid-cols-1",
|
|
103
|
+
2: "grid grid-cols-2",
|
|
104
|
+
3: "grid grid-cols-3",
|
|
105
|
+
4: "grid grid-cols-4",
|
|
106
|
+
auto: "grid grid-cols-[repeat(auto-fit,minmax(14rem,1fr))]"
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
defaultVariants: { columns: "stack" }
|
|
110
|
+
}), E = (a) => {
|
|
111
|
+
const { columns: e = "stack", className: t, slot: o, ...s } = a;
|
|
112
|
+
return /* @__PURE__ */ r(
|
|
91
113
|
d.div,
|
|
92
114
|
{
|
|
93
|
-
className:
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
"data-[data-slot=checkbox-group]:gap-3",
|
|
97
|
-
"*:data-[slot=field-group]:gap-4",
|
|
98
|
-
t
|
|
99
|
-
),
|
|
100
|
-
...o,
|
|
101
|
-
"data-slot": e ?? "field-group"
|
|
115
|
+
className: l(x({ columns: e }), t),
|
|
116
|
+
...s,
|
|
117
|
+
"data-slot": o ?? "field-group"
|
|
102
118
|
}
|
|
103
119
|
);
|
|
104
|
-
},
|
|
105
|
-
const { className:
|
|
106
|
-
return /* @__PURE__ */
|
|
120
|
+
}, L = (a) => {
|
|
121
|
+
const { className: e, slot: t, ...o } = a;
|
|
122
|
+
return /* @__PURE__ */ r(
|
|
107
123
|
d.div,
|
|
108
124
|
{
|
|
109
|
-
className:
|
|
125
|
+
className: l(
|
|
110
126
|
"group/field-content",
|
|
111
127
|
"flex flex-1 flex-col gap-1.5",
|
|
112
128
|
"leading-snug",
|
|
113
|
-
|
|
129
|
+
e
|
|
114
130
|
),
|
|
115
131
|
...o,
|
|
116
|
-
"data-slot":
|
|
132
|
+
"data-slot": t ?? "field-content"
|
|
117
133
|
}
|
|
118
134
|
);
|
|
119
|
-
},
|
|
120
|
-
const { className:
|
|
121
|
-
return /* @__PURE__ */
|
|
135
|
+
}, R = (a) => {
|
|
136
|
+
const { className: e, slot: t, ...o } = a;
|
|
137
|
+
return /* @__PURE__ */ r(
|
|
122
138
|
i.Label,
|
|
123
139
|
{
|
|
124
|
-
className:
|
|
140
|
+
className: l(
|
|
125
141
|
"group/field-label peer/field-label",
|
|
126
142
|
"select-none font-medium text-sm leading-snug",
|
|
127
143
|
"flex w-fit gap-1",
|
|
@@ -129,49 +145,57 @@ const k = m, g = u({
|
|
|
129
145
|
"has-data-[state=checked]:border-primary has-data-[state=checked]:bg-primary/5",
|
|
130
146
|
"group-data-disabled/field:opacity-64",
|
|
131
147
|
"dark:has-data-[state=checked]:bg-primary/10",
|
|
132
|
-
|
|
148
|
+
e
|
|
133
149
|
),
|
|
134
150
|
...o,
|
|
135
|
-
"data-slot":
|
|
151
|
+
"data-slot": t ?? "field-label"
|
|
136
152
|
}
|
|
137
153
|
);
|
|
138
|
-
},
|
|
139
|
-
const { className:
|
|
140
|
-
return /* @__PURE__ */
|
|
154
|
+
}, q = (a) => {
|
|
155
|
+
const { className: e, children: t, slot: o, fallback: s, ...c } = a;
|
|
156
|
+
return /* @__PURE__ */ r(
|
|
141
157
|
i.RequiredIndicator,
|
|
142
158
|
{
|
|
143
159
|
"aria-hidden": !0,
|
|
144
|
-
className:
|
|
160
|
+
className: l(
|
|
145
161
|
"select-none text-destructive-foreground text-sm",
|
|
146
|
-
|
|
162
|
+
e
|
|
147
163
|
),
|
|
148
|
-
|
|
164
|
+
fallback: s == null ? null : /* @__PURE__ */ r(
|
|
165
|
+
"span",
|
|
166
|
+
{
|
|
167
|
+
className: "select-none font-normal text-muted-foreground text-sm",
|
|
168
|
+
"data-slot": "field-optional-indicator",
|
|
169
|
+
children: s
|
|
170
|
+
}
|
|
171
|
+
),
|
|
172
|
+
...c,
|
|
149
173
|
"data-slot": o ?? "field-required-indicator",
|
|
150
|
-
children:
|
|
174
|
+
children: t ?? "*"
|
|
151
175
|
}
|
|
152
176
|
);
|
|
153
|
-
},
|
|
154
|
-
const { className:
|
|
155
|
-
return /* @__PURE__ */
|
|
177
|
+
}, z = (a) => {
|
|
178
|
+
const { className: e, slot: t, ...o } = a;
|
|
179
|
+
return /* @__PURE__ */ r(
|
|
156
180
|
d.div,
|
|
157
181
|
{
|
|
158
|
-
className:
|
|
182
|
+
className: l(
|
|
159
183
|
"w-fit",
|
|
160
184
|
"flex items-center gap-2",
|
|
161
185
|
"font-medium text-sm leading-snug",
|
|
162
186
|
"group-data-[disabled=true]/field:opacity-64",
|
|
163
|
-
|
|
187
|
+
e
|
|
164
188
|
),
|
|
165
189
|
...o,
|
|
166
|
-
"data-slot":
|
|
190
|
+
"data-slot": t ?? "field-title"
|
|
167
191
|
}
|
|
168
192
|
);
|
|
169
|
-
},
|
|
170
|
-
const { className:
|
|
171
|
-
return /* @__PURE__ */
|
|
193
|
+
}, j = (a) => {
|
|
194
|
+
const { className: e, slot: t, ...o } = a;
|
|
195
|
+
return /* @__PURE__ */ r(
|
|
172
196
|
d.p,
|
|
173
197
|
{
|
|
174
|
-
className:
|
|
198
|
+
className: l(
|
|
175
199
|
"pointer-events-none",
|
|
176
200
|
"font-normal text-muted-foreground text-sm leading-normal",
|
|
177
201
|
"group-has-data-[orientation=horizontal]/field:text-balance",
|
|
@@ -179,107 +203,121 @@ const k = m, g = u({
|
|
|
179
203
|
"nth-last-2:-mt-1 last:mt-0 [[data-variant=legend]+&]:-mt-1.5",
|
|
180
204
|
"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!",
|
|
181
205
|
"[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4",
|
|
182
|
-
|
|
206
|
+
e
|
|
183
207
|
),
|
|
184
208
|
...o,
|
|
185
|
-
"data-slot":
|
|
209
|
+
"data-slot": t ?? "field-description"
|
|
186
210
|
}
|
|
187
211
|
);
|
|
188
|
-
},
|
|
189
|
-
const { className:
|
|
190
|
-
return /* @__PURE__ */
|
|
212
|
+
}, C = (a) => {
|
|
213
|
+
const { className: e, children: t, slot: o, ...s } = a;
|
|
214
|
+
return /* @__PURE__ */ u(
|
|
191
215
|
d.div,
|
|
192
216
|
{
|
|
193
|
-
className:
|
|
217
|
+
className: l(
|
|
194
218
|
"relative",
|
|
195
219
|
"h-5",
|
|
196
220
|
"-my-2 group-data-[variant=outline]/field-group:-mb-2",
|
|
197
221
|
"text-sm",
|
|
198
|
-
|
|
222
|
+
e
|
|
199
223
|
),
|
|
200
|
-
"data-content": !!
|
|
224
|
+
"data-content": !!t,
|
|
201
225
|
...s,
|
|
202
226
|
"data-slot": o ?? "field-separator",
|
|
203
227
|
children: [
|
|
204
|
-
/* @__PURE__ */
|
|
205
|
-
!!
|
|
228
|
+
/* @__PURE__ */ r(p, { className: "absolute inset-0 top-1/2" }),
|
|
229
|
+
!!t && /* @__PURE__ */ r(
|
|
206
230
|
"span",
|
|
207
231
|
{
|
|
208
|
-
className:
|
|
232
|
+
className: l(
|
|
209
233
|
"relative block",
|
|
210
234
|
"w-fit",
|
|
211
235
|
"mx-auto px-2",
|
|
212
236
|
"bg-background",
|
|
213
237
|
"text-muted-foreground text-sm"
|
|
214
238
|
),
|
|
215
|
-
children:
|
|
239
|
+
children: t
|
|
216
240
|
}
|
|
217
241
|
)
|
|
218
242
|
]
|
|
219
243
|
}
|
|
220
244
|
);
|
|
221
|
-
},
|
|
222
|
-
|
|
223
|
-
|
|
245
|
+
}, v = f({
|
|
246
|
+
base: "text-sm",
|
|
247
|
+
variants: {
|
|
248
|
+
// `muted` is what a helper always was. The two others are for a message that is neither
|
|
249
|
+
// guidance nor an error: a warning the value survives, or a note about what it will do. They
|
|
250
|
+
// are text colours and nothing else — a message that must block belongs in `FieldError`.
|
|
251
|
+
tone: {
|
|
252
|
+
muted: "text-muted-foreground",
|
|
253
|
+
info: "text-info-foreground",
|
|
254
|
+
warning: "text-warning-foreground"
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
defaultVariants: { tone: "muted" }
|
|
258
|
+
}), G = (a) => {
|
|
259
|
+
const { tone: e = "muted", className: t, slot: o, ...s } = a;
|
|
260
|
+
return /* @__PURE__ */ r(
|
|
224
261
|
i.HelperText,
|
|
225
262
|
{
|
|
226
|
-
className:
|
|
227
|
-
|
|
228
|
-
|
|
263
|
+
className: l(v({ tone: e }), t),
|
|
264
|
+
"data-tone": e,
|
|
265
|
+
...s,
|
|
266
|
+
"data-slot": o ?? "field-helper"
|
|
229
267
|
}
|
|
230
268
|
);
|
|
231
269
|
}, I = (a) => {
|
|
232
|
-
const { className:
|
|
233
|
-
return /* @__PURE__ */
|
|
270
|
+
const { className: e, slot: t, ...o } = a;
|
|
271
|
+
return /* @__PURE__ */ r(
|
|
234
272
|
i.ErrorText,
|
|
235
273
|
{
|
|
236
|
-
className:
|
|
274
|
+
className: l(
|
|
237
275
|
"font-normal text-destructive-foreground text-sm",
|
|
238
|
-
|
|
276
|
+
e
|
|
239
277
|
),
|
|
240
278
|
...o,
|
|
241
|
-
"data-slot":
|
|
279
|
+
"data-slot": t ?? "field-error"
|
|
242
280
|
}
|
|
243
281
|
);
|
|
244
|
-
},
|
|
245
|
-
const { className:
|
|
246
|
-
return /* @__PURE__ */
|
|
282
|
+
}, D = (a) => {
|
|
283
|
+
const { className: e, slot: t, ...o } = a;
|
|
284
|
+
return /* @__PURE__ */ r(
|
|
247
285
|
n.HelperText,
|
|
248
286
|
{
|
|
249
|
-
className:
|
|
287
|
+
className: l("text-muted-foreground text-sm", e),
|
|
250
288
|
...o,
|
|
251
|
-
"data-slot":
|
|
289
|
+
"data-slot": t ?? "field-set-helper"
|
|
252
290
|
}
|
|
253
291
|
);
|
|
254
|
-
},
|
|
255
|
-
const { className:
|
|
256
|
-
return /* @__PURE__ */
|
|
292
|
+
}, $ = (a) => {
|
|
293
|
+
const { className: e, slot: t, ...o } = a;
|
|
294
|
+
return /* @__PURE__ */ r(
|
|
257
295
|
n.ErrorText,
|
|
258
296
|
{
|
|
259
|
-
className:
|
|
297
|
+
className: l(
|
|
260
298
|
"font-normal text-destructive-foreground text-sm",
|
|
261
|
-
|
|
299
|
+
e
|
|
262
300
|
),
|
|
263
301
|
...o,
|
|
264
|
-
"data-slot":
|
|
302
|
+
"data-slot": t ?? "field-set-error"
|
|
265
303
|
}
|
|
266
304
|
);
|
|
267
305
|
};
|
|
268
306
|
export {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
307
|
+
H as Field,
|
|
308
|
+
L as FieldContent,
|
|
309
|
+
j as FieldDescription,
|
|
272
310
|
I as FieldError,
|
|
273
311
|
E as FieldGroup,
|
|
274
|
-
|
|
275
|
-
|
|
312
|
+
G as FieldHelper,
|
|
313
|
+
R as FieldLabel,
|
|
276
314
|
T as FieldLegend,
|
|
277
|
-
|
|
278
|
-
|
|
315
|
+
q as FieldRequiredIndicator,
|
|
316
|
+
C as FieldSeparator,
|
|
279
317
|
S as FieldSet,
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
318
|
+
$ as FieldSetError,
|
|
319
|
+
D as FieldSetHelper,
|
|
320
|
+
z as FieldTitle,
|
|
321
|
+
V as useField
|
|
284
322
|
};
|
|
285
323
|
//# 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,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,I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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\nconst fieldGroupVariants = tv({\n base: [\n \"group/field-group @container/field-group\",\n \"w-full gap-4\",\n \"data-[data-slot=checkbox-group]:gap-3\",\n \"*:data-[slot=field-group]:gap-4\",\n ],\n variants: {\n // A closed set of counts, each a whole class, so a caller overrides one per breakpoint with a\n // class of its own — `columns={1} className=\"sm:grid-cols-2\"`. It was a `--columns` custom\n // property written to `style`, as `RadioGroup` does, and an inline property beats every class,\n // so that override was the one thing it could not express.\n columns: {\n stack: \"flex flex-col\",\n 1: \"grid grid-cols-1\",\n 2: \"grid grid-cols-2\",\n 3: \"grid grid-cols-3\",\n 4: \"grid grid-cols-4\",\n auto: \"grid grid-cols-[repeat(auto-fit,minmax(14rem,1fr))]\",\n },\n },\n defaultVariants: { columns: \"stack\" },\n});\n\ninterface FieldGroupProps extends React.ComponentProps<typeof ark.div> {\n /**\n * Lay the fields out in a grid: one to four equal columns, or `\"auto\"` to fit as many as the\n * width allows. Omitted, they stack. A field that should span the row takes `col-span-full`.\n */\n columns?: 1 | 2 | 3 | 4 | \"auto\";\n}\n\nexport const FieldGroup = (props: FieldGroupProps) => {\n const { columns = \"stack\", className, slot, ...rest } = props;\n\n return (\n <ark.div\n className={cn(fieldGroupVariants({ columns }), className)}\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\nconst fieldHelperVariants = tv({\n base: \"text-sm\",\n variants: {\n // `muted` is what a helper always was. The two others are for a message that is neither\n // guidance nor an error: a warning the value survives, or a note about what it will do. They\n // are text colours and nothing else — a message that must block belongs in `FieldError`.\n tone: {\n muted: \"text-muted-foreground\",\n info: \"text-info-foreground\",\n warning: \"text-warning-foreground\",\n },\n },\n defaultVariants: { tone: \"muted\" },\n});\n\ninterface FieldHelperProps\n extends React.ComponentProps<typeof ArkField.HelperText>,\n VariantProps<typeof fieldHelperVariants> {}\n\n/**\n * The one message wired into the control's `aria-describedby`, and there is one per `Field`: Ark\n * gives every `HelperText` the same id, so a second would collide. A warning beside a description\n * is therefore this part with a `tone` for the warning and `FieldDescription` for the description.\n */\nexport const FieldHelper = (props: FieldHelperProps) => {\n const { tone = \"muted\", className, slot, ...rest } = props;\n\n return (\n <ArkField.HelperText\n className={cn(fieldHelperVariants({ tone }), className)}\n data-tone={tone}\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","fieldGroupVariants","FieldGroup","columns","ark","FieldContent","FieldLabel","FieldRequiredIndicator","children","fallback","FieldTitle","FieldDescription","FieldSeparator","jsxs","Separator","fieldHelperVariants","FieldHelper","tone","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,uCA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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,GAOa2B,IAAiB,CAC5B/B,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,GAEa4B,IAAgB,CAC3BhC,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,4 @@
|
|
|
1
|
+
import { LocaleProvider as ArkLocaleProvider } from '@ark-ui/react/locale';
|
|
2
|
+
export declare const LocaleProvider: (props: React.ComponentProps<typeof ArkLocaleProvider>) => import("react").JSX.Element;
|
|
3
|
+
export declare const useLocale: () => import('@ark-ui/react').UseLocaleContext;
|
|
4
|
+
//# sourceMappingURL=locale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale.d.ts","sourceRoot":"","sources":["../../src/simples/locale.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,IAAI,iBAAiB,EAEpC,MAAM,sBAAsB,CAAC;AAO9B,eAAO,MAAM,cAAc,GACzB,OAAO,KAAK,CAAC,cAAc,CAAC,OAAO,iBAAiB,CAAC,gCAClB,CAAC;AAGtC,eAAO,MAAM,SAAS,gDAAmB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useLocaleContext as r, LocaleProvider as c } from "@ark-ui/react/locale";
|
|
3
|
+
const s = (o) => /* @__PURE__ */ e(c, { ...o }), i = r;
|
|
4
|
+
export {
|
|
5
|
+
s as LocaleProvider,
|
|
6
|
+
i as useLocale
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=locale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale.js","sources":["../../src/simples/locale.tsx"],"sourcesContent":["import {\n LocaleProvider as ArkLocaleProvider,\n useLocaleContext,\n} from \"@ark-ui/react/locale\";\n\n// Transparent, like `ClientOnly`: Ark's provider renders `children` and no element, so there is no\n// DOM node to slot. What it sets is the `locale` and `dir` every Ark machine below it formats and\n// mirrors by — `Format`, `DatePicker`, `useFilter`, the number and date inputs — which is why a\n// product that is not in `en-US` puts one at its root. It translates nothing: the words a\n// component draws are props on the component, written by the host.\nexport const LocaleProvider = (\n props: React.ComponentProps<typeof ArkLocaleProvider>\n) => <ArkLocaleProvider {...props} />;\n\n// Shark's name for Ark's `useLocaleContext`, by the same rule as every other context alias here.\nexport const useLocale = useLocaleContext;\n"],"names":["LocaleProvider","props","jsx","ArkLocaleProvider","useLocale","useLocaleContext"],"mappings":";;AAUO,MAAMA,IAAiB,CAC5BC,MACG,gBAAAC,EAACC,GAAA,EAAmB,GAAGF,EAAA,CAAO,GAGtBG,IAAYC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segment-group.d.ts","sourceRoot":"","sources":["../../src/simples/segment-group.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"segment-group.d.ts","sourceRoot":"","sources":["../../src/simples/segment-group.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,IAAI,eAAe,EAEhC,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,eAAO,MAAM,eAAe,sDAAyB,CAAC;AAEtD,KAAK,mBAAmB,GAAG,SAAS,GAAG,WAAW,GAAG,OAAO,CAAC;AAE7D,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,UAAU,iBACR,SAAQ,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,IAAI,CAAC;IACzD;;;;OAIG;IACH,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,qFAAqF;IACrF,OAAO,CAAC,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACxC,6DAA6D;IAC7D,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAKD,eAAO,MAAM,YAAY,GAAI,OAAO,iBAAiB,sBA4DpD,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAC3B,OAAO,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,IAAI,CAAC,sBA4BzD,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,OAAO,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,QAAQ,CAAC,sBAW7D,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAChC,OAAO,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,SAAS,CAAC,sBA8B9D,CAAC"}
|