@enablo/swirlcn-ui 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-7XUCETA6.js → chunk-DA6NGVQZ.js} +6 -0
- package/dist/{chunk-3DJWDNQL.js → chunk-HRH6AKCA.js} +2 -1
- package/dist/flip.js +1 -1
- package/dist/index.d.ts +89 -3
- package/dist/index.js +385 -217
- package/dist/server.js +1 -1
- package/package.json +5 -5
- package/src/components/app-bar.tsx +145 -0
- package/src/components/card.tsx +27 -2
- package/src/components/dialog.tsx +28 -11
- package/src/components/resource-list.tsx +1 -3
- package/src/components/tab-bar.tsx +77 -0
- package/src/index.ts +5 -0
- package/src/lib/glyphs.ts +6 -0
- package/src/lib/spacing.ts +7 -0
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Glyph, Spinner,
|
|
3
|
-
export { Button, Spinner, buttonVariants, useOptionalTheme } from './chunk-
|
|
4
|
-
import { gap, gapX, gapY, padding } from './chunk-
|
|
5
|
-
export { gap, gapX, gapY, padding, spacingScale } from './chunk-
|
|
2
|
+
import { Button, Glyph, Spinner, ThemeContext } from './chunk-DA6NGVQZ.js';
|
|
3
|
+
export { Button, Spinner, buttonVariants, useOptionalTheme } from './chunk-DA6NGVQZ.js';
|
|
4
|
+
import { gap, gapX, gapY, spaceVar, padding } from './chunk-HRH6AKCA.js';
|
|
5
|
+
export { gap, gapX, gapY, padding, spacingScale } from './chunk-HRH6AKCA.js';
|
|
6
6
|
import { cn, focusRing } from './chunk-KZESIYUN.js';
|
|
7
7
|
export { cn, focusRing, focusRingInset, resolveAlias } from './chunk-KZESIYUN.js';
|
|
8
8
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
9
9
|
import { Tooltip as Tooltip$1, Dialog as Dialog$1, AlertDialog as AlertDialog$1, Tabs as Tabs$1, Accordion as Accordion$1, Slot, Avatar as Avatar$1, Progress as Progress$1, Label as Label$1, Checkbox as Checkbox$1, RadioGroup as RadioGroup$1, Switch as Switch$1, Popover as Popover$1, ToggleGroup as ToggleGroup$1, Toast, DropdownMenu } from 'radix-ui';
|
|
10
10
|
import { cva } from 'class-variance-authority';
|
|
11
|
-
import * as
|
|
11
|
+
import * as React11 from 'react';
|
|
12
12
|
import { DayPicker } from 'react-day-picker';
|
|
13
13
|
import { format, parse, isValid } from 'date-fns';
|
|
14
14
|
import { HexColorPicker } from 'react-colorful';
|
|
@@ -579,6 +579,11 @@ function Card({
|
|
|
579
579
|
elevated = false,
|
|
580
580
|
elevationLevel = 3,
|
|
581
581
|
padding: padding2,
|
|
582
|
+
paddingBlockStart,
|
|
583
|
+
paddingBlockEnd,
|
|
584
|
+
paddingInlineStart,
|
|
585
|
+
paddingInlineEnd,
|
|
586
|
+
minHeight,
|
|
582
587
|
borderless = false,
|
|
583
588
|
interactive = false,
|
|
584
589
|
highlighted,
|
|
@@ -589,11 +594,18 @@ function Card({
|
|
|
589
594
|
floatingControls,
|
|
590
595
|
flashing = false,
|
|
591
596
|
children,
|
|
597
|
+
style,
|
|
592
598
|
...props
|
|
593
599
|
}) {
|
|
594
600
|
const isLink = href !== void 0;
|
|
595
601
|
const Component = as ?? (isLink ? "a" : "div");
|
|
596
602
|
const body = image !== void 0;
|
|
603
|
+
const sides = {
|
|
604
|
+
paddingBlockStart: spaceVar(paddingBlockStart),
|
|
605
|
+
paddingBlockEnd: spaceVar(paddingBlockEnd),
|
|
606
|
+
paddingInlineStart: spaceVar(paddingInlineStart),
|
|
607
|
+
paddingInlineEnd: spaceVar(paddingInlineEnd)
|
|
608
|
+
};
|
|
597
609
|
return /* @__PURE__ */ jsxs(
|
|
598
610
|
Component,
|
|
599
611
|
{
|
|
@@ -613,6 +625,7 @@ function Card({
|
|
|
613
625
|
!body && padding2 && padding(padding2),
|
|
614
626
|
className
|
|
615
627
|
),
|
|
628
|
+
style: { minHeight, ...body ? {} : sides, ...style },
|
|
616
629
|
...props,
|
|
617
630
|
children: [
|
|
618
631
|
body && /* @__PURE__ */ jsx(
|
|
@@ -634,7 +647,14 @@ function Card({
|
|
|
634
647
|
children: floatingControls
|
|
635
648
|
}
|
|
636
649
|
),
|
|
637
|
-
body ? /* @__PURE__ */ jsx(
|
|
650
|
+
body ? /* @__PURE__ */ jsx(
|
|
651
|
+
"div",
|
|
652
|
+
{
|
|
653
|
+
className: cn("flex min-h-0 grow flex-col gap-4", padding2 ? padding(padding2) : "px-4 pt-3 pb-4"),
|
|
654
|
+
style: sides,
|
|
655
|
+
children
|
|
656
|
+
}
|
|
657
|
+
) : children
|
|
638
658
|
]
|
|
639
659
|
}
|
|
640
660
|
);
|
|
@@ -654,6 +674,113 @@ function CardContent({ className, ...props }) {
|
|
|
654
674
|
function CardFooter({ className, ...props }) {
|
|
655
675
|
return /* @__PURE__ */ jsx("div", { className: cn("flex items-center gap-2 p-4 pt-0", className), ...props });
|
|
656
676
|
}
|
|
677
|
+
function AppBar({
|
|
678
|
+
heading,
|
|
679
|
+
showHeading = true,
|
|
680
|
+
centerControls,
|
|
681
|
+
cta,
|
|
682
|
+
rightControls,
|
|
683
|
+
showBackButton = false,
|
|
684
|
+
backButtonLabel = "Go back",
|
|
685
|
+
onBackButtonClick,
|
|
686
|
+
showCloseButton = false,
|
|
687
|
+
closeButtonLabel = "Close",
|
|
688
|
+
closeButtonIcon,
|
|
689
|
+
onCloseButtonClick,
|
|
690
|
+
showStepperControls = false,
|
|
691
|
+
stepUpButtonLabel = "Previous item",
|
|
692
|
+
stepDownButtonLabel = "Next item",
|
|
693
|
+
onStepUpButtonClick,
|
|
694
|
+
onStepDownButtonClick,
|
|
695
|
+
paddingInlineStart = "16",
|
|
696
|
+
paddingInlineEnd = "16",
|
|
697
|
+
className,
|
|
698
|
+
style,
|
|
699
|
+
...props
|
|
700
|
+
}) {
|
|
701
|
+
const hasHeading = heading !== void 0 && heading !== null && showHeading;
|
|
702
|
+
const showNavigation = showBackButton || showCloseButton;
|
|
703
|
+
return /* @__PURE__ */ jsxs(
|
|
704
|
+
"div",
|
|
705
|
+
{
|
|
706
|
+
className: cn("flex min-h-14 w-full items-center gap-4 overflow-x-auto", className),
|
|
707
|
+
style: {
|
|
708
|
+
paddingInlineStart: spaceVar(paddingInlineStart),
|
|
709
|
+
paddingInlineEnd: spaceVar(paddingInlineEnd),
|
|
710
|
+
...style
|
|
711
|
+
},
|
|
712
|
+
...props,
|
|
713
|
+
children: [
|
|
714
|
+
(showNavigation || showStepperControls) && /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 shrink-0 items-center gap-4", children: [
|
|
715
|
+
showNavigation && /* @__PURE__ */ jsxs("div", { className: "shrink-0", children: [
|
|
716
|
+
showBackButton && /* @__PURE__ */ jsx(
|
|
717
|
+
Button,
|
|
718
|
+
{
|
|
719
|
+
hideLabel: true,
|
|
720
|
+
icon: /* @__PURE__ */ jsx(Glyph, { name: "arrowBack" }),
|
|
721
|
+
label: backButtonLabel,
|
|
722
|
+
onClick: onBackButtonClick
|
|
723
|
+
}
|
|
724
|
+
),
|
|
725
|
+
showCloseButton && /* @__PURE__ */ jsx(
|
|
726
|
+
Button,
|
|
727
|
+
{
|
|
728
|
+
hideLabel: true,
|
|
729
|
+
icon: closeButtonIcon ?? /* @__PURE__ */ jsx(Glyph, { name: "close" }),
|
|
730
|
+
label: closeButtonLabel,
|
|
731
|
+
onClick: onCloseButtonClick
|
|
732
|
+
}
|
|
733
|
+
)
|
|
734
|
+
] }),
|
|
735
|
+
showStepperControls && /* @__PURE__ */ jsxs(
|
|
736
|
+
"div",
|
|
737
|
+
{
|
|
738
|
+
className: cn(
|
|
739
|
+
"relative flex shrink-0 gap-1",
|
|
740
|
+
// A short rule between the stepper and the buttons before it.
|
|
741
|
+
"not-first:pl-4 not-first:after:absolute not-first:after:top-1/2 not-first:after:left-0",
|
|
742
|
+
"not-first:after:h-5 not-first:after:w-px not-first:after:-translate-y-1/2 not-first:after:bg-border"
|
|
743
|
+
),
|
|
744
|
+
children: [
|
|
745
|
+
/* @__PURE__ */ jsx(
|
|
746
|
+
Button,
|
|
747
|
+
{
|
|
748
|
+
hideLabel: true,
|
|
749
|
+
icon: /* @__PURE__ */ jsx(Glyph, { name: "arrowUpward" }),
|
|
750
|
+
label: stepUpButtonLabel,
|
|
751
|
+
onClick: onStepUpButtonClick
|
|
752
|
+
}
|
|
753
|
+
),
|
|
754
|
+
/* @__PURE__ */ jsx(
|
|
755
|
+
Button,
|
|
756
|
+
{
|
|
757
|
+
hideLabel: true,
|
|
758
|
+
icon: /* @__PURE__ */ jsx(Glyph, { name: "arrowDownward" }),
|
|
759
|
+
label: stepDownButtonLabel,
|
|
760
|
+
onClick: onStepDownButtonClick
|
|
761
|
+
}
|
|
762
|
+
)
|
|
763
|
+
]
|
|
764
|
+
}
|
|
765
|
+
)
|
|
766
|
+
] }),
|
|
767
|
+
cta !== void 0 && cta !== null && /* @__PURE__ */ jsx("div", { children: cta }),
|
|
768
|
+
hasHeading && /* @__PURE__ */ jsx("div", { className: "flex min-w-40 grow items-center min-[62rem]:min-w-0 min-[62rem]:grow-0", children: heading }),
|
|
769
|
+
/* @__PURE__ */ jsx(
|
|
770
|
+
"div",
|
|
771
|
+
{
|
|
772
|
+
className: cn(
|
|
773
|
+
"grow items-center justify-center",
|
|
774
|
+
hasHeading ? "hidden min-[62rem]:flex" : "flex"
|
|
775
|
+
),
|
|
776
|
+
children: centerControls
|
|
777
|
+
}
|
|
778
|
+
),
|
|
779
|
+
rightControls !== void 0 && rightControls !== null && /* @__PURE__ */ jsx("div", { className: "flex min-w-0 shrink-0 items-center justify-end", children: rightControls })
|
|
780
|
+
]
|
|
781
|
+
}
|
|
782
|
+
);
|
|
783
|
+
}
|
|
657
784
|
var badgeVariants = cva(
|
|
658
785
|
// Swirl rings every badge in the page colour, so badges that touch or sit
|
|
659
786
|
// over something (a stack, an avatar's corner) stay separate. Pass another
|
|
@@ -1031,7 +1158,7 @@ function Avatar({
|
|
|
1031
1158
|
}) {
|
|
1032
1159
|
const resolvedColor = color === "auto" ? avatarColorFor(label) : color ?? "kiwi";
|
|
1033
1160
|
const resolvedInitials = initials ?? initialsFor(label);
|
|
1034
|
-
const dotBadge =
|
|
1161
|
+
const dotBadge = React11.isValidElement(badge) && badge.props.variant === "dot";
|
|
1035
1162
|
const avatar = /* @__PURE__ */ jsxs(
|
|
1036
1163
|
Avatar$1.Root,
|
|
1037
1164
|
{
|
|
@@ -1121,7 +1248,7 @@ function AvatarGroup({
|
|
|
1121
1248
|
children,
|
|
1122
1249
|
...props
|
|
1123
1250
|
}) {
|
|
1124
|
-
const items =
|
|
1251
|
+
const items = React11.Children.toArray(children);
|
|
1125
1252
|
const shown = max ? items.slice(0, max) : items;
|
|
1126
1253
|
const hidden = items.length - shown.length;
|
|
1127
1254
|
return /* @__PURE__ */ jsxs(
|
|
@@ -1290,20 +1417,20 @@ function Label({ className, required, children, ...props }) {
|
|
|
1290
1417
|
}
|
|
1291
1418
|
);
|
|
1292
1419
|
}
|
|
1293
|
-
var FieldContext =
|
|
1420
|
+
var FieldContext = React11.createContext(null);
|
|
1294
1421
|
function useField() {
|
|
1295
|
-
return
|
|
1422
|
+
return React11.useContext(FieldContext);
|
|
1296
1423
|
}
|
|
1297
1424
|
function useFieldText(value, defaultValue, onChange) {
|
|
1298
1425
|
const field = useField();
|
|
1299
1426
|
const controlled = value !== void 0;
|
|
1300
|
-
const [uncontrolled, setUncontrolled] =
|
|
1427
|
+
const [uncontrolled, setUncontrolled] = React11.useState(
|
|
1301
1428
|
() => defaultValue == null ? "" : String(defaultValue)
|
|
1302
1429
|
);
|
|
1303
1430
|
const text = controlled ? value == null ? "" : String(value) : uncontrolled;
|
|
1304
1431
|
const filled = text !== "";
|
|
1305
1432
|
const setFilled = field?.setFilled;
|
|
1306
|
-
|
|
1433
|
+
React11.useEffect(() => {
|
|
1307
1434
|
setFilled?.(filled);
|
|
1308
1435
|
}, [setFilled, filled]);
|
|
1309
1436
|
const handleChange = (event) => {
|
|
@@ -1457,22 +1584,22 @@ function FieldFormControl({
|
|
|
1457
1584
|
onBlur,
|
|
1458
1585
|
...props
|
|
1459
1586
|
}) {
|
|
1460
|
-
const base =
|
|
1587
|
+
const base = React11.useId();
|
|
1461
1588
|
const id = `${base}-control`;
|
|
1462
1589
|
const descriptionId = `${base}-description`;
|
|
1463
1590
|
const errorId = `${base}-error`;
|
|
1464
1591
|
const message = errorMessage ?? error;
|
|
1465
1592
|
const isInvalid = invalid ?? Boolean(message);
|
|
1466
|
-
const [filled, setFilled] =
|
|
1467
|
-
const [hasPlaceholder, setHasPlaceholder] =
|
|
1468
|
-
const [hasCounter, setHasCounter] =
|
|
1469
|
-
const [focused, setFocused] =
|
|
1593
|
+
const [filled, setFilled] = React11.useState(false);
|
|
1594
|
+
const [hasPlaceholder, setHasPlaceholder] = React11.useState(false);
|
|
1595
|
+
const [hasCounter, setHasCounter] = React11.useState(false);
|
|
1596
|
+
const [focused, setFocused] = React11.useState(false);
|
|
1470
1597
|
const outside = labelPosition === "outside";
|
|
1471
1598
|
const compact = outside || inline;
|
|
1472
1599
|
const labelAsPlaceholder = !outside && !filled && !focused && (inline || !hasPlaceholder);
|
|
1473
1600
|
const describedBy = message ? errorId : description ? descriptionId : void 0;
|
|
1474
1601
|
const active = focused && !disabled && !readOnly;
|
|
1475
|
-
const context =
|
|
1602
|
+
const context = React11.useMemo(
|
|
1476
1603
|
() => ({
|
|
1477
1604
|
id,
|
|
1478
1605
|
describedBy,
|
|
@@ -1558,7 +1685,7 @@ function FieldFormControl({
|
|
|
1558
1685
|
),
|
|
1559
1686
|
children: [
|
|
1560
1687
|
prefix,
|
|
1561
|
-
|
|
1688
|
+
React11.isValidElement(prefix) && prefix.type === "select" && /* @__PURE__ */ jsx(
|
|
1562
1689
|
Glyph,
|
|
1563
1690
|
{
|
|
1564
1691
|
name: "expandMore",
|
|
@@ -1681,7 +1808,7 @@ function RenderFunctionFormControl({
|
|
|
1681
1808
|
bottom: _bottom,
|
|
1682
1809
|
...props
|
|
1683
1810
|
}) {
|
|
1684
|
-
const base =
|
|
1811
|
+
const base = React11.useId();
|
|
1685
1812
|
const id = `${base}-control`;
|
|
1686
1813
|
const descriptionId = `${base}-description`;
|
|
1687
1814
|
const errorId = `${base}-error`;
|
|
@@ -1797,16 +1924,16 @@ function Input({
|
|
|
1797
1924
|
...props
|
|
1798
1925
|
}) {
|
|
1799
1926
|
const { field, text, handleChange } = useFieldText(value, defaultValue, onChange);
|
|
1800
|
-
const generatedId =
|
|
1927
|
+
const generatedId = React11.useId();
|
|
1801
1928
|
const inputId = id ?? field?.id ?? generatedId;
|
|
1802
1929
|
const getInput = () => document.getElementById(inputId);
|
|
1803
|
-
const [revealed, setRevealed] =
|
|
1930
|
+
const [revealed, setRevealed] = React11.useState(false);
|
|
1804
1931
|
const setHasPlaceholder = field?.setHasPlaceholder;
|
|
1805
1932
|
const setHasCounter = field?.setHasCounter;
|
|
1806
|
-
|
|
1933
|
+
React11.useEffect(() => {
|
|
1807
1934
|
setHasPlaceholder?.(Boolean(placeholder));
|
|
1808
1935
|
}, [setHasPlaceholder, placeholder]);
|
|
1809
|
-
|
|
1936
|
+
React11.useEffect(() => {
|
|
1810
1937
|
setHasCounter?.(showCharacterCounter);
|
|
1811
1938
|
}, [setHasCounter, showCharacterCounter]);
|
|
1812
1939
|
const isDisabled = disabled ?? field?.disabled;
|
|
@@ -2033,10 +2160,10 @@ function Textarea({
|
|
|
2033
2160
|
const { field, text, handleChange } = useFieldText(value, defaultValue, onChange);
|
|
2034
2161
|
const setHasPlaceholder = field?.setHasPlaceholder;
|
|
2035
2162
|
const setHasCounter = field?.setHasCounter;
|
|
2036
|
-
|
|
2163
|
+
React11.useEffect(() => {
|
|
2037
2164
|
setHasPlaceholder?.(Boolean(placeholder));
|
|
2038
2165
|
}, [setHasPlaceholder, placeholder]);
|
|
2039
|
-
|
|
2166
|
+
React11.useEffect(() => {
|
|
2040
2167
|
setHasCounter?.(showCharacterCounter);
|
|
2041
2168
|
}, [setHasCounter, showCharacterCounter]);
|
|
2042
2169
|
const showCounter = showCharacterCounter && (!showCharacterCounterNearLimit || maxLength != null && text.length >= maxLength * 0.8);
|
|
@@ -2378,7 +2505,7 @@ function Switch({
|
|
|
2378
2505
|
}
|
|
2379
2506
|
var MOBILE_QUERY = "(max-width: 767px)";
|
|
2380
2507
|
function useMobile() {
|
|
2381
|
-
return
|
|
2508
|
+
return React11.useSyncExternalStore(
|
|
2382
2509
|
(onChange) => {
|
|
2383
2510
|
const query = window.matchMedia(MOBILE_QUERY);
|
|
2384
2511
|
query.addEventListener("change", onChange);
|
|
@@ -2395,9 +2522,9 @@ function enabledItems(list) {
|
|
|
2395
2522
|
);
|
|
2396
2523
|
}
|
|
2397
2524
|
function ActionList({ className, onKeyDown, onFocus, onBlur, ...props }) {
|
|
2398
|
-
const ref =
|
|
2399
|
-
const lastFocused =
|
|
2400
|
-
const [focusWithin, setFocusWithin] =
|
|
2525
|
+
const ref = React11.useRef(null);
|
|
2526
|
+
const lastFocused = React11.useRef(null);
|
|
2527
|
+
const [focusWithin, setFocusWithin] = React11.useState(false);
|
|
2401
2528
|
const move = (to) => {
|
|
2402
2529
|
const list = ref.current;
|
|
2403
2530
|
if (!list) return;
|
|
@@ -2568,7 +2695,7 @@ function ActionListSection({
|
|
|
2568
2695
|
children,
|
|
2569
2696
|
...props
|
|
2570
2697
|
}) {
|
|
2571
|
-
const id =
|
|
2698
|
+
const id = React11.useId();
|
|
2572
2699
|
return /* @__PURE__ */ jsxs("div", { className: cn("group/section w-full", className), ...props, children: [
|
|
2573
2700
|
hasSeparator && /* @__PURE__ */ jsx(
|
|
2574
2701
|
"div",
|
|
@@ -2616,9 +2743,9 @@ var DragHandleIcon = () => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", "a
|
|
|
2616
2743
|
(y) => [7.5, 13.5].map((x) => /* @__PURE__ */ jsx("rect", { x, y, width: "3", height: "3", rx: "1.5", fill: "currentColor" }, `${x}-${y}`))
|
|
2617
2744
|
) });
|
|
2618
2745
|
var SELECT_ALL = "\0select-all";
|
|
2619
|
-
var OptionListContext =
|
|
2746
|
+
var OptionListContext = React11.createContext(null);
|
|
2620
2747
|
function useOptionList() {
|
|
2621
|
-
const context =
|
|
2748
|
+
const context = React11.useContext(OptionListContext);
|
|
2622
2749
|
if (!context) throw new Error("OptionListItem must be used inside an OptionList.");
|
|
2623
2750
|
return context;
|
|
2624
2751
|
}
|
|
@@ -2644,16 +2771,16 @@ function OptionList({
|
|
|
2644
2771
|
children,
|
|
2645
2772
|
...props
|
|
2646
2773
|
}) {
|
|
2647
|
-
const ref =
|
|
2648
|
-
const [uncontrolled, setUncontrolled] =
|
|
2774
|
+
const ref = React11.useRef(null);
|
|
2775
|
+
const [uncontrolled, setUncontrolled] = React11.useState(defaultValue);
|
|
2649
2776
|
const value = valueProp ?? uncontrolled;
|
|
2650
|
-
const [items, setItems] =
|
|
2651
|
-
const [active, setActive] =
|
|
2652
|
-
const [drag, setDrag] =
|
|
2653
|
-
const [assistiveText, setAssistiveText] =
|
|
2777
|
+
const [items, setItems] = React11.useState([]);
|
|
2778
|
+
const [active, setActive] = React11.useState();
|
|
2779
|
+
const [drag, setDrag] = React11.useState(null);
|
|
2780
|
+
const [assistiveText, setAssistiveText] = React11.useState("");
|
|
2654
2781
|
const selectAll = multiSelect && showSelectAll;
|
|
2655
2782
|
const canDrag = allowDrag && multiSelect;
|
|
2656
|
-
|
|
2783
|
+
React11.useEffect(() => {
|
|
2657
2784
|
if (allowDrag && !multiSelect) {
|
|
2658
2785
|
console.error("[OptionList] Drag can only be allowed for multi select lists.");
|
|
2659
2786
|
} else if (allowDrag && ref.current?.querySelector('[role="group"]')) {
|
|
@@ -2798,7 +2925,7 @@ function OptionList({
|
|
|
2798
2925
|
}
|
|
2799
2926
|
function OptionListItem({ value, ...props }) {
|
|
2800
2927
|
const { register, isSelected, allowDrag } = useOptionList();
|
|
2801
|
-
|
|
2928
|
+
React11.useLayoutEffect(() => register(value), [value]);
|
|
2802
2929
|
return /* @__PURE__ */ jsx(OptionRow, { value, selected: isSelected(value), dragEnabled: allowDrag, ...props });
|
|
2803
2930
|
}
|
|
2804
2931
|
function OptionRow({
|
|
@@ -2823,8 +2950,8 @@ function OptionRow({
|
|
|
2823
2950
|
...props
|
|
2824
2951
|
}) {
|
|
2825
2952
|
const list = useOptionList();
|
|
2826
|
-
const id =
|
|
2827
|
-
const [focusWithin, setFocusWithin] =
|
|
2953
|
+
const id = React11.useId();
|
|
2954
|
+
const [focusWithin, setFocusWithin] = React11.useState(false);
|
|
2828
2955
|
const isSelectAll = value === SELECT_ALL;
|
|
2829
2956
|
const disabled = disabledProp || list.disabled;
|
|
2830
2957
|
const context = isSelectAll || list.multiSelect ? "multi" : "single";
|
|
@@ -3011,23 +3138,23 @@ function OptionRow({
|
|
|
3011
3138
|
function OptionListSection(props) {
|
|
3012
3139
|
return /* @__PURE__ */ jsx(ActionListSection, { ...props });
|
|
3013
3140
|
}
|
|
3014
|
-
var SheetContext =
|
|
3141
|
+
var SheetContext = React11.createContext(false);
|
|
3015
3142
|
function Popover({ mobileBottomSheet = true, ...props }) {
|
|
3016
3143
|
const sheet = useMobile() && mobileBottomSheet;
|
|
3017
3144
|
return /* @__PURE__ */ jsx(SheetContext.Provider, { value: sheet, children: sheet ? /* @__PURE__ */ jsx(Dialog$1.Root, { ...props }) : /* @__PURE__ */ jsx(Popover$1.Root, { ...props }) });
|
|
3018
3145
|
}
|
|
3019
3146
|
function PopoverTrigger(props) {
|
|
3020
|
-
return
|
|
3147
|
+
return React11.useContext(SheetContext) ? /* @__PURE__ */ jsx(Dialog$1.Trigger, { ...props }) : /* @__PURE__ */ jsx(Popover$1.Trigger, { ...props });
|
|
3021
3148
|
}
|
|
3022
3149
|
function PopoverClose(props) {
|
|
3023
|
-
return
|
|
3150
|
+
return React11.useContext(SheetContext) ? /* @__PURE__ */ jsx(Dialog$1.Close, { ...props }) : /* @__PURE__ */ jsx(Popover$1.Close, { ...props });
|
|
3024
3151
|
}
|
|
3025
3152
|
function PopoverAnchor({
|
|
3026
3153
|
asChild,
|
|
3027
3154
|
children,
|
|
3028
3155
|
...props
|
|
3029
3156
|
}) {
|
|
3030
|
-
if (!
|
|
3157
|
+
if (!React11.useContext(SheetContext)) {
|
|
3031
3158
|
return /* @__PURE__ */ jsx(Popover$1.Anchor, { asChild, ...props, children });
|
|
3032
3159
|
}
|
|
3033
3160
|
return asChild ? children : /* @__PURE__ */ jsx("div", { ...props, children });
|
|
@@ -3056,7 +3183,7 @@ function PopoverContent({
|
|
|
3056
3183
|
children,
|
|
3057
3184
|
...props
|
|
3058
3185
|
}) {
|
|
3059
|
-
const sheet =
|
|
3186
|
+
const sheet = React11.useContext(SheetContext);
|
|
3060
3187
|
if (sheet) {
|
|
3061
3188
|
return /* @__PURE__ */ jsxs(Dialog$1.Portal, { children: [
|
|
3062
3189
|
/* @__PURE__ */ jsx(
|
|
@@ -3165,9 +3292,9 @@ function SelectSection(_props) {
|
|
|
3165
3292
|
}
|
|
3166
3293
|
function collectOptions(children, section) {
|
|
3167
3294
|
const options = [];
|
|
3168
|
-
|
|
3169
|
-
if (!
|
|
3170
|
-
if (child.type ===
|
|
3295
|
+
React11.Children.forEach(children, (child) => {
|
|
3296
|
+
if (!React11.isValidElement(child)) return;
|
|
3297
|
+
if (child.type === React11.Fragment) {
|
|
3171
3298
|
options.push(...collectOptions(child.props.children, section));
|
|
3172
3299
|
} else if (child.type === SelectSection) {
|
|
3173
3300
|
const props = child.props;
|
|
@@ -3204,21 +3331,21 @@ function Select(props) {
|
|
|
3204
3331
|
const standalone = standaloneProp || !field;
|
|
3205
3332
|
const disabled = disabledProp ?? field?.disabled ?? false;
|
|
3206
3333
|
const readOnly = field?.readOnly ?? false;
|
|
3207
|
-
const [uncontrolled, setUncontrolled] =
|
|
3334
|
+
const [uncontrolled, setUncontrolled] = React11.useState(
|
|
3208
3335
|
() => toArray(props.defaultValue) ?? []
|
|
3209
3336
|
);
|
|
3210
3337
|
const value = toArray(props.value) ?? uncontrolled;
|
|
3211
|
-
const [open, setOpen] =
|
|
3212
|
-
const [term, setTerm] =
|
|
3213
|
-
const options =
|
|
3338
|
+
const [open, setOpen] = React11.useState(false);
|
|
3339
|
+
const [term, setTerm] = React11.useState("");
|
|
3340
|
+
const options = React11.useMemo(() => collectOptions(children), [children]);
|
|
3214
3341
|
const selected = value.map((v) => options.find((o) => o.value === v)).filter((o) => Boolean(o));
|
|
3215
3342
|
const filled = value.length > 0;
|
|
3216
3343
|
const setFilled = field?.setFilled;
|
|
3217
3344
|
const setHasPlaceholder = field?.setHasPlaceholder;
|
|
3218
|
-
|
|
3345
|
+
React11.useEffect(() => {
|
|
3219
3346
|
setFilled?.(filled);
|
|
3220
3347
|
}, [setFilled, filled]);
|
|
3221
|
-
|
|
3348
|
+
React11.useEffect(() => {
|
|
3222
3349
|
setHasPlaceholder?.(Boolean(placeholder));
|
|
3223
3350
|
}, [setHasPlaceholder, placeholder]);
|
|
3224
3351
|
const update = (next) => {
|
|
@@ -3226,12 +3353,12 @@ function Select(props) {
|
|
|
3226
3353
|
if (multiSelect) props.onValueChange?.(next);
|
|
3227
3354
|
else props.onValueChange?.(next[0] ?? "");
|
|
3228
3355
|
};
|
|
3229
|
-
const generatedId =
|
|
3356
|
+
const generatedId = React11.useId();
|
|
3230
3357
|
const triggerId = id ?? field?.id ?? generatedId;
|
|
3231
3358
|
const listId = `${triggerId}-options`;
|
|
3232
|
-
const contentRef =
|
|
3233
|
-
const [anchor, setAnchor] =
|
|
3234
|
-
const [boxWidth, setBoxWidth] =
|
|
3359
|
+
const contentRef = React11.useRef(null);
|
|
3360
|
+
const [anchor, setAnchor] = React11.useState(null);
|
|
3361
|
+
const [boxWidth, setBoxWidth] = React11.useState();
|
|
3235
3362
|
const openChange = (next) => {
|
|
3236
3363
|
if (next && (disabled || readOnly)) return;
|
|
3237
3364
|
if (next) {
|
|
@@ -3246,7 +3373,7 @@ function Select(props) {
|
|
|
3246
3373
|
setOpen(next);
|
|
3247
3374
|
};
|
|
3248
3375
|
const shown = filter && term ? options.filter((o) => o.label.toLowerCase().includes(term.toLowerCase())) : options;
|
|
3249
|
-
const typeahead =
|
|
3376
|
+
const typeahead = React11.useRef({ buffer: "", timer: void 0 });
|
|
3250
3377
|
const onListKeyDown = (event) => {
|
|
3251
3378
|
if (event.key.length !== 1 || event.metaKey || event.ctrlKey || event.altKey || event.key === " ") return;
|
|
3252
3379
|
if (event.target.tagName === "INPUT") return;
|
|
@@ -3294,7 +3421,7 @@ function Select(props) {
|
|
|
3294
3421
|
},
|
|
3295
3422
|
option.value
|
|
3296
3423
|
));
|
|
3297
|
-
return section ? /* @__PURE__ */ jsx(OptionListSection, { label: section, children: rendered }, section) : /* @__PURE__ */ jsx(
|
|
3424
|
+
return section ? /* @__PURE__ */ jsx(OptionListSection, { label: section, children: rendered }, section) : /* @__PURE__ */ jsx(React11.Fragment, { children: rendered }, `items-${index}`);
|
|
3298
3425
|
})
|
|
3299
3426
|
}
|
|
3300
3427
|
);
|
|
@@ -3473,7 +3600,7 @@ function Autocomplete(props) {
|
|
|
3473
3600
|
const multiSelect = multiSelectProp === true;
|
|
3474
3601
|
const field = useField();
|
|
3475
3602
|
const disabled = disabledProp ?? field?.disabled ?? false;
|
|
3476
|
-
const [uncontrolled, setUncontrolled] =
|
|
3603
|
+
const [uncontrolled, setUncontrolled] = React11.useState(
|
|
3477
3604
|
() => defaultValue ?? (multiSelect ? [] : void 0)
|
|
3478
3605
|
);
|
|
3479
3606
|
const value = valueProp !== void 0 ? valueProp : uncontrolled;
|
|
@@ -3483,15 +3610,15 @@ function Autocomplete(props) {
|
|
|
3483
3610
|
if (valueProp === void 0) setUncontrolled(next);
|
|
3484
3611
|
onValueChange?.(next);
|
|
3485
3612
|
};
|
|
3486
|
-
const [text, setText] =
|
|
3487
|
-
const [open, setOpen] =
|
|
3488
|
-
const [loading, setLoading] =
|
|
3489
|
-
const [suggestions, setSuggestions] =
|
|
3490
|
-
const generatedId =
|
|
3613
|
+
const [text, setText] = React11.useState(() => single?.label ?? "");
|
|
3614
|
+
const [open, setOpen] = React11.useState(false);
|
|
3615
|
+
const [loading, setLoading] = React11.useState(false);
|
|
3616
|
+
const [suggestions, setSuggestions] = React11.useState([]);
|
|
3617
|
+
const generatedId = React11.useId();
|
|
3491
3618
|
const inputId = id ?? field?.id ?? generatedId;
|
|
3492
3619
|
const listId = `${inputId}-suggestions`;
|
|
3493
3620
|
const getInput = () => document.getElementById(inputId);
|
|
3494
|
-
const request =
|
|
3621
|
+
const request = React11.useRef(0);
|
|
3495
3622
|
const updateSuggestions = async (term) => {
|
|
3496
3623
|
const current = ++request.current;
|
|
3497
3624
|
setLoading(true);
|
|
@@ -3501,8 +3628,8 @@ function Autocomplete(props) {
|
|
|
3501
3628
|
setSuggestions(next);
|
|
3502
3629
|
setLoading(false);
|
|
3503
3630
|
};
|
|
3504
|
-
const [anchor, setAnchor] =
|
|
3505
|
-
const [geometry, setGeometry] =
|
|
3631
|
+
const [anchor, setAnchor] = React11.useState(null);
|
|
3632
|
+
const [geometry, setGeometry] = React11.useState({ width: 0, sideOffset: 0, alignOffset: 0 });
|
|
3506
3633
|
const compact = field ? field.inline || field.labelPosition === "outside" : true;
|
|
3507
3634
|
const show = () => {
|
|
3508
3635
|
if (open || disabled) return;
|
|
@@ -3525,8 +3652,8 @@ function Autocomplete(props) {
|
|
|
3525
3652
|
setText(multiSelect ? "" : single?.label ?? "");
|
|
3526
3653
|
setOpen(false);
|
|
3527
3654
|
};
|
|
3528
|
-
const debounce =
|
|
3529
|
-
|
|
3655
|
+
const debounce = React11.useRef(void 0);
|
|
3656
|
+
React11.useEffect(() => () => clearTimeout(debounce.current), []);
|
|
3530
3657
|
const onTextChange = (event) => {
|
|
3531
3658
|
const term = event.target.value;
|
|
3532
3659
|
setText(term);
|
|
@@ -3556,12 +3683,12 @@ function Autocomplete(props) {
|
|
|
3556
3683
|
getInput()?.focus();
|
|
3557
3684
|
};
|
|
3558
3685
|
const parentSetFilled = field?.setFilled;
|
|
3559
|
-
const [textFilled, setTextFilled] =
|
|
3686
|
+
const [textFilled, setTextFilled] = React11.useState(false);
|
|
3560
3687
|
const filled = textFilled || chosen.length > 0;
|
|
3561
|
-
|
|
3688
|
+
React11.useEffect(() => {
|
|
3562
3689
|
parentSetFilled?.(filled);
|
|
3563
3690
|
}, [parentSetFilled, filled]);
|
|
3564
|
-
const innerField =
|
|
3691
|
+
const innerField = React11.useMemo(
|
|
3565
3692
|
() => field ? { ...field, setFilled: setTextFilled } : null,
|
|
3566
3693
|
[field]
|
|
3567
3694
|
);
|
|
@@ -3683,8 +3810,8 @@ function DayButton({ day: _day, modifiers, className, ...props }) {
|
|
|
3683
3810
|
const start = modifiers.range_start && !modifiers.range_end;
|
|
3684
3811
|
const end = modifiers.range_end && !modifiers.range_start;
|
|
3685
3812
|
const filled = modifiers.selected && !middle;
|
|
3686
|
-
const ref =
|
|
3687
|
-
|
|
3813
|
+
const ref = React11.useRef(null);
|
|
3814
|
+
React11.useEffect(() => {
|
|
3688
3815
|
if (modifiers.focused) ref.current?.focus();
|
|
3689
3816
|
}, [modifiers.focused]);
|
|
3690
3817
|
return /* @__PURE__ */ jsx(
|
|
@@ -3727,30 +3854,30 @@ function DatePicker(props) {
|
|
|
3727
3854
|
} = props;
|
|
3728
3855
|
const labels = { ...defaultLabels, ...labelsProp };
|
|
3729
3856
|
const range = props.range === true;
|
|
3730
|
-
const [single, setSingle] =
|
|
3857
|
+
const [single, setSingle] = React11.useState(
|
|
3731
3858
|
() => range ? void 0 : props.defaultValue
|
|
3732
3859
|
);
|
|
3733
|
-
const [pending, setPending] =
|
|
3860
|
+
const [pending, setPending] = React11.useState(() => {
|
|
3734
3861
|
const initial = range ? props.defaultValue : void 0;
|
|
3735
3862
|
return initial ? { from: initial[0], to: initial[1] } : void 0;
|
|
3736
3863
|
});
|
|
3737
3864
|
const controlled = props.value !== void 0;
|
|
3738
3865
|
const selectedSingle = range ? void 0 : controlled ? props.value : single;
|
|
3739
3866
|
const controlledRange = range && controlled ? props.value : void 0;
|
|
3740
|
-
const [editing, setEditing] =
|
|
3867
|
+
const [editing, setEditing] = React11.useState(false);
|
|
3741
3868
|
const selectedRange = controlledRange && !editing ? { from: controlledRange[0], to: controlledRange[1] } : pending;
|
|
3742
3869
|
const first = range ? selectedRange?.from : selectedSingle;
|
|
3743
|
-
const [month, setMonth] =
|
|
3870
|
+
const [month, setMonth] = React11.useState(() => {
|
|
3744
3871
|
const date = first ?? startDate ?? /* @__PURE__ */ new Date();
|
|
3745
3872
|
return new Date(date.getFullYear(), date.getMonth(), 1);
|
|
3746
3873
|
});
|
|
3747
|
-
const monthNames =
|
|
3874
|
+
const monthNames = React11.useMemo(() => {
|
|
3748
3875
|
const format = new Intl.DateTimeFormat(locale, { month: "long" });
|
|
3749
3876
|
return Array.from({ length: 12 }, (_, i) => format.format(new Date(2e3, i, 1)));
|
|
3750
3877
|
}, [locale]);
|
|
3751
|
-
const weekday =
|
|
3752
|
-
const weekdayLong =
|
|
3753
|
-
const fullDate =
|
|
3878
|
+
const weekday = React11.useMemo(() => new Intl.DateTimeFormat(locale, { weekday: "short" }), [locale]);
|
|
3879
|
+
const weekdayLong = React11.useMemo(() => new Intl.DateTimeFormat(locale, { weekday: "long" }), [locale]);
|
|
3880
|
+
const fullDate = React11.useMemo(() => new Intl.DateTimeFormat(locale, { dateStyle: "long" }), [locale]);
|
|
3754
3881
|
const step = (by) => setMonth((m) => new Date(m.getFullYear(), m.getMonth() + by, 1));
|
|
3755
3882
|
const shared = {
|
|
3756
3883
|
month,
|
|
@@ -4025,20 +4152,20 @@ function DateInput({
|
|
|
4025
4152
|
const pattern = normalizePattern(format$1);
|
|
4026
4153
|
const disabled = disabledProp ?? field?.disabled ?? false;
|
|
4027
4154
|
const readOnly = readOnlyProp ?? field?.readOnly ?? false;
|
|
4028
|
-
const [uncontrolled, setUncontrolled] =
|
|
4155
|
+
const [uncontrolled, setUncontrolled] = React11.useState(defaultValue ?? "");
|
|
4029
4156
|
const value = valueProp ?? uncontrolled;
|
|
4030
4157
|
const display2 = (iso) => {
|
|
4031
4158
|
const date2 = fromIso(iso);
|
|
4032
4159
|
return date2 ? format(date2, pattern) : "";
|
|
4033
4160
|
};
|
|
4034
|
-
const [text, setText] =
|
|
4035
|
-
const [shown, setShown] =
|
|
4161
|
+
const [text, setText] = React11.useState(() => display2(value));
|
|
4162
|
+
const [shown, setShown] = React11.useState(value);
|
|
4036
4163
|
if (value !== shown) {
|
|
4037
4164
|
setShown(value);
|
|
4038
4165
|
setText(display2(value));
|
|
4039
4166
|
}
|
|
4040
|
-
const [open, setOpen] =
|
|
4041
|
-
const generatedId =
|
|
4167
|
+
const [open, setOpen] = React11.useState(false);
|
|
4168
|
+
const generatedId = React11.useId();
|
|
4042
4169
|
const inputId = id ?? field?.id ?? generatedId;
|
|
4043
4170
|
const commit = (iso) => {
|
|
4044
4171
|
setShown(iso);
|
|
@@ -4065,7 +4192,7 @@ function DateInput({
|
|
|
4065
4192
|
const pickOnly = preferredInputMode === "pick" && mobile;
|
|
4066
4193
|
const compact = field ? field.inline || field.labelPosition === "outside" : true;
|
|
4067
4194
|
const collapsed = Boolean(field && !compact && field.labelAsPlaceholder);
|
|
4068
|
-
const innerField =
|
|
4195
|
+
const innerField = React11.useMemo(
|
|
4069
4196
|
() => field ? { ...field, setHasPlaceholder: () => {
|
|
4070
4197
|
} } : null,
|
|
4071
4198
|
[field]
|
|
@@ -4165,10 +4292,10 @@ function TimeInput({
|
|
|
4165
4292
|
}) {
|
|
4166
4293
|
const field = useField();
|
|
4167
4294
|
const pattern = normalizePattern(format$1);
|
|
4168
|
-
const [uncontrolled, setUncontrolled] =
|
|
4295
|
+
const [uncontrolled, setUncontrolled] = React11.useState(defaultValue ?? "");
|
|
4169
4296
|
const value = valueProp ?? uncontrolled;
|
|
4170
|
-
const [text, setText] =
|
|
4171
|
-
const [shown, setShown] =
|
|
4297
|
+
const [text, setText] = React11.useState(() => display(value, pattern));
|
|
4298
|
+
const [shown, setShown] = React11.useState(value);
|
|
4172
4299
|
if (value !== shown) {
|
|
4173
4300
|
setShown(value);
|
|
4174
4301
|
setText(display(value, pattern));
|
|
@@ -4190,7 +4317,7 @@ function TimeInput({
|
|
|
4190
4317
|
};
|
|
4191
4318
|
const compact = field ? field.inline || field.labelPosition === "outside" : true;
|
|
4192
4319
|
const collapsed = Boolean(field && !compact && field.labelAsPlaceholder);
|
|
4193
|
-
const innerField =
|
|
4320
|
+
const innerField = React11.useMemo(
|
|
4194
4321
|
() => field ? { ...field, setHasPlaceholder: () => {
|
|
4195
4322
|
} } : null,
|
|
4196
4323
|
[field]
|
|
@@ -4244,7 +4371,7 @@ function ColorInput({
|
|
|
4244
4371
|
const field = useField();
|
|
4245
4372
|
const disabled = disabledProp ?? field?.disabled ?? false;
|
|
4246
4373
|
const readOnly = readOnlyProp ?? field?.readOnly ?? false;
|
|
4247
|
-
const [uncontrolled, setUncontrolled] =
|
|
4374
|
+
const [uncontrolled, setUncontrolled] = React11.useState(defaultValue ?? "");
|
|
4248
4375
|
const value = valueProp ?? uncontrolled;
|
|
4249
4376
|
const update = (next) => {
|
|
4250
4377
|
if (valueProp === void 0) setUncontrolled(next);
|
|
@@ -4306,10 +4433,10 @@ function FileUploader({
|
|
|
4306
4433
|
ref,
|
|
4307
4434
|
...props
|
|
4308
4435
|
}) {
|
|
4309
|
-
const generatedId =
|
|
4436
|
+
const generatedId = React11.useId();
|
|
4310
4437
|
const inputId = id ?? generatedId;
|
|
4311
4438
|
const getInput = () => document.getElementById(inputId);
|
|
4312
|
-
|
|
4439
|
+
React11.useImperativeHandle(ref, () => ({
|
|
4313
4440
|
reset: () => {
|
|
4314
4441
|
const input = getInput();
|
|
4315
4442
|
if (input) input.value = "";
|
|
@@ -4430,10 +4557,10 @@ function Search({
|
|
|
4430
4557
|
onChange?.(event);
|
|
4431
4558
|
onValueChange?.(event.target.value);
|
|
4432
4559
|
});
|
|
4433
|
-
const generatedId =
|
|
4560
|
+
const generatedId = React11.useId();
|
|
4434
4561
|
const inputId = id ?? generatedId;
|
|
4435
4562
|
const getInput = () => document.getElementById(inputId);
|
|
4436
|
-
|
|
4563
|
+
React11.useEffect(() => {
|
|
4437
4564
|
if (!shortcut || disabled) return;
|
|
4438
4565
|
const onKeyDown = (event) => {
|
|
4439
4566
|
if ((event.code === "KeyK" || event.code === "Slash") && (event.metaKey || event.ctrlKey)) {
|
|
@@ -4519,8 +4646,8 @@ function Toolbar({
|
|
|
4519
4646
|
children,
|
|
4520
4647
|
...props
|
|
4521
4648
|
}) {
|
|
4522
|
-
const ref =
|
|
4523
|
-
|
|
4649
|
+
const ref = React11.useRef(null);
|
|
4650
|
+
React11.useEffect(() => {
|
|
4524
4651
|
const toolbar = ref.current;
|
|
4525
4652
|
if (!toolbar) return;
|
|
4526
4653
|
const apply = () => {
|
|
@@ -4591,7 +4718,7 @@ function ToggleGroup({
|
|
|
4591
4718
|
...props
|
|
4592
4719
|
}) {
|
|
4593
4720
|
const single = props.type === "single";
|
|
4594
|
-
const [uncontrolled, setUncontrolled] =
|
|
4721
|
+
const [uncontrolled, setUncontrolled] = React11.useState(
|
|
4595
4722
|
single ? props.defaultValue ?? "" : ""
|
|
4596
4723
|
);
|
|
4597
4724
|
const classes = cn(
|
|
@@ -4700,7 +4827,7 @@ var contentVariants = cva(
|
|
|
4700
4827
|
default: [
|
|
4701
4828
|
"inset-0 h-dvh max-h-dvh w-screen max-w-[100vw]",
|
|
4702
4829
|
"data-[state=open]:zoom-in-0 data-[state=closed]:fade-out-0",
|
|
4703
|
-
"md:inset-auto md:top-1/2 md:left-1/2 md:h-auto md:max-h-[90dvh] md:w-[90vw] md:-translate-x-1/2 md:-translate-y-1/2",
|
|
4830
|
+
"md:inset-auto md:top-1/2 md:left-1/2 md:h-auto md:max-h-[var(--dialog-max-height,90dvh)] md:w-[90vw] md:-translate-x-1/2 md:-translate-y-1/2",
|
|
4704
4831
|
"md:rounded-base md:shadow-level-3"
|
|
4705
4832
|
],
|
|
4706
4833
|
drawer: [
|
|
@@ -4725,9 +4852,9 @@ var contentVariants = cva(
|
|
|
4725
4852
|
}
|
|
4726
4853
|
);
|
|
4727
4854
|
function useScrollState() {
|
|
4728
|
-
const [element, setElement] =
|
|
4729
|
-
const [state, setState] =
|
|
4730
|
-
const update =
|
|
4855
|
+
const [element, setElement] = React11.useState(null);
|
|
4856
|
+
const [state, setState] = React11.useState({ scrolled: false, scrollable: false, atEnd: true });
|
|
4857
|
+
const update = React11.useCallback(() => {
|
|
4731
4858
|
if (!element) return;
|
|
4732
4859
|
const next = {
|
|
4733
4860
|
scrolled: element.scrollTop > 0,
|
|
@@ -4738,7 +4865,7 @@ function useScrollState() {
|
|
|
4738
4865
|
(prev) => prev.scrolled === next.scrolled && prev.scrollable === next.scrollable && prev.atEnd === next.atEnd ? prev : next
|
|
4739
4866
|
);
|
|
4740
4867
|
}, [element]);
|
|
4741
|
-
|
|
4868
|
+
React11.useEffect(() => {
|
|
4742
4869
|
if (!element) return;
|
|
4743
4870
|
const observer = new ResizeObserver(update);
|
|
4744
4871
|
observer.observe(element);
|
|
@@ -4763,6 +4890,7 @@ function DialogContent({
|
|
|
4763
4890
|
secondaryActionLabel,
|
|
4764
4891
|
onPrimaryAction,
|
|
4765
4892
|
onSecondaryAction,
|
|
4893
|
+
customFooter,
|
|
4766
4894
|
headerTools,
|
|
4767
4895
|
secondaryContent,
|
|
4768
4896
|
hideSecondaryContentBorders = false,
|
|
@@ -4772,6 +4900,7 @@ function DialogContent({
|
|
|
4772
4900
|
sidebarPadded = true,
|
|
4773
4901
|
sidebarFooterPadded = true,
|
|
4774
4902
|
maxWidth,
|
|
4903
|
+
maxHeight,
|
|
4775
4904
|
style,
|
|
4776
4905
|
...props
|
|
4777
4906
|
}) {
|
|
@@ -4782,9 +4911,10 @@ function DialogContent({
|
|
|
4782
4911
|
const hasSecondary = secondaryContent !== void 0;
|
|
4783
4912
|
const hasSidebar = sidebarContent !== void 0;
|
|
4784
4913
|
const hasTools = headerTools !== void 0;
|
|
4785
|
-
const
|
|
4914
|
+
const hasCustomFooter = customFooter !== void 0 && customFooter !== null;
|
|
4915
|
+
const hasControls = !hasCustomFooter && Boolean(primaryActionLabel || secondaryActionLabel);
|
|
4786
4916
|
const secondaryBorders = hasSecondary && !hideSecondaryContentBorders;
|
|
4787
|
-
const id =
|
|
4917
|
+
const id = React11.useId();
|
|
4788
4918
|
const { setElement: setMainElement, update: updateMain, ...main } = useScrollState();
|
|
4789
4919
|
const { setElement: setSidebarElement, update: updateSidebar, ...sidebar } = useScrollState();
|
|
4790
4920
|
const width = hasSidebar ? "md:max-w-[65rem]" : hasSecondary ? "md:max-w-[64rem]" : "md:max-w-[40rem]";
|
|
@@ -4795,7 +4925,11 @@ function DialogContent({
|
|
|
4795
4925
|
{
|
|
4796
4926
|
...label ? { "aria-describedby": void 0 } : {},
|
|
4797
4927
|
className: cn(variantName !== "sheet" && width, contentVariants({ variant, size }), className),
|
|
4798
|
-
style: {
|
|
4928
|
+
style: {
|
|
4929
|
+
...maxWidth ? { maxWidth } : {},
|
|
4930
|
+
...maxHeight ? { "--dialog-max-height": maxHeight } : {},
|
|
4931
|
+
...style
|
|
4932
|
+
},
|
|
4799
4933
|
...props,
|
|
4800
4934
|
children: [
|
|
4801
4935
|
hasSidebar && /* @__PURE__ */ jsxs("aside", { className: "hidden w-[25rem] shrink-0 flex-col overflow-y-auto border-r border-border md:flex", children: [
|
|
@@ -4928,15 +5062,16 @@ function DialogContent({
|
|
|
4928
5062
|
}
|
|
4929
5063
|
)
|
|
4930
5064
|
] }),
|
|
4931
|
-
hasControls && /* @__PURE__ */ jsx(
|
|
5065
|
+
(hasControls || hasCustomFooter) && /* @__PURE__ */ jsx(
|
|
4932
5066
|
"footer",
|
|
4933
5067
|
{
|
|
4934
5068
|
className: cn(
|
|
4935
|
-
"
|
|
5069
|
+
"shrink-0",
|
|
5070
|
+
!hasCustomFooter && "flex justify-end",
|
|
4936
5071
|
"px-4 pt-3 pb-[max(env(safe-area-inset-bottom),0.75rem)] md:px-6 md:pt-4 md:pb-[max(env(safe-area-inset-bottom),1rem)]",
|
|
4937
5072
|
(main.scrollable && !main.atEnd || secondaryBorders) && "border-t border-border"
|
|
4938
5073
|
),
|
|
4939
|
-
children: /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap justify-end gap-2", children: [
|
|
5074
|
+
children: hasCustomFooter ? customFooter : /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap justify-end gap-2", children: [
|
|
4940
5075
|
secondaryActionLabel && /* @__PURE__ */ jsx(Button, { label: secondaryActionLabel, onClick: onSecondaryAction }),
|
|
4941
5076
|
primaryActionLabel && /* @__PURE__ */ jsx(Button, { variant: "flat", intent: "primary", label: primaryActionLabel, onClick: onPrimaryAction })
|
|
4942
5077
|
] })
|
|
@@ -4994,9 +5129,9 @@ var ChevronLeftIcon = () => glyph("M13.2 17.4L8.59999 12.8C8.48333 12.6834 8.399
|
|
|
4994
5129
|
var CloseIcon = () => glyph("M12 13.6L7.19999 18.4C6.98333 18.6167 6.71666 18.725 6.39999 18.725C6.08333 18.725 5.81666 18.6167 5.59999 18.4C5.38333 18.1834 5.27499 17.9167 5.27499 17.6C5.27499 17.2834 5.38333 17.0167 5.59999 16.8L10.4 12L5.59999 7.20002C5.38333 6.98336 5.27499 6.71669 5.27499 6.40002C5.27499 6.08336 5.38333 5.81669 5.59999 5.60002C5.81666 5.38336 6.08333 5.27502 6.39999 5.27502C6.71666 5.27502 6.98333 5.38336 7.19999 5.60002L12 10.4L16.8 5.60002C17.0167 5.38336 17.2833 5.27502 17.6 5.27502C17.9167 5.27502 18.1833 5.38336 18.4 5.60002C18.6167 5.81669 18.725 6.08336 18.725 6.40002C18.725 6.71669 18.6167 6.98336 18.4 7.20002L13.6 12L18.4 16.8C18.6167 17.0167 18.725 17.2834 18.725 17.6C18.725 17.9167 18.6167 18.1834 18.4 18.4C18.1833 18.6167 17.9167 18.725 17.6 18.725C17.2833 18.725 17.0167 18.6167 16.8 18.4L12 13.6Z");
|
|
4995
5130
|
function collect(children, type) {
|
|
4996
5131
|
const found = [];
|
|
4997
|
-
|
|
4998
|
-
if (!
|
|
4999
|
-
if (child.type ===
|
|
5132
|
+
React11.Children.forEach(children, (child) => {
|
|
5133
|
+
if (!React11.isValidElement(child)) return;
|
|
5134
|
+
if (child.type === React11.Fragment) {
|
|
5000
5135
|
found.push(...collect(child.props.children, type));
|
|
5001
5136
|
} else if (child.type === type) {
|
|
5002
5137
|
found.push(child);
|
|
@@ -5021,7 +5156,7 @@ function parseMenu(props, id) {
|
|
|
5021
5156
|
};
|
|
5022
5157
|
}
|
|
5023
5158
|
function useSelections(root2) {
|
|
5024
|
-
const [values, setValues] =
|
|
5159
|
+
const [values, setValues] = React11.useState({});
|
|
5025
5160
|
const valueOf = (menu) => menu.props.value ?? (menu.id in values ? values[menu.id] : menu.props.defaultValue);
|
|
5026
5161
|
const select = (menu, value) => {
|
|
5027
5162
|
menu.props.onValueChange?.(value);
|
|
@@ -5035,7 +5170,7 @@ function useSelections(root2) {
|
|
|
5035
5170
|
return { valueOf, select, chosenLabel, root: root2 };
|
|
5036
5171
|
}
|
|
5037
5172
|
function useOpen(props) {
|
|
5038
|
-
const [uncontrolled, setUncontrolled] =
|
|
5173
|
+
const [uncontrolled, setUncontrolled] = React11.useState(props.defaultOpen ?? false);
|
|
5039
5174
|
const open = props.open ?? uncontrolled;
|
|
5040
5175
|
const setOpen = (next) => {
|
|
5041
5176
|
props.onOpenChange?.(next);
|
|
@@ -5049,9 +5184,9 @@ var subSurface = [
|
|
|
5049
5184
|
"before:absolute before:inset-0 before:-z-10 before:rounded-[inherit] before:bg-translucent-low before:backdrop-blur-l"
|
|
5050
5185
|
];
|
|
5051
5186
|
function DesktopItems({ menu, selections }) {
|
|
5052
|
-
const [openSub, setOpenSub] =
|
|
5053
|
-
const subContents =
|
|
5054
|
-
|
|
5187
|
+
const [openSub, setOpenSub] = React11.useState(null);
|
|
5188
|
+
const subContents = React11.useRef(/* @__PURE__ */ new Map());
|
|
5189
|
+
React11.useEffect(() => {
|
|
5055
5190
|
if (!openSub) return;
|
|
5056
5191
|
const frame = requestAnimationFrame(() => {
|
|
5057
5192
|
subContents.current.get(openSub)?.querySelector('[role^="menuitem"]:not([data-disabled])')?.focus();
|
|
@@ -5167,11 +5302,11 @@ function DesktopMenu({ root: root2, selections }) {
|
|
|
5167
5302
|
var SLIDE_MS = 200;
|
|
5168
5303
|
function MobileMenu({ root: root2, selections }) {
|
|
5169
5304
|
const [open, setOpen] = useOpen(root2.props);
|
|
5170
|
-
const [stack, setStack] =
|
|
5171
|
-
const [depth, setDepth] =
|
|
5172
|
-
const panels =
|
|
5173
|
-
const returnTo =
|
|
5174
|
-
const titleId =
|
|
5305
|
+
const [stack, setStack] = React11.useState([root2]);
|
|
5306
|
+
const [depth, setDepth] = React11.useState(0);
|
|
5307
|
+
const panels = React11.useRef(/* @__PURE__ */ new Map());
|
|
5308
|
+
const returnTo = React11.useRef([]);
|
|
5309
|
+
const titleId = React11.useId();
|
|
5175
5310
|
const focusIn = (menuId, itemId) => {
|
|
5176
5311
|
const panel = panels.current.get(menuId);
|
|
5177
5312
|
const target = itemId ? panel?.querySelector(`[data-item="${itemId}"]`) : panel?.querySelector('[role^="menuitem"]:not([disabled])');
|
|
@@ -5457,7 +5592,7 @@ function AlertDialogCancel({ variant = "ghost", ...props }) {
|
|
|
5457
5592
|
return /* @__PURE__ */ jsx(AlertDialog$1.Cancel, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant, ...props }) });
|
|
5458
5593
|
}
|
|
5459
5594
|
var Tabs = Tabs$1.Root;
|
|
5460
|
-
var VariantContext =
|
|
5595
|
+
var VariantContext = React11.createContext("underline");
|
|
5461
5596
|
function TabsList({
|
|
5462
5597
|
className,
|
|
5463
5598
|
variant = "underline",
|
|
@@ -5516,7 +5651,7 @@ function TabsTrigger({
|
|
|
5516
5651
|
children,
|
|
5517
5652
|
...props
|
|
5518
5653
|
}) {
|
|
5519
|
-
const variant =
|
|
5654
|
+
const variant = React11.useContext(VariantContext);
|
|
5520
5655
|
const trigger = /* @__PURE__ */ jsxs(
|
|
5521
5656
|
Tabs$1.Trigger,
|
|
5522
5657
|
{
|
|
@@ -5562,6 +5697,40 @@ function TabsTrigger({
|
|
|
5562
5697
|
function TabsContent({ className, ...props }) {
|
|
5563
5698
|
return /* @__PURE__ */ jsx(Tabs$1.Content, { className: cn("p-2 outline-none", className), ...props });
|
|
5564
5699
|
}
|
|
5700
|
+
function TabBar({
|
|
5701
|
+
tabs,
|
|
5702
|
+
label,
|
|
5703
|
+
variant = "default",
|
|
5704
|
+
justify = "start",
|
|
5705
|
+
wrap = false,
|
|
5706
|
+
onActivateTab,
|
|
5707
|
+
className,
|
|
5708
|
+
...props
|
|
5709
|
+
}) {
|
|
5710
|
+
const active = tabs.find((tab) => tab.active)?.id ?? "";
|
|
5711
|
+
return /* @__PURE__ */ jsx(Tabs, { value: active, onValueChange: onActivateTab, activationMode: "manual", children: /* @__PURE__ */ jsx(
|
|
5712
|
+
TabsList,
|
|
5713
|
+
{
|
|
5714
|
+
"aria-label": label,
|
|
5715
|
+
variant: variant === "pill" ? "pill" : "underline",
|
|
5716
|
+
stretch: justify === "evenly",
|
|
5717
|
+
className: cn(wrap && "flex-wrap", className),
|
|
5718
|
+
...props,
|
|
5719
|
+
children: tabs.map((tab) => /* @__PURE__ */ jsx(
|
|
5720
|
+
TabsTrigger,
|
|
5721
|
+
{
|
|
5722
|
+
value: tab.id,
|
|
5723
|
+
icon: tab.icon,
|
|
5724
|
+
suffix: tab.suffix,
|
|
5725
|
+
badge: tab.badge,
|
|
5726
|
+
tooltip: tab.tooltip,
|
|
5727
|
+
children: tab.label
|
|
5728
|
+
},
|
|
5729
|
+
tab.id
|
|
5730
|
+
))
|
|
5731
|
+
}
|
|
5732
|
+
) });
|
|
5733
|
+
}
|
|
5565
5734
|
var Accordion = Accordion$1.Root;
|
|
5566
5735
|
function AccordionItem({
|
|
5567
5736
|
className,
|
|
@@ -5644,10 +5813,10 @@ var ExpandMoreIcon = () => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", cl
|
|
|
5644
5813
|
fill: "currentColor"
|
|
5645
5814
|
}
|
|
5646
5815
|
) });
|
|
5647
|
-
var TreeViewContext =
|
|
5648
|
-
var LevelContext =
|
|
5816
|
+
var TreeViewContext = React11.createContext(null);
|
|
5817
|
+
var LevelContext = React11.createContext(0);
|
|
5649
5818
|
function useTreeView() {
|
|
5650
|
-
const context =
|
|
5819
|
+
const context = React11.useContext(TreeViewContext);
|
|
5651
5820
|
if (!context) throw new Error("TreeViewItem must be used inside a TreeView.");
|
|
5652
5821
|
return context;
|
|
5653
5822
|
}
|
|
@@ -5667,16 +5836,16 @@ function TreeView({
|
|
|
5667
5836
|
children,
|
|
5668
5837
|
...props
|
|
5669
5838
|
}) {
|
|
5670
|
-
const ref =
|
|
5671
|
-
const [uncontrolled, setUncontrolled] =
|
|
5839
|
+
const ref = React11.useRef(null);
|
|
5840
|
+
const [uncontrolled, setUncontrolled] = React11.useState(defaultExpandedItemIds);
|
|
5672
5841
|
const expanded = expandedItemIds ?? uncontrolled;
|
|
5673
|
-
const [tabStop, setTabStop2] =
|
|
5842
|
+
const [tabStop, setTabStop2] = React11.useState();
|
|
5674
5843
|
const setExpanded = (itemId, open) => {
|
|
5675
5844
|
const next = open ? Array.from(/* @__PURE__ */ new Set([...expanded, itemId])) : expanded.filter((id) => id !== itemId);
|
|
5676
5845
|
if (expandedItemIds === void 0) setUncontrolled(next);
|
|
5677
5846
|
onExpandedItemIdsChange?.(next);
|
|
5678
5847
|
};
|
|
5679
|
-
|
|
5848
|
+
React11.useLayoutEffect(() => {
|
|
5680
5849
|
if (semantics !== "tree" || !ref.current) return;
|
|
5681
5850
|
const items = visibleItems(ref.current);
|
|
5682
5851
|
if (!items.some((item) => item.dataset.itemId === tabStop)) {
|
|
@@ -5760,8 +5929,8 @@ function TreeViewItem({
|
|
|
5760
5929
|
...props
|
|
5761
5930
|
}) {
|
|
5762
5931
|
const tree = useTreeView();
|
|
5763
|
-
const level =
|
|
5764
|
-
const hasChildren =
|
|
5932
|
+
const level = React11.useContext(LevelContext);
|
|
5933
|
+
const hasChildren = React11.Children.toArray(children).some(React11.isValidElement);
|
|
5765
5934
|
const isTree = tree.semantics === "tree";
|
|
5766
5935
|
const expanded = tree.isExpanded(itemId);
|
|
5767
5936
|
const toggle = (event) => {
|
|
@@ -5840,7 +6009,7 @@ var OpenInNewIcon = () => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", cla
|
|
|
5840
6009
|
fill: "currentColor"
|
|
5841
6010
|
}
|
|
5842
6011
|
) });
|
|
5843
|
-
var LevelContext2 =
|
|
6012
|
+
var LevelContext2 = React11.createContext(1);
|
|
5844
6013
|
function TreeNavigation({ className, label, ...props }) {
|
|
5845
6014
|
return /* @__PURE__ */ jsx(
|
|
5846
6015
|
"ul",
|
|
@@ -5868,10 +6037,10 @@ function TreeNavigationItem({
|
|
|
5868
6037
|
onKeyDown,
|
|
5869
6038
|
...props
|
|
5870
6039
|
}) {
|
|
5871
|
-
const level =
|
|
5872
|
-
const id =
|
|
5873
|
-
const [expanded, setExpanded] =
|
|
5874
|
-
const hasChildren =
|
|
6040
|
+
const level = React11.useContext(LevelContext2);
|
|
6041
|
+
const id = React11.useId();
|
|
6042
|
+
const [expanded, setExpanded] = React11.useState(defaultExpanded);
|
|
6043
|
+
const hasChildren = React11.Children.toArray(children).some(React11.isValidElement);
|
|
5875
6044
|
const canToggle = expandable && hasChildren;
|
|
5876
6045
|
const nested = level > 1;
|
|
5877
6046
|
const Component = href ? "a" : "button";
|
|
@@ -6095,14 +6264,14 @@ function PageInput({
|
|
|
6095
6264
|
label,
|
|
6096
6265
|
onPage
|
|
6097
6266
|
}) {
|
|
6098
|
-
const [draft, setDraft] =
|
|
6099
|
-
const timer =
|
|
6100
|
-
const [shownPage, setShownPage] =
|
|
6267
|
+
const [draft, setDraft] = React11.useState(String(page));
|
|
6268
|
+
const timer = React11.useRef(void 0);
|
|
6269
|
+
const [shownPage, setShownPage] = React11.useState(page);
|
|
6101
6270
|
if (page !== shownPage) {
|
|
6102
6271
|
setShownPage(page);
|
|
6103
6272
|
setDraft(String(page));
|
|
6104
6273
|
}
|
|
6105
|
-
|
|
6274
|
+
React11.useEffect(() => () => clearTimeout(timer.current), []);
|
|
6106
6275
|
return /* @__PURE__ */ jsx(
|
|
6107
6276
|
"input",
|
|
6108
6277
|
{
|
|
@@ -6426,9 +6595,9 @@ var toastVariants = cva(
|
|
|
6426
6595
|
defaultVariants: { intent: "default" }
|
|
6427
6596
|
}
|
|
6428
6597
|
);
|
|
6429
|
-
var ToastContext =
|
|
6598
|
+
var ToastContext = React11.createContext(null);
|
|
6430
6599
|
function useToast() {
|
|
6431
|
-
const context =
|
|
6600
|
+
const context = React11.useContext(ToastContext);
|
|
6432
6601
|
if (!context) throw new Error("useToast must be used within a <ToastProvider>");
|
|
6433
6602
|
return context;
|
|
6434
6603
|
}
|
|
@@ -6445,23 +6614,23 @@ function ToastProvider({
|
|
|
6445
6614
|
position = "bottom-center",
|
|
6446
6615
|
label = "Notifications"
|
|
6447
6616
|
}) {
|
|
6448
|
-
const [toasts, setToasts] =
|
|
6449
|
-
const nextId =
|
|
6450
|
-
const dismiss =
|
|
6617
|
+
const [toasts, setToasts] = React11.useState([]);
|
|
6618
|
+
const nextId = React11.useRef(0);
|
|
6619
|
+
const dismiss = React11.useCallback((id) => {
|
|
6451
6620
|
setToasts((current) => current.map((t) => t.id === id ? { ...t, open: false } : t));
|
|
6452
6621
|
}, []);
|
|
6453
|
-
const toast =
|
|
6622
|
+
const toast = React11.useCallback((options) => {
|
|
6454
6623
|
const id = nextId.current++;
|
|
6455
6624
|
setToasts((current) => [...current, { ...options, id, open: true }]);
|
|
6456
6625
|
return id;
|
|
6457
6626
|
}, []);
|
|
6458
|
-
const remove =
|
|
6627
|
+
const remove = React11.useCallback((id) => {
|
|
6459
6628
|
setToasts((current) => current.filter((t) => t.id !== id));
|
|
6460
6629
|
}, []);
|
|
6461
|
-
const clearAll =
|
|
6630
|
+
const clearAll = React11.useCallback(() => {
|
|
6462
6631
|
setToasts((current) => current.map((t) => ({ ...t, open: false })));
|
|
6463
6632
|
}, []);
|
|
6464
|
-
const value =
|
|
6633
|
+
const value = React11.useMemo(() => ({ toast, dismiss, clearAll }), [toast, dismiss, clearAll]);
|
|
6465
6634
|
return /* @__PURE__ */ jsx(ToastContext.Provider, { value, children: /* @__PURE__ */ jsxs(Toast.Provider, { duration, label, swipeDirection: "right", children: [
|
|
6466
6635
|
children,
|
|
6467
6636
|
toasts.map((item) => /* @__PURE__ */ jsxs(
|
|
@@ -6576,9 +6745,9 @@ function Table({
|
|
|
6576
6745
|
children,
|
|
6577
6746
|
...props
|
|
6578
6747
|
}) {
|
|
6579
|
-
const ref =
|
|
6580
|
-
const [scroll, setScroll] =
|
|
6581
|
-
const measure =
|
|
6748
|
+
const ref = React11.useRef(null);
|
|
6749
|
+
const [scroll, setScroll] = React11.useState({ scrolled: false, scrollable: false, atEnd: true });
|
|
6750
|
+
const measure = React11.useCallback(() => {
|
|
6582
6751
|
const el = ref.current;
|
|
6583
6752
|
if (!el) return;
|
|
6584
6753
|
const max = el.scrollWidth - el.clientWidth;
|
|
@@ -6587,7 +6756,7 @@ function Table({
|
|
|
6587
6756
|
(prev) => prev.scrolled === next.scrolled && prev.scrollable === next.scrollable && prev.atEnd === next.atEnd ? prev : next
|
|
6588
6757
|
);
|
|
6589
6758
|
}, []);
|
|
6590
|
-
|
|
6759
|
+
React11.useEffect(() => {
|
|
6591
6760
|
const el = ref.current;
|
|
6592
6761
|
if (!el) return;
|
|
6593
6762
|
measure();
|
|
@@ -6818,7 +6987,7 @@ function DataCell({
|
|
|
6818
6987
|
className,
|
|
6819
6988
|
...props
|
|
6820
6989
|
}) {
|
|
6821
|
-
const id =
|
|
6990
|
+
const id = React11.useId();
|
|
6822
6991
|
const isInteractive = interactive || Boolean(href);
|
|
6823
6992
|
const Tag2 = href ? "a" : interactive ? "button" : "div";
|
|
6824
6993
|
const hasLabel = label !== void 0 && label !== null && label !== "";
|
|
@@ -6907,7 +7076,7 @@ function DataCellStack({
|
|
|
6907
7076
|
children,
|
|
6908
7077
|
...props
|
|
6909
7078
|
}) {
|
|
6910
|
-
const id =
|
|
7079
|
+
const id = React11.useId();
|
|
6911
7080
|
const showLabel = label !== void 0 && !hideLabel;
|
|
6912
7081
|
return /* @__PURE__ */ jsxs("div", { role: "group", className: cn("flex w-full flex-col gap-4", className), ...props, children: [
|
|
6913
7082
|
(showLabel || description !== void 0 || cta !== void 0) && /* @__PURE__ */ jsxs("header", { className: "flex w-full items-start justify-between gap-2", children: [
|
|
@@ -6933,16 +7102,16 @@ function DataCellStack({
|
|
|
6933
7102
|
"[&>[data-data-cell][data-size=s]:last-child:not(:first-child)]:[--data-cell-radius:var(--radius-s)_var(--radius-s)_var(--radius-base)_var(--radius-base)]",
|
|
6934
7103
|
"[&>[data-data-cell][data-size=s]:first-child:last-child]:[--data-cell-radius:var(--radius-base)]"
|
|
6935
7104
|
),
|
|
6936
|
-
children:
|
|
7105
|
+
children: React11.Children.map(
|
|
6937
7106
|
children,
|
|
6938
|
-
(child) =>
|
|
7107
|
+
(child) => React11.isValidElement(child) ? /* @__PURE__ */ jsx(DataCellListItem, { children: child }) : child
|
|
6939
7108
|
)
|
|
6940
7109
|
}
|
|
6941
7110
|
)
|
|
6942
7111
|
] });
|
|
6943
7112
|
}
|
|
6944
7113
|
function DataCellListItem({ children }) {
|
|
6945
|
-
return
|
|
7114
|
+
return React11.cloneElement(children, { role: "listitem" });
|
|
6946
7115
|
}
|
|
6947
7116
|
function fileKind(type) {
|
|
6948
7117
|
if (["image/jpeg", "image/png", "image/avif", "image/gif", "image/webp"].includes(type)) return "image";
|
|
@@ -7099,7 +7268,7 @@ var subscribeHover = (onChange) => {
|
|
|
7099
7268
|
return () => query.removeEventListener("change", onChange);
|
|
7100
7269
|
};
|
|
7101
7270
|
function useCanHover() {
|
|
7102
|
-
return
|
|
7271
|
+
return React11.useSyncExternalStore(
|
|
7103
7272
|
subscribeHover,
|
|
7104
7273
|
() => window.matchMedia(HOVER).matches,
|
|
7105
7274
|
() => true
|
|
@@ -7144,7 +7313,7 @@ function Thumbnail({
|
|
|
7144
7313
|
...props
|
|
7145
7314
|
}) {
|
|
7146
7315
|
const canHover = useCanHover();
|
|
7147
|
-
const [menuOpen, setMenuOpen] =
|
|
7316
|
+
const [menuOpen, setMenuOpen] = React11.useState(false);
|
|
7148
7317
|
const compact = sizes2[size].compact;
|
|
7149
7318
|
const uploading = progress !== void 0;
|
|
7150
7319
|
const hasAction = showEditButton || showRemoveButton;
|
|
@@ -7249,7 +7418,7 @@ function Thumbnail({
|
|
|
7249
7418
|
}
|
|
7250
7419
|
);
|
|
7251
7420
|
}
|
|
7252
|
-
var ImageGridContext =
|
|
7421
|
+
var ImageGridContext = React11.createContext(null);
|
|
7253
7422
|
var radii2 = { xs: "var(--radius-xs)", sm: "var(--radius-sm)", base: "var(--radius-base)", l: "var(--radius-l)", xl: "var(--radius-xl)" };
|
|
7254
7423
|
var layouts = {
|
|
7255
7424
|
1: "grid-cols-[100%] grid-rows-[100%]",
|
|
@@ -7260,7 +7429,7 @@ var layouts = {
|
|
|
7260
7429
|
};
|
|
7261
7430
|
var defaultRatio = { 1: "1", 2: "2/1", 3: "3/2", 4: "1" };
|
|
7262
7431
|
function ImageGrid({ label, aspectRatio, borderRadius = "sm", className, style, children, ...props }) {
|
|
7263
|
-
const items =
|
|
7432
|
+
const items = React11.Children.toArray(children).filter(React11.isValidElement);
|
|
7264
7433
|
const count = Math.min(4, items.length);
|
|
7265
7434
|
return /* @__PURE__ */ jsx(
|
|
7266
7435
|
"div",
|
|
@@ -7336,16 +7505,16 @@ function ImageGridItem({
|
|
|
7336
7505
|
className,
|
|
7337
7506
|
...props
|
|
7338
7507
|
}) {
|
|
7339
|
-
const slot =
|
|
7508
|
+
const slot = React11.useContext(ImageGridContext);
|
|
7340
7509
|
const count = slot?.count ?? 1;
|
|
7341
7510
|
const index = slot?.index ?? 0;
|
|
7342
7511
|
const overlay = overlayProp ?? slot?.overlay;
|
|
7343
|
-
const [element, setElement] =
|
|
7344
|
-
const [inView, setInView] =
|
|
7345
|
-
const [loaded, setLoaded] =
|
|
7346
|
-
const [error, setError] =
|
|
7347
|
-
const [paused, setPaused] =
|
|
7348
|
-
|
|
7512
|
+
const [element, setElement] = React11.useState(null);
|
|
7513
|
+
const [inView, setInView] = React11.useState(false);
|
|
7514
|
+
const [loaded, setLoaded] = React11.useState(false);
|
|
7515
|
+
const [error, setError] = React11.useState(false);
|
|
7516
|
+
const [paused, setPaused] = React11.useState(null);
|
|
7517
|
+
React11.useEffect(() => {
|
|
7349
7518
|
if (!element || loading !== "intersecting") return;
|
|
7350
7519
|
let timer;
|
|
7351
7520
|
const observer = new IntersectionObserver((entries) => {
|
|
@@ -7454,7 +7623,7 @@ function ImageGridItem({
|
|
|
7454
7623
|
)
|
|
7455
7624
|
] });
|
|
7456
7625
|
}
|
|
7457
|
-
var SlideContext =
|
|
7626
|
+
var SlideContext = React11.createContext({ near: true });
|
|
7458
7627
|
async function saveFile2(url, name) {
|
|
7459
7628
|
const blob = await (await fetch(url)).blob();
|
|
7460
7629
|
const href = URL.createObjectURL(blob);
|
|
@@ -7473,7 +7642,7 @@ function LightboxSlide({
|
|
|
7473
7642
|
watermark,
|
|
7474
7643
|
downloadButtonLabel = "Download"
|
|
7475
7644
|
}) {
|
|
7476
|
-
const { near } =
|
|
7645
|
+
const { near } = React11.useContext(SlideContext);
|
|
7477
7646
|
if (!near) return null;
|
|
7478
7647
|
if (IMAGE_TYPES.includes(type)) {
|
|
7479
7648
|
return /* @__PURE__ */ jsx("figure", { className: "pointer-events-none m-0 inline-flex max-h-full justify-center", children: /* @__PURE__ */ jsxs("span", { className: "relative flex max-w-full", children: [
|
|
@@ -7529,17 +7698,17 @@ function Lightbox({
|
|
|
7529
7698
|
nextSlideButtonLabel = "Next slide",
|
|
7530
7699
|
previousSlideButtonLabel = "Previous slide"
|
|
7531
7700
|
}) {
|
|
7532
|
-
const slides =
|
|
7533
|
-
const [uncontrolledOpen, setUncontrolledOpen] =
|
|
7701
|
+
const slides = React11.Children.toArray(children).filter(React11.isValidElement);
|
|
7702
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React11.useState(defaultOpen ?? false);
|
|
7534
7703
|
const isOpen = open ?? uncontrolledOpen;
|
|
7535
7704
|
const setOpen = (next) => {
|
|
7536
7705
|
if (open === void 0) setUncontrolledOpen(next);
|
|
7537
7706
|
onOpenChange?.(next);
|
|
7538
7707
|
};
|
|
7539
|
-
const swiped =
|
|
7540
|
-
const [active, setActive] =
|
|
7541
|
-
const [drag, setDrag] =
|
|
7542
|
-
const [container, setContainer] =
|
|
7708
|
+
const swiped = React11.useRef(false);
|
|
7709
|
+
const [active, setActive] = React11.useState(defaultSlide);
|
|
7710
|
+
const [drag, setDrag] = React11.useState(null);
|
|
7711
|
+
const [container, setContainer] = React11.useState(null);
|
|
7543
7712
|
const count = slides.length;
|
|
7544
7713
|
const go = (index) => {
|
|
7545
7714
|
const next = Math.max(0, Math.min(count - 1, index));
|
|
@@ -7547,7 +7716,7 @@ function Lightbox({
|
|
|
7547
7716
|
setActive(next);
|
|
7548
7717
|
onActiveSlideChange?.(next);
|
|
7549
7718
|
};
|
|
7550
|
-
|
|
7719
|
+
React11.useEffect(() => {
|
|
7551
7720
|
container?.querySelectorAll("video").forEach((video) => video.pause());
|
|
7552
7721
|
}, [active, container]);
|
|
7553
7722
|
const download = () => {
|
|
@@ -7704,14 +7873,14 @@ function Carousel({
|
|
|
7704
7873
|
children,
|
|
7705
7874
|
...props
|
|
7706
7875
|
}) {
|
|
7707
|
-
const [scroller, setScroller] =
|
|
7708
|
-
const [state, setState] =
|
|
7709
|
-
const activeKey =
|
|
7710
|
-
const slides =
|
|
7876
|
+
const [scroller, setScroller] = React11.useState(null);
|
|
7877
|
+
const [state, setState] = React11.useState({ scrollable: false, atStart: true, atEnd: true });
|
|
7878
|
+
const activeKey = React11.useRef("");
|
|
7879
|
+
const slides = React11.useCallback(
|
|
7711
7880
|
() => Array.from(scroller?.querySelectorAll(SLIDE) ?? []),
|
|
7712
7881
|
[scroller]
|
|
7713
7882
|
);
|
|
7714
|
-
const inView =
|
|
7883
|
+
const inView = React11.useCallback(
|
|
7715
7884
|
(el) => {
|
|
7716
7885
|
if (!scroller) return false;
|
|
7717
7886
|
const left = scroller.scrollLeft;
|
|
@@ -7720,7 +7889,7 @@ function Carousel({
|
|
|
7720
7889
|
},
|
|
7721
7890
|
[scroller]
|
|
7722
7891
|
);
|
|
7723
|
-
const measure =
|
|
7892
|
+
const measure = React11.useCallback(() => {
|
|
7724
7893
|
if (!scroller) return;
|
|
7725
7894
|
const all = slides();
|
|
7726
7895
|
const active = all.filter(inView);
|
|
@@ -7738,7 +7907,7 @@ function Carousel({
|
|
|
7738
7907
|
onActiveSlidesChange?.(active.map((el) => el.id));
|
|
7739
7908
|
}
|
|
7740
7909
|
}, [scroller, slides, inView, onActiveSlidesChange]);
|
|
7741
|
-
|
|
7910
|
+
React11.useEffect(() => {
|
|
7742
7911
|
if (!scroller) return;
|
|
7743
7912
|
const observer = new ResizeObserver(measure);
|
|
7744
7913
|
observer.observe(scroller);
|
|
@@ -7752,7 +7921,7 @@ function Carousel({
|
|
|
7752
7921
|
const scrollTo = (el) => {
|
|
7753
7922
|
if (scroller && el instanceof HTMLElement) scroller.scroll({ left: el.offsetLeft, behavior: "smooth" });
|
|
7754
7923
|
};
|
|
7755
|
-
|
|
7924
|
+
React11.useImperativeHandle(ref, () => ({
|
|
7756
7925
|
scrollToSlide: (id) => scrollTo(slides().find((el) => el.id === id))
|
|
7757
7926
|
}));
|
|
7758
7927
|
const previous = () => {
|
|
@@ -7873,7 +8042,7 @@ function CarouselSlide({
|
|
|
7873
8042
|
}
|
|
7874
8043
|
);
|
|
7875
8044
|
}
|
|
7876
|
-
var ResourceListContext =
|
|
8045
|
+
var ResourceListContext = React11.createContext(null);
|
|
7877
8046
|
var CONTENT = "[data-resource-list-content]";
|
|
7878
8047
|
var FOCUSABLE_IN_CONTROL = "[data-resource-list-control] :is(button, a[href], input, select, textarea, [tabindex])";
|
|
7879
8048
|
function setTabStop(list, index) {
|
|
@@ -7885,7 +8054,6 @@ function setTabStop(list, index) {
|
|
|
7885
8054
|
});
|
|
7886
8055
|
}
|
|
7887
8056
|
var ITEM2 = "data-resource-list-item";
|
|
7888
|
-
var space2 = (s) => s === void 0 ? void 0 : `var(--s-space-${s})`;
|
|
7889
8057
|
function ResourceList({
|
|
7890
8058
|
label,
|
|
7891
8059
|
semantics = "grid",
|
|
@@ -7907,15 +8075,15 @@ function ResourceList({
|
|
|
7907
8075
|
children,
|
|
7908
8076
|
...props
|
|
7909
8077
|
}) {
|
|
7910
|
-
const ref =
|
|
7911
|
-
const [drag, setDrag] =
|
|
7912
|
-
const [assistiveText, setAssistiveText] =
|
|
7913
|
-
const focused =
|
|
8078
|
+
const ref = React11.useRef(null);
|
|
8079
|
+
const [drag, setDrag] = React11.useState(null);
|
|
8080
|
+
const [assistiveText, setAssistiveText] = React11.useState("");
|
|
8081
|
+
const focused = React11.useRef(0);
|
|
7914
8082
|
const contents = () => Array.from(ref.current?.querySelectorAll(CONTENT) ?? []);
|
|
7915
8083
|
const itemValues = () => Array.from(ref.current?.querySelectorAll(`[${ITEM2}]`) ?? []).map(
|
|
7916
8084
|
(el) => el.getAttribute(ITEM2)
|
|
7917
8085
|
);
|
|
7918
|
-
|
|
8086
|
+
React11.useEffect(() => {
|
|
7919
8087
|
const list = ref.current;
|
|
7920
8088
|
if (!list || semantics !== "grid") return;
|
|
7921
8089
|
const sync = () => {
|
|
@@ -7988,10 +8156,10 @@ function ResourceList({
|
|
|
7988
8156
|
"div",
|
|
7989
8157
|
{
|
|
7990
8158
|
style: {
|
|
7991
|
-
paddingBlockStart:
|
|
7992
|
-
paddingBlockEnd:
|
|
7993
|
-
paddingInlineStart:
|
|
7994
|
-
paddingInlineEnd:
|
|
8159
|
+
paddingBlockStart: spaceVar(paddingBlockStart ?? padding2),
|
|
8160
|
+
paddingBlockEnd: spaceVar(paddingBlockEnd ?? padding2),
|
|
8161
|
+
paddingInlineStart: spaceVar(paddingInlineStart ?? padding2 ?? "8"),
|
|
8162
|
+
paddingInlineEnd: spaceVar(paddingInlineEnd ?? padding2 ?? "8"),
|
|
7995
8163
|
...style
|
|
7996
8164
|
},
|
|
7997
8165
|
className: cn("w-full", className),
|
|
@@ -8037,7 +8205,7 @@ function ResourceList({
|
|
|
8037
8205
|
] });
|
|
8038
8206
|
}
|
|
8039
8207
|
function useResourceList() {
|
|
8040
|
-
return
|
|
8208
|
+
return React11.useContext(ResourceListContext) ?? {
|
|
8041
8209
|
semantics: "list",
|
|
8042
8210
|
allowDrag: false,
|
|
8043
8211
|
drag: null,
|
|
@@ -8089,7 +8257,7 @@ function ResourceListItem({
|
|
|
8089
8257
|
}) {
|
|
8090
8258
|
const list = useResourceList();
|
|
8091
8259
|
const roles = useRowRoles();
|
|
8092
|
-
const id =
|
|
8260
|
+
const id = React11.useId();
|
|
8093
8261
|
const value = valueProp ?? id;
|
|
8094
8262
|
const isInteractive = interactive || selectable;
|
|
8095
8263
|
const Tag2 = !isInteractive ? "div" : href && !selectable ? "a" : "button";
|
|
@@ -8294,7 +8462,7 @@ function ResourceListSection({
|
|
|
8294
8462
|
...props
|
|
8295
8463
|
}) {
|
|
8296
8464
|
const { semantics } = useResourceList();
|
|
8297
|
-
const id =
|
|
8465
|
+
const id = React11.useId();
|
|
8298
8466
|
const grid = semantics === "grid";
|
|
8299
8467
|
return /* @__PURE__ */ jsxs("div", { className: cn("block w-full", className), ...props, children: [
|
|
8300
8468
|
hasSeparator && /* @__PURE__ */ jsx(Separator, { spacing: separatorSpacing }),
|
|
@@ -8363,7 +8531,7 @@ function ResourceListFileItem({
|
|
|
8363
8531
|
) });
|
|
8364
8532
|
}
|
|
8365
8533
|
function useTheme() {
|
|
8366
|
-
const context =
|
|
8534
|
+
const context = React11.useContext(ThemeContext);
|
|
8367
8535
|
if (!context) throw new Error("useTheme must be used within a <ThemeProvider>");
|
|
8368
8536
|
return context;
|
|
8369
8537
|
}
|
|
@@ -8397,24 +8565,24 @@ function ThemeProvider({
|
|
|
8397
8565
|
storageKey = "swirlcn-theme",
|
|
8398
8566
|
target
|
|
8399
8567
|
}) {
|
|
8400
|
-
const stored =
|
|
8568
|
+
const stored = React11.useSyncExternalStore(
|
|
8401
8569
|
subscribeToStoredTheme,
|
|
8402
8570
|
() => readStoredTheme(storageKey),
|
|
8403
8571
|
() => null
|
|
8404
8572
|
);
|
|
8405
|
-
const systemTheme =
|
|
8573
|
+
const systemTheme = React11.useSyncExternalStore(
|
|
8406
8574
|
subscribeToSystemTheme,
|
|
8407
8575
|
() => window.matchMedia(DARK_QUERY).matches ? "dark" : "light",
|
|
8408
8576
|
() => "light"
|
|
8409
8577
|
);
|
|
8410
|
-
const [chosen, setChosen] =
|
|
8578
|
+
const [chosen, setChosen] = React11.useState(null);
|
|
8411
8579
|
const theme = chosen ?? stored ?? defaultTheme;
|
|
8412
|
-
|
|
8580
|
+
React11.useEffect(() => {
|
|
8413
8581
|
const element = target ? target() : document.documentElement;
|
|
8414
8582
|
element.classList.remove("theme-light", "theme-dark");
|
|
8415
8583
|
if (theme !== "system") element.classList.add(`theme-${theme}`);
|
|
8416
8584
|
}, [theme, target]);
|
|
8417
|
-
const setTheme =
|
|
8585
|
+
const setTheme = React11.useCallback(
|
|
8418
8586
|
(next, options) => {
|
|
8419
8587
|
if (storageKey && options?.persist !== false) {
|
|
8420
8588
|
try {
|
|
@@ -8429,11 +8597,11 @@ function ThemeProvider({
|
|
|
8429
8597
|
},
|
|
8430
8598
|
[storageKey]
|
|
8431
8599
|
);
|
|
8432
|
-
const value =
|
|
8600
|
+
const value = React11.useMemo(
|
|
8433
8601
|
() => ({ theme, resolvedTheme: theme === "system" ? systemTheme : theme, setTheme }),
|
|
8434
8602
|
[theme, systemTheme, setTheme]
|
|
8435
8603
|
);
|
|
8436
8604
|
return /* @__PURE__ */ jsx(ThemeContext.Provider, { value, children });
|
|
8437
8605
|
}
|
|
8438
8606
|
|
|
8439
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, ActionList, ActionListItem, ActionListSection, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, Autocomplete, Avatar, AvatarGroup, Badge, Banner, ButtonGroup, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselSlide, Checkbox, Chip, ColorInput, DataCell, DataCellStack, DateInput, DatePicker, DescriptionList, DescriptionListItem, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, EmptyState, FileChip, FileUploader, FormControl, FormGroup, Heading, Icon, ImageGrid, ImageGridItem, InlineError, InlineNotification, InlineStatus, Input, Label, Lightbox, LightboxSlide, Link, List, Menu, MenuItem, OptionList, OptionListItem, OptionListSection, Pagination, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, Progress, Radio, RadioGroup, ResourceList, ResourceListFileItem, ResourceListItem, ResourceListSection, Search, Select, SelectOption, SelectSection, Separator, SkeletonBox, SkeletonText, Stack, StatusIndicator, Switch, Table, TableBody, TableCell, TableEmpty, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Tag, Text, Textarea, ThemeProvider, Thumbnail, TimeInput, ToastProvider, ToggleGroup, ToggleGroupItem, Toolbar, Tooltip, TooltipContent, TooltipProvider, TooltipRoot, TooltipTrigger, TreeNavigation, TreeNavigationItem, TreeView, TreeViewItem, avatarColorFor, badgeVariants, bannerVariants, cardVariants, contentVariants as dialogContentVariants, initialsFor, inputVariants, notificationVariants, tagVariants, textVariants, toastVariants, useField, useTheme, useToast };
|
|
8607
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, ActionList, ActionListItem, ActionListSection, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AppBar, Autocomplete, Avatar, AvatarGroup, Badge, Banner, ButtonGroup, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselSlide, Checkbox, Chip, ColorInput, DataCell, DataCellStack, DateInput, DatePicker, DescriptionList, DescriptionListItem, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, EmptyState, FileChip, FileUploader, FormControl, FormGroup, Heading, Icon, ImageGrid, ImageGridItem, InlineError, InlineNotification, InlineStatus, Input, Label, Lightbox, LightboxSlide, Link, List, Menu, MenuItem, OptionList, OptionListItem, OptionListSection, Pagination, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, Progress, Radio, RadioGroup, ResourceList, ResourceListFileItem, ResourceListItem, ResourceListSection, Search, Select, SelectOption, SelectSection, Separator, SkeletonBox, SkeletonText, Stack, StatusIndicator, Switch, TabBar, Table, TableBody, TableCell, TableEmpty, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Tag, Text, Textarea, ThemeProvider, Thumbnail, TimeInput, ToastProvider, ToggleGroup, ToggleGroupItem, Toolbar, Tooltip, TooltipContent, TooltipProvider, TooltipRoot, TooltipTrigger, TreeNavigation, TreeNavigationItem, TreeView, TreeViewItem, avatarColorFor, badgeVariants, bannerVariants, cardVariants, contentVariants as dialogContentVariants, initialsFor, inputVariants, notificationVariants, tagVariants, textVariants, toastVariants, useField, useTheme, useToast };
|