@wise/dynamic-flow-client 5.14.0-experimental-a850677 → 5.14.0-experimental-2996a75

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/build/main.js CHANGED
@@ -1447,28 +1447,32 @@ var createCollectionComponent = (props, onComponentUpdate, searchFunction) => {
1447
1447
  if (draft.state.type === "empty") {
1448
1448
  return;
1449
1449
  }
1450
- const updated = draft.state.sections.map((section) => {
1450
+ const knownSections = draft.state.sections.map((section) => section.id);
1451
+ const newSections = response.sections.filter(
1452
+ (section) => !knownSections.includes(section.id)
1453
+ );
1454
+ draft.state.sections.forEach((section) => {
1451
1455
  const m = response.sections.find((s) => s.id === section.id);
1452
1456
  if (m) {
1453
- return __spreadProps(__spreadValues({}, section), {
1454
- items: [...section.items, ...m.items]
1455
- });
1457
+ section.items.push(...m.items);
1456
1458
  }
1457
- return section;
1458
1459
  });
1459
- draft.state.sections = updated;
1460
+ draft.state.sections.push(...newSections);
1460
1461
  draft.state.nextCursor = response.nextCursor;
1461
1462
  draft.cursorStale = false;
1463
+ draft.loading = false;
1462
1464
  });
1463
1465
  } else {
1464
1466
  update(component2, (draft) => {
1465
1467
  draft.state = __spreadValues({}, response);
1466
1468
  draft.cursorStale = false;
1469
+ draft.loading = false;
1467
1470
  });
1468
1471
  }
1469
1472
  } else {
1470
1473
  update(component2, (draft) => {
1471
1474
  draft.state = response;
1475
+ draft.loading = false;
1472
1476
  });
1473
1477
  }
