@coreui/data-grid 0.1.0-rc.0 → 0.3.0-rc.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/README.md +9 -6
- package/dist/css/data-grid.css +156 -38
- package/dist/css/data-grid.css.map +1 -1
- package/dist/css/data-grid.min.css +2 -2
- package/dist/css/data-grid.min.css.map +1 -1
- package/dist/css/data-grid.standalone.css +1066 -0
- package/dist/css/data-grid.standalone.css.map +1 -0
- package/dist/css/data-grid.standalone.min.css +5 -0
- package/dist/css/data-grid.standalone.min.css.map +1 -0
- package/dist/js/clipboard.cjs +56 -0
- package/dist/js/clipboard.cjs.map +1 -0
- package/dist/js/clipboard.mjs +54 -0
- package/dist/js/clipboard.mjs.map +1 -0
- package/dist/js/csv.cjs +36 -59
- package/dist/js/csv.cjs.map +1 -1
- package/dist/js/csv.mjs +35 -55
- package/dist/js/csv.mjs.map +1 -1
- package/dist/js/data-grid.esm.js +14108 -9331
- package/dist/js/data-grid.esm.js.map +1 -1
- package/dist/js/data-grid.esm.min.js +6 -6
- package/dist/js/data-grid.esm.min.js.map +1 -1
- package/dist/js/data-grid.js +14408 -9634
- package/dist/js/data-grid.js.map +1 -1
- package/dist/js/data-grid.lite.esm.js +10507 -0
- package/dist/js/data-grid.lite.esm.js.map +1 -0
- package/dist/js/data-grid.lite.esm.min.js +8 -0
- package/dist/js/data-grid.lite.esm.min.js.map +1 -0
- package/dist/js/data-grid.lite.js +10520 -0
- package/dist/js/data-grid.lite.js.map +1 -0
- package/dist/js/data-grid.lite.min.js +8 -0
- package/dist/js/data-grid.lite.min.js.map +1 -0
- package/dist/js/data-grid.lite.mjs +10507 -0
- package/dist/js/data-grid.lite.mjs.map +1 -0
- package/dist/js/data-grid.min.js +6 -6
- package/dist/js/data-grid.min.js.map +1 -1
- package/dist/js/data-grid.mjs +14108 -9331
- package/dist/js/data-grid.mjs.map +1 -1
- package/dist/js/direction.cjs +26 -0
- package/dist/js/direction.cjs.map +1 -0
- package/dist/js/direction.mjs +24 -0
- package/dist/js/direction.mjs.map +1 -0
- package/dist/js/drag.cjs +467 -0
- package/dist/js/drag.cjs.map +1 -0
- package/dist/js/drag.mjs +464 -0
- package/dist/js/drag.mjs.map +1 -0
- package/dist/js/export-table-BdabEbJG.mjs +26 -0
- package/dist/js/export-table-BdabEbJG.mjs.map +1 -0
- package/dist/js/export-table-D762wrZ1.cjs +55 -0
- package/dist/js/export-table-D762wrZ1.cjs.map +1 -0
- package/dist/js/filters.cjs +89 -132
- package/dist/js/filters.cjs.map +1 -1
- package/dist/js/filters.mjs +88 -128
- package/dist/js/filters.mjs.map +1 -1
- package/dist/js/labels.cjs +65 -70
- package/dist/js/labels.cjs.map +1 -1
- package/dist/js/labels.mjs +64 -66
- package/dist/js/labels.mjs.map +1 -1
- package/dist/js/print.cjs +66 -0
- package/dist/js/print.cjs.map +1 -0
- package/dist/js/print.mjs +64 -0
- package/dist/js/print.mjs.map +1 -0
- package/dist/js/validate.cjs +43 -0
- package/dist/js/validate.cjs.map +1 -0
- package/dist/js/validate.mjs +42 -0
- package/dist/js/validate.mjs.map +1 -0
- package/dist/js/xlsx.cjs +240 -0
- package/dist/js/xlsx.cjs.map +1 -0
- package/dist/js/xlsx.mjs +238 -0
- package/dist/js/xlsx.mjs.map +1 -0
- package/dist/types/base-component.d.ts +28 -18
- package/dist/types/data-grid.d.ts +26 -13
- package/dist/types/dom/data.d.ts +15 -0
- package/dist/types/dom/event-handler.d.ts +21 -10
- package/dist/types/dom/manipulator.d.ts +15 -8
- package/dist/types/engine/active-cell.d.ts +1 -0
- package/dist/types/engine/data-source.d.ts +1 -1
- package/dist/types/engine/features-lite.d.ts +25 -0
- package/dist/types/engine/features.d.ts +35 -0
- package/dist/types/engine/table.d.ts +3 -3
- package/dist/types/engine/validate.d.mts +1 -0
- package/dist/types/engine/validate.d.ts +20 -0
- package/dist/types/engine/virtualizer.d.ts +2 -0
- package/dist/types/icons.d.ts +6 -4
- package/dist/types/index-lite.d.mts +1 -0
- package/dist/types/index-lite.d.ts +19 -0
- package/dist/types/index.d.ts +11 -2
- package/dist/types/types.d.ts +53 -31
- package/dist/types/ui/body.d.ts +6 -3
- package/dist/types/ui/header.d.ts +3 -2
- package/dist/types/ui/loading.d.ts +1 -1
- package/dist/types/ui/pinning.d.ts +1 -1
- package/dist/types/ui/toolbar.d.ts +10 -2
- package/dist/types/util/clipboard.d.mts +1 -0
- package/dist/types/util/clipboard.d.ts +29 -0
- package/dist/types/util/config.d.ts +27 -10
- package/dist/types/util/csv.d.ts +5 -5
- package/dist/types/util/direction.d.mts +1 -0
- package/dist/types/util/direction.d.ts +17 -0
- package/dist/types/util/drag.d.mts +1 -0
- package/dist/types/util/drag.d.ts +48 -0
- package/dist/types/util/export-table.d.ts +47 -0
- package/dist/types/util/index.d.ts +66 -10
- package/dist/types/util/print.d.mts +1 -0
- package/dist/types/util/print.d.ts +32 -0
- package/dist/types/util/sanitizer.d.ts +15 -11
- package/dist/types/util/xlsx.d.mts +1 -0
- package/dist/types/util/xlsx.d.ts +17 -0
- package/dist/types/util/zip.d.ts +11 -0
- package/package.json +101 -10
- package/scss/_base.scss +13 -0
- package/scss/_config.scss +14 -0
- package/scss/_functions.scss +1 -0
- package/scss/_mixins.scss +1 -0
- package/scss/base/_buttons.scss +113 -0
- package/scss/base/_forms.scss +157 -0
- package/scss/base/_helpers.scss +24 -0
- package/scss/base/_pagination.scss +100 -0
- package/scss/base/_reboot.scss +93 -0
- package/scss/base/_root.scss +85 -0
- package/scss/base/_spinner.scss +45 -0
- package/scss/base/_table.scss +78 -0
- package/scss/components/_data-grid.scss +807 -0
- package/scss/data-grid.scss +7 -555
- package/scss/data-grid.standalone.scss +16 -0
- package/scss/functions/_defaults.scss +25 -0
- package/scss/mixins/_tokens.scss +12 -0
- package/src/{base-component.js → base-component.ts} +21 -17
- package/src/data-grid.ts +523 -201
- package/src/dom/{data.js → data.ts} +13 -10
- package/src/dom/event-handler.ts +380 -0
- package/src/dom/{manipulator.js → manipulator.ts} +11 -11
- package/src/engine/active-cell.ts +10 -3
- package/src/engine/data-source.ts +7 -3
- package/src/engine/features-lite.ts +47 -0
- package/src/engine/features.ts +68 -0
- package/src/engine/table.ts +86 -45
- package/src/engine/validate.ts +64 -0
- package/src/engine/virtualizer.ts +17 -1
- package/src/icons.ts +11 -5
- package/src/index-lite.ts +85 -0
- package/src/index.ts +30 -2
- package/src/labels.ts +6 -4
- package/src/types.ts +87 -32
- package/src/ui/body.ts +73 -17
- package/src/ui/header.ts +51 -26
- package/src/ui/loading.ts +2 -2
- package/src/ui/pinning.ts +16 -16
- package/src/ui/toolbar.ts +27 -3
- package/src/util/clipboard.ts +112 -0
- package/src/util/{config.js → config.ts} +25 -11
- package/src/util/csv.ts +11 -30
- package/src/util/direction.ts +37 -0
- package/src/util/drag.ts +832 -0
- package/src/util/export-table.ts +86 -0
- package/src/util/{index.js → index.ts} +55 -35
- package/src/util/print.ts +125 -0
- package/src/util/{sanitizer.js → sanitizer.ts} +17 -13
- package/src/util/xlsx.ts +183 -0
- package/src/util/zip.ts +170 -0
- package/src/base-component.d.ts +0 -19
- package/src/dom/event-handler.d.ts +0 -11
- package/src/dom/event-handler.js +0 -331
- package/src/dom/manipulator.d.ts +0 -9
- package/src/util/config.d.ts +0 -11
- package/src/util/index.d.ts +0 -10
- package/src/util/sanitizer.d.ts +0 -11
package/dist/js/filters.cjs
CHANGED
|
@@ -1,143 +1,100 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* --------------------------------------------------------------------------
|
|
12
|
-
* CoreUI PRO data-grid filters.ts
|
|
13
|
-
* License (https://coreui.io/pro/license/)
|
|
14
|
-
* --------------------------------------------------------------------------
|
|
15
|
-
* Pure filter-operator logic, built as the dependency-free
|
|
16
|
-
* `@coreui/data-grid/filters` subpath so the framework bindings share one
|
|
17
|
-
* implementation without pulling in the vanilla component runtime.
|
|
18
|
-
*/
|
|
2
|
+
* CoreUI PRO data-grid v0.3.0-rc.0 (https://coreui.io)
|
|
3
|
+
* Copyright 2026 The CoreUI Team (https://github.com/orgs/coreui/people)
|
|
4
|
+
* License (https://coreui.io/pro/license/)
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
+
//#region src/filters.ts
|
|
19
8
|
const FILTER_OPERATORS = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
9
|
+
text: [
|
|
10
|
+
"contains",
|
|
11
|
+
"notContains",
|
|
12
|
+
"equals",
|
|
13
|
+
"notEquals",
|
|
14
|
+
"startsWith",
|
|
15
|
+
"endsWith",
|
|
16
|
+
"blank",
|
|
17
|
+
"notBlank"
|
|
18
|
+
],
|
|
19
|
+
number: [
|
|
20
|
+
"equals",
|
|
21
|
+
"notEquals",
|
|
22
|
+
"greaterThan",
|
|
23
|
+
"greaterThanOrEqual",
|
|
24
|
+
"lessThan",
|
|
25
|
+
"lessThanOrEqual",
|
|
26
|
+
"between",
|
|
27
|
+
"blank",
|
|
28
|
+
"notBlank"
|
|
29
|
+
],
|
|
30
|
+
date: [
|
|
31
|
+
"equals",
|
|
32
|
+
"notEquals",
|
|
33
|
+
"greaterThan",
|
|
34
|
+
"greaterThanOrEqual",
|
|
35
|
+
"lessThan",
|
|
36
|
+
"lessThanOrEqual",
|
|
37
|
+
"between",
|
|
38
|
+
"blank",
|
|
39
|
+
"notBlank"
|
|
40
|
+
]
|
|
43
41
|
};
|
|
44
|
-
const VALUELESS_OPERATORS = new Set([
|
|
45
|
-
const isBlank = (value) => value === null || value ===
|
|
42
|
+
const VALUELESS_OPERATORS = /* @__PURE__ */ new Set(["blank", "notBlank"]);
|
|
43
|
+
const isBlank = (value) => value === null || value === void 0 || String(value).trim() === "";
|
|
46
44
|
const toComparable = (value, filterType) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
if (filterType === "date") {
|
|
46
|
+
const time = value instanceof Date ? value.getTime() : new Date(String(value)).getTime();
|
|
47
|
+
return Number.isNaN(time) ? null : time;
|
|
48
|
+
}
|
|
49
|
+
const numeric = typeof value === "number" ? value : Number(value);
|
|
50
|
+
return Number.isFinite(numeric) ? numeric : null;
|
|
53
51
|
};
|
|
54
52
|
const evaluateCondition = (cellValue, condition, filterType) => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
case 'lessThanOrEqual': {
|
|
90
|
-
return cell <= bound;
|
|
91
|
-
}
|
|
92
|
-
case 'between': {
|
|
93
|
-
const upper = toComparable(condition.value2, filterType);
|
|
94
|
-
return upper === null ? cell >= bound : cell >= bound && cell <= upper;
|
|
95
|
-
}
|
|
96
|
-
default: {
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
const cell = String(cellValue !== null && cellValue !== void 0 ? cellValue : '').toLowerCase();
|
|
102
|
-
const needle = String(condition.value).toLowerCase();
|
|
103
|
-
switch (operator) {
|
|
104
|
-
case 'contains': {
|
|
105
|
-
return cell.includes(needle);
|
|
106
|
-
}
|
|
107
|
-
case 'notContains': {
|
|
108
|
-
return !cell.includes(needle);
|
|
109
|
-
}
|
|
110
|
-
case 'equals': {
|
|
111
|
-
return cell === needle;
|
|
112
|
-
}
|
|
113
|
-
case 'notEquals': {
|
|
114
|
-
return cell !== needle;
|
|
115
|
-
}
|
|
116
|
-
case 'startsWith': {
|
|
117
|
-
return cell.startsWith(needle);
|
|
118
|
-
}
|
|
119
|
-
case 'endsWith': {
|
|
120
|
-
return cell.endsWith(needle);
|
|
121
|
-
}
|
|
122
|
-
default: {
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
53
|
+
const { operator } = condition;
|
|
54
|
+
if (operator === "blank") return isBlank(cellValue);
|
|
55
|
+
if (operator === "notBlank") return !isBlank(cellValue);
|
|
56
|
+
if (isBlank(condition.value)) return true;
|
|
57
|
+
if (filterType === "number" || filterType === "date") {
|
|
58
|
+
const cell = toComparable(cellValue, filterType);
|
|
59
|
+
const bound = toComparable(condition.value, filterType);
|
|
60
|
+
if (cell === null || bound === null) return false;
|
|
61
|
+
switch (operator) {
|
|
62
|
+
case "equals": return cell === bound;
|
|
63
|
+
case "notEquals": return cell !== bound;
|
|
64
|
+
case "greaterThan": return cell > bound;
|
|
65
|
+
case "greaterThanOrEqual": return cell >= bound;
|
|
66
|
+
case "lessThan": return cell < bound;
|
|
67
|
+
case "lessThanOrEqual": return cell <= bound;
|
|
68
|
+
case "between": {
|
|
69
|
+
const upper = toComparable(condition.value2, filterType);
|
|
70
|
+
return upper === null ? cell >= bound : cell >= bound && cell <= upper;
|
|
71
|
+
}
|
|
72
|
+
default: return false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const cell = String(cellValue ?? "").toLowerCase();
|
|
76
|
+
const needle = String(condition.value).toLowerCase();
|
|
77
|
+
switch (operator) {
|
|
78
|
+
case "contains": return cell.includes(needle);
|
|
79
|
+
case "notContains": return !cell.includes(needle);
|
|
80
|
+
case "equals": return cell === needle;
|
|
81
|
+
case "notEquals": return cell !== needle;
|
|
82
|
+
case "startsWith": return cell.startsWith(needle);
|
|
83
|
+
case "endsWith": return cell.endsWith(needle);
|
|
84
|
+
default: return false;
|
|
85
|
+
}
|
|
126
86
|
};
|
|
127
|
-
const evaluateColumnFilter = (cellValue, filterValue, filterType =
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const results = filterValue.conditions.map(condition => evaluateCondition(cellValue, condition, filterType));
|
|
135
|
-
return filterValue.join === 'or' ? results.some(Boolean) : results.every(Boolean);
|
|
136
|
-
}
|
|
137
|
-
return filterValue.value.some(candidate => String(candidate) === String(cellValue));
|
|
87
|
+
const evaluateColumnFilter = (cellValue, filterValue, filterType = "text") => {
|
|
88
|
+
if (typeof filterValue === "string") return String(cellValue ?? "").toLowerCase().includes(filterValue.toLowerCase());
|
|
89
|
+
if ("conditions" in filterValue) {
|
|
90
|
+
const results = filterValue.conditions.map((condition) => evaluateCondition(cellValue, condition, filterType));
|
|
91
|
+
return filterValue.join === "or" ? results.some(Boolean) : results.every(Boolean);
|
|
92
|
+
}
|
|
93
|
+
return filterValue.value.some((candidate) => String(candidate) === String(cellValue));
|
|
138
94
|
};
|
|
139
|
-
|
|
95
|
+
//#endregion
|
|
140
96
|
exports.FILTER_OPERATORS = FILTER_OPERATORS;
|
|
141
97
|
exports.VALUELESS_OPERATORS = VALUELESS_OPERATORS;
|
|
142
98
|
exports.evaluateColumnFilter = evaluateColumnFilter;
|
|
143
|
-
|
|
99
|
+
|
|
100
|
+
//# sourceMappingURL=filters.cjs.map
|
package/dist/js/filters.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filters.cjs","sources":["../../src/filters.ts"],"sourcesContent":[
|
|
1
|
+
{"version":3,"file":"filters.cjs","names":[],"sources":["../../src/filters.ts"],"sourcesContent":["/**\n * --------------------------------------------------------------------------\n * CoreUI PRO data-grid filters.ts\n * License (https://coreui.io/pro/license/)\n * --------------------------------------------------------------------------\n * Pure filter-operator logic, built as the dependency-free\n * `@coreui/data-grid/filters` subpath so the framework bindings share one\n * implementation without pulling in the vanilla component runtime.\n */\n\nimport type {\n DataGridColumnFilterValue,\n DataGridFilterCondition,\n DataGridFilterOperator,\n DataGridFilterType\n} from './types'\n\nexport const FILTER_OPERATORS: Record<Exclude<DataGridFilterType, 'select'>, DataGridFilterOperator[]> = {\n text: ['contains', 'notContains', 'equals', 'notEquals', 'startsWith', 'endsWith', 'blank', 'notBlank'],\n number: [\n 'equals',\n 'notEquals',\n 'greaterThan',\n 'greaterThanOrEqual',\n 'lessThan',\n 'lessThanOrEqual',\n 'between',\n 'blank',\n 'notBlank'\n ],\n date: [\n 'equals',\n 'notEquals',\n 'greaterThan',\n 'greaterThanOrEqual',\n 'lessThan',\n 'lessThanOrEqual',\n 'between',\n 'blank',\n 'notBlank'\n ]\n}\n\nexport const VALUELESS_OPERATORS: ReadonlySet<DataGridFilterOperator> = new Set(['blank', 'notBlank'])\n\nconst isBlank = (value: unknown): boolean =>\n value === null || value === undefined || String(value).trim() === ''\n\nconst toComparable = (value: unknown, filterType: DataGridFilterType): number | null => {\n if (filterType === 'date') {\n const time = value instanceof Date ? value.getTime() : new Date(String(value)).getTime()\n return Number.isNaN(time) ? null : time\n }\n\n const numeric = typeof value === 'number' ? value : Number(value)\n return Number.isFinite(numeric) ? numeric : null\n}\n\nconst evaluateCondition = (\n cellValue: unknown,\n condition: DataGridFilterCondition,\n filterType: DataGridFilterType\n): boolean => {\n const { operator } = condition\n\n if (operator === 'blank') {\n return isBlank(cellValue)\n }\n\n if (operator === 'notBlank') {\n return !isBlank(cellValue)\n }\n\n // A condition without a value filters nothing (the menu treats it as\n // incomplete rather than matching nothing).\n if (isBlank(condition.value)) {\n return true\n }\n\n if (filterType === 'number' || filterType === 'date') {\n const cell = toComparable(cellValue, filterType)\n const bound = toComparable(condition.value, filterType)\n if (cell === null || bound === null) {\n return false\n }\n\n switch (operator) {\n case 'equals': {\n return cell === bound\n }\n\n case 'notEquals': {\n return cell !== bound\n }\n\n case 'greaterThan': {\n return cell > bound\n }\n\n case 'greaterThanOrEqual': {\n return cell >= bound\n }\n\n case 'lessThan': {\n return cell < bound\n }\n\n case 'lessThanOrEqual': {\n return cell <= bound\n }\n\n case 'between': {\n const upper = toComparable(condition.value2, filterType)\n return upper === null ? cell >= bound : cell >= bound && cell <= upper\n }\n\n default: {\n return false\n }\n }\n }\n\n const cell = String(cellValue ?? '').toLowerCase()\n const needle = String(condition.value).toLowerCase()\n\n switch (operator) {\n case 'contains': {\n return cell.includes(needle)\n }\n\n case 'notContains': {\n return !cell.includes(needle)\n }\n\n case 'equals': {\n return cell === needle\n }\n\n case 'notEquals': {\n return cell !== needle\n }\n\n case 'startsWith': {\n return cell.startsWith(needle)\n }\n\n case 'endsWith': {\n return cell.endsWith(needle)\n }\n\n default: {\n return false\n }\n }\n}\n\nexport const evaluateColumnFilter = (\n cellValue: unknown,\n filterValue: DataGridColumnFilterValue,\n filterType: DataGridFilterType = 'text'\n): boolean => {\n if (typeof filterValue === 'string') {\n return String(cellValue ?? '')\n .toLowerCase()\n .includes(filterValue.toLowerCase())\n }\n\n if ('conditions' in filterValue) {\n const results = filterValue.conditions.map(condition =>\n evaluateCondition(cellValue, condition, filterType)\n )\n return filterValue.join === 'or' ? results.some(Boolean) : results.every(Boolean)\n }\n\n return filterValue.value.some(candidate => String(candidate) === String(cellValue))\n}\n"],"mappings":";;;;;;;AAiBA,MAAa,mBAA4F;CACvG,MAAM;EAAC;EAAY;EAAe;EAAU;EAAa;EAAc;EAAY;EAA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AU,OAAO,QAAQ,QAAQ,QAAQ,SAAS,QAAQ;GACnE;GAEA,SACE,OAAO;EAEX;CACF;CAEA,MAAM,OAAO,OAAO,aAAa,EAAE,CAAC,CAAC,YAAY;CACjD,MAAM,SAAS,OAAO,UAAU,KAAK,CAAC,CAAC,YAAY;CAEnD,QAAQ,UAAR;EACE,KAAK,YACH,OAAO,KAAK,SAAS,MAAM;EAG7B,KAAK,eACH,OAAO,CAAC,KAAK,SAAS,MAAM;EAG9B,KAAK,UACH,OAAO,SAAS;EAGlB,KAAK,aACH,OAAO,SAAS;EAGlB,KAAK,cACH,OAAO,KAAK,WAAW,MAAM;EAG/B,KAAK,YACH,OAAO,KAAK,SAAS,MAAM;EAG7B,SACE,OAAO;CAEX;AACF;AAEA,MAAa,wBACX,WACA,aACA,aAAiC,WACrB;CACZ,IAAI,OAAO,gBAAgB,UACzB,OAAO,OAAO,aAAa,EAAE,CAAC,CAC3B,YAAY,CAAC,CACb,SAAS,YAAY,YAAY,CAAC;CAGvC,IAAI,gBAAgB,aAAa;EAC/B,MAAM,UAAU,YAAY,WAAW,KAAI,cACzC,kBAAkB,WAAW,WAAW,UAAU,CACpD;EACA,OAAO,YAAY,SAAS,OAAO,QAAQ,KAAK,OAAO,IAAI,QAAQ,MAAM,OAAO;CAClF;CAEA,OAAO,YAAY,MAAM,MAAK,cAAa,OAAO,SAAS,MAAM,OAAO,SAAS,CAAC;AACpF"}
|
package/dist/js/filters.mjs
CHANGED
|
@@ -1,137 +1,97 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* --------------------------------------------------------------------------
|
|
8
|
-
* CoreUI PRO data-grid filters.ts
|
|
9
|
-
* License (https://coreui.io/pro/license/)
|
|
10
|
-
* --------------------------------------------------------------------------
|
|
11
|
-
* Pure filter-operator logic, built as the dependency-free
|
|
12
|
-
* `@coreui/data-grid/filters` subpath so the framework bindings share one
|
|
13
|
-
* implementation without pulling in the vanilla component runtime.
|
|
14
|
-
*/
|
|
2
|
+
* CoreUI PRO data-grid v0.3.0-rc.0 (https://coreui.io)
|
|
3
|
+
* Copyright 2026 The CoreUI Team (https://github.com/orgs/coreui/people)
|
|
4
|
+
* License (https://coreui.io/pro/license/)
|
|
5
|
+
*/
|
|
6
|
+
//#region src/filters.ts
|
|
15
7
|
const FILTER_OPERATORS = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
8
|
+
text: [
|
|
9
|
+
"contains",
|
|
10
|
+
"notContains",
|
|
11
|
+
"equals",
|
|
12
|
+
"notEquals",
|
|
13
|
+
"startsWith",
|
|
14
|
+
"endsWith",
|
|
15
|
+
"blank",
|
|
16
|
+
"notBlank"
|
|
17
|
+
],
|
|
18
|
+
number: [
|
|
19
|
+
"equals",
|
|
20
|
+
"notEquals",
|
|
21
|
+
"greaterThan",
|
|
22
|
+
"greaterThanOrEqual",
|
|
23
|
+
"lessThan",
|
|
24
|
+
"lessThanOrEqual",
|
|
25
|
+
"between",
|
|
26
|
+
"blank",
|
|
27
|
+
"notBlank"
|
|
28
|
+
],
|
|
29
|
+
date: [
|
|
30
|
+
"equals",
|
|
31
|
+
"notEquals",
|
|
32
|
+
"greaterThan",
|
|
33
|
+
"greaterThanOrEqual",
|
|
34
|
+
"lessThan",
|
|
35
|
+
"lessThanOrEqual",
|
|
36
|
+
"between",
|
|
37
|
+
"blank",
|
|
38
|
+
"notBlank"
|
|
39
|
+
]
|
|
39
40
|
};
|
|
40
|
-
const VALUELESS_OPERATORS = new Set([
|
|
41
|
-
const isBlank = (value) => value === null || value ===
|
|
41
|
+
const VALUELESS_OPERATORS = /* @__PURE__ */ new Set(["blank", "notBlank"]);
|
|
42
|
+
const isBlank = (value) => value === null || value === void 0 || String(value).trim() === "";
|
|
42
43
|
const toComparable = (value, filterType) => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
if (filterType === "date") {
|
|
45
|
+
const time = value instanceof Date ? value.getTime() : new Date(String(value)).getTime();
|
|
46
|
+
return Number.isNaN(time) ? null : time;
|
|
47
|
+
}
|
|
48
|
+
const numeric = typeof value === "number" ? value : Number(value);
|
|
49
|
+
return Number.isFinite(numeric) ? numeric : null;
|
|
49
50
|
};
|
|
50
51
|
const evaluateCondition = (cellValue, condition, filterType) => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
case 'lessThanOrEqual': {
|
|
86
|
-
return cell <= bound;
|
|
87
|
-
}
|
|
88
|
-
case 'between': {
|
|
89
|
-
const upper = toComparable(condition.value2, filterType);
|
|
90
|
-
return upper === null ? cell >= bound : cell >= bound && cell <= upper;
|
|
91
|
-
}
|
|
92
|
-
default: {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
const cell = String(cellValue !== null && cellValue !== void 0 ? cellValue : '').toLowerCase();
|
|
98
|
-
const needle = String(condition.value).toLowerCase();
|
|
99
|
-
switch (operator) {
|
|
100
|
-
case 'contains': {
|
|
101
|
-
return cell.includes(needle);
|
|
102
|
-
}
|
|
103
|
-
case 'notContains': {
|
|
104
|
-
return !cell.includes(needle);
|
|
105
|
-
}
|
|
106
|
-
case 'equals': {
|
|
107
|
-
return cell === needle;
|
|
108
|
-
}
|
|
109
|
-
case 'notEquals': {
|
|
110
|
-
return cell !== needle;
|
|
111
|
-
}
|
|
112
|
-
case 'startsWith': {
|
|
113
|
-
return cell.startsWith(needle);
|
|
114
|
-
}
|
|
115
|
-
case 'endsWith': {
|
|
116
|
-
return cell.endsWith(needle);
|
|
117
|
-
}
|
|
118
|
-
default: {
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
52
|
+
const { operator } = condition;
|
|
53
|
+
if (operator === "blank") return isBlank(cellValue);
|
|
54
|
+
if (operator === "notBlank") return !isBlank(cellValue);
|
|
55
|
+
if (isBlank(condition.value)) return true;
|
|
56
|
+
if (filterType === "number" || filterType === "date") {
|
|
57
|
+
const cell = toComparable(cellValue, filterType);
|
|
58
|
+
const bound = toComparable(condition.value, filterType);
|
|
59
|
+
if (cell === null || bound === null) return false;
|
|
60
|
+
switch (operator) {
|
|
61
|
+
case "equals": return cell === bound;
|
|
62
|
+
case "notEquals": return cell !== bound;
|
|
63
|
+
case "greaterThan": return cell > bound;
|
|
64
|
+
case "greaterThanOrEqual": return cell >= bound;
|
|
65
|
+
case "lessThan": return cell < bound;
|
|
66
|
+
case "lessThanOrEqual": return cell <= bound;
|
|
67
|
+
case "between": {
|
|
68
|
+
const upper = toComparable(condition.value2, filterType);
|
|
69
|
+
return upper === null ? cell >= bound : cell >= bound && cell <= upper;
|
|
70
|
+
}
|
|
71
|
+
default: return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const cell = String(cellValue ?? "").toLowerCase();
|
|
75
|
+
const needle = String(condition.value).toLowerCase();
|
|
76
|
+
switch (operator) {
|
|
77
|
+
case "contains": return cell.includes(needle);
|
|
78
|
+
case "notContains": return !cell.includes(needle);
|
|
79
|
+
case "equals": return cell === needle;
|
|
80
|
+
case "notEquals": return cell !== needle;
|
|
81
|
+
case "startsWith": return cell.startsWith(needle);
|
|
82
|
+
case "endsWith": return cell.endsWith(needle);
|
|
83
|
+
default: return false;
|
|
84
|
+
}
|
|
122
85
|
};
|
|
123
|
-
const evaluateColumnFilter = (cellValue, filterValue, filterType =
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const results = filterValue.conditions.map(condition => evaluateCondition(cellValue, condition, filterType));
|
|
131
|
-
return filterValue.join === 'or' ? results.some(Boolean) : results.every(Boolean);
|
|
132
|
-
}
|
|
133
|
-
return filterValue.value.some(candidate => String(candidate) === String(cellValue));
|
|
86
|
+
const evaluateColumnFilter = (cellValue, filterValue, filterType = "text") => {
|
|
87
|
+
if (typeof filterValue === "string") return String(cellValue ?? "").toLowerCase().includes(filterValue.toLowerCase());
|
|
88
|
+
if ("conditions" in filterValue) {
|
|
89
|
+
const results = filterValue.conditions.map((condition) => evaluateCondition(cellValue, condition, filterType));
|
|
90
|
+
return filterValue.join === "or" ? results.some(Boolean) : results.every(Boolean);
|
|
91
|
+
}
|
|
92
|
+
return filterValue.value.some((candidate) => String(candidate) === String(cellValue));
|
|
134
93
|
};
|
|
135
|
-
|
|
94
|
+
//#endregion
|
|
136
95
|
export { FILTER_OPERATORS, VALUELESS_OPERATORS, evaluateColumnFilter };
|
|
137
|
-
|
|
96
|
+
|
|
97
|
+
//# sourceMappingURL=filters.mjs.map
|
package/dist/js/filters.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filters.mjs","sources":["../../src/filters.ts"],"sourcesContent":[
|
|
1
|
+
{"version":3,"file":"filters.mjs","names":[],"sources":["../../src/filters.ts"],"sourcesContent":["/**\n * --------------------------------------------------------------------------\n * CoreUI PRO data-grid filters.ts\n * License (https://coreui.io/pro/license/)\n * --------------------------------------------------------------------------\n * Pure filter-operator logic, built as the dependency-free\n * `@coreui/data-grid/filters` subpath so the framework bindings share one\n * implementation without pulling in the vanilla component runtime.\n */\n\nimport type {\n DataGridColumnFilterValue,\n DataGridFilterCondition,\n DataGridFilterOperator,\n DataGridFilterType\n} from './types'\n\nexport const FILTER_OPERATORS: Record<Exclude<DataGridFilterType, 'select'>, DataGridFilterOperator[]> = {\n text: ['contains', 'notContains', 'equals', 'notEquals', 'startsWith', 'endsWith', 'blank', 'notBlank'],\n number: [\n 'equals',\n 'notEquals',\n 'greaterThan',\n 'greaterThanOrEqual',\n 'lessThan',\n 'lessThanOrEqual',\n 'between',\n 'blank',\n 'notBlank'\n ],\n date: [\n 'equals',\n 'notEquals',\n 'greaterThan',\n 'greaterThanOrEqual',\n 'lessThan',\n 'lessThanOrEqual',\n 'between',\n 'blank',\n 'notBlank'\n ]\n}\n\nexport const VALUELESS_OPERATORS: ReadonlySet<DataGridFilterOperator> = new Set(['blank', 'notBlank'])\n\nconst isBlank = (value: unknown): boolean =>\n value === null || value === undefined || String(value).trim() === ''\n\nconst toComparable = (value: unknown, filterType: DataGridFilterType): number | null => {\n if (filterType === 'date') {\n const time = value instanceof Date ? value.getTime() : new Date(String(value)).getTime()\n return Number.isNaN(time) ? null : time\n }\n\n const numeric = typeof value === 'number' ? value : Number(value)\n return Number.isFinite(numeric) ? numeric : null\n}\n\nconst evaluateCondition = (\n cellValue: unknown,\n condition: DataGridFilterCondition,\n filterType: DataGridFilterType\n): boolean => {\n const { operator } = condition\n\n if (operator === 'blank') {\n return isBlank(cellValue)\n }\n\n if (operator === 'notBlank') {\n return !isBlank(cellValue)\n }\n\n // A condition without a value filters nothing (the menu treats it as\n // incomplete rather than matching nothing).\n if (isBlank(condition.value)) {\n return true\n }\n\n if (filterType === 'number' || filterType === 'date') {\n const cell = toComparable(cellValue, filterType)\n const bound = toComparable(condition.value, filterType)\n if (cell === null || bound === null) {\n return false\n }\n\n switch (operator) {\n case 'equals': {\n return cell === bound\n }\n\n case 'notEquals': {\n return cell !== bound\n }\n\n case 'greaterThan': {\n return cell > bound\n }\n\n case 'greaterThanOrEqual': {\n return cell >= bound\n }\n\n case 'lessThan': {\n return cell < bound\n }\n\n case 'lessThanOrEqual': {\n return cell <= bound\n }\n\n case 'between': {\n const upper = toComparable(condition.value2, filterType)\n return upper === null ? cell >= bound : cell >= bound && cell <= upper\n }\n\n default: {\n return false\n }\n }\n }\n\n const cell = String(cellValue ?? '').toLowerCase()\n const needle = String(condition.value).toLowerCase()\n\n switch (operator) {\n case 'contains': {\n return cell.includes(needle)\n }\n\n case 'notContains': {\n return !cell.includes(needle)\n }\n\n case 'equals': {\n return cell === needle\n }\n\n case 'notEquals': {\n return cell !== needle\n }\n\n case 'startsWith': {\n return cell.startsWith(needle)\n }\n\n case 'endsWith': {\n return cell.endsWith(needle)\n }\n\n default: {\n return false\n }\n }\n}\n\nexport const evaluateColumnFilter = (\n cellValue: unknown,\n filterValue: DataGridColumnFilterValue,\n filterType: DataGridFilterType = 'text'\n): boolean => {\n if (typeof filterValue === 'string') {\n return String(cellValue ?? '')\n .toLowerCase()\n .includes(filterValue.toLowerCase())\n }\n\n if ('conditions' in filterValue) {\n const results = filterValue.conditions.map(condition =>\n evaluateCondition(cellValue, condition, filterType)\n )\n return filterValue.join === 'or' ? results.some(Boolean) : results.every(Boolean)\n }\n\n return filterValue.value.some(candidate => String(candidate) === String(cellValue))\n}\n"],"mappings":";;;;;;AAiBA,MAAa,mBAA4F;CACvG,MAAM;EAAC;EAAY;EAAe;EAAU;EAAa;EAAc;EAAY;EAAS;CAAU;CACtG,QAAQ;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,MAAM;EACJ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF;AAEA,MAAa,sCAA2D,IAAI,IAAI,CAAC,SAAS,UAAU,CAAC;AA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