@neo4j-ndl/react 4.14.1 → 4.14.3

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.
Files changed (88) hide show
  1. package/lib/cjs/_common/component-docs-page.js +72 -0
  2. package/lib/cjs/_common/component-docs-page.js.map +1 -0
  3. package/lib/cjs/data-grid/Components.js +3 -1
  4. package/lib/cjs/data-grid/Components.js.map +1 -1
  5. package/lib/cjs/data-grid/DataGrid.js +2 -1
  6. package/lib/cjs/data-grid/DataGrid.js.map +1 -1
  7. package/lib/cjs/data-grid/data-grid-context.js.map +1 -1
  8. package/lib/cjs/data-grid/index.js +14 -1
  9. package/lib/cjs/data-grid/index.js.map +1 -1
  10. package/lib/cjs/data-grid/stories/datagrid-custom-cell-with-style-rules.story.js +142 -0
  11. package/lib/cjs/data-grid/stories/datagrid-custom-cell-with-style-rules.story.js.map +1 -0
  12. package/lib/cjs/data-grid/stories/datagrid-rule-based-styling.story.js +133 -0
  13. package/lib/cjs/data-grid/stories/datagrid-rule-based-styling.story.js.map +1 -0
  14. package/lib/cjs/data-grid/stories/index.js +9 -1
  15. package/lib/cjs/data-grid/stories/index.js.map +1 -1
  16. package/lib/cjs/data-grid/style-rules/evaluate.js +283 -0
  17. package/lib/cjs/data-grid/style-rules/evaluate.js.map +1 -0
  18. package/lib/cjs/data-grid/style-rules/hooks.js +45 -0
  19. package/lib/cjs/data-grid/style-rules/hooks.js.map +1 -0
  20. package/lib/cjs/data-grid/style-rules/index.js +37 -0
  21. package/lib/cjs/data-grid/style-rules/index.js.map +1 -0
  22. package/lib/cjs/data-grid/style-rules/types.js +158 -0
  23. package/lib/cjs/data-grid/style-rules/types.js.map +1 -0
  24. package/lib/cjs/graph-label/GraphLabel.js +9 -8
  25. package/lib/cjs/graph-label/GraphLabel.js.map +1 -1
  26. package/lib/cjs/index.js +3 -8
  27. package/lib/cjs/index.js.map +1 -1
  28. package/lib/esm/_common/component-docs-page.js +69 -0
  29. package/lib/esm/_common/component-docs-page.js.map +1 -0
  30. package/lib/esm/data-grid/Components.js +3 -1
  31. package/lib/esm/data-grid/Components.js.map +1 -1
  32. package/lib/esm/data-grid/DataGrid.js +2 -1
  33. package/lib/esm/data-grid/DataGrid.js.map +1 -1
  34. package/lib/esm/data-grid/data-grid-context.js.map +1 -1
  35. package/lib/esm/data-grid/index.js +3 -0
  36. package/lib/esm/data-grid/index.js.map +1 -1
  37. package/lib/esm/data-grid/stories/datagrid-custom-cell-with-style-rules.story.js +140 -0
  38. package/lib/esm/data-grid/stories/datagrid-custom-cell-with-style-rules.story.js.map +1 -0
  39. package/lib/esm/data-grid/stories/datagrid-rule-based-styling.story.js +131 -0
  40. package/lib/esm/data-grid/stories/datagrid-rule-based-styling.story.js.map +1 -0
  41. package/lib/esm/data-grid/stories/index.js +6 -0
  42. package/lib/esm/data-grid/stories/index.js.map +1 -1
  43. package/lib/esm/data-grid/style-rules/evaluate.js +279 -0
  44. package/lib/esm/data-grid/style-rules/evaluate.js.map +1 -0
  45. package/lib/esm/data-grid/style-rules/hooks.js +42 -0
  46. package/lib/esm/data-grid/style-rules/hooks.js.map +1 -0
  47. package/lib/esm/data-grid/style-rules/index.js +24 -0
  48. package/lib/esm/data-grid/style-rules/index.js.map +1 -0
  49. package/lib/esm/data-grid/style-rules/types.js +155 -0
  50. package/lib/esm/data-grid/style-rules/types.js.map +1 -0
  51. package/lib/esm/graph-label/GraphLabel.js +9 -8
  52. package/lib/esm/graph-label/GraphLabel.js.map +1 -1
  53. package/lib/esm/index.js +1 -1
  54. package/lib/esm/index.js.map +1 -1
  55. package/lib/types/_common/{readme-docs-page.d.ts → component-docs-page.d.ts} +2 -2
  56. package/lib/types/_common/component-docs-page.d.ts.map +1 -0
  57. package/lib/types/data-grid/Components.d.ts.map +1 -1
  58. package/lib/types/data-grid/DataGrid.d.ts +4 -1
  59. package/lib/types/data-grid/DataGrid.d.ts.map +1 -1
  60. package/lib/types/data-grid/data-grid-context.d.ts +2 -0
  61. package/lib/types/data-grid/data-grid-context.d.ts.map +1 -1
  62. package/lib/types/data-grid/index.d.ts +4 -0
  63. package/lib/types/data-grid/index.d.ts.map +1 -1
  64. package/lib/types/data-grid/stories/datagrid-custom-cell-with-style-rules.story.d.ts +24 -0
  65. package/lib/types/data-grid/stories/datagrid-custom-cell-with-style-rules.story.d.ts.map +1 -0
  66. package/lib/types/data-grid/stories/datagrid-pinned-columns.stories.d.ts +2 -2
  67. package/lib/types/data-grid/stories/datagrid-rule-based-styling.story.d.ts +24 -0
  68. package/lib/types/data-grid/stories/datagrid-rule-based-styling.story.d.ts.map +1 -0
  69. package/lib/types/data-grid/stories/datagrid-search-and-filters.stories.d.ts +2 -2
  70. package/lib/types/data-grid/stories/index.d.ts +4 -0
  71. package/lib/types/data-grid/stories/index.d.ts.map +1 -1
  72. package/lib/types/data-grid/style-rules/evaluate.d.ts +41 -0
  73. package/lib/types/data-grid/style-rules/evaluate.d.ts.map +1 -0
  74. package/lib/types/data-grid/style-rules/hooks.d.ts +27 -0
  75. package/lib/types/data-grid/style-rules/hooks.d.ts.map +1 -0
  76. package/lib/types/data-grid/style-rules/index.d.ts +25 -0
  77. package/lib/types/data-grid/style-rules/index.d.ts.map +1 -0
  78. package/lib/types/data-grid/style-rules/types.d.ts +161 -0
  79. package/lib/types/data-grid/style-rules/types.d.ts.map +1 -0
  80. package/lib/types/graph-label/GraphLabel.d.ts.map +1 -1
  81. package/lib/types/index.d.ts +1 -1
  82. package/lib/types/index.d.ts.map +1 -1
  83. package/package.json +4 -3
  84. package/lib/cjs/_common/readme-docs-page.js +0 -55
  85. package/lib/cjs/_common/readme-docs-page.js.map +0 -1
  86. package/lib/esm/_common/readme-docs-page.js +0 -52
  87. package/lib/esm/_common/readme-docs-page.js.map +0 -1
  88. package/lib/types/_common/readme-docs-page.d.ts.map +0 -1