1474
1478
  }).catch(() => {
@@ -1479,6 +1483,7 @@ var createCollectionComponent = (props, onComponentUpdate, searchFunction) => {
1479
1483
  type: "collection",
1480
1484
  kind: "layout",
1481
1485
  uid,
1486
+ loading: false,
1482
1487
  analyticsId,
1483
1488
  control,
1484
1489
  cursorStale: false,
@@ -1491,6 +1496,7 @@ var createCollectionComponent = (props, onComponentUpdate, searchFunction) => {
1491
1496
  onChange(query) {
1492
1497
  component._update((draft) => {
1493
1498
  draft.search.query = query;
1499
+ draft.loading = true;
1494
1500
  });
1495
1501
  debouncedSearch(component, query, component.filters);
1496
1502
  }
@@ -1507,10 +1513,12 @@ var createCollectionComponent = (props, onComponentUpdate, searchFunction) => {
1507
1513
  component._update((draft) => {
1508
1514
  if (filter.multiSelection) {
1509
1515
  draft.filters[i].options[j].selected = !currentValue;
1516
+ draft.loading = true;
1510
1517
  } else {
1511
1518
  draft.filters[i].options = draft.filters[i].options.map((option, k) => __spreadProps(__spreadValues({}, option), {
1512
1519
  selected: k === j ? !currentValue : false
1513
1520
  }));
1521
+ draft.loading = true;
1514
1522
  }
1515
1523
  });
1516
1524
  searchFn(component, component.search.query, component.filters, void 0);
@@ -1529,6 +1537,7 @@ var createCollectionComponent = (props, onComponentUpdate, searchFunction) => {
1529
1537
  const cursor = this.state.nextCursor;
1530
1538
  this._update((draft) => {
1531
1539
  draft.cursorStale = true;
1540
+ draft.loading = true;
1532
1541
  });
1533
1542
  searchFn(this, this.search.query, this.filters, cursor);
1534
1543
  }
@@ -1602,7 +1611,15 @@ var collectionLayoutToComponent = (uid, {
1602
1611
  id: section.id,
1603
1612
  title: section.title,
1604
1613
  items: section.items.map((item) => {
1614
+ const behavior = getDomainLayerBehavior(
1615
+ { behavior: item.primaryBehavior },
1616
+ [],
1617
+ mapperProps.registerSubmissionBehavior
1618
+ );
1605
1619
  return __spreadProps(__spreadValues({}, item), {
1620
+ onClick: item.primaryBehavior ? () => {
1621
+ void mapperProps.onBehavior(behavior);
1622
+ } : void 0,
1606
1623
  callToAction: getDomainLayerCallToAction(item.callToAction, mapperProps),
1607
1624
  inlineAlert: mapInlineAlert(item.inlineAlert)
1608
1625
  });
@@ -1613,7 +1630,7 @@ var collectionLayoutToComponent = (uid, {
1613
1630
  },
1614
1631
  search: {
1615
1632
  query: null,
1616
- onChange(query) {
1633
+ onChange() {
1617
1634
  }
1618
1635
  },
1619
1636
  filters: filters.filter((filter) => filter.options)
@@ -1654,10 +1671,21 @@ var getPerformCollectionSearchFunction = (httpClient, url, method, searchParam,
1654
1671
  sections: [
1655
1672
  ...results.sections.map((section) => __spreadProps(__spreadValues({}, section), {
1656
1673
  callToAction: getDomainLayerCallToAction(section.callToAction, mapperProps),
1657
- items: section.items.map((item) => __spreadProps(__spreadValues({}, item), {
1658
- callToAction: getDomainLayerCallToAction(item.callToAction, mapperProps),
1659
- inlineAlert: mapInlineAlert(item.inlineAlert)
1660
- }))
1674
+ items: section.items.map((item) => {
1675
+ const behavior = getDomainLayerBehavior(
1676
+ { behavior: item.primaryBehavior },
1677
+ [],
1678
+ mapperProps.registerSubmissionBehavior
1679
+ );
1680
+ return __spreadProps(__spreadValues({}, item), {
1681
+ onClick: item.primaryBehavior ? () => {
1682
+ void mapperProps.onBehavior(behavior);
1683
+ } : void 0,
1684
+ href: behavior.type === "link" ? behavior.url : void 0,
1685
+ callToAction: getDomainLayerCallToAction(item.callToAction, mapperProps),
1686
+ inlineAlert: mapInlineAlert(item.inlineAlert)
1687
+ });
1688
+ })
1661
1689
  }))
1662
1690
  ],
1663
1691
  nextCursor: results.nextCursor
@@ -7712,6 +7740,7 @@ var collectionComponentToProps = (component, rendererMapperProps) => {
7712
7740
  query: (_a = component.search.query) != null ? _a : void 0
7713
7741
  }),
7714
7742
  filters: component.filters,
7743
+ loading: component.loading,
7715
7744
  loadMore: !component.cursorStale && component.state.type === "collection-content" && component.state.nextCursor ? component.loadMore.bind(component) : void 0
7716
7745
  });
7717
7746
  };
package/build/main.mjs CHANGED
@@ -1417,28 +1417,32 @@ var createCollectionComponent = (props, onComponentUpdate, searchFunction) => {
1417
1417
  if (draft.state.type === "empty") {
1418
1418
  return;
1419
1419
  }
1420
- const updated = draft.state.sections.map((section) => {
1420
+ const knownSections = draft.state.sections.map((section) => section.id);
1421
+ const newSections = response.sections.filter(
1422
+ (section) => !knownSections.includes(section.id)
1423
+ );
1424
+ draft.state.sections.forEach((section) => {
1421
1425
  const m = response.sections.find((s) => s.id === section.id);
1422
1426
  if (m) {
1423
- return __spreadProps(__spreadValues({}, section), {
1424
- items: [...section.items, ...m.items]
1425
- });
1427
+ section.items.push(...m.items);
1426
1428
  }
1427
- return section;
1428
1429
  });
1429
- draft.state.sections = updated;
1430
+ draft.state.sections.push(...newSections);
1430
1431
  draft.state.nextCursor = response.nextCursor;
1431
1432
  draft.cursorStale = false;
1433
+ draft.loading = false;
1432
1434
  });
1433
1435
  } else {
1434
1436
  update(component2, (draft) => {
1435
1437
  draft.state = __spreadValues({}, response);
1436
1438
  draft.cursorStale = false;
1439
+ draft.loading = false;
1437
1440
  });
1438
1441
  }
1439
1442
  } else {
1440
1443
  update(component2, (draft) => {
1441
1444
  draft.state = response;
1445
+ draft.loading = false;
1442
1446
  });
1443
1447
  }
1444
1448
  }).catch(() => {
@@ -1449,6 +1453,7 @@ var createCollectionComponent = (props, onComponentUpdate, searchFunction) => {
1449
1453
  type: "collection",
1450
1454
  kind: "layout",
1451
1455
  uid,
1456
+ loading: false,
1452
1457
  analyticsId,
1453
1458
  control,
1454
1459
  cursorStale: false,
@@ -1461,6 +1466,7 @@ var createCollectionComponent = (props, onComponentUpdate, searchFunction) => {
1461
1466
  onChange(query) {
1462
1467
  component._update((draft) => {
1463
1468
  draft.search.query = query;
1469
+ draft.loading = true;
1464
1470
  });
1465
1471
  debouncedSearch(component, query, component.filters);
1466
1472
  }
@@ -1477,10 +1483,12 @@ var createCollectionComponent = (props, onComponentUpdate, searchFunction) => {
1477
1483
  component._update((draft) => {
1478
1484
  if (filter.multiSelection) {
1479
1485
  draft.filters[i].options[j].selected = !currentValue;
1486
+ draft.loading = true;
1480
1487
  } else {
1481
1488
  draft.filters[i].options = draft.filters[i].options.map((option, k) => __spreadProps(__spreadValues({}, option), {
1482
1489
  selected: k === j ? !currentValue : false
1483
1490
  }));
1491
+ draft.loading = true;
1484
1492
  }
1485
1493
  });
1486
1494
  searchFn(component, component.search.query, component.filters, void 0);
@@ -1499,6 +1507,7 @@ var createCollectionComponent = (props, onComponentUpdate, searchFunction) => {
1499
1507
  const cursor = this.state.nextCursor;
1500
1508
  this._update((draft) => {
1501
1509
  draft.cursorStale = true;
1510
+ draft.loading = true;
1502
1511
  });
1503
1512
  searchFn(this, this.search.query, this.filters, cursor);
1504
1513
  }
@@ -1572,7 +1581,15 @@ var collectionLayoutToComponent = (uid, {
1572
1581
  id: section.id,
1573
1582
  title: section.title,
1574
1583
  items: section.items.map((item) => {
1584
+ const behavior = getDomainLayerBehavior(
1585
+ { behavior: item.primaryBehavior },
1586
+ [],
1587
+ mapperProps.registerSubmissionBehavior
1588
+ );
1575
1589
  return __spreadProps(__spreadValues({}, item), {
1590
+ onClick: item.primaryBehavior ? () => {
1591
+ void mapperProps.onBehavior(behavior);
1592
+ } : void 0,
1576
1593
  callToAction: getDomainLayerCallToAction(item.callToAction, mapperProps),
1577
1594
  inlineAlert: mapInlineAlert(item.inlineAlert)
1578
1595
  });
@@ -1583,7 +1600,7 @@ var collectionLayoutToComponent = (uid, {
1583
1600
  },
1584
1601
  search: {
1585
1602
  query: null,
1586
- onChange(query) {
1603
+ onChange() {
1587
1604
  }
1588
1605
  },
1589
1606
  filters: filters.filter((filter) => filter.options)
@@ -1624,10 +1641,21 @@ var getPerformCollectionSearchFunction = (httpClient, url, method, searchParam,
1624
1641
  sections: [
1625
1642
  ...results.sections.map((section) => __spreadProps(__spreadValues({}, section), {
1626
1643
  callToAction: getDomainLayerCallToAction(section.callToAction, mapperProps),
1627
- items: section.items.map((item) => __spreadProps(__spreadValues({}, item), {
1628
- callToAction: getDomainLayerCallToAction(item.callToAction, mapperProps),
1629
- inlineAlert: mapInlineAlert(item.inlineAlert)
1630
- }))
1644
+ items: section.items.map((item) => {
1645
+ const behavior = getDomainLayerBehavior(
1646
+ { behavior: item.primaryBehavior },
1647
+ [],
1648
+ mapperProps.registerSubmissionBehavior
1649
+ );
1650
+ return __spreadProps(__spreadValues({}, item), {
1651
+ onClick: item.primaryBehavior ? () => {
1652
+ void mapperProps.onBehavior(behavior);
1653
+ } : void 0,
1654
+ href: behavior.type === "link" ? behavior.url : void 0,
1655
+ callToAction: getDomainLayerCallToAction(item.callToAction, mapperProps),
1656
+ inlineAlert: mapInlineAlert(item.inlineAlert)
1657
+ });
1658
+ })
1631
1659
  }))
1632
1660
  ],
1633
1661
  nextCursor: results.nextCursor
@@ -7682,6 +7710,7 @@ var collectionComponentToProps = (component, rendererMapperProps) => {
7682
7710
  query: (_a = component.search.query) != null ? _a : void 0
7683
7711
  }),
7684
7712
  filters: component.filters,
7713
+ loading: component.loading,
7685
7714
  loadMore: !component.cursorStale && component.state.type === "collection-content" && component.state.nextCursor ? component.loadMore.bind(component) : void 0
7686
7715
  });
7687
7716
  };