@mlw-packages/react-components 1.9.0 → 1.9.2
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 +0 -111
- package/dist/index.css +20 -5
- package/dist/index.js +111 -210
- package/dist/index.mjs +111 -210
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -123,117 +123,6 @@ Use **Controls** para testar props dinamicamente e **Docs** para copiar snippets
|
|
|
123
123
|
|
|
124
124
|
---
|
|
125
125
|
|
|
126
|
-
### Lista completa de componentes
|
|
127
|
-
|
|
128
|
-
Abaixo está a lista completa de componentes :
|
|
129
|
-
|
|
130
|
-
- AlertDialog
|
|
131
|
-
|
|
132
|
-
- Avatar
|
|
133
|
-
|
|
134
|
-
- Badge
|
|
135
|
-
|
|
136
|
-
- BarChart
|
|
137
|
-
|
|
138
|
-
- Breadcrumb
|
|
139
|
-
|
|
140
|
-
- Button
|
|
141
|
-
|
|
142
|
-
- Calendar
|
|
143
|
-
|
|
144
|
-
- Card
|
|
145
|
-
|
|
146
|
-
- Carousel
|
|
147
|
-
|
|
148
|
-
- Chart
|
|
149
|
-
|
|
150
|
-
- CheckBox
|
|
151
|
-
|
|
152
|
-
- Collapsible
|
|
153
|
-
|
|
154
|
-
- Combobox
|
|
155
|
-
|
|
156
|
-
- ComboboxBase
|
|
157
|
-
|
|
158
|
-
- Command
|
|
159
|
-
|
|
160
|
-
- ContextMenu
|
|
161
|
-
|
|
162
|
-
- DateTimePicker
|
|
163
|
-
|
|
164
|
-
- DebouncedInput
|
|
165
|
-
|
|
166
|
-
- DestructiveDialog
|
|
167
|
-
|
|
168
|
-
- Dialog
|
|
169
|
-
|
|
170
|
-
- DraggableTooltip
|
|
171
|
-
|
|
172
|
-
- Drawer
|
|
173
|
-
|
|
174
|
-
- DropDownMenu
|
|
175
|
-
|
|
176
|
-
- FileUploader
|
|
177
|
-
|
|
178
|
-
- Filter
|
|
179
|
-
|
|
180
|
-
- Home
|
|
181
|
-
|
|
182
|
-
- HoverCard
|
|
183
|
-
|
|
184
|
-
- Input
|
|
185
|
-
|
|
186
|
-
- Input-OTP
|
|
187
|
-
|
|
188
|
-
- Label
|
|
189
|
-
|
|
190
|
-
- LineChart
|
|
191
|
-
|
|
192
|
-
- Loading
|
|
193
|
-
|
|
194
|
-
- Modal
|
|
195
|
-
|
|
196
|
-
- ModeToggle
|
|
197
|
-
|
|
198
|
-
- MultiCombobox
|
|
199
|
-
|
|
200
|
-
- NavigationMenu
|
|
201
|
-
|
|
202
|
-
- PieChart
|
|
203
|
-
|
|
204
|
-
- Popover
|
|
205
|
-
|
|
206
|
-
- rogress
|
|
207
|
-
|
|
208
|
-
- RangePicker
|
|
209
|
-
|
|
210
|
-
- Scrollarea
|
|
211
|
-
|
|
212
|
-
- Select
|
|
213
|
-
|
|
214
|
-
- Separator
|
|
215
|
-
|
|
216
|
-
- Sheet
|
|
217
|
-
|
|
218
|
-
- Sidebar
|
|
219
|
-
|
|
220
|
-
- Skeleton
|
|
221
|
-
|
|
222
|
-
- Slider
|
|
223
|
-
|
|
224
|
-
- Sonner
|
|
225
|
-
|
|
226
|
-
- Switch
|
|
227
|
-
|
|
228
|
-
- Table
|
|
229
|
-
|
|
230
|
-
- Tabs
|
|
231
|
-
|
|
232
|
-
- TextArea
|
|
233
|
-
|
|
234
|
-
- Tooltip
|
|
235
|
-
|
|
236
|
-
---
|
|
237
126
|
|
|
238
127
|
## Desenvolvimento local
|
|
239
128
|
|
package/dist/index.css
CHANGED
|
@@ -1043,11 +1043,14 @@ body {
|
|
|
1043
1043
|
.max-h-\[--radix-popover-content-available-height\] {
|
|
1044
1044
|
max-height: var(--radix-popover-content-available-height);
|
|
1045
1045
|
}
|
|
1046
|
+
.max-h-\[100dvh\] {
|
|
1047
|
+
max-height: 100dvh;
|
|
1048
|
+
}
|
|
1046
1049
|
.max-h-\[300px\] {
|
|
1047
1050
|
max-height: 300px;
|
|
1048
1051
|
}
|
|
1049
|
-
.max-h-\[
|
|
1050
|
-
max-height:
|
|
1052
|
+
.max-h-\[95vh\] {
|
|
1053
|
+
max-height: 95vh;
|
|
1051
1054
|
}
|
|
1052
1055
|
.max-h-\[calc\(100dvh-2rem\)\] {
|
|
1053
1056
|
max-height: calc(100dvh - 2rem);
|
|
@@ -1613,6 +1616,15 @@ body {
|
|
|
1613
1616
|
.resize {
|
|
1614
1617
|
resize: both;
|
|
1615
1618
|
}
|
|
1619
|
+
.snap-y {
|
|
1620
|
+
scroll-snap-type: y var(--tw-scroll-snap-strictness);
|
|
1621
|
+
}
|
|
1622
|
+
.snap-mandatory {
|
|
1623
|
+
--tw-scroll-snap-strictness: mandatory;
|
|
1624
|
+
}
|
|
1625
|
+
.snap-center {
|
|
1626
|
+
scroll-snap-align: center;
|
|
1627
|
+
}
|
|
1616
1628
|
.list-inside {
|
|
1617
1629
|
list-style-position: inside;
|
|
1618
1630
|
}
|
|
@@ -1843,6 +1855,9 @@ body {
|
|
|
1843
1855
|
.overflow-y-scroll {
|
|
1844
1856
|
overflow-y: scroll;
|
|
1845
1857
|
}
|
|
1858
|
+
.overscroll-contain {
|
|
1859
|
+
overscroll-behavior: contain;
|
|
1860
|
+
}
|
|
1846
1861
|
.scroll-smooth {
|
|
1847
1862
|
scroll-behavior: smooth;
|
|
1848
1863
|
}
|
|
@@ -3318,6 +3333,9 @@ body {
|
|
|
3318
3333
|
.text-muted-foreground\/50 {
|
|
3319
3334
|
color: hsl(var(--muted-foreground) / 0.5);
|
|
3320
3335
|
}
|
|
3336
|
+
.text-muted-foreground\/60 {
|
|
3337
|
+
color: hsl(var(--muted-foreground) / 0.6);
|
|
3338
|
+
}
|
|
3321
3339
|
.text-muted-foreground\/70 {
|
|
3322
3340
|
color: hsl(var(--muted-foreground) / 0.7);
|
|
3323
3341
|
}
|
|
@@ -6193,9 +6211,6 @@ body {
|
|
|
6193
6211
|
.sm\:w-12 {
|
|
6194
6212
|
width: 3rem;
|
|
6195
6213
|
}
|
|
6196
|
-
.sm\:w-16 {
|
|
6197
|
-
width: 4rem;
|
|
6198
|
-
}
|
|
6199
6214
|
.sm\:w-20 {
|
|
6200
6215
|
width: 5rem;
|
|
6201
6216
|
}
|
package/dist/index.js
CHANGED
|
@@ -670,7 +670,7 @@ var DialogOverlayBase = React33__namespace.forwardRef(({ className, testid: data
|
|
|
670
670
|
{
|
|
671
671
|
ref,
|
|
672
672
|
className: cn(
|
|
673
|
-
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0
|
|
673
|
+
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 ",
|
|
674
674
|
className
|
|
675
675
|
),
|
|
676
676
|
"data-testid": dataTestId,
|
|
@@ -688,7 +688,7 @@ var DialogContentBase = React33__namespace.forwardRef(
|
|
|
688
688
|
{
|
|
689
689
|
ref,
|
|
690
690
|
className: cn(
|
|
691
|
-
"fixed left-[50%] top-[50%] z-50 w-
|
|
691
|
+
"fixed left-[50%] top-[50%] z-50 w-lg grid translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg max-h-[100dvh] overflow-auto rounded-md border-border",
|
|
692
692
|
className
|
|
693
693
|
),
|
|
694
694
|
"data-testid": dataTestId,
|
|
@@ -696,8 +696,8 @@ var DialogContentBase = React33__namespace.forwardRef(
|
|
|
696
696
|
onWheel: userOnWheel,
|
|
697
697
|
children: [
|
|
698
698
|
children,
|
|
699
|
-
/* @__PURE__ */ jsxRuntime.jsxs(DialogPrimitive__namespace.Close, { className: "absolute right-
|
|
700
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.XIcon, { className: "h-
|
|
699
|
+
/* @__PURE__ */ jsxRuntime.jsxs(DialogPrimitive__namespace.Close, { className: "absolute right-3 top-3 sm:right-4 sm:top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground z-10 touch-manipulation", children: [
|
|
700
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.XIcon, { className: "h-6 w-6 sm:h-4 sm:w-4 hover:text-red-500 font-extrabold" }),
|
|
701
701
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Close" })
|
|
702
702
|
] })
|
|
703
703
|
]
|
|
@@ -712,7 +712,7 @@ var DialogHeaderBase = React33__namespace.forwardRef(({ className, testid: dataT
|
|
|
712
712
|
{
|
|
713
713
|
ref,
|
|
714
714
|
className: cn(
|
|
715
|
-
"flex flex-col space-y-1
|
|
715
|
+
"flex flex-col space-y-1.5 text-center sm:text-left",
|
|
716
716
|
className
|
|
717
717
|
),
|
|
718
718
|
"data-testid": dataTestId,
|
|
@@ -725,7 +725,7 @@ var DialogFooterBase = React33__namespace.forwardRef(({ className, testid: dataT
|
|
|
725
725
|
{
|
|
726
726
|
ref,
|
|
727
727
|
className: cn(
|
|
728
|
-
"flex flex-col-reverse
|
|
728
|
+
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
|
729
729
|
className
|
|
730
730
|
),
|
|
731
731
|
"data-testid": dataTestId,
|
|
@@ -1315,15 +1315,27 @@ var toast = {
|
|
|
1315
1315
|
};
|
|
1316
1316
|
var MOBILE_BREAKPOINT = 768;
|
|
1317
1317
|
function useIsMobile() {
|
|
1318
|
-
const [isMobile, setIsMobile] = React33__namespace.useState(
|
|
1318
|
+
const [isMobile, setIsMobile] = React33__namespace.useState(
|
|
1319
|
+
void 0
|
|
1320
|
+
);
|
|
1319
1321
|
React33__namespace.useEffect(() => {
|
|
1322
|
+
const checkIsMobile = () => {
|
|
1323
|
+
const isTouch = window.matchMedia("(pointer: coarse)").matches || navigator.maxTouchPoints > 0;
|
|
1324
|
+
const isSmallScreen = window.innerWidth < MOBILE_BREAKPOINT;
|
|
1325
|
+
return isTouch || isSmallScreen;
|
|
1326
|
+
};
|
|
1320
1327
|
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
1328
|
+
const touchMql = window.matchMedia("(pointer: coarse)");
|
|
1321
1329
|
const onChange = () => {
|
|
1322
|
-
setIsMobile(
|
|
1330
|
+
setIsMobile(checkIsMobile());
|
|
1323
1331
|
};
|
|
1324
1332
|
mql.addEventListener("change", onChange);
|
|
1325
|
-
|
|
1326
|
-
|
|
1333
|
+
touchMql.addEventListener("change", onChange);
|
|
1334
|
+
setIsMobile(checkIsMobile());
|
|
1335
|
+
return () => {
|
|
1336
|
+
mql.removeEventListener("change", onChange);
|
|
1337
|
+
touchMql.removeEventListener("change", onChange);
|
|
1338
|
+
};
|
|
1327
1339
|
}, []);
|
|
1328
1340
|
return !!isMobile;
|
|
1329
1341
|
}
|
|
@@ -7679,175 +7691,68 @@ function useScrollColumn({
|
|
|
7679
7691
|
}) {
|
|
7680
7692
|
const containerRef = React33.useRef(null);
|
|
7681
7693
|
const items = getItems(max, step);
|
|
7682
|
-
const [isDragging, setIsDragging] = React33.useState(false);
|
|
7683
|
-
const [startY, setStartY] = React33.useState(0);
|
|
7684
|
-
const [scrollTop, setScrollTop] = React33.useState(0);
|
|
7685
7694
|
const scrollTimeoutRef = React33.useRef(null);
|
|
7686
|
-
const
|
|
7687
|
-
const
|
|
7688
|
-
const
|
|
7689
|
-
const
|
|
7690
|
-
const momentumAnimationRef = React33.useRef(null);
|
|
7695
|
+
const isScrollingRef = React33.useRef(false);
|
|
7696
|
+
const [isDragging, setIsDragging] = React33.useState(false);
|
|
7697
|
+
const startYRef = React33.useRef(0);
|
|
7698
|
+
const startScrollRef = React33.useRef(0);
|
|
7691
7699
|
const itemHeight = ITEM_HEIGHT;
|
|
7692
7700
|
const centerIndex = CENTER_INDEX;
|
|
7693
7701
|
const visibleItems = VISIBLE_ITEMS;
|
|
7694
7702
|
const containerHeight = visibleItems * itemHeight;
|
|
7695
7703
|
React33.useEffect(() => {
|
|
7696
|
-
if (containerRef.current && !
|
|
7697
|
-
|
|
7698
|
-
|
|
7699
|
-
|
|
7700
|
-
|
|
7701
|
-
const scrollPosition = clampedIndex * itemHeight;
|
|
7702
|
-
containerRef.current.scrollTop = scrollPosition;
|
|
7703
|
-
}
|
|
7704
|
-
});
|
|
7704
|
+
if (containerRef.current && !isScrollingRef.current) {
|
|
7705
|
+
const index = Math.round(value / step);
|
|
7706
|
+
const clampedIndex = Math.max(0, Math.min(items.length - 1, index));
|
|
7707
|
+
const scrollPosition = clampedIndex * itemHeight;
|
|
7708
|
+
containerRef.current.scrollTop = scrollPosition;
|
|
7705
7709
|
}
|
|
7706
|
-
}, [value,
|
|
7710
|
+
}, [value, itemHeight, step, items.length]);
|
|
7707
7711
|
React33.useEffect(() => {
|
|
7708
|
-
const animationRef = momentumAnimationRef.current;
|
|
7709
7712
|
return () => {
|
|
7710
7713
|
if (scrollTimeoutRef.current) clearTimeout(scrollTimeoutRef.current);
|
|
7711
|
-
if (animationRef) {
|
|
7712
|
-
cancelAnimationFrame(animationRef);
|
|
7713
|
-
}
|
|
7714
7714
|
};
|
|
7715
7715
|
}, []);
|
|
7716
|
-
const handleScroll = (
|
|
7717
|
-
|
|
7718
|
-
|
|
7719
|
-
if (!containerRef.current || isDragging) return;
|
|
7716
|
+
const handleScroll = () => {
|
|
7717
|
+
if (!containerRef.current) return;
|
|
7718
|
+
isScrollingRef.current = true;
|
|
7720
7719
|
if (scrollTimeoutRef.current) clearTimeout(scrollTimeoutRef.current);
|
|
7721
7720
|
scrollTimeoutRef.current = setTimeout(() => {
|
|
7722
7721
|
if (!containerRef.current) return;
|
|
7723
7722
|
const newIndex = Math.round(containerRef.current.scrollTop / itemHeight);
|
|
7724
7723
|
const newValue = items[newIndex];
|
|
7725
|
-
if (newValue !== void 0) {
|
|
7726
|
-
|
|
7727
|
-
if (newValue !== value) onChange(newValue);
|
|
7724
|
+
if (newValue !== void 0 && newValue !== value) {
|
|
7725
|
+
onChange(newValue);
|
|
7728
7726
|
}
|
|
7729
|
-
|
|
7727
|
+
isScrollingRef.current = false;
|
|
7728
|
+
}, 150);
|
|
7730
7729
|
};
|
|
7731
|
-
const
|
|
7730
|
+
const handleMouseDown = (e) => {
|
|
7732
7731
|
if (!containerRef.current) return;
|
|
7733
|
-
if (momentumAnimationRef.current) {
|
|
7734
|
-
cancelAnimationFrame(momentumAnimationRef.current);
|
|
7735
|
-
momentumAnimationRef.current = null;
|
|
7736
|
-
}
|
|
7737
7732
|
setIsDragging(true);
|
|
7738
|
-
|
|
7739
|
-
|
|
7740
|
-
|
|
7741
|
-
lastTouchY.current = pageY;
|
|
7742
|
-
lastTouchTime.current = Date.now();
|
|
7733
|
+
startYRef.current = e.clientY;
|
|
7734
|
+
startScrollRef.current = containerRef.current.scrollTop;
|
|
7735
|
+
e.preventDefault();
|
|
7743
7736
|
};
|
|
7744
|
-
const
|
|
7737
|
+
const handleMouseMove = (e) => {
|
|
7745
7738
|
if (!isDragging || !containerRef.current) return;
|
|
7746
|
-
const
|
|
7747
|
-
|
|
7748
|
-
if (timeDelta > 0) {
|
|
7749
|
-
const delta = pageY - lastTouchY.current;
|
|
7750
|
-
velocityRef.current = delta / timeDelta;
|
|
7751
|
-
}
|
|
7752
|
-
lastTouchY.current = pageY;
|
|
7753
|
-
lastTouchTime.current = now;
|
|
7754
|
-
const multiplier = isTouchRef.current ? 1 : 1;
|
|
7755
|
-
containerRef.current.scrollTop = scrollTop + (startY - pageY) * multiplier;
|
|
7739
|
+
const deltaY = startYRef.current - e.clientY;
|
|
7740
|
+
containerRef.current.scrollTop = startScrollRef.current + deltaY;
|
|
7756
7741
|
};
|
|
7757
|
-
const
|
|
7758
|
-
if (!containerRef.current) return;
|
|
7742
|
+
const handleMouseUp = () => {
|
|
7759
7743
|
setIsDragging(false);
|
|
7760
|
-
if (isTouchRef.current && Math.abs(velocityRef.current) > 0.1) {
|
|
7761
|
-
let velocity = velocityRef.current * -30;
|
|
7762
|
-
const friction = 0.92;
|
|
7763
|
-
const minVelocity = 0.5;
|
|
7764
|
-
const animate = () => {
|
|
7765
|
-
if (!containerRef.current) return;
|
|
7766
|
-
velocity *= friction;
|
|
7767
|
-
if (Math.abs(velocity) < minVelocity) {
|
|
7768
|
-
const newIndex = Math.round(
|
|
7769
|
-
containerRef.current.scrollTop / itemHeight
|
|
7770
|
-
);
|
|
7771
|
-
const newValue = items[newIndex];
|
|
7772
|
-
if (newValue !== void 0) {
|
|
7773
|
-
const targetScroll = newIndex * itemHeight;
|
|
7774
|
-
const currentScroll = containerRef.current.scrollTop;
|
|
7775
|
-
const diff = targetScroll - currentScroll;
|
|
7776
|
-
if (Math.abs(diff) > 0.5) {
|
|
7777
|
-
containerRef.current.scrollTop += diff * 0.3;
|
|
7778
|
-
momentumAnimationRef.current = requestAnimationFrame(animate);
|
|
7779
|
-
} else {
|
|
7780
|
-
containerRef.current.scrollTop = targetScroll;
|
|
7781
|
-
onChange(newValue);
|
|
7782
|
-
momentumAnimationRef.current = null;
|
|
7783
|
-
}
|
|
7784
|
-
}
|
|
7785
|
-
return;
|
|
7786
|
-
}
|
|
7787
|
-
containerRef.current.scrollTop += velocity;
|
|
7788
|
-
momentumAnimationRef.current = requestAnimationFrame(animate);
|
|
7789
|
-
};
|
|
7790
|
-
momentumAnimationRef.current = requestAnimationFrame(animate);
|
|
7791
|
-
} else {
|
|
7792
|
-
requestAnimationFrame(() => {
|
|
7793
|
-
if (!containerRef.current) return;
|
|
7794
|
-
const newIndex = Math.round(
|
|
7795
|
-
containerRef.current.scrollTop / itemHeight
|
|
7796
|
-
);
|
|
7797
|
-
const newValue = items[newIndex];
|
|
7798
|
-
if (newValue !== void 0) {
|
|
7799
|
-
containerRef.current.scrollTop = newIndex * itemHeight;
|
|
7800
|
-
onChange(newValue);
|
|
7801
|
-
}
|
|
7802
|
-
});
|
|
7803
|
-
}
|
|
7804
|
-
};
|
|
7805
|
-
const handlers = {
|
|
7806
|
-
onScroll: handleScroll,
|
|
7807
|
-
onWheel: (e) => e.stopPropagation(),
|
|
7808
|
-
onMouseDown: (e) => {
|
|
7809
|
-
isTouchRef.current = false;
|
|
7810
|
-
handleStart(e.pageY);
|
|
7811
|
-
},
|
|
7812
|
-
onMouseMove: (e) => {
|
|
7813
|
-
if (isDragging) {
|
|
7814
|
-
e.preventDefault();
|
|
7815
|
-
handleMove(e.pageY);
|
|
7816
|
-
}
|
|
7817
|
-
},
|
|
7818
|
-
onMouseUp: () => handleEnd(),
|
|
7819
|
-
onMouseLeave: () => {
|
|
7820
|
-
if (isDragging) handleEnd();
|
|
7821
|
-
},
|
|
7822
|
-
onTouchStart: (e) => {
|
|
7823
|
-
isTouchRef.current = true;
|
|
7824
|
-
handleStart(e.touches[0].pageY);
|
|
7825
|
-
},
|
|
7826
|
-
onTouchMove: (e) => {
|
|
7827
|
-
if (isDragging) {
|
|
7828
|
-
if (e.cancelable) e.preventDefault();
|
|
7829
|
-
handleMove(e.touches[0].pageY);
|
|
7830
|
-
}
|
|
7831
|
-
},
|
|
7832
|
-
onTouchEnd: () => {
|
|
7833
|
-
isTouchRef.current = false;
|
|
7834
|
-
handleEnd();
|
|
7835
|
-
}
|
|
7836
|
-
};
|
|
7837
|
-
const scrollToIndex = (index) => {
|
|
7838
|
-
if (!containerRef.current) return;
|
|
7839
|
-
const clamped = Math.max(0, Math.min(items.length - 1, index));
|
|
7840
|
-
containerRef.current.scrollTop = clamped * itemHeight;
|
|
7841
7744
|
};
|
|
7842
7745
|
return {
|
|
7843
7746
|
items,
|
|
7844
7747
|
containerRef,
|
|
7845
|
-
isDragging,
|
|
7846
7748
|
itemHeight,
|
|
7847
7749
|
containerHeight,
|
|
7848
7750
|
centerIndex,
|
|
7849
|
-
|
|
7850
|
-
|
|
7751
|
+
handleScroll,
|
|
7752
|
+
handleMouseDown,
|
|
7753
|
+
handleMouseMove,
|
|
7754
|
+
handleMouseUp,
|
|
7755
|
+
isDragging
|
|
7851
7756
|
};
|
|
7852
7757
|
}
|
|
7853
7758
|
function ScrollColumn({
|
|
@@ -7860,57 +7765,66 @@ function ScrollColumn({
|
|
|
7860
7765
|
const {
|
|
7861
7766
|
items,
|
|
7862
7767
|
containerRef,
|
|
7863
|
-
isDragging,
|
|
7864
7768
|
itemHeight,
|
|
7865
7769
|
containerHeight,
|
|
7866
7770
|
centerIndex,
|
|
7867
|
-
|
|
7771
|
+
handleScroll,
|
|
7772
|
+
handleMouseDown,
|
|
7773
|
+
handleMouseMove,
|
|
7774
|
+
handleMouseUp,
|
|
7775
|
+
isDragging
|
|
7868
7776
|
} = useScrollColumn({ value, onChange, max, step });
|
|
7869
7777
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center", children: [
|
|
7870
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground rounded-md font-semibold text-sm
|
|
7871
|
-
/* @__PURE__ */ jsxRuntime.
|
|
7872
|
-
|
|
7873
|
-
|
|
7874
|
-
|
|
7875
|
-
|
|
7876
|
-
|
|
7877
|
-
|
|
7878
|
-
|
|
7879
|
-
|
|
7880
|
-
|
|
7881
|
-
|
|
7882
|
-
|
|
7883
|
-
|
|
7884
|
-
|
|
7885
|
-
|
|
7886
|
-
|
|
7887
|
-
|
|
7888
|
-
|
|
7889
|
-
|
|
7890
|
-
|
|
7891
|
-
|
|
7892
|
-
|
|
7893
|
-
|
|
7894
|
-
|
|
7895
|
-
|
|
7896
|
-
|
|
7897
|
-
|
|
7898
|
-
|
|
7899
|
-
|
|
7900
|
-
|
|
7901
|
-
|
|
7902
|
-
|
|
7903
|
-
|
|
7904
|
-
|
|
7905
|
-
|
|
7778
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground rounded-md font-semibold text-sm text-center pb-2 uppercase tracking-wider", children: label }),
|
|
7779
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("relative w-20"), children: [
|
|
7780
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7781
|
+
"div",
|
|
7782
|
+
{
|
|
7783
|
+
className: "absolute left-0 right-0 pointer-events-none bg-muted/50 rounded-md border border-border",
|
|
7784
|
+
style: {
|
|
7785
|
+
top: `${centerIndex * itemHeight}px`,
|
|
7786
|
+
height: `${itemHeight}px`
|
|
7787
|
+
}
|
|
7788
|
+
}
|
|
7789
|
+
),
|
|
7790
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7791
|
+
"div",
|
|
7792
|
+
{
|
|
7793
|
+
ref: containerRef,
|
|
7794
|
+
onScroll: handleScroll,
|
|
7795
|
+
onMouseDown: handleMouseDown,
|
|
7796
|
+
onMouseMove: handleMouseMove,
|
|
7797
|
+
onMouseUp: handleMouseUp,
|
|
7798
|
+
onMouseLeave: handleMouseUp,
|
|
7799
|
+
className: cn(
|
|
7800
|
+
"overflow-y-scroll snap-y snap-mandatory [&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none] overscroll-contain",
|
|
7801
|
+
isDragging && "cursor-grabbing"
|
|
7802
|
+
),
|
|
7803
|
+
style: {
|
|
7804
|
+
height: `${containerHeight}px`,
|
|
7805
|
+
paddingTop: `${centerIndex * itemHeight}px`,
|
|
7806
|
+
paddingBottom: `${centerIndex * itemHeight}px`,
|
|
7807
|
+
cursor: isDragging ? "grabbing" : "grab"
|
|
7808
|
+
},
|
|
7809
|
+
children: items.map((item, idx) => {
|
|
7810
|
+
const itemIndex = items.indexOf(value);
|
|
7811
|
+
const isCentered = idx === itemIndex;
|
|
7812
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7813
|
+
"div",
|
|
7814
|
+
{
|
|
7815
|
+
className: cn(
|
|
7816
|
+
"snap-center flex items-center justify-center select-none font-bold tabular-nums transition-all duration-200",
|
|
7817
|
+
isCentered ? "text-2xl sm:text-xl text-foreground scale-110" : "text-base sm:text-sm text-muted-foreground/60"
|
|
7818
|
+
),
|
|
7819
|
+
style: { height: `${itemHeight}px` },
|
|
7820
|
+
children: item.toString().padStart(2, "0")
|
|
7906
7821
|
},
|
|
7907
|
-
|
|
7908
|
-
|
|
7909
|
-
|
|
7910
|
-
|
|
7911
|
-
|
|
7912
|
-
|
|
7913
|
-
) })
|
|
7822
|
+
item
|
|
7823
|
+
);
|
|
7824
|
+
})
|
|
7825
|
+
}
|
|
7826
|
+
)
|
|
7827
|
+
] })
|
|
7914
7828
|
] });
|
|
7915
7829
|
}
|
|
7916
7830
|
function TimeScrollPicker({
|
|
@@ -7919,8 +7833,6 @@ function TimeScrollPicker({
|
|
|
7919
7833
|
hideSeconds = false
|
|
7920
7834
|
}) {
|
|
7921
7835
|
const currentDate = date || /* @__PURE__ */ new Date();
|
|
7922
|
-
const itemHeight = ITEM_HEIGHT;
|
|
7923
|
-
const centerIndex = CENTER_INDEX;
|
|
7924
7836
|
const handleTimeChange = (type, value) => {
|
|
7925
7837
|
const newDate = new Date(currentDate);
|
|
7926
7838
|
if (type === "hours") newDate.setHours(value);
|
|
@@ -7928,17 +7840,7 @@ function TimeScrollPicker({
|
|
|
7928
7840
|
else newDate.setSeconds(value);
|
|
7929
7841
|
setDate(newDate);
|
|
7930
7842
|
};
|
|
7931
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center gap-2 p-1.5 sm:p-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className:
|
|
7932
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7933
|
-
"div",
|
|
7934
|
-
{
|
|
7935
|
-
className: "absolute left-0 right-0 pointer-events-none z-10 rounded-lg bg-primary/10 border border-primary/20",
|
|
7936
|
-
style: {
|
|
7937
|
-
top: `calc(1.85rem + ${centerIndex * itemHeight}px)`,
|
|
7938
|
-
height: `${itemHeight}px`
|
|
7939
|
-
}
|
|
7940
|
-
}
|
|
7941
|
-
),
|
|
7843
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center gap-2 p-1.5 sm:p-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative flex gap-2 sm:gap-3", children: [
|
|
7942
7844
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7943
7845
|
ScrollColumn,
|
|
7944
7846
|
{
|
|
@@ -7946,7 +7848,7 @@ function TimeScrollPicker({
|
|
|
7946
7848
|
onChange: (v) => handleTimeChange("hours", v),
|
|
7947
7849
|
max: 24,
|
|
7948
7850
|
label: "Hora",
|
|
7949
|
-
|
|
7851
|
+
step: 1
|
|
7950
7852
|
}
|
|
7951
7853
|
),
|
|
7952
7854
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -7956,8 +7858,7 @@ function TimeScrollPicker({
|
|
|
7956
7858
|
onChange: (v) => handleTimeChange("minutes", v),
|
|
7957
7859
|
max: 60,
|
|
7958
7860
|
step: 5,
|
|
7959
|
-
label: "Min"
|
|
7960
|
-
hideSeconds
|
|
7861
|
+
label: "Min"
|
|
7961
7862
|
}
|
|
7962
7863
|
),
|
|
7963
7864
|
!hideSeconds && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -7967,7 +7868,7 @@ function TimeScrollPicker({
|
|
|
7967
7868
|
onChange: (v) => handleTimeChange("seconds", v),
|
|
7968
7869
|
max: 60,
|
|
7969
7870
|
label: "Seg",
|
|
7970
|
-
|
|
7871
|
+
step: 1
|
|
7971
7872
|
}
|
|
7972
7873
|
)
|
|
7973
7874
|
] }) });
|
|
@@ -8263,7 +8164,7 @@ function DateTimePicker({
|
|
|
8263
8164
|
}
|
|
8264
8165
|
),
|
|
8265
8166
|
/* @__PURE__ */ jsxRuntime.jsx(ErrorMessage_default, { error }),
|
|
8266
|
-
/* @__PURE__ */ jsxRuntime.jsx(DialogContentBase, { className: "p-0 max-h-[
|
|
8167
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogContentBase, { className: "p-0 max-h-[95vh] w-[calc(100vw-24px)] sm:w-[calc(100vw-32px)] overflow-hidden flex flex-col", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-y-auto flex-1", children: renderPickerContent() }) })
|
|
8267
8168
|
] }) : /* @__PURE__ */ jsxRuntime.jsxs(PopoverBase, { open, onOpenChange: setOpen, children: [
|
|
8268
8169
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8269
8170
|
PopoverTriggerBase,
|
package/dist/index.mjs
CHANGED
|
@@ -627,7 +627,7 @@ var DialogOverlayBase = React33.forwardRef(({ className, testid: dataTestId = "d
|
|
|
627
627
|
{
|
|
628
628
|
ref,
|
|
629
629
|
className: cn(
|
|
630
|
-
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0
|
|
630
|
+
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 ",
|
|
631
631
|
className
|
|
632
632
|
),
|
|
633
633
|
"data-testid": dataTestId,
|
|
@@ -645,7 +645,7 @@ var DialogContentBase = React33.forwardRef(
|
|
|
645
645
|
{
|
|
646
646
|
ref,
|
|
647
647
|
className: cn(
|
|
648
|
-
"fixed left-[50%] top-[50%] z-50 w-
|
|
648
|
+
"fixed left-[50%] top-[50%] z-50 w-lg grid translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg max-h-[100dvh] overflow-auto rounded-md border-border",
|
|
649
649
|
className
|
|
650
650
|
),
|
|
651
651
|
"data-testid": dataTestId,
|
|
@@ -653,8 +653,8 @@ var DialogContentBase = React33.forwardRef(
|
|
|
653
653
|
onWheel: userOnWheel,
|
|
654
654
|
children: [
|
|
655
655
|
children,
|
|
656
|
-
/* @__PURE__ */ jsxs(DialogPrimitive.Close, { className: "absolute right-
|
|
657
|
-
/* @__PURE__ */ jsx(XIcon, { className: "h-
|
|
656
|
+
/* @__PURE__ */ jsxs(DialogPrimitive.Close, { className: "absolute right-3 top-3 sm:right-4 sm:top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground z-10 touch-manipulation", children: [
|
|
657
|
+
/* @__PURE__ */ jsx(XIcon, { className: "h-6 w-6 sm:h-4 sm:w-4 hover:text-red-500 font-extrabold" }),
|
|
658
658
|
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
|
|
659
659
|
] })
|
|
660
660
|
]
|
|
@@ -669,7 +669,7 @@ var DialogHeaderBase = React33.forwardRef(({ className, testid: dataTestId = "di
|
|
|
669
669
|
{
|
|
670
670
|
ref,
|
|
671
671
|
className: cn(
|
|
672
|
-
"flex flex-col space-y-1
|
|
672
|
+
"flex flex-col space-y-1.5 text-center sm:text-left",
|
|
673
673
|
className
|
|
674
674
|
),
|
|
675
675
|
"data-testid": dataTestId,
|
|
@@ -682,7 +682,7 @@ var DialogFooterBase = React33.forwardRef(({ className, testid: dataTestId = "di
|
|
|
682
682
|
{
|
|
683
683
|
ref,
|
|
684
684
|
className: cn(
|
|
685
|
-
"flex flex-col-reverse
|
|
685
|
+
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
|
686
686
|
className
|
|
687
687
|
),
|
|
688
688
|
"data-testid": dataTestId,
|
|
@@ -1272,15 +1272,27 @@ var toast = {
|
|
|
1272
1272
|
};
|
|
1273
1273
|
var MOBILE_BREAKPOINT = 768;
|
|
1274
1274
|
function useIsMobile() {
|
|
1275
|
-
const [isMobile, setIsMobile] = React33.useState(
|
|
1275
|
+
const [isMobile, setIsMobile] = React33.useState(
|
|
1276
|
+
void 0
|
|
1277
|
+
);
|
|
1276
1278
|
React33.useEffect(() => {
|
|
1279
|
+
const checkIsMobile = () => {
|
|
1280
|
+
const isTouch = window.matchMedia("(pointer: coarse)").matches || navigator.maxTouchPoints > 0;
|
|
1281
|
+
const isSmallScreen = window.innerWidth < MOBILE_BREAKPOINT;
|
|
1282
|
+
return isTouch || isSmallScreen;
|
|
1283
|
+
};
|
|
1277
1284
|
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
1285
|
+
const touchMql = window.matchMedia("(pointer: coarse)");
|
|
1278
1286
|
const onChange = () => {
|
|
1279
|
-
setIsMobile(
|
|
1287
|
+
setIsMobile(checkIsMobile());
|
|
1280
1288
|
};
|
|
1281
1289
|
mql.addEventListener("change", onChange);
|
|
1282
|
-
|
|
1283
|
-
|
|
1290
|
+
touchMql.addEventListener("change", onChange);
|
|
1291
|
+
setIsMobile(checkIsMobile());
|
|
1292
|
+
return () => {
|
|
1293
|
+
mql.removeEventListener("change", onChange);
|
|
1294
|
+
touchMql.removeEventListener("change", onChange);
|
|
1295
|
+
};
|
|
1284
1296
|
}, []);
|
|
1285
1297
|
return !!isMobile;
|
|
1286
1298
|
}
|
|
@@ -7636,175 +7648,68 @@ function useScrollColumn({
|
|
|
7636
7648
|
}) {
|
|
7637
7649
|
const containerRef = useRef(null);
|
|
7638
7650
|
const items = getItems(max, step);
|
|
7639
|
-
const [isDragging, setIsDragging] = useState(false);
|
|
7640
|
-
const [startY, setStartY] = useState(0);
|
|
7641
|
-
const [scrollTop, setScrollTop] = useState(0);
|
|
7642
7651
|
const scrollTimeoutRef = useRef(null);
|
|
7643
|
-
const
|
|
7644
|
-
const
|
|
7645
|
-
const
|
|
7646
|
-
const
|
|
7647
|
-
const momentumAnimationRef = useRef(null);
|
|
7652
|
+
const isScrollingRef = useRef(false);
|
|
7653
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
7654
|
+
const startYRef = useRef(0);
|
|
7655
|
+
const startScrollRef = useRef(0);
|
|
7648
7656
|
const itemHeight = ITEM_HEIGHT;
|
|
7649
7657
|
const centerIndex = CENTER_INDEX;
|
|
7650
7658
|
const visibleItems = VISIBLE_ITEMS;
|
|
7651
7659
|
const containerHeight = visibleItems * itemHeight;
|
|
7652
7660
|
useEffect(() => {
|
|
7653
|
-
if (containerRef.current && !
|
|
7654
|
-
|
|
7655
|
-
|
|
7656
|
-
|
|
7657
|
-
|
|
7658
|
-
const scrollPosition = clampedIndex * itemHeight;
|
|
7659
|
-
containerRef.current.scrollTop = scrollPosition;
|
|
7660
|
-
}
|
|
7661
|
-
});
|
|
7661
|
+
if (containerRef.current && !isScrollingRef.current) {
|
|
7662
|
+
const index = Math.round(value / step);
|
|
7663
|
+
const clampedIndex = Math.max(0, Math.min(items.length - 1, index));
|
|
7664
|
+
const scrollPosition = clampedIndex * itemHeight;
|
|
7665
|
+
containerRef.current.scrollTop = scrollPosition;
|
|
7662
7666
|
}
|
|
7663
|
-
}, [value,
|
|
7667
|
+
}, [value, itemHeight, step, items.length]);
|
|
7664
7668
|
useEffect(() => {
|
|
7665
|
-
const animationRef = momentumAnimationRef.current;
|
|
7666
7669
|
return () => {
|
|
7667
7670
|
if (scrollTimeoutRef.current) clearTimeout(scrollTimeoutRef.current);
|
|
7668
|
-
if (animationRef) {
|
|
7669
|
-
cancelAnimationFrame(animationRef);
|
|
7670
|
-
}
|
|
7671
7671
|
};
|
|
7672
7672
|
}, []);
|
|
7673
|
-
const handleScroll = (
|
|
7674
|
-
|
|
7675
|
-
|
|
7676
|
-
if (!containerRef.current || isDragging) return;
|
|
7673
|
+
const handleScroll = () => {
|
|
7674
|
+
if (!containerRef.current) return;
|
|
7675
|
+
isScrollingRef.current = true;
|
|
7677
7676
|
if (scrollTimeoutRef.current) clearTimeout(scrollTimeoutRef.current);
|
|
7678
7677
|
scrollTimeoutRef.current = setTimeout(() => {
|
|
7679
7678
|
if (!containerRef.current) return;
|
|
7680
7679
|
const newIndex = Math.round(containerRef.current.scrollTop / itemHeight);
|
|
7681
7680
|
const newValue = items[newIndex];
|
|
7682
|
-
if (newValue !== void 0) {
|
|
7683
|
-
|
|
7684
|
-
if (newValue !== value) onChange(newValue);
|
|
7681
|
+
if (newValue !== void 0 && newValue !== value) {
|
|
7682
|
+
onChange(newValue);
|
|
7685
7683
|
}
|
|
7686
|
-
|
|
7684
|
+
isScrollingRef.current = false;
|
|
7685
|
+
}, 150);
|
|
7687
7686
|
};
|
|
7688
|
-
const
|
|
7687
|
+
const handleMouseDown = (e) => {
|
|
7689
7688
|
if (!containerRef.current) return;
|
|
7690
|
-
if (momentumAnimationRef.current) {
|
|
7691
|
-
cancelAnimationFrame(momentumAnimationRef.current);
|
|
7692
|
-
momentumAnimationRef.current = null;
|
|
7693
|
-
}
|
|
7694
7689
|
setIsDragging(true);
|
|
7695
|
-
|
|
7696
|
-
|
|
7697
|
-
|
|
7698
|
-
lastTouchY.current = pageY;
|
|
7699
|
-
lastTouchTime.current = Date.now();
|
|
7690
|
+
startYRef.current = e.clientY;
|
|
7691
|
+
startScrollRef.current = containerRef.current.scrollTop;
|
|
7692
|
+
e.preventDefault();
|
|
7700
7693
|
};
|
|
7701
|
-
const
|
|
7694
|
+
const handleMouseMove = (e) => {
|
|
7702
7695
|
if (!isDragging || !containerRef.current) return;
|
|
7703
|
-
const
|
|
7704
|
-
|
|
7705
|
-
if (timeDelta > 0) {
|
|
7706
|
-
const delta = pageY - lastTouchY.current;
|
|
7707
|
-
velocityRef.current = delta / timeDelta;
|
|
7708
|
-
}
|
|
7709
|
-
lastTouchY.current = pageY;
|
|
7710
|
-
lastTouchTime.current = now;
|
|
7711
|
-
const multiplier = isTouchRef.current ? 1 : 1;
|
|
7712
|
-
containerRef.current.scrollTop = scrollTop + (startY - pageY) * multiplier;
|
|
7696
|
+
const deltaY = startYRef.current - e.clientY;
|
|
7697
|
+
containerRef.current.scrollTop = startScrollRef.current + deltaY;
|
|
7713
7698
|
};
|
|
7714
|
-
const
|
|
7715
|
-
if (!containerRef.current) return;
|
|
7699
|
+
const handleMouseUp = () => {
|
|
7716
7700
|
setIsDragging(false);
|
|
7717
|
-
if (isTouchRef.current && Math.abs(velocityRef.current) > 0.1) {
|
|
7718
|
-
let velocity = velocityRef.current * -30;
|
|
7719
|
-
const friction = 0.92;
|
|
7720
|
-
const minVelocity = 0.5;
|
|
7721
|
-
const animate = () => {
|
|
7722
|
-
if (!containerRef.current) return;
|
|
7723
|
-
velocity *= friction;
|
|
7724
|
-
if (Math.abs(velocity) < minVelocity) {
|
|
7725
|
-
const newIndex = Math.round(
|
|
7726
|
-
containerRef.current.scrollTop / itemHeight
|
|
7727
|
-
);
|
|
7728
|
-
const newValue = items[newIndex];
|
|
7729
|
-
if (newValue !== void 0) {
|
|
7730
|
-
const targetScroll = newIndex * itemHeight;
|
|
7731
|
-
const currentScroll = containerRef.current.scrollTop;
|
|
7732
|
-
const diff = targetScroll - currentScroll;
|
|
7733
|
-
if (Math.abs(diff) > 0.5) {
|
|
7734
|
-
containerRef.current.scrollTop += diff * 0.3;
|
|
7735
|
-
momentumAnimationRef.current = requestAnimationFrame(animate);
|
|
7736
|
-
} else {
|
|
7737
|
-
containerRef.current.scrollTop = targetScroll;
|
|
7738
|
-
onChange(newValue);
|
|
7739
|
-
momentumAnimationRef.current = null;
|
|
7740
|
-
}
|
|
7741
|
-
}
|
|
7742
|
-
return;
|
|
7743
|
-
}
|
|
7744
|
-
containerRef.current.scrollTop += velocity;
|
|
7745
|
-
momentumAnimationRef.current = requestAnimationFrame(animate);
|
|
7746
|
-
};
|
|
7747
|
-
momentumAnimationRef.current = requestAnimationFrame(animate);
|
|
7748
|
-
} else {
|
|
7749
|
-
requestAnimationFrame(() => {
|
|
7750
|
-
if (!containerRef.current) return;
|
|
7751
|
-
const newIndex = Math.round(
|
|
7752
|
-
containerRef.current.scrollTop / itemHeight
|
|
7753
|
-
);
|
|
7754
|
-
const newValue = items[newIndex];
|
|
7755
|
-
if (newValue !== void 0) {
|
|
7756
|
-
containerRef.current.scrollTop = newIndex * itemHeight;
|
|
7757
|
-
onChange(newValue);
|
|
7758
|
-
}
|
|
7759
|
-
});
|
|
7760
|
-
}
|
|
7761
|
-
};
|
|
7762
|
-
const handlers = {
|
|
7763
|
-
onScroll: handleScroll,
|
|
7764
|
-
onWheel: (e) => e.stopPropagation(),
|
|
7765
|
-
onMouseDown: (e) => {
|
|
7766
|
-
isTouchRef.current = false;
|
|
7767
|
-
handleStart(e.pageY);
|
|
7768
|
-
},
|
|
7769
|
-
onMouseMove: (e) => {
|
|
7770
|
-
if (isDragging) {
|
|
7771
|
-
e.preventDefault();
|
|
7772
|
-
handleMove(e.pageY);
|
|
7773
|
-
}
|
|
7774
|
-
},
|
|
7775
|
-
onMouseUp: () => handleEnd(),
|
|
7776
|
-
onMouseLeave: () => {
|
|
7777
|
-
if (isDragging) handleEnd();
|
|
7778
|
-
},
|
|
7779
|
-
onTouchStart: (e) => {
|
|
7780
|
-
isTouchRef.current = true;
|
|
7781
|
-
handleStart(e.touches[0].pageY);
|
|
7782
|
-
},
|
|
7783
|
-
onTouchMove: (e) => {
|
|
7784
|
-
if (isDragging) {
|
|
7785
|
-
if (e.cancelable) e.preventDefault();
|
|
7786
|
-
handleMove(e.touches[0].pageY);
|
|
7787
|
-
}
|
|
7788
|
-
},
|
|
7789
|
-
onTouchEnd: () => {
|
|
7790
|
-
isTouchRef.current = false;
|
|
7791
|
-
handleEnd();
|
|
7792
|
-
}
|
|
7793
|
-
};
|
|
7794
|
-
const scrollToIndex = (index) => {
|
|
7795
|
-
if (!containerRef.current) return;
|
|
7796
|
-
const clamped = Math.max(0, Math.min(items.length - 1, index));
|
|
7797
|
-
containerRef.current.scrollTop = clamped * itemHeight;
|
|
7798
7701
|
};
|
|
7799
7702
|
return {
|
|
7800
7703
|
items,
|
|
7801
7704
|
containerRef,
|
|
7802
|
-
isDragging,
|
|
7803
7705
|
itemHeight,
|
|
7804
7706
|
containerHeight,
|
|
7805
7707
|
centerIndex,
|
|
7806
|
-
|
|
7807
|
-
|
|
7708
|
+
handleScroll,
|
|
7709
|
+
handleMouseDown,
|
|
7710
|
+
handleMouseMove,
|
|
7711
|
+
handleMouseUp,
|
|
7712
|
+
isDragging
|
|
7808
7713
|
};
|
|
7809
7714
|
}
|
|
7810
7715
|
function ScrollColumn({
|
|
@@ -7817,57 +7722,66 @@ function ScrollColumn({
|
|
|
7817
7722
|
const {
|
|
7818
7723
|
items,
|
|
7819
7724
|
containerRef,
|
|
7820
|
-
isDragging,
|
|
7821
7725
|
itemHeight,
|
|
7822
7726
|
containerHeight,
|
|
7823
7727
|
centerIndex,
|
|
7824
|
-
|
|
7728
|
+
handleScroll,
|
|
7729
|
+
handleMouseDown,
|
|
7730
|
+
handleMouseMove,
|
|
7731
|
+
handleMouseUp,
|
|
7732
|
+
isDragging
|
|
7825
7733
|
} = useScrollColumn({ value, onChange, max, step });
|
|
7826
7734
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center", children: [
|
|
7827
|
-
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground rounded-md font-semibold text-sm
|
|
7828
|
-
/* @__PURE__ */
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
|
|
7835
|
-
|
|
7836
|
-
|
|
7837
|
-
|
|
7838
|
-
|
|
7839
|
-
|
|
7840
|
-
|
|
7841
|
-
|
|
7842
|
-
|
|
7843
|
-
|
|
7844
|
-
|
|
7845
|
-
|
|
7846
|
-
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
|
|
7850
|
-
|
|
7851
|
-
|
|
7852
|
-
|
|
7853
|
-
|
|
7854
|
-
|
|
7855
|
-
|
|
7856
|
-
|
|
7857
|
-
|
|
7858
|
-
|
|
7859
|
-
|
|
7860
|
-
|
|
7861
|
-
|
|
7862
|
-
|
|
7735
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground rounded-md font-semibold text-sm text-center pb-2 uppercase tracking-wider", children: label }),
|
|
7736
|
+
/* @__PURE__ */ jsxs("div", { className: cn("relative w-20"), children: [
|
|
7737
|
+
/* @__PURE__ */ jsx(
|
|
7738
|
+
"div",
|
|
7739
|
+
{
|
|
7740
|
+
className: "absolute left-0 right-0 pointer-events-none bg-muted/50 rounded-md border border-border",
|
|
7741
|
+
style: {
|
|
7742
|
+
top: `${centerIndex * itemHeight}px`,
|
|
7743
|
+
height: `${itemHeight}px`
|
|
7744
|
+
}
|
|
7745
|
+
}
|
|
7746
|
+
),
|
|
7747
|
+
/* @__PURE__ */ jsx(
|
|
7748
|
+
"div",
|
|
7749
|
+
{
|
|
7750
|
+
ref: containerRef,
|
|
7751
|
+
onScroll: handleScroll,
|
|
7752
|
+
onMouseDown: handleMouseDown,
|
|
7753
|
+
onMouseMove: handleMouseMove,
|
|
7754
|
+
onMouseUp: handleMouseUp,
|
|
7755
|
+
onMouseLeave: handleMouseUp,
|
|
7756
|
+
className: cn(
|
|
7757
|
+
"overflow-y-scroll snap-y snap-mandatory [&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none] overscroll-contain",
|
|
7758
|
+
isDragging && "cursor-grabbing"
|
|
7759
|
+
),
|
|
7760
|
+
style: {
|
|
7761
|
+
height: `${containerHeight}px`,
|
|
7762
|
+
paddingTop: `${centerIndex * itemHeight}px`,
|
|
7763
|
+
paddingBottom: `${centerIndex * itemHeight}px`,
|
|
7764
|
+
cursor: isDragging ? "grabbing" : "grab"
|
|
7765
|
+
},
|
|
7766
|
+
children: items.map((item, idx) => {
|
|
7767
|
+
const itemIndex = items.indexOf(value);
|
|
7768
|
+
const isCentered = idx === itemIndex;
|
|
7769
|
+
return /* @__PURE__ */ jsx(
|
|
7770
|
+
"div",
|
|
7771
|
+
{
|
|
7772
|
+
className: cn(
|
|
7773
|
+
"snap-center flex items-center justify-center select-none font-bold tabular-nums transition-all duration-200",
|
|
7774
|
+
isCentered ? "text-2xl sm:text-xl text-foreground scale-110" : "text-base sm:text-sm text-muted-foreground/60"
|
|
7775
|
+
),
|
|
7776
|
+
style: { height: `${itemHeight}px` },
|
|
7777
|
+
children: item.toString().padStart(2, "0")
|
|
7863
7778
|
},
|
|
7864
|
-
|
|
7865
|
-
|
|
7866
|
-
|
|
7867
|
-
|
|
7868
|
-
|
|
7869
|
-
|
|
7870
|
-
) })
|
|
7779
|
+
item
|
|
7780
|
+
);
|
|
7781
|
+
})
|
|
7782
|
+
}
|
|
7783
|
+
)
|
|
7784
|
+
] })
|
|
7871
7785
|
] });
|
|
7872
7786
|
}
|
|
7873
7787
|
function TimeScrollPicker({
|
|
@@ -7876,8 +7790,6 @@ function TimeScrollPicker({
|
|
|
7876
7790
|
hideSeconds = false
|
|
7877
7791
|
}) {
|
|
7878
7792
|
const currentDate = date || /* @__PURE__ */ new Date();
|
|
7879
|
-
const itemHeight = ITEM_HEIGHT;
|
|
7880
|
-
const centerIndex = CENTER_INDEX;
|
|
7881
7793
|
const handleTimeChange = (type, value) => {
|
|
7882
7794
|
const newDate = new Date(currentDate);
|
|
7883
7795
|
if (type === "hours") newDate.setHours(value);
|
|
@@ -7885,17 +7797,7 @@ function TimeScrollPicker({
|
|
|
7885
7797
|
else newDate.setSeconds(value);
|
|
7886
7798
|
setDate(newDate);
|
|
7887
7799
|
};
|
|
7888
|
-
return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center gap-2 p-1.5 sm:p-4", children: /* @__PURE__ */ jsxs("div", { className:
|
|
7889
|
-
/* @__PURE__ */ jsx(
|
|
7890
|
-
"div",
|
|
7891
|
-
{
|
|
7892
|
-
className: "absolute left-0 right-0 pointer-events-none z-10 rounded-lg bg-primary/10 border border-primary/20",
|
|
7893
|
-
style: {
|
|
7894
|
-
top: `calc(1.85rem + ${centerIndex * itemHeight}px)`,
|
|
7895
|
-
height: `${itemHeight}px`
|
|
7896
|
-
}
|
|
7897
|
-
}
|
|
7898
|
-
),
|
|
7800
|
+
return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center gap-2 p-1.5 sm:p-4", children: /* @__PURE__ */ jsxs("div", { className: "relative flex gap-2 sm:gap-3", children: [
|
|
7899
7801
|
/* @__PURE__ */ jsx(
|
|
7900
7802
|
ScrollColumn,
|
|
7901
7803
|
{
|
|
@@ -7903,7 +7805,7 @@ function TimeScrollPicker({
|
|
|
7903
7805
|
onChange: (v) => handleTimeChange("hours", v),
|
|
7904
7806
|
max: 24,
|
|
7905
7807
|
label: "Hora",
|
|
7906
|
-
|
|
7808
|
+
step: 1
|
|
7907
7809
|
}
|
|
7908
7810
|
),
|
|
7909
7811
|
/* @__PURE__ */ jsx(
|
|
@@ -7913,8 +7815,7 @@ function TimeScrollPicker({
|
|
|
7913
7815
|
onChange: (v) => handleTimeChange("minutes", v),
|
|
7914
7816
|
max: 60,
|
|
7915
7817
|
step: 5,
|
|
7916
|
-
label: "Min"
|
|
7917
|
-
hideSeconds
|
|
7818
|
+
label: "Min"
|
|
7918
7819
|
}
|
|
7919
7820
|
),
|
|
7920
7821
|
!hideSeconds && /* @__PURE__ */ jsx(
|
|
@@ -7924,7 +7825,7 @@ function TimeScrollPicker({
|
|
|
7924
7825
|
onChange: (v) => handleTimeChange("seconds", v),
|
|
7925
7826
|
max: 60,
|
|
7926
7827
|
label: "Seg",
|
|
7927
|
-
|
|
7828
|
+
step: 1
|
|
7928
7829
|
}
|
|
7929
7830
|
)
|
|
7930
7831
|
] }) });
|
|
@@ -8220,7 +8121,7 @@ function DateTimePicker({
|
|
|
8220
8121
|
}
|
|
8221
8122
|
),
|
|
8222
8123
|
/* @__PURE__ */ jsx(ErrorMessage_default, { error }),
|
|
8223
|
-
/* @__PURE__ */ jsx(DialogContentBase, { className: "p-0 max-h-[
|
|
8124
|
+
/* @__PURE__ */ jsx(DialogContentBase, { className: "p-0 max-h-[95vh] w-[calc(100vw-24px)] sm:w-[calc(100vw-32px)] overflow-hidden flex flex-col", children: /* @__PURE__ */ jsx("div", { className: "overflow-y-auto flex-1", children: renderPickerContent() }) })
|
|
8224
8125
|
] }) : /* @__PURE__ */ jsxs(PopoverBase, { open, onOpenChange: setOpen, children: [
|
|
8225
8126
|
/* @__PURE__ */ jsx(
|
|
8226
8127
|
PopoverTriggerBase,
|