@mlw-packages/react-components 1.7.11 → 1.7.13

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.mjs CHANGED
@@ -889,7 +889,7 @@ var CommandItemBase = React5.forwardRef(({ className, testid: dataTestId = "comm
889
889
  {
890
890
  ref,
891
891
  className: cn(
892
- "relative flex cursor-pointer gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-all data-[disabled=true]:pointer-events-none data-[selected=true]:bg-muted data-[selected=true]:text-primary data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 hover:scale-[1.02] active:scale-[0.98]",
892
+ "relative flex cursor-pointer gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-all data-[disabled=true]:pointer-events-none data-[selected=true]:bg-muted data-[selected=true]:text-primary data-[disabled=true]:opacity-50 aria-[selected=true]:bg-accent hover:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 hover:scale-[1.02] active:scale-[0.98]",
893
893
  className
894
894
  ),
895
895
  "data-testid": dataTestId,
@@ -958,6 +958,7 @@ function ComboboxBase({
958
958
  keepOpen = false,
959
959
  closeAll,
960
960
  searchPlaceholder,
961
+ empty = "Nenhum dado encontrado",
961
962
  error,
962
963
  testIds = {}
963
964
  }) {
@@ -1023,7 +1024,7 @@ function ComboboxBase({
1023
1024
  }
1024
1025
  ),
1025
1026
  /* @__PURE__ */ jsxs5(CommandListBase, { "data-testid": testIds.list ?? "combobox-list", children: [
1026
- /* @__PURE__ */ jsx8(CommandEmptyBase, { "data-testid": testIds.empty ?? "combobox-empty", children: "Nenhum dado encontrado" }),
1027
+ /* @__PURE__ */ jsx8(CommandEmptyBase, { "data-testid": testIds.empty ?? "combobox-empty", children: empty }),
1027
1028
  /* @__PURE__ */ jsx8(CommandGroupBase, { "data-testid": testIds.group ?? "combobox-group", children: items.map((item) => {
1028
1029
  const isSelected = checkIsSelected(item.value);
1029
1030
  return /* @__PURE__ */ jsxs5(
@@ -1088,6 +1089,7 @@ function Combobox({
1088
1089
  className,
1089
1090
  placeholder,
1090
1091
  searchPlaceholder,
1092
+ empty,
1091
1093
  label,
1092
1094
  labelClassname,
1093
1095
  testIds,
@@ -1124,6 +1126,7 @@ function Combobox({
1124
1126
  handleSelection,
1125
1127
  checkIsSelected,
1126
1128
  searchPlaceholder,
1129
+ empty,
1127
1130
  error,
1128
1131
  testIds
1129
1132
  }
@@ -1415,7 +1418,7 @@ var SelectItemBase = React8.forwardRef(({ className, children, ...props }, ref)
1415
1418
  {
1416
1419
  ref,
1417
1420
  className: cn(
1418
- "relative flex cursor-pointer gap-2 select-none items-center rounded-sm px-2 py-1.5 hover:bg-accent text-sm outline-none transition-all data-[disabled=true]:pointer-events-none data-[selected=true]:bg-muted data-[selected=true]:text-primary data-[disabled=true]:opacity-50",
1421
+ "relative flex cursor-pointer gap-2 select-none items-center rounded-sm px-2 py-1.5 hover:bg-accent focus:bg-accent data-[highlighted]:bg-accent text-sm outline-none transition-all data-[disabled=true]:pointer-events-none data-[selected=true]:bg-muted data-[selected=true]:text-primary data-[disabled=true]:opacity-50",
1419
1422
  className
1420
1423
  ),
1421
1424
  ...props,
@@ -1796,7 +1799,7 @@ function Select({
1796
1799
  className
1797
1800
  }) {
1798
1801
  return /* @__PURE__ */ jsxs13("div", { "data-testid": testIds.root ?? "select-root", children: [
1799
- label ? /* @__PURE__ */ jsx18("label", { className: cn("block text-sm font-medium", labelClassname), children: label }) : null,
1802
+ label && /* @__PURE__ */ jsx18(LabelBase_default, { className: labelClassname, children: label }),
1800
1803
  /* @__PURE__ */ jsxs13(
1801
1804
  SelectBase,
1802
1805
  {
@@ -7265,44 +7268,50 @@ import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
7265
7268
  import { CheckIcon as CheckIcon8, MinusIcon } from "@phosphor-icons/react";
7266
7269
  import { motion as motion11 } from "framer-motion";
7267
7270
  import { jsx as jsx44, jsxs as jsxs33 } from "react/jsx-runtime";
7268
- var CheckboxBase = React24.forwardRef(({ className, testid: dataTestId = "checkbox-base", ...props }, ref) => /* @__PURE__ */ jsx44(
7269
- CheckboxPrimitive.Root,
7270
- {
7271
- ref,
7272
- className: cn(
7273
- "peer h-4 w-4 shrink-0 rounded-md border border-primary shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground transition-colors",
7274
- className
7275
- ),
7276
- "data-testid": dataTestId,
7277
- ...props,
7278
- children: /* @__PURE__ */ jsx44(CheckboxPrimitive.Indicator, { asChild: true, children: /* @__PURE__ */ jsxs33(
7279
- motion11.div,
7280
- {
7281
- initial: { scale: 0, opacity: 0, rotate: -90 },
7282
- animate: { scale: 1, opacity: 1, rotate: 0 },
7283
- exit: { scale: 0, opacity: 0, rotate: 90 },
7284
- transition: { type: "spring", stiffness: 500, damping: 30 },
7285
- className: "flex items-center justify-center text-current group",
7286
- children: [
7287
- /* @__PURE__ */ jsx44(
7288
- CheckIcon8,
7289
- {
7290
- className: "h-4 w-4 hidden group-data-[state=checked]:block",
7291
- weight: "bold"
7292
- }
7293
- ),
7294
- /* @__PURE__ */ jsx44(
7295
- MinusIcon,
7296
- {
7297
- className: "h-4 w-4 hidden group-data-[state=indeterminate]:block",
7298
- weight: "bold"
7299
- }
7300
- )
7301
- ]
7302
- }
7303
- ) })
7304
- }
7305
- ));
7271
+ var CheckboxBase = React24.forwardRef(({ className, testid: dataTestId = "checkbox-base", checked: checkedProp, defaultChecked, onCheckedChange, ...props }, ref) => {
7272
+ const isControlled = checkedProp !== void 0;
7273
+ const [checkedState, setCheckedState] = React24.useState(
7274
+ isControlled ? checkedProp : defaultChecked ?? false
7275
+ );
7276
+ React24.useEffect(() => {
7277
+ if (isControlled) setCheckedState(checkedProp);
7278
+ }, [checkedProp, isControlled]);
7279
+ const handleCheckedChange = (next) => {
7280
+ if (!isControlled) setCheckedState(next);
7281
+ onCheckedChange?.(next);
7282
+ };
7283
+ const stateClass = checkedState === true || checkedState === "indeterminate" ? "bg-primary text-primary-foreground" : "";
7284
+ return /* @__PURE__ */ jsx44(
7285
+ CheckboxPrimitive.Root,
7286
+ {
7287
+ ref,
7288
+ checked: checkedProp,
7289
+ defaultChecked,
7290
+ onCheckedChange: handleCheckedChange,
7291
+ className: cn(
7292
+ "group h-4 w-4 shrink-0 rounded-md border border-primary shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 transition-colors",
7293
+ stateClass,
7294
+ className
7295
+ ),
7296
+ "data-testid": dataTestId,
7297
+ ...props,
7298
+ children: /* @__PURE__ */ jsx44(CheckboxPrimitive.Indicator, { asChild: true, children: /* @__PURE__ */ jsxs33(
7299
+ motion11.div,
7300
+ {
7301
+ initial: { scale: 0, opacity: 0, rotate: -90 },
7302
+ animate: { scale: 1, opacity: 1, rotate: 0 },
7303
+ exit: { scale: 0, opacity: 0, rotate: 90 },
7304
+ transition: { type: "spring", stiffness: 500, damping: 30 },
7305
+ className: "flex items-center justify-center text-current",
7306
+ children: [
7307
+ checkedState === true && /* @__PURE__ */ jsx44(CheckIcon8, { className: "h-4 w-4", weight: "bold" }),
7308
+ checkedState === "indeterminate" && /* @__PURE__ */ jsx44(MinusIcon, { className: "h-4 w-4", weight: "bold" })
7309
+ ]
7310
+ }
7311
+ ) })
7312
+ }
7313
+ );
7314
+ });
7306
7315
  CheckboxBase.displayName = CheckboxPrimitive.Root.displayName;
7307
7316
 
7308
7317
  // src/components/ui/form/CollapsibleBase.tsx
@@ -9917,7 +9926,7 @@ function DrawerDescriptionBase({
9917
9926
  }
9918
9927
 
9919
9928
  // src/hooks/use-universal-tooltip.tsx
9920
- import { createContext as createContext4, useContext as useContext5, useState as useState16, useCallback as useCallback11, useEffect as useEffect14, useRef as useRef7 } from "react";
9929
+ import { createContext as createContext4, useContext as useContext5, useState as useState17, useCallback as useCallback11, useEffect as useEffect15, useRef as useRef7 } from "react";
9921
9930
  import { jsx as jsx61 } from "react/jsx-runtime";
9922
9931
  var UniversalTooltipContext = createContext4(null);
9923
9932
  var useUniversalTooltip = () => {
@@ -10217,7 +10226,7 @@ CalendarBase2.displayName = "CalendarBase";
10217
10226
 
10218
10227
  // src/components/picker/DateTimePicker.tsx
10219
10228
  import { ptBR } from "date-fns/locale";
10220
- import { useEffect as useEffect15, useState as useState18 } from "react";
10229
+ import { useEffect as useEffect16, useState as useState19 } from "react";
10221
10230
 
10222
10231
  // src/components/picker/TimePicker.tsx
10223
10232
  import { motion as motion14, AnimatePresence as AnimatePresence10 } from "framer-motion";
@@ -10678,9 +10687,9 @@ function DateTimePicker({
10678
10687
  className,
10679
10688
  error
10680
10689
  }) {
10681
- const [internalDate, setInternalDate] = useState18(date);
10682
- const [open, setOpen] = useState18(false);
10683
- const [timePickerOpen, setTimePickerOpen] = useState18(false);
10690
+ const [internalDate, setInternalDate] = useState19(date);
10691
+ const [open, setOpen] = useState19(false);
10692
+ const [timePickerOpen, setTimePickerOpen] = useState19(false);
10684
10693
  const handleSelect = (newDay) => {
10685
10694
  if (!newDay) return;
10686
10695
  if (!internalDate) {
@@ -10711,7 +10720,7 @@ function DateTimePicker({
10711
10720
  if (!timeFormat) return "dd MMMM yyyy";
10712
10721
  return `dd MMMM yyyy - ${timeFormat}`;
10713
10722
  };
10714
- useEffect15(() => {
10723
+ useEffect16(() => {
10715
10724
  setInternalDate(date);
10716
10725
  }, [date, open]);
10717
10726
  return /* @__PURE__ */ jsxs49("div", { className: cn("w-full sm:w-auto", className), children: [
@@ -10728,7 +10737,7 @@ function DateTimePicker({
10728
10737
  {
10729
10738
  variant: "outline",
10730
10739
  className: cn(
10731
- "w-full justify-start text-left min-w-0 overflow-hidden no-active-animation",
10740
+ "w-full justify-start text-left min-w-0 overflow-hidden",
10732
10741
  !date && "text-muted-foreground"
10733
10742
  ),
10734
10743
  children: [
@@ -11665,7 +11674,7 @@ function StatusIndicator({
11665
11674
  }
11666
11675
 
11667
11676
  // src/components/ui/form/DebouncedInput.tsx
11668
- import { useEffect as useEffect17, useState as useState20 } from "react";
11677
+ import { useEffect as useEffect18, useState as useState21 } from "react";
11669
11678
  import { CircleNotchIcon as CircleNotchIcon2 } from "@phosphor-icons/react";
11670
11679
  import { jsx as jsx71 } from "react/jsx-runtime";
11671
11680
  function DebouncedInput({
@@ -11681,12 +11690,12 @@ function DebouncedInput({
11681
11690
  error,
11682
11691
  ...props
11683
11692
  }) {
11684
- const [value, setValue] = useState20(initialValue);
11685
- const [isDebouncing, setIsDebouncing] = useState20(false);
11686
- useEffect17(() => {
11693
+ const [value, setValue] = useState21(initialValue);
11694
+ const [isDebouncing, setIsDebouncing] = useState21(false);
11695
+ useEffect18(() => {
11687
11696
  setValue(initialValue);
11688
11697
  }, [initialValue]);
11689
- useEffect17(() => {
11698
+ useEffect18(() => {
11690
11699
  if (value !== initialValue) {
11691
11700
  setIsDebouncing(true);
11692
11701
  }
@@ -11797,7 +11806,7 @@ import {
11797
11806
  useSensors
11798
11807
  } from "@dnd-kit/core";
11799
11808
  import { addMinutes, differenceInMinutes } from "date-fns";
11800
- import { useId as useId2, useRef as useRef9, useState as useState21 } from "react";
11809
+ import { useId as useId2, useRef as useRef9, useState as useState22 } from "react";
11801
11810
 
11802
11811
  // src/components/event-calendar/hooks.ts
11803
11812
  import { createContext as createContext5, useContext as useContext6 } from "react";
@@ -11819,16 +11828,16 @@ function CalendarDndProvider({
11819
11828
  children,
11820
11829
  onEventUpdate
11821
11830
  }) {
11822
- const [activeEvent, setActiveEvent] = useState21(null);
11823
- const [activeId, setActiveId] = useState21(null);
11824
- const [activeView, setActiveView] = useState21(
11831
+ const [activeEvent, setActiveEvent] = useState22(null);
11832
+ const [activeId, setActiveId] = useState22(null);
11833
+ const [activeView, setActiveView] = useState22(
11825
11834
  null
11826
11835
  );
11827
- const [currentTime, setCurrentTime] = useState21(null);
11828
- const [eventHeight, setEventHeight] = useState21(null);
11829
- const [isMultiDay, setIsMultiDay] = useState21(false);
11830
- const [multiDayWidth, setMultiDayWidth] = useState21(null);
11831
- const [dragHandlePosition, setDragHandlePosition] = useState21(null);
11836
+ const [currentTime, setCurrentTime] = useState22(null);
11837
+ const [eventHeight, setEventHeight] = useState22(null);
11838
+ const [isMultiDay, setIsMultiDay] = useState22(false);
11839
+ const [multiDayWidth, setMultiDayWidth] = useState22(null);
11840
+ const [dragHandlePosition, setDragHandlePosition] = useState22(null);
11832
11841
  const eventDimensions = useRef9({ height: 0 });
11833
11842
  const sensors = useSensors(
11834
11843
  useSensor(MouseSensor, {
@@ -12268,7 +12277,7 @@ function DayView({
12268
12277
  import { useDraggable } from "@dnd-kit/core";
12269
12278
  import { CSS } from "@dnd-kit/utilities";
12270
12279
  import { differenceInDays } from "date-fns";
12271
- import { useRef as useRef10, useState as useState22 } from "react";
12280
+ import { useRef as useRef10, useState as useState23 } from "react";
12272
12281
  import { jsx as jsx75 } from "react/jsx-runtime";
12273
12282
  function DraggableEvent({
12274
12283
  event,
@@ -12284,7 +12293,7 @@ function DraggableEvent({
12284
12293
  }) {
12285
12294
  const { activeId } = useCalendarDnd();
12286
12295
  const elementRef = useRef10(null);
12287
- const [dragHandlePosition, setDragHandlePosition] = useState22(null);
12296
+ const [dragHandlePosition, setDragHandlePosition] = useState23(null);
12288
12297
  const eventStart = new Date(event.start);
12289
12298
  const eventEnd = new Date(event.end);
12290
12299
  const isMultiDayEvent2 = isMultiDay || event.allDay || differenceInDays(eventEnd, eventStart) >= 1;
@@ -12419,7 +12428,7 @@ import {
12419
12428
  subWeeks
12420
12429
  } from "date-fns";
12421
12430
  import { ptBR as ptBR4 } from "date-fns/locale";
12422
- import { useEffect as useEffect18, useMemo as useMemo11, useState as useState23, useCallback as useCallback12 } from "react";
12431
+ import { useEffect as useEffect19, useMemo as useMemo11, useState as useState24, useCallback as useCallback12 } from "react";
12423
12432
  import { toast as toast3 } from "sonner";
12424
12433
  import {
12425
12434
  ArrowDownIcon,
@@ -12437,9 +12446,9 @@ function EventCalendar({
12437
12446
  className,
12438
12447
  initialView = "month"
12439
12448
  }) {
12440
- const [currentDate, setCurrentDate] = useState23(/* @__PURE__ */ new Date());
12441
- const [view, setView] = useState23(initialView);
12442
- const [isFading, setIsFading] = useState23(false);
12449
+ const [currentDate, setCurrentDate] = useState24(/* @__PURE__ */ new Date());
12450
+ const [view, setView] = useState24(initialView);
12451
+ const [isFading, setIsFading] = useState24(false);
12443
12452
  const FADE_DURATION = 220;
12444
12453
  const changeView = useCallback12(
12445
12454
  (next) => {
@@ -12452,8 +12461,8 @@ function EventCalendar({
12452
12461
  },
12453
12462
  [view]
12454
12463
  );
12455
- const [isPaging, setIsPaging] = useState23(false);
12456
- const [pageDirection, setPageDirection] = useState23(
12464
+ const [isPaging, setIsPaging] = useState24(false);
12465
+ const [pageDirection, setPageDirection] = useState24(
12457
12466
  null
12458
12467
  );
12459
12468
  const PAGE_DURATION = 200;
@@ -12471,11 +12480,11 @@ function EventCalendar({
12471
12480
  },
12472
12481
  []
12473
12482
  );
12474
- const [isEventDialogOpen, setIsEventDialogOpen] = useState23(false);
12475
- const [selectedEvent, setSelectedEvent] = useState23(
12483
+ const [isEventDialogOpen, setIsEventDialogOpen] = useState24(false);
12484
+ const [selectedEvent, setSelectedEvent] = useState24(
12476
12485
  null
12477
12486
  );
12478
- useEffect18(() => {
12487
+ useEffect19(() => {
12479
12488
  const handleKeyDown = (e) => {
12480
12489
  if (isEventDialogOpen || e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement || e.target instanceof HTMLElement && e.target.isContentEditable) {
12481
12490
  return;
@@ -12862,7 +12871,7 @@ function EventCalendar({
12862
12871
 
12863
12872
  // src/components/event-calendar/EventDialog.tsx
12864
12873
  import { format as format6, isBefore } from "date-fns";
12865
- import { useCallback as useCallback13, useEffect as useEffect19, useMemo as useMemo12, useState as useState24 } from "react";
12874
+ import { useCallback as useCallback13, useEffect as useEffect20, useMemo as useMemo12, useState as useState25 } from "react";
12866
12875
  import { RadioGroup as RadioGroup3, RadioGroupItem } from "@radix-ui/react-radio-group";
12867
12876
  import { motion as motion16 } from "framer-motion";
12868
12877
  import { ptBR as ptBR5 } from "date-fns/locale";
@@ -12875,19 +12884,19 @@ function EventDialog({
12875
12884
  onSave,
12876
12885
  onDelete
12877
12886
  }) {
12878
- const [title, setTitle] = useState24("");
12879
- const [description, setDescription] = useState24("");
12880
- const [startDate, setStartDate] = useState24(/* @__PURE__ */ new Date());
12881
- const [endDate, setEndDate] = useState24(/* @__PURE__ */ new Date());
12882
- const [startTime, setStartTime] = useState24(`${DefaultStartHour}:00`);
12883
- const [endTime, setEndTime] = useState24(`${DefaultEndHour}:00`);
12884
- const [allDay, setAllDay] = useState24(false);
12885
- const [location, setLocation] = useState24("");
12886
- const [color, setColor] = useState24("sky");
12887
- const [error, setError] = useState24(null);
12888
- const [startDateOpen, setStartDateOpen] = useState24(false);
12889
- const [endDateOpen, setEndDateOpen] = useState24(false);
12890
- useEffect19(() => {
12887
+ const [title, setTitle] = useState25("");
12888
+ const [description, setDescription] = useState25("");
12889
+ const [startDate, setStartDate] = useState25(/* @__PURE__ */ new Date());
12890
+ const [endDate, setEndDate] = useState25(/* @__PURE__ */ new Date());
12891
+ const [startTime, setStartTime] = useState25(`${DefaultStartHour}:00`);
12892
+ const [endTime, setEndTime] = useState25(`${DefaultEndHour}:00`);
12893
+ const [allDay, setAllDay] = useState25(false);
12894
+ const [location, setLocation] = useState25("");
12895
+ const [color, setColor] = useState25("sky");
12896
+ const [error, setError] = useState25(null);
12897
+ const [startDateOpen, setStartDateOpen] = useState25(false);
12898
+ const [endDateOpen, setEndDateOpen] = useState25(false);
12899
+ useEffect20(() => {
12891
12900
  }, [event]);
12892
12901
  const resetForm = useCallback13(() => {
12893
12902
  setTitle("");
@@ -12906,7 +12915,7 @@ function EventDialog({
12906
12915
  const minutes = Math.floor(date.getMinutes() / 15) * 15;
12907
12916
  return `${hours}:${minutes.toString().padStart(2, "0")}`;
12908
12917
  }, []);
12909
- useEffect19(() => {
12918
+ useEffect20(() => {
12910
12919
  if (event) {
12911
12920
  setTitle(event.title || "");
12912
12921
  setDescription(event.description || "");
@@ -13518,7 +13527,7 @@ function EventItem({
13518
13527
  // src/components/event-calendar/EventsPopUp.tsx
13519
13528
  import { format as format8, isSameDay as isSameDay2 } from "date-fns";
13520
13529
  import { ptBR as ptBR6 } from "date-fns/locale";
13521
- import { useEffect as useEffect20, useMemo as useMemo14, useRef as useRef11 } from "react";
13530
+ import { useEffect as useEffect21, useMemo as useMemo14, useRef as useRef11 } from "react";
13522
13531
  import { motion as motion17 } from "framer-motion";
13523
13532
  import { XIcon as XIcon11 } from "@phosphor-icons/react";
13524
13533
  import { jsx as jsx80, jsxs as jsxs60 } from "react/jsx-runtime";
@@ -13530,7 +13539,7 @@ function EventsPopup({
13530
13539
  onEventSelect
13531
13540
  }) {
13532
13541
  const popupRef = useRef11(null);
13533
- useEffect20(() => {
13542
+ useEffect21(() => {
13534
13543
  const handleClickOutside = (event) => {
13535
13544
  if (popupRef.current && !popupRef.current.contains(event.target)) {
13536
13545
  onClose();
@@ -13541,7 +13550,7 @@ function EventsPopup({
13541
13550
  document.removeEventListener("mousedown", handleClickOutside);
13542
13551
  };
13543
13552
  }, [onClose]);
13544
- useEffect20(() => {
13553
+ useEffect21(() => {
13545
13554
  const handleEscKey = (event) => {
13546
13555
  if (event.key === "Escape") {
13547
13556
  onClose();
@@ -13635,11 +13644,11 @@ function EventsPopup({
13635
13644
  // src/components/event-calendar/hooks/use-current-time-indicator.ts
13636
13645
  import { endOfWeek as endOfWeek2, isSameDay as isSameDay3, isWithinInterval, startOfWeek as startOfWeek2 } from "date-fns";
13637
13646
  import { ptBR as ptBR7 } from "date-fns/locale";
13638
- import { useEffect as useEffect21, useState as useState25 } from "react";
13647
+ import { useEffect as useEffect22, useState as useState26 } from "react";
13639
13648
  function useCurrentTimeIndicator(currentDate, view) {
13640
- const [currentTimePosition, setCurrentTimePosition] = useState25(0);
13641
- const [currentTimeVisible, setCurrentTimeVisible] = useState25(false);
13642
- useEffect21(() => {
13649
+ const [currentTimePosition, setCurrentTimePosition] = useState26(0);
13650
+ const [currentTimeVisible, setCurrentTimeVisible] = useState26(false);
13651
+ useEffect22(() => {
13643
13652
  const calculateTimePosition = () => {
13644
13653
  const now = /* @__PURE__ */ new Date();
13645
13654
  const hours = now.getHours();
@@ -13670,14 +13679,14 @@ function useCurrentTimeIndicator(currentDate, view) {
13670
13679
  }
13671
13680
 
13672
13681
  // src/components/event-calendar/hooks/use-event-visibility.ts
13673
- import { useLayoutEffect as useLayoutEffect2, useMemo as useMemo15, useRef as useRef12, useState as useState26 } from "react";
13682
+ import { useLayoutEffect as useLayoutEffect2, useMemo as useMemo15, useRef as useRef12, useState as useState27 } from "react";
13674
13683
  function useEventVisibility({
13675
13684
  eventHeight,
13676
13685
  eventGap
13677
13686
  }) {
13678
13687
  const contentRef = useRef12(null);
13679
13688
  const observerRef = useRef12(null);
13680
- const [contentHeight, setContentHeight] = useState26(null);
13689
+ const [contentHeight, setContentHeight] = useState27(null);
13681
13690
  useLayoutEffect2(() => {
13682
13691
  if (!contentRef.current) return;
13683
13692
  const updateHeight = () => {
@@ -13729,7 +13738,7 @@ import {
13729
13738
  startOfWeek as startOfWeek3
13730
13739
  } from "date-fns";
13731
13740
  import { ptBR as ptBR8 } from "date-fns/locale";
13732
- import { useEffect as useEffect22, useMemo as useMemo16, useState as useState27 } from "react";
13741
+ import { useEffect as useEffect23, useMemo as useMemo16, useState as useState28 } from "react";
13733
13742
  import { jsx as jsx81, jsxs as jsxs61 } from "react/jsx-runtime";
13734
13743
  function MonthView({
13735
13744
  currentDate,
@@ -13767,12 +13776,12 @@ function MonthView({
13767
13776
  e.stopPropagation();
13768
13777
  onEventSelect(event);
13769
13778
  };
13770
- const [isMounted, setIsMounted] = useState27(false);
13779
+ const [isMounted, setIsMounted] = useState28(false);
13771
13780
  const { contentRef, getVisibleEventCount } = useEventVisibility({
13772
13781
  eventGap: EventGap,
13773
13782
  eventHeight: EventHeight
13774
13783
  });
13775
- useEffect22(() => {
13784
+ useEffect23(() => {
13776
13785
  setIsMounted(true);
13777
13786
  }, []);
13778
13787
  return /* @__PURE__ */ jsxs61("div", { className: "contents", "data-slot": "month-view", children: [
@@ -14324,14 +14333,164 @@ function WeekView({
14324
14333
  ] });
14325
14334
  }
14326
14335
 
14336
+ // src/components/ui/form/CheckBoxThree.tsx
14337
+ import { useCallback as useCallback14, useMemo as useMemo18, useState as useState29, useEffect as useEffect24, useRef as useRef13 } from "react";
14338
+ import { motion as motion18, AnimatePresence as AnimatePresence12 } from "framer-motion";
14339
+ import { jsx as jsx83, jsxs as jsxs63 } from "react/jsx-runtime";
14340
+ function useCheckboxTree(initialTree) {
14341
+ const initialCheckedNodes = useMemo18(() => {
14342
+ const checkedSet = /* @__PURE__ */ new Set();
14343
+ const initializeCheckedNodes = (node) => {
14344
+ if (node.defaultChecked) {
14345
+ checkedSet.add(node.id);
14346
+ }
14347
+ node.children?.forEach(initializeCheckedNodes);
14348
+ };
14349
+ initializeCheckedNodes(initialTree);
14350
+ return checkedSet;
14351
+ }, [initialTree]);
14352
+ const [checkedNodes, setCheckedNodes] = useState29(initialCheckedNodes);
14353
+ const isChecked = useCallback14(
14354
+ (node) => {
14355
+ if (!node.children) {
14356
+ return checkedNodes.has(node.id);
14357
+ }
14358
+ const childrenChecked = node.children.map((child) => isChecked(child));
14359
+ if (childrenChecked.every((status) => status === true)) {
14360
+ return true;
14361
+ }
14362
+ if (childrenChecked.some(
14363
+ (status) => status === true || status === "indeterminate"
14364
+ )) {
14365
+ return "indeterminate";
14366
+ }
14367
+ return false;
14368
+ },
14369
+ [checkedNodes]
14370
+ );
14371
+ const handleCheck = useCallback14(
14372
+ (node) => {
14373
+ const newCheckedNodes = new Set(checkedNodes);
14374
+ const toggleNode = (n, check) => {
14375
+ if (check) {
14376
+ newCheckedNodes.add(n.id);
14377
+ } else {
14378
+ newCheckedNodes.delete(n.id);
14379
+ }
14380
+ for (const child of n.children ?? []) {
14381
+ toggleNode(child, check);
14382
+ }
14383
+ };
14384
+ const currentStatus = isChecked(node);
14385
+ const newCheck = currentStatus !== true;
14386
+ toggleNode(node, newCheck);
14387
+ setCheckedNodes(newCheckedNodes);
14388
+ },
14389
+ [checkedNodes, isChecked]
14390
+ );
14391
+ return { handleCheck, isChecked };
14392
+ }
14393
+ function CheckboxTree({ tree, renderNode }) {
14394
+ const { isChecked, handleCheck } = useCheckboxTree(tree);
14395
+ const DefaultNode = ({
14396
+ node,
14397
+ isChecked: status,
14398
+ onCheckedChange,
14399
+ children
14400
+ }) => {
14401
+ const [open, setOpen] = useState29(() => !!node.children && status !== false);
14402
+ const checkboxRef = useRef13(null);
14403
+ useEffect24(() => {
14404
+ if (checkboxRef.current) {
14405
+ checkboxRef.current.indeterminate = status === "indeterminate";
14406
+ }
14407
+ if (node.children) {
14408
+ setOpen(status !== false);
14409
+ }
14410
+ }, [status, node.children]);
14411
+ return /* @__PURE__ */ jsxs63("div", { className: "pl-1", children: [
14412
+ /* @__PURE__ */ jsxs63("div", { className: "flex items-center gap-2", children: [
14413
+ node.children ? /* @__PURE__ */ jsx83(
14414
+ "button",
14415
+ {
14416
+ "aria-label": open ? "Fechar" : "Abrir",
14417
+ onClick: () => setOpen((v) => !v),
14418
+ className: "w-6 h-6 flex items-center justify-center rounded hover:bg-slate-100 dark:hover:bg-slate-800",
14419
+ children: /* @__PURE__ */ jsx83(
14420
+ motion18.span,
14421
+ {
14422
+ animate: { rotate: open ? 90 : 0 },
14423
+ transition: { duration: 0.18 },
14424
+ className: "inline-block text-slate-500",
14425
+ children: "\u25B6"
14426
+ }
14427
+ )
14428
+ }
14429
+ ) : /* @__PURE__ */ jsx83("div", { className: "w-6 h-6" }),
14430
+ /* @__PURE__ */ jsxs63("label", { className: "flex items-center gap-2 cursor-pointer select-none", children: [
14431
+ /* @__PURE__ */ jsxs63("span", { className: "relative", children: [
14432
+ /* @__PURE__ */ jsx83(
14433
+ "input",
14434
+ {
14435
+ ref: checkboxRef,
14436
+ type: "checkbox",
14437
+ checked: status === true,
14438
+ onChange: onCheckedChange,
14439
+ className: "appearance-none w-5 h-5 rounded border border-slate-300 dark:border-slate-700 flex items-center justify-center bg-white dark:bg-slate-900 checked:bg-blue-600 checked:border-blue-600 focus:outline-none"
14440
+ }
14441
+ ),
14442
+ /* @__PURE__ */ jsx83(
14443
+ motion18.span,
14444
+ {
14445
+ initial: false,
14446
+ animate: { scale: status === true ? 1 : 0.8, opacity: status === true ? 1 : 0 },
14447
+ transition: { duration: 0.14 },
14448
+ className: "pointer-events-none absolute left-0 top-0 w-5 h-5 flex items-center justify-center text-white",
14449
+ children: status === true ? /* @__PURE__ */ jsx83("svg", { width: "12", height: "10", viewBox: "0 0 12 10", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx83("path", { d: "M1 5L4 8L11 1", stroke: "white", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) : null
14450
+ }
14451
+ )
14452
+ ] }),
14453
+ /* @__PURE__ */ jsx83("span", { className: "text-sm text-slate-700 dark:text-slate-200", children: node.label })
14454
+ ] })
14455
+ ] }),
14456
+ /* @__PURE__ */ jsx83(AnimatePresence12, { initial: false, children: open && node.children && /* @__PURE__ */ jsx83(
14457
+ motion18.div,
14458
+ {
14459
+ initial: { height: 0, opacity: 0 },
14460
+ animate: { height: "auto", opacity: 1 },
14461
+ exit: { height: 0, opacity: 0 },
14462
+ transition: { duration: 0.18 },
14463
+ className: "ml-6 mt-2 overflow-hidden",
14464
+ children: /* @__PURE__ */ jsx83("div", { className: "flex flex-col gap-1", children })
14465
+ },
14466
+ "children"
14467
+ ) })
14468
+ ] });
14469
+ };
14470
+ const renderTreeNode = (node) => {
14471
+ const children = node.children?.map(renderTreeNode);
14472
+ const nodePayload = {
14473
+ children,
14474
+ isChecked: isChecked(node),
14475
+ node,
14476
+ onCheckedChange: () => handleCheck(node)
14477
+ };
14478
+ if (renderNode) {
14479
+ return renderNode(nodePayload);
14480
+ }
14481
+ return /* @__PURE__ */ jsx83(DefaultNode, { ...nodePayload });
14482
+ };
14483
+ return renderTreeNode(tree);
14484
+ }
14485
+
14327
14486
  // src/hooks/use-drag.tsx
14328
- import { useState as useState28, useCallback as useCallback14, useRef as useRef13, useEffect as useEffect23 } from "react";
14487
+ import { useState as useState30, useCallback as useCallback15, useRef as useRef14, useEffect as useEffect25 } from "react";
14329
14488
  var useDrag = (options = {}) => {
14330
- const [isDragging, setIsDragging] = useState28(null);
14331
- const [positions, setPositions] = useState28({});
14332
- const dragStartPos = useRef13(null);
14333
- const dragId = useRef13(null);
14334
- const handleMouseDown = useCallback14((id, e) => {
14489
+ const [isDragging, setIsDragging] = useState30(null);
14490
+ const [positions, setPositions] = useState30({});
14491
+ const dragStartPos = useRef14(null);
14492
+ const dragId = useRef14(null);
14493
+ const handleMouseDown = useCallback15((id, e) => {
14335
14494
  e.preventDefault();
14336
14495
  const currentPosition = positions[id] || { top: 0, left: 0 };
14337
14496
  dragStartPos.current = {
@@ -14344,7 +14503,7 @@ var useDrag = (options = {}) => {
14344
14503
  setIsDragging(id);
14345
14504
  options.onDragStart?.(id);
14346
14505
  }, [positions, options]);
14347
- const handleMouseMove = useCallback14((e) => {
14506
+ const handleMouseMove = useCallback15((e) => {
14348
14507
  if (!isDragging || !dragStartPos.current || !dragId.current) return;
14349
14508
  const deltaX = e.clientX - dragStartPos.current.x;
14350
14509
  const deltaY = e.clientY - dragStartPos.current.y;
@@ -14360,7 +14519,7 @@ var useDrag = (options = {}) => {
14360
14519
  }));
14361
14520
  options.onDrag?.(dragId.current, newPosition);
14362
14521
  }, [isDragging, options]);
14363
- const handleMouseUp = useCallback14(() => {
14522
+ const handleMouseUp = useCallback15(() => {
14364
14523
  if (dragId.current) {
14365
14524
  options.onDragEnd?.(dragId.current);
14366
14525
  }
@@ -14368,7 +14527,7 @@ var useDrag = (options = {}) => {
14368
14527
  dragStartPos.current = null;
14369
14528
  dragId.current = null;
14370
14529
  }, [options]);
14371
- useEffect23(() => {
14530
+ useEffect25(() => {
14372
14531
  if (isDragging) {
14373
14532
  document.addEventListener("mousemove", handleMouseMove);
14374
14533
  document.addEventListener("mouseup", handleMouseUp);
@@ -14380,16 +14539,16 @@ var useDrag = (options = {}) => {
14380
14539
  };
14381
14540
  }
14382
14541
  }, [isDragging, handleMouseMove, handleMouseUp]);
14383
- const setPosition = useCallback14((id, position) => {
14542
+ const setPosition = useCallback15((id, position) => {
14384
14543
  setPositions((prev) => ({
14385
14544
  ...prev,
14386
14545
  [id]: position
14387
14546
  }));
14388
14547
  }, []);
14389
- const getPosition = useCallback14((id) => {
14548
+ const getPosition = useCallback15((id) => {
14390
14549
  return positions[id] || { top: 0, left: 0 };
14391
14550
  }, [positions]);
14392
- const isElementDragging = useCallback14((id) => {
14551
+ const isElementDragging = useCallback15((id) => {
14393
14552
  return isDragging === id;
14394
14553
  }, [isDragging]);
14395
14554
  return {
@@ -14448,6 +14607,7 @@ export {
14448
14607
  Chart_default as Chart,
14449
14608
  CheckButton,
14450
14609
  CheckboxBase,
14610
+ CheckboxTree,
14451
14611
  CloseAllButton_default as CloseAllButton,
14452
14612
  CloseButton,
14453
14613
  CodeBlock,