sprint-asia-custom-component 0.1.136 → 0.1.138
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 +87 -0
- package/package.json +1 -1
- package/src/components/filter/filterCheckboxDropdown/index.js +111 -0
- package/src/index.js +2 -0
- package/src/templates/index.js +23 -0
package/dist/index.js
CHANGED
|
@@ -26797,6 +26797,92 @@
|
|
|
26797
26797
|
}, option))))));
|
|
26798
26798
|
};
|
|
26799
26799
|
|
|
26800
|
+
const FilterCheckboxDropdown = ({
|
|
26801
|
+
options = [{
|
|
26802
|
+
option: "Option 1",
|
|
26803
|
+
value: "value 1"
|
|
26804
|
+
}, {
|
|
26805
|
+
option: "Option 2",
|
|
26806
|
+
value: "value 2"
|
|
26807
|
+
}, {
|
|
26808
|
+
option: "Option 3",
|
|
26809
|
+
value: "value 3"
|
|
26810
|
+
}],
|
|
26811
|
+
currentValue = [],
|
|
26812
|
+
buttonText = "Filter",
|
|
26813
|
+
onSelect
|
|
26814
|
+
}) => {
|
|
26815
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
26816
|
+
const [selectedOptions, setSelectedOptions] = React.useState([]);
|
|
26817
|
+
const dropdownRef = React.useRef(null);
|
|
26818
|
+
React.useEffect(() => {
|
|
26819
|
+
setSelectedOptions(currentValue);
|
|
26820
|
+
}, [currentValue]);
|
|
26821
|
+
React.useEffect(() => {
|
|
26822
|
+
const handleOutsideClick = event => {
|
|
26823
|
+
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
26824
|
+
setIsOpen(false);
|
|
26825
|
+
}
|
|
26826
|
+
};
|
|
26827
|
+
if (isOpen) {
|
|
26828
|
+
document.addEventListener('mousedown', handleOutsideClick);
|
|
26829
|
+
}
|
|
26830
|
+
return () => {
|
|
26831
|
+
document.removeEventListener('mousedown', handleOutsideClick);
|
|
26832
|
+
};
|
|
26833
|
+
}, [isOpen]);
|
|
26834
|
+
const handleToggleFilterCheckboxDropdown = () => {
|
|
26835
|
+
setIsOpen(!isOpen);
|
|
26836
|
+
};
|
|
26837
|
+
const handleOptionClick = optionValue => {
|
|
26838
|
+
const updatedOptions = selectedOptions.some(option => option.value === optionValue) ? selectedOptions.filter(selected => selected.value !== optionValue) : [...selectedOptions, options.find(option => option.value === optionValue)];
|
|
26839
|
+
setSelectedOptions(updatedOptions);
|
|
26840
|
+
if (onSelect) {
|
|
26841
|
+
onSelect(updatedOptions);
|
|
26842
|
+
}
|
|
26843
|
+
};
|
|
26844
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
26845
|
+
className: "relative inline-block text-left",
|
|
26846
|
+
ref: dropdownRef
|
|
26847
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
26848
|
+
className: "rounded-md shadow-sm"
|
|
26849
|
+
}, /*#__PURE__*/React__default["default"].createElement("button", {
|
|
26850
|
+
type: "button",
|
|
26851
|
+
className: "flex items-center w-60 py-2.5 text-left px-4 bg-neutral20 border-neutral50 font-normal text-sm text-neutral300 rounded-md border focus:outline-none",
|
|
26852
|
+
onClick: handleToggleFilterCheckboxDropdown
|
|
26853
|
+
}, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
26854
|
+
className: "flex-grow"
|
|
26855
|
+
}, buttonText), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
26856
|
+
className: "ml-2"
|
|
26857
|
+
}, isOpen ? /*#__PURE__*/React__default["default"].createElement(PiCaretUp, {
|
|
26858
|
+
size: 16,
|
|
26859
|
+
className: "text-neutral300"
|
|
26860
|
+
}) : /*#__PURE__*/React__default["default"].createElement(PiCaretDown, {
|
|
26861
|
+
size: 16,
|
|
26862
|
+
className: "text-neutral300"
|
|
26863
|
+
}))))), isOpen && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
26864
|
+
className: "z-10 origin-top-right absolute left-0 mt-2 w-60 rounded-md shadow-md bg-white ring-1 ring-black ring-opacity-5 focus:outline-none",
|
|
26865
|
+
role: "menu",
|
|
26866
|
+
"aria-orientation": "vertical",
|
|
26867
|
+
"aria-labelledby": "options-menu"
|
|
26868
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
26869
|
+
className: "px-1 py-2"
|
|
26870
|
+
}, options.length === 0 ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
26871
|
+
className: "bg-neutral20 py-2.5 px-4 my-0.5 rounded-md text-sm text-neutral500 text-center"
|
|
26872
|
+
}, "No Data") : options.map(val => /*#__PURE__*/React__default["default"].createElement("div", {
|
|
26873
|
+
key: val.value,
|
|
26874
|
+
className: `hover:bg-neutral20 bg-white py-2.5 px-4 my-0.5 rounded-md flex items-center cursor-pointer ${selectedOptions.some(option => option.value === val.value) ? 'bg-primary500' : ''}`,
|
|
26875
|
+
onClick: () => handleOptionClick(val.value)
|
|
26876
|
+
}, /*#__PURE__*/React__default["default"].createElement("input", {
|
|
26877
|
+
type: "checkbox",
|
|
26878
|
+
className: "mr-2",
|
|
26879
|
+
checked: selectedOptions.some(option => option.value === val.value),
|
|
26880
|
+
onChange: () => handleOptionClick(val.value)
|
|
26881
|
+
}), /*#__PURE__*/React__default["default"].createElement("p", {
|
|
26882
|
+
className: `text-sm ${selectedOptions.some(option => option.value === val.value) ? 'text-primary500' : 'text-black'}`
|
|
26883
|
+
}, val.option))))));
|
|
26884
|
+
};
|
|
26885
|
+
|
|
26800
26886
|
const FilterText = ({
|
|
26801
26887
|
options = ["Type", "Company"],
|
|
26802
26888
|
onSelect
|
|
@@ -48775,6 +48861,7 @@
|
|
|
48775
48861
|
exports.EmptyData = EmptyData;
|
|
48776
48862
|
exports.ExportToExcel = ExportToExcel;
|
|
48777
48863
|
exports.FilterCheckbox = FilterCheckbox;
|
|
48864
|
+
exports.FilterCheckboxDropdown = FilterCheckboxDropdown;
|
|
48778
48865
|
exports.FilterDropdown = FilterDropdown;
|
|
48779
48866
|
exports.FilterText = FilterText;
|
|
48780
48867
|
exports.Footer = Footer;
|
package/package.json
CHANGED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react';
|
|
2
|
+
import { PiCaretDown, PiCaretUp } from 'react-icons/pi';
|
|
3
|
+
|
|
4
|
+
const FilterCheckboxDropdown = ({
|
|
5
|
+
options = [
|
|
6
|
+
{ option: "Option 1", value: "value 1" },
|
|
7
|
+
{ option: "Option 2", value: "value 2" },
|
|
8
|
+
{ option: "Option 3", value: "value 3" },
|
|
9
|
+
],
|
|
10
|
+
currentValue = [],
|
|
11
|
+
buttonText = "Filter",
|
|
12
|
+
onSelect
|
|
13
|
+
}) => {
|
|
14
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
15
|
+
const [selectedOptions, setSelectedOptions] = useState([]);
|
|
16
|
+
const dropdownRef = useRef(null);
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
setSelectedOptions(currentValue);
|
|
20
|
+
}, [currentValue]);
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const handleOutsideClick = (event) => {
|
|
24
|
+
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
25
|
+
setIsOpen(false);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
if (isOpen) {
|
|
30
|
+
document.addEventListener('mousedown', handleOutsideClick);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return () => {
|
|
34
|
+
document.removeEventListener('mousedown', handleOutsideClick);
|
|
35
|
+
};
|
|
36
|
+
}, [isOpen]);
|
|
37
|
+
|
|
38
|
+
const handleToggleFilterCheckboxDropdown = () => {
|
|
39
|
+
setIsOpen(!isOpen);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const handleOptionClick = (optionValue) => {
|
|
43
|
+
const updatedOptions = selectedOptions.some(option => option.value === optionValue)
|
|
44
|
+
? selectedOptions.filter((selected) => selected.value !== optionValue)
|
|
45
|
+
: [...selectedOptions, options.find(option => option.value === optionValue)];
|
|
46
|
+
|
|
47
|
+
setSelectedOptions(updatedOptions);
|
|
48
|
+
|
|
49
|
+
if (onSelect) {
|
|
50
|
+
onSelect(updatedOptions);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<div className='relative inline-block text-left' ref={dropdownRef}>
|
|
56
|
+
<div>
|
|
57
|
+
<span className='rounded-md shadow-sm'>
|
|
58
|
+
<button
|
|
59
|
+
type='button'
|
|
60
|
+
className="flex items-center w-60 py-2.5 text-left px-4 bg-neutral20 border-neutral50 font-normal text-sm text-neutral300 rounded-md border focus:outline-none"
|
|
61
|
+
onClick={handleToggleFilterCheckboxDropdown}
|
|
62
|
+
>
|
|
63
|
+
<span className='flex-grow'>{buttonText}</span>
|
|
64
|
+
<span className='ml-2'>
|
|
65
|
+
{isOpen ? <PiCaretUp size={16} className='text-neutral300' /> : <PiCaretDown size={16} className='text-neutral300' />}
|
|
66
|
+
</span>
|
|
67
|
+
</button>
|
|
68
|
+
</span>
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
{isOpen && (
|
|
72
|
+
<div
|
|
73
|
+
className='z-10 origin-top-right absolute left-0 mt-2 w-60 rounded-md shadow-md bg-white ring-1 ring-black ring-opacity-5 focus:outline-none'
|
|
74
|
+
role='menu'
|
|
75
|
+
aria-orientation='vertical'
|
|
76
|
+
aria-labelledby='options-menu'
|
|
77
|
+
>
|
|
78
|
+
<div className='px-1 py-2'>
|
|
79
|
+
{options.length === 0 ? (
|
|
80
|
+
<div className='bg-neutral20 py-2.5 px-4 my-0.5 rounded-md text-sm text-neutral500 text-center'>
|
|
81
|
+
No Data
|
|
82
|
+
</div>
|
|
83
|
+
) : (
|
|
84
|
+
options.map((val) => (
|
|
85
|
+
<div
|
|
86
|
+
key={val.value}
|
|
87
|
+
className={`hover:bg-neutral20 bg-white py-2.5 px-4 my-0.5 rounded-md flex items-center cursor-pointer ${
|
|
88
|
+
selectedOptions.some(option => option.value === val.value) ? 'bg-primary500' : ''
|
|
89
|
+
}`}
|
|
90
|
+
onClick={() => handleOptionClick(val.value)}
|
|
91
|
+
>
|
|
92
|
+
<input
|
|
93
|
+
type='checkbox'
|
|
94
|
+
className='mr-2'
|
|
95
|
+
checked={selectedOptions.some(option => option.value === val.value)}
|
|
96
|
+
onChange={() => handleOptionClick(val.value)}
|
|
97
|
+
/>
|
|
98
|
+
<p className={`text-sm ${selectedOptions.some(option => option.value === val.value) ? 'text-primary500' : 'text-black'}`}>
|
|
99
|
+
{val.option}
|
|
100
|
+
</p>
|
|
101
|
+
</div>
|
|
102
|
+
))
|
|
103
|
+
)}
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
)}
|
|
107
|
+
</div>
|
|
108
|
+
);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export default FilterCheckboxDropdown;
|
package/src/index.js
CHANGED
|
@@ -48,6 +48,7 @@ import EmptyData from "./components/emptystate/table/emptydata";
|
|
|
48
48
|
import NotFound from "./components/emptystate/table/notfound";
|
|
49
49
|
import ExportToExcel from "./components/export/excel";
|
|
50
50
|
import FilterCheckbox from "./components/filter/filterCheckbox";
|
|
51
|
+
import FilterCheckboxDropdown from "./components/filter/filterCheckboxDropdown";
|
|
51
52
|
import FilterText from "./components/filter/filterText";
|
|
52
53
|
import Menu from "./components/menu";
|
|
53
54
|
import ModalLoading from "./components/modal/modalLoading";
|
|
@@ -123,6 +124,7 @@ export {
|
|
|
123
124
|
Menu,
|
|
124
125
|
FilterText,
|
|
125
126
|
FilterCheckbox,
|
|
127
|
+
FilterCheckboxDropdown,
|
|
126
128
|
ExportToExcel,
|
|
127
129
|
NotFound,
|
|
128
130
|
EmptyData,
|
package/src/templates/index.js
CHANGED
|
@@ -61,6 +61,7 @@ import CellModelSix from "../components/table/listTable/cellmodesix";
|
|
|
61
61
|
import CellModelSeven from "../components/table/listTable/cellmodelseven";
|
|
62
62
|
import CustomPhone from "../components/customphone";
|
|
63
63
|
import DescriptionFile from "../components/description/file";
|
|
64
|
+
import FilterCheckboxDropdown from "../components/filter/filterCheckboxDropdown";
|
|
64
65
|
|
|
65
66
|
const Templates = () => {
|
|
66
67
|
const [startDate, setStartDate] = useState(null);
|
|
@@ -828,6 +829,7 @@ const Templates = () => {
|
|
|
828
829
|
});
|
|
829
830
|
|
|
830
831
|
const [searchFilter, setSearchFilter] = useState();
|
|
832
|
+
const [valueSelectFilter, setValueSelectFilter] = useState([]);
|
|
831
833
|
const [filterDropdown, setFilterDropdown] = useState({
|
|
832
834
|
option: "duar",
|
|
833
835
|
value: "dfdsf",
|
|
@@ -1171,6 +1173,27 @@ const Templates = () => {
|
|
|
1171
1173
|
<div className="m-9"></div>
|
|
1172
1174
|
<FilterText options={["Option 1", "Option 2", "Option 3"]} onSelect={handleSelect} />
|
|
1173
1175
|
|
|
1176
|
+
<div className="m-9"></div>
|
|
1177
|
+
<FilterCheckboxDropdown
|
|
1178
|
+
options={[
|
|
1179
|
+
{
|
|
1180
|
+
option : "Option1",
|
|
1181
|
+
value : "value 1"
|
|
1182
|
+
},
|
|
1183
|
+
{
|
|
1184
|
+
option : "Option2",
|
|
1185
|
+
value : "value 2"
|
|
1186
|
+
},
|
|
1187
|
+
]}
|
|
1188
|
+
buttonText="Division"
|
|
1189
|
+
currentValue={valueSelectFilter}
|
|
1190
|
+
onSelect={setValueSelectFilter}
|
|
1191
|
+
/>
|
|
1192
|
+
|
|
1193
|
+
{
|
|
1194
|
+
console.log("ini value select", valueSelectFilter)
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1174
1197
|
<div className="m-9"></div>
|
|
1175
1198
|
<FilterDropdown
|
|
1176
1199
|
options={[
|