componentes-sinco 1.1.40 → 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.cjs +155 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +164 -46
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1632,9 +1632,6 @@ var useDrawerState = ({ open, setOpen }) => {
|
|
|
1632
1632
|
// src/Components/Drawer/hooks/useChipFilters.ts
|
|
1633
1633
|
var import_react12 = require("react");
|
|
1634
1634
|
var useChipFilters = (arrayElements, chipFilters) => {
|
|
1635
|
-
debugger;
|
|
1636
|
-
console.log("arrayElements en useChipFilters", arrayElements);
|
|
1637
|
-
console.log("chipFilters en useChipFilters", chipFilters);
|
|
1638
1635
|
const [stateChipFilters, setChipFilters] = (0, import_react12.useState)(false);
|
|
1639
1636
|
const [textFilters, setTextFilters] = (0, import_react12.useState)([]);
|
|
1640
1637
|
(0, import_react12.useEffect)(() => {
|
|
@@ -1644,19 +1641,13 @@ var useChipFilters = (arrayElements, chipFilters) => {
|
|
|
1644
1641
|
}
|
|
1645
1642
|
}, [chipFilters]);
|
|
1646
1643
|
const processChipFilters = () => {
|
|
1647
|
-
debugger;
|
|
1648
|
-
console.log("Procesando chip filters. !chipFilters?.length", !(chipFilters == null ? void 0 : chipFilters.length));
|
|
1649
1644
|
if (!(chipFilters == null ? void 0 : chipFilters.length)) {
|
|
1650
1645
|
processManualFilters();
|
|
1651
1646
|
return;
|
|
1652
1647
|
}
|
|
1653
|
-
debugger;
|
|
1654
|
-
console.log("arrayElements", arrayElements);
|
|
1655
1648
|
arrayElements.forEach((arrayElement) => {
|
|
1656
1649
|
const { validation, element: typeElement } = validateTypeElements(arrayElement);
|
|
1657
1650
|
const currentValue = getCurrentValue(validation, typeElement);
|
|
1658
|
-
console.log("currentValue en useChipFilters", currentValue);
|
|
1659
|
-
console.log("chipFilters en useChipFilters", chipFilters);
|
|
1660
1651
|
chipFilters.forEach((chipFilter) => {
|
|
1661
1652
|
const chipValue = String(chipFilter).trim();
|
|
1662
1653
|
if (currentValue === chipValue && currentValue !== "" && currentValue !== ",") {
|
|
@@ -1713,27 +1704,19 @@ var useChipFilters = (arrayElements, chipFilters) => {
|
|
|
1713
1704
|
if (validation === "time") {
|
|
1714
1705
|
return ((_h = (_g = typeElement.state) == null ? void 0 : _g.isValid) == null ? void 0 : _h.call(_g)) ? typeElement.state.format("HH:mm") : "";
|
|
1715
1706
|
}
|
|
1716
|
-
console.log("typeElement.state en useChipFilters", typeElement.state);
|
|
1717
1707
|
return ((_i = typeElement.state) == null ? void 0 : _i.textValue) !== void 0 ? String(typeElement.state.textValue).trim() : String(typeElement.state).trim();
|
|
1718
1708
|
};
|
|
1719
1709
|
const updateFilter = (value, typeElement, label) => {
|
|
1720
1710
|
setTextFilters((prevFilters) => {
|
|
1721
|
-
debugger;
|
|
1722
|
-
console.log("prevFilters en useChipFilters", prevFilters);
|
|
1723
|
-
console.log("Updating filter. value:", value, "label:", label);
|
|
1724
1711
|
const newFilter = { value, arrayElement: typeElement };
|
|
1725
|
-
console.log("newFilter en useChipFilters", newFilter);
|
|
1726
1712
|
const existingFilterIndex = prevFilters.findIndex(
|
|
1727
1713
|
(filter) => label !== void 0 ? filter.arrayElement.label === label : filter.value === value
|
|
1728
1714
|
);
|
|
1729
|
-
console.log("existingFilterIndex en useChipFilters", existingFilterIndex);
|
|
1730
1715
|
if (existingFilterIndex !== -1) {
|
|
1731
1716
|
const updatedFilters = [...prevFilters];
|
|
1732
1717
|
updatedFilters[existingFilterIndex] = newFilter;
|
|
1733
|
-
console.log("updatedFilters en useChipFilters", updatedFilters);
|
|
1734
1718
|
return updatedFilters;
|
|
1735
1719
|
} else {
|
|
1736
|
-
console.log("Adding new filter. prevFilters: en useChipFilters", prevFilters, "newFilter:", newFilter);
|
|
1737
1720
|
return [...prevFilters, newFilter];
|
|
1738
1721
|
}
|
|
1739
1722
|
});
|
|
@@ -1752,11 +1735,7 @@ var useChipFilters = (arrayElements, chipFilters) => {
|
|
|
1752
1735
|
}
|
|
1753
1736
|
});
|
|
1754
1737
|
};
|
|
1755
|
-
debugger;
|
|
1756
|
-
console.log("stateChipFilters", stateChipFilters);
|
|
1757
1738
|
const shouldShowChips = (chipFilters == null ? void 0 : chipFilters.length) ? true : stateChipFilters && hasActiveFilters();
|
|
1758
|
-
console.log("shouldShowChips", shouldShowChips);
|
|
1759
|
-
console.log("textFilters", textFilters);
|
|
1760
1739
|
return {
|
|
1761
1740
|
stateChipFilters,
|
|
1762
1741
|
setChipFilters,
|
|
@@ -1885,8 +1864,6 @@ var ChipFiltersDisplay = ({
|
|
|
1885
1864
|
textFilters,
|
|
1886
1865
|
onDeleteFilter
|
|
1887
1866
|
}) => {
|
|
1888
|
-
debugger;
|
|
1889
|
-
console.log("textFilters en chipfiltersDisplay", textFilters);
|
|
1890
1867
|
const scrollRef = (0, import_react15.useRef)(null);
|
|
1891
1868
|
const scroll = (offset) => {
|
|
1892
1869
|
if (scrollRef.current) {
|
|
@@ -2537,7 +2514,8 @@ function SCAutocomplete({
|
|
|
2537
2514
|
state,
|
|
2538
2515
|
inputChange,
|
|
2539
2516
|
maxCheck,
|
|
2540
|
-
width = "100%"
|
|
2517
|
+
width = "100%",
|
|
2518
|
+
chipOutside
|
|
2541
2519
|
}) {
|
|
2542
2520
|
const labelContent = `<span style="color: red;">* </span>` + label;
|
|
2543
2521
|
let group = "";
|
|
@@ -2573,6 +2551,16 @@ function SCAutocomplete({
|
|
|
2573
2551
|
setIsUserTyping(false);
|
|
2574
2552
|
}
|
|
2575
2553
|
}, [inputValue]);
|
|
2554
|
+
const handleDeleteChip = (optionToDelete) => {
|
|
2555
|
+
const newSelected = selectedOptions.filter(
|
|
2556
|
+
(opt) => getItemValue(opt).value !== getItemValue(optionToDelete).value
|
|
2557
|
+
);
|
|
2558
|
+
setSelectedOptions(newSelected);
|
|
2559
|
+
setState({
|
|
2560
|
+
hiddenValue: newSelected.length > 0 ? newSelected.map((item) => getItemValue(item).value) : "-1",
|
|
2561
|
+
textValue: newSelected.length > 0 ? newSelected.map((item) => getItemValue(item).text) : ""
|
|
2562
|
+
});
|
|
2563
|
+
};
|
|
2576
2564
|
const normalizedData = (0, import_react19.useMemo)(() => {
|
|
2577
2565
|
return data.map((option) => {
|
|
2578
2566
|
if ((option == null ? void 0 : option.icon) && option.icon.type === void 0) {
|
|
@@ -2631,6 +2619,10 @@ function SCAutocomplete({
|
|
|
2631
2619
|
const componentClickActiveRef = import_react19.default.useRef(false);
|
|
2632
2620
|
const containerRef = import_react19.default.useRef(null);
|
|
2633
2621
|
const [chipLimit, setChipLimit] = import_react19.default.useState(2);
|
|
2622
|
+
const outsideChipsMeasureRef = import_react19.default.useRef(null);
|
|
2623
|
+
const [visibleChipCount, setVisibleChipCount] = import_react19.default.useState(Number.MAX_SAFE_INTEGER);
|
|
2624
|
+
const [popoverAnchor, setPopoverAnchor] = import_react19.default.useState(null);
|
|
2625
|
+
const popoverTimerRef = import_react19.default.useRef(null);
|
|
2634
2626
|
(0, import_react19.useEffect)(() => {
|
|
2635
2627
|
const el = containerRef.current;
|
|
2636
2628
|
if (!el) return;
|
|
@@ -2642,6 +2634,50 @@ function SCAutocomplete({
|
|
|
2642
2634
|
observer.observe(el);
|
|
2643
2635
|
return () => observer.disconnect();
|
|
2644
2636
|
}, []);
|
|
2637
|
+
(0, import_react19.useEffect)(() => {
|
|
2638
|
+
if (!chipOutside || typeFormat !== "multiselect") return;
|
|
2639
|
+
const box = outsideChipsMeasureRef.current;
|
|
2640
|
+
if (!box) return;
|
|
2641
|
+
const measure = () => {
|
|
2642
|
+
const chips = Array.from(box.querySelectorAll("[data-outside-chip]"));
|
|
2643
|
+
let count = selectedOptions.length;
|
|
2644
|
+
for (let i = 0; i < chips.length; i++) {
|
|
2645
|
+
if (chips[i].offsetTop + chips[i].offsetHeight > 36) {
|
|
2646
|
+
count = i;
|
|
2647
|
+
break;
|
|
2648
|
+
}
|
|
2649
|
+
}
|
|
2650
|
+
setVisibleChipCount(count);
|
|
2651
|
+
};
|
|
2652
|
+
measure();
|
|
2653
|
+
const observer = new ResizeObserver(measure);
|
|
2654
|
+
observer.observe(box);
|
|
2655
|
+
return () => observer.disconnect();
|
|
2656
|
+
}, [selectedOptions, chipOutside, typeFormat]);
|
|
2657
|
+
(0, import_react19.useEffect)(() => {
|
|
2658
|
+
const displayCount = Math.min(visibleChipCount, selectedOptions.length);
|
|
2659
|
+
if (selectedOptions.length - displayCount === 0) {
|
|
2660
|
+
setPopoverAnchor(null);
|
|
2661
|
+
}
|
|
2662
|
+
}, [selectedOptions, visibleChipCount]);
|
|
2663
|
+
const handlePlusEnter = (event2) => {
|
|
2664
|
+
if (popoverTimerRef.current) clearTimeout(popoverTimerRef.current);
|
|
2665
|
+
setPopoverAnchor(event2.currentTarget);
|
|
2666
|
+
};
|
|
2667
|
+
const handlePlusLeave = () => {
|
|
2668
|
+
popoverTimerRef.current = setTimeout(() => setPopoverAnchor(null), 150);
|
|
2669
|
+
};
|
|
2670
|
+
const handlePopperEnter = () => {
|
|
2671
|
+
if (popoverTimerRef.current) clearTimeout(popoverTimerRef.current);
|
|
2672
|
+
};
|
|
2673
|
+
const handlePopperLeave = () => {
|
|
2674
|
+
popoverTimerRef.current = setTimeout(() => setPopoverAnchor(null), 150);
|
|
2675
|
+
};
|
|
2676
|
+
const resolveAvatarText = (option) => {
|
|
2677
|
+
const optionText = getItemValue(option).text;
|
|
2678
|
+
if (!(chipOutside == null ? void 0 : chipOutside.textSeccion)) return optionText.charAt(0).toUpperCase();
|
|
2679
|
+
return chipOutside.textSeccion.split(",").map((p) => optionText.charAt(Number(p.trim())).toUpperCase()).join("");
|
|
2680
|
+
};
|
|
2645
2681
|
const hayOnComponentClickGlobal = (0, import_react19.useMemo)(() => {
|
|
2646
2682
|
return data.some((opt) => {
|
|
2647
2683
|
const item = getItemValue(opt);
|
|
@@ -2679,7 +2715,7 @@ function SCAutocomplete({
|
|
|
2679
2715
|
maxWidth: "100%"
|
|
2680
2716
|
},
|
|
2681
2717
|
limitTags: chipLimit,
|
|
2682
|
-
renderTags: (value, getTagProps) => {
|
|
2718
|
+
renderTags: chipOutside ? () => null : (value, getTagProps) => {
|
|
2683
2719
|
const limit = chipLimit;
|
|
2684
2720
|
return /* @__PURE__ */ import_react19.default.createElement(import_react19.default.Fragment, null, value.slice(0, limit).map((option, index) => {
|
|
2685
2721
|
const _a = getTagProps({ index }), { key } = _a, chipProps = __objRest(_a, ["key"]);
|
|
@@ -2764,12 +2800,14 @@ function SCAutocomplete({
|
|
|
2764
2800
|
renderInput: (params) => /* @__PURE__ */ import_react19.default.createElement(import_react19.default.Fragment, null, /* @__PURE__ */ import_react19.default.createElement(
|
|
2765
2801
|
import_material13.TextField,
|
|
2766
2802
|
__spreadProps(__spreadValues({
|
|
2767
|
-
sx: {
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2803
|
+
sx: {
|
|
2804
|
+
"& .MuiOutlinedInput-input": {
|
|
2805
|
+
padding: "2.5px 2px 2.5px 2px !important",
|
|
2806
|
+
// ajusta aquí
|
|
2807
|
+
width: "10px !important",
|
|
2808
|
+
minWidth: "10px !important"
|
|
2809
|
+
}
|
|
2810
|
+
}
|
|
2773
2811
|
}, params), {
|
|
2774
2812
|
label: required ? /* @__PURE__ */ import_react19.default.createElement("span", { dangerouslySetInnerHTML: { __html: labelContent } }) : label,
|
|
2775
2813
|
placeholder: selectedOptions.length == 0 ? "B\xFAsqueda" : "",
|
|
@@ -2845,7 +2883,90 @@ function SCAutocomplete({
|
|
|
2845
2883
|
}
|
|
2846
2884
|
}
|
|
2847
2885
|
})
|
|
2848
|
-
))
|
|
2886
|
+
), chipOutside && typeFormat === "multiselect" && selectedOptions.length > 0 && (() => {
|
|
2887
|
+
const displayCount = Math.min(visibleChipCount, selectedOptions.length);
|
|
2888
|
+
const hiddenCount = selectedOptions.length - displayCount;
|
|
2889
|
+
return /* @__PURE__ */ import_react19.default.createElement(import_material13.Box, { sx: { position: "relative", mt: 0.5 } }, /* @__PURE__ */ import_react19.default.createElement(
|
|
2890
|
+
import_material13.Box,
|
|
2891
|
+
{
|
|
2892
|
+
ref: outsideChipsMeasureRef,
|
|
2893
|
+
"aria-hidden": "true",
|
|
2894
|
+
sx: {
|
|
2895
|
+
display: "flex",
|
|
2896
|
+
flexWrap: "wrap",
|
|
2897
|
+
gap: 0.5,
|
|
2898
|
+
position: "absolute",
|
|
2899
|
+
top: 0,
|
|
2900
|
+
left: 0,
|
|
2901
|
+
right: 0,
|
|
2902
|
+
visibility: "hidden",
|
|
2903
|
+
pointerEvents: "none"
|
|
2904
|
+
}
|
|
2905
|
+
},
|
|
2906
|
+
selectedOptions.map((option) => {
|
|
2907
|
+
const avatarText = resolveAvatarText(option);
|
|
2908
|
+
return /* @__PURE__ */ import_react19.default.createElement("div", { key: getItemValue(option).value, "data-outside-chip": true, style: { display: "inline-flex" } }, /* @__PURE__ */ import_react19.default.createElement(
|
|
2909
|
+
import_material13.Chip,
|
|
2910
|
+
__spreadValues({
|
|
2911
|
+
size: "small",
|
|
2912
|
+
label: getItemValue(option).text
|
|
2913
|
+
}, chipOutside.type === "avatar" ? { avatar: /* @__PURE__ */ import_react19.default.createElement(import_material13.Avatar, null, avatarText) } : {})
|
|
2914
|
+
));
|
|
2915
|
+
})
|
|
2916
|
+
), /* @__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) => {
|
|
2917
|
+
const avatarText = resolveAvatarText(option);
|
|
2918
|
+
return /* @__PURE__ */ import_react19.default.createElement(
|
|
2919
|
+
import_material13.Chip,
|
|
2920
|
+
__spreadValues({
|
|
2921
|
+
key: getItemValue(option).value,
|
|
2922
|
+
color: "default",
|
|
2923
|
+
size: "small",
|
|
2924
|
+
variant: "filled",
|
|
2925
|
+
label: getItemValue(option).text,
|
|
2926
|
+
onDelete: () => handleDeleteChip(option)
|
|
2927
|
+
}, chipOutside.type === "avatar" ? { avatar: /* @__PURE__ */ import_react19.default.createElement(import_material13.Avatar, null, avatarText) } : {})
|
|
2928
|
+
);
|
|
2929
|
+
}), hiddenCount > 0 && /* @__PURE__ */ import_react19.default.createElement(
|
|
2930
|
+
import_material13.Box,
|
|
2931
|
+
{
|
|
2932
|
+
onMouseEnter: handlePlusEnter,
|
|
2933
|
+
onMouseLeave: handlePlusLeave,
|
|
2934
|
+
sx: { ml: 0.5, fontSize: 13, color: "#666", display: "flex", alignItems: "center", cursor: "default" }
|
|
2935
|
+
},
|
|
2936
|
+
`+${hiddenCount}`
|
|
2937
|
+
)), /* @__PURE__ */ import_react19.default.createElement(
|
|
2938
|
+
import_material13.Popper,
|
|
2939
|
+
{
|
|
2940
|
+
open: Boolean(popoverAnchor),
|
|
2941
|
+
anchorEl: popoverAnchor,
|
|
2942
|
+
placement: "bottom-start",
|
|
2943
|
+
sx: { zIndex: 1500 }
|
|
2944
|
+
},
|
|
2945
|
+
/* @__PURE__ */ import_react19.default.createElement(
|
|
2946
|
+
import_material13.Paper,
|
|
2947
|
+
{
|
|
2948
|
+
elevation: 3,
|
|
2949
|
+
onMouseEnter: handlePopperEnter,
|
|
2950
|
+
onMouseLeave: handlePopperLeave,
|
|
2951
|
+
sx: { p: 1, display: "flex", flexWrap: "wrap", gap: 0.5, maxWidth: 300 }
|
|
2952
|
+
},
|
|
2953
|
+
selectedOptions.slice(displayCount).map((option) => {
|
|
2954
|
+
const avatarText = resolveAvatarText(option);
|
|
2955
|
+
return /* @__PURE__ */ import_react19.default.createElement(
|
|
2956
|
+
import_material13.Chip,
|
|
2957
|
+
__spreadValues({
|
|
2958
|
+
key: getItemValue(option).value,
|
|
2959
|
+
color: "default",
|
|
2960
|
+
size: "small",
|
|
2961
|
+
variant: "filled",
|
|
2962
|
+
label: getItemValue(option).text,
|
|
2963
|
+
onDelete: () => handleDeleteChip(option)
|
|
2964
|
+
}, chipOutside.type === "avatar" ? { avatar: /* @__PURE__ */ import_react19.default.createElement(import_material13.Avatar, { sx: { fontSize: avatarText.length > 1 ? "0.55rem" : "0.75rem" } }, avatarText) } : {})
|
|
2965
|
+
);
|
|
2966
|
+
})
|
|
2967
|
+
)
|
|
2968
|
+
));
|
|
2969
|
+
})()));
|
|
2849
2970
|
}
|
|
2850
2971
|
|
|
2851
2972
|
// src/Components/SCDateRange.tsx
|
|
@@ -3223,9 +3344,6 @@ function SCDrawer({
|
|
|
3223
3344
|
];
|
|
3224
3345
|
};
|
|
3225
3346
|
const drawerActions = getActions();
|
|
3226
|
-
debugger;
|
|
3227
|
-
console.log("shouldShowChips en scDrawer", shouldShowChips);
|
|
3228
|
-
console.log("textFilters en scDrawer", textFilters);
|
|
3229
3347
|
return /* @__PURE__ */ import_react24.default.createElement(import_react24.default.Fragment, null, toast && /* @__PURE__ */ import_react24.default.createElement(SCToastNotification, __spreadValues({}, toast)), /* @__PURE__ */ import_react24.default.createElement(
|
|
3230
3348
|
import_Grid4.default,
|
|
3231
3349
|
{
|
|
@@ -3242,13 +3360,13 @@ function SCDrawer({
|
|
|
3242
3360
|
onDeleteFilter: handleDeleteFilter
|
|
3243
3361
|
}
|
|
3244
3362
|
),
|
|
3245
|
-
buttonDrawer && /* @__PURE__ */ import_react24.default.createElement(
|
|
3363
|
+
buttonDrawer && /* @__PURE__ */ import_react24.default.createElement(
|
|
3246
3364
|
DrawerButton,
|
|
3247
3365
|
{
|
|
3248
3366
|
buttonDrawer,
|
|
3249
3367
|
onToggle: toggleDrawer(true)
|
|
3250
3368
|
}
|
|
3251
|
-
)
|
|
3369
|
+
)
|
|
3252
3370
|
), anchor != "bottom" ? /* @__PURE__ */ import_react24.default.createElement(
|
|
3253
3371
|
import_material18.Drawer,
|
|
3254
3372
|
{
|