@megha-ui/react 1.2.440 → 1.2.442

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.
@@ -13,6 +13,7 @@ interface DropdownProps {
13
13
  options: DropdownOption[];
14
14
  selectedValues: (string | number | any)[];
15
15
  onChange: (values: (string | number)[]) => void;
16
+ closeOnSelect?: boolean;
16
17
  placeholder?: string;
17
18
  className?: string;
18
19
  style?: React.CSSProperties;
@@ -8,7 +8,7 @@ import Text from "../text";
8
8
  import Button from "../button";
9
9
  import { HiChevronDown } from "react-icons/hi";
10
10
  import { FaChevronDown, FaChevronUp } from "react-icons/fa";
11
- const Dropdown = ({ options, selectedValues, onChange, placeholder = "Select...", isMultiple = false, isSelectAll = false, className, style, labelFontSize, labelFontWeight, labelMarginBottom, asteriskColor, label, disabled = false, width, searchEnabled = true, dropdownListWidth, marginBottom, marginTop, marginRight, marginLeft, required, dropdownListBG, searchBorderColor = "#2377ba", maxDropdownHeight = "12rem", border = "1px solid #dbdfe9", selectedCharLength = 0, menuFrom = "left", Tooltip, DropDownIcon, onMenuClose, onMenuOpen, isClear, ClearIcon, clearId, selectedDisplay, checkboxWrapper, isSort = true, onSelectChange, isLoading = false, onApplyChange, withTooltip = false, isCreatable = false, onCreate = () => { }, autoPosition = false, compactDisplay = false, ultraCompactDisplay = false, isGrouping = false, isIcon = false, withValue = false, }) => {
11
+ const Dropdown = ({ options, selectedValues, onChange, placeholder = "Select...", isMultiple = false, isSelectAll = false, className, style, labelFontSize, labelFontWeight, labelMarginBottom, asteriskColor, label, disabled = false, width, searchEnabled = true, dropdownListWidth, marginBottom, marginTop, marginRight, marginLeft, required, dropdownListBG, searchBorderColor = "#2377ba", maxDropdownHeight = "12rem", border = "1px solid #dbdfe9", selectedCharLength = 0, menuFrom = "left", Tooltip, DropDownIcon, onMenuClose, onMenuOpen, isClear, ClearIcon, clearId, selectedDisplay, checkboxWrapper, isSort = true, onSelectChange, isLoading = false, onApplyChange, withTooltip = false, isCreatable = false, onCreate = () => { }, autoPosition = false, compactDisplay = false, ultraCompactDisplay = false, isGrouping = false, isIcon = false, withValue = false, closeOnSelect = true, }) => {
12
12
  var _a, _b;
13
13
  const { density } = useDensity();
14
14
  const [isOpen, setIsOpen] = useState(false);
@@ -182,7 +182,8 @@ const Dropdown = ({ options, selectedValues, onChange, placeholder = "Select..."
182
182
  }
183
183
  else {
184
184
  onApplyChange ? setIntermediateValues([value]) : onChange([value]);
185
- setIsOpen(false);
185
+ if (closeOnSelect)
186
+ setIsOpen(false);
186
187
  }
187
188
  };
188
189
  const handleItemSelect = (item, isDisabled) => {
@@ -196,7 +197,8 @@ const Dropdown = ({ options, selectedValues, onChange, placeholder = "Select..."
196
197
  }
197
198
  else {
198
199
  onSelectChange && onSelectChange([item]);
199
- setIsOpen(false);
200
+ if (closeOnSelect)
201
+ setIsOpen(false);
200
202
  }
201
203
  };
202
204
  const handleAllSelect = () => {
@@ -332,7 +334,13 @@ const Dropdown = ({ options, selectedValues, onChange, placeholder = "Select..."
332
334
  justifyContent: "space-between",
333
335
  cursor: "pointer",
334
336
  width: "100%",
335
- }, ref: clearIconRef, onClick: handleClick, children: [_jsx("span", { style: { display: isIcon ? withValue ? "inline-block" : "none" : "inline-block" }, children: selectedDisplay
337
+ }, ref: clearIconRef, onClick: handleClick, children: [_jsx("span", { style: {
338
+ display: isIcon
339
+ ? withValue
340
+ ? "inline-block"
341
+ : "none"
342
+ : "inline-block",
343
+ }, children: selectedDisplay
336
344
  ? selectedDisplay
337
345
  : displayValue
338
346
  ? wrapMiddle(displayValue, selectedCharLength)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megha-ui/react",
3
- "version": "1.2.440",
3
+ "version": "1.2.442",
4
4
  "description": "A collection of reusable UI components for React applications, built with TypeScript.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",