@object-ui/plugin-tree 13.2.0 → 14.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,69 @@
1
1
  # @object-ui/plugin-tree
2
2
 
3
+ ## 14.1.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [0890fa7]
8
+ - Updated dependencies [2ded18c]
9
+ - Updated dependencies [e628d1f]
10
+ - Updated dependencies [5523fc4]
11
+ - Updated dependencies [887062c]
12
+ - Updated dependencies [055e1d2]
13
+ - Updated dependencies [9e2d58f]
14
+ - Updated dependencies [dea65f7]
15
+ - Updated dependencies [f30ff68]
16
+ - Updated dependencies [073e7aa]
17
+ - Updated dependencies [6c0135c]
18
+ - Updated dependencies [5b52624]
19
+ - Updated dependencies [4afb251]
20
+ - Updated dependencies [d5b1bc0]
21
+ - Updated dependencies [f94905d]
22
+ - Updated dependencies [f0f10f5]
23
+ - @object-ui/core@14.1.0
24
+ - @object-ui/types@14.1.0
25
+ - @object-ui/react@14.1.0
26
+ - @object-ui/components@14.1.0
27
+
28
+ ## 14.0.0
29
+
30
+ ### Patch Changes
31
+
32
+ - 5971cc4: i18n: translate the Profile page, honor inline i18n label objects under bare
33
+ base-language codes, and localize managed-by badges / record quick actions.
34
+
35
+ - `pickLocalized` now upgrades a bare base language (`zh`) to any
36
+ region-qualified key sharing the base (`zh-CN`) — runtime language is
37
+ normalized to the base code while metadata authors write full BCP-47 tags,
38
+ so inline `{ en, 'zh-CN', ... }` label objects previously fell back to
39
+ English.
40
+ - ProfilePage (`account:profile_card` / `/system/profile`): every hardcoded
41
+ string — page title/subtitle, avatar Upload/Replace/Remove, Personal
42
+ Information card, Change/Set Password card — now goes through
43
+ `useObjectTranslation()` with `profile.*` keys (new namespace in all ten
44
+ locale bundles); the lazy-load fallback reuses `common.loading`.
45
+ - `ManagedByBadge` chips/tooltips (Config/System/Append-only/Identity) now
46
+ resolve through new `managedByBadge.*` keys with `{{provider}}`
47
+ interpolation.
48
+ - `record:quick_actions` resolves action labels via the
49
+ `objects.{object}._actions.{action}.label` convention plus `pickLocalized`,
50
+ so object action buttons (Change Password, Enable 2FA, …) localize.
51
+ - `record:details` / `record:related_list` / `record:alert` / `ObjectTree`
52
+ pass inline label objects through `pickLocalized`.
53
+ - Locale bundles: added `managedByBadge` namespace to all ten locales and
54
+ backfilled `list.inlineEditShort` / `inlineEditLabel` /
55
+ `recordEditingTitle` for ja/es/ko/de/fr/pt/ru/ar.
56
+
57
+ - Updated dependencies [443360a]
58
+ - Updated dependencies [86c69c3]
59
+ - Updated dependencies [05e56ca]
60
+ - Updated dependencies [a44e7b6]
61
+ - Updated dependencies [6a74160]
62
+ - @object-ui/core@14.0.0
63
+ - @object-ui/react@14.0.0
64
+ - @object-ui/types@14.0.0
65
+ - @object-ui/components@14.0.0
66
+
3
67
  ## 13.2.0
4
68
 
5
69
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectTree.d.ts","sourceRoot":"","sources":["../src/ObjectTree.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;GAWG;AAEH,OAAO,KAAuC,MAAM,OAAO,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAY,MAAM,kBAAkB,CAAC;AAM7D,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,GAAG,CAAC;IACZ,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACnC,sEAAsE;IACtE,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AA6KD,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA8PhD,CAAC;AAEF,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"ObjectTree.d.ts","sourceRoot":"","sources":["../src/ObjectTree.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;GAWG;AAEH,OAAO,KAAuC,MAAM,OAAO,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAY,MAAM,kBAAkB,CAAC;AAM7D,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,GAAG,CAAC;IACZ,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACnC,sEAAsE;IACtE,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AA6KD,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAoQhD,CAAC;AAEF,eAAe,UAAU,CAAC"}
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { useEffect as e, useMemo as t, useState as n } from "react";
2
2
  import { ComponentRegistry as r, buildExpandFields as i, extractRecords as a } from "@object-ui/core";
3
- import { useNavigationOverlay as o, useSchemaContext as s } from "@object-ui/react";
4
- import { NavigationOverlay as c, cn as l } from "@object-ui/components";
5
- import { ChevronDown as u, ChevronRight as d } from "lucide-react";
6
- import { jsx as f, jsxs as p } from "react/jsx-runtime";
3
+ import { useNavigationOverlay as o, useSafeFieldLabel as s, useSchemaContext as c } from "@object-ui/react";
4
+ import { NavigationOverlay as l, cn as u } from "@object-ui/components";
5
+ import { ChevronDown as d, ChevronRight as f } from "lucide-react";
6
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
7
7
  //#region src/ObjectTree.tsx
