@giddaa-housing/ui 3.4.0 → 3.5.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/css/generated/shared.css +1 -1
- package/dist/accordion.js +1 -1
- package/dist/activity-timeline.js +1 -1
- package/dist/alert.js +1 -1
- package/dist/auth-layout.js +1 -1
- package/dist/avatar.js +1 -1
- package/dist/badge.js +1 -1
- package/dist/bar-chart.js +1 -1
- package/dist/breadcrumb.js +1 -1
- package/dist/bullet-chart.js +1 -1
- package/dist/button-group.js +1 -1
- package/dist/button.js +1 -1
- package/dist/calendar.js +2 -2
- package/dist/call-card.js +1 -1
- package/dist/card.js +1 -1
- package/dist/carousel.js +2 -2
- package/dist/chart.js +1 -1
- package/dist/chat.js +1 -1
- package/dist/checkbox.js +1 -1
- package/dist/collapsible.js +1 -1
- package/dist/combobox-B7cKFJ9V.js +398 -0
- package/dist/combobox.d.ts +2 -2
- package/dist/combobox.js +1 -308
- package/dist/cta.js +1 -1
- package/dist/currency-selector.js +2 -2
- package/dist/data-table.d.ts +1 -1
- package/dist/data-table.js +1 -1
- package/dist/date-picker.d.ts +4 -3
- package/dist/date-picker.js +7 -17
- package/dist/details-card.js +1 -1
- package/dist/dialog.js +1 -1
- package/dist/dropdown-menu.js +1 -1
- package/dist/dropzone.js +1 -1
- package/dist/editorial-card.js +2 -4
- package/dist/empty-state.js +1 -1
- package/dist/field.js +1 -1
- package/dist/file-upload.js +1 -1
- package/dist/filter.js +1 -1
- package/dist/footer.js +1 -1
- package/dist/funnel-chart.js +1 -1
- package/dist/gallery-indicator.js +1 -1
- package/dist/icons-C9JXR5Xv.d.ts +111 -0
- package/dist/icons.d.ts +2 -93
- package/dist/icons.js +37 -1
- package/dist/image.d.ts +59 -0
- package/dist/image.js +53 -0
- package/dist/infinite-scroll.js +3 -29
- package/dist/infotip.js +1 -1
- package/dist/input-group.js +1 -1
- package/dist/input-otp.js +1 -1
- package/dist/input.js +1 -1
- package/dist/item.js +1 -1
- package/dist/kpi-card.js +1 -1
- package/dist/label.js +1 -1
- package/dist/line-chart.js +1 -1
- package/dist/list-item.js +1 -1
- package/dist/map-indicator.js +1 -1
- package/dist/match.js +1 -1
- package/dist/media-gallery-hero.js +6 -3
- package/dist/media-player.js +5 -13
- package/dist/message.js +2 -12
- package/dist/mobile-sidebar.js +1 -1
- package/dist/multi-step-form.js +2 -2
- package/dist/number-input.js +1 -1
- package/dist/page-header.js +1 -1
- package/dist/pagination.js +1 -1
- package/dist/password-input.js +1 -1
- package/dist/phone-input.js +11 -17
- package/dist/photo-gallery.js +6 -3
- package/dist/picker-CsnHtbe4.d.ts +14 -0
- package/dist/{picker-xSTzeYhc.js → picker-DmIiQKLJ.js} +2 -7
- package/dist/pie-chart.js +1 -1
- package/dist/popover-DSlPeH7x.d.ts +20 -0
- package/dist/popover.d.ts +1 -19
- package/dist/popover.js +1 -1
- package/dist/price-tag.d.ts +1 -1
- package/dist/price-tag.js +50 -22
- package/dist/progress.js +1 -1
- package/dist/property-listing-card.d.ts +63 -1
- package/dist/property-listing-card.js +97 -28
- package/dist/purchase-option-card.js +1 -1
- package/dist/radar-chart.js +1 -1
- package/dist/radio-group.js +1 -1
- package/dist/review-block.js +1 -1
- package/dist/rich-text-editor.js +1 -1
- package/dist/scatter-chart.js +1 -1
- package/dist/scroll-spy.js +3 -3
- package/dist/search-input.js +1 -1
- package/dist/select.js +1 -1
- package/dist/separator.js +1 -1
- package/dist/sheet.js +1 -1
- package/dist/sidebar.js +3 -16
- package/dist/skeleton.js +1 -1
- package/dist/slider.js +1 -1
- package/dist/sonar.js +1 -1
- package/dist/sparkline.js +1 -1
- package/dist/stepper.js +1 -1
- package/dist/styles.css +42 -2
- package/dist/switch.js +1 -1
- package/dist/table-card.js +1 -1
- package/dist/table.js +1 -1
- package/dist/tabs.js +1 -1
- package/dist/tag.js +1 -1
- package/dist/testimonial-block.js +1 -1
- package/dist/textarea.js +1 -1
- package/dist/theme-switcher.js +1 -1
- package/dist/time-picker.d.ts +3 -2
- package/dist/time-picker.js +5 -7
- package/dist/toast.js +1 -1
- package/dist/tooltip.js +1 -1
- package/dist/top-navbar.js +1 -1
- package/dist/tree-map.js +1 -1
- package/dist/utils/cn.d.ts +5 -0
- package/dist/utils/cn.js +33 -0
- package/dist/utils/format.d.ts +45 -0
- package/dist/utils/format.js +70 -0
- package/dist/utils/phone.d.ts +98 -0
- package/dist/utils/phone.js +93 -0
- package/dist/utils/use-intersection.d.ts +9 -0
- package/dist/utils/use-intersection.js +29 -0
- package/dist/utils/use-is-mobile.d.ts +5 -0
- package/dist/utils/use-is-mobile.js +16 -0
- package/dist/utils/use-reduced-motion.d.ts +5 -0
- package/dist/{use-reduced-motion-BDvOK14x.js → utils/use-reduced-motion.js} +2 -2
- package/dist/utils/use-uncontrolled.d.ts +11 -0
- package/dist/{use-uncontrolled-CLfM1XbB.js → utils/use-uncontrolled.js} +2 -2
- package/dist/video-player-dialog.d.ts +12 -2
- package/dist/video-player-dialog.js +47 -7
- package/dist/waterfall-chart.js +1 -1
- package/package.json +9 -1
- package/dist/cn-BI_4DMBf.js +0 -23
package/dist/accordion.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { ChevronRight } from "./icons.js";
|
|
3
|
-
import {
|
|
3
|
+
import { cn } from "./utils/cn.js";
|
|
4
4
|
import { Accordion as Accordion$1 } from "@base-ui/react/accordion";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
//#region src/accordion.tsx
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { ChevronRight } from "./icons.js";
|
|
3
|
-
import {
|
|
3
|
+
import { cn } from "./utils/cn.js";
|
|
4
4
|
import { Avatar, AvatarFallback, AvatarImage } from "./avatar.js";
|
|
5
5
|
import { Badge } from "./badge.js";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
package/dist/alert.js
CHANGED
package/dist/auth-layout.js
CHANGED
package/dist/avatar.js
CHANGED
package/dist/badge.js
CHANGED
package/dist/bar-chart.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { cn } from "./utils/cn.js";
|
|
3
3
|
import { SizeProvider, useComponentSize } from "./size-context.js";
|
|
4
4
|
import { ChartContainer, cartesianAxisProps } from "./chart.js";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
package/dist/breadcrumb.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { ChevronRight, MoreHorizontal } from "./icons.js";
|
|
3
|
-
import {
|
|
3
|
+
import { cn } from "./utils/cn.js";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { mergeProps } from "@base-ui/react/merge-props";
|
|
6
6
|
import { useRender } from "@base-ui/react/use-render";
|
package/dist/bullet-chart.js
CHANGED
package/dist/button-group.js
CHANGED
package/dist/button.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Loader } from "./icons.js";
|
|
3
|
-
import {
|
|
3
|
+
import { cn } from "./utils/cn.js";
|
|
4
4
|
import { useComponentSize } from "./size-context.js";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { mergeProps } from "@base-ui/react/merge-props";
|
package/dist/calendar.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { ChevronLeft, ChevronRight } from "./icons.js";
|
|
3
|
-
import {
|
|
3
|
+
import { cn } from "./utils/cn.js";
|
|
4
4
|
import { Button } from "./button.js";
|
|
5
|
-
import {
|
|
5
|
+
import { f as ComboboxList, h as ComboboxValue, l as ComboboxInput, m as ComboboxTrigger, o as ComboboxContent, s as ComboboxEmpty, t as Combobox, u as ComboboxItem } from "./combobox-B7cKFJ9V.js";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import * as React from "react";
|
|
8
8
|
import { DayPicker, getDefaultClassNames } from "react-day-picker";
|
package/dist/call-card.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Maximize2, Mic, MicOff, Minimize2, Phone, User } from "./icons.js";
|
|
3
|
-
import {
|
|
3
|
+
import { cn } from "./utils/cn.js";
|
|
4
4
|
import { Avatar, AvatarFallback, AvatarImage } from "./avatar.js";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { cva } from "class-variance-authority";
|
package/dist/card.js
CHANGED
package/dist/carousel.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { ChevronLeft, ChevronRight } from "./icons.js";
|
|
3
|
-
import {
|
|
3
|
+
import { cn } from "./utils/cn.js";
|
|
4
4
|
import { useComponentSize } from "./size-context.js";
|
|
5
|
-
import {
|
|
5
|
+
import { useReducedMotion } from "./utils/use-reduced-motion.js";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { cva } from "class-variance-authority";
|
|
8
8
|
import * as React from "react";
|
package/dist/chart.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { ArrowDown, ArrowUp } from "./icons.js";
|
|
3
|
-
import {
|
|
3
|
+
import { cn } from "./utils/cn.js";
|
|
4
4
|
import { SizeProvider, useComponentSize } from "./size-context.js";
|
|
5
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { cva } from "class-variance-authority";
|
package/dist/chat.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { FileText, Image, Plus, Send, Video } from "./icons.js";
|
|
3
|
-
import {
|
|
3
|
+
import { cn } from "./utils/cn.js";
|
|
4
4
|
import { Button } from "./button.js";
|
|
5
5
|
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from "./input-group.js";
|
|
6
6
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "./dropdown-menu.js";
|
package/dist/checkbox.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Check } from "./icons.js";
|
|
3
|
-
import {
|
|
3
|
+
import { cn } from "./utils/cn.js";
|
|
4
4
|
import { useComponentSize } from "./size-context.js";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import { cva } from "class-variance-authority";
|
package/dist/collapsible.js
CHANGED
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import { Check, ChevronDown, X } from "./icons.js";
|
|
2
|
+
import { cn } from "./utils/cn.js";
|
|
3
|
+
import { SizeProvider, useComponentSize } from "./size-context.js";
|
|
4
|
+
import { Button } from "./button.js";
|
|
5
|
+
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from "./input-group.js";
|
|
6
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { cva } from "class-variance-authority";
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
import { useCallback, useRef, useState } from "react";
|
|
10
|
+
import { Combobox } from "@base-ui/react";
|
|
11
|
+
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
12
|
+
//#region src/lib/use-grown.ts
|
|
13
|
+
/**
|
|
14
|
+
* Tracks whether an element has grown taller than its own `min-height` — a
|
|
15
|
+
* chips field that has wrapped onto a second row, in practice.
|
|
16
|
+
*
|
|
17
|
+
* CSS can ask about a container's width but never its own height, and a radius
|
|
18
|
+
* that reads as a pill on one row reads as a mistake on two, so the height has
|
|
19
|
+
* to be measured. `min-height` is the baseline because it is the height the
|
|
20
|
+
* control lays out at when empty. An element without one has no baseline to
|
|
21
|
+
* have grown past and always reports `false`, which is why the size variants
|
|
22
|
+
* that set a fixed `h-*` set a matching `min-h-*` beside it: a call site that
|
|
23
|
+
* swaps in `h-auto` then keeps both its floor and this measurement.
|
|
24
|
+
*/
|
|
25
|
+
function useGrown() {
|
|
26
|
+
const [grown, setGrown] = useState(false);
|
|
27
|
+
const elementRef = useRef(null);
|
|
28
|
+
const observerRef = useRef(null);
|
|
29
|
+
const measure = useCallback(() => {
|
|
30
|
+
const element = elementRef.current;
|
|
31
|
+
if (!element) return;
|
|
32
|
+
const base = Number.parseFloat(getComputedStyle(element).minHeight);
|
|
33
|
+
setGrown(base > 0 && element.offsetHeight > base + 1);
|
|
34
|
+
}, []);
|
|
35
|
+
return {
|
|
36
|
+
ref: useCallback((element) => {
|
|
37
|
+
observerRef.current?.disconnect();
|
|
38
|
+
observerRef.current = null;
|
|
39
|
+
elementRef.current = element;
|
|
40
|
+
if (element === null) {
|
|
41
|
+
setGrown(false);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
measure();
|
|
45
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
46
|
+
const observer = new ResizeObserver(measure);
|
|
47
|
+
observer.observe(element);
|
|
48
|
+
observerRef.current = observer;
|
|
49
|
+
}, [measure]),
|
|
50
|
+
grown
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/combobox.tsx
|
|
55
|
+
const ComboboxSelectionContext = React.createContext({ multiple: false });
|
|
56
|
+
/**
|
|
57
|
+
* True for anything rendered inside `ComboboxContent`. A `ComboboxInput` is
|
|
58
|
+
* either the field that opens the popup or the search box inside it, and the
|
|
59
|
+
* two want opposite treatment — the styling and the anchoring both turn on
|
|
60
|
+
* this, and reading it from the tree beats guessing from CSS state that is
|
|
61
|
+
* true in both places (the popup is, after all, open in both).
|
|
62
|
+
*/
|
|
63
|
+
const ComboboxPopupContext = React.createContext(false);
|
|
64
|
+
function Combobox$1({ multiple, children, size, ...props }) {
|
|
65
|
+
return /* @__PURE__ */ jsx(SizeProvider, {
|
|
66
|
+
size,
|
|
67
|
+
children: /* @__PURE__ */ jsx(ComboboxSelectionContext.Provider, {
|
|
68
|
+
value: { multiple: multiple === true },
|
|
69
|
+
children: /* @__PURE__ */ jsx(Combobox.Root, {
|
|
70
|
+
multiple,
|
|
71
|
+
...props,
|
|
72
|
+
children
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
const comboboxTriggerVariants = cva("group/combobox-trigger flex w-fit min-w-0 items-center justify-between rounded-full data-[grown=true]:rounded-2xl border border-line bg-canvas text-left font-normal whitespace-nowrap text-fg-primary shadow-none outline-none transition-[background-color,border-color,border-radius,box-shadow,color] select-none hover:border-line-strong focus-visible:border-line-focus focus-visible:inset-ring-1 focus-visible:inset-ring-line-focus data-focused:border-line-focus data-focused:inset-ring-1 data-focused:inset-ring-line-focus data-popup-open:rounded-2xl data-popup-open:border-line-focus data-popup-open:inset-ring-1 data-popup-open:inset-ring-line-focus disabled:pointer-events-none disabled:cursor-not-allowed disabled:border-line-subtle disabled:bg-surface disabled:text-fg-caption-placeholder data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:border-line-subtle data-disabled:bg-surface data-disabled:text-fg-caption-placeholder data-placeholder:text-fg-caption-placeholder aria-invalid:border-line-danger aria-invalid:text-fg-danger aria-invalid:shadow-none data-[invalid=true]:border-line-danger data-[invalid=true]:text-fg-danger *:data-[slot=combobox-value]:line-clamp-1 *:data-[slot=combobox-value]:flex *:data-[slot=combobox-value]:min-w-0 *:data-[slot=combobox-value]:items-center *:data-[slot=combobox-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0", {
|
|
78
|
+
variants: { size: {
|
|
79
|
+
sm: "h-8 min-h-8 gap-2 px-3 text-gdt-xs [&_svg:not([class*='size-'])]:size-3.5",
|
|
80
|
+
md: "h-10 min-h-10 gap-2 px-3.5 text-gdt-sm [&_svg:not([class*='size-'])]:size-4",
|
|
81
|
+
lg: "h-12 min-h-12 gap-2.5 px-4 pr-5 text-gdt-md [&_svg:not([class*='size-'])]:size-4.5"
|
|
82
|
+
} },
|
|
83
|
+
defaultVariants: { size: "md" }
|
|
84
|
+
});
|
|
85
|
+
const comboboxInputVariants = cva("w-auto data-[grown=true]:rounded-2xl has-data-popup-open:rounded-2xl has-data-popup-open:border-line-focus has-data-popup-open:inset-ring-1 has-data-popup-open:inset-ring-line-focus", {
|
|
86
|
+
variants: { size: {
|
|
87
|
+
sm: "min-h-8",
|
|
88
|
+
md: "min-h-10",
|
|
89
|
+
lg: "min-h-12"
|
|
90
|
+
} },
|
|
91
|
+
defaultVariants: { size: "md" }
|
|
92
|
+
});
|
|
93
|
+
/**
|
|
94
|
+
* The same field, standing in the popup as its search box. It is inside the
|
|
95
|
+
* open popup rather than being the thing that opened it, so none of the
|
|
96
|
+
* trigger's open-state treatment applies: no pill, no focus ring competing
|
|
97
|
+
* with the popup's own border, and a radius that belongs to the list it sits
|
|
98
|
+
* above rather than to a field on the page.
|
|
99
|
+
*/
|
|
100
|
+
const comboboxPopupInputVariants = cva("w-auto", {
|
|
101
|
+
variants: { size: {
|
|
102
|
+
sm: "rounded-md",
|
|
103
|
+
md: "rounded-lg",
|
|
104
|
+
lg: "rounded-lg"
|
|
105
|
+
} },
|
|
106
|
+
defaultVariants: { size: "md" }
|
|
107
|
+
});
|
|
108
|
+
const comboboxContentVariants = cva("relative isolate z-50 max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width))] origin-(--transform-origin) overflow-hidden border border-line-subtle bg-canvas text-fg-primary shadow-(--elevation-e1-shadow) transition-[opacity,scale,translate] duration-[var(--duration-motion-popup)] ease-gdt-out data-[chips=true]:min-w-(--anchor-width) data-starting-style:opacity-0 data-starting-style:scale-95 data-ending-style:opacity-0 data-ending-style:scale-95 data-[side=bottom]:data-starting-style:translate-y-2 data-[side=bottom]:data-ending-style:translate-y-2 data-[side=top]:data-starting-style:-translate-y-2 data-[side=top]:data-ending-style:-translate-y-2 data-[side=left]:data-starting-style:translate-x-2 data-[side=left]:data-ending-style:translate-x-2 data-[side=right]:data-starting-style:-translate-x-2 data-[side=right]:data-ending-style:-translate-x-2 data-[side=inline-end]:data-starting-style:-translate-x-2 data-[side=inline-end]:data-ending-style:-translate-x-2 data-[side=inline-start]:data-starting-style:translate-x-2 data-[side=inline-start]:data-ending-style:translate-x-2 motion-reduce:data-starting-style:scale-100 motion-reduce:data-ending-style:scale-100 motion-reduce:data-[side=bottom]:data-starting-style:translate-y-0 motion-reduce:data-[side=bottom]:data-ending-style:translate-y-0 motion-reduce:data-[side=top]:data-starting-style:translate-y-0 motion-reduce:data-[side=top]:data-ending-style:translate-y-0 motion-reduce:data-[side=left]:data-starting-style:translate-x-0 motion-reduce:data-[side=left]:data-ending-style:translate-x-0 motion-reduce:data-[side=right]:data-starting-style:translate-x-0 motion-reduce:data-[side=right]:data-ending-style:translate-x-0 motion-reduce:data-[side=inline-end]:data-starting-style:translate-x-0 motion-reduce:data-[side=inline-end]:data-ending-style:translate-x-0 motion-reduce:data-[side=inline-start]:data-starting-style:translate-x-0 motion-reduce:data-[side=inline-start]:data-ending-style:translate-x-0 *:data-[slot=input-group]:mb-1", {
|
|
109
|
+
variants: { size: {
|
|
110
|
+
sm: "rounded-lg p-1",
|
|
111
|
+
md: "rounded-xl p-1.5",
|
|
112
|
+
lg: "rounded-[18px] p-2"
|
|
113
|
+
} },
|
|
114
|
+
defaultVariants: { size: "md" }
|
|
115
|
+
});
|
|
116
|
+
const comboboxItemVariants = cva("group/combobox-item relative flex w-full cursor-pointer items-center font-normal text-fg-primary outline-none select-none data-highlighted:bg-surface data-disabled:pointer-events-none data-disabled:text-fg-caption-placeholder [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
|
|
117
|
+
variants: { size: {
|
|
118
|
+
sm: "gap-1.5 rounded-md px-3 py-1.5 text-gdt-xs",
|
|
119
|
+
md: "gap-2 rounded-md px-4 py-2 text-gdt-sm",
|
|
120
|
+
lg: "gap-2.5 rounded-md px-4 py-2.5 text-gdt-md"
|
|
121
|
+
} },
|
|
122
|
+
defaultVariants: { size: "md" }
|
|
123
|
+
});
|
|
124
|
+
const comboboxChipsVariants = cva("flex flex-wrap items-center gap-1 rounded-full data-[grown=true]:rounded-2xl border border-line bg-canvas bg-clip-padding text-fg-primary transition-[background-color,border-color,box-shadow,color] focus-within:border-line-focus focus-within:inset-ring-1 focus-within:inset-ring-line-focus has-aria-invalid:border-line-danger has-aria-invalid:text-fg-danger has-aria-invalid:shadow-none has-data-popup-open:rounded-2xl has-data-popup-open:border-line-focus has-data-popup-open:inset-ring-1 has-data-popup-open:inset-ring-line-focus", {
|
|
125
|
+
variants: { size: {
|
|
126
|
+
sm: "min-h-8 px-2.5 py-1 text-gdt-xs has-data-[slot=combobox-chip]:px-1.5",
|
|
127
|
+
md: "min-h-10 px-3 py-1.5 text-gdt-sm has-data-[slot=combobox-chip]:px-2",
|
|
128
|
+
lg: "min-h-12 px-4 py-2 text-gdt-md has-data-[slot=combobox-chip]:px-2.5"
|
|
129
|
+
} },
|
|
130
|
+
defaultVariants: { size: "md" }
|
|
131
|
+
});
|
|
132
|
+
const comboboxChipVariants = cva("flex w-fit items-center justify-center gap-1 rounded-sm bg-surface font-medium whitespace-nowrap text-fg-primary has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pr-0", {
|
|
133
|
+
variants: { size: {
|
|
134
|
+
sm: "h-5 px-1.5 text-gdt-xs",
|
|
135
|
+
md: "h-[calc(--spacing(5.25))] px-1.5 text-gdt-xs",
|
|
136
|
+
lg: "h-6 px-2 text-gdt-sm"
|
|
137
|
+
} },
|
|
138
|
+
defaultVariants: { size: "md" }
|
|
139
|
+
});
|
|
140
|
+
function ComboboxValue({ ...props }) {
|
|
141
|
+
return /* @__PURE__ */ jsx(Combobox.Value, {
|
|
142
|
+
"data-slot": "combobox-value",
|
|
143
|
+
...props
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
function ComboboxTrigger({ className, children, ...props }) {
|
|
147
|
+
const resolvedSize = useComponentSize();
|
|
148
|
+
const { ref, grown } = useGrown();
|
|
149
|
+
return /* @__PURE__ */ jsxs(Combobox.Trigger, {
|
|
150
|
+
ref,
|
|
151
|
+
"data-slot": "combobox-trigger",
|
|
152
|
+
"data-size": resolvedSize,
|
|
153
|
+
"data-grown": grown ? "true" : void 0,
|
|
154
|
+
className: cn(comboboxTriggerVariants({ size: resolvedSize }), className),
|
|
155
|
+
...props,
|
|
156
|
+
children: [children, /* @__PURE__ */ jsx(Combobox.Icon, { render: /* @__PURE__ */ jsx(ChevronDown, { className: "text-line-strong transition-transform group-data-disabled/combobox-trigger:text-fg-caption-placeholder group-data-popup-open/combobox-trigger:rotate-180" }) })]
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
function ComboboxClear({ className, ...props }) {
|
|
160
|
+
return /* @__PURE__ */ jsx(Combobox.Clear, {
|
|
161
|
+
"data-slot": "combobox-clear",
|
|
162
|
+
className: cn(className),
|
|
163
|
+
...props,
|
|
164
|
+
render: /* @__PURE__ */ jsx(InputGroupButton, {
|
|
165
|
+
variant: "ghost",
|
|
166
|
+
size: "icon-xs",
|
|
167
|
+
children: /* @__PURE__ */ jsx(X, { className: "pointer-events-none" })
|
|
168
|
+
})
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
function ComboboxInput({ className, children, disabled = false, showTrigger = true, showClear = false, ...props }) {
|
|
172
|
+
const resolvedSize = useComponentSize();
|
|
173
|
+
const insidePopup = React.useContext(ComboboxPopupContext);
|
|
174
|
+
const { ref, grown } = useGrown();
|
|
175
|
+
const contents = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
176
|
+
/* @__PURE__ */ jsx(Combobox.Input, {
|
|
177
|
+
render: /* @__PURE__ */ jsx(InputGroupInput, { disabled }),
|
|
178
|
+
...props
|
|
179
|
+
}),
|
|
180
|
+
/* @__PURE__ */ jsxs(InputGroupAddon, {
|
|
181
|
+
align: "inline-end",
|
|
182
|
+
children: [showTrigger && /* @__PURE__ */ jsx(InputGroupButton, {
|
|
183
|
+
size: "icon-xs",
|
|
184
|
+
variant: "ghost",
|
|
185
|
+
render: /* @__PURE__ */ jsx(ComboboxTrigger, {}),
|
|
186
|
+
"data-slot": "input-group-button",
|
|
187
|
+
className: "border-0 bg-transparent p-0 shadow-none inset-ring-0 group-has-data-[slot=combobox-clear]/input-group:hidden hover:border-transparent focus-visible:border-transparent focus-visible:inset-ring-0 data-popup-open:border-transparent data-popup-open:bg-transparent data-popup-open:inset-ring-0 data-pressed:bg-transparent",
|
|
188
|
+
disabled
|
|
189
|
+
}), showClear && /* @__PURE__ */ jsx(ComboboxClear, { disabled })]
|
|
190
|
+
}),
|
|
191
|
+
children
|
|
192
|
+
] });
|
|
193
|
+
if (insidePopup) return /* @__PURE__ */ jsx(InputGroup, {
|
|
194
|
+
className: cn(comboboxPopupInputVariants({ size: resolvedSize }), className),
|
|
195
|
+
children: contents
|
|
196
|
+
});
|
|
197
|
+
return /* @__PURE__ */ jsx(Combobox.InputGroup, {
|
|
198
|
+
ref,
|
|
199
|
+
"data-grown": grown ? "true" : void 0,
|
|
200
|
+
render: /* @__PURE__ */ jsx(InputGroup, { className: cn(comboboxInputVariants({ size: resolvedSize }), className) }),
|
|
201
|
+
children: contents
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
function ComboboxContent({ className, side = "bottom", sideOffset = 6, align = "start", alignOffset = 0, anchor, children, ...props }) {
|
|
205
|
+
const resolvedSize = useComponentSize();
|
|
206
|
+
return /* @__PURE__ */ jsx(Combobox.Portal, { children: /* @__PURE__ */ jsx(Combobox.Positioner, {
|
|
207
|
+
side,
|
|
208
|
+
sideOffset,
|
|
209
|
+
align,
|
|
210
|
+
alignOffset,
|
|
211
|
+
anchor,
|
|
212
|
+
className: "isolate z-50",
|
|
213
|
+
children: /* @__PURE__ */ jsx(Combobox.Popup, {
|
|
214
|
+
"data-slot": "combobox-content",
|
|
215
|
+
"data-chips": !!anchor,
|
|
216
|
+
className: cn("group/combobox-content", comboboxContentVariants({ size: resolvedSize }), "has-data-[slot=combobox-virtualized]:max-h-none", className),
|
|
217
|
+
...props,
|
|
218
|
+
children: /* @__PURE__ */ jsx(ComboboxPopupContext.Provider, {
|
|
219
|
+
value: true,
|
|
220
|
+
children
|
|
221
|
+
})
|
|
222
|
+
})
|
|
223
|
+
}) });
|
|
224
|
+
}
|
|
225
|
+
function ComboboxList({ className, ...props }) {
|
|
226
|
+
return /* @__PURE__ */ jsx(Combobox.List, {
|
|
227
|
+
"data-slot": "combobox-list",
|
|
228
|
+
className: cn("no-scrollbar max-h-(--available-height) space-y-0.5 scroll-py-1 overflow-y-auto overscroll-contain data-empty:p-0 has-data-[slot=combobox-virtualized]:max-h-none has-data-[slot=combobox-virtualized]:space-y-0 has-data-[slot=combobox-virtualized]:overflow-hidden", className),
|
|
229
|
+
...props
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
function ComboboxItem({ className, children, ...props }) {
|
|
233
|
+
const { multiple } = React.useContext(ComboboxSelectionContext);
|
|
234
|
+
const resolvedSize = useComponentSize();
|
|
235
|
+
return /* @__PURE__ */ jsxs(Combobox.Item, {
|
|
236
|
+
"data-slot": "combobox-item",
|
|
237
|
+
className: cn(comboboxItemVariants({ size: resolvedSize }), !multiple && "data-selected:bg-surface-brand-subtle data-selected:font-medium data-selected:text-fg-brand", className),
|
|
238
|
+
...props,
|
|
239
|
+
children: [multiple ? /* @__PURE__ */ jsx(Combobox.ItemIndicator, {
|
|
240
|
+
keepMounted: true,
|
|
241
|
+
className: "flex size-5 shrink-0 items-center justify-center rounded-sm border border-line bg-canvas text-transparent transition-[background-color,border-color,color] group-data-selected/combobox-item:border-action-primary group-data-selected/combobox-item:bg-action-primary group-data-selected/combobox-item:text-fg-on-brand group-data-disabled/combobox-item:border-line-subtle group-data-disabled/combobox-item:bg-surface group-data-disabled/combobox-item:text-fg-caption-placeholder [&>svg]:size-3",
|
|
242
|
+
children: /* @__PURE__ */ jsx(Check, {})
|
|
243
|
+
}) : null, /* @__PURE__ */ jsx("span", {
|
|
244
|
+
className: "flex min-w-0 flex-1 shrink-0 items-center gap-2",
|
|
245
|
+
children
|
|
246
|
+
})]
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
function ComboboxGroup({ className, ...props }) {
|
|
250
|
+
return /* @__PURE__ */ jsx(Combobox.Group, {
|
|
251
|
+
"data-slot": "combobox-group",
|
|
252
|
+
className: cn("scroll-my-1 space-y-0.5", className),
|
|
253
|
+
...props
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
function ComboboxLabel({ className, ...props }) {
|
|
257
|
+
return /* @__PURE__ */ jsx(Combobox.GroupLabel, {
|
|
258
|
+
"data-slot": "combobox-label",
|
|
259
|
+
className: cn("px-3 py-1 text-gdt-xs text-fg-secondary", className),
|
|
260
|
+
...props
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
function ComboboxCollection({ ...props }) {
|
|
264
|
+
return /* @__PURE__ */ jsx(Combobox.Collection, {
|
|
265
|
+
"data-slot": "combobox-collection",
|
|
266
|
+
...props
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
function ComboboxEmpty({ className, ...props }) {
|
|
270
|
+
return /* @__PURE__ */ jsx(Combobox.Empty, {
|
|
271
|
+
"data-slot": "combobox-empty",
|
|
272
|
+
className: cn("hidden w-full justify-center py-2 text-center text-gdt-sm text-fg-secondary group-data-empty/combobox-content:flex", className),
|
|
273
|
+
...props
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
function ComboboxSeparator({ className, ...props }) {
|
|
277
|
+
return /* @__PURE__ */ jsx(Combobox.Separator, {
|
|
278
|
+
"data-slot": "combobox-separator",
|
|
279
|
+
className: cn("pointer-events-none my-1 h-px bg-line-subtle", className),
|
|
280
|
+
...props
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
function ComboboxChips({ className, ref: refProp, ...props }) {
|
|
284
|
+
const resolvedSize = useComponentSize();
|
|
285
|
+
const { ref, grown } = useGrown();
|
|
286
|
+
return /* @__PURE__ */ jsx(Combobox.Chips, {
|
|
287
|
+
ref: (element) => {
|
|
288
|
+
ref(element);
|
|
289
|
+
if (typeof refProp === "function") refProp(element);
|
|
290
|
+
else if (refProp) refProp.current = element;
|
|
291
|
+
},
|
|
292
|
+
"data-slot": "combobox-chips",
|
|
293
|
+
"data-grown": grown ? "true" : void 0,
|
|
294
|
+
className: cn(comboboxChipsVariants({ size: resolvedSize }), className),
|
|
295
|
+
...props
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
function ComboboxChip({ className, children, showRemove = true, ...props }) {
|
|
299
|
+
const resolvedSize = useComponentSize();
|
|
300
|
+
return /* @__PURE__ */ jsxs(Combobox.Chip, {
|
|
301
|
+
"data-slot": "combobox-chip",
|
|
302
|
+
className: cn(comboboxChipVariants({ size: resolvedSize }), className),
|
|
303
|
+
...props,
|
|
304
|
+
children: [children, showRemove && /* @__PURE__ */ jsx(Combobox.ChipRemove, {
|
|
305
|
+
className: "-ml-1 opacity-50 hover:opacity-100",
|
|
306
|
+
"data-slot": "combobox-chip-remove",
|
|
307
|
+
render: /* @__PURE__ */ jsx(Button, {
|
|
308
|
+
variant: "ghost",
|
|
309
|
+
size: "icon-xs",
|
|
310
|
+
children: /* @__PURE__ */ jsx(X, { className: "pointer-events-none" })
|
|
311
|
+
})
|
|
312
|
+
})]
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
function ComboboxChipsInput({ className, ...props }) {
|
|
316
|
+
return /* @__PURE__ */ jsx(Combobox.Input, {
|
|
317
|
+
"data-slot": "combobox-chip-input",
|
|
318
|
+
className: cn("min-w-16 flex-1 bg-transparent text-fg-primary outline-none placeholder:text-fg-caption-placeholder", className),
|
|
319
|
+
...props
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
function useComboboxAnchor() {
|
|
323
|
+
return React.useRef(null);
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Wires up an external virtualizer for a large `Combobox`. Spread the returned
|
|
327
|
+
* `onItemHighlighted` onto `<Combobox virtualized items={...}>` and pass
|
|
328
|
+
* `virtualizerRef` to `<ComboboxVirtualizedList>`. Keeps keyboard navigation in
|
|
329
|
+
* sync by scrolling the highlighted (off-screen) item into view.
|
|
330
|
+
*/
|
|
331
|
+
function useComboboxVirtualizer() {
|
|
332
|
+
const virtualizerRef = React.useRef(null);
|
|
333
|
+
return {
|
|
334
|
+
virtualizerRef,
|
|
335
|
+
onItemHighlighted: React.useCallback((item, { reason, index }) => {
|
|
336
|
+
const virtualizer = virtualizerRef.current;
|
|
337
|
+
if (item == null || !virtualizer || index < 0) return;
|
|
338
|
+
const isStart = index === 0;
|
|
339
|
+
const isEnd = index === virtualizer.options.count - 1;
|
|
340
|
+
if (reason === "none" || reason === "keyboard" && (isStart || isEnd)) queueMicrotask(() => {
|
|
341
|
+
virtualizer.scrollToIndex(index, { align: isEnd ? "start" : "end" });
|
|
342
|
+
});
|
|
343
|
+
}, [])
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
function ComboboxVirtualizedList({ virtualizerRef, estimateSize = 40, overscan = 20, paddingStart = 4, paddingEnd = 4, maxHeight = "22rem", className, children }) {
|
|
347
|
+
const filteredItems = Combobox.useFilteredItems();
|
|
348
|
+
const scrollElementRef = React.useRef(null);
|
|
349
|
+
const virtualizer = useVirtualizer({
|
|
350
|
+
count: filteredItems.length,
|
|
351
|
+
getScrollElement: () => scrollElementRef.current,
|
|
352
|
+
estimateSize: typeof estimateSize === "function" ? estimateSize : () => estimateSize,
|
|
353
|
+
overscan,
|
|
354
|
+
paddingStart,
|
|
355
|
+
paddingEnd,
|
|
356
|
+
scrollPaddingStart: paddingStart,
|
|
357
|
+
scrollPaddingEnd: paddingEnd
|
|
358
|
+
});
|
|
359
|
+
React.useImperativeHandle(virtualizerRef, () => virtualizer, [virtualizer]);
|
|
360
|
+
const handleScrollElementRef = React.useCallback((element) => {
|
|
361
|
+
scrollElementRef.current = element;
|
|
362
|
+
if (element) virtualizer.measure();
|
|
363
|
+
}, [virtualizer]);
|
|
364
|
+
const totalSize = virtualizer.getTotalSize();
|
|
365
|
+
if (!filteredItems.length) return null;
|
|
366
|
+
return /* @__PURE__ */ jsx("div", {
|
|
367
|
+
role: "presentation",
|
|
368
|
+
ref: handleScrollElementRef,
|
|
369
|
+
"data-slot": "combobox-virtualized",
|
|
370
|
+
style: { maxHeight },
|
|
371
|
+
className: cn("no-scrollbar overflow-y-auto overscroll-contain", className),
|
|
372
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
373
|
+
role: "presentation",
|
|
374
|
+
className: "relative w-full",
|
|
375
|
+
style: { height: totalSize },
|
|
376
|
+
children: virtualizer.getVirtualItems().map((virtualItem) => {
|
|
377
|
+
const item = filteredItems[virtualItem.index];
|
|
378
|
+
if (item == null) return null;
|
|
379
|
+
return /* @__PURE__ */ jsx(React.Fragment, { children: children(item, {
|
|
380
|
+
index: virtualItem.index,
|
|
381
|
+
"data-index": virtualItem.index,
|
|
382
|
+
"aria-setsize": filteredItems.length,
|
|
383
|
+
"aria-posinset": virtualItem.index + 1,
|
|
384
|
+
style: {
|
|
385
|
+
position: "absolute",
|
|
386
|
+
top: 0,
|
|
387
|
+
left: 0,
|
|
388
|
+
width: "100%",
|
|
389
|
+
height: virtualItem.size,
|
|
390
|
+
transform: `translateY(${virtualItem.start}px)`
|
|
391
|
+
}
|
|
392
|
+
}) }, virtualItem.key);
|
|
393
|
+
})
|
|
394
|
+
})
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
//#endregion
|
|
398
|
+
export { useComboboxAnchor as _, ComboboxCollection as a, ComboboxGroup as c, ComboboxLabel as d, ComboboxList as f, ComboboxVirtualizedList as g, ComboboxValue as h, ComboboxChipsInput as i, ComboboxInput as l, ComboboxTrigger as m, ComboboxChip as n, ComboboxContent as o, ComboboxSeparator as p, ComboboxChips as r, ComboboxEmpty as s, Combobox$1 as t, ComboboxItem as u, useComboboxVirtualizer as v };
|
package/dist/combobox.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ declare function ComboboxInput({ className, children, disabled, showTrigger, sho
|
|
|
13
13
|
showTrigger?: boolean;
|
|
14
14
|
showClear?: boolean;
|
|
15
15
|
}): React.JSX.Element;
|
|
16
|
-
declare function ComboboxContent({ className, side, sideOffset, align, alignOffset, anchor, ...props }: Combobox$1.Popup.Props & Pick<Combobox$1.Positioner.Props, "side" | "align" | "sideOffset" | "alignOffset" | "anchor">): React.JSX.Element;
|
|
16
|
+
declare function ComboboxContent({ className, side, sideOffset, align, alignOffset, anchor, children, ...props }: Combobox$1.Popup.Props & Pick<Combobox$1.Positioner.Props, "side" | "align" | "sideOffset" | "alignOffset" | "anchor">): React.JSX.Element;
|
|
17
17
|
declare function ComboboxList({ className, ...props }: Combobox$1.List.Props): React.JSX.Element;
|
|
18
18
|
declare function ComboboxItem({ className, children, ...props }: Combobox$1.Item.Props): React.JSX.Element;
|
|
19
19
|
declare function ComboboxGroup({ className, ...props }: Combobox$1.Group.Props): React.JSX.Element;
|
|
@@ -21,7 +21,7 @@ declare function ComboboxLabel({ className, ...props }: Combobox$1.GroupLabel.Pr
|
|
|
21
21
|
declare function ComboboxCollection({ ...props }: Combobox$1.Collection.Props): React.JSX.Element;
|
|
22
22
|
declare function ComboboxEmpty({ className, ...props }: Combobox$1.Empty.Props): React.JSX.Element;
|
|
23
23
|
declare function ComboboxSeparator({ className, ...props }: Combobox$1.Separator.Props): React.JSX.Element;
|
|
24
|
-
declare function ComboboxChips({ className, ...props }: React.ComponentPropsWithRef<typeof Combobox$1.Chips> & Combobox$1.Chips.Props): React.JSX.Element;
|
|
24
|
+
declare function ComboboxChips({ className, ref: refProp, ...props }: React.ComponentPropsWithRef<typeof Combobox$1.Chips> & Combobox$1.Chips.Props): React.JSX.Element;
|
|
25
25
|
declare function ComboboxChip({ className, children, showRemove, ...props }: Combobox$1.Chip.Props & {
|
|
26
26
|
showRemove?: boolean;
|
|
27
27
|
}): React.JSX.Element;
|