@avenue-ticketing/ui 0.11.0 → 0.12.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -0
- package/dist/badge-types-B67wcd4m.d.ts +22 -0
- package/dist/react/app-store-buttons-outline.d.ts +17 -0
- package/dist/react/app-store-buttons-outline.js +582 -0
- package/dist/react/app-store-buttons-outline.js.map +1 -0
- package/dist/react/app-store-buttons.d.ts +20 -0
- package/dist/react/app-store-buttons.js +817 -0
- package/dist/react/app-store-buttons.js.map +1 -0
- package/dist/react/avatar-label-group.d.ts +14 -0
- package/dist/react/avatar-label-group.js +183 -0
- package/dist/react/avatar-label-group.js.map +1 -0
- package/dist/react/avatar-profile-photo.d.ts +9 -0
- package/dist/react/avatar-profile-photo.js +202 -0
- package/dist/react/avatar-profile-photo.js.map +1 -0
- package/dist/react/avatar.d.ts +66 -40
- package/dist/react/avatar.js +159 -149
- package/dist/react/avatar.js.map +1 -1
- package/dist/react/badge-groups.d.ts +25 -0
- package/dist/react/badge-groups.js +162 -0
- package/dist/react/badge-groups.js.map +1 -0
- package/dist/react/badge.d.ts +123 -59
- package/dist/react/badge.js +314 -86
- package/dist/react/badge.js.map +1 -1
- package/dist/react/button-group.d.ts +43 -0
- package/dist/react/button-group.js +108 -0
- package/dist/react/button-group.js.map +1 -0
- package/dist/react/button-utility.d.ts +47 -0
- package/dist/react/button-utility.js +158 -0
- package/dist/react/button-utility.js.map +1 -0
- package/dist/react/button.d.ts +112 -37
- package/dist/react/button.js +270 -55
- package/dist/react/button.js.map +1 -1
- package/dist/react/checkbox.d.ts +25 -8
- package/dist/react/checkbox.js +112 -110
- package/dist/react/checkbox.js.map +1 -1
- package/dist/react/close-button.d.ts +25 -0
- package/dist/react/close-button.js +54 -0
- package/dist/react/close-button.js.map +1 -0
- package/dist/react/combobox.d.ts +17 -0
- package/dist/react/combobox.js +322 -0
- package/dist/react/combobox.js.map +1 -0
- package/dist/react/dialog.d.ts +15 -15
- package/dist/react/dialog.js +43 -108
- package/dist/react/dialog.js.map +1 -1
- package/dist/react/dropdown-account-breadcrumb.d.ts +5 -0
- package/dist/react/dropdown-account-breadcrumb.js +319 -0
- package/dist/react/dropdown-account-breadcrumb.js.map +1 -0
- package/dist/react/dropdown-account-button.d.ts +5 -0
- package/dist/react/dropdown-account-button.js +773 -0
- package/dist/react/dropdown-account-button.js.map +1 -0
- package/dist/react/dropdown-account-card-md.d.ts +5 -0
- package/dist/react/dropdown-account-card-md.js +549 -0
- package/dist/react/dropdown-account-card-md.js.map +1 -0
- package/dist/react/dropdown-account-card-sm.d.ts +5 -0
- package/dist/react/dropdown-account-card-sm.js +527 -0
- package/dist/react/dropdown-account-card-sm.js.map +1 -0
- package/dist/react/dropdown-account-card-xs.d.ts +5 -0
- package/dist/react/dropdown-account-card-xs.js +507 -0
- package/dist/react/dropdown-account-card-xs.js.map +1 -0
- package/dist/react/dropdown-avatar.d.ts +5 -0
- package/dist/react/dropdown-avatar.js +790 -0
- package/dist/react/dropdown-avatar.js.map +1 -0
- package/dist/react/dropdown-button-advanced.d.ts +5 -0
- package/dist/react/dropdown-button-advanced.js +799 -0
- package/dist/react/dropdown-button-advanced.js.map +1 -0
- package/dist/react/dropdown-button-link.d.ts +5 -0
- package/dist/react/dropdown-button-link.js +501 -0
- package/dist/react/dropdown-button-link.js.map +1 -0
- package/dist/react/dropdown-button-simple.d.ts +5 -0
- package/dist/react/dropdown-button-simple.js +754 -0
- package/dist/react/dropdown-button-simple.js.map +1 -0
- package/dist/react/dropdown-icon-advanced.d.ts +5 -0
- package/dist/react/dropdown-icon-advanced.js +543 -0
- package/dist/react/dropdown-icon-advanced.js.map +1 -0
- package/dist/react/dropdown-icon-simple.d.ts +5 -0
- package/dist/react/dropdown-icon-simple.js +505 -0
- package/dist/react/dropdown-icon-simple.js.map +1 -0
- package/dist/react/dropdown-integration.d.ts +5 -0
- package/dist/react/dropdown-integration.js +1325 -0
- package/dist/react/dropdown-integration.js.map +1 -0
- package/dist/react/dropdown-search-advanced.d.ts +5 -0
- package/dist/react/dropdown-search-advanced.js +998 -0
- package/dist/react/dropdown-search-advanced.js.map +1 -0
- package/dist/react/dropdown-search-simple.d.ts +5 -0
- package/dist/react/dropdown-search-simple.js +960 -0
- package/dist/react/dropdown-search-simple.js.map +1 -0
- package/dist/react/dropdown.d.ts +32 -133
- package/dist/react/dropdown.js +404 -1351
- package/dist/react/dropdown.js.map +1 -1
- package/dist/react/file-upload-trigger.d.ts +34 -0
- package/dist/react/file-upload-trigger.js +39 -0
- package/dist/react/file-upload-trigger.js.map +1 -0
- package/dist/react/form.d.ts +10 -0
- package/dist/react/form.js +11 -0
- package/dist/react/form.js.map +1 -0
- package/dist/react/hint-text.d.ts +17 -0
- package/dist/react/hint-text.js +36 -0
- package/dist/react/hint-text.js.map +1 -0
- package/dist/react/hook-form.d.ts +35 -0
- package/dist/react/hook-form.js +50 -0
- package/dist/react/hook-form.js.map +1 -0
- package/dist/react/input-date.d.ts +43 -0
- package/dist/react/input-date.js +306 -0
- package/dist/react/input-date.js.map +1 -0
- package/dist/react/input-file.d.ts +45 -0
- package/dist/react/input-file.js +748 -0
- package/dist/react/input-file.js.map +1 -0
- package/dist/react/input-group.d.ts +37 -0
- package/dist/react/input-group.js +251 -0
- package/dist/react/input-group.js.map +1 -0
- package/dist/react/input-number.d.ts +32 -0
- package/dist/react/input-number.js +553 -0
- package/dist/react/input-number.js.map +1 -0
- package/dist/react/input-payment.d.ts +16 -0
- package/dist/react/input-payment.js +593 -0
- package/dist/react/input-payment.js.map +1 -0
- package/dist/react/input-tags-outer.d.ts +53 -0
- package/dist/react/input-tags-outer.js +607 -0
- package/dist/react/input-tags-outer.js.map +1 -0
- package/dist/react/input-tags.d.ts +53 -0
- package/dist/react/input-tags.js +565 -0
- package/dist/react/input-tags.js.map +1 -0
- package/dist/react/input.d.ts +71 -22
- package/dist/react/input.js +332 -45
- package/dist/react/input.js.map +1 -1
- package/dist/react/label.d.ts +18 -0
- package/dist/react/label.js +112 -0
- package/dist/react/label.js.map +1 -0
- package/dist/react/multi-select.d.ts +89 -0
- package/dist/react/multi-select.js +1036 -0
- package/dist/react/multi-select.js.map +1 -0
- package/dist/react/pin-input.d.ts +59 -0
- package/dist/react/pin-input.js +229 -0
- package/dist/react/pin-input.js.map +1 -0
- package/dist/react/popover.d.ts +7 -73
- package/dist/react/popover.js +23 -569
- package/dist/react/popover.js.map +1 -1
- package/dist/react/progress-circle.d.ts +9 -0
- package/dist/react/progress-circle.js +36 -0
- package/dist/react/progress-circle.js.map +1 -0
- package/dist/react/progress-circles.d.ts +14 -0
- package/dist/react/progress-circles.js +160 -0
- package/dist/react/progress-circles.js.map +1 -0
- package/dist/react/progress-indicators.d.ts +52 -0
- package/dist/react/progress-indicators.js +78 -0
- package/dist/react/progress-indicators.js.map +1 -0
- package/dist/react/radio-buttons.d.ts +35 -0
- package/dist/react/radio-buttons.js +116 -0
- package/dist/react/radio-buttons.js.map +1 -0
- package/dist/react/scroll-header.d.ts +6 -0
- package/dist/react/scroll-header.js +42 -61
- package/dist/react/scroll-header.js.map +1 -1
- package/dist/react/scroll-wheel.d.ts +4 -5
- package/dist/react/scroll-wheel.js +19 -15
- package/dist/react/scroll-wheel.js.map +1 -1
- package/dist/react/select-item.d.ts +13 -0
- package/dist/react/select-item.js +336 -0
- package/dist/react/select-item.js.map +1 -0
- package/dist/react/select-native.d.ts +17 -0
- package/dist/react/select-native.js +203 -0
- package/dist/react/select-native.js.map +1 -0
- package/dist/react/select.d.ts +18 -61
- package/dist/react/select.js +625 -923
- package/dist/react/select.js.map +1 -1
- package/dist/react/sheet.d.ts +19 -19
- package/dist/react/sheet.js +97 -219
- package/dist/react/sheet.js.map +1 -1
- package/dist/react/slider.d.ts +15 -0
- package/dist/react/slider.js +66 -0
- package/dist/react/slider.js.map +1 -0
- package/dist/react/social-button.d.ts +55 -0
- package/dist/react/social-button.js +263 -0
- package/dist/react/social-button.js.map +1 -0
- package/dist/react/social-logos.d.ts +20 -0
- package/dist/react/social-logos.js +131 -0
- package/dist/react/social-logos.js.map +1 -0
- package/dist/react/switch.d.ts +21 -36
- package/dist/react/switch.js +121 -109
- package/dist/react/switch.js.map +1 -1
- package/dist/react/tag-select.d.ts +44 -0
- package/dist/react/tag-select.js +1062 -0
- package/dist/react/tag-select.js.map +1 -0
- package/dist/react/tags.d.ts +30 -0
- package/dist/react/tags.js +228 -0
- package/dist/react/tags.js.map +1 -0
- package/dist/react/textarea.d.ts +40 -4
- package/dist/react/textarea.js +193 -27
- package/dist/react/textarea.js.map +1 -1
- package/dist/react/tooltip.d.ts +30 -43
- package/dist/react/tooltip.js +65 -521
- package/dist/react/tooltip.js.map +1 -1
- package/dist/select-shared-B3Y5SMXU.d.ts +62 -0
- package/package.json +28 -21
- package/source.css +2 -13
- package/theme.css +883 -79
- package/dist/react/calendar.d.ts +0 -13
- package/dist/react/calendar.js +0 -4639
- package/dist/react/calendar.js.map +0 -1
- package/dist/react/card.d.ts +0 -11
- package/dist/react/card.js +0 -113
- package/dist/react/card.js.map +0 -1
- package/dist/react/datetime-picker.d.ts +0 -21
- package/dist/react/datetime-picker.js +0 -6142
- package/dist/react/datetime-picker.js.map +0 -1
- package/dist/react/pagination.d.ts +0 -28
- package/dist/react/pagination.js +0 -262
- package/dist/react/pagination.js.map +0 -1
- package/dist/react/table-pagination.d.ts +0 -15
- package/dist/react/table-pagination.js +0 -1247
- package/dist/react/table-pagination.js.map +0 -1
- package/dist/react/table-view/column-menu.d.ts +0 -15
- package/dist/react/table-view/column-menu.js +0 -1049
- package/dist/react/table-view/column-menu.js.map +0 -1
- package/dist/react/table-view/index.d.ts +0 -70
- package/dist/react/table-view/index.js +0 -2284
- package/dist/react/table-view/index.js.map +0 -1
- package/dist/react/table.d.ts +0 -86
- package/dist/react/table.js +0 -414
- package/dist/react/table.js.map +0 -1
- package/dist/react/tabs.d.ts +0 -34
- package/dist/react/tabs.js +0 -423
- package/dist/react/tabs.js.map +0 -1
- package/dist/react/time-picker.d.ts +0 -22
- package/dist/react/time-picker.js +0 -856
- package/dist/react/time-picker.js.map +0 -1
|
@@ -1,1247 +0,0 @@
|
|
|
1
|
-
import { ChevronLeft, MoreHorizontal, ChevronRight, X, Loader2, ChevronDown, Check } from 'lucide-react';
|
|
2
|
-
import * as React2 from 'react';
|
|
3
|
-
import { useCallback, useState, useRef, useMemo, useLayoutEffect, useEffect } from 'react';
|
|
4
|
-
import { clsx } from 'clsx';
|
|
5
|
-
import { twMerge } from 'tailwind-merge';
|
|
6
|
-
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
|
-
import { createPortal } from 'react-dom';
|
|
8
|
-
|
|
9
|
-
function cn(...inputs) {
|
|
10
|
-
return twMerge(clsx(inputs));
|
|
11
|
-
}
|
|
12
|
-
var sizeClass = {
|
|
13
|
-
xs: "h-8 min-h-8 gap-2 px-4 text-sm has-[>svg]:px-3 [&_svg:not([class*='size-'])]:size-3",
|
|
14
|
-
default: "h-10 min-h-10 gap-2 px-5 text-sm has-[>svg]:px-4 [&_svg:not([class*='size-'])]:size-4",
|
|
15
|
-
lg: "h-11 min-h-11 gap-2 px-6 text-base has-[>svg]:px-5 [&_svg:not([class*='size-'])]:size-5"
|
|
16
|
-
};
|
|
17
|
-
var iconOnlySizeClass = {
|
|
18
|
-
xs: "size-8 min-h-8 min-w-8 gap-0 p-0 [&_svg:not([class*='size-'])]:size-3",
|
|
19
|
-
default: "size-10 min-h-10 min-w-10 gap-0 p-0 [&_svg:not([class*='size-'])]:size-4",
|
|
20
|
-
lg: "size-11 min-h-11 min-w-11 gap-0 p-0 [&_svg:not([class*='size-'])]:size-5"
|
|
21
|
-
};
|
|
22
|
-
var roundedClass = {
|
|
23
|
-
full: "rounded-full",
|
|
24
|
-
lg: "rounded-lg",
|
|
25
|
-
md: "rounded-md"
|
|
26
|
-
};
|
|
27
|
-
var variantClass = {
|
|
28
|
-
primary: "bg-primary text-background border border-transparent hover:bg-primary/90 active:bg-primary/85",
|
|
29
|
-
secondary: "bg-background text-primary border border-primary/10 hover:bg-primary/5",
|
|
30
|
-
destructive: "bg-background text-red-500 border border-red-500/25 hover:bg-red-500/5",
|
|
31
|
-
success: "bg-background text-green-500 border border-green-500/25 hover:bg-green-500/5"
|
|
32
|
-
};
|
|
33
|
-
var Button = React2.forwardRef(
|
|
34
|
-
({
|
|
35
|
-
className,
|
|
36
|
-
type = "button",
|
|
37
|
-
variant = "secondary",
|
|
38
|
-
rounded: roundedProp,
|
|
39
|
-
size = "default",
|
|
40
|
-
iconOnly = false,
|
|
41
|
-
disabled,
|
|
42
|
-
...props
|
|
43
|
-
}, ref) => {
|
|
44
|
-
const rounded = roundedProp ?? (iconOnly ? "md" : "full");
|
|
45
|
-
return /* @__PURE__ */ jsx(
|
|
46
|
-
"button",
|
|
47
|
-
{
|
|
48
|
-
type,
|
|
49
|
-
disabled,
|
|
50
|
-
"data-slot": "button",
|
|
51
|
-
"data-icon-only": iconOnly ? "" : void 0,
|
|
52
|
-
className: cn(
|
|
53
|
-
"inline-flex shrink-0 cursor-pointer items-center justify-center whitespace-nowrap outline-none scale-100 transition-[color,background-color,box-shadow,transform] duration-150 ease-out active:scale-[0.98] active:duration-100 active:ease-linear [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
54
|
-
"disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
55
|
-
"focus-visible:border-ring font-medium lg:tracking-wide focus-visible:ring-ring/50 focus-visible:ring-[3px]",
|
|
56
|
-
iconOnly ? iconOnlySizeClass[size] : sizeClass[size],
|
|
57
|
-
roundedClass[rounded],
|
|
58
|
-
variantClass[variant],
|
|
59
|
-
className
|
|
60
|
-
),
|
|
61
|
-
ref,
|
|
62
|
-
...props
|
|
63
|
-
}
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
);
|
|
67
|
-
Button.displayName = "Button";
|
|
68
|
-
var PaginationInner = React2.forwardRef(
|
|
69
|
-
function Pagination({
|
|
70
|
-
meta,
|
|
71
|
-
onPageChange,
|
|
72
|
-
className,
|
|
73
|
-
maxVisibleButtons = 3,
|
|
74
|
-
disabled = false,
|
|
75
|
-
size = "default",
|
|
76
|
-
rounded = "full"
|
|
77
|
-
}, ref) {
|
|
78
|
-
const handlePageChange = React2.useCallback(
|
|
79
|
-
(page) => {
|
|
80
|
-
onPageChange?.(page);
|
|
81
|
-
},
|
|
82
|
-
[onPageChange]
|
|
83
|
-
);
|
|
84
|
-
const totalPages = React2.useMemo(() => {
|
|
85
|
-
const totalItems = Math.max(0, Number(meta.totalItems) || 0);
|
|
86
|
-
const itemsPerPage = Math.max(1, Number(meta.itemsPerPage) || 16);
|
|
87
|
-
if (meta.totalPages != null && Number.isFinite(meta.totalPages)) {
|
|
88
|
-
return Math.max(1, Math.floor(Number(meta.totalPages)));
|
|
89
|
-
}
|
|
90
|
-
return Math.max(1, Math.ceil(totalItems / itemsPerPage));
|
|
91
|
-
}, [meta.totalItems, meta.itemsPerPage, meta.totalPages]);
|
|
92
|
-
const currentPage = React2.useMemo(
|
|
93
|
-
() => Math.max(1, Number(meta.currentPage) || 1),
|
|
94
|
-
[meta.currentPage]
|
|
95
|
-
);
|
|
96
|
-
const { endPage, adjustedStart } = React2.useMemo(() => {
|
|
97
|
-
const sp = Math.max(1, currentPage - Math.floor(maxVisibleButtons / 2));
|
|
98
|
-
const ep = Math.min(totalPages, sp + maxVisibleButtons - 1);
|
|
99
|
-
const adj = ep - sp + 1 < maxVisibleButtons ? Math.max(1, ep - maxVisibleButtons + 1) : sp;
|
|
100
|
-
return { endPage: ep, adjustedStart: adj };
|
|
101
|
-
}, [currentPage, totalPages, maxVisibleButtons]);
|
|
102
|
-
const middlePageNumbers = React2.useMemo(
|
|
103
|
-
() => Array.from({ length: endPage - adjustedStart + 1 }, (_, i) => adjustedStart + i),
|
|
104
|
-
[endPage, adjustedStart]
|
|
105
|
-
);
|
|
106
|
-
const navButtonSize = React2.useMemo(
|
|
107
|
-
() => size === "xs" ? "default" : "lg",
|
|
108
|
-
[size]
|
|
109
|
-
);
|
|
110
|
-
const ellipsisClassName = React2.useMemo(
|
|
111
|
-
() => cn(
|
|
112
|
-
"inline-flex shrink-0 items-center justify-center",
|
|
113
|
-
navButtonSize === "lg" ? "size-11 min-h-11 min-w-11" : "size-10 min-h-10 min-w-10",
|
|
114
|
-
rounded === "full" ? "rounded-full" : rounded === "lg" ? "rounded-lg" : "rounded-md"
|
|
115
|
-
),
|
|
116
|
-
[navButtonSize, rounded]
|
|
117
|
-
);
|
|
118
|
-
const gapIconClassName = React2.useMemo(
|
|
119
|
-
() => cn(
|
|
120
|
-
"mx-auto shrink-0 text-primary/45",
|
|
121
|
-
navButtonSize === "lg" ? "size-[18px]" : "size-4"
|
|
122
|
-
),
|
|
123
|
-
[navButtonSize]
|
|
124
|
-
);
|
|
125
|
-
if (totalPages <= 1) return null;
|
|
126
|
-
return /* @__PURE__ */ jsx("div", { ref, className: cn("flex w-full justify-center", className), children: /* @__PURE__ */ jsxs(
|
|
127
|
-
"nav",
|
|
128
|
-
{
|
|
129
|
-
role: "navigation",
|
|
130
|
-
"aria-label": "Pagination",
|
|
131
|
-
className: "text-primary flex items-center justify-center gap-0.5 text-base font-medium tabular-nums tracking-tight",
|
|
132
|
-
children: [
|
|
133
|
-
/* @__PURE__ */ jsx(
|
|
134
|
-
Button,
|
|
135
|
-
{
|
|
136
|
-
type: "button",
|
|
137
|
-
rounded,
|
|
138
|
-
iconOnly: true,
|
|
139
|
-
size: navButtonSize,
|
|
140
|
-
className: "border-0 tracking-tight focus-visible:border-transparent focus-visible:ring-0",
|
|
141
|
-
disabled: disabled || currentPage <= 1,
|
|
142
|
-
onClick: () => handlePageChange(currentPage - 1),
|
|
143
|
-
"aria-label": "Previous page",
|
|
144
|
-
children: /* @__PURE__ */ jsx(ChevronLeft, { "aria-hidden": true, className: "size-5 shrink-0 mr-0.5" })
|
|
145
|
-
}
|
|
146
|
-
),
|
|
147
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-0.5", children: [
|
|
148
|
-
adjustedStart > 1 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
149
|
-
currentPage === 1 ? /* @__PURE__ */ jsx(
|
|
150
|
-
Button,
|
|
151
|
-
{
|
|
152
|
-
type: "button",
|
|
153
|
-
variant: "primary",
|
|
154
|
-
rounded,
|
|
155
|
-
iconOnly: true,
|
|
156
|
-
size: navButtonSize,
|
|
157
|
-
className: "tracking-tight",
|
|
158
|
-
"aria-current": "page",
|
|
159
|
-
tabIndex: -1,
|
|
160
|
-
children: /* @__PURE__ */ jsx("span", { className: "tabular-nums", children: 1 })
|
|
161
|
-
}
|
|
162
|
-
) : /* @__PURE__ */ jsx(
|
|
163
|
-
Button,
|
|
164
|
-
{
|
|
165
|
-
type: "button",
|
|
166
|
-
rounded,
|
|
167
|
-
iconOnly: true,
|
|
168
|
-
size: navButtonSize,
|
|
169
|
-
className: "border-none tracking-tight",
|
|
170
|
-
disabled,
|
|
171
|
-
onClick: () => handlePageChange(1),
|
|
172
|
-
"aria-label": "Go to page 1",
|
|
173
|
-
children: /* @__PURE__ */ jsx("span", { className: "tabular-nums", children: "1" })
|
|
174
|
-
}
|
|
175
|
-
),
|
|
176
|
-
adjustedStart > 2 && /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: ellipsisClassName, children: /* @__PURE__ */ jsx(MoreHorizontal, { className: gapIconClassName, "aria-hidden": true }) })
|
|
177
|
-
] }),
|
|
178
|
-
middlePageNumbers.map(
|
|
179
|
-
(page) => currentPage === page ? /* @__PURE__ */ jsx(
|
|
180
|
-
Button,
|
|
181
|
-
{
|
|
182
|
-
type: "button",
|
|
183
|
-
variant: "primary",
|
|
184
|
-
rounded,
|
|
185
|
-
iconOnly: true,
|
|
186
|
-
size: navButtonSize,
|
|
187
|
-
className: "tracking-tight",
|
|
188
|
-
"aria-current": "page",
|
|
189
|
-
tabIndex: -1,
|
|
190
|
-
children: /* @__PURE__ */ jsx("span", { className: "tabular-nums", children: page })
|
|
191
|
-
},
|
|
192
|
-
page
|
|
193
|
-
) : /* @__PURE__ */ jsx(
|
|
194
|
-
Button,
|
|
195
|
-
{
|
|
196
|
-
type: "button",
|
|
197
|
-
rounded,
|
|
198
|
-
iconOnly: true,
|
|
199
|
-
size: navButtonSize,
|
|
200
|
-
className: "border-none tracking-tight",
|
|
201
|
-
disabled,
|
|
202
|
-
onClick: () => handlePageChange(page),
|
|
203
|
-
"aria-label": `Go to page ${page}`,
|
|
204
|
-
children: /* @__PURE__ */ jsx("span", { className: "tabular-nums", children: page })
|
|
205
|
-
},
|
|
206
|
-
page
|
|
207
|
-
)
|
|
208
|
-
),
|
|
209
|
-
endPage < totalPages && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
210
|
-
endPage < totalPages - 1 && /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: ellipsisClassName, children: /* @__PURE__ */ jsx(MoreHorizontal, { className: gapIconClassName, "aria-hidden": true }) }),
|
|
211
|
-
currentPage === totalPages ? /* @__PURE__ */ jsx(
|
|
212
|
-
Button,
|
|
213
|
-
{
|
|
214
|
-
type: "button",
|
|
215
|
-
variant: "primary",
|
|
216
|
-
rounded,
|
|
217
|
-
iconOnly: true,
|
|
218
|
-
size: navButtonSize,
|
|
219
|
-
className: "tracking-tight",
|
|
220
|
-
"aria-current": "page",
|
|
221
|
-
tabIndex: -1,
|
|
222
|
-
children: /* @__PURE__ */ jsx("span", { className: "tabular-nums", children: totalPages })
|
|
223
|
-
}
|
|
224
|
-
) : /* @__PURE__ */ jsx(
|
|
225
|
-
Button,
|
|
226
|
-
{
|
|
227
|
-
type: "button",
|
|
228
|
-
rounded,
|
|
229
|
-
iconOnly: true,
|
|
230
|
-
size: navButtonSize,
|
|
231
|
-
className: "border-none tracking-tight",
|
|
232
|
-
disabled,
|
|
233
|
-
onClick: () => handlePageChange(totalPages),
|
|
234
|
-
"aria-label": `Go to page ${totalPages}`,
|
|
235
|
-
children: /* @__PURE__ */ jsx("span", { className: "tabular-nums", children: totalPages })
|
|
236
|
-
}
|
|
237
|
-
)
|
|
238
|
-
] })
|
|
239
|
-
] }),
|
|
240
|
-
/* @__PURE__ */ jsx(
|
|
241
|
-
Button,
|
|
242
|
-
{
|
|
243
|
-
type: "button",
|
|
244
|
-
rounded,
|
|
245
|
-
iconOnly: true,
|
|
246
|
-
size: navButtonSize,
|
|
247
|
-
className: "border-0 tracking-tight focus-visible:border-transparent focus-visible:ring-0",
|
|
248
|
-
disabled: disabled || currentPage >= totalPages,
|
|
249
|
-
onClick: () => handlePageChange(currentPage + 1),
|
|
250
|
-
"aria-label": "Next page",
|
|
251
|
-
children: /* @__PURE__ */ jsx(ChevronRight, { "aria-hidden": true, className: "size-5 shrink-0 ml-0.5" })
|
|
252
|
-
}
|
|
253
|
-
)
|
|
254
|
-
]
|
|
255
|
-
}
|
|
256
|
-
) });
|
|
257
|
-
}
|
|
258
|
-
);
|
|
259
|
-
PaginationInner.displayName = "Pagination";
|
|
260
|
-
var Pagination2 = React2.memo(PaginationInner);
|
|
261
|
-
|
|
262
|
-
// src/lib/typeahead.ts
|
|
263
|
-
var TYPEAHEAD_TIMEOUT_MS = 500;
|
|
264
|
-
function createTypeaheadState() {
|
|
265
|
-
return { search: "", timer: null };
|
|
266
|
-
}
|
|
267
|
-
function resetTypeahead(state) {
|
|
268
|
-
state.search = "";
|
|
269
|
-
if (state.timer) {
|
|
270
|
-
clearTimeout(state.timer);
|
|
271
|
-
state.timer = null;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
function getItemLabel(item) {
|
|
275
|
-
const aria = item.getAttribute("aria-label")?.trim();
|
|
276
|
-
if (aria) return aria;
|
|
277
|
-
const marked = item.querySelector("[data-menu-label]");
|
|
278
|
-
if (marked?.textContent) return marked.textContent.replace(/\s+/g, " ").trim();
|
|
279
|
-
return (item.textContent ?? "").replace(/\s+/g, " ").trim();
|
|
280
|
-
}
|
|
281
|
-
function normalizeSearch(value) {
|
|
282
|
-
return value.trim().toLocaleLowerCase();
|
|
283
|
-
}
|
|
284
|
-
function isTypeaheadTarget(target) {
|
|
285
|
-
if (!(target instanceof HTMLElement)) return true;
|
|
286
|
-
if (target.isContentEditable) return false;
|
|
287
|
-
const tag = target.tagName;
|
|
288
|
-
return tag !== "INPUT" && tag !== "TEXTAREA" && tag !== "SELECT";
|
|
289
|
-
}
|
|
290
|
-
function handleTypeaheadKeyDown(event, items, state, options) {
|
|
291
|
-
if (options?.enabled === false || items.length === 0) return false;
|
|
292
|
-
if (event.ctrlKey || event.metaKey || event.altKey) return false;
|
|
293
|
-
if (event.key.length !== 1 || !isTypeaheadTarget(event.target)) return false;
|
|
294
|
-
event.preventDefault();
|
|
295
|
-
const timeoutMs = options?.timeoutMs ?? TYPEAHEAD_TIMEOUT_MS;
|
|
296
|
-
const char = event.key;
|
|
297
|
-
const prevSearch = state.search;
|
|
298
|
-
const repeatSingleChar = prevSearch.length === 1 && prevSearch === char;
|
|
299
|
-
if (repeatSingleChar) {
|
|
300
|
-
state.search = prevSearch;
|
|
301
|
-
} else {
|
|
302
|
-
state.search = prevSearch + char;
|
|
303
|
-
}
|
|
304
|
-
if (state.timer) clearTimeout(state.timer);
|
|
305
|
-
state.timer = setTimeout(() => {
|
|
306
|
-
state.search = "";
|
|
307
|
-
state.timer = null;
|
|
308
|
-
}, timeoutMs);
|
|
309
|
-
const labels = items.map((item) => normalizeSearch(getItemLabel(item)));
|
|
310
|
-
let needle = normalizeSearch(state.search);
|
|
311
|
-
let matches = items.map((item, index) => ({ item, index, label: labels[index] })).filter(({ label }) => label.startsWith(needle));
|
|
312
|
-
if (matches.length === 0 && state.search.length > 1) {
|
|
313
|
-
state.search = char;
|
|
314
|
-
needle = normalizeSearch(char);
|
|
315
|
-
matches = items.map((item, index) => ({ item, index, label: labels[index] })).filter(({ label }) => label.startsWith(needle));
|
|
316
|
-
}
|
|
317
|
-
if (matches.length === 0) return true;
|
|
318
|
-
const focused = document.activeElement;
|
|
319
|
-
const focusedIndex = focused ? items.indexOf(focused) : -1;
|
|
320
|
-
if (repeatSingleChar && focusedIndex !== -1) {
|
|
321
|
-
const currentMatch = matches.findIndex(
|
|
322
|
-
({ index }) => index === focusedIndex
|
|
323
|
-
);
|
|
324
|
-
if (currentMatch !== -1) {
|
|
325
|
-
const next = matches[(currentMatch + 1) % matches.length];
|
|
326
|
-
next?.item.focus();
|
|
327
|
-
return true;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
if (focusedIndex !== -1) {
|
|
331
|
-
const nextAfterFocus = matches.find(({ index }) => index > focusedIndex);
|
|
332
|
-
if (nextAfterFocus) {
|
|
333
|
-
nextAfterFocus.item.focus();
|
|
334
|
-
return true;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
matches[0]?.item.focus();
|
|
338
|
-
return true;
|
|
339
|
-
}
|
|
340
|
-
var PANEL_OPEN_EASING = "cubic-bezier(0,0.55,0.45,1)";
|
|
341
|
-
var PANEL_CLOSE_EASING = "cubic-bezier(0.55,0,1,0.45)";
|
|
342
|
-
var MOBILE_SHEET_MAX_PX = 1024;
|
|
343
|
-
var MOBILE_SHEET_MS = 175;
|
|
344
|
-
var MOBILE_SHEET_IN = "cubic-bezier(0.85, 0, 0.15, 1)";
|
|
345
|
-
var MOBILE_SHEET_OUT = "cubic-bezier(0.85, 0, 1, 0.15)";
|
|
346
|
-
var SLIDE_DEFAULT_PX = 120;
|
|
347
|
-
var SHEET_MENU_TEXT = "max-[1024px]:text-base";
|
|
348
|
-
var SHEET_MENU_SHORTCUT = "max-[1024px]:text-sm";
|
|
349
|
-
var SELECT_FLIP_MIN_SPACE_PX = 100;
|
|
350
|
-
var CONTENT_ORIGIN = {
|
|
351
|
-
bottom: "top center",
|
|
352
|
-
top: "bottom center",
|
|
353
|
-
left: "right center",
|
|
354
|
-
right: "left center"
|
|
355
|
-
};
|
|
356
|
-
var CONTENT_HIDDEN = {
|
|
357
|
-
bottom: "translateY(-4px) scale(0.97)",
|
|
358
|
-
top: "translateY(4px) scale(0.97)",
|
|
359
|
-
left: "translateX(4px) scale(0.97)",
|
|
360
|
-
right: "translateX(-4px) scale(0.97)"
|
|
361
|
-
};
|
|
362
|
-
function computeMenuPosition(trigger, menu, side, align, offset, pad) {
|
|
363
|
-
const tr = trigger.getBoundingClientRect();
|
|
364
|
-
const mr = menu.getBoundingClientRect();
|
|
365
|
-
const contentHeight = menu.scrollHeight;
|
|
366
|
-
const vh = window.innerHeight;
|
|
367
|
-
const vw = window.innerWidth;
|
|
368
|
-
const sx = window.scrollX;
|
|
369
|
-
const sy = window.scrollY;
|
|
370
|
-
let top = 0;
|
|
371
|
-
let left = 0;
|
|
372
|
-
let effectiveSide = side;
|
|
373
|
-
let maxHeight;
|
|
374
|
-
const placeVertical = (s, height) => {
|
|
375
|
-
if (s === "bottom") top = tr.bottom + sy + offset;
|
|
376
|
-
else top = tr.top + sy - height - offset;
|
|
377
|
-
if (align === "start") left = tr.left + sx;
|
|
378
|
-
else if (align === "end") left = tr.right + sx - mr.width;
|
|
379
|
-
else left = tr.left + sx + tr.width / 2 - mr.width / 2;
|
|
380
|
-
};
|
|
381
|
-
const place = (s, height = contentHeight) => {
|
|
382
|
-
switch (s) {
|
|
383
|
-
case "bottom":
|
|
384
|
-
case "top":
|
|
385
|
-
placeVertical(s, height);
|
|
386
|
-
break;
|
|
387
|
-
case "right":
|
|
388
|
-
left = tr.right + sx + offset;
|
|
389
|
-
if (align === "start") top = tr.top + sy;
|
|
390
|
-
else if (align === "end") top = tr.bottom + sy - mr.height;
|
|
391
|
-
else top = tr.top + sy + tr.height / 2 - mr.height / 2;
|
|
392
|
-
break;
|
|
393
|
-
case "left":
|
|
394
|
-
left = tr.left + sx - mr.width - offset;
|
|
395
|
-
if (align === "start") top = tr.top + sy;
|
|
396
|
-
else if (align === "end") top = tr.bottom + sy - mr.height;
|
|
397
|
-
else top = tr.top + sy + tr.height / 2 - mr.height / 2;
|
|
398
|
-
break;
|
|
399
|
-
}
|
|
400
|
-
};
|
|
401
|
-
place(side);
|
|
402
|
-
const spaceBelow = Math.max(0, vh - pad - tr.bottom - offset);
|
|
403
|
-
const spaceAbove = Math.max(0, tr.top - offset - pad);
|
|
404
|
-
if (side === "bottom" || side === "top") {
|
|
405
|
-
const primarySpace = side === "bottom" ? spaceBelow : spaceAbove;
|
|
406
|
-
const alternateSpace = side === "bottom" ? spaceAbove : spaceBelow;
|
|
407
|
-
const alternateSide = side === "bottom" ? "top" : "bottom";
|
|
408
|
-
if (contentHeight > primarySpace) {
|
|
409
|
-
maxHeight = Math.min(contentHeight, primarySpace);
|
|
410
|
-
place(side, maxHeight);
|
|
411
|
-
}
|
|
412
|
-
if (contentHeight > primarySpace && primarySpace < SELECT_FLIP_MIN_SPACE_PX && alternateSpace > primarySpace) {
|
|
413
|
-
effectiveSide = alternateSide;
|
|
414
|
-
maxHeight = Math.min(contentHeight, alternateSpace);
|
|
415
|
-
place(alternateSide, maxHeight);
|
|
416
|
-
}
|
|
417
|
-
} else if (side === "right" && left + mr.width > vw + sx - pad) {
|
|
418
|
-
const flip = tr.left + sx - mr.width - offset;
|
|
419
|
-
if (flip >= sx + pad) {
|
|
420
|
-
effectiveSide = "left";
|
|
421
|
-
left = flip;
|
|
422
|
-
}
|
|
423
|
-
} else if (side === "left" && left < sx + pad) {
|
|
424
|
-
const flip = tr.right + sx + offset;
|
|
425
|
-
if (flip + mr.width <= vw + sx - pad) {
|
|
426
|
-
effectiveSide = "right";
|
|
427
|
-
left = flip;
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
return { top, left, side: effectiveSide, maxHeight };
|
|
431
|
-
}
|
|
432
|
-
function useNarrowSheetViewport(breakpoint = 1025) {
|
|
433
|
-
const [narrow, setNarrow] = useState(false);
|
|
434
|
-
useEffect(() => {
|
|
435
|
-
const mq = window.matchMedia(`(max-width: ${breakpoint - 1}px)`);
|
|
436
|
-
setNarrow(mq.matches);
|
|
437
|
-
const h = (e) => setNarrow(e.matches);
|
|
438
|
-
mq.addEventListener("change", h);
|
|
439
|
-
return () => mq.removeEventListener("change", h);
|
|
440
|
-
}, [breakpoint]);
|
|
441
|
-
return narrow;
|
|
442
|
-
}
|
|
443
|
-
function plainTextFromNode(node) {
|
|
444
|
-
if (node == null || node === false || node === true) return "";
|
|
445
|
-
if (typeof node === "string" || typeof node === "number")
|
|
446
|
-
return String(node);
|
|
447
|
-
if (Array.isArray(node)) return node.map(plainTextFromNode).join("");
|
|
448
|
-
if (React2.isValidElement(node)) {
|
|
449
|
-
return plainTextFromNode(
|
|
450
|
-
node.props.children
|
|
451
|
-
);
|
|
452
|
-
}
|
|
453
|
-
return "";
|
|
454
|
-
}
|
|
455
|
-
var ValueContext = React2.createContext(null);
|
|
456
|
-
function useSelectValue() {
|
|
457
|
-
const c = React2.useContext(ValueContext);
|
|
458
|
-
if (!c) throw new Error("Select subcomponents must be used within <Select>");
|
|
459
|
-
return c;
|
|
460
|
-
}
|
|
461
|
-
var OpenContext = React2.createContext(null);
|
|
462
|
-
function useSelectOpen() {
|
|
463
|
-
const c = React2.useContext(OpenContext);
|
|
464
|
-
if (!c)
|
|
465
|
-
throw new Error(
|
|
466
|
-
"Select.Trigger, SelectContent, and SelectItem need <Select> without native"
|
|
467
|
-
);
|
|
468
|
-
return c;
|
|
469
|
-
}
|
|
470
|
-
var Select = ({
|
|
471
|
-
children,
|
|
472
|
-
className,
|
|
473
|
-
value: valueProp,
|
|
474
|
-
defaultValue = "",
|
|
475
|
-
onValueChange,
|
|
476
|
-
native: nativeProp = false,
|
|
477
|
-
disabled = false,
|
|
478
|
-
name,
|
|
479
|
-
id: idAttr,
|
|
480
|
-
placeholder = "Select",
|
|
481
|
-
open: openProp,
|
|
482
|
-
onOpenChange
|
|
483
|
-
}) => {
|
|
484
|
-
const isValueControlled = valueProp !== void 0;
|
|
485
|
-
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
486
|
-
const value = isValueControlled ? valueProp : internalValue;
|
|
487
|
-
const [labels, setLabels] = useState({});
|
|
488
|
-
const [nativeMeta, setNativeMeta] = useState({});
|
|
489
|
-
const [nativeOrder, setNativeOrder] = useState([]);
|
|
490
|
-
const setValue = useCallback(
|
|
491
|
-
(v) => {
|
|
492
|
-
if (!isValueControlled) setInternalValue(v);
|
|
493
|
-
onValueChange?.(v);
|
|
494
|
-
},
|
|
495
|
-
[isValueControlled, onValueChange]
|
|
496
|
-
);
|
|
497
|
-
const setLabel = useCallback((v, n) => {
|
|
498
|
-
setLabels((p) => p[v] === n ? p : { ...p, [v]: n });
|
|
499
|
-
}, []);
|
|
500
|
-
const clearLabel = useCallback((v) => {
|
|
501
|
-
setLabels((p) => {
|
|
502
|
-
if (!(v in p)) return p;
|
|
503
|
-
const n = { ...p };
|
|
504
|
-
delete n[v];
|
|
505
|
-
return n;
|
|
506
|
-
});
|
|
507
|
-
}, []);
|
|
508
|
-
const labelsRef = useRef(labels);
|
|
509
|
-
labelsRef.current = labels;
|
|
510
|
-
const labelFor = useCallback(
|
|
511
|
-
(v) => labelsRef.current[v],
|
|
512
|
-
[]
|
|
513
|
-
);
|
|
514
|
-
const registerNativeItem = useCallback(
|
|
515
|
-
(e) => {
|
|
516
|
-
setLabel(e.value, e.label);
|
|
517
|
-
setNativeMeta((p) => ({ ...p, [e.value]: { label: e.label, disabled: e.disabled } }));
|
|
518
|
-
setNativeOrder((o) => o.includes(e.value) ? o : [...o, e.value]);
|
|
519
|
-
},
|
|
520
|
-
[setLabel]
|
|
521
|
-
);
|
|
522
|
-
const unregisterNativeItem = useCallback(
|
|
523
|
-
(v) => {
|
|
524
|
-
setNativeMeta((p) => {
|
|
525
|
-
if (!(v in p)) return p;
|
|
526
|
-
const n = { ...p };
|
|
527
|
-
delete n[v];
|
|
528
|
-
return n;
|
|
529
|
-
});
|
|
530
|
-
setNativeOrder((o) => o.filter((x) => x !== v));
|
|
531
|
-
clearLabel(v);
|
|
532
|
-
},
|
|
533
|
-
[clearLabel]
|
|
534
|
-
);
|
|
535
|
-
const valueCtx = useMemo(
|
|
536
|
-
() => ({
|
|
537
|
-
native: nativeProp,
|
|
538
|
-
value,
|
|
539
|
-
setValue,
|
|
540
|
-
disabled,
|
|
541
|
-
setLabel,
|
|
542
|
-
clearLabel,
|
|
543
|
-
registerNativeItem,
|
|
544
|
-
unregisterNativeItem,
|
|
545
|
-
labelFor,
|
|
546
|
-
placeholder
|
|
547
|
-
}),
|
|
548
|
-
[
|
|
549
|
-
nativeProp,
|
|
550
|
-
value,
|
|
551
|
-
setValue,
|
|
552
|
-
disabled,
|
|
553
|
-
labels,
|
|
554
|
-
setLabel,
|
|
555
|
-
clearLabel,
|
|
556
|
-
registerNativeItem,
|
|
557
|
-
unregisterNativeItem,
|
|
558
|
-
labelFor,
|
|
559
|
-
placeholder
|
|
560
|
-
]
|
|
561
|
-
);
|
|
562
|
-
if (nativeProp) {
|
|
563
|
-
return /* @__PURE__ */ jsxs(ValueContext.Provider, { value: valueCtx, children: [
|
|
564
|
-
/* @__PURE__ */ jsxs(
|
|
565
|
-
"div",
|
|
566
|
-
{
|
|
567
|
-
className: cn(
|
|
568
|
-
"group relative inline-block w-max min-w-0 max-w-full",
|
|
569
|
-
className
|
|
570
|
-
),
|
|
571
|
-
children: [
|
|
572
|
-
/* @__PURE__ */ jsxs(
|
|
573
|
-
"select",
|
|
574
|
-
{
|
|
575
|
-
id: idAttr,
|
|
576
|
-
name,
|
|
577
|
-
className: cn(
|
|
578
|
-
"peer",
|
|
579
|
-
"border-primary/10 bg-background text-primary w-full min-w-0 max-w-full cursor-pointer appearance-none border pr-9 pl-3 outline-none",
|
|
580
|
-
"h-10 min-h-10 text-sm font-medium",
|
|
581
|
-
"rounded-full transition-[color,background-color,box-shadow,transform] duration-150",
|
|
582
|
-
"focus-visible:ring-ring/50 focus-visible:ring-[3px]",
|
|
583
|
-
"active:scale-[0.99]",
|
|
584
|
-
"disabled:cursor-not-allowed disabled:opacity-50"
|
|
585
|
-
),
|
|
586
|
-
value,
|
|
587
|
-
disabled,
|
|
588
|
-
onChange: (ev) => setValue(ev.target.value),
|
|
589
|
-
children: [
|
|
590
|
-
/* @__PURE__ */ jsx("option", { value: "", disabled: true, children: placeholder }),
|
|
591
|
-
nativeOrder.map((key) => {
|
|
592
|
-
const m = nativeMeta[key];
|
|
593
|
-
if (!m) return null;
|
|
594
|
-
return /* @__PURE__ */ jsx("option", { value: key, disabled: m.disabled, children: plainTextFromNode(m.label) }, key);
|
|
595
|
-
})
|
|
596
|
-
]
|
|
597
|
-
}
|
|
598
|
-
),
|
|
599
|
-
/* @__PURE__ */ jsx(
|
|
600
|
-
ChevronDown,
|
|
601
|
-
{
|
|
602
|
-
"aria-hidden": true,
|
|
603
|
-
className: "text-primary/50 pointer-events-none absolute top-1/2 right-2.5 size-4 -translate-y-1/2 peer-disabled:opacity-50"
|
|
604
|
-
}
|
|
605
|
-
)
|
|
606
|
-
]
|
|
607
|
-
}
|
|
608
|
-
),
|
|
609
|
-
children
|
|
610
|
-
] });
|
|
611
|
-
}
|
|
612
|
-
return /* @__PURE__ */ jsx(ValueContext.Provider, { value: valueCtx, children: /* @__PURE__ */ jsx(SelectOpenBridge, { open: openProp, onOpenChange, children: /* @__PURE__ */ jsx("div", { className: cn("inline-block min-w-0 max-w-full", className), children }) }) });
|
|
613
|
-
};
|
|
614
|
-
function SelectOpenBridge({
|
|
615
|
-
children,
|
|
616
|
-
open: controlled,
|
|
617
|
-
onOpenChange
|
|
618
|
-
}) {
|
|
619
|
-
const [inner, setInner] = useState(false);
|
|
620
|
-
const isControlled = controlled !== void 0;
|
|
621
|
-
const open = isControlled ? controlled : inner;
|
|
622
|
-
const setOpen = useCallback(
|
|
623
|
-
(o) => {
|
|
624
|
-
if (!isControlled) setInner(o);
|
|
625
|
-
onOpenChange?.(o);
|
|
626
|
-
},
|
|
627
|
-
[isControlled, onOpenChange]
|
|
628
|
-
);
|
|
629
|
-
const triggerRef = useRef(null);
|
|
630
|
-
const ctx = useMemo(
|
|
631
|
-
() => ({ open, setOpen, triggerRef }),
|
|
632
|
-
[open, setOpen]
|
|
633
|
-
);
|
|
634
|
-
return /* @__PURE__ */ jsx(OpenContext.Provider, { value: ctx, children });
|
|
635
|
-
}
|
|
636
|
-
var SheetClose = React2.forwardRef(({ className, type = "button", ...p }, ref) => /* @__PURE__ */ jsxs(
|
|
637
|
-
"button",
|
|
638
|
-
{
|
|
639
|
-
ref,
|
|
640
|
-
type,
|
|
641
|
-
className: cn(
|
|
642
|
-
"z-100 flex size-12 shrink-0 cursor-pointer items-center justify-center rounded-full transition-all hover:bg-secondary-background active:scale-[0.96]",
|
|
643
|
-
className
|
|
644
|
-
),
|
|
645
|
-
...p,
|
|
646
|
-
children: [
|
|
647
|
-
/* @__PURE__ */ jsx(X, { className: "size-5.5" }),
|
|
648
|
-
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
|
|
649
|
-
]
|
|
650
|
-
}
|
|
651
|
-
));
|
|
652
|
-
SheetClose.displayName = "SelectSheetClose";
|
|
653
|
-
function resolveSheetOpts(o) {
|
|
654
|
-
return {
|
|
655
|
-
sheet: o?.sheet ?? true,
|
|
656
|
-
title: o?.title,
|
|
657
|
-
panelClass: o?.className,
|
|
658
|
-
bodyClass: o?.contentClassName
|
|
659
|
-
};
|
|
660
|
-
}
|
|
661
|
-
function MobileSheetPortal({
|
|
662
|
-
open,
|
|
663
|
-
isAnimating,
|
|
664
|
-
slideEntrance,
|
|
665
|
-
slideOffsetPx,
|
|
666
|
-
sheetTitle,
|
|
667
|
-
sheetPanelClassName,
|
|
668
|
-
contentClassName,
|
|
669
|
-
onRequestClose,
|
|
670
|
-
menuRef,
|
|
671
|
-
children,
|
|
672
|
-
className,
|
|
673
|
-
style,
|
|
674
|
-
...rest
|
|
675
|
-
}) {
|
|
676
|
-
const ease = open ? MOBILE_SHEET_IN : MOBILE_SHEET_OUT;
|
|
677
|
-
const hiddenY = slideEntrance ? `translateY(${slideOffsetPx}px)` : "translateY(100%)";
|
|
678
|
-
return createPortal(
|
|
679
|
-
/* @__PURE__ */ jsxs("div", { className: "fixed inset-0 z-50 flex items-end justify-center p-0", children: [
|
|
680
|
-
/* @__PURE__ */ jsx(
|
|
681
|
-
"div",
|
|
682
|
-
{
|
|
683
|
-
className: cn(
|
|
684
|
-
"fixed inset-0 bg-black/40 dark:bg-primary/4",
|
|
685
|
-
isAnimating ? "opacity-100" : "opacity-0"
|
|
686
|
-
),
|
|
687
|
-
style: {
|
|
688
|
-
transition: `opacity ${MOBILE_SHEET_MS}ms ${ease}`
|
|
689
|
-
},
|
|
690
|
-
onClick: onRequestClose
|
|
691
|
-
}
|
|
692
|
-
),
|
|
693
|
-
/* @__PURE__ */ jsxs(
|
|
694
|
-
"div",
|
|
695
|
-
{
|
|
696
|
-
...rest,
|
|
697
|
-
ref: menuRef,
|
|
698
|
-
className: cn(
|
|
699
|
-
"bg-background border-primary/10 relative z-10 flex w-full max-h-[min(90dvh,calc(100dvh-env(safe-area-inset-bottom,0px)))] flex-col overflow-hidden shadow-2xl outline-none",
|
|
700
|
-
"rounded-t-2xl rounded-b-none border-x-0 border-b-0 border-t",
|
|
701
|
-
sheetPanelClassName,
|
|
702
|
-
className
|
|
703
|
-
),
|
|
704
|
-
style: {
|
|
705
|
-
transform: isAnimating ? "translateY(0)" : hiddenY,
|
|
706
|
-
opacity: isAnimating ? 1 : 0,
|
|
707
|
-
transition: `transform ${MOBILE_SHEET_MS}ms ${ease}, opacity ${MOBILE_SHEET_MS}ms ${ease}`,
|
|
708
|
-
...style
|
|
709
|
-
},
|
|
710
|
-
children: [
|
|
711
|
-
/* @__PURE__ */ jsxs(
|
|
712
|
-
"div",
|
|
713
|
-
{
|
|
714
|
-
className: cn(
|
|
715
|
-
"flex w-full shrink-0 items-center py-2 pl-4 pr-2",
|
|
716
|
-
sheetTitle ? "justify-between gap-3" : "justify-end"
|
|
717
|
-
),
|
|
718
|
-
children: [
|
|
719
|
-
sheetTitle ? /* @__PURE__ */ jsx("p", { className: "text-foreground min-w-0 flex-1 truncate text-base font-semibold", children: sheetTitle }) : null,
|
|
720
|
-
/* @__PURE__ */ jsx(
|
|
721
|
-
SheetClose,
|
|
722
|
-
{
|
|
723
|
-
onClick: (e) => {
|
|
724
|
-
e.stopPropagation();
|
|
725
|
-
onRequestClose();
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
)
|
|
729
|
-
]
|
|
730
|
-
}
|
|
731
|
-
),
|
|
732
|
-
/* @__PURE__ */ jsx(
|
|
733
|
-
"div",
|
|
734
|
-
{
|
|
735
|
-
className: cn(
|
|
736
|
-
"min-h-0 flex-1 overflow-y-auto pb-[calc(5rem+env(safe-area-inset-bottom,0px))]",
|
|
737
|
-
contentClassName
|
|
738
|
-
),
|
|
739
|
-
children
|
|
740
|
-
}
|
|
741
|
-
)
|
|
742
|
-
]
|
|
743
|
-
}
|
|
744
|
-
)
|
|
745
|
-
] }),
|
|
746
|
-
document.body
|
|
747
|
-
);
|
|
748
|
-
}
|
|
749
|
-
function listFocusableItems(host) {
|
|
750
|
-
return Array.from(
|
|
751
|
-
host.querySelectorAll(
|
|
752
|
-
'[data-select-item="true"]:not([aria-disabled="true"])'
|
|
753
|
-
)
|
|
754
|
-
);
|
|
755
|
-
}
|
|
756
|
-
var SelectContent = ({
|
|
757
|
-
children,
|
|
758
|
-
side = "bottom",
|
|
759
|
-
align = "start",
|
|
760
|
-
offset = 10,
|
|
761
|
-
duration = 80,
|
|
762
|
-
viewportPadding = 8,
|
|
763
|
-
closeOnEscape = true,
|
|
764
|
-
minWidth = "trigger",
|
|
765
|
-
loop = true,
|
|
766
|
-
typeahead = true,
|
|
767
|
-
mobileOptions,
|
|
768
|
-
slideEntrance = true,
|
|
769
|
-
slideEntranceOffsetPx: slidePxProp,
|
|
770
|
-
className,
|
|
771
|
-
style,
|
|
772
|
-
...rest
|
|
773
|
-
}) => {
|
|
774
|
-
const narrow = useNarrowSheetViewport(MOBILE_SHEET_MAX_PX + 1);
|
|
775
|
-
const { open, setOpen, triggerRef } = useSelectOpen();
|
|
776
|
-
const [show, setShow] = useState(false);
|
|
777
|
-
const [anim, setAnim] = useState(false);
|
|
778
|
-
const [pos, setPos] = useState({ top: -9999, left: -9999, side });
|
|
779
|
-
const [triggerW, setTriggerW] = useState(0);
|
|
780
|
-
const menuRef = useRef(null);
|
|
781
|
-
const typeaheadStateRef = useRef(createTypeaheadState());
|
|
782
|
-
const sheet = useMemo(() => resolveSheetOpts(mobileOptions), [mobileOptions]);
|
|
783
|
-
const slidePx = slidePxProp ?? SLIDE_DEFAULT_PX;
|
|
784
|
-
const closeMs = narrow && sheet.sheet ? MOBILE_SHEET_MS : duration;
|
|
785
|
-
const close = useCallback(() => setOpen(false), [setOpen]);
|
|
786
|
-
const [portalReady, setPortalReady] = useState(false);
|
|
787
|
-
useLayoutEffect(() => {
|
|
788
|
-
setPortalReady(true);
|
|
789
|
-
}, []);
|
|
790
|
-
useEffect(() => {
|
|
791
|
-
if (open) {
|
|
792
|
-
setShow(true);
|
|
793
|
-
} else {
|
|
794
|
-
setAnim(false);
|
|
795
|
-
const t = setTimeout(() => setShow(false), closeMs);
|
|
796
|
-
return () => clearTimeout(t);
|
|
797
|
-
}
|
|
798
|
-
}, [open, closeMs]);
|
|
799
|
-
useEffect(() => {
|
|
800
|
-
if (!show || !open) return;
|
|
801
|
-
let r2 = 0;
|
|
802
|
-
const r1 = requestAnimationFrame(() => {
|
|
803
|
-
r2 = requestAnimationFrame(() => setAnim(true));
|
|
804
|
-
});
|
|
805
|
-
return () => {
|
|
806
|
-
cancelAnimationFrame(r1);
|
|
807
|
-
if (r2) cancelAnimationFrame(r2);
|
|
808
|
-
};
|
|
809
|
-
}, [show, open]);
|
|
810
|
-
useLayoutEffect(() => {
|
|
811
|
-
if (!triggerRef.current || !menuRef.current) return;
|
|
812
|
-
if (!open && !show) return;
|
|
813
|
-
const run = () => {
|
|
814
|
-
if (!triggerRef.current || !menuRef.current) return;
|
|
815
|
-
setTriggerW(triggerRef.current.getBoundingClientRect().width);
|
|
816
|
-
setPos(
|
|
817
|
-
computeMenuPosition(
|
|
818
|
-
triggerRef.current,
|
|
819
|
-
menuRef.current,
|
|
820
|
-
side,
|
|
821
|
-
align,
|
|
822
|
-
offset,
|
|
823
|
-
viewportPadding
|
|
824
|
-
)
|
|
825
|
-
);
|
|
826
|
-
};
|
|
827
|
-
run();
|
|
828
|
-
window.addEventListener("resize", run);
|
|
829
|
-
window.addEventListener("scroll", run, true);
|
|
830
|
-
return () => {
|
|
831
|
-
window.removeEventListener("resize", run);
|
|
832
|
-
window.removeEventListener("scroll", run, true);
|
|
833
|
-
};
|
|
834
|
-
}, [open, show, side, align, offset, viewportPadding, triggerRef]);
|
|
835
|
-
useEffect(() => {
|
|
836
|
-
if (anim && menuRef.current) menuRef.current.focus();
|
|
837
|
-
}, [anim]);
|
|
838
|
-
useEffect(() => {
|
|
839
|
-
if (!open) resetTypeahead(typeaheadStateRef.current);
|
|
840
|
-
}, [open]);
|
|
841
|
-
useEffect(() => {
|
|
842
|
-
if (!open) return;
|
|
843
|
-
const onDoc = (e) => {
|
|
844
|
-
const t = e.target;
|
|
845
|
-
if (menuRef.current?.contains(t) || triggerRef.current?.contains(t)) return;
|
|
846
|
-
setOpen(false);
|
|
847
|
-
};
|
|
848
|
-
document.addEventListener("mousedown", onDoc);
|
|
849
|
-
return () => document.removeEventListener("mousedown", onDoc);
|
|
850
|
-
}, [open, setOpen, triggerRef]);
|
|
851
|
-
useEffect(() => {
|
|
852
|
-
if (!open) return;
|
|
853
|
-
const onKey = (e) => {
|
|
854
|
-
const m = menuRef.current;
|
|
855
|
-
if (!m) return;
|
|
856
|
-
const active = document.activeElement;
|
|
857
|
-
if (active && !m.contains(active) && !triggerRef.current?.contains(active))
|
|
858
|
-
return;
|
|
859
|
-
const items = listFocusableItems(m);
|
|
860
|
-
const i = items.indexOf(active);
|
|
861
|
-
switch (e.key) {
|
|
862
|
-
case "Escape":
|
|
863
|
-
if (closeOnEscape) {
|
|
864
|
-
e.preventDefault();
|
|
865
|
-
setOpen(false);
|
|
866
|
-
triggerRef.current?.focus();
|
|
867
|
-
}
|
|
868
|
-
break;
|
|
869
|
-
case "ArrowDown":
|
|
870
|
-
e.preventDefault();
|
|
871
|
-
if (!items.length) break;
|
|
872
|
-
if (i === -1 || i === items.length - 1 && loop) items[0]?.focus();
|
|
873
|
-
else if (i < items.length - 1) items[i + 1]?.focus();
|
|
874
|
-
break;
|
|
875
|
-
case "ArrowUp":
|
|
876
|
-
e.preventDefault();
|
|
877
|
-
if (!items.length) break;
|
|
878
|
-
if (i <= 0 && loop) items[items.length - 1]?.focus();
|
|
879
|
-
else if (i > 0) items[i - 1]?.focus();
|
|
880
|
-
break;
|
|
881
|
-
case "Home":
|
|
882
|
-
e.preventDefault();
|
|
883
|
-
items[0]?.focus();
|
|
884
|
-
break;
|
|
885
|
-
case "End":
|
|
886
|
-
e.preventDefault();
|
|
887
|
-
items[items.length - 1]?.focus();
|
|
888
|
-
break;
|
|
889
|
-
case "Tab":
|
|
890
|
-
setOpen(false);
|
|
891
|
-
break;
|
|
892
|
-
default:
|
|
893
|
-
handleTypeaheadKeyDown(e, items, typeaheadStateRef.current, {
|
|
894
|
-
enabled: typeahead
|
|
895
|
-
});
|
|
896
|
-
break;
|
|
897
|
-
}
|
|
898
|
-
};
|
|
899
|
-
window.addEventListener("keydown", onKey);
|
|
900
|
-
return () => window.removeEventListener("keydown", onKey);
|
|
901
|
-
}, [open, closeOnEscape, loop, typeahead, setOpen, triggerRef]);
|
|
902
|
-
const lockBodyScroll = (open || show) && narrow && sheet.sheet;
|
|
903
|
-
useEffect(() => {
|
|
904
|
-
if (!lockBodyScroll) return;
|
|
905
|
-
const prev = document.body.style.overflow;
|
|
906
|
-
document.body.style.overflow = "hidden";
|
|
907
|
-
return () => {
|
|
908
|
-
document.body.style.overflow = prev;
|
|
909
|
-
};
|
|
910
|
-
}, [lockBodyScroll]);
|
|
911
|
-
if (narrow && sheet.sheet) {
|
|
912
|
-
if (!open && !show) {
|
|
913
|
-
const registrationSlot = /* @__PURE__ */ jsx("div", { className: "sr-only pointer-events-none", "aria-hidden": true, children });
|
|
914
|
-
if (!portalReady) return registrationSlot;
|
|
915
|
-
return createPortal(registrationSlot, document.body);
|
|
916
|
-
}
|
|
917
|
-
return /* @__PURE__ */ jsx(
|
|
918
|
-
MobileSheetPortal,
|
|
919
|
-
{
|
|
920
|
-
...rest,
|
|
921
|
-
open,
|
|
922
|
-
isAnimating: anim,
|
|
923
|
-
slideEntrance,
|
|
924
|
-
slideOffsetPx: slidePx,
|
|
925
|
-
sheetTitle: sheet.title,
|
|
926
|
-
sheetPanelClassName: sheet.panelClass,
|
|
927
|
-
contentClassName: sheet.bodyClass,
|
|
928
|
-
onRequestClose: close,
|
|
929
|
-
menuRef,
|
|
930
|
-
className,
|
|
931
|
-
style,
|
|
932
|
-
role: "listbox",
|
|
933
|
-
tabIndex: -1,
|
|
934
|
-
"aria-label": sheet.title,
|
|
935
|
-
children
|
|
936
|
-
}
|
|
937
|
-
);
|
|
938
|
-
}
|
|
939
|
-
const resolvedMin = minWidth === "trigger" ? triggerW > 0 ? triggerW : void 0 : minWidth;
|
|
940
|
-
const listbox = /* @__PURE__ */ jsx(
|
|
941
|
-
"div",
|
|
942
|
-
{
|
|
943
|
-
...rest,
|
|
944
|
-
ref: menuRef,
|
|
945
|
-
role: "listbox",
|
|
946
|
-
tabIndex: -1,
|
|
947
|
-
"aria-hidden": !open,
|
|
948
|
-
className: cn(
|
|
949
|
-
"bg-background border-primary/10 absolute z-50 rounded-xl border py-1.5 shadow-xl outline-none",
|
|
950
|
-
className,
|
|
951
|
-
pos.maxHeight != null ? "overflow-y-auto overscroll-contain" : "overflow-hidden"
|
|
952
|
-
),
|
|
953
|
-
style: {
|
|
954
|
-
position: "absolute",
|
|
955
|
-
top: pos.top,
|
|
956
|
-
left: pos.left,
|
|
957
|
-
...typeof resolvedMin === "number" ? { minWidth: resolvedMin } : {},
|
|
958
|
-
maxHeight: pos.maxHeight,
|
|
959
|
-
transformOrigin: CONTENT_ORIGIN[pos.side],
|
|
960
|
-
transform: anim ? "none" : CONTENT_HIDDEN[pos.side],
|
|
961
|
-
opacity: anim ? 1 : 0,
|
|
962
|
-
pointerEvents: !open ? "none" : "auto",
|
|
963
|
-
transitionProperty: "opacity, transform",
|
|
964
|
-
transitionDuration: `${duration}ms`,
|
|
965
|
-
transitionTimingFunction: anim ? PANEL_OPEN_EASING : PANEL_CLOSE_EASING,
|
|
966
|
-
...style
|
|
967
|
-
},
|
|
968
|
-
children
|
|
969
|
-
}
|
|
970
|
-
);
|
|
971
|
-
if (!portalReady) {
|
|
972
|
-
return listbox;
|
|
973
|
-
}
|
|
974
|
-
return createPortal(listbox, document.body);
|
|
975
|
-
};
|
|
976
|
-
function mergeRef(store, node, fromChild) {
|
|
977
|
-
store.current = node;
|
|
978
|
-
if (typeof fromChild === "function") fromChild(node);
|
|
979
|
-
else if (fromChild && typeof fromChild === "object")
|
|
980
|
-
fromChild.current = node;
|
|
981
|
-
}
|
|
982
|
-
var SelectTrigger = React2.forwardRef(
|
|
983
|
-
function SelectTrigger2({ children, asChild, className, onClick, disabled, ...buttonProps }, ref) {
|
|
984
|
-
const { open, setOpen, triggerRef } = useSelectOpen();
|
|
985
|
-
const triggerVariant = buttonProps.variant ?? "secondary";
|
|
986
|
-
const onPress = useCallback(
|
|
987
|
-
(e) => {
|
|
988
|
-
onClick?.(
|
|
989
|
-
e
|
|
990
|
-
);
|
|
991
|
-
e.stopPropagation();
|
|
992
|
-
if (disabled) return;
|
|
993
|
-
setOpen(!open);
|
|
994
|
-
},
|
|
995
|
-
[onClick, disabled, open, setOpen]
|
|
996
|
-
);
|
|
997
|
-
const setBtnRef = useCallback(
|
|
998
|
-
(el) => {
|
|
999
|
-
mergeRef(triggerRef, el, null);
|
|
1000
|
-
if (typeof ref === "function") ref(el);
|
|
1001
|
-
else if (ref) ref.current = el;
|
|
1002
|
-
},
|
|
1003
|
-
[ref, triggerRef]
|
|
1004
|
-
);
|
|
1005
|
-
if (asChild && React2.isValidElement(children)) {
|
|
1006
|
-
const ch = children;
|
|
1007
|
-
const childRef = ch.ref;
|
|
1008
|
-
return React2.cloneElement(ch, {
|
|
1009
|
-
ref: (n) => mergeRef(triggerRef, n, childRef),
|
|
1010
|
-
className: cn("group w-fit max-w-full min-w-0 justify-start gap-2", ch.props.className),
|
|
1011
|
-
onClick: (e) => {
|
|
1012
|
-
ch.props.onClick?.(e);
|
|
1013
|
-
onPress(e);
|
|
1014
|
-
},
|
|
1015
|
-
"aria-expanded": open,
|
|
1016
|
-
"aria-haspopup": "listbox",
|
|
1017
|
-
"data-state": open ? "open" : "closed",
|
|
1018
|
-
"data-variant": triggerVariant,
|
|
1019
|
-
...disabled !== void 0 ? { "aria-disabled": disabled } : {}
|
|
1020
|
-
});
|
|
1021
|
-
}
|
|
1022
|
-
return /* @__PURE__ */ jsx(
|
|
1023
|
-
Button,
|
|
1024
|
-
{
|
|
1025
|
-
ref: setBtnRef,
|
|
1026
|
-
type: "button",
|
|
1027
|
-
...buttonProps,
|
|
1028
|
-
disabled,
|
|
1029
|
-
className: cn("group w-fit max-w-full min-w-0 justify-start gap-2", className),
|
|
1030
|
-
"aria-expanded": open,
|
|
1031
|
-
"aria-haspopup": "listbox",
|
|
1032
|
-
"data-state": open ? "open" : "closed",
|
|
1033
|
-
"data-variant": triggerVariant,
|
|
1034
|
-
onClick: onPress,
|
|
1035
|
-
children
|
|
1036
|
-
}
|
|
1037
|
-
);
|
|
1038
|
-
}
|
|
1039
|
-
);
|
|
1040
|
-
SelectTrigger.displayName = "SelectTrigger";
|
|
1041
|
-
var SelectChevron = ({
|
|
1042
|
-
className,
|
|
1043
|
-
...props
|
|
1044
|
-
}) => {
|
|
1045
|
-
const { open } = useSelectOpen();
|
|
1046
|
-
return /* @__PURE__ */ jsx(
|
|
1047
|
-
ChevronDown,
|
|
1048
|
-
{
|
|
1049
|
-
"aria-hidden": true,
|
|
1050
|
-
className: cn("size-4 shrink-0", open && "rotate-180", className),
|
|
1051
|
-
...props
|
|
1052
|
-
}
|
|
1053
|
-
);
|
|
1054
|
-
};
|
|
1055
|
-
var SelectValue = ({ placeholder, className }) => {
|
|
1056
|
-
const c = useSelectValue();
|
|
1057
|
-
if (c.native) return null;
|
|
1058
|
-
const ph = placeholder ?? c.placeholder;
|
|
1059
|
-
const text = c.value ? c.labelFor(c.value) : void 0;
|
|
1060
|
-
const isEmpty = !c.value;
|
|
1061
|
-
return /* @__PURE__ */ jsx(
|
|
1062
|
-
"span",
|
|
1063
|
-
{
|
|
1064
|
-
"data-slot": "select-value",
|
|
1065
|
-
className: cn(
|
|
1066
|
-
"min-w-0 flex-1 truncate text-left",
|
|
1067
|
-
isEmpty && cn(
|
|
1068
|
-
"group-data-[variant=primary]:!text-background/50",
|
|
1069
|
-
"group-data-[variant=secondary]:!text-primary/50",
|
|
1070
|
-
"group-data-[variant=destructive]:!text-red-500/50",
|
|
1071
|
-
"group-data-[variant=success]:!text-green-500/50"
|
|
1072
|
-
),
|
|
1073
|
-
className
|
|
1074
|
-
),
|
|
1075
|
-
children: text != null ? text : ph
|
|
1076
|
-
}
|
|
1077
|
-
);
|
|
1078
|
-
};
|
|
1079
|
-
var SelectItemRow = ({
|
|
1080
|
-
value: v,
|
|
1081
|
-
children,
|
|
1082
|
-
disabled,
|
|
1083
|
-
shortcut,
|
|
1084
|
-
className,
|
|
1085
|
-
onClick: userClick,
|
|
1086
|
-
...divProps
|
|
1087
|
-
}) => {
|
|
1088
|
-
const c = useSelectValue();
|
|
1089
|
-
const { setOpen } = useSelectOpen();
|
|
1090
|
-
const selected = c.value === v;
|
|
1091
|
-
const click = (e) => {
|
|
1092
|
-
if (disabled) return;
|
|
1093
|
-
c.setValue(v);
|
|
1094
|
-
userClick?.(e);
|
|
1095
|
-
setOpen(false);
|
|
1096
|
-
};
|
|
1097
|
-
const keyDown = (e) => {
|
|
1098
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
1099
|
-
e.preventDefault();
|
|
1100
|
-
click(e);
|
|
1101
|
-
}
|
|
1102
|
-
};
|
|
1103
|
-
return /* @__PURE__ */ jsxs(
|
|
1104
|
-
"div",
|
|
1105
|
-
{
|
|
1106
|
-
...divProps,
|
|
1107
|
-
"data-select-item": "true",
|
|
1108
|
-
role: "option",
|
|
1109
|
-
"aria-selected": selected,
|
|
1110
|
-
tabIndex: disabled ? void 0 : -1,
|
|
1111
|
-
"aria-disabled": disabled,
|
|
1112
|
-
onClick: click,
|
|
1113
|
-
onKeyDown: keyDown,
|
|
1114
|
-
className: cn(
|
|
1115
|
-
"relative mx-1.5 flex items-center gap-2 rounded-md px-3 py-2 text-sm transition-colors duration-0 outline-none select-none",
|
|
1116
|
-
SHEET_MENU_TEXT,
|
|
1117
|
-
!disabled && "text-foreground hover:bg-primary/8 focus-visible:bg-primary/8 dark:hover:bg-primary/4 dark:focus-visible:bg-primary/4",
|
|
1118
|
-
disabled && "lg:cursor-not-allowed text-foreground/45 dark:text-foreground/50",
|
|
1119
|
-
!disabled && "cursor-pointer",
|
|
1120
|
-
className
|
|
1121
|
-
),
|
|
1122
|
-
children: [
|
|
1123
|
-
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1", "data-menu-label": true, children }),
|
|
1124
|
-
shortcut ? /* @__PURE__ */ jsx(
|
|
1125
|
-
"span",
|
|
1126
|
-
{
|
|
1127
|
-
className: cn(
|
|
1128
|
-
"shrink-0 text-xs tracking-widest opacity-40",
|
|
1129
|
-
SHEET_MENU_SHORTCUT
|
|
1130
|
-
),
|
|
1131
|
-
children: shortcut
|
|
1132
|
-
}
|
|
1133
|
-
) : null,
|
|
1134
|
-
/* @__PURE__ */ jsx("span", { className: "flex size-4 shrink-0 items-center justify-center", "aria-hidden": true, children: selected ? /* @__PURE__ */ jsx(Check, { className: "size-3.5", strokeWidth: 2.5 }) : null })
|
|
1135
|
-
]
|
|
1136
|
-
}
|
|
1137
|
-
);
|
|
1138
|
-
};
|
|
1139
|
-
var SelectItem = ({
|
|
1140
|
-
value: v,
|
|
1141
|
-
children,
|
|
1142
|
-
disabled,
|
|
1143
|
-
...rest
|
|
1144
|
-
}) => {
|
|
1145
|
-
const {
|
|
1146
|
-
native,
|
|
1147
|
-
setLabel,
|
|
1148
|
-
clearLabel,
|
|
1149
|
-
registerNativeItem,
|
|
1150
|
-
unregisterNativeItem
|
|
1151
|
-
} = useSelectValue();
|
|
1152
|
-
useLayoutEffect(() => {
|
|
1153
|
-
setLabel(v, children);
|
|
1154
|
-
if (native) registerNativeItem({ value: v, label: children, disabled });
|
|
1155
|
-
return () => {
|
|
1156
|
-
clearLabel(v);
|
|
1157
|
-
if (native) unregisterNativeItem(v);
|
|
1158
|
-
};
|
|
1159
|
-
}, [
|
|
1160
|
-
v,
|
|
1161
|
-
children,
|
|
1162
|
-
disabled,
|
|
1163
|
-
native,
|
|
1164
|
-
setLabel,
|
|
1165
|
-
clearLabel,
|
|
1166
|
-
registerNativeItem,
|
|
1167
|
-
unregisterNativeItem
|
|
1168
|
-
]);
|
|
1169
|
-
if (native) return null;
|
|
1170
|
-
return /* @__PURE__ */ jsx(SelectItemRow, { value: v, disabled, ...rest, children });
|
|
1171
|
-
};
|
|
1172
|
-
SelectItem.displayName = "SelectItem";
|
|
1173
|
-
function TablePagination({
|
|
1174
|
-
currentPage = 1,
|
|
1175
|
-
totalPages = 1,
|
|
1176
|
-
paginationItemsToDisplay = 10,
|
|
1177
|
-
currentItems,
|
|
1178
|
-
totalItems,
|
|
1179
|
-
onPageChange,
|
|
1180
|
-
onLimitChange,
|
|
1181
|
-
className
|
|
1182
|
-
}) {
|
|
1183
|
-
const itemsPerPage = Math.max(1, paginationItemsToDisplay);
|
|
1184
|
-
const paginationMeta = React2.useMemo(
|
|
1185
|
-
() => ({
|
|
1186
|
-
currentPage,
|
|
1187
|
-
totalItems: totalItems ?? Math.max(0, totalPages * itemsPerPage),
|
|
1188
|
-
itemsPerPage,
|
|
1189
|
-
totalPages
|
|
1190
|
-
}),
|
|
1191
|
-
[currentPage, totalItems, totalPages, itemsPerPage]
|
|
1192
|
-
);
|
|
1193
|
-
return /* @__PURE__ */ jsxs(
|
|
1194
|
-
"div",
|
|
1195
|
-
{
|
|
1196
|
-
className: cn(
|
|
1197
|
-
"flex max-sm:flex-col items-center justify-between gap-3",
|
|
1198
|
-
className
|
|
1199
|
-
),
|
|
1200
|
-
children: [
|
|
1201
|
-
/* @__PURE__ */ jsx(
|
|
1202
|
-
"p",
|
|
1203
|
-
{
|
|
1204
|
-
className: "text-primary/60 flex-1 text-sm whitespace-nowrap",
|
|
1205
|
-
"aria-live": "polite",
|
|
1206
|
-
children: /* @__PURE__ */ jsxs("span", { className: "ml-2", children: [
|
|
1207
|
-
"Showing",
|
|
1208
|
-
" ",
|
|
1209
|
-
/* @__PURE__ */ jsx("span", { className: "text-primary", children: currentItems ?? paginationItemsToDisplay }),
|
|
1210
|
-
" ",
|
|
1211
|
-
"out of",
|
|
1212
|
-
" ",
|
|
1213
|
-
/* @__PURE__ */ jsx("span", { className: "text-primary", children: totalItems ?? /* @__PURE__ */ jsx(Loader2, { className: "mb-[3px] inline h-4 w-4 animate-spin" }) }),
|
|
1214
|
-
" ",
|
|
1215
|
-
"results"
|
|
1216
|
-
] })
|
|
1217
|
-
}
|
|
1218
|
-
),
|
|
1219
|
-
/* @__PURE__ */ jsx("div", { className: "grow", children: /* @__PURE__ */ jsx(Pagination2, { meta: paginationMeta, onPageChange }) }),
|
|
1220
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-1 justify-end", children: /* @__PURE__ */ jsxs(
|
|
1221
|
-
Select,
|
|
1222
|
-
{
|
|
1223
|
-
value: paginationItemsToDisplay.toString(),
|
|
1224
|
-
onValueChange: (value) => {
|
|
1225
|
-
onLimitChange(parseInt(value, 10));
|
|
1226
|
-
},
|
|
1227
|
-
children: [
|
|
1228
|
-
/* @__PURE__ */ jsxs(SelectTrigger, { className: "w-fit rounded-full whitespace-nowrap", children: [
|
|
1229
|
-
/* @__PURE__ */ jsx(SelectValue, { placeholder: "Select number of results" }),
|
|
1230
|
-
/* @__PURE__ */ jsx(SelectChevron, { className: "opacity-60" })
|
|
1231
|
-
] }),
|
|
1232
|
-
/* @__PURE__ */ jsx(SelectContent, { children: [10, 25, 50, 100].map((pageSize) => /* @__PURE__ */ jsxs(SelectItem, { value: pageSize.toString(), children: [
|
|
1233
|
-
pageSize,
|
|
1234
|
-
" / page"
|
|
1235
|
-
] }, pageSize)) })
|
|
1236
|
-
]
|
|
1237
|
-
}
|
|
1238
|
-
) })
|
|
1239
|
-
]
|
|
1240
|
-
}
|
|
1241
|
-
);
|
|
1242
|
-
}
|
|
1243
|
-
var table_pagination_default = TablePagination;
|
|
1244
|
-
|
|
1245
|
-
export { TablePagination, table_pagination_default as default };
|
|
1246
|
-
//# sourceMappingURL=table-pagination.js.map
|
|
1247
|
-
//# sourceMappingURL=table-pagination.js.map
|