@object-ui/core 7.0.0 → 7.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 CHANGED
@@ -1,5 +1,27 @@
1
1
  # @object-ui/core
2
2
 
3
+ ## 7.1.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 08c47da: feat(dashboard): dataset chart widgets paint select/lookup dimensions in their option colors
8
+
9
+ A dashboard `DatasetWidget` chart grouped by a select/lookup dimension (e.g.
10
+ project `health`) painted its categories from the generic `--chart-1..5`
11
+ palette — the same gap the chart view (`object-chart`) had before #1932. It now
12
+ resolves the dimension field's option colors (using the dataset's base `object`
13
+ - dimension→field map the query already returns) and threads them to the
14
+ renderer as a per-category `categoryColors` map, so health green/red/yellow
15
+ paints semantically.
16
+
17
+ The value/label→color resolution is extracted into a shared `buildOptionColorMap`
18
+ (`@object-ui/core`) now used by both `DatasetWidget` and `ObjectChart`.
19
+
20
+ - Updated dependencies [677f7ed]
21
+ - Updated dependencies [a71be60]
22
+ - Updated dependencies [cb03bc3]
23
+ - @object-ui/types@7.1.0
24
+
3
25
  ## 7.0.0
4
26
 
5
27
  ### Minor Changes
@@ -160,6 +160,21 @@ export class ActionEngine {
160
160
  const evaluator = this.runner.getEvaluator();
161
161
  return Array.from(this.actions.values())
162
162
  .filter(ra => ra.locations.includes(location))
163
+ .filter(ra => {
164
+ // [ADR-0066 D4] Capability gate (UI half — the server enforces the
165
+ // source of truth). Hide an action whose `requiredPermissions` are not
166
+ // ALL held by the caller's `systemPermissions`. Fail-OPEN when
167
+ // systemPermissions is unknown (undefined): the server still 403s, and
168
+ // hiding on missing data is a worse regression than showing a button
169
+ // that errors clearly. Mirrors the App/nav requiredPermissions gate.
170
+ const required = ra.action.requiredPermissions;
171
+ if (!Array.isArray(required) || required.length === 0)
172
+ return true;
173
+ const held = this.runner.getContext()?.user?.systemPermissions;
174
+ if (!Array.isArray(held))
175
+ return true;
176
+ return required.every((p) => held.includes(p));
177
+ })
163
178
  .filter(ra => {
164
179
  const raw = ra.action.visible;
165
180
  if (raw == null || raw === '' || raw === true)
@@ -50,3 +50,17 @@ export declare function buildChartSeries(rows: Array<Record<string, unknown>> |
50
50
  * surfaces as `category` / series key). Returns `-1` when nothing matches.
51
51
  */
52
52
  export declare function findChartSeriesRow(rows: Array<Record<string, unknown>> | null | undefined, dimensions: string[] | null | undefined, values: string[] | null | undefined, category: string | undefined, seriesKey?: string): number;
53
+ /**
54
+ * Build a per-category colour map from a select/lookup field's `options`.
55
+ *
56
+ * Keyed by BOTH the option `value` AND its display `label`, because a chart
57
+ * row's category may carry either — the server resolves dataset select
58
+ * dimensions value→label, while the legacy aggregate path keeps the raw value.
59
+ * Returns `null` when the field has no options or none carry a colour, so the
60
+ * caller can fall back to the positional palette.
61
+ *
62
+ * Shared by `ObjectChart` (plugin-charts) and `DatasetWidget` (plugin-dashboard)
63
+ * so a select/lookup dimension's option colours (e.g. health green/red/yellow)
64
+ * paint identically across the chart view and dashboard widgets.
65
+ */
66
+ export declare function buildOptionColorMap(options: unknown): Record<string, string> | null;
@@ -70,3 +70,33 @@ export function findChartSeriesRow(rows, dimensions, values, category, seriesKey
70
70
  }
71
71
  return safeRows.findIndex((r) => String(r[xDim] ?? '') === c);
72
72
  }
73
+ /**
74
+ * Build a per-category colour map from a select/lookup field's `options`.
75
+ *
76
+ * Keyed by BOTH the option `value` AND its display `label`, because a chart
77
+ * row's category may carry either — the server resolves dataset select
78
+ * dimensions value→label, while the legacy aggregate path keeps the raw value.
79
+ * Returns `null` when the field has no options or none carry a colour, so the
80
+ * caller can fall back to the positional palette.
81
+ *
82
+ * Shared by `ObjectChart` (plugin-charts) and `DatasetWidget` (plugin-dashboard)
83
+ * so a select/lookup dimension's option colours (e.g. health green/red/yellow)
84
+ * paint identically across the chart view and dashboard widgets.
85
+ */
86
+ export function buildOptionColorMap(options) {
87
+ if (!Array.isArray(options) || options.length === 0)
88
+ return null;
89
+ const map = {};
90
+ for (const opt of options) {
91
+ if (opt && typeof opt === 'object') {
92
+ const o = opt;
93
+ if (typeof o.color === 'string' && o.color) {
94
+ if (o.value != null)
95
+ map[String(o.value)] = o.color;
96
+ if (o.label != null)
97
+ map[String(o.label)] = o.color;
98
+ }
99
+ }
100
+ }
101
+ return Object.keys(map).length > 0 ? map : null;
102
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@object-ui/core",
3
- "version": "7.0.0",
3
+ "version": "7.1.0",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "license": "MIT",
@@ -29,7 +29,7 @@
29
29
  "@objectstack/spec": "^10.0.0",
30
30
  "lodash": "^4.18.1",
31
31
  "zod": "^4.4.3",
32
- "@object-ui/types": "7.0.0"
32
+ "@object-ui/types": "7.1.0"
33
33
  },
34
34
  "devDependencies": {
35
35
  "typescript": "^6.0.3",