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.
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ type DropDownFormProps = {
3
+ items: string[];
4
+ onSelect: (val: string) => void;
5
+ };
6
+ declare const DropDownForm: React.FC<DropDownFormProps>;
7
+ export default DropDownForm;
@@ -0,0 +1,2 @@
1
+ import DropDownForm from "./DropDownForm";
2
+ 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";
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ type DropDownFormProps = {
3
+ items: string[];
4
+ onSelect: (val: string) => void;
5
+ };
6
+ declare const DropDownForm: React.FC<DropDownFormProps>;
7
+ export default DropDownForm;
@@ -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;
@@ -0,0 +1,2 @@
1
+ import DropDownForm from "./DropDownForm";
2
+ export default DropDownForm;
@@ -0,0 +1,2 @@
1
+ import DropDownForm from "./DropDownForm";
2
+ 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";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qlu-20-ui-library",
3
- "version": "1.7.76",
3
+ "version": "1.7.77",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",