qlu-20-ui-library 1.7.76 → 1.7.77
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/build/index.css +1 -1
- package/dist/build/qlu-20-ui-library.cjs +71 -71
- package/dist/build/qlu-20-ui-library.js +7134 -6962
- package/dist/components/DropDownForm/DropDownForm.d.ts +7 -0
- package/dist/components/DropDownForm/index.d.ts +2 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/types/components/DropDownForm/DropDownForm.d.ts +7 -0
- package/dist/types/components/DropDownForm/DropDownForm.js +39 -0
- package/dist/types/components/DropDownForm/index.d.ts +2 -0
- package/dist/types/components/DropDownForm/index.js +2 -0
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/components/index.js +1 -0
- package/package.json +1 -1
|
@@ -170,6 +170,7 @@ export { default as BadgeWithCount } from "./BadgeWithCount";
|
|
|
170
170
|
export { default as SelectablePill } from "./SelectablePill";
|
|
171
171
|
export { default as SelectionDropDown } from "./SelectionDropdown";
|
|
172
172
|
export { default as ContinuousRangeComponent } from "./ContinuousRangeComponent";
|
|
173
|
+
export { default as DropDownForm } from "./DropDownForm";
|
|
173
174
|
export { default as CreditBarChart } from "./CreditBarChart";
|
|
174
175
|
export { default as CreditUsageChart } from "./CreditUsageChart";
|
|
175
176
|
export { default as CreditManagementDropdownButton } from "./CreditsManagementDropdownButton/CreditsManagementDropdownButton";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { GetSvgIcon } from '..';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import styles from './style.module.scss';
|
|
6
|
+
const DropDownForm = ({ items, onSelect, }) => {
|
|
7
|
+
const [extend, setExtend] = useState(false);
|
|
8
|
+
const [selectedItem, setSelectedItem] = useState(items[0] || "");
|
|
9
|
+
const elementRef = useRef(null);
|
|
10
|
+
const handleArrow = () => {
|
|
11
|
+
setExtend(prev => !prev);
|
|
12
|
+
};
|
|
13
|
+
const handleItem = (e) => {
|
|
14
|
+
setSelectedItem(e);
|
|
15
|
+
onSelect(e);
|
|
16
|
+
setExtend(false);
|
|
17
|
+
};
|
|
18
|
+
// Add an event listener to the document to detect clicks outside the element
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
function handleClickOutside(event) {
|
|
21
|
+
if (elementRef.current && !elementRef.current.contains(event.target)) {
|
|
22
|
+
handleArrow();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
26
|
+
return () => {
|
|
27
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
28
|
+
};
|
|
29
|
+
}, []);
|
|
30
|
+
const getItemClasses = (index) => {
|
|
31
|
+
return clsx(styles.dropdownItem, {
|
|
32
|
+
[styles.itemFirst]: index === 0,
|
|
33
|
+
[styles.itemLast]: index === items.length - 1
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
return (_jsxs("div", { className: styles.dropdownContainer, children: [_jsxs("button", { type: 'button', className: styles.dropdownTrigger, onClick: handleArrow, children: [_jsxs("span", { className: styles.dropdownLabel, children: [" ", selectedItem, " "] }), _jsx("span", { className: styles.dropdownIcon, children: _jsx(GetSvgIcon, { iconType: `${extend ? 'cheveronUp' : 'cheveronDown'}`, iconSize: '18' }) })] }), extend &&
|
|
37
|
+
_jsx("div", { className: styles.dropdownContent, ref: elementRef, children: items.map((ele, idx) => (_jsx("div", { className: getItemClasses(idx), onClick: () => handleItem(ele), children: ele }, ele + idx))) })] }));
|
|
38
|
+
};
|
|
39
|
+
export default DropDownForm;
|
|
@@ -170,6 +170,7 @@ export { default as BadgeWithCount } from "./BadgeWithCount";
|
|
|
170
170
|
export { default as SelectablePill } from "./SelectablePill";
|
|
171
171
|
export { default as SelectionDropDown } from "./SelectionDropdown";
|
|
172
172
|
export { default as ContinuousRangeComponent } from "./ContinuousRangeComponent";
|
|
173
|
+
export { default as DropDownForm } from "./DropDownForm";
|
|
173
174
|
export { default as CreditBarChart } from "./CreditBarChart";
|
|
174
175
|
export { default as CreditUsageChart } from "./CreditUsageChart";
|
|
175
176
|
export { default as CreditManagementDropdownButton } from "./CreditsManagementDropdownButton/CreditsManagementDropdownButton";
|
|
@@ -170,6 +170,7 @@ export { default as BadgeWithCount } from "./BadgeWithCount";
|
|
|
170
170
|
export { default as SelectablePill } from "./SelectablePill";
|
|
171
171
|
export { default as SelectionDropDown } from "./SelectionDropdown";
|
|
172
172
|
export { default as ContinuousRangeComponent } from "./ContinuousRangeComponent";
|
|
173
|
+
export { default as DropDownForm } from "./DropDownForm";
|
|
173
174
|
export { default as CreditBarChart } from "./CreditBarChart";
|
|
174
175
|
export { default as CreditUsageChart } from "./CreditUsageChart";
|
|
175
176
|
export { default as CreditManagementDropdownButton } from "./CreditsManagementDropdownButton/CreditsManagementDropdownButton";
|