@appcorp/shadcn 1.0.27 → 1.0.28

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.
@@ -63,22 +63,31 @@ var EnhancedTable = function (_a) {
63
63
  if (!key)
64
64
  return source;
65
65
  if (typeof key === "string") {
66
+ // Handle colon-separated nested keys
67
+ if (key.includes(":")) {
68
+ var keys = key.split(":");
69
+ var cur = source;
70
+ for (var _i = 0, keys_2 = keys; _i < keys_2.length; _i++) {
71
+ var k = keys_2[_i];
72
+ if (cur == null || typeof cur !== "object")
73
+ return undefined;
74
+ cur = cur[k];
75
+ }
76
+ return cur;
77
+ }
78
+ // Simple key access
66
79
  if (source && typeof source === "object")
67
80
  return source[key];
68
81
  return undefined;
69
82
  }
70
- // array of keys
71
- var path = key.slice(0, 3); // enforce max depth 3
72
- var cur = source;
73
- for (var _i = 0, path_1 = path; _i < path_1.length; _i++) {
74
- var k = path_1[_i];
75
- if (cur == null)
76
- return undefined;
77
- if (typeof cur !== "object")
78
- return undefined;
79
- cur = cur[k];
83
+ // array of keys - try each until we find a defined value
84
+ for (var _a = 0, key_1 = key; _a < key_1.length; _a++) {
85
+ var k = key_1[_a];
86
+ var val = resolveValue(source, k);
87
+ if (val != null)
88
+ return val;
80
89
  }
81
- return cur;
90
+ return undefined;
82
91
  };
83
92
  var getProp = function (obj, prop) {
84
93
  if (obj &&
@@ -150,47 +159,51 @@ var EnhancedTable = function (_a) {
150
159
  ? "bg-green-500 hover:bg-green-600"
151
160
  : "bg-red-500 hover:bg-red-600") }, isTrue ? labels.booleanYes : labels.booleanNo));
152
161
  }
153
- // OBJECT => nested property path supplied as array of strings OR colon-separated string
154
- // e.g., "category:name" => row.category.name, "user:profile:bio" => row.user.profile.bio
162
+ // OBJECT => nested property path supplied as array of colon-separated strings
163
+ // e.g., ["user:company", "profile:department"] with fallback support
164
+ // If first path is undefined, try the next one. If all undefined, render '-'
155
165
  if (normalizedType === COMPONENT_TYPE.OBJECT) {
156
166
  var nested = void 0;
157
- // Check if key is a colon-separated string for nested access
158
- if (typeof col.key === "string" && col.key.includes(":")) {
159
- var keys = col.key.split(":");
160
- var cur = row;
161
- for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
162
- var k = keys_1[_i];
163
- if (cur == null || typeof cur !== "object") {
164
- nested = undefined;
165
- break;
167
+ // Key must be an array of colon-separated strings
168
+ if (Array.isArray(col.key)) {
169
+ // Try each key path until we find a defined value
170
+ for (var _i = 0, _c = col.key; _i < _c.length; _i++) {
171
+ var keyPath = _c[_i];
172
+ if (typeof keyPath === "string" && keyPath.includes(":")) {
173
+ var keys = keyPath.split(":");
174
+ var cur = row;
175
+ var found = true;
176
+ for (var _d = 0, keys_1 = keys; _d < keys_1.length; _d++) {
177
+ var k = keys_1[_d];
178
+ if (cur == null || typeof cur !== "object") {
179
+ found = false;
180
+ break;
181
+ }
182
+ cur = cur[k];
183
+ }
184
+ if (found && cur != null) {
185
+ nested = cur;
186
+ break;
187
+ }
166
188
  }
167
- cur = cur[k];
168
189
  }
169
- nested = cur;
170
190
  }
171
- else {
172
- // Fallback to array-based path or single key
173
- nested = resolveValue(row, col.key);
174
- }
175
- // If nested is primitive, show it. If object, stringify first-level value.
191
+ // If all paths are undefined, render '-'
176
192
  if (nested == null)
177
- return react_1.default.createElement("span", null, "");
193
+ return react_1.default.createElement("span", null, "-");
194
+ // If nested is an object, try to find a primitive value
178
195
  if (typeof nested === "object") {
179
- // Render primitive values inside object or JSON fallback
180
- var primitive = typeof nested === "object"
181
- ? // try to find a primitive child
182
- Object.values(nested).find(function (v) {
183
- return ["string", "number", "boolean"].includes(typeof v);
184
- })
185
- : nested;
196
+ var primitive = Object.values(nested).find(function (v) {
197
+ return ["string", "number", "boolean"].includes(typeof v);
198
+ });
186
199
  var toRender = primitive !== null && primitive !== void 0 ? primitive : JSON.stringify(nested);
187
200
  return (react_1.default.createElement("span", null, col.textFormatter
188
201
  ? col.textFormatter(toRender, row)
189
202
  : String(toRender)));
190
203
  }
204
+ // Nested is a primitive value
191
205
  return (react_1.default.createElement("span", null, col.textFormatter ? col.textFormatter(nested, row) : String(nested)));
192
- }
193
- // MULTIPLE_TEXT_LINES => col.key is an array of keys, render up to 3 lines
206
+ } // MULTIPLE_TEXT_LINES => col.key is an array of keys, render up to 3 lines
194
207
  if (normalizedType === COMPONENT_TYPE.MULTIPLE_TEXT_LINES) {
195
208
  var keys = Array.isArray(col.key) ? col.key : [];
196
209
  var lines = keys.slice(0, 3).map(function (k) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/shadcn",
3
- "version": "1.0.27",
3
+ "version": "1.0.28",
4
4
  "scripts": {
5
5
  "build:next": "next build",
6
6
  "build:storybook": "storybook build -c .storybook -o .out",