@kjaniec-dev/ui 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +268 -91
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +267 -90
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var clsx = require('clsx');
|
|
4
4
|
var tailwindMerge = require('tailwind-merge');
|
|
5
|
-
var
|
|
5
|
+
var React17 = require('react');
|
|
6
6
|
var classVarianceAuthority = require('class-variance-authority');
|
|
7
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
8
|
|
|
@@ -24,8 +24,9 @@ function _interopNamespace(e) {
|
|
|
24
24
|
return Object.freeze(n);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
var
|
|
27
|
+
var React17__namespace = /*#__PURE__*/_interopNamespace(React17);
|
|
28
28
|
|
|
29
|
+
// src/lib/cn.ts
|
|
29
30
|
function cn(...inputs) {
|
|
30
31
|
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
31
32
|
}
|
|
@@ -59,7 +60,7 @@ var buttonVariants = classVarianceAuthority.cva(
|
|
|
59
60
|
defaultVariants: { variant: "primary", size: "md" }
|
|
60
61
|
}
|
|
61
62
|
);
|
|
62
|
-
var Button =
|
|
63
|
+
var Button = React17__namespace.forwardRef(
|
|
63
64
|
({ className, variant, size, loading, leadingIcon, trailingIcon, children, disabled, ...props }, ref) => {
|
|
64
65
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
65
66
|
"button",
|
|
@@ -106,7 +107,7 @@ var badgeVariants = classVarianceAuthority.cva(
|
|
|
106
107
|
defaultVariants: { variant: "neutral" }
|
|
107
108
|
}
|
|
108
109
|
);
|
|
109
|
-
var Badge =
|
|
110
|
+
var Badge = React17__namespace.forwardRef(
|
|
110
111
|
({ className, variant, dot, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs("span", { ref, className: cn(badgeVariants({ variant }), className), ...props, children: [
|
|
111
112
|
dot && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "h-1.5 w-1.5 rounded-full bg-current", "aria-hidden": true }),
|
|
112
113
|
children
|
|
@@ -133,7 +134,7 @@ var iconColor = {
|
|
|
133
134
|
warning: "text-warning",
|
|
134
135
|
danger: "text-danger"
|
|
135
136
|
};
|
|
136
|
-
var Alert =
|
|
137
|
+
var Alert = React17__namespace.forwardRef(
|
|
137
138
|
({ className, variant = "info", icon, title, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, role: "alert", className: cn(alertVariants({ variant }), className), ...props, children: [
|
|
138
139
|
icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("shrink-0 mt-0.5 [&_svg]:h-[1.15rem] [&_svg]:w-[1.15rem]", iconColor[variant ?? "info"]), children: icon }),
|
|
139
140
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-foreground", children: [
|
|
@@ -143,7 +144,7 @@ var Alert = React16__namespace.forwardRef(
|
|
|
143
144
|
] })
|
|
144
145
|
);
|
|
145
146
|
Alert.displayName = "Alert";
|
|
146
|
-
var Spinner =
|
|
147
|
+
var Spinner = React17__namespace.forwardRef(
|
|
147
148
|
({ className, size = 24, style, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
148
149
|
"span",
|
|
149
150
|
{
|
|
@@ -160,7 +161,7 @@ var Spinner = React16__namespace.forwardRef(
|
|
|
160
161
|
)
|
|
161
162
|
);
|
|
162
163
|
Spinner.displayName = "Spinner";
|
|
163
|
-
var Progress =
|
|
164
|
+
var Progress = React17__namespace.forwardRef(
|
|
164
165
|
({ className, value = 0, tone = "primary", barClassName, ...props }, ref) => {
|
|
165
166
|
const pct = Math.max(0, Math.min(100, value));
|
|
166
167
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -168,6 +169,7 @@ var Progress = React16__namespace.forwardRef(
|
|
|
168
169
|
{
|
|
169
170
|
ref,
|
|
170
171
|
role: "progressbar",
|
|
172
|
+
"aria-label": props["aria-label"] ?? "Progress",
|
|
171
173
|
"aria-valuenow": pct,
|
|
172
174
|
"aria-valuemin": 0,
|
|
173
175
|
"aria-valuemax": 100,
|
|
@@ -190,7 +192,7 @@ var Progress = React16__namespace.forwardRef(
|
|
|
190
192
|
);
|
|
191
193
|
Progress.displayName = "Progress";
|
|
192
194
|
var baseField = "w-full font-sans text-sm text-foreground bg-surface border rounded-kj-md px-[0.85rem] transition-[border-color,box-shadow] duration-150 placeholder:text-muted-foreground focus:outline-none focus:border-ring focus:ring-[3px] focus:ring-ring/30 disabled:bg-muted disabled:text-muted-foreground disabled:cursor-not-allowed";
|
|
193
|
-
var Input =
|
|
195
|
+
var Input = React17__namespace.forwardRef(
|
|
194
196
|
({ className, error, leadingIcon, style, ...props }, ref) => {
|
|
195
197
|
const field = /* @__PURE__ */ jsxRuntime.jsx(
|
|
196
198
|
"input",
|
|
@@ -215,7 +217,7 @@ var Input = React16__namespace.forwardRef(
|
|
|
215
217
|
}
|
|
216
218
|
);
|
|
217
219
|
Input.displayName = "Input";
|
|
218
|
-
var Textarea =
|
|
220
|
+
var Textarea = React17__namespace.forwardRef(
|
|
219
221
|
({ className, error, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
220
222
|
"textarea",
|
|
221
223
|
{
|
|
@@ -232,14 +234,14 @@ var Textarea = React16__namespace.forwardRef(
|
|
|
232
234
|
)
|
|
233
235
|
);
|
|
234
236
|
Textarea.displayName = "Textarea";
|
|
235
|
-
var Label =
|
|
237
|
+
var Label = React17__namespace.forwardRef(
|
|
236
238
|
({ className, required, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs("label", { ref, className: cn("text-[0.8rem] font-semibold text-foreground", className), ...props, children: [
|
|
237
239
|
children,
|
|
238
240
|
required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-danger", children: " *" })
|
|
239
241
|
] })
|
|
240
242
|
);
|
|
241
243
|
Label.displayName = "Label";
|
|
242
|
-
var Hint =
|
|
244
|
+
var Hint = React17__namespace.forwardRef(
|
|
243
245
|
({ className, error, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
244
246
|
"span",
|
|
245
247
|
{
|
|
@@ -250,12 +252,12 @@ var Hint = React16__namespace.forwardRef(
|
|
|
250
252
|
)
|
|
251
253
|
);
|
|
252
254
|
Hint.displayName = "Hint";
|
|
253
|
-
var Field =
|
|
255
|
+
var Field = React17__namespace.forwardRef(
|
|
254
256
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("flex flex-col gap-1.5", className), ...props })
|
|
255
257
|
);
|
|
256
258
|
Field.displayName = "Field";
|
|
257
259
|
var chevron = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E";
|
|
258
|
-
var Select =
|
|
260
|
+
var Select = React17__namespace.forwardRef(
|
|
259
261
|
({ className, error, style, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
260
262
|
"select",
|
|
261
263
|
{
|
|
@@ -283,9 +285,9 @@ var Select = React16__namespace.forwardRef(
|
|
|
283
285
|
)
|
|
284
286
|
);
|
|
285
287
|
Select.displayName = "Select";
|
|
286
|
-
var Checkbox =
|
|
288
|
+
var Checkbox = React17__namespace.forwardRef(
|
|
287
289
|
({ className, label, id, ...props }, ref) => {
|
|
288
|
-
const autoId =
|
|
290
|
+
const autoId = React17__namespace.useId();
|
|
289
291
|
const inputId = id ?? autoId;
|
|
290
292
|
return /* @__PURE__ */ jsxRuntime.jsxs("label", { htmlFor: inputId, className: cn("inline-flex items-center gap-2.5 cursor-pointer text-sm select-none", className), children: [
|
|
291
293
|
/* @__PURE__ */ jsxRuntime.jsx("input", { ref, id: inputId, type: "checkbox", className: "peer sr-only", ...props }),
|
|
@@ -295,9 +297,9 @@ var Checkbox = React16__namespace.forwardRef(
|
|
|
295
297
|
}
|
|
296
298
|
);
|
|
297
299
|
Checkbox.displayName = "Checkbox";
|
|
298
|
-
var Radio =
|
|
300
|
+
var Radio = React17__namespace.forwardRef(
|
|
299
301
|
({ className, label, id, ...props }, ref) => {
|
|
300
|
-
const autoId =
|
|
302
|
+
const autoId = React17__namespace.useId();
|
|
301
303
|
const inputId = id ?? autoId;
|
|
302
304
|
return /* @__PURE__ */ jsxRuntime.jsxs("label", { htmlFor: inputId, className: cn("inline-flex items-center gap-2.5 cursor-pointer text-sm select-none", className), children: [
|
|
303
305
|
/* @__PURE__ */ jsxRuntime.jsx("input", { ref, id: inputId, type: "radio", className: "peer sr-only", ...props }),
|
|
@@ -307,9 +309,9 @@ var Radio = React16__namespace.forwardRef(
|
|
|
307
309
|
}
|
|
308
310
|
);
|
|
309
311
|
Radio.displayName = "Radio";
|
|
310
|
-
var Switch =
|
|
312
|
+
var Switch = React17__namespace.forwardRef(
|
|
311
313
|
({ className, label, id, ...props }, ref) => {
|
|
312
|
-
const autoId =
|
|
314
|
+
const autoId = React17__namespace.useId();
|
|
313
315
|
const inputId = id ?? autoId;
|
|
314
316
|
return /* @__PURE__ */ jsxRuntime.jsxs("label", { htmlFor: inputId, className: cn("inline-flex items-center gap-2.5 cursor-pointer text-sm select-none", className), children: [
|
|
315
317
|
/* @__PURE__ */ jsxRuntime.jsx("input", { ref, id: inputId, type: "checkbox", role: "switch", className: "peer sr-only", ...props }),
|
|
@@ -319,7 +321,7 @@ var Switch = React16__namespace.forwardRef(
|
|
|
319
321
|
}
|
|
320
322
|
);
|
|
321
323
|
Switch.displayName = "Switch";
|
|
322
|
-
var Slider =
|
|
324
|
+
var Slider = React17__namespace.forwardRef(
|
|
323
325
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
324
326
|
"input",
|
|
325
327
|
{
|
|
@@ -372,7 +374,7 @@ function Segmented({
|
|
|
372
374
|
}
|
|
373
375
|
);
|
|
374
376
|
}
|
|
375
|
-
var Card =
|
|
377
|
+
var Card = React17__namespace.forwardRef(
|
|
376
378
|
({ as: Tag = "div", className, elevated, interactive, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
377
379
|
Tag,
|
|
378
380
|
{
|
|
@@ -388,23 +390,23 @@ var Card = React16__namespace.forwardRef(
|
|
|
388
390
|
)
|
|
389
391
|
);
|
|
390
392
|
Card.displayName = "Card";
|
|
391
|
-
var CardHeader =
|
|
393
|
+
var CardHeader = React17__namespace.forwardRef(
|
|
392
394
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("p-[1.35rem] flex flex-col gap-1", className), ...props })
|
|
393
395
|
);
|
|
394
396
|
CardHeader.displayName = "CardHeader";
|
|
395
|
-
var CardTitle =
|
|
397
|
+
var CardTitle = React17__namespace.forwardRef(
|
|
396
398
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("h3", { ref, className: cn("m-0 text-base font-bold tracking-[-0.01em]", className), ...props })
|
|
397
399
|
);
|
|
398
400
|
CardTitle.displayName = "CardTitle";
|
|
399
|
-
var CardDescription =
|
|
401
|
+
var CardDescription = React17__namespace.forwardRef(
|
|
400
402
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("p", { ref, className: cn("m-0 text-[0.85rem] text-muted-foreground", className), ...props })
|
|
401
403
|
);
|
|
402
404
|
CardDescription.displayName = "CardDescription";
|
|
403
|
-
var CardContent =
|
|
405
|
+
var CardContent = React17__namespace.forwardRef(
|
|
404
406
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("px-[1.35rem] pb-[1.35rem]", className), ...props })
|
|
405
407
|
);
|
|
406
408
|
CardContent.displayName = "CardContent";
|
|
407
|
-
var CardFooter =
|
|
409
|
+
var CardFooter = React17__namespace.forwardRef(
|
|
408
410
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
409
411
|
"div",
|
|
410
412
|
{
|
|
@@ -415,7 +417,7 @@ var CardFooter = React16__namespace.forwardRef(
|
|
|
415
417
|
)
|
|
416
418
|
);
|
|
417
419
|
CardFooter.displayName = "CardFooter";
|
|
418
|
-
var Stat =
|
|
420
|
+
var Stat = React17__namespace.forwardRef(
|
|
419
421
|
({ className, label, value, delta, trend, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(Card, { ref, className: cn("p-[1.35rem] flex flex-col gap-2", className), ...props, children: [
|
|
420
422
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[0.78rem] font-semibold uppercase tracking-[0.05em] text-muted-foreground", children: label }),
|
|
421
423
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[2rem] font-bold tracking-[-0.03em] tabular-nums leading-none", children: value }),
|
|
@@ -455,7 +457,7 @@ var avatarVariants = classVarianceAuthority.cva(
|
|
|
455
457
|
defaultVariants: { size: "md", tone: "secondary" }
|
|
456
458
|
}
|
|
457
459
|
);
|
|
458
|
-
var Avatar =
|
|
460
|
+
var Avatar = React17__namespace.forwardRef(
|
|
459
461
|
({ className, size, tone, src, alt, status, children, ...props }, ref) => {
|
|
460
462
|
const node = /* @__PURE__ */ jsxRuntime.jsx("span", { ref, className: cn(avatarVariants({ size, tone }), "overflow-hidden", className), ...props, children: src ? /* @__PURE__ */ jsxRuntime.jsx("img", { src, alt, className: "h-full w-full object-cover" }) : children });
|
|
461
463
|
if (!status) return node;
|
|
@@ -466,20 +468,20 @@ var Avatar = React16__namespace.forwardRef(
|
|
|
466
468
|
}
|
|
467
469
|
);
|
|
468
470
|
Avatar.displayName = "Avatar";
|
|
469
|
-
var AvatarGroup =
|
|
471
|
+
var AvatarGroup = React17__namespace.forwardRef(
|
|
470
472
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("flex [&>*:not(:first-child)]:-ml-2.5", className), ...props })
|
|
471
473
|
);
|
|
472
474
|
AvatarGroup.displayName = "AvatarGroup";
|
|
473
|
-
var TabsContext =
|
|
475
|
+
var TabsContext = React17__namespace.createContext(null);
|
|
474
476
|
function useTabs() {
|
|
475
|
-
const ctx =
|
|
477
|
+
const ctx = React17__namespace.useContext(TabsContext);
|
|
476
478
|
if (!ctx) throw new Error("Tabs.* must be used within <Tabs>");
|
|
477
479
|
return ctx;
|
|
478
480
|
}
|
|
479
481
|
function Tabs({ value, defaultValue, onValueChange, className, children, ...props }) {
|
|
480
|
-
const [internal, setInternal] =
|
|
482
|
+
const [internal, setInternal] = React17__namespace.useState(defaultValue ?? "");
|
|
481
483
|
const current = value ?? internal;
|
|
482
|
-
const setValue =
|
|
484
|
+
const setValue = React17__namespace.useCallback(
|
|
483
485
|
(v) => {
|
|
484
486
|
if (value === void 0) setInternal(v);
|
|
485
487
|
onValueChange?.(v);
|
|
@@ -488,11 +490,51 @@ function Tabs({ value, defaultValue, onValueChange, className, children, ...prop
|
|
|
488
490
|
);
|
|
489
491
|
return /* @__PURE__ */ jsxRuntime.jsx(TabsContext.Provider, { value: { value: current, setValue }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className, ...props, children }) });
|
|
490
492
|
}
|
|
491
|
-
var TabsList =
|
|
492
|
-
({ className, ...props }, ref) =>
|
|
493
|
+
var TabsList = React17__namespace.forwardRef(
|
|
494
|
+
({ className, onKeyDown, ...props }, ref) => {
|
|
495
|
+
const handleKeyDown = (e) => {
|
|
496
|
+
const container = e.currentTarget;
|
|
497
|
+
const tabs = Array.from(container.querySelectorAll('[role="tab"]'));
|
|
498
|
+
if (tabs.length === 0) return;
|
|
499
|
+
const activeIndex = tabs.findIndex((tab) => tab.getAttribute("aria-selected") === "true");
|
|
500
|
+
let newIndex = activeIndex;
|
|
501
|
+
if (e.key === "ArrowRight" || e.key === "ArrowDown") {
|
|
502
|
+
e.preventDefault();
|
|
503
|
+
newIndex = (activeIndex + 1) % tabs.length;
|
|
504
|
+
tabs[newIndex].focus();
|
|
505
|
+
tabs[newIndex].click();
|
|
506
|
+
} else if (e.key === "ArrowLeft" || e.key === "ArrowUp") {
|
|
507
|
+
e.preventDefault();
|
|
508
|
+
newIndex = (activeIndex - 1 + tabs.length) % tabs.length;
|
|
509
|
+
tabs[newIndex].focus();
|
|
510
|
+
tabs[newIndex].click();
|
|
511
|
+
} else if (e.key === "Home") {
|
|
512
|
+
e.preventDefault();
|
|
513
|
+
newIndex = 0;
|
|
514
|
+
tabs[newIndex].focus();
|
|
515
|
+
tabs[newIndex].click();
|
|
516
|
+
} else if (e.key === "End") {
|
|
517
|
+
e.preventDefault();
|
|
518
|
+
newIndex = tabs.length - 1;
|
|
519
|
+
tabs[newIndex].focus();
|
|
520
|
+
tabs[newIndex].click();
|
|
521
|
+
}
|
|
522
|
+
onKeyDown?.(e);
|
|
523
|
+
};
|
|
524
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
525
|
+
"div",
|
|
526
|
+
{
|
|
527
|
+
ref,
|
|
528
|
+
role: "tablist",
|
|
529
|
+
onKeyDown: handleKeyDown,
|
|
530
|
+
className: cn("flex gap-1 border-b border-border", className),
|
|
531
|
+
...props
|
|
532
|
+
}
|
|
533
|
+
);
|
|
534
|
+
}
|
|
493
535
|
);
|
|
494
536
|
TabsList.displayName = "TabsList";
|
|
495
|
-
var TabsTrigger =
|
|
537
|
+
var TabsTrigger = React17__namespace.forwardRef(
|
|
496
538
|
({ className, value, children, ...props }, ref) => {
|
|
497
539
|
const { value: current, setValue } = useTabs();
|
|
498
540
|
const active = current === value;
|
|
@@ -502,10 +544,14 @@ var TabsTrigger = React16__namespace.forwardRef(
|
|
|
502
544
|
ref,
|
|
503
545
|
type: "button",
|
|
504
546
|
role: "tab",
|
|
547
|
+
id: `tabs-trigger-${value}`,
|
|
548
|
+
"aria-controls": `tabs-panel-${value}`,
|
|
505
549
|
"aria-selected": active,
|
|
550
|
+
tabIndex: active ? 0 : -1,
|
|
506
551
|
onClick: () => setValue(value),
|
|
507
552
|
className: cn(
|
|
508
|
-
"relative px-[0.9rem] py-2.5 text-sm font-semibold cursor-pointer transition-colors duration-150",
|
|
553
|
+
"relative px-[0.9rem] py-2.5 text-sm font-semibold cursor-pointer transition-colors duration-150 outline-none",
|
|
554
|
+
"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:rounded-sm",
|
|
509
555
|
"after:content-[''] after:absolute after:left-[0.9rem] after:right-[0.9rem] after:-bottom-px after:h-0.5 after:rounded-sm after:transition-colors",
|
|
510
556
|
active ? "text-foreground after:bg-primary" : "text-muted-foreground hover:text-foreground after:bg-transparent",
|
|
511
557
|
className
|
|
@@ -517,18 +563,30 @@ var TabsTrigger = React16__namespace.forwardRef(
|
|
|
517
563
|
}
|
|
518
564
|
);
|
|
519
565
|
TabsTrigger.displayName = "TabsTrigger";
|
|
520
|
-
var TabsContent =
|
|
566
|
+
var TabsContent = React17__namespace.forwardRef(
|
|
521
567
|
({ className, value, ...props }, ref) => {
|
|
522
568
|
const { value: current } = useTabs();
|
|
523
|
-
|
|
524
|
-
|
|
569
|
+
const active = current === value;
|
|
570
|
+
if (!active) return null;
|
|
571
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
572
|
+
"div",
|
|
573
|
+
{
|
|
574
|
+
ref,
|
|
575
|
+
role: "tabpanel",
|
|
576
|
+
id: `tabs-panel-${value}`,
|
|
577
|
+
"aria-labelledby": `tabs-trigger-${value}`,
|
|
578
|
+
tabIndex: 0,
|
|
579
|
+
className: cn("pt-5 text-[0.9rem] text-muted-foreground outline-none", className),
|
|
580
|
+
...props
|
|
581
|
+
}
|
|
582
|
+
);
|
|
525
583
|
}
|
|
526
584
|
);
|
|
527
585
|
TabsContent.displayName = "TabsContent";
|
|
528
|
-
var AccordionContext =
|
|
586
|
+
var AccordionContext = React17__namespace.createContext(null);
|
|
529
587
|
function Accordion({ type = "single", defaultValue = [], className, children, ...props }) {
|
|
530
|
-
const [open, setOpen] =
|
|
531
|
-
const toggle =
|
|
588
|
+
const [open, setOpen] = React17__namespace.useState(defaultValue);
|
|
589
|
+
const toggle = React17__namespace.useCallback(
|
|
532
590
|
(v) => {
|
|
533
591
|
setOpen((prev) => {
|
|
534
592
|
const isOpen = prev.includes(v);
|
|
@@ -540,15 +598,15 @@ function Accordion({ type = "single", defaultValue = [], className, children, ..
|
|
|
540
598
|
);
|
|
541
599
|
return /* @__PURE__ */ jsxRuntime.jsx(AccordionContext.Provider, { value: { open, toggle }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("border border-border rounded-kj-lg overflow-hidden", className), ...props, children }) });
|
|
542
600
|
}
|
|
543
|
-
var ItemContext =
|
|
544
|
-
var AccordionItem =
|
|
601
|
+
var ItemContext = React17__namespace.createContext("");
|
|
602
|
+
var AccordionItem = React17__namespace.forwardRef(
|
|
545
603
|
({ className, value, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(ItemContext.Provider, { value, children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("border-t border-border first:border-t-0", className), ...props }) })
|
|
546
604
|
);
|
|
547
605
|
AccordionItem.displayName = "AccordionItem";
|
|
548
|
-
var AccordionTrigger =
|
|
606
|
+
var AccordionTrigger = React17__namespace.forwardRef(
|
|
549
607
|
({ className, children, ...props }, ref) => {
|
|
550
|
-
const ctx =
|
|
551
|
-
const value =
|
|
608
|
+
const ctx = React17__namespace.useContext(AccordionContext);
|
|
609
|
+
const value = React17__namespace.useContext(ItemContext);
|
|
552
610
|
const isOpen = ctx.open.includes(value);
|
|
553
611
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
554
612
|
"button",
|
|
@@ -585,10 +643,10 @@ var AccordionTrigger = React16__namespace.forwardRef(
|
|
|
585
643
|
}
|
|
586
644
|
);
|
|
587
645
|
AccordionTrigger.displayName = "AccordionTrigger";
|
|
588
|
-
var AccordionContent =
|
|
646
|
+
var AccordionContent = React17__namespace.forwardRef(
|
|
589
647
|
({ className, children, ...props }, ref) => {
|
|
590
|
-
const ctx =
|
|
591
|
-
const value =
|
|
648
|
+
const ctx = React17__namespace.useContext(AccordionContext);
|
|
649
|
+
const value = React17__namespace.useContext(ItemContext);
|
|
592
650
|
const isOpen = ctx.open.includes(value);
|
|
593
651
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
594
652
|
"div",
|
|
@@ -602,11 +660,11 @@ var AccordionContent = React16__namespace.forwardRef(
|
|
|
602
660
|
}
|
|
603
661
|
);
|
|
604
662
|
AccordionContent.displayName = "AccordionContent";
|
|
605
|
-
var MenuContext =
|
|
663
|
+
var MenuContext = React17__namespace.createContext(null);
|
|
606
664
|
function DropdownMenu({ children, className }) {
|
|
607
|
-
const [open, setOpen] =
|
|
608
|
-
const ref =
|
|
609
|
-
|
|
665
|
+
const [open, setOpen] = React17__namespace.useState(false);
|
|
666
|
+
const ref = React17__namespace.useRef(null);
|
|
667
|
+
React17__namespace.useEffect(() => {
|
|
610
668
|
if (!open) return;
|
|
611
669
|
const onDoc = (e) => {
|
|
612
670
|
if (ref.current && !ref.current.contains(e.target)) setOpen(false);
|
|
@@ -621,8 +679,23 @@ function DropdownMenu({ children, className }) {
|
|
|
621
679
|
}, [open]);
|
|
622
680
|
return /* @__PURE__ */ jsxRuntime.jsx(MenuContext.Provider, { value: { open, setOpen }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("relative inline-block", className), children }) });
|
|
623
681
|
}
|
|
624
|
-
var DropdownMenuTrigger =
|
|
625
|
-
const ctx =
|
|
682
|
+
var DropdownMenuTrigger = React17__namespace.forwardRef(({ onClick, asChild, ...props }, ref) => {
|
|
683
|
+
const ctx = React17__namespace.useContext(MenuContext);
|
|
684
|
+
if (asChild) {
|
|
685
|
+
const child = React17__namespace.Children.only(props.children);
|
|
686
|
+
return React17__namespace.cloneElement(child, {
|
|
687
|
+
ref,
|
|
688
|
+
...props,
|
|
689
|
+
...child.props,
|
|
690
|
+
onClick: (e) => {
|
|
691
|
+
ctx.setOpen(!ctx.open);
|
|
692
|
+
onClick?.(e);
|
|
693
|
+
child.props.onClick?.(e);
|
|
694
|
+
},
|
|
695
|
+
"aria-haspopup": "menu",
|
|
696
|
+
"aria-expanded": ctx.open
|
|
697
|
+
});
|
|
698
|
+
}
|
|
626
699
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
627
700
|
"button",
|
|
628
701
|
{
|
|
@@ -640,14 +713,46 @@ var DropdownMenuTrigger = React16__namespace.forwardRef(({ onClick, ...props },
|
|
|
640
713
|
});
|
|
641
714
|
DropdownMenuTrigger.displayName = "DropdownMenuTrigger";
|
|
642
715
|
function DropdownMenuContent({ className, align = "start", children, ...props }) {
|
|
643
|
-
const ctx =
|
|
716
|
+
const ctx = React17__namespace.useContext(MenuContext);
|
|
717
|
+
const ref = React17__namespace.useRef(null);
|
|
718
|
+
React17__namespace.useEffect(() => {
|
|
719
|
+
if (!ctx.open) return;
|
|
720
|
+
const container = ref.current;
|
|
721
|
+
if (container) {
|
|
722
|
+
const items = Array.from(container.querySelectorAll('[role="menuitem"]'));
|
|
723
|
+
if (items.length > 0) {
|
|
724
|
+
setTimeout(() => items[0].focus(), 50);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
}, [ctx.open]);
|
|
728
|
+
const handleKeyDown = (e) => {
|
|
729
|
+
const container = ref.current;
|
|
730
|
+
if (!container) return;
|
|
731
|
+
const items = Array.from(container.querySelectorAll('[role="menuitem"]'));
|
|
732
|
+
if (items.length === 0) return;
|
|
733
|
+
const currentIndex = items.indexOf(document.activeElement);
|
|
734
|
+
if (e.key === "ArrowDown") {
|
|
735
|
+
e.preventDefault();
|
|
736
|
+
const nextIndex = (currentIndex + 1) % items.length;
|
|
737
|
+
items[nextIndex].focus();
|
|
738
|
+
} else if (e.key === "ArrowUp") {
|
|
739
|
+
e.preventDefault();
|
|
740
|
+
const prevIndex = (currentIndex - 1 + items.length) % items.length;
|
|
741
|
+
items[prevIndex].focus();
|
|
742
|
+
} else if (e.key === "Tab" || e.key === "Escape") {
|
|
743
|
+
ctx.setOpen(false);
|
|
744
|
+
}
|
|
745
|
+
};
|
|
644
746
|
if (!ctx.open) return null;
|
|
645
747
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
646
748
|
"div",
|
|
647
749
|
{
|
|
750
|
+
ref,
|
|
648
751
|
role: "menu",
|
|
752
|
+
tabIndex: -1,
|
|
753
|
+
onKeyDown: handleKeyDown,
|
|
649
754
|
className: cn(
|
|
650
|
-
"absolute top-[calc(100%+6px)] z-40 min-w-[200px] p-1.5 rounded-kj-md bg-surface border border-border shadow-kj-lg",
|
|
755
|
+
"absolute top-[calc(100%+6px)] z-40 min-w-[200px] p-1.5 rounded-kj-md bg-surface border border-border shadow-kj-lg outline-none",
|
|
651
756
|
"animate-[kjpop_.12s_ease]",
|
|
652
757
|
align === "end" ? "right-0" : "left-0",
|
|
653
758
|
className
|
|
@@ -657,9 +762,9 @@ function DropdownMenuContent({ className, align = "start", children, ...props })
|
|
|
657
762
|
}
|
|
658
763
|
);
|
|
659
764
|
}
|
|
660
|
-
var DropdownMenuItem =
|
|
765
|
+
var DropdownMenuItem = React17__namespace.forwardRef(
|
|
661
766
|
({ className, danger, icon, children, onClick, ...props }, ref) => {
|
|
662
|
-
const ctx =
|
|
767
|
+
const ctx = React17__namespace.useContext(MenuContext);
|
|
663
768
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
664
769
|
"button",
|
|
665
770
|
{
|
|
@@ -689,11 +794,11 @@ DropdownMenuItem.displayName = "DropdownMenuItem";
|
|
|
689
794
|
function DropdownMenuSeparator({ className }) {
|
|
690
795
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("h-px bg-border my-1.5", className), role: "separator" });
|
|
691
796
|
}
|
|
692
|
-
var Breadcrumb =
|
|
797
|
+
var Breadcrumb = React17__namespace.forwardRef(
|
|
693
798
|
({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("nav", { ref, "aria-label": "Breadcrumb", className: cn("flex items-center gap-1.5 text-[0.85rem] text-muted-foreground", className), ...props, children })
|
|
694
799
|
);
|
|
695
800
|
Breadcrumb.displayName = "Breadcrumb";
|
|
696
|
-
var BreadcrumbItem =
|
|
801
|
+
var BreadcrumbItem = React17__namespace.forwardRef(
|
|
697
802
|
({ className, current, children, ...props }, ref) => {
|
|
698
803
|
if (current) {
|
|
699
804
|
return /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-current": "page", className: cn("text-foreground font-semibold", className), children });
|
|
@@ -740,27 +845,27 @@ function Pagination({ page, pageCount, onPageChange, className }) {
|
|
|
740
845
|
/* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "ghost", size: "icon-sm", "aria-label": "Next", disabled: page >= pageCount, onClick: () => onPageChange(page + 1), children: /* @__PURE__ */ jsxRuntime.jsx(Chevron, { dir: "right" }) })
|
|
741
846
|
] });
|
|
742
847
|
}
|
|
743
|
-
var TableWrap =
|
|
848
|
+
var TableWrap = React17__namespace.forwardRef(
|
|
744
849
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("border border-border rounded-kj-lg overflow-hidden", className), ...props })
|
|
745
850
|
);
|
|
746
851
|
TableWrap.displayName = "TableWrap";
|
|
747
|
-
var Table =
|
|
852
|
+
var Table = React17__namespace.forwardRef(
|
|
748
853
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("table", { ref, className: cn("w-full border-collapse text-[0.85rem]", className), ...props })
|
|
749
854
|
);
|
|
750
855
|
Table.displayName = "Table";
|
|
751
|
-
var TableHeader =
|
|
856
|
+
var TableHeader = React17__namespace.forwardRef(
|
|
752
857
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("thead", { ref, className, ...props })
|
|
753
858
|
);
|
|
754
859
|
TableHeader.displayName = "TableHeader";
|
|
755
|
-
var TableBody =
|
|
860
|
+
var TableBody = React17__namespace.forwardRef(
|
|
756
861
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("tbody", { ref, className, ...props })
|
|
757
862
|
);
|
|
758
863
|
TableBody.displayName = "TableBody";
|
|
759
|
-
var TableRow =
|
|
864
|
+
var TableRow = React17__namespace.forwardRef(
|
|
760
865
|
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("tr", { ref, className: cn("transition-colors hover:bg-muted/50", className), ...props })
|
|
761
866
|
);
|
|
762
867
|
TableRow.displayName = "TableRow";
|
|
763
|
-
var TableHead =
|
|
868
|
+
var TableHead = React17__namespace.forwardRef(
|
|
764
869
|
({ className, numeric, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
765
870
|
"th",
|
|
766
871
|
{
|
|
@@ -775,7 +880,7 @@ var TableHead = React16__namespace.forwardRef(
|
|
|
775
880
|
)
|
|
776
881
|
);
|
|
777
882
|
TableHead.displayName = "TableHead";
|
|
778
|
-
var TableCell =
|
|
883
|
+
var TableCell = React17__namespace.forwardRef(
|
|
779
884
|
({ className, numeric, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
780
885
|
"td",
|
|
781
886
|
{
|
|
@@ -808,14 +913,68 @@ function Tooltip({ content, children, className }) {
|
|
|
808
913
|
)
|
|
809
914
|
] });
|
|
810
915
|
}
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
916
|
+
var ModalContext = React17__namespace.createContext(null);
|
|
917
|
+
function Modal({ open, onClose, children, width = 440, className, showClose = true }) {
|
|
918
|
+
const titleId = React17__namespace.useId();
|
|
919
|
+
const descId = React17__namespace.useId();
|
|
920
|
+
const containerRef = React17__namespace.useRef(null);
|
|
921
|
+
const lastActiveElement = React17__namespace.useRef(null);
|
|
922
|
+
React17__namespace.useEffect(() => {
|
|
923
|
+
if (!open) {
|
|
924
|
+
if (lastActiveElement.current) {
|
|
925
|
+
lastActiveElement.current.focus();
|
|
926
|
+
lastActiveElement.current = null;
|
|
927
|
+
}
|
|
928
|
+
return;
|
|
929
|
+
}
|
|
930
|
+
lastActiveElement.current = document.activeElement;
|
|
931
|
+
const container = containerRef.current;
|
|
932
|
+
if (container) {
|
|
933
|
+
const focusables = container.querySelectorAll(
|
|
934
|
+
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
935
|
+
);
|
|
936
|
+
if (focusables.length > 0) {
|
|
937
|
+
setTimeout(() => focusables[0].focus(), 50);
|
|
938
|
+
} else {
|
|
939
|
+
container.focus();
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
const handleKeyDown = (e) => {
|
|
943
|
+
if (e.key === "Escape") {
|
|
944
|
+
onClose();
|
|
945
|
+
return;
|
|
946
|
+
}
|
|
947
|
+
if (e.key === "Tab") {
|
|
948
|
+
const container2 = containerRef.current;
|
|
949
|
+
if (!container2) return;
|
|
950
|
+
const focusables = Array.from(
|
|
951
|
+
container2.querySelectorAll(
|
|
952
|
+
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
953
|
+
)
|
|
954
|
+
);
|
|
955
|
+
if (focusables.length === 0) {
|
|
956
|
+
e.preventDefault();
|
|
957
|
+
return;
|
|
958
|
+
}
|
|
959
|
+
const first = focusables[0];
|
|
960
|
+
const last = focusables[focusables.length - 1];
|
|
961
|
+
if (e.shiftKey) {
|
|
962
|
+
if (document.activeElement === first || document.activeElement === container2) {
|
|
963
|
+
last.focus();
|
|
964
|
+
e.preventDefault();
|
|
965
|
+
}
|
|
966
|
+
} else {
|
|
967
|
+
if (document.activeElement === last) {
|
|
968
|
+
first.focus();
|
|
969
|
+
e.preventDefault();
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
};
|
|
974
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
816
975
|
document.body.style.overflow = "hidden";
|
|
817
976
|
return () => {
|
|
818
|
-
document.removeEventListener("keydown",
|
|
977
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
819
978
|
document.body.style.overflow = "";
|
|
820
979
|
};
|
|
821
980
|
}, [open, onClose]);
|
|
@@ -828,35 +987,53 @@ function Modal({ open, onClose, children, width = 440, className }) {
|
|
|
828
987
|
"bg-[color-mix(in_oklch,#09090b_55%,transparent)]",
|
|
829
988
|
open ? "opacity-100 pointer-events-auto" : "opacity-0 pointer-events-none"
|
|
830
989
|
),
|
|
831
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
990
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ModalContext.Provider, { value: { titleId, descId }, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
832
991
|
"div",
|
|
833
992
|
{
|
|
993
|
+
ref: containerRef,
|
|
834
994
|
role: "dialog",
|
|
835
995
|
"aria-modal": "true",
|
|
996
|
+
"aria-labelledby": titleId,
|
|
997
|
+
"aria-describedby": descId,
|
|
998
|
+
tabIndex: -1,
|
|
836
999
|
style: { maxWidth: width },
|
|
837
1000
|
className: cn(
|
|
838
|
-
"w-full p-7 rounded-kj-2xl bg-surface border border-border shadow-kj-lg transition-transform duration-200",
|
|
1001
|
+
"relative w-full p-7 rounded-kj-2xl bg-surface border border-border shadow-kj-lg transition-transform duration-200 outline-none",
|
|
839
1002
|
open ? "scale-100 translate-y-0" : "scale-95 translate-y-2",
|
|
840
1003
|
className
|
|
841
1004
|
),
|
|
842
|
-
children
|
|
1005
|
+
children: [
|
|
1006
|
+
showClose && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1007
|
+
"button",
|
|
1008
|
+
{
|
|
1009
|
+
type: "button",
|
|
1010
|
+
onClick: onClose,
|
|
1011
|
+
"aria-label": "Close",
|
|
1012
|
+
className: "absolute top-4 right-4 p-1.5 rounded-kj-sm text-muted-foreground hover:text-foreground hover:bg-muted transition-colors cursor-pointer",
|
|
1013
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: 16, height: 16, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2.5, strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M18 6 6 18M6 6l12 12" }) })
|
|
1014
|
+
}
|
|
1015
|
+
),
|
|
1016
|
+
children
|
|
1017
|
+
]
|
|
843
1018
|
}
|
|
844
|
-
)
|
|
1019
|
+
) })
|
|
845
1020
|
}
|
|
846
1021
|
);
|
|
847
1022
|
}
|
|
848
|
-
function ModalTitle({ className, ...props }) {
|
|
849
|
-
|
|
1023
|
+
function ModalTitle({ className, id, ...props }) {
|
|
1024
|
+
const ctx = React17__namespace.useContext(ModalContext);
|
|
1025
|
+
return /* @__PURE__ */ jsxRuntime.jsx("h3", { id: id ?? ctx?.titleId, className: cn("m-0 mb-2 text-[1.15rem] font-bold tracking-[-0.01em]", className), ...props });
|
|
850
1026
|
}
|
|
851
|
-
function ModalDescription({ className, ...props }) {
|
|
852
|
-
|
|
1027
|
+
function ModalDescription({ className, id, ...props }) {
|
|
1028
|
+
const ctx = React17__namespace.useContext(ModalContext);
|
|
1029
|
+
return /* @__PURE__ */ jsxRuntime.jsx("p", { id: id ?? ctx?.descId, className: cn("m-0 text-[0.9rem] text-muted-foreground", className), ...props });
|
|
853
1030
|
}
|
|
854
1031
|
function ModalActions({ className, ...props }) {
|
|
855
1032
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("flex gap-2.5 justify-end mt-6", className), ...props });
|
|
856
1033
|
}
|
|
857
|
-
var ToastContext =
|
|
1034
|
+
var ToastContext = React17__namespace.createContext(null);
|
|
858
1035
|
function useToast() {
|
|
859
|
-
const ctx =
|
|
1036
|
+
const ctx = React17__namespace.useContext(ToastContext);
|
|
860
1037
|
if (!ctx) throw new Error("useToast must be used within <ToastProvider>");
|
|
861
1038
|
return ctx;
|
|
862
1039
|
}
|
|
@@ -877,13 +1054,13 @@ var toneBorder = {
|
|
|
877
1054
|
danger: "border-l-danger"
|
|
878
1055
|
};
|
|
879
1056
|
function ToastProvider({ children }) {
|
|
880
|
-
const [items, setItems] =
|
|
881
|
-
const idRef =
|
|
882
|
-
const remove =
|
|
1057
|
+
const [items, setItems] = React17__namespace.useState([]);
|
|
1058
|
+
const idRef = React17__namespace.useRef(0);
|
|
1059
|
+
const remove = React17__namespace.useCallback((id) => {
|
|
883
1060
|
setItems((prev) => prev.map((t) => t.id === id ? { ...t, leaving: true } : t));
|
|
884
1061
|
setTimeout(() => setItems((prev) => prev.filter((t) => t.id !== id)), 250);
|
|
885
1062
|
}, []);
|
|
886
|
-
const toast =
|
|
1063
|
+
const toast = React17__namespace.useCallback(
|
|
887
1064
|
({ message, tone = "default", duration = 3200 }) => {
|
|
888
1065
|
const id = ++idRef.current;
|
|
889
1066
|
setItems((prev) => [...prev, { id, message, tone, duration }]);
|
|
@@ -913,7 +1090,7 @@ function ToastProvider({ children }) {
|
|
|
913
1090
|
)) })
|
|
914
1091
|
] });
|
|
915
1092
|
}
|
|
916
|
-
var PageHeader =
|
|
1093
|
+
var PageHeader = React17__namespace.forwardRef(
|
|
917
1094
|
({ eyebrow, title, description, actions }, ref) => /* @__PURE__ */ jsxRuntime.jsx("header", { ref, className: "py-12 md:py-16", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6 md:flex-row md:items-end md:justify-between", children: [
|
|
918
1095
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3 max-w-2xl", children: [
|
|
919
1096
|
eyebrow && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-mono text-xs font-bold uppercase tracking-[0.2em] text-primary", children: eyebrow }),
|