lizaui 9.0.25 → 9.0.26
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/calendar/index.cjs.js +137 -27
- package/dist/calendar/index.cjs.js.map +1 -1
- package/dist/calendar/index.es.js +137 -27
- package/dist/calendar/index.es.js.map +1 -1
- package/dist/components/calendar/date-picker/date-picker.d.ts.map +1 -1
- package/dist/components/calendar/date-picker/date-picker.style.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -14,7 +14,6 @@ import { twMerge } from "tailwind-merge";
|
|
|
14
14
|
import { v4 } from "uuid";
|
|
15
15
|
import { L as LabelError } from "../chunks/label-error-BTCuInp7.js";
|
|
16
16
|
import { c as cn } from "../chunks/utils-H80jjgLf.js";
|
|
17
|
-
import { B as Button } from "../chunks/button-B0fpJrMg.js";
|
|
18
17
|
function FaArrowLeft(props) {
|
|
19
18
|
return GenIcon({ "attr": { "viewBox": "0 0 448 512" }, "child": [{ "tag": "path", "attr": { "d": "M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.2 288 416 288c17.7 0 32-14.3 32-32s-14.3-32-32-32l-306.7 0L214.6 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160z" }, "child": [] }] })(props);
|
|
20
19
|
}
|
|
@@ -415,18 +414,18 @@ const CalendarStyle = dt.div`
|
|
|
415
414
|
width: ${({ widthcalendar }) => `${widthcalendar}px`};
|
|
416
415
|
} */
|
|
417
416
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
417
|
+
.react-calendar--doubleView {
|
|
418
|
+
--cal-cell-size: 34px !important;
|
|
419
|
+
width: 512px !important;
|
|
420
|
+
}
|
|
422
421
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
422
|
+
.react-calendar--doubleView .react-calendar__month-view__weekdays {
|
|
423
|
+
gap: 0px;
|
|
424
|
+
}
|
|
426
425
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
426
|
+
.react-calendar--doubleView .react-calendar__month-view__days {
|
|
427
|
+
gap: 0px;
|
|
428
|
+
}
|
|
430
429
|
|
|
431
430
|
.react-calendar__navigation {
|
|
432
431
|
height: 40px; /* Más compacto */
|
|
@@ -531,6 +530,11 @@ const CalendarStyle = dt.div`
|
|
|
531
530
|
transition: background-color 0.18s ease, color 0.18s ease, border-radius 0.25s ease, transform 0.18s ease;
|
|
532
531
|
}
|
|
533
532
|
|
|
533
|
+
.react-calendar__tile--hasActive {
|
|
534
|
+
background: var(--color-primary-300);
|
|
535
|
+
border-radius: 50% !important;
|
|
536
|
+
}
|
|
537
|
+
|
|
534
538
|
/* Suavizar botones navegación (heredan selector button) */
|
|
535
539
|
.react-calendar__navigation button {
|
|
536
540
|
transition: background-color 0.18s ease, color 0.18s ease, border-radius 0.25s ease;
|
|
@@ -582,16 +586,16 @@ const CalendarStyle = dt.div`
|
|
|
582
586
|
border-radius: 50%;
|
|
583
587
|
width: var(--cal-cell-size);
|
|
584
588
|
height: var(--cal-cell-size);
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
589
|
+
min-width: var(--cal-cell-size);
|
|
590
|
+
max-width: var(--cal-cell-size);
|
|
591
|
+
min-height: var(--cal-cell-size);
|
|
592
|
+
max-height: var(--cal-cell-size);
|
|
593
|
+
color: hsl(var(--color-default-400) / 1);
|
|
590
594
|
}
|
|
591
595
|
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
596
|
+
.react-calendar__year-view__months__month {
|
|
597
|
+
border-radius: 8px !important;
|
|
598
|
+
}
|
|
595
599
|
|
|
596
600
|
${({ color }) => {
|
|
597
601
|
switch (color) {
|
|
@@ -715,15 +719,21 @@ const CalendarStyle = dt.div`
|
|
|
715
719
|
}}
|
|
716
720
|
|
|
717
721
|
.react-calendar--doubleView .react-calendar__tile--active {
|
|
718
|
-
background-color: var(--color-
|
|
719
|
-
color: var(--color-
|
|
722
|
+
background-color: var(--color-primary-50);
|
|
723
|
+
color: var(--color-primary);
|
|
720
724
|
border-radius: 0px;
|
|
725
|
+
position: relative;
|
|
721
726
|
}
|
|
722
727
|
|
|
728
|
+
|
|
723
729
|
.react-calendar--selectRange .react-calendar__tile--hover {
|
|
724
730
|
background-color: var(--color-default-100);
|
|
725
731
|
}
|
|
726
732
|
|
|
733
|
+
.react-calendar--selectRange .react-calendar__tile--hover.react-calendar__month-view__days__day{
|
|
734
|
+
/* border-radius: 0px !important; */
|
|
735
|
+
}
|
|
736
|
+
|
|
727
737
|
.react-calendar__tile--active.react-calendar__month-view__days__day.react-calendar__month-view__days__day--neighboringMonth {
|
|
728
738
|
background-color: var(--color-content1-default);
|
|
729
739
|
color: var(--color-default-300);
|
|
@@ -793,6 +803,81 @@ const CalendarPicker = ({
|
|
|
793
803
|
handleChange(date);
|
|
794
804
|
}
|
|
795
805
|
};
|
|
806
|
+
const startOfDay = useCallback((d) => new Date(d.getFullYear(), d.getMonth(), d.getDate(), 0, 0, 0, 0), []);
|
|
807
|
+
const addDays = useCallback((d, n) => startOfDay(new Date(d.getFullYear(), d.getMonth(), d.getDate() + n)), [startOfDay]);
|
|
808
|
+
const startOfMonth = useCallback((d) => new Date(d.getFullYear(), d.getMonth(), 1, 0, 0, 0, 0), []);
|
|
809
|
+
const endOfMonth = useCallback((d) => new Date(d.getFullYear(), d.getMonth() + 1, 0, 23, 59, 59, 999), []);
|
|
810
|
+
const isSameDay = (a, b) => {
|
|
811
|
+
if (!a || !b) return false;
|
|
812
|
+
return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
813
|
+
};
|
|
814
|
+
const isSameRange = (range, target) => {
|
|
815
|
+
if (!Array.isArray(range) || !Array.isArray(target)) return false;
|
|
816
|
+
const [r0, r1] = range;
|
|
817
|
+
const [t0, t1] = target;
|
|
818
|
+
return isSameDay(r0, t0) && isSameDay(r1, t1);
|
|
819
|
+
};
|
|
820
|
+
const presets = useMemo(() => {
|
|
821
|
+
const today = startOfDay(/* @__PURE__ */ new Date());
|
|
822
|
+
if (type === "date-picker") {
|
|
823
|
+
return [
|
|
824
|
+
{ key: "today", label: "Hoy", getValue: () => today },
|
|
825
|
+
{ key: "tomorrow", label: "Mañana", getValue: () => addDays(today, 1) },
|
|
826
|
+
{ key: "in7", label: "+7 días", getValue: () => addDays(today, 7) },
|
|
827
|
+
{ key: "in30", label: "+30 días", getValue: () => addDays(today, 30) },
|
|
828
|
+
{ key: "clear", label: "Limpiar", action: () => onChange(null), separator: true }
|
|
829
|
+
];
|
|
830
|
+
} else {
|
|
831
|
+
const last7Start = addDays(today, -6);
|
|
832
|
+
const next7End = addDays(today, 6);
|
|
833
|
+
const thisMonthStart = startOfMonth(today);
|
|
834
|
+
const thisMonthEnd = endOfMonth(today);
|
|
835
|
+
const lastMonthRef = addDays(thisMonthStart, -1);
|
|
836
|
+
const lastMonthStart = startOfMonth(lastMonthRef);
|
|
837
|
+
const lastMonthEnd = endOfMonth(lastMonthRef);
|
|
838
|
+
return [
|
|
839
|
+
{ key: "today", label: "Hoy", getValue: () => [today, today] },
|
|
840
|
+
{ key: "last7", label: "Últimos 7 días", getValue: () => [last7Start, today] },
|
|
841
|
+
{ key: "next7", label: "Próx. 7 días", getValue: () => [today, next7End] },
|
|
842
|
+
{ key: "thisMonth", label: "Este mes", getValue: () => [thisMonthStart, thisMonthEnd] },
|
|
843
|
+
{
|
|
844
|
+
key: "nextMonth",
|
|
845
|
+
label: "Próximo mes",
|
|
846
|
+
getValue: () => {
|
|
847
|
+
const nextMonthRef = addDays(thisMonthEnd, 1);
|
|
848
|
+
const nextMonthStart = startOfMonth(nextMonthRef);
|
|
849
|
+
const nextMonthEnd = endOfMonth(nextMonthRef);
|
|
850
|
+
return [nextMonthStart, nextMonthEnd];
|
|
851
|
+
}
|
|
852
|
+
},
|
|
853
|
+
{ key: "lastMonth", label: "Mes pasado", getValue: () => [lastMonthStart, lastMonthEnd] }
|
|
854
|
+
// { key: "clear", label: "Limpiar", action: () => onChange(null), separator: true },
|
|
855
|
+
];
|
|
856
|
+
}
|
|
857
|
+
}, [type, onChange, addDays, startOfDay, startOfMonth, endOfMonth]);
|
|
858
|
+
const isPresetActive = (preset) => {
|
|
859
|
+
if (preset.getValue) {
|
|
860
|
+
const pv = preset.getValue();
|
|
861
|
+
if (type === "date-picker") {
|
|
862
|
+
return !Array.isArray(value) && !Array.isArray(pv) && isSameDay(value, pv);
|
|
863
|
+
} else {
|
|
864
|
+
return Array.isArray(value) && Array.isArray(pv) && isSameRange(value, pv);
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
return false;
|
|
868
|
+
};
|
|
869
|
+
const handlePresetClick = (preset) => {
|
|
870
|
+
if (preset.action) {
|
|
871
|
+
preset.action();
|
|
872
|
+
setShow(false);
|
|
873
|
+
return;
|
|
874
|
+
}
|
|
875
|
+
if (preset.getValue) {
|
|
876
|
+
const v = preset.getValue();
|
|
877
|
+
onChange(v);
|
|
878
|
+
setShow(false);
|
|
879
|
+
}
|
|
880
|
+
};
|
|
796
881
|
const handleCloseCalendar = () => {
|
|
797
882
|
if (disabled) return;
|
|
798
883
|
setShow(false);
|
|
@@ -834,7 +919,36 @@ const CalendarPicker = ({
|
|
|
834
919
|
/* <Loading size="sm" color="secondary" /> */
|
|
835
920
|
/* @__PURE__ */ jsx("p", { children: "loading" })
|
|
836
921
|
) : null,
|
|
837
|
-
/* @__PURE__ */ jsxs("div", { className: "w-full relative flex
|
|
922
|
+
/* @__PURE__ */ jsxs("div", { className: "w-full relative flex gap-2", children: [
|
|
923
|
+
showActionButtons && /* @__PURE__ */ jsxs("div", { className: "w-[150px] border-r border-default-200 px-3 py-3 flex flex-col gap-1 overflow-y-auto max-h-[340px]", children: [
|
|
924
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-default-400 mb-1 select-none uppercase tracking-wide", children: "Atajos" }),
|
|
925
|
+
presets.map((p) => {
|
|
926
|
+
const active = isPresetActive(p);
|
|
927
|
+
return /* @__PURE__ */ jsx(
|
|
928
|
+
"button",
|
|
929
|
+
{
|
|
930
|
+
type: "button",
|
|
931
|
+
onClick: () => handlePresetClick(p),
|
|
932
|
+
className: twMerge(
|
|
933
|
+
"text-left rounded-md px-2 py-1.5 text-sm w-full cursor-pointer transition-colors",
|
|
934
|
+
active ? "bg-default-200/70 dark:bg-default-100 font-medium" : "bg-content1 hover:bg-default-100"
|
|
935
|
+
),
|
|
936
|
+
"data-active": active || void 0,
|
|
937
|
+
children: p.label
|
|
938
|
+
},
|
|
939
|
+
p.key
|
|
940
|
+
);
|
|
941
|
+
}),
|
|
942
|
+
/* @__PURE__ */ jsx("div", { className: "mt-2 pt-2 border-t border-default-200 flex flex-col gap-1", children: /* @__PURE__ */ jsx(
|
|
943
|
+
"button",
|
|
944
|
+
{
|
|
945
|
+
type: "button",
|
|
946
|
+
onClick: handleChangeToDay,
|
|
947
|
+
className: "text-left rounded-md px-2 py-1.5 text-sm w-full cursor-pointer bg-content1 hover:bg-default-100",
|
|
948
|
+
children: "Ir a hoy (Cerrar)"
|
|
949
|
+
}
|
|
950
|
+
) })
|
|
951
|
+
] }),
|
|
838
952
|
/* @__PURE__ */ jsx(
|
|
839
953
|
Calendar,
|
|
840
954
|
{
|
|
@@ -852,11 +966,7 @@ const CalendarPicker = ({
|
|
|
852
966
|
nextLabel: /* @__PURE__ */ jsx(FaArrowRight, { className: "w-4 h-4 text-default-400" }),
|
|
853
967
|
tileContent
|
|
854
968
|
}
|
|
855
|
-
)
|
|
856
|
-
showActionButtons && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center gap-x-4 p-3 w-full", children: [
|
|
857
|
-
/* @__PURE__ */ jsx(Button, { onClick: handleChangeToDay, color, className: "flex-1", children: "Hoy" }),
|
|
858
|
-
/* @__PURE__ */ jsx(Button, { color: "default", variant: "bordered", className: "flex-1", onClick: () => setShow(false), children: "Cerrar" })
|
|
859
|
-
] })
|
|
969
|
+
)
|
|
860
970
|
] })
|
|
861
971
|
]
|
|
862
972
|
}
|