componentes-sinco 1.1.41 → 1.1.42

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.d.cts CHANGED
@@ -516,8 +516,12 @@ interface SCAutocompleteProps<T> {
516
516
  inputChange?: (value: string) => void;
517
517
  maxCheck?: number;
518
518
  width?: string;
519
+ chipOutside?: {
520
+ type: "default" | "avatar";
521
+ textSeccion?: string;
522
+ };
519
523
  }
520
- declare function SCAutocomplete<T>({ label, data, columnGroup, getItemValue, typeFormat, checkMassive, deleteType, fnAplicar, required, disabled, background, setState, state, inputChange, maxCheck, width, }: SCAutocompleteProps<T>): React__default.JSX.Element;
524
+ declare function SCAutocomplete<T>({ label, data, columnGroup, getItemValue, typeFormat, checkMassive, deleteType, fnAplicar, required, disabled, background, setState, state, inputChange, maxCheck, width, chipOutside, }: SCAutocompleteProps<T>): React__default.JSX.Element;
521
525
 
522
526
  interface SCCalendarSwipeableProps {
523
527
  background?: string;
package/dist/index.d.ts CHANGED
@@ -516,8 +516,12 @@ interface SCAutocompleteProps<T> {
516
516
  inputChange?: (value: string) => void;
517
517
  maxCheck?: number;
518
518
  width?: string;
519
+ chipOutside?: {
520
+ type: "default" | "avatar";
521
+ textSeccion?: string;
522
+ };
519
523
  }
520
- declare function SCAutocomplete<T>({ label, data, columnGroup, getItemValue, typeFormat, checkMassive, deleteType, fnAplicar, required, disabled, background, setState, state, inputChange, maxCheck, width, }: SCAutocompleteProps<T>): React__default.JSX.Element;
524
+ declare function SCAutocomplete<T>({ label, data, columnGroup, getItemValue, typeFormat, checkMassive, deleteType, fnAplicar, required, disabled, background, setState, state, inputChange, maxCheck, width, chipOutside, }: SCAutocompleteProps<T>): React__default.JSX.Element;
521
525
 
522
526
  interface SCCalendarSwipeableProps {
523
527
  background?: string;
package/dist/index.js CHANGED
@@ -1278,7 +1278,7 @@ var CalendarToolbar = ({
1278
1278
 
1279
1279
  // src/Components/Calendario/Views/MonthView.tsx
1280
1280
  import React28 from "react";
1281
- import { Box as Box16, Typography as Typography14, IconButton as IconButton11, Paper, Tooltip as Tooltip6, Stack as Stack11, CircularProgress as CircularProgress2, Button as Button11 } from "@mui/material";
1281
+ import { Box as Box16, Typography as Typography14, IconButton as IconButton11, Paper as Paper2, Tooltip as Tooltip6, Stack as Stack11, CircularProgress as CircularProgress2, Button as Button11 } from "@mui/material";
1282
1282
  import AddIcon from "@mui/icons-material/Add";
1283
1283
  import dayjs5 from "dayjs";
1284
1284
  import localeData from "dayjs/plugin/localeData";
@@ -2393,7 +2393,7 @@ function SCSelect({
2393
2393
 
2394
2394
  // src/Components/SCAutocomplete.tsx
2395
2395
  import React15, { useEffect as useEffect10, useMemo as useMemo3 } from "react";
2396
- import { Autocomplete, Checkbox, InputAdornment as InputAdornment3, MenuItem as MenuItem3, TextField as TextField3, Typography as Typography10, SvgIcon as SvgIcon6, ListItemIcon as ListItemIcon2, ListItemText as ListItemText2, Divider as Divider4, FormControlLabel as FormControlLabel2, IconButton as IconButton9, Chip as Chip4, Box as Box11, Button as Button7, Grid as Grid3 } from "@mui/material";
2396
+ import { Autocomplete, Checkbox, InputAdornment as InputAdornment3, MenuItem as MenuItem3, TextField as TextField3, Avatar, Typography as Typography10, SvgIcon as SvgIcon6, ListItemIcon as ListItemIcon2, ListItemText as ListItemText2, Divider as Divider4, FormControlLabel as FormControlLabel2, IconButton as IconButton9, Chip as Chip4, Box as Box11, Button as Button7, Grid as Grid3, Popper, Paper } from "@mui/material";
2397
2397
  import { Search, Clear } from "@mui/icons-material";
2398
2398
  import * as Muicon6 from "@mui/icons-material";
2399
2399
  var StopEvent = ({ children }) => {
@@ -2430,7 +2430,8 @@ function SCAutocomplete({
2430
2430
  state,
2431
2431
  inputChange,
2432
2432
  maxCheck,
2433
- width = "100%"
2433
+ width = "100%",
2434
+ chipOutside
2434
2435
  }) {
2435
2436
  const labelContent = `<span style="color: red;">* </span>` + label;
2436
2437
  let group = "";
@@ -2466,6 +2467,16 @@ function SCAutocomplete({
2466
2467
  setIsUserTyping(false);
2467
2468
  }
2468
2469
  }, [inputValue]);
2470
+ const handleDeleteChip = (optionToDelete) => {
2471
+ const newSelected = selectedOptions.filter(
2472
+ (opt) => getItemValue(opt).value !== getItemValue(optionToDelete).value
2473
+ );
2474
+ setSelectedOptions(newSelected);
2475
+ setState({
2476
+ hiddenValue: newSelected.length > 0 ? newSelected.map((item) => getItemValue(item).value) : "-1",
2477
+ textValue: newSelected.length > 0 ? newSelected.map((item) => getItemValue(item).text) : ""
2478
+ });
2479
+ };
2469
2480
  const normalizedData = useMemo3(() => {
2470
2481
  return data.map((option) => {
2471
2482
  if ((option == null ? void 0 : option.icon) && option.icon.type === void 0) {
@@ -2524,6 +2535,10 @@ function SCAutocomplete({
2524
2535
  const componentClickActiveRef = React15.useRef(false);
2525
2536
  const containerRef = React15.useRef(null);
2526
2537
  const [chipLimit, setChipLimit] = React15.useState(2);
2538
+ const outsideChipsMeasureRef = React15.useRef(null);
2539
+ const [visibleChipCount, setVisibleChipCount] = React15.useState(Number.MAX_SAFE_INTEGER);
2540
+ const [popoverAnchor, setPopoverAnchor] = React15.useState(null);
2541
+ const popoverTimerRef = React15.useRef(null);
2527
2542
  useEffect10(() => {
2528
2543
  const el = containerRef.current;
2529
2544
  if (!el) return;
@@ -2535,6 +2550,50 @@ function SCAutocomplete({
2535
2550
  observer.observe(el);
2536
2551
  return () => observer.disconnect();
2537
2552
  }, []);
2553
+ useEffect10(() => {
2554
+ if (!chipOutside || typeFormat !== "multiselect") return;
2555
+ const box = outsideChipsMeasureRef.current;
2556
+ if (!box) return;
2557
+ const measure = () => {
2558
+ const chips = Array.from(box.querySelectorAll("[data-outside-chip]"));
2559
+ let count = selectedOptions.length;
2560
+ for (let i = 0; i < chips.length; i++) {
2561
+ if (chips[i].offsetTop + chips[i].offsetHeight > 36) {
2562
+ count = i;
2563
+ break;
2564
+ }
2565
+ }
2566
+ setVisibleChipCount(count);
2567
+ };
2568
+ measure();
2569
+ const observer = new ResizeObserver(measure);
2570
+ observer.observe(box);
2571
+ return () => observer.disconnect();
2572
+ }, [selectedOptions, chipOutside, typeFormat]);
2573
+ useEffect10(() => {
2574
+ const displayCount = Math.min(visibleChipCount, selectedOptions.length);
2575
+ if (selectedOptions.length - displayCount === 0) {
2576
+ setPopoverAnchor(null);
2577
+ }
2578
+ }, [selectedOptions, visibleChipCount]);
2579
+ const handlePlusEnter = (event2) => {
2580
+ if (popoverTimerRef.current) clearTimeout(popoverTimerRef.current);
2581
+ setPopoverAnchor(event2.currentTarget);
2582
+ };
2583
+ const handlePlusLeave = () => {
2584
+ popoverTimerRef.current = setTimeout(() => setPopoverAnchor(null), 150);
2585
+ };
2586
+ const handlePopperEnter = () => {
2587
+ if (popoverTimerRef.current) clearTimeout(popoverTimerRef.current);
2588
+ };
2589
+ const handlePopperLeave = () => {
2590
+ popoverTimerRef.current = setTimeout(() => setPopoverAnchor(null), 150);
2591
+ };
2592
+ const resolveAvatarText = (option) => {
2593
+ const optionText = getItemValue(option).text;
2594
+ if (!(chipOutside == null ? void 0 : chipOutside.textSeccion)) return optionText.charAt(0).toUpperCase();
2595
+ return chipOutside.textSeccion.split(",").map((p) => optionText.charAt(Number(p.trim())).toUpperCase()).join("");
2596
+ };
2538
2597
  const hayOnComponentClickGlobal = useMemo3(() => {
2539
2598
  return data.some((opt) => {
2540
2599
  const item = getItemValue(opt);
@@ -2572,7 +2631,7 @@ function SCAutocomplete({
2572
2631
  maxWidth: "100%"
2573
2632
  },
2574
2633
  limitTags: chipLimit,
2575
- renderTags: (value, getTagProps) => {
2634
+ renderTags: chipOutside ? () => null : (value, getTagProps) => {
2576
2635
  const limit = chipLimit;
2577
2636
  return /* @__PURE__ */ React15.createElement(React15.Fragment, null, value.slice(0, limit).map((option, index) => {
2578
2637
  const _a = getTagProps({ index }), { key } = _a, chipProps = __objRest(_a, ["key"]);
@@ -2657,12 +2716,14 @@ function SCAutocomplete({
2657
2716
  renderInput: (params) => /* @__PURE__ */ React15.createElement(React15.Fragment, null, /* @__PURE__ */ React15.createElement(
2658
2717
  TextField3,
2659
2718
  __spreadProps(__spreadValues({
2660
- sx: { "& .MuiOutlinedInput-input": {
2661
- padding: "2.5px 2px 2.5px 2px !important",
2662
- // ajusta aquí
2663
- width: "10px !important",
2664
- minWidth: "10px !important"
2665
- } }
2719
+ sx: {
2720
+ "& .MuiOutlinedInput-input": {
2721
+ padding: "2.5px 2px 2.5px 2px !important",
2722
+ // ajusta aquí
2723
+ width: "10px !important",
2724
+ minWidth: "10px !important"
2725
+ }
2726
+ }
2666
2727
  }, params), {
2667
2728
  label: required ? /* @__PURE__ */ React15.createElement("span", { dangerouslySetInnerHTML: { __html: labelContent } }) : label,
2668
2729
  placeholder: selectedOptions.length == 0 ? "B\xFAsqueda" : "",
@@ -2738,7 +2799,90 @@ function SCAutocomplete({
2738
2799
  }
2739
2800
  }
2740
2801
  })
2741
- )));
2802
+ ), chipOutside && typeFormat === "multiselect" && selectedOptions.length > 0 && (() => {
2803
+ const displayCount = Math.min(visibleChipCount, selectedOptions.length);
2804
+ const hiddenCount = selectedOptions.length - displayCount;
2805
+ return /* @__PURE__ */ React15.createElement(Box11, { sx: { position: "relative", mt: 0.5 } }, /* @__PURE__ */ React15.createElement(
2806
+ Box11,
2807
+ {
2808
+ ref: outsideChipsMeasureRef,
2809
+ "aria-hidden": "true",
2810
+ sx: {
2811
+ display: "flex",
2812
+ flexWrap: "wrap",
2813
+ gap: 0.5,
2814
+ position: "absolute",
2815
+ top: 0,
2816
+ left: 0,
2817
+ right: 0,
2818
+ visibility: "hidden",
2819
+ pointerEvents: "none"
2820
+ }
2821
+ },
2822
+ selectedOptions.map((option) => {
2823
+ const avatarText = resolveAvatarText(option);
2824
+ return /* @__PURE__ */ React15.createElement("div", { key: getItemValue(option).value, "data-outside-chip": true, style: { display: "inline-flex" } }, /* @__PURE__ */ React15.createElement(
2825
+ Chip4,
2826
+ __spreadValues({
2827
+ size: "small",
2828
+ label: getItemValue(option).text
2829
+ }, chipOutside.type === "avatar" ? { avatar: /* @__PURE__ */ React15.createElement(Avatar, null, avatarText) } : {})
2830
+ ));
2831
+ })
2832
+ ), /* @__PURE__ */ React15.createElement(Box11, { sx: { display: "flex", flexWrap: "wrap", gap: 0.5, maxHeight: 36, overflow: "hidden" } }, selectedOptions.slice(0, displayCount).map((option) => {
2833
+ const avatarText = resolveAvatarText(option);
2834
+ return /* @__PURE__ */ React15.createElement(
2835
+ Chip4,
2836
+ __spreadValues({
2837
+ key: getItemValue(option).value,
2838
+ color: "default",
2839
+ size: "small",
2840
+ variant: "filled",
2841
+ label: getItemValue(option).text,
2842
+ onDelete: () => handleDeleteChip(option)
2843
+ }, chipOutside.type === "avatar" ? { avatar: /* @__PURE__ */ React15.createElement(Avatar, null, avatarText) } : {})
2844
+ );
2845
+ }), hiddenCount > 0 && /* @__PURE__ */ React15.createElement(
2846
+ Box11,
2847
+ {
2848
+ onMouseEnter: handlePlusEnter,
2849
+ onMouseLeave: handlePlusLeave,
2850
+ sx: { ml: 0.5, fontSize: 13, color: "#666", display: "flex", alignItems: "center", cursor: "default" }
2851
+ },
2852
+ `+${hiddenCount}`
2853
+ )), /* @__PURE__ */ React15.createElement(
2854
+ Popper,
2855
+ {
2856
+ open: Boolean(popoverAnchor),
2857
+ anchorEl: popoverAnchor,
2858
+ placement: "bottom-start",
2859
+ sx: { zIndex: 1500 }
2860
+ },
2861
+ /* @__PURE__ */ React15.createElement(
2862
+ Paper,
2863
+ {
2864
+ elevation: 3,
2865
+ onMouseEnter: handlePopperEnter,
2866
+ onMouseLeave: handlePopperLeave,
2867
+ sx: { p: 1, display: "flex", flexWrap: "wrap", gap: 0.5, maxWidth: 300 }
2868
+ },
2869
+ selectedOptions.slice(displayCount).map((option) => {
2870
+ const avatarText = resolveAvatarText(option);
2871
+ return /* @__PURE__ */ React15.createElement(
2872
+ Chip4,
2873
+ __spreadValues({
2874
+ key: getItemValue(option).value,
2875
+ color: "default",
2876
+ size: "small",
2877
+ variant: "filled",
2878
+ label: getItemValue(option).text,
2879
+ onDelete: () => handleDeleteChip(option)
2880
+ }, chipOutside.type === "avatar" ? { avatar: /* @__PURE__ */ React15.createElement(Avatar, { sx: { fontSize: avatarText.length > 1 ? "0.55rem" : "0.75rem" } }, avatarText) } : {})
2881
+ );
2882
+ })
2883
+ )
2884
+ ));
2885
+ })()));
2742
2886
  }
2743
2887
 
2744
2888
  // src/Components/SCDateRange.tsx
@@ -3512,7 +3656,7 @@ var MonthView = ({ events, isLoading, onDayClick, onMoreClick, currentDate, onEv
3512
3656
  const dayEvents = filterEventsForDay(events, day);
3513
3657
  const isCurrentMonth = day.month() === currentDate.month();
3514
3658
  return /* @__PURE__ */ React28.createElement(
3515
- Paper,
3659
+ Paper2,
3516
3660
  {
3517
3661
  key: day.toString(),
3518
3662
  onClick: () => onDayClick == null ? void 0 : onDayClick(day),
@@ -4298,7 +4442,7 @@ import { format, startOfWeek, addDays, isSameDay } from "date-fns";
4298
4442
  import React36 from "react";
4299
4443
  import { Divider as Divider6, List, ListItemButton, ListItemIcon as ListItemIcon4, ListItemText as ListItemText3, SvgIcon as SvgIcon7 } from "@mui/material";
4300
4444
  import Grid7 from "@mui/material/Grid";
4301
- import Avatar from "@mui/material/Avatar";
4445
+ import Avatar2 from "@mui/material/Avatar";
4302
4446
  import * as Muicon7 from "@mui/icons-material";
4303
4447
  var SCListContent = ({ options, iconLeftType = "Icon", iconRightType = "Icon" }) => {
4304
4448
  const [selectedIndex, setSelectedIndex] = React36.useState("1");
@@ -4330,7 +4474,7 @@ var SCListContent = ({ options, iconLeftType = "Icon", iconRightType = "Icon" })
4330
4474
  onClick: option.fn,
4331
4475
  sx: { gap: 1, padding: iconLeftType == "Icon" ? "8px 8px" : "8px 8px 8px 0px" }
4332
4476
  },
4333
- option.iconLeft ? iconLeftType == "Icon" ? /* @__PURE__ */ React36.createElement(ListItemIcon4, { sx: { minWidth: "0px !important" } }, /* @__PURE__ */ React36.createElement(SvgIcon7, { fontSize: "small", sx: { color: option.iconLeftColor || "action" }, component: option.iconLeft })) : /* @__PURE__ */ React36.createElement(Avatar, { sx: { width: 25, height: 25, fontSize: "11px", bgcolor: option.iconLeftColor ? `${option.iconLeftColor}.main` : "default" } }, ((_a = option.iconLeft) == null ? void 0 : _a.type) != void 0 ? /* @__PURE__ */ React36.createElement(SvgIcon7, { fontSize: "small", component: option.iconLeft }) : option.iconLeft) : "",
4477
+ option.iconLeft ? iconLeftType == "Icon" ? /* @__PURE__ */ React36.createElement(ListItemIcon4, { sx: { minWidth: "0px !important" } }, /* @__PURE__ */ React36.createElement(SvgIcon7, { fontSize: "small", sx: { color: option.iconLeftColor || "action" }, component: option.iconLeft })) : /* @__PURE__ */ React36.createElement(Avatar2, { sx: { width: 25, height: 25, fontSize: "11px", bgcolor: option.iconLeftColor ? `${option.iconLeftColor}.main` : "default" } }, ((_a = option.iconLeft) == null ? void 0 : _a.type) != void 0 ? /* @__PURE__ */ React36.createElement(SvgIcon7, { fontSize: "small", component: option.iconLeft }) : option.iconLeft) : "",
4334
4478
  /* @__PURE__ */ React36.createElement(
4335
4479
  ListItemText3,
4336
4480
  {
@@ -4339,7 +4483,7 @@ var SCListContent = ({ options, iconLeftType = "Icon", iconRightType = "Icon" })
4339
4483
  secondary: /* @__PURE__ */ React36.createElement(Grid7, { gap: 0.5 }, /* @__PURE__ */ React36.createElement(Grid7, { container: true, gap: 0.5, sx: { color: option.colorDisabled == true ? "text.disabled" : "default" } }, option.subtitle), /* @__PURE__ */ React36.createElement(Grid7, { container: true, gap: 0.5, sx: { color: option.colorDisabled == true ? "text.disabled" : "default" } }, option.description))
4340
4484
  }
4341
4485
  ),
4342
- option.iconRight ? iconRightType == "Icon" ? /* @__PURE__ */ React36.createElement(ListItemIcon4, { sx: { minWidth: "0px !important", marginRight: "8px" } }, /* @__PURE__ */ React36.createElement(SvgIcon7, { fontSize: "small", sx: { color: option.iconRightColor || "action" }, component: option.iconRight })) : /* @__PURE__ */ React36.createElement(Avatar, { variant: "circular", sx: { width: 20, height: 20 } }, ((_b = option.iconRight) == null ? void 0 : _b.type) != void 0 ? /* @__PURE__ */ React36.createElement(SvgIcon7, { fontSize: "small", color: option.iconRightColor || "action", component: option.iconRight }) : option.iconRight) : ""
4486
+ option.iconRight ? iconRightType == "Icon" ? /* @__PURE__ */ React36.createElement(ListItemIcon4, { sx: { minWidth: "0px !important", marginRight: "8px" } }, /* @__PURE__ */ React36.createElement(SvgIcon7, { fontSize: "small", sx: { color: option.iconRightColor || "action" }, component: option.iconRight })) : /* @__PURE__ */ React36.createElement(Avatar2, { variant: "circular", sx: { width: 20, height: 20 } }, ((_b = option.iconRight) == null ? void 0 : _b.type) != void 0 ? /* @__PURE__ */ React36.createElement(SvgIcon7, { fontSize: "small", color: option.iconRightColor || "action", component: option.iconRight }) : option.iconRight) : ""
4343
4487
  ), option.divider == true ? /* @__PURE__ */ React36.createElement(Divider6, null) : "");
4344
4488
  })));
4345
4489
  };
@@ -5496,7 +5640,7 @@ var SCDialog = ({ title, iconTitle, subtitle, content, actions, buttonDialog, di
5496
5640
 
5497
5641
  // src/Components/SCMenu.tsx
5498
5642
  import React45 from "react";
5499
- import { Box as Box27, Typography as Typography26, Paper as Paper4, Divider as Divider8, MenuList as MenuList3, MenuItem as MenuItem9, ListItemIcon as ListItemIcon7, SvgIcon as SvgIcon11 } from "@mui/material";
5643
+ import { Box as Box27, Typography as Typography26, Paper as Paper5, Divider as Divider8, MenuList as MenuList3, MenuItem as MenuItem9, ListItemIcon as ListItemIcon7, SvgIcon as SvgIcon11 } from "@mui/material";
5500
5644
  import Grid12 from "@mui/material/Grid";
5501
5645
 
5502
5646
  // src/Components/Hooks/useWindowDimensions.ts
@@ -5563,7 +5707,7 @@ var SCMenu = ({ header, options, defaultOption, disable, widthMenu, heightMenu,
5563
5707
  setValue(String(index + 1));
5564
5708
  }
5565
5709
  };
5566
- return /* @__PURE__ */ React45.createElement(React45.Fragment, null, /* @__PURE__ */ React45.createElement(Grid12, { container: true, sx: { height: heightContainer, width: widthContainer, flexDirection: "column" } }, /* @__PURE__ */ React45.createElement(Paper4, { "data-testid": "menu-content", sx: { width: menuSize, height: heightContainer, overflow: "auto" } }, header && header.component, /* @__PURE__ */ React45.createElement(MenuList3, { sx: { height: options.length * 45, padding: "8px 0px" } }, options.map((option, index) => /* @__PURE__ */ React45.createElement(React45.Fragment, null, /* @__PURE__ */ React45.createElement(
5710
+ return /* @__PURE__ */ React45.createElement(React45.Fragment, null, /* @__PURE__ */ React45.createElement(Grid12, { container: true, sx: { height: heightContainer, width: widthContainer, flexDirection: "column" } }, /* @__PURE__ */ React45.createElement(Paper5, { "data-testid": "menu-content", sx: { width: menuSize, height: heightContainer, overflow: "auto" } }, header && header.component, /* @__PURE__ */ React45.createElement(MenuList3, { sx: { height: options.length * 45, padding: "8px 0px" } }, options.map((option, index) => /* @__PURE__ */ React45.createElement(React45.Fragment, null, /* @__PURE__ */ React45.createElement(
5567
5711
  MenuItem9,
5568
5712
  {
5569
5713
  disabled: disable == true ? true : false,