@foundrykit/components 2.1.1 → 2.1.4
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/.turbo/turbo-build.log +14 -14
- package/.turbo/turbo-type-check.log +1 -1
- package/CHANGELOG.md +26 -0
- package/README.md +49 -145
- package/dist/index.d.ts +270 -60
- package/dist/index.js +2137 -1447
- package/dist/index.js.map +1 -1
- package/package.json +16 -9
- package/src/components/advanced-search-bar/index.tsx +121 -122
- package/src/components/calendar/config.ts +1 -1
- package/src/components/calendar/index.tsx +37 -25
- package/src/components/carousel/config.ts +28 -0
- package/src/components/carousel/index.tsx +258 -0
- package/src/components/chart/config.ts +28 -0
- package/src/components/chart/index.tsx +365 -0
- package/src/components/combobox/config.ts +28 -0
- package/src/components/combobox/index.tsx +101 -0
- package/src/components/command/config.ts +1 -1
- package/src/components/command/index.tsx +23 -12
- package/src/components/data-table/config.ts +28 -0
- package/src/components/data-table/index.tsx +124 -0
- package/src/components/date-picker/config.ts +1 -1
- package/src/components/date-picker/index.tsx +119 -51
- package/src/components/form/index.tsx +29 -11
- package/src/components/input-otp/config.ts +28 -0
- package/src/components/input-otp/index.tsx +92 -0
- package/src/components/pagination/config.ts +1 -1
- package/src/components/pagination/index.tsx +16 -8
- package/src/components/search-bar/config.ts +1 -1
- package/src/components/search-bar/index.tsx +9 -3
- package/src/components/sidebar/index.tsx +22 -25
- package/src/components/theme-toggle/index.tsx +2 -3
- package/src/index.ts +66 -37
- package/eslint.config.js +0 -4
package/dist/index.js
CHANGED
|
@@ -1,1558 +1,2012 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import { cn as cn12 } from "@foundrykit/utils";
|
|
5
|
+
|
|
6
|
+
// src/components/advanced-search-bar/index.tsx
|
|
7
|
+
import {
|
|
8
|
+
SearchContext,
|
|
9
|
+
useAdvancedSearch
|
|
10
|
+
} from "@foundrykit/hooks";
|
|
11
|
+
import {
|
|
12
|
+
Badge,
|
|
13
|
+
Button,
|
|
14
|
+
Input,
|
|
15
|
+
ScrollArea,
|
|
16
|
+
Separator
|
|
17
|
+
} from "@foundrykit/primitives";
|
|
5
18
|
import { cn } from "@foundrykit/utils";
|
|
19
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
20
|
+
import { cva } from "class-variance-authority";
|
|
21
|
+
import { ChevronDown, Search, X } from "lucide-react";
|
|
22
|
+
import * as React from "react";
|
|
6
23
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
|
|
24
|
+
function AdvancedSearchProvider({
|
|
25
|
+
children,
|
|
26
|
+
onSearch,
|
|
27
|
+
onResultSelect,
|
|
28
|
+
debounceMs = 300,
|
|
29
|
+
minQueryLength = 1,
|
|
30
|
+
emptyStateBehaviour = "show-empty-message",
|
|
31
|
+
initialResults = [],
|
|
32
|
+
styles = {
|
|
33
|
+
results: {
|
|
34
|
+
maxHeight: "24rem"
|
|
35
|
+
},
|
|
36
|
+
width: "100%"
|
|
37
|
+
}
|
|
38
|
+
}) {
|
|
39
|
+
const inputId = React.useId();
|
|
40
|
+
const resultsId = React.useId();
|
|
41
|
+
const [query, setQuery] = React.useState("");
|
|
42
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
43
|
+
const [results, setResults] = React.useState(initialResults);
|
|
44
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
45
|
+
const [activeIndex, setActiveIndex] = React.useState(-1);
|
|
46
|
+
const timeoutRef = React.useRef(null);
|
|
47
|
+
const requestIdRef = React.useRef(0);
|
|
48
|
+
React.useEffect(() => {
|
|
49
|
+
return () => {
|
|
50
|
+
if (timeoutRef.current) {
|
|
51
|
+
clearTimeout(timeoutRef.current);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}, []);
|
|
55
|
+
const handleSearch = React.useCallback(
|
|
56
|
+
(searchQuery) => {
|
|
57
|
+
if (timeoutRef.current) {
|
|
58
|
+
clearTimeout(timeoutRef.current);
|
|
59
|
+
}
|
|
60
|
+
setActiveIndex(-1);
|
|
61
|
+
const trimmedQuery = searchQuery.trim();
|
|
62
|
+
const isEmptyQuery = trimmedQuery.length === 0;
|
|
63
|
+
const isTooShort = trimmedQuery.length < minQueryLength;
|
|
64
|
+
if (isEmptyQuery || isTooShort || !onSearch) {
|
|
65
|
+
requestIdRef.current += 1;
|
|
66
|
+
setIsLoading(false);
|
|
67
|
+
setResults(
|
|
68
|
+
emptyStateBehaviour === "show-all-results" && (isEmptyQuery || isTooShort) ? initialResults : []
|
|
69
|
+
);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const requestId = requestIdRef.current + 1;
|
|
73
|
+
requestIdRef.current = requestId;
|
|
74
|
+
timeoutRef.current = setTimeout(async () => {
|
|
75
|
+
setIsLoading(true);
|
|
76
|
+
try {
|
|
77
|
+
const searchResults = await onSearch(trimmedQuery);
|
|
78
|
+
if (requestIdRef.current === requestId) {
|
|
79
|
+
setResults(searchResults);
|
|
80
|
+
}
|
|
81
|
+
} catch (error) {
|
|
82
|
+
if (requestIdRef.current === requestId) {
|
|
83
|
+
console.error("Search error:", error);
|
|
84
|
+
setResults([]);
|
|
85
|
+
}
|
|
86
|
+
} finally {
|
|
87
|
+
if (requestIdRef.current === requestId) {
|
|
88
|
+
setIsLoading(false);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}, debounceMs);
|
|
92
|
+
},
|
|
93
|
+
[debounceMs, emptyStateBehaviour, initialResults, minQueryLength, onSearch]
|
|
94
|
+
);
|
|
95
|
+
const handleResultSelect = React.useCallback(
|
|
96
|
+
(result) => {
|
|
97
|
+
onResultSelect?.(result);
|
|
98
|
+
setQuery(result.title);
|
|
99
|
+
setActiveIndex(-1);
|
|
100
|
+
setIsOpen(false);
|
|
101
|
+
},
|
|
102
|
+
[onResultSelect]
|
|
103
|
+
);
|
|
104
|
+
const value = React.useMemo(
|
|
105
|
+
() => ({
|
|
106
|
+
query,
|
|
107
|
+
setQuery,
|
|
108
|
+
isOpen,
|
|
109
|
+
setIsOpen,
|
|
110
|
+
inputId,
|
|
111
|
+
resultsId,
|
|
112
|
+
activeIndex,
|
|
113
|
+
setActiveIndex,
|
|
114
|
+
results,
|
|
115
|
+
setResults,
|
|
116
|
+
isLoading,
|
|
117
|
+
setIsLoading,
|
|
118
|
+
onSearch: handleSearch,
|
|
119
|
+
onResultSelect: handleResultSelect,
|
|
120
|
+
emptyStateBehaviour,
|
|
121
|
+
minQueryLength
|
|
122
|
+
}),
|
|
123
|
+
[
|
|
124
|
+
query,
|
|
125
|
+
isOpen,
|
|
126
|
+
inputId,
|
|
127
|
+
resultsId,
|
|
128
|
+
activeIndex,
|
|
129
|
+
results,
|
|
130
|
+
isLoading,
|
|
131
|
+
handleSearch,
|
|
132
|
+
handleResultSelect,
|
|
133
|
+
emptyStateBehaviour,
|
|
134
|
+
minQueryLength
|
|
135
|
+
]
|
|
136
|
+
);
|
|
137
|
+
return /* @__PURE__ */ jsx(SearchContext.Provider, { value, children: /* @__PURE__ */ jsx(
|
|
138
|
+
"div",
|
|
139
|
+
{
|
|
140
|
+
style: {
|
|
141
|
+
"--results-max-height": styles.results?.maxHeight ?? "24rem",
|
|
142
|
+
width: styles.width
|
|
143
|
+
},
|
|
144
|
+
children
|
|
145
|
+
}
|
|
146
|
+
) });
|
|
147
|
+
}
|
|
148
|
+
var searchInputWrapperVariants = cva("relative flex w-full items-center", {
|
|
149
|
+
variants: {
|
|
150
|
+
size: {
|
|
151
|
+
sm: "h-8",
|
|
152
|
+
md: "h-10",
|
|
153
|
+
lg: "h-12",
|
|
154
|
+
xl: "h-14"
|
|
155
|
+
},
|
|
156
|
+
variant: {
|
|
157
|
+
default: "border-input bg-background border",
|
|
158
|
+
ghost: "bg-transparent",
|
|
159
|
+
filled: "bg-muted"
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
defaultVariants: {
|
|
163
|
+
size: "md",
|
|
164
|
+
variant: "default"
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
var searchResultsVariants = cva("w-full", {
|
|
168
|
+
variants: {
|
|
169
|
+
size: {
|
|
170
|
+
sm: "max-w-sm",
|
|
171
|
+
md: "max-w-md",
|
|
172
|
+
lg: "max-w-lg",
|
|
173
|
+
xl: "max-w-xl",
|
|
174
|
+
"2xl": "max-w-2xl",
|
|
175
|
+
full: "max-w-full"
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
defaultVariants: {
|
|
179
|
+
size: "lg"
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
var SearchInput = React.forwardRef(
|
|
8
183
|
({
|
|
9
184
|
className,
|
|
10
|
-
|
|
185
|
+
size,
|
|
186
|
+
variant,
|
|
11
187
|
placeholder = "Search...",
|
|
12
|
-
|
|
13
|
-
|
|
188
|
+
showSearchIcon = true,
|
|
189
|
+
showClearButton = true,
|
|
190
|
+
onClear,
|
|
191
|
+
asChild = false,
|
|
14
192
|
...props
|
|
15
193
|
}, ref) => {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
194
|
+
const {
|
|
195
|
+
query,
|
|
196
|
+
setQuery,
|
|
197
|
+
onSearch,
|
|
198
|
+
onResultSelect,
|
|
199
|
+
results,
|
|
200
|
+
isOpen,
|
|
201
|
+
setIsOpen,
|
|
202
|
+
inputId,
|
|
203
|
+
resultsId,
|
|
204
|
+
activeIndex,
|
|
205
|
+
setActiveIndex,
|
|
206
|
+
emptyStateBehaviour,
|
|
207
|
+
minQueryLength
|
|
208
|
+
} = useAdvancedSearch();
|
|
209
|
+
const Comp = asChild ? Slot : "div";
|
|
19
210
|
const handleChange = (e) => {
|
|
20
211
|
const value = e.target.value;
|
|
21
|
-
|
|
22
|
-
|
|
212
|
+
setQuery(value);
|
|
213
|
+
if (emptyStateBehaviour === "hide-until-min-chars") {
|
|
214
|
+
setIsOpen(value.length >= minQueryLength);
|
|
215
|
+
} else {
|
|
216
|
+
setIsOpen(true);
|
|
23
217
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
/* @__PURE__ */ jsx(Search, { className: "text-muted-foreground absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2" }),
|
|
29
|
-
/* @__PURE__ */ jsx(
|
|
30
|
-
Input,
|
|
31
|
-
{
|
|
32
|
-
ref,
|
|
33
|
-
type: "search",
|
|
34
|
-
placeholder,
|
|
35
|
-
value: query,
|
|
36
|
-
onChange: handleChange,
|
|
37
|
-
className: "pl-10",
|
|
38
|
-
...props
|
|
39
|
-
}
|
|
40
|
-
)
|
|
41
|
-
] });
|
|
42
|
-
}
|
|
43
|
-
);
|
|
44
|
-
SearchBar.displayName = "SearchBar";
|
|
45
|
-
|
|
46
|
-
// src/components/date-picker/index.tsx
|
|
47
|
-
import * as React2 from "react";
|
|
48
|
-
import { Calendar as CalendarIcon } from "lucide-react";
|
|
49
|
-
import { format } from "date-fns";
|
|
50
|
-
import { Button } from "@foundrykit/primitives";
|
|
51
|
-
import { Input as Input2 } from "@foundrykit/primitives";
|
|
52
|
-
import { cn as cn2 } from "@foundrykit/utils";
|
|
53
|
-
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
54
|
-
var DatePicker = React2.forwardRef(
|
|
55
|
-
({ value, onValueChange, placeholder = "Pick a date", className, disabled }, ref) => {
|
|
56
|
-
const [open, setOpen] = React2.useState(false);
|
|
57
|
-
const [selectedDate, setSelectedDate] = React2.useState(
|
|
58
|
-
value
|
|
59
|
-
);
|
|
60
|
-
const handleDateSelect = (date) => {
|
|
61
|
-
setSelectedDate(date);
|
|
62
|
-
onValueChange?.(date);
|
|
63
|
-
setOpen(false);
|
|
218
|
+
setTimeout(() => {
|
|
219
|
+
onSearch(value);
|
|
220
|
+
}, 0);
|
|
221
|
+
props.onChange?.(e);
|
|
64
222
|
};
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const date = new Date(inputValue);
|
|
69
|
-
if (!isNaN(date.getTime())) {
|
|
70
|
-
setSelectedDate(date);
|
|
71
|
-
onValueChange?.(date);
|
|
72
|
-
}
|
|
223
|
+
const handleFocus = (e) => {
|
|
224
|
+
if (emptyStateBehaviour === "hide-until-min-chars") {
|
|
225
|
+
setIsOpen(query.length >= minQueryLength);
|
|
73
226
|
} else {
|
|
74
|
-
|
|
75
|
-
onValueChange?.(void 0);
|
|
227
|
+
setIsOpen(true);
|
|
76
228
|
}
|
|
229
|
+
props.onFocus?.(e);
|
|
77
230
|
};
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const startingDayOfWeek = firstDay.getDay();
|
|
86
|
-
const days = [];
|
|
87
|
-
for (let i = 0; i < startingDayOfWeek; i++) {
|
|
88
|
-
days.push(null);
|
|
89
|
-
}
|
|
90
|
-
for (let day = 1; day <= daysInMonth; day++) {
|
|
91
|
-
days.push(new Date(currentYear, currentMonth, day));
|
|
92
|
-
}
|
|
93
|
-
return days;
|
|
231
|
+
const handleClear = () => {
|
|
232
|
+
setQuery("");
|
|
233
|
+
setActiveIndex(-1);
|
|
234
|
+
setTimeout(() => {
|
|
235
|
+
onSearch("");
|
|
236
|
+
}, 0);
|
|
237
|
+
onClear?.();
|
|
94
238
|
};
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
type: "date",
|
|
103
|
-
value: selectedDate ? format(selectedDate, "yyyy-MM-dd") : "",
|
|
104
|
-
onChange: handleInputChange,
|
|
105
|
-
placeholder,
|
|
106
|
-
disabled,
|
|
107
|
-
className: "flex-1"
|
|
108
|
-
}
|
|
109
|
-
),
|
|
110
|
-
/* @__PURE__ */ jsx2(
|
|
111
|
-
Button,
|
|
112
|
-
{
|
|
113
|
-
variant: "outline",
|
|
114
|
-
onClick: () => setOpen(!open),
|
|
115
|
-
disabled,
|
|
116
|
-
className: "px-3",
|
|
117
|
-
children: /* @__PURE__ */ jsx2(CalendarIcon, { className: "h-4 w-4" })
|
|
118
|
-
}
|
|
119
|
-
)
|
|
120
|
-
] }),
|
|
121
|
-
open && /* @__PURE__ */ jsxs2("div", { className: "bg-popover absolute top-full z-50 mt-1 w-80 rounded-md border p-3 shadow-md", children: [
|
|
122
|
-
/* @__PURE__ */ jsx2("div", { className: "mb-2 grid grid-cols-7 gap-1 text-center text-sm font-medium", children: weekDays.map((day) => /* @__PURE__ */ jsx2("div", { className: "p-1", children: day }, day)) }),
|
|
123
|
-
/* @__PURE__ */ jsx2("div", { className: "grid grid-cols-7 gap-1", children: calendarDays.map((day, index) => /* @__PURE__ */ jsx2(
|
|
124
|
-
"button",
|
|
125
|
-
{
|
|
126
|
-
className: cn2(
|
|
127
|
-
"hover:bg-accent hover:text-accent-foreground rounded p-2 text-sm",
|
|
128
|
-
day && selectedDate && day.toDateString() === selectedDate.toDateString() ? "bg-primary text-primary-foreground" : day && day.toDateString() === (/* @__PURE__ */ new Date()).toDateString() ? "bg-muted" : "text-muted-foreground"
|
|
129
|
-
),
|
|
130
|
-
onClick: () => day && handleDateSelect(day),
|
|
131
|
-
disabled: !day,
|
|
132
|
-
children: day ? day.getDate() : ""
|
|
133
|
-
},
|
|
134
|
-
index
|
|
135
|
-
)) })
|
|
136
|
-
] })
|
|
137
|
-
] });
|
|
138
|
-
}
|
|
139
|
-
);
|
|
140
|
-
DatePicker.displayName = "DatePicker";
|
|
141
|
-
|
|
142
|
-
// src/components/calendar/index.tsx
|
|
143
|
-
import * as React3 from "react";
|
|
144
|
-
import {
|
|
145
|
-
ChevronDownIcon,
|
|
146
|
-
ChevronLeftIcon,
|
|
147
|
-
ChevronRightIcon
|
|
148
|
-
} from "lucide-react";
|
|
149
|
-
import { DayPicker, getDefaultClassNames } from "react-day-picker";
|
|
150
|
-
import { Button as Button2, buttonVariants } from "@foundrykit/primitives";
|
|
151
|
-
import { cn as cn3 } from "@foundrykit/utils";
|
|
152
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
153
|
-
function Calendar({
|
|
154
|
-
className,
|
|
155
|
-
classNames,
|
|
156
|
-
showOutsideDays = true,
|
|
157
|
-
captionLayout = "label",
|
|
158
|
-
buttonVariant = "ghost",
|
|
159
|
-
formatters,
|
|
160
|
-
components,
|
|
161
|
-
...props
|
|
162
|
-
}) {
|
|
163
|
-
const defaultClassNames = getDefaultClassNames();
|
|
164
|
-
return /* @__PURE__ */ jsx3(
|
|
165
|
-
DayPicker,
|
|
166
|
-
{
|
|
167
|
-
showOutsideDays,
|
|
168
|
-
className: cn3(
|
|
169
|
-
"bg-background group/calendar p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
|
|
170
|
-
String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
|
|
171
|
-
String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
|
|
172
|
-
className
|
|
173
|
-
),
|
|
174
|
-
captionLayout,
|
|
175
|
-
formatters: {
|
|
176
|
-
formatMonthDropdown: (date) => date.toLocaleString("default", { month: "short" }),
|
|
177
|
-
...formatters
|
|
178
|
-
},
|
|
179
|
-
classNames: {
|
|
180
|
-
root: cn3("w-fit", defaultClassNames.root),
|
|
181
|
-
months: cn3(
|
|
182
|
-
"flex gap-4 flex-col md:flex-row relative",
|
|
183
|
-
defaultClassNames.months
|
|
184
|
-
),
|
|
185
|
-
month: cn3("flex flex-col w-full gap-4", defaultClassNames.month),
|
|
186
|
-
nav: cn3(
|
|
187
|
-
"flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between",
|
|
188
|
-
defaultClassNames.nav
|
|
189
|
-
),
|
|
190
|
-
button_previous: cn3(
|
|
191
|
-
buttonVariants({ variant: buttonVariant }),
|
|
192
|
-
"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",
|
|
193
|
-
defaultClassNames.button_previous
|
|
194
|
-
),
|
|
195
|
-
button_next: cn3(
|
|
196
|
-
buttonVariants({ variant: buttonVariant }),
|
|
197
|
-
"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",
|
|
198
|
-
defaultClassNames.button_next
|
|
199
|
-
),
|
|
200
|
-
month_caption: cn3(
|
|
201
|
-
"flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)",
|
|
202
|
-
defaultClassNames.month_caption
|
|
203
|
-
),
|
|
204
|
-
dropdowns: cn3(
|
|
205
|
-
"w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5",
|
|
206
|
-
defaultClassNames.dropdowns
|
|
207
|
-
),
|
|
208
|
-
dropdown_root: cn3(
|
|
209
|
-
"relative has-focus:border-ring border border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] rounded-md",
|
|
210
|
-
defaultClassNames.dropdown_root
|
|
211
|
-
),
|
|
212
|
-
dropdown: cn3(
|
|
213
|
-
"absolute bg-popover inset-0 opacity-0",
|
|
214
|
-
defaultClassNames.dropdown
|
|
215
|
-
),
|
|
216
|
-
caption_label: cn3(
|
|
217
|
-
"select-none font-medium",
|
|
218
|
-
captionLayout === "label" ? "text-sm" : "rounded-md pl-2 pr-1 flex items-center gap-1 text-sm h-8 [&>svg]:text-muted-foreground [&>svg]:size-3.5",
|
|
219
|
-
defaultClassNames.caption_label
|
|
220
|
-
),
|
|
221
|
-
table: "w-full border-collapse",
|
|
222
|
-
weekdays: cn3("flex", defaultClassNames.weekdays),
|
|
223
|
-
weekday: cn3(
|
|
224
|
-
"text-muted-foreground rounded-md flex-1 font-normal text-[0.8rem] select-none",
|
|
225
|
-
defaultClassNames.weekday
|
|
226
|
-
),
|
|
227
|
-
week: cn3("flex w-full mt-2", defaultClassNames.week),
|
|
228
|
-
week_number_header: cn3(
|
|
229
|
-
"select-none w-(--cell-size)",
|
|
230
|
-
defaultClassNames.week_number_header
|
|
231
|
-
),
|
|
232
|
-
week_number: cn3(
|
|
233
|
-
"text-[0.8rem] select-none text-muted-foreground",
|
|
234
|
-
defaultClassNames.week_number
|
|
235
|
-
),
|
|
236
|
-
day: cn3(
|
|
237
|
-
"relative w-full h-full p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md group/day aspect-square select-none",
|
|
238
|
-
defaultClassNames.day
|
|
239
|
-
),
|
|
240
|
-
range_start: cn3(
|
|
241
|
-
"rounded-l-md bg-accent",
|
|
242
|
-
defaultClassNames.range_start
|
|
243
|
-
),
|
|
244
|
-
range_middle: cn3("rounded-none", defaultClassNames.range_middle),
|
|
245
|
-
range_end: cn3("rounded-r-md bg-accent", defaultClassNames.range_end),
|
|
246
|
-
today: cn3(
|
|
247
|
-
"bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",
|
|
248
|
-
defaultClassNames.today
|
|
249
|
-
),
|
|
250
|
-
outside: cn3(
|
|
251
|
-
"text-muted-foreground aria-selected:text-muted-foreground",
|
|
252
|
-
defaultClassNames.outside
|
|
253
|
-
),
|
|
254
|
-
disabled: cn3(
|
|
255
|
-
"text-muted-foreground opacity-50",
|
|
256
|
-
defaultClassNames.disabled
|
|
257
|
-
),
|
|
258
|
-
hidden: cn3("invisible", defaultClassNames.hidden),
|
|
259
|
-
...classNames
|
|
260
|
-
},
|
|
261
|
-
components: {
|
|
262
|
-
Root: ({ className: className2, rootRef, ...props2 }) => {
|
|
263
|
-
return /* @__PURE__ */ jsx3(
|
|
264
|
-
"div",
|
|
265
|
-
{
|
|
266
|
-
"data-slot": "calendar",
|
|
267
|
-
ref: rootRef,
|
|
268
|
-
className: cn3(className2),
|
|
269
|
-
...props2
|
|
270
|
-
}
|
|
271
|
-
);
|
|
272
|
-
},
|
|
273
|
-
Chevron: ({ className: className2, orientation, ...props2 }) => {
|
|
274
|
-
if (orientation === "left") {
|
|
275
|
-
return /* @__PURE__ */ jsx3(ChevronLeftIcon, { className: cn3("size-4", className2), ...props2 });
|
|
276
|
-
}
|
|
277
|
-
if (orientation === "right") {
|
|
278
|
-
return /* @__PURE__ */ jsx3(
|
|
279
|
-
ChevronRightIcon,
|
|
280
|
-
{
|
|
281
|
-
className: cn3("size-4", className2),
|
|
282
|
-
...props2
|
|
283
|
-
}
|
|
284
|
-
);
|
|
285
|
-
}
|
|
286
|
-
return /* @__PURE__ */ jsx3(ChevronDownIcon, { className: cn3("size-4", className2), ...props2 });
|
|
287
|
-
},
|
|
288
|
-
DayButton: CalendarDayButton,
|
|
289
|
-
WeekNumber: ({ children, ...props2 }) => {
|
|
290
|
-
return /* @__PURE__ */ jsx3("td", { ...props2, children: /* @__PURE__ */ jsx3("div", { className: "size-(--cell-size) flex items-center justify-center text-center", children }) });
|
|
291
|
-
},
|
|
292
|
-
...components
|
|
293
|
-
},
|
|
294
|
-
...props
|
|
295
|
-
}
|
|
296
|
-
);
|
|
297
|
-
}
|
|
298
|
-
function CalendarDayButton({
|
|
299
|
-
className,
|
|
300
|
-
day,
|
|
301
|
-
modifiers,
|
|
302
|
-
...props
|
|
303
|
-
}) {
|
|
304
|
-
const defaultClassNames = getDefaultClassNames();
|
|
305
|
-
const ref = React3.useRef(null);
|
|
306
|
-
React3.useEffect(() => {
|
|
307
|
-
if (modifiers.focused) ref.current?.focus();
|
|
308
|
-
}, [modifiers.focused]);
|
|
309
|
-
return /* @__PURE__ */ jsx3(
|
|
310
|
-
Button2,
|
|
311
|
-
{
|
|
312
|
-
ref,
|
|
313
|
-
variant: "ghost",
|
|
314
|
-
size: "icon",
|
|
315
|
-
"data-day": day.date.toLocaleDateString(),
|
|
316
|
-
"data-selected-single": modifiers.selected && !modifiers.range_start && !modifiers.range_end && !modifiers.range_middle,
|
|
317
|
-
"data-range-start": modifiers.range_start,
|
|
318
|
-
"data-range-end": modifiers.range_end,
|
|
319
|
-
"data-range-middle": modifiers.range_middle,
|
|
320
|
-
className: cn3(
|
|
321
|
-
"data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 dark:hover:text-accent-foreground min-w-(--cell-size) flex aspect-square size-auto w-full flex-col gap-1 font-normal leading-none data-[range-end=true]:rounded-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-start=true]:rounded-l-md group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] [&>span]:text-xs [&>span]:opacity-70",
|
|
322
|
-
defaultClassNames.day,
|
|
323
|
-
className
|
|
324
|
-
),
|
|
325
|
-
...props
|
|
326
|
-
}
|
|
327
|
-
);
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// src/components/pagination/index.tsx
|
|
331
|
-
import {
|
|
332
|
-
ChevronLeftIcon as ChevronLeftIcon2,
|
|
333
|
-
ChevronRightIcon as ChevronRightIcon2,
|
|
334
|
-
MoreHorizontalIcon
|
|
335
|
-
} from "lucide-react";
|
|
336
|
-
import { cn as cn4 } from "@foundrykit/utils";
|
|
337
|
-
import { buttonVariants as buttonVariants2 } from "@foundrykit/primitives";
|
|
338
|
-
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
339
|
-
function Pagination({ className, ...props }) {
|
|
340
|
-
return /* @__PURE__ */ jsx4(
|
|
341
|
-
"nav",
|
|
342
|
-
{
|
|
343
|
-
role: "navigation",
|
|
344
|
-
"aria-label": "pagination",
|
|
345
|
-
"data-slot": "pagination",
|
|
346
|
-
className: cn4("mx-auto flex w-full justify-center", className),
|
|
347
|
-
...props
|
|
348
|
-
}
|
|
349
|
-
);
|
|
350
|
-
}
|
|
351
|
-
function PaginationContent({
|
|
352
|
-
className,
|
|
353
|
-
...props
|
|
354
|
-
}) {
|
|
355
|
-
return /* @__PURE__ */ jsx4(
|
|
356
|
-
"ul",
|
|
357
|
-
{
|
|
358
|
-
"data-slot": "pagination-content",
|
|
359
|
-
className: cn4("flex flex-row items-center gap-1", className),
|
|
360
|
-
...props
|
|
361
|
-
}
|
|
362
|
-
);
|
|
363
|
-
}
|
|
364
|
-
function PaginationItem({ ...props }) {
|
|
365
|
-
return /* @__PURE__ */ jsx4("li", { "data-slot": "pagination-item", ...props });
|
|
366
|
-
}
|
|
367
|
-
function PaginationLink({
|
|
368
|
-
className,
|
|
369
|
-
isActive,
|
|
370
|
-
size = "icon",
|
|
371
|
-
...props
|
|
372
|
-
}) {
|
|
373
|
-
return /* @__PURE__ */ jsx4(
|
|
374
|
-
"a",
|
|
375
|
-
{
|
|
376
|
-
"aria-current": isActive ? "page" : void 0,
|
|
377
|
-
"data-slot": "pagination-link",
|
|
378
|
-
"data-active": isActive,
|
|
379
|
-
className: cn4(
|
|
380
|
-
buttonVariants2({
|
|
381
|
-
variant: isActive ? "outline" : "ghost",
|
|
382
|
-
size
|
|
383
|
-
}),
|
|
384
|
-
className
|
|
385
|
-
),
|
|
386
|
-
...props
|
|
387
|
-
}
|
|
388
|
-
);
|
|
389
|
-
}
|
|
390
|
-
function PaginationPrevious({
|
|
391
|
-
className,
|
|
392
|
-
...props
|
|
393
|
-
}) {
|
|
394
|
-
return /* @__PURE__ */ jsxs3(
|
|
395
|
-
PaginationLink,
|
|
396
|
-
{
|
|
397
|
-
"aria-label": "Go to previous page",
|
|
398
|
-
size: "default",
|
|
399
|
-
className: cn4("gap-1 px-2.5 sm:pl-2.5", className),
|
|
400
|
-
...props,
|
|
401
|
-
children: [
|
|
402
|
-
/* @__PURE__ */ jsx4(ChevronLeftIcon2, {}),
|
|
403
|
-
/* @__PURE__ */ jsx4("span", { className: "hidden sm:block", children: "Previous" })
|
|
404
|
-
]
|
|
405
|
-
}
|
|
406
|
-
);
|
|
407
|
-
}
|
|
408
|
-
function PaginationNext({
|
|
409
|
-
className,
|
|
410
|
-
...props
|
|
411
|
-
}) {
|
|
412
|
-
return /* @__PURE__ */ jsxs3(
|
|
413
|
-
PaginationLink,
|
|
414
|
-
{
|
|
415
|
-
"aria-label": "Go to next page",
|
|
416
|
-
size: "default",
|
|
417
|
-
className: cn4("gap-1 px-2.5 sm:pr-2.5", className),
|
|
418
|
-
...props,
|
|
419
|
-
children: [
|
|
420
|
-
/* @__PURE__ */ jsx4("span", { className: "hidden sm:block", children: "Next" }),
|
|
421
|
-
/* @__PURE__ */ jsx4(ChevronRightIcon2, {})
|
|
422
|
-
]
|
|
423
|
-
}
|
|
424
|
-
);
|
|
425
|
-
}
|
|
426
|
-
function PaginationEllipsis({
|
|
427
|
-
className,
|
|
428
|
-
...props
|
|
429
|
-
}) {
|
|
430
|
-
return /* @__PURE__ */ jsxs3(
|
|
431
|
-
"span",
|
|
432
|
-
{
|
|
433
|
-
"aria-hidden": true,
|
|
434
|
-
"data-slot": "pagination-ellipsis",
|
|
435
|
-
className: cn4("flex size-9 items-center justify-center", className),
|
|
436
|
-
...props,
|
|
437
|
-
children: [
|
|
438
|
-
/* @__PURE__ */ jsx4(MoreHorizontalIcon, { className: "size-4" }),
|
|
439
|
-
/* @__PURE__ */ jsx4("span", { className: "sr-only", children: "More pages" })
|
|
440
|
-
]
|
|
441
|
-
}
|
|
442
|
-
);
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
// src/components/command/index.tsx
|
|
446
|
-
import { Command as CommandPrimitive } from "cmdk";
|
|
447
|
-
import { SearchIcon } from "lucide-react";
|
|
448
|
-
import { cn as cn5 } from "@foundrykit/utils";
|
|
449
|
-
import {
|
|
450
|
-
Dialog,
|
|
451
|
-
DialogContent,
|
|
452
|
-
DialogDescription,
|
|
453
|
-
DialogHeader,
|
|
454
|
-
DialogTitle
|
|
455
|
-
} from "@foundrykit/primitives";
|
|
456
|
-
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
457
|
-
function Command({
|
|
458
|
-
className,
|
|
459
|
-
...props
|
|
460
|
-
}) {
|
|
461
|
-
return /* @__PURE__ */ jsx5(
|
|
462
|
-
CommandPrimitive,
|
|
463
|
-
{
|
|
464
|
-
"data-slot": "command",
|
|
465
|
-
className: cn5(
|
|
466
|
-
"bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",
|
|
467
|
-
className
|
|
468
|
-
),
|
|
469
|
-
...props
|
|
470
|
-
}
|
|
471
|
-
);
|
|
472
|
-
}
|
|
473
|
-
function CommandDialog({
|
|
474
|
-
title = "Command Palette",
|
|
475
|
-
description = "Search for a command to run...",
|
|
476
|
-
children,
|
|
477
|
-
className,
|
|
478
|
-
showCloseButton = true,
|
|
479
|
-
...props
|
|
480
|
-
}) {
|
|
481
|
-
return /* @__PURE__ */ jsxs4(Dialog, { ...props, children: [
|
|
482
|
-
/* @__PURE__ */ jsxs4(DialogHeader, { className: "sr-only", children: [
|
|
483
|
-
/* @__PURE__ */ jsx5(DialogTitle, { children: title }),
|
|
484
|
-
/* @__PURE__ */ jsx5(DialogDescription, { children: description })
|
|
485
|
-
] }),
|
|
486
|
-
/* @__PURE__ */ jsx5(
|
|
487
|
-
DialogContent,
|
|
488
|
-
{
|
|
489
|
-
className: cn5("overflow-hidden p-0", className),
|
|
490
|
-
showCloseButton,
|
|
491
|
-
children: /* @__PURE__ */ jsx5(Command, { className: "[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5", children })
|
|
492
|
-
}
|
|
493
|
-
)
|
|
494
|
-
] });
|
|
495
|
-
}
|
|
496
|
-
function CommandInput({
|
|
497
|
-
className,
|
|
498
|
-
...props
|
|
499
|
-
}) {
|
|
500
|
-
return /* @__PURE__ */ jsxs4(
|
|
501
|
-
"div",
|
|
502
|
-
{
|
|
503
|
-
"data-slot": "command-input-wrapper",
|
|
504
|
-
className: "flex h-9 items-center gap-2 border-b px-3",
|
|
505
|
-
children: [
|
|
506
|
-
/* @__PURE__ */ jsx5(SearchIcon, { className: "size-4 shrink-0 opacity-50" }),
|
|
507
|
-
/* @__PURE__ */ jsx5(
|
|
508
|
-
CommandPrimitive.Input,
|
|
509
|
-
{
|
|
510
|
-
"data-slot": "command-input",
|
|
511
|
-
className: cn5(
|
|
512
|
-
"placeholder:text-muted-foreground outline-hidden flex h-10 w-full rounded-md bg-transparent py-3 text-sm disabled:cursor-not-allowed disabled:opacity-50",
|
|
513
|
-
className
|
|
514
|
-
),
|
|
515
|
-
...props
|
|
516
|
-
}
|
|
517
|
-
)
|
|
518
|
-
]
|
|
519
|
-
}
|
|
520
|
-
);
|
|
521
|
-
}
|
|
522
|
-
function CommandList({
|
|
523
|
-
className,
|
|
524
|
-
...props
|
|
525
|
-
}) {
|
|
526
|
-
return /* @__PURE__ */ jsx5(
|
|
527
|
-
CommandPrimitive.List,
|
|
528
|
-
{
|
|
529
|
-
"data-slot": "command-list",
|
|
530
|
-
className: cn5(
|
|
531
|
-
"max-h-[300px] scroll-py-1 overflow-y-auto overflow-x-hidden",
|
|
532
|
-
className
|
|
533
|
-
),
|
|
534
|
-
...props
|
|
535
|
-
}
|
|
536
|
-
);
|
|
537
|
-
}
|
|
538
|
-
function CommandEmpty({
|
|
539
|
-
...props
|
|
540
|
-
}) {
|
|
541
|
-
return /* @__PURE__ */ jsx5(
|
|
542
|
-
CommandPrimitive.Empty,
|
|
543
|
-
{
|
|
544
|
-
"data-slot": "command-empty",
|
|
545
|
-
className: "py-6 text-center text-sm",
|
|
546
|
-
...props
|
|
547
|
-
}
|
|
548
|
-
);
|
|
549
|
-
}
|
|
550
|
-
function CommandGroup({
|
|
551
|
-
className,
|
|
552
|
-
...props
|
|
553
|
-
}) {
|
|
554
|
-
return /* @__PURE__ */ jsx5(
|
|
555
|
-
CommandPrimitive.Group,
|
|
556
|
-
{
|
|
557
|
-
"data-slot": "command-group",
|
|
558
|
-
className: cn5(
|
|
559
|
-
"text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",
|
|
560
|
-
className
|
|
561
|
-
),
|
|
562
|
-
...props
|
|
563
|
-
}
|
|
564
|
-
);
|
|
565
|
-
}
|
|
566
|
-
function CommandSeparator({
|
|
567
|
-
className,
|
|
568
|
-
...props
|
|
569
|
-
}) {
|
|
570
|
-
return /* @__PURE__ */ jsx5(
|
|
571
|
-
CommandPrimitive.Separator,
|
|
572
|
-
{
|
|
573
|
-
"data-slot": "command-separator",
|
|
574
|
-
className: cn5("bg-border -mx-1 h-px", className),
|
|
575
|
-
...props
|
|
576
|
-
}
|
|
577
|
-
);
|
|
578
|
-
}
|
|
579
|
-
function CommandItem({
|
|
580
|
-
className,
|
|
581
|
-
...props
|
|
582
|
-
}) {
|
|
583
|
-
return /* @__PURE__ */ jsx5(
|
|
584
|
-
CommandPrimitive.Item,
|
|
585
|
-
{
|
|
586
|
-
"data-slot": "command-item",
|
|
587
|
-
className: cn5(
|
|
588
|
-
"data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground outline-hidden relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
589
|
-
className
|
|
590
|
-
),
|
|
591
|
-
...props
|
|
592
|
-
}
|
|
593
|
-
);
|
|
594
|
-
}
|
|
595
|
-
function CommandShortcut({
|
|
596
|
-
className,
|
|
597
|
-
...props
|
|
598
|
-
}) {
|
|
599
|
-
return /* @__PURE__ */ jsx5(
|
|
600
|
-
"span",
|
|
601
|
-
{
|
|
602
|
-
"data-slot": "command-shortcut",
|
|
603
|
-
className: cn5(
|
|
604
|
-
"text-muted-foreground ml-auto text-xs tracking-widest",
|
|
605
|
-
className
|
|
606
|
-
),
|
|
607
|
-
...props
|
|
608
|
-
}
|
|
609
|
-
);
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
// src/components/advanced-search-bar/index.tsx
|
|
613
|
-
import * as React4 from "react";
|
|
614
|
-
import { Slot } from "@radix-ui/react-slot";
|
|
615
|
-
|
|
616
|
-
// ../../node_modules/class-variance-authority/dist/index.mjs
|
|
617
|
-
import { clsx } from "clsx";
|
|
618
|
-
var falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
|
|
619
|
-
var cx = clsx;
|
|
620
|
-
var cva = (base, config) => (props) => {
|
|
621
|
-
var _config_compoundVariants;
|
|
622
|
-
if ((config === null || config === void 0 ? void 0 : config.variants) == null) return cx(base, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
|
|
623
|
-
const { variants, defaultVariants } = config;
|
|
624
|
-
const getVariantClassNames = Object.keys(variants).map((variant) => {
|
|
625
|
-
const variantProp = props === null || props === void 0 ? void 0 : props[variant];
|
|
626
|
-
const defaultVariantProp = defaultVariants === null || defaultVariants === void 0 ? void 0 : defaultVariants[variant];
|
|
627
|
-
if (variantProp === null) return null;
|
|
628
|
-
const variantKey = falsyToString(variantProp) || falsyToString(defaultVariantProp);
|
|
629
|
-
return variants[variant][variantKey];
|
|
630
|
-
});
|
|
631
|
-
const propsWithoutUndefined = props && Object.entries(props).reduce((acc, param) => {
|
|
632
|
-
let [key, value] = param;
|
|
633
|
-
if (value === void 0) {
|
|
634
|
-
return acc;
|
|
635
|
-
}
|
|
636
|
-
acc[key] = value;
|
|
637
|
-
return acc;
|
|
638
|
-
}, {});
|
|
639
|
-
const getCompoundVariantClassNames = config === null || config === void 0 ? void 0 : (_config_compoundVariants = config.compoundVariants) === null || _config_compoundVariants === void 0 ? void 0 : _config_compoundVariants.reduce((acc, param) => {
|
|
640
|
-
let { class: cvClass, className: cvClassName, ...compoundVariantOptions } = param;
|
|
641
|
-
return Object.entries(compoundVariantOptions).every((param2) => {
|
|
642
|
-
let [key, value] = param2;
|
|
643
|
-
return Array.isArray(value) ? value.includes({
|
|
644
|
-
...defaultVariants,
|
|
645
|
-
...propsWithoutUndefined
|
|
646
|
-
}[key]) : {
|
|
647
|
-
...defaultVariants,
|
|
648
|
-
...propsWithoutUndefined
|
|
649
|
-
}[key] === value;
|
|
650
|
-
}) ? [
|
|
651
|
-
...acc,
|
|
652
|
-
cvClass,
|
|
653
|
-
cvClassName
|
|
654
|
-
] : acc;
|
|
655
|
-
}, []);
|
|
656
|
-
return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
|
|
657
|
-
};
|
|
658
|
-
|
|
659
|
-
// src/components/advanced-search-bar/index.tsx
|
|
660
|
-
import { Search as Search2, X, ChevronDown } from "lucide-react";
|
|
661
|
-
import { cn as cn6 } from "@foundrykit/utils";
|
|
662
|
-
import {
|
|
663
|
-
useAdvancedSearch,
|
|
664
|
-
SearchContext
|
|
665
|
-
} from "@foundrykit/hooks";
|
|
666
|
-
import { Input as Input3 } from "@foundrykit/primitives";
|
|
667
|
-
import { Button as Button4 } from "@foundrykit/primitives";
|
|
668
|
-
import { Separator } from "@foundrykit/primitives";
|
|
669
|
-
import { Badge } from "@foundrykit/primitives";
|
|
670
|
-
import { ScrollArea } from "@foundrykit/primitives";
|
|
671
|
-
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
672
|
-
function AdvancedSearchProvider({
|
|
673
|
-
children,
|
|
674
|
-
onSearch,
|
|
675
|
-
onResultSelect,
|
|
676
|
-
debounceMs = 300,
|
|
677
|
-
minQueryLength = 1,
|
|
678
|
-
emptyStateBehaviour = "show-empty-message",
|
|
679
|
-
initialResults = [],
|
|
680
|
-
styles = {
|
|
681
|
-
results: {
|
|
682
|
-
maxHeight: "24rem"
|
|
683
|
-
},
|
|
684
|
-
width: "100%"
|
|
685
|
-
}
|
|
686
|
-
}) {
|
|
687
|
-
const inputId = React4.useId();
|
|
688
|
-
const resultsId = React4.useId();
|
|
689
|
-
const [query, setQuery] = React4.useState("");
|
|
690
|
-
const [isOpen, setIsOpen] = React4.useState(false);
|
|
691
|
-
const [results, setResults] = React4.useState(initialResults);
|
|
692
|
-
const [isLoading, setIsLoading] = React4.useState(false);
|
|
693
|
-
const [activeIndex, setActiveIndex] = React4.useState(-1);
|
|
694
|
-
const timeoutRef = React4.useRef(null);
|
|
695
|
-
const requestIdRef = React4.useRef(0);
|
|
696
|
-
React4.useEffect(() => {
|
|
697
|
-
return () => {
|
|
698
|
-
if (timeoutRef.current) {
|
|
699
|
-
clearTimeout(timeoutRef.current);
|
|
239
|
+
const handleKeyDown = (e) => {
|
|
240
|
+
props.onKeyDown?.(e);
|
|
241
|
+
if (e.defaultPrevented) return;
|
|
242
|
+
if (e.key === "Escape") {
|
|
243
|
+
setIsOpen(false);
|
|
244
|
+
setActiveIndex(-1);
|
|
245
|
+
return;
|
|
700
246
|
}
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
247
|
+
if (e.key === "ArrowDown") {
|
|
248
|
+
e.preventDefault();
|
|
249
|
+
setIsOpen(true);
|
|
250
|
+
setActiveIndex(
|
|
251
|
+
results.length ? (activeIndex + 1) % results.length : -1
|
|
252
|
+
);
|
|
253
|
+
return;
|
|
707
254
|
}
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
requestIdRef.current += 1;
|
|
714
|
-
setIsLoading(false);
|
|
715
|
-
setResults(
|
|
716
|
-
emptyStateBehaviour === "show-all-results" && (isEmptyQuery || isTooShort) ? initialResults : []
|
|
255
|
+
if (e.key === "ArrowUp") {
|
|
256
|
+
e.preventDefault();
|
|
257
|
+
setIsOpen(true);
|
|
258
|
+
setActiveIndex(
|
|
259
|
+
results.length ? activeIndex <= 0 ? results.length - 1 : activeIndex - 1 : -1
|
|
717
260
|
);
|
|
718
261
|
return;
|
|
719
262
|
}
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
263
|
+
if (e.key === "Home") {
|
|
264
|
+
if (!results.length) return;
|
|
265
|
+
e.preventDefault();
|
|
266
|
+
setActiveIndex(0);
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
if (e.key === "End") {
|
|
270
|
+
if (!results.length) return;
|
|
271
|
+
e.preventDefault();
|
|
272
|
+
setActiveIndex(results.length - 1);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
if (e.key === "Enter" && activeIndex >= 0 && results[activeIndex]) {
|
|
276
|
+
e.preventDefault();
|
|
277
|
+
onResultSelect(results[activeIndex]);
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
return /* @__PURE__ */ jsxs(
|
|
281
|
+
Comp,
|
|
282
|
+
{
|
|
283
|
+
className: cn(
|
|
284
|
+
searchInputWrapperVariants({ size, variant }),
|
|
285
|
+
"rounded-md",
|
|
286
|
+
className
|
|
287
|
+
),
|
|
288
|
+
onClick: (e) => {
|
|
289
|
+
if (e.target !== e.currentTarget) return;
|
|
290
|
+
const input = e.currentTarget.querySelector("input");
|
|
291
|
+
input?.focus();
|
|
292
|
+
},
|
|
293
|
+
children: [
|
|
294
|
+
showSearchIcon && /* @__PURE__ */ jsx(Search, { className: "text-muted-foreground absolute left-3 h-4 w-4" }),
|
|
295
|
+
/* @__PURE__ */ jsx(
|
|
296
|
+
Input,
|
|
297
|
+
{
|
|
298
|
+
ref,
|
|
299
|
+
...props,
|
|
300
|
+
id: inputId,
|
|
301
|
+
type: "search",
|
|
302
|
+
role: "combobox",
|
|
303
|
+
"aria-label": "Search",
|
|
304
|
+
"aria-autocomplete": "list",
|
|
305
|
+
"aria-expanded": isOpen,
|
|
306
|
+
"aria-controls": resultsId,
|
|
307
|
+
"aria-activedescendant": activeIndex >= 0 && results[activeIndex] ? `${resultsId}-option-${results[activeIndex].id}` : void 0,
|
|
308
|
+
placeholder,
|
|
309
|
+
value: query,
|
|
310
|
+
onChange: handleChange,
|
|
311
|
+
onFocus: handleFocus,
|
|
312
|
+
onKeyDown: handleKeyDown,
|
|
313
|
+
className: cn(
|
|
314
|
+
"border-0 bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0",
|
|
315
|
+
showSearchIcon && "pl-10",
|
|
316
|
+
showClearButton && query && "pr-10"
|
|
317
|
+
),
|
|
318
|
+
size: void 0
|
|
319
|
+
}
|
|
320
|
+
),
|
|
321
|
+
showClearButton && query && /* @__PURE__ */ jsx(
|
|
322
|
+
Button,
|
|
323
|
+
{
|
|
324
|
+
type: "button",
|
|
325
|
+
variant: "ghost",
|
|
326
|
+
size: "sm",
|
|
327
|
+
"aria-label": "Clear search",
|
|
328
|
+
className: "absolute right-1 h-6 w-6 p-0",
|
|
329
|
+
onClick: handleClear,
|
|
330
|
+
children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
|
|
331
|
+
}
|
|
332
|
+
)
|
|
333
|
+
]
|
|
334
|
+
}
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
);
|
|
338
|
+
SearchInput.displayName = "SearchInput";
|
|
339
|
+
var SearchTrigger = React.forwardRef(({ className, asChild = false, children, onClick, ...props }, ref) => {
|
|
340
|
+
const { isOpen, setIsOpen, resultsId } = useAdvancedSearch();
|
|
341
|
+
const Comp = asChild ? Slot : Button;
|
|
342
|
+
return /* @__PURE__ */ jsx(
|
|
343
|
+
Comp,
|
|
344
|
+
{
|
|
345
|
+
ref,
|
|
346
|
+
...props,
|
|
347
|
+
type: "button",
|
|
348
|
+
"aria-expanded": isOpen,
|
|
349
|
+
"aria-controls": resultsId,
|
|
350
|
+
className: cn(className),
|
|
351
|
+
onClick: (event) => {
|
|
352
|
+
onClick?.(event);
|
|
353
|
+
if (!event.defaultPrevented) {
|
|
354
|
+
setIsOpen(!isOpen);
|
|
738
355
|
}
|
|
739
|
-
},
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
);
|
|
743
|
-
const handleResultSelect = React4.useCallback(
|
|
744
|
-
(result) => {
|
|
745
|
-
onResultSelect?.(result);
|
|
746
|
-
setQuery(result.title);
|
|
747
|
-
setActiveIndex(-1);
|
|
748
|
-
setIsOpen(false);
|
|
749
|
-
},
|
|
750
|
-
[onResultSelect]
|
|
356
|
+
},
|
|
357
|
+
children
|
|
358
|
+
}
|
|
751
359
|
);
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
360
|
+
});
|
|
361
|
+
SearchTrigger.displayName = "SearchTrigger";
|
|
362
|
+
var SearchResults = React.forwardRef(
|
|
363
|
+
({
|
|
364
|
+
className,
|
|
365
|
+
size = "full",
|
|
366
|
+
sections,
|
|
367
|
+
showEmptyState = true,
|
|
368
|
+
emptyStateMessage = "No results found",
|
|
369
|
+
showLoadingState = true,
|
|
370
|
+
loadingBehaviour = "replace-results",
|
|
371
|
+
loadingState,
|
|
372
|
+
loadingMessage = "Searching...",
|
|
373
|
+
...props
|
|
374
|
+
}, ref) => {
|
|
375
|
+
const {
|
|
762
376
|
results,
|
|
763
|
-
setResults,
|
|
764
377
|
isLoading,
|
|
765
|
-
setIsLoading,
|
|
766
|
-
onSearch: handleSearch,
|
|
767
|
-
onResultSelect: handleResultSelect,
|
|
768
|
-
emptyStateBehaviour,
|
|
769
|
-
minQueryLength
|
|
770
|
-
}),
|
|
771
|
-
[
|
|
772
378
|
query,
|
|
773
|
-
|
|
774
|
-
inputId,
|
|
379
|
+
onResultSelect,
|
|
775
380
|
resultsId,
|
|
776
381
|
activeIndex,
|
|
777
|
-
results,
|
|
778
|
-
isLoading,
|
|
779
|
-
handleSearch,
|
|
780
|
-
handleResultSelect,
|
|
781
382
|
emptyStateBehaviour,
|
|
782
383
|
minQueryLength
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
384
|
+
} = useAdvancedSearch();
|
|
385
|
+
const shouldReplaceResultsWithLoading = loadingBehaviour === "replace-results" || results.length === 0;
|
|
386
|
+
if (isLoading && showLoadingState && shouldReplaceResultsWithLoading) {
|
|
387
|
+
return /* @__PURE__ */ jsx(
|
|
388
|
+
"div",
|
|
389
|
+
{
|
|
390
|
+
ref,
|
|
391
|
+
id: resultsId,
|
|
392
|
+
className: cn(
|
|
393
|
+
searchResultsVariants({ size }),
|
|
394
|
+
"text-muted-foreground p-4 text-center",
|
|
395
|
+
className
|
|
396
|
+
),
|
|
397
|
+
role: "status",
|
|
398
|
+
"aria-live": "polite",
|
|
399
|
+
...props,
|
|
400
|
+
children: loadingState ?? loadingMessage
|
|
401
|
+
}
|
|
402
|
+
);
|
|
793
403
|
}
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
404
|
+
const shouldShowEmptyState = results.length === 0 || !query && emptyStateBehaviour !== "show-all-results";
|
|
405
|
+
if (shouldShowEmptyState) {
|
|
406
|
+
if (!showEmptyState) return null;
|
|
407
|
+
if (emptyStateBehaviour === "hide-until-min-chars" && query.length < minQueryLength) {
|
|
408
|
+
return null;
|
|
409
|
+
}
|
|
410
|
+
return /* @__PURE__ */ jsx(
|
|
411
|
+
"div",
|
|
412
|
+
{
|
|
413
|
+
ref,
|
|
414
|
+
id: resultsId,
|
|
415
|
+
className: cn(
|
|
416
|
+
searchResultsVariants({ size }),
|
|
417
|
+
"text-muted-foreground p-4 text-center",
|
|
418
|
+
className
|
|
419
|
+
),
|
|
420
|
+
role: "status",
|
|
421
|
+
"aria-live": "polite",
|
|
422
|
+
...props,
|
|
423
|
+
children: emptyStateMessage
|
|
424
|
+
}
|
|
425
|
+
);
|
|
808
426
|
}
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
427
|
+
const displaySections = sections || [
|
|
428
|
+
{
|
|
429
|
+
id: "results",
|
|
430
|
+
title: "Results",
|
|
431
|
+
results
|
|
432
|
+
}
|
|
433
|
+
];
|
|
434
|
+
return /* @__PURE__ */ jsx(
|
|
435
|
+
"div",
|
|
436
|
+
{
|
|
437
|
+
ref,
|
|
438
|
+
id: resultsId,
|
|
439
|
+
className: cn(
|
|
440
|
+
searchResultsVariants({ size }),
|
|
441
|
+
"max-h-[var(--results-max-height)]",
|
|
442
|
+
className
|
|
443
|
+
),
|
|
444
|
+
role: "listbox",
|
|
445
|
+
"aria-label": "Search results",
|
|
446
|
+
"aria-busy": isLoading || void 0,
|
|
447
|
+
...props,
|
|
448
|
+
children: /* @__PURE__ */ jsx(ScrollArea, { className: "h-fit max-h-[var(--results-max-height)] *:max-h-[var(--results-max-height)]", children: /* @__PURE__ */ jsx("div", { className: "space-y-4 p-4", children: displaySections.map((section, index) => /* @__PURE__ */ jsxs("div", { children: [
|
|
449
|
+
index > 0 && /* @__PURE__ */ jsx(Separator, { className: "my-4" }),
|
|
450
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
451
|
+
/* @__PURE__ */ jsx("h3", { className: "text-muted-foreground text-sm font-semibold tracking-wide uppercase", children: section.title }),
|
|
452
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
453
|
+
section.results.map((result) => {
|
|
454
|
+
const resultIndex = results.findIndex(
|
|
455
|
+
(item) => item.id === result.id
|
|
456
|
+
);
|
|
457
|
+
return /* @__PURE__ */ jsx(
|
|
458
|
+
SearchResultItem,
|
|
459
|
+
{
|
|
460
|
+
id: `${resultsId}-option-${result.id}`,
|
|
461
|
+
result,
|
|
462
|
+
isActive: resultIndex === activeIndex,
|
|
463
|
+
onClick: () => onResultSelect(result)
|
|
464
|
+
},
|
|
465
|
+
result.id
|
|
466
|
+
);
|
|
467
|
+
}),
|
|
468
|
+
section.showMore && section.onShowMore && /* @__PURE__ */ jsxs(
|
|
469
|
+
Button,
|
|
470
|
+
{
|
|
471
|
+
variant: "ghost",
|
|
472
|
+
size: "sm",
|
|
473
|
+
className: "text-muted-foreground w-full justify-start",
|
|
474
|
+
onClick: section.onShowMore,
|
|
475
|
+
children: [
|
|
476
|
+
"Show more",
|
|
477
|
+
/* @__PURE__ */ jsx(ChevronDown, { className: "ml-2 h-3 w-3" })
|
|
478
|
+
]
|
|
479
|
+
}
|
|
480
|
+
)
|
|
481
|
+
] })
|
|
482
|
+
] })
|
|
483
|
+
] }, section.id)) }) })
|
|
484
|
+
}
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
);
|
|
488
|
+
SearchResults.displayName = "SearchResults";
|
|
489
|
+
var SearchResultItem = ({
|
|
490
|
+
id,
|
|
491
|
+
result,
|
|
492
|
+
isActive,
|
|
493
|
+
onClick
|
|
494
|
+
}) => {
|
|
495
|
+
const itemClasses = cn(
|
|
496
|
+
"hover:bg-accent hover:text-accent-foreground focus-visible:border-ring focus-visible:ring-ring/50 w-full rounded-md text-left transition-colors outline-none focus-visible:ring-[3px]",
|
|
497
|
+
isActive && "bg-accent text-accent-foreground"
|
|
498
|
+
);
|
|
499
|
+
if (result.type === "category") {
|
|
500
|
+
return /* @__PURE__ */ jsx(
|
|
501
|
+
"div",
|
|
502
|
+
{
|
|
503
|
+
id,
|
|
504
|
+
role: "presentation",
|
|
505
|
+
className: "text-muted-foreground p-2 text-sm font-medium",
|
|
506
|
+
children: result.title
|
|
507
|
+
}
|
|
508
|
+
);
|
|
509
|
+
}
|
|
510
|
+
if (result.type === "suggestion") {
|
|
511
|
+
return /* @__PURE__ */ jsx(
|
|
512
|
+
"button",
|
|
513
|
+
{
|
|
514
|
+
id,
|
|
515
|
+
type: "button",
|
|
516
|
+
role: "option",
|
|
517
|
+
"aria-selected": isActive,
|
|
518
|
+
className: cn(itemClasses, "p-2 text-sm"),
|
|
519
|
+
onClick,
|
|
520
|
+
children: result.title
|
|
521
|
+
}
|
|
522
|
+
);
|
|
813
523
|
}
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
524
|
+
const content = /* @__PURE__ */ jsxs("div", { className: "flex gap-3 p-3", children: [
|
|
525
|
+
result.image && /* @__PURE__ */ jsx("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsx(
|
|
526
|
+
"img",
|
|
527
|
+
{
|
|
528
|
+
src: result.image,
|
|
529
|
+
alt: result.title,
|
|
530
|
+
className: "h-12 w-12 rounded-md object-cover",
|
|
531
|
+
loading: "lazy"
|
|
532
|
+
}
|
|
533
|
+
) }),
|
|
534
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
535
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-2", children: [
|
|
536
|
+
/* @__PURE__ */ jsx("h4", { className: "truncate text-sm font-semibold", children: result.title }),
|
|
537
|
+
result.badge && /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "text-xs", children: result.badge })
|
|
538
|
+
] }),
|
|
539
|
+
result.description && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground mt-1 line-clamp-2 text-xs", children: result.description })
|
|
540
|
+
] })
|
|
541
|
+
] });
|
|
542
|
+
if (result.href) {
|
|
543
|
+
return /* @__PURE__ */ jsx(
|
|
544
|
+
"a",
|
|
545
|
+
{
|
|
546
|
+
id,
|
|
547
|
+
role: "option",
|
|
548
|
+
"aria-selected": isActive,
|
|
549
|
+
href: result.href,
|
|
550
|
+
className: cn(itemClasses, "block"),
|
|
551
|
+
onClick,
|
|
552
|
+
children: content
|
|
553
|
+
}
|
|
554
|
+
);
|
|
828
555
|
}
|
|
829
|
-
|
|
830
|
-
|
|
556
|
+
return /* @__PURE__ */ jsx(
|
|
557
|
+
"button",
|
|
558
|
+
{
|
|
559
|
+
id,
|
|
560
|
+
type: "button",
|
|
561
|
+
role: "option",
|
|
562
|
+
"aria-selected": isActive,
|
|
563
|
+
className: itemClasses,
|
|
564
|
+
onClick,
|
|
565
|
+
children: content
|
|
566
|
+
}
|
|
567
|
+
);
|
|
568
|
+
};
|
|
569
|
+
var AdvancedSearchBar = React.forwardRef(
|
|
831
570
|
({
|
|
832
571
|
className,
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
asChild = false,
|
|
572
|
+
children,
|
|
573
|
+
open,
|
|
574
|
+
onOpenChange,
|
|
575
|
+
resultsMode = "popover",
|
|
576
|
+
triggerClassName,
|
|
577
|
+
resultsClassName,
|
|
840
578
|
...props
|
|
841
579
|
}, ref) => {
|
|
842
|
-
const {
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
isOpen
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
resultsId,
|
|
852
|
-
activeIndex,
|
|
853
|
-
setActiveIndex,
|
|
854
|
-
emptyStateBehaviour,
|
|
855
|
-
minQueryLength
|
|
856
|
-
} = useAdvancedSearch();
|
|
857
|
-
const Comp = asChild ? Slot : "div";
|
|
858
|
-
const handleChange = (e) => {
|
|
859
|
-
const value = e.target.value;
|
|
860
|
-
setQuery(value);
|
|
861
|
-
if (emptyStateBehaviour === "hide-until-min-chars") {
|
|
862
|
-
setIsOpen(value.length >= minQueryLength);
|
|
863
|
-
} else {
|
|
864
|
-
setIsOpen(true);
|
|
865
|
-
}
|
|
866
|
-
setTimeout(() => {
|
|
867
|
-
onSearch(value);
|
|
868
|
-
}, 0);
|
|
869
|
-
props.onChange?.(e);
|
|
870
|
-
};
|
|
871
|
-
const handleFocus = (e) => {
|
|
872
|
-
if (emptyStateBehaviour === "hide-until-min-chars") {
|
|
873
|
-
setIsOpen(query.length >= minQueryLength);
|
|
874
|
-
} else {
|
|
875
|
-
setIsOpen(true);
|
|
580
|
+
const { isOpen, setIsOpen, setActiveIndex } = useAdvancedSearch();
|
|
581
|
+
const rootRef = React.useRef(null);
|
|
582
|
+
const previousOpenRef = React.useRef(isOpen);
|
|
583
|
+
const isControlled = open !== void 0;
|
|
584
|
+
const isOpenState = isControlled ? open : isOpen;
|
|
585
|
+
React.useEffect(() => {
|
|
586
|
+
if (previousOpenRef.current !== isOpen) {
|
|
587
|
+
previousOpenRef.current = isOpen;
|
|
588
|
+
onOpenChange?.(isOpen);
|
|
876
589
|
}
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
if (e.defaultPrevented) return;
|
|
890
|
-
if (e.key === "Escape") {
|
|
891
|
-
setIsOpen(false);
|
|
590
|
+
}, [isOpen, onOpenChange]);
|
|
591
|
+
React.useEffect(() => {
|
|
592
|
+
if (!isOpenState) return;
|
|
593
|
+
const handlePointerDown = (event) => {
|
|
594
|
+
if (!rootRef.current?.contains(event.target)) {
|
|
595
|
+
setActiveIndex(-1);
|
|
596
|
+
setIsOpen(false);
|
|
597
|
+
onOpenChange?.(false);
|
|
598
|
+
}
|
|
599
|
+
};
|
|
600
|
+
const handleKeyDown = (event) => {
|
|
601
|
+
if (event.key !== "Escape") return;
|
|
892
602
|
setActiveIndex(-1);
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
setIsOpen(true);
|
|
898
|
-
setActiveIndex(
|
|
899
|
-
results.length ? (activeIndex + 1) % results.length : -1
|
|
900
|
-
);
|
|
901
|
-
return;
|
|
902
|
-
}
|
|
903
|
-
if (e.key === "ArrowUp") {
|
|
904
|
-
e.preventDefault();
|
|
905
|
-
setIsOpen(true);
|
|
906
|
-
setActiveIndex(
|
|
907
|
-
results.length ? activeIndex <= 0 ? results.length - 1 : activeIndex - 1 : -1
|
|
603
|
+
setIsOpen(false);
|
|
604
|
+
onOpenChange?.(false);
|
|
605
|
+
const focusTarget = rootRef.current?.querySelector(
|
|
606
|
+
'input, button, [href], [tabindex]:not([tabindex="-1"])'
|
|
908
607
|
);
|
|
909
|
-
|
|
608
|
+
focusTarget?.focus();
|
|
609
|
+
};
|
|
610
|
+
document.addEventListener("pointerdown", handlePointerDown);
|
|
611
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
612
|
+
return () => {
|
|
613
|
+
document.removeEventListener("pointerdown", handlePointerDown);
|
|
614
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
615
|
+
};
|
|
616
|
+
}, [isOpenState, onOpenChange, setActiveIndex, setIsOpen]);
|
|
617
|
+
const setRefs = React.useCallback(
|
|
618
|
+
(node) => {
|
|
619
|
+
rootRef.current = node;
|
|
620
|
+
if (typeof ref === "function") {
|
|
621
|
+
ref(node);
|
|
622
|
+
} else if (ref) {
|
|
623
|
+
ref.current = node;
|
|
624
|
+
}
|
|
625
|
+
},
|
|
626
|
+
[ref]
|
|
627
|
+
);
|
|
628
|
+
const isSearchResultsChild = (child) => {
|
|
629
|
+
if (!React.isValidElement(child)) return false;
|
|
630
|
+
const childType = child.type;
|
|
631
|
+
return child.type === SearchResults || childType.displayName === SearchResults.displayName;
|
|
632
|
+
};
|
|
633
|
+
const childrenArray = React.Children.toArray(children);
|
|
634
|
+
const resultsChildren = childrenArray.filter(isSearchResultsChild);
|
|
635
|
+
const triggerChildren = childrenArray.filter(
|
|
636
|
+
(child) => !isSearchResultsChild(child)
|
|
637
|
+
);
|
|
638
|
+
const triggerElement = triggerChildren.length ? triggerChildren : /* @__PURE__ */ jsx(SearchInput, {});
|
|
639
|
+
const resultsElement = resultsChildren.length ? resultsChildren : /* @__PURE__ */ jsx(SearchResults, {});
|
|
640
|
+
const resultsPanel = isOpenState ? resultsMode === "inline" ? /* @__PURE__ */ jsx("div", { className: cn("w-full overflow-hidden", resultsClassName), children: resultsElement }) : /* @__PURE__ */ jsx(
|
|
641
|
+
"div",
|
|
642
|
+
{
|
|
643
|
+
className: cn(
|
|
644
|
+
"bg-popover text-popover-foreground border-border absolute top-full left-0 z-50 mt-1 max-h-[min(var(--results-max-height),calc(100vh-8rem))] w-full overflow-hidden rounded-md border shadow-lg",
|
|
645
|
+
resultsClassName
|
|
646
|
+
),
|
|
647
|
+
children: resultsElement
|
|
910
648
|
}
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
649
|
+
) : null;
|
|
650
|
+
return /* @__PURE__ */ jsxs(
|
|
651
|
+
"div",
|
|
652
|
+
{
|
|
653
|
+
ref: setRefs,
|
|
654
|
+
"data-state": isOpenState ? "open" : "closed",
|
|
655
|
+
className: cn("relative w-full", className),
|
|
656
|
+
...props,
|
|
657
|
+
children: [
|
|
658
|
+
/* @__PURE__ */ jsx("div", { className: cn("w-full", triggerClassName), children: triggerElement }),
|
|
659
|
+
resultsPanel
|
|
660
|
+
]
|
|
916
661
|
}
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
662
|
+
);
|
|
663
|
+
}
|
|
664
|
+
);
|
|
665
|
+
AdvancedSearchBar.displayName = "AdvancedSearchBar";
|
|
666
|
+
var SearchSection = React.forwardRef(({ className, title, showMore, onShowMore, children, ...props }, ref) => {
|
|
667
|
+
return /* @__PURE__ */ jsxs("div", { ref, className: cn("space-y-2", className), ...props, children: [
|
|
668
|
+
title && /* @__PURE__ */ jsx("h3", { className: "text-muted-foreground text-sm font-semibold tracking-wide uppercase", children: title }),
|
|
669
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
670
|
+
children,
|
|
671
|
+
showMore && onShowMore && /* @__PURE__ */ jsxs(
|
|
672
|
+
Button,
|
|
673
|
+
{
|
|
674
|
+
variant: "ghost",
|
|
675
|
+
size: "sm",
|
|
676
|
+
className: "text-muted-foreground w-full justify-start",
|
|
677
|
+
onClick: onShowMore,
|
|
678
|
+
children: [
|
|
679
|
+
"Show more",
|
|
680
|
+
/* @__PURE__ */ jsx(ChevronDown, { className: "ml-2 h-3 w-3" })
|
|
681
|
+
]
|
|
682
|
+
}
|
|
683
|
+
)
|
|
684
|
+
] })
|
|
685
|
+
] });
|
|
686
|
+
});
|
|
687
|
+
SearchSection.displayName = "SearchSection";
|
|
688
|
+
var SearchItem = React.forwardRef(
|
|
689
|
+
({ className, result, onClick, children, ...props }, ref) => {
|
|
690
|
+
const { onResultSelect } = useAdvancedSearch();
|
|
691
|
+
const handleClick = () => {
|
|
692
|
+
if (result) {
|
|
693
|
+
onResultSelect(result);
|
|
922
694
|
}
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
695
|
+
onClick?.();
|
|
696
|
+
};
|
|
697
|
+
const handleKeyDown = (event) => {
|
|
698
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
699
|
+
event.preventDefault();
|
|
700
|
+
handleClick();
|
|
926
701
|
}
|
|
927
702
|
};
|
|
928
|
-
|
|
929
|
-
|
|
703
|
+
if (children) {
|
|
704
|
+
return /* @__PURE__ */ jsx(
|
|
705
|
+
"div",
|
|
706
|
+
{
|
|
707
|
+
ref,
|
|
708
|
+
role: "button",
|
|
709
|
+
tabIndex: 0,
|
|
710
|
+
className: cn("cursor-pointer outline-none", className),
|
|
711
|
+
onClick: handleClick,
|
|
712
|
+
onKeyDown: handleKeyDown,
|
|
713
|
+
...props,
|
|
714
|
+
children
|
|
715
|
+
}
|
|
716
|
+
);
|
|
717
|
+
}
|
|
718
|
+
if (!result) return null;
|
|
719
|
+
if (result.type === "category") {
|
|
720
|
+
return /* @__PURE__ */ jsx(
|
|
721
|
+
"div",
|
|
722
|
+
{
|
|
723
|
+
ref,
|
|
724
|
+
role: "presentation",
|
|
725
|
+
className: cn(
|
|
726
|
+
"text-muted-foreground p-2 text-sm font-medium",
|
|
727
|
+
className
|
|
728
|
+
),
|
|
729
|
+
...props,
|
|
730
|
+
children: result.title
|
|
731
|
+
}
|
|
732
|
+
);
|
|
733
|
+
}
|
|
734
|
+
if (result.type === "suggestion") {
|
|
735
|
+
return /* @__PURE__ */ jsx(
|
|
736
|
+
Button,
|
|
737
|
+
{
|
|
738
|
+
ref,
|
|
739
|
+
variant: "ghost",
|
|
740
|
+
size: "sm",
|
|
741
|
+
className: cn("h-auto w-full justify-start p-2", className),
|
|
742
|
+
onClick: handleClick,
|
|
743
|
+
...props,
|
|
744
|
+
children: /* @__PURE__ */ jsx("span", { className: "text-sm", children: result.title })
|
|
745
|
+
}
|
|
746
|
+
);
|
|
747
|
+
}
|
|
748
|
+
return /* @__PURE__ */ jsx(
|
|
749
|
+
"button",
|
|
930
750
|
{
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
751
|
+
ref,
|
|
752
|
+
type: "button",
|
|
753
|
+
className: cn(
|
|
754
|
+
"hover:bg-accent hover:text-accent-foreground focus-visible:border-ring focus-visible:ring-ring/50 w-full cursor-pointer rounded-md text-left transition-colors outline-none focus-visible:ring-[3px]",
|
|
934
755
|
className
|
|
935
756
|
),
|
|
936
|
-
onClick:
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
children: [
|
|
942
|
-
showSearchIcon && /* @__PURE__ */ jsx6(Search2, { className: "text-muted-foreground absolute left-3 h-4 w-4" }),
|
|
943
|
-
/* @__PURE__ */ jsx6(
|
|
944
|
-
Input3,
|
|
945
|
-
{
|
|
946
|
-
ref,
|
|
947
|
-
...props,
|
|
948
|
-
id: inputId,
|
|
949
|
-
type: "search",
|
|
950
|
-
role: "combobox",
|
|
951
|
-
"aria-label": "Search",
|
|
952
|
-
"aria-autocomplete": "list",
|
|
953
|
-
"aria-expanded": isOpen,
|
|
954
|
-
"aria-controls": resultsId,
|
|
955
|
-
"aria-activedescendant": activeIndex >= 0 && results[activeIndex] ? `${resultsId}-option-${results[activeIndex].id}` : void 0,
|
|
956
|
-
placeholder,
|
|
957
|
-
value: query,
|
|
958
|
-
onChange: handleChange,
|
|
959
|
-
onFocus: handleFocus,
|
|
960
|
-
onKeyDown: handleKeyDown,
|
|
961
|
-
className: cn6(
|
|
962
|
-
"border-0 bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0",
|
|
963
|
-
showSearchIcon && "pl-10",
|
|
964
|
-
showClearButton && query && "pr-10"
|
|
965
|
-
),
|
|
966
|
-
size: void 0
|
|
967
|
-
}
|
|
968
|
-
),
|
|
969
|
-
showClearButton && query && /* @__PURE__ */ jsx6(
|
|
970
|
-
Button4,
|
|
757
|
+
onClick: handleClick,
|
|
758
|
+
...props,
|
|
759
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex gap-3 p-3", children: [
|
|
760
|
+
result.image && /* @__PURE__ */ jsx("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsx(
|
|
761
|
+
"img",
|
|
971
762
|
{
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
className: "absolute right-1 h-6 w-6 p-0",
|
|
977
|
-
onClick: handleClear,
|
|
978
|
-
children: /* @__PURE__ */ jsx6(X, { className: "h-3 w-3" })
|
|
763
|
+
src: result.image,
|
|
764
|
+
alt: result.title,
|
|
765
|
+
className: "h-12 w-12 rounded-md object-cover",
|
|
766
|
+
loading: "lazy"
|
|
979
767
|
}
|
|
980
|
-
)
|
|
981
|
-
|
|
768
|
+
) }),
|
|
769
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
770
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-2", children: [
|
|
771
|
+
/* @__PURE__ */ jsx("h4", { className: "truncate text-sm font-semibold", children: result.title }),
|
|
772
|
+
result.badge && /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "text-xs", children: result.badge })
|
|
773
|
+
] }),
|
|
774
|
+
result.description && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground mt-1 line-clamp-2 text-xs", children: result.description })
|
|
775
|
+
] })
|
|
776
|
+
] })
|
|
982
777
|
}
|
|
983
778
|
);
|
|
984
779
|
}
|
|
985
780
|
);
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
const {
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
781
|
+
SearchItem.displayName = "SearchItem";
|
|
782
|
+
function AdvancedSearchBarWrapper(props = {}) {
|
|
783
|
+
const {
|
|
784
|
+
minQueryLength = 1,
|
|
785
|
+
emptyStateBehaviour = "show-all-results",
|
|
786
|
+
size = "md",
|
|
787
|
+
variant = "default",
|
|
788
|
+
useCustomTrigger = false
|
|
789
|
+
} = props;
|
|
790
|
+
const mockSearchResults = [
|
|
791
|
+
{
|
|
792
|
+
id: "1",
|
|
793
|
+
title: "Beach Holidays",
|
|
794
|
+
description: "Relaxing beach destinations",
|
|
795
|
+
type: "result",
|
|
796
|
+
badge: "Popular"
|
|
797
|
+
},
|
|
798
|
+
{
|
|
799
|
+
id: "2",
|
|
800
|
+
title: "Adventure Trips",
|
|
801
|
+
description: "Exciting adventure experiences",
|
|
802
|
+
type: "result",
|
|
803
|
+
badge: "New"
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
id: "3",
|
|
807
|
+
title: "City Breaks",
|
|
808
|
+
description: "Urban exploration trips",
|
|
809
|
+
type: "result"
|
|
810
|
+
},
|
|
811
|
+
{
|
|
812
|
+
id: "4",
|
|
813
|
+
title: "Mountain Retreats",
|
|
814
|
+
description: "Peaceful mountain getaways",
|
|
815
|
+
type: "result"
|
|
816
|
+
},
|
|
817
|
+
{
|
|
818
|
+
id: "5",
|
|
819
|
+
title: "Cultural Tours",
|
|
820
|
+
description: "Explore local culture and history",
|
|
821
|
+
type: "result"
|
|
822
|
+
}
|
|
823
|
+
];
|
|
824
|
+
const handleSearch = async (query) => {
|
|
825
|
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
826
|
+
if (!query.trim()) {
|
|
827
|
+
return emptyStateBehaviour === "show-all-results" ? mockSearchResults : [];
|
|
828
|
+
}
|
|
829
|
+
return mockSearchResults.filter(
|
|
830
|
+
(result) => result.title.toLowerCase().includes(query.toLowerCase()) || result.description.toLowerCase().includes(query.toLowerCase())
|
|
831
|
+
);
|
|
832
|
+
};
|
|
833
|
+
const handleResultSelect = (result) => {
|
|
834
|
+
console.log("Selected result:", result);
|
|
835
|
+
};
|
|
836
|
+
const getPlaceholder = () => {
|
|
837
|
+
if (emptyStateBehaviour === "hide-until-min-chars") {
|
|
838
|
+
return `Type at least ${minQueryLength} characters...`;
|
|
839
|
+
}
|
|
840
|
+
return "Search destinations...";
|
|
841
|
+
};
|
|
842
|
+
return /* @__PURE__ */ jsx(
|
|
843
|
+
AdvancedSearchProvider,
|
|
844
|
+
{
|
|
845
|
+
onSearch: handleSearch,
|
|
846
|
+
onResultSelect: handleResultSelect,
|
|
847
|
+
debounceMs: 300,
|
|
848
|
+
minQueryLength,
|
|
849
|
+
emptyStateBehaviour,
|
|
850
|
+
initialResults: emptyStateBehaviour === "show-all-results" ? mockSearchResults : [],
|
|
851
|
+
children: /* @__PURE__ */ jsxs(AdvancedSearchBar, { children: [
|
|
852
|
+
useCustomTrigger ? /* @__PURE__ */ jsx(SearchTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "outline", className: "w-full justify-start", children: [
|
|
853
|
+
/* @__PURE__ */ jsx(Search, { className: "mr-2 h-4 w-4" }),
|
|
854
|
+
"Click to search..."
|
|
855
|
+
] }) }) : /* @__PURE__ */ jsx(
|
|
856
|
+
SearchInput,
|
|
857
|
+
{
|
|
858
|
+
placeholder: getPlaceholder(),
|
|
859
|
+
size,
|
|
860
|
+
variant,
|
|
861
|
+
showSearchIcon: true,
|
|
862
|
+
showClearButton: true
|
|
863
|
+
}
|
|
864
|
+
),
|
|
865
|
+
/* @__PURE__ */ jsx(
|
|
866
|
+
SearchResults,
|
|
867
|
+
{
|
|
868
|
+
size: size === "sm" ? "sm" : size === "lg" ? "lg" : "md",
|
|
869
|
+
showEmptyState: true,
|
|
870
|
+
emptyStateMessage: "No destinations found.",
|
|
871
|
+
showLoadingState: true,
|
|
872
|
+
loadingMessage: "Searching destinations..."
|
|
873
|
+
}
|
|
874
|
+
)
|
|
875
|
+
] })
|
|
876
|
+
}
|
|
877
|
+
);
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
// src/components/calendar/index.tsx
|
|
881
|
+
import { Button as Button2, buttonVariants } from "@foundrykit/primitives";
|
|
882
|
+
import { cn as cn2 } from "@foundrykit/utils";
|
|
883
|
+
import {
|
|
884
|
+
ChevronDownIcon,
|
|
885
|
+
ChevronLeftIcon,
|
|
886
|
+
ChevronRightIcon
|
|
887
|
+
} from "lucide-react";
|
|
888
|
+
import * as React2 from "react";
|
|
889
|
+
import {
|
|
890
|
+
DayPicker,
|
|
891
|
+
getDefaultClassNames
|
|
892
|
+
} from "react-day-picker";
|
|
893
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
894
|
+
function Calendar({
|
|
895
|
+
className,
|
|
896
|
+
classNames,
|
|
897
|
+
showOutsideDays = true,
|
|
898
|
+
captionLayout = "label",
|
|
899
|
+
buttonVariant = "ghost",
|
|
900
|
+
formatters,
|
|
901
|
+
components,
|
|
902
|
+
...props
|
|
903
|
+
}) {
|
|
904
|
+
const defaultClassNames = getDefaultClassNames();
|
|
905
|
+
return /* @__PURE__ */ jsx2(
|
|
906
|
+
DayPicker,
|
|
907
|
+
{
|
|
908
|
+
showOutsideDays,
|
|
909
|
+
className: cn2(
|
|
910
|
+
"bg-background group/calendar p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
|
|
911
|
+
String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
|
|
912
|
+
String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
|
|
913
|
+
className
|
|
914
|
+
),
|
|
915
|
+
captionLayout,
|
|
916
|
+
formatters: {
|
|
917
|
+
formatMonthDropdown: (date) => date.toLocaleString("default", { month: "short" }),
|
|
918
|
+
...formatters
|
|
919
|
+
},
|
|
920
|
+
classNames: {
|
|
921
|
+
root: cn2("w-fit", defaultClassNames.root),
|
|
922
|
+
months: cn2(
|
|
923
|
+
"relative flex flex-col gap-4 md:flex-row",
|
|
924
|
+
defaultClassNames.months
|
|
925
|
+
),
|
|
926
|
+
month: cn2("flex w-full flex-col gap-4", defaultClassNames.month),
|
|
927
|
+
nav: cn2(
|
|
928
|
+
"absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",
|
|
929
|
+
defaultClassNames.nav
|
|
930
|
+
),
|
|
931
|
+
button_previous: cn2(
|
|
932
|
+
buttonVariants({ variant: buttonVariant }),
|
|
933
|
+
"size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
|
|
934
|
+
defaultClassNames.button_previous
|
|
935
|
+
),
|
|
936
|
+
button_next: cn2(
|
|
937
|
+
buttonVariants({ variant: buttonVariant }),
|
|
938
|
+
"size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
|
|
939
|
+
defaultClassNames.button_next
|
|
940
|
+
),
|
|
941
|
+
month_caption: cn2(
|
|
942
|
+
"flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)",
|
|
943
|
+
defaultClassNames.month_caption
|
|
944
|
+
),
|
|
945
|
+
dropdowns: cn2(
|
|
946
|
+
"flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium",
|
|
947
|
+
defaultClassNames.dropdowns
|
|
948
|
+
),
|
|
949
|
+
dropdown_root: cn2(
|
|
950
|
+
"has-focus:border-ring border-input has-focus:ring-ring/50 relative rounded-md border shadow-xs has-focus:ring-[3px]",
|
|
951
|
+
defaultClassNames.dropdown_root
|
|
952
|
+
),
|
|
953
|
+
dropdown: cn2(
|
|
954
|
+
"bg-popover absolute inset-0 opacity-0",
|
|
955
|
+
defaultClassNames.dropdown
|
|
956
|
+
),
|
|
957
|
+
caption_label: cn2(
|
|
958
|
+
"font-medium select-none",
|
|
959
|
+
captionLayout === "label" ? "text-sm" : "[&>svg]:text-muted-foreground flex h-8 items-center gap-1 rounded-md pr-1 pl-2 text-sm [&>svg]:size-3.5",
|
|
960
|
+
defaultClassNames.caption_label
|
|
961
|
+
),
|
|
962
|
+
table: "w-full border-collapse",
|
|
963
|
+
weekdays: cn2("flex", defaultClassNames.weekdays),
|
|
964
|
+
weekday: cn2(
|
|
965
|
+
"text-muted-foreground flex-1 rounded-md text-[0.8rem] font-normal select-none",
|
|
966
|
+
defaultClassNames.weekday
|
|
967
|
+
),
|
|
968
|
+
week: cn2("mt-2 flex w-full", defaultClassNames.week),
|
|
969
|
+
week_number_header: cn2(
|
|
970
|
+
"w-(--cell-size) select-none",
|
|
971
|
+
defaultClassNames.week_number_header
|
|
972
|
+
),
|
|
973
|
+
week_number: cn2(
|
|
974
|
+
"text-muted-foreground text-[0.8rem] select-none",
|
|
975
|
+
defaultClassNames.week_number
|
|
976
|
+
),
|
|
977
|
+
day: cn2(
|
|
978
|
+
"group/day relative aspect-square h-full w-full p-0 text-center select-none [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md",
|
|
979
|
+
defaultClassNames.day
|
|
980
|
+
),
|
|
981
|
+
range_start: cn2(
|
|
982
|
+
"bg-accent rounded-l-md",
|
|
983
|
+
defaultClassNames.range_start
|
|
984
|
+
),
|
|
985
|
+
range_middle: cn2("rounded-none", defaultClassNames.range_middle),
|
|
986
|
+
range_end: cn2("bg-accent rounded-r-md", defaultClassNames.range_end),
|
|
987
|
+
today: cn2(
|
|
988
|
+
"bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",
|
|
989
|
+
defaultClassNames.today
|
|
990
|
+
),
|
|
991
|
+
outside: cn2(
|
|
992
|
+
"text-muted-foreground aria-selected:text-muted-foreground",
|
|
993
|
+
defaultClassNames.outside
|
|
994
|
+
),
|
|
995
|
+
disabled: cn2(
|
|
996
|
+
"text-muted-foreground opacity-50",
|
|
997
|
+
defaultClassNames.disabled
|
|
998
|
+
),
|
|
999
|
+
hidden: cn2("invisible", defaultClassNames.hidden),
|
|
1000
|
+
...classNames
|
|
1001
|
+
},
|
|
1002
|
+
components: {
|
|
1003
|
+
Root: ({ className: className2, rootRef, ...props2 }) => {
|
|
1004
|
+
return /* @__PURE__ */ jsx2(
|
|
1005
|
+
"div",
|
|
1006
|
+
{
|
|
1007
|
+
"data-slot": "calendar",
|
|
1008
|
+
ref: rootRef,
|
|
1009
|
+
className: cn2(className2),
|
|
1010
|
+
...props2
|
|
1011
|
+
}
|
|
1012
|
+
);
|
|
1013
|
+
},
|
|
1014
|
+
Chevron: ({ className: className2, orientation, ...props2 }) => {
|
|
1015
|
+
if (orientation === "left") {
|
|
1016
|
+
return /* @__PURE__ */ jsx2(ChevronLeftIcon, { className: cn2("size-4", className2), ...props2 });
|
|
1017
|
+
}
|
|
1018
|
+
if (orientation === "right") {
|
|
1019
|
+
return /* @__PURE__ */ jsx2(
|
|
1020
|
+
ChevronRightIcon,
|
|
1021
|
+
{
|
|
1022
|
+
className: cn2("size-4", className2),
|
|
1023
|
+
...props2
|
|
1024
|
+
}
|
|
1025
|
+
);
|
|
1026
|
+
}
|
|
1027
|
+
return /* @__PURE__ */ jsx2(ChevronDownIcon, { className: cn2("size-4", className2), ...props2 });
|
|
1028
|
+
},
|
|
1029
|
+
DayButton: CalendarDayButton,
|
|
1030
|
+
WeekNumber: ({ children, ...props2 }) => {
|
|
1031
|
+
return /* @__PURE__ */ jsx2("td", { ...props2, children: /* @__PURE__ */ jsx2("div", { className: "flex size-(--cell-size) items-center justify-center text-center", children }) });
|
|
1032
|
+
},
|
|
1033
|
+
...components
|
|
1034
|
+
},
|
|
1035
|
+
...props
|
|
1036
|
+
}
|
|
1037
|
+
);
|
|
1038
|
+
}
|
|
1039
|
+
function CalendarDayButton({
|
|
1040
|
+
className,
|
|
1041
|
+
day,
|
|
1042
|
+
modifiers,
|
|
1043
|
+
...props
|
|
1044
|
+
}) {
|
|
1045
|
+
const defaultClassNames = getDefaultClassNames();
|
|
1046
|
+
const ref = React2.useRef(null);
|
|
1047
|
+
React2.useEffect(() => {
|
|
1048
|
+
if (modifiers.focused) ref.current?.focus();
|
|
1049
|
+
}, [modifiers.focused]);
|
|
1050
|
+
return /* @__PURE__ */ jsx2(
|
|
1051
|
+
Button2,
|
|
992
1052
|
{
|
|
993
1053
|
ref,
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
"
|
|
997
|
-
"
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1054
|
+
variant: "ghost",
|
|
1055
|
+
size: "icon",
|
|
1056
|
+
"data-day": day.date.toLocaleDateString(),
|
|
1057
|
+
"data-selected-single": modifiers.selected && !modifiers.range_start && !modifiers.range_end && !modifiers.range_middle,
|
|
1058
|
+
"data-range-start": modifiers.range_start,
|
|
1059
|
+
"data-range-end": modifiers.range_end,
|
|
1060
|
+
"data-range-middle": modifiers.range_middle,
|
|
1061
|
+
className: cn2(
|
|
1062
|
+
"data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 dark:hover:text-accent-foreground flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md [&>span]:text-xs [&>span]:opacity-70",
|
|
1063
|
+
defaultClassNames.day,
|
|
1064
|
+
className
|
|
1065
|
+
),
|
|
1066
|
+
...props
|
|
1006
1067
|
}
|
|
1007
1068
|
);
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
// src/components/carousel/index.tsx
|
|
1072
|
+
import { Button as Button3 } from "@foundrykit/primitives";
|
|
1073
|
+
import { cn as cn3 } from "@foundrykit/utils";
|
|
1074
|
+
import useEmblaCarousel from "embla-carousel-react";
|
|
1075
|
+
import { ArrowLeftIcon, ArrowRightIcon } from "lucide-react";
|
|
1076
|
+
import * as React3 from "react";
|
|
1077
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1078
|
+
var CarouselContext = React3.createContext(null);
|
|
1079
|
+
function useCarousel() {
|
|
1080
|
+
const context = React3.useContext(CarouselContext);
|
|
1081
|
+
if (!context) {
|
|
1082
|
+
throw new Error("useCarousel must be used within a <Carousel />");
|
|
1083
|
+
}
|
|
1084
|
+
return context;
|
|
1085
|
+
}
|
|
1086
|
+
function Carousel({
|
|
1087
|
+
orientation = "horizontal",
|
|
1088
|
+
opts,
|
|
1089
|
+
setApi,
|
|
1090
|
+
plugins,
|
|
1091
|
+
className,
|
|
1092
|
+
children,
|
|
1093
|
+
...props
|
|
1094
|
+
}) {
|
|
1095
|
+
const [carouselRef, api] = useEmblaCarousel(
|
|
1096
|
+
{
|
|
1097
|
+
...opts,
|
|
1098
|
+
axis: orientation === "horizontal" ? "x" : "y"
|
|
1099
|
+
},
|
|
1100
|
+
plugins
|
|
1101
|
+
);
|
|
1102
|
+
const [canScrollPrev, setCanScrollPrev] = React3.useState(false);
|
|
1103
|
+
const [canScrollNext, setCanScrollNext] = React3.useState(false);
|
|
1104
|
+
const onSelect = React3.useCallback((api2) => {
|
|
1105
|
+
if (!api2) return;
|
|
1106
|
+
setCanScrollPrev(api2.canScrollPrev());
|
|
1107
|
+
setCanScrollNext(api2.canScrollNext());
|
|
1108
|
+
}, []);
|
|
1109
|
+
const scrollPrev = React3.useCallback(() => {
|
|
1110
|
+
api?.scrollPrev();
|
|
1111
|
+
}, [api]);
|
|
1112
|
+
const scrollNext = React3.useCallback(() => {
|
|
1113
|
+
api?.scrollNext();
|
|
1114
|
+
}, [api]);
|
|
1115
|
+
const handleKeyDown = React3.useCallback(
|
|
1116
|
+
(event) => {
|
|
1117
|
+
if (event.key === "ArrowLeft") {
|
|
1118
|
+
event.preventDefault();
|
|
1119
|
+
scrollPrev();
|
|
1120
|
+
} else if (event.key === "ArrowRight") {
|
|
1121
|
+
event.preventDefault();
|
|
1122
|
+
scrollNext();
|
|
1123
|
+
}
|
|
1124
|
+
},
|
|
1125
|
+
[scrollPrev, scrollNext]
|
|
1126
|
+
);
|
|
1127
|
+
React3.useEffect(() => {
|
|
1128
|
+
if (!api || !setApi) return;
|
|
1129
|
+
setApi(api);
|
|
1130
|
+
}, [api, setApi]);
|
|
1131
|
+
React3.useEffect(() => {
|
|
1132
|
+
if (!api) return;
|
|
1133
|
+
onSelect(api);
|
|
1134
|
+
api.on("reInit", onSelect);
|
|
1135
|
+
api.on("select", onSelect);
|
|
1136
|
+
return () => {
|
|
1137
|
+
api?.off("select", onSelect);
|
|
1138
|
+
};
|
|
1139
|
+
}, [api, onSelect]);
|
|
1140
|
+
return /* @__PURE__ */ jsx3(
|
|
1141
|
+
CarouselContext.Provider,
|
|
1142
|
+
{
|
|
1143
|
+
value: {
|
|
1144
|
+
carouselRef,
|
|
1145
|
+
api,
|
|
1146
|
+
opts,
|
|
1147
|
+
orientation: orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
|
|
1148
|
+
scrollPrev,
|
|
1149
|
+
scrollNext,
|
|
1150
|
+
canScrollPrev,
|
|
1151
|
+
canScrollNext
|
|
1152
|
+
},
|
|
1153
|
+
children: /* @__PURE__ */ jsx3(
|
|
1036
1154
|
"div",
|
|
1037
1155
|
{
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
className:
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
className
|
|
1044
|
-
),
|
|
1045
|
-
role: "status",
|
|
1046
|
-
"aria-live": "polite",
|
|
1156
|
+
"data-slot": "carousel",
|
|
1157
|
+
onKeyDownCapture: handleKeyDown,
|
|
1158
|
+
className: cn3("relative", className),
|
|
1159
|
+
role: "region",
|
|
1160
|
+
"aria-roledescription": "carousel",
|
|
1047
1161
|
...props,
|
|
1048
|
-
children
|
|
1162
|
+
children
|
|
1049
1163
|
}
|
|
1050
|
-
)
|
|
1164
|
+
)
|
|
1051
1165
|
}
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1166
|
+
);
|
|
1167
|
+
}
|
|
1168
|
+
function CarouselContent({ className, ...props }) {
|
|
1169
|
+
const { carouselRef, orientation } = useCarousel();
|
|
1170
|
+
return /* @__PURE__ */ jsx3(
|
|
1171
|
+
"div",
|
|
1172
|
+
{
|
|
1173
|
+
ref: carouselRef,
|
|
1174
|
+
"data-slot": "carousel-content",
|
|
1175
|
+
className: "overflow-hidden",
|
|
1176
|
+
children: /* @__PURE__ */ jsx3(
|
|
1059
1177
|
"div",
|
|
1060
1178
|
{
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
searchResultsVariants({ size }),
|
|
1065
|
-
"text-muted-foreground p-4 text-center",
|
|
1179
|
+
className: cn3(
|
|
1180
|
+
"flex",
|
|
1181
|
+
orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col",
|
|
1066
1182
|
className
|
|
1067
1183
|
),
|
|
1068
|
-
|
|
1069
|
-
"aria-live": "polite",
|
|
1070
|
-
...props,
|
|
1071
|
-
children: emptyStateMessage
|
|
1184
|
+
...props
|
|
1072
1185
|
}
|
|
1073
|
-
)
|
|
1186
|
+
)
|
|
1074
1187
|
}
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1188
|
+
);
|
|
1189
|
+
}
|
|
1190
|
+
function CarouselItem({ className, ...props }) {
|
|
1191
|
+
const { orientation } = useCarousel();
|
|
1192
|
+
return /* @__PURE__ */ jsx3(
|
|
1193
|
+
"div",
|
|
1194
|
+
{
|
|
1195
|
+
"data-slot": "carousel-item",
|
|
1196
|
+
role: "group",
|
|
1197
|
+
"aria-roledescription": "slide",
|
|
1198
|
+
className: cn3(
|
|
1199
|
+
"min-w-0 shrink-0 grow-0 basis-full",
|
|
1200
|
+
orientation === "horizontal" ? "pl-4" : "pt-4",
|
|
1201
|
+
className
|
|
1202
|
+
),
|
|
1203
|
+
...props
|
|
1204
|
+
}
|
|
1205
|
+
);
|
|
1206
|
+
}
|
|
1207
|
+
function CarouselPrevious({
|
|
1208
|
+
className,
|
|
1209
|
+
variant = "outline",
|
|
1210
|
+
size = "icon",
|
|
1211
|
+
...props
|
|
1212
|
+
}) {
|
|
1213
|
+
const { orientation, scrollPrev, canScrollPrev } = useCarousel();
|
|
1214
|
+
return /* @__PURE__ */ jsxs2(
|
|
1215
|
+
Button3,
|
|
1216
|
+
{
|
|
1217
|
+
"data-slot": "carousel-previous",
|
|
1218
|
+
variant,
|
|
1219
|
+
size,
|
|
1220
|
+
className: cn3(
|
|
1221
|
+
"absolute size-8 rounded-full",
|
|
1222
|
+
orientation === "horizontal" ? "top-1/2 -left-12 -translate-y-1/2" : "-top-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
1223
|
+
className
|
|
1224
|
+
),
|
|
1225
|
+
disabled: !canScrollPrev,
|
|
1226
|
+
onClick: scrollPrev,
|
|
1227
|
+
...props,
|
|
1228
|
+
children: [
|
|
1229
|
+
/* @__PURE__ */ jsx3(ArrowLeftIcon, {}),
|
|
1230
|
+
/* @__PURE__ */ jsx3("span", { className: "sr-only", children: "Previous slide" })
|
|
1231
|
+
]
|
|
1232
|
+
}
|
|
1233
|
+
);
|
|
1234
|
+
}
|
|
1235
|
+
function CarouselNext({
|
|
1236
|
+
className,
|
|
1237
|
+
variant = "outline",
|
|
1238
|
+
size = "icon",
|
|
1239
|
+
...props
|
|
1240
|
+
}) {
|
|
1241
|
+
const { orientation, scrollNext, canScrollNext } = useCarousel();
|
|
1242
|
+
return /* @__PURE__ */ jsxs2(
|
|
1243
|
+
Button3,
|
|
1244
|
+
{
|
|
1245
|
+
"data-slot": "carousel-next",
|
|
1246
|
+
variant,
|
|
1247
|
+
size,
|
|
1248
|
+
className: cn3(
|
|
1249
|
+
"absolute size-8 rounded-full",
|
|
1250
|
+
orientation === "horizontal" ? "top-1/2 -right-12 -translate-y-1/2" : "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
1251
|
+
className
|
|
1252
|
+
),
|
|
1253
|
+
disabled: !canScrollNext,
|
|
1254
|
+
onClick: scrollNext,
|
|
1255
|
+
...props,
|
|
1256
|
+
children: [
|
|
1257
|
+
/* @__PURE__ */ jsx3(ArrowRightIcon, {}),
|
|
1258
|
+
/* @__PURE__ */ jsx3("span", { className: "sr-only", children: "Next slide" })
|
|
1259
|
+
]
|
|
1260
|
+
}
|
|
1261
|
+
);
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
// src/components/chart/index.tsx
|
|
1265
|
+
import { cn as cn4 } from "@foundrykit/utils";
|
|
1266
|
+
import * as React4 from "react";
|
|
1267
|
+
import * as RechartsPrimitive from "recharts";
|
|
1268
|
+
import { Fragment, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1269
|
+
var THEMES = { light: "", dark: ".dark" };
|
|
1270
|
+
var ChartContext = React4.createContext(null);
|
|
1271
|
+
function useChart() {
|
|
1272
|
+
const context = React4.useContext(ChartContext);
|
|
1273
|
+
if (!context) {
|
|
1274
|
+
throw new Error("useChart must be used within a <ChartContainer />");
|
|
1275
|
+
}
|
|
1276
|
+
return context;
|
|
1277
|
+
}
|
|
1278
|
+
function ChartContainer({
|
|
1279
|
+
id,
|
|
1280
|
+
className,
|
|
1281
|
+
children,
|
|
1282
|
+
config,
|
|
1283
|
+
...props
|
|
1284
|
+
}) {
|
|
1285
|
+
const uniqueId = React4.useId();
|
|
1286
|
+
const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
|
|
1287
|
+
return /* @__PURE__ */ jsx4(ChartContext.Provider, { value: { config }, children: /* @__PURE__ */ jsxs3(
|
|
1288
|
+
"div",
|
|
1289
|
+
{
|
|
1290
|
+
"data-slot": "chart",
|
|
1291
|
+
"data-chart": chartId,
|
|
1292
|
+
className: cn4(
|
|
1293
|
+
"[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border flex aspect-video justify-center text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
|
|
1294
|
+
className
|
|
1295
|
+
),
|
|
1296
|
+
...props,
|
|
1297
|
+
children: [
|
|
1298
|
+
/* @__PURE__ */ jsx4(ChartStyle, { id: chartId, config }),
|
|
1299
|
+
/* @__PURE__ */ jsx4(RechartsPrimitive.ResponsiveContainer, { children })
|
|
1300
|
+
]
|
|
1301
|
+
}
|
|
1302
|
+
) });
|
|
1303
|
+
}
|
|
1304
|
+
function ChartStyle({ id, config }) {
|
|
1305
|
+
const colorConfig = Object.entries(config).filter(
|
|
1306
|
+
([, itemConfig]) => itemConfig.theme || itemConfig.color
|
|
1307
|
+
);
|
|
1308
|
+
if (!colorConfig.length) {
|
|
1309
|
+
return null;
|
|
1310
|
+
}
|
|
1311
|
+
return /* @__PURE__ */ jsx4(
|
|
1312
|
+
"style",
|
|
1313
|
+
{
|
|
1314
|
+
dangerouslySetInnerHTML: {
|
|
1315
|
+
__html: Object.entries(THEMES).map(
|
|
1316
|
+
([theme, prefix]) => `
|
|
1317
|
+
${prefix} [data-chart=${id}] {
|
|
1318
|
+
${colorConfig.map(([key, itemConfig]) => {
|
|
1319
|
+
const color = itemConfig.theme?.[theme] || itemConfig.color;
|
|
1320
|
+
return color ? ` --color-${key}: ${color};` : null;
|
|
1321
|
+
}).join("\n")}
|
|
1322
|
+
}
|
|
1323
|
+
`
|
|
1324
|
+
).join("\n")
|
|
1080
1325
|
}
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1326
|
+
}
|
|
1327
|
+
);
|
|
1328
|
+
}
|
|
1329
|
+
var ChartTooltip = RechartsPrimitive.Tooltip;
|
|
1330
|
+
function ChartTooltipContent({
|
|
1331
|
+
active,
|
|
1332
|
+
payload,
|
|
1333
|
+
className,
|
|
1334
|
+
indicator = "dot",
|
|
1335
|
+
hideLabel = false,
|
|
1336
|
+
hideIndicator = false,
|
|
1337
|
+
label,
|
|
1338
|
+
labelFormatter,
|
|
1339
|
+
labelClassName,
|
|
1340
|
+
formatter,
|
|
1341
|
+
color,
|
|
1342
|
+
nameKey,
|
|
1343
|
+
labelKey
|
|
1344
|
+
}) {
|
|
1345
|
+
const { config } = useChart();
|
|
1346
|
+
const tooltipLabel = React4.useMemo(() => {
|
|
1347
|
+
if (hideLabel || !payload?.length) {
|
|
1348
|
+
return null;
|
|
1349
|
+
}
|
|
1350
|
+
const [item] = payload;
|
|
1351
|
+
const key = `${labelKey || item?.dataKey || item?.name || "value"}`;
|
|
1352
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
1353
|
+
const value = !labelKey && typeof label === "string" ? config[label]?.label || label : itemConfig?.label;
|
|
1354
|
+
if (labelFormatter) {
|
|
1355
|
+
return /* @__PURE__ */ jsx4("div", { className: cn4("font-medium", labelClassName), children: labelFormatter(value, payload) });
|
|
1356
|
+
}
|
|
1357
|
+
if (!value) {
|
|
1358
|
+
return null;
|
|
1359
|
+
}
|
|
1360
|
+
return /* @__PURE__ */ jsx4("div", { className: cn4("font-medium", labelClassName), children: value });
|
|
1361
|
+
}, [
|
|
1362
|
+
label,
|
|
1363
|
+
labelFormatter,
|
|
1364
|
+
payload,
|
|
1365
|
+
hideLabel,
|
|
1366
|
+
labelClassName,
|
|
1367
|
+
config,
|
|
1368
|
+
labelKey
|
|
1369
|
+
]);
|
|
1370
|
+
if (!active || !payload?.length) {
|
|
1371
|
+
return null;
|
|
1372
|
+
}
|
|
1373
|
+
const nestLabel = payload.length === 1 && indicator !== "dot";
|
|
1374
|
+
return /* @__PURE__ */ jsxs3(
|
|
1375
|
+
"div",
|
|
1376
|
+
{
|
|
1377
|
+
"data-slot": "chart-tooltip-content",
|
|
1378
|
+
className: cn4(
|
|
1379
|
+
"border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl",
|
|
1380
|
+
className
|
|
1381
|
+
),
|
|
1382
|
+
children: [
|
|
1383
|
+
!nestLabel ? tooltipLabel : null,
|
|
1384
|
+
/* @__PURE__ */ jsx4("div", { className: "grid gap-1.5", children: payload.map((item, index) => {
|
|
1385
|
+
const key = `${nameKey || item.name || item.dataKey || "value"}`;
|
|
1386
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
1387
|
+
const indicatorColor = color || item.payload.fill || item.color;
|
|
1388
|
+
return /* @__PURE__ */ jsx4(
|
|
1389
|
+
"div",
|
|
1390
|
+
{
|
|
1391
|
+
className: cn4(
|
|
1392
|
+
"[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5",
|
|
1393
|
+
indicator === "dot" && "items-center"
|
|
1394
|
+
),
|
|
1395
|
+
children: formatter && item?.value !== void 0 && item.name ? formatter(item.value, item.name, item, index, item.payload) : /* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
1396
|
+
itemConfig?.icon ? /* @__PURE__ */ jsx4(itemConfig.icon, {}) : !hideIndicator && /* @__PURE__ */ jsx4(
|
|
1397
|
+
"div",
|
|
1107
1398
|
{
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1399
|
+
className: cn4(
|
|
1400
|
+
"shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
|
|
1401
|
+
{
|
|
1402
|
+
"h-2.5 w-2.5": indicator === "dot",
|
|
1403
|
+
"w-1": indicator === "line",
|
|
1404
|
+
"w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
|
|
1405
|
+
"my-0.5": nestLabel && indicator === "dashed"
|
|
1406
|
+
}
|
|
1407
|
+
),
|
|
1408
|
+
style: {
|
|
1409
|
+
"--color-bg": indicatorColor,
|
|
1410
|
+
"--color-border": indicatorColor
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
),
|
|
1414
|
+
/* @__PURE__ */ jsxs3(
|
|
1415
|
+
"div",
|
|
1416
|
+
{
|
|
1417
|
+
className: cn4(
|
|
1418
|
+
"flex flex-1 justify-between leading-none",
|
|
1419
|
+
nestLabel ? "items-end" : "items-center"
|
|
1420
|
+
),
|
|
1421
|
+
children: [
|
|
1422
|
+
/* @__PURE__ */ jsxs3("div", { className: "grid gap-1.5", children: [
|
|
1423
|
+
nestLabel ? tooltipLabel : null,
|
|
1424
|
+
/* @__PURE__ */ jsx4("span", { className: "text-muted-foreground", children: itemConfig?.label || item.name })
|
|
1425
|
+
] }),
|
|
1426
|
+
item.value && /* @__PURE__ */ jsx4("span", { className: "text-foreground font-mono font-medium tabular-nums", children: item.value.toLocaleString() })
|
|
1427
|
+
]
|
|
1428
|
+
}
|
|
1429
|
+
)
|
|
1430
|
+
] })
|
|
1431
|
+
},
|
|
1432
|
+
item.dataKey
|
|
1433
|
+
);
|
|
1434
|
+
}) })
|
|
1435
|
+
]
|
|
1436
|
+
}
|
|
1437
|
+
);
|
|
1438
|
+
}
|
|
1439
|
+
var ChartLegend = RechartsPrimitive.Legend;
|
|
1440
|
+
function ChartLegendContent({
|
|
1441
|
+
className,
|
|
1442
|
+
hideIcon = false,
|
|
1443
|
+
payload,
|
|
1444
|
+
verticalAlign = "bottom",
|
|
1445
|
+
nameKey
|
|
1446
|
+
}) {
|
|
1447
|
+
const { config } = useChart();
|
|
1448
|
+
if (!payload?.length) {
|
|
1449
|
+
return null;
|
|
1450
|
+
}
|
|
1451
|
+
return /* @__PURE__ */ jsx4(
|
|
1452
|
+
"div",
|
|
1453
|
+
{
|
|
1454
|
+
"data-slot": "chart-legend-content",
|
|
1455
|
+
className: cn4(
|
|
1456
|
+
"flex items-center justify-center gap-4",
|
|
1457
|
+
verticalAlign === "top" ? "pb-3" : "pt-3",
|
|
1458
|
+
className
|
|
1459
|
+
),
|
|
1460
|
+
children: payload.map((item) => {
|
|
1461
|
+
const key = `${nameKey || item.dataKey || "value"}`;
|
|
1462
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
1463
|
+
return /* @__PURE__ */ jsxs3(
|
|
1464
|
+
"div",
|
|
1465
|
+
{
|
|
1466
|
+
className: cn4(
|
|
1467
|
+
"[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"
|
|
1468
|
+
),
|
|
1469
|
+
children: [
|
|
1470
|
+
itemConfig?.icon && !hideIcon ? /* @__PURE__ */ jsx4(itemConfig.icon, {}) : /* @__PURE__ */ jsx4(
|
|
1471
|
+
"div",
|
|
1118
1472
|
{
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
className: "text-muted-foreground w-full justify-start",
|
|
1122
|
-
onClick: section.onShowMore,
|
|
1123
|
-
children: [
|
|
1124
|
-
"Show more",
|
|
1125
|
-
/* @__PURE__ */ jsx6(ChevronDown, { className: "ml-2 h-3 w-3" })
|
|
1126
|
-
]
|
|
1473
|
+
className: "h-2 w-2 shrink-0 rounded-[2px]",
|
|
1474
|
+
style: { backgroundColor: item.color }
|
|
1127
1475
|
}
|
|
1128
|
-
)
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
SearchResults.displayName = "SearchResults";
|
|
1137
|
-
var SearchResultItem = ({
|
|
1138
|
-
id,
|
|
1139
|
-
result,
|
|
1140
|
-
isActive,
|
|
1141
|
-
onClick
|
|
1142
|
-
}) => {
|
|
1143
|
-
const itemClasses = cn6(
|
|
1144
|
-
"hover:bg-accent hover:text-accent-foreground focus-visible:border-ring focus-visible:ring-ring/50 w-full rounded-md text-left transition-colors outline-none focus-visible:ring-[3px]",
|
|
1145
|
-
isActive && "bg-accent text-accent-foreground"
|
|
1476
|
+
),
|
|
1477
|
+
itemConfig?.label
|
|
1478
|
+
]
|
|
1479
|
+
},
|
|
1480
|
+
item.value
|
|
1481
|
+
);
|
|
1482
|
+
})
|
|
1483
|
+
}
|
|
1146
1484
|
);
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
id,
|
|
1152
|
-
role: "presentation",
|
|
1153
|
-
className: "text-muted-foreground p-2 text-sm font-medium",
|
|
1154
|
-
children: result.title
|
|
1155
|
-
}
|
|
1156
|
-
);
|
|
1485
|
+
}
|
|
1486
|
+
function getPayloadConfigFromPayload(config, payload, key) {
|
|
1487
|
+
if (typeof payload !== "object" || payload === null) {
|
|
1488
|
+
return void 0;
|
|
1157
1489
|
}
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
role: "option",
|
|
1165
|
-
"aria-selected": isActive,
|
|
1166
|
-
className: cn6(itemClasses, "p-2 text-sm"),
|
|
1167
|
-
onClick,
|
|
1168
|
-
children: result.title
|
|
1169
|
-
}
|
|
1170
|
-
);
|
|
1490
|
+
const payloadPayload = "payload" in payload && typeof payload.payload === "object" && payload.payload !== null ? payload.payload : void 0;
|
|
1491
|
+
let configLabelKey = key;
|
|
1492
|
+
if (key in payload && typeof payload[key] === "string") {
|
|
1493
|
+
configLabelKey = payload[key];
|
|
1494
|
+
} else if (payloadPayload && key in payloadPayload && typeof payloadPayload[key] === "string") {
|
|
1495
|
+
configLabelKey = payloadPayload[key];
|
|
1171
1496
|
}
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1497
|
+
return configLabelKey in config ? config[configLabelKey] : config[key];
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1500
|
+
// src/components/combobox/index.tsx
|
|
1501
|
+
import {
|
|
1502
|
+
Button as Button4,
|
|
1503
|
+
Popover,
|
|
1504
|
+
PopoverContent,
|
|
1505
|
+
PopoverTrigger
|
|
1506
|
+
} from "@foundrykit/primitives";
|
|
1507
|
+
import { cn as cn6 } from "@foundrykit/utils";
|
|
1508
|
+
import { CheckIcon, ChevronsUpDownIcon } from "lucide-react";
|
|
1509
|
+
import * as React5 from "react";
|
|
1510
|
+
|
|
1511
|
+
// src/components/command/index.tsx
|
|
1512
|
+
import {
|
|
1513
|
+
Dialog,
|
|
1514
|
+
DialogContent,
|
|
1515
|
+
DialogDescription,
|
|
1516
|
+
DialogHeader,
|
|
1517
|
+
DialogTitle
|
|
1518
|
+
} from "@foundrykit/primitives";
|
|
1519
|
+
import { cn as cn5 } from "@foundrykit/utils";
|
|
1520
|
+
import { Command as CommandPrimitive } from "cmdk";
|
|
1521
|
+
import { SearchIcon } from "lucide-react";
|
|
1522
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1523
|
+
function Command({
|
|
1524
|
+
className,
|
|
1525
|
+
...props
|
|
1526
|
+
}) {
|
|
1527
|
+
return /* @__PURE__ */ jsx5(
|
|
1528
|
+
CommandPrimitive,
|
|
1529
|
+
{
|
|
1530
|
+
"data-slot": "command",
|
|
1531
|
+
className: cn5(
|
|
1532
|
+
"bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",
|
|
1533
|
+
className
|
|
1534
|
+
),
|
|
1535
|
+
...props
|
|
1536
|
+
}
|
|
1537
|
+
);
|
|
1538
|
+
}
|
|
1539
|
+
function CommandDialog({
|
|
1540
|
+
title = "Command Palette",
|
|
1541
|
+
description = "Search for a command to run...",
|
|
1542
|
+
children,
|
|
1543
|
+
className,
|
|
1544
|
+
showCloseButton = true,
|
|
1545
|
+
...props
|
|
1546
|
+
}) {
|
|
1547
|
+
return /* @__PURE__ */ jsxs4(Dialog, { ...props, children: [
|
|
1548
|
+
/* @__PURE__ */ jsxs4(DialogHeader, { className: "sr-only", children: [
|
|
1549
|
+
/* @__PURE__ */ jsx5(DialogTitle, { children: title }),
|
|
1550
|
+
/* @__PURE__ */ jsx5(DialogDescription, { children: description })
|
|
1551
|
+
] }),
|
|
1552
|
+
/* @__PURE__ */ jsx5(
|
|
1553
|
+
DialogContent,
|
|
1175
1554
|
{
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
className: "h-12 w-12
|
|
1179
|
-
loading: "lazy"
|
|
1555
|
+
className: cn5("overflow-hidden p-0", className),
|
|
1556
|
+
showCloseButton,
|
|
1557
|
+
children: /* @__PURE__ */ jsx5(Command, { className: "[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5", children })
|
|
1180
1558
|
}
|
|
1181
|
-
)
|
|
1182
|
-
/* @__PURE__ */ jsxs5("div", { className: "min-w-0 flex-1", children: [
|
|
1183
|
-
/* @__PURE__ */ jsxs5("div", { className: "flex items-start justify-between gap-2", children: [
|
|
1184
|
-
/* @__PURE__ */ jsx6("h4", { className: "truncate text-sm font-semibold", children: result.title }),
|
|
1185
|
-
result.badge && /* @__PURE__ */ jsx6(Badge, { variant: "secondary", className: "text-xs", children: result.badge })
|
|
1186
|
-
] }),
|
|
1187
|
-
result.description && /* @__PURE__ */ jsx6("p", { className: "text-muted-foreground mt-1 line-clamp-2 text-xs", children: result.description })
|
|
1188
|
-
] })
|
|
1559
|
+
)
|
|
1189
1560
|
] });
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
href: result.href,
|
|
1198
|
-
className: cn6(itemClasses, "block"),
|
|
1199
|
-
onClick,
|
|
1200
|
-
children: content
|
|
1201
|
-
}
|
|
1202
|
-
);
|
|
1203
|
-
}
|
|
1204
|
-
return /* @__PURE__ */ jsx6(
|
|
1205
|
-
"button",
|
|
1561
|
+
}
|
|
1562
|
+
function CommandInput({
|
|
1563
|
+
className,
|
|
1564
|
+
...props
|
|
1565
|
+
}) {
|
|
1566
|
+
return /* @__PURE__ */ jsxs4(
|
|
1567
|
+
"div",
|
|
1206
1568
|
{
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1569
|
+
"data-slot": "command-input-wrapper",
|
|
1570
|
+
className: "flex h-9 items-center gap-2 border-b px-3",
|
|
1571
|
+
children: [
|
|
1572
|
+
/* @__PURE__ */ jsx5(SearchIcon, { className: "size-4 shrink-0 opacity-50" }),
|
|
1573
|
+
/* @__PURE__ */ jsx5(
|
|
1574
|
+
CommandPrimitive.Input,
|
|
1575
|
+
{
|
|
1576
|
+
"data-slot": "command-input",
|
|
1577
|
+
className: cn5(
|
|
1578
|
+
"placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",
|
|
1579
|
+
className
|
|
1580
|
+
),
|
|
1581
|
+
...props
|
|
1582
|
+
}
|
|
1583
|
+
)
|
|
1584
|
+
]
|
|
1585
|
+
}
|
|
1586
|
+
);
|
|
1587
|
+
}
|
|
1588
|
+
function CommandList({
|
|
1589
|
+
className,
|
|
1590
|
+
...props
|
|
1591
|
+
}) {
|
|
1592
|
+
return /* @__PURE__ */ jsx5(
|
|
1593
|
+
CommandPrimitive.List,
|
|
1594
|
+
{
|
|
1595
|
+
"data-slot": "command-list",
|
|
1596
|
+
className: cn5(
|
|
1597
|
+
"max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",
|
|
1598
|
+
className
|
|
1599
|
+
),
|
|
1600
|
+
...props
|
|
1601
|
+
}
|
|
1602
|
+
);
|
|
1603
|
+
}
|
|
1604
|
+
function CommandEmpty({
|
|
1605
|
+
...props
|
|
1606
|
+
}) {
|
|
1607
|
+
return /* @__PURE__ */ jsx5(
|
|
1608
|
+
CommandPrimitive.Empty,
|
|
1609
|
+
{
|
|
1610
|
+
"data-slot": "command-empty",
|
|
1611
|
+
className: "py-6 text-center text-sm",
|
|
1612
|
+
...props
|
|
1613
|
+
}
|
|
1614
|
+
);
|
|
1615
|
+
}
|
|
1616
|
+
function CommandGroup({
|
|
1617
|
+
className,
|
|
1618
|
+
...props
|
|
1619
|
+
}) {
|
|
1620
|
+
return /* @__PURE__ */ jsx5(
|
|
1621
|
+
CommandPrimitive.Group,
|
|
1622
|
+
{
|
|
1623
|
+
"data-slot": "command-group",
|
|
1624
|
+
className: cn5(
|
|
1625
|
+
"text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",
|
|
1626
|
+
className
|
|
1627
|
+
),
|
|
1628
|
+
...props
|
|
1629
|
+
}
|
|
1630
|
+
);
|
|
1631
|
+
}
|
|
1632
|
+
function CommandSeparator({
|
|
1633
|
+
className,
|
|
1634
|
+
...props
|
|
1635
|
+
}) {
|
|
1636
|
+
return /* @__PURE__ */ jsx5(
|
|
1637
|
+
CommandPrimitive.Separator,
|
|
1638
|
+
{
|
|
1639
|
+
"data-slot": "command-separator",
|
|
1640
|
+
className: cn5("bg-border -mx-1 h-px", className),
|
|
1641
|
+
...props
|
|
1642
|
+
}
|
|
1643
|
+
);
|
|
1644
|
+
}
|
|
1645
|
+
function CommandItem({
|
|
1646
|
+
className,
|
|
1647
|
+
...props
|
|
1648
|
+
}) {
|
|
1649
|
+
return /* @__PURE__ */ jsx5(
|
|
1650
|
+
CommandPrimitive.Item,
|
|
1651
|
+
{
|
|
1652
|
+
"data-slot": "command-item",
|
|
1653
|
+
className: cn5(
|
|
1654
|
+
"data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
1655
|
+
className
|
|
1656
|
+
),
|
|
1657
|
+
...props
|
|
1658
|
+
}
|
|
1659
|
+
);
|
|
1660
|
+
}
|
|
1661
|
+
function CommandShortcut({
|
|
1662
|
+
className,
|
|
1663
|
+
...props
|
|
1664
|
+
}) {
|
|
1665
|
+
return /* @__PURE__ */ jsx5(
|
|
1666
|
+
"span",
|
|
1667
|
+
{
|
|
1668
|
+
"data-slot": "command-shortcut",
|
|
1669
|
+
className: cn5(
|
|
1670
|
+
"text-muted-foreground ml-auto text-xs tracking-widest",
|
|
1671
|
+
className
|
|
1672
|
+
),
|
|
1673
|
+
...props
|
|
1214
1674
|
}
|
|
1215
1675
|
);
|
|
1216
|
-
}
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
const isControlled = open !== void 0;
|
|
1232
|
-
const isOpenState = isControlled ? open : isOpen;
|
|
1233
|
-
React4.useEffect(() => {
|
|
1234
|
-
if (previousOpenRef.current !== isOpen) {
|
|
1235
|
-
previousOpenRef.current = isOpen;
|
|
1236
|
-
onOpenChange?.(isOpen);
|
|
1237
|
-
}
|
|
1238
|
-
}, [isOpen, onOpenChange]);
|
|
1239
|
-
React4.useEffect(() => {
|
|
1240
|
-
if (!isOpenState) return;
|
|
1241
|
-
const handlePointerDown = (event) => {
|
|
1242
|
-
if (!rootRef.current?.contains(event.target)) {
|
|
1243
|
-
setActiveIndex(-1);
|
|
1244
|
-
setIsOpen(false);
|
|
1245
|
-
onOpenChange?.(false);
|
|
1246
|
-
}
|
|
1247
|
-
};
|
|
1248
|
-
const handleKeyDown = (event) => {
|
|
1249
|
-
if (event.key !== "Escape") return;
|
|
1250
|
-
setActiveIndex(-1);
|
|
1251
|
-
setIsOpen(false);
|
|
1252
|
-
onOpenChange?.(false);
|
|
1253
|
-
const focusTarget = rootRef.current?.querySelector(
|
|
1254
|
-
'input, button, [href], [tabindex]:not([tabindex="-1"])'
|
|
1255
|
-
);
|
|
1256
|
-
focusTarget?.focus();
|
|
1257
|
-
};
|
|
1258
|
-
document.addEventListener("pointerdown", handlePointerDown);
|
|
1259
|
-
document.addEventListener("keydown", handleKeyDown);
|
|
1260
|
-
return () => {
|
|
1261
|
-
document.removeEventListener("pointerdown", handlePointerDown);
|
|
1262
|
-
document.removeEventListener("keydown", handleKeyDown);
|
|
1263
|
-
};
|
|
1264
|
-
}, [isOpenState, onOpenChange, setActiveIndex, setIsOpen]);
|
|
1265
|
-
const setRefs = React4.useCallback(
|
|
1266
|
-
(node) => {
|
|
1267
|
-
rootRef.current = node;
|
|
1268
|
-
if (typeof ref === "function") {
|
|
1269
|
-
ref(node);
|
|
1270
|
-
} else if (ref) {
|
|
1271
|
-
ref.current = node;
|
|
1272
|
-
}
|
|
1273
|
-
},
|
|
1274
|
-
[ref]
|
|
1275
|
-
);
|
|
1276
|
-
const isSearchResultsChild = (child) => {
|
|
1277
|
-
if (!React4.isValidElement(child)) return false;
|
|
1278
|
-
const childType = child.type;
|
|
1279
|
-
return child.type === SearchResults || childType.displayName === SearchResults.displayName;
|
|
1280
|
-
};
|
|
1281
|
-
const childrenArray = React4.Children.toArray(children);
|
|
1282
|
-
const resultsChildren = childrenArray.filter(isSearchResultsChild);
|
|
1283
|
-
const triggerChildren = childrenArray.filter(
|
|
1284
|
-
(child) => !isSearchResultsChild(child)
|
|
1285
|
-
);
|
|
1286
|
-
const triggerElement = triggerChildren.length ? triggerChildren : /* @__PURE__ */ jsx6(SearchInput, {});
|
|
1287
|
-
const resultsElement = resultsChildren.length ? resultsChildren : /* @__PURE__ */ jsx6(SearchResults, {});
|
|
1288
|
-
const resultsPanel = isOpenState ? resultsMode === "inline" ? /* @__PURE__ */ jsx6("div", { className: cn6("w-full overflow-hidden", resultsClassName), children: resultsElement }) : /* @__PURE__ */ jsx6(
|
|
1289
|
-
"div",
|
|
1290
|
-
{
|
|
1291
|
-
className: cn6(
|
|
1292
|
-
"bg-popover text-popover-foreground border-border absolute left-0 top-full z-50 mt-1 max-h-[min(var(--results-max-height),calc(100vh-8rem))] w-full overflow-hidden rounded-md border shadow-lg",
|
|
1293
|
-
resultsClassName
|
|
1294
|
-
),
|
|
1295
|
-
children: resultsElement
|
|
1296
|
-
}
|
|
1297
|
-
) : null;
|
|
1298
|
-
return /* @__PURE__ */ jsxs5(
|
|
1299
|
-
"div",
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
// src/components/combobox/index.tsx
|
|
1679
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1680
|
+
function Combobox({
|
|
1681
|
+
options,
|
|
1682
|
+
value,
|
|
1683
|
+
onValueChange,
|
|
1684
|
+
placeholder = "Select an option..."
|
|
1685
|
+
}) {
|
|
1686
|
+
const [open, setOpen] = React5.useState(false);
|
|
1687
|
+
const selected = options.find((option) => option.value === value);
|
|
1688
|
+
return /* @__PURE__ */ jsxs5(Popover, { open, onOpenChange: setOpen, children: [
|
|
1689
|
+
/* @__PURE__ */ jsx6(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs5(
|
|
1690
|
+
Button4,
|
|
1300
1691
|
{
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1692
|
+
"data-slot": "combobox-trigger",
|
|
1693
|
+
variant: "outline",
|
|
1694
|
+
role: "combobox",
|
|
1695
|
+
"aria-expanded": open,
|
|
1696
|
+
className: "w-[200px] justify-between",
|
|
1305
1697
|
children: [
|
|
1306
|
-
|
|
1307
|
-
|
|
1698
|
+
selected ? selected.label : placeholder,
|
|
1699
|
+
/* @__PURE__ */ jsx6(ChevronsUpDownIcon, { className: "ml-2 size-4 shrink-0 opacity-50" })
|
|
1308
1700
|
]
|
|
1309
1701
|
}
|
|
1310
|
-
)
|
|
1311
|
-
|
|
1312
|
-
)
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1702
|
+
) }),
|
|
1703
|
+
/* @__PURE__ */ jsx6(PopoverContent, { "data-slot": "combobox-content", className: "w-[200px] p-0", children: /* @__PURE__ */ jsxs5(Command, { children: [
|
|
1704
|
+
/* @__PURE__ */ jsx6(CommandInput, { placeholder, className: "h-9" }),
|
|
1705
|
+
/* @__PURE__ */ jsxs5(CommandList, { children: [
|
|
1706
|
+
/* @__PURE__ */ jsx6(CommandEmpty, { children: "No option found." }),
|
|
1707
|
+
/* @__PURE__ */ jsx6(CommandGroup, { children: options.map((option) => /* @__PURE__ */ jsxs5(
|
|
1708
|
+
CommandItem,
|
|
1709
|
+
{
|
|
1710
|
+
value: option.value,
|
|
1711
|
+
onSelect: (currentValue) => {
|
|
1712
|
+
onValueChange?.(currentValue === value ? "" : currentValue);
|
|
1713
|
+
setOpen(false);
|
|
1714
|
+
},
|
|
1715
|
+
children: [
|
|
1716
|
+
option.label,
|
|
1717
|
+
/* @__PURE__ */ jsx6(
|
|
1718
|
+
CheckIcon,
|
|
1719
|
+
{
|
|
1720
|
+
className: cn6(
|
|
1721
|
+
"ml-auto size-4",
|
|
1722
|
+
value === option.value ? "opacity-100" : "opacity-0"
|
|
1723
|
+
)
|
|
1724
|
+
}
|
|
1725
|
+
)
|
|
1726
|
+
]
|
|
1727
|
+
},
|
|
1728
|
+
option.value
|
|
1729
|
+
)) })
|
|
1730
|
+
] })
|
|
1731
|
+
] }) })
|
|
1333
1732
|
] });
|
|
1334
|
-
}
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
// src/components/data-table/index.tsx
|
|
1736
|
+
import {
|
|
1737
|
+
Button as Button5,
|
|
1738
|
+
Table,
|
|
1739
|
+
TableBody,
|
|
1740
|
+
TableCell,
|
|
1741
|
+
TableHead,
|
|
1742
|
+
TableHeader,
|
|
1743
|
+
TableRow
|
|
1744
|
+
} from "@foundrykit/primitives";
|
|
1745
|
+
import {
|
|
1746
|
+
flexRender,
|
|
1747
|
+
getCoreRowModel,
|
|
1748
|
+
getPaginationRowModel,
|
|
1749
|
+
getSortedRowModel,
|
|
1750
|
+
useReactTable
|
|
1751
|
+
} from "@tanstack/react-table";
|
|
1752
|
+
import * as React6 from "react";
|
|
1753
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1754
|
+
function DataTable({
|
|
1755
|
+
columns,
|
|
1756
|
+
data
|
|
1757
|
+
}) {
|
|
1758
|
+
const [sorting, setSorting] = React6.useState([]);
|
|
1759
|
+
const table = useReactTable({
|
|
1760
|
+
data,
|
|
1761
|
+
columns,
|
|
1762
|
+
getCoreRowModel: getCoreRowModel(),
|
|
1763
|
+
getPaginationRowModel: getPaginationRowModel(),
|
|
1764
|
+
getSortedRowModel: getSortedRowModel(),
|
|
1765
|
+
onSortingChange: setSorting,
|
|
1766
|
+
state: {
|
|
1767
|
+
sorting
|
|
1365
1768
|
}
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1769
|
+
});
|
|
1770
|
+
return /* @__PURE__ */ jsxs6("div", { "data-slot": "data-table", className: "space-y-4", children: [
|
|
1771
|
+
/* @__PURE__ */ jsx7("div", { className: "rounded-md border", children: /* @__PURE__ */ jsxs6(Table, { children: [
|
|
1772
|
+
/* @__PURE__ */ jsx7(TableHeader, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx7(TableRow, { children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx7(TableHead, { children: header.isPlaceholder ? null : flexRender(
|
|
1773
|
+
header.column.columnDef.header,
|
|
1774
|
+
header.getContext()
|
|
1775
|
+
) }, header.id)) }, headerGroup.id)) }),
|
|
1776
|
+
/* @__PURE__ */ jsx7(TableBody, { children: table.getRowModel().rows?.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ jsx7(
|
|
1777
|
+
TableRow,
|
|
1370
1778
|
{
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1779
|
+
"data-state": row.getIsSelected() && "selected",
|
|
1780
|
+
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx7(TableCell, { children: flexRender(
|
|
1781
|
+
cell.column.columnDef.cell,
|
|
1782
|
+
cell.getContext()
|
|
1783
|
+
) }, cell.id))
|
|
1784
|
+
},
|
|
1785
|
+
row.id
|
|
1786
|
+
)) : /* @__PURE__ */ jsx7(TableRow, { children: /* @__PURE__ */ jsx7(
|
|
1787
|
+
TableCell,
|
|
1788
|
+
{
|
|
1789
|
+
colSpan: columns.length,
|
|
1790
|
+
className: "h-24 text-center",
|
|
1791
|
+
children: "No results."
|
|
1379
1792
|
}
|
|
1380
|
-
)
|
|
1381
|
-
}
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1793
|
+
) }) })
|
|
1794
|
+
] }) }),
|
|
1795
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex items-center justify-end gap-2", children: [
|
|
1796
|
+
/* @__PURE__ */ jsx7(
|
|
1797
|
+
Button5,
|
|
1385
1798
|
{
|
|
1386
|
-
|
|
1387
|
-
variant: "ghost",
|
|
1799
|
+
variant: "outline",
|
|
1388
1800
|
size: "sm",
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
children: /* @__PURE__ */ jsx6("span", { className: "text-sm", children: result.title })
|
|
1801
|
+
onClick: () => table.previousPage(),
|
|
1802
|
+
disabled: !table.getCanPreviousPage(),
|
|
1803
|
+
children: "Previous"
|
|
1393
1804
|
}
|
|
1394
|
-
)
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
);
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
(
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
return /* @__PURE__ */ jsx6(
|
|
1491
|
-
AdvancedSearchProvider,
|
|
1492
|
-
{
|
|
1493
|
-
onSearch: handleSearch,
|
|
1494
|
-
onResultSelect: handleResultSelect,
|
|
1495
|
-
debounceMs: 300,
|
|
1496
|
-
minQueryLength,
|
|
1497
|
-
emptyStateBehaviour,
|
|
1498
|
-
initialResults: emptyStateBehaviour === "show-all-results" ? mockSearchResults : [],
|
|
1499
|
-
children: /* @__PURE__ */ jsxs5(AdvancedSearchBar, { children: [
|
|
1500
|
-
useCustomTrigger ? /* @__PURE__ */ jsx6(SearchTrigger, { asChild: true, children: /* @__PURE__ */ jsxs5(Button4, { variant: "outline", className: "w-full justify-start", children: [
|
|
1501
|
-
/* @__PURE__ */ jsx6(Search2, { className: "mr-2 h-4 w-4" }),
|
|
1502
|
-
"Click to search..."
|
|
1503
|
-
] }) }) : /* @__PURE__ */ jsx6(
|
|
1504
|
-
SearchInput,
|
|
1805
|
+
),
|
|
1806
|
+
/* @__PURE__ */ jsx7(
|
|
1807
|
+
Button5,
|
|
1808
|
+
{
|
|
1809
|
+
variant: "outline",
|
|
1810
|
+
size: "sm",
|
|
1811
|
+
onClick: () => table.nextPage(),
|
|
1812
|
+
disabled: !table.getCanNextPage(),
|
|
1813
|
+
children: "Next"
|
|
1814
|
+
}
|
|
1815
|
+
)
|
|
1816
|
+
] })
|
|
1817
|
+
] });
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
// src/components/date-picker/index.tsx
|
|
1821
|
+
import { Button as Button6, Input as Input2 } from "@foundrykit/primitives";
|
|
1822
|
+
import { cn as cn7 } from "@foundrykit/utils";
|
|
1823
|
+
import { format } from "date-fns";
|
|
1824
|
+
import { Calendar as CalendarIcon } from "lucide-react";
|
|
1825
|
+
import * as React7 from "react";
|
|
1826
|
+
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1827
|
+
var WEEK_DAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
1828
|
+
var DatePicker = React7.forwardRef(
|
|
1829
|
+
({ value, onValueChange, placeholder = "Pick a date", className, disabled }, ref) => {
|
|
1830
|
+
const [open, setOpen] = React7.useState(false);
|
|
1831
|
+
const [selectedDate, setSelectedDate] = React7.useState(
|
|
1832
|
+
value
|
|
1833
|
+
);
|
|
1834
|
+
React7.useEffect(() => {
|
|
1835
|
+
setSelectedDate(value);
|
|
1836
|
+
}, [value]);
|
|
1837
|
+
const containerRef = React7.useRef(null);
|
|
1838
|
+
const toggleRef = React7.useRef(null);
|
|
1839
|
+
React7.useImperativeHandle(
|
|
1840
|
+
ref,
|
|
1841
|
+
() => containerRef.current
|
|
1842
|
+
);
|
|
1843
|
+
React7.useEffect(() => {
|
|
1844
|
+
if (!open) return;
|
|
1845
|
+
const onPointerDown = (e) => {
|
|
1846
|
+
if (!containerRef.current?.contains(e.target)) setOpen(false);
|
|
1847
|
+
};
|
|
1848
|
+
const onKeyDown = (e) => {
|
|
1849
|
+
if (e.key === "Escape") {
|
|
1850
|
+
setOpen(false);
|
|
1851
|
+
toggleRef.current?.focus();
|
|
1852
|
+
}
|
|
1853
|
+
};
|
|
1854
|
+
document.addEventListener("mousedown", onPointerDown);
|
|
1855
|
+
document.addEventListener("keydown", onKeyDown);
|
|
1856
|
+
return () => {
|
|
1857
|
+
document.removeEventListener("mousedown", onPointerDown);
|
|
1858
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
1859
|
+
};
|
|
1860
|
+
}, [open]);
|
|
1861
|
+
const handleDateSelect = (date) => {
|
|
1862
|
+
setSelectedDate(date);
|
|
1863
|
+
onValueChange?.(date);
|
|
1864
|
+
setOpen(false);
|
|
1865
|
+
toggleRef.current?.focus();
|
|
1866
|
+
};
|
|
1867
|
+
const handleInputChange = (e) => {
|
|
1868
|
+
const inputValue = e.target.value;
|
|
1869
|
+
if (inputValue) {
|
|
1870
|
+
const date = new Date(inputValue);
|
|
1871
|
+
if (!isNaN(date.getTime())) {
|
|
1872
|
+
setSelectedDate(date);
|
|
1873
|
+
onValueChange?.(date);
|
|
1874
|
+
}
|
|
1875
|
+
} else {
|
|
1876
|
+
setSelectedDate(void 0);
|
|
1877
|
+
onValueChange?.(void 0);
|
|
1878
|
+
}
|
|
1879
|
+
};
|
|
1880
|
+
const viewDate = selectedDate ?? /* @__PURE__ */ new Date();
|
|
1881
|
+
const currentMonth = viewDate.getMonth();
|
|
1882
|
+
const currentYear = viewDate.getFullYear();
|
|
1883
|
+
const monthLabel = format(viewDate, "MMMM yyyy");
|
|
1884
|
+
const calendarDays = React7.useMemo(() => {
|
|
1885
|
+
const firstDay = new Date(currentYear, currentMonth, 1);
|
|
1886
|
+
const daysInMonth = new Date(currentYear, currentMonth + 1, 0).getDate();
|
|
1887
|
+
const startingDayOfWeek = firstDay.getDay();
|
|
1888
|
+
const days = [];
|
|
1889
|
+
for (let i = 0; i < startingDayOfWeek; i++) days.push(null);
|
|
1890
|
+
for (let day = 1; day <= daysInMonth; day++) {
|
|
1891
|
+
days.push(new Date(currentYear, currentMonth, day));
|
|
1892
|
+
}
|
|
1893
|
+
return days;
|
|
1894
|
+
}, [currentMonth, currentYear]);
|
|
1895
|
+
const today = /* @__PURE__ */ new Date();
|
|
1896
|
+
const dialogId = React7.useId();
|
|
1897
|
+
return /* @__PURE__ */ jsxs7("div", { className: cn7("relative", className), ref: containerRef, children: [
|
|
1898
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex gap-2", children: [
|
|
1899
|
+
/* @__PURE__ */ jsx8(
|
|
1900
|
+
Input2,
|
|
1505
1901
|
{
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1902
|
+
type: "date",
|
|
1903
|
+
value: selectedDate ? format(selectedDate, "yyyy-MM-dd") : "",
|
|
1904
|
+
onChange: handleInputChange,
|
|
1905
|
+
placeholder,
|
|
1906
|
+
disabled,
|
|
1907
|
+
className: "flex-1"
|
|
1511
1908
|
}
|
|
1512
1909
|
),
|
|
1513
|
-
/* @__PURE__ */
|
|
1514
|
-
|
|
1910
|
+
/* @__PURE__ */ jsx8(
|
|
1911
|
+
Button6,
|
|
1515
1912
|
{
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1913
|
+
ref: toggleRef,
|
|
1914
|
+
type: "button",
|
|
1915
|
+
variant: "outline",
|
|
1916
|
+
onClick: () => setOpen(!open),
|
|
1917
|
+
disabled,
|
|
1918
|
+
className: "px-3",
|
|
1919
|
+
"aria-label": selectedDate ? `Change date, currently ${format(selectedDate, "PPP")}` : "Choose date",
|
|
1920
|
+
"aria-haspopup": "dialog",
|
|
1921
|
+
"aria-expanded": open,
|
|
1922
|
+
"aria-controls": open ? dialogId : void 0,
|
|
1923
|
+
children: /* @__PURE__ */ jsx8(CalendarIcon, { className: "h-4 w-4" })
|
|
1521
1924
|
}
|
|
1522
1925
|
)
|
|
1523
|
-
] })
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1926
|
+
] }),
|
|
1927
|
+
open && /* @__PURE__ */ jsxs7(
|
|
1928
|
+
"div",
|
|
1929
|
+
{
|
|
1930
|
+
id: dialogId,
|
|
1931
|
+
role: "dialog",
|
|
1932
|
+
"aria-label": `Choose date, ${monthLabel}`,
|
|
1933
|
+
className: "bg-popover absolute top-full z-50 mt-1 w-80 rounded-md border p-3 shadow-md",
|
|
1934
|
+
children: [
|
|
1935
|
+
/* @__PURE__ */ jsx8(
|
|
1936
|
+
"div",
|
|
1937
|
+
{
|
|
1938
|
+
"aria-hidden": "true",
|
|
1939
|
+
className: "text-foreground mb-2 text-center text-sm font-semibold",
|
|
1940
|
+
children: monthLabel
|
|
1941
|
+
}
|
|
1942
|
+
),
|
|
1943
|
+
/* @__PURE__ */ jsx8(
|
|
1944
|
+
"div",
|
|
1945
|
+
{
|
|
1946
|
+
className: "mb-2 grid grid-cols-7 gap-1 text-center text-sm font-medium",
|
|
1947
|
+
"aria-hidden": "true",
|
|
1948
|
+
children: WEEK_DAYS.map((day) => /* @__PURE__ */ jsx8("div", { className: "p-1", children: day }, day))
|
|
1949
|
+
}
|
|
1950
|
+
),
|
|
1951
|
+
/* @__PURE__ */ jsx8("div", { role: "grid", className: "grid grid-cols-7 gap-1", children: calendarDays.map((day, index) => {
|
|
1952
|
+
if (!day) {
|
|
1953
|
+
return /* @__PURE__ */ jsx8("div", { role: "presentation" }, `empty-${index}`);
|
|
1954
|
+
}
|
|
1955
|
+
const isSelected = selectedDate && day.toDateString() === selectedDate.toDateString();
|
|
1956
|
+
const isToday = day.toDateString() === today.toDateString();
|
|
1957
|
+
return /* @__PURE__ */ jsx8(
|
|
1958
|
+
"button",
|
|
1959
|
+
{
|
|
1960
|
+
type: "button",
|
|
1961
|
+
"aria-label": format(day, "PPPP"),
|
|
1962
|
+
"aria-pressed": isSelected,
|
|
1963
|
+
"aria-current": isToday ? "date" : void 0,
|
|
1964
|
+
className: cn7(
|
|
1965
|
+
"hover:bg-accent hover:text-accent-foreground rounded p-2 text-sm",
|
|
1966
|
+
isSelected ? "bg-primary text-primary-foreground" : isToday ? "bg-muted" : "text-muted-foreground"
|
|
1967
|
+
),
|
|
1968
|
+
onClick: () => handleDateSelect(day),
|
|
1969
|
+
children: day.getDate()
|
|
1970
|
+
},
|
|
1971
|
+
day.toDateString()
|
|
1972
|
+
);
|
|
1973
|
+
}) })
|
|
1974
|
+
]
|
|
1975
|
+
}
|
|
1976
|
+
)
|
|
1977
|
+
] });
|
|
1978
|
+
}
|
|
1979
|
+
);
|
|
1980
|
+
DatePicker.displayName = "DatePicker";
|
|
1527
1981
|
|
|
1528
1982
|
// src/components/form/index.tsx
|
|
1529
|
-
import
|
|
1983
|
+
import { Label } from "@foundrykit/primitives";
|
|
1984
|
+
import { cn as cn8 } from "@foundrykit/utils";
|
|
1530
1985
|
import { Slot as Slot2 } from "@radix-ui/react-slot";
|
|
1986
|
+
import * as React8 from "react";
|
|
1531
1987
|
import {
|
|
1532
1988
|
Controller,
|
|
1533
1989
|
FormProvider
|
|
1534
1990
|
} from "react-hook-form";
|
|
1535
|
-
import { cn as cn7 } from "@foundrykit/utils";
|
|
1536
|
-
import { Label } from "@foundrykit/primitives";
|
|
1537
1991
|
import {
|
|
1538
|
-
useFormField,
|
|
1539
1992
|
FormFieldContext,
|
|
1540
|
-
FormItemContext
|
|
1993
|
+
FormItemContext,
|
|
1994
|
+
useFormField
|
|
1541
1995
|
} from "@foundrykit/hooks";
|
|
1542
|
-
import { jsx as
|
|
1996
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
1543
1997
|
var Form = FormProvider;
|
|
1544
1998
|
var FormField = ({
|
|
1545
1999
|
...props
|
|
1546
2000
|
}) => {
|
|
1547
|
-
return /* @__PURE__ */
|
|
2001
|
+
return /* @__PURE__ */ jsx9(FormFieldContext.Provider, { value: { name: props.name }, children: /* @__PURE__ */ jsx9(Controller, { ...props }) });
|
|
1548
2002
|
};
|
|
1549
2003
|
function FormItem({ className, ...props }) {
|
|
1550
|
-
const id =
|
|
1551
|
-
return /* @__PURE__ */
|
|
2004
|
+
const id = React8.useId();
|
|
2005
|
+
return /* @__PURE__ */ jsx9(FormItemContext.Provider, { value: { id }, children: /* @__PURE__ */ jsx9(
|
|
1552
2006
|
"div",
|
|
1553
2007
|
{
|
|
1554
2008
|
"data-slot": "form-item",
|
|
1555
|
-
className:
|
|
2009
|
+
className: cn8("grid gap-2", className),
|
|
1556
2010
|
...props
|
|
1557
2011
|
}
|
|
1558
2012
|
) });
|
|
@@ -1562,12 +2016,12 @@ function FormLabel({
|
|
|
1562
2016
|
...props
|
|
1563
2017
|
}) {
|
|
1564
2018
|
const { error, formItemId } = useFormField();
|
|
1565
|
-
return /* @__PURE__ */
|
|
2019
|
+
return /* @__PURE__ */ jsx9(
|
|
1566
2020
|
Label,
|
|
1567
2021
|
{
|
|
1568
2022
|
"data-slot": "form-label",
|
|
1569
2023
|
"data-error": !!error,
|
|
1570
|
-
className:
|
|
2024
|
+
className: cn8("data-[error=true]:text-destructive", className),
|
|
1571
2025
|
htmlFor: formItemId,
|
|
1572
2026
|
...props
|
|
1573
2027
|
}
|
|
@@ -1575,7 +2029,7 @@ function FormLabel({
|
|
|
1575
2029
|
}
|
|
1576
2030
|
function FormControl({ ...props }) {
|
|
1577
2031
|
const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
|
|
1578
|
-
return /* @__PURE__ */
|
|
2032
|
+
return /* @__PURE__ */ jsx9(
|
|
1579
2033
|
Slot2,
|
|
1580
2034
|
{
|
|
1581
2035
|
"data-slot": "form-control",
|
|
@@ -1588,12 +2042,12 @@ function FormControl({ ...props }) {
|
|
|
1588
2042
|
}
|
|
1589
2043
|
function FormDescription({ className, ...props }) {
|
|
1590
2044
|
const { formDescriptionId } = useFormField();
|
|
1591
|
-
return /* @__PURE__ */
|
|
2045
|
+
return /* @__PURE__ */ jsx9(
|
|
1592
2046
|
"p",
|
|
1593
2047
|
{
|
|
1594
2048
|
"data-slot": "form-description",
|
|
1595
2049
|
id: formDescriptionId,
|
|
1596
|
-
className:
|
|
2050
|
+
className: cn8("text-muted-foreground text-sm", className),
|
|
1597
2051
|
...props
|
|
1598
2052
|
}
|
|
1599
2053
|
);
|
|
@@ -1604,25 +2058,255 @@ function FormMessage({ className, ...props }) {
|
|
|
1604
2058
|
if (!body) {
|
|
1605
2059
|
return null;
|
|
1606
2060
|
}
|
|
1607
|
-
return /* @__PURE__ */
|
|
2061
|
+
return /* @__PURE__ */ jsx9(
|
|
1608
2062
|
"p",
|
|
1609
2063
|
{
|
|
1610
2064
|
"data-slot": "form-message",
|
|
1611
2065
|
id: formMessageId,
|
|
1612
|
-
className:
|
|
2066
|
+
className: cn8("text-destructive text-sm", className),
|
|
1613
2067
|
...props,
|
|
1614
2068
|
children: body
|
|
1615
2069
|
}
|
|
1616
2070
|
);
|
|
1617
2071
|
}
|
|
1618
2072
|
|
|
1619
|
-
// src/index.
|
|
1620
|
-
import { cn as
|
|
2073
|
+
// src/components/input-otp/index.tsx
|
|
2074
|
+
import { cn as cn9 } from "@foundrykit/utils";
|
|
2075
|
+
import { OTPInput, OTPInputContext } from "input-otp";
|
|
2076
|
+
import { MinusIcon } from "lucide-react";
|
|
2077
|
+
import * as React9 from "react";
|
|
2078
|
+
import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2079
|
+
function InputOTP({
|
|
2080
|
+
className,
|
|
2081
|
+
containerClassName,
|
|
2082
|
+
...props
|
|
2083
|
+
}) {
|
|
2084
|
+
return /* @__PURE__ */ jsx10(
|
|
2085
|
+
OTPInput,
|
|
2086
|
+
{
|
|
2087
|
+
"data-slot": "input-otp",
|
|
2088
|
+
containerClassName: cn9(
|
|
2089
|
+
"flex items-center gap-2 has-disabled:opacity-50",
|
|
2090
|
+
containerClassName
|
|
2091
|
+
),
|
|
2092
|
+
className: cn9("disabled:cursor-not-allowed", className),
|
|
2093
|
+
...props
|
|
2094
|
+
}
|
|
2095
|
+
);
|
|
2096
|
+
}
|
|
2097
|
+
function InputOTPGroup({ className, ...props }) {
|
|
2098
|
+
return /* @__PURE__ */ jsx10(
|
|
2099
|
+
"div",
|
|
2100
|
+
{
|
|
2101
|
+
"data-slot": "input-otp-group",
|
|
2102
|
+
className: cn9("flex items-center", className),
|
|
2103
|
+
...props
|
|
2104
|
+
}
|
|
2105
|
+
);
|
|
2106
|
+
}
|
|
2107
|
+
function InputOTPSlot({
|
|
2108
|
+
index,
|
|
2109
|
+
className,
|
|
2110
|
+
...props
|
|
2111
|
+
}) {
|
|
2112
|
+
const inputOTPContext = React9.useContext(OTPInputContext);
|
|
2113
|
+
const { char, hasFakeCaret, isActive } = inputOTPContext?.slots[index] ?? {};
|
|
2114
|
+
return /* @__PURE__ */ jsxs8(
|
|
2115
|
+
"div",
|
|
2116
|
+
{
|
|
2117
|
+
"data-slot": "input-otp-slot",
|
|
2118
|
+
"data-active": isActive,
|
|
2119
|
+
className: cn9(
|
|
2120
|
+
"data-[active=true]:border-ring data-[active=true]:ring-ring/50 data-[active=true]:aria-invalid:ring-destructive/20 dark:data-[active=true]:aria-invalid:ring-destructive/40 aria-invalid:border-destructive data-[active=true]:aria-invalid:border-destructive dark:bg-input/30 border-input relative flex h-9 w-9 items-center justify-center border-y border-r text-sm shadow-xs transition-all outline-none first:rounded-l-md first:border-l last:rounded-r-md data-[active=true]:z-10 data-[active=true]:ring-[3px]",
|
|
2121
|
+
className
|
|
2122
|
+
),
|
|
2123
|
+
...props,
|
|
2124
|
+
children: [
|
|
2125
|
+
char,
|
|
2126
|
+
hasFakeCaret && /* @__PURE__ */ jsx10("div", { className: "pointer-events-none absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ jsx10("div", { className: "animate-caret-blink bg-foreground h-4 w-px duration-1000" }) })
|
|
2127
|
+
]
|
|
2128
|
+
}
|
|
2129
|
+
);
|
|
2130
|
+
}
|
|
2131
|
+
function InputOTPSeparator({ ...props }) {
|
|
2132
|
+
return /* @__PURE__ */ jsx10("div", { "data-slot": "input-otp-separator", role: "separator", ...props, children: /* @__PURE__ */ jsx10(MinusIcon, {}) });
|
|
2133
|
+
}
|
|
2134
|
+
|
|
2135
|
+
// src/components/pagination/index.tsx
|
|
2136
|
+
import { buttonVariants as buttonVariants2 } from "@foundrykit/primitives";
|
|
2137
|
+
import { cn as cn10 } from "@foundrykit/utils";
|
|
2138
|
+
import {
|
|
2139
|
+
ChevronLeftIcon as ChevronLeftIcon2,
|
|
2140
|
+
ChevronRightIcon as ChevronRightIcon2,
|
|
2141
|
+
MoreHorizontalIcon
|
|
2142
|
+
} from "lucide-react";
|
|
2143
|
+
import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2144
|
+
function Pagination({ className, ...props }) {
|
|
2145
|
+
return /* @__PURE__ */ jsx11(
|
|
2146
|
+
"nav",
|
|
2147
|
+
{
|
|
2148
|
+
"aria-label": "pagination",
|
|
2149
|
+
"data-slot": "pagination",
|
|
2150
|
+
className: cn10("mx-auto flex w-full justify-center", className),
|
|
2151
|
+
...props
|
|
2152
|
+
}
|
|
2153
|
+
);
|
|
2154
|
+
}
|
|
2155
|
+
function PaginationContent({
|
|
2156
|
+
className,
|
|
2157
|
+
...props
|
|
2158
|
+
}) {
|
|
2159
|
+
return /* @__PURE__ */ jsx11(
|
|
2160
|
+
"ul",
|
|
2161
|
+
{
|
|
2162
|
+
"data-slot": "pagination-content",
|
|
2163
|
+
className: cn10("flex flex-row items-center gap-1", className),
|
|
2164
|
+
...props
|
|
2165
|
+
}
|
|
2166
|
+
);
|
|
2167
|
+
}
|
|
2168
|
+
function PaginationItem({ ...props }) {
|
|
2169
|
+
return /* @__PURE__ */ jsx11("li", { "data-slot": "pagination-item", ...props });
|
|
2170
|
+
}
|
|
2171
|
+
function PaginationLink({
|
|
2172
|
+
className,
|
|
2173
|
+
isActive,
|
|
2174
|
+
size = "icon",
|
|
2175
|
+
...props
|
|
2176
|
+
}) {
|
|
2177
|
+
return /* @__PURE__ */ jsx11(
|
|
2178
|
+
"a",
|
|
2179
|
+
{
|
|
2180
|
+
"aria-current": isActive ? "page" : void 0,
|
|
2181
|
+
"data-slot": "pagination-link",
|
|
2182
|
+
"data-active": isActive,
|
|
2183
|
+
className: cn10(
|
|
2184
|
+
buttonVariants2({
|
|
2185
|
+
variant: isActive ? "outline" : "ghost",
|
|
2186
|
+
size
|
|
2187
|
+
}),
|
|
2188
|
+
className
|
|
2189
|
+
),
|
|
2190
|
+
...props
|
|
2191
|
+
}
|
|
2192
|
+
);
|
|
2193
|
+
}
|
|
2194
|
+
function PaginationPrevious({
|
|
2195
|
+
className,
|
|
2196
|
+
...props
|
|
2197
|
+
}) {
|
|
2198
|
+
return /* @__PURE__ */ jsxs9(
|
|
2199
|
+
PaginationLink,
|
|
2200
|
+
{
|
|
2201
|
+
"aria-label": "Go to previous page",
|
|
2202
|
+
size: "default",
|
|
2203
|
+
className: cn10("gap-1 px-2.5 sm:pl-2.5", className),
|
|
2204
|
+
...props,
|
|
2205
|
+
children: [
|
|
2206
|
+
/* @__PURE__ */ jsx11(ChevronLeftIcon2, {}),
|
|
2207
|
+
/* @__PURE__ */ jsx11("span", { className: "hidden sm:block", children: "Previous" })
|
|
2208
|
+
]
|
|
2209
|
+
}
|
|
2210
|
+
);
|
|
2211
|
+
}
|
|
2212
|
+
function PaginationNext({
|
|
2213
|
+
className,
|
|
2214
|
+
...props
|
|
2215
|
+
}) {
|
|
2216
|
+
return /* @__PURE__ */ jsxs9(
|
|
2217
|
+
PaginationLink,
|
|
2218
|
+
{
|
|
2219
|
+
"aria-label": "Go to next page",
|
|
2220
|
+
size: "default",
|
|
2221
|
+
className: cn10("gap-1 px-2.5 sm:pr-2.5", className),
|
|
2222
|
+
...props,
|
|
2223
|
+
children: [
|
|
2224
|
+
/* @__PURE__ */ jsx11("span", { className: "hidden sm:block", children: "Next" }),
|
|
2225
|
+
/* @__PURE__ */ jsx11(ChevronRightIcon2, {})
|
|
2226
|
+
]
|
|
2227
|
+
}
|
|
2228
|
+
);
|
|
2229
|
+
}
|
|
2230
|
+
function PaginationEllipsis({
|
|
2231
|
+
className,
|
|
2232
|
+
...props
|
|
2233
|
+
}) {
|
|
2234
|
+
return /* @__PURE__ */ jsxs9(
|
|
2235
|
+
"span",
|
|
2236
|
+
{
|
|
2237
|
+
"aria-hidden": true,
|
|
2238
|
+
"data-slot": "pagination-ellipsis",
|
|
2239
|
+
className: cn10("flex size-9 items-center justify-center", className),
|
|
2240
|
+
...props,
|
|
2241
|
+
children: [
|
|
2242
|
+
/* @__PURE__ */ jsx11(MoreHorizontalIcon, { className: "size-4" }),
|
|
2243
|
+
/* @__PURE__ */ jsx11("span", { className: "sr-only", children: "More pages" })
|
|
2244
|
+
]
|
|
2245
|
+
}
|
|
2246
|
+
);
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
// src/components/search-bar/index.tsx
|
|
2250
|
+
import { Input as Input3 } from "@foundrykit/primitives";
|
|
2251
|
+
import { cn as cn11 } from "@foundrykit/utils";
|
|
2252
|
+
import { Search as Search2 } from "lucide-react";
|
|
2253
|
+
import * as React10 from "react";
|
|
2254
|
+
import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2255
|
+
var SearchBar = React10.forwardRef(
|
|
2256
|
+
({
|
|
2257
|
+
className,
|
|
2258
|
+
onSearch,
|
|
2259
|
+
placeholder = "Search...",
|
|
2260
|
+
value: externalValue,
|
|
2261
|
+
onChange: externalOnChange,
|
|
2262
|
+
...props
|
|
2263
|
+
}, ref) => {
|
|
2264
|
+
const [internalQuery, setInternalQuery] = React10.useState("");
|
|
2265
|
+
const query = externalValue !== void 0 ? externalValue : internalQuery;
|
|
2266
|
+
const isControlled = externalValue !== void 0;
|
|
2267
|
+
const handleChange = (e) => {
|
|
2268
|
+
const value = e.target.value;
|
|
2269
|
+
if (!isControlled) {
|
|
2270
|
+
setInternalQuery(value);
|
|
2271
|
+
}
|
|
2272
|
+
onSearch?.(value);
|
|
2273
|
+
externalOnChange?.(e);
|
|
2274
|
+
};
|
|
2275
|
+
return /* @__PURE__ */ jsxs10("div", { className: cn11("relative", className), children: [
|
|
2276
|
+
/* @__PURE__ */ jsx12(Search2, { className: "text-muted-foreground absolute top-1/2 left-3 h-4 w-4 -translate-y-1/2" }),
|
|
2277
|
+
/* @__PURE__ */ jsx12(
|
|
2278
|
+
Input3,
|
|
2279
|
+
{
|
|
2280
|
+
ref,
|
|
2281
|
+
type: "search",
|
|
2282
|
+
placeholder,
|
|
2283
|
+
value: query,
|
|
2284
|
+
onChange: handleChange,
|
|
2285
|
+
className: "pl-10",
|
|
2286
|
+
...props
|
|
2287
|
+
}
|
|
2288
|
+
)
|
|
2289
|
+
] });
|
|
2290
|
+
}
|
|
2291
|
+
);
|
|
2292
|
+
SearchBar.displayName = "SearchBar";
|
|
1621
2293
|
export {
|
|
1622
2294
|
AdvancedSearchBar,
|
|
1623
2295
|
AdvancedSearchBarWrapper,
|
|
1624
2296
|
AdvancedSearchProvider,
|
|
1625
2297
|
Calendar,
|
|
2298
|
+
Carousel,
|
|
2299
|
+
CarouselContent,
|
|
2300
|
+
CarouselItem,
|
|
2301
|
+
CarouselNext,
|
|
2302
|
+
CarouselPrevious,
|
|
2303
|
+
ChartContainer,
|
|
2304
|
+
ChartLegend,
|
|
2305
|
+
ChartLegendContent,
|
|
2306
|
+
ChartStyle,
|
|
2307
|
+
ChartTooltip,
|
|
2308
|
+
ChartTooltipContent,
|
|
2309
|
+
Combobox,
|
|
1626
2310
|
Command,
|
|
1627
2311
|
CommandDialog,
|
|
1628
2312
|
CommandEmpty,
|
|
@@ -1632,6 +2316,7 @@ export {
|
|
|
1632
2316
|
CommandList,
|
|
1633
2317
|
CommandSeparator,
|
|
1634
2318
|
CommandShortcut,
|
|
2319
|
+
DataTable,
|
|
1635
2320
|
DatePicker,
|
|
1636
2321
|
Form,
|
|
1637
2322
|
FormControl,
|
|
@@ -1640,6 +2325,10 @@ export {
|
|
|
1640
2325
|
FormItem,
|
|
1641
2326
|
FormLabel,
|
|
1642
2327
|
FormMessage,
|
|
2328
|
+
InputOTP,
|
|
2329
|
+
InputOTPGroup,
|
|
2330
|
+
InputOTPSeparator,
|
|
2331
|
+
InputOTPSlot,
|
|
1643
2332
|
Pagination,
|
|
1644
2333
|
PaginationContent,
|
|
1645
2334
|
PaginationEllipsis,
|
|
@@ -1653,7 +2342,8 @@ export {
|
|
|
1653
2342
|
SearchResults,
|
|
1654
2343
|
SearchSection,
|
|
1655
2344
|
SearchTrigger,
|
|
1656
|
-
|
|
2345
|
+
cn12 as cn,
|
|
2346
|
+
useChart,
|
|
1657
2347
|
useFormField
|
|
1658
2348
|
};
|
|
1659
2349
|
//# sourceMappingURL=index.js.map
|