@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,3594 @@
|
|
|
1
|
+
// ../../src/components/ui/button.tsx
|
|
2
|
+
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
|
|
5
|
+
// ../../src/lib/utils.ts
|
|
6
|
+
import { clsx } from "clsx";
|
|
7
|
+
import { twMerge } from "tailwind-merge";
|
|
8
|
+
function cn(...inputs) {
|
|
9
|
+
return twMerge(clsx(inputs));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// ../../src/components/ui/button.tsx
|
|
13
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
14
|
+
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", {
|
|
15
|
+
variants: {
|
|
16
|
+
variant: {
|
|
17
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/80",
|
|
18
|
+
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",
|
|
19
|
+
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",
|
|
20
|
+
ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
|
21
|
+
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",
|
|
22
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
23
|
+
},
|
|
24
|
+
size: {
|
|
25
|
+
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",
|
|
26
|
+
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",
|
|
27
|
+
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",
|
|
28
|
+
lg: "h-10 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
29
|
+
icon: "size-9",
|
|
30
|
+
"icon-xs": "size-6 rounded-[min(var(--radius-md),8px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3",
|
|
31
|
+
"icon-sm": "size-8 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md",
|
|
32
|
+
"icon-lg": "size-10"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
defaultVariants: {
|
|
36
|
+
variant: "default",
|
|
37
|
+
size: "default"
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
function Button({
|
|
41
|
+
className,
|
|
42
|
+
variant = "default",
|
|
43
|
+
size = "default",
|
|
44
|
+
...props
|
|
45
|
+
}) {
|
|
46
|
+
return /* @__PURE__ */ jsxDEV(ButtonPrimitive, {
|
|
47
|
+
"data-slot": "button",
|
|
48
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
49
|
+
...props
|
|
50
|
+
}, undefined, false, undefined, this);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ../../src/components/ui/virtualized-combobox.tsx
|
|
54
|
+
import { Combobox as ComboboxPrimitive } from "@base-ui/react";
|
|
55
|
+
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
56
|
+
import { Check, ChevronsUpDown } from "lucide-react";
|
|
57
|
+
import {
|
|
58
|
+
useCallback,
|
|
59
|
+
useImperativeHandle,
|
|
60
|
+
useRef
|
|
61
|
+
} from "react";
|
|
62
|
+
|
|
63
|
+
// ../../src/components/ui/input-group.tsx
|
|
64
|
+
import { cva as cva2 } from "class-variance-authority";
|
|
65
|
+
|
|
66
|
+
// ../../src/components/ui/input.tsx
|
|
67
|
+
import { Input as InputPrimitive } from "@base-ui/react/input";
|
|
68
|
+
import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
|
|
69
|
+
function Input({ className, type, ...props }) {
|
|
70
|
+
return /* @__PURE__ */ jsxDEV2(InputPrimitive, {
|
|
71
|
+
type,
|
|
72
|
+
"data-slot": "input",
|
|
73
|
+
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),
|
|
74
|
+
...props
|
|
75
|
+
}, undefined, false, undefined, this);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// ../../src/components/ui/textarea.tsx
|
|
79
|
+
import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
|
|
80
|
+
|
|
81
|
+
// ../../src/components/ui/input-group.tsx
|
|
82
|
+
import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
|
|
83
|
+
function InputGroup({ className, ...props }) {
|
|
84
|
+
return /* @__PURE__ */ jsxDEV4("div", {
|
|
85
|
+
"data-slot": "input-group",
|
|
86
|
+
role: "group",
|
|
87
|
+
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),
|
|
88
|
+
...props
|
|
89
|
+
}, undefined, false, undefined, this);
|
|
90
|
+
}
|
|
91
|
+
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", {
|
|
92
|
+
variants: {
|
|
93
|
+
align: {
|
|
94
|
+
"inline-start": "order-first pl-2 has-[>button]:-ml-1 has-[>kbd]:ml-[-0.15rem]",
|
|
95
|
+
"inline-end": "order-last pr-2 has-[>button]:-mr-1 has-[>kbd]:mr-[-0.15rem]",
|
|
96
|
+
"block-start": "order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2",
|
|
97
|
+
"block-end": "order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2"
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
defaultVariants: { align: "inline-start" }
|
|
101
|
+
});
|
|
102
|
+
var inputGroupButtonVariants = cva2("flex items-center gap-2 text-sm shadow-none", {
|
|
103
|
+
variants: {
|
|
104
|
+
size: {
|
|
105
|
+
xs: "h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",
|
|
106
|
+
sm: "",
|
|
107
|
+
"icon-xs": "size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0",
|
|
108
|
+
"icon-sm": "size-8 p-0 has-[>svg]:p-0"
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
defaultVariants: { size: "xs" }
|
|
112
|
+
});
|
|
113
|
+
function InputGroupInput({
|
|
114
|
+
className,
|
|
115
|
+
...props
|
|
116
|
+
}) {
|
|
117
|
+
return /* @__PURE__ */ jsxDEV4(Input, {
|
|
118
|
+
"data-slot": "input-group-control",
|
|
119
|
+
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),
|
|
120
|
+
...props
|
|
121
|
+
}, undefined, false, undefined, this);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// ../../src/paraglide/runtime.js
|
|
125
|
+
import"@inlang/paraglide-js/urlpattern-polyfill";
|
|
126
|
+
var baseLocale = "en";
|
|
127
|
+
var locales = ["en", "fr"];
|
|
128
|
+
var cookieName = "locale";
|
|
129
|
+
var cookieMaxAge = 34560000;
|
|
130
|
+
var cookieDomain = "";
|
|
131
|
+
var localStorageKey = "PARAGLIDE_LOCALE";
|
|
132
|
+
var strategy = [
|
|
133
|
+
"url",
|
|
134
|
+
"cookie",
|
|
135
|
+
"preferredLanguage",
|
|
136
|
+
"baseLocale"
|
|
137
|
+
];
|
|
138
|
+
var routeStrategies = [
|
|
139
|
+
{
|
|
140
|
+
match: "/api/:path(.*)?",
|
|
141
|
+
exclude: true
|
|
142
|
+
}
|
|
143
|
+
];
|
|
144
|
+
var urlPatterns = [
|
|
145
|
+
{
|
|
146
|
+
pattern: "/:path(.*)?",
|
|
147
|
+
localized: [
|
|
148
|
+
[
|
|
149
|
+
"en",
|
|
150
|
+
"/en/:path(.*)?"
|
|
151
|
+
],
|
|
152
|
+
[
|
|
153
|
+
"fr",
|
|
154
|
+
"/fr/:path(.*)?"
|
|
155
|
+
]
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
];
|
|
159
|
+
var cachedRouteStrategyUrl;
|
|
160
|
+
var cachedRouteStrategy;
|
|
161
|
+
function findMatchingRouteStrategy(url) {
|
|
162
|
+
if (routeStrategies.length === 0) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const urlString = typeof url === "string" ? url : url.href;
|
|
166
|
+
if (cachedRouteStrategyUrl === urlString) {
|
|
167
|
+
return cachedRouteStrategy;
|
|
168
|
+
}
|
|
169
|
+
const urlObject = new URL(urlString, "http://dummy.com");
|
|
170
|
+
let match;
|
|
171
|
+
for (const routeStrategy of routeStrategies) {
|
|
172
|
+
const pattern = new URLPattern(routeStrategy.match, urlObject.href);
|
|
173
|
+
if (pattern.exec(urlObject.href)) {
|
|
174
|
+
match = routeStrategy;
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
cachedRouteStrategyUrl = urlString;
|
|
179
|
+
cachedRouteStrategy = match;
|
|
180
|
+
return match;
|
|
181
|
+
}
|
|
182
|
+
function getStrategyForUrl(url) {
|
|
183
|
+
const routeStrategy = findMatchingRouteStrategy(url);
|
|
184
|
+
if (routeStrategy && routeStrategy.exclude !== true && Array.isArray(routeStrategy.strategy)) {
|
|
185
|
+
return routeStrategy.strategy;
|
|
186
|
+
}
|
|
187
|
+
return strategy;
|
|
188
|
+
}
|
|
189
|
+
var serverAsyncLocalStorage = undefined;
|
|
190
|
+
var isServer = import.meta.env?.SSR ?? typeof window === "undefined";
|
|
191
|
+
var experimentalStaticLocale = undefined;
|
|
192
|
+
var TREE_SHAKE_COOKIE_STRATEGY_USED = true;
|
|
193
|
+
var TREE_SHAKE_URL_STRATEGY_USED = true;
|
|
194
|
+
var TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED = false;
|
|
195
|
+
var TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED = true;
|
|
196
|
+
var TREE_SHAKE_DEFAULT_URL_PATTERN_USED = false;
|
|
197
|
+
var TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED = false;
|
|
198
|
+
globalThis.__paraglide = globalThis.__paraglide ?? {};
|
|
199
|
+
globalThis.__paraglide.ssr = globalThis.__paraglide.ssr ?? {};
|
|
200
|
+
var _locale;
|
|
201
|
+
var localeInitiallySet = false;
|
|
202
|
+
var getLocale = () => {
|
|
203
|
+
if (experimentalStaticLocale !== undefined) {
|
|
204
|
+
return experimentalStaticLocale;
|
|
205
|
+
}
|
|
206
|
+
if (serverAsyncLocalStorage) {
|
|
207
|
+
const locale = serverAsyncLocalStorage?.getStore()?.locale;
|
|
208
|
+
if (locale) {
|
|
209
|
+
return locale;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
let strategyToUse = strategy;
|
|
213
|
+
if (!isServer && typeof window !== "undefined" && window.location?.href) {
|
|
214
|
+
strategyToUse = getStrategyForUrl(window.location.href);
|
|
215
|
+
}
|
|
216
|
+
const resolved = resolveLocaleWithStrategies(strategyToUse, typeof window !== "undefined" ? window.location?.href : undefined);
|
|
217
|
+
if (resolved) {
|
|
218
|
+
if (!localeInitiallySet) {
|
|
219
|
+
_locale = resolved;
|
|
220
|
+
localeInitiallySet = true;
|
|
221
|
+
setLocale(resolved, { reload: false });
|
|
222
|
+
}
|
|
223
|
+
return resolved;
|
|
224
|
+
}
|
|
225
|
+
throw new Error("No locale found. Read the docs https://paraglidejs.com/errors#no-locale-found");
|
|
226
|
+
};
|
|
227
|
+
function resolveLocaleWithStrategies(strategyToUse, urlForUrlStrategy) {
|
|
228
|
+
let locale;
|
|
229
|
+
for (const strat of strategyToUse) {
|
|
230
|
+
if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === "cookie") {
|
|
231
|
+
locale = extractLocaleFromCookie();
|
|
232
|
+
} else if (strat === "baseLocale") {
|
|
233
|
+
locale = baseLocale;
|
|
234
|
+
} else if (TREE_SHAKE_URL_STRATEGY_USED && strat === "url" && !isServer && typeof urlForUrlStrategy === "string") {
|
|
235
|
+
locale = extractLocaleFromUrl(urlForUrlStrategy);
|
|
236
|
+
} else if (TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED && strat === "globalVariable" && _locale !== undefined) {
|
|
237
|
+
locale = _locale;
|
|
238
|
+
} else if (TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED && strat === "preferredLanguage" && !isServer) {
|
|
239
|
+
locale = extractLocaleFromNavigator();
|
|
240
|
+
} else if (TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED && strat === "localStorage" && !isServer) {
|
|
241
|
+
locale = localStorage.getItem(localStorageKey) ?? undefined;
|
|
242
|
+
} else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
|
|
243
|
+
const handler = customClientStrategies.get(strat);
|
|
244
|
+
if (handler) {
|
|
245
|
+
const result = handler.getLocale();
|
|
246
|
+
if (result instanceof Promise) {
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
if (result !== undefined) {
|
|
250
|
+
return assertIsLocale(result);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
const matchedLocale = toLocale(locale);
|
|
255
|
+
if (matchedLocale) {
|
|
256
|
+
return matchedLocale;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
var rtlLanguages = new Set([
|
|
262
|
+
"ar",
|
|
263
|
+
"dv",
|
|
264
|
+
"fa",
|
|
265
|
+
"he",
|
|
266
|
+
"ks",
|
|
267
|
+
"ku",
|
|
268
|
+
"ps",
|
|
269
|
+
"sd",
|
|
270
|
+
"ug",
|
|
271
|
+
"ur",
|
|
272
|
+
"yi"
|
|
273
|
+
]);
|
|
274
|
+
var navigateOrReload = (newLocation) => {
|
|
275
|
+
if (newLocation) {
|
|
276
|
+
window.location.href = newLocation;
|
|
277
|
+
} else {
|
|
278
|
+
window.location.reload();
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
var setLocale = (newLocale, options) => {
|
|
282
|
+
const optionsWithDefaults = {
|
|
283
|
+
reload: true,
|
|
284
|
+
...options
|
|
285
|
+
};
|
|
286
|
+
let currentLocale;
|
|
287
|
+
try {
|
|
288
|
+
currentLocale = getLocale();
|
|
289
|
+
} catch {}
|
|
290
|
+
const customSetLocalePromises = [];
|
|
291
|
+
let newLocation = undefined;
|
|
292
|
+
let strategyToUse = strategy;
|
|
293
|
+
if (!isServer && typeof window !== "undefined" && window.location?.href) {
|
|
294
|
+
strategyToUse = getStrategyForUrl(window.location.href);
|
|
295
|
+
}
|
|
296
|
+
for (const strat of strategyToUse) {
|
|
297
|
+
if (TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED && strat === "globalVariable") {
|
|
298
|
+
_locale = newLocale;
|
|
299
|
+
} else if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === "cookie") {
|
|
300
|
+
if (isServer || typeof document === "undefined" || typeof window === "undefined") {
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
const cookieString = `${cookieName}=${newLocale}; path=/; max-age=${cookieMaxAge}`;
|
|
304
|
+
document.cookie = cookieDomain ? `${cookieString}; domain=${cookieDomain}` : cookieString;
|
|
305
|
+
} else if (strat === "baseLocale") {
|
|
306
|
+
continue;
|
|
307
|
+
} else if (TREE_SHAKE_URL_STRATEGY_USED && strat === "url" && typeof window !== "undefined") {
|
|
308
|
+
newLocation = localizeUrl(window.location.href, {
|
|
309
|
+
locale: newLocale
|
|
310
|
+
}).href;
|
|
311
|
+
} else if (TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED && strat === "localStorage" && typeof window !== "undefined") {
|
|
312
|
+
localStorage.setItem(localStorageKey, newLocale);
|
|
313
|
+
} else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
|
|
314
|
+
const handler = customClientStrategies.get(strat);
|
|
315
|
+
if (handler) {
|
|
316
|
+
let result = handler.setLocale(newLocale);
|
|
317
|
+
if (result instanceof Promise) {
|
|
318
|
+
result = result.catch((error) => {
|
|
319
|
+
throw new Error(`Custom strategy "${strat}" setLocale failed.`, {
|
|
320
|
+
cause: error
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
customSetLocalePromises.push(result);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
const runReload = () => {
|
|
329
|
+
if (!isServer && optionsWithDefaults.reload && window.location && newLocale !== currentLocale) {
|
|
330
|
+
navigateOrReload(newLocation);
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
if (customSetLocalePromises.length) {
|
|
334
|
+
return Promise.all(customSetLocalePromises).then(() => {
|
|
335
|
+
runReload();
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
runReload();
|
|
339
|
+
return;
|
|
340
|
+
};
|
|
341
|
+
var getUrlOrigin = () => {
|
|
342
|
+
if (serverAsyncLocalStorage) {
|
|
343
|
+
return serverAsyncLocalStorage.getStore()?.origin ?? "http://fallback.com";
|
|
344
|
+
} else if (typeof window !== "undefined") {
|
|
345
|
+
return window.location.origin;
|
|
346
|
+
}
|
|
347
|
+
return "http://fallback.com";
|
|
348
|
+
};
|
|
349
|
+
function toLocale(value) {
|
|
350
|
+
if (typeof value !== "string") {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
const lowerValue = value.toLowerCase();
|
|
354
|
+
for (const locale of locales) {
|
|
355
|
+
if (locale.toLowerCase() === lowerValue) {
|
|
356
|
+
return locale;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
function assertIsLocale(input) {
|
|
362
|
+
const locale = toLocale(input);
|
|
363
|
+
if (locale)
|
|
364
|
+
return locale;
|
|
365
|
+
throw new Error(`Invalid locale: ${input}. Expected one of: ${locales.join(", ")}`);
|
|
366
|
+
}
|
|
367
|
+
function extractLocaleFromCookie() {
|
|
368
|
+
if (typeof document === "undefined" || !document.cookie) {
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
const match = document.cookie.match(new RegExp(`(^| )${cookieName}=([^;]+)`));
|
|
372
|
+
const locale = match?.[2];
|
|
373
|
+
return toLocale(locale);
|
|
374
|
+
}
|
|
375
|
+
function extractLocaleFromNavigator() {
|
|
376
|
+
if (!navigator?.languages?.length) {
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
const languages = navigator.languages.map((lang) => ({
|
|
380
|
+
fullTag: lang,
|
|
381
|
+
baseTag: lang.split("-")[0]
|
|
382
|
+
}));
|
|
383
|
+
for (const lang of languages) {
|
|
384
|
+
const fullLocale = toLocale(lang.fullTag);
|
|
385
|
+
if (fullLocale) {
|
|
386
|
+
return fullLocale;
|
|
387
|
+
}
|
|
388
|
+
const baseLocale2 = toLocale(lang.baseTag);
|
|
389
|
+
if (baseLocale2) {
|
|
390
|
+
return baseLocale2;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
var cachedUrl;
|
|
396
|
+
var cachedLocale;
|
|
397
|
+
function extractLocaleFromUrl(url) {
|
|
398
|
+
const urlString = typeof url === "string" ? url : url.href;
|
|
399
|
+
if (cachedUrl === urlString) {
|
|
400
|
+
return cachedLocale;
|
|
401
|
+
}
|
|
402
|
+
let result;
|
|
403
|
+
if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
|
|
404
|
+
result = defaultUrlPatternExtractLocale(url);
|
|
405
|
+
} else {
|
|
406
|
+
const urlObj = typeof url === "string" ? new URL(url) : url;
|
|
407
|
+
for (const element of urlPatterns) {
|
|
408
|
+
for (const [locale, localizedPattern] of element.localized) {
|
|
409
|
+
const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href);
|
|
410
|
+
if (match) {
|
|
411
|
+
result = locale;
|
|
412
|
+
break;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
if (result)
|
|
416
|
+
break;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
cachedUrl = urlString;
|
|
420
|
+
cachedLocale = result;
|
|
421
|
+
return result;
|
|
422
|
+
}
|
|
423
|
+
function defaultUrlPatternExtractLocale(url) {
|
|
424
|
+
const urlObj = new URL(url, "http://dummy.com");
|
|
425
|
+
const pathSegments = urlObj.pathname.split("/").filter(Boolean);
|
|
426
|
+
return toLocale(pathSegments[0]) || baseLocale;
|
|
427
|
+
}
|
|
428
|
+
function localizeUrl(url, options) {
|
|
429
|
+
const targetLocale = options?.locale ? assertIsLocale(options?.locale) : getLocale();
|
|
430
|
+
if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
|
|
431
|
+
return localizeUrlDefaultPattern(url, targetLocale);
|
|
432
|
+
}
|
|
433
|
+
const urlObj = typeof url === "string" ? new URL(url) : url;
|
|
434
|
+
for (const element of urlPatterns) {
|
|
435
|
+
for (const [, localizedPattern] of element.localized) {
|
|
436
|
+
const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href);
|
|
437
|
+
if (!match) {
|
|
438
|
+
continue;
|
|
439
|
+
}
|
|
440
|
+
const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1];
|
|
441
|
+
if (!targetPattern) {
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
const localizedUrl = fillPattern(targetPattern, aggregateGroups(match), urlObj.origin);
|
|
445
|
+
return fillMissingUrlParts(localizedUrl, match);
|
|
446
|
+
}
|
|
447
|
+
const unlocalizedMatch = new URLPattern(element.pattern, urlObj.href).exec(urlObj.href);
|
|
448
|
+
if (unlocalizedMatch) {
|
|
449
|
+
const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1];
|
|
450
|
+
if (targetPattern) {
|
|
451
|
+
const localizedUrl = fillPattern(targetPattern, aggregateGroups(unlocalizedMatch), urlObj.origin);
|
|
452
|
+
return fillMissingUrlParts(localizedUrl, unlocalizedMatch);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
return urlObj;
|
|
457
|
+
}
|
|
458
|
+
function localizeUrlDefaultPattern(url, locale) {
|
|
459
|
+
const urlObj = typeof url === "string" ? new URL(url, getUrlOrigin()) : new URL(url);
|
|
460
|
+
const currentLocale = extractLocaleFromUrl(urlObj);
|
|
461
|
+
if (currentLocale === locale) {
|
|
462
|
+
return urlObj;
|
|
463
|
+
}
|
|
464
|
+
const pathSegments = urlObj.pathname.split("/").filter(Boolean);
|
|
465
|
+
if (pathSegments.length > 0 && toLocale(pathSegments[0])) {
|
|
466
|
+
pathSegments.shift();
|
|
467
|
+
}
|
|
468
|
+
if (locale === baseLocale) {
|
|
469
|
+
urlObj.pathname = "/" + pathSegments.join("/");
|
|
470
|
+
} else {
|
|
471
|
+
urlObj.pathname = "/" + locale + "/" + pathSegments.join("/");
|
|
472
|
+
}
|
|
473
|
+
return urlObj;
|
|
474
|
+
}
|
|
475
|
+
function fillMissingUrlParts(url, match) {
|
|
476
|
+
if (match.protocol.groups["0"]) {
|
|
477
|
+
url.protocol = match.protocol.groups["0"] ?? "";
|
|
478
|
+
}
|
|
479
|
+
if (match.hostname.groups["0"]) {
|
|
480
|
+
url.hostname = match.hostname.groups["0"] ?? "";
|
|
481
|
+
}
|
|
482
|
+
if (match.username.groups["0"]) {
|
|
483
|
+
url.username = match.username.groups["0"] ?? "";
|
|
484
|
+
}
|
|
485
|
+
if (match.password.groups["0"]) {
|
|
486
|
+
url.password = match.password.groups["0"] ?? "";
|
|
487
|
+
}
|
|
488
|
+
if (match.port.groups["0"]) {
|
|
489
|
+
url.port = match.port.groups["0"] ?? "";
|
|
490
|
+
}
|
|
491
|
+
if (match.pathname.groups["0"]) {
|
|
492
|
+
url.pathname = match.pathname.groups["0"] ?? "";
|
|
493
|
+
}
|
|
494
|
+
if (match.search.groups["0"]) {
|
|
495
|
+
url.search = match.search.groups["0"] ?? "";
|
|
496
|
+
}
|
|
497
|
+
if (match.hash.groups["0"]) {
|
|
498
|
+
url.hash = match.hash.groups["0"] ?? "";
|
|
499
|
+
}
|
|
500
|
+
return url;
|
|
501
|
+
}
|
|
502
|
+
function fillPattern(pattern, values, origin) {
|
|
503
|
+
let processedPattern = pattern.replace(/(https?:\/\/[^:/]+):(\d+)(\/|$)/g, (_, protocol, port, slash) => {
|
|
504
|
+
return `${protocol}#PORT-${port}#${slash}`;
|
|
505
|
+
});
|
|
506
|
+
let processedGroupDelimiters = processedPattern.replace(/\{([^{}]*)\}([?+*]?)/g, (_, content, modifier) => {
|
|
507
|
+
if (modifier === "?") {
|
|
508
|
+
return content;
|
|
509
|
+
}
|
|
510
|
+
return content;
|
|
511
|
+
});
|
|
512
|
+
let filled = processedGroupDelimiters.replace(/(\/?):([a-zA-Z0-9_]+)(\([^)]*\))?([?+*]?)/g, (_, slash, name, __, modifier) => {
|
|
513
|
+
const value = values[name];
|
|
514
|
+
if (value === null) {
|
|
515
|
+
return "";
|
|
516
|
+
}
|
|
517
|
+
if (modifier === "?") {
|
|
518
|
+
return value !== undefined ? `${slash}${value}` : "";
|
|
519
|
+
}
|
|
520
|
+
if (modifier === "+" || modifier === "*") {
|
|
521
|
+
if (value === undefined && modifier === "+") {
|
|
522
|
+
throw new Error(`Missing value for "${name}" (one or more required)`);
|
|
523
|
+
}
|
|
524
|
+
return value ? `${slash}${value}` : "";
|
|
525
|
+
}
|
|
526
|
+
if (value === undefined) {
|
|
527
|
+
throw new Error(`Missing value for "${name}"`);
|
|
528
|
+
}
|
|
529
|
+
return `${slash}${value}`;
|
|
530
|
+
});
|
|
531
|
+
filled = filled.replace(/#PORT-(\d+)#/g, ":$1");
|
|
532
|
+
return new URL(filled, origin);
|
|
533
|
+
}
|
|
534
|
+
function aggregateGroups(match) {
|
|
535
|
+
return {
|
|
536
|
+
...match.hash.groups,
|
|
537
|
+
...match.hostname.groups,
|
|
538
|
+
...match.password.groups,
|
|
539
|
+
...match.pathname.groups,
|
|
540
|
+
...match.port.groups,
|
|
541
|
+
...match.protocol.groups,
|
|
542
|
+
...match.search.groups,
|
|
543
|
+
...match.username.groups
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
var customServerStrategies = new Map;
|
|
547
|
+
var customClientStrategies = new Map;
|
|
548
|
+
function isCustomStrategy(strategy2) {
|
|
549
|
+
return typeof strategy2 === "string" && /^custom-[A-Za-z0-9_-]+$/.test(strategy2);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
// ../../src/components/ui/virtualized-combobox.tsx
|
|
553
|
+
import { jsxDEV as jsxDEV5 } from "react/jsx-dev-runtime";
|
|
554
|
+
"use client";
|
|
555
|
+
var messages = {
|
|
556
|
+
en: {
|
|
557
|
+
search: "Search...",
|
|
558
|
+
selected: (count) => `${count} selected`,
|
|
559
|
+
selectMore: "Select more"
|
|
560
|
+
},
|
|
561
|
+
fr: {
|
|
562
|
+
search: "Rechercher...",
|
|
563
|
+
selected: (count) => `${count} sélectionnés`,
|
|
564
|
+
selectMore: "Sélectionner davantage"
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
var virtualizedComboboxMessages = (overrides) => ({
|
|
568
|
+
...getLocale().startsWith("fr") ? messages.fr : messages.en,
|
|
569
|
+
...overrides
|
|
570
|
+
});
|
|
571
|
+
var optionEquals = (item, selected) => item.value === selected.value;
|
|
572
|
+
var VirtualizedComboboxList = ({
|
|
573
|
+
emptyLabel,
|
|
574
|
+
groupSelections,
|
|
575
|
+
messages: messageOverrides,
|
|
576
|
+
renderItem,
|
|
577
|
+
selectedValues,
|
|
578
|
+
virtualizerRef
|
|
579
|
+
}) => {
|
|
580
|
+
const filteredItems = ComboboxPrimitive.useFilteredItems();
|
|
581
|
+
const labels = virtualizedComboboxMessages(messageOverrides);
|
|
582
|
+
const entries = filteredItems.flatMap((item, index) => {
|
|
583
|
+
if (!groupSelections)
|
|
584
|
+
return [{ kind: "item", item, index }];
|
|
585
|
+
const selected = selectedValues.has(item.value);
|
|
586
|
+
const previous = filteredItems[index - 1];
|
|
587
|
+
const startsGroup = index === 0 || selectedValues.has(previous?.value ?? "") !== selected;
|
|
588
|
+
const itemEntry = { kind: "item", item, index };
|
|
589
|
+
return startsGroup ? [
|
|
590
|
+
{
|
|
591
|
+
kind: "group",
|
|
592
|
+
key: selected ? "selected" : "available",
|
|
593
|
+
label: selected ? labels.selected(selectedValues.size) : labels.selectMore
|
|
594
|
+
},
|
|
595
|
+
itemEntry
|
|
596
|
+
] : [itemEntry];
|
|
597
|
+
});
|
|
598
|
+
const scrollRef = useRef(null);
|
|
599
|
+
const virtualizer = useVirtualizer({
|
|
600
|
+
count: entries.length,
|
|
601
|
+
getScrollElement: () => scrollRef.current,
|
|
602
|
+
getItemKey: (index) => {
|
|
603
|
+
const entry = entries[index];
|
|
604
|
+
return entry?.kind === "group" ? `group-${entry.key}` : entry?.item.value ?? index;
|
|
605
|
+
},
|
|
606
|
+
estimateSize: () => 36,
|
|
607
|
+
overscan: 8
|
|
608
|
+
});
|
|
609
|
+
useImperativeHandle(virtualizerRef, () => virtualizer, [virtualizer]);
|
|
610
|
+
const handleScrollElementRef = useCallback((element) => {
|
|
611
|
+
scrollRef.current = element;
|
|
612
|
+
if (element)
|
|
613
|
+
virtualizer.measure();
|
|
614
|
+
}, [virtualizer]);
|
|
615
|
+
if (filteredItems.length === 0) {
|
|
616
|
+
return /* @__PURE__ */ jsxDEV5("div", {
|
|
617
|
+
className: "text-muted-foreground py-6 text-center text-sm",
|
|
618
|
+
children: emptyLabel
|
|
619
|
+
}, undefined, false, undefined, this);
|
|
620
|
+
}
|
|
621
|
+
return /* @__PURE__ */ jsxDEV5(ComboboxPrimitive.List, {
|
|
622
|
+
className: "scroll-py-1 overflow-auto overscroll-contain p-1",
|
|
623
|
+
ref: handleScrollElementRef,
|
|
624
|
+
style: {
|
|
625
|
+
height: Math.min(virtualizer.getTotalSize() + 8, 288),
|
|
626
|
+
maxHeight: "var(--available-height)"
|
|
627
|
+
},
|
|
628
|
+
children: /* @__PURE__ */ jsxDEV5("div", {
|
|
629
|
+
className: "relative w-full",
|
|
630
|
+
role: "presentation",
|
|
631
|
+
style: { height: virtualizer.getTotalSize() },
|
|
632
|
+
children: virtualizer.getVirtualItems().map((virtualItem) => {
|
|
633
|
+
const entry = entries[virtualItem.index];
|
|
634
|
+
if (!entry)
|
|
635
|
+
return null;
|
|
636
|
+
const style = {
|
|
637
|
+
height: virtualItem.size,
|
|
638
|
+
transform: `translateY(${virtualItem.start}px)`
|
|
639
|
+
};
|
|
640
|
+
if (entry.kind === "group") {
|
|
641
|
+
return /* @__PURE__ */ jsxDEV5(ComboboxPrimitive.Group, {
|
|
642
|
+
className: "contents",
|
|
643
|
+
children: /* @__PURE__ */ jsxDEV5(ComboboxPrimitive.GroupLabel, {
|
|
644
|
+
className: "text-muted-foreground absolute top-0 left-0 w-full px-2 pt-3 pb-1 text-xs",
|
|
645
|
+
"data-index": virtualItem.index,
|
|
646
|
+
ref: virtualizer.measureElement,
|
|
647
|
+
style,
|
|
648
|
+
children: entry.label
|
|
649
|
+
}, undefined, false, undefined, this)
|
|
650
|
+
}, entry.key, false, undefined, this);
|
|
651
|
+
}
|
|
652
|
+
return /* @__PURE__ */ jsxDEV5(ComboboxPrimitive.Item, {
|
|
653
|
+
"aria-posinset": entry.index + 1,
|
|
654
|
+
"aria-setsize": filteredItems.length,
|
|
655
|
+
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",
|
|
656
|
+
"data-index": virtualItem.index,
|
|
657
|
+
index: entry.index,
|
|
658
|
+
ref: virtualizer.measureElement,
|
|
659
|
+
style,
|
|
660
|
+
value: entry.item,
|
|
661
|
+
children: [
|
|
662
|
+
renderItem?.(entry.item) ?? /* @__PURE__ */ jsxDEV5("span", {
|
|
663
|
+
className: "min-w-0 truncate",
|
|
664
|
+
children: entry.item.label
|
|
665
|
+
}, undefined, false, undefined, this),
|
|
666
|
+
/* @__PURE__ */ jsxDEV5(ComboboxPrimitive.ItemIndicator, {
|
|
667
|
+
className: "absolute right-2 flex size-4 items-center justify-center",
|
|
668
|
+
children: /* @__PURE__ */ jsxDEV5(Check, {}, undefined, false, undefined, this)
|
|
669
|
+
}, undefined, false, undefined, this)
|
|
670
|
+
]
|
|
671
|
+
}, entry.item.value, true, undefined, this);
|
|
672
|
+
})
|
|
673
|
+
}, undefined, false, undefined, this)
|
|
674
|
+
}, undefined, false, undefined, this);
|
|
675
|
+
};
|
|
676
|
+
var VirtualizedComboboxContent = ({
|
|
677
|
+
contentClassName,
|
|
678
|
+
emptyLabel,
|
|
679
|
+
groupSelections,
|
|
680
|
+
messages: messageOverrides,
|
|
681
|
+
renderItem,
|
|
682
|
+
selectedValues,
|
|
683
|
+
virtualizerRef
|
|
684
|
+
}) => {
|
|
685
|
+
const labels = virtualizedComboboxMessages(messageOverrides);
|
|
686
|
+
return /* @__PURE__ */ jsxDEV5(ComboboxPrimitive.Portal, {
|
|
687
|
+
children: /* @__PURE__ */ jsxDEV5(ComboboxPrimitive.Positioner, {
|
|
688
|
+
align: "start",
|
|
689
|
+
className: "isolate z-50",
|
|
690
|
+
side: "bottom",
|
|
691
|
+
sideOffset: 6,
|
|
692
|
+
children: /* @__PURE__ */ jsxDEV5(ComboboxPrimitive.Popup, {
|
|
693
|
+
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),
|
|
694
|
+
children: [
|
|
695
|
+
/* @__PURE__ */ jsxDEV5("div", {
|
|
696
|
+
className: "min-w-0 p-1 pb-0",
|
|
697
|
+
children: /* @__PURE__ */ jsxDEV5(InputGroup, {
|
|
698
|
+
className: "border-input/30 bg-input/30 h-8 w-full min-w-0 shadow-none",
|
|
699
|
+
children: /* @__PURE__ */ jsxDEV5(ComboboxPrimitive.Input, {
|
|
700
|
+
placeholder: labels.search,
|
|
701
|
+
render: /* @__PURE__ */ jsxDEV5(InputGroupInput, {}, undefined, false, undefined, this)
|
|
702
|
+
}, undefined, false, undefined, this)
|
|
703
|
+
}, undefined, false, undefined, this)
|
|
704
|
+
}, undefined, false, undefined, this),
|
|
705
|
+
/* @__PURE__ */ jsxDEV5(VirtualizedComboboxList, {
|
|
706
|
+
emptyLabel,
|
|
707
|
+
groupSelections,
|
|
708
|
+
messages: messageOverrides,
|
|
709
|
+
renderItem,
|
|
710
|
+
selectedValues,
|
|
711
|
+
virtualizerRef
|
|
712
|
+
}, undefined, false, undefined, this)
|
|
713
|
+
]
|
|
714
|
+
}, undefined, true, undefined, this)
|
|
715
|
+
}, undefined, false, undefined, this)
|
|
716
|
+
}, undefined, false, undefined, this);
|
|
717
|
+
};
|
|
718
|
+
var defaultTrigger = (ariaLabel, ariaInvalid, disabled, label, triggerId) => /* @__PURE__ */ jsxDEV5(Button, {
|
|
719
|
+
"aria-label": ariaLabel,
|
|
720
|
+
"aria-invalid": ariaInvalid,
|
|
721
|
+
className: "w-full max-w-full min-w-0 justify-between overflow-hidden",
|
|
722
|
+
disabled,
|
|
723
|
+
id: triggerId,
|
|
724
|
+
type: "button",
|
|
725
|
+
variant: "outline",
|
|
726
|
+
children: [
|
|
727
|
+
/* @__PURE__ */ jsxDEV5("span", {
|
|
728
|
+
className: "min-w-0 truncate text-left",
|
|
729
|
+
children: label
|
|
730
|
+
}, undefined, false, undefined, this),
|
|
731
|
+
/* @__PURE__ */ jsxDEV5(ChevronsUpDown, {
|
|
732
|
+
className: "text-muted-foreground shrink-0 opacity-70"
|
|
733
|
+
}, undefined, false, undefined, this)
|
|
734
|
+
]
|
|
735
|
+
}, undefined, true, undefined, this);
|
|
736
|
+
var selectedLabel = (value, placeholder) => {
|
|
737
|
+
if (Array.isArray(value)) {
|
|
738
|
+
return value.length > 0 ? value.map(({ label }) => label).join(", ") : placeholder;
|
|
739
|
+
}
|
|
740
|
+
return value && "label" in value ? value.label : placeholder;
|
|
741
|
+
};
|
|
742
|
+
var useComboboxVirtualizerRef = (providedRef) => {
|
|
743
|
+
const localRef = useRef(null);
|
|
744
|
+
return providedRef ?? localRef;
|
|
745
|
+
};
|
|
746
|
+
var VirtualizedComboboxSingle = (props) => {
|
|
747
|
+
const virtualizerRef = useComboboxVirtualizerRef(props.virtualizerRef);
|
|
748
|
+
return /* @__PURE__ */ jsxDEV5(ComboboxPrimitive.Root, {
|
|
749
|
+
disabled: props.disabled,
|
|
750
|
+
inputValue: props.searchValue,
|
|
751
|
+
items: [...props.items],
|
|
752
|
+
itemToStringLabel: (item) => item.label,
|
|
753
|
+
isItemEqualToValue: optionEquals,
|
|
754
|
+
onInputValueChange: (value) => props.onSearchValueChange?.(value),
|
|
755
|
+
onItemHighlighted: (_, { index, reason }) => {
|
|
756
|
+
if (reason === "keyboard" && index >= 0) {
|
|
757
|
+
virtualizerRef.current?.scrollToIndex(index, { align: "auto" });
|
|
758
|
+
}
|
|
759
|
+
},
|
|
760
|
+
onOpenChange: (open) => props.onOpenChange?.(open),
|
|
761
|
+
onValueChange: (value) => props.onValueChange(value),
|
|
762
|
+
open: props.open,
|
|
763
|
+
value: props.value,
|
|
764
|
+
virtualized: true,
|
|
765
|
+
children: [
|
|
766
|
+
/* @__PURE__ */ jsxDEV5(ComboboxPrimitive.Trigger, {
|
|
767
|
+
render: props.trigger ?? defaultTrigger(props.ariaLabel, props.ariaInvalid, props.disabled, selectedLabel(props.value, props.placeholder), props.triggerId)
|
|
768
|
+
}, undefined, false, undefined, this),
|
|
769
|
+
/* @__PURE__ */ jsxDEV5(VirtualizedComboboxContent, {
|
|
770
|
+
...props,
|
|
771
|
+
groupSelections: false,
|
|
772
|
+
selectedValues: new Set(props.value ? [props.value.value] : []),
|
|
773
|
+
virtualizerRef
|
|
774
|
+
}, undefined, false, undefined, this)
|
|
775
|
+
]
|
|
776
|
+
}, undefined, true, undefined, this);
|
|
777
|
+
};
|
|
778
|
+
var VirtualizedComboboxMultiple = (props) => {
|
|
779
|
+
const virtualizerRef = useComboboxVirtualizerRef(props.virtualizerRef);
|
|
780
|
+
return /* @__PURE__ */ jsxDEV5(ComboboxPrimitive.Root, {
|
|
781
|
+
disabled: props.disabled,
|
|
782
|
+
inputValue: props.searchValue,
|
|
783
|
+
items: [...props.items],
|
|
784
|
+
itemToStringLabel: (item) => item.label,
|
|
785
|
+
isItemEqualToValue: optionEquals,
|
|
786
|
+
multiple: true,
|
|
787
|
+
onInputValueChange: (value) => props.onSearchValueChange?.(value),
|
|
788
|
+
onItemHighlighted: (_, { index, reason }) => {
|
|
789
|
+
if (reason === "keyboard" && index >= 0) {
|
|
790
|
+
virtualizerRef.current?.scrollToIndex(index, { align: "auto" });
|
|
791
|
+
}
|
|
792
|
+
},
|
|
793
|
+
onOpenChange: (open) => props.onOpenChange?.(open),
|
|
794
|
+
onValueChange: (value) => props.onValueChange(value),
|
|
795
|
+
open: props.open,
|
|
796
|
+
value: [...props.value],
|
|
797
|
+
virtualized: true,
|
|
798
|
+
children: [
|
|
799
|
+
/* @__PURE__ */ jsxDEV5(ComboboxPrimitive.Trigger, {
|
|
800
|
+
render: props.trigger ?? defaultTrigger(props.ariaLabel, props.ariaInvalid, props.disabled, selectedLabel(props.value, props.placeholder), props.triggerId)
|
|
801
|
+
}, undefined, false, undefined, this),
|
|
802
|
+
/* @__PURE__ */ jsxDEV5(VirtualizedComboboxContent, {
|
|
803
|
+
...props,
|
|
804
|
+
groupSelections: true,
|
|
805
|
+
selectedValues: new Set(props.value.map(({ value }) => value)),
|
|
806
|
+
virtualizerRef
|
|
807
|
+
}, undefined, false, undefined, this)
|
|
808
|
+
]
|
|
809
|
+
}, undefined, true, undefined, this);
|
|
810
|
+
};
|
|
811
|
+
function VirtualizedCombobox(props) {
|
|
812
|
+
return props.multiple ? /* @__PURE__ */ jsxDEV5(VirtualizedComboboxMultiple, {
|
|
813
|
+
...props
|
|
814
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV5(VirtualizedComboboxSingle, {
|
|
815
|
+
...props
|
|
816
|
+
}, undefined, false, undefined, this);
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
// ../../src/components/ui/dropdown-menu.tsx
|
|
820
|
+
import { Menu as MenuPrimitive } from "@base-ui/react/menu";
|
|
821
|
+
import { ChevronRightIcon, CheckIcon } from "lucide-react";
|
|
822
|
+
import { jsxDEV as jsxDEV6 } from "react/jsx-dev-runtime";
|
|
823
|
+
function DropdownMenu({ ...props }) {
|
|
824
|
+
return /* @__PURE__ */ jsxDEV6(MenuPrimitive.Root, {
|
|
825
|
+
"data-slot": "dropdown-menu",
|
|
826
|
+
...props
|
|
827
|
+
}, undefined, false, undefined, this);
|
|
828
|
+
}
|
|
829
|
+
function DropdownMenuTrigger({ ...props }) {
|
|
830
|
+
return /* @__PURE__ */ jsxDEV6(MenuPrimitive.Trigger, {
|
|
831
|
+
"data-slot": "dropdown-menu-trigger",
|
|
832
|
+
...props
|
|
833
|
+
}, undefined, false, undefined, this);
|
|
834
|
+
}
|
|
835
|
+
function DropdownMenuContent({
|
|
836
|
+
align = "start",
|
|
837
|
+
alignOffset = 0,
|
|
838
|
+
side = "bottom",
|
|
839
|
+
sideOffset = 4,
|
|
840
|
+
className,
|
|
841
|
+
...props
|
|
842
|
+
}) {
|
|
843
|
+
return /* @__PURE__ */ jsxDEV6(MenuPrimitive.Portal, {
|
|
844
|
+
children: /* @__PURE__ */ jsxDEV6(MenuPrimitive.Positioner, {
|
|
845
|
+
className: "isolate z-50 outline-none",
|
|
846
|
+
align,
|
|
847
|
+
alignOffset,
|
|
848
|
+
side,
|
|
849
|
+
sideOffset,
|
|
850
|
+
children: /* @__PURE__ */ jsxDEV6(MenuPrimitive.Popup, {
|
|
851
|
+
"data-slot": "dropdown-menu-content",
|
|
852
|
+
className: cn("z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-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:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95", className),
|
|
853
|
+
...props
|
|
854
|
+
}, undefined, false, undefined, this)
|
|
855
|
+
}, undefined, false, undefined, this)
|
|
856
|
+
}, undefined, false, undefined, this);
|
|
857
|
+
}
|
|
858
|
+
function DropdownMenuGroup({ ...props }) {
|
|
859
|
+
return /* @__PURE__ */ jsxDEV6(MenuPrimitive.Group, {
|
|
860
|
+
"data-slot": "dropdown-menu-group",
|
|
861
|
+
...props
|
|
862
|
+
}, undefined, false, undefined, this);
|
|
863
|
+
}
|
|
864
|
+
function DropdownMenuLabel({
|
|
865
|
+
className,
|
|
866
|
+
inset,
|
|
867
|
+
...props
|
|
868
|
+
}) {
|
|
869
|
+
return /* @__PURE__ */ jsxDEV6(MenuPrimitive.GroupLabel, {
|
|
870
|
+
"data-slot": "dropdown-menu-label",
|
|
871
|
+
"data-inset": inset,
|
|
872
|
+
className: cn("px-2 py-1.5 text-xs font-medium text-muted-foreground data-inset:pl-8", className),
|
|
873
|
+
...props
|
|
874
|
+
}, undefined, false, undefined, this);
|
|
875
|
+
}
|
|
876
|
+
function DropdownMenuItem({
|
|
877
|
+
className,
|
|
878
|
+
inset,
|
|
879
|
+
variant = "default",
|
|
880
|
+
...props
|
|
881
|
+
}) {
|
|
882
|
+
return /* @__PURE__ */ jsxDEV6(MenuPrimitive.Item, {
|
|
883
|
+
"data-slot": "dropdown-menu-item",
|
|
884
|
+
"data-inset": inset,
|
|
885
|
+
"data-variant": variant,
|
|
886
|
+
className: cn("group/dropdown-menu-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive", className),
|
|
887
|
+
...props
|
|
888
|
+
}, undefined, false, undefined, this);
|
|
889
|
+
}
|
|
890
|
+
function DropdownMenuSub({ ...props }) {
|
|
891
|
+
return /* @__PURE__ */ jsxDEV6(MenuPrimitive.SubmenuRoot, {
|
|
892
|
+
"data-slot": "dropdown-menu-sub",
|
|
893
|
+
...props
|
|
894
|
+
}, undefined, false, undefined, this);
|
|
895
|
+
}
|
|
896
|
+
function DropdownMenuSubTrigger({
|
|
897
|
+
className,
|
|
898
|
+
inset,
|
|
899
|
+
children,
|
|
900
|
+
...props
|
|
901
|
+
}) {
|
|
902
|
+
return /* @__PURE__ */ jsxDEV6(MenuPrimitive.SubmenuTrigger, {
|
|
903
|
+
"data-slot": "dropdown-menu-sub-trigger",
|
|
904
|
+
"data-inset": inset,
|
|
905
|
+
className: cn("flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-8 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
|
|
906
|
+
...props,
|
|
907
|
+
children: [
|
|
908
|
+
children,
|
|
909
|
+
/* @__PURE__ */ jsxDEV6(ChevronRightIcon, {
|
|
910
|
+
className: "ml-auto"
|
|
911
|
+
}, undefined, false, undefined, this)
|
|
912
|
+
]
|
|
913
|
+
}, undefined, true, undefined, this);
|
|
914
|
+
}
|
|
915
|
+
function DropdownMenuSubContent({
|
|
916
|
+
align = "start",
|
|
917
|
+
alignOffset = -3,
|
|
918
|
+
side = "right",
|
|
919
|
+
sideOffset = 0,
|
|
920
|
+
className,
|
|
921
|
+
...props
|
|
922
|
+
}) {
|
|
923
|
+
return /* @__PURE__ */ jsxDEV6(DropdownMenuContent, {
|
|
924
|
+
"data-slot": "dropdown-menu-sub-content",
|
|
925
|
+
className: cn("w-auto min-w-[96px] rounded-md bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-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-out-95", className),
|
|
926
|
+
align,
|
|
927
|
+
alignOffset,
|
|
928
|
+
side,
|
|
929
|
+
sideOffset,
|
|
930
|
+
...props
|
|
931
|
+
}, undefined, false, undefined, this);
|
|
932
|
+
}
|
|
933
|
+
function DropdownMenuCheckboxItem({
|
|
934
|
+
className,
|
|
935
|
+
children,
|
|
936
|
+
checked,
|
|
937
|
+
inset,
|
|
938
|
+
...props
|
|
939
|
+
}) {
|
|
940
|
+
return /* @__PURE__ */ jsxDEV6(MenuPrimitive.CheckboxItem, {
|
|
941
|
+
"data-slot": "dropdown-menu-checkbox-item",
|
|
942
|
+
"data-inset": inset,
|
|
943
|
+
className: cn("relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-8 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
|
|
944
|
+
checked,
|
|
945
|
+
...props,
|
|
946
|
+
children: [
|
|
947
|
+
/* @__PURE__ */ jsxDEV6("span", {
|
|
948
|
+
className: "pointer-events-none absolute right-2 flex items-center justify-center",
|
|
949
|
+
"data-slot": "dropdown-menu-checkbox-item-indicator",
|
|
950
|
+
children: /* @__PURE__ */ jsxDEV6(MenuPrimitive.CheckboxItemIndicator, {
|
|
951
|
+
children: /* @__PURE__ */ jsxDEV6(CheckIcon, {}, undefined, false, undefined, this)
|
|
952
|
+
}, undefined, false, undefined, this)
|
|
953
|
+
}, undefined, false, undefined, this),
|
|
954
|
+
children
|
|
955
|
+
]
|
|
956
|
+
}, undefined, true, undefined, this);
|
|
957
|
+
}
|
|
958
|
+
function DropdownMenuRadioGroup({ ...props }) {
|
|
959
|
+
return /* @__PURE__ */ jsxDEV6(MenuPrimitive.RadioGroup, {
|
|
960
|
+
"data-slot": "dropdown-menu-radio-group",
|
|
961
|
+
...props
|
|
962
|
+
}, undefined, false, undefined, this);
|
|
963
|
+
}
|
|
964
|
+
function DropdownMenuRadioItem({
|
|
965
|
+
className,
|
|
966
|
+
children,
|
|
967
|
+
inset,
|
|
968
|
+
...props
|
|
969
|
+
}) {
|
|
970
|
+
return /* @__PURE__ */ jsxDEV6(MenuPrimitive.RadioItem, {
|
|
971
|
+
"data-slot": "dropdown-menu-radio-item",
|
|
972
|
+
"data-inset": inset,
|
|
973
|
+
className: cn("relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-8 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
|
|
974
|
+
...props,
|
|
975
|
+
children: [
|
|
976
|
+
/* @__PURE__ */ jsxDEV6("span", {
|
|
977
|
+
className: "pointer-events-none absolute right-2 flex items-center justify-center",
|
|
978
|
+
"data-slot": "dropdown-menu-radio-item-indicator",
|
|
979
|
+
children: /* @__PURE__ */ jsxDEV6(MenuPrimitive.RadioItemIndicator, {
|
|
980
|
+
children: /* @__PURE__ */ jsxDEV6(CheckIcon, {}, undefined, false, undefined, this)
|
|
981
|
+
}, undefined, false, undefined, this)
|
|
982
|
+
}, undefined, false, undefined, this),
|
|
983
|
+
children
|
|
984
|
+
]
|
|
985
|
+
}, undefined, true, undefined, this);
|
|
986
|
+
}
|
|
987
|
+
function DropdownMenuSeparator({
|
|
988
|
+
className,
|
|
989
|
+
...props
|
|
990
|
+
}) {
|
|
991
|
+
return /* @__PURE__ */ jsxDEV6(MenuPrimitive.Separator, {
|
|
992
|
+
"data-slot": "dropdown-menu-separator",
|
|
993
|
+
className: cn("-mx-1 my-1 h-px bg-border", className),
|
|
994
|
+
...props
|
|
995
|
+
}, undefined, false, undefined, this);
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
// ../../src/components/ui/pagination.tsx
|
|
999
|
+
import {
|
|
1000
|
+
ChevronLeft,
|
|
1001
|
+
ChevronRight,
|
|
1002
|
+
ChevronsLeft,
|
|
1003
|
+
ChevronsRight
|
|
1004
|
+
} from "lucide-react";
|
|
1005
|
+
import { useId } from "react";
|
|
1006
|
+
|
|
1007
|
+
// ../../src/components/ui/label.tsx
|
|
1008
|
+
import { jsxDEV as jsxDEV7 } from "react/jsx-dev-runtime";
|
|
1009
|
+
"use client";
|
|
1010
|
+
function Label({ className, ...props }) {
|
|
1011
|
+
return /* @__PURE__ */ jsxDEV7("label", {
|
|
1012
|
+
"data-slot": "label",
|
|
1013
|
+
className: cn("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50", className),
|
|
1014
|
+
...props
|
|
1015
|
+
}, undefined, false, undefined, this);
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
// ../../src/components/ui/select.tsx
|
|
1019
|
+
import { Select as SelectPrimitive } from "@base-ui/react/select";
|
|
1020
|
+
import { ChevronDownIcon, CheckIcon as CheckIcon2, ChevronUpIcon } from "lucide-react";
|
|
1021
|
+
import { jsxDEV as jsxDEV8 } from "react/jsx-dev-runtime";
|
|
1022
|
+
"use client";
|
|
1023
|
+
var Select = SelectPrimitive.Root;
|
|
1024
|
+
function SelectValue({ className, ...props }) {
|
|
1025
|
+
return /* @__PURE__ */ jsxDEV8(SelectPrimitive.Value, {
|
|
1026
|
+
"data-slot": "select-value",
|
|
1027
|
+
className: cn("flex flex-1 text-left", className),
|
|
1028
|
+
...props
|
|
1029
|
+
}, undefined, false, undefined, this);
|
|
1030
|
+
}
|
|
1031
|
+
function SelectTrigger({
|
|
1032
|
+
className,
|
|
1033
|
+
size = "default",
|
|
1034
|
+
children,
|
|
1035
|
+
...props
|
|
1036
|
+
}) {
|
|
1037
|
+
return /* @__PURE__ */ jsxDEV8(SelectPrimitive.Trigger, {
|
|
1038
|
+
"data-slot": "select-trigger",
|
|
1039
|
+
"data-size": size,
|
|
1040
|
+
className: cn("flex w-fit items-center justify-between gap-1.5 rounded-md border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 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", className),
|
|
1041
|
+
...props,
|
|
1042
|
+
children: [
|
|
1043
|
+
children,
|
|
1044
|
+
/* @__PURE__ */ jsxDEV8(SelectPrimitive.Icon, {
|
|
1045
|
+
render: /* @__PURE__ */ jsxDEV8(ChevronDownIcon, {
|
|
1046
|
+
className: "text-muted-foreground pointer-events-none size-4"
|
|
1047
|
+
}, undefined, false, undefined, this)
|
|
1048
|
+
}, undefined, false, undefined, this)
|
|
1049
|
+
]
|
|
1050
|
+
}, undefined, true, undefined, this);
|
|
1051
|
+
}
|
|
1052
|
+
function SelectContent({
|
|
1053
|
+
className,
|
|
1054
|
+
children,
|
|
1055
|
+
side = "bottom",
|
|
1056
|
+
sideOffset = 4,
|
|
1057
|
+
align = "center",
|
|
1058
|
+
alignOffset = 0,
|
|
1059
|
+
alignItemWithTrigger = true,
|
|
1060
|
+
...props
|
|
1061
|
+
}) {
|
|
1062
|
+
return /* @__PURE__ */ jsxDEV8(SelectPrimitive.Portal, {
|
|
1063
|
+
children: /* @__PURE__ */ jsxDEV8(SelectPrimitive.Positioner, {
|
|
1064
|
+
side,
|
|
1065
|
+
sideOffset,
|
|
1066
|
+
align,
|
|
1067
|
+
alignOffset,
|
|
1068
|
+
alignItemWithTrigger,
|
|
1069
|
+
className: "isolate z-50",
|
|
1070
|
+
children: /* @__PURE__ */ jsxDEV8(SelectPrimitive.Popup, {
|
|
1071
|
+
"data-slot": "select-content",
|
|
1072
|
+
"data-align-trigger": alignItemWithTrigger,
|
|
1073
|
+
className: cn("relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-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-out-95", className),
|
|
1074
|
+
...props,
|
|
1075
|
+
children: [
|
|
1076
|
+
/* @__PURE__ */ jsxDEV8(SelectScrollUpButton, {}, undefined, false, undefined, this),
|
|
1077
|
+
/* @__PURE__ */ jsxDEV8(SelectPrimitive.List, {
|
|
1078
|
+
children
|
|
1079
|
+
}, undefined, false, undefined, this),
|
|
1080
|
+
/* @__PURE__ */ jsxDEV8(SelectScrollDownButton, {}, undefined, false, undefined, this)
|
|
1081
|
+
]
|
|
1082
|
+
}, undefined, true, undefined, this)
|
|
1083
|
+
}, undefined, false, undefined, this)
|
|
1084
|
+
}, undefined, false, undefined, this);
|
|
1085
|
+
}
|
|
1086
|
+
function SelectItem({
|
|
1087
|
+
className,
|
|
1088
|
+
children,
|
|
1089
|
+
...props
|
|
1090
|
+
}) {
|
|
1091
|
+
return /* @__PURE__ */ jsxDEV8(SelectPrimitive.Item, {
|
|
1092
|
+
"data-slot": "select-item",
|
|
1093
|
+
className: cn("relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2", className),
|
|
1094
|
+
...props,
|
|
1095
|
+
children: [
|
|
1096
|
+
/* @__PURE__ */ jsxDEV8(SelectPrimitive.ItemText, {
|
|
1097
|
+
className: "flex flex-1 shrink-0 gap-2 whitespace-nowrap",
|
|
1098
|
+
children
|
|
1099
|
+
}, undefined, false, undefined, this),
|
|
1100
|
+
/* @__PURE__ */ jsxDEV8(SelectPrimitive.ItemIndicator, {
|
|
1101
|
+
render: /* @__PURE__ */ jsxDEV8("span", {
|
|
1102
|
+
className: "pointer-events-none absolute right-2 flex size-4 items-center justify-center"
|
|
1103
|
+
}, undefined, false, undefined, this),
|
|
1104
|
+
children: /* @__PURE__ */ jsxDEV8(CheckIcon2, {
|
|
1105
|
+
className: "pointer-events-none"
|
|
1106
|
+
}, undefined, false, undefined, this)
|
|
1107
|
+
}, undefined, false, undefined, this)
|
|
1108
|
+
]
|
|
1109
|
+
}, undefined, true, undefined, this);
|
|
1110
|
+
}
|
|
1111
|
+
function SelectScrollUpButton({
|
|
1112
|
+
className,
|
|
1113
|
+
...props
|
|
1114
|
+
}) {
|
|
1115
|
+
return /* @__PURE__ */ jsxDEV8(SelectPrimitive.ScrollUpArrow, {
|
|
1116
|
+
"data-slot": "select-scroll-up-button",
|
|
1117
|
+
className: cn("top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4", className),
|
|
1118
|
+
...props,
|
|
1119
|
+
children: /* @__PURE__ */ jsxDEV8(ChevronUpIcon, {}, undefined, false, undefined, this)
|
|
1120
|
+
}, undefined, false, undefined, this);
|
|
1121
|
+
}
|
|
1122
|
+
function SelectScrollDownButton({
|
|
1123
|
+
className,
|
|
1124
|
+
...props
|
|
1125
|
+
}) {
|
|
1126
|
+
return /* @__PURE__ */ jsxDEV8(SelectPrimitive.ScrollDownArrow, {
|
|
1127
|
+
"data-slot": "select-scroll-down-button",
|
|
1128
|
+
className: cn("bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4", className),
|
|
1129
|
+
...props,
|
|
1130
|
+
children: /* @__PURE__ */ jsxDEV8(ChevronDownIcon, {}, undefined, false, undefined, this)
|
|
1131
|
+
}, undefined, false, undefined, this);
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
// ../../src/components/ui/pagination.tsx
|
|
1135
|
+
import { jsxDEV as jsxDEV9 } from "react/jsx-dev-runtime";
|
|
1136
|
+
var messages2 = {
|
|
1137
|
+
en: {
|
|
1138
|
+
pageSize: "Page size",
|
|
1139
|
+
results: (count) => `${count} results`,
|
|
1140
|
+
selectedOf: (selected, total) => `${selected} of ${total}`,
|
|
1141
|
+
pageOf: (page, total) => `Page ${page} of ${total}`,
|
|
1142
|
+
goToFirstPage: "Go to first page",
|
|
1143
|
+
goToPreviousPage: "Go to previous page",
|
|
1144
|
+
goToNextPage: "Go to next page",
|
|
1145
|
+
goToLastPage: "Go to last page"
|
|
1146
|
+
},
|
|
1147
|
+
fr: {
|
|
1148
|
+
pageSize: "Taille de la page",
|
|
1149
|
+
results: (count) => `${count} résultats`,
|
|
1150
|
+
selectedOf: (selected, total) => `${selected} sur ${total}`,
|
|
1151
|
+
pageOf: (page, total) => `Page ${page} sur ${total}`,
|
|
1152
|
+
goToFirstPage: "Aller à la première page",
|
|
1153
|
+
goToPreviousPage: "Aller à la page précédente",
|
|
1154
|
+
goToNextPage: "Aller à la page suivante",
|
|
1155
|
+
goToLastPage: "Aller à la dernière page"
|
|
1156
|
+
}
|
|
1157
|
+
};
|
|
1158
|
+
var paginationMessages = (locale = getLocale(), overrides) => ({
|
|
1159
|
+
...locale.startsWith("fr") ? messages2.fr : messages2.en,
|
|
1160
|
+
...overrides
|
|
1161
|
+
});
|
|
1162
|
+
function Pagination({
|
|
1163
|
+
compact = false,
|
|
1164
|
+
messages: messageOverrides,
|
|
1165
|
+
onPageChange,
|
|
1166
|
+
onPageSizeChange,
|
|
1167
|
+
page,
|
|
1168
|
+
pageCount,
|
|
1169
|
+
pageSize,
|
|
1170
|
+
pageSizes = [10, 20, 30, 40, 50],
|
|
1171
|
+
selectedRows = 0,
|
|
1172
|
+
showResults = true,
|
|
1173
|
+
totalRows
|
|
1174
|
+
}) {
|
|
1175
|
+
const labels = paginationMessages(getLocale(), messageOverrides);
|
|
1176
|
+
const pageSizeId = useId();
|
|
1177
|
+
const canGoBack = page > 0;
|
|
1178
|
+
const canGoForward = page + 1 < pageCount;
|
|
1179
|
+
return /* @__PURE__ */ jsxDEV9("div", {
|
|
1180
|
+
className: cn("flex flex-col gap-3 px-2 sm:flex-row sm:items-center sm:justify-between", compact && "gap-2 px-0 sm:flex-col sm:items-stretch"),
|
|
1181
|
+
children: [
|
|
1182
|
+
showResults ? /* @__PURE__ */ jsxDEV9("div", {
|
|
1183
|
+
className: "text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",
|
|
1184
|
+
children: [
|
|
1185
|
+
/* @__PURE__ */ jsxDEV9("span", {
|
|
1186
|
+
children: labels.results(totalRows)
|
|
1187
|
+
}, undefined, false, undefined, this),
|
|
1188
|
+
selectedRows > 0 ? /* @__PURE__ */ jsxDEV9("span", {
|
|
1189
|
+
children: labels.selectedOf(selectedRows, totalRows)
|
|
1190
|
+
}, undefined, false, undefined, this) : null
|
|
1191
|
+
]
|
|
1192
|
+
}, undefined, true, undefined, this) : null,
|
|
1193
|
+
/* @__PURE__ */ jsxDEV9("div", {
|
|
1194
|
+
className: cn("flex items-center gap-4 sm:justify-end", compact && "flex-wrap justify-between gap-2 sm:justify-between"),
|
|
1195
|
+
children: [
|
|
1196
|
+
/* @__PURE__ */ jsxDEV9("div", {
|
|
1197
|
+
className: "flex items-center gap-2",
|
|
1198
|
+
children: [
|
|
1199
|
+
/* @__PURE__ */ jsxDEV9(Label, {
|
|
1200
|
+
htmlFor: pageSizeId,
|
|
1201
|
+
className: cn("hidden text-sm sm:block", compact && "block"),
|
|
1202
|
+
children: labels.pageSize
|
|
1203
|
+
}, undefined, false, undefined, this),
|
|
1204
|
+
/* @__PURE__ */ jsxDEV9(Select, {
|
|
1205
|
+
items: pageSizes.map((size) => ({
|
|
1206
|
+
label: size.toString(),
|
|
1207
|
+
value: size.toString()
|
|
1208
|
+
})),
|
|
1209
|
+
value: `${pageSize}`,
|
|
1210
|
+
onValueChange: (value) => onPageSizeChange(Number(value)),
|
|
1211
|
+
children: [
|
|
1212
|
+
/* @__PURE__ */ jsxDEV9(SelectTrigger, {
|
|
1213
|
+
className: "h-8 w-[70px]",
|
|
1214
|
+
id: pageSizeId,
|
|
1215
|
+
children: /* @__PURE__ */ jsxDEV9(SelectValue, {
|
|
1216
|
+
placeholder: pageSize
|
|
1217
|
+
}, undefined, false, undefined, this)
|
|
1218
|
+
}, undefined, false, undefined, this),
|
|
1219
|
+
/* @__PURE__ */ jsxDEV9(SelectContent, {
|
|
1220
|
+
side: "top",
|
|
1221
|
+
children: pageSizes.map((size) => /* @__PURE__ */ jsxDEV9(SelectItem, {
|
|
1222
|
+
value: `${size}`,
|
|
1223
|
+
children: size
|
|
1224
|
+
}, size, false, undefined, this))
|
|
1225
|
+
}, undefined, false, undefined, this)
|
|
1226
|
+
]
|
|
1227
|
+
}, undefined, true, undefined, this)
|
|
1228
|
+
]
|
|
1229
|
+
}, undefined, true, undefined, this),
|
|
1230
|
+
/* @__PURE__ */ jsxDEV9("div", {
|
|
1231
|
+
className: "flex items-center gap-2",
|
|
1232
|
+
children: [
|
|
1233
|
+
/* @__PURE__ */ jsxDEV9("div", {
|
|
1234
|
+
className: "flex items-center justify-center text-sm font-medium sm:block",
|
|
1235
|
+
children: labels.pageOf(page + 1, pageCount)
|
|
1236
|
+
}, undefined, false, undefined, this),
|
|
1237
|
+
/* @__PURE__ */ jsxDEV9("div", {
|
|
1238
|
+
className: "flex items-center gap-1",
|
|
1239
|
+
children: [
|
|
1240
|
+
/* @__PURE__ */ jsxDEV9(Button, {
|
|
1241
|
+
className: cn("hidden h-8 w-8 p-0 lg:flex", compact && "!hidden"),
|
|
1242
|
+
disabled: !canGoBack,
|
|
1243
|
+
onClick: () => onPageChange(0),
|
|
1244
|
+
type: "button",
|
|
1245
|
+
children: [
|
|
1246
|
+
/* @__PURE__ */ jsxDEV9("span", {
|
|
1247
|
+
className: "sr-only",
|
|
1248
|
+
children: labels.goToFirstPage
|
|
1249
|
+
}, undefined, false, undefined, this),
|
|
1250
|
+
/* @__PURE__ */ jsxDEV9(ChevronsLeft, {}, undefined, false, undefined, this)
|
|
1251
|
+
]
|
|
1252
|
+
}, undefined, true, undefined, this),
|
|
1253
|
+
/* @__PURE__ */ jsxDEV9(Button, {
|
|
1254
|
+
className: "h-8 w-8 p-0",
|
|
1255
|
+
disabled: !canGoBack,
|
|
1256
|
+
onClick: () => onPageChange(page - 1),
|
|
1257
|
+
type: "button",
|
|
1258
|
+
children: [
|
|
1259
|
+
/* @__PURE__ */ jsxDEV9("span", {
|
|
1260
|
+
className: "sr-only",
|
|
1261
|
+
children: labels.goToPreviousPage
|
|
1262
|
+
}, undefined, false, undefined, this),
|
|
1263
|
+
/* @__PURE__ */ jsxDEV9(ChevronLeft, {}, undefined, false, undefined, this)
|
|
1264
|
+
]
|
|
1265
|
+
}, undefined, true, undefined, this),
|
|
1266
|
+
/* @__PURE__ */ jsxDEV9(Button, {
|
|
1267
|
+
className: "h-8 w-8 p-0",
|
|
1268
|
+
disabled: !canGoForward,
|
|
1269
|
+
onClick: () => onPageChange(page + 1),
|
|
1270
|
+
type: "button",
|
|
1271
|
+
children: [
|
|
1272
|
+
/* @__PURE__ */ jsxDEV9("span", {
|
|
1273
|
+
className: "sr-only",
|
|
1274
|
+
children: labels.goToNextPage
|
|
1275
|
+
}, undefined, false, undefined, this),
|
|
1276
|
+
/* @__PURE__ */ jsxDEV9(ChevronRight, {}, undefined, false, undefined, this)
|
|
1277
|
+
]
|
|
1278
|
+
}, undefined, true, undefined, this),
|
|
1279
|
+
/* @__PURE__ */ jsxDEV9(Button, {
|
|
1280
|
+
className: cn("hidden h-8 w-8 p-0 lg:flex", compact && "!hidden"),
|
|
1281
|
+
disabled: !canGoForward,
|
|
1282
|
+
onClick: () => onPageChange(pageCount - 1),
|
|
1283
|
+
type: "button",
|
|
1284
|
+
children: [
|
|
1285
|
+
/* @__PURE__ */ jsxDEV9("span", {
|
|
1286
|
+
className: "sr-only",
|
|
1287
|
+
children: labels.goToLastPage
|
|
1288
|
+
}, undefined, false, undefined, this),
|
|
1289
|
+
/* @__PURE__ */ jsxDEV9(ChevronsRight, {}, undefined, false, undefined, this)
|
|
1290
|
+
]
|
|
1291
|
+
}, undefined, true, undefined, this)
|
|
1292
|
+
]
|
|
1293
|
+
}, undefined, true, undefined, this)
|
|
1294
|
+
]
|
|
1295
|
+
}, undefined, true, undefined, this)
|
|
1296
|
+
]
|
|
1297
|
+
}, undefined, true, undefined, this)
|
|
1298
|
+
]
|
|
1299
|
+
}, undefined, true, undefined, this);
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
// ../../src/components/ui/popover.tsx
|
|
1303
|
+
import { Popover as PopoverPrimitive } from "@base-ui/react/popover";
|
|
1304
|
+
import { jsxDEV as jsxDEV10 } from "react/jsx-dev-runtime";
|
|
1305
|
+
function Popover({ ...props }) {
|
|
1306
|
+
return /* @__PURE__ */ jsxDEV10(PopoverPrimitive.Root, {
|
|
1307
|
+
"data-slot": "popover",
|
|
1308
|
+
...props
|
|
1309
|
+
}, undefined, false, undefined, this);
|
|
1310
|
+
}
|
|
1311
|
+
function PopoverTrigger({ ...props }) {
|
|
1312
|
+
return /* @__PURE__ */ jsxDEV10(PopoverPrimitive.Trigger, {
|
|
1313
|
+
"data-slot": "popover-trigger",
|
|
1314
|
+
...props
|
|
1315
|
+
}, undefined, false, undefined, this);
|
|
1316
|
+
}
|
|
1317
|
+
function PopoverContent({
|
|
1318
|
+
className,
|
|
1319
|
+
align = "center",
|
|
1320
|
+
alignOffset = 0,
|
|
1321
|
+
side = "bottom",
|
|
1322
|
+
sideOffset = 4,
|
|
1323
|
+
...props
|
|
1324
|
+
}) {
|
|
1325
|
+
return /* @__PURE__ */ jsxDEV10(PopoverPrimitive.Portal, {
|
|
1326
|
+
children: /* @__PURE__ */ jsxDEV10(PopoverPrimitive.Positioner, {
|
|
1327
|
+
align,
|
|
1328
|
+
alignOffset,
|
|
1329
|
+
side,
|
|
1330
|
+
sideOffset,
|
|
1331
|
+
className: "isolate z-50",
|
|
1332
|
+
children: /* @__PURE__ */ jsxDEV10(PopoverPrimitive.Popup, {
|
|
1333
|
+
"data-slot": "popover-content",
|
|
1334
|
+
className: cn("z-50 flex w-72 origin-(--transform-origin) flex-col gap-4 rounded-md bg-popover p-4 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-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-out-95", className),
|
|
1335
|
+
...props
|
|
1336
|
+
}, undefined, false, undefined, this)
|
|
1337
|
+
}, undefined, false, undefined, this)
|
|
1338
|
+
}, undefined, false, undefined, this);
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
// ../../src/components/ui/scroll-area.tsx
|
|
1342
|
+
import { ScrollArea as ScrollAreaPrimitive } from "@base-ui/react/scroll-area";
|
|
1343
|
+
import { jsxDEV as jsxDEV11 } from "react/jsx-dev-runtime";
|
|
1344
|
+
function ScrollArea({
|
|
1345
|
+
className,
|
|
1346
|
+
children,
|
|
1347
|
+
...props
|
|
1348
|
+
}) {
|
|
1349
|
+
return /* @__PURE__ */ jsxDEV11(ScrollAreaPrimitive.Root, {
|
|
1350
|
+
"data-slot": "scroll-area",
|
|
1351
|
+
className: cn("relative", className),
|
|
1352
|
+
...props,
|
|
1353
|
+
children: [
|
|
1354
|
+
/* @__PURE__ */ jsxDEV11(ScrollAreaPrimitive.Viewport, {
|
|
1355
|
+
"data-slot": "scroll-area-viewport",
|
|
1356
|
+
className: "focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",
|
|
1357
|
+
children
|
|
1358
|
+
}, undefined, false, undefined, this),
|
|
1359
|
+
/* @__PURE__ */ jsxDEV11(ScrollBar, {}, undefined, false, undefined, this),
|
|
1360
|
+
/* @__PURE__ */ jsxDEV11(ScrollAreaPrimitive.Corner, {}, undefined, false, undefined, this)
|
|
1361
|
+
]
|
|
1362
|
+
}, undefined, true, undefined, this);
|
|
1363
|
+
}
|
|
1364
|
+
function ScrollBar({
|
|
1365
|
+
className,
|
|
1366
|
+
orientation = "vertical",
|
|
1367
|
+
...props
|
|
1368
|
+
}) {
|
|
1369
|
+
return /* @__PURE__ */ jsxDEV11(ScrollAreaPrimitive.Scrollbar, {
|
|
1370
|
+
"data-slot": "scroll-area-scrollbar",
|
|
1371
|
+
"data-orientation": orientation,
|
|
1372
|
+
orientation,
|
|
1373
|
+
className: cn("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent", className),
|
|
1374
|
+
...props,
|
|
1375
|
+
children: /* @__PURE__ */ jsxDEV11(ScrollAreaPrimitive.Thumb, {
|
|
1376
|
+
"data-slot": "scroll-area-thumb",
|
|
1377
|
+
className: "bg-border relative flex-1 rounded-full"
|
|
1378
|
+
}, undefined, false, undefined, this)
|
|
1379
|
+
}, undefined, false, undefined, this);
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
// ../../src/components/ui/table.tsx
|
|
1383
|
+
import { jsxDEV as jsxDEV12 } from "react/jsx-dev-runtime";
|
|
1384
|
+
function Table({ className, ...props }) {
|
|
1385
|
+
return /* @__PURE__ */ jsxDEV12("div", {
|
|
1386
|
+
"data-slot": "table-container",
|
|
1387
|
+
className: "relative w-full overflow-x-auto",
|
|
1388
|
+
children: /* @__PURE__ */ jsxDEV12("table", {
|
|
1389
|
+
"data-slot": "table",
|
|
1390
|
+
className: cn("w-full caption-bottom text-sm", className),
|
|
1391
|
+
...props
|
|
1392
|
+
}, undefined, false, undefined, this)
|
|
1393
|
+
}, undefined, false, undefined, this);
|
|
1394
|
+
}
|
|
1395
|
+
function TableHeader({ className, ...props }) {
|
|
1396
|
+
return /* @__PURE__ */ jsxDEV12("thead", {
|
|
1397
|
+
"data-slot": "table-header",
|
|
1398
|
+
className: cn("[&_tr]:border-b", className),
|
|
1399
|
+
...props
|
|
1400
|
+
}, undefined, false, undefined, this);
|
|
1401
|
+
}
|
|
1402
|
+
function TableBody({ className, ...props }) {
|
|
1403
|
+
return /* @__PURE__ */ jsxDEV12("tbody", {
|
|
1404
|
+
"data-slot": "table-body",
|
|
1405
|
+
className: cn("[&_tr:last-child]:border-0", className),
|
|
1406
|
+
...props
|
|
1407
|
+
}, undefined, false, undefined, this);
|
|
1408
|
+
}
|
|
1409
|
+
function TableRow({ className, ...props }) {
|
|
1410
|
+
return /* @__PURE__ */ jsxDEV12("tr", {
|
|
1411
|
+
"data-slot": "table-row",
|
|
1412
|
+
className: cn("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted", className),
|
|
1413
|
+
...props
|
|
1414
|
+
}, undefined, false, undefined, this);
|
|
1415
|
+
}
|
|
1416
|
+
function TableHead({ className, ...props }) {
|
|
1417
|
+
return /* @__PURE__ */ jsxDEV12("th", {
|
|
1418
|
+
"data-slot": "table-head",
|
|
1419
|
+
className: cn("h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0", className),
|
|
1420
|
+
...props
|
|
1421
|
+
}, undefined, false, undefined, this);
|
|
1422
|
+
}
|
|
1423
|
+
function TableCell({ className, ...props }) {
|
|
1424
|
+
return /* @__PURE__ */ jsxDEV12("td", {
|
|
1425
|
+
"data-slot": "table-cell",
|
|
1426
|
+
className: cn("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0", className),
|
|
1427
|
+
...props
|
|
1428
|
+
}, undefined, false, undefined, this);
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
// ../../src/components/ui/tooltip.tsx
|
|
1432
|
+
import { Tooltip as TooltipPrimitive } from "@base-ui/react/tooltip";
|
|
1433
|
+
import { jsxDEV as jsxDEV13 } from "react/jsx-dev-runtime";
|
|
1434
|
+
"use client";
|
|
1435
|
+
function TooltipProvider({
|
|
1436
|
+
delay = 0,
|
|
1437
|
+
...props
|
|
1438
|
+
}) {
|
|
1439
|
+
return /* @__PURE__ */ jsxDEV13(TooltipPrimitive.Provider, {
|
|
1440
|
+
"data-slot": "tooltip-provider",
|
|
1441
|
+
delay,
|
|
1442
|
+
...props
|
|
1443
|
+
}, undefined, false, undefined, this);
|
|
1444
|
+
}
|
|
1445
|
+
function Tooltip({ ...props }) {
|
|
1446
|
+
return /* @__PURE__ */ jsxDEV13(TooltipPrimitive.Root, {
|
|
1447
|
+
"data-slot": "tooltip",
|
|
1448
|
+
...props
|
|
1449
|
+
}, undefined, false, undefined, this);
|
|
1450
|
+
}
|
|
1451
|
+
function TooltipTrigger({ ...props }) {
|
|
1452
|
+
return /* @__PURE__ */ jsxDEV13(TooltipPrimitive.Trigger, {
|
|
1453
|
+
"data-slot": "tooltip-trigger",
|
|
1454
|
+
...props
|
|
1455
|
+
}, undefined, false, undefined, this);
|
|
1456
|
+
}
|
|
1457
|
+
function TooltipContent({
|
|
1458
|
+
className,
|
|
1459
|
+
side = "top",
|
|
1460
|
+
sideOffset = 4,
|
|
1461
|
+
align = "center",
|
|
1462
|
+
alignOffset = 0,
|
|
1463
|
+
children,
|
|
1464
|
+
...props
|
|
1465
|
+
}) {
|
|
1466
|
+
return /* @__PURE__ */ jsxDEV13(TooltipPrimitive.Portal, {
|
|
1467
|
+
children: /* @__PURE__ */ jsxDEV13(TooltipPrimitive.Positioner, {
|
|
1468
|
+
align,
|
|
1469
|
+
alignOffset,
|
|
1470
|
+
side,
|
|
1471
|
+
sideOffset,
|
|
1472
|
+
className: "isolate z-50",
|
|
1473
|
+
children: /* @__PURE__ */ jsxDEV13(TooltipPrimitive.Popup, {
|
|
1474
|
+
"data-slot": "tooltip-content",
|
|
1475
|
+
className: cn("z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className),
|
|
1476
|
+
...props,
|
|
1477
|
+
children: [
|
|
1478
|
+
children,
|
|
1479
|
+
/* @__PURE__ */ jsxDEV13(TooltipPrimitive.Arrow, {
|
|
1480
|
+
className: "bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5"
|
|
1481
|
+
}, undefined, false, undefined, this)
|
|
1482
|
+
]
|
|
1483
|
+
}, undefined, true, undefined, this)
|
|
1484
|
+
}, undefined, false, undefined, this)
|
|
1485
|
+
}, undefined, false, undefined, this);
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
// ../../src/lib/query.ts
|
|
1489
|
+
import {
|
|
1490
|
+
Effect,
|
|
1491
|
+
Option,
|
|
1492
|
+
Schema,
|
|
1493
|
+
SchemaIssue,
|
|
1494
|
+
SchemaTransformation
|
|
1495
|
+
} from "effect";
|
|
1496
|
+
var parseSortParam = (sort) => {
|
|
1497
|
+
const id = sort.startsWith("-") ? sort.slice(1) : sort;
|
|
1498
|
+
if (!id || id.includes(",") || id.includes(":")) {
|
|
1499
|
+
return null;
|
|
1500
|
+
}
|
|
1501
|
+
return { id, direction: sort.startsWith("-") ? "desc" : "asc" };
|
|
1502
|
+
};
|
|
1503
|
+
var SortDirection = Schema.Union([
|
|
1504
|
+
Schema.Literal("asc"),
|
|
1505
|
+
Schema.Literal("desc")
|
|
1506
|
+
]).pipe(Schema.annotate({
|
|
1507
|
+
identifier: "SortDirection",
|
|
1508
|
+
title: "Sort Direction",
|
|
1509
|
+
description: "Sort direction for list query results.",
|
|
1510
|
+
examples: ["asc", "desc"]
|
|
1511
|
+
}));
|
|
1512
|
+
var SortParam = Schema.Struct({
|
|
1513
|
+
id: Schema.NonEmptyString,
|
|
1514
|
+
direction: SortDirection
|
|
1515
|
+
}).pipe(Schema.annotate({
|
|
1516
|
+
identifier: "SortParam",
|
|
1517
|
+
title: "Sort Parameter",
|
|
1518
|
+
description: "Decoded sort parameter with a field id and direction.",
|
|
1519
|
+
examples: [{ id: "publicName", direction: "asc" }]
|
|
1520
|
+
}));
|
|
1521
|
+
var SortParamFromString = Schema.String.pipe(Schema.decodeTo(SortParam, SchemaTransformation.transformOrFail({
|
|
1522
|
+
decode: (sort) => {
|
|
1523
|
+
const sortParam = parseSortParam(sort);
|
|
1524
|
+
if (!sortParam) {
|
|
1525
|
+
return Effect.fail(new SchemaIssue.InvalidValue(Option.some(sort), {
|
|
1526
|
+
message: 'Expected sort in the format "field" or "-field"'
|
|
1527
|
+
}));
|
|
1528
|
+
}
|
|
1529
|
+
return Effect.succeed(sortParam);
|
|
1530
|
+
},
|
|
1531
|
+
encode: (sort) => Effect.succeed(sort.direction === "desc" ? `-${sort.id}` : sort.id)
|
|
1532
|
+
})), Schema.annotate({
|
|
1533
|
+
identifier: "SortParamFromString",
|
|
1534
|
+
title: "Sort Parameter From String",
|
|
1535
|
+
description: 'URL encoded single sort parameter where descending fields are prefixed with "-".',
|
|
1536
|
+
examples: [{ id: "publicName", direction: "asc" }]
|
|
1537
|
+
}));
|
|
1538
|
+
var SortParamsFromString = Schema.String.pipe(Schema.decodeTo(Schema.Array(SortParam), SchemaTransformation.transformOrFail({
|
|
1539
|
+
decode: (sort) => {
|
|
1540
|
+
const parts = sort.split(",");
|
|
1541
|
+
const sortParams = [];
|
|
1542
|
+
for (const part of parts) {
|
|
1543
|
+
const sortParam = parseSortParam(part);
|
|
1544
|
+
if (!sortParam) {
|
|
1545
|
+
return Effect.fail(new SchemaIssue.InvalidValue(Option.some(sort), {
|
|
1546
|
+
message: 'Expected sort in the format "field,-otherField"'
|
|
1547
|
+
}));
|
|
1548
|
+
}
|
|
1549
|
+
sortParams.push(sortParam);
|
|
1550
|
+
}
|
|
1551
|
+
return Effect.succeed(sortParams);
|
|
1552
|
+
},
|
|
1553
|
+
encode: (sort) => Effect.succeed(sort.map((part) => Schema.encodeSync(SortParamFromString)(part)).join(","))
|
|
1554
|
+
})), Schema.annotate({
|
|
1555
|
+
identifier: "SortParamsFromString",
|
|
1556
|
+
title: "Sort Parameters From String",
|
|
1557
|
+
description: 'URL encoded sort parameters where descending fields are prefixed with "-" and multiple fields are comma-separated.',
|
|
1558
|
+
examples: [
|
|
1559
|
+
[
|
|
1560
|
+
{ id: "name", direction: "desc" },
|
|
1561
|
+
{ id: "age", direction: "asc" }
|
|
1562
|
+
]
|
|
1563
|
+
]
|
|
1564
|
+
}));
|
|
1565
|
+
var SortParamSearch = SortParamsFromString.pipe(Schema.decodeTo(Schema.String, SchemaTransformation.transform({
|
|
1566
|
+
decode: (sort) => Schema.encodeSync(SortParamsFromString)(sort),
|
|
1567
|
+
encode: (sort) => Schema.decodeUnknownSync(SortParamsFromString)(sort)
|
|
1568
|
+
})), Schema.annotate({
|
|
1569
|
+
identifier: "SortParamSearch",
|
|
1570
|
+
title: "Sort Search Parameter",
|
|
1571
|
+
description: 'Search parameter sort value normalized to the compact "-field,otherField" URL format.',
|
|
1572
|
+
examples: ["-name,age"]
|
|
1573
|
+
}));
|
|
1574
|
+
var Query = Schema.Struct({
|
|
1575
|
+
page: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
|
|
1576
|
+
pageSize: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 100 })),
|
|
1577
|
+
globalFilter: Schema.optional(Schema.String),
|
|
1578
|
+
sort: Schema.optional(SortParamSearch)
|
|
1579
|
+
}).annotate({
|
|
1580
|
+
identifier: "Query",
|
|
1581
|
+
title: "Query",
|
|
1582
|
+
description: "Zero-based page request parameters with optional filtering and sorting for list endpoints.",
|
|
1583
|
+
examples: [
|
|
1584
|
+
{
|
|
1585
|
+
page: 0,
|
|
1586
|
+
pageSize: 10,
|
|
1587
|
+
globalFilter: "housing",
|
|
1588
|
+
sort: "-publicName,createdAt"
|
|
1589
|
+
}
|
|
1590
|
+
]
|
|
1591
|
+
});
|
|
1592
|
+
var PaginationMeta = Schema.Struct({
|
|
1593
|
+
page: Schema.Int,
|
|
1594
|
+
pageSize: Schema.Int,
|
|
1595
|
+
total: Schema.Int,
|
|
1596
|
+
pageCount: Schema.Int
|
|
1597
|
+
}).pipe(Schema.annotate({
|
|
1598
|
+
identifier: "PaginationMeta",
|
|
1599
|
+
title: "Pagination Metadata",
|
|
1600
|
+
description: "Pagination metadata returned with a paginated list response.",
|
|
1601
|
+
examples: [{ page: 0, pageSize: 10, total: 125, pageCount: 13 }]
|
|
1602
|
+
}));
|
|
1603
|
+
|
|
1604
|
+
// ../../src/components/ui/data-table.tsx
|
|
1605
|
+
import {
|
|
1606
|
+
DndContext,
|
|
1607
|
+
DragOverlay,
|
|
1608
|
+
PointerSensor,
|
|
1609
|
+
useDraggable,
|
|
1610
|
+
useDroppable,
|
|
1611
|
+
useSensor,
|
|
1612
|
+
useSensors
|
|
1613
|
+
} from "@dnd-kit/core";
|
|
1614
|
+
import {
|
|
1615
|
+
SortableContext,
|
|
1616
|
+
useSortable,
|
|
1617
|
+
verticalListSortingStrategy
|
|
1618
|
+
} from "@dnd-kit/sortable";
|
|
1619
|
+
import { CSS } from "@dnd-kit/utilities";
|
|
1620
|
+
import {
|
|
1621
|
+
useNavigate,
|
|
1622
|
+
useRouterState
|
|
1623
|
+
} from "@tanstack/react-router";
|
|
1624
|
+
import { useAtom } from "@effect/atom-react";
|
|
1625
|
+
import { BrowserKeyValueStore } from "@effect/platform-browser";
|
|
1626
|
+
import {
|
|
1627
|
+
flexRender,
|
|
1628
|
+
getCoreRowModel,
|
|
1629
|
+
getFilteredRowModel,
|
|
1630
|
+
getPaginationRowModel,
|
|
1631
|
+
getSortedRowModel,
|
|
1632
|
+
useReactTable
|
|
1633
|
+
} from "@tanstack/react-table";
|
|
1634
|
+
import {
|
|
1635
|
+
ArrowDown,
|
|
1636
|
+
ArrowUp,
|
|
1637
|
+
ChevronDown,
|
|
1638
|
+
ChevronRight as ChevronRight2,
|
|
1639
|
+
ChevronsUpDown as ChevronsUpDown2,
|
|
1640
|
+
Download,
|
|
1641
|
+
EyeOff,
|
|
1642
|
+
FileJson,
|
|
1643
|
+
FileText,
|
|
1644
|
+
GripVertical,
|
|
1645
|
+
LayoutGrid,
|
|
1646
|
+
MoreHorizontal,
|
|
1647
|
+
RefreshCw,
|
|
1648
|
+
Rows3,
|
|
1649
|
+
Search,
|
|
1650
|
+
Settings2,
|
|
1651
|
+
X
|
|
1652
|
+
} from "lucide-react";
|
|
1653
|
+
import {
|
|
1654
|
+
useEffect,
|
|
1655
|
+
useMemo,
|
|
1656
|
+
useState,
|
|
1657
|
+
createContext
|
|
1658
|
+
} from "react";
|
|
1659
|
+
import { Effect as Effect2, Layer, Schema as Schema2 } from "effect";
|
|
1660
|
+
import { KeyValueStore } from "effect/unstable/persistence";
|
|
1661
|
+
import { Atom } from "effect/unstable/reactivity";
|
|
1662
|
+
|
|
1663
|
+
// ../../src/components/ui/badge.tsx
|
|
1664
|
+
import { mergeProps } from "@base-ui/react/merge-props";
|
|
1665
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
1666
|
+
import { cva as cva3 } from "class-variance-authority";
|
|
1667
|
+
var badgeVariants = cva3("group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!", {
|
|
1668
|
+
variants: {
|
|
1669
|
+
variant: {
|
|
1670
|
+
default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
|
|
1671
|
+
secondary: "bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",
|
|
1672
|
+
destructive: "bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",
|
|
1673
|
+
outline: "border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",
|
|
1674
|
+
ghost: "hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",
|
|
1675
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
1676
|
+
}
|
|
1677
|
+
},
|
|
1678
|
+
defaultVariants: {
|
|
1679
|
+
variant: "default"
|
|
1680
|
+
}
|
|
1681
|
+
});
|
|
1682
|
+
function Badge({
|
|
1683
|
+
className,
|
|
1684
|
+
variant = "default",
|
|
1685
|
+
render,
|
|
1686
|
+
...props
|
|
1687
|
+
}) {
|
|
1688
|
+
return useRender({
|
|
1689
|
+
defaultTagName: "span",
|
|
1690
|
+
props: mergeProps({
|
|
1691
|
+
className: cn(badgeVariants({ variant }), className)
|
|
1692
|
+
}, props),
|
|
1693
|
+
render,
|
|
1694
|
+
state: {
|
|
1695
|
+
slot: "badge",
|
|
1696
|
+
variant
|
|
1697
|
+
}
|
|
1698
|
+
});
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
// ../../src/components/ui/card.tsx
|
|
1702
|
+
import { jsxDEV as jsxDEV14 } from "react/jsx-dev-runtime";
|
|
1703
|
+
function Card({
|
|
1704
|
+
className,
|
|
1705
|
+
size = "default",
|
|
1706
|
+
...props
|
|
1707
|
+
}) {
|
|
1708
|
+
return /* @__PURE__ */ jsxDEV14("div", {
|
|
1709
|
+
"data-slot": "card",
|
|
1710
|
+
"data-size": size,
|
|
1711
|
+
className: cn("group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground shadow-xs ring-1 ring-foreground/10 [--card-spacing:--spacing(6)] has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(4)] *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl", className),
|
|
1712
|
+
...props
|
|
1713
|
+
}, undefined, false, undefined, this);
|
|
1714
|
+
}
|
|
1715
|
+
function CardHeader({ className, ...props }) {
|
|
1716
|
+
return /* @__PURE__ */ jsxDEV14("div", {
|
|
1717
|
+
"data-slot": "card-header",
|
|
1718
|
+
className: cn("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)", className),
|
|
1719
|
+
...props
|
|
1720
|
+
}, undefined, false, undefined, this);
|
|
1721
|
+
}
|
|
1722
|
+
function CardTitle({ className, ...props }) {
|
|
1723
|
+
return /* @__PURE__ */ jsxDEV14("div", {
|
|
1724
|
+
"data-slot": "card-title",
|
|
1725
|
+
className: cn("text-base leading-normal font-medium group-data-[size=sm]/card:text-sm", className),
|
|
1726
|
+
...props
|
|
1727
|
+
}, undefined, false, undefined, this);
|
|
1728
|
+
}
|
|
1729
|
+
function CardDescription({ className, ...props }) {
|
|
1730
|
+
return /* @__PURE__ */ jsxDEV14("div", {
|
|
1731
|
+
"data-slot": "card-description",
|
|
1732
|
+
className: cn("text-sm text-muted-foreground", className),
|
|
1733
|
+
...props
|
|
1734
|
+
}, undefined, false, undefined, this);
|
|
1735
|
+
}
|
|
1736
|
+
function CardAction({ className, ...props }) {
|
|
1737
|
+
return /* @__PURE__ */ jsxDEV14("div", {
|
|
1738
|
+
"data-slot": "card-action",
|
|
1739
|
+
className: cn("col-start-2 row-span-2 row-start-1 self-start justify-self-end", className),
|
|
1740
|
+
...props
|
|
1741
|
+
}, undefined, false, undefined, this);
|
|
1742
|
+
}
|
|
1743
|
+
function CardContent({ className, ...props }) {
|
|
1744
|
+
return /* @__PURE__ */ jsxDEV14("div", {
|
|
1745
|
+
"data-slot": "card-content",
|
|
1746
|
+
className: cn("px-(--card-spacing)", className),
|
|
1747
|
+
...props
|
|
1748
|
+
}, undefined, false, undefined, this);
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
// ../../src/components/ui/loading.tsx
|
|
1752
|
+
import { Loader2 } from "lucide-react";
|
|
1753
|
+
import { jsxDEV as jsxDEV15 } from "react/jsx-dev-runtime";
|
|
1754
|
+
var labels = {
|
|
1755
|
+
en: {
|
|
1756
|
+
loading: "Loading..."
|
|
1757
|
+
},
|
|
1758
|
+
fr: {
|
|
1759
|
+
loading: "Chargement..."
|
|
1760
|
+
}
|
|
1761
|
+
};
|
|
1762
|
+
var loadingLabel = () => getLocale().startsWith("fr") ? labels.fr.loading : labels.en.loading;
|
|
1763
|
+
function Loading({
|
|
1764
|
+
className,
|
|
1765
|
+
label,
|
|
1766
|
+
variant = "inline"
|
|
1767
|
+
}) {
|
|
1768
|
+
return /* @__PURE__ */ jsxDEV15("div", {
|
|
1769
|
+
className: cn("text-muted-foreground flex items-center justify-center gap-2 text-sm", variant === "centered" && "min-h-[50svh] w-full", className),
|
|
1770
|
+
children: [
|
|
1771
|
+
/* @__PURE__ */ jsxDEV15(Loader2, {
|
|
1772
|
+
className: "size-4 animate-spin"
|
|
1773
|
+
}, undefined, false, undefined, this),
|
|
1774
|
+
label ?? loadingLabel()
|
|
1775
|
+
]
|
|
1776
|
+
}, undefined, true, undefined, this);
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
// ../../src/components/ui/data-table.tsx
|
|
1780
|
+
import { jsxDEV as jsxDEV16, Fragment } from "react/jsx-dev-runtime";
|
|
1781
|
+
var DataTableViewContext = createContext("table");
|
|
1782
|
+
var TableSearchSchema = Schema2.Struct({
|
|
1783
|
+
page: Schema2.optional(Query.fields.page),
|
|
1784
|
+
pageSize: Schema2.optional(Query.fields.pageSize),
|
|
1785
|
+
globalFilter: Query.fields.globalFilter,
|
|
1786
|
+
sort: Query.fields.sort,
|
|
1787
|
+
grouping: Schema2.optional(Schema2.Array(Schema2.String))
|
|
1788
|
+
});
|
|
1789
|
+
var TableSearchSchemaStandard = Schema2.toStandardSchemaV1(TableSearchSchema);
|
|
1790
|
+
var compactDataTableStorage = Layer.effect(KeyValueStore.KeyValueStore, Effect2.map(KeyValueStore.KeyValueStore, (store) => KeyValueStore.make({
|
|
1791
|
+
clear: store.clear,
|
|
1792
|
+
get: (key) => Effect2.flatMap(store.get(key), (value) => value === "{}" ? Effect2.as(store.remove(key), undefined) : Effect2.succeed(value)),
|
|
1793
|
+
getUint8Array: store.getUint8Array,
|
|
1794
|
+
remove: store.remove,
|
|
1795
|
+
set: (key, value) => value === "{}" ? store.remove(key) : store.set(key, value),
|
|
1796
|
+
size: store.size
|
|
1797
|
+
}))).pipe(Layer.provide(BrowserKeyValueStore.layerLocalStorage));
|
|
1798
|
+
var dataTableStorageRuntime = Atom.runtime(compactDataTableStorage);
|
|
1799
|
+
var DataTableViewSchema = Schema2.Union([
|
|
1800
|
+
Schema2.Literal("table"),
|
|
1801
|
+
Schema2.Literal("gallery")
|
|
1802
|
+
]);
|
|
1803
|
+
var ColumnVisibilitySchema = Schema2.Record(Schema2.String, Schema2.Boolean);
|
|
1804
|
+
var ColumnSizingSchema = Schema2.Record(Schema2.String, Schema2.Number);
|
|
1805
|
+
var messages3 = {
|
|
1806
|
+
en: {
|
|
1807
|
+
...paginationMessages("en"),
|
|
1808
|
+
actions: "Actions",
|
|
1809
|
+
empty: "No results.",
|
|
1810
|
+
loading: "Loading...",
|
|
1811
|
+
filter: "Filter results...",
|
|
1812
|
+
export: "Export",
|
|
1813
|
+
exportCsv: "CSV",
|
|
1814
|
+
exportJson: "JSON",
|
|
1815
|
+
refresh: "Refresh",
|
|
1816
|
+
view: "View",
|
|
1817
|
+
tableView: "Table",
|
|
1818
|
+
galleryView: "Gallery",
|
|
1819
|
+
columns: "Columns",
|
|
1820
|
+
groupBy: "Group by",
|
|
1821
|
+
sortAsc: "Asc",
|
|
1822
|
+
sortDesc: "Desc",
|
|
1823
|
+
sortHide: "Hide",
|
|
1824
|
+
sortClear: "Clear",
|
|
1825
|
+
sortBy: "Sort by",
|
|
1826
|
+
reorder: "Drag to reorder",
|
|
1827
|
+
resizeColumn: (column) => `Resize ${column} column`,
|
|
1828
|
+
listOthers: (count) => count === 1 ? "and 1 other" : `and ${count} others`
|
|
1829
|
+
},
|
|
1830
|
+
fr: {
|
|
1831
|
+
...paginationMessages("fr"),
|
|
1832
|
+
actions: "Actions",
|
|
1833
|
+
empty: "Aucun résultat.",
|
|
1834
|
+
loading: "Chargement...",
|
|
1835
|
+
filter: "Filtrer les résultats...",
|
|
1836
|
+
export: "Exporter",
|
|
1837
|
+
exportCsv: "CSV",
|
|
1838
|
+
exportJson: "JSON",
|
|
1839
|
+
refresh: "Rafraîchir",
|
|
1840
|
+
view: "Affichage",
|
|
1841
|
+
tableView: "Tableau",
|
|
1842
|
+
galleryView: "Galerie",
|
|
1843
|
+
columns: "Colonnes",
|
|
1844
|
+
groupBy: "Grouper par",
|
|
1845
|
+
sortAsc: "Croissant",
|
|
1846
|
+
sortDesc: "Décroissant",
|
|
1847
|
+
sortHide: "Cacher",
|
|
1848
|
+
sortClear: "Effacer",
|
|
1849
|
+
sortBy: "Trier par",
|
|
1850
|
+
reorder: "Glisser pour réordonner",
|
|
1851
|
+
resizeColumn: (column) => `Redimensionner la colonne ${column}`,
|
|
1852
|
+
listOthers: (count) => count === 1 ? "et 1 autre" : `et ${count} autres`
|
|
1853
|
+
}
|
|
1854
|
+
};
|
|
1855
|
+
var dataTableMessages = (overrides) => ({
|
|
1856
|
+
...getLocale().startsWith("fr") ? messages3.fr : messages3.en,
|
|
1857
|
+
...overrides
|
|
1858
|
+
});
|
|
1859
|
+
var GROUP_INDENT_PX = 20;
|
|
1860
|
+
var GROUP_ROW_INDENT_OFFSET_PX = 44;
|
|
1861
|
+
var snapDragOverlayVerticalCenterToCursor = ({
|
|
1862
|
+
activatorEvent,
|
|
1863
|
+
activeNodeRect,
|
|
1864
|
+
overlayNodeRect,
|
|
1865
|
+
transform
|
|
1866
|
+
}) => {
|
|
1867
|
+
if (!(activatorEvent instanceof MouseEvent) || !activeNodeRect || !overlayNodeRect) {
|
|
1868
|
+
return transform;
|
|
1869
|
+
}
|
|
1870
|
+
return {
|
|
1871
|
+
...transform,
|
|
1872
|
+
y: transform.y + activatorEvent.clientY - activeNodeRect.top - overlayNodeRect.height / 2
|
|
1873
|
+
};
|
|
1874
|
+
};
|
|
1875
|
+
var getDefaultGrouping = (grouping) => {
|
|
1876
|
+
if (!grouping) {
|
|
1877
|
+
return [];
|
|
1878
|
+
}
|
|
1879
|
+
const validInitial = grouping.initial?.filter((id) => grouping.fields.some((field) => field.id === id));
|
|
1880
|
+
if (validInitial?.length) {
|
|
1881
|
+
return validInitial;
|
|
1882
|
+
}
|
|
1883
|
+
return grouping.fields[0] ? [grouping.fields[0].id] : [];
|
|
1884
|
+
};
|
|
1885
|
+
var getGroupTargetDropId = (key) => `group-target:${key}`;
|
|
1886
|
+
var getRowDragId = (rowId) => `row:${rowId}`;
|
|
1887
|
+
var getSortableRowId = (rowId) => `sortable-row:${rowId}`;
|
|
1888
|
+
var DataTableRowActions = ({
|
|
1889
|
+
actions,
|
|
1890
|
+
contentClassName,
|
|
1891
|
+
row,
|
|
1892
|
+
title
|
|
1893
|
+
}) => {
|
|
1894
|
+
const resolvedTitle = title ?? dataTableMessages().actions;
|
|
1895
|
+
const visibleActions = actions.filter((action) => !action.visible || action.visible(row));
|
|
1896
|
+
if (visibleActions.length === 0) {
|
|
1897
|
+
return null;
|
|
1898
|
+
}
|
|
1899
|
+
return /* @__PURE__ */ jsxDEV16(DropdownMenu, {
|
|
1900
|
+
children: [
|
|
1901
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuTrigger, {
|
|
1902
|
+
onClick: (event) => event.stopPropagation(),
|
|
1903
|
+
render: /* @__PURE__ */ jsxDEV16(Button, {
|
|
1904
|
+
className: "size-7 shadow-md [&_svg:not([class*='size-'])]:size-3.5",
|
|
1905
|
+
variant: "ghost",
|
|
1906
|
+
size: "icon",
|
|
1907
|
+
children: [
|
|
1908
|
+
/* @__PURE__ */ jsxDEV16("span", {
|
|
1909
|
+
className: "sr-only",
|
|
1910
|
+
children: resolvedTitle
|
|
1911
|
+
}, undefined, false, undefined, this),
|
|
1912
|
+
/* @__PURE__ */ jsxDEV16(MoreHorizontal, {}, undefined, false, undefined, this)
|
|
1913
|
+
]
|
|
1914
|
+
}, undefined, true, undefined, this)
|
|
1915
|
+
}, undefined, false, undefined, this),
|
|
1916
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuContent, {
|
|
1917
|
+
align: "end",
|
|
1918
|
+
className: cn("w-max", contentClassName),
|
|
1919
|
+
children: /* @__PURE__ */ jsxDEV16(DropdownMenuGroup, {
|
|
1920
|
+
children: [
|
|
1921
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuLabel, {
|
|
1922
|
+
children: resolvedTitle
|
|
1923
|
+
}, undefined, false, undefined, this),
|
|
1924
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuSeparator, {}, undefined, false, undefined, this),
|
|
1925
|
+
visibleActions.map((action) => /* @__PURE__ */ jsxDEV16(DropdownMenuItem, {
|
|
1926
|
+
className: "whitespace-nowrap",
|
|
1927
|
+
onClick: (event) => {
|
|
1928
|
+
event.stopPropagation();
|
|
1929
|
+
action.onClick(row);
|
|
1930
|
+
},
|
|
1931
|
+
...action.variant ? { variant: action.variant } : {},
|
|
1932
|
+
children: [
|
|
1933
|
+
action.icon,
|
|
1934
|
+
action.name
|
|
1935
|
+
]
|
|
1936
|
+
}, action.id ?? action.name, true, undefined, this))
|
|
1937
|
+
]
|
|
1938
|
+
}, undefined, true, undefined, this)
|
|
1939
|
+
}, undefined, false, undefined, this)
|
|
1940
|
+
]
|
|
1941
|
+
}, undefined, true, undefined, this);
|
|
1942
|
+
};
|
|
1943
|
+
var buildGroupedSections = (rows, fields, depth = 0, parentKey = "") => {
|
|
1944
|
+
if (fields.length === 0) {
|
|
1945
|
+
return [];
|
|
1946
|
+
}
|
|
1947
|
+
const [field, ...remainingFields] = fields;
|
|
1948
|
+
const groups = new Map;
|
|
1949
|
+
field.getGroupIds?.().forEach((groupId) => {
|
|
1950
|
+
groups.set(groupId, []);
|
|
1951
|
+
});
|
|
1952
|
+
rows.forEach((row) => {
|
|
1953
|
+
const groupIds = field.getRowGroupIds?.(row.original) ?? [
|
|
1954
|
+
field.getGroupId(row.original)
|
|
1955
|
+
];
|
|
1956
|
+
for (const groupId of groupIds) {
|
|
1957
|
+
const currentRows = groups.get(groupId) ?? [];
|
|
1958
|
+
currentRows.push(row);
|
|
1959
|
+
groups.set(groupId, currentRows);
|
|
1960
|
+
}
|
|
1961
|
+
});
|
|
1962
|
+
return Array.from(groups.entries()).map(([groupId, groupRows]) => {
|
|
1963
|
+
const key = parentKey ? `${parentKey}::${field.id}:${groupId}` : `${field.id}:${groupId}`;
|
|
1964
|
+
return {
|
|
1965
|
+
key,
|
|
1966
|
+
groupId,
|
|
1967
|
+
depth,
|
|
1968
|
+
field,
|
|
1969
|
+
rows: groupRows,
|
|
1970
|
+
children: groupRows.length > 0 ? buildGroupedSections(groupRows, remainingFields, depth + 1, key) : []
|
|
1971
|
+
};
|
|
1972
|
+
});
|
|
1973
|
+
};
|
|
1974
|
+
var GroupHeaderRow = ({
|
|
1975
|
+
collapsed,
|
|
1976
|
+
colSpan,
|
|
1977
|
+
onToggle,
|
|
1978
|
+
section
|
|
1979
|
+
}) => {
|
|
1980
|
+
const label = section.field.getGroupLabel?.(section.groupId, section.rows.map((row) => row.original)) ?? section.groupId;
|
|
1981
|
+
const renderedLabel = section.field.renderGroupLabel?.(section.groupId, section.rows.map((row) => row.original)) ?? label;
|
|
1982
|
+
return /* @__PURE__ */ jsxDEV16(TableRow, {
|
|
1983
|
+
children: /* @__PURE__ */ jsxDEV16(TableCell, {
|
|
1984
|
+
className: "relative p-0",
|
|
1985
|
+
colSpan,
|
|
1986
|
+
onClick: onToggle,
|
|
1987
|
+
children: /* @__PURE__ */ jsxDEV16("div", {
|
|
1988
|
+
className: "flex cursor-pointer items-center gap-3 px-2 py-2 font-medium transition-colors",
|
|
1989
|
+
style: {
|
|
1990
|
+
paddingLeft: `calc(0.5rem + ${section.depth * GROUP_INDENT_PX}px)`
|
|
1991
|
+
},
|
|
1992
|
+
children: [
|
|
1993
|
+
collapsed ? /* @__PURE__ */ jsxDEV16(ChevronRight2, {
|
|
1994
|
+
className: "size-4"
|
|
1995
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV16(ChevronDown, {
|
|
1996
|
+
className: "size-4"
|
|
1997
|
+
}, undefined, false, undefined, this),
|
|
1998
|
+
/* @__PURE__ */ jsxDEV16("div", {
|
|
1999
|
+
className: "min-w-0 flex-1 text-left",
|
|
2000
|
+
children: renderedLabel
|
|
2001
|
+
}, undefined, false, undefined, this),
|
|
2002
|
+
/* @__PURE__ */ jsxDEV16(Badge, {
|
|
2003
|
+
variant: "secondary",
|
|
2004
|
+
className: "ml-auto",
|
|
2005
|
+
children: section.rows.length
|
|
2006
|
+
}, undefined, false, undefined, this),
|
|
2007
|
+
/* @__PURE__ */ jsxDEV16(DataTableGroupActions, {
|
|
2008
|
+
actions: section.field.actions,
|
|
2009
|
+
groupId: section.groupId,
|
|
2010
|
+
title: section.field.actionsTitle
|
|
2011
|
+
}, undefined, false, undefined, this)
|
|
2012
|
+
]
|
|
2013
|
+
}, undefined, true, undefined, this)
|
|
2014
|
+
}, undefined, false, undefined, this)
|
|
2015
|
+
}, undefined, false, undefined, this);
|
|
2016
|
+
};
|
|
2017
|
+
var GroupTableSection = ({
|
|
2018
|
+
children,
|
|
2019
|
+
section
|
|
2020
|
+
}) => {
|
|
2021
|
+
const { isOver, setNodeRef } = useDroppable({
|
|
2022
|
+
id: getGroupTargetDropId(section.key),
|
|
2023
|
+
disabled: !section.field.onMoveToGroup,
|
|
2024
|
+
data: {
|
|
2025
|
+
type: "group-target",
|
|
2026
|
+
fieldId: section.field.id,
|
|
2027
|
+
groupId: section.groupId
|
|
2028
|
+
}
|
|
2029
|
+
});
|
|
2030
|
+
return /* @__PURE__ */ jsxDEV16(TableBody, {
|
|
2031
|
+
className: cn("relative px-2", isOver && "ring-primary ring-1 ring-inset"),
|
|
2032
|
+
ref: setNodeRef,
|
|
2033
|
+
children
|
|
2034
|
+
}, undefined, false, undefined, this);
|
|
2035
|
+
};
|
|
2036
|
+
var GroupHeaderCard = ({
|
|
2037
|
+
collapsed,
|
|
2038
|
+
onToggle,
|
|
2039
|
+
section
|
|
2040
|
+
}) => {
|
|
2041
|
+
const { isOver, setNodeRef } = useDroppable({
|
|
2042
|
+
id: getGroupTargetDropId(section.key),
|
|
2043
|
+
disabled: !section.field.onMoveToGroup,
|
|
2044
|
+
data: {
|
|
2045
|
+
type: "group-target",
|
|
2046
|
+
fieldId: section.field.id,
|
|
2047
|
+
groupId: section.groupId
|
|
2048
|
+
}
|
|
2049
|
+
});
|
|
2050
|
+
const label = section.field.getGroupLabel?.(section.groupId, section.rows.map((row) => row.original)) ?? section.groupId;
|
|
2051
|
+
const renderedLabel = section.field.renderGroupLabel?.(section.groupId, section.rows.map((row) => row.original)) ?? label;
|
|
2052
|
+
return /* @__PURE__ */ jsxDEV16("div", {
|
|
2053
|
+
className: cn("flex w-full items-center gap-3 rounded-lg border px-3 py-2 text-left font-medium transition-colors", isOver && "outline outline-primary"),
|
|
2054
|
+
ref: setNodeRef,
|
|
2055
|
+
children: [
|
|
2056
|
+
/* @__PURE__ */ jsxDEV16("button", {
|
|
2057
|
+
className: "flex min-w-0 flex-1 items-center gap-3 text-left",
|
|
2058
|
+
onClick: onToggle,
|
|
2059
|
+
type: "button",
|
|
2060
|
+
children: [
|
|
2061
|
+
collapsed ? /* @__PURE__ */ jsxDEV16(ChevronRight2, {
|
|
2062
|
+
className: "size-4"
|
|
2063
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV16(ChevronDown, {
|
|
2064
|
+
className: "size-4"
|
|
2065
|
+
}, undefined, false, undefined, this),
|
|
2066
|
+
/* @__PURE__ */ jsxDEV16("div", {
|
|
2067
|
+
className: "min-w-0 flex-1",
|
|
2068
|
+
children: renderedLabel
|
|
2069
|
+
}, undefined, false, undefined, this),
|
|
2070
|
+
/* @__PURE__ */ jsxDEV16(Badge, {
|
|
2071
|
+
variant: "secondary",
|
|
2072
|
+
className: "ml-auto",
|
|
2073
|
+
children: section.rows.length
|
|
2074
|
+
}, undefined, false, undefined, this)
|
|
2075
|
+
]
|
|
2076
|
+
}, undefined, true, undefined, this),
|
|
2077
|
+
/* @__PURE__ */ jsxDEV16(DataTableGroupActions, {
|
|
2078
|
+
actions: section.field.actions,
|
|
2079
|
+
groupId: section.groupId,
|
|
2080
|
+
title: section.field.actionsTitle
|
|
2081
|
+
}, undefined, false, undefined, this)
|
|
2082
|
+
]
|
|
2083
|
+
}, undefined, true, undefined, this);
|
|
2084
|
+
};
|
|
2085
|
+
var DataTableGroupActions = ({
|
|
2086
|
+
actions,
|
|
2087
|
+
groupId,
|
|
2088
|
+
title
|
|
2089
|
+
}) => {
|
|
2090
|
+
const visibleActions = actions?.filter((action) => !action.visible || action.visible(groupId));
|
|
2091
|
+
if (!visibleActions?.length)
|
|
2092
|
+
return null;
|
|
2093
|
+
return /* @__PURE__ */ jsxDEV16(DropdownMenu, {
|
|
2094
|
+
children: [
|
|
2095
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuTrigger, {
|
|
2096
|
+
onClick: (event) => event.stopPropagation(),
|
|
2097
|
+
render: /* @__PURE__ */ jsxDEV16(Button, {
|
|
2098
|
+
className: "size-7 shadow-md [&_svg:not([class*='size-'])]:size-3.5",
|
|
2099
|
+
size: "icon",
|
|
2100
|
+
variant: "ghost",
|
|
2101
|
+
children: [
|
|
2102
|
+
/* @__PURE__ */ jsxDEV16("span", {
|
|
2103
|
+
className: "sr-only",
|
|
2104
|
+
children: title
|
|
2105
|
+
}, undefined, false, undefined, this),
|
|
2106
|
+
/* @__PURE__ */ jsxDEV16(MoreHorizontal, {}, undefined, false, undefined, this)
|
|
2107
|
+
]
|
|
2108
|
+
}, undefined, true, undefined, this)
|
|
2109
|
+
}, undefined, false, undefined, this),
|
|
2110
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuContent, {
|
|
2111
|
+
align: "end",
|
|
2112
|
+
className: "w-max",
|
|
2113
|
+
children: /* @__PURE__ */ jsxDEV16(DropdownMenuGroup, {
|
|
2114
|
+
children: [
|
|
2115
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuLabel, {
|
|
2116
|
+
children: title
|
|
2117
|
+
}, undefined, false, undefined, this),
|
|
2118
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuSeparator, {}, undefined, false, undefined, this),
|
|
2119
|
+
visibleActions.map((action) => /* @__PURE__ */ jsxDEV16(DropdownMenuItem, {
|
|
2120
|
+
className: "whitespace-nowrap",
|
|
2121
|
+
onClick: (event) => {
|
|
2122
|
+
event.stopPropagation();
|
|
2123
|
+
action.onClick(groupId);
|
|
2124
|
+
},
|
|
2125
|
+
...action.variant ? { variant: action.variant } : {},
|
|
2126
|
+
children: [
|
|
2127
|
+
action.icon,
|
|
2128
|
+
action.name
|
|
2129
|
+
]
|
|
2130
|
+
}, action.name, true, undefined, this))
|
|
2131
|
+
]
|
|
2132
|
+
}, undefined, true, undefined, this)
|
|
2133
|
+
}, undefined, false, undefined, this)
|
|
2134
|
+
]
|
|
2135
|
+
}, undefined, true, undefined, this);
|
|
2136
|
+
};
|
|
2137
|
+
var DataTableRow = ({
|
|
2138
|
+
canDrag,
|
|
2139
|
+
canReorder,
|
|
2140
|
+
dragLabel,
|
|
2141
|
+
indentDepth = 0,
|
|
2142
|
+
reorderHandleLabel,
|
|
2143
|
+
onRowClick,
|
|
2144
|
+
row,
|
|
2145
|
+
rowActions,
|
|
2146
|
+
rowActionsLabel
|
|
2147
|
+
}) => {
|
|
2148
|
+
const sortable = useSortable({
|
|
2149
|
+
id: getSortableRowId(row.id),
|
|
2150
|
+
disabled: !canReorder,
|
|
2151
|
+
data: {
|
|
2152
|
+
type: "row-reorder",
|
|
2153
|
+
row: row.original,
|
|
2154
|
+
label: dragLabel
|
|
2155
|
+
}
|
|
2156
|
+
});
|
|
2157
|
+
const draggable = useDraggable({
|
|
2158
|
+
id: getRowDragId(row.id),
|
|
2159
|
+
disabled: !canDrag || canReorder,
|
|
2160
|
+
data: {
|
|
2161
|
+
type: "row",
|
|
2162
|
+
row: row.original,
|
|
2163
|
+
label: dragLabel
|
|
2164
|
+
}
|
|
2165
|
+
});
|
|
2166
|
+
const attributes = canReorder ? sortable.attributes : draggable.attributes;
|
|
2167
|
+
const listeners = canReorder ? sortable.listeners : draggable.listeners;
|
|
2168
|
+
const isDragging = canReorder ? sortable.isDragging : draggable.isDragging;
|
|
2169
|
+
const setRowNodeRef = canReorder ? sortable.setNodeRef : draggable.setNodeRef;
|
|
2170
|
+
const transform = canReorder ? CSS.Transform.toString(sortable.transform) : undefined;
|
|
2171
|
+
const firstCellIndent = indentDepth > 0 ? `calc(0.5rem + ${(indentDepth - 1) * GROUP_INDENT_PX + GROUP_ROW_INDENT_OFFSET_PX}px)` : undefined;
|
|
2172
|
+
const rowAttributes = canReorder ? onRowClick ? { role: "button", tabIndex: 0 } : {} : onRowClick ? { ...attributes, role: "button", tabIndex: 0 } : attributes;
|
|
2173
|
+
const visibleCells = row.getVisibleCells();
|
|
2174
|
+
return /* @__PURE__ */ jsxDEV16(TableRow, {
|
|
2175
|
+
className: cn("h-16 focus-visible:outline-ring focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-solid", onRowClick && "cursor-pointer", isDragging && "opacity-50"),
|
|
2176
|
+
"data-state": row.getIsSelected() && "selected",
|
|
2177
|
+
onClick: () => {
|
|
2178
|
+
if (onRowClick) {
|
|
2179
|
+
onRowClick(row.original);
|
|
2180
|
+
}
|
|
2181
|
+
},
|
|
2182
|
+
onKeyDown: (event) => {
|
|
2183
|
+
if (!onRowClick || event.key !== "Enter" && event.key !== " ") {
|
|
2184
|
+
return;
|
|
2185
|
+
}
|
|
2186
|
+
event.preventDefault();
|
|
2187
|
+
onRowClick(row.original);
|
|
2188
|
+
},
|
|
2189
|
+
ref: setRowNodeRef,
|
|
2190
|
+
style: {
|
|
2191
|
+
transform,
|
|
2192
|
+
transition: sortable.transition
|
|
2193
|
+
},
|
|
2194
|
+
...rowAttributes,
|
|
2195
|
+
...!canReorder ? listeners : {},
|
|
2196
|
+
children: [
|
|
2197
|
+
canReorder ? /* @__PURE__ */ jsxDEV16(TableCell, {
|
|
2198
|
+
className: "w-10 min-w-10 pr-0",
|
|
2199
|
+
children: /* @__PURE__ */ jsxDEV16(Button, {
|
|
2200
|
+
"aria-label": reorderHandleLabel,
|
|
2201
|
+
className: "size-8 cursor-grab active:cursor-grabbing",
|
|
2202
|
+
onClick: (event) => event.stopPropagation(),
|
|
2203
|
+
size: "icon",
|
|
2204
|
+
type: "button",
|
|
2205
|
+
variant: "ghost",
|
|
2206
|
+
...attributes,
|
|
2207
|
+
...listeners,
|
|
2208
|
+
children: /* @__PURE__ */ jsxDEV16(GripVertical, {}, undefined, false, undefined, this)
|
|
2209
|
+
}, undefined, false, undefined, this)
|
|
2210
|
+
}, undefined, false, undefined, this) : null,
|
|
2211
|
+
visibleCells.map((cell, index) => {
|
|
2212
|
+
const isLastCell = index === visibleCells.length - 1;
|
|
2213
|
+
return /* @__PURE__ */ jsxDEV16(TableCell, {
|
|
2214
|
+
className: cn("align-center min-w-32 overflow-hidden [&:has([data-slot=relationship-cell])]:relative [&:has([data-slot=relationship-cell])]:p-0 [&:has([data-slot=relationship-cell])>div]:absolute [&:has([data-slot=relationship-cell])>div]:inset-0", cell.column.columnDef.meta?.truncate ? "whitespace-nowrap" : "whitespace-normal", rowActions && isLastCell && "min-w-40 pr-12 [&:has([data-slot=relationship-cell])]:pr-0 [&:has([data-slot=relationship-cell])>div]:mr-11"),
|
|
2215
|
+
style: index === 0 && firstCellIndent ? {
|
|
2216
|
+
paddingLeft: firstCellIndent,
|
|
2217
|
+
width: cell.column.getSize()
|
|
2218
|
+
} : { width: cell.column.getSize() },
|
|
2219
|
+
children: /* @__PURE__ */ jsxDEV16("div", {
|
|
2220
|
+
className: cn("w-full max-w-full min-w-0 overflow-hidden break-words [&:has([data-slot=list-summary])]:line-clamp-none", cell.column.columnDef.meta?.truncate ? "truncate" : "line-clamp-3"),
|
|
2221
|
+
children: flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
2222
|
+
}, undefined, false, undefined, this)
|
|
2223
|
+
}, cell.id, false, undefined, this);
|
|
2224
|
+
}),
|
|
2225
|
+
rowActions ? /* @__PURE__ */ jsxDEV16(TableCell, {
|
|
2226
|
+
className: "sticky right-0 z-20 w-0 min-w-0 overflow-visible p-0",
|
|
2227
|
+
children: /* @__PURE__ */ jsxDEV16("div", {
|
|
2228
|
+
className: "bg-background/95 absolute top-1/2 right-2 -translate-y-1/2 rounded-md shadow-sm backdrop-blur",
|
|
2229
|
+
children: /* @__PURE__ */ jsxDEV16(DataTableRowActions, {
|
|
2230
|
+
actions: rowActions,
|
|
2231
|
+
row: row.original,
|
|
2232
|
+
title: rowActionsLabel
|
|
2233
|
+
}, undefined, false, undefined, this)
|
|
2234
|
+
}, undefined, false, undefined, this)
|
|
2235
|
+
}, undefined, false, undefined, this) : null
|
|
2236
|
+
]
|
|
2237
|
+
}, row.id, true, undefined, this);
|
|
2238
|
+
};
|
|
2239
|
+
var DataTableGalleryCard = ({
|
|
2240
|
+
canDrag,
|
|
2241
|
+
dragLabel,
|
|
2242
|
+
gallery,
|
|
2243
|
+
onRowClick,
|
|
2244
|
+
row,
|
|
2245
|
+
rowActions,
|
|
2246
|
+
rowActionsLabel,
|
|
2247
|
+
table
|
|
2248
|
+
}) => {
|
|
2249
|
+
const { attributes, listeners, setNodeRef, isDragging } = useDraggable({
|
|
2250
|
+
id: getRowDragId(row.id),
|
|
2251
|
+
disabled: !canDrag,
|
|
2252
|
+
data: {
|
|
2253
|
+
type: "row",
|
|
2254
|
+
row: row.original,
|
|
2255
|
+
label: dragLabel
|
|
2256
|
+
}
|
|
2257
|
+
});
|
|
2258
|
+
const nameCell = gallery ? row.getVisibleCells().find((cell) => cell.column.id === gallery.name) : null;
|
|
2259
|
+
const descriptionCell = gallery?.description ? row.getVisibleCells().find((cell) => cell.column.id === gallery.description) : null;
|
|
2260
|
+
const tagCell = gallery?.tag ? row.getVisibleCells().find((cell) => cell.column.id === gallery.tag) : null;
|
|
2261
|
+
if (gallery) {
|
|
2262
|
+
const tagValue = gallery.tag ? row.getValue(gallery.tag) : null;
|
|
2263
|
+
const tagLabel = tagValue === null || tagValue === undefined ? null : String(tagValue);
|
|
2264
|
+
return /* @__PURE__ */ jsxDEV16(Card, {
|
|
2265
|
+
className: cn("relative mx-auto w-full max-w-sm transition-colors", onRowClick && "cursor-pointer hover:bg-accent/20", isDragging && "opacity-50"),
|
|
2266
|
+
"data-state": row.getIsSelected() && "selected",
|
|
2267
|
+
onClick: () => {
|
|
2268
|
+
if (onRowClick) {
|
|
2269
|
+
onRowClick(row.original);
|
|
2270
|
+
}
|
|
2271
|
+
},
|
|
2272
|
+
ref: setNodeRef,
|
|
2273
|
+
...attributes,
|
|
2274
|
+
...listeners,
|
|
2275
|
+
children: [
|
|
2276
|
+
rowActions ? /* @__PURE__ */ jsxDEV16("div", {
|
|
2277
|
+
className: "absolute top-4 right-4 z-10",
|
|
2278
|
+
onClick: (event) => event.stopPropagation(),
|
|
2279
|
+
children: /* @__PURE__ */ jsxDEV16(DataTableRowActions, {
|
|
2280
|
+
actions: rowActions,
|
|
2281
|
+
row: row.original,
|
|
2282
|
+
title: rowActionsLabel
|
|
2283
|
+
}, undefined, false, undefined, this)
|
|
2284
|
+
}, undefined, false, undefined, this) : null,
|
|
2285
|
+
/* @__PURE__ */ jsxDEV16(CardHeader, {
|
|
2286
|
+
className: cn(rowActions && "pr-14"),
|
|
2287
|
+
children: [
|
|
2288
|
+
tagCell && tagLabel ? /* @__PURE__ */ jsxDEV16(Badge, {
|
|
2289
|
+
variant: "secondary",
|
|
2290
|
+
className: "mb-1 w-fit gap-1",
|
|
2291
|
+
children: [
|
|
2292
|
+
gallery.tagIcon,
|
|
2293
|
+
tagLabel
|
|
2294
|
+
]
|
|
2295
|
+
}, undefined, true, undefined, this) : null,
|
|
2296
|
+
nameCell ? /* @__PURE__ */ jsxDEV16(CardTitle, {
|
|
2297
|
+
className: "min-w-0 text-base",
|
|
2298
|
+
children: flexRender(nameCell.column.columnDef.cell, nameCell.getContext())
|
|
2299
|
+
}, undefined, false, undefined, this) : null,
|
|
2300
|
+
descriptionCell ? /* @__PURE__ */ jsxDEV16(CardDescription, {
|
|
2301
|
+
className: "line-clamp-2 min-w-0",
|
|
2302
|
+
children: flexRender(descriptionCell.column.columnDef.cell, descriptionCell.getContext())
|
|
2303
|
+
}, undefined, false, undefined, this) : null
|
|
2304
|
+
]
|
|
2305
|
+
}, undefined, true, undefined, this)
|
|
2306
|
+
]
|
|
2307
|
+
}, undefined, true, undefined, this);
|
|
2308
|
+
}
|
|
2309
|
+
const contentCells = row.getVisibleCells();
|
|
2310
|
+
return /* @__PURE__ */ jsxDEV16(Card, {
|
|
2311
|
+
className: cn("gap-3 transition-colors", onRowClick && "cursor-pointer hover:bg-accent/20", isDragging && "opacity-50"),
|
|
2312
|
+
"data-state": row.getIsSelected() && "selected",
|
|
2313
|
+
onClick: () => {
|
|
2314
|
+
if (onRowClick) {
|
|
2315
|
+
onRowClick(row.original);
|
|
2316
|
+
}
|
|
2317
|
+
},
|
|
2318
|
+
ref: setNodeRef,
|
|
2319
|
+
...attributes,
|
|
2320
|
+
...listeners,
|
|
2321
|
+
children: [
|
|
2322
|
+
/* @__PURE__ */ jsxDEV16(CardHeader, {
|
|
2323
|
+
children: [
|
|
2324
|
+
rowActions ? /* @__PURE__ */ jsxDEV16(CardAction, {
|
|
2325
|
+
onClick: (event) => event.stopPropagation(),
|
|
2326
|
+
children: /* @__PURE__ */ jsxDEV16(DataTableRowActions, {
|
|
2327
|
+
actions: rowActions,
|
|
2328
|
+
row: row.original,
|
|
2329
|
+
title: rowActionsLabel
|
|
2330
|
+
}, undefined, false, undefined, this)
|
|
2331
|
+
}, undefined, false, undefined, this) : null,
|
|
2332
|
+
contentCells.length > 0 && /* @__PURE__ */ jsxDEV16("div", {
|
|
2333
|
+
className: "grid min-w-0 gap-3",
|
|
2334
|
+
children: [
|
|
2335
|
+
/* @__PURE__ */ jsxDEV16(CardDescription, {
|
|
2336
|
+
className: "text-muted-foreground text-xs font-medium tracking-wide uppercase",
|
|
2337
|
+
children: getColumnDisplayName(table, contentCells[0].column.id)
|
|
2338
|
+
}, undefined, false, undefined, this),
|
|
2339
|
+
/* @__PURE__ */ jsxDEV16(CardTitle, {
|
|
2340
|
+
className: "text-base",
|
|
2341
|
+
children: flexRender(contentCells[0].column.columnDef.cell, contentCells[0].getContext())
|
|
2342
|
+
}, undefined, false, undefined, this)
|
|
2343
|
+
]
|
|
2344
|
+
}, undefined, true, undefined, this)
|
|
2345
|
+
]
|
|
2346
|
+
}, undefined, true, undefined, this),
|
|
2347
|
+
contentCells.length > 1 && /* @__PURE__ */ jsxDEV16(CardContent, {
|
|
2348
|
+
className: "grid gap-3",
|
|
2349
|
+
children: contentCells.slice(1).map((cell) => /* @__PURE__ */ jsxDEV16("div", {
|
|
2350
|
+
className: "grid gap-1",
|
|
2351
|
+
children: [
|
|
2352
|
+
/* @__PURE__ */ jsxDEV16("div", {
|
|
2353
|
+
className: "text-muted-foreground text-xs font-medium tracking-wide uppercase",
|
|
2354
|
+
children: getColumnDisplayName(table, cell.column.id)
|
|
2355
|
+
}, undefined, false, undefined, this),
|
|
2356
|
+
/* @__PURE__ */ jsxDEV16("div", {
|
|
2357
|
+
className: "min-w-0 text-sm",
|
|
2358
|
+
children: flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
2359
|
+
}, undefined, false, undefined, this)
|
|
2360
|
+
]
|
|
2361
|
+
}, cell.id, true, undefined, this))
|
|
2362
|
+
}, undefined, false, undefined, this)
|
|
2363
|
+
]
|
|
2364
|
+
}, undefined, true, undefined, this);
|
|
2365
|
+
};
|
|
2366
|
+
var extractTextFromElement = (element) => {
|
|
2367
|
+
if (typeof element === "string")
|
|
2368
|
+
return element;
|
|
2369
|
+
if (typeof element === "number")
|
|
2370
|
+
return String(element);
|
|
2371
|
+
if (!element || typeof element !== "object")
|
|
2372
|
+
return null;
|
|
2373
|
+
const props = element.props;
|
|
2374
|
+
if (!props)
|
|
2375
|
+
return null;
|
|
2376
|
+
if (typeof props.title === "string")
|
|
2377
|
+
return props.title;
|
|
2378
|
+
return extractTextFromElement(props.children);
|
|
2379
|
+
};
|
|
2380
|
+
var getHeaderName = (header) => {
|
|
2381
|
+
const columnDef = header.column.columnDef;
|
|
2382
|
+
if (typeof columnDef.header === "function") {
|
|
2383
|
+
const headerContext = columnDef.header(header.getContext());
|
|
2384
|
+
if (typeof headerContext === "string") {
|
|
2385
|
+
return headerContext;
|
|
2386
|
+
}
|
|
2387
|
+
return extractTextFromElement(headerContext) ?? header.id;
|
|
2388
|
+
}
|
|
2389
|
+
return String(columnDef.header ?? header.id);
|
|
2390
|
+
};
|
|
2391
|
+
var getHeaderNames = (headers) => headers.map((header) => getHeaderName(header));
|
|
2392
|
+
var getColumnDisplayName = (table, columnId) => {
|
|
2393
|
+
const header = table.getFlatHeaders().find((currentHeader) => currentHeader.column.id === columnId);
|
|
2394
|
+
return header ? getHeaderName(header) : columnId;
|
|
2395
|
+
};
|
|
2396
|
+
var renderHeader = (header) => {
|
|
2397
|
+
if (header.isPlaceholder)
|
|
2398
|
+
return null;
|
|
2399
|
+
const content = flexRender(header.column.columnDef.header, header.getContext());
|
|
2400
|
+
return typeof content === "string" || typeof content === "number" ? /* @__PURE__ */ jsxDEV16("div", {
|
|
2401
|
+
className: "flex h-12 items-center px-2 text-sm",
|
|
2402
|
+
children: content
|
|
2403
|
+
}, undefined, false, undefined, this) : content;
|
|
2404
|
+
};
|
|
2405
|
+
var withFileExtension = (fileName, extension) => {
|
|
2406
|
+
const normalizedExtension = extension.startsWith(".") ? extension : `.${extension}`;
|
|
2407
|
+
return fileName.includes(".") ? fileName.replace(/\.[^/.]+$/, normalizedExtension) : `${fileName}${normalizedExtension}`;
|
|
2408
|
+
};
|
|
2409
|
+
var escapeCsvValue = (value) => {
|
|
2410
|
+
if (value === null || value === undefined)
|
|
2411
|
+
return "";
|
|
2412
|
+
const stringValue = String(value);
|
|
2413
|
+
if (stringValue.includes(",") || stringValue.includes('"') || stringValue.includes(`
|
|
2414
|
+
`)) {
|
|
2415
|
+
return `"${stringValue.replace(/"/g, '""')}"`;
|
|
2416
|
+
}
|
|
2417
|
+
return stringValue;
|
|
2418
|
+
};
|
|
2419
|
+
var downloadCsv = (headers, data, fileName = "data.csv") => {
|
|
2420
|
+
const csvContent = [headers, ...data].map((row) => row.map(escapeCsvValue).join(",")).join(`
|
|
2421
|
+
`);
|
|
2422
|
+
const blob = new Blob([csvContent], { type: "text/csv;charset=utf-8;" });
|
|
2423
|
+
const link = document.createElement("a");
|
|
2424
|
+
const url = window.URL.createObjectURL(blob);
|
|
2425
|
+
link.href = url;
|
|
2426
|
+
link.setAttribute("download", withFileExtension(fileName, "csv"));
|
|
2427
|
+
document.body.appendChild(link);
|
|
2428
|
+
link.click();
|
|
2429
|
+
link.remove();
|
|
2430
|
+
requestAnimationFrame(() => window.URL.revokeObjectURL(url));
|
|
2431
|
+
};
|
|
2432
|
+
var downloadJson = (data, fileName = "data.json") => {
|
|
2433
|
+
const jsonContent = JSON.stringify(data, null, 2);
|
|
2434
|
+
const blob = new Blob([jsonContent], {
|
|
2435
|
+
type: "application/json;charset=utf-8;"
|
|
2436
|
+
});
|
|
2437
|
+
const link = document.createElement("a");
|
|
2438
|
+
const url = window.URL.createObjectURL(blob);
|
|
2439
|
+
link.href = url;
|
|
2440
|
+
link.setAttribute("download", withFileExtension(fileName, "json"));
|
|
2441
|
+
document.body.appendChild(link);
|
|
2442
|
+
link.click();
|
|
2443
|
+
link.remove();
|
|
2444
|
+
requestAnimationFrame(() => window.URL.revokeObjectURL(url));
|
|
2445
|
+
};
|
|
2446
|
+
var exportTableToCsv = (table, rows, fileName = "data.csv") => {
|
|
2447
|
+
const exportableColumns = table.getVisibleLeafColumns();
|
|
2448
|
+
const headerNames = exportableColumns.map((column) => getColumnDisplayName(table, column.id));
|
|
2449
|
+
const data = rows.map((row) => exportableColumns.map((column) => {
|
|
2450
|
+
const value = row.getValue(column.id);
|
|
2451
|
+
return value === null || value === undefined ? "" : String(value);
|
|
2452
|
+
}));
|
|
2453
|
+
downloadCsv(headerNames, data, fileName);
|
|
2454
|
+
};
|
|
2455
|
+
var exportTableToJson = (table, rows, fileName = "data.json") => {
|
|
2456
|
+
const exportableColumns = table.getVisibleLeafColumns();
|
|
2457
|
+
const data = rows.map((row) => Object.fromEntries(exportableColumns.map((column) => [column.id, row.getValue(column.id)])));
|
|
2458
|
+
downloadJson(data, fileName);
|
|
2459
|
+
};
|
|
2460
|
+
function DataTable({
|
|
2461
|
+
columns,
|
|
2462
|
+
data,
|
|
2463
|
+
state,
|
|
2464
|
+
search: controlledSearch,
|
|
2465
|
+
onSearchChange,
|
|
2466
|
+
searchState = "url",
|
|
2467
|
+
emptyLabel,
|
|
2468
|
+
messages: messages4,
|
|
2469
|
+
exportFileName,
|
|
2470
|
+
isLoading: legacyIsLoading,
|
|
2471
|
+
onRefresh,
|
|
2472
|
+
onRowClick,
|
|
2473
|
+
from,
|
|
2474
|
+
routeFrom,
|
|
2475
|
+
grouping,
|
|
2476
|
+
gallery,
|
|
2477
|
+
rowActions: legacyRowActions,
|
|
2478
|
+
reordering,
|
|
2479
|
+
serverPagination,
|
|
2480
|
+
features
|
|
2481
|
+
}) {
|
|
2482
|
+
const labels2 = dataTableMessages(messages4);
|
|
2483
|
+
const isLoading = state?.loading ?? legacyIsLoading ?? false;
|
|
2484
|
+
const emptyContent = state?.error ?? state?.empty ?? emptyLabel ?? labels2.empty;
|
|
2485
|
+
const paginationFeature = features?.pagination ?? (serverPagination ? { mode: "server", rowCount: serverPagination.rowCount } : { mode: "client" });
|
|
2486
|
+
const exportFeature = features?.export ?? (exportFileName ? { baseName: exportFileName, scope: "currentPage" } : false);
|
|
2487
|
+
const exportBaseName = exportFeature ? exportFeature.baseName : "table";
|
|
2488
|
+
const galleryConfig = features?.gallery === false ? undefined : features?.gallery ?? gallery;
|
|
2489
|
+
const rowActionsFeature = features?.rowActions === false ? undefined : features?.rowActions ?? (legacyRowActions?.length ? {
|
|
2490
|
+
items: legacyRowActions.map((action) => ({
|
|
2491
|
+
...action,
|
|
2492
|
+
id: action.id ?? action.name
|
|
2493
|
+
}))
|
|
2494
|
+
} : undefined);
|
|
2495
|
+
const rowActions = rowActionsFeature?.items.length ? rowActionsFeature.items : undefined;
|
|
2496
|
+
const rowActionsLabel = rowActionsFeature?.label ?? labels2.actions;
|
|
2497
|
+
const showPagination = paginationFeature !== false;
|
|
2498
|
+
const pageSizes = paginationFeature ? paginationFeature.pageSizes : undefined;
|
|
2499
|
+
const showSearch = features?.search ?? true;
|
|
2500
|
+
const showExport = exportFeature !== false;
|
|
2501
|
+
const columnVisibilityFeature = features?.columnVisibility ?? true;
|
|
2502
|
+
const showColumnVisibility = columnVisibilityFeature !== false;
|
|
2503
|
+
const defaultColumnVisibility = typeof columnVisibilityFeature === "object" ? columnVisibilityFeature.default : undefined;
|
|
2504
|
+
const showGallery = !!galleryConfig;
|
|
2505
|
+
const showSorting = features?.sorting ?? true;
|
|
2506
|
+
const isServerMode = paginationFeature !== false && paginationFeature.mode === "server";
|
|
2507
|
+
const serverRowCount = isServerMode ? paginationFeature.rowCount : undefined;
|
|
2508
|
+
const location = useRouterState({
|
|
2509
|
+
select: (state2) => state2.location
|
|
2510
|
+
});
|
|
2511
|
+
const search = location.search;
|
|
2512
|
+
const pathname = location.pathname;
|
|
2513
|
+
const resolvedRouteFrom = routeFrom ?? from;
|
|
2514
|
+
const [storagePath] = useState(() => resolvedRouteFrom ?? pathname);
|
|
2515
|
+
const navigate = useNavigate(resolvedRouteFrom ? { from: resolvedRouteFrom } : undefined);
|
|
2516
|
+
const [localSearch, setLocalSearch] = useState({
|
|
2517
|
+
globalFilter: ""
|
|
2518
|
+
});
|
|
2519
|
+
const tableSearch = controlledSearch ?? (searchState === "local" ? localSearch : search);
|
|
2520
|
+
const {
|
|
2521
|
+
page = 0,
|
|
2522
|
+
pageSize = 10,
|
|
2523
|
+
sort,
|
|
2524
|
+
globalFilter = "",
|
|
2525
|
+
grouping: urlGrouping
|
|
2526
|
+
} = tableSearch ?? {};
|
|
2527
|
+
const pagination = { pageIndex: page, pageSize };
|
|
2528
|
+
const decodedSort = sort ? Schema2.decodeSync(SortParamsFromString)(sort) : [];
|
|
2529
|
+
const sorting = decodedSort.map((sortParam) => ({
|
|
2530
|
+
id: sortParam.id,
|
|
2531
|
+
desc: sortParam.direction === "desc"
|
|
2532
|
+
}));
|
|
2533
|
+
const tableStorageId = useMemo(() => {
|
|
2534
|
+
const columnIds = columns.map((column, index) => {
|
|
2535
|
+
if ("id" in column && typeof column.id === "string") {
|
|
2536
|
+
return column.id;
|
|
2537
|
+
}
|
|
2538
|
+
if ("accessorKey" in column && typeof column.accessorKey === "string") {
|
|
2539
|
+
return column.accessorKey;
|
|
2540
|
+
}
|
|
2541
|
+
return String(index);
|
|
2542
|
+
}).join(",");
|
|
2543
|
+
return `${storagePath}:${columnIds}`;
|
|
2544
|
+
}, [columns, storagePath]);
|
|
2545
|
+
const columnVisibilityAtom = useMemo(() => Atom.kvs({
|
|
2546
|
+
runtime: dataTableStorageRuntime,
|
|
2547
|
+
key: `data-table:column-visibility:${tableStorageId}`,
|
|
2548
|
+
schema: ColumnVisibilitySchema,
|
|
2549
|
+
defaultValue: () => defaultColumnVisibility ?? {}
|
|
2550
|
+
}), [defaultColumnVisibility, tableStorageId]);
|
|
2551
|
+
const columnSizingAtom = useMemo(() => Atom.kvs({
|
|
2552
|
+
runtime: dataTableStorageRuntime,
|
|
2553
|
+
key: `data-table:column-sizing:${tableStorageId}`,
|
|
2554
|
+
schema: ColumnSizingSchema,
|
|
2555
|
+
defaultValue: () => ({})
|
|
2556
|
+
}), [tableStorageId]);
|
|
2557
|
+
const viewAtom = useMemo(() => Atom.kvs({
|
|
2558
|
+
runtime: dataTableStorageRuntime,
|
|
2559
|
+
key: `data-table:view:${tableStorageId}`,
|
|
2560
|
+
schema: DataTableViewSchema,
|
|
2561
|
+
defaultValue: () => "table"
|
|
2562
|
+
}), [tableStorageId]);
|
|
2563
|
+
const [columnVisibility, setColumnVisibility] = useAtom(columnVisibilityAtom);
|
|
2564
|
+
const [columnSizing, setColumnSizing] = useAtom(columnSizingAtom);
|
|
2565
|
+
const [storedView, setStoredView] = useAtom(viewAtom);
|
|
2566
|
+
const currentView = showGallery ? storedView : "table";
|
|
2567
|
+
const isGalleryView = currentView === "gallery";
|
|
2568
|
+
const hasToolbar = Boolean(showSearch || grouping?.fields.length || showSorting || showGallery || showColumnVisibility || onRefresh || showExport);
|
|
2569
|
+
const [rowSelection, setRowSelection] = useState({});
|
|
2570
|
+
const [collapsedGroups, setCollapsedGroups] = useState({});
|
|
2571
|
+
const [activeDragLabel, setActiveDragLabel] = useState(null);
|
|
2572
|
+
const [refreshSpinCount, setRefreshSpinCount] = useState(0);
|
|
2573
|
+
const [searchInput, setSearchInput] = useState(globalFilter);
|
|
2574
|
+
const availableGroupFieldIds = grouping?.fields.map((field) => field.id) ?? [];
|
|
2575
|
+
const activeGrouping = urlGrouping?.filter((groupId) => availableGroupFieldIds.includes(groupId)) ?? getDefaultGrouping(grouping);
|
|
2576
|
+
const sensors = useSensors(useSensor(PointerSensor, {
|
|
2577
|
+
activationConstraint: {
|
|
2578
|
+
distance: 8
|
|
2579
|
+
}
|
|
2580
|
+
}));
|
|
2581
|
+
const updateTableSearch = (updater, options) => {
|
|
2582
|
+
if (controlledSearch || onSearchChange || searchState === "local") {
|
|
2583
|
+
const nextSearch = updater(controlledSearch ?? localSearch ?? {});
|
|
2584
|
+
if (onSearchChange) {
|
|
2585
|
+
onSearchChange(nextSearch);
|
|
2586
|
+
} else {
|
|
2587
|
+
setLocalSearch(nextSearch);
|
|
2588
|
+
}
|
|
2589
|
+
return;
|
|
2590
|
+
}
|
|
2591
|
+
navigate({
|
|
2592
|
+
to: ".",
|
|
2593
|
+
replace: options?.replace ?? false,
|
|
2594
|
+
resetScroll: false,
|
|
2595
|
+
search: (current) => updater(current ?? {})
|
|
2596
|
+
});
|
|
2597
|
+
};
|
|
2598
|
+
const table = useReactTable({
|
|
2599
|
+
data,
|
|
2600
|
+
columns,
|
|
2601
|
+
defaultColumn: {
|
|
2602
|
+
minSize: 128,
|
|
2603
|
+
size: 224,
|
|
2604
|
+
maxSize: 640
|
|
2605
|
+
},
|
|
2606
|
+
columnResizeMode: "onChange",
|
|
2607
|
+
enableColumnResizing: true,
|
|
2608
|
+
onColumnSizingChange: (updater) => {
|
|
2609
|
+
const nextColumnSizing = typeof updater === "function" ? updater(columnSizing) : updater;
|
|
2610
|
+
setColumnSizing(nextColumnSizing);
|
|
2611
|
+
},
|
|
2612
|
+
...reordering ? { getRowId: reordering.getRowId } : {},
|
|
2613
|
+
onPaginationChange: (updater) => {
|
|
2614
|
+
const newPagination = typeof updater === "function" ? updater(pagination) : updater;
|
|
2615
|
+
if (pagination.pageIndex === newPagination.pageIndex && pagination.pageSize === newPagination.pageSize) {
|
|
2616
|
+
return;
|
|
2617
|
+
}
|
|
2618
|
+
updateTableSearch((current) => ({
|
|
2619
|
+
...current,
|
|
2620
|
+
page: newPagination.pageIndex,
|
|
2621
|
+
pageSize: newPagination.pageSize
|
|
2622
|
+
}));
|
|
2623
|
+
},
|
|
2624
|
+
onSortingChange: (updater) => {
|
|
2625
|
+
const newSorting = typeof updater === "function" ? updater([...sorting]) : updater;
|
|
2626
|
+
if (sorting.length === newSorting.length && sorting.every((sortState, i) => sortState.id === newSorting[i]?.id && sortState.desc === newSorting[i]?.desc)) {
|
|
2627
|
+
return;
|
|
2628
|
+
}
|
|
2629
|
+
const nextSort = newSorting.length ? Schema2.encodeSync(SortParamsFromString)(newSorting.map((sortState) => ({
|
|
2630
|
+
id: sortState.id,
|
|
2631
|
+
direction: sortState.desc ? "desc" : "asc"
|
|
2632
|
+
}))) : undefined;
|
|
2633
|
+
updateTableSearch((current) => ({
|
|
2634
|
+
...current,
|
|
2635
|
+
sort: nextSort,
|
|
2636
|
+
page: 0
|
|
2637
|
+
}));
|
|
2638
|
+
},
|
|
2639
|
+
getCoreRowModel: getCoreRowModel(),
|
|
2640
|
+
onGlobalFilterChange: (updater) => {
|
|
2641
|
+
const newGlobalFilter = typeof updater === "function" ? updater(globalFilter) : updater;
|
|
2642
|
+
if (globalFilter === newGlobalFilter) {
|
|
2643
|
+
return;
|
|
2644
|
+
}
|
|
2645
|
+
updateTableSearch((current) => ({
|
|
2646
|
+
...current,
|
|
2647
|
+
page: 0,
|
|
2648
|
+
globalFilter: newGlobalFilter
|
|
2649
|
+
}), { replace: true });
|
|
2650
|
+
},
|
|
2651
|
+
...isServerMode ? { manualSorting: true } : {},
|
|
2652
|
+
...!isServerMode ? { getSortedRowModel: getSortedRowModel() } : {},
|
|
2653
|
+
...isServerMode ? { manualFiltering: true } : {},
|
|
2654
|
+
...!isServerMode ? { getFilteredRowModel: getFilteredRowModel() } : {},
|
|
2655
|
+
...paginationFeature !== false && paginationFeature.mode === "server" ? { manualPagination: true, rowCount: paginationFeature.rowCount } : paginationFeature === false ? {} : { getPaginationRowModel: getPaginationRowModel() },
|
|
2656
|
+
autoResetPageIndex: false,
|
|
2657
|
+
onColumnVisibilityChange: (updater) => {
|
|
2658
|
+
const nextColumnVisibility = typeof updater === "function" ? updater(columnVisibility) : updater;
|
|
2659
|
+
setColumnVisibility(nextColumnVisibility);
|
|
2660
|
+
},
|
|
2661
|
+
onRowSelectionChange: setRowSelection,
|
|
2662
|
+
state: {
|
|
2663
|
+
sorting,
|
|
2664
|
+
pagination,
|
|
2665
|
+
globalFilter,
|
|
2666
|
+
columnVisibility,
|
|
2667
|
+
columnSizing,
|
|
2668
|
+
rowSelection
|
|
2669
|
+
}
|
|
2670
|
+
});
|
|
2671
|
+
useEffect(() => {
|
|
2672
|
+
setSearchInput(globalFilter);
|
|
2673
|
+
}, [globalFilter]);
|
|
2674
|
+
const activeGroupingFields = useMemo(() => activeGrouping.map((groupId) => grouping?.fields.find((field) => field.id === groupId)).filter((field) => !!field), [activeGrouping, grouping]);
|
|
2675
|
+
const hasActiveGrouping = activeGroupingFields.length > 0;
|
|
2676
|
+
const filteredRows = table.getPrePaginationRowModel().rows;
|
|
2677
|
+
const exportRows = exportFeature && exportFeature.scope === "filteredRows" ? filteredRows : table.getRowModel().rows;
|
|
2678
|
+
const bodyRows = hasActiveGrouping ? filteredRows : table.getRowModel().rows;
|
|
2679
|
+
const sortableRowIds = bodyRows.map((row) => getSortableRowId(row.id));
|
|
2680
|
+
const groupedSections = useMemo(() => buildGroupedSections(bodyRows, activeGroupingFields), [activeGroupingFields, bodyRows]);
|
|
2681
|
+
const canReorderRows = Boolean(reordering) && !hasActiveGrouping;
|
|
2682
|
+
const colSpan = Math.max(table.getVisibleLeafColumns().length, 1) + (rowActions ? 1 : 0) + (canReorderRows ? 1 : 0);
|
|
2683
|
+
const canDragRows = activeGroupingFields.some((field) => !!field.onMoveToGroup);
|
|
2684
|
+
const hasExportableRows = exportRows.length > 0;
|
|
2685
|
+
const addGroupingField = (fieldId) => {
|
|
2686
|
+
if (activeGrouping.includes(fieldId))
|
|
2687
|
+
return;
|
|
2688
|
+
updateTableSearch((current) => ({
|
|
2689
|
+
...current,
|
|
2690
|
+
grouping: [...activeGrouping, fieldId]
|
|
2691
|
+
}));
|
|
2692
|
+
};
|
|
2693
|
+
const removeGroupingField = (fieldId) => {
|
|
2694
|
+
updateTableSearch((current) => ({
|
|
2695
|
+
...current,
|
|
2696
|
+
grouping: activeGrouping.filter((currentId) => currentId !== fieldId)
|
|
2697
|
+
}));
|
|
2698
|
+
};
|
|
2699
|
+
const toggleGroupingField = (fieldId, enabled) => {
|
|
2700
|
+
if (enabled) {
|
|
2701
|
+
addGroupingField(fieldId);
|
|
2702
|
+
return;
|
|
2703
|
+
}
|
|
2704
|
+
removeGroupingField(fieldId);
|
|
2705
|
+
};
|
|
2706
|
+
const toggleGroup = (groupKey) => {
|
|
2707
|
+
setCollapsedGroups((current) => ({
|
|
2708
|
+
...current,
|
|
2709
|
+
[groupKey]: !current[groupKey]
|
|
2710
|
+
}));
|
|
2711
|
+
};
|
|
2712
|
+
const setView = (nextView) => {
|
|
2713
|
+
if (nextView === currentView) {
|
|
2714
|
+
return;
|
|
2715
|
+
}
|
|
2716
|
+
setStoredView(nextView);
|
|
2717
|
+
};
|
|
2718
|
+
const renderLoadingState = () => /* @__PURE__ */ jsxDEV16(Loading, {
|
|
2719
|
+
label: labels2.loading
|
|
2720
|
+
}, undefined, false, undefined, this);
|
|
2721
|
+
const renderEmptyContent = () => state?.error ?? (isLoading ? renderLoadingState() : emptyContent);
|
|
2722
|
+
const renderTableEmptyState = () => /* @__PURE__ */ jsxDEV16(TableRow, {
|
|
2723
|
+
children: /* @__PURE__ */ jsxDEV16(TableCell, {
|
|
2724
|
+
className: "h-24 text-center",
|
|
2725
|
+
colSpan,
|
|
2726
|
+
children: renderEmptyContent()
|
|
2727
|
+
}, undefined, false, undefined, this)
|
|
2728
|
+
}, undefined, false, undefined, this);
|
|
2729
|
+
const renderGalleryEmptyState = (message) => /* @__PURE__ */ jsxDEV16("div", {
|
|
2730
|
+
className: "text-muted-foreground rounded-xl border border-dashed px-4 py-10 text-center text-sm",
|
|
2731
|
+
children: message ?? renderEmptyContent()
|
|
2732
|
+
}, undefined, false, undefined, this);
|
|
2733
|
+
const renderGalleryRows = (rows, canDrag) => /* @__PURE__ */ jsxDEV16("div", {
|
|
2734
|
+
className: "grid gap-3 sm:grid-cols-2 xl:grid-cols-3",
|
|
2735
|
+
children: rows.map((row) => /* @__PURE__ */ jsxDEV16(DataTableGalleryCard, {
|
|
2736
|
+
canDrag,
|
|
2737
|
+
dragLabel: grouping?.getRowLabel?.(row.original),
|
|
2738
|
+
gallery: galleryConfig,
|
|
2739
|
+
onRowClick,
|
|
2740
|
+
row,
|
|
2741
|
+
rowActions,
|
|
2742
|
+
rowActionsLabel,
|
|
2743
|
+
table
|
|
2744
|
+
}, row.id, false, undefined, this))
|
|
2745
|
+
}, undefined, false, undefined, this);
|
|
2746
|
+
const renderGroupedTableSections = (sections) => sections.flatMap((section) => {
|
|
2747
|
+
const isCollapsed = collapsedGroups[section.key] ?? false;
|
|
2748
|
+
const hasChildren = section.children.length > 0;
|
|
2749
|
+
const sectionBody = /* @__PURE__ */ jsxDEV16(GroupTableSection, {
|
|
2750
|
+
section,
|
|
2751
|
+
children: [
|
|
2752
|
+
/* @__PURE__ */ jsxDEV16(GroupHeaderRow, {
|
|
2753
|
+
collapsed: isCollapsed,
|
|
2754
|
+
colSpan,
|
|
2755
|
+
onToggle: () => toggleGroup(section.key),
|
|
2756
|
+
section
|
|
2757
|
+
}, undefined, false, undefined, this),
|
|
2758
|
+
!isCollapsed && !hasChildren && (section.rows.length > 0 ? section.rows.map((row) => /* @__PURE__ */ jsxDEV16(DataTableRow, {
|
|
2759
|
+
canDrag: canDragRows,
|
|
2760
|
+
canReorder: false,
|
|
2761
|
+
dragLabel: grouping?.getRowLabel?.(row.original),
|
|
2762
|
+
indentDepth: section.depth + 1,
|
|
2763
|
+
onRowClick,
|
|
2764
|
+
row,
|
|
2765
|
+
rowActions,
|
|
2766
|
+
rowActionsLabel
|
|
2767
|
+
}, row.id, false, undefined, this)) : /* @__PURE__ */ jsxDEV16(TableRow, {
|
|
2768
|
+
children: /* @__PURE__ */ jsxDEV16(TableCell, {
|
|
2769
|
+
className: "text-muted-foreground h-16",
|
|
2770
|
+
colSpan,
|
|
2771
|
+
style: {
|
|
2772
|
+
paddingLeft: `calc(0.5rem + ${section.depth * GROUP_INDENT_PX + GROUP_ROW_INDENT_OFFSET_PX}px)`
|
|
2773
|
+
},
|
|
2774
|
+
children: isLoading ? renderLoadingState() : section.field.renderEmptyGroup?.(section.groupId) ?? labels2.empty
|
|
2775
|
+
}, undefined, false, undefined, this)
|
|
2776
|
+
}, undefined, false, undefined, this))
|
|
2777
|
+
]
|
|
2778
|
+
}, section.key, true, undefined, this);
|
|
2779
|
+
return !isCollapsed && hasChildren ? [sectionBody, renderGroupedTableSections(section.children)] : [sectionBody];
|
|
2780
|
+
});
|
|
2781
|
+
const renderGroupedGallerySections = (sections) => sections.map((section) => {
|
|
2782
|
+
const isCollapsed = collapsedGroups[section.key] ?? false;
|
|
2783
|
+
const hasChildren = section.children.length > 0;
|
|
2784
|
+
return /* @__PURE__ */ jsxDEV16("div", {
|
|
2785
|
+
className: "space-y-3",
|
|
2786
|
+
children: [
|
|
2787
|
+
/* @__PURE__ */ jsxDEV16(GroupHeaderCard, {
|
|
2788
|
+
collapsed: isCollapsed,
|
|
2789
|
+
onToggle: () => toggleGroup(section.key),
|
|
2790
|
+
section
|
|
2791
|
+
}, undefined, false, undefined, this),
|
|
2792
|
+
!isCollapsed && (hasChildren ? renderGroupedGallerySections(section.children) : section.rows.length > 0 ? renderGalleryRows(section.rows, canDragRows) : renderGalleryEmptyState(isLoading ? renderLoadingState() : section.field.renderEmptyGroup?.(section.groupId) ?? labels2.empty))
|
|
2793
|
+
]
|
|
2794
|
+
}, section.key, true, undefined, this);
|
|
2795
|
+
});
|
|
2796
|
+
return /* @__PURE__ */ jsxDEV16("div", {
|
|
2797
|
+
className: "w-full max-w-full min-w-0 rounded-md",
|
|
2798
|
+
children: [
|
|
2799
|
+
hasToolbar ? /* @__PURE__ */ jsxDEV16("div", {
|
|
2800
|
+
className: "flex flex-col gap-3 pb-4",
|
|
2801
|
+
children: /* @__PURE__ */ jsxDEV16("div", {
|
|
2802
|
+
className: "flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center sm:justify-between",
|
|
2803
|
+
children: [
|
|
2804
|
+
showSearch ? /* @__PURE__ */ jsxDEV16("div", {
|
|
2805
|
+
className: "relative w-full min-w-0 flex-1 sm:min-w-sm",
|
|
2806
|
+
children: [
|
|
2807
|
+
/* @__PURE__ */ jsxDEV16(Search, {
|
|
2808
|
+
className: "text-muted-foreground pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2"
|
|
2809
|
+
}, undefined, false, undefined, this),
|
|
2810
|
+
/* @__PURE__ */ jsxDEV16(Input, {
|
|
2811
|
+
className: "px-9",
|
|
2812
|
+
onChange: (event) => {
|
|
2813
|
+
setSearchInput(event.target.value);
|
|
2814
|
+
table.setGlobalFilter(event.target.value);
|
|
2815
|
+
},
|
|
2816
|
+
placeholder: labels2.filter,
|
|
2817
|
+
value: searchInput
|
|
2818
|
+
}, undefined, false, undefined, this),
|
|
2819
|
+
searchInput ? /* @__PURE__ */ jsxDEV16(Button, {
|
|
2820
|
+
"aria-label": labels2.filter,
|
|
2821
|
+
className: "text-muted-foreground hover:text-foreground absolute top-1/2 right-1 size-7 -translate-y-1/2 active:!-translate-y-1/2",
|
|
2822
|
+
onClick: () => {
|
|
2823
|
+
setSearchInput("");
|
|
2824
|
+
table.setGlobalFilter("");
|
|
2825
|
+
},
|
|
2826
|
+
size: "icon",
|
|
2827
|
+
type: "button",
|
|
2828
|
+
variant: "ghost",
|
|
2829
|
+
children: /* @__PURE__ */ jsxDEV16(X, {
|
|
2830
|
+
className: "size-4"
|
|
2831
|
+
}, undefined, false, undefined, this)
|
|
2832
|
+
}, undefined, false, undefined, this) : null
|
|
2833
|
+
]
|
|
2834
|
+
}, undefined, true, undefined, this) : /* @__PURE__ */ jsxDEV16("div", {}, undefined, false, undefined, this),
|
|
2835
|
+
/* @__PURE__ */ jsxDEV16("div", {
|
|
2836
|
+
className: "-m-1 flex items-center gap-2 overflow-x-auto p-1",
|
|
2837
|
+
children: [
|
|
2838
|
+
grouping?.fields.length ? /* @__PURE__ */ jsxDEV16(DropdownMenu, {
|
|
2839
|
+
children: [
|
|
2840
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuTrigger, {
|
|
2841
|
+
render: /* @__PURE__ */ jsxDEV16(Button, {
|
|
2842
|
+
"aria-label": labels2.groupBy,
|
|
2843
|
+
className: "h-9",
|
|
2844
|
+
size: "sm",
|
|
2845
|
+
variant: "outline",
|
|
2846
|
+
children: [
|
|
2847
|
+
/* @__PURE__ */ jsxDEV16(Rows3, {}, undefined, false, undefined, this),
|
|
2848
|
+
/* @__PURE__ */ jsxDEV16("span", {
|
|
2849
|
+
className: "hidden sm:inline",
|
|
2850
|
+
children: labels2.groupBy
|
|
2851
|
+
}, undefined, false, undefined, this)
|
|
2852
|
+
]
|
|
2853
|
+
}, undefined, true, undefined, this)
|
|
2854
|
+
}, undefined, false, undefined, this),
|
|
2855
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuContent, {
|
|
2856
|
+
align: "end",
|
|
2857
|
+
className: "w-[200px]",
|
|
2858
|
+
children: /* @__PURE__ */ jsxDEV16(DropdownMenuGroup, {
|
|
2859
|
+
children: [
|
|
2860
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuLabel, {
|
|
2861
|
+
children: labels2.groupBy
|
|
2862
|
+
}, undefined, false, undefined, this),
|
|
2863
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuSeparator, {}, undefined, false, undefined, this),
|
|
2864
|
+
grouping.fields.map((field) => /* @__PURE__ */ jsxDEV16(DropdownMenuCheckboxItem, {
|
|
2865
|
+
checked: activeGrouping.includes(field.id),
|
|
2866
|
+
onCheckedChange: (value) => toggleGroupingField(field.id, !!value),
|
|
2867
|
+
children: field.label
|
|
2868
|
+
}, field.id, false, undefined, this))
|
|
2869
|
+
]
|
|
2870
|
+
}, undefined, true, undefined, this)
|
|
2871
|
+
}, undefined, false, undefined, this)
|
|
2872
|
+
]
|
|
2873
|
+
}, undefined, true, undefined, this) : null,
|
|
2874
|
+
showSorting ? /* @__PURE__ */ jsxDEV16(DataTableSortDropdown, {
|
|
2875
|
+
messages: labels2,
|
|
2876
|
+
table
|
|
2877
|
+
}, undefined, false, undefined, this) : null,
|
|
2878
|
+
showGallery ? /* @__PURE__ */ jsxDEV16(DataTableDisplayModeSwitch, {
|
|
2879
|
+
messages: labels2,
|
|
2880
|
+
onChange: setView,
|
|
2881
|
+
value: currentView
|
|
2882
|
+
}, undefined, false, undefined, this) : null,
|
|
2883
|
+
showColumnVisibility ? /* @__PURE__ */ jsxDEV16(DataTableViewOptions, {
|
|
2884
|
+
messages: labels2,
|
|
2885
|
+
table
|
|
2886
|
+
}, undefined, false, undefined, this) : null,
|
|
2887
|
+
onRefresh ? /* @__PURE__ */ jsxDEV16(Button, {
|
|
2888
|
+
"aria-label": labels2.refresh,
|
|
2889
|
+
className: "h-9",
|
|
2890
|
+
onClick: () => {
|
|
2891
|
+
setRefreshSpinCount((count) => count + 1);
|
|
2892
|
+
onRefresh();
|
|
2893
|
+
},
|
|
2894
|
+
size: "sm",
|
|
2895
|
+
type: "button",
|
|
2896
|
+
variant: "outline",
|
|
2897
|
+
children: [
|
|
2898
|
+
/* @__PURE__ */ jsxDEV16(RefreshCw, {
|
|
2899
|
+
className: cn(refreshSpinCount > 0 && "animate-[spin_500ms_ease-in-out_1]")
|
|
2900
|
+
}, refreshSpinCount, false, undefined, this),
|
|
2901
|
+
/* @__PURE__ */ jsxDEV16("span", {
|
|
2902
|
+
className: "hidden sm:inline",
|
|
2903
|
+
children: labels2.refresh
|
|
2904
|
+
}, undefined, false, undefined, this)
|
|
2905
|
+
]
|
|
2906
|
+
}, undefined, true, undefined, this) : null,
|
|
2907
|
+
showExport ? /* @__PURE__ */ jsxDEV16(DropdownMenu, {
|
|
2908
|
+
children: [
|
|
2909
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuTrigger, {
|
|
2910
|
+
render: /* @__PURE__ */ jsxDEV16(Button, {
|
|
2911
|
+
"aria-label": labels2.export,
|
|
2912
|
+
className: "h-9",
|
|
2913
|
+
disabled: !hasExportableRows,
|
|
2914
|
+
size: "sm",
|
|
2915
|
+
variant: "outline",
|
|
2916
|
+
children: [
|
|
2917
|
+
/* @__PURE__ */ jsxDEV16(Download, {}, undefined, false, undefined, this),
|
|
2918
|
+
/* @__PURE__ */ jsxDEV16("span", {
|
|
2919
|
+
className: "hidden sm:inline",
|
|
2920
|
+
children: labels2.export
|
|
2921
|
+
}, undefined, false, undefined, this)
|
|
2922
|
+
]
|
|
2923
|
+
}, undefined, true, undefined, this)
|
|
2924
|
+
}, undefined, false, undefined, this),
|
|
2925
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuContent, {
|
|
2926
|
+
align: "end",
|
|
2927
|
+
className: "w-[180px]",
|
|
2928
|
+
children: /* @__PURE__ */ jsxDEV16(DropdownMenuGroup, {
|
|
2929
|
+
children: [
|
|
2930
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuLabel, {
|
|
2931
|
+
children: labels2.export
|
|
2932
|
+
}, undefined, false, undefined, this),
|
|
2933
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuSeparator, {}, undefined, false, undefined, this),
|
|
2934
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuItem, {
|
|
2935
|
+
onClick: () => exportTableToCsv(table, exportRows, exportBaseName),
|
|
2936
|
+
children: [
|
|
2937
|
+
/* @__PURE__ */ jsxDEV16(FileText, {}, undefined, false, undefined, this),
|
|
2938
|
+
labels2.exportCsv
|
|
2939
|
+
]
|
|
2940
|
+
}, undefined, true, undefined, this),
|
|
2941
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuItem, {
|
|
2942
|
+
onClick: () => exportTableToJson(table, exportRows, exportBaseName),
|
|
2943
|
+
children: [
|
|
2944
|
+
/* @__PURE__ */ jsxDEV16(FileJson, {}, undefined, false, undefined, this),
|
|
2945
|
+
labels2.exportJson
|
|
2946
|
+
]
|
|
2947
|
+
}, undefined, true, undefined, this)
|
|
2948
|
+
]
|
|
2949
|
+
}, undefined, true, undefined, this)
|
|
2950
|
+
}, undefined, false, undefined, this)
|
|
2951
|
+
]
|
|
2952
|
+
}, undefined, true, undefined, this) : null
|
|
2953
|
+
]
|
|
2954
|
+
}, undefined, true, undefined, this)
|
|
2955
|
+
]
|
|
2956
|
+
}, undefined, true, undefined, this)
|
|
2957
|
+
}, undefined, false, undefined, this) : null,
|
|
2958
|
+
/* @__PURE__ */ jsxDEV16(DndContext, {
|
|
2959
|
+
onDragCancel: () => setActiveDragLabel(null),
|
|
2960
|
+
onDragEnd: ({ active, over }) => {
|
|
2961
|
+
setActiveDragLabel(null);
|
|
2962
|
+
if (!over) {
|
|
2963
|
+
return;
|
|
2964
|
+
}
|
|
2965
|
+
const dragType = active.data.current?.type;
|
|
2966
|
+
if (dragType === "row-reorder" && reordering && canReorderRows) {
|
|
2967
|
+
const sourceRowId = String(active.id).replace(/^sortable-row:/, "");
|
|
2968
|
+
const targetRowId = String(over.id).replace(/^sortable-row:/, "");
|
|
2969
|
+
if (sourceRowId === targetRowId) {
|
|
2970
|
+
return;
|
|
2971
|
+
}
|
|
2972
|
+
const currentIndex = bodyRows.findIndex((row2) => row2.id === sourceRowId);
|
|
2973
|
+
const nextIndex = bodyRows.findIndex((row2) => row2.id === targetRowId);
|
|
2974
|
+
if (currentIndex === -1 || nextIndex === -1) {
|
|
2975
|
+
return;
|
|
2976
|
+
}
|
|
2977
|
+
const rows = bodyRows.map((row2) => row2.original);
|
|
2978
|
+
const [rowToMove] = rows.splice(currentIndex, 1);
|
|
2979
|
+
if (!rowToMove)
|
|
2980
|
+
return;
|
|
2981
|
+
rows.splice(nextIndex, 0, rowToMove);
|
|
2982
|
+
reordering.onReorder(rows);
|
|
2983
|
+
return;
|
|
2984
|
+
}
|
|
2985
|
+
if (dragType !== "row" || over.data.current?.type !== "group-target") {
|
|
2986
|
+
return;
|
|
2987
|
+
}
|
|
2988
|
+
const row = active.data.current?.row;
|
|
2989
|
+
const field = grouping?.fields.find((currentField) => currentField.id === over.data.current?.fieldId);
|
|
2990
|
+
const nextGroupId = String(over.data.current?.groupId ?? "");
|
|
2991
|
+
if (!row || !field?.onMoveToGroup) {
|
|
2992
|
+
return;
|
|
2993
|
+
}
|
|
2994
|
+
const currentGroupId = field.getGroupId(row);
|
|
2995
|
+
if (currentGroupId === nextGroupId) {
|
|
2996
|
+
return;
|
|
2997
|
+
}
|
|
2998
|
+
field.onMoveToGroup(row, nextGroupId);
|
|
2999
|
+
},
|
|
3000
|
+
onDragStart: ({ active }) => {
|
|
3001
|
+
const label = active.data.current?.label;
|
|
3002
|
+
const dragType = active.data.current?.type;
|
|
3003
|
+
setActiveDragLabel(dragType === "row" && typeof label === "string" ? label : null);
|
|
3004
|
+
},
|
|
3005
|
+
sensors,
|
|
3006
|
+
children: /* @__PURE__ */ jsxDEV16(DataTableViewContext.Provider, {
|
|
3007
|
+
value: currentView,
|
|
3008
|
+
children: [
|
|
3009
|
+
isGalleryView ? hasActiveGrouping ? groupedSections.length > 0 ? /* @__PURE__ */ jsxDEV16("div", {
|
|
3010
|
+
className: "space-y-4",
|
|
3011
|
+
children: renderGroupedGallerySections(groupedSections)
|
|
3012
|
+
}, undefined, false, undefined, this) : renderGalleryEmptyState() : bodyRows.length > 0 ? renderGalleryRows(bodyRows, false) : renderGalleryEmptyState() : /* @__PURE__ */ jsxDEV16(ScrollArea, {
|
|
3013
|
+
className: "-m-1 max-w-full min-w-0",
|
|
3014
|
+
children: [
|
|
3015
|
+
/* @__PURE__ */ jsxDEV16("div", {
|
|
3016
|
+
className: "max-w-full min-w-0 p-1",
|
|
3017
|
+
children: /* @__PURE__ */ jsxDEV16(Table, {
|
|
3018
|
+
className: "table-fixed",
|
|
3019
|
+
style: {
|
|
3020
|
+
width: `max(100%, ${table.getTotalSize() + (canReorderRows ? 40 : 0)}px)`
|
|
3021
|
+
},
|
|
3022
|
+
children: [
|
|
3023
|
+
/* @__PURE__ */ jsxDEV16(TableHeader, {
|
|
3024
|
+
children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsxDEV16(TableRow, {
|
|
3025
|
+
className: "p-4",
|
|
3026
|
+
children: [
|
|
3027
|
+
canReorderRows ? /* @__PURE__ */ jsxDEV16(TableHead, {
|
|
3028
|
+
className: "w-10 min-w-10 p-0"
|
|
3029
|
+
}, undefined, false, undefined, this) : null,
|
|
3030
|
+
headerGroup.headers.map((header) => {
|
|
3031
|
+
return /* @__PURE__ */ jsxDEV16(TableHead, {
|
|
3032
|
+
className: "relative h-12 min-w-32 p-0",
|
|
3033
|
+
style: { width: header.getSize() },
|
|
3034
|
+
children: [
|
|
3035
|
+
renderHeader(header),
|
|
3036
|
+
header.column.getCanResize() ? /* @__PURE__ */ jsxDEV16("button", {
|
|
3037
|
+
"aria-label": labels2.resizeColumn(getHeaderName(header)),
|
|
3038
|
+
className: cn("hover:bg-primary/60 absolute inset-y-0 right-0 z-10 w-1 cursor-col-resize touch-none bg-transparent p-0 select-none", header.column.getIsResizing() && "bg-primary"),
|
|
3039
|
+
type: "button",
|
|
3040
|
+
onDoubleClick: () => header.column.resetSize(),
|
|
3041
|
+
onMouseDown: header.getResizeHandler(),
|
|
3042
|
+
onTouchStart: header.getResizeHandler()
|
|
3043
|
+
}, undefined, false, undefined, this) : null
|
|
3044
|
+
]
|
|
3045
|
+
}, header.id, true, undefined, this);
|
|
3046
|
+
}),
|
|
3047
|
+
rowActions ? /* @__PURE__ */ jsxDEV16(TableHead, {
|
|
3048
|
+
className: "sticky right-0 z-20 w-0 min-w-0 p-0"
|
|
3049
|
+
}, undefined, false, undefined, this) : null
|
|
3050
|
+
]
|
|
3051
|
+
}, headerGroup.id, true, undefined, this))
|
|
3052
|
+
}, undefined, false, undefined, this),
|
|
3053
|
+
hasActiveGrouping ? groupedSections.length > 0 ? renderGroupedTableSections(groupedSections) : /* @__PURE__ */ jsxDEV16(TableBody, {
|
|
3054
|
+
className: "px-2",
|
|
3055
|
+
children: renderTableEmptyState()
|
|
3056
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV16(TableBody, {
|
|
3057
|
+
className: "px-2",
|
|
3058
|
+
children: bodyRows.length > 0 ? canReorderRows ? /* @__PURE__ */ jsxDEV16(SortableContext, {
|
|
3059
|
+
items: sortableRowIds,
|
|
3060
|
+
strategy: verticalListSortingStrategy,
|
|
3061
|
+
children: bodyRows.map((row) => /* @__PURE__ */ jsxDEV16(DataTableRow, {
|
|
3062
|
+
canDrag: false,
|
|
3063
|
+
canReorder: true,
|
|
3064
|
+
dragLabel: reordering?.getRowLabel?.(row.original),
|
|
3065
|
+
onRowClick,
|
|
3066
|
+
reorderHandleLabel: reordering?.handleLabel ?? labels2.reorder,
|
|
3067
|
+
row,
|
|
3068
|
+
rowActions,
|
|
3069
|
+
rowActionsLabel
|
|
3070
|
+
}, row.id, false, undefined, this))
|
|
3071
|
+
}, undefined, false, undefined, this) : bodyRows.map((row) => /* @__PURE__ */ jsxDEV16(DataTableRow, {
|
|
3072
|
+
canDrag: false,
|
|
3073
|
+
canReorder: false,
|
|
3074
|
+
onRowClick,
|
|
3075
|
+
row,
|
|
3076
|
+
rowActions,
|
|
3077
|
+
rowActionsLabel
|
|
3078
|
+
}, row.id, false, undefined, this)) : renderTableEmptyState()
|
|
3079
|
+
}, undefined, false, undefined, this)
|
|
3080
|
+
]
|
|
3081
|
+
}, undefined, true, undefined, this)
|
|
3082
|
+
}, undefined, false, undefined, this),
|
|
3083
|
+
/* @__PURE__ */ jsxDEV16(ScrollBar, {
|
|
3084
|
+
orientation: "horizontal"
|
|
3085
|
+
}, undefined, false, undefined, this)
|
|
3086
|
+
]
|
|
3087
|
+
}, undefined, true, undefined, this),
|
|
3088
|
+
/* @__PURE__ */ jsxDEV16(DragOverlay, {
|
|
3089
|
+
modifiers: [snapDragOverlayVerticalCenterToCursor],
|
|
3090
|
+
children: activeDragLabel ? /* @__PURE__ */ jsxDEV16("div", {
|
|
3091
|
+
className: "bg-background rounded-md border px-3 py-2 text-sm shadow-sm",
|
|
3092
|
+
children: activeDragLabel
|
|
3093
|
+
}, undefined, false, undefined, this) : null
|
|
3094
|
+
}, undefined, false, undefined, this)
|
|
3095
|
+
]
|
|
3096
|
+
}, undefined, true, undefined, this)
|
|
3097
|
+
}, undefined, false, undefined, this),
|
|
3098
|
+
showPagination && !hasActiveGrouping && /* @__PURE__ */ jsxDEV16("div", {
|
|
3099
|
+
className: "p-2",
|
|
3100
|
+
children: /* @__PURE__ */ jsxDEV16(DataTablePagination, {
|
|
3101
|
+
messages: labels2,
|
|
3102
|
+
pageSizes,
|
|
3103
|
+
rowCount: serverRowCount,
|
|
3104
|
+
table
|
|
3105
|
+
}, undefined, false, undefined, this)
|
|
3106
|
+
}, undefined, false, undefined, this)
|
|
3107
|
+
]
|
|
3108
|
+
}, undefined, true, undefined, this);
|
|
3109
|
+
}
|
|
3110
|
+
function DataTableDisplayModeSwitch({
|
|
3111
|
+
messages: messages4,
|
|
3112
|
+
value,
|
|
3113
|
+
onChange
|
|
3114
|
+
}) {
|
|
3115
|
+
return /* @__PURE__ */ jsxDEV16(DropdownMenu, {
|
|
3116
|
+
children: [
|
|
3117
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuTrigger, {
|
|
3118
|
+
render: /* @__PURE__ */ jsxDEV16(Button, {
|
|
3119
|
+
"aria-label": messages4.view,
|
|
3120
|
+
className: "h-9",
|
|
3121
|
+
size: "sm",
|
|
3122
|
+
variant: "outline",
|
|
3123
|
+
children: [
|
|
3124
|
+
value === "gallery" ? /* @__PURE__ */ jsxDEV16(LayoutGrid, {}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV16(Rows3, {}, undefined, false, undefined, this),
|
|
3125
|
+
/* @__PURE__ */ jsxDEV16("span", {
|
|
3126
|
+
className: "hidden sm:inline",
|
|
3127
|
+
children: messages4.view
|
|
3128
|
+
}, undefined, false, undefined, this)
|
|
3129
|
+
]
|
|
3130
|
+
}, undefined, true, undefined, this)
|
|
3131
|
+
}, undefined, false, undefined, this),
|
|
3132
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuContent, {
|
|
3133
|
+
align: "end",
|
|
3134
|
+
className: "w-[160px]",
|
|
3135
|
+
children: /* @__PURE__ */ jsxDEV16(DropdownMenuRadioGroup, {
|
|
3136
|
+
value,
|
|
3137
|
+
onValueChange: (v) => onChange(v),
|
|
3138
|
+
children: [
|
|
3139
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuRadioItem, {
|
|
3140
|
+
value: "table",
|
|
3141
|
+
children: [
|
|
3142
|
+
/* @__PURE__ */ jsxDEV16(Rows3, {}, undefined, false, undefined, this),
|
|
3143
|
+
messages4.tableView
|
|
3144
|
+
]
|
|
3145
|
+
}, undefined, true, undefined, this),
|
|
3146
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuRadioItem, {
|
|
3147
|
+
value: "gallery",
|
|
3148
|
+
children: [
|
|
3149
|
+
/* @__PURE__ */ jsxDEV16(LayoutGrid, {}, undefined, false, undefined, this),
|
|
3150
|
+
messages4.galleryView
|
|
3151
|
+
]
|
|
3152
|
+
}, undefined, true, undefined, this)
|
|
3153
|
+
]
|
|
3154
|
+
}, undefined, true, undefined, this)
|
|
3155
|
+
}, undefined, false, undefined, this)
|
|
3156
|
+
]
|
|
3157
|
+
}, undefined, true, undefined, this);
|
|
3158
|
+
}
|
|
3159
|
+
function DataTableSortDropdown({
|
|
3160
|
+
messages: messages4,
|
|
3161
|
+
table
|
|
3162
|
+
}) {
|
|
3163
|
+
const sorting = table.getState().sorting;
|
|
3164
|
+
const sortableColumns = table.getAllColumns().filter((column) => column.getCanSort());
|
|
3165
|
+
const columnLabels = useMemo(() => new Map(table.getFlatHeaders().map((header) => [header.column.id, getHeaderName(header)])), [table]);
|
|
3166
|
+
if (sortableColumns.length === 0) {
|
|
3167
|
+
return null;
|
|
3168
|
+
}
|
|
3169
|
+
const activeSortColumn = sorting.length > 0 ? sorting[0] : null;
|
|
3170
|
+
return /* @__PURE__ */ jsxDEV16(DropdownMenu, {
|
|
3171
|
+
children: [
|
|
3172
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuTrigger, {
|
|
3173
|
+
render: /* @__PURE__ */ jsxDEV16(Button, {
|
|
3174
|
+
"aria-label": messages4.sortBy,
|
|
3175
|
+
className: "h-9",
|
|
3176
|
+
size: "sm",
|
|
3177
|
+
variant: "outline",
|
|
3178
|
+
children: [
|
|
3179
|
+
activeSortColumn ? activeSortColumn.desc ? /* @__PURE__ */ jsxDEV16(ArrowDown, {}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV16(ArrowUp, {}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV16(ChevronsUpDown2, {}, undefined, false, undefined, this),
|
|
3180
|
+
/* @__PURE__ */ jsxDEV16("span", {
|
|
3181
|
+
className: "hidden sm:inline",
|
|
3182
|
+
children: messages4.sortBy
|
|
3183
|
+
}, undefined, false, undefined, this)
|
|
3184
|
+
]
|
|
3185
|
+
}, undefined, true, undefined, this)
|
|
3186
|
+
}, undefined, false, undefined, this),
|
|
3187
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuContent, {
|
|
3188
|
+
align: "end",
|
|
3189
|
+
className: "w-[200px]",
|
|
3190
|
+
children: /* @__PURE__ */ jsxDEV16(DropdownMenuGroup, {
|
|
3191
|
+
children: [
|
|
3192
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuLabel, {
|
|
3193
|
+
children: messages4.sortBy
|
|
3194
|
+
}, undefined, false, undefined, this),
|
|
3195
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuSeparator, {}, undefined, false, undefined, this),
|
|
3196
|
+
sortableColumns.map((column) => {
|
|
3197
|
+
const sortState = sorting.find((s) => s.id === column.id);
|
|
3198
|
+
const label = columnLabels.get(column.id) ?? column.id;
|
|
3199
|
+
return /* @__PURE__ */ jsxDEV16(DropdownMenuSub, {
|
|
3200
|
+
children: [
|
|
3201
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuSubTrigger, {
|
|
3202
|
+
inset: !!sortState,
|
|
3203
|
+
children: [
|
|
3204
|
+
sortState ? /* @__PURE__ */ jsxDEV16("span", {
|
|
3205
|
+
className: "pointer-events-none absolute left-3 flex size-4 items-center justify-center",
|
|
3206
|
+
children: sortState.desc ? /* @__PURE__ */ jsxDEV16(ArrowDown, {}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV16(ArrowUp, {}, undefined, false, undefined, this)
|
|
3207
|
+
}, undefined, false, undefined, this) : null,
|
|
3208
|
+
label
|
|
3209
|
+
]
|
|
3210
|
+
}, undefined, true, undefined, this),
|
|
3211
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuSubContent, {
|
|
3212
|
+
children: [
|
|
3213
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuItem, {
|
|
3214
|
+
onClick: () => column.toggleSorting(false),
|
|
3215
|
+
children: [
|
|
3216
|
+
/* @__PURE__ */ jsxDEV16(ArrowUp, {}, undefined, false, undefined, this),
|
|
3217
|
+
messages4.sortAsc
|
|
3218
|
+
]
|
|
3219
|
+
}, undefined, true, undefined, this),
|
|
3220
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuItem, {
|
|
3221
|
+
onClick: () => column.toggleSorting(true),
|
|
3222
|
+
children: [
|
|
3223
|
+
/* @__PURE__ */ jsxDEV16(ArrowDown, {}, undefined, false, undefined, this),
|
|
3224
|
+
messages4.sortDesc
|
|
3225
|
+
]
|
|
3226
|
+
}, undefined, true, undefined, this),
|
|
3227
|
+
sortState && /* @__PURE__ */ jsxDEV16(Fragment, {
|
|
3228
|
+
children: [
|
|
3229
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuSeparator, {}, undefined, false, undefined, this),
|
|
3230
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuItem, {
|
|
3231
|
+
onClick: () => column.clearSorting(),
|
|
3232
|
+
children: messages4.sortClear
|
|
3233
|
+
}, undefined, false, undefined, this)
|
|
3234
|
+
]
|
|
3235
|
+
}, undefined, true, undefined, this)
|
|
3236
|
+
]
|
|
3237
|
+
}, undefined, true, undefined, this)
|
|
3238
|
+
]
|
|
3239
|
+
}, column.id, true, undefined, this);
|
|
3240
|
+
})
|
|
3241
|
+
]
|
|
3242
|
+
}, undefined, true, undefined, this)
|
|
3243
|
+
}, undefined, false, undefined, this)
|
|
3244
|
+
]
|
|
3245
|
+
}, undefined, true, undefined, this);
|
|
3246
|
+
}
|
|
3247
|
+
function DataTableViewOptions({
|
|
3248
|
+
messages: messages4,
|
|
3249
|
+
table
|
|
3250
|
+
}) {
|
|
3251
|
+
const columnLabels = useMemo(() => new Map(table.getFlatHeaders().map((header) => [header.column.id, getHeaderName(header)])), [table]);
|
|
3252
|
+
const columns = table.getAllColumns().filter((column) => typeof column.accessorFn !== "undefined" && column.getCanHide());
|
|
3253
|
+
if (columns.length === 0) {
|
|
3254
|
+
return null;
|
|
3255
|
+
}
|
|
3256
|
+
return /* @__PURE__ */ jsxDEV16(DropdownMenu, {
|
|
3257
|
+
children: [
|
|
3258
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuTrigger, {
|
|
3259
|
+
render: /* @__PURE__ */ jsxDEV16(Button, {
|
|
3260
|
+
"aria-label": messages4.columns,
|
|
3261
|
+
className: "h-9",
|
|
3262
|
+
size: "sm",
|
|
3263
|
+
variant: "outline",
|
|
3264
|
+
children: [
|
|
3265
|
+
/* @__PURE__ */ jsxDEV16(Settings2, {}, undefined, false, undefined, this),
|
|
3266
|
+
/* @__PURE__ */ jsxDEV16("span", {
|
|
3267
|
+
className: "hidden sm:inline",
|
|
3268
|
+
children: messages4.columns
|
|
3269
|
+
}, undefined, false, undefined, this)
|
|
3270
|
+
]
|
|
3271
|
+
}, undefined, true, undefined, this)
|
|
3272
|
+
}, undefined, false, undefined, this),
|
|
3273
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuContent, {
|
|
3274
|
+
align: "end",
|
|
3275
|
+
className: "w-[180px]",
|
|
3276
|
+
children: /* @__PURE__ */ jsxDEV16(DropdownMenuGroup, {
|
|
3277
|
+
children: [
|
|
3278
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuLabel, {
|
|
3279
|
+
children: messages4.columns
|
|
3280
|
+
}, undefined, false, undefined, this),
|
|
3281
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuSeparator, {}, undefined, false, undefined, this),
|
|
3282
|
+
columns.map((column) => /* @__PURE__ */ jsxDEV16(DropdownMenuCheckboxItem, {
|
|
3283
|
+
checked: column.getIsVisible(),
|
|
3284
|
+
className: "capitalize",
|
|
3285
|
+
onCheckedChange: (value) => column.toggleVisibility(!!value),
|
|
3286
|
+
children: columnLabels.get(column.id) ?? column.id
|
|
3287
|
+
}, column.id, false, undefined, this))
|
|
3288
|
+
]
|
|
3289
|
+
}, undefined, true, undefined, this)
|
|
3290
|
+
}, undefined, false, undefined, this)
|
|
3291
|
+
]
|
|
3292
|
+
}, undefined, true, undefined, this);
|
|
3293
|
+
}
|
|
3294
|
+
function DataTablePagination({
|
|
3295
|
+
messages: messages4,
|
|
3296
|
+
pageSizes = [10, 20, 30, 40, 50],
|
|
3297
|
+
rowCount,
|
|
3298
|
+
table
|
|
3299
|
+
}) {
|
|
3300
|
+
const labels2 = dataTableMessages(messages4);
|
|
3301
|
+
const selectedRows = table.getFilteredSelectedRowModel().rows.length;
|
|
3302
|
+
const filteredRows = table.getFilteredRowModel().rows.length;
|
|
3303
|
+
const totalRows = rowCount ?? filteredRows;
|
|
3304
|
+
return /* @__PURE__ */ jsxDEV16(Pagination, {
|
|
3305
|
+
messages: {
|
|
3306
|
+
pageSize: labels2.pageSize,
|
|
3307
|
+
results: labels2.results,
|
|
3308
|
+
selectedOf: labels2.selectedOf,
|
|
3309
|
+
pageOf: labels2.pageOf,
|
|
3310
|
+
goToFirstPage: labels2.goToFirstPage,
|
|
3311
|
+
goToPreviousPage: labels2.goToPreviousPage,
|
|
3312
|
+
goToNextPage: labels2.goToNextPage,
|
|
3313
|
+
goToLastPage: labels2.goToLastPage
|
|
3314
|
+
},
|
|
3315
|
+
onPageChange: (page) => table.setPageIndex(page),
|
|
3316
|
+
onPageSizeChange: (pageSize) => table.setPageSize(pageSize),
|
|
3317
|
+
page: table.getState().pagination.pageIndex,
|
|
3318
|
+
pageCount: table.getPageCount(),
|
|
3319
|
+
pageSize: table.getState().pagination.pageSize,
|
|
3320
|
+
pageSizes,
|
|
3321
|
+
selectedRows,
|
|
3322
|
+
totalRows
|
|
3323
|
+
}, undefined, false, undefined, this);
|
|
3324
|
+
}
|
|
3325
|
+
function DataTableRelationshipCell({
|
|
3326
|
+
emptyLabel,
|
|
3327
|
+
manageLabel,
|
|
3328
|
+
onAdd,
|
|
3329
|
+
onRemove,
|
|
3330
|
+
options,
|
|
3331
|
+
value
|
|
3332
|
+
}) {
|
|
3333
|
+
const [selectedOptions, setSelectedOptions] = useState(() => [...value]);
|
|
3334
|
+
const selectedValues = new Set(selectedOptions.map(({ value: value2 }) => value2));
|
|
3335
|
+
const orderedOptions = [...options].sort((a, b) => Number(selectedValues.has(b.value)) - Number(selectedValues.has(a.value)));
|
|
3336
|
+
useEffect(() => {
|
|
3337
|
+
setSelectedOptions([...value]);
|
|
3338
|
+
}, [value]);
|
|
3339
|
+
return /* @__PURE__ */ jsxDEV16(VirtualizedCombobox, {
|
|
3340
|
+
ariaLabel: manageLabel,
|
|
3341
|
+
emptyLabel,
|
|
3342
|
+
items: orderedOptions,
|
|
3343
|
+
messages: { search: manageLabel },
|
|
3344
|
+
multiple: true,
|
|
3345
|
+
onValueChange: (nextOptions) => {
|
|
3346
|
+
const nextValues = new Set(nextOptions.map(({ value: value2 }) => value2));
|
|
3347
|
+
for (const option of selectedOptions) {
|
|
3348
|
+
if (!nextValues.has(option.value))
|
|
3349
|
+
onRemove?.(option.value);
|
|
3350
|
+
}
|
|
3351
|
+
for (const option of nextOptions) {
|
|
3352
|
+
if (!selectedValues.has(option.value))
|
|
3353
|
+
onAdd?.(option.value);
|
|
3354
|
+
}
|
|
3355
|
+
setSelectedOptions(nextOptions);
|
|
3356
|
+
},
|
|
3357
|
+
placeholder: emptyLabel,
|
|
3358
|
+
trigger: /* @__PURE__ */ jsxDEV16(Button, {
|
|
3359
|
+
"aria-label": manageLabel,
|
|
3360
|
+
className: "h-full min-h-16 w-full min-w-0 justify-between gap-2 overflow-hidden rounded-none px-2 py-2 text-left font-normal",
|
|
3361
|
+
"data-slot": "relationship-cell",
|
|
3362
|
+
type: "button",
|
|
3363
|
+
variant: "ghost",
|
|
3364
|
+
children: [
|
|
3365
|
+
/* @__PURE__ */ jsxDEV16(DataTableListSummary, {
|
|
3366
|
+
emptyLabel,
|
|
3367
|
+
expandable: false,
|
|
3368
|
+
items: selectedOptions,
|
|
3369
|
+
variant: selectedOptions.some(({ icon }) => icon) ? "icon" : "text"
|
|
3370
|
+
}, undefined, false, undefined, this),
|
|
3371
|
+
/* @__PURE__ */ jsxDEV16(ChevronDown, {
|
|
3372
|
+
className: "text-muted-foreground size-4 shrink-0"
|
|
3373
|
+
}, undefined, false, undefined, this)
|
|
3374
|
+
]
|
|
3375
|
+
}, undefined, true, undefined, this),
|
|
3376
|
+
value: selectedOptions
|
|
3377
|
+
}, undefined, false, undefined, this);
|
|
3378
|
+
}
|
|
3379
|
+
function DataTableListSummary({
|
|
3380
|
+
emptyLabel,
|
|
3381
|
+
expandable = true,
|
|
3382
|
+
items,
|
|
3383
|
+
overflowLabel,
|
|
3384
|
+
totalCount = items.length,
|
|
3385
|
+
variant = "text",
|
|
3386
|
+
visibleCount = 3
|
|
3387
|
+
}) {
|
|
3388
|
+
const labels2 = dataTableMessages();
|
|
3389
|
+
const normalizedItems = items.map((item) => typeof item === "string" ? { label: item } : item);
|
|
3390
|
+
const visibleItems = normalizedItems.slice(0, visibleCount);
|
|
3391
|
+
const visibleLabels = visibleItems.map(({ label }) => label).join(", ");
|
|
3392
|
+
const remaining = Math.max(totalCount - visibleItems.length, 0);
|
|
3393
|
+
const remainingLabel = overflowLabel?.(remaining) ?? labels2.listOthers(remaining);
|
|
3394
|
+
const expandedItems = /* @__PURE__ */ jsxDEV16(PopoverContent, {
|
|
3395
|
+
align: "start",
|
|
3396
|
+
className: "max-h-72 w-72 overflow-y-auto p-2",
|
|
3397
|
+
onClick: (event) => event.stopPropagation(),
|
|
3398
|
+
children: /* @__PURE__ */ jsxDEV16("ul", {
|
|
3399
|
+
className: "grid gap-1",
|
|
3400
|
+
children: normalizedItems.map((item, index) => /* @__PURE__ */ jsxDEV16("li", {
|
|
3401
|
+
className: "flex items-center gap-2 rounded-sm px-2 py-1.5 break-words",
|
|
3402
|
+
children: [
|
|
3403
|
+
item.icon ? /* @__PURE__ */ jsxDEV16("span", {
|
|
3404
|
+
className: "bg-muted flex size-6 shrink-0 items-center justify-center overflow-hidden rounded-full text-[9px] font-semibold",
|
|
3405
|
+
children: item.icon
|
|
3406
|
+
}, undefined, false, undefined, this) : null,
|
|
3407
|
+
/* @__PURE__ */ jsxDEV16("span", {
|
|
3408
|
+
className: "min-w-0",
|
|
3409
|
+
children: item.label
|
|
3410
|
+
}, undefined, false, undefined, this)
|
|
3411
|
+
]
|
|
3412
|
+
}, item.value ?? `${item.label}-${index}`, true, undefined, this))
|
|
3413
|
+
}, undefined, false, undefined, this)
|
|
3414
|
+
}, undefined, false, undefined, this);
|
|
3415
|
+
if (normalizedItems.length === 0) {
|
|
3416
|
+
return /* @__PURE__ */ jsxDEV16("span", {
|
|
3417
|
+
className: "text-muted-foreground text-sm",
|
|
3418
|
+
children: emptyLabel
|
|
3419
|
+
}, undefined, false, undefined, this);
|
|
3420
|
+
}
|
|
3421
|
+
if (variant === "icon") {
|
|
3422
|
+
return /* @__PURE__ */ jsxDEV16(TooltipProvider, {
|
|
3423
|
+
children: /* @__PURE__ */ jsxDEV16("span", {
|
|
3424
|
+
className: "flex min-w-0 items-center pl-2",
|
|
3425
|
+
children: [
|
|
3426
|
+
visibleItems.map((item, index) => /* @__PURE__ */ jsxDEV16(Tooltip, {
|
|
3427
|
+
children: [
|
|
3428
|
+
/* @__PURE__ */ jsxDEV16(TooltipTrigger, {
|
|
3429
|
+
render: /* @__PURE__ */ jsxDEV16("span", {
|
|
3430
|
+
"aria-label": item.label,
|
|
3431
|
+
className: "bg-muted border-background relative flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-full border-2 text-[10px] font-semibold",
|
|
3432
|
+
style: { marginLeft: index ? -8 : 0 },
|
|
3433
|
+
children: item.icon ?? item.label.slice(0, 2).toUpperCase()
|
|
3434
|
+
}, undefined, false, undefined, this)
|
|
3435
|
+
}, undefined, false, undefined, this),
|
|
3436
|
+
/* @__PURE__ */ jsxDEV16(TooltipContent, {
|
|
3437
|
+
children: item.label
|
|
3438
|
+
}, undefined, false, undefined, this)
|
|
3439
|
+
]
|
|
3440
|
+
}, item.value ?? item.label, true, undefined, this)),
|
|
3441
|
+
remaining ? expandable ? /* @__PURE__ */ jsxDEV16(Popover, {
|
|
3442
|
+
children: [
|
|
3443
|
+
/* @__PURE__ */ jsxDEV16(PopoverTrigger, {
|
|
3444
|
+
render: /* @__PURE__ */ jsxDEV16("button", {
|
|
3445
|
+
"aria-label": labels2.listOthers(remaining),
|
|
3446
|
+
className: "bg-muted border-background relative -ml-2 flex size-8 shrink-0 items-center justify-center rounded-full border-2 text-[10px] font-semibold tabular-nums",
|
|
3447
|
+
onClick: (event) => event.stopPropagation(),
|
|
3448
|
+
onPointerDown: (event) => event.stopPropagation(),
|
|
3449
|
+
type: "button",
|
|
3450
|
+
children: [
|
|
3451
|
+
"+",
|
|
3452
|
+
remaining
|
|
3453
|
+
]
|
|
3454
|
+
}, undefined, true, undefined, this)
|
|
3455
|
+
}, undefined, false, undefined, this),
|
|
3456
|
+
expandedItems
|
|
3457
|
+
]
|
|
3458
|
+
}, undefined, true, undefined, this) : /* @__PURE__ */ jsxDEV16("span", {
|
|
3459
|
+
className: "bg-muted border-background relative -ml-2 flex size-8 shrink-0 items-center justify-center rounded-full border-2 text-[10px] font-semibold tabular-nums",
|
|
3460
|
+
children: [
|
|
3461
|
+
"+",
|
|
3462
|
+
remaining
|
|
3463
|
+
]
|
|
3464
|
+
}, undefined, true, undefined, this) : null
|
|
3465
|
+
]
|
|
3466
|
+
}, undefined, true, undefined, this)
|
|
3467
|
+
}, undefined, false, undefined, this);
|
|
3468
|
+
}
|
|
3469
|
+
return remaining > 0 ? /* @__PURE__ */ jsxDEV16("span", {
|
|
3470
|
+
className: "block min-w-0 text-sm whitespace-normal",
|
|
3471
|
+
"data-slot": "list-summary",
|
|
3472
|
+
children: [
|
|
3473
|
+
/* @__PURE__ */ jsxDEV16("span", {
|
|
3474
|
+
children: visibleLabels
|
|
3475
|
+
}, undefined, false, undefined, this),
|
|
3476
|
+
" ",
|
|
3477
|
+
/* @__PURE__ */ jsxDEV16("span", {
|
|
3478
|
+
className: "inline-block whitespace-nowrap",
|
|
3479
|
+
children: expandable ? /* @__PURE__ */ jsxDEV16(Popover, {
|
|
3480
|
+
children: [
|
|
3481
|
+
/* @__PURE__ */ jsxDEV16(PopoverTrigger, {
|
|
3482
|
+
render: /* @__PURE__ */ jsxDEV16("button", {
|
|
3483
|
+
className: "text-muted-foreground hover:text-foreground underline decoration-dotted underline-offset-2",
|
|
3484
|
+
onClick: (event) => event.stopPropagation(),
|
|
3485
|
+
onPointerDown: (event) => event.stopPropagation(),
|
|
3486
|
+
type: "button",
|
|
3487
|
+
children: remainingLabel
|
|
3488
|
+
}, undefined, false, undefined, this)
|
|
3489
|
+
}, undefined, false, undefined, this),
|
|
3490
|
+
expandedItems
|
|
3491
|
+
]
|
|
3492
|
+
}, undefined, true, undefined, this) : remainingLabel
|
|
3493
|
+
}, undefined, false, undefined, this)
|
|
3494
|
+
]
|
|
3495
|
+
}, undefined, true, undefined, this) : /* @__PURE__ */ jsxDEV16("span", {
|
|
3496
|
+
className: "block min-w-0 text-sm",
|
|
3497
|
+
"data-slot": "list-summary",
|
|
3498
|
+
children: visibleLabels
|
|
3499
|
+
}, undefined, false, undefined, this);
|
|
3500
|
+
}
|
|
3501
|
+
function DataTableColumnHeader({
|
|
3502
|
+
column,
|
|
3503
|
+
messages: messages4,
|
|
3504
|
+
title,
|
|
3505
|
+
className
|
|
3506
|
+
}) {
|
|
3507
|
+
const labels2 = dataTableMessages(messages4);
|
|
3508
|
+
const sortDirection = column.getIsSorted();
|
|
3509
|
+
if (!column.getCanSort()) {
|
|
3510
|
+
return /* @__PURE__ */ jsxDEV16("div", {
|
|
3511
|
+
className: cn("flex h-12 items-center truncate px-2 text-sm", className),
|
|
3512
|
+
children: title
|
|
3513
|
+
}, undefined, false, undefined, this);
|
|
3514
|
+
}
|
|
3515
|
+
return /* @__PURE__ */ jsxDEV16("div", {
|
|
3516
|
+
className: cn("flex h-12 items-center", className),
|
|
3517
|
+
children: /* @__PURE__ */ jsxDEV16(DropdownMenu, {
|
|
3518
|
+
children: [
|
|
3519
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuTrigger, {
|
|
3520
|
+
render: /* @__PURE__ */ jsxDEV16(Button, {
|
|
3521
|
+
variant: "ghost",
|
|
3522
|
+
size: "sm",
|
|
3523
|
+
className: "data-[state=open]:bg-accent h-12 w-full justify-start rounded-none px-2",
|
|
3524
|
+
children: [
|
|
3525
|
+
/* @__PURE__ */ jsxDEV16("span", {
|
|
3526
|
+
className: "min-w-0 truncate text-sm",
|
|
3527
|
+
children: title
|
|
3528
|
+
}, undefined, false, undefined, this),
|
|
3529
|
+
sortDirection === "desc" ? /* @__PURE__ */ jsxDEV16(ArrowDown, {}, undefined, false, undefined, this) : sortDirection === "asc" ? /* @__PURE__ */ jsxDEV16(ArrowUp, {}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV16(ChevronsUpDown2, {}, undefined, false, undefined, this)
|
|
3530
|
+
]
|
|
3531
|
+
}, undefined, true, undefined, this)
|
|
3532
|
+
}, undefined, false, undefined, this),
|
|
3533
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuContent, {
|
|
3534
|
+
align: "start",
|
|
3535
|
+
children: /* @__PURE__ */ jsxDEV16(DropdownMenuGroup, {
|
|
3536
|
+
children: [
|
|
3537
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuItem, {
|
|
3538
|
+
onClick: () => column.toggleSorting(false),
|
|
3539
|
+
children: [
|
|
3540
|
+
/* @__PURE__ */ jsxDEV16(ArrowUp, {
|
|
3541
|
+
className: "text-muted-foreground/70 h-3.5 w-3.5"
|
|
3542
|
+
}, undefined, false, undefined, this),
|
|
3543
|
+
labels2.sortAsc
|
|
3544
|
+
]
|
|
3545
|
+
}, undefined, true, undefined, this),
|
|
3546
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuItem, {
|
|
3547
|
+
onClick: () => column.toggleSorting(true),
|
|
3548
|
+
children: [
|
|
3549
|
+
/* @__PURE__ */ jsxDEV16(ArrowDown, {
|
|
3550
|
+
className: "text-muted-foreground/70 h-3.5 w-3.5"
|
|
3551
|
+
}, undefined, false, undefined, this),
|
|
3552
|
+
labels2.sortDesc
|
|
3553
|
+
]
|
|
3554
|
+
}, undefined, true, undefined, this),
|
|
3555
|
+
sortDirection ? /* @__PURE__ */ jsxDEV16(DropdownMenuItem, {
|
|
3556
|
+
onClick: () => column.clearSorting(),
|
|
3557
|
+
children: [
|
|
3558
|
+
/* @__PURE__ */ jsxDEV16(X, {
|
|
3559
|
+
className: "text-muted-foreground/70 h-3.5 w-3.5"
|
|
3560
|
+
}, undefined, false, undefined, this),
|
|
3561
|
+
labels2.sortClear
|
|
3562
|
+
]
|
|
3563
|
+
}, undefined, true, undefined, this) : null,
|
|
3564
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuSeparator, {}, undefined, false, undefined, this),
|
|
3565
|
+
/* @__PURE__ */ jsxDEV16(DropdownMenuItem, {
|
|
3566
|
+
onClick: () => column.toggleVisibility(false),
|
|
3567
|
+
children: [
|
|
3568
|
+
/* @__PURE__ */ jsxDEV16(EyeOff, {
|
|
3569
|
+
className: "text-muted-foreground/70 h-3.5 w-3.5"
|
|
3570
|
+
}, undefined, false, undefined, this),
|
|
3571
|
+
labels2.sortHide
|
|
3572
|
+
]
|
|
3573
|
+
}, undefined, true, undefined, this)
|
|
3574
|
+
]
|
|
3575
|
+
}, undefined, true, undefined, this)
|
|
3576
|
+
}, undefined, false, undefined, this)
|
|
3577
|
+
]
|
|
3578
|
+
}, undefined, true, undefined, this)
|
|
3579
|
+
}, undefined, false, undefined, this);
|
|
3580
|
+
}
|
|
3581
|
+
export {
|
|
3582
|
+
getHeaderNames,
|
|
3583
|
+
downloadJson,
|
|
3584
|
+
downloadCsv,
|
|
3585
|
+
dataTableMessages,
|
|
3586
|
+
TableSearchSchemaStandard,
|
|
3587
|
+
TableSearchSchema,
|
|
3588
|
+
DataTableRowActions,
|
|
3589
|
+
DataTableRelationshipCell,
|
|
3590
|
+
DataTablePagination,
|
|
3591
|
+
DataTableListSummary,
|
|
3592
|
+
DataTableColumnHeader,
|
|
3593
|
+
DataTable
|
|
3594
|
+
};
|