componentes-sinco 1.1.20 → 1.1.22

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
@@ -1716,7 +1716,10 @@ var StopEvent = ({ children }) => {
1716
1716
  e.preventDefault();
1717
1717
  e.stopPropagation();
1718
1718
  },
1719
- onClick: (e) => e.stopPropagation(),
1719
+ onClick: (e) => {
1720
+ e.preventDefault();
1721
+ e.stopPropagation();
1722
+ },
1720
1723
  display: "inline-flex",
1721
1724
  alignItems: "center"
1722
1725
  },
@@ -1829,17 +1832,19 @@ function SCAutocomplete({
1829
1832
  (item) => getItemValue(item).value === state.hiddenValue
1830
1833
  ) || null;
1831
1834
  const [open, setOpen] = React11.useState(false);
1835
+ const componentClickActiveRef = React11.useRef(false);
1832
1836
  const hayOnComponentClickGlobal = useMemo3(() => {
1833
1837
  return data.some((opt) => {
1834
1838
  const item = getItemValue(opt);
1835
1839
  return Boolean(item.onComponentClick);
1836
1840
  });
1837
- }, [data]);
1841
+ }, [data, getItemValue]);
1838
1842
  return /* @__PURE__ */ React11.createElement(React11.Fragment, null, data && /* @__PURE__ */ React11.createElement(
1839
1843
  Autocomplete,
1840
1844
  __spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, hayOnComponentClickGlobal ? { disableCloseOnSelect: true } : {}), hayOnComponentClickGlobal ? { blurOnSelect: false } : {}), hayOnComponentClickGlobal ? { open } : {}), hayOnComponentClickGlobal ? { onOpen: () => setOpen(true) } : {}), hayOnComponentClickGlobal ? {
1841
1845
  onClose: (event2, reason) => {
1842
- if (reason === "blur") return;
1846
+ if (componentClickActiveRef.current) return;
1847
+ if (reason === "selectOption") return;
1843
1848
  setOpen(false);
1844
1849
  }
1845
1850
  } : {}), {
@@ -1925,9 +1930,22 @@ function SCAutocomplete({
1925
1930
  item.component != null ? /* @__PURE__ */ React11.createElement(StopEvent, null, /* @__PURE__ */ React11.createElement(
1926
1931
  "span",
1927
1932
  {
1928
- onClick: (e) => {
1933
+ onMouseDown: (event2) => {
1934
+ componentClickActiveRef.current = true;
1935
+ event2.preventDefault();
1936
+ event2.stopPropagation();
1937
+ event2.defaultMuiPrevented = true;
1938
+ },
1939
+ onClick: (event2) => {
1929
1940
  var _a2;
1930
- (_a2 = item.onComponentClick) == null ? void 0 : _a2.call(item, e, option);
1941
+ event2.preventDefault();
1942
+ event2.stopPropagation();
1943
+ event2.defaultMuiPrevented = true;
1944
+ (_a2 = item.onComponentClick) == null ? void 0 : _a2.call(item, event2, option);
1945
+ setOpen(true);
1946
+ setTimeout(() => {
1947
+ componentClickActiveRef.current = false;
1948
+ }, 200);
1931
1949
  }
1932
1950
  },
1933
1951
  item.component
@@ -4914,7 +4932,7 @@ var SCCard = ({ width, title, image, iconTitle, actionsTitle, subtitle, content,
4914
4932
 
4915
4933
  // src/Components/SCActivityCalendar.tsx
4916
4934
  import React42, { useState as useState23 } from "react";
4917
- import { Typography as Typography25, IconButton as IconButton15, Box as Box27, Badge as Badge2 } from "@mui/material";
4935
+ import { Typography as Typography25, IconButton as IconButton15, Box as Box27, Badge as Badge2, Menu as Menu3, MenuItem as MenuItem8, ListItemIcon as ListItemIcon6, Popover as Popover7 } from "@mui/material";
4918
4936
  import Grid11 from "@mui/material/Grid";
4919
4937
  import { AdapterDateFns as AdapterDateFns2 } from "@mui/x-date-pickers/AdapterDateFns";
4920
4938
  import { LocalizationProvider as LocalizationProvider4 } from "@mui/x-date-pickers/LocalizationProvider";
@@ -4925,6 +4943,11 @@ import KeyboardDoubleArrowDownIcon2 from "@mui/icons-material/KeyboardDoubleArro
4925
4943
  import KeyboardDoubleArrowUpIcon2 from "@mui/icons-material/KeyboardDoubleArrowUp";
4926
4944
  import ArrowForwardIcon from "@mui/icons-material/ArrowForward";
4927
4945
  import LightModeOutlinedIcon from "@mui/icons-material/LightModeOutlined";
4946
+ import FilterListIcon from "@mui/icons-material/FilterList";
4947
+ import CalendarMonthOutlinedIcon from "@mui/icons-material/CalendarMonthOutlined";
4948
+ import CheckCircleOutlineOutlinedIcon from "@mui/icons-material/CheckCircleOutlineOutlined";
4949
+ import EventBusyOutlinedIcon from "@mui/icons-material/EventBusyOutlined";
4950
+ import PendingOutlinedIcon from "@mui/icons-material/PendingOutlined";
4928
4951
  var SCActivityCalendar = ({
4929
4952
  //informativas
4930
4953
  //apariencia
@@ -4941,6 +4964,11 @@ var SCActivityCalendar = ({
4941
4964
  const [fechaSeleccionada, setFechaSeleccionada] = useState23();
4942
4965
  const [stateVal, setstateVal] = React42.useState(/* @__PURE__ */ new Date());
4943
4966
  const [openCalendar, setOpenCalendar] = React42.useState(false);
4967
+ const [anchorPopoverFiltro, setAnchorPopoverFiltro] = useState23(null);
4968
+ const [datosEventos, setDatosEventos] = React42.useState(events);
4969
+ console.log("eventos", events);
4970
+ console.log("datosEventos", datosEventos);
4971
+ const openPopoverFiltro = Boolean(anchorPopoverFiltro);
4944
4972
  const hoy = /* @__PURE__ */ new Date();
4945
4973
  const inicioSemana = startOfWeek2(fecha, { weekStartsOn: 0 });
4946
4974
  const diasSemana = Array.from({ length: 7 }, (_, i) => addDays2(inicioSemana, i));
@@ -4949,6 +4977,11 @@ var SCActivityCalendar = ({
4949
4977
  handleConvertFecha(fecha);
4950
4978
  }
4951
4979
  }, [fecha]);
4980
+ React42.useEffect(() => {
4981
+ if (events != null) {
4982
+ setDatosEventos(events);
4983
+ }
4984
+ }, [events]);
4952
4985
  const handleConvertFecha = (fecha2) => {
4953
4986
  if (fecha2) {
4954
4987
  let day = (fecha2.getDate() < 10 ? "0" : "") + fecha2.getDate();
@@ -4968,6 +5001,22 @@ var SCActivityCalendar = ({
4968
5001
  // 0 = domingo, 1 = lunes
4969
5002
  })
4970
5003
  });
5004
+ const handleClickPopoverFiltro = (event2) => {
5005
+ setAnchorPopoverFiltro(event2.currentTarget);
5006
+ };
5007
+ const handleClosePopoverFiltro = () => {
5008
+ setAnchorPopoverFiltro(null);
5009
+ };
5010
+ const filtrarActividad = (event2, filtro) => {
5011
+ if (filtro === "Todo") {
5012
+ setDatosEventos(events);
5013
+ } else {
5014
+ const resultado = events.filter(
5015
+ (item) => item.state === filtro
5016
+ );
5017
+ setDatosEventos(resultado);
5018
+ }
5019
+ };
4971
5020
  return /* @__PURE__ */ React42.createElement(React42.Fragment, null, /* @__PURE__ */ React42.createElement(LocalizationProvider4, { dateAdapter: AdapterDateFns2, adapterLocale: locale }, openCalendar == false ? /* @__PURE__ */ React42.createElement(Box27, { "data-testid": "calendar-mobile", sx: { width: "100%", background: background ? background : "white", display: "flex", flexDirection: "column", alignItems: "center" } }, /* @__PURE__ */ React42.createElement(Box27, { sx: { width: "100%", padding: "0px", background: "transparent" } }, /* @__PURE__ */ React42.createElement(Grid11, { container: true, gap: 0.5, sx: { justifyContent: "space-between", padding: "12px 16px", background: "transparent" } }, diasSemana.map((dia) => /* @__PURE__ */ React42.createElement(Grid11, { sx: { width: "36px" }, key: dia.toString() }, /* @__PURE__ */ React42.createElement(Box27, { sx: { width: "36px", height: "40px", display: "flex", alignItems: "center", justifyContent: "center" } }, /* @__PURE__ */ React42.createElement(Typography25, { sx: { fontSize: "12px !important", color: "#10184099" } }, format2(dia, "EEEE", { locale: es2 }).charAt(0).toUpperCase())), /* @__PURE__ */ React42.createElement(
4972
5021
  Box27,
4973
5022
  {
@@ -4991,7 +5040,7 @@ var SCActivityCalendar = ({
4991
5040
  slotProps: { toolbar: { hidden: true }, actionBar: { actions: [] } },
4992
5041
  sx: {
4993
5042
  "& .MuiDateCalendar-root": {
4994
- width: "97.5%",
5043
+ width: "91.5%",
4995
5044
  maxWidth: "unset",
4996
5045
  margin: 0,
4997
5046
  padding: "0px 16px"
@@ -5007,7 +5056,36 @@ var SCActivityCalendar = ({
5007
5056
  },
5008
5057
  onChange: (newValue) => setFecha(newValue)
5009
5058
  }
5010
- ), /* @__PURE__ */ React42.createElement(Grid11, { container: true, justifyContent: "center" }, /* @__PURE__ */ React42.createElement(IconButton15, { "data-testid": "close-calendar-button", onClick: toggleCalendar(false) }, /* @__PURE__ */ React42.createElement(KeyboardDoubleArrowUpIcon2, { color: "action" }))))), /* @__PURE__ */ React42.createElement(Box27, { sx: { boxSizing: "border-box", padding: "0px 16px", width: "100%", height: openCalendar ? "calc(91% - 260px)" : "calc(91% - 100px)", background: "white", display: "flex", flexDirection: "column", overflowY: "auto", gap: "8px", scrollSnapType: "x mandatory", paddingBottom: "10px" } }, diasSemana.map((day, dayIndex) => /* @__PURE__ */ React42.createElement(
5059
+ ), /* @__PURE__ */ React42.createElement(Grid11, { container: true, justifyContent: "center" }, /* @__PURE__ */ React42.createElement(IconButton15, { "data-testid": "close-calendar-button", onClick: toggleCalendar(false) }, /* @__PURE__ */ React42.createElement(KeyboardDoubleArrowUpIcon2, { color: "action" }))))), /* @__PURE__ */ React42.createElement(IconButton15, { onClick: handleClickPopoverFiltro, sx: { position: "fixed", right: "calc(100% - 96%)", top: openCalendar == false ? "220px" : "380px" } }, /* @__PURE__ */ React42.createElement(FilterListIcon, { color: "action" })), /* @__PURE__ */ React42.createElement(
5060
+ Popover7,
5061
+ {
5062
+ open: openPopoverFiltro,
5063
+ anchorEl: anchorPopoverFiltro,
5064
+ onClose: handleClosePopoverFiltro,
5065
+ anchorOrigin: {
5066
+ vertical: "bottom",
5067
+ horizontal: "right"
5068
+ }
5069
+ },
5070
+ /* @__PURE__ */ React42.createElement(
5071
+ Menu3,
5072
+ {
5073
+ id: "basic-menu",
5074
+ anchorEl: anchorPopoverFiltro,
5075
+ open: openPopoverFiltro,
5076
+ onClose: handleClosePopoverFiltro,
5077
+ slotProps: {
5078
+ list: {
5079
+ "aria-labelledby": "basic-button"
5080
+ }
5081
+ }
5082
+ },
5083
+ /* @__PURE__ */ React42.createElement(MenuItem8, { onClick: (event2) => filtrarActividad(event2, "Todo") }, /* @__PURE__ */ React42.createElement(ListItemIcon6, null, /* @__PURE__ */ React42.createElement(CalendarMonthOutlinedIcon, { fontSize: "small" })), /* @__PURE__ */ React42.createElement(Typography25, { variant: "inherit" }, "Ver todo")),
5084
+ /* @__PURE__ */ React42.createElement(MenuItem8, { onClick: (event2) => filtrarActividad(event2, "Finalizada") }, /* @__PURE__ */ React42.createElement(ListItemIcon6, null, /* @__PURE__ */ React42.createElement(CheckCircleOutlineOutlinedIcon, { fontSize: "small" })), /* @__PURE__ */ React42.createElement(Typography25, { variant: "inherit" }, "Ver finalizadas")),
5085
+ /* @__PURE__ */ React42.createElement(MenuItem8, { onClick: (event2) => filtrarActividad(event2, "Aplazada") }, /* @__PURE__ */ React42.createElement(ListItemIcon6, null, /* @__PURE__ */ React42.createElement(EventBusyOutlinedIcon, { fontSize: "small" })), /* @__PURE__ */ React42.createElement(Typography25, { variant: "inherit" }, "Ver aplazadas")),
5086
+ /* @__PURE__ */ React42.createElement(MenuItem8, { onClick: (event2) => filtrarActividad(event2, "En progreso") }, /* @__PURE__ */ React42.createElement(ListItemIcon6, null, /* @__PURE__ */ React42.createElement(PendingOutlinedIcon, { fontSize: "small" })), /* @__PURE__ */ React42.createElement(Typography25, { variant: "inherit" }, "Ver en progreso"))
5087
+ )
5088
+ ), /* @__PURE__ */ React42.createElement(Box27, { sx: { boxSizing: "border-box", padding: "0px 16px", width: "100%", height: openCalendar ? "calc(91% - 260px)" : "calc(91% - 100px)", background: "white", display: "flex", flexDirection: "column", overflowY: "auto", gap: "8px", scrollSnapType: "x mandatory", paddingBottom: "10px" } }, diasSemana.map((day, dayIndex) => /* @__PURE__ */ React42.createElement(
5011
5089
  Box27,
5012
5090
  {
5013
5091
  key: dayIndex
@@ -5024,9 +5102,12 @@ var SCActivityCalendar = ({
5024
5102
  flexDirection: "column"
5025
5103
  } }, (() => {
5026
5104
  const esDomingo = day.getDay() === 0;
5027
- const eventosDelDia = events.filter(
5105
+ console.log("D\xEDa:", day);
5106
+ console.log("Filtrando eventos para el d\xEDa:", datosEventos);
5107
+ const eventosDelDia = datosEventos.filter(
5028
5108
  (event2) => new Date(event2.date).toDateString() === day.toDateString()
5029
5109
  );
5110
+ console.log("Cantidad eventos para el d\xEDa:", eventosDelDia);
5030
5111
  if (eventosDelDia.length > 0) {
5031
5112
  return eventosDelDia.map((event2, idx) => /* @__PURE__ */ React42.createElement(
5032
5113
  SCListContent,
@@ -5037,7 +5118,7 @@ var SCActivityCalendar = ({
5037
5118
  subtitle: /* @__PURE__ */ React42.createElement(React42.Fragment, null, configRangeHour && new Date(event2.date.replace("00:00:00", event2.startTime)).getHours() === new Date(event2.date.replace("00:00:00", configRangeHour.split("-")[0])).getHours() && new Date(event2.date.replace("00:00:00", event2.finalTime)).getHours() === new Date(event2.date.replace("00:00:00", configRangeHour.split("-")[1])).getHours() && new Date(event2.date.replace("00:00:00", event2.startTime)).getMinutes() === new Date(event2.date.replace("00:00:00", configRangeHour.split("-")[0])).getMinutes() && new Date(event2.date.replace("00:00:00", event2.finalTime)).getMinutes() === new Date(event2.date.replace("00:00:00", configRangeHour.split("-")[1])).getMinutes() ? /* @__PURE__ */ React42.createElement(React42.Fragment, null, /* @__PURE__ */ React42.createElement(Typography25, null, "Todo el dia"), /* @__PURE__ */ React42.createElement(LightModeOutlinedIcon, { fontSize: "small" })) : /* @__PURE__ */ React42.createElement(React42.Fragment, null, /* @__PURE__ */ React42.createElement(Typography25, null, new Date(event2.date.replace("00:00:00", event2.startTime)).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit", hour12: true })), /* @__PURE__ */ React42.createElement(ArrowForwardIcon, { fontSize: "small" }), /* @__PURE__ */ React42.createElement(Typography25, null, new Date(event2.date.replace("00:00:00", event2.finalTime)).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit", hour12: true })))),
5038
5119
  iconLeftColor: event2.state === "Finalizada" ? "#C7E49D" : "action",
5039
5120
  iconLeft: event2.state === "Finalizada" ? "CheckCircle" : event2.state === "Aplazada" ? "EventBusyOutlined" : event2.state === "En progreso" ? "PendingOutlined" : "RadioButtonUnchecked",
5040
- description: /* @__PURE__ */ React42.createElement(Grid11, { display: "flex", flexDirection: "column", alignItems: "flex-start" }, event2.state === "Aplazada" || event2.state === "En progreso" || event2.state === "Auto asignada" ? /* @__PURE__ */ React42.createElement(Grid11, { display: "flex", flexDirection: "row", alignItems: "center", gap: 0.5, sx: { marginLeft: "7px" } }, /* @__PURE__ */ React42.createElement(Badge2, { variant: "dot", badgeContent: "", sx: { display: "flex", alignItems: "center", "& .MuiBadge-badge": { top: "50%", transform: "translateY(-50%)" }, color: "action" } }), /* @__PURE__ */ React42.createElement(Typography25, null, event2.state == "Auto asignada" ? "Adicional" : event2.state)) : null, /* @__PURE__ */ React42.createElement(Typography25, { variant: "body2" }, event2.equipmentDescription)),
5121
+ description: /* @__PURE__ */ React42.createElement(React42.Fragment, null, event2.state === "Aplazada" || event2.state === "En progreso" || event2.state === "Auto asignada" ? /* @__PURE__ */ React42.createElement(React42.Fragment, null, /* @__PURE__ */ React42.createElement(Badge2, { variant: "dot", badgeContent: "", sx: { display: "flex", alignItems: "center", "& .MuiBadge-badge": { top: "50%", transform: "translateY(-50%)" }, color: "action" } }), /* @__PURE__ */ React42.createElement(Typography25, null, event2.state == "Auto asignada" ? "Adicional" : event2.state)) : null),
5041
5122
  divider: eventosDelDia.length === idx + 1 ? false : true,
5042
5123
  colorDisabled: event2.state === "Finalizada" || event2.state === "Aplazada" || event2.state === "En progreso" ? true : false,
5043
5124
  fn: fn ? () => fn(event2) : void 0
@@ -5541,7 +5622,7 @@ var SCSnackBar = ({
5541
5622
 
5542
5623
  // src/Components/SCAppBar.tsx
5543
5624
  import React46, { useState as useState26, useEffect as useEffect22 } from "react";
5544
- import { Menu as Menu3, Box as Box29, Typography as Typography27, MenuItem as MenuItem8, IconButton as IconButton17, Badge as Badge3 } from "@mui/material";
5625
+ import { Menu as Menu4, Box as Box29, Typography as Typography27, MenuItem as MenuItem9, IconButton as IconButton17, Badge as Badge3 } from "@mui/material";
5545
5626
  import Grid12 from "@mui/material/Grid";
5546
5627
  import "dayjs/locale/es";
5547
5628
  import MenuIcon from "@mui/icons-material/Menu";
@@ -5597,7 +5678,7 @@ var SCAppBar = ({
5597
5678
  color: isOnline ? "success" : "error"
5598
5679
  }
5599
5680
  ), /* @__PURE__ */ React46.createElement(Typography27, { variant: "caption", color: "text.secondary" }, isOnline ? "Online" : "Offline")), visibleMenu && /* @__PURE__ */ React46.createElement(React46.Fragment, null, /* @__PURE__ */ React46.createElement(IconButton17, { size: "medium", onClick: handleMenuClick }, /* @__PURE__ */ React46.createElement(MenuIcon, { color: "action" })), /* @__PURE__ */ React46.createElement(
5600
- Menu3,
5681
+ Menu4,
5601
5682
  {
5602
5683
  anchorEl,
5603
5684
  open: openMenu,
@@ -5612,7 +5693,7 @@ var SCAppBar = ({
5612
5693
  },
5613
5694
  sx: { zIndex: "2000" }
5614
5695
  },
5615
- options.map((option, index) => /* @__PURE__ */ React46.createElement(MenuItem8, { onClick: option.fn, disabled: option.disabled, key: index }, /* @__PURE__ */ React46.createElement(Typography27, { variant: "body2" }, option.name)))
5696
+ options.map((option, index) => /* @__PURE__ */ React46.createElement(MenuItem9, { onClick: option.fn, disabled: option.disabled, key: index }, /* @__PURE__ */ React46.createElement(Typography27, { variant: "body2" }, option.name)))
5616
5697
  )))), /* @__PURE__ */ React46.createElement(Box29, { sx: { padding: "8px 16px 0px 16px" } }, contenidoExtra)));
5617
5698
  };
5618
5699