@krak-stack/registry 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -0
- package/dist/components/ui/alert-dialog.d.ts +18 -0
- package/dist/components/ui/app-brand.d.ts +26 -0
- package/dist/components/ui/app-brand.js +78 -0
- package/dist/components/ui/attachment.d.ts +23 -0
- package/dist/components/ui/badge.d.ts +7 -0
- package/dist/components/ui/button.d.ts +8 -0
- package/dist/components/ui/card.d.ts +11 -0
- package/dist/components/ui/checkbox.d.ts +3 -0
- package/dist/components/ui/code-block.d.ts +14 -0
- package/dist/components/ui/code-block.js +224 -0
- package/dist/components/ui/command.d.ts +18 -0
- package/dist/components/ui/copy-button.d.ts +18 -0
- package/dist/components/ui/copy-button.js +133 -0
- package/dist/components/ui/data-table.d.ts +264 -0
- package/dist/components/ui/data-table.js +3594 -0
- package/dist/components/ui/dialog.d.ts +13 -0
- package/dist/components/ui/dropdown-menu.d.ts +29 -0
- package/dist/components/ui/editing-locale-switcher.d.ts +7 -0
- package/dist/components/ui/editing-locale-switcher.js +626 -0
- package/dist/components/ui/effect-form.d.ts +137 -0
- package/dist/components/ui/effect-form.js +2330 -0
- package/dist/components/ui/field.d.ts +24 -0
- package/dist/components/ui/file-picker.d.ts +30 -0
- package/dist/components/ui/file-picker.js +811 -0
- package/dist/components/ui/form.d.ts +402 -0
- package/dist/components/ui/form.js +2245 -0
- package/dist/components/ui/google-map.d.ts +103 -0
- package/dist/components/ui/google-map.js +754 -0
- package/dist/components/ui/icon-input.d.ts +9 -0
- package/dist/components/ui/icon-input.js +971 -0
- package/dist/components/ui/input-group.d.ts +17 -0
- package/dist/components/ui/input.d.ts +3 -0
- package/dist/components/ui/label.d.ts +3 -0
- package/dist/components/ui/loading.d.ts +7 -0
- package/dist/components/ui/loading.js +467 -0
- package/dist/components/ui/locale-switcher.d.ts +7 -0
- package/dist/components/ui/locale-switcher.js +632 -0
- package/dist/components/ui/pagination.d.ts +43 -0
- package/dist/components/ui/pagination.js +787 -0
- package/dist/components/ui/popover.d.ts +9 -0
- package/dist/components/ui/scroll-area.d.ts +4 -0
- package/dist/components/ui/search-menu.d.ts +34 -0
- package/dist/components/ui/search-menu.js +839 -0
- package/dist/components/ui/select.d.ts +15 -0
- package/dist/components/ui/separator.d.ts +3 -0
- package/dist/components/ui/sheet.d.ts +14 -0
- package/dist/components/ui/sidebar-layout.d.ts +29 -0
- package/dist/components/ui/sidebar-layout.js +755 -0
- package/dist/components/ui/sidebar.d.ts +63 -0
- package/dist/components/ui/skeleton.d.ts +2 -0
- package/dist/components/ui/stats-card.d.ts +12 -0
- package/dist/components/ui/stats-card.js +125 -0
- package/dist/components/ui/table.d.ts +10 -0
- package/dist/components/ui/textarea.d.ts +3 -0
- package/dist/components/ui/theme-switcher.d.ts +29 -0
- package/dist/components/ui/theme-switcher.js +775 -0
- package/dist/components/ui/tooltip.d.ts +6 -0
- package/dist/components/ui/virtualized-combobox.d.ts +54 -0
- package/dist/components/ui/virtualized-combobox.js +821 -0
- package/dist/hooks/use-mobile.d.ts +1 -0
- package/dist/lib/query.d.ts +49 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/paraglide/runtime.d.ts +978 -0
- package/dist/services/embedding.d.ts +2 -0
- package/dist/services/embedding.js +23 -0
- package/dist/services/notification/channels/index.d.ts +22 -0
- package/dist/services/notification/channels/index.js +11 -0
- package/dist/services/notification/channels/ses/index.d.ts +51 -0
- package/dist/services/notification/channels/ses/index.js +145 -0
- package/dist/services/notification/channels/ses/schema.d.ts +13 -0
- package/dist/services/notification/channels/ses/schema.js +35 -0
- package/dist/services/notification/index.d.ts +15 -0
- package/dist/services/notification/index.js +67 -0
- package/dist/services/notification/schema.d.ts +10 -0
- package/dist/services/notification/schema.js +30 -0
- package/dist/services/opentelemetry.d.ts +8 -0
- package/dist/services/opentelemetry.js +23 -0
- package/dist/services/s3/index.d.ts +62 -0
- package/dist/services/s3/index.js +208 -0
- package/dist/services/s3/schema.d.ts +18 -0
- package/dist/services/s3/schema.js +37 -0
- package/package.json +218 -0
- package/tailwind.css +1 -0
|
@@ -0,0 +1,971 @@
|
|
|
1
|
+
// ../../src/components/ui/icon-input.tsx
|
|
2
|
+
import { useAtomValue } from "@effect/atom-react";
|
|
3
|
+
import { Effect, Schema } from "effect";
|
|
4
|
+
import {
|
|
5
|
+
FetchHttpClient,
|
|
6
|
+
HttpClient,
|
|
7
|
+
HttpClientRequest,
|
|
8
|
+
HttpClientResponse
|
|
9
|
+
} from "effect/unstable/http";
|
|
10
|
+
import { AsyncResult, Atom } from "effect/unstable/reactivity";
|
|
11
|
+
import { useDeferredValue, useState } from "react";
|
|
12
|
+
import { Icon } from "@iconify/react";
|
|
13
|
+
import { ExternalLink, Search } from "lucide-react";
|
|
14
|
+
|
|
15
|
+
// ../../src/components/ui/button.tsx
|
|
16
|
+
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
17
|
+
import { cva } from "class-variance-authority";
|
|
18
|
+
|
|
19
|
+
// ../../src/lib/utils.ts
|
|
20
|
+
import { clsx } from "clsx";
|
|
21
|
+
import { twMerge } from "tailwind-merge";
|
|
22
|
+
function cn(...inputs) {
|
|
23
|
+
return twMerge(clsx(inputs));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// ../../src/components/ui/button.tsx
|
|
27
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
28
|
+
var buttonVariants = cva("group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
|
|
29
|
+
variants: {
|
|
30
|
+
variant: {
|
|
31
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/80",
|
|
32
|
+
outline: "border-border bg-background shadow-xs hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
|
|
33
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
|
|
34
|
+
ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
|
35
|
+
destructive: "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
|
|
36
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
37
|
+
},
|
|
38
|
+
size: {
|
|
39
|
+
default: "h-9 gap-1.5 px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
40
|
+
xs: "h-6 gap-1 rounded-[min(var(--radius-md),8px)] px-2 text-xs in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
|
|
41
|
+
sm: "h-8 gap-1 rounded-[min(var(--radius-md),10px)] px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5",
|
|
42
|
+
lg: "h-10 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
43
|
+
icon: "size-9",
|
|
44
|
+
"icon-xs": "size-6 rounded-[min(var(--radius-md),8px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3",
|
|
45
|
+
"icon-sm": "size-8 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md",
|
|
46
|
+
"icon-lg": "size-10"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
defaultVariants: {
|
|
50
|
+
variant: "default",
|
|
51
|
+
size: "default"
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
function Button({
|
|
55
|
+
className,
|
|
56
|
+
variant = "default",
|
|
57
|
+
size = "default",
|
|
58
|
+
...props
|
|
59
|
+
}) {
|
|
60
|
+
return /* @__PURE__ */ jsxDEV(ButtonPrimitive, {
|
|
61
|
+
"data-slot": "button",
|
|
62
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
63
|
+
...props
|
|
64
|
+
}, undefined, false, undefined, this);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// ../../src/components/ui/virtualized-combobox.tsx
|
|
68
|
+
import { Combobox as ComboboxPrimitive } from "@base-ui/react";
|
|
69
|
+
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
70
|
+
import { Check, ChevronsUpDown } from "lucide-react";
|
|
71
|
+
import {
|
|
72
|
+
useCallback,
|
|
73
|
+
useImperativeHandle,
|
|
74
|
+
useRef
|
|
75
|
+
} from "react";
|
|
76
|
+
|
|
77
|
+
// ../../src/components/ui/input-group.tsx
|
|
78
|
+
import { cva as cva2 } from "class-variance-authority";
|
|
79
|
+
|
|
80
|
+
// ../../src/components/ui/input.tsx
|
|
81
|
+
import { Input as InputPrimitive } from "@base-ui/react/input";
|
|
82
|
+
import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
|
|
83
|
+
function Input({ className, type, ...props }) {
|
|
84
|
+
return /* @__PURE__ */ jsxDEV2(InputPrimitive, {
|
|
85
|
+
type,
|
|
86
|
+
"data-slot": "input",
|
|
87
|
+
className: cn("h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-2.5 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40", className),
|
|
88
|
+
...props
|
|
89
|
+
}, undefined, false, undefined, this);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// ../../src/components/ui/textarea.tsx
|
|
93
|
+
import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
|
|
94
|
+
|
|
95
|
+
// ../../src/components/ui/input-group.tsx
|
|
96
|
+
import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
|
|
97
|
+
function InputGroup({ className, ...props }) {
|
|
98
|
+
return /* @__PURE__ */ jsxDEV4("div", {
|
|
99
|
+
"data-slot": "input-group",
|
|
100
|
+
role: "group",
|
|
101
|
+
className: cn("group/input-group relative flex h-9 w-full min-w-0 items-center rounded-md border border-input shadow-xs transition-[color,box-shadow] outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5", className),
|
|
102
|
+
...props
|
|
103
|
+
}, undefined, false, undefined, this);
|
|
104
|
+
}
|
|
105
|
+
var inputGroupAddonVariants = cva2("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4", {
|
|
106
|
+
variants: {
|
|
107
|
+
align: {
|
|
108
|
+
"inline-start": "order-first pl-2 has-[>button]:-ml-1 has-[>kbd]:ml-[-0.15rem]",
|
|
109
|
+
"inline-end": "order-last pr-2 has-[>button]:-mr-1 has-[>kbd]:mr-[-0.15rem]",
|
|
110
|
+
"block-start": "order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2",
|
|
111
|
+
"block-end": "order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2"
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
defaultVariants: { align: "inline-start" }
|
|
115
|
+
});
|
|
116
|
+
var inputGroupButtonVariants = cva2("flex items-center gap-2 text-sm shadow-none", {
|
|
117
|
+
variants: {
|
|
118
|
+
size: {
|
|
119
|
+
xs: "h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",
|
|
120
|
+
sm: "",
|
|
121
|
+
"icon-xs": "size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0",
|
|
122
|
+
"icon-sm": "size-8 p-0 has-[>svg]:p-0"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
defaultVariants: { size: "xs" }
|
|
126
|
+
});
|
|
127
|
+
function InputGroupInput({
|
|
128
|
+
className,
|
|
129
|
+
...props
|
|
130
|
+
}) {
|
|
131
|
+
return /* @__PURE__ */ jsxDEV4(Input, {
|
|
132
|
+
"data-slot": "input-group-control",
|
|
133
|
+
className: cn("flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 aria-invalid:ring-0 dark:bg-transparent", className),
|
|
134
|
+
...props
|
|
135
|
+
}, undefined, false, undefined, this);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// ../../src/paraglide/runtime.js
|
|
139
|
+
import"@inlang/paraglide-js/urlpattern-polyfill";
|
|
140
|
+
var baseLocale = "en";
|
|
141
|
+
var locales = ["en", "fr"];
|
|
142
|
+
var cookieName = "locale";
|
|
143
|
+
var cookieMaxAge = 34560000;
|
|
144
|
+
var cookieDomain = "";
|
|
145
|
+
var localStorageKey = "PARAGLIDE_LOCALE";
|
|
146
|
+
var strategy = [
|
|
147
|
+
"url",
|
|
148
|
+
"cookie",
|
|
149
|
+
"preferredLanguage",
|
|
150
|
+
"baseLocale"
|
|
151
|
+
];
|
|
152
|
+
var routeStrategies = [
|
|
153
|
+
{
|
|
154
|
+
match: "/api/:path(.*)?",
|
|
155
|
+
exclude: true
|
|
156
|
+
}
|
|
157
|
+
];
|
|
158
|
+
var urlPatterns = [
|
|
159
|
+
{
|
|
160
|
+
pattern: "/:path(.*)?",
|
|
161
|
+
localized: [
|
|
162
|
+
[
|
|
163
|
+
"en",
|
|
164
|
+
"/en/:path(.*)?"
|
|
165
|
+
],
|
|
166
|
+
[
|
|
167
|
+
"fr",
|
|
168
|
+
"/fr/:path(.*)?"
|
|
169
|
+
]
|
|
170
|
+
]
|
|
171
|
+
}
|
|
172
|
+
];
|
|
173
|
+
var cachedRouteStrategyUrl;
|
|
174
|
+
var cachedRouteStrategy;
|
|
175
|
+
function findMatchingRouteStrategy(url) {
|
|
176
|
+
if (routeStrategies.length === 0) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
const urlString = typeof url === "string" ? url : url.href;
|
|
180
|
+
if (cachedRouteStrategyUrl === urlString) {
|
|
181
|
+
return cachedRouteStrategy;
|
|
182
|
+
}
|
|
183
|
+
const urlObject = new URL(urlString, "http://dummy.com");
|
|
184
|
+
let match;
|
|
185
|
+
for (const routeStrategy of routeStrategies) {
|
|
186
|
+
const pattern = new URLPattern(routeStrategy.match, urlObject.href);
|
|
187
|
+
if (pattern.exec(urlObject.href)) {
|
|
188
|
+
match = routeStrategy;
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
cachedRouteStrategyUrl = urlString;
|
|
193
|
+
cachedRouteStrategy = match;
|
|
194
|
+
return match;
|
|
195
|
+
}
|
|
196
|
+
function getStrategyForUrl(url) {
|
|
197
|
+
const routeStrategy = findMatchingRouteStrategy(url);
|
|
198
|
+
if (routeStrategy && routeStrategy.exclude !== true && Array.isArray(routeStrategy.strategy)) {
|
|
199
|
+
return routeStrategy.strategy;
|
|
200
|
+
}
|
|
201
|
+
return strategy;
|
|
202
|
+
}
|
|
203
|
+
var serverAsyncLocalStorage = undefined;
|
|
204
|
+
var isServer = import.meta.env?.SSR ?? typeof window === "undefined";
|
|
205
|
+
var experimentalStaticLocale = undefined;
|
|
206
|
+
var TREE_SHAKE_COOKIE_STRATEGY_USED = true;
|
|
207
|
+
var TREE_SHAKE_URL_STRATEGY_USED = true;
|
|
208
|
+
var TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED = false;
|
|
209
|
+
var TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED = true;
|
|
210
|
+
var TREE_SHAKE_DEFAULT_URL_PATTERN_USED = false;
|
|
211
|
+
var TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED = false;
|
|
212
|
+
globalThis.__paraglide = globalThis.__paraglide ?? {};
|
|
213
|
+
globalThis.__paraglide.ssr = globalThis.__paraglide.ssr ?? {};
|
|
214
|
+
var _locale;
|
|
215
|
+
var localeInitiallySet = false;
|
|
216
|
+
var getLocale = () => {
|
|
217
|
+
if (experimentalStaticLocale !== undefined) {
|
|
218
|
+
return experimentalStaticLocale;
|
|
219
|
+
}
|
|
220
|
+
if (serverAsyncLocalStorage) {
|
|
221
|
+
const locale = serverAsyncLocalStorage?.getStore()?.locale;
|
|
222
|
+
if (locale) {
|
|
223
|
+
return locale;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
let strategyToUse = strategy;
|
|
227
|
+
if (!isServer && typeof window !== "undefined" && window.location?.href) {
|
|
228
|
+
strategyToUse = getStrategyForUrl(window.location.href);
|
|
229
|
+
}
|
|
230
|
+
const resolved = resolveLocaleWithStrategies(strategyToUse, typeof window !== "undefined" ? window.location?.href : undefined);
|
|
231
|
+
if (resolved) {
|
|
232
|
+
if (!localeInitiallySet) {
|
|
233
|
+
_locale = resolved;
|
|
234
|
+
localeInitiallySet = true;
|
|
235
|
+
setLocale(resolved, { reload: false });
|
|
236
|
+
}
|
|
237
|
+
return resolved;
|
|
238
|
+
}
|
|
239
|
+
throw new Error("No locale found. Read the docs https://paraglidejs.com/errors#no-locale-found");
|
|
240
|
+
};
|
|
241
|
+
function resolveLocaleWithStrategies(strategyToUse, urlForUrlStrategy) {
|
|
242
|
+
let locale;
|
|
243
|
+
for (const strat of strategyToUse) {
|
|
244
|
+
if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === "cookie") {
|
|
245
|
+
locale = extractLocaleFromCookie();
|
|
246
|
+
} else if (strat === "baseLocale") {
|
|
247
|
+
locale = baseLocale;
|
|
248
|
+
} else if (TREE_SHAKE_URL_STRATEGY_USED && strat === "url" && !isServer && typeof urlForUrlStrategy === "string") {
|
|
249
|
+
locale = extractLocaleFromUrl(urlForUrlStrategy);
|
|
250
|
+
} else if (TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED && strat === "globalVariable" && _locale !== undefined) {
|
|
251
|
+
locale = _locale;
|
|
252
|
+
} else if (TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED && strat === "preferredLanguage" && !isServer) {
|
|
253
|
+
locale = extractLocaleFromNavigator();
|
|
254
|
+
} else if (TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED && strat === "localStorage" && !isServer) {
|
|
255
|
+
locale = localStorage.getItem(localStorageKey) ?? undefined;
|
|
256
|
+
} else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
|
|
257
|
+
const handler = customClientStrategies.get(strat);
|
|
258
|
+
if (handler) {
|
|
259
|
+
const result = handler.getLocale();
|
|
260
|
+
if (result instanceof Promise) {
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
if (result !== undefined) {
|
|
264
|
+
return assertIsLocale(result);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
const matchedLocale = toLocale(locale);
|
|
269
|
+
if (matchedLocale) {
|
|
270
|
+
return matchedLocale;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
var rtlLanguages = new Set([
|
|
276
|
+
"ar",
|
|
277
|
+
"dv",
|
|
278
|
+
"fa",
|
|
279
|
+
"he",
|
|
280
|
+
"ks",
|
|
281
|
+
"ku",
|
|
282
|
+
"ps",
|
|
283
|
+
"sd",
|
|
284
|
+
"ug",
|
|
285
|
+
"ur",
|
|
286
|
+
"yi"
|
|
287
|
+
]);
|
|
288
|
+
var navigateOrReload = (newLocation) => {
|
|
289
|
+
if (newLocation) {
|
|
290
|
+
window.location.href = newLocation;
|
|
291
|
+
} else {
|
|
292
|
+
window.location.reload();
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
var setLocale = (newLocale, options) => {
|
|
296
|
+
const optionsWithDefaults = {
|
|
297
|
+
reload: true,
|
|
298
|
+
...options
|
|
299
|
+
};
|
|
300
|
+
let currentLocale;
|
|
301
|
+
try {
|
|
302
|
+
currentLocale = getLocale();
|
|
303
|
+
} catch {}
|
|
304
|
+
const customSetLocalePromises = [];
|
|
305
|
+
let newLocation = undefined;
|
|
306
|
+
let strategyToUse = strategy;
|
|
307
|
+
if (!isServer && typeof window !== "undefined" && window.location?.href) {
|
|
308
|
+
strategyToUse = getStrategyForUrl(window.location.href);
|
|
309
|
+
}
|
|
310
|
+
for (const strat of strategyToUse) {
|
|
311
|
+
if (TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED && strat === "globalVariable") {
|
|
312
|
+
_locale = newLocale;
|
|
313
|
+
} else if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === "cookie") {
|
|
314
|
+
if (isServer || typeof document === "undefined" || typeof window === "undefined") {
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
const cookieString = `${cookieName}=${newLocale}; path=/; max-age=${cookieMaxAge}`;
|
|
318
|
+
document.cookie = cookieDomain ? `${cookieString}; domain=${cookieDomain}` : cookieString;
|
|
319
|
+
} else if (strat === "baseLocale") {
|
|
320
|
+
continue;
|
|
321
|
+
} else if (TREE_SHAKE_URL_STRATEGY_USED && strat === "url" && typeof window !== "undefined") {
|
|
322
|
+
newLocation = localizeUrl(window.location.href, {
|
|
323
|
+
locale: newLocale
|
|
324
|
+
}).href;
|
|
325
|
+
} else if (TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED && strat === "localStorage" && typeof window !== "undefined") {
|
|
326
|
+
localStorage.setItem(localStorageKey, newLocale);
|
|
327
|
+
} else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
|
|
328
|
+
const handler = customClientStrategies.get(strat);
|
|
329
|
+
if (handler) {
|
|
330
|
+
let result = handler.setLocale(newLocale);
|
|
331
|
+
if (result instanceof Promise) {
|
|
332
|
+
result = result.catch((error) => {
|
|
333
|
+
throw new Error(`Custom strategy "${strat}" setLocale failed.`, {
|
|
334
|
+
cause: error
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
customSetLocalePromises.push(result);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
const runReload = () => {
|
|
343
|
+
if (!isServer && optionsWithDefaults.reload && window.location && newLocale !== currentLocale) {
|
|
344
|
+
navigateOrReload(newLocation);
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
if (customSetLocalePromises.length) {
|
|
348
|
+
return Promise.all(customSetLocalePromises).then(() => {
|
|
349
|
+
runReload();
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
runReload();
|
|
353
|
+
return;
|
|
354
|
+
};
|
|
355
|
+
var getUrlOrigin = () => {
|
|
356
|
+
if (serverAsyncLocalStorage) {
|
|
357
|
+
return serverAsyncLocalStorage.getStore()?.origin ?? "http://fallback.com";
|
|
358
|
+
} else if (typeof window !== "undefined") {
|
|
359
|
+
return window.location.origin;
|
|
360
|
+
}
|
|
361
|
+
return "http://fallback.com";
|
|
362
|
+
};
|
|
363
|
+
function toLocale(value) {
|
|
364
|
+
if (typeof value !== "string") {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
const lowerValue = value.toLowerCase();
|
|
368
|
+
for (const locale of locales) {
|
|
369
|
+
if (locale.toLowerCase() === lowerValue) {
|
|
370
|
+
return locale;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
function assertIsLocale(input) {
|
|
376
|
+
const locale = toLocale(input);
|
|
377
|
+
if (locale)
|
|
378
|
+
return locale;
|
|
379
|
+
throw new Error(`Invalid locale: ${input}. Expected one of: ${locales.join(", ")}`);
|
|
380
|
+
}
|
|
381
|
+
function extractLocaleFromCookie() {
|
|
382
|
+
if (typeof document === "undefined" || !document.cookie) {
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
const match = document.cookie.match(new RegExp(`(^| )${cookieName}=([^;]+)`));
|
|
386
|
+
const locale = match?.[2];
|
|
387
|
+
return toLocale(locale);
|
|
388
|
+
}
|
|
389
|
+
function extractLocaleFromNavigator() {
|
|
390
|
+
if (!navigator?.languages?.length) {
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
const languages = navigator.languages.map((lang) => ({
|
|
394
|
+
fullTag: lang,
|
|
395
|
+
baseTag: lang.split("-")[0]
|
|
396
|
+
}));
|
|
397
|
+
for (const lang of languages) {
|
|
398
|
+
const fullLocale = toLocale(lang.fullTag);
|
|
399
|
+
if (fullLocale) {
|
|
400
|
+
return fullLocale;
|
|
401
|
+
}
|
|
402
|
+
const baseLocale2 = toLocale(lang.baseTag);
|
|
403
|
+
if (baseLocale2) {
|
|
404
|
+
return baseLocale2;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
var cachedUrl;
|
|
410
|
+
var cachedLocale;
|
|
411
|
+
function extractLocaleFromUrl(url) {
|
|
412
|
+
const urlString = typeof url === "string" ? url : url.href;
|
|
413
|
+
if (cachedUrl === urlString) {
|
|
414
|
+
return cachedLocale;
|
|
415
|
+
}
|
|
416
|
+
let result;
|
|
417
|
+
if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
|
|
418
|
+
result = defaultUrlPatternExtractLocale(url);
|
|
419
|
+
} else {
|
|
420
|
+
const urlObj = typeof url === "string" ? new URL(url) : url;
|
|
421
|
+
for (const element of urlPatterns) {
|
|
422
|
+
for (const [locale, localizedPattern] of element.localized) {
|
|
423
|
+
const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href);
|
|
424
|
+
if (match) {
|
|
425
|
+
result = locale;
|
|
426
|
+
break;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
if (result)
|
|
430
|
+
break;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
cachedUrl = urlString;
|
|
434
|
+
cachedLocale = result;
|
|
435
|
+
return result;
|
|
436
|
+
}
|
|
437
|
+
function defaultUrlPatternExtractLocale(url) {
|
|
438
|
+
const urlObj = new URL(url, "http://dummy.com");
|
|
439
|
+
const pathSegments = urlObj.pathname.split("/").filter(Boolean);
|
|
440
|
+
return toLocale(pathSegments[0]) || baseLocale;
|
|
441
|
+
}
|
|
442
|
+
function localizeUrl(url, options) {
|
|
443
|
+
const targetLocale = options?.locale ? assertIsLocale(options?.locale) : getLocale();
|
|
444
|
+
if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
|
|
445
|
+
return localizeUrlDefaultPattern(url, targetLocale);
|
|
446
|
+
}
|
|
447
|
+
const urlObj = typeof url === "string" ? new URL(url) : url;
|
|
448
|
+
for (const element of urlPatterns) {
|
|
449
|
+
for (const [, localizedPattern] of element.localized) {
|
|
450
|
+
const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href);
|
|
451
|
+
if (!match) {
|
|
452
|
+
continue;
|
|
453
|
+
}
|
|
454
|
+
const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1];
|
|
455
|
+
if (!targetPattern) {
|
|
456
|
+
continue;
|
|
457
|
+
}
|
|
458
|
+
const localizedUrl = fillPattern(targetPattern, aggregateGroups(match), urlObj.origin);
|
|
459
|
+
return fillMissingUrlParts(localizedUrl, match);
|
|
460
|
+
}
|
|
461
|
+
const unlocalizedMatch = new URLPattern(element.pattern, urlObj.href).exec(urlObj.href);
|
|
462
|
+
if (unlocalizedMatch) {
|
|
463
|
+
const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1];
|
|
464
|
+
if (targetPattern) {
|
|
465
|
+
const localizedUrl = fillPattern(targetPattern, aggregateGroups(unlocalizedMatch), urlObj.origin);
|
|
466
|
+
return fillMissingUrlParts(localizedUrl, unlocalizedMatch);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return urlObj;
|
|
471
|
+
}
|
|
472
|
+
function localizeUrlDefaultPattern(url, locale) {
|
|
473
|
+
const urlObj = typeof url === "string" ? new URL(url, getUrlOrigin()) : new URL(url);
|
|
474
|
+
const currentLocale = extractLocaleFromUrl(urlObj);
|
|
475
|
+
if (currentLocale === locale) {
|
|
476
|
+
return urlObj;
|
|
477
|
+
}
|
|
478
|
+
const pathSegments = urlObj.pathname.split("/").filter(Boolean);
|
|
479
|
+
if (pathSegments.length > 0 && toLocale(pathSegments[0])) {
|
|
480
|
+
pathSegments.shift();
|
|
481
|
+
}
|
|
482
|
+
if (locale === baseLocale) {
|
|
483
|
+
urlObj.pathname = "/" + pathSegments.join("/");
|
|
484
|
+
} else {
|
|
485
|
+
urlObj.pathname = "/" + locale + "/" + pathSegments.join("/");
|
|
486
|
+
}
|
|
487
|
+
return urlObj;
|
|
488
|
+
}
|
|
489
|
+
function fillMissingUrlParts(url, match) {
|
|
490
|
+
if (match.protocol.groups["0"]) {
|
|
491
|
+
url.protocol = match.protocol.groups["0"] ?? "";
|
|
492
|
+
}
|
|
493
|
+
if (match.hostname.groups["0"]) {
|
|
494
|
+
url.hostname = match.hostname.groups["0"] ?? "";
|
|
495
|
+
}
|
|
496
|
+
if (match.username.groups["0"]) {
|
|
497
|
+
url.username = match.username.groups["0"] ?? "";
|
|
498
|
+
}
|
|
499
|
+
if (match.password.groups["0"]) {
|
|
500
|
+
url.password = match.password.groups["0"] ?? "";
|
|
501
|
+
}
|
|
502
|
+
if (match.port.groups["0"]) {
|
|
503
|
+
url.port = match.port.groups["0"] ?? "";
|
|
504
|
+
}
|
|
505
|
+
if (match.pathname.groups["0"]) {
|
|
506
|
+
url.pathname = match.pathname.groups["0"] ?? "";
|
|
507
|
+
}
|
|
508
|
+
if (match.search.groups["0"]) {
|
|
509
|
+
url.search = match.search.groups["0"] ?? "";
|
|
510
|
+
}
|
|
511
|
+
if (match.hash.groups["0"]) {
|
|
512
|
+
url.hash = match.hash.groups["0"] ?? "";
|
|
513
|
+
}
|
|
514
|
+
return url;
|
|
515
|
+
}
|
|
516
|
+
function fillPattern(pattern, values, origin) {
|
|
517
|
+
let processedPattern = pattern.replace(/(https?:\/\/[^:/]+):(\d+)(\/|$)/g, (_, protocol, port, slash) => {
|
|
518
|
+
return `${protocol}#PORT-${port}#${slash}`;
|
|
519
|
+
});
|
|
520
|
+
let processedGroupDelimiters = processedPattern.replace(/\{([^{}]*)\}([?+*]?)/g, (_, content, modifier) => {
|
|
521
|
+
if (modifier === "?") {
|
|
522
|
+
return content;
|
|
523
|
+
}
|
|
524
|
+
return content;
|
|
525
|
+
});
|
|
526
|
+
let filled = processedGroupDelimiters.replace(/(\/?):([a-zA-Z0-9_]+)(\([^)]*\))?([?+*]?)/g, (_, slash, name, __, modifier) => {
|
|
527
|
+
const value = values[name];
|
|
528
|
+
if (value === null) {
|
|
529
|
+
return "";
|
|
530
|
+
}
|
|
531
|
+
if (modifier === "?") {
|
|
532
|
+
return value !== undefined ? `${slash}${value}` : "";
|
|
533
|
+
}
|
|
534
|
+
if (modifier === "+" || modifier === "*") {
|
|
535
|
+
if (value === undefined && modifier === "+") {
|
|
536
|
+
throw new Error(`Missing value for "${name}" (one or more required)`);
|
|
537
|
+
}
|
|
538
|
+
return value ? `${slash}${value}` : "";
|
|
539
|
+
}
|
|
540
|
+
if (value === undefined) {
|
|
541
|
+
throw new Error(`Missing value for "${name}"`);
|
|
542
|
+
}
|
|
543
|
+
return `${slash}${value}`;
|
|
544
|
+
});
|
|
545
|
+
filled = filled.replace(/#PORT-(\d+)#/g, ":$1");
|
|
546
|
+
return new URL(filled, origin);
|
|
547
|
+
}
|
|
548
|
+
function aggregateGroups(match) {
|
|
549
|
+
return {
|
|
550
|
+
...match.hash.groups,
|
|
551
|
+
...match.hostname.groups,
|
|
552
|
+
...match.password.groups,
|
|
553
|
+
...match.pathname.groups,
|
|
554
|
+
...match.port.groups,
|
|
555
|
+
...match.protocol.groups,
|
|
556
|
+
...match.search.groups,
|
|
557
|
+
...match.username.groups
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
var customServerStrategies = new Map;
|
|
561
|
+
var customClientStrategies = new Map;
|
|
562
|
+
function isCustomStrategy(strategy2) {
|
|
563
|
+
return typeof strategy2 === "string" && /^custom-[A-Za-z0-9_-]+$/.test(strategy2);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
// ../../src/components/ui/virtualized-combobox.tsx
|
|
567
|
+
import { jsxDEV as jsxDEV5 } from "react/jsx-dev-runtime";
|
|
568
|
+
"use client";
|
|
569
|
+
var messages = {
|
|
570
|
+
en: {
|
|
571
|
+
search: "Search...",
|
|
572
|
+
selected: (count) => `${count} selected`,
|
|
573
|
+
selectMore: "Select more"
|
|
574
|
+
},
|
|
575
|
+
fr: {
|
|
576
|
+
search: "Rechercher...",
|
|
577
|
+
selected: (count) => `${count} sélectionnés`,
|
|
578
|
+
selectMore: "Sélectionner davantage"
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
var virtualizedComboboxMessages = (overrides) => ({
|
|
582
|
+
...getLocale().startsWith("fr") ? messages.fr : messages.en,
|
|
583
|
+
...overrides
|
|
584
|
+
});
|
|
585
|
+
var optionEquals = (item, selected) => item.value === selected.value;
|
|
586
|
+
var VirtualizedComboboxList = ({
|
|
587
|
+
emptyLabel,
|
|
588
|
+
groupSelections,
|
|
589
|
+
messages: messageOverrides,
|
|
590
|
+
renderItem,
|
|
591
|
+
selectedValues,
|
|
592
|
+
virtualizerRef
|
|
593
|
+
}) => {
|
|
594
|
+
const filteredItems = ComboboxPrimitive.useFilteredItems();
|
|
595
|
+
const labels = virtualizedComboboxMessages(messageOverrides);
|
|
596
|
+
const entries = filteredItems.flatMap((item, index) => {
|
|
597
|
+
if (!groupSelections)
|
|
598
|
+
return [{ kind: "item", item, index }];
|
|
599
|
+
const selected = selectedValues.has(item.value);
|
|
600
|
+
const previous = filteredItems[index - 1];
|
|
601
|
+
const startsGroup = index === 0 || selectedValues.has(previous?.value ?? "") !== selected;
|
|
602
|
+
const itemEntry = { kind: "item", item, index };
|
|
603
|
+
return startsGroup ? [
|
|
604
|
+
{
|
|
605
|
+
kind: "group",
|
|
606
|
+
key: selected ? "selected" : "available",
|
|
607
|
+
label: selected ? labels.selected(selectedValues.size) : labels.selectMore
|
|
608
|
+
},
|
|
609
|
+
itemEntry
|
|
610
|
+
] : [itemEntry];
|
|
611
|
+
});
|
|
612
|
+
const scrollRef = useRef(null);
|
|
613
|
+
const virtualizer = useVirtualizer({
|
|
614
|
+
count: entries.length,
|
|
615
|
+
getScrollElement: () => scrollRef.current,
|
|
616
|
+
getItemKey: (index) => {
|
|
617
|
+
const entry = entries[index];
|
|
618
|
+
return entry?.kind === "group" ? `group-${entry.key}` : entry?.item.value ?? index;
|
|
619
|
+
},
|
|
620
|
+
estimateSize: () => 36,
|
|
621
|
+
overscan: 8
|
|
622
|
+
});
|
|
623
|
+
useImperativeHandle(virtualizerRef, () => virtualizer, [virtualizer]);
|
|
624
|
+
const handleScrollElementRef = useCallback((element) => {
|
|
625
|
+
scrollRef.current = element;
|
|
626
|
+
if (element)
|
|
627
|
+
virtualizer.measure();
|
|
628
|
+
}, [virtualizer]);
|
|
629
|
+
if (filteredItems.length === 0) {
|
|
630
|
+
return /* @__PURE__ */ jsxDEV5("div", {
|
|
631
|
+
className: "text-muted-foreground py-6 text-center text-sm",
|
|
632
|
+
children: emptyLabel
|
|
633
|
+
}, undefined, false, undefined, this);
|
|
634
|
+
}
|
|
635
|
+
return /* @__PURE__ */ jsxDEV5(ComboboxPrimitive.List, {
|
|
636
|
+
className: "scroll-py-1 overflow-auto overscroll-contain p-1",
|
|
637
|
+
ref: handleScrollElementRef,
|
|
638
|
+
style: {
|
|
639
|
+
height: Math.min(virtualizer.getTotalSize() + 8, 288),
|
|
640
|
+
maxHeight: "var(--available-height)"
|
|
641
|
+
},
|
|
642
|
+
children: /* @__PURE__ */ jsxDEV5("div", {
|
|
643
|
+
className: "relative w-full",
|
|
644
|
+
role: "presentation",
|
|
645
|
+
style: { height: virtualizer.getTotalSize() },
|
|
646
|
+
children: virtualizer.getVirtualItems().map((virtualItem) => {
|
|
647
|
+
const entry = entries[virtualItem.index];
|
|
648
|
+
if (!entry)
|
|
649
|
+
return null;
|
|
650
|
+
const style = {
|
|
651
|
+
height: virtualItem.size,
|
|
652
|
+
transform: `translateY(${virtualItem.start}px)`
|
|
653
|
+
};
|
|
654
|
+
if (entry.kind === "group") {
|
|
655
|
+
return /* @__PURE__ */ jsxDEV5(ComboboxPrimitive.Group, {
|
|
656
|
+
className: "contents",
|
|
657
|
+
children: /* @__PURE__ */ jsxDEV5(ComboboxPrimitive.GroupLabel, {
|
|
658
|
+
className: "text-muted-foreground absolute top-0 left-0 w-full px-2 pt-3 pb-1 text-xs",
|
|
659
|
+
"data-index": virtualItem.index,
|
|
660
|
+
ref: virtualizer.measureElement,
|
|
661
|
+
style,
|
|
662
|
+
children: entry.label
|
|
663
|
+
}, undefined, false, undefined, this)
|
|
664
|
+
}, entry.key, false, undefined, this);
|
|
665
|
+
}
|
|
666
|
+
return /* @__PURE__ */ jsxDEV5(ComboboxPrimitive.Item, {
|
|
667
|
+
"aria-posinset": entry.index + 1,
|
|
668
|
+
"aria-setsize": filteredItems.length,
|
|
669
|
+
className: "data-highlighted:bg-accent data-highlighted:text-accent-foreground absolute top-0 left-0 flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50",
|
|
670
|
+
"data-index": virtualItem.index,
|
|
671
|
+
index: entry.index,
|
|
672
|
+
ref: virtualizer.measureElement,
|
|
673
|
+
style,
|
|
674
|
+
value: entry.item,
|
|
675
|
+
children: [
|
|
676
|
+
renderItem?.(entry.item) ?? /* @__PURE__ */ jsxDEV5("span", {
|
|
677
|
+
className: "min-w-0 truncate",
|
|
678
|
+
children: entry.item.label
|
|
679
|
+
}, undefined, false, undefined, this),
|
|
680
|
+
/* @__PURE__ */ jsxDEV5(ComboboxPrimitive.ItemIndicator, {
|
|
681
|
+
className: "absolute right-2 flex size-4 items-center justify-center",
|
|
682
|
+
children: /* @__PURE__ */ jsxDEV5(Check, {}, undefined, false, undefined, this)
|
|
683
|
+
}, undefined, false, undefined, this)
|
|
684
|
+
]
|
|
685
|
+
}, entry.item.value, true, undefined, this);
|
|
686
|
+
})
|
|
687
|
+
}, undefined, false, undefined, this)
|
|
688
|
+
}, undefined, false, undefined, this);
|
|
689
|
+
};
|
|
690
|
+
var VirtualizedComboboxContent = ({
|
|
691
|
+
contentClassName,
|
|
692
|
+
emptyLabel,
|
|
693
|
+
groupSelections,
|
|
694
|
+
messages: messageOverrides,
|
|
695
|
+
renderItem,
|
|
696
|
+
selectedValues,
|
|
697
|
+
virtualizerRef
|
|
698
|
+
}) => {
|
|
699
|
+
const labels = virtualizedComboboxMessages(messageOverrides);
|
|
700
|
+
return /* @__PURE__ */ jsxDEV5(ComboboxPrimitive.Portal, {
|
|
701
|
+
children: /* @__PURE__ */ jsxDEV5(ComboboxPrimitive.Positioner, {
|
|
702
|
+
align: "start",
|
|
703
|
+
className: "isolate z-50",
|
|
704
|
+
side: "bottom",
|
|
705
|
+
sideOffset: 6,
|
|
706
|
+
children: /* @__PURE__ */ jsxDEV5(ComboboxPrimitive.Popup, {
|
|
707
|
+
className: cn("relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-0 origin-(--transform-origin) overflow-hidden rounded-md bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-in-95", contentClassName),
|
|
708
|
+
children: [
|
|
709
|
+
/* @__PURE__ */ jsxDEV5("div", {
|
|
710
|
+
className: "min-w-0 p-1 pb-0",
|
|
711
|
+
children: /* @__PURE__ */ jsxDEV5(InputGroup, {
|
|
712
|
+
className: "border-input/30 bg-input/30 h-8 w-full min-w-0 shadow-none",
|
|
713
|
+
children: /* @__PURE__ */ jsxDEV5(ComboboxPrimitive.Input, {
|
|
714
|
+
placeholder: labels.search,
|
|
715
|
+
render: /* @__PURE__ */ jsxDEV5(InputGroupInput, {}, undefined, false, undefined, this)
|
|
716
|
+
}, undefined, false, undefined, this)
|
|
717
|
+
}, undefined, false, undefined, this)
|
|
718
|
+
}, undefined, false, undefined, this),
|
|
719
|
+
/* @__PURE__ */ jsxDEV5(VirtualizedComboboxList, {
|
|
720
|
+
emptyLabel,
|
|
721
|
+
groupSelections,
|
|
722
|
+
messages: messageOverrides,
|
|
723
|
+
renderItem,
|
|
724
|
+
selectedValues,
|
|
725
|
+
virtualizerRef
|
|
726
|
+
}, undefined, false, undefined, this)
|
|
727
|
+
]
|
|
728
|
+
}, undefined, true, undefined, this)
|
|
729
|
+
}, undefined, false, undefined, this)
|
|
730
|
+
}, undefined, false, undefined, this);
|
|
731
|
+
};
|
|
732
|
+
var defaultTrigger = (ariaLabel, ariaInvalid, disabled, label, triggerId) => /* @__PURE__ */ jsxDEV5(Button, {
|
|
733
|
+
"aria-label": ariaLabel,
|
|
734
|
+
"aria-invalid": ariaInvalid,
|
|
735
|
+
className: "w-full max-w-full min-w-0 justify-between overflow-hidden",
|
|
736
|
+
disabled,
|
|
737
|
+
id: triggerId,
|
|
738
|
+
type: "button",
|
|
739
|
+
variant: "outline",
|
|
740
|
+
children: [
|
|
741
|
+
/* @__PURE__ */ jsxDEV5("span", {
|
|
742
|
+
className: "min-w-0 truncate text-left",
|
|
743
|
+
children: label
|
|
744
|
+
}, undefined, false, undefined, this),
|
|
745
|
+
/* @__PURE__ */ jsxDEV5(ChevronsUpDown, {
|
|
746
|
+
className: "text-muted-foreground shrink-0 opacity-70"
|
|
747
|
+
}, undefined, false, undefined, this)
|
|
748
|
+
]
|
|
749
|
+
}, undefined, true, undefined, this);
|
|
750
|
+
var selectedLabel = (value, placeholder) => {
|
|
751
|
+
if (Array.isArray(value)) {
|
|
752
|
+
return value.length > 0 ? value.map(({ label }) => label).join(", ") : placeholder;
|
|
753
|
+
}
|
|
754
|
+
return value && "label" in value ? value.label : placeholder;
|
|
755
|
+
};
|
|
756
|
+
var useComboboxVirtualizerRef = (providedRef) => {
|
|
757
|
+
const localRef = useRef(null);
|
|
758
|
+
return providedRef ?? localRef;
|
|
759
|
+
};
|
|
760
|
+
var VirtualizedComboboxSingle = (props) => {
|
|
761
|
+
const virtualizerRef = useComboboxVirtualizerRef(props.virtualizerRef);
|
|
762
|
+
return /* @__PURE__ */ jsxDEV5(ComboboxPrimitive.Root, {
|
|
763
|
+
disabled: props.disabled,
|
|
764
|
+
inputValue: props.searchValue,
|
|
765
|
+
items: [...props.items],
|
|
766
|
+
itemToStringLabel: (item) => item.label,
|
|
767
|
+
isItemEqualToValue: optionEquals,
|
|
768
|
+
onInputValueChange: (value) => props.onSearchValueChange?.(value),
|
|
769
|
+
onItemHighlighted: (_, { index, reason }) => {
|
|
770
|
+
if (reason === "keyboard" && index >= 0) {
|
|
771
|
+
virtualizerRef.current?.scrollToIndex(index, { align: "auto" });
|
|
772
|
+
}
|
|
773
|
+
},
|
|
774
|
+
onOpenChange: (open) => props.onOpenChange?.(open),
|
|
775
|
+
onValueChange: (value) => props.onValueChange(value),
|
|
776
|
+
open: props.open,
|
|
777
|
+
value: props.value,
|
|
778
|
+
virtualized: true,
|
|
779
|
+
children: [
|
|
780
|
+
/* @__PURE__ */ jsxDEV5(ComboboxPrimitive.Trigger, {
|
|
781
|
+
render: props.trigger ?? defaultTrigger(props.ariaLabel, props.ariaInvalid, props.disabled, selectedLabel(props.value, props.placeholder), props.triggerId)
|
|
782
|
+
}, undefined, false, undefined, this),
|
|
783
|
+
/* @__PURE__ */ jsxDEV5(VirtualizedComboboxContent, {
|
|
784
|
+
...props,
|
|
785
|
+
groupSelections: false,
|
|
786
|
+
selectedValues: new Set(props.value ? [props.value.value] : []),
|
|
787
|
+
virtualizerRef
|
|
788
|
+
}, undefined, false, undefined, this)
|
|
789
|
+
]
|
|
790
|
+
}, undefined, true, undefined, this);
|
|
791
|
+
};
|
|
792
|
+
var VirtualizedComboboxMultiple = (props) => {
|
|
793
|
+
const virtualizerRef = useComboboxVirtualizerRef(props.virtualizerRef);
|
|
794
|
+
return /* @__PURE__ */ jsxDEV5(ComboboxPrimitive.Root, {
|
|
795
|
+
disabled: props.disabled,
|
|
796
|
+
inputValue: props.searchValue,
|
|
797
|
+
items: [...props.items],
|
|
798
|
+
itemToStringLabel: (item) => item.label,
|
|
799
|
+
isItemEqualToValue: optionEquals,
|
|
800
|
+
multiple: true,
|
|
801
|
+
onInputValueChange: (value) => props.onSearchValueChange?.(value),
|
|
802
|
+
onItemHighlighted: (_, { index, reason }) => {
|
|
803
|
+
if (reason === "keyboard" && index >= 0) {
|
|
804
|
+
virtualizerRef.current?.scrollToIndex(index, { align: "auto" });
|
|
805
|
+
}
|
|
806
|
+
},
|
|
807
|
+
onOpenChange: (open) => props.onOpenChange?.(open),
|
|
808
|
+
onValueChange: (value) => props.onValueChange(value),
|
|
809
|
+
open: props.open,
|
|
810
|
+
value: [...props.value],
|
|
811
|
+
virtualized: true,
|
|
812
|
+
children: [
|
|
813
|
+
/* @__PURE__ */ jsxDEV5(ComboboxPrimitive.Trigger, {
|
|
814
|
+
render: props.trigger ?? defaultTrigger(props.ariaLabel, props.ariaInvalid, props.disabled, selectedLabel(props.value, props.placeholder), props.triggerId)
|
|
815
|
+
}, undefined, false, undefined, this),
|
|
816
|
+
/* @__PURE__ */ jsxDEV5(VirtualizedComboboxContent, {
|
|
817
|
+
...props,
|
|
818
|
+
groupSelections: true,
|
|
819
|
+
selectedValues: new Set(props.value.map(({ value }) => value)),
|
|
820
|
+
virtualizerRef
|
|
821
|
+
}, undefined, false, undefined, this)
|
|
822
|
+
]
|
|
823
|
+
}, undefined, true, undefined, this);
|
|
824
|
+
};
|
|
825
|
+
function VirtualizedCombobox(props) {
|
|
826
|
+
return props.multiple ? /* @__PURE__ */ jsxDEV5(VirtualizedComboboxMultiple, {
|
|
827
|
+
...props
|
|
828
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV5(VirtualizedComboboxSingle, {
|
|
829
|
+
...props
|
|
830
|
+
}, undefined, false, undefined, this);
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
// ../../src/components/ui/icon-input.tsx
|
|
834
|
+
import { jsxDEV as jsxDEV6, Fragment } from "react/jsx-dev-runtime";
|
|
835
|
+
var IconifySearchResponse = Schema.Struct({
|
|
836
|
+
icons: Schema.Array(Schema.String)
|
|
837
|
+
}).pipe(Schema.annotate({ identifier: "IconifySearchResponse" }));
|
|
838
|
+
var iconifyRuntime = Atom.runtime(FetchHttpClient.layer);
|
|
839
|
+
var iconSearchAtoms = Atom.family((key) => {
|
|
840
|
+
const separatorIndex = key.indexOf("\x00");
|
|
841
|
+
const collection = key.slice(0, separatorIndex);
|
|
842
|
+
const query = key.slice(separatorIndex + 1);
|
|
843
|
+
return iconifyRuntime.atom(Effect.gen(function* () {
|
|
844
|
+
if (!query.trim())
|
|
845
|
+
return [];
|
|
846
|
+
const client = yield* HttpClient.HttpClient;
|
|
847
|
+
const request = HttpClientRequest.get("https://api.iconify.design/search").pipe(HttpClientRequest.setUrlParams({ prefix: collection, query }));
|
|
848
|
+
const response = yield* client.execute(request);
|
|
849
|
+
const { icons } = yield* HttpClientResponse.schemaBodyJson(IconifySearchResponse)(response);
|
|
850
|
+
return icons.filter((icon) => icon.startsWith(`${collection}:`)).map((icon) => icon.slice(collection.length + 1));
|
|
851
|
+
}).pipe(Effect.provideService(HttpClient.TracerPropagationEnabled, false)));
|
|
852
|
+
});
|
|
853
|
+
var useIconSearchAtom = (collection, query) => useAtomValue(iconSearchAtoms(`${collection}\x00${query}`));
|
|
854
|
+
var labels = {
|
|
855
|
+
en: {
|
|
856
|
+
browse: "Browse Iconify",
|
|
857
|
+
empty: "No icons found.",
|
|
858
|
+
searchPlaceholder: "Search icons",
|
|
859
|
+
searchPrompt: "Start typing to search icons.",
|
|
860
|
+
select: "Select icon"
|
|
861
|
+
},
|
|
862
|
+
fr: {
|
|
863
|
+
browse: "Parcourir Iconify",
|
|
864
|
+
empty: "Aucune icône trouvée.",
|
|
865
|
+
searchPlaceholder: "Rechercher des icônes",
|
|
866
|
+
searchPrompt: "Commencez à taper pour rechercher des icônes.",
|
|
867
|
+
select: "Sélectionner une icône"
|
|
868
|
+
}
|
|
869
|
+
};
|
|
870
|
+
var iconInputLabels = () => getLocale().startsWith("fr") ? labels.fr : labels.en;
|
|
871
|
+
var iconifyCollectionUrl = (collection) => `https://icon-sets.iconify.design/${encodeURIComponent(collection)}/`;
|
|
872
|
+
function IconInput({
|
|
873
|
+
collection = "lucide",
|
|
874
|
+
disabled,
|
|
875
|
+
id,
|
|
876
|
+
onValueChange,
|
|
877
|
+
value
|
|
878
|
+
}) {
|
|
879
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
880
|
+
const [query, setQuery] = useState("");
|
|
881
|
+
const deferredQuery = useDeferredValue(query);
|
|
882
|
+
const iconSearchResult = useIconSearchAtom(collection, deferredQuery);
|
|
883
|
+
const icons = AsyncResult.isSuccess(iconSearchResult) ? iconSearchResult.value : [];
|
|
884
|
+
const copy = iconInputLabels();
|
|
885
|
+
const isWaiting = deferredQuery.trim() !== "" && AsyncResult.isWaiting(iconSearchResult);
|
|
886
|
+
const items = icons.map((icon) => ({ label: icon, value: icon }));
|
|
887
|
+
const selectedItem = value ? { label: value, value } : null;
|
|
888
|
+
return /* @__PURE__ */ jsxDEV6(VirtualizedCombobox, {
|
|
889
|
+
ariaLabel: copy.select,
|
|
890
|
+
contentClassName: "w-80",
|
|
891
|
+
emptyLabel: isWaiting ? null : /* @__PURE__ */ jsxDEV6("div", {
|
|
892
|
+
className: "text-muted-foreground flex flex-col items-center gap-2 px-3",
|
|
893
|
+
children: [
|
|
894
|
+
/* @__PURE__ */ jsxDEV6(Search, {
|
|
895
|
+
className: "size-5"
|
|
896
|
+
}, undefined, false, undefined, this),
|
|
897
|
+
/* @__PURE__ */ jsxDEV6("p", {
|
|
898
|
+
children: query ? copy.empty : copy.searchPrompt
|
|
899
|
+
}, undefined, false, undefined, this),
|
|
900
|
+
/* @__PURE__ */ jsxDEV6(Button, {
|
|
901
|
+
render: /* @__PURE__ */ jsxDEV6("a", {
|
|
902
|
+
href: iconifyCollectionUrl(collection),
|
|
903
|
+
rel: "noreferrer",
|
|
904
|
+
target: "_blank"
|
|
905
|
+
}, undefined, false, undefined, this),
|
|
906
|
+
size: "sm",
|
|
907
|
+
variant: "link",
|
|
908
|
+
children: [
|
|
909
|
+
copy.browse,
|
|
910
|
+
" ",
|
|
911
|
+
/* @__PURE__ */ jsxDEV6(ExternalLink, {
|
|
912
|
+
className: "inline size-3"
|
|
913
|
+
}, undefined, false, undefined, this)
|
|
914
|
+
]
|
|
915
|
+
}, undefined, true, undefined, this)
|
|
916
|
+
]
|
|
917
|
+
}, undefined, true, undefined, this),
|
|
918
|
+
items,
|
|
919
|
+
messages: { search: copy.searchPlaceholder },
|
|
920
|
+
onOpenChange: (open) => {
|
|
921
|
+
setIsOpen(open);
|
|
922
|
+
if (open)
|
|
923
|
+
setQuery("");
|
|
924
|
+
},
|
|
925
|
+
open: isOpen,
|
|
926
|
+
onSearchValueChange: setQuery,
|
|
927
|
+
onValueChange: (item) => {
|
|
928
|
+
if (!item)
|
|
929
|
+
return;
|
|
930
|
+
onValueChange(item.value);
|
|
931
|
+
setQuery("");
|
|
932
|
+
setIsOpen(false);
|
|
933
|
+
},
|
|
934
|
+
placeholder: copy.select,
|
|
935
|
+
renderItem: (item) => /* @__PURE__ */ jsxDEV6(Fragment, {
|
|
936
|
+
children: [
|
|
937
|
+
/* @__PURE__ */ jsxDEV6(Icon, {
|
|
938
|
+
className: "size-5 shrink-0",
|
|
939
|
+
icon: `${collection}:${item.value}`
|
|
940
|
+
}, undefined, false, undefined, this),
|
|
941
|
+
/* @__PURE__ */ jsxDEV6("span", {
|
|
942
|
+
className: "truncate",
|
|
943
|
+
children: item.label
|
|
944
|
+
}, undefined, false, undefined, this),
|
|
945
|
+
/* @__PURE__ */ jsxDEV6("span", {
|
|
946
|
+
className: "sr-only",
|
|
947
|
+
children: copy.select
|
|
948
|
+
}, undefined, false, undefined, this)
|
|
949
|
+
]
|
|
950
|
+
}, undefined, true, undefined, this),
|
|
951
|
+
searchValue: query,
|
|
952
|
+
trigger: /* @__PURE__ */ jsxDEV6(Button, {
|
|
953
|
+
"aria-label": copy.select,
|
|
954
|
+
disabled,
|
|
955
|
+
id,
|
|
956
|
+
size: "icon",
|
|
957
|
+
title: value,
|
|
958
|
+
type: "button",
|
|
959
|
+
variant: "outline",
|
|
960
|
+
children: /* @__PURE__ */ jsxDEV6(Icon, {
|
|
961
|
+
className: "size-5",
|
|
962
|
+
icon: `${collection}:${value}`
|
|
963
|
+
}, undefined, false, undefined, this)
|
|
964
|
+
}, undefined, false, undefined, this),
|
|
965
|
+
value: selectedItem,
|
|
966
|
+
...disabled === undefined ? {} : { disabled }
|
|
967
|
+
}, undefined, false, undefined, this);
|
|
968
|
+
}
|
|
969
|
+
export {
|
|
970
|
+
IconInput
|
|
971
|
+
};
|