@@ -0,0 +1,283 @@
1
+ "use strict";
2
+ /**
3
+ *
4
+ * Copyright (c) "Neo4j"
5
+ * Neo4j Sweden AB [http://neo4j.com]
6
+ *
7
+ * This file is part of Neo4j.
8
+ *
9
+ * Neo4j is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation, either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
21
+ */
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.computeDataGridRowStyles = computeDataGridRowStyles;
24
+ exports.evaluateDataGridStyleRules = evaluateDataGridStyleRules;
25
+ const react_color_1 = require("@uiw/react-color");
26
+ // --- Color interpolation (duplicated from react-graph to avoid cross-package coupling) ---
27
+ function getWeight(startValue, endValue, value) {
28
+ return (value - startValue) / (endValue - startValue);
29
+ }
30
+ function lerpColor(startColor, endColor, weight) {
31
+ return {
32
+ b: Math.round(startColor.b * (1 - weight) + endColor.b * weight),
33
+ g: Math.round(startColor.g * (1 - weight) + endColor.g * weight),
34
+ r: Math.round(startColor.r * (1 - weight) + endColor.r * weight),
35
+ };
36
+ }
37
+ function getInterpolatedColor(colorRange, rowData) {
38
+ const { onColumn, minValue, minColor, maxValue, maxColor, midValue, midColor, } = colorRange;
39
+ if (!(0, react_color_1.validHex)(minColor) || !(0, react_color_1.validHex)(maxColor)) {
40
+ return null;
41
+ }
42
+ const minRgb = (0, react_color_1.color)(minColor).rgb;
43
+ const maxRgb = (0, react_color_1.color)(maxColor).rgb;
44
+ const actualMinValue = Math.min(minValue, maxValue);
45
+ const actualMaxValue = Math.max(minValue, maxValue);
46
+ let midRgb = undefined;
47
+ if (midValue !== undefined && midColor !== undefined) {
48
+ const isMidInRange = actualMinValue <= midValue && midValue <= actualMaxValue;
49
+ if (!isMidInRange || !(0, react_color_1.validHex)(midColor)) {
50
+ return null;
51
+ }
52
+ midRgb = (0, react_color_1.color)(midColor).rgb;
53
+ }
54
+ const rawValue = rowData[onColumn];
55
+ if (typeof rawValue !== 'number') {
56
+ return null;
57
+ }
58
+ const clampedValue = Math.max(actualMinValue, Math.min(actualMaxValue, rawValue));
59
+ let rgb;
60
+ if (midRgb !== undefined && midValue !== undefined) {
61
+ const t = getWeight(minValue, midValue, clampedValue);
62
+ const isBetweenMinAndMid = t <= 1;
63
+ if (isBetweenMinAndMid) {
64
+ rgb = lerpColor(minRgb, midRgb, t);
65
+ }
66
+ else {
67
+ const t2 = getWeight(midValue, maxValue, clampedValue);
68
+ rgb = lerpColor(midRgb, maxRgb, t2);
69
+ }
70
+ }
71
+ else {
72
+ const t = getWeight(minValue, maxValue, clampedValue);
73
+ rgb = lerpColor(minRgb, maxRgb, t);
74
+ }
75
+ return (0, react_color_1.rgbToHex)(rgb);
76
+ }
77
+ function resolveValue(value, rowData) {
78
+ if (typeof value === 'object' && value !== null && 'column' in value) {
79
+ const cellVal = rowData[value.column];
80
+ if (cellVal === undefined) {
81
+ return null;
82
+ }
83
+ if (typeof cellVal === 'string' ||
84
+ typeof cellVal === 'number' ||
85
+ typeof cellVal === 'boolean') {
86
+ return cellVal;
87
+ }
88
+ return null;
89
+ }
90
+ return value;
91
+ }
92
+ function safeCompare(left, right, rowData, compareFn) {
93
+ const leftVal = resolveValue(left, rowData);
94
+ const rightVal = resolveValue(right, rowData);
95
+ if (leftVal === null || rightVal === null) {
96
+ return null;
97
+ }
98
+ return compareFn(leftVal, rightVal);
99
+ }
100
+ function safeStringCompare(left, right, rowData, compareFn) {
101
+ const leftVal = resolveValue(left, rowData);
102
+ const rightVal = resolveValue(right, rowData);
103
+ if (leftVal === null ||
104
+ rightVal === null ||
105
+ typeof leftVal !== 'string' ||
106
+ typeof rightVal !== 'string') {
107
+ return null;
108
+ }
109
+ return compareFn(leftVal, rightVal);
110
+ }
111
+ function evaluateWhere(rowData, where) {
112
+ if (!where) {
113
+ return true;
114
+ }
115
+ if ('equal' in where) {
116
+ const [left, right] = where.equal;
117
+ const leftVal = resolveValue(left, rowData);
118
+ const rightVal = resolveValue(right, rowData);
119
+ if (leftVal === null || rightVal === null) {
120
+ return null;
121
+ }
122
+ return leftVal === rightVal;
123
+ }
124
+ if ('not' in where) {
125
+ const isMatch = evaluateWhere(rowData, where.not);
126
+ return isMatch === null ? null : !isMatch;
127
+ }
128
+ if ('lessThan' in where) {
129
+ return safeCompare(where.lessThan[0], where.lessThan[1], rowData, (a, b) => a < b);
130
+ }
131
+ if ('lessThanOrEqual' in where) {
132
+ return safeCompare(where.lessThanOrEqual[0], where.lessThanOrEqual[1], rowData, (a, b) => a <= b);
133
+ }
134
+ if ('greaterThan' in where) {
135
+ return safeCompare(where.greaterThan[0], where.greaterThan[1], rowData, (a, b) => a > b);
136
+ }
137
+ if ('greaterThanOrEqual' in where) {
138
+ return safeCompare(where.greaterThanOrEqual[0], where.greaterThanOrEqual[1], rowData, (a, b) => a >= b);
139
+ }
140
+ if ('contains' in where) {
141
+ return safeStringCompare(where.contains[0], where.contains[1], rowData, (a, b) => a.includes(b));
142
+ }
143
+ if ('startsWith' in where) {
144
+ return safeStringCompare(where.startsWith[0], where.startsWith[1], rowData, (a, b) => a.startsWith(b));
145
+ }
146
+ if ('endsWith' in where) {
147
+ return safeStringCompare(where.endsWith[0], where.endsWith[1], rowData, (a, b) => a.endsWith(b));
148
+ }
149
+ if ('isNull' in where) {
150
+ const value = resolveValue(where.isNull, rowData);
151
+ return value === null;
152
+ }
153
+ if ('and' in where) {
154
+ let hasNull = false;
155
+ for (const clause of where.and) {
156
+ const isMatch = evaluateWhere(rowData, clause);
157
+ if (isMatch === false) {
158
+ return false;
159
+ }
160
+ if (isMatch === null) {
161
+ hasNull = true;
162
+ }
163
+ }
164
+ return hasNull ? null : true;
165
+ }
166
+ if ('or' in where) {
167
+ let hasNull = false;
168
+ for (const clause of where.or) {
169
+ const isMatch = evaluateWhere(rowData, clause);
170
+ if (isMatch === true) {
171
+ return true;
172
+ }
173
+ if (isMatch === null) {
174
+ hasNull = true;
175
+ }
176
+ }
177
+ return hasNull ? null : false;
178
+ }
179
+ return false;
180
+ }
181
+ // --- Style resolution ---
182
+ function resolveAppliedStyle(apply, rowData) {
183
+ const result = {};
184
+ let hasStyle = false;
185
+ if (apply.color && !apply.color.isDisabled) {
186
+ result.backgroundColor = apply.color.value;
187
+ hasStyle = true;
188
+ }
189
+ if (apply.textColor && !apply.textColor.isDisabled) {
190
+ result.color = apply.textColor.value;
191
+ hasStyle = true;
192
+ }
193
+ if (apply.colorRange && !apply.colorRange.isDisabled) {
194
+ const interpolated = getInterpolatedColor(apply.colorRange, rowData);
195
+ if (interpolated !== null) {
196
+ result.backgroundColor = interpolated;
197
+ hasStyle = true;
198
+ }
199
+ }
200
+ if (apply.textColorRange && !apply.textColorRange.isDisabled) {
201
+ const interpolated = getInterpolatedColor(apply.textColorRange, rowData);
202
+ if (interpolated !== null) {
203
+ result.color = interpolated;
204
+ hasStyle = true;
205
+ }
206
+ }
207
+ return hasStyle ? result : undefined;
208
+ }
209
+ /**
210
+ * Computes styles for all cells in a row based on the given style rules.
211
+ * When a rule's `column` is `null`, its style is applied to every cell.
212
+ *
213
+ * Used internally by hooks, but exported for context-free usage.
214
+ */
215
+ function computeDataGridRowStyles(rules, rowData) {
216
+ const enabledRules = rules.filter((r) => !r.isDisabled);
217
+ const totalRules = enabledRules.length;
218
+ const sortedRules = enabledRules
219
+ .map((rule, index) => {
220
+ var _a;
221
+ if (rule.priority !== undefined && rule.priority < 0) {
222
+ throw new Error(`DataGridStyleRule priority must be >= 0, got ${rule.priority}. Negative values are reserved for internal use.`);
223
+ }
224
+ return Object.assign(Object.assign({}, rule), { _order: index, _priority: (_a = rule.priority) !== null && _a !== void 0 ? _a : index - totalRules });
225
+ })
226
+ .sort((a, b) => {
227
+ if (a._priority !== b._priority) {
228
+ return a._priority - b._priority;
229
+ }
230
+ return a._order - b._order;
231
+ });
232
+ const cellPriorityMap = {};
233
+ for (const rule of sortedRules) {
234
+ const isMatching = evaluateWhere(rowData, rule.where) === true;
235
+ if (!isMatching) {
236
+ continue;
237
+ }
238
+ const style = resolveAppliedStyle(rule.apply, rowData);
239
+ if (!style) {
240
+ continue;
241
+ }
242
+ const effectivePriority = rule._priority;
243
+ const affectedColumns = rule.column === null ? Object.keys(rowData) : [rule.column];
244
+ for (const col of affectedColumns) {
245
+ if (!cellPriorityMap[col]) {
246
+ cellPriorityMap[col] = {};
247
+ }
248
+ for (const [prop, value] of Object.entries(style)) {
249
+ const existing = cellPriorityMap[col][prop];
250
+ if (!existing || effectivePriority >= existing.priority) {
251
+ cellPriorityMap[col][prop] = {
252
+ priority: effectivePriority,
253
+ value: value,
254
+ };
255
+ }
256
+ }
257
+ }
258
+ }
259
+ const cellStyles = {};
260
+ for (const [col, propMap] of Object.entries(cellPriorityMap)) {
261
+ const style = {};
262
+ let hasProp = false;
263
+ for (const [prop, entry] of Object.entries(propMap)) {
264
+ style[prop] = entry.value;
265
+ hasProp = true;
266
+ }
267
+ cellStyles[col] = hasProp ? style : undefined;
268
+ }
269
+ return { cellStyles };
270
+ }
271
+ /**
272
+ * Evaluate style rules for a single cell.
273
+ * Pure function -- no React context needed.
274
+ *
275
+ * @param rules - Array of style rules to evaluate
276
+ * @param rowData - The row's data as a record (column id -> value)
277
+ * @param columnId - Returns the computed style for this specific cell.
278
+ */
279
+ function evaluateDataGridStyleRules(rules, rowData, columnId) {
280
+ const { cellStyles } = computeDataGridRowStyles(rules, rowData);
281
+ return cellStyles[columnId];
282
+ }
283
+ //# sourceMappingURL=evaluate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluate.js","sourceRoot":"","sources":["../../../../src/data-grid/style-rules/evaluate.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;AA2UH,4DAyEC;AAUD,gEAOC;AAnaD,kDAA4E;AAW5E,4FAA4F;AAE5F,SAAS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C,eAAe,CAAC,EAAE,CAAC;QAC7D,MAAM,KAAK,GAAwB,EAAE,CAAC;QACtC,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YACnD,KAAgC,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC;YACtD,OAAO,GAAG,IAAI,CAAC;QACjB,CAAC;QACD,UAAU,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IAChD,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,CAAC;AACxB,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,0BAA0B,CACxC,KAA0B,EAC1B,OAAgC,EAChC,QAAgB;IAEhB,MAAM,EAAE,UAAU,EAAE,GAAG,wBAAwB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAChE,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { color, type RgbColor, rgbToHex, validHex } from '@uiw/react-color';\n\nimport {\n type DataGridCellStyle,\n type DataGridColorRange,\n type DataGridStyleRule,\n type DataGridStyleRuleLiteral,\n type DataGridStyleRuleOperand,\n type DataGridStyleRuleWhere,\n} from './types';\n\n// --- Color interpolation (duplicated from react-graph to avoid cross-package coupling) ---\n\nfunction getWeight(\n startValue: number,\n endValue: number,\n value: number,\n): number {\n return (value - startValue) / (endValue - startValue);\n}\n\nfunction lerpColor(\n startColor: RgbColor,\n endColor: RgbColor,\n weight: number,\n): RgbColor {\n return {\n b: Math.round(startColor.b * (1 - weight) + endColor.b * weight),\n g: Math.round(startColor.g * (1 - weight) + endColor.g * weight),\n r: Math.round(startColor.r * (1 - weight) + endColor.r * weight),\n };\n}\n\nfunction getInterpolatedColor(\n colorRange: DataGridColorRange,\n rowData: Record<string, unknown>,\n): string | null {\n const {\n onColumn,\n minValue,\n minColor,\n maxValue,\n maxColor,\n midValue,\n midColor,\n } = colorRange;\n\n if (!validHex(minColor) || !validHex(maxColor)) {\n return null;\n }\n\n const minRgb = color(minColor).rgb;\n const maxRgb = color(maxColor).rgb;\n const actualMinValue = Math.min(minValue, maxValue);\n const actualMaxValue = Math.max(minValue, maxValue);\n\n let midRgb: RgbColor | undefined = undefined;\n if (midValue !== undefined && midColor !== undefined) {\n const isMidInRange =\n actualMinValue <= midValue && midValue <= actualMaxValue;\n if (!isMidInRange || !validHex(midColor)) {\n return null;\n }\n midRgb = color(midColor).rgb;\n }\n\n const rawValue = rowData[onColumn];\n if (typeof rawValue !== 'number') {\n return null;\n }\n\n const clampedValue = Math.max(\n actualMinValue,\n Math.min(actualMaxValue, rawValue),\n );\n\n let rgb: RgbColor;\n\n if (midRgb !== undefined && midValue !== undefined) {\n const t = getWeight(minValue, midValue, clampedValue);\n const isBetweenMinAndMid = t <= 1;\n if (isBetweenMinAndMid) {\n rgb = lerpColor(minRgb, midRgb, t);\n } else {\n const t2 = getWeight(midValue, maxValue, clampedValue);\n rgb = lerpColor(midRgb, maxRgb, t2);\n }\n } else {\n const t = getWeight(minValue, maxValue, clampedValue);\n rgb = lerpColor(minRgb, maxRgb, t);\n }\n\n return rgbToHex(rgb);\n}\n\n// --- Where clause evaluation ---\n\ntype Ternary = boolean | null;\n\nfunction resolveValue(\n value: DataGridStyleRuleOperand,\n rowData: Record<string, unknown>,\n): DataGridStyleRuleLiteral {\n if (typeof value === 'object' && value !== null && 'column' in value) {\n const cellVal = rowData[value.column];\n if (cellVal === undefined) {\n return null;\n }\n if (\n typeof cellVal === 'string' ||\n typeof cellVal === 'number' ||\n typeof cellVal === 'boolean'\n ) {\n return cellVal;\n }\n return null;\n }\n return value;\n}\n\nfunction safeCompare(\n left: DataGridStyleRuleOperand,\n right: DataGridStyleRuleOperand,\n rowData: Record<string, unknown>,\n compareFn: (\n a: NonNullable<DataGridStyleRuleLiteral>,\n b: NonNullable<DataGridStyleRuleLiteral>,\n ) => boolean,\n): Ternary {\n const leftVal = resolveValue(left, rowData);\n const rightVal = resolveValue(right, rowData);\n if (leftVal === null || rightVal === null) {\n return null;\n }\n return compareFn(leftVal, rightVal);\n}\n\nfunction safeStringCompare(\n left: DataGridStyleRuleOperand,\n right: DataGridStyleRuleOperand,\n rowData: Record<string, unknown>,\n compareFn: (a: string, b: string) => boolean,\n): Ternary {\n const leftVal = resolveValue(left, rowData);\n const rightVal = resolveValue(right, rowData);\n if (\n leftVal === null ||\n rightVal === null ||\n typeof leftVal !== 'string' ||\n typeof rightVal !== 'string'\n ) {\n return null;\n }\n return compareFn(leftVal, rightVal);\n}\n\nfunction evaluateWhere(\n rowData: Record<string, unknown>,\n where?: DataGridStyleRuleWhere,\n): Ternary {\n if (!where) {\n return true;\n }\n\n if ('equal' in where) {\n const [left, right] = where.equal;\n const leftVal = resolveValue(left, rowData);\n const rightVal = resolveValue(right, rowData);\n if (leftVal === null || rightVal === null) {\n return null;\n }\n return leftVal === rightVal;\n }\n\n if ('not' in where) {\n const isMatch = evaluateWhere(rowData, where.not);\n return isMatch === null ? null : !isMatch;\n }\n\n if ('lessThan' in where) {\n return safeCompare(\n where.lessThan[0],\n where.lessThan[1],\n rowData,\n (a, b) => a < b,\n );\n }\n\n if ('lessThanOrEqual' in where) {\n return safeCompare(\n where.lessThanOrEqual[0],\n where.lessThanOrEqual[1],\n rowData,\n (a, b) => a <= b,\n );\n }\n\n if ('greaterThan' in where) {\n return safeCompare(\n where.greaterThan[0],\n where.greaterThan[1],\n rowData,\n (a, b) => a > b,\n );\n }\n\n if ('greaterThanOrEqual' in where) {\n return safeCompare(\n where.greaterThanOrEqual[0],\n where.greaterThanOrEqual[1],\n rowData,\n (a, b) => a >= b,\n );\n }\n\n if ('contains' in where) {\n return safeStringCompare(\n where.contains[0],\n where.contains[1],\n rowData,\n (a, b) => a.includes(b),\n );\n }\n\n if ('startsWith' in where) {\n return safeStringCompare(\n where.startsWith[0],\n where.startsWith[1],\n rowData,\n (a, b) => a.startsWith(b),\n );\n }\n\n if ('endsWith' in where) {\n return safeStringCompare(\n where.endsWith[0],\n where.endsWith[1],\n rowData,\n (a, b) => a.endsWith(b),\n );\n }\n\n if ('isNull' in where) {\n const value = resolveValue(where.isNull, rowData);\n return value === null;\n }\n\n if ('and' in where) {\n let hasNull = false;\n for (const clause of where.and) {\n const isMatch = evaluateWhere(rowData, clause);\n if (isMatch === false) {\n return false;\n }\n if (isMatch === null) {\n hasNull = true;\n }\n }\n return hasNull ? null : true;\n }\n\n if ('or' in where) {\n let hasNull = false;\n for (const clause of where.or) {\n const isMatch = evaluateWhere(rowData, clause);\n if (isMatch === true) {\n return true;\n }\n if (isMatch === null) {\n hasNull = true;\n }\n }\n return hasNull ? null : false;\n }\n\n return false;\n}\n\n// --- Style resolution ---\n\nfunction resolveAppliedStyle(\n apply: DataGridCellStyle,\n rowData: Record<string, unknown>,\n): React.CSSProperties | undefined {\n const result: React.CSSProperties = {};\n let hasStyle = false;\n\n if (apply.color && !apply.color.isDisabled) {\n result.backgroundColor = apply.color.value;\n hasStyle = true;\n }\n\n if (apply.textColor && !apply.textColor.isDisabled) {\n result.color = apply.textColor.value;\n hasStyle = true;\n }\n\n if (apply.colorRange && !apply.colorRange.isDisabled) {\n const interpolated = getInterpolatedColor(apply.colorRange, rowData);\n if (interpolated !== null) {\n result.backgroundColor = interpolated;\n hasStyle = true;\n }\n }\n\n if (apply.textColorRange && !apply.textColorRange.isDisabled) {\n const interpolated = getInterpolatedColor(apply.textColorRange, rowData);\n if (interpolated !== null) {\n result.color = interpolated;\n hasStyle = true;\n }\n }\n\n return hasStyle ? result : undefined;\n}\n\nexport type ComputedDataGridStyles = {\n cellStyles: Record<string, React.CSSProperties | undefined>;\n};\n\ntype PriorityEntry = { value: string; priority: number };\ntype PropPriorityMap = Record<string, PriorityEntry>;\n\n/**\n * Computes styles for all cells in a row based on the given style rules.\n * When a rule's `column` is `null`, its style is applied to every cell.\n *\n * Used internally by hooks, but exported for context-free usage.\n */\nexport function computeDataGridRowStyles(\n rules: DataGridStyleRule[],\n rowData: Record<string, unknown>,\n): ComputedDataGridStyles {\n const enabledRules = rules.filter((r) => !r.isDisabled);\n const totalRules = enabledRules.length;\n\n const sortedRules = enabledRules\n .map((rule, index) => {\n if (rule.priority !== undefined && rule.priority < 0) {\n throw new Error(\n `DataGridStyleRule priority must be >= 0, got ${rule.priority}. Negative values are reserved for internal use.`,\n );\n }\n\n return {\n ...rule,\n _order: index,\n _priority: rule.priority ?? index - totalRules,\n };\n })\n .sort((a, b) => {\n if (a._priority !== b._priority) {\n return a._priority - b._priority;\n }\n return a._order - b._order;\n });\n\n const cellPriorityMap: Record<string, PropPriorityMap> = {};\n\n for (const rule of sortedRules) {\n const isMatching = evaluateWhere(rowData, rule.where) === true;\n if (!isMatching) {\n continue;\n }\n\n const style = resolveAppliedStyle(rule.apply, rowData);\n if (!style) {\n continue;\n }\n\n const effectivePriority = rule._priority;\n const affectedColumns =\n rule.column === null ? Object.keys(rowData) : [rule.column];\n\n for (const col of affectedColumns) {\n if (!cellPriorityMap[col]) {\n cellPriorityMap[col] = {};\n }\n for (const [prop, value] of Object.entries(style)) {\n const existing = cellPriorityMap[col][prop];\n if (!existing || effectivePriority >= existing.priority) {\n cellPriorityMap[col][prop] = {\n priority: effectivePriority,\n value: value as string,\n };\n }\n }\n }\n }\n\n const cellStyles: Record<string, React.CSSProperties | undefined> = {};\n for (const [col, propMap] of Object.entries(cellPriorityMap)) {\n const style: React.CSSProperties = {};\n let hasProp = false;\n for (const [prop, entry] of Object.entries(propMap)) {\n (style as Record<string, string>)[prop] = entry.value;\n hasProp = true;\n }\n cellStyles[col] = hasProp ? style : undefined;\n }\n\n return { cellStyles };\n}\n\n/**\n * Evaluate style rules for a single cell.\n * Pure function -- no React context needed.\n *\n * @param rules - Array of style rules to evaluate\n * @param rowData - The row's data as a record (column id -> value)\n * @param columnId - Returns the computed style for this specific cell.\n */\nexport function evaluateDataGridStyleRules(\n rules: DataGridStyleRule[],\n rowData: Record<string, unknown>,\n columnId: string,\n): React.CSSProperties | undefined {\n const { cellStyles } = computeDataGridRowStyles(rules, rowData);\n return cellStyles[columnId];\n}\n"]}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ /**
3
+ *
4
+ * Copyright (c) "Neo4j"
5
+ * Neo4j Sweden AB [http://neo4j.com]
6
+ *
7
+ * This file is part of Neo4j.
8
+ *
9
+ * Neo4j is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation, either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
21
+ */
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.useDataGridCellStyle = useDataGridCellStyle;
24
+ const react_1 = require("react");
25
+ const data_grid_context_1 = require("../data-grid-context");
26
+ const evaluate_1 = require("./evaluate");
27
+ /**
28
+ * Returns computed inline style for a specific cell based on style rules in context.
29
+ * Use this in custom BodyCell overrides to apply rule-based styling.
30
+ */
31
+ function useDataGridCellStyle(cell) {
32
+ const { styleRules } = (0, data_grid_context_1.useDataGridContext)();
33
+ return (0, react_1.useMemo)(() => {
34
+ if (!styleRules || styleRules.length === 0) {
35
+ return undefined;
36
+ }
37
+ const original = cell.row.original;
38
+ const rowData = typeof original === 'object' && original !== null
39
+ ? original
40
+ : {};
41
+ const { cellStyles } = (0, evaluate_1.computeDataGridRowStyles)(styleRules, rowData);
42
+ return cellStyles[cell.column.id];
43
+ }, [styleRules, cell]);
44
+ }
45
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../../../src/data-grid/style-rules/hooks.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;AAYH,oDAiBC;AA1BD,iCAAgC;AAEhC,4DAA0D;AAC1D,yCAAsD;AAEtD;;;GAGG;AACH,SAAgB,oBAAoB,CAClC,IAAsB;IAEtB,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,sCAAkB,GAAK,CAAC;IAE/C,OAAO,IAAA,eAAO,EAAC,GAAG,EAAE;QAClB,IAAI,CAAC,UAAU,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3C,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC;QACnC,MAAM,OAAO,GACX,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,IAAI;YAC/C,CAAC,CAAE,QAAoC;YACvC,CAAC,CAAC,EAAE,CAAC;QACT,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,mCAAwB,EAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QACrE,OAAO,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACpC,CAAC,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;AACzB,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { type Cell, type RowData } from '@tanstack/react-table';\nimport { useMemo } from 'react';\n\nimport { useDataGridContext } from '../data-grid-context';\nimport { computeDataGridRowStyles } from './evaluate';\n\n/**\n * Returns computed inline style for a specific cell based on style rules in context.\n * Use this in custom BodyCell overrides to apply rule-based styling.\n */\nexport function useDataGridCellStyle<T extends RowData>(\n cell: Cell<T, unknown>,\n): React.CSSProperties | undefined {\n const { styleRules } = useDataGridContext<T>();\n\n return useMemo(() => {\n if (!styleRules || styleRules.length === 0) {\n return undefined;\n }\n const original = cell.row.original;\n const rowData =\n typeof original === 'object' && original !== null\n ? (original as Record<string, unknown>)\n : {};\n const { cellStyles } = computeDataGridRowStyles(styleRules, rowData);\n return cellStyles[cell.column.id];\n }, [styleRules, cell]);\n}\n"]}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ /**
3
+ *
4
+ * Copyright (c) "Neo4j"
5
+ * Neo4j Sweden AB [http://neo4j.com]
6
+ *
7
+ * This file is part of Neo4j.
8
+ *
9
+ * Neo4j is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation, either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
21
+ */
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.DataGridStyleRuleWhereSchema = exports.DataGridStyleRuleSchema = exports.DataGridStyleRuleOperandSchema = exports.DataGridStyleRuleLiteralSchema = exports.DataGridDisableableColorSchema = exports.DataGridColumnRefSchema = exports.DataGridColorRangeSchema = exports.DataGridCellStyleSchema = exports.useDataGridCellStyle = exports.evaluateDataGridStyleRules = void 0;
24
+ var evaluate_1 = require("./evaluate");
25
+ Object.defineProperty(exports, "evaluateDataGridStyleRules", { enumerable: true, get: function () { return evaluate_1.evaluateDataGridStyleRules; } });
26
+ var hooks_1 = require("./hooks");
27
+ Object.defineProperty(exports, "useDataGridCellStyle", { enumerable: true, get: function () { return hooks_1.useDataGridCellStyle; } });
28
+ var types_1 = require("./types");
29
+ Object.defineProperty(exports, "DataGridCellStyleSchema", { enumerable: true, get: function () { return types_1.DataGridCellStyleSchema; } });
30
+ Object.defineProperty(exports, "DataGridColorRangeSchema", { enumerable: true, get: function () { return types_1.DataGridColorRangeSchema; } });
31
+ Object.defineProperty(exports, "DataGridColumnRefSchema", { enumerable: true, get: function () { return types_1.DataGridColumnRefSchema; } });
32
+ Object.defineProperty(exports, "DataGridDisableableColorSchema", { enumerable: true, get: function () { return types_1.DataGridDisableableColorSchema; } });
33
+ Object.defineProperty(exports, "DataGridStyleRuleLiteralSchema", { enumerable: true, get: function () { return types_1.DataGridStyleRuleLiteralSchema; } });
34
+ Object.defineProperty(exports, "DataGridStyleRuleOperandSchema", { enumerable: true, get: function () { return types_1.DataGridStyleRuleOperandSchema; } });
35
+ Object.defineProperty(exports, "DataGridStyleRuleSchema", { enumerable: true, get: function () { return types_1.DataGridStyleRuleSchema; } });
36
+ Object.defineProperty(exports, "DataGridStyleRuleWhereSchema", { enumerable: true, get: function () { return types_1.DataGridStyleRuleWhereSchema; } });
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/data-grid/style-rules/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAEH,uCAAwD;AAA/C,sHAAA,0BAA0B,OAAA;AACnC,iCAA+C;AAAtC,6GAAA,oBAAoB,OAAA;AAC7B,iCASiB;AARf,gHAAA,uBAAuB,OAAA;AACvB,iHAAA,wBAAwB,OAAA;AACxB,gHAAA,uBAAuB,OAAA;AACvB,uHAAA,8BAA8B,OAAA;AAC9B,uHAAA,8BAA8B,OAAA;AAC9B,uHAAA,8BAA8B,OAAA;AAC9B,gHAAA,uBAAuB,OAAA;AACvB,qHAAA,4BAA4B,OAAA","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nexport { evaluateDataGridStyleRules } from './evaluate';\nexport { useDataGridCellStyle } from './hooks';\nexport {\n DataGridCellStyleSchema,\n DataGridColorRangeSchema,\n DataGridColumnRefSchema,\n DataGridDisableableColorSchema,\n DataGridStyleRuleLiteralSchema,\n DataGridStyleRuleOperandSchema,\n DataGridStyleRuleSchema,\n DataGridStyleRuleWhereSchema,\n} from './types';\nexport type {\n DataGridCellStyle,\n DataGridColorRange,\n DataGridColumnRef,\n DataGridDisableableColor,\n DataGridStyleRuleLiteral,\n DataGridStyleRuleOperand,\n DataGridStyleRule,\n DataGridStyleRuleWhere,\n} from './types';\n"]}
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ /**
3
+ *
4
+ * Copyright (c) "Neo4j"
5
+ * Neo4j Sweden AB [http://neo4j.com]
6
+ *
7
+ * This file is part of Neo4j.
8
+ *
9
+ * Neo4j is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation, either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
21
+ */
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.DataGridStyleRuleSchema = exports.DataGridCellStyleSchema = exports.DataGridDisableableColorSchema = exports.DataGridColorRangeSchema = exports.DataGridStyleRuleWhereSchema = exports.DataGridStyleRuleOperandSchema = exports.DataGridColumnRefSchema = exports.DataGridStyleRuleLiteralSchema = void 0;
24
+ const zod_1 = require("zod");
25
+ /*
26
+ * Style types defined in Zod, so that we can use the schemas to generate JSON Schema.
27
+ * This is useful for generating documentation, importing and for future integration into editors.
28
+ */
29
+ /** A scalar literal that can appear as an operand in a style-rule where clause. */
30
+ exports.DataGridStyleRuleLiteralSchema = zod_1.z.union([
31
+ zod_1.z.string(),
32
+ zod_1.z.number(),
33
+ zod_1.z.boolean(),
34
+ zod_1.z.null(),
35
+ ]);
36
+ /** A reference to a column whose cell value is resolved at evaluation time. */
37
+ exports.DataGridColumnRefSchema = zod_1.z.object({ column: zod_1.z.string() });
38
+ /** An operand in a style-rule where clause -- either a literal value or a column reference. */
39
+ exports.DataGridStyleRuleOperandSchema = zod_1.z.union([
40
+ exports.DataGridColumnRefSchema,
41
+ exports.DataGridStyleRuleLiteralSchema,
42
+ ]);
43
+ exports.DataGridStyleRuleWhereSchema = zod_1.z.lazy(() => zod_1.z.union([
44
+ zod_1.z.object({ not: exports.DataGridStyleRuleWhereSchema }),
45
+ zod_1.z.object({ and: zod_1.z.array(exports.DataGridStyleRuleWhereSchema) }),
46
+ zod_1.z.object({ or: zod_1.z.array(exports.DataGridStyleRuleWhereSchema) }),
47
+ zod_1.z.object({
48
+ equal: zod_1.z.tuple([
49
+ exports.DataGridStyleRuleOperandSchema,
50
+ exports.DataGridStyleRuleOperandSchema,
51
+ ]),
52
+ }),
53
+ zod_1.z.object({
54
+ lessThan: zod_1.z.tuple([
55
+ exports.DataGridStyleRuleOperandSchema,
56
+ exports.DataGridStyleRuleOperandSchema,
57
+ ]),
58
+ }),
59
+ zod_1.z.object({
60
+ lessThanOrEqual: zod_1.z.tuple([
61
+ exports.DataGridStyleRuleOperandSchema,
62
+ exports.DataGridStyleRuleOperandSchema,
63
+ ]),
64
+ }),
65
+ zod_1.z.object({
66
+ greaterThan: zod_1.z.tuple([
67
+ exports.DataGridStyleRuleOperandSchema,
68
+ exports.DataGridStyleRuleOperandSchema,
69
+ ]),
70
+ }),
71
+ zod_1.z.object({
72
+ greaterThanOrEqual: zod_1.z.tuple([
73
+ exports.DataGridStyleRuleOperandSchema,
74
+ exports.DataGridStyleRuleOperandSchema,
75
+ ]),
76
+ }),
77
+ zod_1.z.object({
78
+ contains: zod_1.z.tuple([
79
+ exports.DataGridStyleRuleOperandSchema,
80
+ exports.DataGridStyleRuleOperandSchema,
81
+ ]),
82
+ }),
83
+ zod_1.z.object({
84
+ startsWith: zod_1.z.tuple([
85
+ exports.DataGridStyleRuleOperandSchema,
86
+ exports.DataGridStyleRuleOperandSchema,
87
+ ]),
88
+ }),
89
+ zod_1.z.object({
90
+ endsWith: zod_1.z.tuple([
91
+ exports.DataGridStyleRuleOperandSchema,
92
+ exports.DataGridStyleRuleOperandSchema,
93
+ ]),
94
+ }),
95
+ zod_1.z.object({ isNull: exports.DataGridStyleRuleOperandSchema }),
96
+ ]));
97
+ /**
98
+ * Gradient coloring based on a continuous numeric column value.
99
+ * Colors should be hex strings (#rrggbb).
100
+ * If the column value is missing or non-numeric, the colorRange is ignored.
101
+ */
102
+ exports.DataGridColorRangeSchema = zod_1.z.object({
103
+ /** Disable this color range without removing it. */
104
+ isDisabled: zod_1.z.boolean().optional(),
105
+ /** Hex color (#rrggbb) at the maximum value. */
106
+ maxColor: zod_1.z.string(),
107
+ /** The high end of the numeric range. Values above this clamp to maxColor. */
108
+ maxValue: zod_1.z.number(),
109
+ /** Hex color (#rrggbb) at the optional mid-point for a 3-stop gradient. */
110
+ midColor: zod_1.z.string().optional(),
111
+ /** Optional inflection point between minValue and maxValue for a 3-stop gradient. */
112
+ midValue: zod_1.z.number().optional(),
113
+ /** Hex color (#rrggbb) at the minimum value. */
114
+ minColor: zod_1.z.string(),
115
+ /** The low end of the numeric range. Values below this clamp to minColor. */
116
+ minValue: zod_1.z.number(),
117
+ /** The column whose numeric value drives the interpolation. */
118
+ onColumn: zod_1.z.string(),
119
+ });
120
+ /** A disable-able static color value. */
121
+ exports.DataGridDisableableColorSchema = zod_1.z.object({
122
+ /** Disable this style without removing it. */
123
+ isDisabled: zod_1.z.boolean().optional(),
124
+ /** The CSS color value (e.g. '#fee2e2'). */
125
+ value: zod_1.z.string(),
126
+ });
127
+ /** Visual properties that a style rule can apply to a cell or row. */
128
+ exports.DataGridCellStyleSchema = zod_1.z.object({
129
+ /** CSS background color / cell fill (e.g. '#fee2e2'). Matches the graph `Style.color`. */
130
+ color: exports.DataGridDisableableColorSchema.optional(),
131
+ /** Gradient color interpolation applied to the cell fill. Matches the graph `Style.colorRange`. */
132
+ colorRange: exports.DataGridColorRangeSchema.optional(),
133
+ /** CSS text color (e.g. '#991b1b'). Grid-only; no graph equivalent. */
134
+ textColor: exports.DataGridDisableableColorSchema.optional(),
135
+ /** Gradient color interpolation applied to the text color. Grid-only; no graph equivalent. */
136
+ textColorRange: exports.DataGridColorRangeSchema.optional(),
137
+ });
138
+ /**
139
+ * metaData is an free-form object that can be used to store additional information about a style rule.
140
+ * The data is not taken into account when evaluating the rule.
141
+ */
142
+ const metaDataSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.unknown());
143
+ /** A single declarative rule that conditionally applies styles to DataGrid cells. */
144
+ exports.DataGridStyleRuleSchema = zod_1.z.object({
145
+ /** Style properties to apply when the rule matches. */
146
+ apply: exports.DataGridCellStyleSchema,
147
+ /** Which column this rule targets. Set to null to apply styles to all columns (row-level effect). */
148
+ column: zod_1.z.string().nullable(),
149
+ /** Disable this rule without removing it. */
150
+ isDisabled: zod_1.z.boolean().optional(),
151
+ /** Additional metadata about the rule. */
152
+ metaData: metaDataSchema.optional(),
153
+ /** Higher priority rules are applied later (override lower). Must be >= 0; negative values are reserved for internal use. Rules without explicit priority preserve their array order but are always applied before rules with explicit priority. */
154
+ priority: zod_1.z.number().nonnegative().optional(),
155
+ /** Condition to evaluate. If omitted, rule always applies to matched column(s). */
156
+ where: exports.DataGridStyleRuleWhereSchema.optional(),
157
+ });
158
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/data-grid/style-rules/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAEH,6BAAwB;AAExB;;;GAGG;AAEH,mFAAmF;AACtE,QAAA,8BAA8B,GAAG,OAAC,CAAC,KAAK,CAAC;IACpD,OAAC,CAAC,MAAM,EAAE;IACV,OAAC,CAAC,MAAM,EAAE;IACV,OAAC,CAAC,OAAO,EAAE;IACX,OAAC,CAAC,IAAI,EAAE;CACT,CAAC,CAAC;AAKH,+EAA+E;AAClE,QAAA,uBAAuB,GAAG,OAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAGxE,+FAA+F;AAClF,QAAA,8BAA8B,GAAG,OAAC,CAAC,KAAK,CAAC;IACpD,+BAAuB;IACvB,sCAA8B;CAC/B,CA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AQ,EAAE;IAC/C,uEAAuE;IACvE,SAAS,EAAE,sCAA8B,CAAC,QAAQ,EAAE;IACpD,8FAA8F;IAC9F,cAAc,EAAE,gCAAwB,CAAC,QAAQ,EAAE;CACpD,CAAC,CAAC;AAGH;;;GAGG;AACH,MAAM,cAAc,GAAG,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,CAAC;AAEzD,qFAAqF;AACxE,QAAA,uBAAuB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC9C,uDAAuD;IACvD,KAAK,EAAE,+BAAuB;IAC9B,qGAAqG;IACrG,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,6CAA6C;IAC7C,UAAU,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAClC,0CAA0C;IAC1C,QAAQ,EAAE,cAAc,CAAC,QAAQ,EAAE;IACnC,oPAAoP;IACpP,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE;IAC7C,mFAAmF;IACnF,KAAK,EAAE,oCAA4B,CAAC,QAAQ,EAAE;CAC/C,CAAC,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { z } from 'zod';\n\n/*\n * Style types defined in Zod, so that we can use the schemas to generate JSON Schema.\n * This is useful for generating documentation, importing and for future integration into editors.\n */\n\n/** A scalar literal that can appear as an operand in a style-rule where clause. */\nexport const DataGridStyleRuleLiteralSchema = z.union([\n z.string(),\n z.number(),\n z.boolean(),\n z.null(),\n]);\nexport type DataGridStyleRuleLiteral = z.infer<\n typeof DataGridStyleRuleLiteralSchema\n>;\n\n/** A reference to a column whose cell value is resolved at evaluation time. */\nexport const DataGridColumnRefSchema = z.object({ column: z.string() });\nexport type DataGridColumnRef = z.infer<typeof DataGridColumnRefSchema>;\n\n/** An operand in a style-rule where clause -- either a literal value or a column reference. */\nexport const DataGridStyleRuleOperandSchema = z.union([\n DataGridColumnRefSchema,\n DataGridStyleRuleLiteralSchema,\n]);\nexport type DataGridStyleRuleOperand = z.infer<\n typeof DataGridStyleRuleOperandSchema\n>;\n\n/**\n * Recursive WHERE clause for conditional expressions.\n * Inspired by the graph visualization style rule system but adapted for tabular data.\n *\n * The type is manually defined for the export, since zod doesn't support\n * exporting inferred recursive types.\n */\nexport type DataGridStyleRuleWhere =\n | { not: DataGridStyleRuleWhere }\n | { and: DataGridStyleRuleWhere[] }\n | { or: DataGridStyleRuleWhere[] }\n | { equal: [DataGridStyleRuleOperand, DataGridStyleRuleOperand] }\n | { lessThan: [DataGridStyleRuleOperand, DataGridStyleRuleOperand] }\n | { lessThanOrEqual: [DataGridStyleRuleOperand, DataGridStyleRuleOperand] }\n | { greaterThan: [DataGridStyleRuleOperand, DataGridStyleRuleOperand] }\n | { greaterThanOrEqual: [DataGridStyleRuleOperand, DataGridStyleRuleOperand] }\n | { contains: [DataGridStyleRuleOperand, DataGridStyleRuleOperand] }\n | { startsWith: [DataGridStyleRuleOperand, DataGridStyleRuleOperand] }\n | { endsWith: [DataGridStyleRuleOperand, DataGridStyleRuleOperand] }\n | { isNull: DataGridStyleRuleOperand };\n\nexport const DataGridStyleRuleWhereSchema: z.ZodType<DataGridStyleRuleWhere> =\n z.lazy(() =>\n z.union([\n z.object({ not: DataGridStyleRuleWhereSchema }),\n z.object({ and: z.array(DataGridStyleRuleWhereSchema) }),\n z.object({ or: z.array(DataGridStyleRuleWhereSchema) }),\n z.object({\n equal: z.tuple([\n DataGridStyleRuleOperandSchema,\n DataGridStyleRuleOperandSchema,\n ]),\n }),\n z.object({\n lessThan: z.tuple([\n DataGridStyleRuleOperandSchema,\n DataGridStyleRuleOperandSchema,\n ]),\n }),\n z.object({\n lessThanOrEqual: z.tuple([\n DataGridStyleRuleOperandSchema,\n DataGridStyleRuleOperandSchema,\n ]),\n }),\n z.object({\n greaterThan: z.tuple([\n DataGridStyleRuleOperandSchema,\n DataGridStyleRuleOperandSchema,\n ]),\n }),\n z.object({\n greaterThanOrEqual: z.tuple([\n DataGridStyleRuleOperandSchema,\n DataGridStyleRuleOperandSchema,\n ]),\n }),\n z.object({\n contains: z.tuple([\n DataGridStyleRuleOperandSchema,\n DataGridStyleRuleOperandSchema,\n ]),\n }),\n z.object({\n startsWith: z.tuple([\n DataGridStyleRuleOperandSchema,\n DataGridStyleRuleOperandSchema,\n ]),\n }),\n z.object({\n endsWith: z.tuple([\n DataGridStyleRuleOperandSchema,\n DataGridStyleRuleOperandSchema,\n ]),\n }),\n z.object({ isNull: DataGridStyleRuleOperandSchema }),\n ]),\n );\n\n/**\n * Gradient coloring based on a continuous numeric column value.\n * Colors should be hex strings (#rrggbb).\n * If the column value is missing or non-numeric, the colorRange is ignored.\n */\nexport const DataGridColorRangeSchema = z.object({\n /** Disable this color range without removing it. */\n isDisabled: z.boolean().optional(),\n /** Hex color (#rrggbb) at the maximum value. */\n maxColor: z.string(),\n /** The high end of the numeric range. Values above this clamp to maxColor. */\n maxValue: z.number(),\n /** Hex color (#rrggbb) at the optional mid-point for a 3-stop gradient. */\n midColor: z.string().optional(),\n /** Optional inflection point between minValue and maxValue for a 3-stop gradient. */\n midValue: z.number().optional(),\n /** Hex color (#rrggbb) at the minimum value. */\n minColor: z.string(),\n /** The low end of the numeric range. Values below this clamp to minColor. */\n minValue: z.number(),\n /** The column whose numeric value drives the interpolation. */\n onColumn: z.string(),\n});\nexport type DataGridColorRange = z.infer<typeof DataGridColorRangeSchema>;\n\n/** A disable-able static color value. */\nexport const DataGridDisableableColorSchema = z.object({\n /** Disable this style without removing it. */\n isDisabled: z.boolean().optional(),\n /** The CSS color value (e.g. '#fee2e2'). */\n value: z.string(),\n});\nexport type DataGridDisableableColor = z.infer<\n typeof DataGridDisableableColorSchema\n>;\n\n/** Visual properties that a style rule can apply to a cell or row. */\nexport const DataGridCellStyleSchema = z.object({\n /** CSS background color / cell fill (e.g. '#fee2e2'). Matches the graph `Style.color`. */\n color: DataGridDisableableColorSchema.optional(),\n /** Gradient color interpolation applied to the cell fill. Matches the graph `Style.colorRange`. */\n colorRange: DataGridColorRangeSchema.optional(),\n /** CSS text color (e.g. '#991b1b'). Grid-only; no graph equivalent. */\n textColor: DataGridDisableableColorSchema.optional(),\n /** Gradient color interpolation applied to the text color. Grid-only; no graph equivalent. */\n textColorRange: DataGridColorRangeSchema.optional(),\n});\nexport type DataGridCellStyle = z.infer<typeof DataGridCellStyleSchema>;\n\n/**\n * metaData is an free-form object that can be used to store additional information about a style rule.\n * The data is not taken into account when evaluating the rule.\n */\nconst metaDataSchema = z.record(z.string(), z.unknown());\n\n/** A single declarative rule that conditionally applies styles to DataGrid cells. */\nexport const DataGridStyleRuleSchema = z.object({\n /** Style properties to apply when the rule matches. */\n apply: DataGridCellStyleSchema,\n /** Which column this rule targets. Set to null to apply styles to all columns (row-level effect). */\n column: z.string().nullable(),\n /** Disable this rule without removing it. */\n isDisabled: z.boolean().optional(),\n /** Additional metadata about the rule. */\n metaData: metaDataSchema.optional(),\n /** Higher priority rules are applied later (override lower). Must be >= 0; negative values are reserved for internal use. Rules without explicit priority preserve their array order but are always applied before rules with explicit priority. */\n priority: z.number().nonnegative().optional(),\n /** Condition to evaluate. If omitted, rule always applies to matched column(s). */\n where: DataGridStyleRuleWhereSchema.optional(),\n});\nexport type DataGridStyleRule = z.infer<typeof DataGridStyleRuleSchema>;\n"]}