@primestyleai/tryon 3.9.0 → 3.9.1

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 (2) hide show
  1. package/dist/react/index.js +21 -11
  2. package/package.json +1 -1
@@ -216,18 +216,28 @@ function allKeysAreSectionNames(obj) {
216
216
  function tryPreNormalized(input) {
217
217
  if (!isObject(input)) return null;
218
218
  const obj = input;
219
- if (obj.found === true && Array.isArray(obj.headers) && Array.isArray(obj.rows) && obj.headers.length > 0 && obj.rows.length > 0) {
220
- const headers = obj.headers;
221
- const rows = obj.rows.map((r) => r.map(String));
222
- return {
223
- found: true,
224
- title: typeof obj.title === "string" ? obj.title : void 0,
225
- headers,
226
- rows,
227
- requiredFields: Array.isArray(obj.requiredFields) && obj.requiredFields.length > 0 ? obj.requiredFields : deriveRequiredFields(headers)
228
- };
219
+ if (!Array.isArray(obj.headers) || !Array.isArray(obj.rows) || obj.headers.length === 0 || obj.rows.length === 0) {
220
+ return null;
221
+ }
222
+ const headers = obj.headers;
223
+ let rows;
224
+ const firstRow = obj.rows[0];
225
+ if (Array.isArray(firstRow)) {
226
+ rows = obj.rows.map((r) => r.map(String));
227
+ } else if (isObject(firstRow)) {
228
+ rows = obj.rows.map(
229
+ (rowObj) => headers.map((h) => String(rowObj[h] ?? ""))
230
+ );
231
+ } else {
232
+ return null;
229
233
  }
230
- return null;
234
+ return {
235
+ found: true,
236
+ title: typeof obj.title === "string" ? obj.title : void 0,
237
+ headers,
238
+ rows,
239
+ requiredFields: Array.isArray(obj.requiredFields) && obj.requiredFields.length > 0 ? obj.requiredFields : deriveRequiredFields(headers)
240
+ };
231
241
  }
232
242
  function tryKeyValueObject(input) {
233
243
  if (!isObject(input)) return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primestyleai/tryon",
3
- "version": "3.9.0",
3
+ "version": "3.9.1",
4
4
  "description": "PrimeStyle Virtual Try-On SDK — React component & Web Component",
5
5
  "type": "module",
6
6
  "main": "dist/primestyle-tryon.js",