@aircall/ds 0.28.0 → 0.29.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/globals.css +1 -1
- package/dist/index.d.ts +190 -75
- package/dist/index.js +666 -390
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -17,19 +17,19 @@ import { Separator as Separator$1 } from "@base-ui/react/separator";
|
|
|
17
17
|
import { DayPicker, getDefaultClassNames } from "react-day-picker";
|
|
18
18
|
import useEmblaCarousel from "embla-carousel-react";
|
|
19
19
|
import { Checkbox as Checkbox$1 } from "@base-ui/react/checkbox";
|
|
20
|
-
import { ScrollArea as ScrollAreaPrimitive } from "@base-ui/react/scroll-area";
|
|
21
20
|
import { Collapsible as Collapsible$1 } from "@base-ui/react/collapsible";
|
|
22
21
|
import { Combobox as Combobox$1 } from "@base-ui/react";
|
|
22
|
+
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
23
|
+
import { useControllableState } from "@aircall/hooks";
|
|
23
24
|
import { Command as Command$1 } from "cmdk";
|
|
24
25
|
import { Dialog as Dialog$1 } from "@base-ui/react/dialog";
|
|
25
|
-
import { useControllableState } from "@aircall/hooks";
|
|
26
26
|
import { flexRender, getCoreRowModel, useReactTable } from "@tanstack/react-table";
|
|
27
|
-
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
28
27
|
import { checkboxesFeature, hotkeysCoreFeature, selectionFeature, syncDataLoaderFeature } from "@headless-tree/core";
|
|
29
28
|
import { useTree } from "@headless-tree/react";
|
|
30
29
|
import { Drawer as DrawerPrimitive } from "@base-ui/react/drawer";
|
|
31
30
|
import { Radio } from "@base-ui/react/radio";
|
|
32
31
|
import { RadioGroup as RadioGroup$1 } from "@base-ui/react/radio-group";
|
|
32
|
+
import { ScrollArea as ScrollAreaPrimitive } from "@base-ui/react/scroll-area";
|
|
33
33
|
import { Menu } from "@base-ui/react/menu";
|
|
34
34
|
import EmojiReactPicker, { Categories, EmojiStyle, SuggestionMode, Theme } from "emoji-picker-react";
|
|
35
35
|
import { Popover as Popover$1 } from "@base-ui/react/popover";
|
|
@@ -205,7 +205,7 @@ const buttonVariants = cva("group/button inline-flex shrink-0 items-center justi
|
|
|
205
205
|
variants: {
|
|
206
206
|
variant: {
|
|
207
207
|
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
208
|
-
outline: "border-border text-foreground hover:bg-muted hover:text-accent-foreground aria-expanded:bg-muted aria-expanded:text-accent-foreground dark:border-input dark:
|
|
208
|
+
outline: "border-border bg-background/80 text-foreground hover:bg-muted hover:text-accent-foreground aria-expanded:bg-muted aria-expanded:text-accent-foreground dark:border-input dark:hover:bg-input/50",
|
|
209
209
|
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
|
|
210
210
|
ghost: "hover:bg-muted hover:text-accent-foreground aria-expanded:bg-muted aria-expanded:text-accent-foreground dark:hover:bg-input/50",
|
|
211
211
|
destructive: "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
|
|
@@ -2674,7 +2674,7 @@ const CardAction = React.forwardRef((componentProps, forwardRef) => {
|
|
|
2674
2674
|
return /* @__PURE__ */ jsx("div", {
|
|
2675
2675
|
ref: forwardRef,
|
|
2676
2676
|
"data-slot": "card-action",
|
|
2677
|
-
className: cn("col-start-2 row-
|
|
2677
|
+
className: cn("col-start-2 row-start-1 flex items-center self-start justify-self-end group-has-data-[slot=card-description]/card-header:row-end-3", className),
|
|
2678
2678
|
...props
|
|
2679
2679
|
});
|
|
2680
2680
|
});
|
|
@@ -3014,128 +3014,6 @@ const Chip = React.forwardRef((componentProps, forwardRef) => {
|
|
|
3014
3014
|
});
|
|
3015
3015
|
Chip.displayName = "Chip";
|
|
3016
3016
|
|
|
3017
|
-
//#endregion
|
|
3018
|
-
//#region src/components/scroll-area.tsx
|
|
3019
|
-
/**
|
|
3020
|
-
* Custom-scrollbar container. Renders the Base UI `ScrollArea.Root` `<div>`
|
|
3021
|
-
* (with `min-h-0` so it can shrink in flex layouts) wrapping a scrollable
|
|
3022
|
-
* viewport, vertical/horizontal scrollbars, and a corner.
|
|
3023
|
-
*
|
|
3024
|
-
* @example
|
|
3025
|
-
* ```tsx
|
|
3026
|
-
* <ScrollArea className="h-72">
|
|
3027
|
-
* <div>Long content…</div>
|
|
3028
|
-
* </ScrollArea>
|
|
3029
|
-
* ```
|
|
3030
|
-
*/
|
|
3031
|
-
const ScrollArea = React.forwardRef((componentProps, forwardRef) => {
|
|
3032
|
-
const { className, children, scrollFade = false, scrollbarGutter = false, ...props } = componentProps;
|
|
3033
|
-
return /* @__PURE__ */ jsxs(ScrollAreaPrimitive.Root, {
|
|
3034
|
-
ref: forwardRef,
|
|
3035
|
-
className: cn("size-full min-h-0", className),
|
|
3036
|
-
...props,
|
|
3037
|
-
children: [
|
|
3038
|
-
/* @__PURE__ */ jsx(ScrollAreaPrimitive.Viewport, {
|
|
3039
|
-
className: cn("h-full rounded-[inherit] outline-none transition-shadows focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background data-has-overflow-y:overscroll-y-contain data-has-overflow-x:overscroll-x-contain", scrollFade && "mask-t-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-y-start)))] mask-b-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-y-end)))] mask-l-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-x-start)))] mask-r-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-x-end)))] [--fade-size:1.5rem]", scrollbarGutter && "data-has-overflow-y:pe-2.5 data-has-overflow-x:pb-2.5"),
|
|
3040
|
-
"data-slot": "scroll-area-viewport",
|
|
3041
|
-
children
|
|
3042
|
-
}),
|
|
3043
|
-
/* @__PURE__ */ jsx(ScrollBar, { orientation: "vertical" }),
|
|
3044
|
-
/* @__PURE__ */ jsx(ScrollBar, { orientation: "horizontal" }),
|
|
3045
|
-
/* @__PURE__ */ jsx(ScrollAreaPrimitive.Corner, { "data-slot": "scroll-area-corner" })
|
|
3046
|
-
]
|
|
3047
|
-
});
|
|
3048
|
-
});
|
|
3049
|
-
ScrollArea.displayName = "ScrollArea";
|
|
3050
|
-
/**
|
|
3051
|
-
* Draggable scrollbar for one axis, shown on hover/scroll. Renders the Base UI
|
|
3052
|
-
* `ScrollArea.Scrollbar` `<div>` containing a rounded `Thumb`.
|
|
3053
|
-
*/
|
|
3054
|
-
const ScrollBar = React.forwardRef((componentProps, forwardRef) => {
|
|
3055
|
-
const { className, orientation = "vertical", ...props } = componentProps;
|
|
3056
|
-
return /* @__PURE__ */ jsx(ScrollAreaPrimitive.Scrollbar, {
|
|
3057
|
-
ref: forwardRef,
|
|
3058
|
-
className: cn("m-1 flex opacity-0 transition-opacity delay-300 data-[orientation=horizontal]:h-1.5 data-[orientation=vertical]:w-1.5 data-[orientation=horizontal]:flex-col data-hovering:opacity-100 data-scrolling:opacity-100 data-hovering:delay-0 data-scrolling:delay-0 data-hovering:duration-100 data-scrolling:duration-100", className),
|
|
3059
|
-
"data-slot": "scroll-area-scrollbar",
|
|
3060
|
-
orientation,
|
|
3061
|
-
...props,
|
|
3062
|
-
children: /* @__PURE__ */ jsx(ScrollAreaPrimitive.Thumb, {
|
|
3063
|
-
className: "relative flex-1 rounded-full bg-foreground/20",
|
|
3064
|
-
"data-slot": "scroll-area-thumb"
|
|
3065
|
-
})
|
|
3066
|
-
});
|
|
3067
|
-
});
|
|
3068
|
-
ScrollBar.displayName = "ScrollBar";
|
|
3069
|
-
|
|
3070
|
-
//#endregion
|
|
3071
|
-
//#region src/components/filter.tsx
|
|
3072
|
-
/**
|
|
3073
|
-
* A removable active-filter token for a filter bar / toolbar — a dark charcoal
|
|
3074
|
-
* `Chip` with a trailing remove (X). Shows each applied filter above a
|
|
3075
|
-
* searchable data view (table / list); clicking the X clears that filter
|
|
3076
|
-
* (`onRemove`). Long values truncate with an ellipsis, capped at the Badge
|
|
3077
|
-
* `max-w-36` (144px). Compose inside a `FilterGroup` with a trailing
|
|
3078
|
-
* `FilterClearAllButton` (see the FilterBar story).
|
|
3079
|
-
*/
|
|
3080
|
-
const Filter = React.forwardRef((componentProps, forwardRef) => {
|
|
3081
|
-
const { className, children, onRemove, removeLabel = "Remove filter" } = componentProps;
|
|
3082
|
-
return /* @__PURE__ */ jsxs(Chip, {
|
|
3083
|
-
ref: forwardRef,
|
|
3084
|
-
color: "charcoal",
|
|
3085
|
-
tone: "medium-dark",
|
|
3086
|
-
className,
|
|
3087
|
-
children: [children, /* @__PURE__ */ jsx(ChipRemove, {
|
|
3088
|
-
"aria-label": removeLabel,
|
|
3089
|
-
onClick: onRemove
|
|
3090
|
-
})]
|
|
3091
|
-
});
|
|
3092
|
-
});
|
|
3093
|
-
Filter.displayName = "Filter";
|
|
3094
|
-
/**
|
|
3095
|
-
* Layout container for a row of `Filter` chips (and a trailing
|
|
3096
|
-
* `FilterClearAllButton`). Always a single, non-wrapping row inside a
|
|
3097
|
-
* horizontal `ScrollArea` (inset scroll + edge fade) — it does not wrap onto
|
|
3098
|
-
* multiple lines.
|
|
3099
|
-
*/
|
|
3100
|
-
const FilterGroup = React.forwardRef((componentProps, forwardRef) => {
|
|
3101
|
-
const { className, children, ...props } = componentProps;
|
|
3102
|
-
return /* @__PURE__ */ jsx("div", {
|
|
3103
|
-
"data-slot": "filter-group",
|
|
3104
|
-
className,
|
|
3105
|
-
children: /* @__PURE__ */ jsx(ScrollArea, {
|
|
3106
|
-
"data-slot": "filter-group-scroll-area",
|
|
3107
|
-
scrollFade: true,
|
|
3108
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
3109
|
-
ref: forwardRef,
|
|
3110
|
-
"data-slot": "filter-group-container",
|
|
3111
|
-
className: "flex w-max items-center gap-2",
|
|
3112
|
-
...props,
|
|
3113
|
-
children
|
|
3114
|
-
})
|
|
3115
|
-
})
|
|
3116
|
-
});
|
|
3117
|
-
});
|
|
3118
|
-
FilterGroup.displayName = "FilterGroup";
|
|
3119
|
-
/**
|
|
3120
|
-
* The trailing "Clear all filters" action for a `FilterGroup` — a ghost,
|
|
3121
|
-
* small `Button` with the styling pinned. Provide `onClick`; the label
|
|
3122
|
-
* defaults to "Clear all filters" (pass translated `children` to override).
|
|
3123
|
-
*/
|
|
3124
|
-
const FilterClearAllButton = React.forwardRef((componentProps, forwardRef) => {
|
|
3125
|
-
const { className, children = "Clear all filters", ...props } = componentProps;
|
|
3126
|
-
return /* @__PURE__ */ jsx(Button, {
|
|
3127
|
-
ref: forwardRef,
|
|
3128
|
-
type: "button",
|
|
3129
|
-
variant: "ghost",
|
|
3130
|
-
size: "sm",
|
|
3131
|
-
"data-slot": "filter-clear-all",
|
|
3132
|
-
className,
|
|
3133
|
-
...props,
|
|
3134
|
-
children
|
|
3135
|
-
});
|
|
3136
|
-
});
|
|
3137
|
-
FilterClearAllButton.displayName = "FilterClearAllButton";
|
|
3138
|
-
|
|
3139
3017
|
//#endregion
|
|
3140
3018
|
//#region src/components/collapsible.tsx
|
|
3141
3019
|
/**
|
|
@@ -3283,8 +3161,8 @@ const inputGroupAddonVariants = cva("text-muted-foreground flex h-auto cursor-te
|
|
|
3283
3161
|
variants: { align: {
|
|
3284
3162
|
"inline-start": "order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]",
|
|
3285
3163
|
"inline-end": "order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]",
|
|
3286
|
-
"block-start": "order-first w-full justify-start px-3
|
|
3287
|
-
"block-end": "order-last w-full justify-start px-3
|
|
3164
|
+
"block-start": "order-first w-full justify-start px-3 py-2 [.border-b]:pb-3",
|
|
3165
|
+
"block-end": "order-last w-full justify-start px-3 py-2 [.border-t]:pt-3"
|
|
3288
3166
|
} },
|
|
3289
3167
|
defaultVariants: { align: "inline-start" }
|
|
3290
3168
|
});
|
|
@@ -3340,7 +3218,7 @@ const InputGroupTextarea = React.forwardRef((componentProps, forwardRef) => {
|
|
|
3340
3218
|
return /* @__PURE__ */ jsx(Textarea, {
|
|
3341
3219
|
ref: forwardRef,
|
|
3342
3220
|
"data-slot": "input-group-control",
|
|
3343
|
-
className: cn("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 aria-invalid:ring-0 dark:bg-transparent", className),
|
|
3221
|
+
className: cn("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 aria-invalid:ring-0 focus-visible:aria-invalid:!ring-0 dark:bg-transparent", className),
|
|
3344
3222
|
...props
|
|
3345
3223
|
});
|
|
3346
3224
|
});
|
|
@@ -3617,87 +3495,599 @@ function useComboboxAnchor() {
|
|
|
3617
3495
|
}
|
|
3618
3496
|
|
|
3619
3497
|
//#endregion
|
|
3620
|
-
//#region src/components/
|
|
3498
|
+
//#region src/components/skeleton.tsx
|
|
3621
3499
|
/**
|
|
3622
|
-
*
|
|
3623
|
-
*
|
|
3500
|
+
* Pulsing placeholder shown while content is loading. Renders a `<div>`;
|
|
3501
|
+
* set its dimensions via `className` to match the content it stands in for.
|
|
3624
3502
|
*
|
|
3625
3503
|
* @example
|
|
3626
3504
|
* ```tsx
|
|
3627
|
-
* <
|
|
3628
|
-
* <DialogTrigger render={<Button />}>Open</DialogTrigger>
|
|
3629
|
-
* <DialogContent>
|
|
3630
|
-
* <DialogHeader>
|
|
3631
|
-
* <DialogTitle>Title</DialogTitle>
|
|
3632
|
-
* <DialogDescription>Description</DialogDescription>
|
|
3633
|
-
* </DialogHeader>
|
|
3634
|
-
* </DialogContent>
|
|
3635
|
-
* </Dialog>
|
|
3505
|
+
* <Skeleton className="h-4 w-32" />
|
|
3636
3506
|
* ```
|
|
3637
3507
|
*/
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
...componentProps
|
|
3642
|
-
});
|
|
3643
|
-
}
|
|
3644
|
-
/**
|
|
3645
|
-
* Button that opens the dialog, wrapping Base UI's `Dialog.Trigger`. Renders a `<button>` by
|
|
3646
|
-
* default (override with `render`).
|
|
3647
|
-
*/
|
|
3648
|
-
const DialogTrigger = React.forwardRef((componentProps, forwardRef) => {
|
|
3649
|
-
const { ...props } = componentProps;
|
|
3650
|
-
return /* @__PURE__ */ jsx(Dialog$1.Trigger, {
|
|
3508
|
+
const Skeleton = React.forwardRef((componentProps, forwardRef) => {
|
|
3509
|
+
const { className, ...props } = componentProps;
|
|
3510
|
+
return /* @__PURE__ */ jsx("div", {
|
|
3651
3511
|
ref: forwardRef,
|
|
3652
|
-
"data-slot": "
|
|
3512
|
+
"data-slot": "skeleton",
|
|
3513
|
+
className: cn("animate-pulse rounded-md bg-muted", className),
|
|
3653
3514
|
...props
|
|
3654
3515
|
});
|
|
3655
3516
|
});
|
|
3656
|
-
|
|
3517
|
+
Skeleton.displayName = "Skeleton";
|
|
3518
|
+
|
|
3519
|
+
//#endregion
|
|
3520
|
+
//#region src/lib/use-fetch-more-sentinel.ts
|
|
3657
3521
|
/**
|
|
3658
|
-
*
|
|
3659
|
-
*
|
|
3522
|
+
* Returns a callback ref for a scroll sentinel element placed at the bottom of a
|
|
3523
|
+
* scrollable list. When the sentinel scrolls into view (within `rootMargin`),
|
|
3524
|
+
* `onFetchMore` fires once. The observer is (re)attached whenever the sentinel
|
|
3525
|
+
* node mounts — so it works even if the sentinel only appears after the first
|
|
3526
|
+
* page loads — and re-arms whenever `resetKey` changes (a page arrived, or the
|
|
3527
|
+
* list reset), so pagination keeps going while the sentinel stays in view and
|
|
3528
|
+
* pauses once it scrolls away. It fires at most once per intersection, so a
|
|
3529
|
+
* sentinel that stays in view can't trigger duplicate loads or a tight retry
|
|
3530
|
+
* loop when a fetch fails and the data is unchanged.
|
|
3531
|
+
*
|
|
3532
|
+
* `getRoot` resolves the scroll container the sentinel is measured against, given
|
|
3533
|
+
* the sentinel node — return the scrolling ancestor (a table container, a
|
|
3534
|
+
* combobox list, …) so `rootMargin` gives prefetch headroom inside a clipped
|
|
3535
|
+
* scroll area, or `null` to measure against the viewport.
|
|
3536
|
+
*
|
|
3537
|
+
* @example
|
|
3538
|
+
* ```tsx
|
|
3539
|
+
* const sentinelRef = useFetchMoreSentinel<HTMLDivElement>(
|
|
3540
|
+
* onFetchMore,
|
|
3541
|
+
* node => node.closest<HTMLElement>('[data-slot="combobox-list"]'),
|
|
3542
|
+
* items.length
|
|
3543
|
+
* );
|
|
3544
|
+
* // …later, at the bottom of the list:
|
|
3545
|
+
* <div aria-hidden ref={sentinelRef} />
|
|
3546
|
+
* ```
|
|
3660
3547
|
*/
|
|
3661
|
-
function
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3548
|
+
function useFetchMoreSentinel(onFetchMore, getRoot, resetKey) {
|
|
3549
|
+
const onFetchMoreRef = React.useRef(onFetchMore);
|
|
3550
|
+
onFetchMoreRef.current = onFetchMore;
|
|
3551
|
+
const getRootRef = React.useRef(getRoot);
|
|
3552
|
+
getRootRef.current = getRoot;
|
|
3553
|
+
const observerRef = React.useRef(null);
|
|
3554
|
+
const nodeRef = React.useRef(null);
|
|
3555
|
+
const armedRef = React.useRef(true);
|
|
3556
|
+
const observe = React.useCallback(() => {
|
|
3557
|
+
observerRef.current?.disconnect();
|
|
3558
|
+
observerRef.current = null;
|
|
3559
|
+
const node = nodeRef.current;
|
|
3560
|
+
if (!node) return;
|
|
3561
|
+
const root = getRootRef.current(node);
|
|
3562
|
+
const observer = new IntersectionObserver((entries) => {
|
|
3563
|
+
if (entries[entries.length - 1]?.isIntersecting) {
|
|
3564
|
+
if (armedRef.current) {
|
|
3565
|
+
armedRef.current = false;
|
|
3566
|
+
onFetchMoreRef.current?.();
|
|
3567
|
+
}
|
|
3568
|
+
} else armedRef.current = true;
|
|
3569
|
+
}, {
|
|
3570
|
+
root,
|
|
3571
|
+
rootMargin: "200px"
|
|
3572
|
+
});
|
|
3573
|
+
observer.observe(node);
|
|
3574
|
+
observerRef.current = observer;
|
|
3575
|
+
}, []);
|
|
3576
|
+
React.useEffect(() => {
|
|
3577
|
+
armedRef.current = true;
|
|
3578
|
+
observe();
|
|
3579
|
+
}, [resetKey, observe]);
|
|
3580
|
+
return React.useCallback((node) => {
|
|
3581
|
+
nodeRef.current = node;
|
|
3582
|
+
observe();
|
|
3583
|
+
}, [observe]);
|
|
3666
3584
|
}
|
|
3585
|
+
|
|
3586
|
+
//#endregion
|
|
3587
|
+
//#region src/components/combobox-rows.tsx
|
|
3588
|
+
const DEFAULT_SKELETON_COUNT$1 = 5;
|
|
3589
|
+
const DEFAULT_ROW_HEIGHT = 36;
|
|
3590
|
+
const VIRTUAL_ROW_OVERSCAN = 8;
|
|
3667
3591
|
/**
|
|
3668
|
-
*
|
|
3669
|
-
*
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
...props
|
|
3677
|
-
});
|
|
3678
|
-
});
|
|
3679
|
-
DialogClose.displayName = "DialogClose";
|
|
3680
|
-
/**
|
|
3681
|
-
* Dimming backdrop rendered behind the dialog, wrapping Base UI's `Dialog.Backdrop`. Renders a
|
|
3682
|
-
* fixed, full-viewport `<div>`. Included automatically by `DialogContent`.
|
|
3592
|
+
* Buckets a flat `items` array into groups for a combobox list, preserving
|
|
3593
|
+
* first-seen group order. Returns `null` when `getGroupKey` is omitted (the flat
|
|
3594
|
+
* list path).
|
|
3595
|
+
*
|
|
3596
|
+
* Lives above the Combobox root rather than inside `ComboboxRows` because the
|
|
3597
|
+
* root's `items` prop must receive the GROUPED shape — Base UI derives its
|
|
3598
|
+
* collection, `data-empty`, keyboard nav and client-side filtering from it.
|
|
3599
|
+
* Internal to the package: not exported from `src/index.ts`.
|
|
3683
3600
|
*/
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3601
|
+
function useComboboxItemGroups(items, getGroupKey, getGroupLabel) {
|
|
3602
|
+
return React.useMemo(() => {
|
|
3603
|
+
if (!getGroupKey) return null;
|
|
3604
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
3605
|
+
for (const item of items) {
|
|
3606
|
+
const gk = getGroupKey(item);
|
|
3607
|
+
const bucket = byKey.get(gk);
|
|
3608
|
+
if (bucket) bucket.push(item);
|
|
3609
|
+
else byKey.set(gk, [item]);
|
|
3610
|
+
}
|
|
3611
|
+
return Array.from(byKey, ([groupKey, groupItems]) => ({
|
|
3612
|
+
groupKey,
|
|
3613
|
+
label: getGroupLabel ? getGroupLabel(groupKey) : groupKey,
|
|
3614
|
+
items: groupItems
|
|
3615
|
+
}));
|
|
3616
|
+
}, [
|
|
3617
|
+
items,
|
|
3618
|
+
getGroupKey,
|
|
3619
|
+
getGroupLabel
|
|
3620
|
+
]);
|
|
3621
|
+
}
|
|
3694
3622
|
/**
|
|
3695
|
-
*
|
|
3696
|
-
*
|
|
3623
|
+
* The scrollable rows region shared by every `DataCombobox` layout and by
|
|
3624
|
+
* `ComboboxBody`: the rows (flat or grouped), the infinite-scroll sentinel, the
|
|
3625
|
+
* skeleton rows, the filtering dim-overlay, the empty state, and the load-more
|
|
3626
|
+
* spinner row. It stops at the rows: the search input and any popup chrome
|
|
3627
|
+
* belong to whichever root renders this.
|
|
3628
|
+
*
|
|
3629
|
+
* Must be rendered inside a `Combobox` root whose `items` is `groups ?? items`.
|
|
3630
|
+
* Internal to the package: not exported from `src/index.ts`.
|
|
3697
3631
|
*/
|
|
3698
|
-
|
|
3699
|
-
const {
|
|
3700
|
-
|
|
3632
|
+
function ComboboxRows(componentProps) {
|
|
3633
|
+
const { items, groups, getItemValue, getItemLabel, renderItem, disabledKeys, loadingState = "idle", skeletonCount = DEFAULT_SKELETON_COUNT$1, onFetchMore, hasMore = false, emptyState, listClassName, listTabIndex, virtualizeRows = false, estimateRowHeight = DEFAULT_ROW_HEIGHT, scrollRowIntoViewRef, "aria-label": ariaLabel } = componentProps;
|
|
3634
|
+
const isInitialLoading = loadingState === "loading";
|
|
3635
|
+
const isFiltering = loadingState === "filtering";
|
|
3636
|
+
const isLoadingMore = loadingState === "loadingMore";
|
|
3637
|
+
const sentinelRef = useFetchMoreSentinel(onFetchMore, (node) => node.closest("[data-slot=\"combobox-list\"]"), items.length);
|
|
3638
|
+
const showFetchSentinel = !!onFetchMore && hasMore;
|
|
3639
|
+
const lastRenderedItem = (groups?.at(-1)?.items ?? items).at(-1);
|
|
3640
|
+
const lastItemKey = lastRenderedItem ? getItemValue(lastRenderedItem) : void 0;
|
|
3641
|
+
const renderRow = (item) => {
|
|
3642
|
+
const key = getItemValue(item);
|
|
3643
|
+
const attachSentinel = showFetchSentinel && !virtualizeRows && key === lastItemKey;
|
|
3644
|
+
return /* @__PURE__ */ jsx(ComboboxItem, {
|
|
3645
|
+
value: item,
|
|
3646
|
+
disabled: disabledKeys?.has(key) ?? false,
|
|
3647
|
+
ref: attachSentinel ? sentinelRef : void 0,
|
|
3648
|
+
"data-test": attachSentinel ? "fetch-sentinel" : void 0,
|
|
3649
|
+
children: renderItem ? renderItem(item) : getItemLabel(item)
|
|
3650
|
+
}, key);
|
|
3651
|
+
};
|
|
3652
|
+
const hasRows = items.length > 0;
|
|
3653
|
+
const virtualRows = virtualizeRows ? /* @__PURE__ */ jsx(ComboboxVirtualRows, {
|
|
3654
|
+
getItemValue,
|
|
3655
|
+
getItemLabel,
|
|
3656
|
+
renderItem,
|
|
3657
|
+
disabledKeys,
|
|
3658
|
+
estimateRowHeight,
|
|
3659
|
+
sentinelRef,
|
|
3660
|
+
showFetchSentinel,
|
|
3661
|
+
scrollRowIntoViewRef
|
|
3662
|
+
}) : null;
|
|
3663
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
3664
|
+
"data-slot": "combobox-rows",
|
|
3665
|
+
className: cn("relative", isFiltering && !hasRows && "min-h-24"),
|
|
3666
|
+
children: [isInitialLoading ? /* @__PURE__ */ jsx(ComboboxSkeletonRows, { count: skeletonCount }) : /* @__PURE__ */ jsx(ComboboxLoadedRows, {
|
|
3667
|
+
groups,
|
|
3668
|
+
renderRow,
|
|
3669
|
+
virtualRows,
|
|
3670
|
+
isFiltering,
|
|
3671
|
+
isLoadingMore,
|
|
3672
|
+
emptyState,
|
|
3673
|
+
listClassName,
|
|
3674
|
+
listTabIndex,
|
|
3675
|
+
"aria-label": ariaLabel
|
|
3676
|
+
}), isFiltering ? /* @__PURE__ */ jsx(ComboboxFilteringOverlay, {}) : null]
|
|
3677
|
+
});
|
|
3678
|
+
}
|
|
3679
|
+
/** The loaded rows region: the list itself, the empty state, and the load-more spinner row. */
|
|
3680
|
+
function ComboboxLoadedRows(componentProps) {
|
|
3681
|
+
const { groups, renderRow, virtualRows, isFiltering, isLoadingMore, emptyState, listClassName, listTabIndex, "aria-label": ariaLabel } = componentProps;
|
|
3682
|
+
const t = useDsTranslation("ds");
|
|
3683
|
+
const listChildren = virtualRows ?? (groups === null ? renderRow : renderGroupSection(renderRow));
|
|
3684
|
+
const tabIndexProps = listTabIndex === void 0 ? {} : { tabIndex: listTabIndex };
|
|
3685
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3686
|
+
/* @__PURE__ */ jsx(ComboboxList, {
|
|
3687
|
+
"aria-label": ariaLabel,
|
|
3688
|
+
className: listClassName,
|
|
3689
|
+
...tabIndexProps,
|
|
3690
|
+
children: listChildren
|
|
3691
|
+
}),
|
|
3692
|
+
isFiltering ? null : /* @__PURE__ */ jsx(ComboboxEmpty, {
|
|
3693
|
+
className: "flex empty:hidden",
|
|
3694
|
+
children: emptyState ?? t("dataCombobox.noResults")
|
|
3695
|
+
}),
|
|
3696
|
+
isLoadingMore ? /* @__PURE__ */ jsx(SpinnerRow, {}) : null
|
|
3697
|
+
] });
|
|
3698
|
+
}
|
|
3699
|
+
/**
|
|
3700
|
+
* Renders only the rows inside the scrolled window of a FLAT combobox list, at
|
|
3701
|
+
* absolute offsets inside a full-height spacer, so a 244-item list keeps roughly
|
|
3702
|
+
* twenty rows in the DOM.
|
|
3703
|
+
*
|
|
3704
|
+
* Reads the rows from Base UI's `useFilteredItems` rather than from the `items`
|
|
3705
|
+
* prop: with client-side filtering on, the window must slide over the FILTERED
|
|
3706
|
+
* rows, and the flat index of a filtered row is exactly what Base UI's keyboard
|
|
3707
|
+
* navigation, `aria-activedescendant` and Enter-to-select are indexed by. That
|
|
3708
|
+
* index is passed to every row explicitly — the automatic DOM-order index is
|
|
3709
|
+
* meaningless when only a window is mounted.
|
|
3710
|
+
*/
|
|
3711
|
+
function ComboboxVirtualRows(componentProps) {
|
|
3712
|
+
const { getItemValue, getItemLabel, renderItem, disabledKeys, estimateRowHeight, sentinelRef, showFetchSentinel, scrollRowIntoViewRef } = componentProps;
|
|
3713
|
+
const filteredItems = Combobox$1.useFilteredItems();
|
|
3714
|
+
const [spacerElement, setSpacerElement] = React.useState(null);
|
|
3715
|
+
const scrollElement = spacerElement?.closest("[data-slot=\"combobox-list\"]") ?? null;
|
|
3716
|
+
const rowVirtualizer = useVirtualizer({
|
|
3717
|
+
count: filteredItems.length,
|
|
3718
|
+
getScrollElement: () => scrollElement,
|
|
3719
|
+
estimateSize: () => estimateRowHeight,
|
|
3720
|
+
overscan: VIRTUAL_ROW_OVERSCAN
|
|
3721
|
+
});
|
|
3722
|
+
React.useEffect(() => {
|
|
3723
|
+
if (!scrollRowIntoViewRef) return void 0;
|
|
3724
|
+
scrollRowIntoViewRef.current = (index) => rowVirtualizer.scrollToIndex(index, { align: "auto" });
|
|
3725
|
+
return () => {
|
|
3726
|
+
scrollRowIntoViewRef.current = null;
|
|
3727
|
+
};
|
|
3728
|
+
}, [rowVirtualizer, scrollRowIntoViewRef]);
|
|
3729
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
3730
|
+
ref: setSpacerElement,
|
|
3731
|
+
"data-slot": "combobox-virtual-rows",
|
|
3732
|
+
className: "relative w-full",
|
|
3733
|
+
style: { height: rowVirtualizer.getTotalSize() },
|
|
3734
|
+
children: [rowVirtualizer.getVirtualItems().map((virtualRow) => {
|
|
3735
|
+
const item = filteredItems[virtualRow.index];
|
|
3736
|
+
if (item === void 0) return null;
|
|
3737
|
+
const key = getItemValue(item);
|
|
3738
|
+
return /* @__PURE__ */ jsx(ComboboxItem, {
|
|
3739
|
+
index: virtualRow.index,
|
|
3740
|
+
value: item,
|
|
3741
|
+
disabled: disabledKeys?.has(key) ?? false,
|
|
3742
|
+
ref: rowVirtualizer.measureElement,
|
|
3743
|
+
"data-index": virtualRow.index,
|
|
3744
|
+
style: {
|
|
3745
|
+
position: "absolute",
|
|
3746
|
+
top: 0,
|
|
3747
|
+
left: 0,
|
|
3748
|
+
width: "100%",
|
|
3749
|
+
transform: `translateY(${virtualRow.start}px)`
|
|
3750
|
+
},
|
|
3751
|
+
children: renderItem ? renderItem(item) : getItemLabel(item)
|
|
3752
|
+
}, key);
|
|
3753
|
+
}), showFetchSentinel && filteredItems.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
3754
|
+
ref: sentinelRef,
|
|
3755
|
+
"aria-hidden": true,
|
|
3756
|
+
"data-test": "fetch-sentinel",
|
|
3757
|
+
"data-slot": "combobox-fetch-sentinel",
|
|
3758
|
+
className: "absolute bottom-0 h-px w-full"
|
|
3759
|
+
}) : null]
|
|
3760
|
+
});
|
|
3761
|
+
}
|
|
3762
|
+
/**
|
|
3763
|
+
* Builds `ComboboxList`'s render-prop for a GROUPED list: one `ComboboxGroup`
|
|
3764
|
+
* per section, each header plus a collection of leaf rows. Base UI calls the
|
|
3765
|
+
* returned function once per group from the Root's grouped `items`.
|
|
3766
|
+
*/
|
|
3767
|
+
function renderGroupSection(renderRow) {
|
|
3768
|
+
return (group) => /* @__PURE__ */ jsxs(ComboboxGroup, {
|
|
3769
|
+
items: group.items,
|
|
3770
|
+
children: [/* @__PURE__ */ jsx(ComboboxLabel, { children: group.label }), /* @__PURE__ */ jsx(ComboboxCollection, { children: renderRow })]
|
|
3771
|
+
}, group.groupKey);
|
|
3772
|
+
}
|
|
3773
|
+
/** The dimmed spinner overlay covering the list while a re-query is in flight. */
|
|
3774
|
+
function ComboboxFilteringOverlay() {
|
|
3775
|
+
return /* @__PURE__ */ jsx("div", {
|
|
3776
|
+
"data-slot": "combobox-loading-overlay",
|
|
3777
|
+
className: "bg-popover/60 absolute inset-0 z-10 flex items-center justify-center",
|
|
3778
|
+
children: /* @__PURE__ */ jsx(Spinner, {})
|
|
3779
|
+
});
|
|
3780
|
+
}
|
|
3781
|
+
/**
|
|
3782
|
+
* A centered spinner row for the filtering and load-more states. Not
|
|
3783
|
+
* `aria-hidden` — the `Spinner`'s `role="status"` announces loading to screen
|
|
3784
|
+
* readers (that's the point of a loading indicator).
|
|
3785
|
+
*/
|
|
3786
|
+
function SpinnerRow() {
|
|
3787
|
+
return /* @__PURE__ */ jsx("div", {
|
|
3788
|
+
"data-slot": "combobox-spinner-row",
|
|
3789
|
+
className: "flex justify-center py-2 text-muted-foreground",
|
|
3790
|
+
children: /* @__PURE__ */ jsx(Spinner, {})
|
|
3791
|
+
});
|
|
3792
|
+
}
|
|
3793
|
+
/** Skeleton rows, padded like the list, shown while the initial page loads. */
|
|
3794
|
+
function ComboboxSkeletonRows({ count }) {
|
|
3795
|
+
return /* @__PURE__ */ jsx("div", {
|
|
3796
|
+
"data-slot": "combobox-skeleton-rows",
|
|
3797
|
+
className: "p-1",
|
|
3798
|
+
children: Array.from({ length: count }, (_, i) => /* @__PURE__ */ jsx("div", {
|
|
3799
|
+
"aria-hidden": true,
|
|
3800
|
+
"data-test": "loading-item",
|
|
3801
|
+
"data-slot": "combobox-skeleton-row",
|
|
3802
|
+
className: "flex items-center gap-2 rounded-md p-2",
|
|
3803
|
+
children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-full" })
|
|
3804
|
+
}, `skeleton-${i}`))
|
|
3805
|
+
});
|
|
3806
|
+
}
|
|
3807
|
+
|
|
3808
|
+
//#endregion
|
|
3809
|
+
//#region src/lib/use-combobox-item-selection.ts
|
|
3810
|
+
const EMPTY_KEYS$1 = /* @__PURE__ */ new Set();
|
|
3811
|
+
/**
|
|
3812
|
+
* The `onInputValueChange` reasons a POPUP combobox forwards to `onSearch`
|
|
3813
|
+
* (`DataCombobox`'s three layouts):
|
|
3814
|
+
* - `input-change` — real typing/paste.
|
|
3815
|
+
* - `input-clear` — Base UI clears the field itself after a selection.
|
|
3816
|
+
* - `clear-press` — the input's clear (x) button.
|
|
3817
|
+
*
|
|
3818
|
+
* `escape-key` is deliberately absent: with a popup, Escape CLOSES it rather
|
|
3819
|
+
* than clearing the query, so forwarding it would refetch on every dismissal.
|
|
3820
|
+
*/
|
|
3821
|
+
const POPUP_SEARCH_TRIGGER_REASONS = new Set([
|
|
3822
|
+
"input-change",
|
|
3823
|
+
"input-clear",
|
|
3824
|
+
"clear-press"
|
|
3825
|
+
]);
|
|
3826
|
+
/**
|
|
3827
|
+
* The `onInputValueChange` reasons an INLINE combobox forwards to `onSearch`
|
|
3828
|
+
* (`ComboboxBody`). Same as the popup set plus `escape-key`.
|
|
3829
|
+
*
|
|
3830
|
+
* With no popup, Escape is the inline list's RESET: Base UI empties the query and
|
|
3831
|
+
* clears the selection under that reason. Forwarding it keeps the consumer's data
|
|
3832
|
+
* in step with the reset it just performed — otherwise the component presents
|
|
3833
|
+
* itself as reset while the caller keeps serving the previous query's page.
|
|
3834
|
+
*/
|
|
3835
|
+
const INLINE_SEARCH_TRIGGER_REASONS = new Set([
|
|
3836
|
+
"input-change",
|
|
3837
|
+
"input-clear",
|
|
3838
|
+
"clear-press",
|
|
3839
|
+
"escape-key"
|
|
3840
|
+
]);
|
|
3841
|
+
/**
|
|
3842
|
+
* Bridges a `Set<string>` of selected keys to the item objects Base UI's
|
|
3843
|
+
* Combobox root wants for `value` / `onValueChange`, and gates the input's
|
|
3844
|
+
* value changes down to real search queries.
|
|
3845
|
+
*
|
|
3846
|
+
* Shared by `DataCombobox` and `ComboboxBody` — both own a Combobox root and
|
|
3847
|
+
* need the identical selection semantics. Internal to the package: not exported
|
|
3848
|
+
* from `src/index.ts`.
|
|
3849
|
+
*
|
|
3850
|
+
* @example
|
|
3851
|
+
* ```tsx
|
|
3852
|
+
* const { keys, selectedObjects, commit, handleInputValueChange } =
|
|
3853
|
+
* useComboboxItemSelection({ items, getItemValue, selectedKeys, onSelectionChange });
|
|
3854
|
+
* ```
|
|
3855
|
+
*/
|
|
3856
|
+
function useComboboxItemSelection(options) {
|
|
3857
|
+
const { items, getItemValue, selectedItems, selectedKeys, defaultSelectedKeys, onSelectionChange, onSearch, searchTriggerReasons = POPUP_SEARCH_TRIGGER_REASONS } = options;
|
|
3858
|
+
const itemCacheRef = React.useRef(/* @__PURE__ */ new Map());
|
|
3859
|
+
if (selectedItems) for (const item of selectedItems) itemCacheRef.current.set(getItemValue(item), item);
|
|
3860
|
+
for (const item of items) itemCacheRef.current.set(getItemValue(item), item);
|
|
3861
|
+
const itemCache = itemCacheRef.current;
|
|
3862
|
+
const [selectionSet, setSelectionSet] = useControllableState({
|
|
3863
|
+
prop: selectedKeys,
|
|
3864
|
+
defaultProp: defaultSelectedKeys,
|
|
3865
|
+
onChange: onSelectionChange
|
|
3866
|
+
});
|
|
3867
|
+
const keys = selectionSet ?? EMPTY_KEYS$1;
|
|
3868
|
+
const selectedObjects = [];
|
|
3869
|
+
for (const key of keys) {
|
|
3870
|
+
const item = itemCache.get(key);
|
|
3871
|
+
if (item) selectedObjects.push(item);
|
|
3872
|
+
}
|
|
3873
|
+
return {
|
|
3874
|
+
keys,
|
|
3875
|
+
selectedObjects,
|
|
3876
|
+
commit: React.useCallback((objs) => setSelectionSet(new Set(objs.map(getItemValue))), [setSelectionSet, getItemValue]),
|
|
3877
|
+
handleInputValueChange: onSearch ? (value, details) => {
|
|
3878
|
+
if (searchTriggerReasons.has(details.reason)) onSearch(value);
|
|
3879
|
+
} : void 0
|
|
3880
|
+
};
|
|
3881
|
+
}
|
|
3882
|
+
|
|
3883
|
+
//#endregion
|
|
3884
|
+
//#region src/components/combobox-body.tsx
|
|
3885
|
+
const LIST_MAX_HEIGHT = "max-h-63";
|
|
3886
|
+
const INPUT_IN_LIST_CLASSES = "m-1 mb-0 border-input/30 bg-input/30 shadow-none";
|
|
3887
|
+
const FOCUSABLE_LIST_CLASSES = "focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:ring-inset";
|
|
3888
|
+
/**
|
|
3889
|
+
* Scrolls a keyboard-highlighted row into view while rows are virtualised.
|
|
3890
|
+
* A no-op without virtualisation (nothing fills the ref), for a pointer-driven
|
|
3891
|
+
* highlight (the row is already under the cursor, so already mounted), and when
|
|
3892
|
+
* the highlight was cleared (index `-1`).
|
|
3893
|
+
*/
|
|
3894
|
+
function scrollHighlightedRowIntoView(scrollRowIntoViewRef, index, reason) {
|
|
3895
|
+
if (reason === "pointer" || index < 0) return;
|
|
3896
|
+
scrollRowIntoViewRef.current?.(index);
|
|
3897
|
+
}
|
|
3898
|
+
/**
|
|
3899
|
+
* A data-driven combobox list with NO trigger and NO popup of its own: an
|
|
3900
|
+
* optional search input above a selectable list, ready to be dropped into a
|
|
3901
|
+
* surface the caller owns (a `Filter` popover, a panel, a dialog). Driven by an
|
|
3902
|
+
* `items` array plus `getItemValue`/`getItemLabel`, with opt-in server-side
|
|
3903
|
+
* search, grouping, infinite scroll, and loading/empty states.
|
|
3904
|
+
*
|
|
3905
|
+
* Use `DataCombobox` instead when you want the field-plus-popup combobox. This
|
|
3906
|
+
* is the same rows region plus an optional search input, without the field or the
|
|
3907
|
+
* popup around them, so the host controls open state, dismissal and positioning.
|
|
3908
|
+
* The name pairs with `ComboboxContent`, which is the popup this deliberately
|
|
3909
|
+
* does not have.
|
|
3910
|
+
*
|
|
3911
|
+
* Dismissal note: with no popup of its own, this holds no dismiss layer, so an
|
|
3912
|
+
* outside press or Escape always reaches the host. Escape ALSO resets the list —
|
|
3913
|
+
* clearing the query and the selection, the combobox convention for a list with
|
|
3914
|
+
* nothing open — but only while the search box is untouched; once the user has
|
|
3915
|
+
* clicked or typed in it, Base UI treats the list as open and Escape just
|
|
3916
|
+
* dismisses. The reset is forwarded to `onSearch('')` so a server-driven list
|
|
3917
|
+
* comes back unfiltered instead of stranding the previous query's page. Dismiss
|
|
3918
|
+
* via an outside press (or the host's own close affordance) when the selection
|
|
3919
|
+
* must survive.
|
|
3920
|
+
*
|
|
3921
|
+
* @example
|
|
3922
|
+
* ```tsx
|
|
3923
|
+
* <ComboboxBody
|
|
3924
|
+
* items={statuses}
|
|
3925
|
+
* getItemValue={status => status.id}
|
|
3926
|
+
* getItemLabel={status => status.label}
|
|
3927
|
+
* selectionMode="multiple"
|
|
3928
|
+
* selectedKeys={selectedKeys}
|
|
3929
|
+
* onSelectionChange={setSelectedKeys}
|
|
3930
|
+
* />
|
|
3931
|
+
* ```
|
|
3932
|
+
*/
|
|
3933
|
+
function ComboboxBody(componentProps) {
|
|
3934
|
+
const { items, getItemValue, getItemLabel, renderItem, getGroupKey, getGroupLabel, selectionMode = "single", selectedKeys, defaultSelectedKeys, onSelectionChange, selectedItems, disabledKeys, loadingState = "idle", skeletonCount, onSearch, onFetchMore, hasMore = false, emptyState, estimateRowHeight, searchable = true, placeholder, className, "aria-label": ariaLabel } = componentProps;
|
|
3935
|
+
const multiple = selectionMode === "multiple";
|
|
3936
|
+
const virtualizeRows = (componentProps.virtualizeRows ?? false) && !getGroupKey;
|
|
3937
|
+
const scrollRowIntoViewRef = React.useRef(null);
|
|
3938
|
+
const { selectedObjects, commit, handleInputValueChange } = useComboboxItemSelection({
|
|
3939
|
+
items,
|
|
3940
|
+
getItemValue,
|
|
3941
|
+
selectedItems,
|
|
3942
|
+
selectedKeys,
|
|
3943
|
+
defaultSelectedKeys,
|
|
3944
|
+
onSelectionChange,
|
|
3945
|
+
onSearch,
|
|
3946
|
+
searchTriggerReasons: INLINE_SEARCH_TRIGGER_REASONS
|
|
3947
|
+
});
|
|
3948
|
+
const groups = useComboboxItemGroups(items, getGroupKey, getGroupLabel);
|
|
3949
|
+
const body = /* @__PURE__ */ jsxs("div", {
|
|
3950
|
+
"data-slot": "combobox-body",
|
|
3951
|
+
className: cn("flex w-full flex-col", className),
|
|
3952
|
+
children: [searchable ? /* @__PURE__ */ jsx(ComboboxInput, {
|
|
3953
|
+
showTrigger: false,
|
|
3954
|
+
placeholder,
|
|
3955
|
+
className: INPUT_IN_LIST_CLASSES
|
|
3956
|
+
}) : null, /* @__PURE__ */ jsx(ComboboxRows, {
|
|
3957
|
+
items,
|
|
3958
|
+
groups,
|
|
3959
|
+
getItemValue,
|
|
3960
|
+
getItemLabel,
|
|
3961
|
+
renderItem,
|
|
3962
|
+
disabledKeys,
|
|
3963
|
+
loadingState,
|
|
3964
|
+
skeletonCount,
|
|
3965
|
+
onFetchMore,
|
|
3966
|
+
hasMore,
|
|
3967
|
+
emptyState,
|
|
3968
|
+
listClassName: cn(LIST_MAX_HEIGHT, !searchable && FOCUSABLE_LIST_CLASSES),
|
|
3969
|
+
listTabIndex: searchable ? void 0 : 0,
|
|
3970
|
+
virtualizeRows,
|
|
3971
|
+
estimateRowHeight,
|
|
3972
|
+
scrollRowIntoViewRef,
|
|
3973
|
+
"aria-label": ariaLabel
|
|
3974
|
+
})]
|
|
3975
|
+
});
|
|
3976
|
+
if (multiple) return /* @__PURE__ */ jsx(Combobox, {
|
|
3977
|
+
multiple: true,
|
|
3978
|
+
inline: true,
|
|
3979
|
+
autoHighlight: true,
|
|
3980
|
+
virtualized: virtualizeRows,
|
|
3981
|
+
onItemHighlighted: (_item, details) => scrollHighlightedRowIntoView(scrollRowIntoViewRef, details.index, details.reason),
|
|
3982
|
+
items: groups ?? items,
|
|
3983
|
+
filter: onSearch || onFetchMore && hasMore ? null : void 0,
|
|
3984
|
+
value: selectedObjects,
|
|
3985
|
+
onValueChange: commit,
|
|
3986
|
+
itemToStringValue: getItemValue,
|
|
3987
|
+
itemToStringLabel: getItemLabel,
|
|
3988
|
+
isItemEqualToValue: (a, b) => getItemValue(a) === getItemValue(b),
|
|
3989
|
+
onInputValueChange: handleInputValueChange,
|
|
3990
|
+
children: body
|
|
3991
|
+
}, selectionMode);
|
|
3992
|
+
return /* @__PURE__ */ jsx(Combobox, {
|
|
3993
|
+
inline: true,
|
|
3994
|
+
autoHighlight: true,
|
|
3995
|
+
virtualized: virtualizeRows,
|
|
3996
|
+
onItemHighlighted: (_item, details) => scrollHighlightedRowIntoView(scrollRowIntoViewRef, details.index, details.reason),
|
|
3997
|
+
items: groups ?? items,
|
|
3998
|
+
filter: onSearch || onFetchMore && hasMore ? null : void 0,
|
|
3999
|
+
value: selectedObjects[0] ?? null,
|
|
4000
|
+
onValueChange: (next) => commit(next == null ? [] : [next]),
|
|
4001
|
+
itemToStringValue: getItemValue,
|
|
4002
|
+
itemToStringLabel: getItemLabel,
|
|
4003
|
+
isItemEqualToValue: (a, b) => getItemValue(a) === getItemValue(b),
|
|
4004
|
+
onInputValueChange: handleInputValueChange,
|
|
4005
|
+
children: body
|
|
4006
|
+
}, selectionMode);
|
|
4007
|
+
}
|
|
4008
|
+
|
|
4009
|
+
//#endregion
|
|
4010
|
+
//#region src/components/dialog.tsx
|
|
4011
|
+
/**
|
|
4012
|
+
* Root of the dialog, wrapping Base UI's `Dialog.Root`. Manages open/close state and renders no DOM
|
|
4013
|
+
* element — place `DialogTrigger` and `DialogContent` inside it.
|
|
4014
|
+
*
|
|
4015
|
+
* @example
|
|
4016
|
+
* ```tsx
|
|
4017
|
+
* <Dialog>
|
|
4018
|
+
* <DialogTrigger render={<Button />}>Open</DialogTrigger>
|
|
4019
|
+
* <DialogContent>
|
|
4020
|
+
* <DialogHeader>
|
|
4021
|
+
* <DialogTitle>Title</DialogTitle>
|
|
4022
|
+
* <DialogDescription>Description</DialogDescription>
|
|
4023
|
+
* </DialogHeader>
|
|
4024
|
+
* </DialogContent>
|
|
4025
|
+
* </Dialog>
|
|
4026
|
+
* ```
|
|
4027
|
+
*/
|
|
4028
|
+
function Dialog(componentProps) {
|
|
4029
|
+
return /* @__PURE__ */ jsx(Dialog$1.Root, {
|
|
4030
|
+
"data-slot": "dialog",
|
|
4031
|
+
...componentProps
|
|
4032
|
+
});
|
|
4033
|
+
}
|
|
4034
|
+
/**
|
|
4035
|
+
* Button that opens the dialog, wrapping Base UI's `Dialog.Trigger`. Renders a `<button>` by
|
|
4036
|
+
* default (override with `render`).
|
|
4037
|
+
*/
|
|
4038
|
+
const DialogTrigger = React.forwardRef((componentProps, forwardRef) => {
|
|
4039
|
+
const { ...props } = componentProps;
|
|
4040
|
+
return /* @__PURE__ */ jsx(Dialog$1.Trigger, {
|
|
4041
|
+
ref: forwardRef,
|
|
4042
|
+
"data-slot": "dialog-trigger",
|
|
4043
|
+
...props
|
|
4044
|
+
});
|
|
4045
|
+
});
|
|
4046
|
+
DialogTrigger.displayName = "DialogTrigger";
|
|
4047
|
+
/**
|
|
4048
|
+
* Portals dialog content into the document body, wrapping Base UI's `Dialog.Portal`. Renders no DOM
|
|
4049
|
+
* element of its own.
|
|
4050
|
+
*/
|
|
4051
|
+
function DialogPortal(componentProps) {
|
|
4052
|
+
return /* @__PURE__ */ jsx(Dialog$1.Portal, {
|
|
4053
|
+
"data-slot": "dialog-portal",
|
|
4054
|
+
...componentProps
|
|
4055
|
+
});
|
|
4056
|
+
}
|
|
4057
|
+
/**
|
|
4058
|
+
* Button that closes the dialog, wrapping Base UI's `Dialog.Close`. Renders a `<button>` by default
|
|
4059
|
+
* (override with `render`).
|
|
4060
|
+
*/
|
|
4061
|
+
const DialogClose = React.forwardRef((componentProps, forwardRef) => {
|
|
4062
|
+
const { ...props } = componentProps;
|
|
4063
|
+
return /* @__PURE__ */ jsx(Dialog$1.Close, {
|
|
4064
|
+
ref: forwardRef,
|
|
4065
|
+
"data-slot": "dialog-close",
|
|
4066
|
+
...props
|
|
4067
|
+
});
|
|
4068
|
+
});
|
|
4069
|
+
DialogClose.displayName = "DialogClose";
|
|
4070
|
+
/**
|
|
4071
|
+
* Dimming backdrop rendered behind the dialog, wrapping Base UI's `Dialog.Backdrop`. Renders a
|
|
4072
|
+
* fixed, full-viewport `<div>`. Included automatically by `DialogContent`.
|
|
4073
|
+
*/
|
|
4074
|
+
const DialogOverlay = React.forwardRef((componentProps, forwardRef) => {
|
|
4075
|
+
const { className, ...props } = componentProps;
|
|
4076
|
+
return /* @__PURE__ */ jsx(Dialog$1.Backdrop, {
|
|
4077
|
+
ref: forwardRef,
|
|
4078
|
+
"data-slot": "dialog-overlay",
|
|
4079
|
+
className: cn("fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0", className),
|
|
4080
|
+
...props
|
|
4081
|
+
});
|
|
4082
|
+
});
|
|
4083
|
+
DialogOverlay.displayName = "DialogOverlay";
|
|
4084
|
+
/**
|
|
4085
|
+
* Centered dialog panel, wrapping Base UI's `Dialog.Popup`. Renders a fixed `<div>` and
|
|
4086
|
+
* automatically includes its own `DialogPortal` and `DialogOverlay`.
|
|
4087
|
+
*/
|
|
4088
|
+
const DialogContent = React.forwardRef((componentProps, forwardRef) => {
|
|
4089
|
+
const { className, children, showCloseButton = true, ...props } = componentProps;
|
|
4090
|
+
return /* @__PURE__ */ jsxs(DialogPortal, { children: [/* @__PURE__ */ jsx(DialogOverlay, {}), /* @__PURE__ */ jsxs(Dialog$1.Popup, {
|
|
3701
4091
|
ref: forwardRef,
|
|
3702
4092
|
"data-slot": "dialog-content",
|
|
3703
4093
|
className: cn("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl ring-1 ring-foreground/10 bg-background px-6 py-4 text-sm duration-100 outline-none sm:max-w-md data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className),
|
|
@@ -3975,99 +4365,8 @@ const CountryFlag = React.forwardRef((componentProps, forwardRef) => {
|
|
|
3975
4365
|
});
|
|
3976
4366
|
CountryFlag.displayName = "CountryFlag";
|
|
3977
4367
|
|
|
3978
|
-
//#endregion
|
|
3979
|
-
//#region src/components/skeleton.tsx
|
|
3980
|
-
/**
|
|
3981
|
-
* Pulsing placeholder shown while content is loading. Renders a `<div>`;
|
|
3982
|
-
* set its dimensions via `className` to match the content it stands in for.
|
|
3983
|
-
*
|
|
3984
|
-
* @example
|
|
3985
|
-
* ```tsx
|
|
3986
|
-
* <Skeleton className="h-4 w-32" />
|
|
3987
|
-
* ```
|
|
3988
|
-
*/
|
|
3989
|
-
const Skeleton = React.forwardRef((componentProps, forwardRef) => {
|
|
3990
|
-
const { className, ...props } = componentProps;
|
|
3991
|
-
return /* @__PURE__ */ jsx("div", {
|
|
3992
|
-
ref: forwardRef,
|
|
3993
|
-
"data-slot": "skeleton",
|
|
3994
|
-
className: cn("animate-pulse rounded-md bg-muted", className),
|
|
3995
|
-
...props
|
|
3996
|
-
});
|
|
3997
|
-
});
|
|
3998
|
-
Skeleton.displayName = "Skeleton";
|
|
3999
|
-
|
|
4000
|
-
//#endregion
|
|
4001
|
-
//#region src/lib/use-fetch-more-sentinel.ts
|
|
4002
|
-
/**
|
|
4003
|
-
* Returns a callback ref for a scroll sentinel element placed at the bottom of a
|
|
4004
|
-
* scrollable list. When the sentinel scrolls into view (within `rootMargin`),
|
|
4005
|
-
* `onFetchMore` fires once. The observer is (re)attached whenever the sentinel
|
|
4006
|
-
* node mounts — so it works even if the sentinel only appears after the first
|
|
4007
|
-
* page loads — and re-arms whenever `resetKey` changes (a page arrived, or the
|
|
4008
|
-
* list reset), so pagination keeps going while the sentinel stays in view and
|
|
4009
|
-
* pauses once it scrolls away. It fires at most once per intersection, so a
|
|
4010
|
-
* sentinel that stays in view can't trigger duplicate loads or a tight retry
|
|
4011
|
-
* loop when a fetch fails and the data is unchanged.
|
|
4012
|
-
*
|
|
4013
|
-
* `getRoot` resolves the scroll container the sentinel is measured against, given
|
|
4014
|
-
* the sentinel node — return the scrolling ancestor (a table container, a
|
|
4015
|
-
* combobox list, …) so `rootMargin` gives prefetch headroom inside a clipped
|
|
4016
|
-
* scroll area, or `null` to measure against the viewport.
|
|
4017
|
-
*
|
|
4018
|
-
* @example
|
|
4019
|
-
* ```tsx
|
|
4020
|
-
* const sentinelRef = useFetchMoreSentinel<HTMLDivElement>(
|
|
4021
|
-
* onFetchMore,
|
|
4022
|
-
* node => node.closest<HTMLElement>('[data-slot="combobox-list"]'),
|
|
4023
|
-
* items.length
|
|
4024
|
-
* );
|
|
4025
|
-
* // …later, at the bottom of the list:
|
|
4026
|
-
* <div aria-hidden ref={sentinelRef} />
|
|
4027
|
-
* ```
|
|
4028
|
-
*/
|
|
4029
|
-
function useFetchMoreSentinel(onFetchMore, getRoot, resetKey) {
|
|
4030
|
-
const onFetchMoreRef = React.useRef(onFetchMore);
|
|
4031
|
-
onFetchMoreRef.current = onFetchMore;
|
|
4032
|
-
const getRootRef = React.useRef(getRoot);
|
|
4033
|
-
getRootRef.current = getRoot;
|
|
4034
|
-
const observerRef = React.useRef(null);
|
|
4035
|
-
const nodeRef = React.useRef(null);
|
|
4036
|
-
const armedRef = React.useRef(true);
|
|
4037
|
-
const observe = React.useCallback(() => {
|
|
4038
|
-
observerRef.current?.disconnect();
|
|
4039
|
-
observerRef.current = null;
|
|
4040
|
-
const node = nodeRef.current;
|
|
4041
|
-
if (!node) return;
|
|
4042
|
-
const root = getRootRef.current(node);
|
|
4043
|
-
const observer = new IntersectionObserver((entries) => {
|
|
4044
|
-
if (entries[entries.length - 1]?.isIntersecting) {
|
|
4045
|
-
if (armedRef.current) {
|
|
4046
|
-
armedRef.current = false;
|
|
4047
|
-
onFetchMoreRef.current?.();
|
|
4048
|
-
}
|
|
4049
|
-
} else armedRef.current = true;
|
|
4050
|
-
}, {
|
|
4051
|
-
root,
|
|
4052
|
-
rootMargin: "200px"
|
|
4053
|
-
});
|
|
4054
|
-
observer.observe(node);
|
|
4055
|
-
observerRef.current = observer;
|
|
4056
|
-
}, []);
|
|
4057
|
-
React.useEffect(() => {
|
|
4058
|
-
armedRef.current = true;
|
|
4059
|
-
observe();
|
|
4060
|
-
}, [resetKey, observe]);
|
|
4061
|
-
return React.useCallback((node) => {
|
|
4062
|
-
nodeRef.current = node;
|
|
4063
|
-
observe();
|
|
4064
|
-
}, [observe]);
|
|
4065
|
-
}
|
|
4066
|
-
|
|
4067
4368
|
//#endregion
|
|
4068
4369
|
//#region src/components/data-combobox.tsx
|
|
4069
|
-
const DEFAULT_SKELETON_COUNT$1 = 5;
|
|
4070
|
-
const EMPTY_KEYS$1 = /* @__PURE__ */ new Set();
|
|
4071
4370
|
/**
|
|
4072
4371
|
* Searchable dropdown built on the DS Combobox primitives, driven by an `items`
|
|
4073
4372
|
* array plus `getItemValue`/`getItemLabel`. Renders an inline input (single) or
|
|
@@ -4086,87 +4385,31 @@ const EMPTY_KEYS$1 = /* @__PURE__ */ new Set();
|
|
|
4086
4385
|
* ```
|
|
4087
4386
|
*/
|
|
4088
4387
|
function DataCombobox(componentProps) {
|
|
4089
|
-
const { items, getItemValue, getItemLabel, renderItem, renderChip, getGroupKey, getGroupLabel, selectionMode = "single", selectedKeys, defaultSelectedKeys, onSelectionChange, onOpenChange, selectedItems, disabledKeys, loadingState
|
|
4090
|
-
const t = useDsTranslation("ds");
|
|
4388
|
+
const { items, getItemValue, getItemLabel, renderItem, renderChip, getGroupKey, getGroupLabel, selectionMode = "single", selectedKeys, defaultSelectedKeys, onSelectionChange, onOpenChange, selectedItems, disabledKeys, loadingState, skeletonCount, onSearch, onFetchMore, hasMore = false, emptyState, trigger, searchable = true, placeholder, disabled = false, className, contentClassName, "aria-label": ariaLabel } = componentProps;
|
|
4091
4389
|
const multiple = selectionMode === "multiple";
|
|
4092
|
-
const
|
|
4093
|
-
const itemCacheRef = React.useRef(/* @__PURE__ */ new Map());
|
|
4094
|
-
if (selectedItems) for (const item of selectedItems) itemCacheRef.current.set(getItemValue(item), item);
|
|
4095
|
-
for (const item of items) itemCacheRef.current.set(getItemValue(item), item);
|
|
4096
|
-
const itemCache = itemCacheRef.current;
|
|
4097
|
-
const [selectionSet, setSelectionSet] = useControllableState({
|
|
4098
|
-
prop: selectedKeys,
|
|
4099
|
-
defaultProp: defaultSelectedKeys,
|
|
4100
|
-
onChange: onSelectionChange
|
|
4101
|
-
});
|
|
4102
|
-
const keys = selectionSet ?? EMPTY_KEYS$1;
|
|
4103
|
-
const selectedObjects = [];
|
|
4104
|
-
for (const key of keys) {
|
|
4105
|
-
const item = itemCache.get(key);
|
|
4106
|
-
if (item) selectedObjects.push(item);
|
|
4107
|
-
}
|
|
4108
|
-
const commit = React.useCallback((objs) => setSelectionSet(new Set(objs.map(getItemValue))), [setSelectionSet, getItemValue]);
|
|
4109
|
-
const handleInputValueChange = onSearch ? (value, details) => {
|
|
4110
|
-
if (details.reason === "input-change" || details.reason === "input-clear" || details.reason === "clear-press") onSearch(value);
|
|
4111
|
-
} : void 0;
|
|
4112
|
-
const isInitialLoading = loadingState === "loading";
|
|
4113
|
-
const isFiltering = loadingState === "filtering";
|
|
4114
|
-
const isLoadingMore = loadingState === "loadingMore";
|
|
4115
|
-
const groups = React.useMemo(() => {
|
|
4116
|
-
if (!getGroupKey) return null;
|
|
4117
|
-
const byKey = /* @__PURE__ */ new Map();
|
|
4118
|
-
for (const item of items) {
|
|
4119
|
-
const gk = getGroupKey(item);
|
|
4120
|
-
const bucket = byKey.get(gk);
|
|
4121
|
-
if (bucket) bucket.push(item);
|
|
4122
|
-
else byKey.set(gk, [item]);
|
|
4123
|
-
}
|
|
4124
|
-
return Array.from(byKey, ([groupKey, groupItems]) => ({
|
|
4125
|
-
groupKey,
|
|
4126
|
-
label: getGroupLabel ? getGroupLabel(groupKey) : groupKey,
|
|
4127
|
-
items: groupItems
|
|
4128
|
-
}));
|
|
4129
|
-
}, [
|
|
4390
|
+
const { keys, selectedObjects, commit, handleInputValueChange } = useComboboxItemSelection({
|
|
4130
4391
|
items,
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
const
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
children: [isInitialLoading ? /* @__PURE__ */ jsx("div", {
|
|
4153
|
-
className: "p-1",
|
|
4154
|
-
children: /* @__PURE__ */ jsx(ComboboxSkeleton, { count: skeletonCount })
|
|
4155
|
-
}) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4156
|
-
/* @__PURE__ */ jsx(ComboboxList, {
|
|
4157
|
-
"aria-label": ariaLabel,
|
|
4158
|
-
children: isGrouped ? (group) => /* @__PURE__ */ jsxs(ComboboxGroup, {
|
|
4159
|
-
items: group.items,
|
|
4160
|
-
children: [/* @__PURE__ */ jsx(ComboboxLabel, { children: group.label }), /* @__PURE__ */ jsx(ComboboxCollection, { children: renderRow })]
|
|
4161
|
-
}, group.groupKey) : renderRow
|
|
4162
|
-
}),
|
|
4163
|
-
isFiltering ? null : /* @__PURE__ */ jsx(ComboboxEmpty, { children: emptyState ?? t("dataCombobox.noResults") }),
|
|
4164
|
-
isLoadingMore ? /* @__PURE__ */ jsx(SpinnerRow, {}) : null
|
|
4165
|
-
] }), isFiltering ? /* @__PURE__ */ jsx("div", {
|
|
4166
|
-
"data-slot": "combobox-loading-overlay",
|
|
4167
|
-
className: "bg-popover/60 absolute inset-0 z-10 flex items-center justify-center",
|
|
4168
|
-
children: /* @__PURE__ */ jsx(Spinner, {})
|
|
4169
|
-
}) : null]
|
|
4392
|
+
getItemValue,
|
|
4393
|
+
selectedItems,
|
|
4394
|
+
selectedKeys,
|
|
4395
|
+
defaultSelectedKeys,
|
|
4396
|
+
onSelectionChange,
|
|
4397
|
+
onSearch
|
|
4398
|
+
});
|
|
4399
|
+
const groups = useComboboxItemGroups(items, getGroupKey, getGroupLabel);
|
|
4400
|
+
const popupRows = /* @__PURE__ */ jsx(ComboboxRows, {
|
|
4401
|
+
items,
|
|
4402
|
+
groups,
|
|
4403
|
+
getItemValue,
|
|
4404
|
+
getItemLabel,
|
|
4405
|
+
renderItem,
|
|
4406
|
+
disabledKeys,
|
|
4407
|
+
loadingState,
|
|
4408
|
+
skeletonCount,
|
|
4409
|
+
onFetchMore,
|
|
4410
|
+
hasMore,
|
|
4411
|
+
emptyState,
|
|
4412
|
+
"aria-label": ariaLabel
|
|
4170
4413
|
});
|
|
4171
4414
|
const chipsAnchor = useComboboxAnchor();
|
|
4172
4415
|
const overlayLayout = trigger ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Combobox$1.Trigger, { render: trigger }), /* @__PURE__ */ jsxs(ComboboxContent, {
|
|
@@ -4174,7 +4417,7 @@ function DataCombobox(componentProps) {
|
|
|
4174
4417
|
children: [searchable ? /* @__PURE__ */ jsx(ComboboxInput, {
|
|
4175
4418
|
showTrigger: false,
|
|
4176
4419
|
placeholder
|
|
4177
|
-
}) : null,
|
|
4420
|
+
}) : null, popupRows]
|
|
4178
4421
|
})] }) : null;
|
|
4179
4422
|
if (multiple) return /* @__PURE__ */ jsx(Combobox, {
|
|
4180
4423
|
multiple: true,
|
|
@@ -4196,7 +4439,7 @@ function DataCombobox(componentProps) {
|
|
|
4196
4439
|
}), /* @__PURE__ */ jsx(ComboboxContent, {
|
|
4197
4440
|
anchor: chipsAnchor,
|
|
4198
4441
|
className: cn("min-w-50", contentClassName),
|
|
4199
|
-
children:
|
|
4442
|
+
children: popupRows
|
|
4200
4443
|
})] })
|
|
4201
4444
|
}, selectionMode);
|
|
4202
4445
|
return /* @__PURE__ */ jsx(Combobox, {
|
|
@@ -4218,30 +4461,10 @@ function DataCombobox(componentProps) {
|
|
|
4218
4461
|
showClear: true
|
|
4219
4462
|
}), /* @__PURE__ */ jsx(ComboboxContent, {
|
|
4220
4463
|
className: cn("min-w-50", contentClassName),
|
|
4221
|
-
children:
|
|
4464
|
+
children: popupRows
|
|
4222
4465
|
})] })
|
|
4223
4466
|
}, selectionMode);
|
|
4224
4467
|
}
|
|
4225
|
-
/**
|
|
4226
|
-
* A centered spinner row for the filtering and load-more states. Not
|
|
4227
|
-
* `aria-hidden` — the `Spinner`'s `role="status"` announces loading to screen
|
|
4228
|
-
* readers (that's the point of a loading indicator).
|
|
4229
|
-
*/
|
|
4230
|
-
function SpinnerRow() {
|
|
4231
|
-
return /* @__PURE__ */ jsx("div", {
|
|
4232
|
-
className: "flex justify-center py-2 text-muted-foreground",
|
|
4233
|
-
children: /* @__PURE__ */ jsx(Spinner, {})
|
|
4234
|
-
});
|
|
4235
|
-
}
|
|
4236
|
-
/** Skeleton rows shown while the initial page loads. */
|
|
4237
|
-
function ComboboxSkeleton({ count }) {
|
|
4238
|
-
return /* @__PURE__ */ jsx(Fragment, { children: Array.from({ length: count }, (_, i) => /* @__PURE__ */ jsx("div", {
|
|
4239
|
-
"aria-hidden": true,
|
|
4240
|
-
"data-test": "loading-item",
|
|
4241
|
-
className: "flex items-center gap-2 rounded-md p-2",
|
|
4242
|
-
children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-full" })
|
|
4243
|
-
}, `skeleton-${i}`)) });
|
|
4244
|
-
}
|
|
4245
4468
|
|
|
4246
4469
|
//#endregion
|
|
4247
4470
|
//#region src/components/table.tsx
|
|
@@ -4949,6 +5172,59 @@ function DataTree(componentProps) {
|
|
|
4949
5172
|
});
|
|
4950
5173
|
}
|
|
4951
5174
|
|
|
5175
|
+
//#endregion
|
|
5176
|
+
//#region src/components/scroll-area.tsx
|
|
5177
|
+
/**
|
|
5178
|
+
* Custom-scrollbar container. Renders the Base UI `ScrollArea.Root` `<div>`
|
|
5179
|
+
* (with `min-h-0` so it can shrink in flex layouts) wrapping a scrollable
|
|
5180
|
+
* viewport, vertical/horizontal scrollbars, and a corner.
|
|
5181
|
+
*
|
|
5182
|
+
* @example
|
|
5183
|
+
* ```tsx
|
|
5184
|
+
* <ScrollArea className="h-72">
|
|
5185
|
+
* <div>Long content…</div>
|
|
5186
|
+
* </ScrollArea>
|
|
5187
|
+
* ```
|
|
5188
|
+
*/
|
|
5189
|
+
const ScrollArea = React.forwardRef((componentProps, forwardRef) => {
|
|
5190
|
+
const { className, children, scrollFade = false, scrollbarGutter = false, ...props } = componentProps;
|
|
5191
|
+
return /* @__PURE__ */ jsxs(ScrollAreaPrimitive.Root, {
|
|
5192
|
+
ref: forwardRef,
|
|
5193
|
+
className: cn("size-full min-h-0", className),
|
|
5194
|
+
...props,
|
|
5195
|
+
children: [
|
|
5196
|
+
/* @__PURE__ */ jsx(ScrollAreaPrimitive.Viewport, {
|
|
5197
|
+
className: cn("h-full rounded-[inherit] outline-none transition-shadows focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background data-has-overflow-y:overscroll-y-contain data-has-overflow-x:overscroll-x-contain", scrollFade && "mask-t-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-y-start)))] mask-b-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-y-end)))] mask-l-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-x-start)))] mask-r-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-x-end)))] [--fade-size:1.5rem]", scrollbarGutter && "data-has-overflow-y:pe-2.5 data-has-overflow-x:pb-2.5"),
|
|
5198
|
+
"data-slot": "scroll-area-viewport",
|
|
5199
|
+
children
|
|
5200
|
+
}),
|
|
5201
|
+
/* @__PURE__ */ jsx(ScrollBar, { orientation: "vertical" }),
|
|
5202
|
+
/* @__PURE__ */ jsx(ScrollBar, { orientation: "horizontal" }),
|
|
5203
|
+
/* @__PURE__ */ jsx(ScrollAreaPrimitive.Corner, { "data-slot": "scroll-area-corner" })
|
|
5204
|
+
]
|
|
5205
|
+
});
|
|
5206
|
+
});
|
|
5207
|
+
ScrollArea.displayName = "ScrollArea";
|
|
5208
|
+
/**
|
|
5209
|
+
* Draggable scrollbar for one axis, shown on hover/scroll. Renders the Base UI
|
|
5210
|
+
* `ScrollArea.Scrollbar` `<div>` containing a rounded `Thumb`.
|
|
5211
|
+
*/
|
|
5212
|
+
const ScrollBar = React.forwardRef((componentProps, forwardRef) => {
|
|
5213
|
+
const { className, orientation = "vertical", ...props } = componentProps;
|
|
5214
|
+
return /* @__PURE__ */ jsx(ScrollAreaPrimitive.Scrollbar, {
|
|
5215
|
+
ref: forwardRef,
|
|
5216
|
+
className: cn("m-1 flex opacity-0 transition-opacity delay-300 data-[orientation=horizontal]:h-1.5 data-[orientation=vertical]:w-1.5 data-[orientation=horizontal]:flex-col data-hovering:opacity-100 data-scrolling:opacity-100 data-hovering:delay-0 data-scrolling:delay-0 data-hovering:duration-100 data-scrolling:duration-100", className),
|
|
5217
|
+
"data-slot": "scroll-area-scrollbar",
|
|
5218
|
+
orientation,
|
|
5219
|
+
...props,
|
|
5220
|
+
children: /* @__PURE__ */ jsx(ScrollAreaPrimitive.Thumb, {
|
|
5221
|
+
className: "relative flex-1 rounded-full bg-foreground/20",
|
|
5222
|
+
"data-slot": "scroll-area-thumb"
|
|
5223
|
+
})
|
|
5224
|
+
});
|
|
5225
|
+
});
|
|
5226
|
+
ScrollBar.displayName = "ScrollBar";
|
|
5227
|
+
|
|
4952
5228
|
//#endregion
|
|
4953
5229
|
//#region src/components/drawer.tsx
|
|
4954
5230
|
const DrawerContext = createContext({ position: "bottom" });
|
|
@@ -5762,7 +6038,7 @@ const EmptyTitle = React.forwardRef((componentProps, forwardRef) => {
|
|
|
5762
6038
|
return /* @__PURE__ */ jsx("div", {
|
|
5763
6039
|
ref: forwardRef,
|
|
5764
6040
|
"data-slot": "empty-title",
|
|
5765
|
-
className: cn("text-
|
|
6041
|
+
className: cn("text-lg text-foreground font-medium tracking-tight", className),
|
|
5766
6042
|
...props
|
|
5767
6043
|
});
|
|
5768
6044
|
});
|
|
@@ -8425,7 +8701,7 @@ const RadioGroupItem = React.forwardRef((componentProps, forwardRef) => {
|
|
|
8425
8701
|
return /* @__PURE__ */ jsx(Radio.Root, {
|
|
8426
8702
|
ref: forwardRef,
|
|
8427
8703
|
"data-slot": "radio-group-item",
|
|
8428
|
-
className: cn("group/radio-group-item peer relative flex aspect-square size-4 shrink-0 rounded-full border border-input outline-none transition-[color,box-shadow,opacity] active:opacity-60 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50 aria-invalid:border-destructive focus-visible:aria-invalid:ring-3 focus-visible:aria-invalid:ring-destructive/20 dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:focus-visible:aria-invalid:ring-destructive/40 data-checked:border-primary aria-invalid:data-checked:border-destructive", className),
|
|
8704
|
+
className: cn("group/radio-group-item peer relative flex aspect-square size-4 shrink-0 rounded-full border border-input outline-none transition-[color,box-shadow,opacity] active:opacity-60 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50 aria-invalid:border-destructive focus-visible:aria-invalid:ring-3 focus-visible:aria-invalid:ring-destructive/20 dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:focus-visible:aria-invalid:ring-destructive/40 data-checked:border-primary aria-invalid:data-checked:border-destructive bg-background", className),
|
|
8429
8705
|
...props,
|
|
8430
8706
|
children: /* @__PURE__ */ jsx(Radio.Indicator, {
|
|
8431
8707
|
"data-slot": "radio-group-indicator",
|
|
@@ -10052,4 +10328,4 @@ function useAudioGauge(options = {}) {
|
|
|
10052
10328
|
}
|
|
10053
10329
|
|
|
10054
10330
|
//#endregion
|
|
10055
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, ActionBar, ActionBarButton, ActionBarContext, ActionBarHeight, Alert, AlertAction, AlertAction as BannerAction, AlertDescription, AlertDescription as BannerDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AlertTitle as BannerTitle, Anchor, Attachment, AttachmentAction, AttachmentActions, AttachmentContent, AttachmentDescription, AttachmentGroup, AttachmentMedia, AttachmentTitle, AttachmentTrigger, Audio, AudioPlayerBar, AudioPlayerButton, AudioPlayerCurrentTime, AudioPlayerDuration, AudioPlayerManager, AudioPlayerRow, AudioPlayerSkip, AudioPlayerSpeed, AudioPlayerTime, Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage, Badge, BadgeGroup, BadgeGroupCount, Banner, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, Checkbox, Chip, ChipRemove, Collapsible, CollapsibleContent, CollapsibleTrigger, Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLabel, ComboboxList, ComboboxSeparator, ComboboxTrigger, ComboboxValue, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, CounterBadge, CountryFlag, DataCombobox, DataTable, DataTree, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerBackdrop, DrawerBar, DrawerClose, DrawerContent, DrawerCreateHandle, DrawerDescription, DrawerFooter, DrawerHeader, DrawerMenu, DrawerMenuCheckboxItem, DrawerMenuGroup, DrawerMenuGroupLabel, DrawerMenuItem, DrawerMenuRadioGroup, DrawerMenuRadioItem, DrawerMenuSeparator, DrawerMenuTrigger, DrawerPanel, DrawerPopup, DrawerPortal, DrawerPrimitive, DrawerSwipeArea, DrawerTitle, DrawerTrigger, DrawerViewport, DropdownMenu, DropdownMenuAddon, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Dropzone, DropzoneActions, DropzoneContent, DropzoneDescription, DropzoneIcon, DropzoneTitle, DropzoneTrigger, DsI18nProvider, EmojiPicker, EmojiPickerCategories, EmojiPickerContent, EmojiPickerTrigger, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, FAB, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLabelAside, FieldLabelInfo, FieldLabelRow, FieldLegend, FieldSeparator, FieldSet, FieldTitle,
|
|
10331
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, ActionBar, ActionBarButton, ActionBarContext, ActionBarHeight, Alert, AlertAction, AlertAction as BannerAction, AlertDescription, AlertDescription as BannerDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AlertTitle as BannerTitle, Anchor, Attachment, AttachmentAction, AttachmentActions, AttachmentContent, AttachmentDescription, AttachmentGroup, AttachmentMedia, AttachmentTitle, AttachmentTrigger, Audio, AudioPlayerBar, AudioPlayerButton, AudioPlayerCurrentTime, AudioPlayerDuration, AudioPlayerManager, AudioPlayerRow, AudioPlayerSkip, AudioPlayerSpeed, AudioPlayerTime, Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage, Badge, BadgeGroup, BadgeGroupCount, Banner, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, Checkbox, Chip, ChipRemove, Collapsible, CollapsibleContent, CollapsibleTrigger, Combobox, ComboboxBody, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLabel, ComboboxList, ComboboxSeparator, ComboboxTrigger, ComboboxValue, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, CounterBadge, CountryFlag, DataCombobox, DataTable, DataTree, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerBackdrop, DrawerBar, DrawerClose, DrawerContent, DrawerCreateHandle, DrawerDescription, DrawerFooter, DrawerHeader, DrawerMenu, DrawerMenuCheckboxItem, DrawerMenuGroup, DrawerMenuGroupLabel, DrawerMenuItem, DrawerMenuRadioGroup, DrawerMenuRadioItem, DrawerMenuSeparator, DrawerMenuTrigger, DrawerPanel, DrawerPopup, DrawerPortal, DrawerPrimitive, DrawerSwipeArea, DrawerTitle, DrawerTrigger, DrawerViewport, DropdownMenu, DropdownMenuAddon, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Dropzone, DropzoneActions, DropzoneContent, DropzoneDescription, DropzoneIcon, DropzoneTitle, DropzoneTrigger, DsI18nProvider, EmojiPicker, EmojiPickerCategories, EmojiPickerContent, EmojiPickerTrigger, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, FAB, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLabelAside, FieldLabelInfo, FieldLabelRow, FieldLegend, FieldSeparator, FieldSet, FieldTitle, Gauge, HoverCard, HoverCardContent, HoverCardTrigger, InlineEditInput, InlineEditMultiselect, InlineEditMultiselectChip, InlineEditMultiselectChips, InlineEditMultiselectContent, InlineEditMultiselectItem, InlineEditMultiselectTrigger, InlineEditMultiselectValue, InlineEditSelect, InlineEditSelectContent, InlineEditSelectItem, InlineEditSelectTrigger, InlineEditSelectValue, InlineEditTextarea, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, ItemSeparator, ItemTitle, Label, List, ListCol, ListRow, NotificationQueueProvider, NotificationSlot, NumericInput, NumericInputControl, NumericInputDecrement, NumericInputIncrement, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, Progress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue, RadioGroup, RadioGroupItem, SUPPORTED_LANGUAGES, ScrollArea, ScrollAreaPrimitive, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Slider, Spinner, Stepper, StepperContent, StepperCounter, StepperPanel, StepperProgress, Switch, Table, TableBody, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, ThemeProvider, Toaster, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, Tree, TreeDragLine, TreeItem, TreeItemLabel, alertVariants, anchorVariants, bannerVariants, buttonGroupVariants, buttonVariants, cn, counterBadgeVariants, detectInitialLanguage, fabVariants, registerI18nNamespace, selectTriggerVariants, spinnerVariants, syncDsLanguage, toast, toggleVariants, useAudioGauge, useAudioPlayer, useAudioPlayerTime, useComboboxAnchor, useDsLocale, useDsTranslation, useNotification, useNotificationQueue, useSidebar, useStepper, useTheme };
|