@lotics/app-sdk 0.123.3 → 0.123.4

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/index.js +32 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -12598,15 +12598,42 @@ function calculateLookupValue(value, linkedRecords, lookupFieldKey, linkedField,
12598
12598
  return a.id < b.id ? 1 : a.id > b.id ? -1 : 0;
12599
12599
  })[0];
12600
12600
  const pickedValue = picked ? readPicked(picked) : void 0;
12601
- return pickedValue === void 0 ? null : [pickedValue];
12601
+ const cells = pickedValue === void 0 ? [] : elementsOf(pickedValue, linkedField);
12602
+ return cells.length > 0 ? cells : null;
12602
12603
  }
12603
- const values2 = [];
12604
- for (const record of relevantRecords) {
12604
+ const values2 = relevantRecords.flatMap((record) => {
12605
12605
  const fieldValue = readPicked(record);
12606
- if (fieldValue !== void 0) values2.push(fieldValue);
12607
- }
12606
+ return fieldValue === void 0 ? [] : elementsOf(fieldValue, linkedField);
12607
+ });
12608
12608
  return values2.length > 0 ? values2 : null;
12609
12609
  }
12610
+ function elementsOf(picked, linkedField) {
12611
+ return linkedField?.type === "lookup" && Array.isArray(picked) ? lookupTerminalCells(picked, linkedField) : [picked];
12612
+ }
12613
+ function lookupTerminalCells(values2, field) {
12614
+ switch (field.lookup_field_type) {
12615
+ case void 0:
12616
+ return [...values2];
12617
+ case "select":
12618
+ case "select_member":
12619
+ case "select_record_link":
12620
+ case "files":
12621
+ return values2.flatMap(innermostLists);
12622
+ case "text":
12623
+ case "number":
12624
+ case "date":
12625
+ case "boolean":
12626
+ case "formula":
12627
+ case "rollup":
12628
+ case "lookup":
12629
+ case "button":
12630
+ case "autonumber":
12631
+ return flattenLookupValues(values2);
12632
+ }
12633
+ }
12634
+ function innermostLists(value) {
12635
+ return Array.isArray(value) && value.some(Array.isArray) ? value.flatMap(innermostLists) : [value];
12636
+ }
12610
12637
 
12611
12638
  // ../shared/src/interpolate.ts
12612
12639
  function interpolateObject(obj, context) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lotics/app-sdk",
3
- "version": "0.123.3",
3
+ "version": "0.123.4",
4
4
  "description": "The SDK a Lotics custom-code app reads and writes through — typed hooks over the host bridge, cell readers, mount() and AppRouter",
5
5
  "type": "module",
6
6
  "exports": {