pixelize-design-library 2.2.94 → 2.2.96
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.
- package/dist/Components/Checkbox/Checkbox.d.ts +1 -1
- package/dist/Components/Checkbox/Checkbox.js +2 -4
- package/dist/Components/Checkbox/Checkbox.styles.js +19 -13
- package/dist/Components/Checkbox/CheckboxProps.d.ts +1 -1
- package/dist/Components/FilterSidebar/FilterSidebar.d.ts +38 -0
- package/dist/Components/FilterSidebar/FilterSidebar.js +266 -0
- package/dist/Components/Table/Components/ActiveFilters.d.ts +9 -0
- package/dist/Components/Table/Components/ActiveFilters.js +91 -0
- package/dist/Components/Table/Components/TableFilters.d.ts +4 -1
- package/dist/Components/Table/Components/TableFilters.js +17 -5
- package/dist/Components/Table/Components/TableHeader.js +7 -3
- package/dist/Components/Table/Table.js +3 -6
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -2
- package/package.json +1 -1
|
@@ -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, }: CheckboxProps): React.JSX.Element;
|
|
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;
|
|
@@ -10,12 +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;
|
|
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;
|
|
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, { spacing: spacing, isInvalid: isInvalid,
|
|
17
|
-
// isRequired={isRequired}
|
|
18
|
-
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, isInformation: isInformation, informationMessage: informationMessage, isRequired: isRequired }))),
|
|
19
17
|
error && react_1.default.createElement(ErrorMessage_1.default, { errorMessage: errorMessage }),
|
|
20
18
|
helperText && !error && react_1.default.createElement(HelperText_1.default, { helperText: helperText })));
|
|
21
19
|
}
|
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Checkbox = void 0;
|
|
4
4
|
exports.Checkbox = {
|
|
5
5
|
baseStyle: function (_a) {
|
|
6
|
-
var
|
|
6
|
+
var _b;
|
|
7
|
+
var theme = _a.theme, _c = _a.colorScheme, colorScheme = _c === void 0 ? "primary" : _c;
|
|
8
|
+
var palette = (_b = theme.colors[colorScheme]) !== null && _b !== void 0 ? _b : theme.colors.primary;
|
|
7
9
|
return {
|
|
8
10
|
control: {
|
|
9
11
|
width: "1.25rem",
|
|
@@ -16,34 +18,34 @@ exports.Checkbox = {
|
|
|
16
18
|
},
|
|
17
19
|
_indeterminate: {
|
|
18
20
|
bg: theme.colors.background[50],
|
|
19
|
-
borderColor:
|
|
21
|
+
borderColor: palette[500],
|
|
20
22
|
svg: {
|
|
21
|
-
color:
|
|
23
|
+
color: palette[500],
|
|
22
24
|
},
|
|
23
25
|
},
|
|
24
26
|
_checked: {
|
|
25
|
-
bg:
|
|
26
|
-
borderColor:
|
|
27
|
+
bg: palette[600],
|
|
28
|
+
borderColor: palette[600],
|
|
27
29
|
},
|
|
28
30
|
_hover: {
|
|
29
31
|
bg: theme.colors.background[100],
|
|
30
|
-
borderColor:
|
|
32
|
+
borderColor: palette[400],
|
|
31
33
|
_checked: {
|
|
32
|
-
bg:
|
|
33
|
-
borderColor:
|
|
34
|
+
bg: palette[600],
|
|
35
|
+
borderColor: palette[600],
|
|
34
36
|
},
|
|
35
37
|
_indeterminate: {
|
|
36
38
|
bg: "none",
|
|
37
|
-
borderColor:
|
|
39
|
+
borderColor: palette[600],
|
|
38
40
|
},
|
|
39
41
|
},
|
|
40
42
|
_focus: {
|
|
41
|
-
boxShadow: "0 0 0 2px ".concat(
|
|
42
|
-
borderColor:
|
|
43
|
+
boxShadow: "0 0 0 2px ".concat(palette[300]),
|
|
44
|
+
borderColor: palette[500],
|
|
43
45
|
},
|
|
44
46
|
_active: {
|
|
45
|
-
bg:
|
|
46
|
-
borderColor:
|
|
47
|
+
bg: palette[600],
|
|
48
|
+
borderColor: palette[600],
|
|
47
49
|
},
|
|
48
50
|
},
|
|
49
51
|
icon: {
|
|
@@ -51,4 +53,8 @@ exports.Checkbox = {
|
|
|
51
53
|
},
|
|
52
54
|
};
|
|
53
55
|
},
|
|
56
|
+
defaultProps: {
|
|
57
|
+
colorScheme: "primary",
|
|
58
|
+
size: "md",
|
|
59
|
+
},
|
|
54
60
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CheckboxProps as ChakraButtonProps } from "@chakra-ui/react";
|
|
2
|
-
export type CheckboxProps = Pick<ChakraButtonProps, "spacing" | "isInvalid" | "size" | "iconColor" | "iconSize" | "isChecked" | "isIndeterminate" | "onChange" | "isDisabled" | "value" | "defaultChecked" | "sx"> & {
|
|
2
|
+
export type CheckboxProps = Pick<ChakraButtonProps, "spacing" | "isInvalid" | "size" | "iconColor" | "iconSize" | "isChecked" | "isIndeterminate" | "onChange" | "isDisabled" | "value" | "defaultChecked" | "sx" | "onClick"> & {
|
|
3
3
|
label?: string;
|
|
4
4
|
width?: string | number;
|
|
5
5
|
variant?: "solid" | "outline" | "ghost" | "link" | "unstyled";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type FilterOption = {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
count?: number;
|
|
6
|
+
};
|
|
7
|
+
export type FilterSection = {
|
|
8
|
+
id: string;
|
|
9
|
+
label: string;
|
|
10
|
+
options?: FilterOption[];
|
|
11
|
+
searchable?: boolean;
|
|
12
|
+
range?: {
|
|
13
|
+
min: number;
|
|
14
|
+
max: number;
|
|
15
|
+
step?: number;
|
|
16
|
+
values?: number[];
|
|
17
|
+
unit?: string;
|
|
18
|
+
};
|
|
19
|
+
initiallyExpanded?: boolean;
|
|
20
|
+
type?: "checkboxes" | "radio";
|
|
21
|
+
checkboxes?: boolean;
|
|
22
|
+
radio?: boolean;
|
|
23
|
+
};
|
|
24
|
+
export type SelectedFilters = Record<string, any>;
|
|
25
|
+
export type FilterSidebarProps = {
|
|
26
|
+
sidebarOptions: FilterSection[];
|
|
27
|
+
selected?: SelectedFilters;
|
|
28
|
+
onChange?: (selected: SelectedFilters) => void;
|
|
29
|
+
maxVisible?: number;
|
|
30
|
+
width?: string | number;
|
|
31
|
+
variant?: "minimal" | "cards";
|
|
32
|
+
containerHeight?: number | string;
|
|
33
|
+
containerPadding?: number | string;
|
|
34
|
+
headerPadding?: number;
|
|
35
|
+
panelPadding?: number;
|
|
36
|
+
};
|
|
37
|
+
declare const FilterSidebar: React.FC<FilterSidebarProps>;
|
|
38
|
+
export default FilterSidebar;
|
|
@@ -0,0 +1,266 @@
|
|
|
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 Accordion_1 = __importDefault(require("../Accordion/Accordion"));
|
|
44
|
+
var Checkbox_1 = __importDefault(require("../Checkbox/Checkbox"));
|
|
45
|
+
var useCustomTheme_1 = require("../../Theme/useCustomTheme");
|
|
46
|
+
var FilterSidebar = function (_a) {
|
|
47
|
+
var sidebarOptions = _a.sidebarOptions, selected = _a.selected, onChange = _a.onChange, _b = _a.maxVisible, maxVisible = _b === void 0 ? 10 : _b, _c = _a.width, width = _c === void 0 ? 280 : _c, _d = _a.variant, variant = _d === void 0 ? "minimal" : _d, containerPadding = _a.containerPadding, _e = _a.headerPadding, headerPadding = _e === void 0 ? 2 : _e, _f = _a.panelPadding, panelPadding = _f === void 0 ? 3 : _f;
|
|
48
|
+
var theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
49
|
+
// Determine if the component is controlled (prop provided) or uncontrolled (internal state)
|
|
50
|
+
var isControlled = selected !== undefined;
|
|
51
|
+
// Local state for uncontrolled mode
|
|
52
|
+
var _g = (0, react_1.useState)(function () { return (__assign({}, (selected || {}))); }), localSelected = _g[0], setLocalSelected = _g[1];
|
|
53
|
+
// Derived state: use prop if controlled, otherwise local state
|
|
54
|
+
var internalSelected = (selected !== undefined ? selected : localSelected);
|
|
55
|
+
// Wrapper for state updates to handle both modes
|
|
56
|
+
var setInternalSelected = function (updater) {
|
|
57
|
+
var next = typeof updater === 'function' ? updater(internalSelected) : updater;
|
|
58
|
+
// In the existing code, the updater function often handles calling onChange.
|
|
59
|
+
// However, for safety in uncontrolled mode, we update local state.
|
|
60
|
+
if (!isControlled) {
|
|
61
|
+
setLocalSelected(next);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var _h = (0, react_1.useState)(function () {
|
|
65
|
+
var initial = {};
|
|
66
|
+
sidebarOptions.forEach(function (s) { return (initial[s.id] = !!s.initiallyExpanded); });
|
|
67
|
+
return initial;
|
|
68
|
+
}), expanded = _h[0], setExpanded = _h[1];
|
|
69
|
+
var _j = (0, react_1.useState)({}), searchTerms = _j[0], setSearchTerms = _j[1];
|
|
70
|
+
var activeCount = (0, react_1.useMemo)(function () {
|
|
71
|
+
return Object.values(internalSelected).reduce(function (acc, v) { return acc + (Array.isArray(v) ? v.length : 0); }, 0);
|
|
72
|
+
}, [internalSelected]);
|
|
73
|
+
var toggleOption = function (sectionId, optionId, checked) {
|
|
74
|
+
setInternalSelected(function (prev) {
|
|
75
|
+
var _a;
|
|
76
|
+
var current = new Set(prev[sectionId] || []);
|
|
77
|
+
if (checked)
|
|
78
|
+
current.add(optionId);
|
|
79
|
+
else
|
|
80
|
+
current.delete(optionId);
|
|
81
|
+
var next = __assign(__assign({}, prev), (_a = {}, _a[sectionId] = Array.from(current), _a));
|
|
82
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(next);
|
|
83
|
+
return next;
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
var clearFilter = function (sectionId, optionId) {
|
|
87
|
+
setInternalSelected(function (prev) {
|
|
88
|
+
var next = __assign({}, prev);
|
|
89
|
+
if (optionId) {
|
|
90
|
+
var list = (next[sectionId] || []);
|
|
91
|
+
next[sectionId] = list.filter(function (id) { return id !== optionId; });
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
delete next[sectionId];
|
|
95
|
+
}
|
|
96
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(next);
|
|
97
|
+
return next;
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
var clearAll = function () {
|
|
101
|
+
setInternalSelected(function () {
|
|
102
|
+
var next = {};
|
|
103
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(next);
|
|
104
|
+
return next;
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
var items = sidebarOptions.map(function (section) { return ({
|
|
108
|
+
header: (react_1.default.createElement(react_2.Flex, { justify: "space-between", align: "center", w: "full", py: 1 },
|
|
109
|
+
react_1.default.createElement(react_2.Text, { fontWeight: "bold", fontSize: "md", color: theme.colors.gray[700] }, section.label),
|
|
110
|
+
(function () {
|
|
111
|
+
var sel = internalSelected[section.id];
|
|
112
|
+
var hasValue = Array.isArray(sel) ? sel.length > 0 : !!sel;
|
|
113
|
+
return hasValue;
|
|
114
|
+
})() ? (react_1.default.createElement(react_2.Badge, { colorScheme: "red", variant: "solid", fontSize: "xs", cursor: "pointer", onClick: function (e) {
|
|
115
|
+
e.stopPropagation();
|
|
116
|
+
clearFilter(section.id);
|
|
117
|
+
}, borderRadius: "full", px: 2 }, "Clear")) : null)),
|
|
118
|
+
content: (react_1.default.createElement(react_2.VStack, { align: "start", spacing: 2, py: 1 }, section.range ? ((function () {
|
|
119
|
+
var _a, _b, _c, _d;
|
|
120
|
+
var range = section.range;
|
|
121
|
+
var step = range.step || 1;
|
|
122
|
+
var values = range.values || Array.from({ length: Math.floor((range.max - range.min) / (step || 100)) + 1 }, function (_, i) { return range.min + i * (step || 100); });
|
|
123
|
+
return (react_1.default.createElement(react_2.Box, { w: "full", px: 2 },
|
|
124
|
+
react_1.default.createElement(react_2.RangeSlider
|
|
125
|
+
// aria-label={["min", "max"]}
|
|
126
|
+
, {
|
|
127
|
+
// aria-label={["min", "max"]}
|
|
128
|
+
min: range.min, max: range.max, step: step, value: internalSelected[section.id] || [range.min, range.max], onChange: function (val) {
|
|
129
|
+
setInternalSelected(function (prev) {
|
|
130
|
+
var _a;
|
|
131
|
+
var next = __assign(__assign({}, prev), (_a = {}, _a[section.id] = val, _a));
|
|
132
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(next);
|
|
133
|
+
return next;
|
|
134
|
+
});
|
|
135
|
+
}, mb: 4 },
|
|
136
|
+
react_1.default.createElement(react_2.RangeSliderTrack, { bg: theme.colors.gray[200], h: 2, borderRadius: "full" },
|
|
137
|
+
react_1.default.createElement(react_2.RangeSliderFilledTrack, { bg: theme.colors.red[500] })),
|
|
138
|
+
react_1.default.createElement(react_2.RangeSliderThumb, { index: 0, boxSize: 5, borderColor: theme.colors.gray[300], boxShadow: "sm" }),
|
|
139
|
+
react_1.default.createElement(react_2.RangeSliderThumb, { index: 1, boxSize: 5, borderColor: theme.colors.gray[300], boxShadow: "sm" })),
|
|
140
|
+
react_1.default.createElement(react_2.HStack, { w: "full", justify: "space-between" },
|
|
141
|
+
react_1.default.createElement(react_2.Box, { className: "price-min", borderWidth: "1px", borderRadius: "md", p: 2, minW: "90px", textAlign: "center", bg: theme.colors.gray[50], borderColor: theme.colors.gray[200] },
|
|
142
|
+
react_1.default.createElement(react_2.Text, { fontSize: "xs", color: "gray.600", mb: "-2px" }, "Min"),
|
|
143
|
+
react_1.default.createElement(react_2.Select, { "aria-label": "Minimum price", className: "price-min-select", variant: "outline", size: "sm", textAlign: "center", borderColor: theme.colors.gray[300], bg: theme.colors.white, borderRadius: "full", _hover: { borderColor: theme.colors.gray[400] }, _focus: { borderColor: theme.colors.red[500], boxShadow: "none" }, value: ((_b = (_a = internalSelected[section.id]) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : range.min), onChange: function (e) {
|
|
144
|
+
var _a, _b;
|
|
145
|
+
var min = Number(e.target.value);
|
|
146
|
+
var max = (_b = (_a = internalSelected[section.id]) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : range.max;
|
|
147
|
+
var nextVal = [Math.min(min, max), Math.max(min, max)];
|
|
148
|
+
setInternalSelected(function (prev) {
|
|
149
|
+
var _a;
|
|
150
|
+
var next = __assign(__assign({}, prev), (_a = {}, _a[section.id] = nextVal, _a));
|
|
151
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(next);
|
|
152
|
+
return next;
|
|
153
|
+
});
|
|
154
|
+
} }, values.map(function (v) { return (react_1.default.createElement("option", { key: "min-".concat(v), value: v },
|
|
155
|
+
v,
|
|
156
|
+
range.unit ? " ".concat(range.unit) : "")); }))),
|
|
157
|
+
react_1.default.createElement(react_2.Text, { fontSize: "sm", color: "gray.400" }, "-"),
|
|
158
|
+
react_1.default.createElement(react_2.Box, { className: "price-max", borderWidth: "1px", borderRadius: "md", p: 2, minW: "100px", textAlign: "center", bg: theme.colors.gray[50], borderColor: theme.colors.gray[200] },
|
|
159
|
+
react_1.default.createElement(react_2.Text, { fontSize: "xs", color: "gray.600", mb: "-2px" }, "Max"),
|
|
160
|
+
react_1.default.createElement(react_2.Select, { "aria-label": "Maximum price", className: "price-max-select", variant: "outline", size: "sm", textAlign: "center", borderColor: theme.colors.gray[300], bg: theme.colors.white, borderRadius: "full", _hover: { borderColor: theme.colors.gray[400] }, _focus: { borderColor: theme.colors.red[500], boxShadow: "none" }, value: ((_d = (_c = internalSelected[section.id]) === null || _c === void 0 ? void 0 : _c[1]) !== null && _d !== void 0 ? _d : range.max), onChange: function (e) {
|
|
161
|
+
var _a, _b;
|
|
162
|
+
var max = Number(e.target.value);
|
|
163
|
+
var min = (_b = (_a = internalSelected[section.id]) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : range.min;
|
|
164
|
+
var nextVal = [Math.min(min, max), Math.max(min, max)];
|
|
165
|
+
setInternalSelected(function (prev) {
|
|
166
|
+
var _a;
|
|
167
|
+
var next = __assign(__assign({}, prev), (_a = {}, _a[section.id] = nextVal, _a));
|
|
168
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(next);
|
|
169
|
+
return next;
|
|
170
|
+
});
|
|
171
|
+
} }, values.map(function (v) { return (react_1.default.createElement("option", { key: "max-".concat(v), value: v },
|
|
172
|
+
v,
|
|
173
|
+
range.unit ? " ".concat(range.unit) : "")); }))))));
|
|
174
|
+
})()) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
175
|
+
section.id === "rating" ? (react_1.default.createElement(react_2.VStack, { align: "start", spacing: 1, w: "full" }, [4, 3, 2, 1].map(function (r) { return (react_1.default.createElement(react_2.Flex, { key: "rating-".concat(r), align: "center", justify: "space-between", w: "full", p: 1, borderRadius: "md", cursor: "pointer", _hover: { bg: theme.colors.gray[50] }, onClick: function () {
|
|
176
|
+
setInternalSelected(function (prev) {
|
|
177
|
+
var _a;
|
|
178
|
+
var next = __assign(__assign({}, prev), (_a = {}, _a[section.id] = String(r), _a));
|
|
179
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(next);
|
|
180
|
+
return next;
|
|
181
|
+
});
|
|
182
|
+
} },
|
|
183
|
+
react_1.default.createElement(react_2.HStack, { spacing: 2, align: "center" },
|
|
184
|
+
react_1.default.createElement(react_2.HStack, { spacing: 1 }, Array.from({ length: 5 }, function (_, i) { return (react_1.default.createElement(react_2.Box, { key: "star-".concat(r, "-").concat(i) },
|
|
185
|
+
react_1.default.createElement(lucide_react_1.Star, { size: 16, color: theme.colors.orange[500], fill: i < r ? theme.colors.orange[500] : "none" }))); })),
|
|
186
|
+
react_1.default.createElement(react_2.Text, { fontSize: "sm", color: theme.colors.gray[700] }, "& Up")),
|
|
187
|
+
String(internalSelected[section.id] || "") === String(r) && (react_1.default.createElement(react_2.Badge, { fontSize: "xs", colorScheme: "red", borderRadius: "full", px: 2 }, "Selected")))); }))) : null,
|
|
188
|
+
section.searchable && (react_1.default.createElement(react_2.Input, { size: "sm", placeholder: "Search ".concat(section.label, "..."), borderRadius: "md", bg: theme.colors.gray[50], border: "1px solid", borderColor: theme.colors.gray[200], _focus: { borderColor: theme.colors.red[400], boxShadow: "none" }, value: searchTerms[section.id] || "", onChange: function (e) {
|
|
189
|
+
var v = e.target.value;
|
|
190
|
+
setSearchTerms(function (prev) {
|
|
191
|
+
var _a;
|
|
192
|
+
return (__assign(__assign({}, prev), (_a = {}, _a[section.id] = v, _a)));
|
|
193
|
+
});
|
|
194
|
+
if (v)
|
|
195
|
+
setExpanded(function (prev) {
|
|
196
|
+
var _a;
|
|
197
|
+
return (__assign(__assign({}, prev), (_a = {}, _a[section.id] = true, _a)));
|
|
198
|
+
});
|
|
199
|
+
} })),
|
|
200
|
+
section.id !== "rating" && (((section.type === "radio") || section.radio) ? (react_1.default.createElement(react_2.RadioGroup, { w: "full", value: internalSelected[section.id] || "", onChange: function (val) {
|
|
201
|
+
setInternalSelected(function (prev) {
|
|
202
|
+
var _a;
|
|
203
|
+
var next = __assign(__assign({}, prev), (_a = {}, _a[section.id] = val, _a));
|
|
204
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(next);
|
|
205
|
+
return next;
|
|
206
|
+
});
|
|
207
|
+
} },
|
|
208
|
+
react_1.default.createElement(react_2.VStack, { align: "start", spacing: 3, w: "full" }, ((expanded[section.id] ? (section.options || []) : (section.options || []).slice(0, maxVisible))
|
|
209
|
+
.filter(function (opt) { return !section.searchable || !(searchTerms[section.id]) || opt.label.toLowerCase().includes((searchTerms[section.id] || "").toLowerCase()); })).map(function (opt) { return (react_1.default.createElement(react_2.Radio, { key: opt.id, value: opt.id, size: "md", colorScheme: "red" },
|
|
210
|
+
react_1.default.createElement(react_2.Text, { fontSize: "sm", color: theme.colors.gray[700] }, opt.label))); })))) : (((expanded[section.id] ? (section.options || []) : (section.options || []).slice(0, maxVisible))
|
|
211
|
+
.filter(function (opt) { return !section.searchable || !(searchTerms[section.id]) || opt.label.toLowerCase().includes((searchTerms[section.id] || "").toLowerCase()); })).map(function (opt) { return (react_1.default.createElement(react_2.Flex, { key: opt.id, align: "center", justify: "space-between", w: "full", _hover: { bg: theme.colors.gray[50], borderRadius: "md" }, p: 1 },
|
|
212
|
+
react_1.default.createElement(react_2.Flex, { align: "center", gap: 3 },
|
|
213
|
+
react_1.default.createElement(Checkbox_1.default, { isChecked: Array.isArray(internalSelected[section.id]) && (internalSelected[section.id] || []).includes(opt.id), onChange: function (e) {
|
|
214
|
+
toggleOption(section.id, opt.id, e.target.checked);
|
|
215
|
+
}, size: "sm", color: "red" }),
|
|
216
|
+
react_1.default.createElement(react_2.Text, { fontSize: "sm", color: theme.colors.gray[700], cursor: "pointer", onClick: function () {
|
|
217
|
+
var isChecked = Array.isArray(internalSelected[section.id]) && (internalSelected[section.id] || []).includes(opt.id);
|
|
218
|
+
toggleOption(section.id, opt.id, !isChecked);
|
|
219
|
+
} }, opt.label)),
|
|
220
|
+
typeof opt.count === "number" && (react_1.default.createElement(react_2.Badge, { fontSize: "xs", colorScheme: "gray", borderRadius: "full", px: 2 }, opt.count)))); }))),
|
|
221
|
+
(section.options && section.options.length > maxVisible) && (react_1.default.createElement(react_2.Text, { fontSize: "sm", fontWeight: "medium", color: theme.colors.blue[600], cursor: "pointer", _hover: { textDecoration: "underline" }, onClick: function () { return setExpanded(function (prev) {
|
|
222
|
+
var _a;
|
|
223
|
+
return (__assign(__assign({}, prev), (_a = {}, _a[section.id] = !prev[section.id], _a)));
|
|
224
|
+
}); } }, expanded[section.id] ? "Show less" : "+ ".concat((section.options.length - maxVisible), " more"))))))),
|
|
225
|
+
itemProps: {
|
|
226
|
+
borderTop: "none",
|
|
227
|
+
borderBottom: "1px solid ".concat(theme.colors.gray[100]),
|
|
228
|
+
_last: { borderBottom: "none" }
|
|
229
|
+
},
|
|
230
|
+
buttonProps: {
|
|
231
|
+
_hover: { bg: theme.colors.gray[50] }
|
|
232
|
+
},
|
|
233
|
+
panelProps: {},
|
|
234
|
+
customStyles: {
|
|
235
|
+
buttonStyle: variant === "minimal"
|
|
236
|
+
? {
|
|
237
|
+
justifyContent: "space-between",
|
|
238
|
+
padding: "8px 0",
|
|
239
|
+
background: "transparent",
|
|
240
|
+
}
|
|
241
|
+
: {
|
|
242
|
+
justifyContent: "space-between",
|
|
243
|
+
padding: headerPadding,
|
|
244
|
+
background: theme.colors.gray[50],
|
|
245
|
+
borderRadius: 8,
|
|
246
|
+
border: "1px solid ".concat(theme.colors.gray[200]),
|
|
247
|
+
marginBottom: 6,
|
|
248
|
+
},
|
|
249
|
+
panelStyle: variant === "minimal"
|
|
250
|
+
? {
|
|
251
|
+
padding: "4px 0 8px 0",
|
|
252
|
+
}
|
|
253
|
+
: {
|
|
254
|
+
padding: panelPadding,
|
|
255
|
+
background: theme.colors.white || "#fff",
|
|
256
|
+
borderRadius: 8,
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
}); });
|
|
260
|
+
return (react_1.default.createElement(react_2.Box, { w: width, bg: variant === "minimal" ? theme.colors.white || "#fff" : theme.colors.gray[50], p: containerPadding !== undefined ? containerPadding : (variant === "minimal" ? 3 : 2), borderRadius: variant === "minimal" ? "lg" : "none", boxShadow: variant === "minimal" ? "sm" : "none", border: variant === "minimal" ? "1px solid ".concat(theme.colors.gray[200]) : "none", h: "fit-content" },
|
|
261
|
+
react_1.default.createElement(react_2.Flex, { className: "filters-header", align: "center", justify: "space-between", mb: 2, borderBottom: "2px solid", borderColor: theme.colors.gray[100] },
|
|
262
|
+
react_1.default.createElement(react_2.Text, { fontSize: "lg", fontWeight: "bold", color: theme.colors.gray[800] }, "Filters"),
|
|
263
|
+
activeCount > 0 && (react_1.default.createElement(react_2.Button, { size: "xs", variant: "outline", leftIcon: react_1.default.createElement(lucide_react_1.X, { size: 12 }), onClick: clearAll, "aria-label": "Clear All", className: "clear-all-btn", colorScheme: "red" }, "Clear All"))),
|
|
264
|
+
react_1.default.createElement(Accordion_1.default, { allowMultiple: true, defaultIndex: sidebarOptions.map(function (_, i) { return i; }), items: items })));
|
|
265
|
+
};
|
|
266
|
+
exports.default = FilterSidebar;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { TableHeaderProps } from "../TableProps";
|
|
3
|
+
interface ActiveFiltersProps {
|
|
4
|
+
columns: TableHeaderProps[];
|
|
5
|
+
columnsSearch: Record<string, string>;
|
|
6
|
+
setColumnsSearch: React.Dispatch<React.SetStateAction<Record<string, string>>>;
|
|
7
|
+
}
|
|
8
|
+
declare const ActiveFilters: React.FC<ActiveFiltersProps>;
|
|
9
|
+
export default ActiveFilters;
|
|
@@ -0,0 +1,91 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
var react_1 = __importDefault(require("react"));
|
|
18
|
+
var react_2 = require("@chakra-ui/react");
|
|
19
|
+
var lucide_react_1 = require("lucide-react");
|
|
20
|
+
var useCustomTheme_1 = require("../../../Theme/useCustomTheme");
|
|
21
|
+
var Divider_1 = __importDefault(require("../../Divider/Divider"));
|
|
22
|
+
var ActiveFilters = function (_a) {
|
|
23
|
+
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
24
|
+
var columns = _a.columns, columnsSearch = _a.columnsSearch, setColumnsSearch = _a.setColumnsSearch;
|
|
25
|
+
var theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
26
|
+
// Get active filters (columns that have a search value)
|
|
27
|
+
var activeFilters = Object.entries(columnsSearch)
|
|
28
|
+
.filter(function (_a) {
|
|
29
|
+
var _ = _a[0], value = _a[1];
|
|
30
|
+
return value && value.trim() !== "";
|
|
31
|
+
})
|
|
32
|
+
.map(function (_a) {
|
|
33
|
+
var columnId = _a[0], value = _a[1];
|
|
34
|
+
var column = columns.find(function (col) { return col.id === columnId; });
|
|
35
|
+
return {
|
|
36
|
+
columnId: columnId,
|
|
37
|
+
label: (column === null || column === void 0 ? void 0 : column.label) || columnId,
|
|
38
|
+
value: value.trim(),
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
if (activeFilters.length === 0) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
var handleRemoveFilter = function (columnId) {
|
|
45
|
+
setColumnsSearch(function (prev) {
|
|
46
|
+
var newSearch = __assign({}, prev);
|
|
47
|
+
delete newSearch[columnId];
|
|
48
|
+
return newSearch;
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
var handleClearAll = function () {
|
|
52
|
+
setColumnsSearch({});
|
|
53
|
+
};
|
|
54
|
+
return (react_1.default.createElement(react_2.Box, { px: 2, py: 1, bg: ((_c = (_b = theme.colors) === null || _b === void 0 ? void 0 : _b.background) === null || _c === void 0 ? void 0 : _c[100]) || ((_e = (_d = theme.colors) === null || _d === void 0 ? void 0 : _d.gray) === null || _e === void 0 ? void 0 : _e[50]), overflowX: "auto", sx: {
|
|
55
|
+
'&::-webkit-scrollbar': {
|
|
56
|
+
height: '6px',
|
|
57
|
+
},
|
|
58
|
+
'&::-webkit-scrollbar-track': {
|
|
59
|
+
background: theme.colors.gray[100],
|
|
60
|
+
borderRadius: '3px',
|
|
61
|
+
},
|
|
62
|
+
'&::-webkit-scrollbar-thumb': {
|
|
63
|
+
background: theme.colors.gray[400],
|
|
64
|
+
borderRadius: '3px',
|
|
65
|
+
},
|
|
66
|
+
'&::-webkit-scrollbar-thumb:hover': {
|
|
67
|
+
background: theme.colors.gray[500],
|
|
68
|
+
},
|
|
69
|
+
scrollbarWidth: 'thin',
|
|
70
|
+
scrollbarColor: "".concat(theme.colors.gray[400], " ").concat(theme.colors.gray[100]),
|
|
71
|
+
} },
|
|
72
|
+
react_1.default.createElement(react_2.Box, { display: "flex", alignItems: "center", gap: 2, flexWrap: "nowrap", minW: "max-content" },
|
|
73
|
+
activeFilters.length > 0 && react_1.default.createElement(Divider_1.default, null),
|
|
74
|
+
activeFilters.map(function (filter) {
|
|
75
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
76
|
+
return (react_1.default.createElement(react_2.Flex, { key: filter.columnId, alignItems: "center", gap: 1, px: 2, py: 1, bg: ((_b = (_a = theme.colors) === null || _a === void 0 ? void 0 : _a.blue) === null || _b === void 0 ? void 0 : _b[50]) || ((_d = (_c = theme.colors) === null || _c === void 0 ? void 0 : _c.primary) === null || _d === void 0 ? void 0 : _d[50]), borderRadius: "md", border: "0.063rem solid ".concat(((_f = (_e = theme.colors) === null || _e === void 0 ? void 0 : _e.blue) === null || _f === void 0 ? void 0 : _f[200]) || ((_h = (_g = theme.colors) === null || _g === void 0 ? void 0 : _g.primary) === null || _h === void 0 ? void 0 : _h[200])), flexShrink: 0 },
|
|
77
|
+
react_1.default.createElement(react_2.Text, { fontSize: "sm", color: (_k = (_j = theme.colors) === null || _j === void 0 ? void 0 : _j.gray) === null || _k === void 0 ? void 0 : _k[700], whiteSpace: "nowrap" },
|
|
78
|
+
react_1.default.createElement(react_2.Text, { as: "span", fontWeight: 600 },
|
|
79
|
+
filter.label,
|
|
80
|
+
":"),
|
|
81
|
+
" ",
|
|
82
|
+
filter.value),
|
|
83
|
+
react_1.default.createElement(react_2.IconButton, { "aria-label": "Remove filter for ".concat(filter.label), icon: react_1.default.createElement(lucide_react_1.X, { size: 14 }), size: "xs", variant: "ghost", onClick: function () { return handleRemoveFilter(filter.columnId); }, _hover: {
|
|
84
|
+
bg: ((_m = (_l = theme.colors) === null || _l === void 0 ? void 0 : _l.blue) === null || _m === void 0 ? void 0 : _m[100]) || ((_p = (_o = theme.colors) === null || _o === void 0 ? void 0 : _o.primary) === null || _p === void 0 ? void 0 : _p[100]),
|
|
85
|
+
}, minW: "auto", h: "auto", p: 0.5, flexShrink: 0 })));
|
|
86
|
+
}),
|
|
87
|
+
activeFilters.length > 1 && (react_1.default.createElement(react_2.Text, { as: "p", className: "clear-all-text", "aria-label": "Clear All", fontSize: "sm", color: ((_g = (_f = theme.colors) === null || _f === void 0 ? void 0 : _f.blue) === null || _g === void 0 ? void 0 : _g[600]) || ((_j = (_h = theme.colors) === null || _h === void 0 ? void 0 : _h.primary) === null || _j === void 0 ? void 0 : _j[600]), cursor: "pointer", fontWeight: 500, onClick: handleClearAll, _hover: {
|
|
88
|
+
textDecoration: "underline",
|
|
89
|
+
}, flexShrink: 0, whiteSpace: "nowrap" }, "Clear All")))));
|
|
90
|
+
};
|
|
91
|
+
exports.default = ActiveFilters;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { TableFiltersProps } from "../TableProps";
|
|
3
|
-
declare const TableFilters: React.MemoExoticComponent<({ header, setColumnsSearch, columnsSearch, onClose }: TableFiltersProps
|
|
3
|
+
declare const TableFilters: React.MemoExoticComponent<({ header, setColumnsSearch, columnsSearch, onClose, isOpen, onOpen, }: TableFiltersProps & {
|
|
4
|
+
isOpen?: boolean | undefined;
|
|
5
|
+
onOpen?: (() => void) | undefined;
|
|
6
|
+
}) => React.JSX.Element>;
|
|
4
7
|
export default TableFilters;
|
|
@@ -28,7 +28,7 @@ var react_2 = require("@chakra-ui/react");
|
|
|
28
28
|
var table_1 = require("../../../Utils/table");
|
|
29
29
|
var lucide_react_1 = require("lucide-react");
|
|
30
30
|
var TableFilters = (0, react_1.memo)(function (_a) {
|
|
31
|
-
var header = _a.header, setColumnsSearch = _a.setColumnsSearch, columnsSearch = _a.columnsSearch, onClose = _a.onClose;
|
|
31
|
+
var header = _a.header, setColumnsSearch = _a.setColumnsSearch, columnsSearch = _a.columnsSearch, onClose = _a.onClose, isOpen = _a.isOpen, onOpen = _a.onOpen;
|
|
32
32
|
var searchRef = (0, react_1.useRef)(null);
|
|
33
33
|
var _b = (0, react_1.useState)(false), refreshDataOnOpen = _b[0], setRefreshDataOnOpen = _b[1];
|
|
34
34
|
var debounceRef = (0, table_1.debounce)(function (value) {
|
|
@@ -40,9 +40,21 @@ var TableFilters = (0, react_1.memo)(function (_a) {
|
|
|
40
40
|
}
|
|
41
41
|
/* eslint-disable */
|
|
42
42
|
}, [refreshDataOnOpen]);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
// Auto-focus input when popover opens
|
|
44
|
+
(0, react_1.useEffect)(function () {
|
|
45
|
+
if (isOpen && searchRef.current) {
|
|
46
|
+
// Small delay to ensure popover is fully rendered
|
|
47
|
+
setTimeout(function () {
|
|
48
|
+
var _a;
|
|
49
|
+
(_a = searchRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
50
|
+
}, 100);
|
|
51
|
+
}
|
|
52
|
+
}, [isOpen]);
|
|
53
|
+
var handleOpen = function () {
|
|
54
|
+
setRefreshDataOnOpen(function (prev) { return !prev; });
|
|
55
|
+
onOpen === null || onOpen === void 0 ? void 0 : onOpen();
|
|
56
|
+
};
|
|
57
|
+
return (react_1.default.createElement(react_2.Popover, { isOpen: isOpen, onClose: onClose, onOpen: handleOpen },
|
|
46
58
|
react_1.default.createElement(react_2.PopoverTrigger, null,
|
|
47
59
|
react_1.default.createElement(react_2.IconButton, { "aria-label": "Search", icon: react_1.default.createElement(lucide_react_1.EllipsisVertical, { size: 17 }), size: "xs", variant: "ghost", _hover: { bg: "none" } })),
|
|
48
60
|
react_1.default.createElement(react_2.Portal, null,
|
|
@@ -50,7 +62,7 @@ var TableFilters = (0, react_1.memo)(function (_a) {
|
|
|
50
62
|
react_1.default.createElement(react_2.PopoverBody, { p: 2 },
|
|
51
63
|
react_1.default.createElement(react_2.InputGroup, { flex: "1", size: "xs" },
|
|
52
64
|
react_1.default.createElement(react_2.InputLeftElement, { pointerEvents: "none" },
|
|
53
|
-
react_1.default.createElement(lucide_react_1.Search,
|
|
65
|
+
react_1.default.createElement(react_2.Icon, { as: lucide_react_1.Search, color: "gray.400", boxSize: 4 })),
|
|
54
66
|
react_1.default.createElement(react_2.Input, { autoFocus: true, placeholder: "Search ".concat(header.label, "..."), size: "xs", ref: searchRef, onChange: function (e) {
|
|
55
67
|
e.stopPropagation();
|
|
56
68
|
debounceRef(e.target.value);
|
|
@@ -47,6 +47,7 @@ var Checkbox_1 = __importDefault(require("../../Checkbox/Checkbox"));
|
|
|
47
47
|
var TableHeader = function (_a) {
|
|
48
48
|
var columns = _a.columns, isCheckbox = _a.isCheckbox, handleSort = _a.handleSort, headerRefs = _a.headerRefs, columnWidths = _a.columnWidths, columnsSort = _a.columnsSort, headerBgColor = _a.headerBgColor, headerTextColor = _a.headerTextColor, freezedBgColor = _a.freezedBgColor, freezedTextColor = _a.freezedTextColor, noBorders = _a.noBorders, handleCheckbox = _a.handleCheckbox, checked = _a.checked, isLoading = _a.isLoading, isContent = _a.isContent, isLink = _a.isLink, isActionFreeze = _a.isActionFreeze, setColumnsSearch = _a.setColumnsSearch, columnsSearch = _a.columnsSearch;
|
|
49
49
|
var theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
50
|
+
var _b = (0, react_2.useState)(null), openFilterId = _b[0], setOpenFilterId = _b[1];
|
|
50
51
|
var RenderCheckbox = (0, react_2.useCallback)(function () {
|
|
51
52
|
var _a, _b, _c, _d;
|
|
52
53
|
return (react_2.default.createElement(react_1.Th, { w: 6, fontSize: 14, fontWeight: 600, color: freezedTextColor, textTransform: "capitalize", backgroundColor: (_c = (_b = (_a = theme.colors) === null || _a === void 0 ? void 0 : _a.table) === null || _b === void 0 ? void 0 : _b.hover) === null || _c === void 0 ? void 0 : _c[600], borderY: noBorders ? "none" : "0.063rem solid ".concat((_d = theme.colors) === null || _d === void 0 ? void 0 : _d.gray[300]), position: "sticky", className: "columns sticky-columns", left: "0px", zIndex: 9, boxShadow: "2px 0 5px rgba(0, 0, 0, 0.1)" },
|
|
@@ -73,7 +74,7 @@ var TableHeader = function (_a) {
|
|
|
73
74
|
columns.map(function (header, index) {
|
|
74
75
|
if (header === null || header === void 0 ? void 0 : header.isHidden)
|
|
75
76
|
return null;
|
|
76
|
-
return (react_2.default.createElement(ColumnHeader, { header: header, index: index, key: header.label, columnWidths: columnWidths, handleSort: handleSort, isCheckbox: isCheckbox, headerBgColor: headerBgColor, headerTextColor: headerTextColor, freezedBgColor: freezedBgColor, freezedTextColor: freezedTextColor, noBorders: noBorders, columnsSort: columnsSort, headerRefs: headerRefs, columnsSearch: columnsSearch, setColumnsSearch: setColumnsSearch }));
|
|
77
|
+
return (react_2.default.createElement(ColumnHeader, { header: header, index: index, key: header.label, columnWidths: columnWidths, handleSort: handleSort, isCheckbox: isCheckbox, headerBgColor: headerBgColor, headerTextColor: headerTextColor, freezedBgColor: freezedBgColor, freezedTextColor: freezedTextColor, noBorders: noBorders, columnsSort: columnsSort, headerRefs: headerRefs, columnsSearch: columnsSearch, setColumnsSearch: setColumnsSearch, openFilterId: openFilterId, setOpenFilterId: setOpenFilterId }));
|
|
77
78
|
}),
|
|
78
79
|
isLink && react_2.default.createElement(RenderView, null)));
|
|
79
80
|
};
|
|
@@ -88,7 +89,7 @@ var SortingIcon = (0, react_2.memo)(function (_a) {
|
|
|
88
89
|
});
|
|
89
90
|
var ColumnHeader = (0, react_2.memo)(function (_a) {
|
|
90
91
|
var _b, _c, _d, _e, _f, _g;
|
|
91
|
-
var header = _a.header, index = _a.index, columnWidths = _a.columnWidths, isCheckbox = _a.isCheckbox, headerTextColor = _a.headerTextColor, freezedTextColor = _a.freezedTextColor, noBorders = _a.noBorders, columnsSort = _a.columnsSort, headerRefs = _a.headerRefs, columnsSearch = _a.columnsSearch, setColumnsSearch = _a.setColumnsSearch, handleSort = _a.handleSort;
|
|
92
|
+
var header = _a.header, index = _a.index, columnWidths = _a.columnWidths, isCheckbox = _a.isCheckbox, headerTextColor = _a.headerTextColor, freezedTextColor = _a.freezedTextColor, noBorders = _a.noBorders, columnsSort = _a.columnsSort, headerRefs = _a.headerRefs, columnsSearch = _a.columnsSearch, setColumnsSearch = _a.setColumnsSearch, handleSort = _a.handleSort, openFilterId = _a.openFilterId, setOpenFilterId = _a.setOpenFilterId;
|
|
92
93
|
var _h = (0, react_2.useState)(false), isHovered = _h[0], setIsHovered = _h[1];
|
|
93
94
|
var theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
94
95
|
var isFrozen = header.isFreeze;
|
|
@@ -142,6 +143,9 @@ var ColumnHeader = (0, react_2.memo)(function (_a) {
|
|
|
142
143
|
var _a;
|
|
143
144
|
return (__assign(__assign({}, prev), (_a = {}, _a[header.id] = searchVal, _a)));
|
|
144
145
|
});
|
|
145
|
-
}, columnsSearch: columnsSearch[header.id] || "", onClose: function () {
|
|
146
|
+
}, columnsSearch: columnsSearch[header.id] || "", onClose: function () {
|
|
147
|
+
setIsHovered(false);
|
|
148
|
+
setOpenFilterId(null);
|
|
149
|
+
}, isOpen: openFilterId === header.id, onOpen: function () { return setOpenFilterId(header.id); } })),
|
|
146
150
|
react_2.default.createElement("div", { className: "resize-handle", onMouseDown: handleMouseDown }))));
|
|
147
151
|
});
|
|
@@ -40,6 +40,7 @@ var TableSettings_1 = __importDefault(require("./TableSettings/TableSettings"));
|
|
|
40
40
|
var HeaderActions_1 = __importDefault(require("./Components/HeaderActions"));
|
|
41
41
|
var Divider_1 = __importDefault(require("../Divider/Divider"));
|
|
42
42
|
var TableSearch_1 = __importDefault(require("./Components/TableSearch"));
|
|
43
|
+
var ActiveFilters_1 = __importDefault(require("./Components/ActiveFilters"));
|
|
43
44
|
function Table(_a) {
|
|
44
45
|
var _b, _c, _d, _e, _f, _g;
|
|
45
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 ? {
|
|
@@ -52,11 +53,6 @@ function Table(_a) {
|
|
|
52
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;
|
|
53
54
|
var theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
54
55
|
var _s = (0, react_1.useState)({}), columnsSearch = _s[0], setColumnsSearch = _s[1];
|
|
55
|
-
// useEffect(() => {
|
|
56
|
-
// if (onColumnFilter) {
|
|
57
|
-
// onColumnFilter(columnsSearch);
|
|
58
|
-
// }
|
|
59
|
-
// }, [columnsSearch, onColumnFilter]);
|
|
60
56
|
var isServerPagination = paginationMode === "server";
|
|
61
57
|
var _t = (0, usePreferences_1.useGetPreferences)({
|
|
62
58
|
baseUrl: preferences.url,
|
|
@@ -114,7 +110,8 @@ function Table(_a) {
|
|
|
114
110
|
selection.length ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
115
111
|
react_1.default.createElement(Divider_1.default, null),
|
|
116
112
|
react_1.default.createElement(HeaderActions_1.default, { actions: headerActions, selections: selection }))) : null,
|
|
117
|
-
|
|
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 },
|
|
118
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 })))),
|
|
119
116
|
react_1.default.createElement(react_2.TableContainer, { maxH: 500, overflowY: "auto", sx: {
|
|
120
117
|
'&::-webkit-scrollbar': {
|
package/dist/index.d.ts
CHANGED
|
@@ -59,5 +59,6 @@ import PaymentCard from "./Components/Card/PaymentCard/PaymentCard";
|
|
|
59
59
|
import ApexLineChart from "./Components/Apexcharts/ApexLineChart/ApexLineChart";
|
|
60
60
|
import Notification from "./Components/Notification/Notification";
|
|
61
61
|
import DatePicker from "./Components/DatePicker/ThemeDatePicker";
|
|
62
|
-
|
|
62
|
+
import FilterSidebar from "./Components/FilterSidebar/FilterSidebar";
|
|
63
|
+
export { Accordian, AlertDialog, ApexBarChart, ApexPieChart, ApexPolarChart, ApexLineChart, Breadcrumbs, Button, ButtonGroupIcon, Card, Checkbox, ContactForm, DatePicker, Drawer, DrawerHeader, DrawerBody, DrawerFooter, Dropdown, Editor, FileUpload, FileUploader, FilterSidebar, FormWrapper, Header, HeaderActions, InputTextArea, InputSwitch, KanbanBoard, Loading, Modal, ModalHeader, ModalBody, ModalFooter, NavigationBar, Notification, NoteTextArea, MultiSelect, NumberInput, PaymentCard, PhoneNumberInput, PinInput, ProductCard, ProductDetails, ProfileCard, ProfileCardHeader, ProfileCardBody, ProfileCardFooter, ProfilePhotoViewer, ProgressBar, RadioButton, RadioButtonGroup, Reorder, Search, Select, SearchSelect, SelectSearch, SideBar, Slider, Skeletons, Switch, Table, TableToggle, Tag, TextInput, Timeline, Toaster, ToolTip, useToaster, VerifyEmailOtp, useCustomTheme, ThemesList, debounce, };
|
|
63
64
|
export default withTheme;
|
package/dist/index.js
CHANGED
|
@@ -27,8 +27,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.
|
|
31
|
-
exports.debounce = exports.ThemesList = exports.useCustomTheme = exports.VerifyEmailOtp = exports.useToaster = exports.ToolTip = exports.Toaster = exports.Timeline = exports.TextInput = exports.Tag = exports.TableToggle = exports.Table = exports.Switch = exports.Skeletons = exports.Slider = exports.SideBar = exports.SelectSearch = exports.SearchSelect = exports.Select = exports.Search = exports.Reorder = void 0;
|
|
30
|
+
exports.RadioButton = exports.ProgressBar = exports.ProfilePhotoViewer = exports.ProfileCardFooter = exports.ProfileCardBody = exports.ProfileCardHeader = exports.ProfileCard = exports.ProductDetails = exports.ProductCard = exports.PinInput = exports.PhoneNumberInput = exports.PaymentCard = exports.NumberInput = exports.MultiSelect = exports.NoteTextArea = exports.Notification = exports.NavigationBar = exports.ModalFooter = exports.ModalBody = exports.ModalHeader = exports.Modal = exports.Loading = exports.KanbanBoard = exports.InputSwitch = exports.InputTextArea = exports.HeaderActions = exports.Header = exports.FormWrapper = exports.FilterSidebar = exports.FileUploader = exports.FileUpload = exports.Editor = exports.Dropdown = exports.DrawerFooter = exports.DrawerBody = exports.DrawerHeader = exports.Drawer = exports.DatePicker = exports.ContactForm = exports.Checkbox = exports.Card = exports.ButtonGroupIcon = exports.Button = exports.Breadcrumbs = exports.ApexLineChart = exports.ApexPolarChart = exports.ApexPieChart = exports.ApexBarChart = exports.AlertDialog = exports.Accordian = void 0;
|
|
31
|
+
exports.debounce = exports.ThemesList = exports.useCustomTheme = exports.VerifyEmailOtp = exports.useToaster = exports.ToolTip = exports.Toaster = exports.Timeline = exports.TextInput = exports.Tag = exports.TableToggle = exports.Table = exports.Switch = exports.Skeletons = exports.Slider = exports.SideBar = exports.SelectSearch = exports.SearchSelect = exports.Select = exports.Search = exports.Reorder = exports.RadioButtonGroup = void 0;
|
|
32
32
|
var Accordion_1 = __importDefault(require("./Components/Accordion/Accordion"));
|
|
33
33
|
exports.Accordian = Accordion_1.default;
|
|
34
34
|
var AlertDialog_1 = __importDefault(require("./Components/AlertDialog/AlertDialog"));
|
|
@@ -162,4 +162,6 @@ var Notification_1 = __importDefault(require("./Components/Notification/Notifica
|
|
|
162
162
|
exports.Notification = Notification_1.default;
|
|
163
163
|
var ThemeDatePicker_1 = __importDefault(require("./Components/DatePicker/ThemeDatePicker"));
|
|
164
164
|
exports.DatePicker = ThemeDatePicker_1.default;
|
|
165
|
+
var FilterSidebar_1 = __importDefault(require("./Components/FilterSidebar/FilterSidebar"));
|
|
166
|
+
exports.FilterSidebar = FilterSidebar_1.default;
|
|
165
167
|
exports.default = withTheme_1.default;
|