pixelize-design-library 2.3.1-beta.3 → 2.3.1-beta.5

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.
@@ -137,14 +137,19 @@ function pickTableColor(value, palette, override) {
137
137
  return { solid: "#8B3FC8", soft: "#8B3FC822", text: "#8B3FC8" };
138
138
  return palette[hashKey(value) % palette.length];
139
139
  }
140
- /** Partition rows by a column key, preserving first-seen group order. */
140
+ /**
141
+ * Partition rows by a column, preserving first-seen group order. The group key is
142
+ * a normalized string so object/array values (e.g. a `user` field that is an object
143
+ * or an array of users) group together by their readable text instead of by object
144
+ * identity.
145
+ */
141
146
  function groupRows(data, groupBy) {
142
147
  var order = [];
143
148
  var map = new Map();
144
149
  for (var _i = 0, data_1 = data; _i < data_1.length; _i++) {
145
150
  var row = data_1[_i];
146
- var raw = row[groupBy];
147
- var key = raw === undefined || raw === null || raw === "" ? "—" : raw;
151
+ var text = getStringValue(row[groupBy]);
152
+ var key = text === "" ? "—" : text;
148
153
  if (!map.has(key)) {
149
154
  map.set(key, []);
150
155
  order.push(key);
@@ -170,21 +175,49 @@ var extractTextFromReactNode = function (node) {
170
175
  }
171
176
  return "";
172
177
  };
178
+ /** Best-effort readable text for an entity object (user/relation/option/etc.). */
179
+ var objectToText = function (o) {
180
+ var _a, _b;
181
+ if (typeof o.label === "string" || typeof o.label === "number")
182
+ return String(o.label);
183
+ if (typeof o.name === "string" || typeof o.name === "number")
184
+ return String(o.name);
185
+ var first = (_a = o.first_name) !== null && _a !== void 0 ? _a : o.firstName;
186
+ var last = (_b = o.last_name) !== null && _b !== void 0 ? _b : o.lastName;
187
+ if (typeof first === "string" || typeof last === "string") {
188
+ return "".concat(first !== null && first !== void 0 ? first : "", " ").concat(last !== null && last !== void 0 ? last : "").trim();
189
+ }
190
+ if (typeof o.full_name === "string")
191
+ return o.full_name;
192
+ if (typeof o.title === "string")
193
+ return o.title;
194
+ if (typeof o.company_name === "string")
195
+ return o.company_name;
196
+ if (typeof o.email === "string")
197
+ return o.email;
198
+ if (typeof o.value === "string" || typeof o.value === "number")
199
+ return String(o.value);
200
+ return "";
201
+ };
202
+ /**
203
+ * Readable string for any cell value. Handles primitives, React elements, entity
204
+ * objects (e.g. `user`: `{ name }` / `{ first_name, last_name }`), and arrays of
205
+ * any of those (e.g. a multi-user field) by joining their texts.
206
+ */
173
207
  var getStringValue = function (value) {
174
- if (typeof value === "string" || typeof value === "number") {
208
+ if (value === null || value === undefined)
209
+ return "";
210
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
175
211
  return String(value);
176
212
  }
177
213
  if (react_1.default.isValidElement(value)) {
178
214
  return extractTextFromReactNode(value);
179
215
  }
180
- if (value && typeof value === "object") {
181
- var o = value;
182
- if (typeof o.label === "string" || typeof o.label === "number") {
183
- return String(o.label);
184
- }
185
- if (typeof o.name === "string" || typeof o.name === "number") {
186
- return String(o.name);
187
- }
216
+ if (Array.isArray(value)) {
217
+ return value.map(getStringValue).filter(function (s) { return s !== ""; }).join(", ");
218
+ }
219
+ if (typeof value === "object") {
220
+ return objectToText(value);
188
221
  }
189
222
  return "";
190
223
  };
@@ -203,21 +236,8 @@ function normalizeTableCellValue(value) {
203
236
  if (react_1.default.isValidElement(value)) {
204
237
  return value;
205
238
  }
206
- if (typeof value === "object") {
207
- var o = value;
208
- if (typeof o.label === "string" || typeof o.label === "number") {
209
- return String(o.label);
210
- }
211
- if (typeof o.name === "string" || typeof o.name === "number") {
212
- return String(o.name);
213
- }
214
- if (typeof o.title === "string")
215
- return o.title;
216
- if (typeof o.company_name === "string")
217
- return o.company_name;
218
- return "";
219
- }
220
- return String(value);
239
+ // Objects (relation/user) and arrays (multi-user / multi-select) → readable text.
240
+ return getStringValue(value);
221
241
  }
222
242
  var searchAndSortData = function (data, searchValues) {
223
243
  var filteredData = data.filter(function (item) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixelize-design-library",
3
- "version": "2.3.1-beta.3",
3
+ "version": "2.3.1-beta.5",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",