@kumix/ui 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -15
- package/dist/components/agents/approval-card/index.d.ts +2 -0
- package/dist/components/agents/approval-card/index.d.ts.map +1 -1
- package/dist/components/agents/approval-card/index.js +2 -0
- package/dist/components/agents/approval-card/index.js.map +1 -1
- package/dist/components/agents/citations.d.ts +14 -2
- package/dist/components/agents/citations.d.ts.map +1 -1
- package/dist/components/agents/citations.js +11 -7
- package/dist/components/agents/citations.js.map +1 -1
- package/dist/components/agents/loading-states/reasoning-text.d.ts.map +1 -1
- package/dist/components/agents/loading-states/reasoning-text.js +3 -0
- package/dist/components/agents/loading-states/reasoning-text.js.map +1 -1
- package/dist/components/charts/bump-chart/context.js +1 -2
- package/dist/components/charts/bump-chart/plot.js +1 -2
- package/dist/components/charts/bump-chart/point.js +1 -1
- package/dist/components/charts/bump-chart/series.d.ts +1 -0
- package/dist/components/charts/candlestick-chart/context.d.ts +79 -0
- package/dist/components/charts/candlestick-chart/context.d.ts.map +1 -0
- package/dist/components/charts/candlestick-chart/context.js +69 -0
- package/dist/components/charts/candlestick-chart/context.js.map +1 -0
- package/dist/components/charts/candlestick-chart/legend.d.ts +12 -0
- package/dist/components/charts/candlestick-chart/legend.d.ts.map +1 -0
- package/dist/components/charts/candlestick-chart/legend.js +56 -0
- package/dist/components/charts/candlestick-chart/legend.js.map +1 -0
- package/dist/components/charts/candlestick-chart/plot.d.ts +9 -0
- package/dist/components/charts/candlestick-chart/plot.d.ts.map +1 -0
- package/dist/components/charts/candlestick-chart/plot.js +218 -0
- package/dist/components/charts/candlestick-chart/plot.js.map +1 -0
- package/dist/components/charts/candlestick-chart.d.ts +18 -0
- package/dist/components/charts/candlestick-chart.d.ts.map +1 -0
- package/dist/components/charts/candlestick-chart.js +34 -0
- package/dist/components/charts/candlestick-chart.js.map +1 -0
- package/dist/components/charts/composition-chart/context.js +1 -2
- package/dist/components/charts/composition-chart/plot.js +1 -1
- package/dist/components/charts/donut-chart/center.d.ts +16 -0
- package/dist/components/charts/donut-chart/center.d.ts.map +1 -0
- package/dist/components/charts/donut-chart/center.js +78 -0
- package/dist/components/charts/donut-chart/center.js.map +1 -0
- package/dist/components/charts/donut-chart/context.d.ts +68 -0
- package/dist/components/charts/donut-chart/context.d.ts.map +1 -0
- package/dist/components/charts/donut-chart/context.js +2 -0
- package/dist/components/charts/donut-chart/legend.d.ts +17 -0
- package/dist/components/charts/donut-chart/legend.d.ts.map +1 -0
- package/dist/components/charts/donut-chart/legend.js +85 -0
- package/dist/components/charts/donut-chart/legend.js.map +1 -0
- package/dist/components/charts/donut-chart/plot.d.ts +10 -0
- package/dist/components/charts/donut-chart/plot.d.ts.map +1 -0
- package/dist/components/charts/donut-chart/plot.js +108 -0
- package/dist/components/charts/donut-chart/plot.js.map +1 -0
- package/dist/components/charts/donut-chart.d.ts +22 -0
- package/dist/components/charts/donut-chart.d.ts.map +1 -0
- package/dist/components/charts/donut-chart.js +37 -0
- package/dist/components/charts/donut-chart.js.map +1 -0
- package/dist/components/charts/funnel-chart.d.ts.map +1 -1
- package/dist/components/charts/funnel-chart.js +1 -2
- package/dist/components/charts/funnel-chart.js.map +1 -1
- package/dist/components/charts/heat-calendar/tooltip.js +1 -1
- package/dist/components/charts/liquidity-heatmap.js +1 -1
- package/dist/components/charts/order-book/depth-row.d.ts +8 -2
- package/dist/components/charts/order-book/depth-row.d.ts.map +1 -1
- package/dist/components/charts/order-book/depth-row.js +11 -3
- package/dist/components/charts/order-book/depth-row.js.map +1 -1
- package/dist/components/charts/order-book.d.ts +33 -1
- package/dist/components/charts/order-book.d.ts.map +1 -1
- package/dist/components/charts/order-book.js +92 -17
- package/dist/components/charts/order-book.js.map +1 -1
- package/dist/components/charts/price-target-fan/tooltip.js +1 -1
- package/dist/components/charts/returns-calendar/tooltip.js +1 -1
- package/dist/components/charts/status-bar/tooltip.js +1 -1
- package/dist/components/charts/treemap/tooltip.js +1 -1
- package/dist/components/charts/volume-profile/tooltip.js +1 -1
- package/dist/components/custom/confirm-dialog.d.ts +1 -0
- package/dist/components/custom/toast.d.ts +1 -0
- package/dist/components/motion/action-swap.d.ts.map +1 -1
- package/dist/components/motion/action-swap.js +3 -0
- package/dist/components/motion/action-swap.js.map +1 -1
- package/dist/components/motion/animated-sidebar.d.ts +1 -0
- package/dist/components/motion/attachment-upload.d.ts.map +1 -1
- package/dist/components/motion/attachment-upload.js +1 -2
- package/dist/components/motion/attachment-upload.js.map +1 -1
- package/dist/components/motion/availability-scheduler/copy-menu.js +1 -2
- package/dist/components/motion/availability-scheduler/day-row.js +2 -2
- package/dist/components/motion/availability-scheduler/index.js +1 -1
- package/dist/components/motion/bloom-menu.d.ts +1 -0
- package/dist/components/motion/bounce-sidebar.d.ts.map +1 -1
- package/dist/components/motion/bounce-sidebar.js +34 -42
- package/dist/components/motion/bounce-sidebar.js.map +1 -1
- package/dist/components/motion/button/stateful.d.ts.map +1 -1
- package/dist/components/motion/button/stateful.js +3 -0
- package/dist/components/motion/button/stateful.js.map +1 -1
- package/dist/components/motion/card.d.ts +44 -0
- package/dist/components/motion/card.d.ts.map +1 -0
- package/dist/components/motion/card.js +122 -0
- package/dist/components/motion/card.js.map +1 -0
- package/dist/components/motion/checkbox.d.ts +3 -1
- package/dist/components/motion/checkbox.d.ts.map +1 -1
- package/dist/components/motion/checkbox.js +18 -6
- package/dist/components/motion/checkbox.js.map +1 -1
- package/dist/components/motion/color-picker.d.ts +110 -0
- package/dist/components/motion/color-picker.d.ts.map +1 -0
- package/dist/components/motion/color-picker.js +1053 -0
- package/dist/components/motion/color-picker.js.map +1 -0
- package/dist/components/motion/color-selector.d.ts.map +1 -1
- package/dist/components/motion/color-selector.js +9 -2
- package/dist/components/motion/color-selector.js.map +1 -1
- package/dist/components/motion/combobox/content.d.ts +1 -0
- package/dist/components/motion/command-palette.js +2 -2
- package/dist/components/motion/command-palette.js.map +1 -1
- package/dist/components/motion/context-menu.d.ts +1 -0
- package/dist/components/motion/digit-swap.d.ts +9 -1
- package/dist/components/motion/digit-swap.d.ts.map +1 -1
- package/dist/components/motion/digit-swap.js +18 -7
- package/dist/components/motion/digit-swap.js.map +1 -1
- package/dist/components/motion/expandable-control.d.ts +1 -0
- package/dist/components/motion/knockout-wheel.d.ts.map +1 -1
- package/dist/components/motion/knockout-wheel.js +1 -2
- package/dist/components/motion/knockout-wheel.js.map +1 -1
- package/dist/components/motion/morphing-search-chips.d.ts +54 -0
- package/dist/components/motion/morphing-search-chips.d.ts.map +1 -0
- package/dist/components/motion/morphing-search-chips.js +599 -0
- package/dist/components/motion/morphing-search-chips.js.map +1 -0
- package/dist/components/motion/multi-select/content.d.ts +1 -0
- package/dist/components/motion/not-found/shared.d.ts +1 -0
- package/dist/components/motion/number-ticker.d.ts +6 -1
- package/dist/components/motion/number-ticker.d.ts.map +1 -1
- package/dist/components/motion/number-ticker.js +19 -9
- package/dist/components/motion/number-ticker.js.map +1 -1
- package/dist/components/motion/parallax.js.map +1 -1
- package/dist/components/motion/popover-morph.d.ts +1 -0
- package/dist/components/motion/popover-morph.js +3 -0
- package/dist/components/motion/popover-morph.js.map +1 -1
- package/dist/components/motion/popover.d.ts +1 -0
- package/dist/components/motion/prediction-market-card.js +2 -3
- package/dist/components/motion/prediction-market-card.js.map +1 -1
- package/dist/components/motion/radio.d.ts +3 -1
- package/dist/components/motion/radio.d.ts.map +1 -1
- package/dist/components/motion/radio.js +17 -5
- package/dist/components/motion/radio.js.map +1 -1
- package/dist/components/motion/scroll-progress.d.ts +1 -0
- package/dist/components/motion/shader-background.d.ts +1 -0
- package/dist/components/motion/sortable-list.d.ts +1 -0
- package/dist/components/motion/sortable-stack.js +1 -2
- package/dist/components/motion/tabs.d.ts +1 -0
- package/dist/components/motion/text-reveal.d.ts +1 -0
- package/dist/components/motion/tooltip/positioner.d.ts +8 -26
- package/dist/components/motion/tooltip/positioner.d.ts.map +1 -1
- package/dist/components/motion/tooltip/positioner.js +1 -2
- package/dist/components/motion/tooltip.d.ts +62 -20
- package/dist/components/motion/tooltip.d.ts.map +1 -1
- package/dist/components/motion/tooltip.js +1 -135
- package/dist/components/motion/wallet-card/account-avatar.js +1 -2
- package/dist/components/reui/alert.d.ts +1 -1
- package/dist/components/reui/autocomplete.d.ts +1 -1
- package/dist/components/reui/autocomplete.d.ts.map +1 -1
- package/dist/components/reui/autocomplete.js.map +1 -1
- package/dist/components/reui/badge.d.ts +2 -2
- package/dist/components/reui/color-picker.d.ts +280 -0
- package/dist/components/reui/color-picker.d.ts.map +1 -0
- package/dist/components/reui/color-picker.js +2013 -0
- package/dist/components/reui/color-picker.js.map +1 -0
- package/dist/components/reui/data-grid/data-grid-cell-selection.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.js +43 -21
- package/dist/components/reui/data-grid/data-grid-column-header.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-pagination.js +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.js +9 -3
- package/dist/components/reui/data-grid/data-grid-scroll-area.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js +12 -8
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.d.ts +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.js +52 -13
- package/dist/components/reui/data-grid/data-grid-table-dnd.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.js +35 -41
- package/dist/components/reui/data-grid/data-grid-table-virtual.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table.d.ts +168 -5
- package/dist/components/reui/data-grid/data-grid-table.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table.js +203 -69
- package/dist/components/reui/data-grid/data-grid-table.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid.d.ts +39 -0
- package/dist/components/reui/data-grid/data-grid.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid.js +33 -1
- package/dist/components/reui/data-grid/data-grid.js.map +1 -1
- package/dist/components/reui/date-selector.d.ts +1 -0
- package/dist/components/reui/date-selector.js +1 -1
- package/dist/components/reui/emoji-picker.d.ts +367 -0
- package/dist/components/reui/emoji-picker.d.ts.map +1 -0
- package/dist/components/reui/emoji-picker.js +1768 -0
- package/dist/components/reui/emoji-picker.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-i18n.d.ts.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.js +2 -2
- package/dist/components/reui/file-type.d.ts +496 -0
- package/dist/components/reui/file-type.d.ts.map +1 -0
- package/dist/components/reui/file-type.js +964 -0
- package/dist/components/reui/file-type.js.map +1 -0
- package/dist/components/reui/filters/filters-advanced.d.ts +1 -0
- package/dist/components/reui/filters/filters-advanced.js +1 -1
- package/dist/components/reui/filters/filters-advanced.js.map +1 -1
- package/dist/components/reui/filters/filters-chip.d.ts +5 -1
- package/dist/components/reui/filters/filters-chip.d.ts.map +1 -1
- package/dist/components/reui/filters/filters-chip.js +1 -1
- package/dist/components/reui/filters/filters-lib.d.ts.map +1 -1
- package/dist/components/reui/frame.d.ts +1 -1
- package/dist/components/reui/frame.d.ts.map +1 -1
- package/dist/components/reui/frame.js.map +1 -1
- package/dist/components/reui/gantt/gantt-nav.js +2 -2
- package/dist/components/reui/icon-tile.d.ts +2 -2
- package/dist/components/reui/icon-tile.js +8 -7
- package/dist/components/reui/icon-tile.js.map +1 -1
- package/dist/components/reui/kanban.d.ts.map +1 -1
- package/dist/components/reui/kanban.js +1 -1
- package/dist/components/reui/kanban.js.map +1 -1
- package/dist/components/reui/number-field.d.ts +3 -3
- package/dist/components/reui/number-field.d.ts.map +1 -1
- package/dist/components/reui/number-field.js.map +1 -1
- package/dist/components/reui/rating.d.ts +1 -1
- package/dist/components/reui/scrollspy.d.ts +1 -0
- package/dist/components/reui/time-picker.js.map +1 -1
- package/dist/components/ui/attachment.d.ts +3 -3
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/bubble.d.ts +1 -1
- package/dist/components/ui/button-group.d.ts +1 -1
- package/dist/components/ui/button.d.ts +2 -2
- package/dist/components/ui/command.d.ts.map +1 -1
- package/dist/components/ui/direction.js +1 -2
- package/dist/components/ui/empty.d.ts +1 -1
- package/dist/components/ui/field.d.ts +1 -1
- package/dist/components/ui/field.js +1 -1
- package/dist/components/ui/input-group.d.ts +1 -1
- package/dist/components/ui/item.d.ts +2 -2
- package/dist/components/ui/marker.d.ts +1 -1
- package/dist/components/ui/message-scroller.d.ts.map +1 -1
- package/dist/components/ui/questionnaire.d.ts.map +1 -1
- package/dist/components/ui/sidebar.d.ts +1 -1
- package/dist/components/ui/sidebar.js +1 -1
- package/dist/components/ui/toggle.d.ts +1 -1
- package/dist/context-tTdLKYNf.js +99 -0
- package/dist/context-tTdLKYNf.js.map +1 -0
- package/dist/{copy-menu-C5GaT4Z-.js → copy-menu-BXUh52bu.js} +2 -2
- package/dist/{copy-menu-C5GaT4Z-.js.map → copy-menu-BXUh52bu.js.map} +1 -1
- package/dist/hooks/use-copy-to-clipboard.d.ts +1 -0
- package/dist/hooks/use-hover-gesture.d.ts +1 -0
- package/dist/hooks/use-intersection-observer.d.ts +1 -0
- package/dist/hooks/use-scroll-position.d.ts +1 -0
- package/dist/hooks/use-slider-input.d.ts +1 -0
- package/dist/hooks/use-viewport.d.ts +1 -0
- package/dist/lib/tick-sound.d.ts +1 -0
- package/dist/model-NSIg2p7a.d.ts +20 -0
- package/dist/model-NSIg2p7a.d.ts.map +1 -0
- package/dist/model-_mRyI6V9.d.ts +18 -0
- package/dist/model-_mRyI6V9.d.ts.map +1 -0
- package/dist/{positioner-3mCqiebN.js → positioner-3r3cfkqT.js} +97 -33
- package/dist/positioner-3r3cfkqT.js.map +1 -0
- package/dist/tooltip-Bam5KeYe.js +535 -0
- package/dist/tooltip-Bam5KeYe.js.map +1 -0
- package/dist/use-position-DOi1gVL0.d.ts +32 -0
- package/dist/use-position-DOi1gVL0.d.ts.map +1 -0
- package/package.json +8 -8
- package/dist/components/motion/tooltip.js.map +0 -1
- package/dist/model-DfeFradZ.d.ts +0 -9
- package/dist/model-DfeFradZ.d.ts.map +0 -1
- package/dist/positioner-3mCqiebN.js.map +0 -1
|
@@ -0,0 +1,599 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useDismiss } from "../../hooks/use-dismiss.js";
|
|
3
|
+
import { useOnOpen } from "../../hooks/use-on-open.js";
|
|
4
|
+
import { useRowCursor } from "../../hooks/use-row-cursor.js";
|
|
5
|
+
import { EASE_OUT, SPRING_LAYOUT, SPRING_SWAP } from "../../lib/ease.js";
|
|
6
|
+
import { t as PresenceGate } from "../../presence-gate-BekdC4Bo.js";
|
|
7
|
+
import { useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
8
|
+
import { cn } from "@kumix/utils";
|
|
9
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
11
|
+
import { Clock, LoaderCircle, Search, X } from "lucide-react";
|
|
12
|
+
//#region src/components/motion/morphing-search-chips.tsx
|
|
13
|
+
const MORPH_ENTER = {
|
|
14
|
+
type: "spring",
|
|
15
|
+
stiffness: 380,
|
|
16
|
+
damping: 28,
|
|
17
|
+
mass: .8,
|
|
18
|
+
opacity: { duration: .1 }
|
|
19
|
+
};
|
|
20
|
+
const MORPH_EXIT = {
|
|
21
|
+
type: "spring",
|
|
22
|
+
stiffness: 520,
|
|
23
|
+
damping: 40,
|
|
24
|
+
mass: .6,
|
|
25
|
+
opacity: {
|
|
26
|
+
duration: .12,
|
|
27
|
+
delay: .1
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const SEED = {
|
|
31
|
+
width: 112,
|
|
32
|
+
height: 40
|
|
33
|
+
};
|
|
34
|
+
const SEED_TUCK = 28;
|
|
35
|
+
const CONTENT_IN = {
|
|
36
|
+
duration: .18,
|
|
37
|
+
ease: EASE_OUT,
|
|
38
|
+
delay: .12
|
|
39
|
+
};
|
|
40
|
+
const CONTENT_OUT = {
|
|
41
|
+
duration: .08,
|
|
42
|
+
ease: EASE_OUT
|
|
43
|
+
};
|
|
44
|
+
const GLASS = "border border-foreground/[0.08] bg-background/55 backdrop-blur-[20px] backdrop-saturate-[1.6] shadow-[inset_0_1px_0_0_rgb(255_255_255/0.06),0_24px_60px_-24px_rgb(0_0_0/0.45)]";
|
|
45
|
+
const CHIP_HIDDEN = {
|
|
46
|
+
opacity: 0,
|
|
47
|
+
scale: .6,
|
|
48
|
+
filter: "blur(4px)"
|
|
49
|
+
};
|
|
50
|
+
const CHIP_SHOWN = {
|
|
51
|
+
opacity: 1,
|
|
52
|
+
scale: 1,
|
|
53
|
+
filter: "blur(0px)"
|
|
54
|
+
};
|
|
55
|
+
const CHIP_ENTER = {
|
|
56
|
+
...SPRING_SWAP,
|
|
57
|
+
opacity: { duration: .16 },
|
|
58
|
+
filter: { duration: .2 }
|
|
59
|
+
};
|
|
60
|
+
const CHIP_EXIT = {
|
|
61
|
+
duration: .16,
|
|
62
|
+
ease: EASE_OUT
|
|
63
|
+
};
|
|
64
|
+
const SURFACE_RADIUS = 28;
|
|
65
|
+
const PANEL_ROOM = 320;
|
|
66
|
+
function useControllable(value, initial, onChange) {
|
|
67
|
+
const [internal, setInternal] = useState(initial);
|
|
68
|
+
return [
|
|
69
|
+
value ?? internal,
|
|
70
|
+
useCallback((next) => {
|
|
71
|
+
if (value === void 0) setInternal(next);
|
|
72
|
+
onChange?.(next);
|
|
73
|
+
}, [value, onChange]),
|
|
74
|
+
setInternal
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
const sameTerm = (a, b) => a.trim().toLowerCase() === b.trim().toLowerCase();
|
|
78
|
+
const contains = (term, query) => term.toLowerCase().includes(query.toLowerCase());
|
|
79
|
+
function Highlight({ text, query }) {
|
|
80
|
+
const at = query ? text.toLowerCase().indexOf(query.toLowerCase()) : -1;
|
|
81
|
+
if (at < 0) return text;
|
|
82
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
83
|
+
text.slice(0, at),
|
|
84
|
+
/* @__PURE__ */ jsx("span", {
|
|
85
|
+
className: "font-semibold",
|
|
86
|
+
children: text.slice(at, at + query.length)
|
|
87
|
+
}),
|
|
88
|
+
text.slice(at + query.length)
|
|
89
|
+
] });
|
|
90
|
+
}
|
|
91
|
+
function MorphingSearchChips({ chips: chipsProp, defaultChips = [], onChipsChange, query: queryProp, defaultQuery = "", onQueryChange, recents: recentsProp, defaultRecents = [], onRecentsChange, storageKey, maxRecents = 5, suggestions = [], filter, maxSuggestions = 6, loading = false, maxChips, normalize, emptyState, side = "top", open: openProp, defaultOpen = false, onOpenChange, disabled = false, name, placeholder = "Search", label = "Search", actions, className }) {
|
|
92
|
+
const reduce = useReducedMotion();
|
|
93
|
+
const [chips, setChips] = useControllable(chipsProp, defaultChips, onChipsChange);
|
|
94
|
+
const [query, setQuery] = useControllable(queryProp, defaultQuery, onQueryChange);
|
|
95
|
+
const [recents, setRecentsState, setStoredRecents] = useControllable(recentsProp, defaultRecents, onRecentsChange);
|
|
96
|
+
const [openState, setOpen] = useControllable(openProp, defaultOpen, onOpenChange);
|
|
97
|
+
const open = openState && !disabled;
|
|
98
|
+
const [announcement, setAnnouncement] = useState({
|
|
99
|
+
text: "",
|
|
100
|
+
count: 0
|
|
101
|
+
});
|
|
102
|
+
const [markedChip, setMarkedChip] = useState(null);
|
|
103
|
+
const [placed, setPlaced] = useState(side === "bottom" ? "bottom" : "top");
|
|
104
|
+
const [rtl, setRtl] = useState(false);
|
|
105
|
+
const rootRef = useRef(null);
|
|
106
|
+
const inputRef = useRef(null);
|
|
107
|
+
const chipsRef = useRef(null);
|
|
108
|
+
const id = useId();
|
|
109
|
+
const listId = `${id}-list`;
|
|
110
|
+
const hintId = `${id}-hint`;
|
|
111
|
+
const optionId = (index) => `${id}-option-${index}`;
|
|
112
|
+
const announce = useCallback((text) => setAnnouncement((current) => ({
|
|
113
|
+
text,
|
|
114
|
+
count: current.count + 1
|
|
115
|
+
})), []);
|
|
116
|
+
const marked = markedChip !== null && chips.includes(markedChip) ? markedChip : null;
|
|
117
|
+
if (markedChip !== null && marked === null) setMarkedChip(null);
|
|
118
|
+
const [panelSize, setPanelSize] = useState({
|
|
119
|
+
width: 0,
|
|
120
|
+
height: 0
|
|
121
|
+
});
|
|
122
|
+
const panelObserver = useRef(null);
|
|
123
|
+
const measurePanel = useCallback((node) => {
|
|
124
|
+
panelObserver.current?.disconnect();
|
|
125
|
+
panelObserver.current = null;
|
|
126
|
+
if (!node) return;
|
|
127
|
+
const read = () => setPanelSize({
|
|
128
|
+
width: node.offsetWidth,
|
|
129
|
+
height: node.offsetHeight
|
|
130
|
+
});
|
|
131
|
+
read();
|
|
132
|
+
panelObserver.current = new ResizeObserver(read);
|
|
133
|
+
panelObserver.current.observe(node);
|
|
134
|
+
}, []);
|
|
135
|
+
const chipsLatest = useRef(chips);
|
|
136
|
+
useLayoutEffect(() => {
|
|
137
|
+
chipsLatest.current = chips;
|
|
138
|
+
});
|
|
139
|
+
useLayoutEffect(() => {
|
|
140
|
+
if (rootRef.current) setRtl(getComputedStyle(rootRef.current).direction === "rtl");
|
|
141
|
+
}, []);
|
|
142
|
+
const persist = storageKey && recentsProp === void 0 ? storageKey : null;
|
|
143
|
+
useEffect(() => {
|
|
144
|
+
if (!persist) return;
|
|
145
|
+
try {
|
|
146
|
+
const stored = JSON.parse(window.localStorage.getItem(persist) ?? "null");
|
|
147
|
+
if (Array.isArray(stored)) setStoredRecents(stored.filter((term) => typeof term === "string").slice(0, maxRecents));
|
|
148
|
+
} catch {}
|
|
149
|
+
}, [
|
|
150
|
+
persist,
|
|
151
|
+
maxRecents,
|
|
152
|
+
setStoredRecents
|
|
153
|
+
]);
|
|
154
|
+
const setRecents = (next) => {
|
|
155
|
+
setRecentsState(next);
|
|
156
|
+
if (!persist) return;
|
|
157
|
+
try {
|
|
158
|
+
window.localStorage.setItem(persist, JSON.stringify(next));
|
|
159
|
+
} catch {}
|
|
160
|
+
};
|
|
161
|
+
const trimmed = query.trim();
|
|
162
|
+
const rows = useMemo(() => {
|
|
163
|
+
if (!trimmed) return recents.map((term) => ({
|
|
164
|
+
id: `recent:${term}`,
|
|
165
|
+
label: term,
|
|
166
|
+
kind: "recent"
|
|
167
|
+
}));
|
|
168
|
+
const seen = /* @__PURE__ */ new Set([trimmed.toLowerCase(), ...chips.map((chip) => chip.toLowerCase())]);
|
|
169
|
+
const matches = [];
|
|
170
|
+
const pools = [[
|
|
171
|
+
"recent",
|
|
172
|
+
recents,
|
|
173
|
+
contains
|
|
174
|
+
], [
|
|
175
|
+
"suggestion",
|
|
176
|
+
suggestions,
|
|
177
|
+
filter === false ? () => true : filter ?? contains
|
|
178
|
+
]];
|
|
179
|
+
for (const [kind, pool, matchFn] of pools) for (const term of pool) {
|
|
180
|
+
const key = term.toLowerCase();
|
|
181
|
+
if (seen.has(key) || !matchFn(term, trimmed)) continue;
|
|
182
|
+
seen.add(key);
|
|
183
|
+
matches.push({
|
|
184
|
+
id: `${kind}:${term}`,
|
|
185
|
+
label: term,
|
|
186
|
+
kind
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
return [{
|
|
190
|
+
id: `query:${trimmed}`,
|
|
191
|
+
label: trimmed,
|
|
192
|
+
kind: "query"
|
|
193
|
+
}, ...matches.slice(0, maxSuggestions)];
|
|
194
|
+
}, [
|
|
195
|
+
trimmed,
|
|
196
|
+
recents,
|
|
197
|
+
suggestions,
|
|
198
|
+
chips,
|
|
199
|
+
filter,
|
|
200
|
+
maxSuggestions
|
|
201
|
+
]);
|
|
202
|
+
const { activeIndex, moveTo, moveActive } = useRowCursor(rows, trimmed);
|
|
203
|
+
const active = rows[activeIndex];
|
|
204
|
+
const showList = rows.length > 0;
|
|
205
|
+
const panelOpen = open && (showList || loading || !trimmed && emptyState != null);
|
|
206
|
+
useOnOpen(open, () => moveTo(null));
|
|
207
|
+
const [panelFloor, setPanelFloor] = useState(0);
|
|
208
|
+
useOnOpen(panelOpen, () => setPanelFloor(0));
|
|
209
|
+
const rowsObserver = useRef(null);
|
|
210
|
+
const measureRows = useCallback((node) => {
|
|
211
|
+
rowsObserver.current?.disconnect();
|
|
212
|
+
rowsObserver.current = null;
|
|
213
|
+
if (!node) return;
|
|
214
|
+
const read = () => setPanelFloor((floor) => Math.max(floor, node.offsetHeight + 16));
|
|
215
|
+
read();
|
|
216
|
+
rowsObserver.current = new ResizeObserver(read);
|
|
217
|
+
rowsObserver.current.observe(node);
|
|
218
|
+
}, []);
|
|
219
|
+
useLayoutEffect(() => {
|
|
220
|
+
if (!panelOpen) return;
|
|
221
|
+
if (side !== "auto") {
|
|
222
|
+
setPlaced(side);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
const rect = rootRef.current?.getBoundingClientRect();
|
|
226
|
+
if (!rect) return;
|
|
227
|
+
const above = rect.top;
|
|
228
|
+
const below = window.innerHeight - rect.bottom;
|
|
229
|
+
setPlaced(above < PANEL_ROOM && below > above ? "bottom" : "top");
|
|
230
|
+
}, [panelOpen, side]);
|
|
231
|
+
const activeOptionId = panelOpen && showList ? optionId(activeIndex) : void 0;
|
|
232
|
+
useEffect(() => {
|
|
233
|
+
if (activeOptionId) document.getElementById(activeOptionId)?.scrollIntoView({ block: "nearest" });
|
|
234
|
+
}, [activeOptionId]);
|
|
235
|
+
const close = useCallback(() => setOpen(false), [setOpen]);
|
|
236
|
+
useDismiss(open, close, rootRef);
|
|
237
|
+
const chipCount = useRef(chips.length);
|
|
238
|
+
useEffect(() => {
|
|
239
|
+
const row = chipsRef.current;
|
|
240
|
+
const added = chips.length > chipCount.current;
|
|
241
|
+
chipCount.current = chips.length;
|
|
242
|
+
if (!row || !added || row.scrollWidth <= row.clientWidth) return;
|
|
243
|
+
row.scrollTo({
|
|
244
|
+
left: rtl ? -row.scrollWidth : row.scrollWidth,
|
|
245
|
+
behavior: reduce ? "auto" : "smooth"
|
|
246
|
+
});
|
|
247
|
+
}, [
|
|
248
|
+
chips.length,
|
|
249
|
+
reduce,
|
|
250
|
+
rtl
|
|
251
|
+
]);
|
|
252
|
+
const full = maxChips !== void 0 && chips.length >= maxChips;
|
|
253
|
+
const addChip = (term) => {
|
|
254
|
+
const value = normalize ? normalize(term) : term.trim();
|
|
255
|
+
if (!value) return;
|
|
256
|
+
const exists = chips.some((chip) => sameTerm(chip, value));
|
|
257
|
+
if (!exists && full) {
|
|
258
|
+
announce(`Up to ${maxChips} filters`);
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
if (!exists) {
|
|
262
|
+
setChips([...chips, value]);
|
|
263
|
+
announce(`Added filter ${value}`);
|
|
264
|
+
}
|
|
265
|
+
setRecents([value, ...recents.filter((recent) => !sameTerm(recent, value))].slice(0, maxRecents));
|
|
266
|
+
setQuery("");
|
|
267
|
+
};
|
|
268
|
+
const removeChip = (term) => {
|
|
269
|
+
setChips(chips.filter((chip) => chip !== term));
|
|
270
|
+
announce(`Removed filter ${term}`);
|
|
271
|
+
inputRef.current?.focus();
|
|
272
|
+
};
|
|
273
|
+
const removeRecent = (term) => {
|
|
274
|
+
setRecents(recents.filter((recent) => recent !== term));
|
|
275
|
+
announce(`Removed ${term} from recent searches`);
|
|
276
|
+
};
|
|
277
|
+
const stepMark = (direction) => setMarkedChip((current) => {
|
|
278
|
+
const list = chipsLatest.current;
|
|
279
|
+
if (list.length === 0) return null;
|
|
280
|
+
const next = (current === null ? list.length : list.indexOf(current)) + direction;
|
|
281
|
+
if (next >= list.length) return null;
|
|
282
|
+
return list[Math.max(next, 0)];
|
|
283
|
+
});
|
|
284
|
+
const onKeyDown = (event) => {
|
|
285
|
+
if (event.nativeEvent.isComposing || event.keyCode === 229) return;
|
|
286
|
+
const field = event.currentTarget;
|
|
287
|
+
const atStart = field.selectionStart === 0 && field.selectionEnd === 0;
|
|
288
|
+
const back = rtl ? "ArrowRight" : "ArrowLeft";
|
|
289
|
+
const forward = rtl ? "ArrowLeft" : "ArrowRight";
|
|
290
|
+
if (marked !== null) {
|
|
291
|
+
if (event.key === "Backspace" || event.key === "Delete") {
|
|
292
|
+
event.preventDefault();
|
|
293
|
+
setMarkedChip(null);
|
|
294
|
+
removeChip(marked);
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
if (event.key === back || event.key === forward) {
|
|
298
|
+
event.preventDefault();
|
|
299
|
+
stepMark(event.key === back ? -1 : 1);
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
if (event.key === "Escape") {
|
|
303
|
+
event.preventDefault();
|
|
304
|
+
event.stopPropagation();
|
|
305
|
+
setMarkedChip(null);
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
setMarkedChip(null);
|
|
309
|
+
}
|
|
310
|
+
if (event.key === "Escape" && query !== "") {
|
|
311
|
+
event.preventDefault();
|
|
312
|
+
event.stopPropagation();
|
|
313
|
+
setQuery("");
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
317
|
+
event.preventDefault();
|
|
318
|
+
if (!open) setOpen(true);
|
|
319
|
+
else moveActive(event.key === "ArrowDown" ? 1 : -1);
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
if (event.key === "Enter") {
|
|
323
|
+
if (!panelOpen || !active) return;
|
|
324
|
+
event.preventDefault();
|
|
325
|
+
addChip(active.label);
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
if (event.key === "Delete" && panelOpen && active?.kind === "recent") {
|
|
329
|
+
event.preventDefault();
|
|
330
|
+
removeRecent(active.label);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
if (event.key === "Backspace" && atStart && chips.length > 0) {
|
|
334
|
+
event.preventDefault();
|
|
335
|
+
const last = chips[chips.length - 1];
|
|
336
|
+
setMarkedChip(last);
|
|
337
|
+
announce(`${last} selected. Press Backspace again to remove it.`);
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
if (event.key === back && atStart && chips.length > 0) {
|
|
341
|
+
event.preventDefault();
|
|
342
|
+
stepMark(-1);
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
const focusField = (event) => {
|
|
346
|
+
if (disabled || event.target.closest("button, input, a")) return;
|
|
347
|
+
event.preventDefault();
|
|
348
|
+
inputRef.current?.focus();
|
|
349
|
+
setOpen(true);
|
|
350
|
+
};
|
|
351
|
+
const layout = reduce ? { duration: 0 } : SPRING_LAYOUT;
|
|
352
|
+
const below = placed === "bottom";
|
|
353
|
+
const seed = {
|
|
354
|
+
...SEED,
|
|
355
|
+
y: below ? -28 : SEED_TUCK
|
|
356
|
+
};
|
|
357
|
+
const panel = /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
358
|
+
/* @__PURE__ */ jsxs("div", {
|
|
359
|
+
className: "flex h-9 items-center justify-between px-3",
|
|
360
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
361
|
+
className: "font-medium text-muted-foreground text-xs",
|
|
362
|
+
children: trimmed ? "Suggestions" : "Recent"
|
|
363
|
+
}), !trimmed && recents.length > 0 ? /* @__PURE__ */ jsx("button", {
|
|
364
|
+
type: "button",
|
|
365
|
+
onClick: () => {
|
|
366
|
+
setRecents([]);
|
|
367
|
+
announce("Cleared recent searches");
|
|
368
|
+
inputRef.current?.focus();
|
|
369
|
+
},
|
|
370
|
+
className: "rounded-md px-1.5 py-0.5 text-muted-foreground text-xs outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",
|
|
371
|
+
children: "Clear"
|
|
372
|
+
}) : null]
|
|
373
|
+
}),
|
|
374
|
+
showList ? /* @__PURE__ */ jsx("div", {
|
|
375
|
+
id: listId,
|
|
376
|
+
role: "listbox",
|
|
377
|
+
"aria-label": trimmed ? "Suggestions" : "Recent searches",
|
|
378
|
+
"aria-busy": loading || void 0,
|
|
379
|
+
className: "max-h-[min(20rem,45vh)] overflow-y-auto overscroll-contain [scrollbar-width:thin]",
|
|
380
|
+
children: rows.map((row, index) => {
|
|
381
|
+
const selected = index === activeIndex;
|
|
382
|
+
return /* @__PURE__ */ jsxs(motion.div, {
|
|
383
|
+
id: optionId(index),
|
|
384
|
+
role: "option",
|
|
385
|
+
"aria-selected": selected,
|
|
386
|
+
onPointerDown: (event) => event.preventDefault(),
|
|
387
|
+
onPointerMove: () => moveTo(row.id),
|
|
388
|
+
onClick: () => addChip(row.label),
|
|
389
|
+
className: "relative flex h-11 cursor-pointer items-center gap-3 rounded-2xl px-3 text-foreground text-sm",
|
|
390
|
+
children: [
|
|
391
|
+
selected ? /* @__PURE__ */ jsx(motion.span, {
|
|
392
|
+
layoutId: `${id}-active`,
|
|
393
|
+
transition: layout,
|
|
394
|
+
className: "absolute inset-0 rounded-2xl bg-foreground/6"
|
|
395
|
+
}) : null,
|
|
396
|
+
row.kind === "recent" ? /* @__PURE__ */ jsx(Clock, {
|
|
397
|
+
"aria-hidden": "true",
|
|
398
|
+
className: "relative size-4 shrink-0 text-muted-foreground"
|
|
399
|
+
}) : /* @__PURE__ */ jsx(Search, {
|
|
400
|
+
"aria-hidden": "true",
|
|
401
|
+
className: "relative size-4 shrink-0 text-muted-foreground"
|
|
402
|
+
}),
|
|
403
|
+
/* @__PURE__ */ jsx("span", {
|
|
404
|
+
className: "relative min-w-0 flex-1 truncate",
|
|
405
|
+
children: row.kind === "query" ? row.label : /* @__PURE__ */ jsx(Highlight, {
|
|
406
|
+
text: row.label,
|
|
407
|
+
query: trimmed
|
|
408
|
+
})
|
|
409
|
+
}),
|
|
410
|
+
row.kind === "recent" ? /* @__PURE__ */ jsx("span", {
|
|
411
|
+
"aria-hidden": "true",
|
|
412
|
+
onClick: (event) => {
|
|
413
|
+
event.stopPropagation();
|
|
414
|
+
removeRecent(row.label);
|
|
415
|
+
},
|
|
416
|
+
className: "relative grid size-7 shrink-0 place-items-center rounded-full text-muted-foreground transition-colors hover:bg-foreground/10 hover:text-foreground",
|
|
417
|
+
children: /* @__PURE__ */ jsx(X, { className: "size-3.5" })
|
|
418
|
+
}) : null
|
|
419
|
+
]
|
|
420
|
+
}, row.id);
|
|
421
|
+
})
|
|
422
|
+
}) : !trimmed && emptyState != null ? /* @__PURE__ */ jsx("div", {
|
|
423
|
+
className: "px-3 pt-1 pb-2 text-muted-foreground text-sm",
|
|
424
|
+
children: emptyState
|
|
425
|
+
}) : null,
|
|
426
|
+
loading ? /* @__PURE__ */ jsxs("div", {
|
|
427
|
+
className: "flex h-11 items-center gap-3 px-3 text-muted-foreground text-sm",
|
|
428
|
+
children: [/* @__PURE__ */ jsx(LoaderCircle, {
|
|
429
|
+
"aria-hidden": "true",
|
|
430
|
+
className: "size-4 motion-safe:animate-spin"
|
|
431
|
+
}), "Searching…"]
|
|
432
|
+
}) : null
|
|
433
|
+
] });
|
|
434
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
435
|
+
ref: rootRef,
|
|
436
|
+
className: cn("relative flex h-14 w-full max-w-xl justify-center", disabled && "opacity-60", className),
|
|
437
|
+
onBlur: (event) => {
|
|
438
|
+
if (rootRef.current?.contains(event.relatedTarget)) return;
|
|
439
|
+
setMarkedChip(null);
|
|
440
|
+
close();
|
|
441
|
+
},
|
|
442
|
+
children: [
|
|
443
|
+
/* @__PURE__ */ jsx(AnimatePresence, { children: panelOpen ? /* @__PURE__ */ jsx(PresenceGate, { children: ({ gate }) => /* @__PURE__ */ jsxs("div", {
|
|
444
|
+
...gate,
|
|
445
|
+
className: cn("absolute inset-x-0 z-10", below ? "top-full mt-2" : "bottom-full mb-2"),
|
|
446
|
+
children: [/* @__PURE__ */ jsx(motion.div, {
|
|
447
|
+
"aria-hidden": "true",
|
|
448
|
+
initial: reduce ? { opacity: 0 } : {
|
|
449
|
+
...seed,
|
|
450
|
+
opacity: 0
|
|
451
|
+
},
|
|
452
|
+
animate: {
|
|
453
|
+
width: panelSize.width || SEED.width,
|
|
454
|
+
height: panelSize.height || SEED.height,
|
|
455
|
+
y: 0,
|
|
456
|
+
opacity: 1
|
|
457
|
+
},
|
|
458
|
+
exit: reduce ? {
|
|
459
|
+
opacity: 0,
|
|
460
|
+
transition: { duration: .12 }
|
|
461
|
+
} : {
|
|
462
|
+
...seed,
|
|
463
|
+
opacity: 0,
|
|
464
|
+
transition: MORPH_EXIT
|
|
465
|
+
},
|
|
466
|
+
transition: reduce ? { duration: 0 } : MORPH_ENTER,
|
|
467
|
+
style: {
|
|
468
|
+
borderRadius: SURFACE_RADIUS,
|
|
469
|
+
x: "-50%"
|
|
470
|
+
},
|
|
471
|
+
className: cn("absolute left-1/2", below ? "top-0" : "bottom-0", GLASS)
|
|
472
|
+
}), /* @__PURE__ */ jsx(motion.div, {
|
|
473
|
+
initial: {
|
|
474
|
+
opacity: 0,
|
|
475
|
+
y: reduce ? 0 : below ? -6 : 6
|
|
476
|
+
},
|
|
477
|
+
animate: {
|
|
478
|
+
opacity: 1,
|
|
479
|
+
y: 0,
|
|
480
|
+
transition: reduce ? { duration: .15 } : CONTENT_IN
|
|
481
|
+
},
|
|
482
|
+
exit: {
|
|
483
|
+
opacity: 0,
|
|
484
|
+
transition: CONTENT_OUT
|
|
485
|
+
},
|
|
486
|
+
ref: measurePanel,
|
|
487
|
+
style: { minHeight: panelFloor || void 0 },
|
|
488
|
+
className: "relative p-2",
|
|
489
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
490
|
+
ref: measureRows,
|
|
491
|
+
children: panel
|
|
492
|
+
})
|
|
493
|
+
})]
|
|
494
|
+
}) }, "panel") : null }),
|
|
495
|
+
/* @__PURE__ */ jsxs(motion.div, {
|
|
496
|
+
layout: true,
|
|
497
|
+
transition: layout,
|
|
498
|
+
onPointerDown: focusField,
|
|
499
|
+
style: { borderRadius: SURFACE_RADIUS },
|
|
500
|
+
className: cn("relative z-20 flex h-14 min-w-0 items-center gap-2 ps-4", GLASS, disabled ? "cursor-not-allowed" : "cursor-text", actions ? "pe-2" : "pe-4", open ? "w-full" : "w-fit max-w-full"),
|
|
501
|
+
children: [
|
|
502
|
+
/* @__PURE__ */ jsx(Search, {
|
|
503
|
+
"aria-hidden": "true",
|
|
504
|
+
className: "size-5 shrink-0 text-muted-foreground"
|
|
505
|
+
}),
|
|
506
|
+
/* @__PURE__ */ jsx("div", {
|
|
507
|
+
ref: chipsRef,
|
|
508
|
+
className: cn("relative flex min-w-0 items-center gap-1.5 overflow-x-auto [scrollbar-width:none]", chips.length > 0 && "mask-[linear-gradient(to_right,transparent,#000_12px,#000_calc(100%-12px),transparent)] -mx-1.5 px-3"),
|
|
509
|
+
children: /* @__PURE__ */ jsx(AnimatePresence, {
|
|
510
|
+
initial: false,
|
|
511
|
+
mode: "popLayout",
|
|
512
|
+
children: chips.map((chip) => /* @__PURE__ */ jsxs(motion.span, {
|
|
513
|
+
layout: reduce ? false : "position",
|
|
514
|
+
initial: reduce ? { opacity: 0 } : CHIP_HIDDEN,
|
|
515
|
+
animate: reduce ? { opacity: 1 } : CHIP_SHOWN,
|
|
516
|
+
exit: reduce ? {
|
|
517
|
+
opacity: 0,
|
|
518
|
+
transition: { duration: .1 }
|
|
519
|
+
} : {
|
|
520
|
+
...CHIP_HIDDEN,
|
|
521
|
+
transition: CHIP_EXIT
|
|
522
|
+
},
|
|
523
|
+
transition: reduce ? { duration: .12 } : CHIP_ENTER,
|
|
524
|
+
style: { transformOrigin: rtl ? "right center" : "left center" },
|
|
525
|
+
className: cn("flex h-9 shrink-0 items-center gap-1 rounded-full ps-3 pe-1 text-foreground text-sm transition-[background-color,box-shadow] duration-150", marked === chip ? "bg-foreground/12 ring-2 ring-foreground/40 ring-inset" : "bg-foreground/[0.07]"),
|
|
526
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
527
|
+
className: "max-w-40 truncate",
|
|
528
|
+
title: chip,
|
|
529
|
+
children: chip
|
|
530
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
531
|
+
type: "button",
|
|
532
|
+
disabled,
|
|
533
|
+
"aria-label": `Remove filter ${chip}`,
|
|
534
|
+
onClick: () => removeChip(chip),
|
|
535
|
+
className: "grid size-7 shrink-0 place-items-center rounded-full text-muted-foreground outline-none transition-colors hover:bg-foreground/10 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none",
|
|
536
|
+
children: /* @__PURE__ */ jsx(X, {
|
|
537
|
+
"aria-hidden": "true",
|
|
538
|
+
className: "size-3.5"
|
|
539
|
+
})
|
|
540
|
+
})]
|
|
541
|
+
}, chip))
|
|
542
|
+
})
|
|
543
|
+
}),
|
|
544
|
+
/* @__PURE__ */ jsx(motion.input, {
|
|
545
|
+
ref: inputRef,
|
|
546
|
+
layout: reduce ? false : "position",
|
|
547
|
+
transition: layout,
|
|
548
|
+
type: "text",
|
|
549
|
+
role: "combobox",
|
|
550
|
+
"aria-label": label,
|
|
551
|
+
"aria-expanded": panelOpen,
|
|
552
|
+
"aria-controls": panelOpen && showList ? listId : void 0,
|
|
553
|
+
"aria-autocomplete": "list",
|
|
554
|
+
"aria-activedescendant": activeOptionId,
|
|
555
|
+
"aria-describedby": hintId,
|
|
556
|
+
autoComplete: "off",
|
|
557
|
+
spellCheck: false,
|
|
558
|
+
enterKeyHint: "search",
|
|
559
|
+
disabled,
|
|
560
|
+
value: query,
|
|
561
|
+
placeholder,
|
|
562
|
+
onChange: (event) => {
|
|
563
|
+
setQuery(event.target.value);
|
|
564
|
+
if (!open) setOpen(true);
|
|
565
|
+
},
|
|
566
|
+
onFocus: () => setOpen(true),
|
|
567
|
+
onClick: () => setOpen(true),
|
|
568
|
+
onKeyDown,
|
|
569
|
+
style: open ? void 0 : { width: `${Math.max(placeholder.length, 6) + 2}ch` },
|
|
570
|
+
className: cn("h-9 min-w-24 text-ellipsis bg-transparent text-base text-foreground outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed", open && "flex-1")
|
|
571
|
+
}),
|
|
572
|
+
actions ? /* @__PURE__ */ jsx("div", {
|
|
573
|
+
className: "flex shrink-0 items-center gap-1",
|
|
574
|
+
children: actions
|
|
575
|
+
}) : null
|
|
576
|
+
]
|
|
577
|
+
}),
|
|
578
|
+
name ? chips.map((chip) => /* @__PURE__ */ jsx("input", {
|
|
579
|
+
type: "hidden",
|
|
580
|
+
name,
|
|
581
|
+
value: chip
|
|
582
|
+
}, chip)) : null,
|
|
583
|
+
/* @__PURE__ */ jsx("span", {
|
|
584
|
+
id: hintId,
|
|
585
|
+
className: "sr-only",
|
|
586
|
+
children: "Enter adds a filter. Backspace at the start of the field selects the last filter, and again removes it. Delete removes the highlighted recent search."
|
|
587
|
+
}),
|
|
588
|
+
/* @__PURE__ */ jsxs("span", {
|
|
589
|
+
"aria-live": "polite",
|
|
590
|
+
className: "sr-only",
|
|
591
|
+
children: [announcement.text, announcement.count % 2 ? "\xA0" : ""]
|
|
592
|
+
})
|
|
593
|
+
]
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
//#endregion
|
|
597
|
+
export { MorphingSearchChips };
|
|
598
|
+
|
|
599
|
+
//# sourceMappingURL=morphing-search-chips.js.map
|