cr-ui-lib 1.1.20 → 1.1.21
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 +129 -111
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +130 -111
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ var chart_js = require('chart.js');
|
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var reactChartjs2 = require('react-chartjs-2');
|
|
8
8
|
var lucideReact = require('lucide-react');
|
|
9
|
-
var
|
|
9
|
+
var reactDom = require('react-dom');
|
|
10
10
|
var dateFns = require('date-fns');
|
|
11
11
|
var DatePicker = require('react-datepicker');
|
|
12
12
|
var ReactPaginate = require('react-paginate');
|
|
@@ -14,7 +14,6 @@ var ReactPaginate = require('react-paginate');
|
|
|
14
14
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
15
|
|
|
16
16
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
17
|
-
var ReactDOM__default = /*#__PURE__*/_interopDefault(ReactDOM);
|
|
18
17
|
var DatePicker__default = /*#__PURE__*/_interopDefault(DatePicker);
|
|
19
18
|
var ReactPaginate__default = /*#__PURE__*/_interopDefault(ReactPaginate);
|
|
20
19
|
|
|
@@ -2660,12 +2659,17 @@ var MultipleAutoSuggestionInput = ({
|
|
|
2660
2659
|
var _a;
|
|
2661
2660
|
const [filteredOptions, setFilteredOptions] = React.useState(options);
|
|
2662
2661
|
const [isDropdownOpen, setIsDropdownOpen] = React.useState(false);
|
|
2662
|
+
const [dropdownPosition, setDropdownPosition] = React.useState({
|
|
2663
|
+
top: 0,
|
|
2664
|
+
left: 0,
|
|
2665
|
+
width: 0
|
|
2666
|
+
});
|
|
2663
2667
|
const inputRef = React.useRef(null);
|
|
2664
|
-
const
|
|
2668
|
+
const containerRef = React.useRef(null);
|
|
2665
2669
|
const selectedList = isMulti ? selectedItems : selectedItems ? [selectedItems] : [];
|
|
2666
2670
|
React.useEffect(() => {
|
|
2667
2671
|
const handleClickOutside = (event) => {
|
|
2668
|
-
if (
|
|
2672
|
+
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
2669
2673
|
setIsDropdownOpen(false);
|
|
2670
2674
|
}
|
|
2671
2675
|
};
|
|
@@ -2685,10 +2689,20 @@ var MultipleAutoSuggestionInput = ({
|
|
|
2685
2689
|
setFilteredOptions(filtered);
|
|
2686
2690
|
if (inputValue) {
|
|
2687
2691
|
setIsDropdownOpen(true);
|
|
2688
|
-
} else {
|
|
2692
|
+
} else if (!isDropdownAutoOpen) {
|
|
2689
2693
|
setIsDropdownOpen(false);
|
|
2690
2694
|
}
|
|
2691
2695
|
}, [inputValue, options, selectedItems]);
|
|
2696
|
+
React.useLayoutEffect(() => {
|
|
2697
|
+
if (isDropdownOpen && containerRef.current) {
|
|
2698
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
2699
|
+
setDropdownPosition({
|
|
2700
|
+
top: rect.bottom + window.scrollY,
|
|
2701
|
+
left: rect.left + window.scrollX,
|
|
2702
|
+
width: rect.width
|
|
2703
|
+
});
|
|
2704
|
+
}
|
|
2705
|
+
}, [isDropdownOpen]);
|
|
2692
2706
|
const handleInputChange = (e) => {
|
|
2693
2707
|
setInputValue(e.target.value);
|
|
2694
2708
|
onChange(e);
|
|
@@ -2698,6 +2712,32 @@ var MultipleAutoSuggestionInput = ({
|
|
|
2698
2712
|
setInputValue("");
|
|
2699
2713
|
setIsDropdownOpen(false);
|
|
2700
2714
|
};
|
|
2715
|
+
const DropdownMenu = /* @__PURE__ */ jsxRuntime.jsx(
|
|
2716
|
+
"div",
|
|
2717
|
+
{
|
|
2718
|
+
style: {
|
|
2719
|
+
position: "absolute",
|
|
2720
|
+
top: `${dropdownPosition.top + 4}px`,
|
|
2721
|
+
// position based on state
|
|
2722
|
+
left: `${dropdownPosition.left}px`,
|
|
2723
|
+
width: `${dropdownPosition.width}px`
|
|
2724
|
+
},
|
|
2725
|
+
className: tailwindMerge.twMerge(
|
|
2726
|
+
"w-full rounded-lg bg-white shadow-lg z-50 max-h-60 overflow-auto border border-[#E2E2E2]",
|
|
2727
|
+
// Increased z-index
|
|
2728
|
+
dropdownOpenClass
|
|
2729
|
+
),
|
|
2730
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "py-1 rounded-lg border-[#E2E2E2]", children: filteredOptions.map((option) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2731
|
+
"div",
|
|
2732
|
+
{
|
|
2733
|
+
className: "px-4 py-2 text-sm cursor-pointer custom-listing-hover",
|
|
2734
|
+
onClick: () => handleOptionSelect(option.key),
|
|
2735
|
+
children: option.name
|
|
2736
|
+
},
|
|
2737
|
+
option.key
|
|
2738
|
+
)) })
|
|
2739
|
+
}
|
|
2740
|
+
);
|
|
2701
2741
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
2702
2742
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2703
2743
|
"label",
|
|
@@ -2709,10 +2749,10 @@ var MultipleAutoSuggestionInput = ({
|
|
|
2709
2749
|
children: label
|
|
2710
2750
|
}
|
|
2711
2751
|
),
|
|
2712
|
-
/* @__PURE__ */ jsxRuntime.
|
|
2752
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2713
2753
|
"div",
|
|
2714
2754
|
{
|
|
2715
|
-
ref:
|
|
2755
|
+
ref: containerRef,
|
|
2716
2756
|
className: "relative",
|
|
2717
2757
|
onClick: () => {
|
|
2718
2758
|
var _a2, _b;
|
|
@@ -2721,81 +2761,34 @@ var MultipleAutoSuggestionInput = ({
|
|
|
2721
2761
|
setIsDropdownOpen(true);
|
|
2722
2762
|
}
|
|
2723
2763
|
},
|
|
2724
|
-
children:
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2736
|
-
"div",
|
|
2737
|
-
{
|
|
2738
|
-
className: tailwindMerge.twMerge(
|
|
2739
|
-
"flex flex border-[#E2E2E2] border items-center px-2 py-1 bg-white text-gray-700 rounded-md text-xs font-medium",
|
|
2740
|
-
selectedItemsClass
|
|
2741
|
-
),
|
|
2742
|
-
children: [
|
|
2743
|
-
option ? option.name : itemKey,
|
|
2744
|
-
onRemove && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2745
|
-
"button",
|
|
2746
|
-
{
|
|
2747
|
-
onClick: (e) => {
|
|
2748
|
-
e.stopPropagation();
|
|
2749
|
-
onRemove(itemKey);
|
|
2750
|
-
},
|
|
2751
|
-
className: tailwindMerge.twMerge(
|
|
2752
|
-
"ml-1 text-gray-500 hover:text-gray-700 bg-white",
|
|
2753
|
-
removeIconClass
|
|
2754
|
-
),
|
|
2755
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2756
|
-
"svg",
|
|
2757
|
-
{
|
|
2758
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
2759
|
-
width: "14",
|
|
2760
|
-
height: "14",
|
|
2761
|
-
viewBox: "0 0 14 14",
|
|
2762
|
-
fill: "none",
|
|
2763
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2764
|
-
"path",
|
|
2765
|
-
{
|
|
2766
|
-
d: "M11.0837 3.739L10.2612 2.9165L7.00033 6.17734L3.73949 2.9165L2.91699 3.739L6.17783 6.99984L2.91699 10.2607L3.73949 11.0832L7.00033 7.82234L10.2612 11.0832L11.0837 10.2607L7.82283 6.99984L11.0837 3.739Z",
|
|
2767
|
-
fill: "#323232"
|
|
2768
|
-
}
|
|
2769
|
-
)
|
|
2770
|
-
}
|
|
2771
|
-
)
|
|
2772
|
-
}
|
|
2773
|
-
)
|
|
2774
|
-
]
|
|
2775
|
-
},
|
|
2776
|
-
itemKey
|
|
2777
|
-
);
|
|
2778
|
-
}) : selectedList.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2764
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2765
|
+
"div",
|
|
2766
|
+
{
|
|
2767
|
+
className: tailwindMerge.twMerge(
|
|
2768
|
+
"border border-[#E2E2E2] focus-within:border-[#4683B4] rounded-lg p-1.5 bg-[#F8F8F8] cursor-pointer flex flex-wrap items-center gap-2 min-h-[2.5rem]",
|
|
2769
|
+
buttonClass
|
|
2770
|
+
),
|
|
2771
|
+
children: [
|
|
2772
|
+
isMulti && Array.isArray(selectedList) ? selectedList.map((itemKey) => {
|
|
2773
|
+
const option = options.find((opt) => opt.key === itemKey);
|
|
2774
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2779
2775
|
"div",
|
|
2780
2776
|
{
|
|
2781
2777
|
className: tailwindMerge.twMerge(
|
|
2782
|
-
"flex border-[#E2E2E2] border items-center px-2 py-1 bg-white text-gray-700 rounded-md text-xs font-medium",
|
|
2778
|
+
"flex flex border-[#E2E2E2] border items-center px-2 py-1 bg-white text-gray-700 rounded-md text-xs font-medium",
|
|
2783
2779
|
selectedItemsClass
|
|
2784
2780
|
),
|
|
2785
2781
|
children: [
|
|
2786
|
-
|
|
2782
|
+
option ? option.name : itemKey,
|
|
2787
2783
|
onRemove && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2788
2784
|
"button",
|
|
2789
2785
|
{
|
|
2790
2786
|
onClick: (e) => {
|
|
2791
|
-
var _a2;
|
|
2792
2787
|
e.stopPropagation();
|
|
2793
|
-
onRemove(
|
|
2794
|
-
((_a2 = options.find((opt) => opt.key === selectedList[0])) == null ? void 0 : _a2.name) || selectedList[0]
|
|
2795
|
-
);
|
|
2788
|
+
onRemove(itemKey);
|
|
2796
2789
|
},
|
|
2797
2790
|
className: tailwindMerge.twMerge(
|
|
2798
|
-
"ml-1 text-gray-500 hover:text-gray-700",
|
|
2791
|
+
"ml-1 text-gray-500 hover:text-gray-700 bg-white",
|
|
2799
2792
|
removeIconClass
|
|
2800
2793
|
),
|
|
2801
2794
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2818,52 +2811,77 @@ var MultipleAutoSuggestionInput = ({
|
|
|
2818
2811
|
}
|
|
2819
2812
|
)
|
|
2820
2813
|
]
|
|
2821
|
-
}
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
className: "
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2814
|
+
},
|
|
2815
|
+
itemKey
|
|
2816
|
+
);
|
|
2817
|
+
}) : selectedList.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2818
|
+
"div",
|
|
2819
|
+
{
|
|
2820
|
+
className: tailwindMerge.twMerge(
|
|
2821
|
+
"flex border-[#E2E2E2] border items-center px-2 py-1 bg-white text-gray-700 rounded-md text-xs font-medium",
|
|
2822
|
+
selectedItemsClass
|
|
2823
|
+
),
|
|
2824
|
+
children: [
|
|
2825
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-medium text-gray-800", children: ((_a = options.find((opt) => opt.key === selectedList[0])) == null ? void 0 : _a.name) || selectedList[0] }),
|
|
2826
|
+
onRemove && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2827
|
+
"button",
|
|
2828
|
+
{
|
|
2829
|
+
onClick: (e) => {
|
|
2830
|
+
var _a2;
|
|
2831
|
+
e.stopPropagation();
|
|
2832
|
+
onRemove(
|
|
2833
|
+
((_a2 = options.find((opt) => opt.key === selectedList[0])) == null ? void 0 : _a2.name) || selectedList[0]
|
|
2834
|
+
);
|
|
2835
|
+
},
|
|
2836
|
+
className: tailwindMerge.twMerge(
|
|
2837
|
+
"ml-1 text-gray-500 hover:text-gray-700",
|
|
2838
|
+
removeIconClass
|
|
2839
|
+
),
|
|
2840
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2841
|
+
"svg",
|
|
2842
|
+
{
|
|
2843
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2844
|
+
width: "14",
|
|
2845
|
+
height: "14",
|
|
2846
|
+
viewBox: "0 0 14 14",
|
|
2847
|
+
fill: "none",
|
|
2848
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2849
|
+
"path",
|
|
2850
|
+
{
|
|
2851
|
+
d: "M11.0837 3.739L10.2612 2.9165L7.00033 6.17734L3.73949 2.9165L2.91699 3.739L6.17783 6.99984L2.91699 10.2607L3.73949 11.0832L7.00033 7.82234L10.2612 11.0832L11.0837 10.2607L7.82283 6.99984L11.0837 3.739Z",
|
|
2852
|
+
fill: "#323232"
|
|
2853
|
+
}
|
|
2854
|
+
)
|
|
2855
|
+
}
|
|
2856
|
+
)
|
|
2836
2857
|
}
|
|
2858
|
+
)
|
|
2859
|
+
]
|
|
2860
|
+
}
|
|
2861
|
+
),
|
|
2862
|
+
(!isMulti || enableTypingSingle) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2863
|
+
"input",
|
|
2864
|
+
{
|
|
2865
|
+
type: "text",
|
|
2866
|
+
ref: inputRef,
|
|
2867
|
+
value: inputValue,
|
|
2868
|
+
onKeyDown: keyDown,
|
|
2869
|
+
onChange: handleInputChange,
|
|
2870
|
+
className: "w-full flex-1 px-0 py-1 bg-[#F8F8F8] text-xs border-none outline-none focus:ring-0",
|
|
2871
|
+
onFocus: () => {
|
|
2872
|
+
if (!isDropdownOpen && (!isMulti || inputValue)) {
|
|
2873
|
+
setIsDropdownOpen(true);
|
|
2837
2874
|
}
|
|
2838
|
-
}
|
|
2839
|
-
)
|
|
2840
|
-
]
|
|
2841
|
-
}
|
|
2842
|
-
),
|
|
2843
|
-
isDropdownOpen && filteredOptions.length > 0 && ReactDOM__default.default.createPortal(
|
|
2844
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2845
|
-
"div",
|
|
2846
|
-
{
|
|
2847
|
-
className: tailwindMerge.twMerge(
|
|
2848
|
-
"absolute top-full left-0 mt-1 w-full rounded-lg bg-white shadow-lg z-10 max-h-60 overflow-auto border border-[#E2E2E2]",
|
|
2849
|
-
dropdownOpenClass
|
|
2850
|
-
),
|
|
2851
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "py-1 rounded-lg border-[#E2E2E2]", children: filteredOptions.map((option) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2852
|
-
"div",
|
|
2853
|
-
{
|
|
2854
|
-
className: "px-4 py-2 text-sm cursor-pointer custom-listing-hover",
|
|
2855
|
-
onClick: () => handleOptionSelect(option.key),
|
|
2856
|
-
children: option.name
|
|
2857
2875
|
},
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
]
|
|
2876
|
+
placeholder: selectedList.length === 0 ? "Type or select..." : ""
|
|
2877
|
+
}
|
|
2878
|
+
)
|
|
2879
|
+
]
|
|
2880
|
+
}
|
|
2881
|
+
)
|
|
2865
2882
|
}
|
|
2866
|
-
)
|
|
2883
|
+
),
|
|
2884
|
+
isDropdownOpen && filteredOptions.length > 0 && reactDom.createPortal(DropdownMenu, document.body)
|
|
2867
2885
|
] });
|
|
2868
2886
|
};
|
|
2869
2887
|
var MultipleAutoSuggestionInput_default = MultipleAutoSuggestionInput;
|