8
- function m(e) {
8
+ function h(e) {
9
9
  return e.data ? e.data : e.staticData ? {
10
10
  provider: "value",
11
11
  items: e.staticData
@@ -14,20 +14,20 @@ function m(e) {
14
14
  object: e.objectName
15
15
  } : null;
16
16
  }
17
- function h(e) {
17
+ function g(e) {
18
18
  if (typeof e == "string") return e;
19
19
  if (e && typeof e == "object") return e.name || e.fieldName || e.field || e.key;
20
20
  }
21
- function g(e) {
21
+ function _(e) {
22
22
  let t = e.tree || e.filter?.tree || {}, n = Array.isArray(e.fields) ? e.fields : Array.isArray(t.fields) ? t.fields : [];
23
23
  return {
24
- parentField: h(e.parentField ?? t.parentField),
25
- labelField: h(e.labelField ?? t.labelField ?? e.titleField) ?? "name",
26
- fields: n.map(h).filter((e) => !!e),
24
+ parentField: g(e.parentField ?? t.parentField),
25
+ labelField: g(e.labelField ?? t.labelField ?? e.titleField) ?? "name",
26
+ fields: n.map(g).filter((e) => !!e),
27
27
  defaultExpandedDepth: e.defaultExpandedDepth ?? t.defaultExpandedDepth
28
28
  };
29
29
  }
30
- function _(e, t) {
30
+ function v(e, t) {
31
31
  let n = e?.fields;
32
32
  if (!n || typeof n != "object") return;
33
33
  let r;
@@ -38,11 +38,11 @@ function _(e, t) {
38
38
  }
39
39
  return r;
40
40
  }
41
- function v(e) {
41
+ function y(e) {
42
42
  let t = e?.id ?? e?._id;
43
43
  return t == null ? void 0 : String(t);
44
44
  }
45
- function y(e, t) {
45
+ function b(e, t) {
46
46
  if (!t) return;
47
47
  let n = e?.[t];
48
48
  if (n != null) {
@@ -53,10 +53,10 @@ function y(e, t) {
53
53
  return String(n);
54
54
  }
55
55
  }
56
- function b(e, t) {
56
+ function x(e, t) {
57
57
  let n = /* @__PURE__ */ new Map(), r = [];
58
58
  for (let t of e) {
59
- let e = v(t);
59
+ let e = y(t);
60
60
  e != null && (n.set(e, {
61
61
  id: e,
62
62
  record: t,
@@ -66,7 +66,7 @@ function b(e, t) {
66
66
  }
67
67
  let i = [];
68
68
  for (let e of r) {
69
- let r = n.get(e), a = y(r.record, t), o = a == null ? void 0 : n.get(a);
69
+ let r = n.get(e), a = b(r.record, t), o = a == null ? void 0 : n.get(a);
70
70
  o && o !== r ? o.children.push(r) : i.push(r);
71
71
  }
72
72
  let a = (e, t) => {
@@ -74,32 +74,32 @@ function b(e, t) {
74
74
  };
75
75
  return a(i, 0), i;
76
76
  }
77
- function x(e, t) {
77
+ function S(e, t) {
78
78
  let n = [], r = (e) => {
79
79
  for (let i of e) n.push(i), i.children.length > 0 && t.has(i.id) && r(i.children);
80
80
  };
81
81
  return r(e), n;
82
82
  }
83
- function S(e, t) {
83
+ function C(e, t) {
84
84
  let n = /* @__PURE__ */ new Set(), r = (e) => {
85
85
  for (let i of e) i.children.length !== 0 && (t == null || i.depth < t) && (n.add(i.id), r(i.children));
86
86
  };
87
87
  return r(e), n;
88
88
  }
89
- function C(e) {
89
+ function w(e) {
90
90
  return e == null ? "" : String(typeof e == "object" ? e.name ?? e.label ?? e.id ?? e._id ?? "" : e);
91
91
  }
92
- var w = ({ schema: r, dataSource: s, className: h, onRowClick: v, ...y }) => {
93
- let [w, T] = n([]), [E, D] = n(!0), [O, k] = n(null), [A, j] = n(null), M = t(() => m(r), [r]), N = Array.isArray(y.data) || Array.isArray(r.data) || M?.provider === "value";
92
+ var T = ({ schema: r, dataSource: c, className: g, onRowClick: y, ...b }) => {
93
+ let [T, E] = n([]), [D, O] = n(!0), [k, A] = n(null), [j, M] = n(null), N = t(() => h(r), [r]), P = Array.isArray(b.data) || Array.isArray(r.data) || N?.provider === "value";
94
94
  e(() => {
95
95
  let e = !1;
96
- return N || (async () => {
96
+ return P || (async () => {
97
97
  try {
98
- if (!s || typeof s.getObjectSchema != "function") return;
99
- let t = M?.provider === "object" ? M.object : r.objectName;
98
+ if (!c || typeof c.getObjectSchema != "function") return;
99
+ let t = N?.provider === "object" ? N.object : r.objectName;
100
100
  if (!t) return;
101
- let n = await s.getObjectSchema(t);
102
- e || j(n);
101
+ let n = await c.getObjectSchema(t);
102
+ e || M(n);
103
103
  } catch (e) {
104
104
  console.error("[ObjectTree] Failed to fetch object schema:", e);
105
105
  }
@@ -108,140 +108,143 @@ var w = ({ schema: r, dataSource: s, className: h, onRowClick: v, ...y }) => {
108
108
  };
109
109
  }, [
110
110
  r.objectName,
111
- s,
112
- M,
113
- N
111
+ c,
112
+ N,
113
+ P
114
114
  ]), e(() => {
115
115
  let e = !1;
116
116
  return (async () => {
117
117
  try {
118
- if (D(!0), k(null), M?.provider === "object" && s && typeof s.find == "function") {
119
- let t = i(A?.fields), n = await s.find(M.object, {
118
+ if (O(!0), A(null), N?.provider === "object" && c && typeof c.find == "function") {
119
+ let t = i(j?.fields), n = await c.find(N.object, {
120
120
  $filter: r.filter,
121
121
  ...t.length > 0 ? { $expand: t } : {}
122
122
  });
123
- e || (T(a(n)), D(!1));
123
+ e || (E(a(n)), O(!1));
124
124
  return;
125
125
  }
126
- let t = y.data ?? r.data;
126
+ let t = b.data ?? r.data;
127
127
  if (Array.isArray(t)) {
128
- e || (T(t), D(!1));
128
+ e || (E(t), O(!1));
129
129
  return;
130
130
  }
131
- if (M?.provider === "value") {
132
- e || (T(M.items ?? []), D(!1));
131
+ if (N?.provider === "value") {
132
+ e || (E(N.items ?? []), O(!1));
133
133
  return;
134
134
  }
135
- e || (T([]), D(!1));
135
+ e || (E([]), O(!1));
136
136
  } catch (t) {
137
- e || (k(t), D(!1));
137
+ e || (A(t), O(!1));
138
138
  }
139
139
  })(), () => {
140
140
  e = !0;
141
141
  };
142
142
  }, [
143
- M,
144
- s,
143
+ N,
144
+ c,
145
145
  r.filter,
146
- A,
147
- y.data
146
+ j,
147
+ b.data
148
148
  ]);
149
- let P = t(() => g(r), [r]), F = t(() => P.parentField ?? _(A, r.objectName), [
150
- P.parentField,
151
- A,
149
+ let F = t(() => _(r), [r]), I = t(() => F.parentField ?? v(j, r.objectName), [
150
+ F.parentField,
151
+ j,
152
152
  r.objectName
153
- ]), I = t(() => b(w, F), [w, F]), [L, R] = n(/* @__PURE__ */ new Set());
153
+ ]), L = t(() => x(T, I), [T, I]), [R, z] = n(/* @__PURE__ */ new Set());
154
154
  e(() => {
155
- R(S(I, P.defaultExpandedDepth));
156
- }, [I, P.defaultExpandedDepth]);
157
- let z = (e) => R((t) => {
155
+ z(C(L, F.defaultExpandedDepth));
156
+ }, [L, F.defaultExpandedDepth]);
157
+ let B = (e) => z((t) => {
158
158
  let n = new Set(t);
159
159
  return n.has(e) ? n.delete(e) : n.add(e), n;
160
- }), B = t(() => x(I, L), [I, L]), V = (e) => A?.fields?.[e]?.label || e.replace(/_/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()), H = o({
160
+ }), V = t(() => S(L, R), [L, R]), H = s(), U = (N?.provider === "object" ? N.object : void 0) ?? r.objectName, W = (e) => {
161
+ let t = j?.fields?.[e]?.label || e.replace(/_/g, " ").replace(/\b\w/g, (e) => e.toUpperCase());
162
+ return U ? H.fieldLabel(U, e, t) : t;
163
+ }, G = o({
161
164
  navigation: r.navigation,
162
165
  objectName: r.objectName,
163
- onRowClick: v
166
+ onRowClick: y
164
167
  });
165
- return O ? /* @__PURE__ */ f("div", {
166
- className: l("flex items-center justify-center h-40 text-destructive", h),
167
- children: /* @__PURE__ */ p("p", { children: ["Failed to load tree: ", O.message] })
168
- }) : E ? /* @__PURE__ */ f("div", {
169
- className: l("flex items-center justify-center h-40 text-muted-foreground", h),
170
- children: /* @__PURE__ */ f("p", { children: "Loading…" })
171
- }) : w.length === 0 ? /* @__PURE__ */ f("div", {
172
- className: l("flex items-center justify-center h-40 text-muted-foreground", h),
173
- children: /* @__PURE__ */ f("p", { children: "No records" })
174
- }) : /* @__PURE__ */ p("div", {
175
- className: l("w-full overflow-auto", h),
168
+ return k ? /* @__PURE__ */ p("div", {
169
+ className: u("flex items-center justify-center h-40 text-destructive", g),
170
+ children: /* @__PURE__ */ m("p", { children: ["Failed to load tree: ", k.message] })
171
+ }) : D ? /* @__PURE__ */ p("div", {
172
+ className: u("flex items-center justify-center h-40 text-muted-foreground", g),
173
+ children: /* @__PURE__ */ p("p", { children: "Loading…" })
174
+ }) : T.length === 0 ? /* @__PURE__ */ p("div", {
175
+ className: u("flex items-center justify-center h-40 text-muted-foreground", g),
176
+ children: /* @__PURE__ */ p("p", { children: "No records" })
177
+ }) : /* @__PURE__ */ m("div", {
178
+ className: u("w-full overflow-auto", g),
176
179
  "data-testid": "object-tree",
177
- children: [/* @__PURE__ */ p("table", {
180
+ children: [/* @__PURE__ */ m("table", {
178
181
  className: "w-full border-collapse text-sm",
179
- children: [/* @__PURE__ */ f("thead", { children: /* @__PURE__ */ p("tr", {
182
+ children: [/* @__PURE__ */ p("thead", { children: /* @__PURE__ */ m("tr", {
180
183
  className: "border-b text-left text-muted-foreground",
181
- children: [/* @__PURE__ */ f("th", {
184
+ children: [/* @__PURE__ */ p("th", {
182
185
  className: "px-3 py-2 font-medium",
183
- children: V(P.labelField)
184
- }), P.fields.filter((e) => e !== P.labelField).map((e) => /* @__PURE__ */ f("th", {
186
+ children: W(F.labelField)
187
+ }), F.fields.filter((e) => e !== F.labelField).map((e) => /* @__PURE__ */ p("th", {
185
188
  className: "px-3 py-2 font-medium",
186
- children: V(e)
189
+ children: W(e)
187
190
  }, e))]
188
- }) }), /* @__PURE__ */ f("tbody", { children: B.map((e) => {
189
- let t = e.children.length > 0, n = L.has(e.id);
190
- return /* @__PURE__ */ p("tr", {
191
+ }) }), /* @__PURE__ */ p("tbody", { children: V.map((e) => {
192
+ let t = e.children.length > 0, n = R.has(e.id);
193
+ return /* @__PURE__ */ m("tr", {
191
194
  className: "border-b hover:bg-accent/50 cursor-pointer",
192
195
  "data-testid": "object-tree-row",
193
196
  "data-depth": e.depth,
194
- onClick: (t) => H.handleClick(e.record, t),
195
- children: [/* @__PURE__ */ f("td", {
197
+ onClick: (t) => G.handleClick(e.record, t),
198
+ children: [/* @__PURE__ */ p("td", {
196
199
  className: "px-3 py-2",
197
- children: /* @__PURE__ */ p("div", {
200
+ children: /* @__PURE__ */ m("div", {
198
201
  className: "flex items-center gap-1",
199
202
  style: { paddingLeft: `${e.depth * 20}px` },
200
- children: [t ? /* @__PURE__ */ f("button", {
203
+ children: [t ? /* @__PURE__ */ p("button", {
201
204
  type: "button",
202
205
  "aria-label": n ? "Collapse" : "Expand",
203
206
  className: "flex h-5 w-5 items-center justify-center rounded-sm text-muted-foreground hover:bg-muted",
204
207
  onClick: (t) => {
205
- t.stopPropagation(), z(e.id);
208
+ t.stopPropagation(), B(e.id);
206
209
  },
207
- children: f(n ? u : d, { className: "h-4 w-4" })
208
- }) : /* @__PURE__ */ f("span", { className: "inline-block h-5 w-5" }), /* @__PURE__ */ f("span", {
210
+ children: p(n ? d : f, { className: "h-4 w-4" })
211
+ }) : /* @__PURE__ */ p("span", { className: "inline-block h-5 w-5" }), /* @__PURE__ */ p("span", {
209
212
  className: "truncate",
210
- children: C(e.record[P.labelField]) || "—"
213
+ children: w(e.record[F.labelField]) || "—"
211
214
  })]
212
215
  })
213
- }), P.fields.filter((e) => e !== P.labelField).map((t) => /* @__PURE__ */ f("td", {
216
+ }), F.fields.filter((e) => e !== F.labelField).map((t) => /* @__PURE__ */ p("td", {
214
217
  className: "px-3 py-2 text-muted-foreground",
215
- children: C(e.record[t])
218
+ children: w(e.record[t])
216
219
  }, t))]
217
220
  }, e.id);
218
221
  }) })]
219
- }), H.isOverlay && /* @__PURE__ */ f(c, {
220
- ...H,
222
+ }), G.isOverlay && /* @__PURE__ */ p(l, {
223
+ ...G,
221
224
  title: "Record Details",
222
- children: (e) => /* @__PURE__ */ f("div", {
225
+ children: (e) => /* @__PURE__ */ p("div", {
223
226
  className: "space-y-3",
224
- children: Object.entries(e).map(([e, t]) => /* @__PURE__ */ p("div", {
227
+ children: Object.entries(e).map(([e, t]) => /* @__PURE__ */ m("div", {
225
228
  className: "flex flex-col",
226
- children: [/* @__PURE__ */ f("span", {
229
+ children: [/* @__PURE__ */ p("span", {
227
230
  className: "text-xs font-medium text-muted-foreground uppercase tracking-wide",
228
231
  children: e.replace(/_/g, " ")
229
- }), /* @__PURE__ */ f("span", {
232
+ }), /* @__PURE__ */ p("span", {
230
233
  className: "text-sm",
231
- children: C(t) || "—"
234
+ children: w(t) || "—"
232
235
  })]
233
236
  }, e))
234
237
  })
235
238
  })]
236
239
  });
237
- }, T = ({ schema: e, ...t }) => {
238
- let { dataSource: n } = s() || {};
239
- return /* @__PURE__ */ f(w, {
240
+ }, E = ({ schema: e, ...t }) => {
241
+ let { dataSource: n } = c() || {};
242
+ return /* @__PURE__ */ p(T, {
240
243
  schema: e,
241
244
  dataSource: n,
242
245
  ...t
243
246
  });
244
- }, E = [{
247
+ }, D = [{
245
248
  name: "objectName",
246
249
  type: "string",
247
250
  label: "Object Name",
@@ -252,16 +255,16 @@ var w = ({ schema: r, dataSource: s, className: h, onRowClick: v, ...y }) => {
252
255
  label: "Tree Config",
253
256
  description: "parentField, labelField, fields, defaultExpandedDepth"
254
257
  }];
255
- r.register("object-tree", T, {
258
+ r.register("object-tree", E, {
256
259
  namespace: "plugin-tree",
257
260
  label: "Object Tree",
258
261
  category: "view",
259
- inputs: E
260
- }), r.register("tree", T, {
262
+ inputs: D
263
+ }), r.register("tree", E, {
261
264
  namespace: "view",
262
265
  label: "Tree View",
263
266
  category: "view",
264
- inputs: E
267
+ inputs: D
265
268
  });
266
269
  //#endregion
267
- export { w as ObjectTree, T as ObjectTreeRenderer };
270
+ export { T as ObjectTree, E as ObjectTreeRenderer };
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("react"),require("@object-ui/core"),require("@object-ui/react"),require("@object-ui/components"),require("lucide-react"),require("react/jsx-runtime")):typeof define==`function`&&define.amd?define([`exports`,`react`,`@object-ui/core`,`@object-ui/react`,`@object-ui/components`,`lucide-react`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginTree={},e.React,e.ObjectUICore,e.ObjectUIReact,e.ObjectUIComponents,e.LucideReact,e.react_jsx_runtime))})(this,function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var s=Object.create,c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty,p=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=u(t),a=0,o=i.length,s;a<o;a++)s=i[a],!f.call(e,s)&&s!==n&&c(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=l(t,s))||r.enumerable});return e};t=((e,t,n)=>(n=e==null?{}:s(d(e)),p(t||!e||!e.__esModule?c(n,`default`,{value:e,enumerable:!0}):n,e)))(t,1);function m(e){return e.data?e.data:e.staticData?{provider:`value`,items:e.staticData}:e.objectName?{provider:`object`,object:e.objectName}:null}function h(e){if(typeof e==`string`)return e;if(e&&typeof e==`object`)return e.name||e.fieldName||e.field||e.key}function g(e){let t=e.tree||e.filter?.tree||{},n=Array.isArray(e.fields)?e.fields:Array.isArray(t.fields)?t.fields:[];return{parentField:h(e.parentField??t.parentField),labelField:h(e.labelField??t.labelField??e.titleField)??`name`,fields:n.map(h).filter(e=>!!e),defaultExpandedDepth:e.defaultExpandedDepth??t.defaultExpandedDepth}}function _(e,t){let n=e?.fields;if(!n||typeof n!=`object`)return;let r;for(let[e,i]of Object.entries(n)){if(i?.type===`tree`)return e;let n=i?.reference||i?.reference_to||i?.referenceTo;!r&&(i?.type===`lookup`||i?.type===`master_detail`)&&n&&t&&n===t&&(r=e)}return r}function v(e){let t=e?.id??e?._id;return t==null?void 0:String(t)}function y(e,t){if(!t)return;let n=e?.[t];if(n!=null){if(typeof n==`object`){let e=n.id??n._id;return e==null?void 0:String(e)}return String(n)}}function b(e,t){let n=new Map,r=[];for(let t of e){let e=v(t);e!=null&&(n.set(e,{id:e,record:t,depth:0,children:[]}),r.push(e))}let i=[];for(let e of r){let r=n.get(e),a=y(r.record,t),o=a==null?void 0:n.get(a);o&&o!==r?o.children.push(r):i.push(r)}let a=(e,t)=>{for(let n of e)n.depth=t,a(n.children,t+1)};return a(i,0),i}function x(e,t){let n=[],r=e=>{for(let i of e)n.push(i),i.children.length>0&&t.has(i.id)&&r(i.children)};return r(e),n}function S(e,t){let n=new Set,r=e=>{for(let i of e)i.children.length!==0&&(t==null||i.depth<t)&&(n.add(i.id),r(i.children))};return r(e),n}function C(e){return e==null?``:String(typeof e==`object`?e.name??e.label??e.id??e._id??``:e)}var w=({schema:e,dataSource:s,className:c,onRowClick:l,...u})=>{let[d,f]=(0,t.useState)([]),[p,h]=(0,t.useState)(!0),[v,y]=(0,t.useState)(null),[w,T]=(0,t.useState)(null),E=(0,t.useMemo)(()=>m(e),[e]),D=Array.isArray(u.data)||Array.isArray(e.data)||E?.provider===`value`;(0,t.useEffect)(()=>{let t=!1;return D||(async()=>{try{if(!s||typeof s.getObjectSchema!=`function`)return;let n=E?.provider===`object`?E.object:e.objectName;if(!n)return;let r=await s.getObjectSchema(n);t||T(r)}catch(e){console.error(`[ObjectTree] Failed to fetch object schema:`,e)}})(),()=>{t=!0}},[e.objectName,s,E,D]),(0,t.useEffect)(()=>{let t=!1;return(async()=>{try{if(h(!0),y(null),E?.provider===`object`&&s&&typeof s.find==`function`){let r=(0,n.buildExpandFields)(w?.fields),i=await s.find(E.object,{$filter:e.filter,...r.length>0?{$expand:r}:{}});t||(f((0,n.extractRecords)(i)),h(!1));return}let r=u.data??e.data;if(Array.isArray(r)){t||(f(r),h(!1));return}if(E?.provider===`value`){t||(f(E.items??[]),h(!1));return}t||(f([]),h(!1))}catch(e){t||(y(e),h(!1))}})(),()=>{t=!0}},[E,s,e.filter,w,u.data]);let O=(0,t.useMemo)(()=>g(e),[e]),k=(0,t.useMemo)(()=>O.parentField??_(w,e.objectName),[O.parentField,w,e.objectName]),A=(0,t.useMemo)(()=>b(d,k),[d,k]),[j,M]=(0,t.useState)(new Set);(0,t.useEffect)(()=>{M(S(A,O.defaultExpandedDepth))},[A,O.defaultExpandedDepth]);let N=e=>M(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),P=(0,t.useMemo)(()=>x(A,j),[A,j]),F=e=>w?.fields?.[e]?.label||e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),I=(0,r.useNavigationOverlay)({navigation:e.navigation,objectName:e.objectName,onRowClick:l});return v?(0,o.jsx)(`div`,{className:(0,i.cn)(`flex items-center justify-center h-40 text-destructive`,c),children:(0,o.jsxs)(`p`,{children:[`Failed to load tree: `,v.message]})}):p?(0,o.jsx)(`div`,{className:(0,i.cn)(`flex items-center justify-center h-40 text-muted-foreground`,c),children:(0,o.jsx)(`p`,{children:`Loading…`})}):d.length===0?(0,o.jsx)(`div`,{className:(0,i.cn)(`flex items-center justify-center h-40 text-muted-foreground`,c),children:(0,o.jsx)(`p`,{children:`No records`})}):(0,o.jsxs)(`div`,{className:(0,i.cn)(`w-full overflow-auto`,c),"data-testid":`object-tree`,children:[(0,o.jsxs)(`table`,{className:`w-full border-collapse text-sm`,children:[(0,o.jsx)(`thead`,{children:(0,o.jsxs)(`tr`,{className:`border-b text-left text-muted-foreground`,children:[(0,o.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:F(O.labelField)}),O.fields.filter(e=>e!==O.labelField).map(e=>(0,o.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:F(e)},e))]})}),(0,o.jsx)(`tbody`,{children:P.map(e=>{let t=e.children.length>0,n=j.has(e.id);return(0,o.jsxs)(`tr`,{className:`border-b hover:bg-accent/50 cursor-pointer`,"data-testid":`object-tree-row`,"data-depth":e.depth,onClick:t=>I.handleClick(e.record,t),children:[(0,o.jsx)(`td`,{className:`px-3 py-2`,children:(0,o.jsxs)(`div`,{className:`flex items-center gap-1`,style:{paddingLeft:`${e.depth*20}px`},children:[t?(0,o.jsx)(`button`,{type:`button`,"aria-label":n?`Collapse`:`Expand`,className:`flex h-5 w-5 items-center justify-center rounded-sm text-muted-foreground hover:bg-muted`,onClick:t=>{t.stopPropagation(),N(e.id)},children:n?(0,o.jsx)(a.ChevronDown,{className:`h-4 w-4`}):(0,o.jsx)(a.ChevronRight,{className:`h-4 w-4`})}):(0,o.jsx)(`span`,{className:`inline-block h-5 w-5`}),(0,o.jsx)(`span`,{className:`truncate`,children:C(e.record[O.labelField])||`—`})]})}),O.fields.filter(e=>e!==O.labelField).map(t=>(0,o.jsx)(`td`,{className:`px-3 py-2 text-muted-foreground`,children:C(e.record[t])},t))]},e.id)})})]}),I.isOverlay&&(0,o.jsx)(i.NavigationOverlay,{...I,title:`Record Details`,children:e=>(0,o.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,o.jsxs)(`div`,{className:`flex flex-col`,children:[(0,o.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,o.jsx)(`span`,{className:`text-sm`,children:C(t)||`—`})]},e))})})]})},T=({schema:e,...t})=>{let{dataSource:n}=(0,r.useSchemaContext)()||{};return(0,o.jsx)(w,{schema:e,dataSource:n,...t})},E=[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`tree`,type:`object`,label:`Tree Config`,description:`parentField, labelField, fields, defaultExpandedDepth`}];n.ComponentRegistry.register(`object-tree`,T,{namespace:`plugin-tree`,label:`Object Tree`,category:`view`,inputs:E}),n.ComponentRegistry.register(`tree`,T,{namespace:`view`,label:`Tree View`,category:`view`,inputs:E}),e.ObjectTree=w,e.ObjectTreeRenderer=T});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("react"),require("@object-ui/core"),require("@object-ui/react"),require("@object-ui/components"),require("lucide-react"),require("react/jsx-runtime")):typeof define==`function`&&define.amd?define([`exports`,`react`,`@object-ui/core`,`@object-ui/react`,`@object-ui/components`,`lucide-react`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginTree={},e.React,e.ObjectUICore,e.ObjectUIReact,e.ObjectUIComponents,e.LucideReact,e.react_jsx_runtime))})(this,function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var s=Object.create,c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty,p=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=u(t),a=0,o=i.length,s;a<o;a++)s=i[a],!f.call(e,s)&&s!==n&&c(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=l(t,s))||r.enumerable});return e};t=((e,t,n)=>(n=e==null?{}:s(d(e)),p(t||!e||!e.__esModule?c(n,`default`,{value:e,enumerable:!0}):n,e)))(t,1);function m(e){return e.data?e.data:e.staticData?{provider:`value`,items:e.staticData}:e.objectName?{provider:`object`,object:e.objectName}:null}function h(e){if(typeof e==`string`)return e;if(e&&typeof e==`object`)return e.name||e.fieldName||e.field||e.key}function g(e){let t=e.tree||e.filter?.tree||{},n=Array.isArray(e.fields)?e.fields:Array.isArray(t.fields)?t.fields:[];return{parentField:h(e.parentField??t.parentField),labelField:h(e.labelField??t.labelField??e.titleField)??`name`,fields:n.map(h).filter(e=>!!e),defaultExpandedDepth:e.defaultExpandedDepth??t.defaultExpandedDepth}}function _(e,t){let n=e?.fields;if(!n||typeof n!=`object`)return;let r;for(let[e,i]of Object.entries(n)){if(i?.type===`tree`)return e;let n=i?.reference||i?.reference_to||i?.referenceTo;!r&&(i?.type===`lookup`||i?.type===`master_detail`)&&n&&t&&n===t&&(r=e)}return r}function v(e){let t=e?.id??e?._id;return t==null?void 0:String(t)}function y(e,t){if(!t)return;let n=e?.[t];if(n!=null){if(typeof n==`object`){let e=n.id??n._id;return e==null?void 0:String(e)}return String(n)}}function b(e,t){let n=new Map,r=[];for(let t of e){let e=v(t);e!=null&&(n.set(e,{id:e,record:t,depth:0,children:[]}),r.push(e))}let i=[];for(let e of r){let r=n.get(e),a=y(r.record,t),o=a==null?void 0:n.get(a);o&&o!==r?o.children.push(r):i.push(r)}let a=(e,t)=>{for(let n of e)n.depth=t,a(n.children,t+1)};return a(i,0),i}function x(e,t){let n=[],r=e=>{for(let i of e)n.push(i),i.children.length>0&&t.has(i.id)&&r(i.children)};return r(e),n}function S(e,t){let n=new Set,r=e=>{for(let i of e)i.children.length!==0&&(t==null||i.depth<t)&&(n.add(i.id),r(i.children))};return r(e),n}function C(e){return e==null?``:String(typeof e==`object`?e.name??e.label??e.id??e._id??``:e)}var w=({schema:e,dataSource:s,className:c,onRowClick:l,...u})=>{let[d,f]=(0,t.useState)([]),[p,h]=(0,t.useState)(!0),[v,y]=(0,t.useState)(null),[w,T]=(0,t.useState)(null),E=(0,t.useMemo)(()=>m(e),[e]),D=Array.isArray(u.data)||Array.isArray(e.data)||E?.provider===`value`;(0,t.useEffect)(()=>{let t=!1;return D||(async()=>{try{if(!s||typeof s.getObjectSchema!=`function`)return;let n=E?.provider===`object`?E.object:e.objectName;if(!n)return;let r=await s.getObjectSchema(n);t||T(r)}catch(e){console.error(`[ObjectTree] Failed to fetch object schema:`,e)}})(),()=>{t=!0}},[e.objectName,s,E,D]),(0,t.useEffect)(()=>{let t=!1;return(async()=>{try{if(h(!0),y(null),E?.provider===`object`&&s&&typeof s.find==`function`){let r=(0,n.buildExpandFields)(w?.fields),i=await s.find(E.object,{$filter:e.filter,...r.length>0?{$expand:r}:{}});t||(f((0,n.extractRecords)(i)),h(!1));return}let r=u.data??e.data;if(Array.isArray(r)){t||(f(r),h(!1));return}if(E?.provider===`value`){t||(f(E.items??[]),h(!1));return}t||(f([]),h(!1))}catch(e){t||(y(e),h(!1))}})(),()=>{t=!0}},[E,s,e.filter,w,u.data]);let O=(0,t.useMemo)(()=>g(e),[e]),k=(0,t.useMemo)(()=>O.parentField??_(w,e.objectName),[O.parentField,w,e.objectName]),A=(0,t.useMemo)(()=>b(d,k),[d,k]),[j,M]=(0,t.useState)(new Set);(0,t.useEffect)(()=>{M(S(A,O.defaultExpandedDepth))},[A,O.defaultExpandedDepth]);let N=e=>M(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),P=(0,t.useMemo)(()=>x(A,j),[A,j]),F=(0,r.useSafeFieldLabel)(),I=(E?.provider===`object`?E.object:void 0)??e.objectName,L=e=>{let t=w?.fields?.[e]?.label||e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase());return I?F.fieldLabel(I,e,t):t},R=(0,r.useNavigationOverlay)({navigation:e.navigation,objectName:e.objectName,onRowClick:l});return v?(0,o.jsx)(`div`,{className:(0,i.cn)(`flex items-center justify-center h-40 text-destructive`,c),children:(0,o.jsxs)(`p`,{children:[`Failed to load tree: `,v.message]})}):p?(0,o.jsx)(`div`,{className:(0,i.cn)(`flex items-center justify-center h-40 text-muted-foreground`,c),children:(0,o.jsx)(`p`,{children:`Loading…`})}):d.length===0?(0,o.jsx)(`div`,{className:(0,i.cn)(`flex items-center justify-center h-40 text-muted-foreground`,c),children:(0,o.jsx)(`p`,{children:`No records`})}):(0,o.jsxs)(`div`,{className:(0,i.cn)(`w-full overflow-auto`,c),"data-testid":`object-tree`,children:[(0,o.jsxs)(`table`,{className:`w-full border-collapse text-sm`,children:[(0,o.jsx)(`thead`,{children:(0,o.jsxs)(`tr`,{className:`border-b text-left text-muted-foreground`,children:[(0,o.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:L(O.labelField)}),O.fields.filter(e=>e!==O.labelField).map(e=>(0,o.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:L(e)},e))]})}),(0,o.jsx)(`tbody`,{children:P.map(e=>{let t=e.children.length>0,n=j.has(e.id);return(0,o.jsxs)(`tr`,{className:`border-b hover:bg-accent/50 cursor-pointer`,"data-testid":`object-tree-row`,"data-depth":e.depth,onClick:t=>R.handleClick(e.record,t),children:[(0,o.jsx)(`td`,{className:`px-3 py-2`,children:(0,o.jsxs)(`div`,{className:`flex items-center gap-1`,style:{paddingLeft:`${e.depth*20}px`},children:[t?(0,o.jsx)(`button`,{type:`button`,"aria-label":n?`Collapse`:`Expand`,className:`flex h-5 w-5 items-center justify-center rounded-sm text-muted-foreground hover:bg-muted`,onClick:t=>{t.stopPropagation(),N(e.id)},children:n?(0,o.jsx)(a.ChevronDown,{className:`h-4 w-4`}):(0,o.jsx)(a.ChevronRight,{className:`h-4 w-4`})}):(0,o.jsx)(`span`,{className:`inline-block h-5 w-5`}),(0,o.jsx)(`span`,{className:`truncate`,children:C(e.record[O.labelField])||`—`})]})}),O.fields.filter(e=>e!==O.labelField).map(t=>(0,o.jsx)(`td`,{className:`px-3 py-2 text-muted-foreground`,children:C(e.record[t])},t))]},e.id)})})]}),R.isOverlay&&(0,o.jsx)(i.NavigationOverlay,{...R,title:`Record Details`,children:e=>(0,o.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,o.jsxs)(`div`,{className:`flex flex-col`,children:[(0,o.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,o.jsx)(`span`,{className:`text-sm`,children:C(t)||`—`})]},e))})})]})},T=({schema:e,...t})=>{let{dataSource:n}=(0,r.useSchemaContext)()||{};return(0,o.jsx)(w,{schema:e,dataSource:n,...t})},E=[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`tree`,type:`object`,label:`Tree Config`,description:`parentField, labelField, fields, defaultExpandedDepth`}];n.ComponentRegistry.register(`object-tree`,T,{namespace:`plugin-tree`,label:`Object Tree`,category:`view`,inputs:E}),n.ComponentRegistry.register(`tree`,T,{namespace:`view`,label:`Tree View`,category:`view`,inputs:E}),e.ObjectTree=w,e.ObjectTreeRenderer=T});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@object-ui/plugin-tree",
3
- "version": "13.2.0",
3
+ "version": "14.1.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Tree / tree-grid visualization plugin for Object UI",
@@ -24,12 +24,12 @@
24
24
  }
25
25
  },
26
26
  "dependencies": {
27
- "@objectstack/spec": "^14.3.0",
28
- "lucide-react": "^1.22.0",
29
- "@object-ui/components": "13.2.0",
30
- "@object-ui/core": "13.2.0",
31
- "@object-ui/react": "13.2.0",
32
- "@object-ui/types": "13.2.0"
27
+ "@objectstack/spec": "^14.6.0",
28
+ "lucide-react": "^1.24.0",
29
+ "@object-ui/components": "14.1.0",
30
+ "@object-ui/core": "14.1.0",
31
+ "@object-ui/react": "14.1.0",
32
+ "@object-ui/types": "14.1.0"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "react": "^18.0.0 || ^19.0.0",
@@ -40,7 +40,7 @@
40
40
  "@types/react-dom": "19.2.3",
41
41
  "@vitejs/plugin-react": "^6.0.3",
42
42
  "typescript": "^6.0.3",
43
- "vite": "^8.1.3",
43
+ "vite": "^8.1.4",
44
44
  "vite-plugin-dts": "^5.0.3"
45
45
  },
46
46
  "keywords": [