@drivenets/design-system 0.0.5 → 0.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/CHANGELOG.md +11 -0
- package/dist/components/ds-alert-banner/ds-alert-banner.d.ts +5 -5
- package/dist/components/ds-alert-banner/ds-alert-banner.d.ts.map +1 -1
- package/dist/components/ds-button/ds-button.d.cts +2 -2
- package/dist/components/ds-button/ds-button.d.ts +2 -2
- package/dist/components/ds-button/versions/ds-button-new/ds-button-new.module.cjs +18 -18
- package/dist/components/ds-button/versions/ds-button-new/ds-button-new.module.js +18 -18
- package/dist/components/ds-button/versions/ds-button-new/ds-button-new.module.js.map +1 -1
- package/dist/components/ds-confirmation/ds-confirmation.d.cts +8 -8
- package/dist/components/ds-confirmation/ds-confirmation.d.cts.map +1 -1
- package/dist/components/ds-confirmation/ds-confirmation.d.ts +8 -8
- package/dist/components/ds-date-input/ds-date-input.cjs +352 -0
- package/dist/components/ds-date-input/ds-date-input.d.cts +31 -0
- package/dist/components/ds-date-input/ds-date-input.d.cts.map +1 -0
- package/dist/components/ds-date-input/ds-date-input.d.ts +31 -0
- package/dist/components/ds-date-input/ds-date-input.d.ts.map +1 -0
- package/dist/components/ds-date-input/ds-date-input.js +351 -0
- package/dist/components/ds-date-input/ds-date-input.js.map +1 -0
- package/dist/components/ds-date-input/ds-date-input.module.cjs +29 -0
- package/dist/components/ds-date-input/ds-date-input.module.js +29 -0
- package/dist/components/ds-date-input/ds-date-input.module.js.map +1 -0
- package/dist/components/ds-date-input/ds-date-input.types.d.cts +92 -0
- package/dist/components/ds-date-input/ds-date-input.types.d.cts.map +1 -0
- package/dist/components/ds-date-input/ds-date-input.types.d.ts +92 -0
- package/dist/components/ds-date-input/ds-date-input.types.d.ts.map +1 -0
- package/dist/components/ds-date-input/ds-date-input.utils.cjs +169 -0
- package/dist/components/ds-date-input/ds-date-input.utils.js +164 -0
- package/dist/components/ds-date-input/ds-date-input.utils.js.map +1 -0
- package/dist/components/ds-date-input/index.cjs +1 -0
- package/dist/components/ds-date-input/index.d.ts +2 -0
- package/dist/components/ds-date-input/index.js +1 -0
- package/dist/components/ds-divider/ds-divider.cjs +47 -0
- package/dist/components/ds-divider/ds-divider.d.cts +8 -0
- package/dist/components/ds-divider/ds-divider.d.cts.map +1 -0
- package/dist/components/ds-divider/ds-divider.d.ts +8 -0
- package/dist/components/ds-divider/ds-divider.d.ts.map +1 -0
- package/dist/components/ds-divider/ds-divider.js +46 -0
- package/dist/components/ds-divider/ds-divider.js.map +1 -0
- package/dist/components/ds-divider/ds-divider.module.cjs +10 -0
- package/dist/components/ds-divider/ds-divider.module.js +10 -0
- package/dist/components/ds-divider/ds-divider.module.js.map +1 -0
- package/dist/components/ds-divider/ds-divider.types.d.cts +25 -0
- package/dist/components/ds-divider/ds-divider.types.d.cts.map +1 -0
- package/dist/components/ds-divider/ds-divider.types.d.ts +25 -0
- package/dist/components/ds-divider/ds-divider.types.d.ts.map +1 -0
- package/dist/components/ds-divider/index.cjs +1 -0
- package/dist/components/ds-divider/index.d.ts +2 -0
- package/dist/components/ds-divider/index.js +1 -0
- package/dist/components/ds-drawer/ds-drawer.d.cts +9 -9
- package/dist/components/ds-drawer/ds-drawer.d.ts +9 -9
- package/dist/components/ds-dropdown-menu/ds-dropdown-menu.cjs +80 -24
- package/dist/components/ds-dropdown-menu/ds-dropdown-menu.d.cts +1 -0
- package/dist/components/ds-dropdown-menu/ds-dropdown-menu.d.cts.map +1 -1
- package/dist/components/ds-dropdown-menu/ds-dropdown-menu.d.ts +1 -0
- package/dist/components/ds-dropdown-menu/ds-dropdown-menu.d.ts.map +1 -1
- package/dist/components/ds-dropdown-menu/ds-dropdown-menu.js +80 -24
- package/dist/components/ds-dropdown-menu/ds-dropdown-menu.js.map +1 -1
- package/dist/components/ds-dropdown-menu/ds-dropdown-menu.module.cjs +20 -18
- package/dist/components/ds-dropdown-menu/ds-dropdown-menu.module.js +20 -18
- package/dist/components/ds-dropdown-menu/ds-dropdown-menu.module.js.map +1 -1
- package/dist/components/ds-dropdown-menu/ds-dropdown-menu.types.d.cts +5 -1
- package/dist/components/ds-dropdown-menu/ds-dropdown-menu.types.d.cts.map +1 -1
- package/dist/components/ds-dropdown-menu/ds-dropdown-menu.types.d.ts +5 -1
- package/dist/components/ds-dropdown-menu/ds-dropdown-menu.types.d.ts.map +1 -1
- package/dist/components/ds-dropdown-menu/index.d.ts +1 -1
- package/dist/components/ds-expandable-text-input/ds-expandable-text-input.d.cts +2 -2
- package/dist/components/ds-expandable-text-input/ds-expandable-text-input.d.ts +2 -2
- package/dist/components/ds-form-control/ds-form-control.cjs +3 -0
- package/dist/components/ds-form-control/ds-form-control.d.cts +9 -7
- package/dist/components/ds-form-control/ds-form-control.d.cts.map +1 -1
- package/dist/components/ds-form-control/ds-form-control.d.ts +10 -7
- package/dist/components/ds-form-control/ds-form-control.d.ts.map +1 -1
- package/dist/components/ds-form-control/ds-form-control.js +3 -0
- package/dist/components/ds-form-control/ds-form-control.js.map +1 -1
- package/dist/components/ds-modal/ds-modal.d.cts +8 -8
- package/dist/components/ds-modal/ds-modal.d.cts.map +1 -1
- package/dist/components/ds-modal/ds-modal.d.ts +8 -8
- package/dist/components/ds-modal/ds-modal.d.ts.map +1 -1
- package/dist/components/ds-panel/ds-panel.d.cts +2 -2
- package/dist/components/ds-panel/ds-panel.d.ts +2 -2
- package/dist/components/ds-radio-group/ds-radio-group.types.d.cts +1 -1
- package/dist/components/ds-radio-group/ds-radio-group.types.d.cts.map +1 -1
- package/dist/components/ds-radio-group/ds-radio-group.types.d.ts +1 -1
- package/dist/components/ds-radio-group/ds-radio-group.types.d.ts.map +1 -1
- package/dist/components/ds-select/ds-select.d.cts +2 -2
- package/dist/components/ds-select/ds-select.d.ts +2 -2
- package/dist/components/ds-smart-tabs/ds-smart-tabs.d.cts +2 -2
- package/dist/components/ds-smart-tabs/ds-smart-tabs.d.ts +2 -2
- package/dist/components/ds-stepper/components/ds-step-content.d.cts +2 -2
- package/dist/components/ds-stepper/components/ds-step-content.d.ts +2 -2
- package/dist/components/ds-stepper/components/ds-step-next-button.d.cts +2 -2
- package/dist/components/ds-stepper/components/ds-step-next-button.d.ts +2 -2
- package/dist/components/ds-stepper/components/ds-step.d.ts +2 -2
- package/dist/components/ds-stepper/ds-stepper.d.cts +2 -2
- package/dist/components/ds-stepper/ds-stepper.d.ts +2 -2
- package/dist/components/ds-table/components/ds-table-cell/ds-table-cell.types.d.cts +1 -0
- package/dist/components/ds-table/components/ds-table-cell/ds-table-cell.types.d.cts.map +1 -1
- package/dist/components/ds-table/components/ds-table-cell/ds-table-cell.types.d.ts +1 -1
- package/dist/components/ds-table/ds-table.d.cts +2 -2
- package/dist/components/ds-table/ds-table.d.ts +2 -2
- package/dist/components/ds-table/filters/adapters/create-checkbox-filter-adapter.cjs +55 -0
- package/dist/components/ds-table/filters/adapters/create-checkbox-filter-adapter.d.cts +49 -0
- package/dist/components/ds-table/filters/adapters/create-checkbox-filter-adapter.d.cts.map +1 -0
- package/dist/components/ds-table/filters/adapters/create-checkbox-filter-adapter.d.ts +50 -0
- package/dist/components/ds-table/filters/adapters/create-checkbox-filter-adapter.d.ts.map +1 -0
- package/dist/components/ds-table/filters/adapters/create-checkbox-filter-adapter.js +55 -0
- package/dist/components/ds-table/filters/adapters/create-checkbox-filter-adapter.js.map +1 -0
- package/dist/components/ds-table/filters/adapters/create-dual-range-filter-adapter.cjs +87 -0
- package/dist/components/ds-table/filters/adapters/create-dual-range-filter-adapter.d.cts +44 -0
- package/dist/components/ds-table/filters/adapters/create-dual-range-filter-adapter.d.cts.map +1 -0
- package/dist/components/ds-table/filters/adapters/create-dual-range-filter-adapter.d.ts +44 -0
- package/dist/components/ds-table/filters/adapters/create-dual-range-filter-adapter.d.ts.map +1 -0
- package/dist/components/ds-table/filters/adapters/create-dual-range-filter-adapter.js +87 -0
- package/dist/components/ds-table/filters/adapters/create-dual-range-filter-adapter.js.map +1 -0
- package/dist/components/ds-table/filters/adapters/create-filter-adapter.cjs +83 -0
- package/dist/components/ds-table/filters/adapters/create-filter-adapter.d.cts +111 -0
- package/dist/components/ds-table/filters/adapters/create-filter-adapter.d.cts.map +1 -0
- package/dist/components/ds-table/filters/adapters/create-filter-adapter.d.ts +111 -0
- package/dist/components/ds-table/filters/adapters/create-filter-adapter.d.ts.map +1 -0
- package/dist/components/ds-table/filters/adapters/create-filter-adapter.js +83 -0
- package/dist/components/ds-table/filters/adapters/create-filter-adapter.js.map +1 -0
- package/dist/components/ds-table/filters/adapters/index.cjs +3 -0
- package/dist/components/ds-table/filters/adapters/index.d.ts +3 -0
- package/dist/components/ds-table/filters/adapters/index.js +3 -0
- package/dist/components/ds-table/filters/components/checkbox-filter/checkbox-filter.cjs +22 -0
- package/dist/components/ds-table/filters/components/checkbox-filter/checkbox-filter.d.cts +17 -0
- package/dist/components/ds-table/filters/components/checkbox-filter/checkbox-filter.d.cts.map +1 -0
- package/dist/components/ds-table/filters/components/checkbox-filter/checkbox-filter.d.ts +18 -0
- package/dist/components/ds-table/filters/components/checkbox-filter/checkbox-filter.d.ts.map +1 -0
- package/dist/components/ds-table/filters/components/checkbox-filter/checkbox-filter.js +22 -0
- package/dist/components/ds-table/filters/components/checkbox-filter/checkbox-filter.js.map +1 -0
- package/dist/components/ds-table/filters/components/checkbox-filter/index.cjs +1 -0
- package/dist/components/ds-table/filters/components/checkbox-filter/index.d.ts +1 -0
- package/dist/components/ds-table/filters/components/checkbox-filter/index.js +1 -0
- package/dist/components/ds-table/filters/components/range-filter/index.cjs +1 -0
- package/dist/components/ds-table/filters/components/range-filter/index.d.ts +1 -0
- package/dist/components/ds-table/filters/components/range-filter/index.js +1 -0
- package/dist/components/ds-table/filters/components/range-filter/range-filter.cjs +177 -0
- package/dist/components/ds-table/filters/components/range-filter/range-filter.d.cts +14 -0
- package/dist/components/ds-table/filters/components/range-filter/range-filter.d.cts.map +1 -0
- package/dist/components/ds-table/filters/components/range-filter/range-filter.d.ts +16 -0
- package/dist/components/ds-table/filters/components/range-filter/range-filter.d.ts.map +1 -0
- package/dist/components/ds-table/filters/components/range-filter/range-filter.js +177 -0
- package/dist/components/ds-table/filters/components/range-filter/range-filter.js.map +1 -0
- package/dist/components/ds-table/filters/components/range-filter/range-filter.module.cjs +11 -0
- package/dist/components/ds-table/filters/components/range-filter/range-filter.module.js +11 -0
- package/dist/components/ds-table/filters/components/range-filter/range-filter.module.js.map +1 -0
- package/dist/components/ds-table/filters/hooks/index.cjs +1 -0
- package/dist/components/ds-table/filters/hooks/index.d.ts +1 -0
- package/dist/components/ds-table/filters/hooks/index.js +1 -0
- package/dist/components/ds-table/filters/hooks/use-table-filters.cjs +211 -0
- package/dist/components/ds-table/filters/hooks/use-table-filters.d.cts +65 -0
- package/dist/components/ds-table/filters/hooks/use-table-filters.d.cts.map +1 -0
- package/dist/components/ds-table/filters/hooks/use-table-filters.d.ts +66 -0
- package/dist/components/ds-table/filters/hooks/use-table-filters.d.ts.map +1 -0
- package/dist/components/ds-table/filters/hooks/use-table-filters.js +211 -0
- package/dist/components/ds-table/filters/hooks/use-table-filters.js.map +1 -0
- package/dist/components/ds-table/filters/index.cjs +6 -0
- package/dist/components/ds-table/filters/index.d.ts +11 -0
- package/dist/components/ds-table/filters/index.js +6 -0
- package/dist/components/ds-table/filters/types/filter-adapter.types.d.cts +101 -0
- package/dist/components/ds-table/filters/types/filter-adapter.types.d.cts.map +1 -0
- package/dist/components/ds-table/filters/types/filter-adapter.types.d.ts +102 -0
- package/dist/components/ds-table/filters/types/filter-adapter.types.d.ts.map +1 -0
- package/dist/components/ds-table/index.cjs +5 -0
- package/dist/components/ds-table/index.d.ts +8 -0
- package/dist/components/ds-table/index.js +5 -0
- package/dist/components/ds-toggle/ds-toggle.cjs +192 -0
- package/dist/components/ds-toggle/ds-toggle.d.cts +24 -0
- package/dist/components/ds-toggle/ds-toggle.d.cts.map +1 -0
- package/dist/components/ds-toggle/ds-toggle.d.ts +24 -0
- package/dist/components/ds-toggle/ds-toggle.d.ts.map +1 -0
- package/dist/components/ds-toggle/ds-toggle.js +191 -0
- package/dist/components/ds-toggle/ds-toggle.js.map +1 -0
- package/dist/components/ds-toggle/ds-toggle.module.cjs +13 -0
- package/dist/components/ds-toggle/ds-toggle.module.js +13 -0
- package/dist/components/ds-toggle/ds-toggle.module.js.map +1 -0
- package/dist/components/ds-toggle/ds-toggle.types.d.cts +67 -0
- package/dist/components/ds-toggle/ds-toggle.types.d.cts.map +1 -0
- package/dist/components/ds-toggle/ds-toggle.types.d.ts +67 -0
- package/dist/components/ds-toggle/ds-toggle.types.d.ts.map +1 -0
- package/dist/components/ds-toggle/index.cjs +1 -0
- package/dist/components/ds-toggle/index.d.ts +2 -0
- package/dist/components/ds-toggle/index.js +1 -0
- package/dist/components/ds-vertical-tabs/ds-vertical-tabs.d.cts +5 -5
- package/dist/components/ds-vertical-tabs/ds-vertical-tabs.d.ts +5 -5
- package/dist/index.cjs +17 -0
- package/dist/index.d.cts +15 -2
- package/dist/index.d.ts +18 -2
- package/dist/index.js +11 -1
- package/dist/index.min.css +1 -1
- package/package.json +2 -1
- package/src/components/ds-button/versions/ds-button-new/ds-button-new.module.scss +0 -1
- package/src/components/ds-date-input/ds-date-input.module.scss +246 -0
- package/src/components/ds-date-input/ds-date-input.tsx +309 -0
- package/src/components/ds-date-input/ds-date-input.types.tsx +104 -0
- package/src/components/ds-date-input/ds-date-input.utils.ts +242 -0
- package/src/components/ds-date-input/index.ts +2 -0
- package/src/components/ds-divider/ds-divider.module.scss +21 -0
- package/src/components/ds-divider/ds-divider.tsx +22 -0
- package/src/components/ds-divider/ds-divider.types.ts +21 -0
- package/src/components/ds-divider/index.ts +2 -0
- package/src/components/ds-dropdown-menu/ds-dropdown-menu.module.scss +11 -3
- package/src/components/ds-dropdown-menu/ds-dropdown-menu.tsx +17 -1
- package/src/components/ds-dropdown-menu/ds-dropdown-menu.types.tsx +5 -0
- package/src/components/ds-form-control/ds-form-control.tsx +2 -0
- package/src/components/ds-radio-group/ds-radio-group.types.tsx +1 -1
- package/src/components/ds-table/filters/hooks/index.ts +1 -0
- package/src/components/ds-table/index.ts +2 -0
- package/src/components/ds-toggle/ds-toggle.module.scss +154 -0
- package/src/components/ds-toggle/ds-toggle.tsx +78 -0
- package/src/components/ds-toggle/ds-toggle.types.tsx +76 -0
- package/src/components/ds-toggle/index.tsx +2 -0
- package/src/index.ts +3 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { c } from "react/compiler-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/ds-table/filters/hooks/use-table-filters.ts
|
|
5
|
+
/**
|
|
6
|
+
* Hook to orchestrate table filtering with adapters
|
|
7
|
+
* Manages filter state, generates chips, handles column definitions
|
|
8
|
+
*
|
|
9
|
+
* @param filterAdapters Array of filter adapters
|
|
10
|
+
* @param baseColumns Base column definitions (optional)
|
|
11
|
+
* @returns Complete filter management system
|
|
12
|
+
*/
|
|
13
|
+
function useTableFilters(filterAdapters, baseColumns) {
|
|
14
|
+
const $ = c(37);
|
|
15
|
+
const _filterAdapters = filterAdapters;
|
|
16
|
+
let initialState;
|
|
17
|
+
if ($[0] !== _filterAdapters) {
|
|
18
|
+
initialState = {};
|
|
19
|
+
_filterAdapters.forEach((adapter) => {
|
|
20
|
+
initialState[adapter.id] = adapter.initialValue;
|
|
21
|
+
});
|
|
22
|
+
$[0] = _filterAdapters;
|
|
23
|
+
$[1] = initialState;
|
|
24
|
+
} else initialState = $[1];
|
|
25
|
+
const [filterState, setFilterState] = useState(initialState);
|
|
26
|
+
let t0;
|
|
27
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
28
|
+
t0 = [];
|
|
29
|
+
$[2] = t0;
|
|
30
|
+
} else t0 = $[2];
|
|
31
|
+
const [columnFilters, setColumnFilters] = useState(t0);
|
|
32
|
+
let t1;
|
|
33
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
34
|
+
t1 = [];
|
|
35
|
+
$[3] = t1;
|
|
36
|
+
} else t1 = $[3];
|
|
37
|
+
const [filterChips, setFilterChips] = useState(t1);
|
|
38
|
+
let t2;
|
|
39
|
+
if ($[4] !== _filterAdapters || $[5] !== filterState) {
|
|
40
|
+
let t3$1;
|
|
41
|
+
if ($[7] !== filterState) {
|
|
42
|
+
t3$1 = (adapter_0) => ({
|
|
43
|
+
id: adapter_0.id,
|
|
44
|
+
label: adapter_0.label,
|
|
45
|
+
count: adapter_0.getActiveFiltersCount(filterState[adapter_0.id])
|
|
46
|
+
});
|
|
47
|
+
$[7] = filterState;
|
|
48
|
+
$[8] = t3$1;
|
|
49
|
+
} else t3$1 = $[8];
|
|
50
|
+
t2 = _filterAdapters.map(t3$1);
|
|
51
|
+
$[4] = _filterAdapters;
|
|
52
|
+
$[5] = filterState;
|
|
53
|
+
$[6] = t2;
|
|
54
|
+
} else t2 = $[6];
|
|
55
|
+
const filterNavItems = t2;
|
|
56
|
+
let t3;
|
|
57
|
+
if ($[9] !== _filterAdapters || $[10] !== baseColumns) {
|
|
58
|
+
t3 = !baseColumns ? [] : baseColumns.map((col) => {
|
|
59
|
+
const adapter_1 = _filterAdapters.find((a) => a.id === col.id);
|
|
60
|
+
if (adapter_1) {
|
|
61
|
+
const cellRenderer = adapter_1.cellRenderer;
|
|
62
|
+
return {
|
|
63
|
+
...col,
|
|
64
|
+
filterFn: adapter_1.columnFilterFn,
|
|
65
|
+
...cellRenderer && { cell: (info) => cellRenderer(info.getValue()) }
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return col;
|
|
69
|
+
});
|
|
70
|
+
$[9] = _filterAdapters;
|
|
71
|
+
$[10] = baseColumns;
|
|
72
|
+
$[11] = t3;
|
|
73
|
+
} else t3 = $[11];
|
|
74
|
+
const enhancedColumns = t3;
|
|
75
|
+
let t4;
|
|
76
|
+
if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
|
|
77
|
+
t4 = (filterId, value) => {
|
|
78
|
+
setFilterState((prev) => ({
|
|
79
|
+
...prev,
|
|
80
|
+
[filterId]: value
|
|
81
|
+
}));
|
|
82
|
+
};
|
|
83
|
+
$[12] = t4;
|
|
84
|
+
} else t4 = $[12];
|
|
85
|
+
const updateFilter = t4;
|
|
86
|
+
let t5;
|
|
87
|
+
if ($[13] !== _filterAdapters || $[14] !== filterState) {
|
|
88
|
+
t5 = () => {
|
|
89
|
+
const filters = [];
|
|
90
|
+
const chips = [];
|
|
91
|
+
_filterAdapters.forEach((adapter_2) => {
|
|
92
|
+
const value_0 = filterState[adapter_2.id];
|
|
93
|
+
if (adapter_2.getActiveFiltersCount(value_0) > 0) filters.push({
|
|
94
|
+
id: adapter_2.id,
|
|
95
|
+
value: value_0
|
|
96
|
+
});
|
|
97
|
+
const adapterChips = adapter_2.toChips(value_0);
|
|
98
|
+
chips.push(...adapterChips);
|
|
99
|
+
});
|
|
100
|
+
setColumnFilters(filters);
|
|
101
|
+
setFilterChips(chips);
|
|
102
|
+
};
|
|
103
|
+
$[13] = _filterAdapters;
|
|
104
|
+
$[14] = filterState;
|
|
105
|
+
$[15] = t5;
|
|
106
|
+
} else t5 = $[15];
|
|
107
|
+
const applyFilters = t5;
|
|
108
|
+
let t6;
|
|
109
|
+
if ($[16] !== _filterAdapters) {
|
|
110
|
+
t6 = () => {
|
|
111
|
+
const resetState = {};
|
|
112
|
+
_filterAdapters.forEach((adapter_3) => {
|
|
113
|
+
resetState[adapter_3.id] = adapter_3.reset();
|
|
114
|
+
});
|
|
115
|
+
setFilterState(resetState);
|
|
116
|
+
setColumnFilters([]);
|
|
117
|
+
setFilterChips([]);
|
|
118
|
+
};
|
|
119
|
+
$[16] = _filterAdapters;
|
|
120
|
+
$[17] = t6;
|
|
121
|
+
} else t6 = $[17];
|
|
122
|
+
const clearAll = t6;
|
|
123
|
+
let t7;
|
|
124
|
+
if ($[18] !== _filterAdapters || $[19] !== clearAll || $[20] !== filterState) {
|
|
125
|
+
t7 = (chip) => {
|
|
126
|
+
const filterKey = typeof chip.metadata?.key === "string" ? chip.metadata.key : void 0;
|
|
127
|
+
if (!filterKey) return;
|
|
128
|
+
const adapter_4 = _filterAdapters.find((a_0) => a_0.id === filterKey);
|
|
129
|
+
if (!adapter_4) return;
|
|
130
|
+
const currentValue = filterState[filterKey];
|
|
131
|
+
const newValue = adapter_4.fromChip(chip, currentValue);
|
|
132
|
+
const chips_0 = [];
|
|
133
|
+
_filterAdapters.forEach((adapter_5) => {
|
|
134
|
+
const value_1 = adapter_5.id === filterKey ? newValue : filterState[adapter_5.id];
|
|
135
|
+
const adapterChips_0 = adapter_5.toChips(value_1);
|
|
136
|
+
chips_0.push(...adapterChips_0);
|
|
137
|
+
});
|
|
138
|
+
if (chips_0.length === 0) {
|
|
139
|
+
clearAll();
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
setFilterState((prev_0) => ({
|
|
143
|
+
...prev_0,
|
|
144
|
+
[filterKey]: newValue
|
|
145
|
+
}));
|
|
146
|
+
if (adapter_4.getActiveFiltersCount(newValue) === 0) setColumnFilters((prev_1) => prev_1.filter((cf) => cf.id !== filterKey));
|
|
147
|
+
else setColumnFilters((prev_2) => prev_2.map((cf_0) => cf_0.id === filterKey ? {
|
|
148
|
+
id: filterKey,
|
|
149
|
+
value: newValue
|
|
150
|
+
} : cf_0));
|
|
151
|
+
setFilterChips(chips_0);
|
|
152
|
+
};
|
|
153
|
+
$[18] = _filterAdapters;
|
|
154
|
+
$[19] = clearAll;
|
|
155
|
+
$[20] = filterState;
|
|
156
|
+
$[21] = t7;
|
|
157
|
+
} else t7 = $[21];
|
|
158
|
+
const deleteChip = t7;
|
|
159
|
+
let t8;
|
|
160
|
+
if ($[22] !== _filterAdapters || $[23] !== filterState) {
|
|
161
|
+
t8 = (selectedFilter) => {
|
|
162
|
+
const adapter_6 = _filterAdapters.find((a_1) => a_1.id === selectedFilter.id);
|
|
163
|
+
if (!adapter_6) return null;
|
|
164
|
+
const value_2 = filterState[adapter_6.id];
|
|
165
|
+
const onChange = (newValue_0) => updateFilter(adapter_6.id, newValue_0);
|
|
166
|
+
return adapter_6.renderFilter(value_2, onChange);
|
|
167
|
+
};
|
|
168
|
+
$[22] = _filterAdapters;
|
|
169
|
+
$[23] = filterState;
|
|
170
|
+
$[24] = t8;
|
|
171
|
+
} else t8 = $[24];
|
|
172
|
+
const renderFilterContent = t8;
|
|
173
|
+
let t9;
|
|
174
|
+
if ($[25] !== applyFilters || $[26] !== clearAll || $[27] !== deleteChip) {
|
|
175
|
+
t9 = {
|
|
176
|
+
updateFilter,
|
|
177
|
+
applyFilters,
|
|
178
|
+
clearAll,
|
|
179
|
+
deleteChip
|
|
180
|
+
};
|
|
181
|
+
$[25] = applyFilters;
|
|
182
|
+
$[26] = clearAll;
|
|
183
|
+
$[27] = deleteChip;
|
|
184
|
+
$[28] = t9;
|
|
185
|
+
} else t9 = $[28];
|
|
186
|
+
let t10;
|
|
187
|
+
if ($[29] !== columnFilters || $[30] !== enhancedColumns || $[31] !== filterChips || $[32] !== filterNavItems || $[33] !== filterState || $[34] !== renderFilterContent || $[35] !== t9) {
|
|
188
|
+
t10 = {
|
|
189
|
+
filterState,
|
|
190
|
+
columnFilters,
|
|
191
|
+
filterChips,
|
|
192
|
+
filterNavItems,
|
|
193
|
+
enhancedColumns,
|
|
194
|
+
handlers: t9,
|
|
195
|
+
renderFilterContent
|
|
196
|
+
};
|
|
197
|
+
$[29] = columnFilters;
|
|
198
|
+
$[30] = enhancedColumns;
|
|
199
|
+
$[31] = filterChips;
|
|
200
|
+
$[32] = filterNavItems;
|
|
201
|
+
$[33] = filterState;
|
|
202
|
+
$[34] = renderFilterContent;
|
|
203
|
+
$[35] = t9;
|
|
204
|
+
$[36] = t10;
|
|
205
|
+
} else t10 = $[36];
|
|
206
|
+
return t10;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
//#endregion
|
|
210
|
+
export { useTableFilters };
|
|
211
|
+
//# sourceMappingURL=use-table-filters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-table-filters.js","names":["ReactNode","useState","CellContext","ColumnDef","ChipItem","AnyAdapter","ColumnFilterState","FilterAdapter","FilterNavItem","FilterState","UseTableFiltersResult","filterState","TValue","columnFilters","filterChips","filterNavItems","enhancedColumns","TData","handlers","updateFilter","filterId","value","applyFilters","clearAll","deleteChip","chip","renderFilterContent","selectedFilter","useTableFilters","filterAdapters","baseColumns","$","_c","_filterAdapters","TCellValue","initialState","forEach","adapter","id","initialValue","setFilterState","t0","Symbol","for","setColumnFilters","t1","setFilterChips","t2","t3","adapter_0","label","count","getActiveFiltersCount","map","col","adapter_1","find","a","cellRenderer","filterFn","columnFilterFn","cell","info","getValue","t4","prev","t5","filters","chips","adapter_2","value_0","push","adapterChips","toChips","t6","resetState","adapter_3","reset","t7","filterKey","metadata","key","undefined","adapter_4","a_0","currentValue","newValue","fromChip","chips_0","adapter_5","value_1","adapterChips_0","length","prev_0","prev_1","filter","cf","prev_2","cf_0","t8","adapter_6","a_1","value_2","onChange","newValue_0","renderFilter","t9","t10"],"sources":["../../../../../src/components/ds-table/filters/hooks/use-table-filters.ts"],"sourcesContent":["import { type ReactNode, useState } from 'react';\nimport type { CellContext, ColumnDef } from '@tanstack/react-table';\nimport type { ChipItem } from '../../../ds-chip-group';\nimport type {\n\tAnyAdapter,\n\tColumnFilterState,\n\tFilterAdapter,\n\tFilterNavItem,\n\tFilterState,\n} from '../types/filter-adapter.types';\n\nexport interface UseTableFiltersResult<TData, TValue> {\n\t/**\n\t * Current filter state\n\t */\n\tfilterState: FilterState<TValue>;\n\n\t/**\n\t * Column filters for TanStack Table\n\t */\n\tcolumnFilters: ColumnFilterState<TValue>[];\n\n\t/**\n\t * Filter chips for display\n\t */\n\tfilterChips: ChipItem[];\n\n\t/**\n\t * Filter navigation items with counts\n\t */\n\tfilterNavItems: FilterNavItem[];\n\n\t/**\n\t * Enhanced column definitions with filter functions\n\t */\n\tenhancedColumns: ColumnDef<TData>[];\n\n\t/**\n\t * Handlers\n\t */\n\thandlers: {\n\t\t/**\n\t\t * Update a specific filter's value\n\t\t */\n\t\tupdateFilter: (filterId: string, value: TValue) => void;\n\n\t\t/**\n\t\t * Apply all filters (converts to TanStack format)\n\t\t */\n\t\tapplyFilters: () => void;\n\n\t\t/**\n\t\t * Clear all filters\n\t\t */\n\t\tclearAll: () => void;\n\n\t\t/**\n\t\t * Delete a specific chip\n\t\t */\n\t\tdeleteChip: (chip: ChipItem) => void;\n\t};\n\n\t/**\n\t * Render function for filter modal content\n\t */\n\trenderFilterContent: (selectedFilter: FilterNavItem) => ReactNode;\n}\n\n/**\n * Hook to orchestrate table filtering with adapters\n * Manages filter state, generates chips, handles column definitions\n *\n * @param filterAdapters Array of filter adapters\n * @param baseColumns Base column definitions (optional)\n * @returns Complete filter management system\n */\nexport function useTableFilters<TData, TValue, TCellValue>(\n\tfilterAdapters: FilterAdapter<TData, TValue, TCellValue>[] | AnyAdapter[],\n\tbaseColumns?: ColumnDef<TData>[],\n): UseTableFiltersResult<TData, TValue> {\n\t// Internal variable just to avoid assignment issues of `any`.\n\tconst _filterAdapters = filterAdapters as FilterAdapter<TData, TValue, TCellValue>[];\n\n\t// Initialize filter state from adapters\n\tconst initialState: FilterState<TValue> = {};\n\t_filterAdapters.forEach((adapter) => {\n\t\tinitialState[adapter.id] = adapter.initialValue;\n\t});\n\n\tconst [filterState, setFilterState] = useState<FilterState<TValue>>(initialState);\n\tconst [columnFilters, setColumnFilters] = useState<ColumnFilterState<TValue>[]>([]);\n\tconst [filterChips, setFilterChips] = useState<ChipItem[]>([]);\n\n\t// Generate filter nav items with counts (updates as user changes filters in modal)\n\tconst filterNavItems: FilterNavItem[] = _filterAdapters.map((adapter) => ({\n\t\tid: adapter.id,\n\t\tlabel: adapter.label,\n\t\tcount: adapter.getActiveFiltersCount(filterState[adapter.id]),\n\t}));\n\n\t// Enhance column definitions with filter functions and renderers\n\tconst enhancedColumns: ColumnDef<TData>[] = !baseColumns\n\t\t? []\n\t\t: baseColumns.map((col) => {\n\t\t\t\tconst adapter = _filterAdapters.find((a) => a.id === col.id);\n\n\t\t\t\tif (adapter) {\n\t\t\t\t\tconst cellRenderer = adapter.cellRenderer;\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...col,\n\t\t\t\t\t\tfilterFn: adapter.columnFilterFn,\n\t\t\t\t\t\t...(cellRenderer && {\n\t\t\t\t\t\t\tcell: (info: CellContext<TData, TCellValue>) => cellRenderer(info.getValue()),\n\t\t\t\t\t\t}),\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn col;\n\t\t\t});\n\n\t// Handlers\n\tconst updateFilter = (filterId: string, value: TValue) => {\n\t\tsetFilterState((prev) => ({\n\t\t\t...prev,\n\t\t\t[filterId]: value,\n\t\t}));\n\t};\n\n\tconst applyFilters = () => {\n\t\tconst filters: ColumnFilterState<TValue>[] = [];\n\t\tconst chips: ChipItem[] = [];\n\n\t\t_filterAdapters.forEach((adapter) => {\n\t\t\tconst value = filterState[adapter.id];\n\n\t\t\tif (adapter.getActiveFiltersCount(value) > 0) {\n\t\t\t\tfilters.push({\n\t\t\t\t\tid: adapter.id,\n\t\t\t\t\tvalue,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Generate chips from current filter value\n\t\t\tconst adapterChips = adapter.toChips(value);\n\t\t\tchips.push(...adapterChips);\n\t\t});\n\n\t\tsetColumnFilters(filters);\n\t\tsetFilterChips(chips);\n\t};\n\n\tconst clearAll = () => {\n\t\tconst resetState: FilterState<TValue> = {};\n\t\t_filterAdapters.forEach((adapter) => {\n\t\t\tresetState[adapter.id] = adapter.reset();\n\t\t});\n\t\tsetFilterState(resetState);\n\t\tsetColumnFilters([]);\n\t\tsetFilterChips([]);\n\t};\n\n\tconst deleteChip = (chip: ChipItem) => {\n\t\tconst filterKey = typeof chip.metadata?.key === 'string' ? chip.metadata.key : undefined;\n\t\tif (!filterKey) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst adapter = _filterAdapters.find((a) => a.id === filterKey);\n\t\tif (!adapter) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst currentValue = filterState[filterKey];\n\t\tconst newValue = adapter.fromChip(chip, currentValue);\n\n\t\t// Regenerate chips to check if this was the last one\n\t\tconst chips: ChipItem[] = [];\n\t\t_filterAdapters.forEach((adapter) => {\n\t\t\tconst value = adapter.id === filterKey ? newValue : filterState[adapter.id];\n\t\t\tconst adapterChips = adapter.toChips(value);\n\t\t\tchips.push(...adapterChips);\n\t\t});\n\n\t\t// If no chips left, clear all filters\n\t\tif (chips.length === 0) {\n\t\t\tclearAll();\n\t\t\treturn;\n\t\t}\n\n\t\t// Otherwise, update state and filters\n\t\tsetFilterState((prev) => ({\n\t\t\t...prev,\n\t\t\t[filterKey]: newValue,\n\t\t}));\n\n\t\t// Update column filters\n\t\tif (adapter.getActiveFiltersCount(newValue) === 0) {\n\t\t\tsetColumnFilters((prev) => prev.filter((cf) => cf.id !== filterKey));\n\t\t} else {\n\t\t\tsetColumnFilters((prev) =>\n\t\t\t\tprev.map((cf) => (cf.id === filterKey ? { id: filterKey, value: newValue } : cf)),\n\t\t\t);\n\t\t}\n\n\t\tsetFilterChips(chips);\n\t};\n\n\tconst renderFilterContent = (selectedFilter: FilterNavItem) => {\n\t\tconst adapter = _filterAdapters.find((a) => a.id === selectedFilter.id);\n\t\tif (!adapter) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst value = filterState[adapter.id];\n\t\tconst onChange = (newValue: TValue) => updateFilter(adapter.id, newValue);\n\n\t\treturn adapter.renderFilter(value, onChange);\n\t};\n\n\treturn {\n\t\tfilterState,\n\t\tcolumnFilters,\n\t\tfilterChips,\n\t\tfilterNavItems,\n\t\tenhancedColumns,\n\t\thandlers: {\n\t\t\tupdateFilter,\n\t\t\tapplyFilters,\n\t\t\tclearAll,\n\t\t\tdeleteChip,\n\t\t},\n\t\trenderFilterContent,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;AA4EA,SAAO4B,gBAAAC,gBAA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,UAMIwF;GAKThF;GAED;AAAAK,IAAA,MAAAlB;AAAAkB,IAAA,MAAAf;AAAAe,IAAA,MAAAjB;AAAAiB,IAAA,MAAAhB;AAAAgB,IAAA,MAAApB;AAAAoB,IAAA,MAAAL;AAAAK,IAAA,MAAA2E;AAAA3E,IAAA,MAAA4E;OAAAA,OAAA5E,EAAA;AAAA,QAbM4E"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const require_create_filter_adapter = require('./adapters/create-filter-adapter.cjs');
|
|
2
|
+
const require_create_checkbox_filter_adapter = require('./adapters/create-checkbox-filter-adapter.cjs');
|
|
3
|
+
const require_create_dual_range_filter_adapter = require('./adapters/create-dual-range-filter-adapter.cjs');
|
|
4
|
+
require('./adapters/index.cjs');
|
|
5
|
+
const require_use_table_filters = require('./hooks/use-table-filters.cjs');
|
|
6
|
+
require('./hooks/index.cjs');
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AnyAdapter, ColumnFilterState, FilterAdapter, FilterNavItem, FilterState } from "./types/filter-adapter.types.js";
|
|
2
|
+
import { FilterAdapterConfig, createFilterAdapter } from "./adapters/create-filter-adapter.js";
|
|
3
|
+
import { CheckboxFilterItem, CheckboxFilterProps } from "./components/checkbox-filter/checkbox-filter.js";
|
|
4
|
+
import "./components/checkbox-filter/index.js";
|
|
5
|
+
import { CheckboxFilterAdapterConfig, createCheckboxFilterAdapter } from "./adapters/create-checkbox-filter-adapter.js";
|
|
6
|
+
import { DualRangeFilterAdapterConfig, DualRangeFilterValue, RangeValue, createDualRangeFilterAdapter } from "./adapters/create-dual-range-filter-adapter.js";
|
|
7
|
+
import "./adapters/index.js";
|
|
8
|
+
import { UseTableFiltersResult, useTableFilters } from "./hooks/use-table-filters.js";
|
|
9
|
+
import "./hooks/index.js";
|
|
10
|
+
import { RangeFilterProps, RangeFilterValue } from "./components/range-filter/range-filter.js";
|
|
11
|
+
import "./components/range-filter/index.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createFilterAdapter } from "./adapters/create-filter-adapter.js";
|
|
2
|
+
import { createCheckboxFilterAdapter } from "./adapters/create-checkbox-filter-adapter.js";
|
|
3
|
+
import { createDualRangeFilterAdapter } from "./adapters/create-dual-range-filter-adapter.js";
|
|
4
|
+
import "./adapters/index.js";
|
|
5
|
+
import { useTableFilters } from "./hooks/use-table-filters.js";
|
|
6
|
+
import "./hooks/index.js";
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { ChipItem } from "../../../ds-chip-group/ds-chip-group.types.cjs";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import { Row } from "@tanstack/react-table";
|
|
4
|
+
|
|
5
|
+
//#region src/components/ds-table/filters/types/filter-adapter.types.d.ts
|
|
6
|
+
type AnyAdapter = FilterAdapter<any, any, any>;
|
|
7
|
+
/**
|
|
8
|
+
* Base filter adapter interface that all filters must implement
|
|
9
|
+
* This provides a consistent contract for filter behavior
|
|
10
|
+
*
|
|
11
|
+
* @template TData - The row data type
|
|
12
|
+
* @template TFilterValue - The filter state value type
|
|
13
|
+
* @template TCellValue - The actual cell value type from the table (defaults to unknown)
|
|
14
|
+
*/
|
|
15
|
+
interface FilterAdapter<TData, TFilterValue, TCellValue = unknown> {
|
|
16
|
+
/**
|
|
17
|
+
* Unique identifier for the filter (should match column accessorKey)
|
|
18
|
+
*/
|
|
19
|
+
id: string;
|
|
20
|
+
/**
|
|
21
|
+
* Display label for the filter in the navigation
|
|
22
|
+
*/
|
|
23
|
+
label: string;
|
|
24
|
+
/**
|
|
25
|
+
* Initial/default value for the filter state
|
|
26
|
+
*/
|
|
27
|
+
initialValue: TFilterValue;
|
|
28
|
+
/**
|
|
29
|
+
* TanStack Table filter function
|
|
30
|
+
* Determines if a row matches the current filter value
|
|
31
|
+
*/
|
|
32
|
+
columnFilterFn: (row: Row<TData>, columnId: string, filterValue: TFilterValue) => boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Optional custom cell renderer for the table column
|
|
35
|
+
* Receives the actual cell value from the table, not the filter value
|
|
36
|
+
* If not provided, default rendering will be used
|
|
37
|
+
*/
|
|
38
|
+
cellRenderer?: (value: TCellValue) => ReactNode;
|
|
39
|
+
/**
|
|
40
|
+
* Convert filter value to filter chips for display
|
|
41
|
+
* Returns empty array if no chips should be shown
|
|
42
|
+
*/
|
|
43
|
+
toChips: (value: TFilterValue) => ChipItem[];
|
|
44
|
+
/**
|
|
45
|
+
* Remove a chip from the filter value
|
|
46
|
+
* Returns updated filter value with the chip's effect removed
|
|
47
|
+
*/
|
|
48
|
+
fromChip: (chip: ChipItem, currentValue: TFilterValue) => TFilterValue;
|
|
49
|
+
/**
|
|
50
|
+
* Calculate how many active filters are applied
|
|
51
|
+
* Used for the count indicator in filter navigation
|
|
52
|
+
* Can also be used to check if filter is active (count > 0)
|
|
53
|
+
*/
|
|
54
|
+
getActiveFiltersCount: (value: TFilterValue) => number;
|
|
55
|
+
/**
|
|
56
|
+
* Reset filter to initial state
|
|
57
|
+
*/
|
|
58
|
+
reset: () => TFilterValue;
|
|
59
|
+
/**
|
|
60
|
+
* Render the filter UI component
|
|
61
|
+
* Receives current value and onChange callback
|
|
62
|
+
*/
|
|
63
|
+
renderFilter: (value: TFilterValue, onChange: (value: TFilterValue) => void) => ReactNode;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Filter navigation item used to render filter tabs in the UI
|
|
67
|
+
*/
|
|
68
|
+
interface FilterNavItem {
|
|
69
|
+
/**
|
|
70
|
+
* Unique identifier for the filter (matches FilterAdapter.id)
|
|
71
|
+
*/
|
|
72
|
+
id: string;
|
|
73
|
+
/**
|
|
74
|
+
* Display label for the filter tab
|
|
75
|
+
*/
|
|
76
|
+
label: string;
|
|
77
|
+
/**
|
|
78
|
+
* Optional count badge to display active filters
|
|
79
|
+
*/
|
|
80
|
+
count?: number;
|
|
81
|
+
/**
|
|
82
|
+
* Whether this filter is disabled
|
|
83
|
+
*/
|
|
84
|
+
disabled?: boolean;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Filter state managed by useTableFilters hook
|
|
88
|
+
*/
|
|
89
|
+
interface FilterState<TValue> {
|
|
90
|
+
[filterId: string]: TValue;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Column filter for TanStack Table
|
|
94
|
+
*/
|
|
95
|
+
interface ColumnFilterState<TValue> {
|
|
96
|
+
id: string;
|
|
97
|
+
value: TValue;
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
export { AnyAdapter, ColumnFilterState, FilterAdapter, FilterNavItem, FilterState };
|
|
101
|
+
//# sourceMappingURL=filter-adapter.types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-adapter.types.d.cts","names":[],"sources":["../../../../../src/components/ds-table/filters/types/filter-adapter.types.ts"],"sourcesContent":[],"mappings":";;;;;KAKY,UAAA,GAAa;;AAAzB;AAUA;;;;;;AA2BuC,UA3BtB,aA2BsB,CAAA,KAAA,EAAA,YAAA,EAAA,aAAA,OAAA,CAAA,CAAA;EAMrB;;;EAMwB,EAAA,EAAA,MAAA;EAAiB;;;EAkBpC,KAAA,EAAA,MAAA;EAAgC;;;EAMtC,YAAA,EAjDF,YAiDe;EAsBb;AAOjB;;;wBAxEuB,IAAI,uCAAuC;;;;;;yBAO1C,eAAe;;;;;mBAMrB,iBAAiB;;;;;mBAMjB,wBAAwB,iBAAiB;;;;;;iCAO3B;;;;eAKlB;;;;;wBAMS,gCAAgC,0BAA0B;;;;;UAMhE,aAAA;;;;;;;;;;;;;;;;;;;;;UAsBA;sBACI;;;;;UAMJ;;SAET"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { ChipItem } from "../../../ds-chip-group/ds-chip-group.types.js";
|
|
2
|
+
import "../../../ds-chip-group/index.js";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
import { Row } from "@tanstack/react-table";
|
|
5
|
+
|
|
6
|
+
//#region src/components/ds-table/filters/types/filter-adapter.types.d.ts
|
|
7
|
+
type AnyAdapter = FilterAdapter<any, any, any>;
|
|
8
|
+
/**
|
|
9
|
+
* Base filter adapter interface that all filters must implement
|
|
10
|
+
* This provides a consistent contract for filter behavior
|
|
11
|
+
*
|
|
12
|
+
* @template TData - The row data type
|
|
13
|
+
* @template TFilterValue - The filter state value type
|
|
14
|
+
* @template TCellValue - The actual cell value type from the table (defaults to unknown)
|
|
15
|
+
*/
|
|
16
|
+
interface FilterAdapter<TData, TFilterValue, TCellValue = unknown> {
|
|
17
|
+
/**
|
|
18
|
+
* Unique identifier for the filter (should match column accessorKey)
|
|
19
|
+
*/
|
|
20
|
+
id: string;
|
|
21
|
+
/**
|
|
22
|
+
* Display label for the filter in the navigation
|
|
23
|
+
*/
|
|
24
|
+
label: string;
|
|
25
|
+
/**
|
|
26
|
+
* Initial/default value for the filter state
|
|
27
|
+
*/
|
|
28
|
+
initialValue: TFilterValue;
|
|
29
|
+
/**
|
|
30
|
+
* TanStack Table filter function
|
|
31
|
+
* Determines if a row matches the current filter value
|
|
32
|
+
*/
|
|
33
|
+
columnFilterFn: (row: Row<TData>, columnId: string, filterValue: TFilterValue) => boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Optional custom cell renderer for the table column
|
|
36
|
+
* Receives the actual cell value from the table, not the filter value
|
|
37
|
+
* If not provided, default rendering will be used
|
|
38
|
+
*/
|
|
39
|
+
cellRenderer?: (value: TCellValue) => ReactNode;
|
|
40
|
+
/**
|
|
41
|
+
* Convert filter value to filter chips for display
|
|
42
|
+
* Returns empty array if no chips should be shown
|
|
43
|
+
*/
|
|
44
|
+
toChips: (value: TFilterValue) => ChipItem[];
|
|
45
|
+
/**
|
|
46
|
+
* Remove a chip from the filter value
|
|
47
|
+
* Returns updated filter value with the chip's effect removed
|
|
48
|
+
*/
|
|
49
|
+
fromChip: (chip: ChipItem, currentValue: TFilterValue) => TFilterValue;
|
|
50
|
+
/**
|
|
51
|
+
* Calculate how many active filters are applied
|
|
52
|
+
* Used for the count indicator in filter navigation
|
|
53
|
+
* Can also be used to check if filter is active (count > 0)
|
|
54
|
+
*/
|
|
55
|
+
getActiveFiltersCount: (value: TFilterValue) => number;
|
|
56
|
+
/**
|
|
57
|
+
* Reset filter to initial state
|
|
58
|
+
*/
|
|
59
|
+
reset: () => TFilterValue;
|
|
60
|
+
/**
|
|
61
|
+
* Render the filter UI component
|
|
62
|
+
* Receives current value and onChange callback
|
|
63
|
+
*/
|
|
64
|
+
renderFilter: (value: TFilterValue, onChange: (value: TFilterValue) => void) => ReactNode;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Filter navigation item used to render filter tabs in the UI
|
|
68
|
+
*/
|
|
69
|
+
interface FilterNavItem {
|
|
70
|
+
/**
|
|
71
|
+
* Unique identifier for the filter (matches FilterAdapter.id)
|
|
72
|
+
*/
|
|
73
|
+
id: string;
|
|
74
|
+
/**
|
|
75
|
+
* Display label for the filter tab
|
|
76
|
+
*/
|
|
77
|
+
label: string;
|
|
78
|
+
/**
|
|
79
|
+
* Optional count badge to display active filters
|
|
80
|
+
*/
|
|
81
|
+
count?: number;
|
|
82
|
+
/**
|
|
83
|
+
* Whether this filter is disabled
|
|
84
|
+
*/
|
|
85
|
+
disabled?: boolean;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Filter state managed by useTableFilters hook
|
|
89
|
+
*/
|
|
90
|
+
interface FilterState<TValue> {
|
|
91
|
+
[filterId: string]: TValue;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Column filter for TanStack Table
|
|
95
|
+
*/
|
|
96
|
+
interface ColumnFilterState<TValue> {
|
|
97
|
+
id: string;
|
|
98
|
+
value: TValue;
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
export { AnyAdapter, ColumnFilterState, FilterAdapter, FilterNavItem, FilterState };
|
|
102
|
+
//# sourceMappingURL=filter-adapter.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-adapter.types.d.ts","names":[],"sources":["../../../../../src/components/ds-table/filters/types/filter-adapter.types.ts"],"sourcesContent":[],"mappings":";;;;;;KAKY,UAAA,GAAa;;;AAAzB;AAUA;;;;;AA2BwB,UA3BP,aA2BO,CAAA,KAAA,EAAA,YAAA,EAAA,aAAA,OAAA,CAAA,CAAA;EAAe;;;EAYrB,EAAA,EAAA,MAAA;EAAwB;;;EAY5B,KAAA,EAAA,MAAA;EAMS;;;EAAmE,YAAA,EA3C3E,YA2C2E;EAMzE;AAsBjB;AAOA;;wBAxEuB,IAAI,uCAAuC;;;;;;yBAO1C,eAAe;;;;;mBAMrB,iBAAiB;;;;;mBAMjB,wBAAwB,iBAAiB;;;;;;iCAO3B;;;;eAKlB;;;;;wBAMS,gCAAgC,0BAA0B;;;;;UAMhE,aAAA;;;;;;;;;;;;;;;;;;;;;UAsBA;sBACI;;;;;UAMJ;;SAET"}
|
|
@@ -1 +1,6 @@
|
|
|
1
|
+
const require_create_filter_adapter = require('./filters/adapters/create-filter-adapter.cjs');
|
|
2
|
+
const require_create_checkbox_filter_adapter = require('./filters/adapters/create-checkbox-filter-adapter.cjs');
|
|
3
|
+
const require_create_dual_range_filter_adapter = require('./filters/adapters/create-dual-range-filter-adapter.cjs');
|
|
4
|
+
const require_use_table_filters = require('./filters/hooks/use-table-filters.cjs');
|
|
5
|
+
require('./filters/index.cjs');
|
|
1
6
|
const require_ds_table = require('./ds-table.cjs');
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { RowAction, SecondaryRowAction } from "./components/ds-table-cell/ds-table-cell.types.js";
|
|
2
2
|
import "./components/ds-table-cell/index.js";
|
|
3
|
+
import { AnyAdapter, ColumnFilterState, FilterAdapter, FilterNavItem, FilterState } from "./filters/types/filter-adapter.types.js";
|
|
4
|
+
import { FilterAdapterConfig, createFilterAdapter } from "./filters/adapters/create-filter-adapter.js";
|
|
5
|
+
import { CheckboxFilterItem, CheckboxFilterProps } from "./filters/components/checkbox-filter/checkbox-filter.js";
|
|
6
|
+
import { CheckboxFilterAdapterConfig, createCheckboxFilterAdapter } from "./filters/adapters/create-checkbox-filter-adapter.js";
|
|
7
|
+
import { DualRangeFilterAdapterConfig, DualRangeFilterValue, RangeValue, createDualRangeFilterAdapter } from "./filters/adapters/create-dual-range-filter-adapter.js";
|
|
8
|
+
import { UseTableFiltersResult, useTableFilters } from "./filters/hooks/use-table-filters.js";
|
|
9
|
+
import { RangeFilterProps, RangeFilterValue } from "./filters/components/range-filter/range-filter.js";
|
|
10
|
+
import "./filters/index.js";
|
|
3
11
|
import { Action, DsDataTableProps, DsTableApi, DsTableRowSize, ScrollParams } from "./ds-table.types.js";
|
|
4
12
|
import { DsTable } from "./ds-table.js";
|
|
@@ -1 +1,6 @@
|
|
|
1
|
+
import { createFilterAdapter } from "./filters/adapters/create-filter-adapter.js";
|
|
2
|
+
import { createCheckboxFilterAdapter } from "./filters/adapters/create-checkbox-filter-adapter.js";
|
|
3
|
+
import { createDualRangeFilterAdapter } from "./filters/adapters/create-dual-range-filter-adapter.js";
|
|
4
|
+
import { useTableFilters } from "./filters/hooks/use-table-filters.js";
|
|
5
|
+
import "./filters/index.js";
|
|
1
6
|
import ds_table_default from "./ds-table.js";
|