@megha-ui/react 1.2.599 → 1.2.601

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
  labelClass?: string;
16
+ labelAlignment?: "vertical" | "horizontal";
16
17
  onChange: (values: (string | number)[]) => void;
17
18
  closeOnSelect?: boolean;
18
19
  placeholder?: string;
@@ -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, labelClass, 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, }) => {
11
+ const Dropdown = ({ options, selectedValues, onChange, placeholder = "Select...", isMultiple = false, isSelectAll = false, className, style, labelAlignment = "vertical", labelFontSize, labelFontWeight, labelMarginBottom, labelClass, 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);
@@ -320,6 +320,8 @@ const Dropdown = ({ options, selectedValues, onChange, placeholder = "Select..."
320
320
  marginTop,
321
321
  marginRight,
322
322
  marginLeft,
323
+ display: "flex",
324
+ flexDirection: labelAlignment === "horizontal" ? "row" : "column",
323
325
  }, children: [label && (_jsxs("p", { style: labelStyle, className: labelClass, children: [label, required && _jsx("span", { style: asteriskStyle, children: " *" })] })), _jsxs("div", { ref: wrapperRef, className: `${className}`, style: Object.assign(Object.assign(Object.assign({ border, borderRadius: 4 }, (isIcon ? {} : { padding: "0 0.5rem" })), { alignItems: "center", display: "flex", minHeight: `var(--control-min-height, ${ultraCompactDisplay
324
326
  ? "1.5rem"
325
327
  : compactDisplay
@@ -1354,121 +1354,117 @@ withCard = false, cardClassName, cardHeader, title, headerLeft, headerRight, sub
1354
1354
  display: "flex",
1355
1355
  alignItems: "center",
1356
1356
  flexWrap: "wrap",
1357
- justifyContent: globalSearch || filterDetails.hasFilters || sortDetails.hasSort
1358
- ? "space-between"
1359
- : "end",
1360
- }, children: [_jsxs("div", { style: { display: "flex", alignItems: "center", flexWrap: "wrap" }, children: [globalSearch && (_jsx("div", { style: { width: expandedGI ? 300 : "fit-content" }, children: _jsx(GlobalSearchChiProps, { expanded: expandedGI, setExpanded: setExpandedGI, globalInputSearch: globalInputSearch, setGlobalInputSearch: setGlobalInputSearch, chips: chips, setChips: setChips, inputValue: inputValue, setInputValue: setInputValue, shouldClose: !globalSearchOpen }) })), filterDetails.hasFilters && (_jsx("div", { title: "Clear All Filters", onClick: () => clearAllFilter(), style: {
1361
- cursor: "pointer",
1362
- marginLeft: "0.75rem",
1363
- color: "var(--clear-color)",
1364
- }, children: _jsx(MdFilterAltOff, { size: 18 }) })), sortDetails.hasSort && (_jsx("div", { title: "Clear All Sorts", onClick: () => {
1365
- // setChanged((prev) => [...prev, "sorts"]);
1366
- setSortQueries({});
1367
- }, style: {
1368
- cursor: "pointer",
1369
- marginLeft: "0.75rem",
1370
- transform: "rotate(-90deg)",
1371
- color: "var(--clear-color)",
1372
- }, children: _jsx(TbAntennaBarsOff, { size: 18 }) })), summarise.hasSummarise && (_jsx("div", { title: "Clear All Sorts", onClick: () => {
1373
- setSummariseKeys({});
1374
- setSummariseDetails({});
1375
- // setChanged((prev) => [...prev, "summary"]);
1376
- }, style: {
1377
- cursor: "pointer",
1378
- marginLeft: "0.75rem",
1379
- color: "var(--clear-color)",
1380
- }, children: _jsx(TbCalculatorOff, {}) })), fixedColumns.map((column) => {
1381
- const selectedValues = fixedFilterValues[column.key]
1382
- ? fixedFilterValues[column.key].map((item) => item.toString())
1383
- : [];
1384
- let options = [
1385
- ...data
1386
- .filter((item) => item[column.key])
1387
- .map((data) => {
1388
- var _a;
1389
- return data[column.key] && data[column.key].value
1390
- ? (_a = data[column.key].value) === null || _a === void 0 ? void 0 : _a.toString()
1391
- : "";
1392
- }),
1393
- ].sort((a, b) => {
1394
- var _a, _b;
1395
- return comparator(a, b, (_a = column.dataType) !== null && _a !== void 0 ? _a : "", (_b = column.fixedFilterOrder) !== null && _b !== void 0 ? _b : "asc");
1396
- });
1397
- selectedValues.forEach((item) => {
1398
- if (!options.includes(item)) {
1399
- options.push(item);
1400
- }
1401
- });
1402
- options = [...new Set(options)];
1403
- if (!column.hidden) {
1404
- return (_jsx("div", { style: {
1405
- position: "relative",
1406
- width: "18rem",
1407
- marginLeft: "0.75rem",
1408
- }, children: _jsx(Dropdown, { options: options.map((option) => ({
1409
- label: option,
1410
- value: option,
1411
- })), label: column.label, placeholder: "Select", selectedValues: selectedValues, onChange: (selected) => {
1412
- if (column.fixedFilter !== "multi-select") {
1413
- const values = selected
1414
- .filter((item) => item)
1415
- .map((item) => item.toString());
1416
- const updatedValues = Object.assign(Object.assign({}, fixedFilterValues), { [column.key]: values });
1417
- setFixedFilterValues(updatedValues);
1418
- updateFixedFilterValues &&
1419
- updateFixedFilterValues(updatedValues);
1420
- }
1421
- }, onApplyChange: column.fixedFilter === "multi-select"
1422
- ? (selected) => {
1423
- if (column.fixedFilter === "multi-select") {
1424
- const values = selected
1425
- .filter((item) => item)
1426
- .map((item) => item.toString());
1427
- const updatedValues = Object.assign(Object.assign({}, fixedFilterValues), { [column.key]: values });
1428
- setFixedFilterValues(updatedValues);
1429
- updateFixedFilterValues &&
1430
- updateFixedFilterValues(updatedValues);
1431
- }
1432
- }
1433
- : undefined, isSort: column.fixedFilterOrder ? false : undefined, isClear: true, searchEnabled: true, dropdownListWidth: "max-content", className: "h-8 mt-2", isMultiple: column.fixedFilter === "multi-select" }) }, column.key));
1434
- }
1435
- return null;
1436
- })] }), _jsxs("div", { style: { display: "flex", alignItems: "center", flexWrap: "wrap" }, children: [isSummarise && (_jsx("div", { onClick: () => setSummariseAvailable((prev) => !prev), style: {
1437
- cursor: "pointer",
1357
+ }, children: [globalSearch && (_jsx("div", { style: { width: expandedGI ? 300 : "fit-content" }, children: _jsx(GlobalSearchChiProps, { expanded: expandedGI, setExpanded: setExpandedGI, globalInputSearch: globalInputSearch, setGlobalInputSearch: setGlobalInputSearch, chips: chips, setChips: setChips, inputValue: inputValue, setInputValue: setInputValue, shouldClose: !globalSearchOpen }) })), filterDetails.hasFilters && (_jsx("div", { title: "Clear All Filters", onClick: () => clearAllFilter(), style: {
1358
+ cursor: "pointer",
1359
+ marginLeft: "0.75rem",
1360
+ color: "var(--clear-color)",
1361
+ }, children: _jsx(MdFilterAltOff, { size: 18 }) })), sortDetails.hasSort && (_jsx("div", { title: "Clear All Sorts", onClick: () => {
1362
+ // setChanged((prev) => [...prev, "sorts"]);
1363
+ setSortQueries({});
1364
+ }, style: {
1365
+ cursor: "pointer",
1366
+ marginLeft: "0.75rem",
1367
+ transform: "rotate(-90deg)",
1368
+ color: "var(--clear-color)",
1369
+ }, children: _jsx(TbAntennaBarsOff, { size: 18 }) })), summarise.hasSummarise && (_jsx("div", { title: "Clear All Sorts", onClick: () => {
1370
+ setSummariseKeys({});
1371
+ setSummariseDetails({});
1372
+ // setChanged((prev) => [...prev, "summary"]);
1373
+ }, style: {
1374
+ cursor: "pointer",
1375
+ marginLeft: "0.75rem",
1376
+ color: "var(--clear-color)",
1377
+ }, children: _jsx(TbCalculatorOff, {}) })), fixedColumns.map((column) => {
1378
+ const selectedValues = fixedFilterValues[column.key]
1379
+ ? fixedFilterValues[column.key].map((item) => item.toString())
1380
+ : [];
1381
+ let options = [
1382
+ ...data
1383
+ .filter((item) => item[column.key])
1384
+ .map((data) => {
1385
+ var _a;
1386
+ return data[column.key] && data[column.key].value
1387
+ ? (_a = data[column.key].value) === null || _a === void 0 ? void 0 : _a.toString()
1388
+ : "";
1389
+ }),
1390
+ ].sort((a, b) => {
1391
+ var _a, _b;
1392
+ return comparator(a, b, (_a = column.dataType) !== null && _a !== void 0 ? _a : "", (_b = column.fixedFilterOrder) !== null && _b !== void 0 ? _b : "asc");
1393
+ });
1394
+ selectedValues.forEach((item) => {
1395
+ if (!options.includes(item)) {
1396
+ options.push(item);
1397
+ }
1398
+ });
1399
+ options = [...new Set(options)];
1400
+ if (!column.hidden) {
1401
+ return (_jsx("div", { style: {
1402
+ width: "18rem",
1438
1403
  marginLeft: "0.75rem",
1439
- }, children: SummariseIcon ? (SummariseIcon) : summariseAvailable ? (_jsx(TbCalculatorFilled, { color: summarizeColor, size: 18 })) : (_jsx(TbCalculator, { size: 18 })) })), showHideAvailable && (_jsx("div", { onClick: openSetting, style: { cursor: "pointer", marginLeft: "0.75rem" }, children: SettingIcon ? SettingIcon : _jsx(FiEye, { size: 18 }) })), exportAvailable && (_jsx("div", { onClick: handleExport, style: { cursor: "pointer", marginLeft: "0.75rem" }, children: ExportIcon ? ExportIcon : _jsx(FiShare, { size: 16 }) })), _jsx("div", { onClick: () => setHideDuplicates((prev) => !prev), style: { cursor: "pointer", marginLeft: "0.75rem" }, title: hideDuplicates ? "Show Duplicates" : "Hide Duplicates", children: hideDuplicates ? _jsx(TbCopyOff, { size: 18 }) : _jsx(TbCopy, { size: 18 }) }), fullScreen && (_jsx("div", { onClick: toggleFullScreen, style: { cursor: "pointer", marginLeft: "0.75rem" }, children: isFullScreen ? (_jsx(MdFullscreenExit, { size: 20 })) : (_jsx(MdFullscreen, { size: 20 })) })), freezeColumnsAvailable && (_jsx("div", { onClick: toggleCollapse, style: { cursor: "pointer", marginLeft: "0.75rem" }, children: isCollapsed ? (_jsx(FiChevronsRight, { size: 20 })) : (_jsx(FiChevronsLeft, { size: 20 })) })), (filterDetails.filtersUpdated ||
1440
- sortDetails.sortUpdated ||
1441
- summarise.summariseUpdated ||
1442
- gridGroupBy !== (groupBy || "")) &&
1443
- handleSaveAsView &&
1444
- saveAsNewView && (_jsx("div", { onClick: () => handleSaveAsView({
1445
- globalInputSearch,
1446
- searchQueries,
1447
- uniqueSearch,
1448
- globalSearchOp,
1449
- searchOp,
1450
- groupBy: gridGroupBy,
1451
- sortQueries: sortQueries,
1452
- summariseKeys: summariseKeys,
1453
- }), style: {
1454
- marginLeft: 6,
1455
- cursor: "pointer",
1456
- }, title: "save", children: saveAsViewIcon ? saveAsViewIcon : _jsx(MdSave, {}) })), hasCustomOperation && customOperation
1457
- ? customOperation
1458
- : hasCustomOperation &&
1459
- resizable && (_jsx("button", { style: {
1460
- color: "#FFFFFF",
1461
- marginLeft: 6,
1462
- backgroundColor: JSON.stringify(gridColumns) === JSON.stringify(columns)
1463
- ? "#D3D3D3"
1464
- : "#2377BA",
1465
- borderColor: "#2377BA",
1466
- padding: "0.5rem 1rem",
1467
- borderRadius: "0.5rem",
1468
- cursor: JSON.stringify(gridColumns) === JSON.stringify(columns)
1469
- ? "not-allowed"
1470
- : "",
1471
- }, disabled: JSON.stringify(gridColumns) === JSON.stringify(columns), onClick: () => updateGridColumns && updateGridColumns(gridColumns), children: "Save preview" }))] })] }), gridGroupBy && (_jsxs("div", { style: {
1404
+ }, children: _jsx(Dropdown, { options: options.map((option) => ({
1405
+ label: option,
1406
+ value: option,
1407
+ })), labelAlignment: "horizontal", label: column.label, placeholder: "Select", selectedValues: selectedValues, onChange: (selected) => {
1408
+ if (column.fixedFilter !== "multi-select") {
1409
+ const values = selected
1410
+ .filter((item) => item)
1411
+ .map((item) => item.toString());
1412
+ const updatedValues = Object.assign(Object.assign({}, fixedFilterValues), { [column.key]: values });
1413
+ setFixedFilterValues(updatedValues);
1414
+ updateFixedFilterValues &&
1415
+ updateFixedFilterValues(updatedValues);
1416
+ }
1417
+ }, onApplyChange: column.fixedFilter === "multi-select"
1418
+ ? (selected) => {
1419
+ if (column.fixedFilter === "multi-select") {
1420
+ const values = selected
1421
+ .filter((item) => item)
1422
+ .map((item) => item.toString());
1423
+ const updatedValues = Object.assign(Object.assign({}, fixedFilterValues), { [column.key]: values });
1424
+ setFixedFilterValues(updatedValues);
1425
+ updateFixedFilterValues &&
1426
+ updateFixedFilterValues(updatedValues);
1427
+ }
1428
+ }
1429
+ : undefined, isSort: column.fixedFilterOrder ? false : undefined, isClear: true, searchEnabled: true, dropdownListWidth: "max-content", className: "h-8 mt-2", isMultiple: column.fixedFilter === "multi-select" }) }, column.key));
1430
+ }
1431
+ return null;
1432
+ }), isSummarise && (_jsx("div", { onClick: () => setSummariseAvailable((prev) => !prev), style: {
1433
+ cursor: "pointer",
1434
+ marginLeft: "0.75rem",
1435
+ }, children: SummariseIcon ? (SummariseIcon) : summariseAvailable ? (_jsx(TbCalculatorFilled, { color: summarizeColor, size: 18 })) : (_jsx(TbCalculator, { size: 18 })) })), showHideAvailable && (_jsx("div", { onClick: openSetting, style: { cursor: "pointer", marginLeft: "0.75rem" }, children: SettingIcon ? SettingIcon : _jsx(FiEye, { size: 18 }) })), exportAvailable && (_jsx("div", { onClick: handleExport, style: { cursor: "pointer", marginLeft: "0.75rem" }, children: ExportIcon ? ExportIcon : _jsx(FiShare, { size: 16 }) })), _jsx("div", { onClick: () => setHideDuplicates((prev) => !prev), style: { cursor: "pointer", marginLeft: "0.75rem" }, title: hideDuplicates ? "Show Duplicates" : "Hide Duplicates", children: hideDuplicates ? _jsx(TbCopyOff, { size: 18 }) : _jsx(TbCopy, { size: 18 }) }), fullScreen && (_jsx("div", { onClick: toggleFullScreen, style: { cursor: "pointer", marginLeft: "0.75rem" }, children: isFullScreen ? (_jsx(MdFullscreenExit, { size: 20 })) : (_jsx(MdFullscreen, { size: 20 })) })), freezeColumnsAvailable && (_jsx("div", { onClick: toggleCollapse, style: { cursor: "pointer", marginLeft: "0.75rem" }, children: isCollapsed ? (_jsx(FiChevronsRight, { size: 20 })) : (_jsx(FiChevronsLeft, { size: 20 })) })), (filterDetails.filtersUpdated ||
1436
+ sortDetails.sortUpdated ||
1437
+ summarise.summariseUpdated ||
1438
+ gridGroupBy !== (groupBy || "")) &&
1439
+ handleSaveAsView &&
1440
+ saveAsNewView && (_jsx("div", { onClick: () => handleSaveAsView({
1441
+ globalInputSearch,
1442
+ searchQueries,
1443
+ uniqueSearch,
1444
+ globalSearchOp,
1445
+ searchOp,
1446
+ groupBy: gridGroupBy,
1447
+ sortQueries: sortQueries,
1448
+ summariseKeys: summariseKeys,
1449
+ }), style: {
1450
+ marginLeft: 6,
1451
+ cursor: "pointer",
1452
+ }, title: "save", children: saveAsViewIcon ? saveAsViewIcon : _jsx(MdSave, {}) })), hasCustomOperation && customOperation
1453
+ ? customOperation
1454
+ : hasCustomOperation &&
1455
+ resizable && (_jsx("button", { style: {
1456
+ color: "#FFFFFF",
1457
+ marginLeft: 6,
1458
+ backgroundColor: JSON.stringify(gridColumns) === JSON.stringify(columns)
1459
+ ? "#D3D3D3"
1460
+ : "#2377BA",
1461
+ borderColor: "#2377BA",
1462
+ padding: "0.5rem 1rem",
1463
+ borderRadius: "0.5rem",
1464
+ cursor: JSON.stringify(gridColumns) === JSON.stringify(columns)
1465
+ ? "not-allowed"
1466
+ : "",
1467
+ }, disabled: JSON.stringify(gridColumns) === JSON.stringify(columns), onClick: () => updateGridColumns && updateGridColumns(gridColumns), children: "Save preview" }))] }), gridGroupBy && (_jsxs("div", { style: {
1472
1468
  width: "100%",
1473
1469
  flexWrap: "wrap",
1474
1470
  display: "flex",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megha-ui/react",
3
- "version": "1.2.599",
3
+ "version": "1.2.601",
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",