@avenue-ticketing/ui 0.10.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 -12
- 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,856 +0,0 @@
|
|
|
1
|
-
import * as React2 from 'react';
|
|
2
|
-
import { clsx } from 'clsx';
|
|
3
|
-
import { twMerge } from 'tailwind-merge';
|
|
4
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
5
|
-
|
|
6
|
-
function cn(...inputs) {
|
|
7
|
-
return twMerge(clsx(inputs));
|
|
8
|
-
}
|
|
9
|
-
var sizeClass = {
|
|
10
|
-
xs: "h-8 min-h-8 gap-2 px-4 text-sm has-[>svg]:px-3 [&_svg:not([class*='size-'])]:size-3",
|
|
11
|
-
default: "h-10 min-h-10 gap-2 px-5 text-sm has-[>svg]:px-4 [&_svg:not([class*='size-'])]:size-4",
|
|
12
|
-
lg: "h-11 min-h-11 gap-2 px-6 text-base has-[>svg]:px-5 [&_svg:not([class*='size-'])]:size-5"
|
|
13
|
-
};
|
|
14
|
-
var iconOnlySizeClass = {
|
|
15
|
-
xs: "size-8 min-h-8 min-w-8 gap-0 p-0 [&_svg:not([class*='size-'])]:size-3",
|
|
16
|
-
default: "size-10 min-h-10 min-w-10 gap-0 p-0 [&_svg:not([class*='size-'])]:size-4",
|
|
17
|
-
lg: "size-11 min-h-11 min-w-11 gap-0 p-0 [&_svg:not([class*='size-'])]:size-5"
|
|
18
|
-
};
|
|
19
|
-
var roundedClass = {
|
|
20
|
-
full: "rounded-full",
|
|
21
|
-
lg: "rounded-lg",
|
|
22
|
-
md: "rounded-md"
|
|
23
|
-
};
|
|
24
|
-
var variantClass = {
|
|
25
|
-
primary: "bg-primary text-background border border-transparent hover:bg-primary/90 active:bg-primary/85",
|
|
26
|
-
secondary: "bg-background text-primary border border-primary/10 hover:bg-primary/5",
|
|
27
|
-
destructive: "bg-background text-red-500 border border-red-500/25 hover:bg-red-500/5",
|
|
28
|
-
success: "bg-background text-green-500 border border-green-500/25 hover:bg-green-500/5"
|
|
29
|
-
};
|
|
30
|
-
var Button = React2.forwardRef(
|
|
31
|
-
({
|
|
32
|
-
className,
|
|
33
|
-
type = "button",
|
|
34
|
-
variant = "secondary",
|
|
35
|
-
rounded: roundedProp,
|
|
36
|
-
size = "default",
|
|
37
|
-
iconOnly = false,
|
|
38
|
-
disabled,
|
|
39
|
-
...props
|
|
40
|
-
}, ref) => {
|
|
41
|
-
const rounded = roundedProp ?? (iconOnly ? "md" : "full");
|
|
42
|
-
return /* @__PURE__ */ jsx(
|
|
43
|
-
"button",
|
|
44
|
-
{
|
|
45
|
-
type,
|
|
46
|
-
disabled,
|
|
47
|
-
"data-slot": "button",
|
|
48
|
-
"data-icon-only": iconOnly ? "" : void 0,
|
|
49
|
-
className: cn(
|
|
50
|
-
"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",
|
|
51
|
-
"disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
52
|
-
"focus-visible:border-ring font-medium lg:tracking-wide focus-visible:ring-ring/50 focus-visible:ring-[3px]",
|
|
53
|
-
iconOnly ? iconOnlySizeClass[size] : sizeClass[size],
|
|
54
|
-
roundedClass[rounded],
|
|
55
|
-
variantClass[variant],
|
|
56
|
-
className
|
|
57
|
-
),
|
|
58
|
-
ref,
|
|
59
|
-
...props
|
|
60
|
-
}
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
);
|
|
64
|
-
Button.displayName = "Button";
|
|
65
|
-
|
|
66
|
-
// src/react/scroll-wheel-axis.ts
|
|
67
|
-
var MAIN_AXIS_MIN_PX = 8;
|
|
68
|
-
function viewportCenter(horizontal, cr) {
|
|
69
|
-
return horizontal ? cr.left + cr.width / 2 : cr.top + cr.height / 2;
|
|
70
|
-
}
|
|
71
|
-
function itemCenter(horizontal, r) {
|
|
72
|
-
return horizontal ? r.left + r.width / 2 : r.top + r.height / 2;
|
|
73
|
-
}
|
|
74
|
-
function mainClientSize(horizontal, el) {
|
|
75
|
-
return horizontal ? el.clientWidth : el.clientHeight;
|
|
76
|
-
}
|
|
77
|
-
function mainViewportRect(horizontal, cr) {
|
|
78
|
-
return horizontal ? cr.width : cr.height;
|
|
79
|
-
}
|
|
80
|
-
function halfMainViewport(horizontal, cr) {
|
|
81
|
-
return Math.max(mainViewportRect(horizontal, cr) / 2, 1);
|
|
82
|
-
}
|
|
83
|
-
function readScroll(horizontal, root) {
|
|
84
|
-
return horizontal ? root.scrollLeft : root.scrollTop;
|
|
85
|
-
}
|
|
86
|
-
function addScroll(horizontal, root, delta) {
|
|
87
|
-
if (horizontal) root.scrollLeft += delta;
|
|
88
|
-
else root.scrollTop += delta;
|
|
89
|
-
}
|
|
90
|
-
function maxScroll(horizontal, root) {
|
|
91
|
-
return horizontal ? Math.max(0, root.scrollWidth - root.clientWidth) : Math.max(0, root.scrollHeight - root.clientHeight);
|
|
92
|
-
}
|
|
93
|
-
function setScroll(horizontal, root, next, behavior) {
|
|
94
|
-
const max = maxScroll(horizontal, root);
|
|
95
|
-
const clamped = Math.min(Math.max(0, next), max);
|
|
96
|
-
if (behavior === "smooth") {
|
|
97
|
-
if (horizontal) root.scrollTo({ left: clamped, behavior: "smooth" });
|
|
98
|
-
else root.scrollTo({ top: clamped, behavior: "smooth" });
|
|
99
|
-
} else if (horizontal) {
|
|
100
|
-
root.scrollLeft = clamped;
|
|
101
|
-
} else {
|
|
102
|
-
root.scrollTop = clamped;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
function applyEndPadding(horizontal, list, root, slotRect) {
|
|
106
|
-
if (horizontal) {
|
|
107
|
-
const pad = Math.max(0, (root.clientWidth - slotRect.width) / 2);
|
|
108
|
-
list.style.paddingLeft = `${pad}px`;
|
|
109
|
-
list.style.paddingRight = `${pad}px`;
|
|
110
|
-
list.style.paddingTop = "";
|
|
111
|
-
list.style.paddingBottom = "";
|
|
112
|
-
} else {
|
|
113
|
-
const pad = Math.max(0, (root.clientHeight - slotRect.height) / 2);
|
|
114
|
-
list.style.paddingTop = `${pad}px`;
|
|
115
|
-
list.style.paddingBottom = `${pad}px`;
|
|
116
|
-
list.style.paddingLeft = "";
|
|
117
|
-
list.style.paddingRight = "";
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
var SCROLL_WHEEL_ITEM_ATTR = "data-scroll-wheel-item";
|
|
121
|
-
var scrollWheelItemProps = { [SCROLL_WHEEL_ITEM_ATTR]: "" };
|
|
122
|
-
var WHEEL_SETTLE_SUPPRESS_MS = 48;
|
|
123
|
-
var WHEEL_SMOOTH_SCROLL_SUPPRESS_MS = 520;
|
|
124
|
-
var WHEEL_SETTLE_IDLE_MS = 200;
|
|
125
|
-
var WHEEL_SETTLE_SCROLLEND_BACKUP_MS = 420;
|
|
126
|
-
var SPOTLIGHT_CENTER_MISMATCH_SUPPRESS_MS = 280;
|
|
127
|
-
var SCROLL_END_SUPPORTED = typeof HTMLElement !== "undefined" && "onscrollend" in HTMLElement.prototype;
|
|
128
|
-
var itemSelector = `[${SCROLL_WHEEL_ITEM_ATTR}]`;
|
|
129
|
-
var selectedItemSelector = `[${SCROLL_WHEEL_ITEM_ATTR}][data-selected]`;
|
|
130
|
-
var CLAMP_EPS = 1;
|
|
131
|
-
var CLAMP_ITERS = 8;
|
|
132
|
-
function applySpotlightFrameStyles(el) {
|
|
133
|
-
el.style.setProperty("position", "relative");
|
|
134
|
-
el.style.setProperty("z-index", "10");
|
|
135
|
-
el.style.setProperty(
|
|
136
|
-
"border-color",
|
|
137
|
-
"color-mix(in oklab, var(--primary) 40%, transparent)"
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
function stripSpotlightFrameStyles(el) {
|
|
141
|
-
el.style.removeProperty("position");
|
|
142
|
-
el.style.removeProperty("z-index");
|
|
143
|
-
el.style.removeProperty("border-color");
|
|
144
|
-
}
|
|
145
|
-
var FADE_EDGES = {
|
|
146
|
-
vertical: [
|
|
147
|
-
"pointer-events-none absolute inset-x-0 top-0 z-10 h-16 bg-linear-to-b from-background via-background/85 to-transparent",
|
|
148
|
-
"pointer-events-none absolute inset-x-0 bottom-0 z-10 h-16 bg-linear-to-t from-background via-background/85 to-transparent"
|
|
149
|
-
],
|
|
150
|
-
horizontal: [
|
|
151
|
-
"pointer-events-none absolute inset-y-0 left-0 z-10 w-16 bg-linear-to-r from-background via-background/85 to-transparent",
|
|
152
|
-
"pointer-events-none absolute inset-y-0 right-0 z-10 w-16 bg-linear-to-l from-background via-background/85 to-transparent"
|
|
153
|
-
]
|
|
154
|
-
};
|
|
155
|
-
function ScrollWheelRoot({
|
|
156
|
-
recenterKey,
|
|
157
|
-
orientation = "vertical",
|
|
158
|
-
disabled,
|
|
159
|
-
onScrollSettle,
|
|
160
|
-
children,
|
|
161
|
-
className,
|
|
162
|
-
centerSpotlightClassName
|
|
163
|
-
}) {
|
|
164
|
-
const horizontal = orientation === "horizontal";
|
|
165
|
-
const centerSpotlightTokens = React2.useMemo(
|
|
166
|
-
() => centerSpotlightClassName?.trim().split(/\s+/).filter(Boolean) ?? [],
|
|
167
|
-
[centerSpotlightClassName]
|
|
168
|
-
);
|
|
169
|
-
const centerSpotlightActive = centerSpotlightTokens.length > 0 && disabled !== true;
|
|
170
|
-
const centerSpotlightFingerprint = centerSpotlightClassName?.trim() ?? "";
|
|
171
|
-
const rootRef = React2.useRef(null);
|
|
172
|
-
const listRef = React2.useRef(null);
|
|
173
|
-
const rafProximityRef = React2.useRef(0);
|
|
174
|
-
const settleTimerRef = React2.useRef(null);
|
|
175
|
-
const lastSettledIdxRef = React2.useRef(null);
|
|
176
|
-
const suppressSettleUntilRef = React2.useRef(0);
|
|
177
|
-
const wasPopoverOpenRef = React2.useRef(false);
|
|
178
|
-
const prevRecenterKeyRef = React2.useRef(void 0);
|
|
179
|
-
const penPointerDownRef = React2.useRef(false);
|
|
180
|
-
const touchIdsOnRootRef = React2.useRef(/* @__PURE__ */ new Set());
|
|
181
|
-
const spotlightDomRef = React2.useRef(null);
|
|
182
|
-
const spotlightAddedClassesRef = React2.useRef(
|
|
183
|
-
/* @__PURE__ */ new WeakMap()
|
|
184
|
-
);
|
|
185
|
-
const spotlightFingerprintRef = React2.useRef("");
|
|
186
|
-
const spotlightSuppressCenterMismatchUntilRef = React2.useRef(0);
|
|
187
|
-
const stripSpotlightFromEl = React2.useCallback((el) => {
|
|
188
|
-
if (!el) return;
|
|
189
|
-
const added = spotlightAddedClassesRef.current.get(el);
|
|
190
|
-
if (added) {
|
|
191
|
-
added.forEach((token) => el.classList.remove(token));
|
|
192
|
-
spotlightAddedClassesRef.current.delete(el);
|
|
193
|
-
}
|
|
194
|
-
el.removeAttribute("data-scroll-wheel-center");
|
|
195
|
-
stripSpotlightFrameStyles(el);
|
|
196
|
-
}, []);
|
|
197
|
-
const moveSpotlightDom = React2.useCallback(
|
|
198
|
-
(next, tokens) => {
|
|
199
|
-
const prev = spotlightDomRef.current;
|
|
200
|
-
if (tokens.length === 0) {
|
|
201
|
-
if (prev) stripSpotlightFromEl(prev);
|
|
202
|
-
spotlightDomRef.current = null;
|
|
203
|
-
spotlightFingerprintRef.current = "";
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
if (!next) return;
|
|
207
|
-
if (prev && prev !== next) stripSpotlightFromEl(prev);
|
|
208
|
-
stripSpotlightFromEl(next);
|
|
209
|
-
const newlyAdded = /* @__PURE__ */ new Set();
|
|
210
|
-
for (const token of tokens) {
|
|
211
|
-
if (!next.classList.contains(token)) {
|
|
212
|
-
next.classList.add(token);
|
|
213
|
-
newlyAdded.add(token);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
if (newlyAdded.size > 0) {
|
|
217
|
-
spotlightAddedClassesRef.current.set(next, newlyAdded);
|
|
218
|
-
}
|
|
219
|
-
next.setAttribute("data-scroll-wheel-center", "");
|
|
220
|
-
applySpotlightFrameStyles(next);
|
|
221
|
-
spotlightDomRef.current = next;
|
|
222
|
-
},
|
|
223
|
-
[stripSpotlightFromEl]
|
|
224
|
-
);
|
|
225
|
-
const suppressingGesture = () => touchIdsOnRootRef.current.size > 0 || penPointerDownRef.current;
|
|
226
|
-
const runScrollCommitRef = React2.useRef(() => {
|
|
227
|
-
});
|
|
228
|
-
const tryCommitAfterGestureRef = React2.useRef(() => {
|
|
229
|
-
});
|
|
230
|
-
const clearSettleTimerRef = React2.useRef(() => {
|
|
231
|
-
});
|
|
232
|
-
const clearSettleTimer = React2.useCallback(() => {
|
|
233
|
-
if (settleTimerRef.current != null) {
|
|
234
|
-
clearTimeout(settleTimerRef.current);
|
|
235
|
-
settleTimerRef.current = null;
|
|
236
|
-
}
|
|
237
|
-
}, []);
|
|
238
|
-
clearSettleTimerRef.current = clearSettleTimer;
|
|
239
|
-
const applyProximityStyles = React2.useCallback(() => {
|
|
240
|
-
const root = rootRef.current;
|
|
241
|
-
if (!root) return;
|
|
242
|
-
const slots = root.querySelectorAll(itemSelector);
|
|
243
|
-
if (slots.length === 0) return;
|
|
244
|
-
const cr = root.getBoundingClientRect();
|
|
245
|
-
const mid = viewportCenter(horizontal, cr);
|
|
246
|
-
const half = halfMainViewport(horizontal, cr);
|
|
247
|
-
const nodes = [...slots];
|
|
248
|
-
const dists = nodes.map((node) => {
|
|
249
|
-
const r = node.getBoundingClientRect();
|
|
250
|
-
return Math.abs(itemCenter(horizontal, r) - mid);
|
|
251
|
-
});
|
|
252
|
-
let bestI = 0;
|
|
253
|
-
let bestD = Number.POSITIVE_INFINITY;
|
|
254
|
-
nodes.forEach((node, i) => {
|
|
255
|
-
const dist = dists[i];
|
|
256
|
-
const t = Math.min(1, dist / half);
|
|
257
|
-
node.style.transform = `scale(${1 - 0.42 * t})`;
|
|
258
|
-
node.style.opacity = String(1 - 0.52 * t);
|
|
259
|
-
if (dist < bestD) {
|
|
260
|
-
bestD = dist;
|
|
261
|
-
bestI = i;
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
if (!centerSpotlightActive) {
|
|
265
|
-
if (spotlightDomRef.current !== null || spotlightFingerprintRef.current !== "") {
|
|
266
|
-
moveSpotlightDom(null, []);
|
|
267
|
-
}
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
const selectedIdx = nodes.findIndex((n) => n.hasAttribute("data-selected"));
|
|
271
|
-
const el = nodes[bestI];
|
|
272
|
-
if (selectedIdx >= 0 && bestI !== selectedIdx && Date.now() < spotlightSuppressCenterMismatchUntilRef.current) {
|
|
273
|
-
if (spotlightDomRef.current !== null || spotlightFingerprintRef.current !== "") {
|
|
274
|
-
moveSpotlightDom(null, []);
|
|
275
|
-
}
|
|
276
|
-
spotlightFingerprintRef.current = "";
|
|
277
|
-
return;
|
|
278
|
-
}
|
|
279
|
-
if (el.hasAttribute("data-selected")) {
|
|
280
|
-
if (spotlightDomRef.current !== null || spotlightFingerprintRef.current !== "") {
|
|
281
|
-
moveSpotlightDom(null, []);
|
|
282
|
-
}
|
|
283
|
-
spotlightFingerprintRef.current = "";
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
const fp = centerSpotlightFingerprint;
|
|
287
|
-
if (el === spotlightDomRef.current && fp === spotlightFingerprintRef.current) {
|
|
288
|
-
applySpotlightFrameStyles(el);
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
291
|
-
moveSpotlightDom(el, centerSpotlightTokens);
|
|
292
|
-
spotlightFingerprintRef.current = fp;
|
|
293
|
-
}, [
|
|
294
|
-
horizontal,
|
|
295
|
-
centerSpotlightActive,
|
|
296
|
-
centerSpotlightTokens,
|
|
297
|
-
centerSpotlightFingerprint,
|
|
298
|
-
moveSpotlightDom
|
|
299
|
-
]);
|
|
300
|
-
const queueProximity = React2.useCallback(() => {
|
|
301
|
-
cancelAnimationFrame(rafProximityRef.current);
|
|
302
|
-
rafProximityRef.current = requestAnimationFrame(applyProximityStyles);
|
|
303
|
-
}, [applyProximityStyles]);
|
|
304
|
-
React2.useLayoutEffect(() => {
|
|
305
|
-
if (disabled === true) {
|
|
306
|
-
moveSpotlightDom(null, []);
|
|
307
|
-
spotlightFingerprintRef.current = "";
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
if (centerSpotlightActive) {
|
|
311
|
-
queueProximity();
|
|
312
|
-
}
|
|
313
|
-
}, [disabled, centerSpotlightActive, moveSpotlightDom, queueProximity]);
|
|
314
|
-
const applyWheelPadding = React2.useCallback(() => {
|
|
315
|
-
const list = listRef.current;
|
|
316
|
-
const root = rootRef.current;
|
|
317
|
-
if (!list || !root) return;
|
|
318
|
-
const slot = root.querySelector(itemSelector);
|
|
319
|
-
if (!slot) return;
|
|
320
|
-
applyEndPadding(horizontal, list, root, slot.getBoundingClientRect());
|
|
321
|
-
}, [horizontal]);
|
|
322
|
-
const findBestIndex = React2.useCallback(() => {
|
|
323
|
-
const root = rootRef.current;
|
|
324
|
-
if (!root) return -1;
|
|
325
|
-
if (mainClientSize(horizontal, root) < MAIN_AXIS_MIN_PX) return -1;
|
|
326
|
-
const slots = [...root.querySelectorAll(itemSelector)];
|
|
327
|
-
if (slots.length === 0) return -1;
|
|
328
|
-
const cr = root.getBoundingClientRect();
|
|
329
|
-
if (mainViewportRect(horizontal, cr) < MAIN_AXIS_MIN_PX) return -1;
|
|
330
|
-
const mid = viewportCenter(horizontal, cr);
|
|
331
|
-
let best = 0;
|
|
332
|
-
let bestD = Number.POSITIVE_INFINITY;
|
|
333
|
-
slots.forEach((node, i) => {
|
|
334
|
-
const d = Math.abs(itemCenter(horizontal, node.getBoundingClientRect()) - mid);
|
|
335
|
-
if (d < bestD) {
|
|
336
|
-
bestD = d;
|
|
337
|
-
best = i;
|
|
338
|
-
}
|
|
339
|
-
});
|
|
340
|
-
return best;
|
|
341
|
-
}, [horizontal]);
|
|
342
|
-
const clampWheelScroll = React2.useCallback(() => {
|
|
343
|
-
const root = rootRef.current;
|
|
344
|
-
if (!root || mainClientSize(horizontal, root) < MAIN_AXIS_MIN_PX) return;
|
|
345
|
-
const slots = [...root.querySelectorAll(itemSelector)];
|
|
346
|
-
if (slots.length < 2) return;
|
|
347
|
-
for (let i = 0; i < CLAMP_ITERS; i += 1) {
|
|
348
|
-
const rootRect = root.getBoundingClientRect();
|
|
349
|
-
const mid = viewportCenter(horizontal, rootRect);
|
|
350
|
-
const fr = slots[0].getBoundingClientRect();
|
|
351
|
-
const lr = slots[slots.length - 1].getBoundingClientRect();
|
|
352
|
-
const firstMid = itemCenter(horizontal, fr);
|
|
353
|
-
const lastMid = itemCenter(horizontal, lr);
|
|
354
|
-
if (firstMid > mid + CLAMP_EPS) {
|
|
355
|
-
suppressSettleUntilRef.current = Date.now() + WHEEL_SETTLE_SUPPRESS_MS;
|
|
356
|
-
addScroll(horizontal, root, firstMid - mid);
|
|
357
|
-
continue;
|
|
358
|
-
}
|
|
359
|
-
if (lastMid < mid - CLAMP_EPS) {
|
|
360
|
-
suppressSettleUntilRef.current = Date.now() + WHEEL_SETTLE_SUPPRESS_MS;
|
|
361
|
-
addScroll(horizontal, root, lastMid - mid);
|
|
362
|
-
continue;
|
|
363
|
-
}
|
|
364
|
-
break;
|
|
365
|
-
}
|
|
366
|
-
}, [horizontal]);
|
|
367
|
-
const runScrollCommit = React2.useCallback(() => {
|
|
368
|
-
if (suppressingGesture() || !onScrollSettle || disabled) return;
|
|
369
|
-
if (Date.now() < suppressSettleUntilRef.current) return;
|
|
370
|
-
clampWheelScroll();
|
|
371
|
-
const idx = findBestIndex();
|
|
372
|
-
if (idx < 0) return;
|
|
373
|
-
if (idx !== lastSettledIdxRef.current) {
|
|
374
|
-
lastSettledIdxRef.current = idx;
|
|
375
|
-
onScrollSettle(idx);
|
|
376
|
-
}
|
|
377
|
-
queueProximity();
|
|
378
|
-
}, [onScrollSettle, disabled, findBestIndex, queueProximity, clampWheelScroll]);
|
|
379
|
-
runScrollCommitRef.current = runScrollCommit;
|
|
380
|
-
const scrollSelectedToCenter = React2.useCallback(
|
|
381
|
-
(scrollBehavior = "auto") => {
|
|
382
|
-
const root = rootRef.current;
|
|
383
|
-
if (!root) return;
|
|
384
|
-
const selected = root.querySelector(selectedItemSelector);
|
|
385
|
-
lastSettledIdxRef.current = null;
|
|
386
|
-
suppressSettleUntilRef.current = Date.now() + (scrollBehavior === "smooth" ? WHEEL_SMOOTH_SCROLL_SUPPRESS_MS : WHEEL_SETTLE_SUPPRESS_MS);
|
|
387
|
-
if (selected) {
|
|
388
|
-
const rootRect = root.getBoundingClientRect();
|
|
389
|
-
const sr = selected.getBoundingClientRect();
|
|
390
|
-
const delta = itemCenter(horizontal, sr) - viewportCenter(horizontal, rootRect);
|
|
391
|
-
setScroll(
|
|
392
|
-
horizontal,
|
|
393
|
-
root,
|
|
394
|
-
readScroll(horizontal, root) + delta,
|
|
395
|
-
scrollBehavior
|
|
396
|
-
);
|
|
397
|
-
}
|
|
398
|
-
queueProximity();
|
|
399
|
-
},
|
|
400
|
-
[horizontal, queueProximity]
|
|
401
|
-
);
|
|
402
|
-
const scheduleIdleSettle = React2.useCallback(() => {
|
|
403
|
-
if (!onScrollSettle || disabled || suppressingGesture()) return;
|
|
404
|
-
clearSettleTimer();
|
|
405
|
-
settleTimerRef.current = setTimeout(
|
|
406
|
-
runScrollCommit,
|
|
407
|
-
SCROLL_END_SUPPORTED ? WHEEL_SETTLE_SCROLLEND_BACKUP_MS : WHEEL_SETTLE_IDLE_MS
|
|
408
|
-
);
|
|
409
|
-
}, [onScrollSettle, disabled, clearSettleTimer, runScrollCommit]);
|
|
410
|
-
const tryCommitAfterGestureRelease = React2.useCallback(() => {
|
|
411
|
-
if (suppressingGesture()) return;
|
|
412
|
-
const root = rootRef.current;
|
|
413
|
-
if (!root) return;
|
|
414
|
-
const s0 = readScroll(horizontal, root);
|
|
415
|
-
requestAnimationFrame(() => {
|
|
416
|
-
requestAnimationFrame(() => {
|
|
417
|
-
if (suppressingGesture()) return;
|
|
418
|
-
const r = rootRef.current;
|
|
419
|
-
if (!r) return;
|
|
420
|
-
if (readScroll(horizontal, r) !== s0) {
|
|
421
|
-
queueProximity();
|
|
422
|
-
scheduleIdleSettle();
|
|
423
|
-
return;
|
|
424
|
-
}
|
|
425
|
-
runScrollCommit();
|
|
426
|
-
});
|
|
427
|
-
});
|
|
428
|
-
}, [horizontal, runScrollCommit, scheduleIdleSettle, queueProximity]);
|
|
429
|
-
tryCommitAfterGestureRef.current = tryCommitAfterGestureRelease;
|
|
430
|
-
const onPointerDownCapture = React2.useCallback(
|
|
431
|
-
(e) => {
|
|
432
|
-
if (!onScrollSettle || disabled || e.pointerType !== "pen") return;
|
|
433
|
-
penPointerDownRef.current = true;
|
|
434
|
-
clearSettleTimer();
|
|
435
|
-
},
|
|
436
|
-
[onScrollSettle, disabled, clearSettleTimer]
|
|
437
|
-
);
|
|
438
|
-
const onTouchStartCapture = React2.useCallback(
|
|
439
|
-
(e) => {
|
|
440
|
-
if (!onScrollSettle || disabled) return;
|
|
441
|
-
for (let i = 0; i < e.changedTouches.length; i += 1) {
|
|
442
|
-
touchIdsOnRootRef.current.add(e.changedTouches[i].identifier);
|
|
443
|
-
}
|
|
444
|
-
clearSettleTimer();
|
|
445
|
-
},
|
|
446
|
-
[onScrollSettle, disabled, clearSettleTimer]
|
|
447
|
-
);
|
|
448
|
-
const onScroll = React2.useCallback(() => {
|
|
449
|
-
queueProximity();
|
|
450
|
-
if (!onScrollSettle || disabled) return;
|
|
451
|
-
if (suppressingGesture()) clearSettleTimer();
|
|
452
|
-
else scheduleIdleSettle();
|
|
453
|
-
}, [queueProximity, onScrollSettle, disabled, clearSettleTimer, scheduleIdleSettle]);
|
|
454
|
-
React2.useEffect(() => {
|
|
455
|
-
if (disabled || !onScrollSettle) return;
|
|
456
|
-
const onPenEnd = (e) => {
|
|
457
|
-
if (e.pointerType !== "pen" || !penPointerDownRef.current) return;
|
|
458
|
-
penPointerDownRef.current = false;
|
|
459
|
-
tryCommitAfterGestureRef.current();
|
|
460
|
-
};
|
|
461
|
-
const onTouchEnd = (e) => {
|
|
462
|
-
for (let i = 0; i < e.changedTouches.length; i += 1) {
|
|
463
|
-
touchIdsOnRootRef.current.delete(e.changedTouches[i].identifier);
|
|
464
|
-
}
|
|
465
|
-
if (touchIdsOnRootRef.current.size === 0) tryCommitAfterGestureRef.current();
|
|
466
|
-
};
|
|
467
|
-
window.addEventListener("pointerup", onPenEnd, true);
|
|
468
|
-
window.addEventListener("pointercancel", onPenEnd, true);
|
|
469
|
-
window.addEventListener("touchend", onTouchEnd, true);
|
|
470
|
-
window.addEventListener("touchcancel", onTouchEnd, true);
|
|
471
|
-
return () => {
|
|
472
|
-
window.removeEventListener("pointerup", onPenEnd, true);
|
|
473
|
-
window.removeEventListener("pointercancel", onPenEnd, true);
|
|
474
|
-
window.removeEventListener("touchend", onTouchEnd, true);
|
|
475
|
-
window.removeEventListener("touchcancel", onTouchEnd, true);
|
|
476
|
-
};
|
|
477
|
-
}, [disabled, onScrollSettle]);
|
|
478
|
-
React2.useLayoutEffect(() => {
|
|
479
|
-
let followRaf1 = 0;
|
|
480
|
-
let followRaf2 = 0;
|
|
481
|
-
let ro;
|
|
482
|
-
const root = rootRef.current;
|
|
483
|
-
if (!root) return;
|
|
484
|
-
const onResize = () => {
|
|
485
|
-
applyWheelPadding();
|
|
486
|
-
queueProximity();
|
|
487
|
-
};
|
|
488
|
-
onResize();
|
|
489
|
-
const prev = prevRecenterKeyRef.current;
|
|
490
|
-
const firstOpen = !wasPopoverOpenRef.current;
|
|
491
|
-
const selectionChanged = wasPopoverOpenRef.current && prev !== void 0 && prev !== recenterKey;
|
|
492
|
-
if (firstOpen || selectionChanged) {
|
|
493
|
-
if (selectionChanged) {
|
|
494
|
-
spotlightSuppressCenterMismatchUntilRef.current = Date.now() + SPOTLIGHT_CENTER_MISMATCH_SUPPRESS_MS;
|
|
495
|
-
}
|
|
496
|
-
const reducedMotion = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
497
|
-
const behavior = selectionChanged && !reducedMotion ? "smooth" : "auto";
|
|
498
|
-
scrollSelectedToCenter(behavior);
|
|
499
|
-
if (firstOpen) {
|
|
500
|
-
followRaf1 = requestAnimationFrame(() => {
|
|
501
|
-
followRaf2 = requestAnimationFrame(() => {
|
|
502
|
-
scrollSelectedToCenter("auto");
|
|
503
|
-
});
|
|
504
|
-
});
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
prevRecenterKeyRef.current = recenterKey;
|
|
508
|
-
wasPopoverOpenRef.current = true;
|
|
509
|
-
if (typeof ResizeObserver !== "undefined") {
|
|
510
|
-
ro = new ResizeObserver(onResize);
|
|
511
|
-
ro.observe(root);
|
|
512
|
-
}
|
|
513
|
-
return () => {
|
|
514
|
-
ro?.disconnect();
|
|
515
|
-
cancelAnimationFrame(followRaf1);
|
|
516
|
-
cancelAnimationFrame(followRaf2);
|
|
517
|
-
};
|
|
518
|
-
}, [
|
|
519
|
-
recenterKey,
|
|
520
|
-
orientation,
|
|
521
|
-
centerSpotlightClassName,
|
|
522
|
-
applyWheelPadding,
|
|
523
|
-
scrollSelectedToCenter,
|
|
524
|
-
queueProximity
|
|
525
|
-
]);
|
|
526
|
-
React2.useLayoutEffect(() => {
|
|
527
|
-
return () => {
|
|
528
|
-
penPointerDownRef.current = false;
|
|
529
|
-
touchIdsOnRootRef.current.clear();
|
|
530
|
-
wasPopoverOpenRef.current = false;
|
|
531
|
-
prevRecenterKeyRef.current = void 0;
|
|
532
|
-
lastSettledIdxRef.current = null;
|
|
533
|
-
spotlightSuppressCenterMismatchUntilRef.current = 0;
|
|
534
|
-
moveSpotlightDom(null, []);
|
|
535
|
-
clearSettleTimer();
|
|
536
|
-
cancelAnimationFrame(rafProximityRef.current);
|
|
537
|
-
};
|
|
538
|
-
}, []);
|
|
539
|
-
React2.useLayoutEffect(() => {
|
|
540
|
-
if (!onScrollSettle || disabled || !SCROLL_END_SUPPORTED) return;
|
|
541
|
-
const root = rootRef.current;
|
|
542
|
-
if (!root) return;
|
|
543
|
-
const onScrollEnd = () => {
|
|
544
|
-
if (suppressingGesture()) return;
|
|
545
|
-
clearSettleTimerRef.current();
|
|
546
|
-
runScrollCommitRef.current();
|
|
547
|
-
};
|
|
548
|
-
root.addEventListener("scrollend", onScrollEnd);
|
|
549
|
-
return () => root.removeEventListener("scrollend", onScrollEnd);
|
|
550
|
-
}, [disabled, onScrollSettle]);
|
|
551
|
-
React2.useLayoutEffect(() => {
|
|
552
|
-
if (!centerSpotlightActive) return;
|
|
553
|
-
queueProximity();
|
|
554
|
-
}, [centerSpotlightActive, children, queueProximity]);
|
|
555
|
-
const fadeClasses = FADE_EDGES[orientation];
|
|
556
|
-
return /* @__PURE__ */ jsx(
|
|
557
|
-
"div",
|
|
558
|
-
{
|
|
559
|
-
className: cn(
|
|
560
|
-
"relative z-2 flex h-full min-h-0 min-w-0 flex-1 basis-0 overflow-hidden",
|
|
561
|
-
horizontal ? "flex-row" : "flex-col",
|
|
562
|
-
className
|
|
563
|
-
),
|
|
564
|
-
"data-scroll-wheel-orientation": orientation,
|
|
565
|
-
children: /* @__PURE__ */ jsxs(
|
|
566
|
-
"div",
|
|
567
|
-
{
|
|
568
|
-
className: cn(
|
|
569
|
-
"relative isolate flex min-h-0 min-w-0 flex-1",
|
|
570
|
-
horizontal ? "flex-row" : "flex-col"
|
|
571
|
-
),
|
|
572
|
-
children: [
|
|
573
|
-
/* @__PURE__ */ jsx(
|
|
574
|
-
"div",
|
|
575
|
-
{
|
|
576
|
-
ref: rootRef,
|
|
577
|
-
className: cn(
|
|
578
|
-
"relative z-0 min-h-0 min-w-0 flex-1 [-ms-overflow-style:none] [scrollbar-width:none] [-webkit-overflow-scrolling:touch] [&::-webkit-scrollbar]:hidden",
|
|
579
|
-
horizontal ? "overflow-x-auto overflow-y-hidden overscroll-x-contain" : "overflow-y-auto overflow-x-hidden overscroll-y-contain"
|
|
580
|
-
),
|
|
581
|
-
onPointerDownCapture,
|
|
582
|
-
onTouchStartCapture,
|
|
583
|
-
onScroll,
|
|
584
|
-
children: /* @__PURE__ */ jsx(
|
|
585
|
-
"div",
|
|
586
|
-
{
|
|
587
|
-
ref: listRef,
|
|
588
|
-
className: cn(
|
|
589
|
-
"flex gap-0.5",
|
|
590
|
-
horizontal ? "min-w-min flex-row flex-nowrap items-center gap-0.5 py-0 pl-2 pr-2 [&>[data-scroll-wheel-item]]:shrink-0" : "min-h-0 flex-col px-2 pb-2"
|
|
591
|
-
),
|
|
592
|
-
children
|
|
593
|
-
}
|
|
594
|
-
)
|
|
595
|
-
}
|
|
596
|
-
),
|
|
597
|
-
fadeClasses.map((cls, i) => /* @__PURE__ */ jsx("div", { className: cls, "aria-hidden": true }, i))
|
|
598
|
-
]
|
|
599
|
-
}
|
|
600
|
-
)
|
|
601
|
-
}
|
|
602
|
-
);
|
|
603
|
-
}
|
|
604
|
-
var ScrollWheelMemo = React2.memo(ScrollWheelRoot);
|
|
605
|
-
ScrollWheelMemo.displayName = "ScrollWheel";
|
|
606
|
-
var ScrollWheel = Object.assign(ScrollWheelMemo, {
|
|
607
|
-
/** Marker props for each wheel row — spread onto the focusable control. */
|
|
608
|
-
itemProps: scrollWheelItemProps
|
|
609
|
-
});
|
|
610
|
-
var HOURS_12 = Array.from({ length: 12 }, (_, i) => i + 1);
|
|
611
|
-
var MINUTES = Array.from({ length: 12 }, (_, i) => i * 5);
|
|
612
|
-
var AMPM = ["AM", "PM"];
|
|
613
|
-
function startOfLocalDay(d) {
|
|
614
|
-
const n = new Date(d);
|
|
615
|
-
n.setHours(0, 0, 0, 0);
|
|
616
|
-
return n;
|
|
617
|
-
}
|
|
618
|
-
function baseDateForTimePick(value) {
|
|
619
|
-
return value ?? startOfLocalDay(/* @__PURE__ */ new Date());
|
|
620
|
-
}
|
|
621
|
-
function setHour12(d, hour12) {
|
|
622
|
-
const n = new Date(d);
|
|
623
|
-
const pm = n.getHours() >= 12;
|
|
624
|
-
n.setHours(hour12 % 12 + (pm ? 12 : 0));
|
|
625
|
-
return n;
|
|
626
|
-
}
|
|
627
|
-
function setMinute(d, m) {
|
|
628
|
-
const n = new Date(d);
|
|
629
|
-
n.setMinutes(m);
|
|
630
|
-
return n;
|
|
631
|
-
}
|
|
632
|
-
function setAmPm(d, ampm) {
|
|
633
|
-
const n = new Date(d);
|
|
634
|
-
const h = n.getHours();
|
|
635
|
-
if (ampm === "PM" && h < 12) n.setHours(h + 12);
|
|
636
|
-
if (ampm === "AM" && h >= 12) n.setHours(h - 12);
|
|
637
|
-
return n;
|
|
638
|
-
}
|
|
639
|
-
var TIME_RAIL_CENTER_BAND_HEIGHT_CLASS = "h-[3.25rem]";
|
|
640
|
-
var SCROLL_WHEEL_CENTER_SPOTLIGHT_CLASSNAME = "relative z-10 border-primary/40";
|
|
641
|
-
var slotClass = cn(
|
|
642
|
-
"box-border flex aspect-square w-full min-h-0 min-w-0 origin-center shrink-0 flex-col justify-center border border-transparent p-3.5 text-base tracking-normal shadow-none will-change-transform",
|
|
643
|
-
"gap-0 leading-none !font-normal !h-auto ![transition-property:color,background-color,box-shadow,opacity]",
|
|
644
|
-
"focus-visible:border-transparent focus-visible:ring-0"
|
|
645
|
-
);
|
|
646
|
-
var slotClassHorizontalCircular = cn(
|
|
647
|
-
slotClass,
|
|
648
|
-
"!box-border !aspect-square !h-[3.25rem] !w-[3.25rem] !max-h-[3.25rem] !max-w-[3.25rem] !min-h-0 !min-w-0 shrink-0"
|
|
649
|
-
);
|
|
650
|
-
function TimePicker({
|
|
651
|
-
value,
|
|
652
|
-
onChange,
|
|
653
|
-
disabled,
|
|
654
|
-
orientation = "vertical",
|
|
655
|
-
className
|
|
656
|
-
}) {
|
|
657
|
-
const horizontal = orientation === "horizontal";
|
|
658
|
-
const onHourScrollSettle = React2.useCallback(
|
|
659
|
-
(idx) => {
|
|
660
|
-
const h = HOURS_12[idx];
|
|
661
|
-
if (h === void 0) return;
|
|
662
|
-
const base = baseDateForTimePick(value);
|
|
663
|
-
if (value && value.getHours() % 12 === h % 12) return;
|
|
664
|
-
onChange(setHour12(base, h));
|
|
665
|
-
},
|
|
666
|
-
[value, onChange]
|
|
667
|
-
);
|
|
668
|
-
const onMinuteScrollSettle = React2.useCallback(
|
|
669
|
-
(idx) => {
|
|
670
|
-
const m = MINUTES[idx];
|
|
671
|
-
if (m === void 0) return;
|
|
672
|
-
const base = baseDateForTimePick(value);
|
|
673
|
-
if (value && value.getMinutes() === m) return;
|
|
674
|
-
onChange(setMinute(base, m));
|
|
675
|
-
},
|
|
676
|
-
[value, onChange]
|
|
677
|
-
);
|
|
678
|
-
const onAmPmScrollSettle = React2.useCallback(
|
|
679
|
-
(idx) => {
|
|
680
|
-
const a = AMPM[idx];
|
|
681
|
-
if (a === void 0) return;
|
|
682
|
-
const base = baseDateForTimePick(value);
|
|
683
|
-
if (value) {
|
|
684
|
-
const pm = value.getHours() >= 12;
|
|
685
|
-
if (a === "PM" === pm) return;
|
|
686
|
-
}
|
|
687
|
-
onChange(setAmPm(base, a));
|
|
688
|
-
},
|
|
689
|
-
[value, onChange]
|
|
690
|
-
);
|
|
691
|
-
const hourSlots = React2.useMemo(
|
|
692
|
-
() => HOURS_12.map((h) => {
|
|
693
|
-
const selected = Boolean(value) && value.getHours() % 12 === h % 12;
|
|
694
|
-
return /* @__PURE__ */ jsx(
|
|
695
|
-
Button,
|
|
696
|
-
{
|
|
697
|
-
type: "button",
|
|
698
|
-
rounded: "full",
|
|
699
|
-
variant: selected ? "primary" : "secondary",
|
|
700
|
-
disabled,
|
|
701
|
-
className: horizontal ? slotClassHorizontalCircular : slotClass,
|
|
702
|
-
...ScrollWheel.itemProps,
|
|
703
|
-
...selected ? { "data-selected": true } : {},
|
|
704
|
-
onClick: () => onChange(setHour12(baseDateForTimePick(value), h)),
|
|
705
|
-
children: /* @__PURE__ */ jsx("span", { className: "tabular-nums", children: h })
|
|
706
|
-
},
|
|
707
|
-
h
|
|
708
|
-
);
|
|
709
|
-
}),
|
|
710
|
-
[value, disabled, onChange, horizontal]
|
|
711
|
-
);
|
|
712
|
-
const minuteSlots = React2.useMemo(
|
|
713
|
-
() => MINUTES.map((m) => {
|
|
714
|
-
const selected = Boolean(value) && value.getMinutes() === m;
|
|
715
|
-
return /* @__PURE__ */ jsx(
|
|
716
|
-
Button,
|
|
717
|
-
{
|
|
718
|
-
type: "button",
|
|
719
|
-
rounded: "full",
|
|
720
|
-
variant: selected ? "primary" : "secondary",
|
|
721
|
-
disabled,
|
|
722
|
-
className: horizontal ? slotClassHorizontalCircular : slotClass,
|
|
723
|
-
...ScrollWheel.itemProps,
|
|
724
|
-
...selected ? { "data-selected": true } : {},
|
|
725
|
-
onClick: () => onChange(setMinute(baseDateForTimePick(value), m)),
|
|
726
|
-
children: /* @__PURE__ */ jsx("span", { className: "tabular-nums", children: String(m).padStart(2, "0") })
|
|
727
|
-
},
|
|
728
|
-
m
|
|
729
|
-
);
|
|
730
|
-
}),
|
|
731
|
-
[value, disabled, onChange, horizontal]
|
|
732
|
-
);
|
|
733
|
-
const amPmSlots = React2.useMemo(
|
|
734
|
-
() => AMPM.map((a) => {
|
|
735
|
-
const selected = Boolean(
|
|
736
|
-
value && (a === "AM" && value.getHours() < 12 || a === "PM" && value.getHours() >= 12)
|
|
737
|
-
);
|
|
738
|
-
return /* @__PURE__ */ jsx(
|
|
739
|
-
Button,
|
|
740
|
-
{
|
|
741
|
-
type: "button",
|
|
742
|
-
rounded: "full",
|
|
743
|
-
variant: selected ? "primary" : "secondary",
|
|
744
|
-
disabled,
|
|
745
|
-
className: horizontal ? slotClassHorizontalCircular : slotClass,
|
|
746
|
-
...ScrollWheel.itemProps,
|
|
747
|
-
...selected ? { "data-selected": true } : {},
|
|
748
|
-
onClick: () => onChange(setAmPm(baseDateForTimePick(value), a)),
|
|
749
|
-
children: /* @__PURE__ */ jsx("span", { className: "text-sm font-normal tracking-wide", children: a })
|
|
750
|
-
},
|
|
751
|
-
a
|
|
752
|
-
);
|
|
753
|
-
}),
|
|
754
|
-
[value, disabled, onChange, horizontal]
|
|
755
|
-
);
|
|
756
|
-
const hourRecenterKey = React2.useMemo(
|
|
757
|
-
() => value ? value.getHours() : "n",
|
|
758
|
-
[value]
|
|
759
|
-
);
|
|
760
|
-
const minuteRecenterKey = React2.useMemo(
|
|
761
|
-
() => value ? value.getMinutes() : "n",
|
|
762
|
-
[value]
|
|
763
|
-
);
|
|
764
|
-
const amPmRecenterKey = React2.useMemo(
|
|
765
|
-
() => value ? value.getHours() >= 12 ? "pm" : "am" : "n",
|
|
766
|
-
[value]
|
|
767
|
-
);
|
|
768
|
-
const horizontalCenterColumnClass = "pointer-events-none absolute inset-y-2 left-1/2 z-1 w-[3.25rem] -translate-x-1/2 rounded-full bg-accent/88 dark:bg-accent/72";
|
|
769
|
-
const verticalCenterBandClass = cn(
|
|
770
|
-
"pointer-events-none absolute top-1/2 left-2 right-2 z-1 -translate-y-1/2 rounded-full bg-accent/88 dark:bg-accent/72",
|
|
771
|
-
TIME_RAIL_CENTER_BAND_HEIGHT_CLASS
|
|
772
|
-
);
|
|
773
|
-
if (horizontal) {
|
|
774
|
-
return /* @__PURE__ */ jsxs(
|
|
775
|
-
"div",
|
|
776
|
-
{
|
|
777
|
-
className: cn(
|
|
778
|
-
"border-border/60 relative flex h-full min-h-0 min-w-0 flex-1 shrink-0 flex-col divide-y divide-border/60 overflow-hidden border-t",
|
|
779
|
-
className
|
|
780
|
-
),
|
|
781
|
-
children: [
|
|
782
|
-
/* @__PURE__ */ jsx("div", { "aria-hidden": true, className: horizontalCenterColumnClass }),
|
|
783
|
-
[
|
|
784
|
-
[hourSlots, hourRecenterKey, onHourScrollSettle],
|
|
785
|
-
[minuteSlots, minuteRecenterKey, onMinuteScrollSettle],
|
|
786
|
-
[amPmSlots, amPmRecenterKey, onAmPmScrollSettle]
|
|
787
|
-
].map(([slots, recenterKey, onSettle], i) => /* @__PURE__ */ jsx(
|
|
788
|
-
"div",
|
|
789
|
-
{
|
|
790
|
-
className: "relative flex w-full shrink-0 flex-col overflow-hidden py-2",
|
|
791
|
-
children: /* @__PURE__ */ jsx(
|
|
792
|
-
ScrollWheel,
|
|
793
|
-
{
|
|
794
|
-
orientation: "horizontal",
|
|
795
|
-
disabled,
|
|
796
|
-
centerSpotlightClassName: SCROLL_WHEEL_CENTER_SPOTLIGHT_CLASSNAME,
|
|
797
|
-
className: "h-[3.25rem] min-h-[3.25rem] w-full shrink-0",
|
|
798
|
-
recenterKey,
|
|
799
|
-
onScrollSettle: disabled ? void 0 : onSettle,
|
|
800
|
-
children: slots
|
|
801
|
-
}
|
|
802
|
-
)
|
|
803
|
-
},
|
|
804
|
-
i
|
|
805
|
-
))
|
|
806
|
-
]
|
|
807
|
-
}
|
|
808
|
-
);
|
|
809
|
-
}
|
|
810
|
-
return /* @__PURE__ */ jsxs(
|
|
811
|
-
"div",
|
|
812
|
-
{
|
|
813
|
-
className: cn(
|
|
814
|
-
"border-border/60 relative flex h-full min-h-0 min-w-0 flex-1 shrink-0 flex-row divide-x divide-border/60 overflow-hidden border-l",
|
|
815
|
-
className
|
|
816
|
-
),
|
|
817
|
-
children: [
|
|
818
|
-
/* @__PURE__ */ jsx("div", { "aria-hidden": true, className: verticalCenterBandClass }),
|
|
819
|
-
/* @__PURE__ */ jsx(
|
|
820
|
-
ScrollWheel,
|
|
821
|
-
{
|
|
822
|
-
disabled,
|
|
823
|
-
centerSpotlightClassName: SCROLL_WHEEL_CENTER_SPOTLIGHT_CLASSNAME,
|
|
824
|
-
recenterKey: hourRecenterKey,
|
|
825
|
-
onScrollSettle: disabled ? void 0 : onHourScrollSettle,
|
|
826
|
-
children: hourSlots
|
|
827
|
-
}
|
|
828
|
-
),
|
|
829
|
-
/* @__PURE__ */ jsx(
|
|
830
|
-
ScrollWheel,
|
|
831
|
-
{
|
|
832
|
-
disabled,
|
|
833
|
-
centerSpotlightClassName: SCROLL_WHEEL_CENTER_SPOTLIGHT_CLASSNAME,
|
|
834
|
-
recenterKey: minuteRecenterKey,
|
|
835
|
-
onScrollSettle: disabled ? void 0 : onMinuteScrollSettle,
|
|
836
|
-
children: minuteSlots
|
|
837
|
-
}
|
|
838
|
-
),
|
|
839
|
-
/* @__PURE__ */ jsx(
|
|
840
|
-
ScrollWheel,
|
|
841
|
-
{
|
|
842
|
-
disabled,
|
|
843
|
-
centerSpotlightClassName: SCROLL_WHEEL_CENTER_SPOTLIGHT_CLASSNAME,
|
|
844
|
-
recenterKey: amPmRecenterKey,
|
|
845
|
-
onScrollSettle: disabled ? void 0 : onAmPmScrollSettle,
|
|
846
|
-
children: amPmSlots
|
|
847
|
-
}
|
|
848
|
-
)
|
|
849
|
-
]
|
|
850
|
-
}
|
|
851
|
-
);
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
export { TimePicker, baseDateForTimePick };
|
|
855
|
-
//# sourceMappingURL=time-picker.js.map
|
|
856
|
-
//# sourceMappingURL=time-picker.js.map
|