pixelize-design-library 2.2.106 → 2.2.108

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,31 @@
1
+ import React from 'react';
2
+ import { useCustomTheme } from "../Theme/useCustomTheme";
3
+
4
+ const DefaultLogo = () => {
5
+ const theme = useCustomTheme();
6
+ return (
7
+ <svg
8
+ width="12.09"
9
+ height="15.95"
10
+ viewBox="0 0 31 29"
11
+ fill="none"
12
+ xmlns="http://www.w3.org/2000/svg"
13
+ >
14
+ <path
15
+ d="M30.4999 6.26137V7.81058H15.9761H14.8787V22.8508V28.8862H12.5226C9.6824 28.8862 7.32632 26.4656 7.06812 23.3995C7.06812 23.2381 7.06812 23.0444 7.06812 22.8508V18.3323C7.06812 18.2677 7.06812 18.2032 7.06812 18.1063V15.5889V6.2291C7.06812 2.80793 9.84378 -5.72205e-06 13.2972 -5.72205e-06H24.8517C28.0147 0.355021 30.4676 3.00158 30.4676 6.2291L30.4999 6.26137Z"
16
+ fill={theme.colors.black}
17
+ />
18
+ <path
19
+ d="M7.10053 23.3672H7.03598C5.16402 23.2381 3.48571 22.4635 2.25926 21.3338C0.871428 20.0428 0 18.2677 0 16.3312V15.6211H7.06825V18.1386C7.06825 18.2032 7.06825 18.2677 7.06825 18.3645V22.883C7.06825 23.0767 7.06825 23.2381 7.06825 23.4317L7.10053 23.3672Z"
20
+ fill={theme.colors.black}
21
+ />
22
+ <path
23
+ d="M30.4678 12.0063V15.6211V17.1703C30.4678 20.6238 26.272 23.3994 21.0757 23.3994H14.8789V22.8508V15.6211H22.6572V7.81056C22.6895 7.81056 30.5001 7.81056 30.5001 7.81056V11.5868C30.5001 11.7159 30.5001 11.8772 30.5001 12.0063H30.4678Z"
24
+ fill={theme.colors.black}
25
+ />
26
+ </svg>
27
+
28
+ )
29
+ };
30
+
31
+ export default DefaultLogo;
@@ -1,3 +1,3 @@
1
1
  import React from "react";
2
2
  import { CheckboxProps } from "./CheckboxProps";
3
- export default function CheckBox({ label, spacing, isInvalid, color, iconColor, iconSize, isChecked, isIndeterminate, onChange, isDisabled, size, value, defaultChecked, sx, isRequired, error, errorMessage, isInformation, informationMessage, id, helperText, onClick, }: CheckboxProps): React.JSX.Element;
3
+ export default function CheckBox({ label, labelFontSize, showLabelTooltip, labelTooltip, labelClampLines, spacing, isInvalid, color, iconColor, iconSize, isChecked, isIndeterminate, onChange, isDisabled, size, value, defaultChecked, sx, isRequired, error, errorMessage, isInformation, informationMessage, id, helperText, onClick, }: CheckboxProps): React.JSX.Element;
@@ -10,10 +10,10 @@ var FormLabel_1 = require("../Common/FormLabel");
10
10
  var ErrorMessage_1 = __importDefault(require("../Common/ErrorMessage"));
11
11
  var HelperText_1 = __importDefault(require("../Common/HelperText"));
12
12
  function CheckBox(_a) {
13
- var label = _a.label, spacing = _a.spacing, isInvalid = _a.isInvalid, color = _a.color, iconColor = _a.iconColor, iconSize = _a.iconSize, isChecked = _a.isChecked, isIndeterminate = _a.isIndeterminate, onChange = _a.onChange, isDisabled = _a.isDisabled, size = _a.size, value = _a.value, defaultChecked = _a.defaultChecked, sx = _a.sx, isRequired = _a.isRequired, error = _a.error, errorMessage = _a.errorMessage, isInformation = _a.isInformation, informationMessage = _a.informationMessage, id = _a.id, helperText = _a.helperText, onClick = _a.onClick;
13
+ var label = _a.label, labelFontSize = _a.labelFontSize, showLabelTooltip = _a.showLabelTooltip, labelTooltip = _a.labelTooltip, labelClampLines = _a.labelClampLines, spacing = _a.spacing, isInvalid = _a.isInvalid, color = _a.color, iconColor = _a.iconColor, iconSize = _a.iconSize, isChecked = _a.isChecked, isIndeterminate = _a.isIndeterminate, onChange = _a.onChange, isDisabled = _a.isDisabled, size = _a.size, value = _a.value, defaultChecked = _a.defaultChecked, sx = _a.sx, isRequired = _a.isRequired, error = _a.error, errorMessage = _a.errorMessage, isInformation = _a.isInformation, informationMessage = _a.informationMessage, id = _a.id, helperText = _a.helperText, onClick = _a.onClick;
14
14
  var theme = (0, useCustomTheme_1.useCustomTheme)();
15
15
  return (react_1.default.createElement(react_1.default.Fragment, null,
16
- react_1.default.createElement(react_2.Checkbox, { onClick: onClick, spacing: spacing, isInvalid: isInvalid, colorScheme: color, iconColor: iconColor, iconSize: iconSize, isChecked: isChecked, isIndeterminate: isIndeterminate, onChange: onChange, isDisabled: isDisabled, size: size, value: value, defaultChecked: defaultChecked, borderColor: theme.colors.gray[500], sx: sx, display: "flex", alignItems: "inherit" }, label && (react_1.default.createElement(FormLabel_1.TextLabel, { label: label, id: id, isInformation: isInformation, informationMessage: informationMessage, isRequired: isRequired }))),
16
+ react_1.default.createElement(react_2.Checkbox, { onClick: onClick, spacing: spacing, isInvalid: isInvalid, colorScheme: color, iconColor: iconColor, iconSize: iconSize, isChecked: isChecked, isIndeterminate: isIndeterminate, onChange: onChange, isDisabled: isDisabled, size: size, value: value, defaultChecked: defaultChecked, borderColor: theme.colors.gray[500], sx: sx, display: "flex", alignItems: "inherit" }, label && (react_1.default.createElement(FormLabel_1.TextLabel, { label: label, id: id, fontSize: labelFontSize, showTooltip: showLabelTooltip, tooltipLabel: labelTooltip, clampLines: labelClampLines, isInformation: isInformation, informationMessage: informationMessage, isRequired: isRequired }))),
17
17
  error && react_1.default.createElement(ErrorMessage_1.default, { errorMessage: errorMessage }),
18
18
  helperText && !error && react_1.default.createElement(HelperText_1.default, { helperText: helperText })));
19
19
  }
@@ -1,6 +1,10 @@
1
1
  import { CheckboxProps as ChakraButtonProps } from "@chakra-ui/react";
