@mlw-packages/react-components 1.8.10 → 1.8.12

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/dist/index.js CHANGED
@@ -1857,6 +1857,7 @@ var InputBase = React33__namespace.forwardRef(
1857
1857
  leftIcon,
1858
1858
  rightIcon,
1859
1859
  "data-testid": dataTestId,
1860
+ numericKeyboard,
1860
1861
  error,
1861
1862
  ...props
1862
1863
  }, ref) => {
@@ -1876,6 +1877,8 @@ var InputBase = React33__namespace.forwardRef(
1876
1877
  "input",
1877
1878
  {
1878
1879
  type,
1880
+ inputMode: numericKeyboard ? "numeric" : void 0,
1881
+ pattern: numericKeyboard ? "[0-9]*" : void 0,
1879
1882
  className: cn(
1880
1883
  "w-full flex-1 text-sm p-1.5 px-3 focus:outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50 bg-background text-foreground",
1881
1884
  className
@@ -7481,16 +7484,176 @@ function CalendarBase2({
7481
7484
  );
7482
7485
  }
7483
7486
  CalendarBase2.displayName = "CalendarBase";
7487
+
7488
+ // src/components/ui/picker/utils/time-picker-utils.ts
7489
+ function isValidHour(value) {
7490
+ return /^(0[0-9]|1[0-9]|2[0-3])$/.test(value);
7491
+ }
7492
+ function isValid12Hour(value) {
7493
+ return /^(0[1-9]|1[0-2])$/.test(value);
7494
+ }
7495
+ function isValidMinuteOrSecond(value) {
7496
+ return /^[0-5][0-9]$/.test(value);
7497
+ }
7498
+ function getValidNumber(value, { max, min = 0, loop = false }) {
7499
+ let numericValue = parseInt(value, 10);
7500
+ if (!isNaN(numericValue)) {
7501
+ if (!loop) {
7502
+ if (numericValue > max) numericValue = max;
7503
+ if (numericValue < min) numericValue = min;
7504
+ } else {
7505
+ if (numericValue > max) numericValue = min;
7506
+ if (numericValue < min) numericValue = max;
7507
+ }
7508
+ return numericValue.toString().padStart(2, "0");
7509
+ }
7510
+ return "00";
7511
+ }
7512
+ function getValidHour(value) {
7513
+ if (isValidHour(value)) return value;
7514
+ return getValidNumber(value, { max: 23 });
7515
+ }
7516
+ function getValid12Hour(value) {
7517
+ if (isValid12Hour(value)) return value;
7518
+ return getValidNumber(value, { min: 1, max: 12 });
7519
+ }
7520
+ function getValidMinuteOrSecond(value) {
7521
+ if (isValidMinuteOrSecond(value)) return value;
7522
+ return getValidNumber(value, { max: 59 });
7523
+ }
7524
+ function getValidArrowNumber(value, { min, max, step }) {
7525
+ let numericValue = parseInt(value, 10);
7526
+ if (!isNaN(numericValue)) {
7527
+ numericValue += step;
7528
+ return getValidNumber(String(numericValue), { min, max, loop: true });
7529
+ }
7530
+ return "00";
7531
+ }
7532
+ function getValidArrowHour(value, step) {
7533
+ return getValidArrowNumber(value, { min: 0, max: 23, step });
7534
+ }
7535
+ function getValidArrow12Hour(value, step) {
7536
+ return getValidArrowNumber(value, { min: 1, max: 12, step });
7537
+ }
7538
+ function getValidArrowMinuteOrSecond(value, step) {
7539
+ return getValidArrowNumber(value, { min: 0, max: 59, step });
7540
+ }
7541
+ function setMinutes(date, value) {
7542
+ const minutes = getValidMinuteOrSecond(value);
7543
+ date.setMinutes(parseInt(minutes, 10));
7544
+ return date;
7545
+ }
7546
+ function setSeconds(date, value) {
7547
+ const seconds = getValidMinuteOrSecond(value);
7548
+ date.setSeconds(parseInt(seconds, 10));
7549
+ return date;
7550
+ }
7551
+ function setHours(date, value) {
7552
+ const hours = getValidHour(value);
7553
+ date.setHours(parseInt(hours, 10));
7554
+ return date;
7555
+ }
7556
+ function set12Hours(date, value, period) {
7557
+ const hours = parseInt(getValid12Hour(value), 10);
7558
+ const convertedHours = convert12HourTo24Hour(hours, period);
7559
+ date.setHours(convertedHours);
7560
+ return date;
7561
+ }
7562
+ function setDateByType(date, value, type, period) {
7563
+ switch (type) {
7564
+ case "minutes":
7565
+ return setMinutes(date, value);
7566
+ case "seconds":
7567
+ return setSeconds(date, value);
7568
+ case "hours":
7569
+ return setHours(date, value);
7570
+ case "12hours": {
7571
+ if (!period) return date;
7572
+ return set12Hours(date, value, period);
7573
+ }
7574
+ default:
7575
+ return date;
7576
+ }
7577
+ }
7578
+ function getDateByType(date, type) {
7579
+ switch (type) {
7580
+ case "minutes":
7581
+ return getValidMinuteOrSecond(String(date.getMinutes()));
7582
+ case "seconds":
7583
+ return getValidMinuteOrSecond(String(date.getSeconds()));
7584
+ case "hours":
7585
+ return getValidHour(String(date.getHours()));
7586
+ case "12hours":
7587
+ const hours = display12HourValue(date.getHours());
7588
+ return getValid12Hour(String(hours));
7589
+ default:
7590
+ return "00";
7591
+ }
7592
+ }
7593
+ function getArrowByType(value, step, type) {
7594
+ switch (type) {
7595
+ case "minutes":
7596
+ return getValidArrowMinuteOrSecond(value, step);
7597
+ case "seconds":
7598
+ return getValidArrowMinuteOrSecond(value, step);
7599
+ case "hours":
7600
+ return getValidArrowHour(value, step);
7601
+ case "12hours":
7602
+ return getValidArrow12Hour(value, step);
7603
+ default:
7604
+ return "00";
7605
+ }
7606
+ }
7607
+ function convert12HourTo24Hour(hour, period) {
7608
+ if (period === "PM") {
7609
+ if (hour <= 11) {
7610
+ return hour + 12;
7611
+ } else {
7612
+ return hour;
7613
+ }
7614
+ } else if (period === "AM") {
7615
+ if (hour === 12) return 0;
7616
+ return hour;
7617
+ }
7618
+ return hour;
7619
+ }
7620
+ function display12HourValue(hours) {
7621
+ if (hours === 0 || hours === 12) return "12";
7622
+ if (hours >= 22) return `${hours - 12}`;
7623
+ if (hours % 12 > 9) return `${hours}`;
7624
+ return `0${hours % 12}`;
7625
+ }
7626
+
7627
+ // src/components/ui/picker/utils/pickerUtils.ts
7628
+ function visualForItem(item, value) {
7629
+ const distance = Math.abs(item - value);
7630
+ const capped = Math.min(distance, 4);
7631
+ const scale = 1 - capped * 0.08;
7632
+ const opacity = 1 - capped * 0.18;
7633
+ const translateY = item === value ? -2 : 0;
7634
+ return { scale, opacity, translateY, distance };
7635
+ }
7484
7636
  var ITEM_HEIGHT = 38.5;
7485
7637
  var VISIBLE_ITEMS = 5;
7486
7638
  var CENTER_INDEX = Math.floor(VISIBLE_ITEMS / 2);
7487
- function ScrollColumn({ value, onChange, max, label }) {
7639
+ function getItems(max, step = 1) {
7640
+ return Array.from({ length: Math.ceil(max / step) }, (_, i) => i * step);
7641
+ }
7642
+
7643
+ // src/components/ui/picker/hooks/useScrollColumn.tsx
7644
+ function useScrollColumn({
7645
+ value,
7646
+ onChange,
7647
+ max,
7648
+ step = 1
7649
+ }) {
7488
7650
  const containerRef = React33.useRef(null);
7489
- const items = Array.from({ length: max }, (_, i) => i);
7651
+ const items = getItems(max, step);
7490
7652
  const [isDragging, setIsDragging] = React33.useState(false);
7491
7653
  const [startY, setStartY] = React33.useState(0);
7492
7654
  const [scrollTop, setScrollTop] = React33.useState(0);
7493
7655
  const scrollTimeoutRef = React33.useRef(null);
7656
+ const isTouchRef = React33.useRef(false);
7494
7657
  const itemHeight = ITEM_HEIGHT;
7495
7658
  const centerIndex = CENTER_INDEX;
7496
7659
  const visibleItems = VISIBLE_ITEMS;
@@ -7499,17 +7662,17 @@ function ScrollColumn({ value, onChange, max, label }) {
7499
7662
  if (containerRef.current && !isDragging) {
7500
7663
  requestAnimationFrame(() => {
7501
7664
  if (containerRef.current) {
7502
- const scrollPosition = value * itemHeight;
7665
+ const index = Math.round(value / step);
7666
+ const clampedIndex = Math.max(0, Math.min(items.length - 1, index));
7667
+ const scrollPosition = clampedIndex * itemHeight;
7503
7668
  containerRef.current.scrollTop = scrollPosition;
7504
7669
  }
7505
7670
  });
7506
7671
  }
7507
- }, [value, isDragging, itemHeight]);
7672
+ }, [value, isDragging, itemHeight, step, items.length]);
7508
7673
  React33.useEffect(() => {
7509
7674
  return () => {
7510
- if (scrollTimeoutRef.current) {
7511
- clearTimeout(scrollTimeoutRef.current);
7512
- }
7675
+ if (scrollTimeoutRef.current) clearTimeout(scrollTimeoutRef.current);
7513
7676
  };
7514
7677
  }, []);
7515
7678
  const handleScroll = (e) => {
@@ -7519,9 +7682,10 @@ function ScrollColumn({ value, onChange, max, label }) {
7519
7682
  if (scrollTimeoutRef.current) clearTimeout(scrollTimeoutRef.current);
7520
7683
  scrollTimeoutRef.current = setTimeout(() => {
7521
7684
  if (!containerRef.current) return;
7522
- const newValue = Math.round(containerRef.current.scrollTop / itemHeight);
7523
- if (newValue >= 0 && newValue < max) {
7524
- containerRef.current.scrollTop = newValue * itemHeight;
7685
+ const newIndex = Math.round(containerRef.current.scrollTop / itemHeight);
7686
+ const newValue = items[newIndex];
7687
+ if (newValue !== void 0) {
7688
+ containerRef.current.scrollTop = newIndex * itemHeight;
7525
7689
  if (newValue !== value) onChange(newValue);
7526
7690
  }
7527
7691
  }, 100);
@@ -7534,50 +7698,86 @@ function ScrollColumn({ value, onChange, max, label }) {
7534
7698
  };
7535
7699
  const handleMove = (pageY) => {
7536
7700
  if (!isDragging || !containerRef.current) return;
7537
- containerRef.current.scrollTop = scrollTop + (startY - pageY) * 2;
7701
+ const multiplier = isTouchRef.current ? 0.6 : 1;
7702
+ containerRef.current.scrollTop = scrollTop + (startY - pageY) * multiplier;
7538
7703
  };
7539
7704
  const handleEnd = () => {
7540
7705
  if (!containerRef.current) return;
7541
7706
  setIsDragging(false);
7542
7707
  requestAnimationFrame(() => {
7543
7708
  if (!containerRef.current) return;
7544
- const newValue = Math.round(containerRef.current.scrollTop / itemHeight);
7545
- if (newValue >= 0 && newValue < max) {
7546
- containerRef.current.scrollTop = newValue * itemHeight;
7709
+ const newIndex = Math.round(containerRef.current.scrollTop / itemHeight);
7710
+ const newValue = items[newIndex];
7711
+ if (newValue !== void 0) {
7712
+ containerRef.current.scrollTop = newIndex * itemHeight;
7547
7713
  onChange(newValue);
7548
7714
  }
7549
7715
  });
7550
7716
  };
7551
- const handleMouseDown = (e) => {
7552
- handleStart(e.pageY);
7553
- };
7554
- const handleMouseMove = (e) => {
7555
- if (isDragging) {
7556
- e.preventDefault();
7557
- handleMove(e.pageY);
7558
- }
7559
- };
7560
- const handleMouseUp = () => {
7561
- handleEnd();
7562
- };
7563
- const handleMouseLeave = () => {
7564
- if (isDragging) handleEnd();
7565
- };
7566
- const handleTouchStart = (e) => {
7567
- handleStart(e.touches[0].pageY);
7568
- };
7569
- const handleTouchMove = (e) => {
7570
- if (isDragging) {
7571
- if (e.cancelable) e.preventDefault();
7572
- handleMove(e.touches[0].pageY);
7717
+ const handlers = {
7718
+ onScroll: handleScroll,
7719
+ onWheel: (e) => e.stopPropagation(),
7720
+ onMouseDown: (e) => {
7721
+ isTouchRef.current = false;
7722
+ handleStart(e.pageY);
7723
+ },
7724
+ onMouseMove: (e) => {
7725
+ if (isDragging) {
7726
+ e.preventDefault();
7727
+ handleMove(e.pageY);
7728
+ }
7729
+ },
7730
+ onMouseUp: () => handleEnd(),
7731
+ onMouseLeave: () => {
7732
+ if (isDragging) handleEnd();
7733
+ },
7734
+ onTouchStart: (e) => {
7735
+ isTouchRef.current = true;
7736
+ handleStart(e.touches[0].pageY);
7737
+ },
7738
+ onTouchMove: (e) => {
7739
+ if (isDragging) {
7740
+ if (e.cancelable) e.preventDefault();
7741
+ handleMove(e.touches[0].pageY);
7742
+ }
7743
+ },
7744
+ onTouchEnd: () => {
7745
+ isTouchRef.current = false;
7746
+ handleEnd();
7573
7747
  }
7574
7748
  };
7575
- const handleTouchEnd = () => {
7576
- handleEnd();
7749
+ const scrollToIndex = (index) => {
7750
+ if (!containerRef.current) return;
7751
+ const clamped = Math.max(0, Math.min(items.length - 1, index));
7752
+ containerRef.current.scrollTop = clamped * itemHeight;
7577
7753
  };
7578
- const handleWheel = (e) => {
7579
- e.stopPropagation();
7754
+ return {
7755
+ items,
7756
+ containerRef,
7757
+ isDragging,
7758
+ itemHeight,
7759
+ containerHeight,
7760
+ centerIndex,
7761
+ handlers,
7762
+ scrollToIndex
7580
7763
  };
7764
+ }
7765
+ function ScrollColumn({
7766
+ value,
7767
+ onChange,
7768
+ max,
7769
+ label,
7770
+ step = 1
7771
+ }) {
7772
+ const {
7773
+ items,
7774
+ containerRef,
7775
+ isDragging,
7776
+ itemHeight,
7777
+ containerHeight,
7778
+ centerIndex,
7779
+ handlers
7780
+ } = useScrollColumn({ value, onChange, max, step });
7581
7781
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center", children: [
7582
7782
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground rounded-md font-semibold text-sm sm:text-sm text-center pb-2 uppercase tracking-wider", children: label }),
7583
7783
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("relative w-20 sm:w-16"), children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -7585,22 +7785,22 @@ function ScrollColumn({ value, onChange, max, label }) {
7585
7785
  {
7586
7786
  ref: containerRef,
7587
7787
  className: "overflow-y-auto [&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none] touch-action-pan-y",
7588
- onScroll: handleScroll,
7589
- onWheel: handleWheel,
7590
- onMouseDown: handleMouseDown,
7591
- onMouseMove: handleMouseMove,
7592
- onMouseUp: handleMouseUp,
7593
- onMouseLeave: handleMouseLeave,
7594
- onTouchStart: handleTouchStart,
7595
- onTouchMove: handleTouchMove,
7596
- onTouchEnd: handleTouchEnd,
7788
+ onScroll: handlers.onScroll,
7789
+ onWheel: handlers.onWheel,
7790
+ onMouseDown: handlers.onMouseDown,
7791
+ onMouseMove: handlers.onMouseMove,
7792
+ onMouseUp: handlers.onMouseUp,
7793
+ onMouseLeave: handlers.onMouseLeave,
7794
+ onTouchStart: handlers.onTouchStart,
7795
+ onTouchMove: handlers.onTouchMove,
7796
+ onTouchEnd: handlers.onTouchEnd,
7597
7797
  style: {
7598
7798
  height: `${containerHeight}px`,
7599
7799
  paddingTop: `${centerIndex * itemHeight}px`,
7600
7800
  paddingBottom: `${centerIndex * itemHeight}px`,
7601
7801
  cursor: isDragging ? "grabbing" : ""
7602
7802
  },
7603
- children: items.map((item) => {
7803
+ children: items.map((item, idx) => {
7604
7804
  const isSelected = item === value;
7605
7805
  return /* @__PURE__ */ jsxRuntime.jsx(
7606
7806
  "div",
@@ -7611,7 +7811,11 @@ function ScrollColumn({ value, onChange, max, label }) {
7611
7811
  isSelected ? "text-lg sm:text-xl text-foreground scale-110" : "text-sm sm:text-base text-muted-foreground opacity-60"
7612
7812
  ),
7613
7813
  style: { height: `${itemHeight}px` },
7614
- onClick: () => !isDragging && onChange(item),
7814
+ onClick: () => {
7815
+ if (isDragging || !containerRef.current) return;
7816
+ containerRef.current.scrollTop = idx * itemHeight;
7817
+ onChange(item);
7818
+ },
7615
7819
  children: item.toString().padStart(2, "0")
7616
7820
  },
7617
7821
  item
@@ -7636,7 +7840,7 @@ function TimeScrollPicker({
7636
7840
  else newDate.setSeconds(value);
7637
7841
  setDate(newDate);
7638
7842
  };
7639
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center gap-2 p-3 sm:p-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("relative flex gap-4 sm:gap-3"), children: [
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: cn("relative flex gap-2 sm:gap-3"), children: [
7640
7844
  /* @__PURE__ */ jsxRuntime.jsx(
7641
7845
  "div",
7642
7846
  {
@@ -7663,6 +7867,7 @@ function TimeScrollPicker({
7663
7867
  value: currentDate.getMinutes(),
7664
7868
  onChange: (v) => handleTimeChange("minutes", v),
7665
7869
  max: 60,
7870
+ step: 5,
7666
7871
  label: "Min",
7667
7872
  hideSeconds
7668
7873
  }
@@ -7806,7 +8011,7 @@ function DateTimePicker({
7806
8011
  }
7807
8012
  );
7808
8013
  const renderPickerContent = () => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-2 sm:p-3 border border-border rounded-md", children: [
7809
- isMobile && !hideTime ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-h-[380px] max-h-[calc(400px)]", children: [
8014
+ isMobile && !hideTime ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col min-h-0", children: [
7810
8015
  internalDate && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-3 px-4 py-3 rounded-lg ", children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-md font-semibold", children: [
7811
8016
  dateFns.format(internalDate, "dd 'de' MMMM 'de' yyyy", {
7812
8017
  locale: locale.ptBR
@@ -7840,7 +8045,7 @@ function DateTimePicker({
7840
8045
  className: cn("w-full rounded-none border-none")
7841
8046
  }
7842
8047
  ) }),
7843
- /* @__PURE__ */ jsxRuntime.jsx(TabsContentBase, { value: "time", className: "mt-0", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col items-center justify-center gap-4 py-2 min-h-[330px]", children: /* @__PURE__ */ jsxRuntime.jsx(
8048
+ /* @__PURE__ */ jsxRuntime.jsx(TabsContentBase, { value: "time", className: "mt-0", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col items-center justify-center gap-4 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(
7844
8049
  TimeScrollPicker,
7845
8050
  {
7846
8051
  setDate: (d) => handleTimeChange(d ?? null),
@@ -7970,7 +8175,7 @@ function DateTimePicker({
7970
8175
  }
7971
8176
  ),
7972
8177
  /* @__PURE__ */ jsxRuntime.jsx(ErrorMessage_default, { error }),
7973
- /* @__PURE__ */ jsxRuntime.jsx(DialogContentBase, { className: "p-0 max-w-[min(95vw,450px)] max-h-[95vh] overflow-y-auto", children: renderPickerContent() })
8178
+ /* @__PURE__ */ jsxRuntime.jsx(DialogContentBase, { className: "p-0 max-h-[65vh] 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() }) })
7974
8179
  ] }) : /* @__PURE__ */ jsxRuntime.jsxs(PopoverBase, { open, onOpenChange: setOpen, children: [
7975
8180
  /* @__PURE__ */ jsxRuntime.jsx(
7976
8181
  PopoverTriggerBase,
@@ -8240,145 +8445,6 @@ function RangePicker({
8240
8445
  ] });
8241
8446
  }
8242
8447
  RangePicker.displayName = "RangePicker";
8243
-
8244
- // src/components/ui/picker/utils/time-picker-utils.ts
8245
- function isValidHour(value) {
8246
- return /^(0[0-9]|1[0-9]|2[0-3])$/.test(value);
8247
- }
8248
- function isValid12Hour(value) {
8249
- return /^(0[1-9]|1[0-2])$/.test(value);
8250
- }
8251
- function isValidMinuteOrSecond(value) {
8252
- return /^[0-5][0-9]$/.test(value);
8253
- }
8254
- function getValidNumber(value, { max, min = 0, loop = false }) {
8255
- let numericValue = parseInt(value, 10);
8256
- if (!isNaN(numericValue)) {
8257
- if (!loop) {
8258
- if (numericValue > max) numericValue = max;
8259
- if (numericValue < min) numericValue = min;
8260
- } else {
8261
- if (numericValue > max) numericValue = min;
8262
- if (numericValue < min) numericValue = max;
8263
- }
8264
- return numericValue.toString().padStart(2, "0");
8265
- }
8266
- return "00";
8267
- }
8268
- function getValidHour(value) {
8269
- if (isValidHour(value)) return value;
8270
- return getValidNumber(value, { max: 23 });
8271
- }
8272
- function getValid12Hour(value) {
8273
- if (isValid12Hour(value)) return value;
8274
- return getValidNumber(value, { min: 1, max: 12 });
8275
- }
8276
- function getValidMinuteOrSecond(value) {
8277
- if (isValidMinuteOrSecond(value)) return value;
8278
- return getValidNumber(value, { max: 59 });
8279
- }
8280
- function getValidArrowNumber(value, { min, max, step }) {
8281
- let numericValue = parseInt(value, 10);
8282
- if (!isNaN(numericValue)) {
8283
- numericValue += step;
8284
- return getValidNumber(String(numericValue), { min, max, loop: true });
8285
- }
8286
- return "00";
8287
- }
8288
- function getValidArrowHour(value, step) {
8289
- return getValidArrowNumber(value, { min: 0, max: 23, step });
8290
- }
8291
- function getValidArrow12Hour(value, step) {
8292
- return getValidArrowNumber(value, { min: 1, max: 12, step });
8293
- }
8294
- function getValidArrowMinuteOrSecond(value, step) {
8295
- return getValidArrowNumber(value, { min: 0, max: 59, step });
8296
- }
8297
- function setMinutes(date, value) {
8298
- const minutes = getValidMinuteOrSecond(value);
8299
- date.setMinutes(parseInt(minutes, 10));
8300
- return date;
8301
- }
8302
- function setSeconds(date, value) {
8303
- const seconds = getValidMinuteOrSecond(value);
8304
- date.setSeconds(parseInt(seconds, 10));
8305
- return date;
8306
- }
8307
- function setHours(date, value) {
8308
- const hours = getValidHour(value);
8309
- date.setHours(parseInt(hours, 10));
8310
- return date;
8311
- }
8312
- function set12Hours(date, value, period) {
8313
- const hours = parseInt(getValid12Hour(value), 10);
8314
- const convertedHours = convert12HourTo24Hour(hours, period);
8315
- date.setHours(convertedHours);
8316
- return date;
8317
- }
8318
- function setDateByType(date, value, type, period) {
8319
- switch (type) {
8320
- case "minutes":
8321
- return setMinutes(date, value);
8322
- case "seconds":
8323
- return setSeconds(date, value);
8324
- case "hours":
8325
- return setHours(date, value);
8326
- case "12hours": {
8327
- if (!period) return date;
8328
- return set12Hours(date, value, period);
8329
- }
8330
- default:
8331
- return date;
8332
- }
8333
- }
8334
- function getDateByType(date, type) {
8335
- switch (type) {
8336
- case "minutes":
8337
- return getValidMinuteOrSecond(String(date.getMinutes()));
8338
- case "seconds":
8339
- return getValidMinuteOrSecond(String(date.getSeconds()));
8340
- case "hours":
8341
- return getValidHour(String(date.getHours()));
8342
- case "12hours":
8343
- const hours = display12HourValue(date.getHours());
8344
- return getValid12Hour(String(hours));
8345
- default:
8346
- return "00";
8347
- }
8348
- }
8349
- function getArrowByType(value, step, type) {
8350
- switch (type) {
8351
- case "minutes":
8352
- return getValidArrowMinuteOrSecond(value, step);
8353
- case "seconds":
8354
- return getValidArrowMinuteOrSecond(value, step);
8355
- case "hours":
8356
- return getValidArrowHour(value, step);
8357
- case "12hours":
8358
- return getValidArrow12Hour(value, step);
8359
- default:
8360
- return "00";
8361
- }
8362
- }
8363
- function convert12HourTo24Hour(hour, period) {
8364
- if (period === "PM") {
8365
- if (hour <= 11) {
8366
- return hour + 12;
8367
- } else {
8368
- return hour;
8369
- }
8370
- } else if (period === "AM") {
8371
- if (hour === 12) return 0;
8372
- return hour;
8373
- }
8374
- return hour;
8375
- }
8376
- function display12HourValue(hours) {
8377
- if (hours === 0 || hours === 12) return "12";
8378
- if (hours >= 22) return `${hours - 12}`;
8379
- if (hours % 12 > 9) return `${hours}`;
8380
- return `0${hours % 12}`;
8381
- }
8382
8448
  var TimePickerInput = React33__namespace.default.forwardRef(
8383
8449
  ({
8384
8450
  className,
@@ -8676,16 +8742,6 @@ function TimePicker({
8676
8742
  }
8677
8743
  );
8678
8744
  }
8679
-
8680
- // src/components/ui/picker/utils/pickerUtils.ts
8681
- function visualForItem(item, value) {
8682
- const distance = Math.abs(item - value);
8683
- const capped = Math.min(distance, 4);
8684
- const scale = 1 - capped * 0.08;
8685
- const opacity = 1 - capped * 0.18;
8686
- const translateY = item === value ? -2 : 0;
8687
- return { scale, opacity, translateY, distance };
8688
- }
8689
8745
  function Agenda({
8690
8746
  currentDate,
8691
8747
  events,
@@ -18776,6 +18832,97 @@ var TimeSeries = ({
18776
18832
  ) });
18777
18833
  };
18778
18834
  var TimeSeries_default = TimeSeries;
18835
+ function NumericInput({
18836
+ value,
18837
+ onChange,
18838
+ min,
18839
+ max,
18840
+ label,
18841
+ className,
18842
+ error,
18843
+ isLoading,
18844
+ disabled,
18845
+ tooltip_on_overflow,
18846
+ hideConfirm = false,
18847
+ numericKeyboard
18848
+ }) {
18849
+ const original = React33.useMemo(() => value, [value]);
18850
+ const [internalValue, setInternalValue] = React33.useState(original);
18851
+ const hasChanged = internalValue !== original;
18852
+ const handleSave = () => {
18853
+ if (!hasChanged || isLoading || disabled) return;
18854
+ onChange(internalValue);
18855
+ };
18856
+ function handleNumberChange(value2, currentValue = 0, max2 = 9999999, min2 = 0) {
18857
+ const numbersOnly = value2.replace(/\D/g, "");
18858
+ if (numbersOnly === "") {
18859
+ return 0;
18860
+ }
18861
+ const numValue = Number(numbersOnly);
18862
+ if (numValue < min2) {
18863
+ if (tooltip_on_overflow) {
18864
+ sonner.toast.warning("O valor deve ser maior que " + min2.toString());
18865
+ }
18866
+ return min2;
18867
+ }
18868
+ if (numValue > max2) {
18869
+ if (tooltip_on_overflow) {
18870
+ sonner.toast.warning("O valor deve ser menor que " + max2.toString());
18871
+ }
18872
+ return currentValue;
18873
+ }
18874
+ return numValue;
18875
+ }
18876
+ function blurOnEnter(e) {
18877
+ if (e.key === "Enter") {
18878
+ e.currentTarget.blur();
18879
+ }
18880
+ }
18881
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${className} flex flex-col`, children: [
18882
+ label && /* @__PURE__ */ jsxRuntime.jsx(LabelBase_default, { children: label }),
18883
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-2", children: [
18884
+ /* @__PURE__ */ jsxRuntime.jsx(
18885
+ InputBase,
18886
+ {
18887
+ value: internalValue,
18888
+ onChange: (e) => {
18889
+ const processedValue = handleNumberChange(
18890
+ e.currentTarget.value,
18891
+ internalValue,
18892
+ max,
18893
+ min
18894
+ );
18895
+ setInternalValue(processedValue);
18896
+ },
18897
+ onBlur: handleSave,
18898
+ onKeyDown: blurOnEnter,
18899
+ rightIcon: /* @__PURE__ */ jsxRuntime.jsx(react.PencilSimpleIcon, { size: 12, className: "mr-2" }),
18900
+ error,
18901
+ disabled,
18902
+ numericKeyboard
18903
+ }
18904
+ ),
18905
+ /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children: hasChanged && !hideConfirm && /* @__PURE__ */ jsxRuntime.jsx(
18906
+ framerMotion.motion.div,
18907
+ {
18908
+ initial: { opacity: 0, scale: 0.8 },
18909
+ animate: { opacity: 1, scale: 1 },
18910
+ exit: { opacity: 0, scale: 0.8 },
18911
+ transition: { type: "spring", stiffness: 500, damping: 30 },
18912
+ children: /* @__PURE__ */ jsxRuntime.jsx(
18913
+ ButtonBase,
18914
+ {
18915
+ className: " h-9 w-9 bg-green-600 text-white hover:bg-green-700 rounded-md flex items-center justify-center",
18916
+ size: "icon",
18917
+ isLoading,
18918
+ children: /* @__PURE__ */ jsxRuntime.jsx(react.CheckIcon, { size: 14 })
18919
+ }
18920
+ )
18921
+ }
18922
+ ) })
18923
+ ] })
18924
+ ] });
18925
+ }
18779
18926
  function Leaderboard({
18780
18927
  items,
18781
18928
  order: initialOrder = "desc",
@@ -18937,6 +19084,7 @@ exports.BreadcrumbSeparatorBase = BreadcrumbSeparatorBase;
18937
19084
  exports.Brush = Brush_default;
18938
19085
  exports.ButtonBase = ButtonBase;
18939
19086
  exports.ButtonGroupBase = ButtonGroupBase;
19087
+ exports.CENTER_INDEX = CENTER_INDEX;
18940
19088
  exports.CalendarBase = CalendarBase;
18941
19089
  exports.CalendarDndProvider = CalendarDndProvider;
18942
19090
  exports.CalendarDndProviderAgenda = CalendarDndProviderAgenda;
@@ -19060,6 +19208,7 @@ exports.Highlights = Highlights_default;
19060
19208
  exports.HoverCardBase = HoverCardBase;
19061
19209
  exports.HoverCardContentBase = HoverCardContentBase;
19062
19210
  exports.HoverCardTriggerBase = HoverCardTriggerBase;
19211
+ exports.ITEM_HEIGHT = ITEM_HEIGHT;
19063
19212
  exports.InputBase = InputBase;
19064
19213
  exports.InputOTPBase = InputOTPBase;
19065
19214
  exports.InputOTPGroupBase = InputOTPGroupBase;
@@ -19104,6 +19253,7 @@ exports.NavigationMenuTriggerBase = NavigationMenuTriggerBase;
19104
19253
  exports.NavigationMenuViewportBase = NavigationMenuViewportBase;
19105
19254
  exports.NoData = NoData_default;
19106
19255
  exports.NotificationButton = NotificationButton;
19256
+ exports.NumericInput = NumericInput;
19107
19257
  exports.PeriodsDropdown = PeriodsDropdown_default;
19108
19258
  exports.PieChart = PieChart_default;
19109
19259
  exports.PopoverAnchorBase = PopoverAnchorBase;
@@ -19203,6 +19353,7 @@ exports.UniversalTooltipRenderer = UniversalTooltipRenderer;
19203
19353
  exports.UnlockButton = UnlockButton;
19204
19354
  exports.UploadButton = UploadButton;
19205
19355
  exports.UseSideBarBase = UseSideBarBase;
19356
+ exports.VISIBLE_ITEMS = VISIBLE_ITEMS;
19206
19357
  exports.ViewButton = ViewButton;
19207
19358
  exports.VisibilityButton = VisibilityButton;
19208
19359
  exports.WeekCellsHeight = WeekCellsHeight;
@@ -19242,6 +19393,7 @@ exports.getEventEndDate = getEventEndDate;
19242
19393
  exports.getEventStartDate = getEventStartDate;
19243
19394
  exports.getEventsForDay = getEventsForDay;
19244
19395
  exports.getEventsForDayAgenda = getEventsForDayAgenda;
19396
+ exports.getItems = getItems;
19245
19397
  exports.getMaxDataValue = getMaxDataValue;
19246
19398
  exports.getMinDataValue = getMinDataValue;
19247
19399
  exports.getSpanningEventsForDay = getSpanningEventsForDay;