@megha-ui/react 1.2.363 → 1.2.365
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef, useState } from "react";
|
|
3
3
|
import { useDensity } from "../../context/DensityContext";
|
|
4
4
|
import Checkbox from "../checkbox";
|
|
@@ -7,7 +7,7 @@ import Block from "../block";
|
|
|
7
7
|
import Text from "../text";
|
|
8
8
|
import Button from "../button";
|
|
9
9
|
import { HiChevronDown } from "react-icons/hi";
|
|
10
|
-
import {
|
|
10
|
+
import { FaChevronDown, FaChevronUp } from "react-icons/fa";
|
|
11
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, isClear, ClearIcon, clearId, selectedDisplay, checkboxWrapper, isSort = true, onSelectChange, isLoading = false, onApplyChange, withTooltip = false, isCreatable = false, onCreate = () => { }, autoPosition = false, compactDisplay = false, ultraCompactDisplay = false, isGrouping = false, }) => {
|
|
12
12
|
var _a, _b;
|
|
13
13
|
const { density } = useDensity();
|
|
@@ -371,58 +371,49 @@ const Dropdown = ({ options, selectedValues, onChange, placeholder = "Select..."
|
|
|
371
371
|
backgroundColor: "var(--row-bg)",
|
|
372
372
|
display: "flex",
|
|
373
373
|
alignItems: "center",
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
}
|
|
418
|
-
}, children: [isMultiple && (_jsx("div", { style: { marginRight: "0.5rem" }, children: _jsx(Checkbox, { selected: intermediateValues.includes(option.value), onChange: () => { }, style: { pointerEvents: "none" }, noLabel: true, wrapperClass: checkboxWrapper }) })), _jsxs("div", { style: {
|
|
419
|
-
display: "flex",
|
|
420
|
-
alignItems: "start",
|
|
421
|
-
width: "100%",
|
|
422
|
-
}, children: [option.icon &&
|
|
423
|
-
option.isDelete &&
|
|
424
|
-
!option.isDelete && _jsx("span", { children: option.icon }), _jsx("span", { style: { margin: "0 0.5rem" }, children: option.label })] }), option.icon && option.isDelete && option.icon] }, String(option.value)));
|
|
425
|
-
})] }, gIndex)))) : (filteredOptions.map((option, index) => (_jsxs("li", { ref: (el) => {
|
|
374
|
+
justifyContent: "space-between",
|
|
375
|
+
}, children: [_jsx("div", { className: "flex items-center justify-center", onClick: () => setCollapsed(collapsed === groupOption.groupedValue ? "" : groupOption.groupedValue), style: {
|
|
376
|
+
background: "rgb(222, 222, 222)",
|
|
377
|
+
borderRadius: "0.25rem",
|
|
378
|
+
cursor: "pointer",
|
|
379
|
+
flexGrow: 0,
|
|
380
|
+
flexShrink: 0,
|
|
381
|
+
padding: "0.25rem",
|
|
382
|
+
}, children: collapsed === groupOption.groupedValue ? (_jsx(FaChevronUp, { style: {
|
|
383
|
+
height: "0.85rem",
|
|
384
|
+
width: "0.85rem",
|
|
385
|
+
} })) : (_jsx(FaChevronDown, { style: {
|
|
386
|
+
height: "0.85rem",
|
|
387
|
+
width: "0.85rem",
|
|
388
|
+
} })) }), _jsx("span", { children: groupOption.groupedValue })] }), collapsed === groupOption.groupedValue ? null : (_jsx(_Fragment, { children: groupOption.options.map((option, index) => {
|
|
389
|
+
let prevOptions = groupedOptions.filter((item, index) => index < gIndex);
|
|
390
|
+
prevOptions = [
|
|
391
|
+
...prevOptions.map((item) => item.options),
|
|
392
|
+
];
|
|
393
|
+
prevOptions = prevOptions.flatMap((item) => item);
|
|
394
|
+
const refIndex = gIndex > 0 ? prevOptions.length + index : index;
|
|
395
|
+
return (_jsxs("li", { ref: (el) => {
|
|
396
|
+
optionRefs.current[refIndex] = el;
|
|
397
|
+
}, id: `${refIndex}`, onClick: (e) => onSelectChange
|
|
398
|
+
? handleItemSelect(option, option.disabled || false)
|
|
399
|
+
: handleSelect(option.value, option.disabled || false), style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, listItemStyle), { display: "flex", alignItems: "center" }), (refIndex === highlightIndex
|
|
400
|
+
? listItemHoverStyle
|
|
401
|
+
: {})), (option.disabled ? listItemDisabledStyle : {})), (refIndex !== highlightIndex &&
|
|
402
|
+
!isMultiple &&
|
|
403
|
+
intermediateValues.includes(option.value)
|
|
404
|
+
? selectedItemStyle
|
|
405
|
+
: {})), { wordWrap: "break-word", textWrap: "wrap", justifyContent: "space-between", padding: "0.75rem 1rem 0.75rem 2.5rem" }), onMouseEnter: (e) => {
|
|
406
|
+
if (!option.disabled) {
|
|
407
|
+
setHighlightIndex(refIndex);
|
|
408
|
+
}
|
|
409
|
+
}, children: [isMultiple && (_jsx("div", { style: { marginRight: "0.5rem" }, children: _jsx(Checkbox, { selected: intermediateValues.includes(option.value), onChange: () => { }, style: { pointerEvents: "none" }, noLabel: true, wrapperClass: checkboxWrapper }) })), _jsxs("div", { style: {
|
|
410
|
+
display: "flex",
|
|
411
|
+
alignItems: "start",
|
|
412
|
+
width: "100%",
|
|
413
|
+
}, children: [option.icon &&
|
|
414
|
+
option.isDelete &&
|
|
415
|
+
!option.isDelete && _jsx("span", { children: option.icon }), _jsx("span", { style: { margin: "0 0.5rem" }, children: option.label })] }), option.icon && option.isDelete && option.icon] }, String(option.value)));
|
|
416
|
+
}) }))] }, gIndex)))) : (filteredOptions.map((option, index) => (_jsxs("li", { ref: (el) => {
|
|
426
417
|
optionRefs.current[index] = el;
|
|
427
418
|
}, onClick: (e) => onSelectChange
|
|
428
419
|
? handleItemSelect(option, option.disabled || false)
|
package/package.json
CHANGED