componentes-sinco 1.1.21 → 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 (["blur", "selectOption"].includes(reason)) return;
1846
+ if (componentClickActiveRef.current) return;
1847
+ if (reason === "selectOption") return;
1843
1848
  setOpen(false);
1844
1849
  }
1845
1850
  } : {}), {
@@ -1925,11 +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
- e.preventDefault();
1931
- e.stopPropagation();
1932
- (_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);
1933
1949
  }
1934
1950
  },
1935
1951
  item.component
@@ -4916,7 +4932,7 @@ var SCCard = ({ width, title, image, iconTitle, actionsTitle, subtitle, content,
4916
4932
 
4917
4933
  // src/Components/SCActivityCalendar.tsx
4918
4934
  import React42, { useState as useState23 } from "react";
4919
- 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";
4920
4936
  import Grid11 from "@mui/material/Grid";
4921
4937
  import { AdapterDateFns as AdapterDateFns2 } from "@mui/x-date-pickers/AdapterDateFns";
4922
4938
  import { LocalizationProvider as LocalizationProvider4 } from "@mui/x-date-pickers/LocalizationProvider";
@@ -4927,6 +4943,11 @@ import KeyboardDoubleArrowDownIcon2 from "@mui/icons-material/KeyboardDoubleArro
4927
4943
  import KeyboardDoubleArrowUpIcon2 from "@mui/icons-material/KeyboardDoubleArrowUp";
4928
4944
  import ArrowForwardIcon from "@mui/icons-material/ArrowForward";
4929
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";
4930
4951
  var SCActivityCalendar = ({
4931
4952
  //informativas
4932
4953
  //apariencia
@@ -4943,6 +4964,11 @@ var SCActivityCalendar = ({
4943
4964
  const [fechaSeleccionada, setFechaSeleccionada] = useState23();
4944
4965
  const [stateVal, setstateVal] = React42.useState(/* @__PURE__ */ new Date());
4945
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);
4946
4972
  const hoy = /* @__PURE__ */ new Date();
4947
4973
  const inicioSemana = startOfWeek2(fecha, { weekStartsOn: 0 });
4948
4974
  const diasSemana = Array.from({ length: 7 }, (_, i) => addDays2(inicioSemana, i));
@@ -4951,6 +4977,11 @@ var SCActivityCalendar = ({
4951
4977
  handleConvertFecha(fecha);
4952
4978
  }
4953
4979
  }, [fecha]);
4980
+ React42.useEffect(() => {
4981
+ if (events != null) {
4982
+ setDatosEventos(events);
4983
+ }
4984
+ }, [events]);
4954
4985
  const handleConvertFecha = (fecha2) => {
4955
4986
  if (fecha2) {
4956
4987
  let day = (fecha2.getDate() < 10 ? "0" : "") + fecha2.getDate();
@@ -4970,6 +5001,22 @@ var SCActivityCalendar = ({
4970
5001
  // 0 = domingo, 1 = lunes
4971
5002
  })
4972
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
+ };
4973
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(
4974
5021
  Box27,
4975
5022
  {
@@ -4993,7 +5040,7 @@ var SCActivityCalendar = ({
4993
5040
  slotProps: { toolbar: { hidden: true }, actionBar: { actions: [] } },
4994
5041
  sx: {
4995
5042
  "& .MuiDateCalendar-root": {
4996
- width: "97.5%",
5043
+ width: "91.5%",
4997
5044
  maxWidth: "unset",
4998
5045
  margin: 0,
4999
5046
  padding: "0px 16px"
@@ -5009,7 +5056,36 @@ var SCActivityCalendar = ({
5009
5056
  },
5010
5057
  onChange: (newValue) => setFecha(newValue)
5011
5058
  }
5012
- ), /* @__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(
5013
5089
  Box27,
5014
5090
  {
5015
5091
  key: dayIndex
@@ -5026,9 +5102,12 @@ var SCActivityCalendar = ({
5026
5102
  flexDirection: "column"
5027
5103
  } }, (() => {
5028
5104
  const esDomingo = day.getDay() === 0;
5029
- 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(
5030
5108
  (event2) => new Date(event2.date).toDateString() === day.toDateString()
5031
5109
  );
5110
+ console.log("Cantidad eventos para el d\xEDa:", eventosDelDia);
5032
5111
  if (eventosDelDia.length > 0) {
5033
5112
  return eventosDelDia.map((event2, idx) => /* @__PURE__ */ React42.createElement(
5034
5113
  SCListContent,
@@ -5039,7 +5118,7 @@ var SCActivityCalendar = ({
5039
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 })))),
5040
5119
  iconLeftColor: event2.state === "Finalizada" ? "#C7E49D" : "action",
5041
5120
  iconLeft: event2.state === "Finalizada" ? "CheckCircle" : event2.state === "Aplazada" ? "EventBusyOutlined" : event2.state === "En progreso" ? "PendingOutlined" : "RadioButtonUnchecked",
5042
- 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),
5043
5122
  divider: eventosDelDia.length === idx + 1 ? false : true,
5044
5123
  colorDisabled: event2.state === "Finalizada" || event2.state === "Aplazada" || event2.state === "En progreso" ? true : false,
5045
5124
  fn: fn ? () => fn(event2) : void 0
@@ -5543,7 +5622,7 @@ var SCSnackBar = ({
5543
5622
 
5544
5623
  // src/Components/SCAppBar.tsx
5545
5624
  import React46, { useState as useState26, useEffect as useEffect22 } from "react";
5546
- 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";
5547
5626
  import Grid12 from "@mui/material/Grid";
5548
5627
  import "dayjs/locale/es";
5549
5628
  import MenuIcon from "@mui/icons-material/Menu";
@@ -5599,7 +5678,7 @@ var SCAppBar = ({
5599
5678
  color: isOnline ? "success" : "error"
5600
5679
  }
5601
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(
5602
- Menu3,
5681
+ Menu4,
5603
5682
  {
5604
5683
  anchorEl,
5605
5684
  open: openMenu,
@@ -5614,7 +5693,7 @@ var SCAppBar = ({
5614
5693
  },
5615
5694
  sx: { zIndex: "2000" }
5616
5695
  },
5617
- 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)))
5618
5697
  )))), /* @__PURE__ */ React46.createElement(Box29, { sx: { padding: "8px 16px 0px 16px" } }, contenidoExtra)));
5619
5698
  };
5620
5699