2
2
  export type CheckboxProps = Pick<ChakraButtonProps, "spacing" | "isInvalid" | "size" | "iconColor" | "iconSize" | "isChecked" | "isIndeterminate" | "onChange" | "isDisabled" | "value" | "defaultChecked" | "sx" | "onClick"> & {
3
3
  label?: string;
4
+ labelFontSize?: string;
5
+ showLabelTooltip?: boolean;
6
+ labelTooltip?: string;
7
+ labelClampLines?: number;
4
8
  width?: string | number;
5
9
  variant?: "solid" | "outline" | "ghost" | "link" | "unstyled";
6
10
  color?: "gray" | "red" | "orange" | "yellow" | "green" | "teal" | "blue" | "cyan" | "purple" | "pink" | "whiteAlpha" | "blackAlpha";
@@ -1,8 +1,12 @@
1
1
  import React from "react";
2
- export declare const TextLabel: ({ label, id, isRequired, isInformation, informationMessage, }: {
2
+ export declare const TextLabel: ({ label, id, isRequired, isInformation, informationMessage, fontSize, showTooltip, tooltipLabel, clampLines, }: {
3
3
  label: string;
4
4
  id?: string | undefined;
5
5
  isInformation?: boolean | undefined;
6
6
  informationMessage?: string | undefined;
7
7
  isRequired?: boolean | undefined;
8
+ fontSize?: string | undefined;
9
+ showTooltip?: boolean | undefined;
10
+ tooltipLabel?: string | undefined;
11
+ clampLines?: number | undefined;
8
12
  }) => React.JSX.Element;
@@ -9,12 +9,21 @@ var react_2 = require("@chakra-ui/react");
9
9
  var useCustomTheme_1 = require("../../Theme/useCustomTheme");
10
10
  var lucide_react_1 = require("lucide-react");
11
11
  var TextLabel = function (_a) {
12
- var label = _a.label, id = _a.id, _b = _a.isRequired, isRequired = _b === void 0 ? false : _b, _c = _a.isInformation, isInformation = _c === void 0 ? false : _c, _d = _a.informationMessage, informationMessage = _d === void 0 ? "" : _d;
12
+ var label = _a.label, id = _a.id, _b = _a.isRequired, isRequired = _b === void 0 ? false : _b, _c = _a.isInformation, isInformation = _c === void 0 ? false : _c, _d = _a.informationMessage, informationMessage = _d === void 0 ? "" : _d, fontSize = _a.fontSize, showTooltip = _a.showTooltip, tooltipLabel = _a.tooltipLabel, clampLines = _a.clampLines;
13
13
  var theme = (0, useCustomTheme_1.useCustomTheme)();
14
+ var clampStyles = clampLines ? {
15
+ display: "-webkit-box",
16
+ WebkitLineClamp: clampLines,
17
+ WebkitBoxOrient: "vertical",
18
+ overflow: "hidden",
19
+ textOverflow: "ellipsis",
20
+ whiteSpace: "normal",
21
+ } : {};
14
22
  return (react_1.default.createElement(react_2.Box, null,
15
- react_1.default.createElement(react_2.FormLabel, { htmlFor: id !== null && id !== void 0 ? id : label, color: theme.colors.gray[600], fontWeight: 400, fontSize: "0.875rem", mb: "0" },
23
+ react_1.default.createElement(react_2.FormLabel, { htmlFor: id !== null && id !== void 0 ? id : label, color: theme.colors.gray[600], fontWeight: 400, fontSize: fontSize !== null && fontSize !== void 0 ? fontSize : "0.875rem", mb: "0" },
16
24
  react_1.default.createElement(react_2.Box, { as: "span", display: "inline-flex", alignItems: "center", gap: "0.35rem" },
17
- label,
25
+ showTooltip ? (react_1.default.createElement(react_2.Tooltip, { label: tooltipLabel !== null && tooltipLabel !== void 0 ? tooltipLabel : label, hasArrow: true, placement: "top", bg: theme.colors.gray[600], color: theme.colors.white, fontSize: "0.75rem" },
26
+ react_1.default.createElement(react_2.Box, { as: "span", sx: clampStyles }, label))) : (react_1.default.createElement(react_2.Box, { as: "span", sx: clampStyles }, label)),
18
27
  isRequired && (react_1.default.createElement("span", { style: { color: theme.colors.semantic.error[500] } }, "*")),
19
28
  isInformation && informationMessage && (react_1.default.createElement(react_2.Tooltip, { label: informationMessage, hasArrow: true, placement: "top", bg: theme.colors.gray[600], color: theme.colors.white, fontSize: "0.75rem" },
20
29
  react_1.default.createElement(react_2.Icon, { as: lucide_react_1.InfoIcon, color: theme.colors.gray[500], boxSize: 4 })))))));
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
2
  import { ChakraRadioProps, ChakraRadioGroupProps } from "./RadioButtonProps";
3
- declare const RadioButton: ({ label, colorScheme, isChecked, onChange, isDisabled, size, value, defaultChecked, }: ChakraRadioProps) => React.JSX.Element;
4
- declare const RadioButtonGroup: ({ options, onChange, value, defaultValue, isDisabled, size, colorScheme, }: ChakraRadioGroupProps) => React.JSX.Element;
3
+ declare const RadioButton: ({ label, colorScheme, isChecked, onChange, isDisabled, size, value, defaultChecked, labelFontSize, labelClampLines, showLabelTooltip, labelTooltip, }: ChakraRadioProps) => React.JSX.Element;
4
+ declare const RadioButtonGroup: ({ options, onChange, value, defaultValue, isDisabled, size, colorScheme, spacing, direction, align, labelFontSize, labelClampLines, showLabelTooltip, }: ChakraRadioGroupProps) => React.JSX.Element;
5
5
  export { RadioButton, RadioButtonGroup };
@@ -7,8 +7,9 @@ exports.RadioButtonGroup = exports.RadioButton = void 0;
7
7
  var react_1 = __importDefault(require("react"));
8
8
  var react_2 = require("@chakra-ui/react");
9
9
  var useCustomTheme_1 = require("../../Theme/useCustomTheme");
10
+ var FormLabel_1 = require("../Common/FormLabel");
10
11
  var RadioButton = function (_a) {
11
- var label = _a.label, colorScheme = _a.colorScheme, isChecked = _a.isChecked, onChange = _a.onChange, isDisabled = _a.isDisabled, size = _a.size, value = _a.value, defaultChecked = _a.defaultChecked;
12
+ var label = _a.label, colorScheme = _a.colorScheme, isChecked = _a.isChecked, onChange = _a.onChange, isDisabled = _a.isDisabled, size = _a.size, value = _a.value, defaultChecked = _a.defaultChecked, _b = _a.labelFontSize, labelFontSize = _b === void 0 ? "0.75rem" : _b, _c = _a.labelClampLines, labelClampLines = _c === void 0 ? 2 : _c, _d = _a.showLabelTooltip, showLabelTooltip = _d === void 0 ? (label || "").length > 18 : _d, _e = _a.labelTooltip, labelTooltip = _e === void 0 ? label : _e;
12
13
  var theme = (0, useCustomTheme_1.useCustomTheme)();
13
14
  return (react_1.default.createElement(react_2.Radio, { colorScheme: colorScheme, isChecked: isChecked, onChange: onChange, isDisabled: isDisabled, size: size, value: value, defaultChecked: defaultChecked, sx: {
14
15
  "&[data-checked]": {
@@ -16,16 +17,19 @@ var RadioButton = function (_a) {
16
17
  borderColor: theme.colors.primary[500]
17
18
  },
18
19
  "&[data-checked]:hover": {
19
- backgroundColor: theme.colors.primary[300],
20
- borderColor: theme.colors.primary[300], // Change this to your desired hover color
20
+ backgroundColor: theme.colors.primary[500],
21
+ borderColor: theme.colors.primary[500],
22
+ boxShadow: "0 0 0 2px ".concat(theme.colors.primary[200]),
21
23
  },
24
+ // alignItems: "flex-start",
25
+ mt: "2px",
22
26
  } },
23
- react_1.default.createElement(react_2.Box, { as: "span" }, label)));
27
+ react_1.default.createElement(FormLabel_1.TextLabel, { label: label, fontSize: labelFontSize, showTooltip: showLabelTooltip, tooltipLabel: labelTooltip, clampLines: labelClampLines })));
24
28
  };
25
29
  exports.RadioButton = RadioButton;
26
30
  var RadioButtonGroup = function (_a) {
27
- var options = _a.options, onChange = _a.onChange, value = _a.value, defaultValue = _a.defaultValue, isDisabled = _a.isDisabled, size = _a.size, colorScheme = _a.colorScheme;
31
+ var options = _a.options, onChange = _a.onChange, value = _a.value, defaultValue = _a.defaultValue, isDisabled = _a.isDisabled, size = _a.size, colorScheme = _a.colorScheme, spacing = _a.spacing, _b = _a.direction, direction = _b === void 0 ? "row" : _b, _c = _a.align, align = _c === void 0 ? "" : _c, labelFontSize = _a.labelFontSize, labelClampLines = _a.labelClampLines, showLabelTooltip = _a.showLabelTooltip;
28
32
  return (react_1.default.createElement(react_2.RadioGroup, { onChange: onChange, value: value, defaultValue: defaultValue },
29
- react_1.default.createElement(react_2.Stack, { direction: "row", spacing: 4 }, options.map(function (option) { return (react_1.default.createElement(RadioButton, { key: option.id, label: option.label, value: option.id, isDisabled: isDisabled, size: size, colorScheme: colorScheme })); }))));
33
+ react_1.default.createElement(react_2.Stack, { direction: direction, spacing: spacing || "2", align: align }, options.map(function (option) { return (react_1.default.createElement(RadioButton, { key: option.id, label: option.label, value: option.id, isDisabled: isDisabled, size: size, colorScheme: colorScheme, labelFontSize: labelFontSize, labelClampLines: labelClampLines, showLabelTooltip: typeof showLabelTooltip === 'function' ? showLabelTooltip(option) : showLabelTooltip })); }))));
30
34
  };
31
35
  exports.RadioButtonGroup = RadioButtonGroup;
@@ -1,6 +1,10 @@
1
1
  import { RadioProps, RadioGroupProps } from '@chakra-ui/react';
2
2
  export type ChakraRadioProps = Pick<RadioProps, "size" | "colorScheme" | "isChecked" | "onChange" | "isDisabled" | "value" | "defaultChecked"> & {
3
3
  label: string;
4
+ labelFontSize?: string;
5
+ labelClampLines?: number;
6
+ showLabelTooltip?: boolean;
7
+ labelTooltip?: string;
4
8
  };
5
9
  export type ChakraRadioGroupProps = Pick<RadioGroupProps, "size" | "colorScheme" | "isDisabled" | "defaultValue" | "value"> & {
6
10
  options: {
@@ -8,4 +12,13 @@ export type ChakraRadioGroupProps = Pick<RadioGroupProps, "size" | "colorScheme"
8
12
  id: string;
9
13
  }[];
10
14
  onChange?: (value: string) => void;
15
+ spacing?: string;
16
+ direction?: "row" | "column";
17
+ align?: "start" | "center" | "end" | "";
18
+ labelFontSize?: string;
19
+ labelClampLines?: number;
20
+ showLabelTooltip?: boolean | ((item: {
21
+ label: string;
22
+ id: string;
23
+ }) => boolean);
11
24
  };
@@ -9,6 +9,7 @@ type PaginationProps = Pick<TableProps, "isVisiblity" | "columns"> & {
9
9
  setCurrentPage: React.Dispatch<React.SetStateAction<number>>;
10
10
  dataLength: number;
11
11
  isServerPagination: boolean;
12
+ pageSizeOptions?: (number | string)[];
12
13
  };
13
- declare const Pagination: ({ paginationText, handlePageSizeChange, rowsPerPage, currentPage, pages, setCurrentPage, dataLength, isServerPagination, }: PaginationProps) => React.JSX.Element;
14
+ declare const Pagination: ({ paginationText, handlePageSizeChange, rowsPerPage, currentPage, pages, setCurrentPage, dataLength, isServerPagination, pageSizeOptions, }: PaginationProps) => React.JSX.Element;
14
15
  export default Pagination;
@@ -8,16 +8,20 @@ var react_2 = require("@chakra-ui/react");
8
8
  var table_1 = require("../../../Utils/table");
9
9
  var lucide_react_1 = require("lucide-react");
10
10
  var Pagination = function (_a) {
11
- var paginationText = _a.paginationText, handlePageSizeChange = _a.handlePageSizeChange, rowsPerPage = _a.rowsPerPage, currentPage = _a.currentPage, pages = _a.pages, setCurrentPage = _a.setCurrentPage, dataLength = _a.dataLength, isServerPagination = _a.isServerPagination;
12
- var pageSizeOptions = (0, table_1.pageSizeCalculation)(dataLength);
11
+ var paginationText = _a.paginationText, handlePageSizeChange = _a.handlePageSizeChange, rowsPerPage = _a.rowsPerPage, currentPage = _a.currentPage, pages = _a.pages, setCurrentPage = _a.setCurrentPage, dataLength = _a.dataLength, isServerPagination = _a.isServerPagination, pageSizeOptions = _a.pageSizeOptions;
12
+ var computedOptions = pageSizeOptions && pageSizeOptions.length
13
+ ? pageSizeOptions
14
+ : (0, table_1.pageSizeCalculation)(dataLength);
13
15
  // const isLeftDisabled = currentPage === 0;
14
16
  // const isRightDisabled = currentPage >= pages - 1;
15
17
  var isLeftDisabled = dataLength === 0 || currentPage === 0;
16
18
  var isRightDisabled = dataLength === 0 || currentPage >= pages - 1;
17
19
  return (react_1.default.createElement(react_2.Flex, { justify: "flex-end", align: "center" },
18
20
  !isServerPagination && (react_1.default.createElement(react_2.Select, { onChange: handlePageSizeChange, value: rowsPerPage, size: "xs", borderRadius: 3, width: 20, isDisabled: dataLength === 0 },
19
- dataLength < 100 ? react_1.default.createElement("option", { value: 0 }) : null,
20
- pageSizeOptions.map(function (size, index) { return (react_1.default.createElement("option", { key: index, value: size }, size)); }))),
21
+ !pageSizeOptions && dataLength < 100 ? react_1.default.createElement("option", { value: 0 }) : null,
22
+ computedOptions.map(function (size, index) {
23
+ return (react_1.default.createElement("option", { key: index, value: size }, String(size)));
24
+ }))),
21
25
  dataLength > 0 && (react_1.default.createElement(react_2.Flex, null,
22
26
  react_1.default.createElement(react_2.IconButton, { "aria-label": "first-page", color: isLeftDisabled ? "gray" : "black", rounded: "full", variant: isLeftDisabled ? "plain" : "ghost", onClick: function () { return setCurrentPage(0); } },
23
27
  react_1.default.createElement(lucide_react_1.ChevronsLeft, null)),
@@ -12,8 +12,9 @@ type UseTableProps = {
12
12
  noOfRowsPerPage?: number;
13
13
  isServerPagination: boolean;
14
14
  totalRecords: number;
15
+ onNoOfRowsPerPageChange?: (noOfRows: number) => void;
15
16
  };
16
- declare const useTable: ({ tableBorderColor, data, isPagination, selections, onSelection, tablePreferences, savePreferences, noOfRowsPerPage, isServerPagination, totalRecords, columns, }: UseTableProps) => {
17
+ declare const useTable: ({ tableBorderColor, data, isPagination, selections, onSelection, tablePreferences, savePreferences, noOfRowsPerPage, isServerPagination, totalRecords, columns, onNoOfRowsPerPageChange, }: UseTableProps) => {
17
18
  tableData: DataObject[];
18
19
  tableContainerStyles: {
19
20
  borderRadius: string;
@@ -25,7 +25,7 @@ var useCustomTheme_1 = require("../../../Theme/useCustomTheme");
25
25
  var table_1 = require("../../../Utils/table");
26
26
  var defaultPageSize = 50;
27
27
  var useTable = function (_a) {
28
- var tableBorderColor = _a.tableBorderColor, data = _a.data, isPagination = _a.isPagination, selections = _a.selections, onSelection = _a.onSelection, tablePreferences = _a.tablePreferences, savePreferences = _a.savePreferences, noOfRowsPerPage = _a.noOfRowsPerPage, isServerPagination = _a.isServerPagination, totalRecords = _a.totalRecords, columns = _a.columns;
28
+ var tableBorderColor = _a.tableBorderColor, data = _a.data, isPagination = _a.isPagination, selections = _a.selections, onSelection = _a.onSelection, tablePreferences = _a.tablePreferences, savePreferences = _a.savePreferences, noOfRowsPerPage = _a.noOfRowsPerPage, isServerPagination = _a.isServerPagination, totalRecords = _a.totalRecords, columns = _a.columns, onNoOfRowsPerPageChange = _a.onNoOfRowsPerPageChange;
29
29
  var theme = (0, useCustomTheme_1.useCustomTheme)();
30
30
  var headerRefs = (0, react_1.useRef)([]);
31
31
  var _b = (0, react_1.useState)([]), columnWidths = _b[0], setColumnWidths = _b[1];
@@ -90,6 +90,9 @@ var useTable = function (_a) {
90
90
  var handlePageSizeChange = function (event) {
91
91
  var value = Number(event.target.value);
92
92
  setRowsPerPage(value !== 0 ? value : defaultPageSize);
93
+ if (onNoOfRowsPerPageChange) {
94
+ onNoOfRowsPerPageChange(value !== 0 ? value : defaultPageSize);
95
+ }
93
96
  setCurrentPage(0);
94
97
  };
95
98
  var handleSort = (0, react_1.useCallback)(function (field, sort) {
@@ -0,0 +1,23 @@
1
+ import React from "react";
2
+ export type FilterItem = {
3
+ id: string;
4
+ label: string;
5
+ type?: "text";
6
+ };
7
+ export type FilterSection = {
8
+ id: string;
9
+ label: string;
10
+ items?: FilterItem[];
11
+ initiallyExpanded?: boolean;
12
+ radio?: boolean;
13
+ };
14
+ export type LeftFilterPaneProps = {
15
+ title?: string;
16
+ height?: number | string;
17
+ sections: FilterSection[];
18
+ onApply?: (selected: Record<string, string[]>) => void;
19
+ onClear?: () => void;
20
+ theme: any;
21
+ };
22
+ declare const LeftFilterPane: ({ title, height, sections, onApply, onClear, theme, }: LeftFilterPaneProps) => React.JSX.Element;
23
+ export default LeftFilterPane;
@@ -0,0 +1,225 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ var react_1 = __importStar(require("react"));
41
+ var react_2 = require("@chakra-ui/react");
42
+ var lucide_react_1 = require("lucide-react");
43
+ var framer_motion_1 = require("framer-motion");
44
+ var react_3 = require("@chakra-ui/react");
45
+ var Checkbox_1 = __importDefault(require("../Checkbox/Checkbox"));
46
+ var RadioButton_1 = require("../RadioButton/RadioButton");
47
+ var TextOperationControls_1 = require("./TextOperationControls");
48
+ var LeftFilterPane = function (_a) {
49
+ var _b, _c;
50
+ var _d = _a.title, title = _d === void 0 ? "Filter" : _d, _e = _a.height, height = _e === void 0 ? 500 : _e, sections = _a.sections, onApply = _a.onApply, onClear = _a.onClear, theme = _a.theme;
51
+ var _f = (0, react_1.useState)(""), search = _f[0], setSearch = _f[1];
52
+ var _g = (0, react_1.useState)(false), isSearching = _g[0], setIsSearching = _g[1];
53
+ var _h = (0, react_1.useState)({}), selected = _h[0], setSelected = _h[1];
54
+ var _j = (0, react_1.useState)({}), textFilters = _j[0], setTextFilters = _j[1];
55
+ var searchRef = (0, react_1.useRef)(null);
56
+ var setTextOperator = function (itemId, operator) {
57
+ setTextFilters(function (prev) {
58
+ var _a;
59
+ var _b;
60
+ return (__assign(__assign({}, prev), (_a = {}, _a[itemId] = { operator: operator, value: ((_b = prev[itemId]) === null || _b === void 0 ? void 0 : _b.value) || "" }, _a)));
61
+ });
62
+ };
63
+ var setTextValue = function (itemId, value) {
64
+ setTextFilters(function (prev) {
65
+ var _a;
66
+ var _b;
67
+ return (__assign(__assign({}, prev), (_a = {}, _a[itemId] = { operator: ((_b = prev[itemId]) === null || _b === void 0 ? void 0 : _b.operator) || "contains", value: value }, _a)));
68
+ });
69
+ };
70
+ var formatHeaderLabel = function (label) {
71
+ var text = (label || "").trim();
72
+ var MAX = 18;
73
+ if (text.length <= MAX)
74
+ return text;
75
+ var removable = new Set(["filters", "fields", "modules", "status", "action"]);
76
+ var parts = text.split(/\s+/);
77
+ if (parts.length < 2)
78
+ return text;
79
+ var last = parts[parts.length - 1].toLowerCase();
80
+ if (removable.has(last)) {
81
+ parts = parts.slice(0, -1);
82
+ }
83
+ else {
84
+ parts = parts.slice(0, -1);
85
+ }
86
+ while (parts.join(" ").length > MAX && parts.length > 2) {
87
+ parts = parts.slice(0, -1);
88
+ }
89
+ return "".concat(parts.join(" "), "..");
90
+ };
91
+ (0, react_3.useOutsideClick)({
92
+ ref: searchRef,
93
+ handler: function () {
94
+ if (isSearching) {
95
+ setIsSearching(false);
96
+ setSearch("");
97
+ }
98
+ },
99
+ });
100
+ var filteredSections = (0, react_1.useMemo)(function () {
101
+ if (!search.trim())
102
+ return sections;
103
+ var q = search.toLowerCase();
104
+ return sections.map(function (sec) { return (__assign(__assign({}, sec), { items: (sec.items || []).filter(function (i) { return i.label.toLowerCase().includes(q); }) })); });
105
+ }, [search, sections]);
106
+ var toggleItem = function (sectionId, itemId, checked) {
107
+ setSelected(function (prev) {
108
+ var _a;
109
+ var cur = new Set(prev[sectionId] || []);
110
+ if (checked)
111
+ cur.add(itemId);
112
+ else
113
+ cur.delete(itemId);
114
+ return __assign(__assign({}, prev), (_a = {}, _a[sectionId] = Array.from(cur), _a));
115
+ });
116
+ };
117
+ var handleApply = function () { return onApply === null || onApply === void 0 ? void 0 : onApply(selected); };
118
+ var handleClear = function () {
119
+ setSelected({});
120
+ onClear === null || onClear === void 0 ? void 0 : onClear();
121
+ };
122
+ var hasSelection = (0, react_1.useMemo)(function () { return Object.values(selected).some(function (arr) { return (arr || []).length > 0; }); }, [selected]);
123
+ return (react_1.default.createElement(react_2.Box, { width: "180px", height: height, bg: "white", borderRight: "1px solid", borderColor: "gray.200", borderRadius: "md", overflow: "hidden", display: "flex", flexDirection: "column" },
124
+ react_1.default.createElement(react_2.Box, { p: 3, borderBottom: "1px solid", borderColor: "gray.200" }, !isSearching ? (react_1.default.createElement(react_2.Flex, { align: "center", justify: "space-between" },
125
+ react_1.default.createElement(react_2.Text, { fontWeight: "semibold", fontSize: "sm" }, title),
126
+ react_1.default.createElement(react_2.Icon, { as: lucide_react_1.Search, transform: "scaleX(-1)", cursor: "pointer", boxSize: 4, color: (_c = (_b = theme.colors) === null || _b === void 0 ? void 0 : _b.text) === null || _c === void 0 ? void 0 : _c[500], onClick: function () { return setIsSearching(true); } }))) : (react_1.default.createElement(framer_motion_1.motion.div, { ref: searchRef, initial: { opacity: 0, x: 40 }, animate: { opacity: 1, x: 0 }, transition: { type: "tween", duration: 0.2 } },
127
+ react_1.default.createElement(react_2.InputGroup, { size: "sm" },
128
+ react_1.default.createElement(react_2.InputLeftElement, { pointerEvents: "none" },
129
+ react_1.default.createElement(lucide_react_1.Search, { size: 16, color: "#555a64" })),
130
+ react_1.default.createElement(react_2.Input, { placeholder: "Search", value: search, onChange: function (e) { return setSearch(e.target.value); }, autoFocus: true }),
131
+ search.length > 0 && (react_1.default.createElement(react_2.InputRightElement, null,
132
+ react_1.default.createElement(react_2.IconButton, { "aria-label": "Clear", size: "xs", variant: "ghost", icon: react_1.default.createElement(lucide_react_1.X, { size: 14 }), onClick: function () {
133
+ setSearch("");
134
+ setIsSearching(false);
135
+ } }))))))),
136
+ react_1.default.createElement(react_2.Box, { flex: "1", overflowY: "auto" },
137
+ filteredSections.length > 1 ? (react_1.default.createElement(react_2.Accordion, { allowMultiple: true, defaultIndex: sections.map(function (s, i) { return (s.initiallyExpanded ? i : -1); }).filter(function (i) { return i >= 0; }) }, filteredSections.map(function (sec) {
138
+ var _a, _b, _c;
139
+ return (react_1.default.createElement(react_2.AccordionItem, { key: sec.id, border: "none" },
140
+ react_1.default.createElement("h2", null,
141
+ react_1.default.createElement(react_2.AccordionButton, { px: 3, py: 2, _expanded: { bg: "gray.50" } },
142
+ (sec.label || "").length > 18 ? (react_1.default.createElement(react_2.Tooltip, { label: sec.label, hasArrow: true, placement: "top", bg: theme.colors.gray[600], color: theme.colors.white, fontSize: "0.75rem" },
143
+ react_1.default.createElement(react_2.Box, { as: "span", flex: "1", textAlign: "left", fontWeight: "medium", fontSize: "sm", sx: {
144
+ whiteSpace: "nowrap",
145
+ overflow: "hidden",
146
+ textOverflow: "ellipsis",
147
+ } }, formatHeaderLabel(sec.label)))) : (react_1.default.createElement(react_2.Box, { as: "span", flex: "1", textAlign: "left", fontWeight: "medium", fontSize: "sm", sx: {
148
+ whiteSpace: "nowrap",
149
+ overflow: "hidden",
150
+ textOverflow: "ellipsis",
151
+ } }, formatHeaderLabel(sec.label))),
152
+ react_1.default.createElement(react_2.AccordionIcon, null))),
153
+ react_1.default.createElement(react_2.AccordionPanel, { px: 3, pt: 2, pb: 1 }, sec.radio ? (react_1.default.createElement(react_1.default.Fragment, null,
154
+ react_1.default.createElement(RadioButton_1.RadioButtonGroup, { value: (selected[sec.id] && selected[sec.id][0]) || "", onChange: function (val) {
155
+ return setSelected(function (prev) {
156
+ var _a;
157
+ return (__assign(__assign({}, prev), (_a = {}, _a[sec.id] = val ? [val] : [], _a)));
158
+ });
159
+ }, options: (sec.items || []).map(function (it) { return ({
160
+ label: it.label,
161
+ id: it.id,
162
+ }); }), size: "sm", spacing: "0.35rem", direction: "column", align: "start", labelFontSize: "0.75rem", labelClampLines: 1, showLabelTooltip: function (item) { return item.label.length > 18; } }),
163
+ ((((_a = (sec.items || []).find(function (i) { return i.id === ((selected[sec.id] && selected[sec.id][0]) || ""); })) === null || _a === void 0 ? void 0 : _a.type) === "text")) && (react_1.default.createElement(TextOperationControls_1.TextOperationControls, { operator: ((_b = textFilters[((selected[sec.id] && selected[sec.id][0]) || "")]) === null || _b === void 0 ? void 0 : _b.operator) || "contains", value: ((_c = textFilters[((selected[sec.id] && selected[sec.id][0]) || "")]) === null || _c === void 0 ? void 0 : _c.value) || "", onOperatorChange: function (op) { return setTextOperator(((selected[sec.id] && selected[sec.id][0]) || ""), op); }, onValueChange: function (val) { return setTextValue(((selected[sec.id] && selected[sec.id][0]) || ""), val); } })))) : (react_1.default.createElement(react_2.VStack, { spacing: 2, align: "stretch" }, (sec.items || []).map(function (it) {
164
+ var _a, _b;
165
+ var checked = (selected[sec.id] || []).includes(it.id);
166
+ return (react_1.default.createElement(react_1.default.Fragment, null,
167
+ react_1.default.createElement(Checkbox_1.default, { key: it.id, label: it.label, labelFontSize: "0.75rem", showLabelTooltip: it.label.length > 18, labelTooltip: it.label, labelClampLines: 1, isChecked: checked, onChange: function (e) { return toggleItem(sec.id, it.id, e.target.checked); }, size: "sm", iconSize: "0.5rem", spacing: "0.5rem", sx: {
168
+ '.chakra-checkbox__control': {
169
+ width: '12px',
170
+ height: '12px',
171
+ mt: '2px',
172
+ },
173
+ '.chakra-checkbox__label': {
174
+ lineHeight: '1rem',
175
+ whiteSpace: 'normal',
176
+ wordBreak: 'break-word',
177
+ },
178
+ } }),
179
+ checked && it.type === "text" && (react_1.default.createElement(TextOperationControls_1.TextOperationControls, { operator: ((_a = textFilters[it.id]) === null || _a === void 0 ? void 0 : _a.operator) || "contains", value: ((_b = textFilters[it.id]) === null || _b === void 0 ? void 0 : _b.value) || "", onOperatorChange: function (op) { return setTextOperator(it.id, op); }, onValueChange: function (val) { return setTextValue(it.id, val); } }))));
180
+ }))))));
181
+ }))) : (filteredSections.map(function (sec) {
182
+ var _a, _b, _c;
183
+ return (react_1.default.createElement(react_2.Box, { key: sec.id },
184
+ react_1.default.createElement(react_2.Box, { px: 3, py: 2, borderBottom: "1px solid", borderColor: "gray.200" }, (sec.label || "").length > 18 ? (react_1.default.createElement(react_2.Tooltip, { label: sec.label, hasArrow: true, placement: "top", bg: theme.colors.gray[600], color: theme.colors.white, fontSize: "0.75rem" },
185
+ react_1.default.createElement(react_2.Box, { as: "span", textAlign: "left", fontWeight: "medium", fontSize: "sm", sx: {
186
+ whiteSpace: "nowrap",
187
+ overflow: "hidden",
188
+ textOverflow: "ellipsis",
189
+ } }, formatHeaderLabel(sec.label)))) : (react_1.default.createElement(react_2.Box, { as: "span", textAlign: "left", fontWeight: "medium", fontSize: "sm", sx: {
190
+ whiteSpace: "nowrap",
191
+ overflow: "hidden",
192
+ textOverflow: "ellipsis",
193
+ } }, formatHeaderLabel(sec.label)))),
194
+ react_1.default.createElement(react_2.Box, { px: 3, pt: 2, pb: 1 }, sec.radio ? (react_1.default.createElement(react_1.default.Fragment, null,
195
+ react_1.default.createElement(RadioButton_1.RadioButtonGroup, { value: (selected[sec.id] && selected[sec.id][0]) || "", onChange: function (val) {
196
+ return setSelected(function (prev) {
197
+ var _a;
198
+ return (__assign(__assign({}, prev), (_a = {}, _a[sec.id] = val ? [val] : [], _a)));
199
+ });
200
+ }, options: (sec.items || []).map(function (it) { return ({
201
+ label: it.label,
202
+ id: it.id,
203
+ }); }), size: "sm", spacing: "0.35rem", direction: "column", align: "start", labelFontSize: "0.75rem", labelClampLines: 1, showLabelTooltip: function (item) { return item.label.length > 18; } }),
204
+ ((((_a = (sec.items || []).find(function (i) { return i.id === ((selected[sec.id] && selected[sec.id][0]) || ""); })) === null || _a === void 0 ? void 0 : _a.type) === "text")) && (react_1.default.createElement(TextOperationControls_1.TextOperationControls, { operator: ((_b = textFilters[((selected[sec.id] && selected[sec.id][0]) || "")]) === null || _b === void 0 ? void 0 : _b.operator) || "contains", value: ((_c = textFilters[((selected[sec.id] && selected[sec.id][0]) || "")]) === null || _c === void 0 ? void 0 : _c.value) || "", onOperatorChange: function (op) { return setTextOperator(((selected[sec.id] && selected[sec.id][0]) || ""), op); }, onValueChange: function (val) { return setTextValue(((selected[sec.id] && selected[sec.id][0]) || ""), val); } })))) : (react_1.default.createElement(react_2.VStack, { spacing: 2, align: "stretch" }, (sec.items || []).map(function (it) {
205
+ var checked = (selected[sec.id] || []).includes(it.id);
206
+ return (react_1.default.createElement(Checkbox_1.default, { key: it.id, label: it.label, labelFontSize: "0.75rem", showLabelTooltip: it.label.length > 18, labelTooltip: it.label, labelClampLines: 1, isChecked: checked, onChange: function (e) { return toggleItem(sec.id, it.id, e.target.checked); }, size: "sm", iconSize: "0.5rem", spacing: "0.5rem", sx: {
207
+ '.chakra-checkbox__control': {
208
+ width: '12px',
209
+ height: '12px',
210
+ mt: '2px',
211
+ },
212
+ '.chakra-checkbox__label': {
213
+ lineHeight: '1rem',
214
+ whiteSpace: 'normal',
215
+ wordBreak: 'break-word',
216
+ },
217
+ } }));
218
+ }))))));
219
+ })),
220
+ hasSelection && (react_1.default.createElement(react_2.Box, { position: "sticky", bottom: 0, zIndex: 1, bg: "white", borderTop: "1px solid", borderColor: "gray.200", px: 3, py: 2 },
221
+ react_1.default.createElement(react_2.VStack, { spacing: 2, m: 0 },
222
+ react_1.default.createElement(react_2.Button, { size: "sm", width: "100%", colorScheme: "blue", onClick: handleApply, m: 0 }, "Apply Filter"),
223
+ react_1.default.createElement(react_2.Button, { size: "sm", width: "100%", onClick: handleClear, m: 0 }, "Clear")))))));
224
+ };
225
+ exports.default = LeftFilterPane;
@@ -1,3 +1,3 @@
1
1
  import React from "react";
2
2
  import { TableProps } from "./TableProps";
3
- export default function Table({ data, columns, onSelection, isLoading, isCheckbox, headerBgColor, freezedBgColor, headerTextColor, freezedTextColor, tableBorderColor, noBorders, isPagination, onRowClick, selections, isActionFreeze, preferences, paginationMode, noOfRowsPerPage, totalRecords, onPagination, isTableSettings, headerActions, onGlobalSearch, tableSettings, }: TableProps): React.JSX.Element;
3
+ export default function Table({ data, columns, onSelection, isLoading, isCheckbox, headerBgColor, freezedBgColor, headerTextColor, freezedTextColor, tableBorderColor, noBorders, isPagination, onRowClick, selections, isActionFreeze, preferences, paginationMode, noOfRowsPerPage, totalRecords, onPagination, isTableSettings, headerActions, onGlobalSearch, onNoOfRowsPerPageChange, paginationSelectOptions, tableMaxHeight, tableSettings, filterSidebar }: TableProps): React.JSX.Element;
@@ -29,6 +29,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  var react_1 = __importStar(require("react"));
30
30
  var react_2 = require("@chakra-ui/react");
31
31
  var react_3 = require("@chakra-ui/react");
32
+ var framer_motion_1 = require("framer-motion");
33
+ var LeftFilterPane_1 = __importDefault(require("./LeftFilterPane"));
32
34
  var Pagination_1 = __importDefault(require("./Components/Pagination"));
33
35
  var TableHeader_1 = __importDefault(require("./Components/TableHeader"));
34
36
  var TableBody_1 = __importDefault(require("./Components/TableBody"));
@@ -41,27 +43,31 @@ var HeaderActions_1 = __importDefault(require("./Components/HeaderActions"));
41
43
  var Divider_1 = __importDefault(require("../Divider/Divider"));
42
44
  var TableSearch_1 = __importDefault(require("./Components/TableSearch"));
43
45
  var ActiveFilters_1 = __importDefault(require("./Components/ActiveFilters"));
46
+ var lucide_react_1 = require("lucide-react");
47
+ var MotionBox = (0, framer_motion_1.motion)(react_2.Box);
44
48
  function Table(_a) {
45
- var _b, _c, _d, _e, _f, _g;
46
- var data = _a.data, columns = _a.columns, onSelection = _a.onSelection, isLoading = _a.isLoading, _h = _a.isCheckbox, isCheckbox = _h === void 0 ? false : _h, headerBgColor = _a.headerBgColor, freezedBgColor = _a.freezedBgColor, headerTextColor = _a.headerTextColor, freezedTextColor = _a.freezedTextColor, tableBorderColor = _a.tableBorderColor, _j = _a.noBorders, noBorders = _j === void 0 ? false : _j, _k = _a.isPagination, isPagination = _k === void 0 ? true : _k, onRowClick = _a.onRowClick, selections = _a.selections, _l = _a.isActionFreeze, isActionFreeze = _l === void 0 ? true : _l, _m = _a.preferences, preferences = _m === void 0 ? {
49
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
50
+ var data = _a.data, columns = _a.columns, onSelection = _a.onSelection, isLoading = _a.isLoading, _q = _a.isCheckbox, isCheckbox = _q === void 0 ? false : _q, headerBgColor = _a.headerBgColor, freezedBgColor = _a.freezedBgColor, headerTextColor = _a.headerTextColor, freezedTextColor = _a.freezedTextColor, tableBorderColor = _a.tableBorderColor, _r = _a.noBorders, noBorders = _r === void 0 ? false : _r, _s = _a.isPagination, isPagination = _s === void 0 ? true : _s, onRowClick = _a.onRowClick, selections = _a.selections, _t = _a.isActionFreeze, isActionFreeze = _t === void 0 ? true : _t, _u = _a.preferences, preferences = _u === void 0 ? {
47
51
  url: "",
48
52
  token: "",
49
53
  key: "",
50
54
  name: "",
51
55
  page: "",
52
56
  orgId: "",
53
- } : _m, _o = _a.paginationMode, paginationMode = _o === void 0 ? "client" : _o, _p = _a.noOfRowsPerPage, noOfRowsPerPage = _p === void 0 ? 50 : _p, _q = _a.totalRecords, totalRecords = _q === void 0 ? 0 : _q, onPagination = _a.onPagination, _r = _a.isTableSettings, isTableSettings = _r === void 0 ? false : _r, headerActions = _a.headerActions, onGlobalSearch = _a.onGlobalSearch, tableSettings = _a.tableSettings;
57
+ } : _u, _v = _a.paginationMode, paginationMode = _v === void 0 ? "client" : _v, _w = _a.noOfRowsPerPage, noOfRowsPerPage = _w === void 0 ? 50 : _w, _x = _a.totalRecords, totalRecords = _x === void 0 ? 0 : _x, onPagination = _a.onPagination, _y = _a.isTableSettings, isTableSettings = _y === void 0 ? false : _y, headerActions = _a.headerActions, onGlobalSearch = _a.onGlobalSearch, onNoOfRowsPerPageChange = _a.onNoOfRowsPerPageChange, paginationSelectOptions = _a.paginationSelectOptions, tableMaxHeight = _a.tableMaxHeight, tableSettings = _a.tableSettings, filterSidebar = _a.filterSidebar
58
+ // onColumnFilter
59
+ ;
54
60
  var theme = (0, useCustomTheme_1.useCustomTheme)();
55
- var _s = (0, react_1.useState)({}), columnsSearch = _s[0], setColumnsSearch = _s[1];
61
+ var _z = (0, react_1.useState)({}), columnsSearch = _z[0], setColumnsSearch = _z[1];
56
62
  var isServerPagination = paginationMode === "server";
57
- var _t = (0, usePreferences_1.useGetPreferences)({
63
+ var _0 = (0, usePreferences_1.useGetPreferences)({
58
64
  baseUrl: preferences.url,
59
65
  page: preferences.page,
60
66
  key: preferences.key,
61
67
  name: preferences.name,
62
68
  authToken: preferences.token,
63
69
  orgId: preferences.orgId,
64
- }), tablePreferencesData = _t.preferences, loading = _t.loading;
70
+ }), tablePreferencesData = _0.preferences, loading = _0.loading;
65
71
  var savePreferences = (0, usePreferences_1.useSavePreferences)({
66
72
  baseUrl: preferences.url,
67
73
  page: preferences.page,
@@ -79,7 +85,7 @@ function Table(_a) {
79
85
  }
80
86
  return {};
81
87
  }, [tablePreferencesData]);
82
- var _u = (0, useTable_1.default)({
88
+ var _1 = (0, useTable_1.default)({
83
89
  tableBorderColor: tableBorderColor,
84
90
  data: data,
85
91
  isPagination: isPagination,
@@ -91,7 +97,8 @@ function Table(_a) {
91
97
  noOfRowsPerPage: noOfRowsPerPage,
92
98
  totalRecords: totalRecords,
93
99
  isServerPagination: isServerPagination,
94
- }), tableData = _u.tableData, isContent = _u.isContent, isLink = _u.isLink, headerRefs = _u.headerRefs, columnWidths = _u.columnWidths, handleSort = _u.handleSort, handleCheckbox = _u.handleCheckbox, filteredData = _u.filteredData, startRow = _u.startRow, endRow = _u.endRow, selection = _u.selection, columnsSort = _u.columnsSort, currentPage = _u.currentPage, pages = _u.pages, rowsPerPage = _u.rowsPerPage, handlePageSizeChange = _u.handlePageSizeChange, setCurrentPage = _u.setCurrentPage, columnsList = _u.columnsList, handleColumnPreferences = _u.handleColumnPreferences;
100
+ onNoOfRowsPerPageChange: onNoOfRowsPerPageChange,
101
+ }), tableData = _1.tableData, isContent = _1.isContent, isLink = _1.isLink, headerRefs = _1.headerRefs, columnWidths = _1.columnWidths, handleSort = _1.handleSort, handleCheckbox = _1.handleCheckbox, filteredData = _1.filteredData, startRow = _1.startRow, endRow = _1.endRow, selection = _1.selection, columnsSort = _1.columnsSort, currentPage = _1.currentPage, pages = _1.pages, rowsPerPage = _1.rowsPerPage, handlePageSizeChange = _1.handlePageSizeChange, setCurrentPage = _1.setCurrentPage, columnsList = _1.columnsList, handleColumnPreferences = _1.handleColumnPreferences;
95
102
  var _filteredData = (0, react_1.useMemo)(function () {
96
103
  return (0, table_1.searchAndSortData)(filteredData, columnsSearch);
97
104
  }, [columnsSearch, filteredData]);
@@ -101,58 +108,70 @@ function Table(_a) {
101
108
  }
102
109
  }, [currentPage, onPagination, noOfRowsPerPage]);
103
110
  var tablePaginationText = "".concat(startRow + 1, " - ").concat(endRow > tableData.length ? tableData.length : endRow, " of ").concat(isServerPagination ? totalRecords : tableData.length);
111
+ var controlsHeight = 45;
112
+ var estimatedRowHeight = 45;
113
+ var visibleRowsCount = isServerPagination ? (noOfRowsPerPage !== null && noOfRowsPerPage !== void 0 ? noOfRowsPerPage : 0) : _filteredData.length;
114
+ var dynamicMaxH = Math.min(500, (visibleRowsCount * estimatedRowHeight) + estimatedRowHeight);
115
+ var tableMaxH = typeof tableMaxHeight === "number" ? tableMaxHeight : dynamicMaxH;
104
116
  return (react_1.default.createElement(react_2.Box, { bg: (_c = (_b = theme.colors) === null || _b === void 0 ? void 0 : _b.background) === null || _c === void 0 ? void 0 : _c[50], border: "0.063rem solid ".concat((_d = theme.colors.border) === null || _d === void 0 ? void 0 : _d[500]), borderRadius: 3 },
105
- react_1.default.createElement(react_2.Box, { display: "flex", alignItems: "center", justifyContent: "space-between", px: 3, py: 0, height: 45, gap: 2 },
106
- react_1.default.createElement(TableSearch_1.default, { onSearch: onGlobalSearch }),
107
- isTableSettings && (react_1.default.createElement(react_1.default.Fragment, null,
108
- react_1.default.createElement(Divider_1.default, null),
109
- react_1.default.createElement(TableSettings_1.default, { columns: columnsList, onSave: function (cols) { return handleColumnPreferences(cols); }, tableSettings: tableSettings }))),
110
- selection.length ? (react_1.default.createElement(react_1.default.Fragment, null,
111
- react_1.default.createElement(Divider_1.default, null),
112
- react_1.default.createElement(HeaderActions_1.default, { actions: headerActions, selections: selection }))) : null,
113
- react_1.default.createElement(ActiveFilters_1.default, { columns: columnsList, columnsSearch: columnsSearch, setColumnsSearch: setColumnsSearch }),
114
- (isPagination || isServerPagination) && (react_1.default.createElement(react_2.Box, { ml: "auto", minW: 310 },
115
- react_1.default.createElement(Pagination_1.default, { columns: columns, currentPage: currentPage, setCurrentPage: setCurrentPage, rowsPerPage: rowsPerPage, pages: pages, paginationText: tablePaginationText, handlePageSizeChange: handlePageSizeChange, dataLength: tableData.length, isServerPagination: isServerPagination, isVisiblity: true })))),
116
- react_1.default.createElement(react_2.TableContainer, { maxH: 500, overflowY: "auto", sx: {
117
- '&::-webkit-scrollbar': {
118
- width: '6px',
119
- height: '6px',
120
- },
121
- '&::-webkit-scrollbar-track': {
122
- background: theme.colors.gray[100],
123
- borderRadius: '3px',
124
- },
125
- '&::-webkit-scrollbar-thumb': {
126
- background: theme.colors.gray[400],
127
- borderRadius: '3px',
128
- },
129
- '&::-webkit-scrollbar-thumb:hover': {
130
- background: theme.colors.gray[500],
131
- },
132
- scrollbarWidth: 'thin',
133
- scrollbarColor: "".concat(theme.colors.gray[400], " ").concat(theme.colors.gray[100]),
134
- } },
135
- react_1.default.createElement(react_3.Table, { variant: "simple", size: "sm", overflowX: "scroll", minW: "100%", className: "table_wrapper", sx: {
136
- width: "100%",
137
- borderCollapse: "collapse",
138
- "th .resize-handle": {
139
- position: "absolute",
140
- top: 0,
141
- right: 0,
142
- width: "8px",
143
- height: "100%",
144
- cursor: "col-resize",
145
- backgroundColor: "transparent",
146
- zIndex: 999,
147
- },
148
- } },
149
- react_1.default.createElement(react_3.Thead, { position: "sticky", top: -0.5, zIndex: 2 },
150
- react_1.default.createElement(TableHeader_1.default, { columns: columnsList, isCheckbox: isCheckbox, headerBgColor: headerBgColor !== null && headerBgColor !== void 0 ? headerBgColor : theme.colors.backgroundColor.muted, headerTextColor: headerTextColor !== null && headerTextColor !== void 0 ? headerTextColor : (_e = theme.colors) === null || _e === void 0 ? void 0 : _e.gray[600], freezedBgColor: freezedBgColor !== null && freezedBgColor !== void 0 ? freezedBgColor : theme.colors.backgroundColor.secondary, freezedTextColor: freezedTextColor !== null && freezedTextColor !== void 0 ? freezedTextColor : (_f = theme.colors) === null || _f === void 0 ? void 0 : _f.gray[600], handleSort: handleSort, headerRefs: headerRefs, columnWidths: columnWidths, columnsSort: columnsSort, noBorders: noBorders, handleCheckbox: handleCheckbox, isLoading: isTableLoading, checked: tableData.length !== 0 && selection.length === tableData.length
151
- ? true
152
- : selection.length === 0
153
- ? false
154
- : "indeterminate", isContent: isContent, isLink: isLink, isActionFreeze: isActionFreeze, setColumnsSearch: setColumnsSearch, columnsSearch: columnsSearch })),
155
- react_1.default.createElement(react_3.Tbody, null,
156
- react_1.default.createElement(TableBody_1.default, { data: _filteredData, columns: columnsList, startRow: startRow, endRow: endRow, isCheckbox: isCheckbox, columnWidths: columnWidths, noBorders: noBorders, freezedBgColor: freezedBgColor !== null && freezedBgColor !== void 0 ? freezedBgColor : theme.colors.backgroundColor.secondary, freezedTextColor: freezedTextColor !== null && freezedTextColor !== void 0 ? freezedTextColor : (_g = theme.colors) === null || _g === void 0 ? void 0 : _g.gray[600], handleCheckbox: handleCheckbox, selections: selection, isLoading: isTableLoading, onRowClick: onRowClick, isContent: isContent, isLink: isLink, isActionFreeze: isActionFreeze }))))));
117
+ react_1.default.createElement(react_2.Flex, { align: "start" },
118
+ react_1.default.createElement(MotionBox, { initial: { width: 0 }, animate: { width: (filterSidebar === null || filterSidebar === void 0 ? void 0 : filterSidebar.isFilterSidebar) ? 180 : 0 }, transition: { type: "tween", duration: 0.25 }, overflow: "hidden", flexShrink: 0, borderRight: "1px solid", borderColor: (_e = theme.colors.border) === null || _e === void 0 ? void 0 : _e[500], style: { height: controlsHeight + tableMaxH } },
119
+ react_1.default.createElement(LeftFilterPane_1.default, { height: controlsHeight + tableMaxH, theme: theme, sections: (_f = filterSidebar === null || filterSidebar === void 0 ? void 0 : filterSidebar.sidebarOptions) !== null && _f !== void 0 ? _f : [], onApply: filterSidebar === null || filterSidebar === void 0 ? void 0 : filterSidebar.onChange })),
120
+ react_1.default.createElement(react_2.Box, { flex: "1", minW: 0 },
121
+ react_1.default.createElement(react_2.Box, { display: "flex", alignItems: "center", justifyContent: "space-between", px: 3, py: 0, height: controlsHeight, gap: 2, bg: (_h = (_g = theme.colors) === null || _g === void 0 ? void 0 : _g.background) === null || _h === void 0 ? void 0 : _h[50], borderBottom: "0.063rem solid ".concat((_j = theme.colors.border) === null || _j === void 0 ? void 0 : _j[500]) },
122
+ filterSidebar && (react_1.default.createElement(react_1.default.Fragment, null,
123
+ react_1.default.createElement(react_3.Icon, { as: lucide_react_1.Filter, transform: "scaleX(-1)", cursor: "pointer", boxSize: 4, color: (_l = (_k = theme.colors) === null || _k === void 0 ? void 0 : _k.text) === null || _l === void 0 ? void 0 : _l[500], onClick: filterSidebar === null || filterSidebar === void 0 ? void 0 : filterSidebar.filterSidebarToggle }),
124
+ react_1.default.createElement(Divider_1.default, null))),
125
+ react_1.default.createElement(TableSearch_1.default, { onSearch: onGlobalSearch }),
126
+ isTableSettings && (react_1.default.createElement(react_1.default.Fragment, null,
127
+ react_1.default.createElement(Divider_1.default, null),
128
+ react_1.default.createElement(TableSettings_1.default, { columns: columnsList, onSave: function (cols) { return handleColumnPreferences(cols); }, tableSettings: tableSettings }))),
129
+ selection.length ? (react_1.default.createElement(react_1.default.Fragment, null,
130
+ react_1.default.createElement(Divider_1.default, null),
131
+ react_1.default.createElement(HeaderActions_1.default, { actions: headerActions, selections: selection }))) : null,
132
+ react_1.default.createElement(ActiveFilters_1.default, { columns: columnsList, columnsSearch: columnsSearch, setColumnsSearch: setColumnsSearch }),
133
+ (isPagination || isServerPagination) && (react_1.default.createElement(react_2.Box, { ml: "auto", minW: 310 },
134
+ react_1.default.createElement(Pagination_1.default, { columns: columns, currentPage: currentPage, setCurrentPage: setCurrentPage, rowsPerPage: rowsPerPage, pages: pages, paginationText: tablePaginationText, handlePageSizeChange: handlePageSizeChange, dataLength: tableData.length, isServerPagination: isServerPagination, pageSizeOptions: paginationSelectOptions, isVisiblity: true })))),
135
+ react_1.default.createElement(react_2.TableContainer, { position: "relative", maxH: tableMaxH, overflowY: "auto", overflowX: "auto", sx: {
136
+ '&::-webkit-scrollbar': {
137
+ width: '6px',
138
+ height: '6px',
139
+ },
140
+ '&::-webkit-scrollbar-track': {
141
+ background: theme.colors.gray[100],
142
+ borderRadius: '3px',
143
+ },
144
+ '&::-webkit-scrollbar-thumb': {
145
+ background: theme.colors.gray[400],
146
+ borderRadius: '3px',
147
+ },
148
+ '&::-webkit-scrollbar-thumb:hover': {
149
+ background: theme.colors.gray[500],
150
+ },
151
+ scrollbarWidth: 'thin',
152
+ scrollbarColor: "".concat(theme.colors.gray[400], " ").concat(theme.colors.gray[100]),
153
+ } },
154
+ react_1.default.createElement(react_3.Table, { variant: "simple", size: "sm", minW: "100%", className: "table_wrapper", sx: {
155
+ width: "100%",
156
+ borderCollapse: "collapse",
157
+ "th .resize-handle": {
158
+ position: "absolute",
159
+ top: 0,
160
+ right: 0,
161
+ width: "8px",
162
+ height: "100%",
163
+ cursor: "col-resize",
164
+ backgroundColor: "transparent",
165
+ zIndex: 999,
166
+ },
167
+ } },
168
+ react_1.default.createElement(react_3.Thead, { position: "sticky", top: 0, zIndex: 4 },
169
+ react_1.default.createElement(TableHeader_1.default, { columns: columnsList, isCheckbox: isCheckbox, headerBgColor: headerBgColor !== null && headerBgColor !== void 0 ? headerBgColor : theme.colors.backgroundColor.muted, headerTextColor: headerTextColor !== null && headerTextColor !== void 0 ? headerTextColor : (_m = theme.colors) === null || _m === void 0 ? void 0 : _m.gray[600], freezedBgColor: freezedBgColor !== null && freezedBgColor !== void 0 ? freezedBgColor : theme.colors.backgroundColor.secondary, freezedTextColor: freezedTextColor !== null && freezedTextColor !== void 0 ? freezedTextColor : (_o = theme.colors) === null || _o === void 0 ? void 0 : _o.gray[600], handleSort: handleSort, headerRefs: headerRefs, columnWidths: columnWidths, columnsSort: columnsSort, noBorders: noBorders, handleCheckbox: handleCheckbox, isLoading: isTableLoading, checked: tableData.length !== 0 && selection.length === tableData.length
170
+ ? true
171
+ : selection.length === 0
172
+ ? false
173
+ : "indeterminate", isContent: isContent, isLink: isLink, isActionFreeze: isActionFreeze, setColumnsSearch: setColumnsSearch, columnsSearch: columnsSearch })),
174
+ react_1.default.createElement(react_3.Tbody, null,
175
+ react_1.default.createElement(TableBody_1.default, { data: _filteredData, columns: columnsList, startRow: startRow, endRow: endRow, isCheckbox: isCheckbox, columnWidths: columnWidths, noBorders: noBorders, freezedBgColor: freezedBgColor !== null && freezedBgColor !== void 0 ? freezedBgColor : theme.colors.backgroundColor.secondary, freezedTextColor: freezedTextColor !== null && freezedTextColor !== void 0 ? freezedTextColor : (_p = theme.colors) === null || _p === void 0 ? void 0 : _p.gray[600], handleCheckbox: handleCheckbox, selections: selection, isLoading: isTableLoading, onRowClick: onRowClick, isContent: isContent, isLink: isLink, isActionFreeze: isActionFreeze }))))))));
157
176
  }
158
177
  exports.default = Table;
@@ -1,4 +1,5 @@
1
1
  import { Dispatch, MutableRefObject, SetStateAction } from "react";
2
+ import { FilterSidebarProps } from "../FilterSidebar/FilterSidebar";
2
3
  export type TableProps = {
3
4
  data: DataObject[];
4
5
  columns: TableHeaderProps[];
@@ -23,6 +24,9 @@ export type TableProps = {
23
24
  noOfRowsPerPage?: number;
24
25
  totalRecords?: number;
25
26
  onPagination?: (page: number, noOfRecords: number) => void;
27
+ onNoOfRowsPerPageChange?: (noOfRows: number) => void;
28
+ paginationSelectOptions?: (number | string)[];
29
+ tableMaxHeight?: number;
26
30
  headerActions?: HeaderActionsProps;
27
31
  onGlobalSearch?: (searchVal: string) => void;
28
32
  onColumnFilter?: (filters: Record<string, any>) => void;
@@ -32,6 +36,11 @@ export type TableProps = {
32
36
  filterSelected?: string[];
33
37
  onFilterSelection?: (filters: string[]) => void;
34
38
  };
39
+ filterSidebar?: Partial<FilterSidebarProps> & {
40
+ isFilterSidebar?: boolean;
41
+ handleSidebarFilterClick?: (filters: Record<string, any>) => void;
42
+ filterSidebarToggle?: () => void;
43
+ };
35
44
  preferences?: {
36
45
  url: string;
37
46
  token: string;
@@ -0,0 +1,12 @@
1
+ import React from "react";
2
+ export declare const TEXT_OPERATORS: string[];
3
+ export declare const requiresValue: (op: string) => boolean;
4
+ export declare function TextOperationControls({ operator, value, onOperatorChange, onValueChange, size, ml, mt, }: {
5
+ operator: string;
6
+ value: string;
7
+ onOperatorChange: (op: string) => void;
8
+ onValueChange: (val: string) => void;
9
+ size?: "xs" | "sm";
10
+ ml?: string | number;
11
+ mt?: string | number;
12
+ }): React.JSX.Element;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TextOperationControls = exports.requiresValue = exports.TEXT_OPERATORS = void 0;
7
+ var react_1 = __importDefault(require("react"));
8
+ var react_2 = require("@chakra-ui/react");
9
+ exports.TEXT_OPERATORS = [
10
+ "is",
11
+ "isn't",
12
+ "contains",
13
+ "doesn't contain",
14
+ "starts with",
15
+ "ends with",
16
+ "is empty",
17
+ "is not empty",
18
+ ];
19
+ var requiresValue = function (op) {
20
+ return !(op === "is empty" || op === "is not empty");
21
+ };
22
+ exports.requiresValue = requiresValue;
23
+ function TextOperationControls(_a) {
24
+ var operator = _a.operator, value = _a.value, onOperatorChange = _a.onOperatorChange, onValueChange = _a.onValueChange, _b = _a.size, size = _b === void 0 ? "xs" : _b, _c = _a.ml, ml = _c === void 0 ? "1.25rem" : _c, _d = _a.mt, mt = _d === void 0 ? 2 : _d;
25
+ return (react_1.default.createElement(react_2.VStack, { spacing: 2, align: "stretch", mt: mt, ml: ml },
26
+ react_1.default.createElement(react_2.Select, { size: size, value: operator, onChange: function (e) { return onOperatorChange(e.target.value); }, sx: { fontSize: "0.75rem", height: "24px" }, width: "110px" }, exports.TEXT_OPERATORS.map(function (op) { return (react_1.default.createElement("option", { key: op, value: op }, op)); })),
27
+ (0, exports.requiresValue)(operator) && (react_1.default.createElement(react_2.Input, { size: size, placeholder: "Type here", value: value, onChange: function (e) { return onValueChange(e.target.value); }, sx: { fontSize: "0.75rem", height: "24px" }, width: "100%" }))));
28
+ }
29
+ exports.TextOperationControls = TextOperationControls;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixelize-design-library",
3
- "version": "2.2.106",
3
+ "version": "2.2.108",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",