@platned/ui 0.10.4 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -98
- package/dist/blocks-charts.cjs +459 -0
- package/dist/blocks-charts.cjs.map +1 -0
- package/dist/blocks-charts.d.cts +64 -0
- package/dist/blocks-charts.d.ts +64 -0
- package/dist/blocks-charts.js +440 -0
- package/dist/blocks-charts.js.map +1 -0
- package/dist/blocks.cjs +8007 -0
- package/dist/blocks.cjs.map +1 -0
- package/dist/blocks.d.cts +3082 -0
- package/dist/blocks.d.ts +3082 -0
- package/dist/blocks.js +8223 -0
- package/dist/blocks.js.map +1 -0
- package/dist/chart.cjs +226 -0
- package/dist/chart.cjs.map +1 -0
- package/dist/chart.d.ts +66 -0
- package/dist/chart.js +183 -0
- package/dist/chart.js.map +1 -0
- package/dist/chunk-2L5XAYNK.js +11 -0
- package/dist/chunk-2L5XAYNK.js.map +1 -0
- package/dist/chunk-327NSKZW.js +3176 -0
- package/dist/chunk-327NSKZW.js.map +1 -0
- package/dist/chunk-GJJWRZ4B.js +200 -0
- package/dist/chunk-GJJWRZ4B.js.map +1 -0
- package/dist/chunk-WGCAQEZ4.js +178 -0
- package/dist/chunk-WGCAQEZ4.js.map +1 -0
- package/dist/code-block-BgEiLXpO.d.ts +111 -0
- package/dist/code-block-highlight.cjs +489 -0
- package/dist/code-block-highlight.cjs.map +1 -0
- package/dist/code-block-highlight.d.ts +28 -0
- package/dist/code-block-highlight.js +120 -0
- package/dist/code-block-highlight.js.map +1 -0
- package/dist/data-table-Dec6t8NO.d.ts +729 -0
- package/dist/data-table.cjs +3506 -2219
- package/dist/data-table.cjs.map +1 -1
- package/dist/data-table.d.ts +2 -1
- package/dist/data-table.js +1396 -246
- package/dist/data-table.js.map +1 -1
- package/dist/index.cjs +8934 -11994
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2524 -5312
- package/dist/index.js +4678 -9574
- package/dist/index.js.map +1 -1
- package/dist/map.cjs +432 -0
- package/dist/map.cjs.map +1 -0
- package/dist/map.d.cts +294 -0
- package/dist/map.d.ts +294 -0
- package/dist/map.js +422 -0
- package/dist/map.js.map +1 -0
- package/dist/theme.css +1897 -0
- package/package.json +65 -24
- package/dist/chunk-OVIRTNT4.js +0 -2787
- package/dist/chunk-OVIRTNT4.js.map +0 -1
- package/dist/data-table-JX-vnL0F.d.ts +0 -464
- package/dist/sidebar.cjs +0 -108
- package/dist/sidebar.cjs.map +0 -1
- package/dist/sidebar.d.cts +0 -257
- package/dist/sidebar.d.ts +0 -257
- package/dist/sidebar.js +0 -70
- package/dist/sidebar.js.map +0 -1
- package/dist/styles.css +0 -1
- package/dist/tokens.css +0 -1
- package/tailwind-preset.cjs +0 -446
package/dist/chunk-OVIRTNT4.js
DELETED
|
@@ -1,2787 +0,0 @@
|
|
|
1
|
-
// src/lib/cn.ts
|
|
2
|
-
import { clsx } from "clsx";
|
|
3
|
-
import { extendTailwindMerge } from "tailwind-merge";
|
|
4
|
-
var FONT_SIZES = [
|
|
5
|
-
"body-micro",
|
|
6
|
-
"body-tiny",
|
|
7
|
-
"body-xs",
|
|
8
|
-
"body-sm",
|
|
9
|
-
"body",
|
|
10
|
-
"body-lg",
|
|
11
|
-
"heading-sm",
|
|
12
|
-
"heading",
|
|
13
|
-
"heading-lg",
|
|
14
|
-
"subheading-sm",
|
|
15
|
-
"subheading",
|
|
16
|
-
"subheading-lg",
|
|
17
|
-
"subtitle-sm",
|
|
18
|
-
"subtitle",
|
|
19
|
-
"subtitle-lg",
|
|
20
|
-
"title-sm",
|
|
21
|
-
"title",
|
|
22
|
-
"title-lg",
|
|
23
|
-
"title-hero",
|
|
24
|
-
"scale-01",
|
|
25
|
-
"scale-02",
|
|
26
|
-
"scale-03",
|
|
27
|
-
"scale-04",
|
|
28
|
-
"scale-05",
|
|
29
|
-
"scale-06",
|
|
30
|
-
"scale-07",
|
|
31
|
-
"scale-08",
|
|
32
|
-
"scale-09",
|
|
33
|
-
"scale-10",
|
|
34
|
-
"scale-12"
|
|
35
|
-
];
|
|
36
|
-
var twMerge = extendTailwindMerge({
|
|
37
|
-
extend: {
|
|
38
|
-
classGroups: {
|
|
39
|
-
"font-size": [{ text: [...FONT_SIZES] }]
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
function cn(...inputs) {
|
|
44
|
-
return twMerge(clsx(inputs));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// src/lib/focus-ring.ts
|
|
48
|
-
var FOCUS_RING = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand focus-visible:ring-offset-1 focus-visible:ring-offset-default";
|
|
49
|
-
var FOCUS_RING_INSET = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-brand";
|
|
50
|
-
|
|
51
|
-
// src/lib/slot.tsx
|
|
52
|
-
import {
|
|
53
|
-
cloneElement,
|
|
54
|
-
forwardRef,
|
|
55
|
-
isValidElement
|
|
56
|
-
} from "react";
|
|
57
|
-
import clsx2 from "clsx";
|
|
58
|
-
var Slot = forwardRef(function Slot2({ children, wrapChildren, ...slotProps }, forwardedRef) {
|
|
59
|
-
if (!isValidElement(children)) return null;
|
|
60
|
-
const child = children;
|
|
61
|
-
const merged = {
|
|
62
|
-
...mergeProps(slotProps, child.props),
|
|
63
|
-
ref: composeRefs(forwardedRef, getElementRef(child))
|
|
64
|
-
};
|
|
65
|
-
return wrapChildren ? cloneElement(child, merged, wrapChildren(child.props.children)) : cloneElement(child, merged);
|
|
66
|
-
});
|
|
67
|
-
function mergeProps(slotProps, childProps) {
|
|
68
|
-
const merged = { ...slotProps };
|
|
69
|
-
for (const key in childProps) {
|
|
70
|
-
const slotValue = slotProps[key];
|
|
71
|
-
const childValue = childProps[key];
|
|
72
|
-
if (/^on[A-Z]/.test(key)) {
|
|
73
|
-
if (typeof slotValue === "function" && typeof childValue === "function") {
|
|
74
|
-
merged[key] = (...args) => {
|
|
75
|
-
slotValue(...args);
|
|
76
|
-
childValue(...args);
|
|
77
|
-
};
|
|
78
|
-
} else {
|
|
79
|
-
merged[key] = childValue ?? slotValue;
|
|
80
|
-
}
|
|
81
|
-
} else if (key === "className") {
|
|
82
|
-
merged[key] = clsx2(slotValue, childValue);
|
|
83
|
-
} else if (key === "style") {
|
|
84
|
-
merged[key] = { ...slotValue, ...childValue };
|
|
85
|
-
} else {
|
|
86
|
-
merged[key] = childValue;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return merged;
|
|
90
|
-
}
|
|
91
|
-
function getElementRef(element) {
|
|
92
|
-
const asRecord = element;
|
|
93
|
-
return asRecord.props?.ref ?? asRecord.ref;
|
|
94
|
-
}
|
|
95
|
-
function composeRefs(...refs) {
|
|
96
|
-
return (node) => {
|
|
97
|
-
for (const ref of refs) {
|
|
98
|
-
if (!ref) continue;
|
|
99
|
-
if (typeof ref === "function") {
|
|
100
|
-
ref(node);
|
|
101
|
-
} else {
|
|
102
|
-
ref.current = node;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// src/components/feedback/spinner.tsx
|
|
109
|
-
import { forwardRef as forwardRef2 } from "react";
|
|
110
|
-
import clsx3 from "clsx";
|
|
111
|
-
import { jsx } from "react/jsx-runtime";
|
|
112
|
-
var SIZE = {
|
|
113
|
-
xs: "size-3 border",
|
|
114
|
-
sm: "size-4 border-[1.5px]",
|
|
115
|
-
md: "size-5 border-2",
|
|
116
|
-
lg: "size-8 border-2"
|
|
117
|
-
};
|
|
118
|
-
var Spinner = forwardRef2(function Spinner2({ size: size2 = "sm", label, className, ...rest }, ref) {
|
|
119
|
-
return /* @__PURE__ */ jsx(
|
|
120
|
-
"span",
|
|
121
|
-
{
|
|
122
|
-
ref,
|
|
123
|
-
role: label ? "status" : void 0,
|
|
124
|
-
"aria-label": label,
|
|
125
|
-
"aria-hidden": label ? void 0 : true,
|
|
126
|
-
className: clsx3(
|
|
127
|
-
"inline-block shrink-0 rounded-full motion-safe:animate-spin motion-reduce:animate-pulse",
|
|
128
|
-
"border-current border-t-transparent",
|
|
129
|
-
SIZE[size2],
|
|
130
|
-
className
|
|
131
|
-
),
|
|
132
|
-
...rest
|
|
133
|
-
}
|
|
134
|
-
);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
// src/components/forms/control-size.tsx
|
|
138
|
-
import { createContext, useContext } from "react";
|
|
139
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
140
|
-
var ControlSizeContext = createContext(null);
|
|
141
|
-
function ControlSizeProvider({ size: size2, children }) {
|
|
142
|
-
return /* @__PURE__ */ jsx2(ControlSizeContext.Provider, { value: size2, children });
|
|
143
|
-
}
|
|
144
|
-
function useControlSize(explicit) {
|
|
145
|
-
const inherited = useContext(ControlSizeContext);
|
|
146
|
-
return explicit ?? inherited ?? "md";
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// src/components/forms/button.tsx
|
|
150
|
-
import { forwardRef as forwardRef3 } from "react";
|
|
151
|
-
import clsx4 from "clsx";
|
|
152
|
-
import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
153
|
-
var variantStyles = {
|
|
154
|
-
primary: clsx4(
|
|
155
|
-
"bg-brand border border-brand text-brand-on-brand",
|
|
156
|
-
"hover:bg-brand-hover",
|
|
157
|
-
"disabled:bg-disabled disabled:border-disabled disabled:text-disabled-on-disabled",
|
|
158
|
-
"aria-disabled:bg-disabled aria-disabled:border-disabled aria-disabled:text-disabled-on-disabled"
|
|
159
|
-
),
|
|
160
|
-
neutral: clsx4(
|
|
161
|
-
"bg-default border border-default text-default",
|
|
162
|
-
"hover:bg-default-hover hover:text-brand",
|
|
163
|
-
"disabled:bg-disabled disabled:border-disabled disabled:text-disabled-on-disabled",
|
|
164
|
-
"aria-disabled:bg-disabled aria-disabled:border-disabled aria-disabled:text-disabled-on-disabled"
|
|
165
|
-
),
|
|
166
|
-
subtle: clsx4(
|
|
167
|
-
// border-transparent holds space so hover border doesn't shift layout
|
|
168
|
-
"bg-transparent border border-transparent text-neutral",
|
|
169
|
-
"hover:border-default hover:text-brand",
|
|
170
|
-
"disabled:bg-disabled disabled:border-disabled disabled:text-disabled-on-disabled",
|
|
171
|
-
"aria-disabled:bg-disabled aria-disabled:border-disabled aria-disabled:text-disabled-on-disabled"
|
|
172
|
-
),
|
|
173
|
-
danger: clsx4(
|
|
174
|
-
"bg-danger border border-danger-secondary text-danger-on-danger",
|
|
175
|
-
// border shifts from danger-secondary → danger-default on hover (Figma spec)
|
|
176
|
-
"hover:bg-danger-hover hover:border-danger",
|
|
177
|
-
"disabled:bg-disabled disabled:border-disabled disabled:text-disabled-on-disabled",
|
|
178
|
-
"aria-disabled:bg-disabled aria-disabled:border-disabled aria-disabled:text-disabled-on-disabled"
|
|
179
|
-
),
|
|
180
|
-
"danger-subtle": clsx4(
|
|
181
|
-
// border-transparent base avoids layout shift when hover border appears
|
|
182
|
-
"bg-transparent border border-transparent text-danger",
|
|
183
|
-
"hover:bg-danger-tertiary-hover hover:border-danger",
|
|
184
|
-
"disabled:bg-disabled disabled:border-disabled disabled:text-disabled-on-disabled",
|
|
185
|
-
"aria-disabled:bg-disabled aria-disabled:border-disabled aria-disabled:text-disabled-on-disabled"
|
|
186
|
-
)
|
|
187
|
-
};
|
|
188
|
-
var sizeStyles = {
|
|
189
|
-
lg: "h-12 px-3 gap-1 rounded-2xl text-body font-semibold [&_svg]:size-5",
|
|
190
|
-
md: "h-9 px-2 gap-0.5 rounded-lg text-body-sm font-semibold [&_svg]:size-5",
|
|
191
|
-
sm: "h-6 px-1.5 pt-0.5 gap-0 rounded-full text-body-tiny font-semibold [&_svg]:size-4"
|
|
192
|
-
};
|
|
193
|
-
var SPINNER_SIZE = {
|
|
194
|
-
lg: "md",
|
|
195
|
-
md: "sm",
|
|
196
|
-
sm: "sm"
|
|
197
|
-
};
|
|
198
|
-
var Button = forwardRef3(function Button2({
|
|
199
|
-
variant = "primary",
|
|
200
|
-
size: sizeProp,
|
|
201
|
-
leadingIcon,
|
|
202
|
-
trailingIcon,
|
|
203
|
-
asChild = false,
|
|
204
|
-
loading = false,
|
|
205
|
-
loadingLabel,
|
|
206
|
-
disabled,
|
|
207
|
-
type,
|
|
208
|
-
children,
|
|
209
|
-
className,
|
|
210
|
-
onClick,
|
|
211
|
-
...props
|
|
212
|
-
}, ref) {
|
|
213
|
-
const size2 = useControlSize(sizeProp);
|
|
214
|
-
const softDisabled = loading || asChild && Boolean(disabled);
|
|
215
|
-
const handleClick = (event) => {
|
|
216
|
-
if (softDisabled) {
|
|
217
|
-
event.preventDefault();
|
|
218
|
-
event.stopPropagation();
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
onClick?.(event);
|
|
222
|
-
};
|
|
223
|
-
const decorate = (content) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
224
|
-
loading ? /* @__PURE__ */ jsx3(Spinner, { size: SPINNER_SIZE[size2], label: loadingLabel }) : leadingIcon,
|
|
225
|
-
/* @__PURE__ */ jsx3("span", { className: "px-1", children: content }),
|
|
226
|
-
trailingIcon
|
|
227
|
-
] });
|
|
228
|
-
const rootProps = {
|
|
229
|
-
// `cn`, so a caller's `className` (say `rounded-full`) beats the size's radius.
|
|
230
|
-
className: cn(
|
|
231
|
-
"inline-flex items-center justify-center whitespace-nowrap transition-colors",
|
|
232
|
-
FOCUS_RING,
|
|
233
|
-
"disabled:cursor-not-allowed aria-disabled:cursor-not-allowed",
|
|
234
|
-
variantStyles[variant],
|
|
235
|
-
sizeStyles[size2],
|
|
236
|
-
className
|
|
237
|
-
),
|
|
238
|
-
"aria-busy": loading || void 0,
|
|
239
|
-
"data-variant": variant,
|
|
240
|
-
"data-size": size2,
|
|
241
|
-
"aria-disabled": softDisabled || void 0,
|
|
242
|
-
onClick: handleClick,
|
|
243
|
-
...props
|
|
244
|
-
};
|
|
245
|
-
if (asChild) {
|
|
246
|
-
return /* @__PURE__ */ jsx3(
|
|
247
|
-
Slot,
|
|
248
|
-
{
|
|
249
|
-
ref,
|
|
250
|
-
wrapChildren: decorate,
|
|
251
|
-
tabIndex: disabled ? -1 : void 0,
|
|
252
|
-
...rootProps,
|
|
253
|
-
children
|
|
254
|
-
}
|
|
255
|
-
);
|
|
256
|
-
}
|
|
257
|
-
return /* @__PURE__ */ jsx3(
|
|
258
|
-
"button",
|
|
259
|
-
{
|
|
260
|
-
ref,
|
|
261
|
-
type: type ?? "button",
|
|
262
|
-
disabled,
|
|
263
|
-
...rootProps,
|
|
264
|
-
children: decorate(children)
|
|
265
|
-
}
|
|
266
|
-
);
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
// src/components/forms/icon-button.tsx
|
|
270
|
-
import { forwardRef as forwardRef4 } from "react";
|
|
271
|
-
import clsx5 from "clsx";
|
|
272
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
273
|
-
var variantStyles2 = {
|
|
274
|
-
primary: clsx5(
|
|
275
|
-
"bg-brand border border-brand text-brand-on-brand",
|
|
276
|
-
"hover:bg-brand-hover",
|
|
277
|
-
"disabled:bg-disabled disabled:border-disabled disabled:text-disabled-on-disabled",
|
|
278
|
-
"aria-disabled:bg-disabled aria-disabled:border-disabled aria-disabled:text-disabled-on-disabled"
|
|
279
|
-
),
|
|
280
|
-
// Neutral uses secondary background (light gray) for visual weight without a text label
|
|
281
|
-
neutral: clsx5(
|
|
282
|
-
"bg-default-secondary border border-default text-default",
|
|
283
|
-
// icon turns brand blue on hover (Figma spec)
|
|
284
|
-
"hover:bg-default-secondary-hover hover:text-brand",
|
|
285
|
-
"disabled:bg-disabled disabled:border-disabled disabled:text-disabled-on-disabled",
|
|
286
|
-
"aria-disabled:bg-disabled aria-disabled:border-disabled aria-disabled:text-disabled-on-disabled"
|
|
287
|
-
),
|
|
288
|
-
subtle: clsx5(
|
|
289
|
-
"bg-transparent text-neutral",
|
|
290
|
-
// hover uses background-default-default-hover (#f5f5f5), icon turns brand blue (Figma spec)
|
|
291
|
-
"hover:bg-default-hover hover:text-brand",
|
|
292
|
-
// disabled needs explicit border since there is no base border
|
|
293
|
-
"disabled:bg-disabled disabled:border disabled:border-disabled disabled:text-disabled-on-disabled",
|
|
294
|
-
"aria-disabled:bg-disabled aria-disabled:border aria-disabled:border-disabled aria-disabled:text-disabled-on-disabled"
|
|
295
|
-
)
|
|
296
|
-
};
|
|
297
|
-
var sizeStyles2 = {
|
|
298
|
-
lg: "size-12 rounded-2xl [&_svg]:size-5",
|
|
299
|
-
md: "size-9 rounded-lg [&_svg]:size-5",
|
|
300
|
-
sm: "size-6 rounded-full [&_svg]:size-4"
|
|
301
|
-
};
|
|
302
|
-
var IconButton = forwardRef4(function IconButton2({
|
|
303
|
-
variant = "primary",
|
|
304
|
-
size: sizeProp,
|
|
305
|
-
asChild = false,
|
|
306
|
-
type,
|
|
307
|
-
disabled,
|
|
308
|
-
onClick,
|
|
309
|
-
children,
|
|
310
|
-
className,
|
|
311
|
-
...props
|
|
312
|
-
}, ref) {
|
|
313
|
-
const size2 = useControlSize(sizeProp);
|
|
314
|
-
const softDisabled = asChild && Boolean(disabled);
|
|
315
|
-
const handleClick = (event) => {
|
|
316
|
-
if (softDisabled) {
|
|
317
|
-
event.preventDefault();
|
|
318
|
-
event.stopPropagation();
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
onClick?.(event);
|
|
322
|
-
};
|
|
323
|
-
const rootProps = {
|
|
324
|
-
// `cn`, so a caller's `className` beats the size's radius and the variant's colours.
|
|
325
|
-
className: cn(
|
|
326
|
-
"inline-flex shrink-0 items-center justify-center transition-colors",
|
|
327
|
-
FOCUS_RING,
|
|
328
|
-
"disabled:cursor-not-allowed aria-disabled:cursor-not-allowed",
|
|
329
|
-
variantStyles2[variant],
|
|
330
|
-
sizeStyles2[size2],
|
|
331
|
-
className
|
|
332
|
-
),
|
|
333
|
-
"data-variant": variant,
|
|
334
|
-
"data-size": size2,
|
|
335
|
-
"aria-disabled": softDisabled || void 0,
|
|
336
|
-
onClick: handleClick,
|
|
337
|
-
...props
|
|
338
|
-
};
|
|
339
|
-
if (asChild) {
|
|
340
|
-
return /* @__PURE__ */ jsx4(Slot, { ref, tabIndex: disabled ? -1 : void 0, ...rootProps, children });
|
|
341
|
-
}
|
|
342
|
-
return /* @__PURE__ */ jsx4(
|
|
343
|
-
"button",
|
|
344
|
-
{
|
|
345
|
-
ref,
|
|
346
|
-
type: type ?? "button",
|
|
347
|
-
disabled,
|
|
348
|
-
...rootProps,
|
|
349
|
-
children
|
|
350
|
-
}
|
|
351
|
-
);
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
// src/components/forms/field.tsx
|
|
355
|
-
import {
|
|
356
|
-
Children,
|
|
357
|
-
createContext as createContext2,
|
|
358
|
-
forwardRef as forwardRef5,
|
|
359
|
-
useCallback,
|
|
360
|
-
useContext as useContext2,
|
|
361
|
-
useEffect,
|
|
362
|
-
useId,
|
|
363
|
-
useLayoutEffect,
|
|
364
|
-
useMemo,
|
|
365
|
-
useState
|
|
366
|
-
} from "react";
|
|
367
|
-
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
368
|
-
var FieldContext = createContext2(null);
|
|
369
|
-
function useFieldContext() {
|
|
370
|
-
return useContext2(FieldContext);
|
|
371
|
-
}
|
|
372
|
-
var useIsomorphicLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
373
|
-
function useRegisterPart(field, part, showing) {
|
|
374
|
-
const register = field?.register;
|
|
375
|
-
useIsomorphicLayoutEffect(() => {
|
|
376
|
-
if (!register || !showing) return;
|
|
377
|
-
return register(part);
|
|
378
|
-
}, [register, part, showing]);
|
|
379
|
-
}
|
|
380
|
-
function hasContent(children) {
|
|
381
|
-
return Children.toArray(children).some((child) => child !== "");
|
|
382
|
-
}
|
|
383
|
-
function useFieldControl() {
|
|
384
|
-
const field = useFieldContext();
|
|
385
|
-
if (!field) {
|
|
386
|
-
return {
|
|
387
|
-
id: void 0,
|
|
388
|
-
"aria-describedby": void 0,
|
|
389
|
-
"aria-invalid": void 0,
|
|
390
|
-
"aria-required": void 0,
|
|
391
|
-
disabled: void 0
|
|
392
|
-
};
|
|
393
|
-
}
|
|
394
|
-
const describedBy = [
|
|
395
|
-
field.hasDescription && field.descriptionId,
|
|
396
|
-
field.hasError && field.errorId,
|
|
397
|
-
field.hasHint && !field.hasError && field.hintId
|
|
398
|
-
].filter(Boolean).join(" ");
|
|
399
|
-
return {
|
|
400
|
-
id: field.controlId,
|
|
401
|
-
"aria-describedby": describedBy || void 0,
|
|
402
|
-
"aria-invalid": field.invalid || void 0,
|
|
403
|
-
"aria-required": field.required || void 0,
|
|
404
|
-
disabled: field.disabled || void 0
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
|
-
var GAP = {
|
|
408
|
-
lg: "gap-2",
|
|
409
|
-
md: "gap-1",
|
|
410
|
-
sm: "gap-0.5"
|
|
411
|
-
};
|
|
412
|
-
function Field({
|
|
413
|
-
children,
|
|
414
|
-
id,
|
|
415
|
-
size: sizeProp,
|
|
416
|
-
invalid = false,
|
|
417
|
-
required = false,
|
|
418
|
-
disabled = false,
|
|
419
|
-
orientation = "vertical",
|
|
420
|
-
className,
|
|
421
|
-
...rest
|
|
422
|
-
}) {
|
|
423
|
-
const generated = useId();
|
|
424
|
-
const controlId = id ?? generated;
|
|
425
|
-
const size2 = useControlSize(sizeProp);
|
|
426
|
-
const [parts2, setParts] = useState({ description: 0, error: 0, hint: 0 });
|
|
427
|
-
const register = useCallback((part) => {
|
|
428
|
-
setParts((p) => ({ ...p, [part]: p[part] + 1 }));
|
|
429
|
-
return () => setParts((p) => ({ ...p, [part]: p[part] - 1 }));
|
|
430
|
-
}, []);
|
|
431
|
-
const hasError = parts2.error > 0;
|
|
432
|
-
const value = useMemo(
|
|
433
|
-
() => ({
|
|
434
|
-
controlId,
|
|
435
|
-
labelId: `${controlId}-label`,
|
|
436
|
-
descriptionId: `${controlId}-description`,
|
|
437
|
-
errorId: `${controlId}-error`,
|
|
438
|
-
hintId: `${controlId}-hint`,
|
|
439
|
-
hasDescription: parts2.description > 0,
|
|
440
|
-
hasError,
|
|
441
|
-
hasHint: parts2.hint > 0,
|
|
442
|
-
invalid: invalid || hasError,
|
|
443
|
-
required,
|
|
444
|
-
disabled,
|
|
445
|
-
size: size2,
|
|
446
|
-
register
|
|
447
|
-
}),
|
|
448
|
-
[controlId, parts2, hasError, invalid, required, disabled, size2, register]
|
|
449
|
-
);
|
|
450
|
-
return /* @__PURE__ */ jsx5(FieldContext.Provider, { value, children: /* @__PURE__ */ jsx5(
|
|
451
|
-
"div",
|
|
452
|
-
{
|
|
453
|
-
role: orientation === "horizontal" ? "group" : void 0,
|
|
454
|
-
"data-slot": "field",
|
|
455
|
-
"data-invalid": invalid || hasError || void 0,
|
|
456
|
-
"data-disabled": disabled || void 0,
|
|
457
|
-
className: cn(
|
|
458
|
-
orientation === "horizontal" ? "flex flex-row items-center justify-between gap-3" : cn("flex flex-col", GAP[size2]),
|
|
459
|
-
className
|
|
460
|
-
),
|
|
461
|
-
...rest,
|
|
462
|
-
children
|
|
463
|
-
}
|
|
464
|
-
) });
|
|
465
|
-
}
|
|
466
|
-
var LABEL_TEXT = {
|
|
467
|
-
lg: "text-body",
|
|
468
|
-
md: "text-body-sm",
|
|
469
|
-
sm: "text-body-tiny"
|
|
470
|
-
};
|
|
471
|
-
function FieldLabel({ children, className, htmlFor, ...rest }) {
|
|
472
|
-
const field = useFieldContext();
|
|
473
|
-
return /* @__PURE__ */ jsx5(
|
|
474
|
-
"label",
|
|
475
|
-
{
|
|
476
|
-
id: field?.labelId,
|
|
477
|
-
htmlFor: htmlFor ?? field?.controlId,
|
|
478
|
-
"data-slot": "field-label",
|
|
479
|
-
className: cn(
|
|
480
|
-
LABEL_TEXT[field?.size ?? "md"],
|
|
481
|
-
field?.disabled ? "text-disabled" : "text-default",
|
|
482
|
-
// The required marker is CSS generated content, not a child element. An
|
|
483
|
-
// `<span aria-hidden>*</span>` would be correct for accessible-name computation
|
|
484
|
-
// (which skips aria-hidden) but it still lands in `textContent`, so every
|
|
485
|
-
// `getByLabelText('Name')` — ours and every consumer's — would have to become
|
|
486
|
-
// `/Name/`. Generated content is in neither, and the real signal is
|
|
487
|
-
// `aria-required` on the control regardless.
|
|
488
|
-
field?.required && "after:ml-0.5 after:text-danger after:content-['*']",
|
|
489
|
-
className
|
|
490
|
-
),
|
|
491
|
-
...rest,
|
|
492
|
-
children
|
|
493
|
-
}
|
|
494
|
-
);
|
|
495
|
-
}
|
|
496
|
-
function FieldDescription({ children, className, ...rest }) {
|
|
497
|
-
const field = useFieldContext();
|
|
498
|
-
const showing = hasContent(children);
|
|
499
|
-
useRegisterPart(field, "description", showing);
|
|
500
|
-
if (!showing) return null;
|
|
501
|
-
return /* @__PURE__ */ jsx5(
|
|
502
|
-
"p",
|
|
503
|
-
{
|
|
504
|
-
id: field?.descriptionId,
|
|
505
|
-
"data-slot": "field-description",
|
|
506
|
-
className: cn(
|
|
507
|
-
LABEL_TEXT[field?.size ?? "md"],
|
|
508
|
-
field?.disabled ? "text-disabled" : "text-default-secondary",
|
|
509
|
-
className
|
|
510
|
-
),
|
|
511
|
-
...rest,
|
|
512
|
-
children
|
|
513
|
-
}
|
|
514
|
-
);
|
|
515
|
-
}
|
|
516
|
-
function FieldError({ children, className, ...rest }) {
|
|
517
|
-
const field = useFieldContext();
|
|
518
|
-
const showing = hasContent(children);
|
|
519
|
-
useRegisterPart(field, "error", showing);
|
|
520
|
-
if (!showing) return null;
|
|
521
|
-
return /* @__PURE__ */ jsx5(
|
|
522
|
-
"p",
|
|
523
|
-
{
|
|
524
|
-
id: field?.errorId,
|
|
525
|
-
role: "alert",
|
|
526
|
-
"data-slot": "field-error",
|
|
527
|
-
className: cn(LABEL_TEXT[field?.size ?? "md"], "text-danger", className),
|
|
528
|
-
...rest,
|
|
529
|
-
children
|
|
530
|
-
}
|
|
531
|
-
);
|
|
532
|
-
}
|
|
533
|
-
function FieldHint({ children, className, ...rest }) {
|
|
534
|
-
const field = useFieldContext();
|
|
535
|
-
const showing = hasContent(children);
|
|
536
|
-
useRegisterPart(field, "hint", showing);
|
|
537
|
-
if (!showing || field?.hasError) return null;
|
|
538
|
-
return /* @__PURE__ */ jsx5(
|
|
539
|
-
"p",
|
|
540
|
-
{
|
|
541
|
-
id: field?.hintId,
|
|
542
|
-
"data-slot": "field-hint",
|
|
543
|
-
className: cn(LABEL_TEXT[field?.size ?? "md"], "text-default-secondary", className),
|
|
544
|
-
...rest,
|
|
545
|
-
children
|
|
546
|
-
}
|
|
547
|
-
);
|
|
548
|
-
}
|
|
549
|
-
function FieldGroup({ children, className, ...rest }) {
|
|
550
|
-
return /* @__PURE__ */ jsx5("div", { "data-slot": "field-group", className: cn("flex flex-col gap-4", className), ...rest, children });
|
|
551
|
-
}
|
|
552
|
-
var FieldSet = forwardRef5(function FieldSet2({ children, className, ...rest }, ref) {
|
|
553
|
-
return /* @__PURE__ */ jsx5(
|
|
554
|
-
"fieldset",
|
|
555
|
-
{
|
|
556
|
-
ref,
|
|
557
|
-
"data-slot": "field-set",
|
|
558
|
-
className: cn("flex flex-col gap-3 border-0 p-0", className),
|
|
559
|
-
...rest,
|
|
560
|
-
children
|
|
561
|
-
}
|
|
562
|
-
);
|
|
563
|
-
});
|
|
564
|
-
function FieldLegend({
|
|
565
|
-
children,
|
|
566
|
-
variant = "legend",
|
|
567
|
-
className,
|
|
568
|
-
...rest
|
|
569
|
-
}) {
|
|
570
|
-
return /* @__PURE__ */ jsx5(
|
|
571
|
-
"legend",
|
|
572
|
-
{
|
|
573
|
-
"data-slot": "field-legend",
|
|
574
|
-
className: cn(
|
|
575
|
-
"p-0",
|
|
576
|
-
variant === "legend" ? "text-body font-semibold text-default" : "text-body-sm text-default",
|
|
577
|
-
className
|
|
578
|
-
),
|
|
579
|
-
...rest,
|
|
580
|
-
children
|
|
581
|
-
}
|
|
582
|
-
);
|
|
583
|
-
}
|
|
584
|
-
function FieldSeparator({ className, ...rest }) {
|
|
585
|
-
return /* @__PURE__ */ jsx5(
|
|
586
|
-
"div",
|
|
587
|
-
{
|
|
588
|
-
role: "separator",
|
|
589
|
-
"data-slot": "field-separator",
|
|
590
|
-
className: cn("h-px w-full bg-divider", className),
|
|
591
|
-
...rest
|
|
592
|
-
}
|
|
593
|
-
);
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
// src/lib/scrollbar.ts
|
|
597
|
-
import clsx6 from "clsx";
|
|
598
|
-
var SCROLLBAR_CLASSES = clsx6(
|
|
599
|
-
// Firefox and the standard property.
|
|
600
|
-
"[scrollbar-color:var(--color-background-default-tertiary)_transparent] [scrollbar-width:thin]",
|
|
601
|
-
// WebKit/Blink.
|
|
602
|
-
"[&::-webkit-scrollbar]:size-2",
|
|
603
|
-
"[&::-webkit-scrollbar-track]:bg-transparent",
|
|
604
|
-
"[&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-default-tertiary",
|
|
605
|
-
"[&::-webkit-scrollbar-thumb:hover]:bg-neutral-secondary",
|
|
606
|
-
"[&::-webkit-scrollbar-corner]:bg-transparent"
|
|
607
|
-
);
|
|
608
|
-
|
|
609
|
-
// src/components/overlays/overlay.ts
|
|
610
|
-
import { useEffect as useEffect3, useRef as useRef2 } from "react";
|
|
611
|
-
import { tabbable } from "tabbable";
|
|
612
|
-
|
|
613
|
-
// src/components/overlays/overlay-stack.ts
|
|
614
|
-
import { useEffect as useEffect2, useRef, useState as useState2 } from "react";
|
|
615
|
-
var layers = [];
|
|
616
|
-
var listeners = /* @__PURE__ */ new Set();
|
|
617
|
-
function notify() {
|
|
618
|
-
for (const listener of listeners) listener();
|
|
619
|
-
}
|
|
620
|
-
function topmost() {
|
|
621
|
-
return layers[layers.length - 1]?.id;
|
|
622
|
-
}
|
|
623
|
-
var deferredEscapes = /* @__PURE__ */ new WeakSet();
|
|
624
|
-
function deferEscapeToInnerPopup(event) {
|
|
625
|
-
const target = event.target;
|
|
626
|
-
const fromOpenCombobox = target instanceof Element && target.closest('[role="combobox"][aria-expanded="true"]') !== null;
|
|
627
|
-
if (layers.length === 0 && !fromOpenCombobox) return false;
|
|
628
|
-
deferredEscapes.add(event);
|
|
629
|
-
event.preventDefault();
|
|
630
|
-
return true;
|
|
631
|
-
}
|
|
632
|
-
function isEscapeDeferred(event) {
|
|
633
|
-
return deferredEscapes.has(event);
|
|
634
|
-
}
|
|
635
|
-
var scrollLocks = 0;
|
|
636
|
-
var restoreBody = null;
|
|
637
|
-
function lockScroll() {
|
|
638
|
-
scrollLocks += 1;
|
|
639
|
-
if (scrollLocks > 1 || typeof document === "undefined") return;
|
|
640
|
-
const { body, documentElement } = document;
|
|
641
|
-
const previousOverflow = body.style.overflow;
|
|
642
|
-
const previousPaddingRight = body.style.paddingRight;
|
|
643
|
-
const scrollbarWidth = window.innerWidth - documentElement.clientWidth;
|
|
644
|
-
if (scrollbarWidth > 0) {
|
|
645
|
-
const current = parseFloat(window.getComputedStyle(body).paddingRight) || 0;
|
|
646
|
-
body.style.paddingRight = `${current + scrollbarWidth}px`;
|
|
647
|
-
}
|
|
648
|
-
body.style.overflow = "hidden";
|
|
649
|
-
restoreBody = () => {
|
|
650
|
-
body.style.overflow = previousOverflow;
|
|
651
|
-
body.style.paddingRight = previousPaddingRight;
|
|
652
|
-
};
|
|
653
|
-
}
|
|
654
|
-
function unlockScroll() {
|
|
655
|
-
scrollLocks = Math.max(0, scrollLocks - 1);
|
|
656
|
-
if (scrollLocks === 0 && restoreBody) {
|
|
657
|
-
restoreBody();
|
|
658
|
-
restoreBody = null;
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
var inerted = /* @__PURE__ */ new Set();
|
|
662
|
-
function applyInert(node) {
|
|
663
|
-
if (typeof document === "undefined" || !node) return;
|
|
664
|
-
let root = node;
|
|
665
|
-
while (root.parentElement && root.parentElement !== document.body) {
|
|
666
|
-
root = root.parentElement;
|
|
667
|
-
}
|
|
668
|
-
for (const child of Array.from(document.body.children)) {
|
|
669
|
-
if (child === root || !(child instanceof HTMLElement)) continue;
|
|
670
|
-
if (child.hasAttribute("inert")) continue;
|
|
671
|
-
child.setAttribute("inert", "");
|
|
672
|
-
inerted.add(child);
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
function releaseInert() {
|
|
676
|
-
for (const el of inerted) el.removeAttribute("inert");
|
|
677
|
-
inerted.clear();
|
|
678
|
-
}
|
|
679
|
-
function useOverlayLayer(active, {
|
|
680
|
-
lockScroll: shouldLockScroll = true,
|
|
681
|
-
inertBackground = true,
|
|
682
|
-
panelRef
|
|
683
|
-
} = {}) {
|
|
684
|
-
const id = useRef();
|
|
685
|
-
if (!id.current) id.current = /* @__PURE__ */ Symbol("overlay-layer");
|
|
686
|
-
const [isTopmost, setIsTopmost] = useState2(false);
|
|
687
|
-
useEffect2(() => {
|
|
688
|
-
if (!active) return;
|
|
689
|
-
const self = id.current;
|
|
690
|
-
layers.push({ id: self });
|
|
691
|
-
const sync = () => setIsTopmost(topmost() === self);
|
|
692
|
-
listeners.add(sync);
|
|
693
|
-
sync();
|
|
694
|
-
notify();
|
|
695
|
-
if (shouldLockScroll) lockScroll();
|
|
696
|
-
return () => {
|
|
697
|
-
const index = layers.findIndex((layer) => layer.id === self);
|
|
698
|
-
if (index !== -1) layers.splice(index, 1);
|
|
699
|
-
listeners.delete(sync);
|
|
700
|
-
notify();
|
|
701
|
-
if (shouldLockScroll) unlockScroll();
|
|
702
|
-
};
|
|
703
|
-
}, [active, shouldLockScroll]);
|
|
704
|
-
useEffect2(() => {
|
|
705
|
-
if (!active || !inertBackground) return;
|
|
706
|
-
if (inerted.size === 0) applyInert(panelRef?.current ?? null);
|
|
707
|
-
return () => {
|
|
708
|
-
if (layers.length <= 1) releaseInert();
|
|
709
|
-
};
|
|
710
|
-
}, [active, inertBackground, panelRef]);
|
|
711
|
-
return { isTopmost };
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
// src/components/overlays/overlay.ts
|
|
715
|
-
var OVERLAY_SCRIM = "bg-overlay";
|
|
716
|
-
function useOverlayDismiss({
|
|
717
|
-
onDismiss,
|
|
718
|
-
panelRef,
|
|
719
|
-
active = true,
|
|
720
|
-
closeOnEscape = true,
|
|
721
|
-
closeOnOutsidePress = true,
|
|
722
|
-
trapFocus = true,
|
|
723
|
-
lockScroll: lockScroll2 = true,
|
|
724
|
-
inertBackground = true,
|
|
725
|
-
autoFocus = true,
|
|
726
|
-
initialFocus,
|
|
727
|
-
returnFocus,
|
|
728
|
-
onEscapeKeyDown,
|
|
729
|
-
onInteractOutside
|
|
730
|
-
}) {
|
|
731
|
-
const { isTopmost } = useOverlayLayer(active, {
|
|
732
|
-
lockScroll: lockScroll2,
|
|
733
|
-
inertBackground,
|
|
734
|
-
panelRef
|
|
735
|
-
});
|
|
736
|
-
const handlers = useRef2({ onDismiss, onEscapeKeyDown, onInteractOutside });
|
|
737
|
-
handlers.current = { onDismiss, onEscapeKeyDown, onInteractOutside };
|
|
738
|
-
const isTopmostRef = useRef2(isTopmost);
|
|
739
|
-
isTopmostRef.current = isTopmost;
|
|
740
|
-
useEffect3(() => {
|
|
741
|
-
if (!active || !closeOnEscape) return;
|
|
742
|
-
function onKeyDown(event) {
|
|
743
|
-
if (event.key !== "Escape") return;
|
|
744
|
-
if (!isTopmostRef.current) return;
|
|
745
|
-
if (isEscapeDeferred(event)) {
|
|
746
|
-
let vetoed = false;
|
|
747
|
-
handlers.current.onEscapeKeyDown?.(vetoable(event, () => vetoed = true));
|
|
748
|
-
if (vetoed) return;
|
|
749
|
-
} else {
|
|
750
|
-
handlers.current.onEscapeKeyDown?.(event);
|
|
751
|
-
if (event.defaultPrevented) return;
|
|
752
|
-
}
|
|
753
|
-
handlers.current.onDismiss();
|
|
754
|
-
}
|
|
755
|
-
document.addEventListener("keydown", onKeyDown);
|
|
756
|
-
return () => document.removeEventListener("keydown", onKeyDown);
|
|
757
|
-
}, [active, closeOnEscape]);
|
|
758
|
-
useEffect3(() => {
|
|
759
|
-
if (!active || !closeOnOutsidePress) return;
|
|
760
|
-
function onPointerDown(event) {
|
|
761
|
-
if (!isTopmostRef.current) return;
|
|
762
|
-
const panel = panelRef.current;
|
|
763
|
-
if (!panel || panel.contains(event.target)) return;
|
|
764
|
-
handlers.current.onInteractOutside?.(event);
|
|
765
|
-
if (event.defaultPrevented) return;
|
|
766
|
-
handlers.current.onDismiss();
|
|
767
|
-
}
|
|
768
|
-
document.addEventListener("pointerdown", onPointerDown);
|
|
769
|
-
return () => document.removeEventListener("pointerdown", onPointerDown);
|
|
770
|
-
}, [active, closeOnOutsidePress, panelRef]);
|
|
771
|
-
useEffect3(() => {
|
|
772
|
-
if (!active || !trapFocus) return;
|
|
773
|
-
function onKeyDown(event) {
|
|
774
|
-
if (event.key !== "Tab" || !isTopmostRef.current) return;
|
|
775
|
-
const panel = panelRef.current;
|
|
776
|
-
if (!panel) return;
|
|
777
|
-
const items = tabbable(panel);
|
|
778
|
-
if (items.length === 0) {
|
|
779
|
-
event.preventDefault();
|
|
780
|
-
panel.focus({ preventScroll: true });
|
|
781
|
-
return;
|
|
782
|
-
}
|
|
783
|
-
const first = items[0];
|
|
784
|
-
const last = items[items.length - 1];
|
|
785
|
-
const activeElement = document.activeElement;
|
|
786
|
-
const inside = panel.contains(activeElement);
|
|
787
|
-
if (event.shiftKey && (activeElement === first || !inside)) {
|
|
788
|
-
event.preventDefault();
|
|
789
|
-
last.focus();
|
|
790
|
-
} else if (!event.shiftKey && (activeElement === last || !inside)) {
|
|
791
|
-
event.preventDefault();
|
|
792
|
-
first.focus();
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
function onFocusIn(event) {
|
|
796
|
-
if (!isTopmostRef.current) return;
|
|
797
|
-
const panel = panelRef.current;
|
|
798
|
-
if (!panel) return;
|
|
799
|
-
if (panel.contains(event.target)) return;
|
|
800
|
-
const items = tabbable(panel);
|
|
801
|
-
(items[0] ?? panel).focus({ preventScroll: true });
|
|
802
|
-
}
|
|
803
|
-
document.addEventListener("keydown", onKeyDown);
|
|
804
|
-
document.addEventListener("focusin", onFocusIn);
|
|
805
|
-
return () => {
|
|
806
|
-
document.removeEventListener("keydown", onKeyDown);
|
|
807
|
-
document.removeEventListener("focusin", onFocusIn);
|
|
808
|
-
};
|
|
809
|
-
}, [active, trapFocus, panelRef]);
|
|
810
|
-
useEffect3(() => {
|
|
811
|
-
if (!active) return;
|
|
812
|
-
const previouslyFocused = document.activeElement;
|
|
813
|
-
const panel = panelRef.current;
|
|
814
|
-
let observer = null;
|
|
815
|
-
if (panel && autoFocus) {
|
|
816
|
-
if (!panel.hasAttribute("tabindex")) panel.setAttribute("tabindex", "-1");
|
|
817
|
-
const focusTarget = () => {
|
|
818
|
-
const explicit = initialFocus?.current;
|
|
819
|
-
if (explicit) {
|
|
820
|
-
explicit.focus({ preventScroll: true });
|
|
821
|
-
return true;
|
|
822
|
-
}
|
|
823
|
-
const items = tabbable(panel);
|
|
824
|
-
if (items.length > 0) {
|
|
825
|
-
items[0].focus({ preventScroll: true });
|
|
826
|
-
return true;
|
|
827
|
-
}
|
|
828
|
-
return false;
|
|
829
|
-
};
|
|
830
|
-
if (!focusTarget()) {
|
|
831
|
-
panel.focus({ preventScroll: true });
|
|
832
|
-
observer = new MutationObserver(() => {
|
|
833
|
-
if (focusTarget()) {
|
|
834
|
-
observer?.disconnect();
|
|
835
|
-
observer = null;
|
|
836
|
-
}
|
|
837
|
-
});
|
|
838
|
-
observer.observe(panel, { childList: true, subtree: true });
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
return () => {
|
|
842
|
-
observer?.disconnect();
|
|
843
|
-
const target = returnFocus ? returnFocus.current : previouslyFocused;
|
|
844
|
-
if (target?.isConnected) target.focus({ preventScroll: true });
|
|
845
|
-
};
|
|
846
|
-
}, [active, panelRef, initialFocus, returnFocus, autoFocus]);
|
|
847
|
-
}
|
|
848
|
-
function vetoable(event, onVeto) {
|
|
849
|
-
let vetoed = false;
|
|
850
|
-
return new Proxy(event, {
|
|
851
|
-
get(target, key) {
|
|
852
|
-
if (key === "preventDefault") {
|
|
853
|
-
return () => {
|
|
854
|
-
vetoed = true;
|
|
855
|
-
onVeto();
|
|
856
|
-
};
|
|
857
|
-
}
|
|
858
|
-
if (key === "defaultPrevented") return vetoed;
|
|
859
|
-
const value = Reflect.get(target, key, target);
|
|
860
|
-
return typeof value === "function" ? value.bind(target) : value;
|
|
861
|
-
}
|
|
862
|
-
});
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
// src/components/overlays/portal.tsx
|
|
866
|
-
import { createContext as createContext3, useContext as useContext3, useEffect as useEffect4, useState as useState3 } from "react";
|
|
867
|
-
import { createPortal } from "react-dom";
|
|
868
|
-
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
869
|
-
var PortalContainerContext = createContext3(null);
|
|
870
|
-
function PortalContainerProvider({
|
|
871
|
-
container,
|
|
872
|
-
children
|
|
873
|
-
}) {
|
|
874
|
-
return /* @__PURE__ */ jsx6(PortalContainerContext.Provider, { value: container, children });
|
|
875
|
-
}
|
|
876
|
-
function usePortalContainer() {
|
|
877
|
-
return useContext3(PortalContainerContext);
|
|
878
|
-
}
|
|
879
|
-
function Portal({ children, container }) {
|
|
880
|
-
const [mounted, setMounted] = useState3(false);
|
|
881
|
-
const contextContainer = useContext3(PortalContainerContext);
|
|
882
|
-
useEffect4(() => setMounted(true), []);
|
|
883
|
-
if (!mounted) return null;
|
|
884
|
-
const target = container ?? contextContainer ?? (typeof document === "undefined" ? null : document.body);
|
|
885
|
-
if (!target) return null;
|
|
886
|
-
return createPortal(children, target);
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
// src/components/forms/select.tsx
|
|
890
|
-
import {
|
|
891
|
-
forwardRef as forwardRef6,
|
|
892
|
-
useEffect as useEffect6,
|
|
893
|
-
useId as useId2,
|
|
894
|
-
useRef as useRef6,
|
|
895
|
-
useState as useState6
|
|
896
|
-
} from "react";
|
|
897
|
-
import clsx8 from "clsx";
|
|
898
|
-
import { CheckIcon, ChevronDownIcon } from "lucide-react";
|
|
899
|
-
|
|
900
|
-
// src/lib/dev-warn.ts
|
|
901
|
-
var seen = /* @__PURE__ */ new Set();
|
|
902
|
-
function devWarn(message) {
|
|
903
|
-
const env = globalThis.process?.env?.NODE_ENV;
|
|
904
|
-
if (env === "production" || seen.has(message)) return;
|
|
905
|
-
seen.add(message);
|
|
906
|
-
console.warn(`[@platned/ui] ${message}`);
|
|
907
|
-
}
|
|
908
|
-
|
|
909
|
-
// src/lib/use-controllable-state.ts
|
|
910
|
-
import { useCallback as useCallback2, useRef as useRef3, useState as useState4 } from "react";
|
|
911
|
-
function useControllableState({
|
|
912
|
-
value,
|
|
913
|
-
defaultValue,
|
|
914
|
-
onChange
|
|
915
|
-
}) {
|
|
916
|
-
const [internal, setInternal] = useState4(defaultValue);
|
|
917
|
-
const isControlled = value !== void 0;
|
|
918
|
-
const current = isControlled ? value : internal;
|
|
919
|
-
const onChangeRef = useRef3(onChange);
|
|
920
|
-
onChangeRef.current = onChange;
|
|
921
|
-
const currentRef = useRef3(current);
|
|
922
|
-
currentRef.current = current;
|
|
923
|
-
const isControlledRef = useRef3(isControlled);
|
|
924
|
-
isControlledRef.current = isControlled;
|
|
925
|
-
const setValue = useCallback2((next) => {
|
|
926
|
-
const resolved = typeof next === "function" ? next(currentRef.current) : next;
|
|
927
|
-
if (resolved === currentRef.current) return;
|
|
928
|
-
if (!isControlledRef.current) setInternal(resolved);
|
|
929
|
-
onChangeRef.current?.(resolved);
|
|
930
|
-
}, []);
|
|
931
|
-
return [current, setValue];
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
// src/lib/use-roving-focus.ts
|
|
935
|
-
import { useCallback as useCallback3, useEffect as useEffect5, useRef as useRef4, useState as useState5 } from "react";
|
|
936
|
-
function useRovingFocus({
|
|
937
|
-
orientation = "horizontal",
|
|
938
|
-
loop = true,
|
|
939
|
-
typeahead = false,
|
|
940
|
-
defaultIndex = 0,
|
|
941
|
-
onEscape
|
|
942
|
-
} = {}) {
|
|
943
|
-
const [activeIndex, setActiveIndex] = useState5(defaultIndex);
|
|
944
|
-
const items = useRef4([]);
|
|
945
|
-
const meta = useRef4([]);
|
|
946
|
-
const search = useRef4("");
|
|
947
|
-
const searchTimer = useRef4(null);
|
|
948
|
-
useEffect5(
|
|
949
|
-
() => () => {
|
|
950
|
-
if (searchTimer.current) clearTimeout(searchTimer.current);
|
|
951
|
-
},
|
|
952
|
-
[]
|
|
953
|
-
);
|
|
954
|
-
const focusIndex = useCallback3((index) => {
|
|
955
|
-
const node = items.current[index];
|
|
956
|
-
if (!node) return;
|
|
957
|
-
setActiveIndex(index);
|
|
958
|
-
node.focus();
|
|
959
|
-
}, []);
|
|
960
|
-
const move = useCallback3(
|
|
961
|
-
(start, step) => {
|
|
962
|
-
const total = items.current.length;
|
|
963
|
-
if (total === 0) return;
|
|
964
|
-
for (let i = 1; i <= total; i++) {
|
|
965
|
-
let next = start + step * i;
|
|
966
|
-
if (loop) {
|
|
967
|
-
next = (next % total + total) % total;
|
|
968
|
-
} else if (next < 0 || next >= total) {
|
|
969
|
-
return;
|
|
970
|
-
}
|
|
971
|
-
if (items.current[next] && !meta.current[next]?.disabled) {
|
|
972
|
-
focusIndex(next);
|
|
973
|
-
return;
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
},
|
|
977
|
-
[loop, focusIndex]
|
|
978
|
-
);
|
|
979
|
-
const moveToEdge = useCallback3(
|
|
980
|
-
(from) => {
|
|
981
|
-
const total = items.current.length;
|
|
982
|
-
if (total === 0) return;
|
|
983
|
-
move(from === "start" ? -1 : total, from === "start" ? 1 : -1);
|
|
984
|
-
},
|
|
985
|
-
[move]
|
|
986
|
-
);
|
|
987
|
-
const runTypeahead = useCallback3(
|
|
988
|
-
(char) => {
|
|
989
|
-
if (searchTimer.current) clearTimeout(searchTimer.current);
|
|
990
|
-
search.current += char.toLowerCase();
|
|
991
|
-
searchTimer.current = setTimeout(() => {
|
|
992
|
-
search.current = "";
|
|
993
|
-
}, 500);
|
|
994
|
-
const total = items.current.length;
|
|
995
|
-
const query = search.current;
|
|
996
|
-
for (let i = 1; i <= total; i++) {
|
|
997
|
-
const index = (activeIndex + i) % total;
|
|
998
|
-
if (meta.current[index]?.disabled) continue;
|
|
999
|
-
const label = meta.current[index]?.label?.toLowerCase();
|
|
1000
|
-
if (label?.startsWith(query)) {
|
|
1001
|
-
focusIndex(index);
|
|
1002
|
-
return;
|
|
1003
|
-
}
|
|
1004
|
-
}
|
|
1005
|
-
},
|
|
1006
|
-
[activeIndex, focusIndex]
|
|
1007
|
-
);
|
|
1008
|
-
const onKeyDown = useCallback3(
|
|
1009
|
-
(event) => {
|
|
1010
|
-
const { key } = event;
|
|
1011
|
-
const vertical = orientation === "vertical" || orientation === "both";
|
|
1012
|
-
const horizontal = orientation === "horizontal" || orientation === "both";
|
|
1013
|
-
const next = vertical && key === "ArrowDown" || horizontal && key === "ArrowRight";
|
|
1014
|
-
const prev = vertical && key === "ArrowUp" || horizontal && key === "ArrowLeft";
|
|
1015
|
-
if (next || prev) {
|
|
1016
|
-
event.preventDefault();
|
|
1017
|
-
move(activeIndex, next ? 1 : -1);
|
|
1018
|
-
return;
|
|
1019
|
-
}
|
|
1020
|
-
if (key === "Home") {
|
|
1021
|
-
event.preventDefault();
|
|
1022
|
-
moveToEdge("start");
|
|
1023
|
-
return;
|
|
1024
|
-
}
|
|
1025
|
-
if (key === "End") {
|
|
1026
|
-
event.preventDefault();
|
|
1027
|
-
moveToEdge("end");
|
|
1028
|
-
return;
|
|
1029
|
-
}
|
|
1030
|
-
if (key === "Escape" && onEscape) {
|
|
1031
|
-
onEscape();
|
|
1032
|
-
return;
|
|
1033
|
-
}
|
|
1034
|
-
if (typeahead && key.length === 1 && key !== " " && !event.ctrlKey && !event.metaKey && !event.altKey) {
|
|
1035
|
-
event.preventDefault();
|
|
1036
|
-
runTypeahead(key);
|
|
1037
|
-
}
|
|
1038
|
-
},
|
|
1039
|
-
[orientation, activeIndex, move, moveToEdge, onEscape, typeahead, runTypeahead]
|
|
1040
|
-
);
|
|
1041
|
-
const itemProps = useCallback3(
|
|
1042
|
-
(index, options = {}) => {
|
|
1043
|
-
meta.current[index] = options;
|
|
1044
|
-
return {
|
|
1045
|
-
ref: (node) => {
|
|
1046
|
-
items.current[index] = node;
|
|
1047
|
-
},
|
|
1048
|
-
// The roving part: exactly one item is in the tab sequence, so Tab enters the
|
|
1049
|
-
// composite once and Tab again leaves it.
|
|
1050
|
-
tabIndex: index === activeIndex ? 0 : -1,
|
|
1051
|
-
onFocus: () => setActiveIndex(index),
|
|
1052
|
-
"data-roving-index": index
|
|
1053
|
-
};
|
|
1054
|
-
},
|
|
1055
|
-
[activeIndex]
|
|
1056
|
-
);
|
|
1057
|
-
return {
|
|
1058
|
-
activeIndex,
|
|
1059
|
-
setActiveIndex,
|
|
1060
|
-
focusIndex,
|
|
1061
|
-
moveToEdge,
|
|
1062
|
-
itemProps,
|
|
1063
|
-
containerProps: { onKeyDown }
|
|
1064
|
-
};
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
|
-
// src/components/overlays/floating.tsx
|
|
1068
|
-
import { useRef as useRef5 } from "react";
|
|
1069
|
-
import {
|
|
1070
|
-
arrow,
|
|
1071
|
-
autoUpdate,
|
|
1072
|
-
flip,
|
|
1073
|
-
offset,
|
|
1074
|
-
shift,
|
|
1075
|
-
size,
|
|
1076
|
-
useFloating
|
|
1077
|
-
} from "@floating-ui/react";
|
|
1078
|
-
function useFloatingPanel({
|
|
1079
|
-
open,
|
|
1080
|
-
onOpenChange,
|
|
1081
|
-
side = "bottom",
|
|
1082
|
-
align = "center",
|
|
1083
|
-
sideOffset = 6,
|
|
1084
|
-
alignOffset = 0,
|
|
1085
|
-
collisionPadding = 8,
|
|
1086
|
-
withArrow = false,
|
|
1087
|
-
matchAnchorWidth = false
|
|
1088
|
-
}) {
|
|
1089
|
-
const arrowRef = useRef5(null);
|
|
1090
|
-
const placement = align === "center" ? side : `${side}-${align}`;
|
|
1091
|
-
const floating = useFloating({
|
|
1092
|
-
open,
|
|
1093
|
-
onOpenChange,
|
|
1094
|
-
placement,
|
|
1095
|
-
// `fixed`, not the default `absolute`: inside a Modal these panels portal into the
|
|
1096
|
-
// dialog's scrolling content (see `PortalContainerProvider`), and an absolutely
|
|
1097
|
-
// positioned panel there would be clipped by its overflow. Radix's Popper does the same.
|
|
1098
|
-
strategy: "fixed",
|
|
1099
|
-
// Only track while the panel is actually on screen. `autoUpdate` attaches scroll and
|
|
1100
|
-
// resize listeners plus a ResizeObserver, so leaving it running on a closed panel
|
|
1101
|
-
// would cost every consumer a listener per menu on the page.
|
|
1102
|
-
whileElementsMounted: autoUpdate,
|
|
1103
|
-
middleware: [
|
|
1104
|
-
offset({ mainAxis: sideOffset, crossAxis: alignOffset }),
|
|
1105
|
-
// `flip` before `shift`: try the opposite edge first, and only slide along the
|
|
1106
|
-
// current one if neither edge fits. The reverse order produces panels that cling to
|
|
1107
|
-
// the viewport edge when they had room to simply flip.
|
|
1108
|
-
flip({ padding: collisionPadding }),
|
|
1109
|
-
shift({ padding: collisionPadding }),
|
|
1110
|
-
matchAnchorWidth && size({
|
|
1111
|
-
padding: collisionPadding,
|
|
1112
|
-
apply({ rects, elements, availableHeight }) {
|
|
1113
|
-
elements.floating.style.setProperty(
|
|
1114
|
-
"--panel-anchor-width",
|
|
1115
|
-
`${rects.reference.width}px`
|
|
1116
|
-
);
|
|
1117
|
-
elements.floating.style.setProperty(
|
|
1118
|
-
"--panel-available-height",
|
|
1119
|
-
`${availableHeight}px`
|
|
1120
|
-
);
|
|
1121
|
-
}
|
|
1122
|
-
}),
|
|
1123
|
-
withArrow && arrow({ element: arrowRef, padding: 4 })
|
|
1124
|
-
].filter(Boolean)
|
|
1125
|
-
});
|
|
1126
|
-
return { ...floating, arrowRef };
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
// src/components/overlays/menu-styles.ts
|
|
1130
|
-
import clsx7 from "clsx";
|
|
1131
|
-
var OVERLAY_PANEL = "rounded-lg border border-default bg-default p-1 shadow-300";
|
|
1132
|
-
var OVERLAY_PANEL_MENU = clsx7(OVERLAY_PANEL, "min-w-[168px]");
|
|
1133
|
-
var OVERLAY_PANEL_SCROLL = clsx7(
|
|
1134
|
-
"max-h-[min(16rem,var(--panel-available-height,16rem))] overflow-y-auto",
|
|
1135
|
-
// A floating panel is already its own scroll container and keeps focus on the input or a
|
|
1136
|
-
// roving option, so it needs the scrollbar styling but not `ScrollArea`'s tab stop.
|
|
1137
|
-
SCROLLBAR_CLASSES
|
|
1138
|
-
);
|
|
1139
|
-
var OVERLAY_ITEM_BASE = "flex w-full cursor-pointer select-none items-start gap-2 rounded-md text-left outline-none transition-colors";
|
|
1140
|
-
var OVERLAY_ITEM_SIZE = {
|
|
1141
|
-
lg: "px-3 py-2.5 text-body",
|
|
1142
|
-
md: "px-2.5 py-2 text-body-sm",
|
|
1143
|
-
sm: "px-2 py-1.5 text-body-tiny"
|
|
1144
|
-
};
|
|
1145
|
-
function overlayItemTone(tone, disabled) {
|
|
1146
|
-
if (disabled) return "cursor-not-allowed text-disabled";
|
|
1147
|
-
return tone === "danger" ? "text-danger hover:bg-danger-tertiary focus:bg-danger-tertiary" : "text-default hover:bg-default-secondary focus:bg-default-secondary";
|
|
1148
|
-
}
|
|
1149
|
-
var OVERLAY_ITEM_ACTIVE = "bg-default-secondary";
|
|
1150
|
-
var OVERLAY_HEADING = "px-2.5 py-1.5 text-body-tiny font-semibold uppercase tracking-wide text-default-tertiary";
|
|
1151
|
-
var OVERLAY_SEPARATOR = "-mx-1 my-1 h-px bg-divider";
|
|
1152
|
-
|
|
1153
|
-
// src/components/forms/select.tsx
|
|
1154
|
-
import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1155
|
-
var selectBase = {
|
|
1156
|
-
lg: "h-12 pl-4 pr-9 text-body",
|
|
1157
|
-
// right-4 (16) + size-5 (20) = 36px
|
|
1158
|
-
md: "h-9 pl-3 pr-7 text-body-sm",
|
|
1159
|
-
// right-3 (12) + size-4 (16) = 28px
|
|
1160
|
-
sm: "h-6 pl-2 pr-5 text-body-tiny"
|
|
1161
|
-
// right-2 (8) + size-3 (12) = 20px
|
|
1162
|
-
};
|
|
1163
|
-
var chevronPos = {
|
|
1164
|
-
lg: { right: "right-4", size: "size-5" },
|
|
1165
|
-
md: { right: "right-3", size: "size-4" },
|
|
1166
|
-
sm: { right: "right-2", size: "size-3" }
|
|
1167
|
-
};
|
|
1168
|
-
function isGroup(entry) {
|
|
1169
|
-
return "options" in entry;
|
|
1170
|
-
}
|
|
1171
|
-
function flatten(entries) {
|
|
1172
|
-
return entries.flatMap((entry) => isGroup(entry) ? entry.options : [entry]);
|
|
1173
|
-
}
|
|
1174
|
-
var Select = forwardRef6(
|
|
1175
|
-
function Select2({
|
|
1176
|
-
options,
|
|
1177
|
-
value: valueProp,
|
|
1178
|
-
defaultValue = null,
|
|
1179
|
-
onValueChange,
|
|
1180
|
-
name,
|
|
1181
|
-
size: sizeProp,
|
|
1182
|
-
invalid = false,
|
|
1183
|
-
required = false,
|
|
1184
|
-
placeholder = "Select\u2026",
|
|
1185
|
-
className,
|
|
1186
|
-
onKeyDown,
|
|
1187
|
-
...props
|
|
1188
|
-
}, ref) {
|
|
1189
|
-
const size2 = useControlSize(sizeProp);
|
|
1190
|
-
const field = useFieldControl();
|
|
1191
|
-
const fieldContext = useFieldContext();
|
|
1192
|
-
const [value, setValue] = useControllableState({
|
|
1193
|
-
value: valueProp,
|
|
1194
|
-
defaultValue,
|
|
1195
|
-
onChange: onValueChange
|
|
1196
|
-
});
|
|
1197
|
-
const [open, setOpen] = useState6(false);
|
|
1198
|
-
const baseId = useId2();
|
|
1199
|
-
const listboxId = `${baseId}-listbox`;
|
|
1200
|
-
const valueId = `${baseId}-value`;
|
|
1201
|
-
const optionId = (index) => `${baseId}-option-${index}`;
|
|
1202
|
-
const triggerRef = useRef6(null);
|
|
1203
|
-
const panelRef = useRef6(null);
|
|
1204
|
-
const [panelNode, setPanelNode] = useState6(null);
|
|
1205
|
-
const pendingEdge = useRef6("start");
|
|
1206
|
-
const flat = flatten(options);
|
|
1207
|
-
const selected = flat.find((option) => option.value === value) ?? null;
|
|
1208
|
-
const isInvalid = invalid || !!field["aria-invalid"];
|
|
1209
|
-
const isDisabled = props.disabled ?? field.disabled;
|
|
1210
|
-
const isRequired = required || Boolean(field["aria-required"]) || Boolean(props["aria-required"]);
|
|
1211
|
-
if (!fieldContext && !props["aria-label"] && !props["aria-labelledby"]) {
|
|
1212
|
-
devWarn(
|
|
1213
|
-
"Select outside a Field needs aria-label or aria-labelledby; otherwise it is named only by its value."
|
|
1214
|
-
);
|
|
1215
|
-
}
|
|
1216
|
-
const roving = useRovingFocus({ orientation: "vertical", loop: true, typeahead: true });
|
|
1217
|
-
const { refs, floatingStyles } = useFloatingPanel({
|
|
1218
|
-
open,
|
|
1219
|
-
onOpenChange: setOpen,
|
|
1220
|
-
side: "bottom",
|
|
1221
|
-
align: "start",
|
|
1222
|
-
sideOffset: 4,
|
|
1223
|
-
matchAnchorWidth: true
|
|
1224
|
-
});
|
|
1225
|
-
useEffect6(() => {
|
|
1226
|
-
refs.setReference(triggerRef.current);
|
|
1227
|
-
}, [refs, open]);
|
|
1228
|
-
useOverlayDismiss({
|
|
1229
|
-
onDismiss: () => setOpen(false),
|
|
1230
|
-
panelRef,
|
|
1231
|
-
active: open,
|
|
1232
|
-
// Not modal: the page behind stays readable and interactive. Only Escape,
|
|
1233
|
-
// outside-press and focus restore — the same four falses as DropdownMenu.
|
|
1234
|
-
trapFocus: false,
|
|
1235
|
-
lockScroll: false,
|
|
1236
|
-
inertBackground: false,
|
|
1237
|
-
// The listbox owns its initial focus below; a "first tabbable element" scan would
|
|
1238
|
-
// fight the roving tabindex, which exposes exactly one option at a time.
|
|
1239
|
-
autoFocus: false
|
|
1240
|
-
});
|
|
1241
|
-
const wasOpen = useRef6(false);
|
|
1242
|
-
useEffect6(() => {
|
|
1243
|
-
if (open && panelNode && !wasOpen.current) {
|
|
1244
|
-
const index = selected ? flat.indexOf(selected) : -1;
|
|
1245
|
-
if (index >= 0 && pendingEdge.current === "start") roving.focusIndex(index);
|
|
1246
|
-
else roving.moveToEdge(pendingEdge.current);
|
|
1247
|
-
pendingEdge.current = "start";
|
|
1248
|
-
wasOpen.current = true;
|
|
1249
|
-
}
|
|
1250
|
-
if (!open) wasOpen.current = false;
|
|
1251
|
-
}, [open, panelNode, roving]);
|
|
1252
|
-
const commit = (option) => {
|
|
1253
|
-
if (option.disabled) return;
|
|
1254
|
-
setValue(option.value);
|
|
1255
|
-
setOpen(false);
|
|
1256
|
-
};
|
|
1257
|
-
const triggerKeyDown = (event) => {
|
|
1258
|
-
onKeyDown?.(event);
|
|
1259
|
-
if (event.defaultPrevented || open) return;
|
|
1260
|
-
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
1261
|
-
event.preventDefault();
|
|
1262
|
-
pendingEdge.current = event.key === "ArrowUp" ? "end" : "start";
|
|
1263
|
-
setOpen(true);
|
|
1264
|
-
}
|
|
1265
|
-
};
|
|
1266
|
-
let cursor = 0;
|
|
1267
|
-
const renderOption = (option, index) => {
|
|
1268
|
-
const isSelected = option.value === value;
|
|
1269
|
-
const itemProps = roving.itemProps(index, {
|
|
1270
|
-
disabled: option.disabled,
|
|
1271
|
-
label: option.label
|
|
1272
|
-
});
|
|
1273
|
-
return /* @__PURE__ */ jsxs2(
|
|
1274
|
-
"div",
|
|
1275
|
-
{
|
|
1276
|
-
role: "option",
|
|
1277
|
-
id: optionId(index),
|
|
1278
|
-
"aria-selected": isSelected,
|
|
1279
|
-
"aria-disabled": option.disabled || void 0,
|
|
1280
|
-
...itemProps,
|
|
1281
|
-
tabIndex: itemProps.tabIndex,
|
|
1282
|
-
onClick: () => commit(option),
|
|
1283
|
-
onKeyDown: (event) => {
|
|
1284
|
-
if (event.key === "Enter" || event.key === " ") {
|
|
1285
|
-
event.preventDefault();
|
|
1286
|
-
commit(option);
|
|
1287
|
-
}
|
|
1288
|
-
},
|
|
1289
|
-
className: clsx8(
|
|
1290
|
-
OVERLAY_ITEM_BASE,
|
|
1291
|
-
OVERLAY_ITEM_SIZE[size2],
|
|
1292
|
-
"items-center",
|
|
1293
|
-
overlayItemTone("default", !!option.disabled),
|
|
1294
|
-
// The tint is shared with hover, so the ring is what marks the keyboard position.
|
|
1295
|
-
FOCUS_RING_INSET
|
|
1296
|
-
),
|
|
1297
|
-
children: [
|
|
1298
|
-
/* @__PURE__ */ jsx7("span", { className: "min-w-0 flex-1 truncate", children: option.label }),
|
|
1299
|
-
isSelected && /* @__PURE__ */ jsx7(CheckIcon, { className: "size-3.5 shrink-0", strokeWidth: 3, "aria-hidden": true })
|
|
1300
|
-
]
|
|
1301
|
-
},
|
|
1302
|
-
option.value
|
|
1303
|
-
);
|
|
1304
|
-
};
|
|
1305
|
-
const cp = chevronPos[size2];
|
|
1306
|
-
return /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
1307
|
-
/* @__PURE__ */ jsxs2("div", { className: "relative flex items-center", children: [
|
|
1308
|
-
/* @__PURE__ */ jsx7(
|
|
1309
|
-
"button",
|
|
1310
|
-
{
|
|
1311
|
-
ref: composeRefs(triggerRef, ref),
|
|
1312
|
-
type: "button",
|
|
1313
|
-
role: "combobox",
|
|
1314
|
-
"aria-haspopup": "listbox",
|
|
1315
|
-
"aria-expanded": open,
|
|
1316
|
-
"aria-controls": open ? listboxId : void 0,
|
|
1317
|
-
"aria-labelledby": fieldContext ? `${fieldContext.labelId} ${valueId}` : void 0,
|
|
1318
|
-
"data-size": size2,
|
|
1319
|
-
...field,
|
|
1320
|
-
"aria-invalid": isInvalid || void 0,
|
|
1321
|
-
"aria-required": isRequired || void 0,
|
|
1322
|
-
disabled: isDisabled,
|
|
1323
|
-
onClick: () => setOpen(!open),
|
|
1324
|
-
onKeyDown: triggerKeyDown,
|
|
1325
|
-
className: clsx8(
|
|
1326
|
-
"w-full appearance-none rounded-lg border text-left outline-none transition-colors",
|
|
1327
|
-
"bg-default text-default",
|
|
1328
|
-
"focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-offset-default",
|
|
1329
|
-
selectBase[size2],
|
|
1330
|
-
isDisabled ? "cursor-not-allowed border-disabled bg-disabled text-disabled" : isInvalid ? "border-danger-secondary focus-visible:border-danger focus-visible:ring-danger" : "border-default focus-visible:border-brand focus-visible:ring-brand",
|
|
1331
|
-
className
|
|
1332
|
-
),
|
|
1333
|
-
...props,
|
|
1334
|
-
children: /* @__PURE__ */ jsx7(
|
|
1335
|
-
"span",
|
|
1336
|
-
{
|
|
1337
|
-
id: valueId,
|
|
1338
|
-
className: clsx8("block truncate", !selected && "text-default-tertiary"),
|
|
1339
|
-
children: selected?.label ?? placeholder
|
|
1340
|
-
}
|
|
1341
|
-
)
|
|
1342
|
-
}
|
|
1343
|
-
),
|
|
1344
|
-
/* @__PURE__ */ jsx7(
|
|
1345
|
-
"span",
|
|
1346
|
-
{
|
|
1347
|
-
"aria-hidden": true,
|
|
1348
|
-
className: clsx8(
|
|
1349
|
-
"pointer-events-none absolute",
|
|
1350
|
-
cp.right,
|
|
1351
|
-
cp.size,
|
|
1352
|
-
"flex items-center justify-center",
|
|
1353
|
-
isDisabled ? "text-icon-disabled" : "text-icon-default-secondary"
|
|
1354
|
-
),
|
|
1355
|
-
children: /* @__PURE__ */ jsx7(ChevronDownIcon, { className: "size-full" })
|
|
1356
|
-
}
|
|
1357
|
-
),
|
|
1358
|
-
name && !isRequired && /* @__PURE__ */ jsx7("input", { type: "hidden", name, value: value ?? "" }),
|
|
1359
|
-
name && isRequired && /* @__PURE__ */ jsx7(
|
|
1360
|
-
"input",
|
|
1361
|
-
{
|
|
1362
|
-
"aria-hidden": true,
|
|
1363
|
-
tabIndex: -1,
|
|
1364
|
-
name,
|
|
1365
|
-
value: value ?? "",
|
|
1366
|
-
required: true,
|
|
1367
|
-
disabled: isDisabled,
|
|
1368
|
-
onChange: () => {
|
|
1369
|
-
},
|
|
1370
|
-
onFocus: () => triggerRef.current?.focus(),
|
|
1371
|
-
className: "pointer-events-none absolute inset-x-0 bottom-0 h-px w-full opacity-0"
|
|
1372
|
-
}
|
|
1373
|
-
)
|
|
1374
|
-
] }),
|
|
1375
|
-
open && /* @__PURE__ */ jsx7(Portal, { children: /* @__PURE__ */ jsx7(
|
|
1376
|
-
"div",
|
|
1377
|
-
{
|
|
1378
|
-
ref: composeRefs(panelRef, setPanelNode, refs.setFloating),
|
|
1379
|
-
id: listboxId,
|
|
1380
|
-
role: "listbox",
|
|
1381
|
-
tabIndex: -1,
|
|
1382
|
-
"aria-orientation": "vertical",
|
|
1383
|
-
"aria-labelledby": fieldContext?.labelId,
|
|
1384
|
-
"aria-required": field["aria-required"],
|
|
1385
|
-
"aria-invalid": field["aria-invalid"],
|
|
1386
|
-
style: { ...floatingStyles, width: "var(--panel-anchor-width)" },
|
|
1387
|
-
className: clsx8("z-popover", OVERLAY_PANEL, OVERLAY_PANEL_SCROLL),
|
|
1388
|
-
...roving.containerProps,
|
|
1389
|
-
onKeyDown: (event) => {
|
|
1390
|
-
roving.containerProps.onKeyDown(event);
|
|
1391
|
-
if (event.key === "Tab") setOpen(false);
|
|
1392
|
-
},
|
|
1393
|
-
children: options.map((entry, entryIndex) => {
|
|
1394
|
-
if (!isGroup(entry)) return renderOption(entry, cursor++);
|
|
1395
|
-
const headingId = `${baseId}-group-${entryIndex}`;
|
|
1396
|
-
return /* @__PURE__ */ jsxs2("div", { role: "group", "aria-labelledby": headingId, children: [
|
|
1397
|
-
/* @__PURE__ */ jsx7("div", { id: headingId, className: OVERLAY_HEADING, children: entry.label }),
|
|
1398
|
-
entry.options.map((option) => renderOption(option, cursor++))
|
|
1399
|
-
] }, `group-${entryIndex}`);
|
|
1400
|
-
})
|
|
1401
|
-
}
|
|
1402
|
-
) })
|
|
1403
|
-
] });
|
|
1404
|
-
}
|
|
1405
|
-
);
|
|
1406
|
-
var SelectControl = Select;
|
|
1407
|
-
|
|
1408
|
-
// src/lib/use-element-width.ts
|
|
1409
|
-
import { useEffect as useEffect7, useLayoutEffect as useLayoutEffect2, useState as useState7 } from "react";
|
|
1410
|
-
var useIsomorphicLayoutEffect2 = typeof window === "undefined" ? useEffect7 : useLayoutEffect2;
|
|
1411
|
-
function useElementWidth() {
|
|
1412
|
-
const [node, setNode] = useState7(null);
|
|
1413
|
-
const [width, setWidth] = useState7(void 0);
|
|
1414
|
-
useIsomorphicLayoutEffect2(() => {
|
|
1415
|
-
if (!node) return;
|
|
1416
|
-
const apply = (next) => {
|
|
1417
|
-
if (next <= 0) return;
|
|
1418
|
-
setWidth((prev) => prev !== void 0 && Math.abs(prev - next) < 1 ? prev : next);
|
|
1419
|
-
};
|
|
1420
|
-
apply(node.getBoundingClientRect().width);
|
|
1421
|
-
if (typeof ResizeObserver === "undefined") return;
|
|
1422
|
-
const observer = new ResizeObserver((entries) => {
|
|
1423
|
-
const entry = entries[0];
|
|
1424
|
-
if (entry) apply(entry.contentRect.width);
|
|
1425
|
-
});
|
|
1426
|
-
observer.observe(node);
|
|
1427
|
-
return () => observer.disconnect();
|
|
1428
|
-
}, [node]);
|
|
1429
|
-
return [setNode, width];
|
|
1430
|
-
}
|
|
1431
|
-
|
|
1432
|
-
// src/components/forms/checkbox.tsx
|
|
1433
|
-
import { forwardRef as forwardRef7, useEffect as useEffect8, useId as useId3, useRef as useRef7 } from "react";
|
|
1434
|
-
import clsx10 from "clsx";
|
|
1435
|
-
|
|
1436
|
-
// src/components/forms/check-control.tsx
|
|
1437
|
-
import clsx9 from "clsx";
|
|
1438
|
-
import { CheckIcon as CheckIcon2, MinusIcon } from "lucide-react";
|
|
1439
|
-
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
1440
|
-
var CHECK_SIZE = {
|
|
1441
|
-
sm: { box: "size-4", glyph: "size-2.5", dot: "size-1.5" },
|
|
1442
|
-
md: { box: "size-[18px]", glyph: "size-3", dot: "size-2" }
|
|
1443
|
-
};
|
|
1444
|
-
function CheckControl({
|
|
1445
|
-
type,
|
|
1446
|
-
checked,
|
|
1447
|
-
indeterminate = false,
|
|
1448
|
-
disabled = false,
|
|
1449
|
-
invalid = false,
|
|
1450
|
-
size: size2 = "md"
|
|
1451
|
-
}) {
|
|
1452
|
-
const s = CHECK_SIZE[size2];
|
|
1453
|
-
const on = checked || indeterminate;
|
|
1454
|
-
return /* @__PURE__ */ jsx8(
|
|
1455
|
-
"span",
|
|
1456
|
-
{
|
|
1457
|
-
"aria-hidden": true,
|
|
1458
|
-
className: clsx9(
|
|
1459
|
-
"mt-px flex shrink-0 items-center justify-center border-[1.5px] transition-colors",
|
|
1460
|
-
s.box,
|
|
1461
|
-
type === "radio" ? "rounded-full" : "rounded-[4px]",
|
|
1462
|
-
// Ring is drawn from the peer input's focus state, so the visual box tracks real
|
|
1463
|
-
// focus rather than hover.
|
|
1464
|
-
"peer-focus-visible:ring-2 peer-focus-visible:ring-brand peer-focus-visible:ring-offset-1 peer-focus-visible:ring-offset-default",
|
|
1465
|
-
disabled ? on ? "border-disabled bg-disabled text-disabled-on-disabled" : "border-disabled bg-disabled" : on ? "border-brand-emphasis bg-brand text-brand-on-brand" : invalid ? "border-danger bg-default" : "border-default-secondary bg-default"
|
|
1466
|
-
),
|
|
1467
|
-
children: type === "checkbox" ? indeterminate ? /* @__PURE__ */ jsx8(MinusIcon, { className: s.glyph, strokeWidth: 3 }) : checked ? /* @__PURE__ */ jsx8(CheckIcon2, { className: s.glyph, strokeWidth: 3 }) : null : checked ? /* @__PURE__ */ jsx8("span", { className: clsx9("rounded-full bg-current", s.dot) }) : null
|
|
1468
|
-
}
|
|
1469
|
-
);
|
|
1470
|
-
}
|
|
1471
|
-
|
|
1472
|
-
// src/components/forms/checkbox.tsx
|
|
1473
|
-
import { jsx as jsx9, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1474
|
-
var LABEL_TEXT2 = {
|
|
1475
|
-
sm: "text-body-tiny",
|
|
1476
|
-
md: "text-body-xs"
|
|
1477
|
-
};
|
|
1478
|
-
var Checkbox = forwardRef7(function Checkbox2({
|
|
1479
|
-
checked: checkedProp,
|
|
1480
|
-
defaultChecked = false,
|
|
1481
|
-
onCheckedChange,
|
|
1482
|
-
label,
|
|
1483
|
-
description,
|
|
1484
|
-
size: size2 = "md",
|
|
1485
|
-
indeterminate = false,
|
|
1486
|
-
invalid = false,
|
|
1487
|
-
disabled = false,
|
|
1488
|
-
id,
|
|
1489
|
-
className,
|
|
1490
|
-
...props
|
|
1491
|
-
}, ref) {
|
|
1492
|
-
const [checked, setChecked] = useControllableState({
|
|
1493
|
-
value: checkedProp,
|
|
1494
|
-
defaultValue: defaultChecked,
|
|
1495
|
-
onChange: onCheckedChange
|
|
1496
|
-
});
|
|
1497
|
-
const inputRef = useRef7(null);
|
|
1498
|
-
const generatedId = useId3();
|
|
1499
|
-
const controlId = id ?? generatedId;
|
|
1500
|
-
const descriptionId = `${controlId}-description`;
|
|
1501
|
-
useEffect8(() => {
|
|
1502
|
-
if (inputRef.current) inputRef.current.indeterminate = indeterminate;
|
|
1503
|
-
}, [indeterminate]);
|
|
1504
|
-
return /* @__PURE__ */ jsxs3("div", { className: clsx10("flex flex-col", className), children: [
|
|
1505
|
-
/* @__PURE__ */ jsxs3(
|
|
1506
|
-
"label",
|
|
1507
|
-
{
|
|
1508
|
-
htmlFor: controlId,
|
|
1509
|
-
className: clsx10(
|
|
1510
|
-
// relative: the hidden input is absolutely positioned (sr-only). Without a positioned
|
|
1511
|
-
// ancestor here its box lands far up the page, and focusing it on click scrolled a
|
|
1512
|
-
// scrolling container to that spot, away from the control.
|
|
1513
|
-
"group relative inline-flex items-start gap-2.5",
|
|
1514
|
-
disabled ? "cursor-not-allowed opacity-60" : "cursor-pointer"
|
|
1515
|
-
),
|
|
1516
|
-
children: [
|
|
1517
|
-
/* @__PURE__ */ jsx9(
|
|
1518
|
-
"input",
|
|
1519
|
-
{
|
|
1520
|
-
ref: composeRefs(inputRef, ref),
|
|
1521
|
-
id: controlId,
|
|
1522
|
-
type: "checkbox",
|
|
1523
|
-
checked,
|
|
1524
|
-
disabled,
|
|
1525
|
-
"aria-invalid": invalid || void 0,
|
|
1526
|
-
"aria-describedby": description ? descriptionId : void 0,
|
|
1527
|
-
onChange: (event) => setChecked(event.target.checked),
|
|
1528
|
-
className: "peer sr-only",
|
|
1529
|
-
...props
|
|
1530
|
-
}
|
|
1531
|
-
),
|
|
1532
|
-
/* @__PURE__ */ jsx9(
|
|
1533
|
-
CheckControl,
|
|
1534
|
-
{
|
|
1535
|
-
type: "checkbox",
|
|
1536
|
-
checked,
|
|
1537
|
-
indeterminate,
|
|
1538
|
-
disabled,
|
|
1539
|
-
invalid,
|
|
1540
|
-
size: size2
|
|
1541
|
-
}
|
|
1542
|
-
),
|
|
1543
|
-
label && /* @__PURE__ */ jsx9("span", { className: clsx10(LABEL_TEXT2[size2], "min-w-0 text-default [overflow-wrap:anywhere]"), children: label })
|
|
1544
|
-
]
|
|
1545
|
-
}
|
|
1546
|
-
),
|
|
1547
|
-
description && /* @__PURE__ */ jsx9(
|
|
1548
|
-
"span",
|
|
1549
|
-
{
|
|
1550
|
-
id: descriptionId,
|
|
1551
|
-
className: clsx10(
|
|
1552
|
-
"mt-0.5 pl-[26px] [overflow-wrap:anywhere]",
|
|
1553
|
-
LABEL_TEXT2[size2],
|
|
1554
|
-
disabled ? "text-disabled" : "text-default-secondary"
|
|
1555
|
-
),
|
|
1556
|
-
children: description
|
|
1557
|
-
}
|
|
1558
|
-
)
|
|
1559
|
-
] });
|
|
1560
|
-
});
|
|
1561
|
-
|
|
1562
|
-
// src/components/forms/input-group.tsx
|
|
1563
|
-
import { forwardRef as forwardRef8 } from "react";
|
|
1564
|
-
import clsx11 from "clsx";
|
|
1565
|
-
import { SearchIcon, XIcon } from "lucide-react";
|
|
1566
|
-
import { jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1567
|
-
var HEIGHT = {
|
|
1568
|
-
lg: "h-12 text-body",
|
|
1569
|
-
md: "h-9 text-body-sm",
|
|
1570
|
-
sm: "h-6 text-body-tiny"
|
|
1571
|
-
};
|
|
1572
|
-
var PAD = {
|
|
1573
|
-
lg: "px-4 gap-2",
|
|
1574
|
-
md: "px-3 gap-1.5",
|
|
1575
|
-
sm: "px-2 gap-1"
|
|
1576
|
-
};
|
|
1577
|
-
var InputGroup = forwardRef8(function InputGroup2({ children, size: sizeProp, invalid = false, disabled = false, className, ...rest }, ref) {
|
|
1578
|
-
const size2 = useControlSize(sizeProp);
|
|
1579
|
-
return /* @__PURE__ */ jsx10(
|
|
1580
|
-
"div",
|
|
1581
|
-
{
|
|
1582
|
-
ref,
|
|
1583
|
-
"data-slot": "input-group",
|
|
1584
|
-
"data-size": size2,
|
|
1585
|
-
className: clsx11(
|
|
1586
|
-
"flex w-full items-center rounded-lg border transition-colors",
|
|
1587
|
-
"bg-default text-default",
|
|
1588
|
-
HEIGHT[size2],
|
|
1589
|
-
PAD[size2],
|
|
1590
|
-
// `focus-within`, because the focused element is the nested input while the ring
|
|
1591
|
-
// belongs to the shell.
|
|
1592
|
-
"focus-within:ring-2 focus-within:ring-offset-1 focus-within:ring-offset-default",
|
|
1593
|
-
disabled ? "cursor-not-allowed border-disabled bg-disabled text-disabled" : invalid ? "border-danger-secondary focus-within:border-danger focus-within:ring-danger" : "border-default focus-within:border-brand focus-within:ring-brand",
|
|
1594
|
-
className
|
|
1595
|
-
),
|
|
1596
|
-
...rest,
|
|
1597
|
-
children
|
|
1598
|
-
}
|
|
1599
|
-
);
|
|
1600
|
-
});
|
|
1601
|
-
var InputGroupInput = forwardRef8(
|
|
1602
|
-
function InputGroupInput2({ className, ...props }, ref) {
|
|
1603
|
-
const field = useFieldControl();
|
|
1604
|
-
return /* @__PURE__ */ jsx10(
|
|
1605
|
-
"input",
|
|
1606
|
-
{
|
|
1607
|
-
ref,
|
|
1608
|
-
...field,
|
|
1609
|
-
className: clsx11(
|
|
1610
|
-
"min-w-0 flex-1 bg-transparent outline-none",
|
|
1611
|
-
"placeholder:text-default-tertiary",
|
|
1612
|
-
"disabled:cursor-not-allowed disabled:text-disabled disabled:placeholder:text-disabled",
|
|
1613
|
-
className
|
|
1614
|
-
),
|
|
1615
|
-
...props
|
|
1616
|
-
}
|
|
1617
|
-
);
|
|
1618
|
-
}
|
|
1619
|
-
);
|
|
1620
|
-
var InputGroupAddon = forwardRef8(
|
|
1621
|
-
function InputGroupAddon2({ children, align = "inline-start", decorative = true, className, ...rest }, ref) {
|
|
1622
|
-
return /* @__PURE__ */ jsx10(
|
|
1623
|
-
"span",
|
|
1624
|
-
{
|
|
1625
|
-
ref,
|
|
1626
|
-
"aria-hidden": decorative || void 0,
|
|
1627
|
-
"data-slot": "input-group-addon",
|
|
1628
|
-
"data-align": align,
|
|
1629
|
-
className: clsx11(
|
|
1630
|
-
"flex shrink-0 items-center text-icon-default-secondary",
|
|
1631
|
-
decorative && "pointer-events-none",
|
|
1632
|
-
align === "inline-end" && "order-last",
|
|
1633
|
-
className
|
|
1634
|
-
),
|
|
1635
|
-
...rest,
|
|
1636
|
-
children
|
|
1637
|
-
}
|
|
1638
|
-
);
|
|
1639
|
-
}
|
|
1640
|
-
);
|
|
1641
|
-
var InputGroupText = forwardRef8(
|
|
1642
|
-
function InputGroupText2({ children, className, ...rest }, ref) {
|
|
1643
|
-
return /* @__PURE__ */ jsx10(
|
|
1644
|
-
"span",
|
|
1645
|
-
{
|
|
1646
|
-
ref,
|
|
1647
|
-
className: clsx11("shrink-0 whitespace-nowrap text-default-secondary", className),
|
|
1648
|
-
...rest,
|
|
1649
|
-
children
|
|
1650
|
-
}
|
|
1651
|
-
);
|
|
1652
|
-
}
|
|
1653
|
-
);
|
|
1654
|
-
var SearchInput = forwardRef8(function SearchInput2({ size: sizeProp, onClear, label = "Search", disabled, value, className, ...props }, ref) {
|
|
1655
|
-
const size2 = useControlSize(sizeProp);
|
|
1656
|
-
const hasValue = value !== void 0 && value !== "";
|
|
1657
|
-
return /* @__PURE__ */ jsxs4(InputGroup, { size: size2, disabled, className, children: [
|
|
1658
|
-
/* @__PURE__ */ jsx10(InputGroupAddon, { children: /* @__PURE__ */ jsx10(SearchIcon, { className: size2 === "sm" ? "size-3" : "size-4" }) }),
|
|
1659
|
-
/* @__PURE__ */ jsx10(
|
|
1660
|
-
InputGroupInput,
|
|
1661
|
-
{
|
|
1662
|
-
ref,
|
|
1663
|
-
type: "search",
|
|
1664
|
-
"aria-label": label,
|
|
1665
|
-
disabled,
|
|
1666
|
-
value,
|
|
1667
|
-
className: "[&::-webkit-search-cancel-button]:appearance-none",
|
|
1668
|
-
...props
|
|
1669
|
-
}
|
|
1670
|
-
),
|
|
1671
|
-
onClear && hasValue && /* @__PURE__ */ jsx10(InputGroupAddon, { align: "inline-end", decorative: false, children: /* @__PURE__ */ jsx10(
|
|
1672
|
-
"button",
|
|
1673
|
-
{
|
|
1674
|
-
type: "button",
|
|
1675
|
-
"aria-label": "Clear search",
|
|
1676
|
-
onClick: onClear,
|
|
1677
|
-
disabled,
|
|
1678
|
-
className: "flex items-center justify-center rounded transition-colors hover:text-default focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand",
|
|
1679
|
-
children: /* @__PURE__ */ jsx10(XIcon, { "aria-hidden": true, className: size2 === "sm" ? "size-3" : "size-4" })
|
|
1680
|
-
}
|
|
1681
|
-
) })
|
|
1682
|
-
] });
|
|
1683
|
-
});
|
|
1684
|
-
|
|
1685
|
-
// src/components/overlays/dropdown-menu.tsx
|
|
1686
|
-
import {
|
|
1687
|
-
createContext as createContext4,
|
|
1688
|
-
forwardRef as forwardRef10,
|
|
1689
|
-
useContext as useContext4,
|
|
1690
|
-
useMemo as useMemo2,
|
|
1691
|
-
useRef as useRef8
|
|
1692
|
-
} from "react";
|
|
1693
|
-
import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui";
|
|
1694
|
-
import { EllipsisIcon } from "lucide-react";
|
|
1695
|
-
|
|
1696
|
-
// src/lib/compose-event-handlers.ts
|
|
1697
|
-
function composeEventHandlers(theirs, ours) {
|
|
1698
|
-
return (event) => {
|
|
1699
|
-
theirs?.(event);
|
|
1700
|
-
if (!event.defaultPrevented) ours(event);
|
|
1701
|
-
};
|
|
1702
|
-
}
|
|
1703
|
-
|
|
1704
|
-
// src/components/overlays/menu-core.tsx
|
|
1705
|
-
import {
|
|
1706
|
-
Fragment as Fragment3,
|
|
1707
|
-
forwardRef as forwardRef9,
|
|
1708
|
-
useId as useId4
|
|
1709
|
-
} from "react";
|
|
1710
|
-
import clsx12 from "clsx";
|
|
1711
|
-
import { CheckIcon as CheckIcon3, ChevronRightIcon } from "lucide-react";
|
|
1712
|
-
import { Fragment as Fragment4, jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1713
|
-
var MENU_PANEL_CLASSES = cn("z-popover", OVERLAY_PANEL_MENU, "focus:outline-none");
|
|
1714
|
-
var ITEM_BASE = clsx12(
|
|
1715
|
-
OVERLAY_ITEM_BASE,
|
|
1716
|
-
OVERLAY_ITEM_SIZE.md,
|
|
1717
|
-
// Highlight follows Radix's `data-highlighted`, which tracks pointer and keyboard alike.
|
|
1718
|
-
// The ring marks the keyboard position on top of it: the tint alone, shared with hover,
|
|
1719
|
-
// cannot tell a keyboard user which of two tinted items has focus.
|
|
1720
|
-
FOCUS_RING_INSET,
|
|
1721
|
-
"data-[disabled]:cursor-not-allowed data-[disabled]:text-disabled"
|
|
1722
|
-
);
|
|
1723
|
-
var ITEM_TONE = {
|
|
1724
|
-
default: "text-default data-[highlighted]:bg-default-secondary",
|
|
1725
|
-
danger: "text-danger data-[highlighted]:bg-danger-tertiary"
|
|
1726
|
-
};
|
|
1727
|
-
function stopToAncestors(event) {
|
|
1728
|
-
event.stopPropagation();
|
|
1729
|
-
}
|
|
1730
|
-
function focusMenuEdge(event, edge) {
|
|
1731
|
-
if (event.target !== event.currentTarget) return;
|
|
1732
|
-
const panel = event.currentTarget;
|
|
1733
|
-
queueMicrotask(() => {
|
|
1734
|
-
const items = panel.querySelectorAll('[role^="menuitem"]:not([data-disabled])');
|
|
1735
|
-
if (edge === "end") items[items.length - 1]?.focus();
|
|
1736
|
-
else if (document.activeElement === panel) items[0]?.focus();
|
|
1737
|
-
});
|
|
1738
|
-
}
|
|
1739
|
-
function visibleMenuItems(items) {
|
|
1740
|
-
const kept = items.filter((item) => {
|
|
1741
|
-
if (item.hidden) return false;
|
|
1742
|
-
if (item.type === "group" || item.type === "submenu") return visibleMenuItems(item.items).length > 0;
|
|
1743
|
-
return true;
|
|
1744
|
-
});
|
|
1745
|
-
return kept.filter((item, i) => {
|
|
1746
|
-
if (item.type !== "separator") return true;
|
|
1747
|
-
const prev = kept[i - 1];
|
|
1748
|
-
return i > 0 && i < kept.length - 1 && prev.type !== "separator";
|
|
1749
|
-
});
|
|
1750
|
-
}
|
|
1751
|
-
function createMenuParts(P) {
|
|
1752
|
-
const Item = forwardRef9(function MenuItem({ children, onSelect, tone = "default", disabled = false, icon, description, shortcut, textValue, className, ...rest }, ref) {
|
|
1753
|
-
const descriptionId = useId4();
|
|
1754
|
-
return /* @__PURE__ */ jsxs5(
|
|
1755
|
-
P.Item,
|
|
1756
|
-
{
|
|
1757
|
-
ref,
|
|
1758
|
-
disabled,
|
|
1759
|
-
textValue,
|
|
1760
|
-
onSelect,
|
|
1761
|
-
"data-tone": tone,
|
|
1762
|
-
"aria-describedby": description ? descriptionId : void 0,
|
|
1763
|
-
className: cn(ITEM_BASE, ITEM_TONE[tone], className),
|
|
1764
|
-
...rest,
|
|
1765
|
-
children: [
|
|
1766
|
-
icon && /* @__PURE__ */ jsx11("span", { "aria-hidden": true, className: "mt-0.5 flex size-4 shrink-0 items-center justify-center", children: icon }),
|
|
1767
|
-
/* @__PURE__ */ jsxs5("span", { className: "min-w-0 flex-1", children: [
|
|
1768
|
-
/* @__PURE__ */ jsx11("span", { className: "block truncate", children }),
|
|
1769
|
-
description && /* @__PURE__ */ jsx11("span", { id: descriptionId, className: "mt-0.5 block text-body-tiny text-default-secondary", children: description })
|
|
1770
|
-
] }),
|
|
1771
|
-
shortcut && /* @__PURE__ */ jsx11("span", { className: "ml-auto shrink-0 pl-4 text-body-tiny text-default-tertiary", children: shortcut })
|
|
1772
|
-
]
|
|
1773
|
-
}
|
|
1774
|
-
);
|
|
1775
|
-
});
|
|
1776
|
-
const CheckboxItem = forwardRef9(function MenuCheckboxItem({ children, checked, onCheckedChange, disabled = false, tone = "default", shortcut, textValue, className, ...rest }, ref) {
|
|
1777
|
-
return /* @__PURE__ */ jsxs5(
|
|
1778
|
-
P.CheckboxItem,
|
|
1779
|
-
{
|
|
1780
|
-
ref,
|
|
1781
|
-
checked,
|
|
1782
|
-
onCheckedChange: (next) => onCheckedChange?.(next === true),
|
|
1783
|
-
onSelect: (event) => event.preventDefault(),
|
|
1784
|
-
disabled,
|
|
1785
|
-
textValue,
|
|
1786
|
-
"data-tone": tone,
|
|
1787
|
-
className: cn(ITEM_BASE, "items-center", ITEM_TONE[tone], className),
|
|
1788
|
-
...rest,
|
|
1789
|
-
children: [
|
|
1790
|
-
/* @__PURE__ */ jsx11("span", { "aria-hidden": true, className: "flex size-4 shrink-0 items-center justify-center", children: /* @__PURE__ */ jsx11(P.ItemIndicator, { children: /* @__PURE__ */ jsx11(CheckIcon3, { className: "size-3.5", strokeWidth: 3 }) }) }),
|
|
1791
|
-
/* @__PURE__ */ jsx11("span", { className: "min-w-0 flex-1 truncate", children }),
|
|
1792
|
-
shortcut && /* @__PURE__ */ jsx11("span", { className: "ml-auto shrink-0 pl-4 text-body-tiny text-default-tertiary", children: shortcut })
|
|
1793
|
-
]
|
|
1794
|
-
}
|
|
1795
|
-
);
|
|
1796
|
-
});
|
|
1797
|
-
function RadioGroup({ children, value, onValueChange }) {
|
|
1798
|
-
return /* @__PURE__ */ jsx11(P.RadioGroup, { value, onValueChange, children });
|
|
1799
|
-
}
|
|
1800
|
-
const RadioItem = forwardRef9(function MenuRadioItem({ children, value, disabled = false, tone = "default", textValue, className, ...rest }, ref) {
|
|
1801
|
-
return /* @__PURE__ */ jsxs5(
|
|
1802
|
-
P.RadioItem,
|
|
1803
|
-
{
|
|
1804
|
-
ref,
|
|
1805
|
-
value,
|
|
1806
|
-
disabled,
|
|
1807
|
-
textValue,
|
|
1808
|
-
"data-tone": tone,
|
|
1809
|
-
className: cn(ITEM_BASE, "items-center", ITEM_TONE[tone], className),
|
|
1810
|
-
...rest,
|
|
1811
|
-
children: [
|
|
1812
|
-
/* @__PURE__ */ jsx11("span", { "aria-hidden": true, className: "flex size-4 shrink-0 items-center justify-center", children: /* @__PURE__ */ jsx11(P.ItemIndicator, { children: /* @__PURE__ */ jsx11("span", { className: "block size-1.5 rounded-full bg-current" }) }) }),
|
|
1813
|
-
/* @__PURE__ */ jsx11("span", { className: "min-w-0 flex-1 truncate", children })
|
|
1814
|
-
]
|
|
1815
|
-
}
|
|
1816
|
-
);
|
|
1817
|
-
});
|
|
1818
|
-
const Group = forwardRef9(function MenuGroup({ children, label, className, ...rest }, ref) {
|
|
1819
|
-
const labelId = useId4();
|
|
1820
|
-
return /* @__PURE__ */ jsxs5(P.Group, { ref, "aria-labelledby": label ? labelId : void 0, className, ...rest, children: [
|
|
1821
|
-
label && /* @__PURE__ */ jsx11("div", { id: labelId, className: OVERLAY_HEADING, children: label }),
|
|
1822
|
-
children
|
|
1823
|
-
] });
|
|
1824
|
-
});
|
|
1825
|
-
const Label = forwardRef9(function MenuLabel({ className, ...rest }, ref) {
|
|
1826
|
-
return /* @__PURE__ */ jsx11(P.Label, { ref, className: cn(OVERLAY_HEADING, className), ...rest });
|
|
1827
|
-
});
|
|
1828
|
-
const Separator = forwardRef9(function MenuSeparator({ className, ...rest }, ref) {
|
|
1829
|
-
return /* @__PURE__ */ jsx11(P.Separator, { ref, className: cn(OVERLAY_SEPARATOR, className), ...rest });
|
|
1830
|
-
});
|
|
1831
|
-
const Shortcut = forwardRef9(function MenuShortcut({ className, ...rest }, ref) {
|
|
1832
|
-
return /* @__PURE__ */ jsx11("span", { ref, className: cn("ml-auto pl-4 text-body-tiny text-default-tertiary", className), ...rest });
|
|
1833
|
-
});
|
|
1834
|
-
function Sub({ children, open, defaultOpen, onOpenChange }) {
|
|
1835
|
-
return /* @__PURE__ */ jsx11(P.Sub, { open, defaultOpen, onOpenChange, children });
|
|
1836
|
-
}
|
|
1837
|
-
const SubTrigger = forwardRef9(function MenuSubTrigger({ children, icon, disabled = false, textValue, className, ...rest }, ref) {
|
|
1838
|
-
return /* @__PURE__ */ jsxs5(
|
|
1839
|
-
P.SubTrigger,
|
|
1840
|
-
{
|
|
1841
|
-
ref,
|
|
1842
|
-
disabled,
|
|
1843
|
-
textValue,
|
|
1844
|
-
className: cn(
|
|
1845
|
-
ITEM_BASE,
|
|
1846
|
-
"items-center",
|
|
1847
|
-
ITEM_TONE.default,
|
|
1848
|
-
"data-[state=open]:bg-default-secondary",
|
|
1849
|
-
className
|
|
1850
|
-
),
|
|
1851
|
-
...rest,
|
|
1852
|
-
children: [
|
|
1853
|
-
icon && /* @__PURE__ */ jsx11("span", { "aria-hidden": true, className: "flex size-4 shrink-0 items-center justify-center", children: icon }),
|
|
1854
|
-
/* @__PURE__ */ jsx11("span", { className: "min-w-0 flex-1 truncate", children }),
|
|
1855
|
-
/* @__PURE__ */ jsx11(ChevronRightIcon, { "aria-hidden": true, className: "ml-auto size-4 shrink-0 text-default-tertiary" })
|
|
1856
|
-
]
|
|
1857
|
-
}
|
|
1858
|
-
);
|
|
1859
|
-
});
|
|
1860
|
-
const SubContent = forwardRef9(function MenuSubContent({ className, onClick, onKeyDown, ...rest }, ref) {
|
|
1861
|
-
const container = usePortalContainer();
|
|
1862
|
-
return /* @__PURE__ */ jsx11(P.Portal, { container: container ?? void 0, children: /* @__PURE__ */ jsx11(
|
|
1863
|
-
P.SubContent,
|
|
1864
|
-
{
|
|
1865
|
-
ref,
|
|
1866
|
-
sideOffset: 4,
|
|
1867
|
-
collisionPadding: 8,
|
|
1868
|
-
className: cn(MENU_PANEL_CLASSES, className),
|
|
1869
|
-
onClick: (event) => {
|
|
1870
|
-
onClick?.(event);
|
|
1871
|
-
stopToAncestors(event);
|
|
1872
|
-
},
|
|
1873
|
-
onKeyDown: (event) => {
|
|
1874
|
-
onKeyDown?.(event);
|
|
1875
|
-
stopToAncestors(event);
|
|
1876
|
-
},
|
|
1877
|
-
...rest
|
|
1878
|
-
}
|
|
1879
|
-
) });
|
|
1880
|
-
});
|
|
1881
|
-
function Items({ items }) {
|
|
1882
|
-
return /* @__PURE__ */ jsx11(Fragment4, { children: visibleMenuItems(items).map(renderItem) });
|
|
1883
|
-
}
|
|
1884
|
-
function renderItem(item) {
|
|
1885
|
-
switch (item.type) {
|
|
1886
|
-
case "checkbox":
|
|
1887
|
-
return /* @__PURE__ */ jsx11(
|
|
1888
|
-
CheckboxItem,
|
|
1889
|
-
{
|
|
1890
|
-
checked: item.checked,
|
|
1891
|
-
onCheckedChange: item.onCheckedChange,
|
|
1892
|
-
disabled: item.disabled,
|
|
1893
|
-
shortcut: item.shortcut,
|
|
1894
|
-
textValue: item.textValue,
|
|
1895
|
-
children: item.label
|
|
1896
|
-
},
|
|
1897
|
-
item.id
|
|
1898
|
-
);
|
|
1899
|
-
case "radio":
|
|
1900
|
-
return /* @__PURE__ */ jsx11(RadioGroup, { value: item.value, onValueChange: item.onValueChange, children: item.options.map((option) => /* @__PURE__ */ jsx11(RadioItem, { value: option.value, disabled: option.disabled, children: option.label }, option.value)) }, item.id);
|
|
1901
|
-
case "group":
|
|
1902
|
-
return /* @__PURE__ */ jsx11(Group, { label: item.label, children: /* @__PURE__ */ jsx11(Items, { items: item.items }) }, item.id);
|
|
1903
|
-
case "submenu":
|
|
1904
|
-
return /* @__PURE__ */ jsxs5(Sub, { children: [
|
|
1905
|
-
/* @__PURE__ */ jsx11(SubTrigger, { icon: item.icon, disabled: item.disabled, children: item.label }),
|
|
1906
|
-
/* @__PURE__ */ jsx11(SubContent, { children: /* @__PURE__ */ jsx11(Items, { items: item.items }) })
|
|
1907
|
-
] }, item.id);
|
|
1908
|
-
case "label":
|
|
1909
|
-
return /* @__PURE__ */ jsx11(Label, { children: item.label }, item.id);
|
|
1910
|
-
case "separator":
|
|
1911
|
-
return /* @__PURE__ */ jsx11(Separator, {}, item.id);
|
|
1912
|
-
case "custom":
|
|
1913
|
-
return /* @__PURE__ */ jsx11(Fragment3, { children: item.render() }, item.id);
|
|
1914
|
-
default:
|
|
1915
|
-
return /* @__PURE__ */ jsx11(
|
|
1916
|
-
Item,
|
|
1917
|
-
{
|
|
1918
|
-
onSelect: item.onSelect,
|
|
1919
|
-
tone: item.tone,
|
|
1920
|
-
disabled: item.disabled,
|
|
1921
|
-
icon: item.icon,
|
|
1922
|
-
description: item.description,
|
|
1923
|
-
shortcut: item.shortcut,
|
|
1924
|
-
textValue: item.textValue,
|
|
1925
|
-
children: item.label
|
|
1926
|
-
},
|
|
1927
|
-
item.id
|
|
1928
|
-
);
|
|
1929
|
-
}
|
|
1930
|
-
}
|
|
1931
|
-
return {
|
|
1932
|
-
Items,
|
|
1933
|
-
Item,
|
|
1934
|
-
CheckboxItem,
|
|
1935
|
-
RadioGroup,
|
|
1936
|
-
RadioItem,
|
|
1937
|
-
Group,
|
|
1938
|
-
Label,
|
|
1939
|
-
Separator,
|
|
1940
|
-
Shortcut,
|
|
1941
|
-
Sub,
|
|
1942
|
-
SubTrigger,
|
|
1943
|
-
SubContent
|
|
1944
|
-
};
|
|
1945
|
-
}
|
|
1946
|
-
|
|
1947
|
-
// src/components/overlays/dropdown-menu.tsx
|
|
1948
|
-
import { Fragment as Fragment5, jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1949
|
-
var DropdownMenuStateContext = createContext4(null);
|
|
1950
|
-
function useDropdownMenuState(part) {
|
|
1951
|
-
const value = useContext4(DropdownMenuStateContext);
|
|
1952
|
-
if (!value) throw new Error(`<${part}> must be used inside <DropdownMenu>`);
|
|
1953
|
-
return value;
|
|
1954
|
-
}
|
|
1955
|
-
function DropdownMenu({
|
|
1956
|
-
children,
|
|
1957
|
-
items,
|
|
1958
|
-
trigger,
|
|
1959
|
-
label,
|
|
1960
|
-
side,
|
|
1961
|
-
align,
|
|
1962
|
-
open: openProp,
|
|
1963
|
-
defaultOpen = false,
|
|
1964
|
-
onOpenChange,
|
|
1965
|
-
modal = false
|
|
1966
|
-
}) {
|
|
1967
|
-
const [open, setOpen] = useControllableState({
|
|
1968
|
-
value: openProp,
|
|
1969
|
-
defaultValue: defaultOpen,
|
|
1970
|
-
onChange: onOpenChange
|
|
1971
|
-
});
|
|
1972
|
-
const pendingEdge = useRef8("start");
|
|
1973
|
-
const state = useMemo2(() => ({ setOpen, pendingEdge }), [setOpen]);
|
|
1974
|
-
return /* @__PURE__ */ jsx12(DropdownMenuPrimitive.Root, { open, onOpenChange: setOpen, modal, children: /* @__PURE__ */ jsx12(DropdownMenuStateContext.Provider, { value: state, children: items ? /* @__PURE__ */ jsxs6(Fragment5, { children: [
|
|
1975
|
-
/* @__PURE__ */ jsx12(DropdownMenuTrigger, { asChild: trigger != null, label, children: trigger }),
|
|
1976
|
-
/* @__PURE__ */ jsx12(DropdownMenuContent, { side, align, children: /* @__PURE__ */ jsx12(DropdownMenuItems, { items }) })
|
|
1977
|
-
] }) : children }) });
|
|
1978
|
-
}
|
|
1979
|
-
var DropdownMenuTrigger = forwardRef10(
|
|
1980
|
-
function DropdownMenuTrigger2({ children, asChild = false, label = "Open menu", onClick, onPointerDown, onMouseDown, onKeyDown, ...rest }, ref) {
|
|
1981
|
-
const state = useDropdownMenuState("DropdownMenuTrigger");
|
|
1982
|
-
const handlers = {
|
|
1983
|
-
onClick: (event) => {
|
|
1984
|
-
onClick?.(event);
|
|
1985
|
-
stopToAncestors(event);
|
|
1986
|
-
},
|
|
1987
|
-
onPointerDown: (event) => {
|
|
1988
|
-
onPointerDown?.(event);
|
|
1989
|
-
event.stopPropagation();
|
|
1990
|
-
},
|
|
1991
|
-
onMouseDown: (event) => {
|
|
1992
|
-
onMouseDown?.(event);
|
|
1993
|
-
stopToAncestors(event);
|
|
1994
|
-
},
|
|
1995
|
-
onKeyDown: (event) => {
|
|
1996
|
-
onKeyDown?.(event);
|
|
1997
|
-
if (event.defaultPrevented) return;
|
|
1998
|
-
if (event.key === "ArrowUp") {
|
|
1999
|
-
event.preventDefault();
|
|
2000
|
-
state.pendingEdge.current = "end";
|
|
2001
|
-
state.setOpen(true);
|
|
2002
|
-
}
|
|
2003
|
-
if (event.key === "Enter" || event.key === " ") stopToAncestors(event);
|
|
2004
|
-
}
|
|
2005
|
-
};
|
|
2006
|
-
if (asChild) {
|
|
2007
|
-
return /* @__PURE__ */ jsx12(DropdownMenuPrimitive.Trigger, { ref, asChild: true, ...rest, ...handlers, children });
|
|
2008
|
-
}
|
|
2009
|
-
return /* @__PURE__ */ jsx12(DropdownMenuPrimitive.Trigger, { ref, asChild: true, ...rest, ...handlers, children: /* @__PURE__ */ jsx12(IconButton, { variant: "neutral", size: "sm", "aria-label": label, children: children ?? /* @__PURE__ */ jsx12(EllipsisIcon, { className: "size-4", "aria-hidden": true }) }) });
|
|
2010
|
-
}
|
|
2011
|
-
);
|
|
2012
|
-
var DropdownMenuContent = forwardRef10(
|
|
2013
|
-
function DropdownMenuContent2({
|
|
2014
|
-
children,
|
|
2015
|
-
side = "bottom",
|
|
2016
|
-
align = "end",
|
|
2017
|
-
sideOffset = 6,
|
|
2018
|
-
container,
|
|
2019
|
-
className,
|
|
2020
|
-
onClick,
|
|
2021
|
-
onKeyDown,
|
|
2022
|
-
onFocus,
|
|
2023
|
-
onCloseAutoFocus,
|
|
2024
|
-
...rest
|
|
2025
|
-
}, ref) {
|
|
2026
|
-
const state = useDropdownMenuState("DropdownMenuContent");
|
|
2027
|
-
const inherited = usePortalContainer();
|
|
2028
|
-
return /* @__PURE__ */ jsx12(DropdownMenuPrimitive.Portal, { container: container ?? inherited ?? void 0, children: /* @__PURE__ */ jsx12(
|
|
2029
|
-
DropdownMenuPrimitive.Content,
|
|
2030
|
-
{
|
|
2031
|
-
ref,
|
|
2032
|
-
side,
|
|
2033
|
-
align,
|
|
2034
|
-
sideOffset,
|
|
2035
|
-
collisionPadding: 8,
|
|
2036
|
-
loop: true,
|
|
2037
|
-
className: cn(MENU_PANEL_CLASSES, className),
|
|
2038
|
-
onCloseAutoFocus: composeEventHandlers(onCloseAutoFocus, () => {
|
|
2039
|
-
state.pendingEdge.current = "start";
|
|
2040
|
-
}),
|
|
2041
|
-
onFocus: composeEventHandlers(onFocus, (event) => {
|
|
2042
|
-
const edge = state.pendingEdge.current;
|
|
2043
|
-
state.pendingEdge.current = "start";
|
|
2044
|
-
focusMenuEdge(event, edge);
|
|
2045
|
-
}),
|
|
2046
|
-
onClick: (event) => {
|
|
2047
|
-
onClick?.(event);
|
|
2048
|
-
stopToAncestors(event);
|
|
2049
|
-
},
|
|
2050
|
-
onKeyDown: (event) => {
|
|
2051
|
-
onKeyDown?.(event);
|
|
2052
|
-
stopToAncestors(event);
|
|
2053
|
-
if (event.key === "Tab") state.setOpen(false);
|
|
2054
|
-
},
|
|
2055
|
-
...rest,
|
|
2056
|
-
children
|
|
2057
|
-
}
|
|
2058
|
-
) });
|
|
2059
|
-
}
|
|
2060
|
-
);
|
|
2061
|
-
var parts = createMenuParts(DropdownMenuPrimitive);
|
|
2062
|
-
var DropdownMenuItems = parts.Items;
|
|
2063
|
-
var DropdownMenuItem = parts.Item;
|
|
2064
|
-
var DropdownMenuCheckboxItem = parts.CheckboxItem;
|
|
2065
|
-
var DropdownMenuRadioGroup = parts.RadioGroup;
|
|
2066
|
-
var DropdownMenuRadioItem = parts.RadioItem;
|
|
2067
|
-
var DropdownMenuGroup = parts.Group;
|
|
2068
|
-
var DropdownMenuLabel = parts.Label;
|
|
2069
|
-
var DropdownMenuSeparator = parts.Separator;
|
|
2070
|
-
var DropdownMenuShortcut = parts.Shortcut;
|
|
2071
|
-
var DropdownMenuSub = parts.Sub;
|
|
2072
|
-
var DropdownMenuSubTrigger = parts.SubTrigger;
|
|
2073
|
-
var DropdownMenuSubContent = parts.SubContent;
|
|
2074
|
-
|
|
2075
|
-
// src/components/chrome/pagination.tsx
|
|
2076
|
-
import { forwardRef as forwardRef11 } from "react";
|
|
2077
|
-
import clsx13 from "clsx";
|
|
2078
|
-
import { ChevronLeftIcon, ChevronRightIcon as ChevronRightIcon2 } from "lucide-react";
|
|
2079
|
-
import { Fragment as Fragment6, jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
2080
|
-
var GAP2 = "\u2026";
|
|
2081
|
-
function paginationRange(page, pageCount, siblingCount = 1) {
|
|
2082
|
-
const totalSlots = siblingCount * 2 + 5;
|
|
2083
|
-
if (pageCount <= totalSlots) {
|
|
2084
|
-
return Array.from({ length: pageCount }, (_, i) => i + 1);
|
|
2085
|
-
}
|
|
2086
|
-
const left = Math.max(page - siblingCount, 1);
|
|
2087
|
-
const right = Math.min(page + siblingCount, pageCount);
|
|
2088
|
-
const showLeftGap = left > 3;
|
|
2089
|
-
const showRightGap = right < pageCount - 2;
|
|
2090
|
-
if (!showLeftGap && showRightGap) {
|
|
2091
|
-
const count = siblingCount * 2 + 3;
|
|
2092
|
-
return [...Array.from({ length: count }, (_, i) => i + 1), GAP2, pageCount];
|
|
2093
|
-
}
|
|
2094
|
-
if (showLeftGap && !showRightGap) {
|
|
2095
|
-
const count = siblingCount * 2 + 3;
|
|
2096
|
-
return [1, GAP2, ...Array.from({ length: count }, (_, i) => pageCount - count + 1 + i)];
|
|
2097
|
-
}
|
|
2098
|
-
return [
|
|
2099
|
-
1,
|
|
2100
|
-
GAP2,
|
|
2101
|
-
...Array.from({ length: right - left + 1 }, (_, i) => left + i),
|
|
2102
|
-
GAP2,
|
|
2103
|
-
pageCount
|
|
2104
|
-
];
|
|
2105
|
-
}
|
|
2106
|
-
var ARROW_BASE = clsx13(
|
|
2107
|
-
"inline-flex size-9 shrink-0 items-center justify-center rounded-lg border transition-colors",
|
|
2108
|
-
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand focus-visible:ring-offset-1 focus-visible:ring-offset-default",
|
|
2109
|
-
"disabled:cursor-not-allowed disabled:border-disabled disabled:bg-disabled disabled:text-disabled",
|
|
2110
|
-
"border-default bg-default text-default hover:bg-default-secondary hover:text-brand"
|
|
2111
|
-
);
|
|
2112
|
-
var Pagination = forwardRef11(function Pagination2({
|
|
2113
|
-
page,
|
|
2114
|
-
pageCount,
|
|
2115
|
-
onPageChange,
|
|
2116
|
-
type = "default",
|
|
2117
|
-
siblingCount = 1,
|
|
2118
|
-
label = "Pagination",
|
|
2119
|
-
className,
|
|
2120
|
-
...rest
|
|
2121
|
-
}, ref) {
|
|
2122
|
-
if (pageCount < 1) return null;
|
|
2123
|
-
const go = (next) => {
|
|
2124
|
-
const clamped = Math.min(Math.max(next, 1), pageCount);
|
|
2125
|
-
if (clamped !== page) onPageChange(clamped);
|
|
2126
|
-
};
|
|
2127
|
-
return /* @__PURE__ */ jsxs7(
|
|
2128
|
-
"nav",
|
|
2129
|
-
{
|
|
2130
|
-
ref,
|
|
2131
|
-
"aria-label": label,
|
|
2132
|
-
"data-slot": "pagination",
|
|
2133
|
-
className: clsx13("flex items-center gap-1.5", className),
|
|
2134
|
-
...rest,
|
|
2135
|
-
children: [
|
|
2136
|
-
/* @__PURE__ */ jsx13(
|
|
2137
|
-
"button",
|
|
2138
|
-
{
|
|
2139
|
-
type: "button",
|
|
2140
|
-
"aria-label": "Previous page",
|
|
2141
|
-
disabled: page <= 1,
|
|
2142
|
-
onClick: () => go(page - 1),
|
|
2143
|
-
className: ARROW_BASE,
|
|
2144
|
-
children: /* @__PURE__ */ jsx13(ChevronLeftIcon, { "aria-hidden": true, className: "size-4" })
|
|
2145
|
-
}
|
|
2146
|
-
),
|
|
2147
|
-
type === "dots" ? (
|
|
2148
|
-
// The dots form has no room for numbers, so the list itself is the only place the
|
|
2149
|
-
// position can be stated — hence the live-region-free but explicitly named group.
|
|
2150
|
-
/* @__PURE__ */ jsx13(
|
|
2151
|
-
"span",
|
|
2152
|
-
{
|
|
2153
|
-
role: "group",
|
|
2154
|
-
"aria-label": `Page ${page} of ${pageCount}`,
|
|
2155
|
-
className: "flex items-center gap-2 px-2",
|
|
2156
|
-
children: Array.from({ length: pageCount }, (_, i) => i + 1).map((n) => /* @__PURE__ */ jsx13(
|
|
2157
|
-
"button",
|
|
2158
|
-
{
|
|
2159
|
-
type: "button",
|
|
2160
|
-
"aria-label": `Page ${n}`,
|
|
2161
|
-
"aria-current": n === page ? "page" : void 0,
|
|
2162
|
-
onClick: () => go(n),
|
|
2163
|
-
className: clsx13(
|
|
2164
|
-
"size-2 rounded-full transition-colors",
|
|
2165
|
-
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand focus-visible:ring-offset-2 focus-visible:ring-offset-default",
|
|
2166
|
-
n === page ? "bg-brand" : "bg-default-tertiary hover:bg-neutral-secondary"
|
|
2167
|
-
)
|
|
2168
|
-
},
|
|
2169
|
-
n
|
|
2170
|
-
))
|
|
2171
|
-
}
|
|
2172
|
-
)
|
|
2173
|
-
) : paginationRange(page, pageCount, siblingCount).map(
|
|
2174
|
-
(entry, index) => entry === GAP2 ? /* @__PURE__ */ jsx13(
|
|
2175
|
-
"span",
|
|
2176
|
-
{
|
|
2177
|
-
"aria-hidden": true,
|
|
2178
|
-
className: "inline-flex size-9 items-center justify-center text-body-sm text-default-tertiary",
|
|
2179
|
-
children: GAP2
|
|
2180
|
-
},
|
|
2181
|
-
`gap-${index}`
|
|
2182
|
-
) : /* @__PURE__ */ jsx13(
|
|
2183
|
-
"button",
|
|
2184
|
-
{
|
|
2185
|
-
type: "button",
|
|
2186
|
-
"aria-label": `Page ${entry}`,
|
|
2187
|
-
"aria-current": entry === page ? "page" : void 0,
|
|
2188
|
-
onClick: () => go(entry),
|
|
2189
|
-
className: clsx13(
|
|
2190
|
-
"inline-flex size-9 shrink-0 items-center justify-center rounded-lg border text-body-sm tabular-nums transition-colors",
|
|
2191
|
-
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand focus-visible:ring-offset-1 focus-visible:ring-offset-default",
|
|
2192
|
-
entry === page ? "border-brand bg-brand font-semibold text-brand-on-brand" : "border-default bg-default text-default hover:bg-default-secondary hover:text-brand"
|
|
2193
|
-
),
|
|
2194
|
-
children: entry
|
|
2195
|
-
},
|
|
2196
|
-
entry
|
|
2197
|
-
)
|
|
2198
|
-
),
|
|
2199
|
-
/* @__PURE__ */ jsx13(
|
|
2200
|
-
"button",
|
|
2201
|
-
{
|
|
2202
|
-
type: "button",
|
|
2203
|
-
"aria-label": "Next page",
|
|
2204
|
-
disabled: page >= pageCount,
|
|
2205
|
-
onClick: () => go(page + 1),
|
|
2206
|
-
className: ARROW_BASE,
|
|
2207
|
-
children: /* @__PURE__ */ jsx13(ChevronRightIcon2, { "aria-hidden": true, className: "size-4" })
|
|
2208
|
-
}
|
|
2209
|
-
)
|
|
2210
|
-
]
|
|
2211
|
-
}
|
|
2212
|
-
);
|
|
2213
|
-
});
|
|
2214
|
-
function PaginationBar({
|
|
2215
|
-
page,
|
|
2216
|
-
pageSize,
|
|
2217
|
-
total,
|
|
2218
|
-
onPageChange,
|
|
2219
|
-
onPageSizeChange,
|
|
2220
|
-
pageSizeOptions = [10, 20, 50],
|
|
2221
|
-
summary,
|
|
2222
|
-
label = "Pages",
|
|
2223
|
-
className
|
|
2224
|
-
}) {
|
|
2225
|
-
const pageCount = Math.max(1, Math.ceil(total / pageSize));
|
|
2226
|
-
const from = total === 0 ? 0 : (page - 1) * pageSize + 1;
|
|
2227
|
-
const to = Math.min(total, page * pageSize);
|
|
2228
|
-
const showSize = Boolean(onPageSizeChange) && pageSizeOptions.length > 0;
|
|
2229
|
-
const options = pageSizeOptions.includes(pageSize) ? pageSizeOptions : [...pageSizeOptions, pageSize].sort((a, b) => a - b);
|
|
2230
|
-
return /* @__PURE__ */ jsxs7(
|
|
2231
|
-
"div",
|
|
2232
|
-
{
|
|
2233
|
-
"data-slot": "pagination-bar",
|
|
2234
|
-
className: clsx13("flex flex-wrap items-center justify-between gap-x-4 gap-y-3", className),
|
|
2235
|
-
children: [
|
|
2236
|
-
/* @__PURE__ */ jsx13("p", { className: "text-body-xs text-default-secondary", children: summary ?? /* @__PURE__ */ jsxs7(Fragment6, { children: [
|
|
2237
|
-
"Showing ",
|
|
2238
|
-
from,
|
|
2239
|
-
"\u2013",
|
|
2240
|
-
to,
|
|
2241
|
-
" of ",
|
|
2242
|
-
total
|
|
2243
|
-
] }) }),
|
|
2244
|
-
/* @__PURE__ */ jsxs7("div", { className: "flex flex-wrap items-center gap-x-4 gap-y-3", children: [
|
|
2245
|
-
showSize && /* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-2", children: [
|
|
2246
|
-
/* @__PURE__ */ jsx13("span", { "aria-hidden": true, className: "text-body-xs text-default-secondary", children: "Rows per page" }),
|
|
2247
|
-
/* @__PURE__ */ jsx13(
|
|
2248
|
-
SelectControl,
|
|
2249
|
-
{
|
|
2250
|
-
"aria-label": "Rows per page",
|
|
2251
|
-
size: "md",
|
|
2252
|
-
className: "w-20",
|
|
2253
|
-
value: String(pageSize),
|
|
2254
|
-
options: options.map((size2) => ({ value: String(size2), label: String(size2) })),
|
|
2255
|
-
onValueChange: (value) => onPageSizeChange?.(Number(value))
|
|
2256
|
-
}
|
|
2257
|
-
)
|
|
2258
|
-
] }),
|
|
2259
|
-
/* @__PURE__ */ jsx13(Pagination, { page, pageCount, onPageChange, label })
|
|
2260
|
-
] })
|
|
2261
|
-
]
|
|
2262
|
-
}
|
|
2263
|
-
);
|
|
2264
|
-
}
|
|
2265
|
-
|
|
2266
|
-
// src/components/feedback/progress-bar.tsx
|
|
2267
|
-
import { useId as useId5 } from "react";
|
|
2268
|
-
import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2269
|
-
var SIZE2 = {
|
|
2270
|
-
xs: "h-1",
|
|
2271
|
-
sm: "h-1.5",
|
|
2272
|
-
md: "h-2",
|
|
2273
|
-
lg: "h-3"
|
|
2274
|
-
};
|
|
2275
|
-
var FILL = {
|
|
2276
|
-
brand: "bg-brand",
|
|
2277
|
-
positive: "bg-positive",
|
|
2278
|
-
warning: "bg-warning",
|
|
2279
|
-
danger: "bg-danger",
|
|
2280
|
-
neutral: "bg-neutral"
|
|
2281
|
-
};
|
|
2282
|
-
function ProgressBar({
|
|
2283
|
-
value,
|
|
2284
|
-
tone = "brand",
|
|
2285
|
-
size: size2 = "sm",
|
|
2286
|
-
label,
|
|
2287
|
-
showValue = false,
|
|
2288
|
-
radius,
|
|
2289
|
-
"aria-label": ariaLabel,
|
|
2290
|
-
segments,
|
|
2291
|
-
valueText,
|
|
2292
|
-
className
|
|
2293
|
-
}) {
|
|
2294
|
-
const clamped = Math.min(100, Math.max(0, value));
|
|
2295
|
-
const rounded = radius ? void 0 : "rounded-full";
|
|
2296
|
-
const labelId = useId5();
|
|
2297
|
-
const filledSegments = segments ? Math.round(clamped / 100 * segments) : 0;
|
|
2298
|
-
const track = segments ? /* @__PURE__ */ jsx14(
|
|
2299
|
-
"div",
|
|
2300
|
-
{
|
|
2301
|
-
role: "progressbar",
|
|
2302
|
-
"aria-valuenow": clamped,
|
|
2303
|
-
"aria-valuemin": 0,
|
|
2304
|
-
"aria-valuemax": 100,
|
|
2305
|
-
"aria-valuetext": valueText,
|
|
2306
|
-
"aria-labelledby": label ? labelId : void 0,
|
|
2307
|
-
"aria-label": label ? void 0 : ariaLabel,
|
|
2308
|
-
"data-tone": tone,
|
|
2309
|
-
className: cn("flex w-full gap-1", className),
|
|
2310
|
-
children: Array.from({ length: segments }, (_, index) => /* @__PURE__ */ jsx14(
|
|
2311
|
-
"span",
|
|
2312
|
-
{
|
|
2313
|
-
"data-filled": index < filledSegments || void 0,
|
|
2314
|
-
className: cn("flex-1 bg-default-tertiary transition-colors", SIZE2[size2], rounded, index < filledSegments && FILL[tone]),
|
|
2315
|
-
style: radius ? { borderRadius: radius } : void 0
|
|
2316
|
-
},
|
|
2317
|
-
index
|
|
2318
|
-
))
|
|
2319
|
-
}
|
|
2320
|
-
) : /* @__PURE__ */ jsx14(
|
|
2321
|
-
"div",
|
|
2322
|
-
{
|
|
2323
|
-
role: "progressbar",
|
|
2324
|
-
"aria-valuenow": clamped,
|
|
2325
|
-
"aria-valuemin": 0,
|
|
2326
|
-
"aria-valuemax": 100,
|
|
2327
|
-
"aria-valuetext": valueText,
|
|
2328
|
-
"data-tone": tone,
|
|
2329
|
-
"aria-labelledby": label ? labelId : void 0,
|
|
2330
|
-
"aria-label": label ? void 0 : ariaLabel,
|
|
2331
|
-
className: cn("w-full overflow-hidden bg-default-tertiary", SIZE2[size2], rounded, className),
|
|
2332
|
-
style: radius ? { borderRadius: radius } : void 0,
|
|
2333
|
-
children: /* @__PURE__ */ jsx14(
|
|
2334
|
-
"div",
|
|
2335
|
-
{
|
|
2336
|
-
className: cn("h-full transition-all motion-reduce:transition-none", rounded, FILL[tone]),
|
|
2337
|
-
style: { width: `${clamped}%`, ...radius ? { borderRadius: radius } : void 0 }
|
|
2338
|
-
}
|
|
2339
|
-
)
|
|
2340
|
-
}
|
|
2341
|
-
);
|
|
2342
|
-
if (!label && !showValue) return track;
|
|
2343
|
-
return /* @__PURE__ */ jsxs8("div", { children: [
|
|
2344
|
-
/* @__PURE__ */ jsxs8("div", { className: "mb-1.5 flex items-center justify-between gap-2", children: [
|
|
2345
|
-
label && /* @__PURE__ */ jsx14("span", { id: labelId, className: "text-body-xs text-default-secondary", children: label }),
|
|
2346
|
-
showValue && /* @__PURE__ */ jsxs8("span", { className: "ml-auto text-body-xs font-medium tabular-nums text-default", children: [
|
|
2347
|
-
Math.round(clamped),
|
|
2348
|
-
"%"
|
|
2349
|
-
] })
|
|
2350
|
-
] }),
|
|
2351
|
-
track
|
|
2352
|
-
] });
|
|
2353
|
-
}
|
|
2354
|
-
|
|
2355
|
-
// src/components/lists/table.tsx
|
|
2356
|
-
import { forwardRef as forwardRef12 } from "react";
|
|
2357
|
-
import clsx14 from "clsx";
|
|
2358
|
-
import { ChevronDownIcon as ChevronDownIcon2, ChevronsUpDownIcon, ChevronUpIcon } from "lucide-react";
|
|
2359
|
-
import { jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2360
|
-
var Table = forwardRef12(function Table2({ label, density = "default", fixed = false, maxHeight, className, children, ...rest }, ref) {
|
|
2361
|
-
return (
|
|
2362
|
-
// The scroll container is separate from the table so the header stays inside the
|
|
2363
|
-
// scrolling region — a table that is its own scroll container cannot have a sticky
|
|
2364
|
-
// header.
|
|
2365
|
-
// The scroll wrapper is required for a <table>, which cannot itself scroll, so this
|
|
2366
|
-
// takes the scrollbar styling rather than ScrollArea.
|
|
2367
|
-
/* @__PURE__ */ jsx15(
|
|
2368
|
-
"div",
|
|
2369
|
-
{
|
|
2370
|
-
className: clsx14(
|
|
2371
|
-
"w-full",
|
|
2372
|
-
maxHeight ? clsx14("overflow-auto overscroll-contain", FOCUS_RING_INSET) : "overflow-x-auto",
|
|
2373
|
-
SCROLLBAR_CLASSES
|
|
2374
|
-
),
|
|
2375
|
-
style: maxHeight ? { maxHeight } : void 0,
|
|
2376
|
-
...maxHeight ? { role: "region", tabIndex: 0, "aria-label": label ? `${label} (scrolls)` : "Table (scrolls)" } : {},
|
|
2377
|
-
children: /* @__PURE__ */ jsx15(
|
|
2378
|
-
"table",
|
|
2379
|
-
{
|
|
2380
|
-
ref,
|
|
2381
|
-
"aria-label": label,
|
|
2382
|
-
"data-slot": "table",
|
|
2383
|
-
"data-density": density,
|
|
2384
|
-
className: cn("w-full border-collapse", fixed && "table-fixed", className),
|
|
2385
|
-
...rest,
|
|
2386
|
-
children
|
|
2387
|
-
}
|
|
2388
|
-
)
|
|
2389
|
-
}
|
|
2390
|
-
)
|
|
2391
|
-
);
|
|
2392
|
-
});
|
|
2393
|
-
var TableCaption = forwardRef12(
|
|
2394
|
-
function TableCaption2({ className, ...rest }, ref) {
|
|
2395
|
-
return /* @__PURE__ */ jsx15(
|
|
2396
|
-
"caption",
|
|
2397
|
-
{
|
|
2398
|
-
ref,
|
|
2399
|
-
className: cn("px-4 py-3 text-left text-body-sm text-default-secondary", className),
|
|
2400
|
-
...rest
|
|
2401
|
-
}
|
|
2402
|
-
);
|
|
2403
|
-
}
|
|
2404
|
-
);
|
|
2405
|
-
var TableHeader = forwardRef12(
|
|
2406
|
-
function TableHeader2({ className, ...rest }, ref) {
|
|
2407
|
-
return /* @__PURE__ */ jsx15("thead", { ref, className: cn("border-b border-default", className), ...rest });
|
|
2408
|
-
}
|
|
2409
|
-
);
|
|
2410
|
-
var TableBody = forwardRef12(
|
|
2411
|
-
function TableBody2({ className, ...rest }, ref) {
|
|
2412
|
-
return /* @__PURE__ */ jsx15("tbody", { ref, className, ...rest });
|
|
2413
|
-
}
|
|
2414
|
-
);
|
|
2415
|
-
var TableFooter = forwardRef12(
|
|
2416
|
-
function TableFooter2({ className, ...rest }, ref) {
|
|
2417
|
-
return /* @__PURE__ */ jsx15(
|
|
2418
|
-
"tfoot",
|
|
2419
|
-
{
|
|
2420
|
-
ref,
|
|
2421
|
-
className: cn("border-t border-default bg-default-secondary font-medium", className),
|
|
2422
|
-
...rest
|
|
2423
|
-
}
|
|
2424
|
-
);
|
|
2425
|
-
}
|
|
2426
|
-
);
|
|
2427
|
-
var ROW_TONE = clsx14(
|
|
2428
|
-
"data-[tone=muted]:bg-default-secondary",
|
|
2429
|
-
"data-[tone=brand]:bg-brand-tertiary",
|
|
2430
|
-
"data-[tone=positive]:bg-positive-tertiary",
|
|
2431
|
-
"data-[tone=warning]:bg-warning-tertiary",
|
|
2432
|
-
"data-[tone=danger]:bg-danger-tertiary"
|
|
2433
|
-
);
|
|
2434
|
-
var TableRow = forwardRef12(function TableRow2({ selected, tone = "default", dimmed = false, className, ...rest }, ref) {
|
|
2435
|
-
return /* @__PURE__ */ jsx15(
|
|
2436
|
-
"tr",
|
|
2437
|
-
{
|
|
2438
|
-
ref,
|
|
2439
|
-
"aria-selected": selected,
|
|
2440
|
-
"data-state": selected ? "selected" : void 0,
|
|
2441
|
-
"data-tone": tone === "default" ? void 0 : tone,
|
|
2442
|
-
"data-dimmed": dimmed || void 0,
|
|
2443
|
-
className: cn(
|
|
2444
|
-
"border-b border-default last:border-b-0 transition-colors",
|
|
2445
|
-
"hover:bg-default-secondary/50",
|
|
2446
|
-
ROW_TONE,
|
|
2447
|
-
"data-[dimmed]:opacity-60",
|
|
2448
|
-
"data-[state=selected]:bg-brand-tertiary",
|
|
2449
|
-
className
|
|
2450
|
-
),
|
|
2451
|
-
...rest
|
|
2452
|
-
}
|
|
2453
|
-
);
|
|
2454
|
-
});
|
|
2455
|
-
var ALIGN = { left: "text-left", center: "text-center", right: "text-right" };
|
|
2456
|
-
var TableHead = forwardRef12(function TableHead2({ sort, onSort, align = "left", sticky = false, className, children, ...rest }, ref) {
|
|
2457
|
-
const sortable = sort !== void 0 && onSort !== void 0;
|
|
2458
|
-
return /* @__PURE__ */ jsx15(
|
|
2459
|
-
"th",
|
|
2460
|
-
{
|
|
2461
|
-
ref,
|
|
2462
|
-
scope: "col",
|
|
2463
|
-
"aria-sort": sort === void 0 ? void 0 : sort === false ? "none" : sort,
|
|
2464
|
-
className: cn(
|
|
2465
|
-
"px-4 py-3 text-body-xs font-semibold text-default-secondary",
|
|
2466
|
-
ALIGN[align],
|
|
2467
|
-
sticky && "sticky top-0 z-raised bg-default",
|
|
2468
|
-
className
|
|
2469
|
-
),
|
|
2470
|
-
...rest,
|
|
2471
|
-
children: sortable ? /* @__PURE__ */ jsxs9(
|
|
2472
|
-
"button",
|
|
2473
|
-
{
|
|
2474
|
-
type: "button",
|
|
2475
|
-
onClick: onSort,
|
|
2476
|
-
className: clsx14(
|
|
2477
|
-
"inline-flex items-center gap-1.5 rounded transition-colors hover:text-default",
|
|
2478
|
-
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand focus-visible:ring-offset-1 focus-visible:ring-offset-default"
|
|
2479
|
-
),
|
|
2480
|
-
children: [
|
|
2481
|
-
children,
|
|
2482
|
-
sort === false ? /* @__PURE__ */ jsx15(ChevronsUpDownIcon, { "aria-hidden": true, className: "size-3.5 opacity-50" }) : sort === "ascending" ? /* @__PURE__ */ jsx15(ChevronUpIcon, { "aria-hidden": true, className: "size-3.5" }) : /* @__PURE__ */ jsx15(ChevronDownIcon2, { "aria-hidden": true, className: "size-3.5" })
|
|
2483
|
-
]
|
|
2484
|
-
}
|
|
2485
|
-
) : children
|
|
2486
|
-
}
|
|
2487
|
-
);
|
|
2488
|
-
});
|
|
2489
|
-
var TableCell = forwardRef12(function TableCell2({ align = "left", density = "default", header = false, className, ...rest }, ref) {
|
|
2490
|
-
const Tag = header ? "th" : "td";
|
|
2491
|
-
return /* @__PURE__ */ jsx15(
|
|
2492
|
-
Tag,
|
|
2493
|
-
{
|
|
2494
|
-
ref,
|
|
2495
|
-
scope: header ? "row" : void 0,
|
|
2496
|
-
className: cn(
|
|
2497
|
-
density === "compact" ? "px-4 py-2" : "px-4 py-3",
|
|
2498
|
-
"text-body-sm text-default",
|
|
2499
|
-
header && "font-medium",
|
|
2500
|
-
ALIGN[align],
|
|
2501
|
-
className
|
|
2502
|
-
),
|
|
2503
|
-
...rest
|
|
2504
|
-
}
|
|
2505
|
-
);
|
|
2506
|
-
});
|
|
2507
|
-
|
|
2508
|
-
// src/components/lists/data-table-cells.tsx
|
|
2509
|
-
import clsx15 from "clsx";
|
|
2510
|
-
import { jsx as jsx16, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2511
|
-
function textFromNode(node) {
|
|
2512
|
-
if (typeof node === "string") return node;
|
|
2513
|
-
if (typeof node === "number") return String(node);
|
|
2514
|
-
if (Array.isArray(node)) {
|
|
2515
|
-
const parts2 = node.map(textFromNode);
|
|
2516
|
-
return parts2.every((part) => part !== void 0) ? parts2.join("") : void 0;
|
|
2517
|
-
}
|
|
2518
|
-
return void 0;
|
|
2519
|
-
}
|
|
2520
|
-
function TableCellLeadText({ primary, secondary, size: size2 = "md", className }) {
|
|
2521
|
-
return /* @__PURE__ */ jsxs10("div", { className: clsx15("flex min-w-0 flex-col gap-0.5", className), children: [
|
|
2522
|
-
/* @__PURE__ */ jsx16(
|
|
2523
|
-
"span",
|
|
2524
|
-
{
|
|
2525
|
-
title: primary,
|
|
2526
|
-
className: clsx15(
|
|
2527
|
-
"block truncate font-medium leading-snug text-default",
|
|
2528
|
-
size2 === "sm" ? "text-body-xs" : "text-body-sm"
|
|
2529
|
-
),
|
|
2530
|
-
children: primary
|
|
2531
|
-
}
|
|
2532
|
-
),
|
|
2533
|
-
secondary && (typeof secondary === "string" || typeof secondary === "number" ? /* @__PURE__ */ jsx16(
|
|
2534
|
-
"span",
|
|
2535
|
-
{
|
|
2536
|
-
title: String(secondary),
|
|
2537
|
-
className: clsx15(
|
|
2538
|
-
"block truncate font-normal leading-tight text-default-secondary",
|
|
2539
|
-
size2 === "sm" ? "text-body-tiny" : "text-body-xs"
|
|
2540
|
-
),
|
|
2541
|
-
children: secondary
|
|
2542
|
-
}
|
|
2543
|
-
) : (
|
|
2544
|
-
// An element brings its own overflow handling, so it gets no `truncate` here,
|
|
2545
|
-
// which a card layout's touch un-truncation would otherwise turn into wrapping.
|
|
2546
|
-
/* @__PURE__ */ jsx16(
|
|
2547
|
-
"span",
|
|
2548
|
-
{
|
|
2549
|
-
className: clsx15(
|
|
2550
|
-
"block min-w-0 font-normal leading-tight text-default-secondary",
|
|
2551
|
-
size2 === "sm" ? "text-body-tiny" : "text-body-xs"
|
|
2552
|
-
),
|
|
2553
|
-
children: secondary
|
|
2554
|
-
}
|
|
2555
|
-
)
|
|
2556
|
-
))
|
|
2557
|
-
] });
|
|
2558
|
-
}
|
|
2559
|
-
function TableCellText({
|
|
2560
|
-
children,
|
|
2561
|
-
muted = true,
|
|
2562
|
-
size: size2 = "md",
|
|
2563
|
-
truncate = true,
|
|
2564
|
-
className
|
|
2565
|
-
}) {
|
|
2566
|
-
return /* @__PURE__ */ jsx16(
|
|
2567
|
-
"span",
|
|
2568
|
-
{
|
|
2569
|
-
title: truncate ? textFromNode(children) : void 0,
|
|
2570
|
-
className: clsx15(
|
|
2571
|
-
"font-normal leading-snug",
|
|
2572
|
-
size2 === "sm" ? "text-body-tiny" : "text-body-xs",
|
|
2573
|
-
truncate ? "block min-w-0 truncate" : "whitespace-nowrap",
|
|
2574
|
-
muted ? "text-default-secondary" : "text-default",
|
|
2575
|
-
className
|
|
2576
|
-
),
|
|
2577
|
-
children
|
|
2578
|
-
}
|
|
2579
|
-
);
|
|
2580
|
-
}
|
|
2581
|
-
function TableCellBadge({ label, className }) {
|
|
2582
|
-
return /* @__PURE__ */ jsx16(
|
|
2583
|
-
"span",
|
|
2584
|
-
{
|
|
2585
|
-
title: label,
|
|
2586
|
-
className: clsx15(
|
|
2587
|
-
"inline-flex max-w-full items-center rounded-md border border-default bg-default-secondary px-2 py-0.5 text-body-tiny font-medium text-default-secondary",
|
|
2588
|
-
className
|
|
2589
|
-
),
|
|
2590
|
-
children: /* @__PURE__ */ jsx16("span", { className: "truncate", children: label })
|
|
2591
|
-
}
|
|
2592
|
-
);
|
|
2593
|
-
}
|
|
2594
|
-
function TableCellProgress({
|
|
2595
|
-
percent,
|
|
2596
|
-
tone = "brand",
|
|
2597
|
-
size: size2 = "md",
|
|
2598
|
-
label,
|
|
2599
|
-
className
|
|
2600
|
-
}) {
|
|
2601
|
-
const clamped = Math.round(Math.min(100, Math.max(0, percent)));
|
|
2602
|
-
return /* @__PURE__ */ jsxs10("div", { className: clsx15("flex w-full min-w-0 items-center gap-2", className), children: [
|
|
2603
|
-
/* @__PURE__ */ jsx16(
|
|
2604
|
-
ProgressBar,
|
|
2605
|
-
{
|
|
2606
|
-
value: clamped,
|
|
2607
|
-
tone,
|
|
2608
|
-
size: size2 === "sm" ? "xs" : "sm",
|
|
2609
|
-
className: "min-w-12 flex-1",
|
|
2610
|
-
"aria-label": label ?? `${clamped}%`
|
|
2611
|
-
}
|
|
2612
|
-
),
|
|
2613
|
-
/* @__PURE__ */ jsxs10("span", { className: "shrink-0 text-body-tiny leading-none tabular-nums text-default-secondary", children: [
|
|
2614
|
-
clamped,
|
|
2615
|
-
"%"
|
|
2616
|
-
] })
|
|
2617
|
-
] });
|
|
2618
|
-
}
|
|
2619
|
-
|
|
2620
|
-
// src/components/feedback/empty-state.tsx
|
|
2621
|
-
import clsx16 from "clsx";
|
|
2622
|
-
import { jsx as jsx17, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
2623
|
-
var SIZES = {
|
|
2624
|
-
sm: "py-8",
|
|
2625
|
-
md: "py-12",
|
|
2626
|
-
lg: "py-16"
|
|
2627
|
-
};
|
|
2628
|
-
var TONES = {
|
|
2629
|
-
empty: "text-default-secondary",
|
|
2630
|
-
loading: "text-default-secondary",
|
|
2631
|
-
error: "text-danger"
|
|
2632
|
-
};
|
|
2633
|
-
function EmptyState({
|
|
2634
|
-
message,
|
|
2635
|
-
variant = "empty",
|
|
2636
|
-
size: size2 = "sm",
|
|
2637
|
-
icon,
|
|
2638
|
-
action,
|
|
2639
|
-
className
|
|
2640
|
-
}) {
|
|
2641
|
-
return /* @__PURE__ */ jsxs11(
|
|
2642
|
-
"div",
|
|
2643
|
-
{
|
|
2644
|
-
"data-variant": variant,
|
|
2645
|
-
className: clsx16(
|
|
2646
|
-
"flex flex-col items-center justify-center gap-2 px-4 text-center text-body-sm",
|
|
2647
|
-
SIZES[size2],
|
|
2648
|
-
TONES[variant],
|
|
2649
|
-
className
|
|
2650
|
-
),
|
|
2651
|
-
"aria-live": variant === "empty" ? void 0 : "polite",
|
|
2652
|
-
children: [
|
|
2653
|
-
icon && /* @__PURE__ */ jsx17("span", { className: "text-default-tertiary", children: icon }),
|
|
2654
|
-
/* @__PURE__ */ jsx17("p", { children: message }),
|
|
2655
|
-
action
|
|
2656
|
-
]
|
|
2657
|
-
}
|
|
2658
|
-
);
|
|
2659
|
-
}
|
|
2660
|
-
|
|
2661
|
-
// src/components/feedback/skeleton.tsx
|
|
2662
|
-
import { forwardRef as forwardRef13 } from "react";
|
|
2663
|
-
import clsx17 from "clsx";
|
|
2664
|
-
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
2665
|
-
var SHAPE = {
|
|
2666
|
-
line: "h-4 rounded",
|
|
2667
|
-
block: "h-full w-full rounded-lg",
|
|
2668
|
-
circle: "aspect-square rounded-full"
|
|
2669
|
-
};
|
|
2670
|
-
var Skeleton = forwardRef13(function Skeleton2({ shape = "line", lines = 1, className, ...rest }, ref) {
|
|
2671
|
-
if (shape === "line" && lines > 1) {
|
|
2672
|
-
return /* @__PURE__ */ jsx18("div", { ref, "aria-hidden": true, "data-slot": "skeleton-group", className: "flex flex-col gap-2", ...rest, children: Array.from({ length: lines }, (_, index) => /* @__PURE__ */ jsx18(
|
|
2673
|
-
"div",
|
|
2674
|
-
{
|
|
2675
|
-
className: clsx17(
|
|
2676
|
-
"motion-safe:animate-pulse bg-default-tertiary",
|
|
2677
|
-
SHAPE.line,
|
|
2678
|
-
// A ragged last line reads as a paragraph rather than a solid slab.
|
|
2679
|
-
index === lines - 1 ? "w-3/5" : "w-full",
|
|
2680
|
-
className
|
|
2681
|
-
)
|
|
2682
|
-
},
|
|
2683
|
-
index
|
|
2684
|
-
)) });
|
|
2685
|
-
}
|
|
2686
|
-
return /* @__PURE__ */ jsx18(
|
|
2687
|
-
"div",
|
|
2688
|
-
{
|
|
2689
|
-
ref,
|
|
2690
|
-
"aria-hidden": true,
|
|
2691
|
-
"data-slot": "skeleton",
|
|
2692
|
-
className: clsx17("motion-safe:animate-pulse bg-default-tertiary", SHAPE[shape], className),
|
|
2693
|
-
...rest
|
|
2694
|
-
}
|
|
2695
|
-
);
|
|
2696
|
-
});
|
|
2697
|
-
|
|
2698
|
-
export {
|
|
2699
|
-
cn,
|
|
2700
|
-
FOCUS_RING,
|
|
2701
|
-
FOCUS_RING_INSET,
|
|
2702
|
-
Slot,
|
|
2703
|
-
composeRefs,
|
|
2704
|
-
Spinner,
|
|
2705
|
-
ControlSizeProvider,
|
|
2706
|
-
useControlSize,
|
|
2707
|
-
Button,
|
|
2708
|
-
IconButton,
|
|
2709
|
-
useFieldContext,
|
|
2710
|
-
useFieldControl,
|
|
2711
|
-
Field,
|
|
2712
|
-
FieldLabel,
|
|
2713
|
-
FieldDescription,
|
|
2714
|
-
FieldError,
|
|
2715
|
-
FieldHint,
|
|
2716
|
-
FieldGroup,
|
|
2717
|
-
FieldSet,
|
|
2718
|
-
FieldLegend,
|
|
2719
|
-
FieldSeparator,
|
|
2720
|
-
devWarn,
|
|
2721
|
-
useControllableState,
|
|
2722
|
-
useRovingFocus,
|
|
2723
|
-
useFloatingPanel,
|
|
2724
|
-
SCROLLBAR_CLASSES,
|
|
2725
|
-
OVERLAY_PANEL,
|
|
2726
|
-
OVERLAY_PANEL_SCROLL,
|
|
2727
|
-
OVERLAY_ITEM_BASE,
|
|
2728
|
-
OVERLAY_ITEM_SIZE,
|
|
2729
|
-
overlayItemTone,
|
|
2730
|
-
OVERLAY_ITEM_ACTIVE,
|
|
2731
|
-
OVERLAY_HEADING,
|
|
2732
|
-
deferEscapeToInnerPopup,
|
|
2733
|
-
OVERLAY_SCRIM,
|
|
2734
|
-
useOverlayDismiss,
|
|
2735
|
-
PortalContainerProvider,
|
|
2736
|
-
usePortalContainer,
|
|
2737
|
-
Portal,
|
|
2738
|
-
Select,
|
|
2739
|
-
SelectControl,
|
|
2740
|
-
useElementWidth,
|
|
2741
|
-
composeEventHandlers,
|
|
2742
|
-
CheckControl,
|
|
2743
|
-
Checkbox,
|
|
2744
|
-
InputGroup,
|
|
2745
|
-
InputGroupInput,
|
|
2746
|
-
InputGroupAddon,
|
|
2747
|
-
InputGroupText,
|
|
2748
|
-
SearchInput,
|
|
2749
|
-
MENU_PANEL_CLASSES,
|
|
2750
|
-
stopToAncestors,
|
|
2751
|
-
focusMenuEdge,
|
|
2752
|
-
createMenuParts,
|
|
2753
|
-
DropdownMenu,
|
|
2754
|
-
DropdownMenuTrigger,
|
|
2755
|
-
DropdownMenuContent,
|
|
2756
|
-
DropdownMenuItems,
|
|
2757
|
-
DropdownMenuItem,
|
|
2758
|
-
DropdownMenuCheckboxItem,
|
|
2759
|
-
DropdownMenuRadioGroup,
|
|
2760
|
-
DropdownMenuRadioItem,
|
|
2761
|
-
DropdownMenuGroup,
|
|
2762
|
-
DropdownMenuLabel,
|
|
2763
|
-
DropdownMenuSeparator,
|
|
2764
|
-
DropdownMenuShortcut,
|
|
2765
|
-
DropdownMenuSub,
|
|
2766
|
-
DropdownMenuSubTrigger,
|
|
2767
|
-
DropdownMenuSubContent,
|
|
2768
|
-
paginationRange,
|
|
2769
|
-
Pagination,
|
|
2770
|
-
PaginationBar,
|
|
2771
|
-
ProgressBar,
|
|
2772
|
-
Table,
|
|
2773
|
-
TableCaption,
|
|
2774
|
-
TableHeader,
|
|
2775
|
-
TableBody,
|
|
2776
|
-
TableFooter,
|
|
2777
|
-
TableRow,
|
|
2778
|
-
TableHead,
|
|
2779
|
-
TableCell,
|
|
2780
|
-
TableCellLeadText,
|
|
2781
|
-
TableCellText,
|
|
2782
|
-
TableCellBadge,
|
|
2783
|
-
TableCellProgress,
|
|
2784
|
-
EmptyState,
|
|
2785
|
-
Skeleton
|
|
2786
|
-
};
|
|
2787
|
-
//# sourceMappingURL=chunk-OVIRTNT4.js.map
|