eidos-ui 1.0.2 → 1.1.0
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/Combobox.types-B7ozlnA9.d.cts +35 -0
- package/dist/Combobox.types-DkigkEh2.d.ts +35 -0
- package/dist/SegmentedControl.types-CK8EiShd.d.ts +35 -0
- package/dist/SegmentedControl.types-Dm4SnwCK.d.cts +35 -0
- package/dist/Select.types-B4kDpkGB.d.ts +42 -0
- package/dist/Select.types-CAkT2ACt.d.cts +42 -0
- package/dist/{chunk-CBLWP43O.cjs → chunk-A5JVDHML.cjs} +197 -74
- package/dist/chunk-A5JVDHML.cjs.map +1 -0
- package/dist/{chunk-S2EICHZK.js → chunk-A5LHCAQY.js} +197 -74
- package/dist/chunk-A5LHCAQY.js.map +1 -0
- package/dist/{chunk-W3X3V72Q.js → chunk-DW2YDWGN.js} +3 -3
- package/dist/chunk-DW2YDWGN.js.map +1 -0
- package/dist/{chunk-YRK56AOP.cjs → chunk-HNUTV3HR.cjs} +3 -3
- package/dist/chunk-HNUTV3HR.cjs.map +1 -0
- package/dist/combobox/index.cjs +2 -2
- package/dist/combobox/index.d.cts +4 -33
- package/dist/combobox/index.d.ts +4 -33
- package/dist/combobox/index.js +1 -1
- package/dist/data-grid/index.cjs +4 -2
- package/dist/data-grid/index.cjs.map +1 -1
- package/dist/data-grid/index.d.cts +91 -3
- package/dist/data-grid/index.d.ts +91 -3
- package/dist/data-grid/index.js +3 -1
- package/dist/index.cjs +8 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +20 -4
- package/dist/index.d.cts +7 -4
- package/dist/index.d.ts +7 -4
- package/dist/index.js +7 -7
- package/dist/segmented-control/index.d.cts +5 -34
- package/dist/segmented-control/index.d.ts +5 -34
- package/dist/select/index.d.cts +5 -41
- package/dist/select/index.d.ts +5 -41
- package/package.json +4 -7
- package/dist/chunk-CBLWP43O.cjs.map +0 -1
- package/dist/chunk-S2EICHZK.js.map +0 -1
- package/dist/chunk-W3X3V72Q.js.map +0 -1
- package/dist/chunk-YRK56AOP.cjs.map +0 -1
|
@@ -21,6 +21,9 @@ import {
|
|
|
21
21
|
import {
|
|
22
22
|
Pagination
|
|
23
23
|
} from "./chunk-56B6RLOE.js";
|
|
24
|
+
import {
|
|
25
|
+
SegmentedControl
|
|
26
|
+
} from "./chunk-BOB5JJ7F.js";
|
|
24
27
|
import {
|
|
25
28
|
Select
|
|
26
29
|
} from "./chunk-5WROPW7Z.js";
|
|
@@ -30,6 +33,9 @@ import {
|
|
|
30
33
|
import {
|
|
31
34
|
Checkbox
|
|
32
35
|
} from "./chunk-H6CWTMAH.js";
|
|
36
|
+
import {
|
|
37
|
+
Combobox
|
|
38
|
+
} from "./chunk-DW2YDWGN.js";
|
|
33
39
|
import {
|
|
34
40
|
Input
|
|
35
41
|
} from "./chunk-WE5FTQGD.js";
|
|
@@ -65,6 +71,13 @@ import {
|
|
|
65
71
|
} from "lucide-react";
|
|
66
72
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
67
73
|
var MIN_COLUMN_WIDTH_PX = 100;
|
|
74
|
+
var QUICK_FILTER_RESET_VALUE = "";
|
|
75
|
+
var hasFilterValue = (value) => {
|
|
76
|
+
if (value === void 0 || value === null || value === "") return false;
|
|
77
|
+
if (Array.isArray(value)) return value.length > 0;
|
|
78
|
+
if (typeof value === "object" && "start" in value) return !!(value.start || value.end);
|
|
79
|
+
return true;
|
|
80
|
+
};
|
|
68
81
|
function SortableTableRow({
|
|
69
82
|
id,
|
|
70
83
|
disabled,
|
|
@@ -176,6 +189,8 @@ function DataGridInner({
|
|
|
176
189
|
filterConfig = [],
|
|
177
190
|
filters,
|
|
178
191
|
onFiltersChange,
|
|
192
|
+
// ── Quick filters ──────────────────────────────────────────────────────────
|
|
193
|
+
quickFilters = [],
|
|
179
194
|
// ── Pagination ─────────────────────────────────────────────────────────────
|
|
180
195
|
showPagination = false,
|
|
181
196
|
pageSize = 10,
|
|
@@ -238,7 +253,13 @@ function DataGridInner({
|
|
|
238
253
|
);
|
|
239
254
|
const effectiveDensity = showDensity ? internalDensity : density;
|
|
240
255
|
const [internalSort, setInternalSort] = useState(null);
|
|
241
|
-
const [internalFilters, setInternalFilters] = useState({
|
|
256
|
+
const [internalFilters, setInternalFilters] = useState(() => {
|
|
257
|
+
const seeded = {};
|
|
258
|
+
quickFilters.forEach(({ key, defaultValue }) => {
|
|
259
|
+
if (hasFilterValue(defaultValue)) seeded[key] = defaultValue;
|
|
260
|
+
});
|
|
261
|
+
return seeded;
|
|
262
|
+
});
|
|
242
263
|
const [currentPage, setCurrentPage] = useState(1);
|
|
243
264
|
const [currentPageSize, setCurrentPageSize] = useState(pageSize);
|
|
244
265
|
const isControlledSelection = controlledSelectedRows !== void 0;
|
|
@@ -319,8 +340,9 @@ function DataGridInner({
|
|
|
319
340
|
() => new Set(isControlledExpansion ? controlledExpandedRows ?? [] : [...internalExpandedKeys]),
|
|
320
341
|
[isControlledExpansion, controlledExpandedRows, internalExpandedKeys]
|
|
321
342
|
);
|
|
343
|
+
const quickFilterKeys = useMemo(() => new Set(quickFilters.map((f) => f.key)), [quickFilters]);
|
|
322
344
|
const filterDropdownColumns = useMemo(() => {
|
|
323
|
-
return filterConfig.map(
|
|
345
|
+
return filterConfig.filter((field) => !quickFilterKeys.has(field.key)).map(
|
|
324
346
|
(field) => ({
|
|
325
347
|
key: field.key,
|
|
326
348
|
label: field.label,
|
|
@@ -330,7 +352,17 @@ function DataGridInner({
|
|
|
330
352
|
dateFilterMode: field.dateFilterMode
|
|
331
353
|
})
|
|
332
354
|
);
|
|
333
|
-
}, [filterConfig]);
|
|
355
|
+
}, [filterConfig, quickFilterKeys]);
|
|
356
|
+
const dropdownFilterKeys = useMemo(
|
|
357
|
+
() => new Set(filterDropdownColumns.map((col) => String(col.key))),
|
|
358
|
+
[filterDropdownColumns]
|
|
359
|
+
);
|
|
360
|
+
const dropdownFilters = useMemo(
|
|
361
|
+
() => Object.fromEntries(
|
|
362
|
+
Object.entries(activeFilters).filter(([key]) => dropdownFilterKeys.has(key))
|
|
363
|
+
),
|
|
364
|
+
[activeFilters, dropdownFilterKeys]
|
|
365
|
+
);
|
|
334
366
|
const filteredData = useMemo(() => {
|
|
335
367
|
if (onFiltersChange) return localData;
|
|
336
368
|
const filterEntries = Object.entries(activeFilters).filter(([, val]) => {
|
|
@@ -667,7 +699,7 @@ function DataGridInner({
|
|
|
667
699
|
},
|
|
668
700
|
[onSortChange, currentSort]
|
|
669
701
|
);
|
|
670
|
-
const
|
|
702
|
+
const commitFilters = useCallback(
|
|
671
703
|
(newFilters) => {
|
|
672
704
|
setCurrentPage(1);
|
|
673
705
|
if (onFiltersChange) {
|
|
@@ -678,6 +710,28 @@ function DataGridInner({
|
|
|
678
710
|
},
|
|
679
711
|
[onFiltersChange]
|
|
680
712
|
);
|
|
713
|
+
const handleFiltersChange = useCallback(
|
|
714
|
+
(newFilters) => {
|
|
715
|
+
const preserved = Object.entries(activeFilters).filter(
|
|
716
|
+
([key]) => !dropdownFilterKeys.has(key)
|
|
717
|
+
);
|
|
718
|
+
commitFilters({ ...Object.fromEntries(preserved), ...newFilters });
|
|
719
|
+
},
|
|
720
|
+
[activeFilters, dropdownFilterKeys, commitFilters]
|
|
721
|
+
);
|
|
722
|
+
const handleQuickFilterChange = useCallback(
|
|
723
|
+
(key, value) => {
|
|
724
|
+
const next = { ...activeFilters };
|
|
725
|
+
if (hasFilterValue(value)) {
|
|
726
|
+
next[key] = value;
|
|
727
|
+
} else {
|
|
728
|
+
delete next[key];
|
|
729
|
+
}
|
|
730
|
+
commitFilters(next);
|
|
731
|
+
},
|
|
732
|
+
[activeFilters, commitFilters]
|
|
733
|
+
);
|
|
734
|
+
const clearAllFilters = useCallback(() => commitFilters({}), [commitFilters]);
|
|
681
735
|
const handlePageChange = useCallback(
|
|
682
736
|
(page) => {
|
|
683
737
|
setCurrentPage(page);
|
|
@@ -899,7 +953,82 @@ function DataGridInner({
|
|
|
899
953
|
if (stickyHeader && maxHeight) {
|
|
900
954
|
containerStyle.maxHeight = typeof maxHeight === "number" ? `${maxHeight}px` : maxHeight;
|
|
901
955
|
}
|
|
902
|
-
const showToolbar = !!showFilters || !!showDensity || !!selectable || !!onRowAdd;
|
|
956
|
+
const showToolbar = !!showFilters || quickFilters.length > 0 || !!showDensity || !!selectable || !!onRowAdd;
|
|
957
|
+
const showQuickFilters = quickFilters.length > 0 && !(selectable && hasSelection);
|
|
958
|
+
const renderQuickFilter = (quickFilter) => {
|
|
959
|
+
const { key, label, disabled, width } = quickFilter;
|
|
960
|
+
const value = activeFilters[key];
|
|
961
|
+
const style = width === void 0 ? void 0 : {
|
|
962
|
+
"--eidos-datagrid-quick-filter-width": typeof width === "number" ? `${width}px` : width
|
|
963
|
+
};
|
|
964
|
+
const control = (() => {
|
|
965
|
+
switch (quickFilter.type) {
|
|
966
|
+
case "segmented":
|
|
967
|
+
return /* @__PURE__ */ jsx(
|
|
968
|
+
SegmentedControl,
|
|
969
|
+
{
|
|
970
|
+
size: "sm",
|
|
971
|
+
color: quickFilter.color,
|
|
972
|
+
disabled,
|
|
973
|
+
options: [
|
|
974
|
+
{ value: QUICK_FILTER_RESET_VALUE, label: quickFilter.allLabel ?? "All" },
|
|
975
|
+
...quickFilter.options
|
|
976
|
+
],
|
|
977
|
+
value: typeof value === "string" ? value : QUICK_FILTER_RESET_VALUE,
|
|
978
|
+
onChange: (next) => handleQuickFilterChange(key, next)
|
|
979
|
+
}
|
|
980
|
+
);
|
|
981
|
+
case "combobox":
|
|
982
|
+
return /* @__PURE__ */ jsx(
|
|
983
|
+
Combobox,
|
|
984
|
+
{
|
|
985
|
+
size: "sm",
|
|
986
|
+
fullWidth: true,
|
|
987
|
+
disabled,
|
|
988
|
+
placeholder: quickFilter.placeholder ?? label,
|
|
989
|
+
clearable: quickFilter.clearable ?? true,
|
|
990
|
+
emptyText: quickFilter.emptyText,
|
|
991
|
+
loading: quickFilter.loading,
|
|
992
|
+
loadingText: quickFilter.loadingText,
|
|
993
|
+
onSearch: quickFilter.onSearch,
|
|
994
|
+
options: (quickFilter.options ?? []).map((option) => ({
|
|
995
|
+
...option,
|
|
996
|
+
id: option.value
|
|
997
|
+
})),
|
|
998
|
+
value: typeof value === "string" ? value : "",
|
|
999
|
+
onChange: (next) => handleQuickFilterChange(key, next)
|
|
1000
|
+
}
|
|
1001
|
+
);
|
|
1002
|
+
case "select":
|
|
1003
|
+
default:
|
|
1004
|
+
return /* @__PURE__ */ jsx(
|
|
1005
|
+
Select,
|
|
1006
|
+
{
|
|
1007
|
+
fullWidth: true,
|
|
1008
|
+
inputProps: { size: "sm" },
|
|
1009
|
+
disabled,
|
|
1010
|
+
placeholder: quickFilter.placeholder ?? label,
|
|
1011
|
+
clearable: quickFilter.clearable ?? true,
|
|
1012
|
+
multiple: quickFilter.multiple,
|
|
1013
|
+
options: quickFilter.options.map((option) => ({ ...option, id: option.value })),
|
|
1014
|
+
value: quickFilter.multiple ? Array.isArray(value) ? value : [] : typeof value === "string" ? value : "",
|
|
1015
|
+
onChange: (next) => handleQuickFilterChange(key, next)
|
|
1016
|
+
}
|
|
1017
|
+
);
|
|
1018
|
+
}
|
|
1019
|
+
})();
|
|
1020
|
+
return /* @__PURE__ */ jsx(
|
|
1021
|
+
"div",
|
|
1022
|
+
{
|
|
1023
|
+
className: `eidos-datagrid-quick-filter eidos-datagrid-quick-filter--${quickFilter.type}`,
|
|
1024
|
+
style,
|
|
1025
|
+
role: "group",
|
|
1026
|
+
"aria-label": label,
|
|
1027
|
+
children: control
|
|
1028
|
+
},
|
|
1029
|
+
key
|
|
1030
|
+
);
|
|
1031
|
+
};
|
|
903
1032
|
const densityClass = effectiveDensity !== "comfortable" ? `eidos-datagrid--${effectiveDensity}` : "";
|
|
904
1033
|
const effectivePageSizeOptions = useMemo(() => {
|
|
905
1034
|
const opts = pageSizeOptions ?? [10, 25, 50, 100];
|
|
@@ -939,72 +1068,75 @@ function DataGridInner({
|
|
|
939
1068
|
style: containerStyle,
|
|
940
1069
|
children: [
|
|
941
1070
|
showToolbar && /* @__PURE__ */ jsxs("div", { className: "eidos-datagrid-toolbar", children: [
|
|
942
|
-
/* @__PURE__ */
|
|
943
|
-
/* @__PURE__ */
|
|
944
|
-
|
|
945
|
-
"
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
1071
|
+
/* @__PURE__ */ jsxs("div", { className: "eidos-datagrid-toolbar-left", children: [
|
|
1072
|
+
showQuickFilters && /* @__PURE__ */ jsx("div", { className: "eidos-datagrid-quick-filters", children: quickFilters.map(renderQuickFilter) }),
|
|
1073
|
+
selectable && hasSelection && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1074
|
+
/* @__PURE__ */ jsxs("span", { className: "eidos-datagrid-selection-count", children: [
|
|
1075
|
+
selectedSet.size,
|
|
1076
|
+
" selected"
|
|
1077
|
+
] }),
|
|
1078
|
+
bulkActions && bulkActions.length > 0 && /* @__PURE__ */ jsx("div", { className: "eidos-datagrid-bulk-actions", children: bulkActions.map((action) => {
|
|
1079
|
+
const isDisabled = typeof action.disabled === "function" ? action.disabled(selectedItems) : action.disabled ?? false;
|
|
1080
|
+
if (action.type === "split-button") {
|
|
1081
|
+
return /* @__PURE__ */ jsx(
|
|
1082
|
+
SplitButton,
|
|
1083
|
+
{
|
|
1084
|
+
size: "sm",
|
|
1085
|
+
variant: action.variant ?? "outlined",
|
|
1086
|
+
color: action.color ?? "secondary",
|
|
1087
|
+
preIcon: action.icon,
|
|
1088
|
+
disabled: isDisabled,
|
|
1089
|
+
label: action.label,
|
|
1090
|
+
onClick: () => action.onClick(selectedItems),
|
|
1091
|
+
options: action.options.map((option) => ({
|
|
1092
|
+
id: option.id,
|
|
1093
|
+
label: option.label,
|
|
1094
|
+
icon: option.icon,
|
|
1095
|
+
disabled: option.disabled,
|
|
1096
|
+
onClick: () => option.onClick(selectedItems)
|
|
1097
|
+
}))
|
|
1098
|
+
},
|
|
1099
|
+
action.id
|
|
1100
|
+
);
|
|
1101
|
+
}
|
|
1102
|
+
return action.label ? /* @__PURE__ */ jsx(
|
|
1103
|
+
Button,
|
|
952
1104
|
{
|
|
953
1105
|
size: "sm",
|
|
954
1106
|
variant: action.variant ?? "outlined",
|
|
955
1107
|
color: action.color ?? "secondary",
|
|
956
1108
|
preIcon: action.icon,
|
|
1109
|
+
posIcon: action.posIcon,
|
|
957
1110
|
disabled: isDisabled,
|
|
958
|
-
label: action.label,
|
|
959
1111
|
onClick: () => action.onClick(selectedItems),
|
|
960
|
-
|
|
961
|
-
id: option.id,
|
|
962
|
-
label: option.label,
|
|
963
|
-
icon: option.icon,
|
|
964
|
-
disabled: option.disabled,
|
|
965
|
-
onClick: () => option.onClick(selectedItems)
|
|
966
|
-
}))
|
|
1112
|
+
children: action.label
|
|
967
1113
|
},
|
|
968
1114
|
action.id
|
|
969
|
-
)
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
) : action.icon ? /* @__PURE__ */ jsx(
|
|
985
|
-
Button,
|
|
1115
|
+
) : action.icon ? /* @__PURE__ */ jsx(
|
|
1116
|
+
Button,
|
|
1117
|
+
{
|
|
1118
|
+
size: "sm",
|
|
1119
|
+
variant: action.variant ?? "outlined",
|
|
1120
|
+
color: action.color ?? "secondary",
|
|
1121
|
+
icon: action.icon,
|
|
1122
|
+
disabled: isDisabled,
|
|
1123
|
+
onClick: () => action.onClick(selectedItems)
|
|
1124
|
+
},
|
|
1125
|
+
action.id
|
|
1126
|
+
) : null;
|
|
1127
|
+
}) }),
|
|
1128
|
+
/* @__PURE__ */ jsx(
|
|
1129
|
+
"button",
|
|
986
1130
|
{
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
}) }),
|
|
997
|
-
/* @__PURE__ */ jsx(
|
|
998
|
-
"button",
|
|
999
|
-
{
|
|
1000
|
-
type: "button",
|
|
1001
|
-
className: "eidos-datagrid-clear-selection",
|
|
1002
|
-
onClick: clearSelection,
|
|
1003
|
-
"aria-label": "Clear selection",
|
|
1004
|
-
children: /* @__PURE__ */ jsx(X, { size: 14 })
|
|
1005
|
-
}
|
|
1006
|
-
)
|
|
1007
|
-
] }) }),
|
|
1131
|
+
type: "button",
|
|
1132
|
+
className: "eidos-datagrid-clear-selection",
|
|
1133
|
+
onClick: clearSelection,
|
|
1134
|
+
"aria-label": "Clear selection",
|
|
1135
|
+
children: /* @__PURE__ */ jsx(X, { size: 14 })
|
|
1136
|
+
}
|
|
1137
|
+
)
|
|
1138
|
+
] })
|
|
1139
|
+
] }),
|
|
1008
1140
|
/* @__PURE__ */ jsxs("div", { className: "eidos-datagrid-toolbar-right", children: [
|
|
1009
1141
|
showDensity && /* @__PURE__ */ jsx(
|
|
1010
1142
|
Dropdown,
|
|
@@ -1038,7 +1170,7 @@ function DataGridInner({
|
|
|
1038
1170
|
TableFiltersDropdown,
|
|
1039
1171
|
{
|
|
1040
1172
|
columns: filterDropdownColumns,
|
|
1041
|
-
filters:
|
|
1173
|
+
filters: dropdownFilters,
|
|
1042
1174
|
onFiltersChange: handleFiltersChange
|
|
1043
1175
|
}
|
|
1044
1176
|
),
|
|
@@ -1129,16 +1261,7 @@ function DataGridInner({
|
|
|
1129
1261
|
icon: /* @__PURE__ */ jsx(SearchX, {}),
|
|
1130
1262
|
title: "No results found",
|
|
1131
1263
|
description: "Try adjusting your filters or search terms.",
|
|
1132
|
-
action: /* @__PURE__ */ jsx(
|
|
1133
|
-
Button,
|
|
1134
|
-
{
|
|
1135
|
-
size: "sm",
|
|
1136
|
-
variant: "outlined",
|
|
1137
|
-
color: "primary",
|
|
1138
|
-
onClick: () => handleFiltersChange({}),
|
|
1139
|
-
children: "Clear filters"
|
|
1140
|
-
}
|
|
1141
|
-
),
|
|
1264
|
+
action: /* @__PURE__ */ jsx(Button, { size: "sm", variant: "outlined", color: "primary", onClick: clearAllFilters, children: "Clear filters" }),
|
|
1142
1265
|
size: "sm"
|
|
1143
1266
|
}
|
|
1144
1267
|
) : /* @__PURE__ */ jsx(
|
|
@@ -1431,7 +1554,7 @@ function DataGridInner({
|
|
|
1431
1554
|
size: "sm",
|
|
1432
1555
|
variant: "outlined",
|
|
1433
1556
|
color: "primary",
|
|
1434
|
-
onClick:
|
|
1557
|
+
onClick: clearAllFilters,
|
|
1435
1558
|
children: "Clear filters"
|
|
1436
1559
|
}
|
|
1437
1560
|
),
|
|
@@ -1483,4 +1606,4 @@ var DataGrid = Object.assign(DataGridInner, { displayName: "DataGrid" });
|
|
|
1483
1606
|
export {
|
|
1484
1607
|
DataGrid
|
|
1485
1608
|
};
|
|
1486
|
-
//# sourceMappingURL=chunk-
|
|
1609
|
+
//# sourceMappingURL=chunk-A5LHCAQY.js.map
|