componentes-sinco 1.1.41 → 1.1.43

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.cjs CHANGED
@@ -484,7 +484,8 @@ var Attachment = ({
484
484
  downloadAction,
485
485
  deleteAction,
486
486
  initialFiles = [],
487
- iconFileItem
487
+ iconFileItem,
488
+ view = "button"
488
489
  }) => {
489
490
  const [files, setFiles] = (0, import_react5.useState)([]);
490
491
  const [fileToDelete, setFileToDelete] = (0, import_react5.useState)(null);
@@ -608,7 +609,7 @@ var Attachment = ({
608
609
  return filteredFiles;
609
610
  });
610
611
  };
611
- return /* @__PURE__ */ import_react5.default.createElement(import_material3.Stack, { spacing: 2 }, toast && /* @__PURE__ */ import_react5.default.createElement(SCToastNotification, __spreadValues({}, toast)), /* @__PURE__ */ import_react5.default.createElement(
612
+ return /* @__PURE__ */ import_react5.default.createElement(import_material3.Stack, { spacing: 2, display: "flex", flexDirection: "column", gap: 1 }, toast && /* @__PURE__ */ import_react5.default.createElement(SCToastNotification, __spreadValues({}, toast)), /* @__PURE__ */ import_react5.default.createElement(
612
613
  "input",
613
614
  {
614
615
  type: "file",
@@ -617,7 +618,7 @@ var Attachment = ({
617
618
  ref: inputRef,
618
619
  onChange: handleUpload
619
620
  }
620
- ), /* @__PURE__ */ import_react5.default.createElement(
621
+ ), view === "button" && /* @__PURE__ */ import_react5.default.createElement(
621
622
  import_material3.Stack,
622
623
  {
623
624
  "data-testid": "ZonaAdjuntos",
@@ -726,6 +727,7 @@ var Attachment = ({
726
727
  id: "ContenedorArchivosAdjuntos",
727
728
  width: "100%",
728
729
  sx: __spreadValues({
730
+ marginTop: "0px !important",
729
731
  overflowY: "auto"
730
732
  }, files.length > 5 && {
731
733
  maxHeight: 250
@@ -785,7 +787,7 @@ var Attachment = ({
785
787
  },
786
788
  /* @__PURE__ */ import_react5.default.createElement(import_icons_material5.FileDownload, { fontSize: "small", color: "action" })
787
789
  )),
788
- /* @__PURE__ */ import_react5.default.createElement(import_material3.Tooltip, { title: "Eliminar" }, /* @__PURE__ */ import_react5.default.createElement(
790
+ view === "button" && /* @__PURE__ */ import_react5.default.createElement(import_material3.Tooltip, { title: "Eliminar" }, /* @__PURE__ */ import_react5.default.createElement(
789
791
  import_material3.IconButton,
790
792
  {
791
793
  size: "small",
@@ -2514,7 +2516,8 @@ function SCAutocomplete({
2514
2516
  state,
2515
2517
  inputChange,
2516
2518
  maxCheck,
2517
- width = "100%"
2519
+ width = "100%",
2520
+ chipOutside
2518
2521
  }) {
2519
2522
  const labelContent = `<span style="color: red;">* </span>` + label;
2520
2523
  let group = "";
@@ -2550,6 +2553,16 @@ function SCAutocomplete({
2550
2553
  setIsUserTyping(false);
2551
2554
  }
2552
2555
  }, [inputValue]);
2556
+ const handleDeleteChip = (optionToDelete) => {
2557
+ const newSelected = selectedOptions.filter(
2558
+ (opt) => getItemValue(opt).value !== getItemValue(optionToDelete).value
2559
+ );
2560
+ setSelectedOptions(newSelected);
2561
+ setState({
2562
+ hiddenValue: newSelected.length > 0 ? newSelected.map((item) => getItemValue(item).value) : "-1",
2563
+ textValue: newSelected.length > 0 ? newSelected.map((item) => getItemValue(item).text) : ""
2564
+ });
2565
+ };
2553
2566
  const normalizedData = (0, import_react19.useMemo)(() => {
2554
2567
  return data.map((option) => {
2555
2568
  if ((option == null ? void 0 : option.icon) && option.icon.type === void 0) {
@@ -2608,6 +2621,10 @@ function SCAutocomplete({
2608
2621
  const componentClickActiveRef = import_react19.default.useRef(false);
2609
2622
  const containerRef = import_react19.default.useRef(null);
2610
2623
  const [chipLimit, setChipLimit] = import_react19.default.useState(2);
2624
+ const outsideChipsMeasureRef = import_react19.default.useRef(null);
2625
+ const [visibleChipCount, setVisibleChipCount] = import_react19.default.useState(Number.MAX_SAFE_INTEGER);
2626
+ const [popoverAnchor, setPopoverAnchor] = import_react19.default.useState(null);
2627
+ const popoverTimerRef = import_react19.default.useRef(null);
2611
2628
  (0, import_react19.useEffect)(() => {
2612
2629
  const el = containerRef.current;
2613
2630
  if (!el) return;
@@ -2619,6 +2636,50 @@ function SCAutocomplete({
2619
2636
  observer.observe(el);
2620
2637
  return () => observer.disconnect();
2621
2638
  }, []);
2639
+ (0, import_react19.useEffect)(() => {
2640
+ if (!chipOutside || typeFormat !== "multiselect") return;
2641
+ const box = outsideChipsMeasureRef.current;
2642
+ if (!box) return;
2643
+ const measure = () => {
2644
+ const chips = Array.from(box.querySelectorAll("[data-outside-chip]"));
2645
+ let count = selectedOptions.length;
2646
+ for (let i = 0; i < chips.length; i++) {
2647
+ if (chips[i].offsetTop + chips[i].offsetHeight > 36) {
2648
+ count = i;
2649
+ break;
2650
+ }
2651
+ }
2652
+ setVisibleChipCount(count);
2653
+ };
2654
+ measure();
2655
+ const observer = new ResizeObserver(measure);
2656
+ observer.observe(box);
2657
+ return () => observer.disconnect();
2658
+ }, [selectedOptions, chipOutside, typeFormat]);
2659
+ (0, import_react19.useEffect)(() => {
2660
+ const displayCount = Math.min(visibleChipCount, selectedOptions.length);
2661
+ if (selectedOptions.length - displayCount === 0) {
2662
+ setPopoverAnchor(null);
2663
+ }
2664
+ }, [selectedOptions, visibleChipCount]);
2665
+ const handlePlusEnter = (event2) => {
2666
+ if (popoverTimerRef.current) clearTimeout(popoverTimerRef.current);
2667
+ setPopoverAnchor(event2.currentTarget);
2668
+ };
2669
+ const handlePlusLeave = () => {
2670
+ popoverTimerRef.current = setTimeout(() => setPopoverAnchor(null), 150);
2671
+ };
2672
+ const handlePopperEnter = () => {
2673
+ if (popoverTimerRef.current) clearTimeout(popoverTimerRef.current);
2674
+ };
2675
+ const handlePopperLeave = () => {
2676
+ popoverTimerRef.current = setTimeout(() => setPopoverAnchor(null), 150);
2677
+ };
2678
+ const resolveAvatarText = (option) => {
2679
+ const optionText = getItemValue(option).text;
2680
+ if (!(chipOutside == null ? void 0 : chipOutside.textSeccion)) return optionText.charAt(0).toUpperCase();
2681
+ return chipOutside.textSeccion.split(",").map((p) => optionText.charAt(Number(p.trim())).toUpperCase()).join("");
2682
+ };
2622
2683
  const hayOnComponentClickGlobal = (0, import_react19.useMemo)(() => {
2623
2684
  return data.some((opt) => {
2624
2685
  const item = getItemValue(opt);
@@ -2656,7 +2717,7 @@ function SCAutocomplete({
2656
2717
  maxWidth: "100%"
2657
2718
  },
2658
2719
  limitTags: chipLimit,
2659
- renderTags: (value, getTagProps) => {
2720
+ renderTags: chipOutside ? () => null : (value, getTagProps) => {
2660
2721
  const limit = chipLimit;
2661
2722
  return /* @__PURE__ */ import_react19.default.createElement(import_react19.default.Fragment, null, value.slice(0, limit).map((option, index) => {
2662
2723
  const _a = getTagProps({ index }), { key } = _a, chipProps = __objRest(_a, ["key"]);
@@ -2741,12 +2802,14 @@ function SCAutocomplete({
2741
2802
  renderInput: (params) => /* @__PURE__ */ import_react19.default.createElement(import_react19.default.Fragment, null, /* @__PURE__ */ import_react19.default.createElement(
2742
2803
  import_material13.TextField,
2743
2804
  __spreadProps(__spreadValues({
2744
- sx: { "& .MuiOutlinedInput-input": {
2745
- padding: "2.5px 2px 2.5px 2px !important",
2746
- // ajusta aquí
2747
- width: "10px !important",
2748
- minWidth: "10px !important"
2749
- } }
2805
+ sx: {
2806
+ "& .MuiOutlinedInput-input": {
2807
+ padding: "2.5px 2px 2.5px 2px !important",
2808
+ // ajusta aquí
2809
+ width: "10px !important",
2810
+ minWidth: "10px !important"
2811
+ }
2812
+ }
2750
2813
  }, params), {
2751
2814
  label: required ? /* @__PURE__ */ import_react19.default.createElement("span", { dangerouslySetInnerHTML: { __html: labelContent } }) : label,
2752
2815
  placeholder: selectedOptions.length == 0 ? "B\xFAsqueda" : "",
@@ -2822,7 +2885,90 @@ function SCAutocomplete({
2822
2885
  }
2823
2886
  }
2824
2887
  })
2825
- )));
2888
+ ), chipOutside && typeFormat === "multiselect" && selectedOptions.length > 0 && (() => {
2889
+ const displayCount = Math.min(visibleChipCount, selectedOptions.length);
2890
+ const hiddenCount = selectedOptions.length - displayCount;
2891
+ return /* @__PURE__ */ import_react19.default.createElement(import_material13.Box, { sx: { position: "relative", mt: 0.5 } }, /* @__PURE__ */ import_react19.default.createElement(
2892
+ import_material13.Box,
2893
+ {
2894
+ ref: outsideChipsMeasureRef,
2895
+ "aria-hidden": "true",
2896
+ sx: {
2897
+ display: "flex",
2898
+ flexWrap: "wrap",
2899
+ gap: 0.5,
2900
+ position: "absolute",
2901
+ top: 0,
2902
+ left: 0,
2903
+ right: 0,
2904
+ visibility: "hidden",
2905
+ pointerEvents: "none"
2906
+ }
2907
+ },
2908
+ selectedOptions.map((option) => {
2909
+ const avatarText = resolveAvatarText(option);
2910
+ return /* @__PURE__ */ import_react19.default.createElement("div", { key: getItemValue(option).value, "data-outside-chip": true, style: { display: "inline-flex" } }, /* @__PURE__ */ import_react19.default.createElement(
2911
+ import_material13.Chip,
2912
+ __spreadValues({
2913
+ size: "small",
2914
+ label: getItemValue(option).text
2915
+ }, chipOutside.type === "avatar" ? { avatar: /* @__PURE__ */ import_react19.default.createElement(import_material13.Avatar, { sx: { height: "15px !important", width: "15px !important" } }, avatarText) } : {})
2916
+ ));
2917
+ })
2918
+ ), /* @__PURE__ */ import_react19.default.createElement(import_material13.Box, { sx: { display: "flex", flexWrap: "wrap", gap: 0.5, maxHeight: 36, overflow: "hidden" } }, selectedOptions.slice(0, displayCount).map((option) => {
2919
+ const avatarText = resolveAvatarText(option);
2920
+ return /* @__PURE__ */ import_react19.default.createElement(
2921
+ import_material13.Chip,
2922
+ __spreadValues({
2923
+ key: getItemValue(option).value,
2924
+ color: "default",
2925
+ size: "small",
2926
+ variant: "filled",
2927
+ label: getItemValue(option).text,
2928
+ onDelete: () => handleDeleteChip(option)
2929
+ }, chipOutside.type === "avatar" ? { avatar: /* @__PURE__ */ import_react19.default.createElement(import_material13.Avatar, { sx: { height: "15px !important", width: "15px !important" } }, avatarText) } : {})
2930
+ );
2931
+ }), hiddenCount > 0 && /* @__PURE__ */ import_react19.default.createElement(
2932
+ import_material13.Box,
2933
+ {
2934
+ onMouseEnter: handlePlusEnter,
2935
+ onMouseLeave: handlePlusLeave,
2936
+ sx: { ml: 0.5, fontSize: 13, color: "#666", display: "flex", alignItems: "center", cursor: "default" }
2937
+ },
2938
+ `+${hiddenCount}`
2939
+ )), /* @__PURE__ */ import_react19.default.createElement(
2940
+ import_material13.Popper,
2941
+ {
2942
+ open: Boolean(popoverAnchor),
2943
+ anchorEl: popoverAnchor,
2944
+ placement: "bottom-start",
2945
+ sx: { zIndex: 1500 }
2946
+ },
2947
+ /* @__PURE__ */ import_react19.default.createElement(
2948
+ import_material13.Paper,
2949
+ {
2950
+ elevation: 3,
2951
+ onMouseEnter: handlePopperEnter,
2952
+ onMouseLeave: handlePopperLeave,
2953
+ sx: { p: 1, display: "flex", flexWrap: "wrap", gap: 0.5, maxWidth: 300 }
2954
+ },
2955
+ selectedOptions.slice(displayCount).map((option) => {
2956
+ const avatarText = resolveAvatarText(option);
2957
+ return /* @__PURE__ */ import_react19.default.createElement(
2958
+ import_material13.Chip,
2959
+ __spreadValues({
2960
+ key: getItemValue(option).value,
2961
+ color: "default",
2962
+ size: "small",
2963
+ variant: "filled",
2964
+ label: getItemValue(option).text,
2965
+ onDelete: () => handleDeleteChip(option)
2966
+ }, chipOutside.type === "avatar" ? { avatar: /* @__PURE__ */ import_react19.default.createElement(import_material13.Avatar, { sx: { fontSize: avatarText.length > 1 ? "0.55rem" : "0.75rem" } }, avatarText) } : {})
2967
+ );
2968
+ })
2969
+ )
2970
+ ));
2971
+ })()));
2826
2972
  }
2827
2973
 
2828
2974
  // src/Components/SCDateRange.tsx
@@ -4352,7 +4498,7 @@ var PageHeader = ({
4352
4498
  fixed,
4353
4499
  shadow = true
4354
4500
  }) => {
4355
- return /* @__PURE__ */ import_react42.default.createElement(
4501
+ return /* @__PURE__ */ import_react42.default.createElement(import_react42.default.Fragment, null, /* @__PURE__ */ import_react42.default.createElement(
4356
4502
  import_material28.Stack,
4357
4503
  {
4358
4504
  "data-testid": "main-container",
@@ -4365,7 +4511,7 @@ var PageHeader = ({
4365
4511
  sx: { boxShadow: shadow ? (theme) => theme.shadows[1] : "none" }
4366
4512
  },
4367
4513
  /* @__PURE__ */ import_react42.default.createElement(import_material28.Stack, { "data-testid": "page-header-content", height: 40, px: 3, pl: buttonBack ? 1 : 3, direction: "row", alignItems: "center", justifyContent: "space-between" }, /* @__PURE__ */ import_react42.default.createElement(import_material28.Stack, { id: "left-section", direction: "row", alignItems: "center", gap: 1 }, buttonBack, /* @__PURE__ */ import_react42.default.createElement(import_material28.Stack, { id: "text-section", gap: 0.5 }, /* @__PURE__ */ import_react42.default.createElement(import_material28.Typography, { "data-testid": "page-header-title", variant: "h6", color: "text.primary" }, title), subtitle && /* @__PURE__ */ import_react42.default.createElement(import_material28.Typography, { "data-testid": "page-header-subtitle", variant: "caption", color: "text.secondary" }, subtitle))), actions && /* @__PURE__ */ import_react42.default.createElement(import_material28.Stack, { id: "right-actions", direction: "row", alignItems: "center", gap: 1 }, actions))
4368
- );
4514
+ ), fixed && /* @__PURE__ */ import_react42.default.createElement(import_material28.Stack, { sx: { height: 48 } }));
4369
4515
  };
4370
4516
 
4371
4517
  // src/Components/SCActivityCalendar.tsx