@aircall/ds 0.28.1 → 0.30.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 +258 -82
- package/dist/index.js +688 -388
- 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
|
/**
|
|
@@ -3617,87 +3495,623 @@ 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
|
+
});
|
|
3866
|
+
const keys = selectionSet ?? EMPTY_KEYS$1;
|
|
3867
|
+
const selectedObjects = [];
|
|
3868
|
+
for (const key of keys) {
|
|
3869
|
+
const item = itemCache.get(key);
|
|
3870
|
+
if (item) selectedObjects.push(item);
|
|
3871
|
+
}
|
|
3872
|
+
return {
|
|
3873
|
+
keys,
|
|
3874
|
+
selectedObjects,
|
|
3875
|
+
commit: React.useCallback((objs, details) => {
|
|
3876
|
+
const next = new Set(objs.map(getItemValue));
|
|
3877
|
+
setSelectionSet(next);
|
|
3878
|
+
onSelectionChange?.(next, details);
|
|
3879
|
+
}, [
|
|
3880
|
+
setSelectionSet,
|
|
3881
|
+
getItemValue,
|
|
3882
|
+
onSelectionChange
|
|
3883
|
+
]),
|
|
3884
|
+
handleInputValueChange: onSearch ? (value, details) => {
|
|
3885
|
+
if (searchTriggerReasons.has(details.reason)) onSearch(value);
|
|
3886
|
+
} : void 0
|
|
3887
|
+
};
|
|
3888
|
+
}
|
|
3889
|
+
|
|
3890
|
+
//#endregion
|
|
3891
|
+
//#region src/components/combobox-body.tsx
|
|
3892
|
+
const LIST_MAX_HEIGHT = "max-h-63";
|
|
3893
|
+
const INPUT_IN_LIST_CLASSES = "m-1 mb-0 border-input/30 bg-input/30 shadow-none";
|
|
3894
|
+
const FOCUSABLE_LIST_CLASSES = "focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:ring-inset";
|
|
3895
|
+
/**
|
|
3896
|
+
* Row count at which `ComboboxBody` virtualises its rows on its own, when `virtualizeRows` was not
|
|
3897
|
+
* passed either way. Exported so it can be asserted against and tuned in ONE place.
|
|
3898
|
+
*
|
|
3899
|
+
* Crossing it LATCHES virtualisation on for the life of the component - see the `virtualizeRows`
|
|
3900
|
+
* prop doc. A list that declares `onFetchMore` can grow without bound, so it starts out virtualised
|
|
3901
|
+
* regardless of this number rather than waiting to cross it.
|
|
3902
|
+
*
|
|
3903
|
+
* A STARTING POINT, not a measured optimum. The two real data points behind it: 244 countries with
|
|
3904
|
+
* a flag per row was visibly laggy unvirtualised, and the user lists are server-capped at 10 rows
|
|
3905
|
+
* today, so both known cases sit far from this line and the exact value is not load-bearing yet.
|
|
3906
|
+
* Measure before tuning it - the honest cost driver is how expensive `renderItem` is, not the row
|
|
3907
|
+
* count alone, and a threshold cannot see that.
|
|
3908
|
+
*/
|
|
3909
|
+
const COMBOBOX_AUTO_VIRTUALIZE_THRESHOLD = 100;
|
|
3910
|
+
/**
|
|
3911
|
+
* Scrolls a keyboard-highlighted row into view while rows are virtualised.
|
|
3912
|
+
* A no-op without virtualisation (nothing fills the ref), for a pointer-driven
|
|
3913
|
+
* highlight (the row is already under the cursor, so already mounted), and when
|
|
3914
|
+
* the highlight was cleared (index `-1`).
|
|
3915
|
+
*/
|
|
3916
|
+
function scrollHighlightedRowIntoView(scrollRowIntoViewRef, index, reason) {
|
|
3917
|
+
if (reason === "pointer" || index < 0) return;
|
|
3918
|
+
scrollRowIntoViewRef.current?.(index);
|
|
3919
|
+
}
|
|
3920
|
+
/**
|
|
3921
|
+
* A data-driven combobox list with NO trigger and NO popup of its own: an
|
|
3922
|
+
* optional search input above a selectable list, ready to be dropped into a
|
|
3923
|
+
* surface the caller owns (a `Filter` popover, a panel, a dialog). Driven by an
|
|
3924
|
+
* `items` array plus `getItemValue`/`getItemLabel`, with opt-in server-side
|
|
3925
|
+
* search, grouping, infinite scroll, and loading/empty states.
|
|
3926
|
+
*
|
|
3927
|
+
* Use `DataCombobox` instead when you want the field-plus-popup combobox. This
|
|
3928
|
+
* is the same rows region plus an optional search input, without the field or the
|
|
3929
|
+
* popup around them, so the host controls open state, dismissal and positioning.
|
|
3930
|
+
* The name pairs with `ComboboxContent`, which is the popup this deliberately
|
|
3931
|
+
* does not have.
|
|
3932
|
+
*
|
|
3933
|
+
* Dismissal note: with no popup of its own, this holds no dismiss layer, so an
|
|
3934
|
+
* outside press or Escape always reaches the host. Escape ALSO resets the list —
|
|
3935
|
+
* clearing the query and the selection, the combobox convention for a list with
|
|
3936
|
+
* nothing open — but only while the search box is untouched; once the user has
|
|
3937
|
+
* clicked or typed in it, Base UI treats the list as open and Escape just
|
|
3938
|
+
* dismisses. The reset is forwarded to `onSearch('')` so a server-driven list
|
|
3939
|
+
* comes back unfiltered instead of stranding the previous query's page. Dismiss
|
|
3940
|
+
* via an outside press (or the host's own close affordance) when the selection
|
|
3941
|
+
* must survive.
|
|
3942
|
+
*
|
|
3943
|
+
* @example
|
|
3944
|
+
* ```tsx
|
|
3945
|
+
* <ComboboxBody
|
|
3946
|
+
* items={statuses}
|
|
3947
|
+
* getItemValue={status => status.id}
|
|
3948
|
+
* getItemLabel={status => status.label}
|
|
3949
|
+
* selectionMode="multiple"
|
|
3950
|
+
* selectedKeys={selectedKeys}
|
|
3951
|
+
* onSelectionChange={setSelectedKeys}
|
|
3952
|
+
* />
|
|
3953
|
+
* ```
|
|
3954
|
+
*/
|
|
3955
|
+
function ComboboxBody(componentProps) {
|
|
3956
|
+
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;
|
|
3957
|
+
const multiple = selectionMode === "multiple";
|
|
3958
|
+
const autoVirtualizeLatch = React.useRef(false);
|
|
3959
|
+
if (!autoVirtualizeLatch.current) autoVirtualizeLatch.current = !!onFetchMore || items.length >= COMBOBOX_AUTO_VIRTUALIZE_THRESHOLD;
|
|
3960
|
+
const virtualizeRows = (componentProps.virtualizeRows ?? autoVirtualizeLatch.current) && !getGroupKey;
|
|
3961
|
+
const scrollRowIntoViewRef = React.useRef(null);
|
|
3962
|
+
const { selectedObjects, commit, handleInputValueChange } = useComboboxItemSelection({
|
|
3963
|
+
items,
|
|
3964
|
+
getItemValue,
|
|
3965
|
+
selectedItems,
|
|
3966
|
+
selectedKeys,
|
|
3967
|
+
defaultSelectedKeys,
|
|
3968
|
+
onSelectionChange,
|
|
3969
|
+
onSearch,
|
|
3970
|
+
searchTriggerReasons: INLINE_SEARCH_TRIGGER_REASONS
|
|
3971
|
+
});
|
|
3972
|
+
const groups = useComboboxItemGroups(items, getGroupKey, getGroupLabel);
|
|
3973
|
+
const body = /* @__PURE__ */ jsxs("div", {
|
|
3974
|
+
"data-slot": "combobox-body",
|
|
3975
|
+
className: cn("flex w-full flex-col", className),
|
|
3976
|
+
children: [searchable ? /* @__PURE__ */ jsx(ComboboxInput, {
|
|
3977
|
+
showTrigger: false,
|
|
3978
|
+
placeholder,
|
|
3979
|
+
className: INPUT_IN_LIST_CLASSES
|
|
3980
|
+
}) : null, /* @__PURE__ */ jsx(ComboboxRows, {
|
|
3981
|
+
items,
|
|
3982
|
+
groups,
|
|
3983
|
+
getItemValue,
|
|
3984
|
+
getItemLabel,
|
|
3985
|
+
renderItem,
|
|
3986
|
+
disabledKeys,
|
|
3987
|
+
loadingState,
|
|
3988
|
+
skeletonCount,
|
|
3989
|
+
onFetchMore,
|
|
3990
|
+
hasMore,
|
|
3991
|
+
emptyState,
|
|
3992
|
+
listClassName: cn(LIST_MAX_HEIGHT, !searchable && FOCUSABLE_LIST_CLASSES),
|
|
3993
|
+
listTabIndex: searchable ? void 0 : 0,
|
|
3994
|
+
virtualizeRows,
|
|
3995
|
+
estimateRowHeight,
|
|
3996
|
+
scrollRowIntoViewRef,
|
|
3997
|
+
"aria-label": ariaLabel
|
|
3998
|
+
})]
|
|
3999
|
+
});
|
|
4000
|
+
if (multiple) return /* @__PURE__ */ jsx(Combobox, {
|
|
4001
|
+
multiple: true,
|
|
4002
|
+
inline: true,
|
|
4003
|
+
autoHighlight: true,
|
|
4004
|
+
virtualized: virtualizeRows,
|
|
4005
|
+
onItemHighlighted: (_item, details) => scrollHighlightedRowIntoView(scrollRowIntoViewRef, details.index, details.reason),
|
|
4006
|
+
items: groups ?? items,
|
|
4007
|
+
filter: onSearch || onFetchMore && hasMore ? null : void 0,
|
|
4008
|
+
value: selectedObjects,
|
|
4009
|
+
onValueChange: commit,
|
|
4010
|
+
itemToStringValue: getItemValue,
|
|
4011
|
+
itemToStringLabel: getItemLabel,
|
|
4012
|
+
isItemEqualToValue: (a, b) => getItemValue(a) === getItemValue(b),
|
|
4013
|
+
onInputValueChange: handleInputValueChange,
|
|
4014
|
+
children: body
|
|
4015
|
+
}, selectionMode);
|
|
4016
|
+
return /* @__PURE__ */ jsx(Combobox, {
|
|
4017
|
+
inline: true,
|
|
4018
|
+
autoHighlight: true,
|
|
4019
|
+
virtualized: virtualizeRows,
|
|
4020
|
+
onItemHighlighted: (_item, details) => scrollHighlightedRowIntoView(scrollRowIntoViewRef, details.index, details.reason),
|
|
4021
|
+
items: groups ?? items,
|
|
4022
|
+
filter: onSearch || onFetchMore && hasMore ? null : void 0,
|
|
4023
|
+
value: selectedObjects[0] ?? null,
|
|
4024
|
+
onValueChange: (next, details) => commit(next == null ? [] : [next], details),
|
|
4025
|
+
itemToStringValue: getItemValue,
|
|
4026
|
+
itemToStringLabel: getItemLabel,
|
|
4027
|
+
isItemEqualToValue: (a, b) => getItemValue(a) === getItemValue(b),
|
|
4028
|
+
onInputValueChange: handleInputValueChange,
|
|
4029
|
+
children: body
|
|
4030
|
+
}, selectionMode);
|
|
4031
|
+
}
|
|
4032
|
+
|
|
4033
|
+
//#endregion
|
|
4034
|
+
//#region src/components/dialog.tsx
|
|
4035
|
+
/**
|
|
4036
|
+
* Root of the dialog, wrapping Base UI's `Dialog.Root`. Manages open/close state and renders no DOM
|
|
4037
|
+
* element — place `DialogTrigger` and `DialogContent` inside it.
|
|
4038
|
+
*
|
|
4039
|
+
* @example
|
|
4040
|
+
* ```tsx
|
|
4041
|
+
* <Dialog>
|
|
4042
|
+
* <DialogTrigger render={<Button />}>Open</DialogTrigger>
|
|
4043
|
+
* <DialogContent>
|
|
4044
|
+
* <DialogHeader>
|
|
4045
|
+
* <DialogTitle>Title</DialogTitle>
|
|
4046
|
+
* <DialogDescription>Description</DialogDescription>
|
|
4047
|
+
* </DialogHeader>
|
|
4048
|
+
* </DialogContent>
|
|
4049
|
+
* </Dialog>
|
|
4050
|
+
* ```
|
|
4051
|
+
*/
|
|
4052
|
+
function Dialog(componentProps) {
|
|
4053
|
+
return /* @__PURE__ */ jsx(Dialog$1.Root, {
|
|
4054
|
+
"data-slot": "dialog",
|
|
4055
|
+
...componentProps
|
|
4056
|
+
});
|
|
4057
|
+
}
|
|
4058
|
+
/**
|
|
4059
|
+
* Button that opens the dialog, wrapping Base UI's `Dialog.Trigger`. Renders a `<button>` by
|
|
4060
|
+
* default (override with `render`).
|
|
4061
|
+
*/
|
|
4062
|
+
const DialogTrigger = React.forwardRef((componentProps, forwardRef) => {
|
|
4063
|
+
const { ...props } = componentProps;
|
|
4064
|
+
return /* @__PURE__ */ jsx(Dialog$1.Trigger, {
|
|
4065
|
+
ref: forwardRef,
|
|
4066
|
+
"data-slot": "dialog-trigger",
|
|
4067
|
+
...props
|
|
4068
|
+
});
|
|
4069
|
+
});
|
|
4070
|
+
DialogTrigger.displayName = "DialogTrigger";
|
|
4071
|
+
/**
|
|
4072
|
+
* Portals dialog content into the document body, wrapping Base UI's `Dialog.Portal`. Renders no DOM
|
|
4073
|
+
* element of its own.
|
|
4074
|
+
*/
|
|
4075
|
+
function DialogPortal(componentProps) {
|
|
4076
|
+
return /* @__PURE__ */ jsx(Dialog$1.Portal, {
|
|
4077
|
+
"data-slot": "dialog-portal",
|
|
4078
|
+
...componentProps
|
|
4079
|
+
});
|
|
4080
|
+
}
|
|
4081
|
+
/**
|
|
4082
|
+
* Button that closes the dialog, wrapping Base UI's `Dialog.Close`. Renders a `<button>` by default
|
|
4083
|
+
* (override with `render`).
|
|
4084
|
+
*/
|
|
4085
|
+
const DialogClose = React.forwardRef((componentProps, forwardRef) => {
|
|
4086
|
+
const { ...props } = componentProps;
|
|
4087
|
+
return /* @__PURE__ */ jsx(Dialog$1.Close, {
|
|
4088
|
+
ref: forwardRef,
|
|
4089
|
+
"data-slot": "dialog-close",
|
|
4090
|
+
...props
|
|
4091
|
+
});
|
|
4092
|
+
});
|
|
4093
|
+
DialogClose.displayName = "DialogClose";
|
|
4094
|
+
/**
|
|
4095
|
+
* Dimming backdrop rendered behind the dialog, wrapping Base UI's `Dialog.Backdrop`. Renders a
|
|
4096
|
+
* fixed, full-viewport `<div>`. Included automatically by `DialogContent`.
|
|
4097
|
+
*/
|
|
4098
|
+
const DialogOverlay = React.forwardRef((componentProps, forwardRef) => {
|
|
4099
|
+
const { className, ...props } = componentProps;
|
|
4100
|
+
return /* @__PURE__ */ jsx(Dialog$1.Backdrop, {
|
|
4101
|
+
ref: forwardRef,
|
|
4102
|
+
"data-slot": "dialog-overlay",
|
|
4103
|
+
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),
|
|
4104
|
+
...props
|
|
4105
|
+
});
|
|
4106
|
+
});
|
|
4107
|
+
DialogOverlay.displayName = "DialogOverlay";
|
|
4108
|
+
/**
|
|
4109
|
+
* Centered dialog panel, wrapping Base UI's `Dialog.Popup`. Renders a fixed `<div>` and
|
|
4110
|
+
* automatically includes its own `DialogPortal` and `DialogOverlay`.
|
|
4111
|
+
*/
|
|
4112
|
+
const DialogContent = React.forwardRef((componentProps, forwardRef) => {
|
|
4113
|
+
const { className, children, showCloseButton = true, ...props } = componentProps;
|
|
4114
|
+
return /* @__PURE__ */ jsxs(DialogPortal, { children: [/* @__PURE__ */ jsx(DialogOverlay, {}), /* @__PURE__ */ jsxs(Dialog$1.Popup, {
|
|
3701
4115
|
ref: forwardRef,
|
|
3702
4116
|
"data-slot": "dialog-content",
|
|
3703
4117
|
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 +4389,8 @@ const CountryFlag = React.forwardRef((componentProps, forwardRef) => {
|
|
|
3975
4389
|
});
|
|
3976
4390
|
CountryFlag.displayName = "CountryFlag";
|
|
3977
4391
|
|
|
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
4392
|
//#endregion
|
|
4068
4393
|
//#region src/components/data-combobox.tsx
|
|
4069
|
-
const DEFAULT_SKELETON_COUNT$1 = 5;
|
|
4070
|
-
const EMPTY_KEYS$1 = /* @__PURE__ */ new Set();
|
|
4071
4394
|
/**
|
|
4072
4395
|
* Searchable dropdown built on the DS Combobox primitives, driven by an `items`
|
|
4073
4396
|
* array plus `getItemValue`/`getItemLabel`. Renders an inline input (single) or
|
|
@@ -4086,87 +4409,31 @@ const EMPTY_KEYS$1 = /* @__PURE__ */ new Set();
|
|
|
4086
4409
|
* ```
|
|
4087
4410
|
*/
|
|
4088
4411
|
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");
|
|
4412
|
+
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
4413
|
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
|
-
}, [
|
|
4414
|
+
const { keys, selectedObjects, commit, handleInputValueChange } = useComboboxItemSelection({
|
|
4130
4415
|
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]
|
|
4416
|
+
getItemValue,
|
|
4417
|
+
selectedItems,
|
|
4418
|
+
selectedKeys,
|
|
4419
|
+
defaultSelectedKeys,
|
|
4420
|
+
onSelectionChange,
|
|
4421
|
+
onSearch
|
|
4422
|
+
});
|
|
4423
|
+
const groups = useComboboxItemGroups(items, getGroupKey, getGroupLabel);
|
|
4424
|
+
const popupRows = /* @__PURE__ */ jsx(ComboboxRows, {
|
|
4425
|
+
items,
|
|
4426
|
+
groups,
|
|
4427
|
+
getItemValue,
|
|
4428
|
+
getItemLabel,
|
|
4429
|
+
renderItem,
|
|
4430
|
+
disabledKeys,
|
|
4431
|
+
loadingState,
|
|
4432
|
+
skeletonCount,
|
|
4433
|
+
onFetchMore,
|
|
4434
|
+
hasMore,
|
|
4435
|
+
emptyState,
|
|
4436
|
+
"aria-label": ariaLabel
|
|
4170
4437
|
});
|
|
4171
4438
|
const chipsAnchor = useComboboxAnchor();
|
|
4172
4439
|
const overlayLayout = trigger ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Combobox$1.Trigger, { render: trigger }), /* @__PURE__ */ jsxs(ComboboxContent, {
|
|
@@ -4174,7 +4441,7 @@ function DataCombobox(componentProps) {
|
|
|
4174
4441
|
children: [searchable ? /* @__PURE__ */ jsx(ComboboxInput, {
|
|
4175
4442
|
showTrigger: false,
|
|
4176
4443
|
placeholder
|
|
4177
|
-
}) : null,
|
|
4444
|
+
}) : null, popupRows]
|
|
4178
4445
|
})] }) : null;
|
|
4179
4446
|
if (multiple) return /* @__PURE__ */ jsx(Combobox, {
|
|
4180
4447
|
multiple: true,
|
|
@@ -4196,7 +4463,7 @@ function DataCombobox(componentProps) {
|
|
|
4196
4463
|
}), /* @__PURE__ */ jsx(ComboboxContent, {
|
|
4197
4464
|
anchor: chipsAnchor,
|
|
4198
4465
|
className: cn("min-w-50", contentClassName),
|
|
4199
|
-
children:
|
|
4466
|
+
children: popupRows
|
|
4200
4467
|
})] })
|
|
4201
4468
|
}, selectionMode);
|
|
4202
4469
|
return /* @__PURE__ */ jsx(Combobox, {
|
|
@@ -4205,7 +4472,7 @@ function DataCombobox(componentProps) {
|
|
|
4205
4472
|
disabled,
|
|
4206
4473
|
filter: onSearch || onFetchMore && hasMore ? null : void 0,
|
|
4207
4474
|
value: selectedObjects[0] ?? null,
|
|
4208
|
-
onValueChange: (next) => commit(next == null ? [] : [next]),
|
|
4475
|
+
onValueChange: (next, details) => commit(next == null ? [] : [next], details),
|
|
4209
4476
|
itemToStringValue: getItemValue,
|
|
4210
4477
|
itemToStringLabel: getItemLabel,
|
|
4211
4478
|
isItemEqualToValue: (a, b) => getItemValue(a) === getItemValue(b),
|
|
@@ -4218,30 +4485,10 @@ function DataCombobox(componentProps) {
|
|
|
4218
4485
|
showClear: true
|
|
4219
4486
|
}), /* @__PURE__ */ jsx(ComboboxContent, {
|
|
4220
4487
|
className: cn("min-w-50", contentClassName),
|
|
4221
|
-
children:
|
|
4488
|
+
children: popupRows
|
|
4222
4489
|
})] })
|
|
4223
4490
|
}, selectionMode);
|
|
4224
4491
|
}
|
|
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
4492
|
|
|
4246
4493
|
//#endregion
|
|
4247
4494
|
//#region src/components/table.tsx
|
|
@@ -4949,6 +5196,59 @@ function DataTree(componentProps) {
|
|
|
4949
5196
|
});
|
|
4950
5197
|
}
|
|
4951
5198
|
|
|
5199
|
+
//#endregion
|
|
5200
|
+
//#region src/components/scroll-area.tsx
|
|
5201
|
+
/**
|
|
5202
|
+
* Custom-scrollbar container. Renders the Base UI `ScrollArea.Root` `<div>`
|
|
5203
|
+
* (with `min-h-0` so it can shrink in flex layouts) wrapping a scrollable
|
|
5204
|
+
* viewport, vertical/horizontal scrollbars, and a corner.
|
|
5205
|
+
*
|
|
5206
|
+
* @example
|
|
5207
|
+
* ```tsx
|
|
5208
|
+
* <ScrollArea className="h-72">
|
|
5209
|
+
* <div>Long content…</div>
|
|
5210
|
+
* </ScrollArea>
|
|
5211
|
+
* ```
|
|
5212
|
+
*/
|
|
5213
|
+
const ScrollArea = React.forwardRef((componentProps, forwardRef) => {
|
|
5214
|
+
const { className, children, scrollFade = false, scrollbarGutter = false, ...props } = componentProps;
|
|
5215
|
+
return /* @__PURE__ */ jsxs(ScrollAreaPrimitive.Root, {
|
|
5216
|
+
ref: forwardRef,
|
|
5217
|
+
className: cn("size-full min-h-0", className),
|
|
5218
|
+
...props,
|
|
5219
|
+
children: [
|
|
5220
|
+
/* @__PURE__ */ jsx(ScrollAreaPrimitive.Viewport, {
|
|
5221
|
+
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"),
|
|
5222
|
+
"data-slot": "scroll-area-viewport",
|
|
5223
|
+
children
|
|
5224
|
+
}),
|
|
5225
|
+
/* @__PURE__ */ jsx(ScrollBar, { orientation: "vertical" }),
|
|
5226
|
+
/* @__PURE__ */ jsx(ScrollBar, { orientation: "horizontal" }),
|
|
5227
|
+
/* @__PURE__ */ jsx(ScrollAreaPrimitive.Corner, { "data-slot": "scroll-area-corner" })
|
|
5228
|
+
]
|
|
5229
|
+
});
|
|
5230
|
+
});
|
|
5231
|
+
ScrollArea.displayName = "ScrollArea";
|
|
5232
|
+
/**
|
|
5233
|
+
* Draggable scrollbar for one axis, shown on hover/scroll. Renders the Base UI
|
|
5234
|
+
* `ScrollArea.Scrollbar` `<div>` containing a rounded `Thumb`.
|
|
5235
|
+
*/
|
|
5236
|
+
const ScrollBar = React.forwardRef((componentProps, forwardRef) => {
|
|
5237
|
+
const { className, orientation = "vertical", ...props } = componentProps;
|
|
5238
|
+
return /* @__PURE__ */ jsx(ScrollAreaPrimitive.Scrollbar, {
|
|
5239
|
+
ref: forwardRef,
|
|
5240
|
+
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),
|
|
5241
|
+
"data-slot": "scroll-area-scrollbar",
|
|
5242
|
+
orientation,
|
|
5243
|
+
...props,
|
|
5244
|
+
children: /* @__PURE__ */ jsx(ScrollAreaPrimitive.Thumb, {
|
|
5245
|
+
className: "relative flex-1 rounded-full bg-foreground/20",
|
|
5246
|
+
"data-slot": "scroll-area-thumb"
|
|
5247
|
+
})
|
|
5248
|
+
});
|
|
5249
|
+
});
|
|
5250
|
+
ScrollBar.displayName = "ScrollBar";
|
|
5251
|
+
|
|
4952
5252
|
//#endregion
|
|
4953
5253
|
//#region src/components/drawer.tsx
|
|
4954
5254
|
const DrawerContext = createContext({ position: "bottom" });
|
|
@@ -5762,7 +6062,7 @@ const EmptyTitle = React.forwardRef((componentProps, forwardRef) => {
|
|
|
5762
6062
|
return /* @__PURE__ */ jsx("div", {
|
|
5763
6063
|
ref: forwardRef,
|
|
5764
6064
|
"data-slot": "empty-title",
|
|
5765
|
-
className: cn("text-
|
|
6065
|
+
className: cn("text-lg text-foreground font-medium tracking-tight", className),
|
|
5766
6066
|
...props
|
|
5767
6067
|
});
|
|
5768
6068
|
});
|
|
@@ -8425,7 +8725,7 @@ const RadioGroupItem = React.forwardRef((componentProps, forwardRef) => {
|
|
|
8425
8725
|
return /* @__PURE__ */ jsx(Radio.Root, {
|
|
8426
8726
|
ref: forwardRef,
|
|
8427
8727
|
"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),
|
|
8728
|
+
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
8729
|
...props,
|
|
8430
8730
|
children: /* @__PURE__ */ jsx(Radio.Indicator, {
|
|
8431
8731
|
"data-slot": "radio-group-indicator",
|
|
@@ -10052,4 +10352,4 @@ function useAudioGauge(options = {}) {
|
|
|
10052
10352
|
}
|
|
10053
10353
|
|
|
10054
10354
|
//#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,
|
|
10355
|
+
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, COMBOBOX_AUTO_VIRTUALIZE_THRESHOLD, 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 };
|