@wise/dynamic-flow-client 5.18.2 → 5.20.0-experimental-2dcb025
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 +372 -84
- package/build/main.mjs +372 -84
- package/build/tsconfig.types.tsbuildinfo +1 -1
- package/build/types/domain/components/collectionComponent/CollectionComponent.d.ts +7 -0
- package/build/types/domain/components/collectionComponent/CollectionComponent.d.ts.map +1 -0
- package/build/types/domain/components/collectionComponent/applyCollectionResponse.d.ts +3 -0
- package/build/types/domain/components/collectionComponent/applyCollectionResponse.d.ts.map +1 -0
- package/build/types/domain/components/collectionComponent/types.d.ts +73 -0
- package/build/types/domain/components/collectionComponent/types.d.ts.map +1 -0
- package/build/types/domain/features/collection/getPerformCollectionQueryFunction.d.ts +12 -0
- package/build/types/domain/features/collection/getPerformCollectionQueryFunction.d.ts.map +1 -0
- package/build/types/domain/features/validation/getPatternRegExp.d.ts +3 -0
- package/build/types/domain/features/validation/getPatternRegExp.d.ts.map +1 -0
- package/build/types/domain/mappers/layout/collectionLayoutToComponent.d.ts +7 -0
- package/build/types/domain/mappers/layout/collectionLayoutToComponent.d.ts.map +1 -0
- package/build/types/domain/mappers/mapLayoutToComponent.d.ts.map +1 -1
- package/build/types/domain/types.d.ts +2 -1
- package/build/types/domain/types.d.ts.map +1 -1
- package/build/types/renderers/mappers/collectionComponentToProps.d.ts +5 -0
- package/build/types/renderers/mappers/collectionComponentToProps.d.ts.map +1 -0
- package/build/types/renderers/mappers/componentToRendererProps.d.ts.map +1 -1
- package/build/types/test-utils/getMergedTestRenderers.d.ts +1 -1
- package/build/types/test-utils/getMergedTestRenderers.d.ts.map +1 -1
- package/package.json +4 -4
- package/build/types/domain/features/validation/validateStringPattern.d.ts +0 -3
- package/build/types/domain/features/validation/validateStringPattern.d.ts.map +0 -1
package/build/main.mjs
CHANGED
|
@@ -852,6 +852,7 @@ var getChildren = (node) => {
|
|
|
852
852
|
return node.tabs.flatMap((c) => c.childrenProps);
|
|
853
853
|
case "alert":
|
|
854
854
|
case "button":
|
|
855
|
+
case "collection":
|
|
855
856
|
case "input-checkbox":
|
|
856
857
|
case "input-date":
|
|
857
858
|
case "decision":
|
|
@@ -1469,6 +1470,339 @@ var boxLayoutToComponent = (uid, { border = false, components, control, margin,
|
|
|
1469
1470
|
)
|
|
1470
1471
|
});
|
|
1471
1472
|
|
|
1473
|
+
// src/domain/mappers/utils/utils.ts
|
|
1474
|
+
var mapInlineAlert = (alert) => {
|
|
1475
|
+
return alert ? {
|
|
1476
|
+
content: alert.content,
|
|
1477
|
+
context: alert.context ? mapLegacyContext(alert.context) : "neutral"
|
|
1478
|
+
} : void 0;
|
|
1479
|
+
};
|
|
1480
|
+
var mapAdditionalInfo = (info, mapperProps) => {
|
|
1481
|
+
const { onBehavior, trackEvent, registerSubmissionBehavior } = mapperProps;
|
|
1482
|
+
if (info) {
|
|
1483
|
+
const behavior = getDomainLayerBehavior(info, [], registerSubmissionBehavior);
|
|
1484
|
+
const isLink = behavior.type === "link";
|
|
1485
|
+
return {
|
|
1486
|
+
text: info.text,
|
|
1487
|
+
href: isLink ? behavior.url : void 0,
|
|
1488
|
+
hrefWithTracking: getHrefWithTracking({
|
|
1489
|
+
behavior,
|
|
1490
|
+
onBehavior,
|
|
1491
|
+
trackEvent
|
|
1492
|
+
}),
|
|
1493
|
+
accessibilityDescription: info.accessibilityDescription,
|
|
1494
|
+
onClick: behavior.type === "none" ? void 0 : () => {
|
|
1495
|
+
void onBehavior(behavior);
|
|
1496
|
+
}
|
|
1497
|
+
};
|
|
1498
|
+
}
|
|
1499
|
+
return void 0;
|
|
1500
|
+
};
|
|
1501
|
+
var mapSchemaAlert = (alert) => {
|
|
1502
|
+
return alert ? {
|
|
1503
|
+
content: alert.markdown,
|
|
1504
|
+
context: alert.context ? mapLegacyContext(alert.context) : "neutral"
|
|
1505
|
+
} : void 0;
|
|
1506
|
+
};
|
|
1507
|
+
|
|
1508
|
+
// src/domain/components/utils/debounce.ts
|
|
1509
|
+
var debounce = (callback, waitMs) => {
|
|
1510
|
+
let timeoutId = null;
|
|
1511
|
+
let lastArgs = null;
|
|
1512
|
+
const clearTimer = () => {
|
|
1513
|
+
if (timeoutId !== null) {
|
|
1514
|
+
clearTimeout(timeoutId);
|
|
1515
|
+
timeoutId = null;
|
|
1516
|
+
}
|
|
1517
|
+
lastArgs = null;
|
|
1518
|
+
};
|
|
1519
|
+
const debouncedFn = (...args) => {
|
|
1520
|
+
lastArgs = args;
|
|
1521
|
+
if (timeoutId !== null) {
|
|
1522
|
+
clearTimeout(timeoutId);
|
|
1523
|
+
}
|
|
1524
|
+
timeoutId = setTimeout(() => {
|
|
1525
|
+
callback(...lastArgs);
|
|
1526
|
+
timeoutId = null;
|
|
1527
|
+
lastArgs = null;
|
|
1528
|
+
}, waitMs);
|
|
1529
|
+
};
|
|
1530
|
+
debouncedFn.cancel = () => {
|
|
1531
|
+
if (timeoutId !== null) {
|
|
1532
|
+
clearTimer();
|
|
1533
|
+
}
|
|
1534
|
+
};
|
|
1535
|
+
debouncedFn.flush = () => {
|
|
1536
|
+
if (timeoutId !== null) {
|
|
1537
|
+
callback(...lastArgs);
|
|
1538
|
+
clearTimer();
|
|
1539
|
+
}
|
|
1540
|
+
};
|
|
1541
|
+
return debouncedFn;
|
|
1542
|
+
};
|
|
1543
|
+
|
|
1544
|
+
// src/domain/components/collectionComponent/applyCollectionResponse.ts
|
|
1545
|
+
var applyCollectionResponse = (currentState, response, isPaginated) => {
|
|
1546
|
+
var _a, _b, _c, _d;
|
|
1547
|
+
const sections = isPaginated ? mergeSections(currentState.sections, response.sections) : response.sections;
|
|
1548
|
+
return {
|
|
1549
|
+
sections,
|
|
1550
|
+
nextCursor: response.nextCursor,
|
|
1551
|
+
filters: (_a = response.filters) != null ? _a : currentState.filters,
|
|
1552
|
+
search: (_b = response.search) != null ? _b : currentState.search,
|
|
1553
|
+
beforeSections: (_c = response.beforeSections) != null ? _c : currentState.beforeSections,
|
|
1554
|
+
afterSections: (_d = response.afterSections) != null ? _d : currentState.afterSections
|
|
1555
|
+
};
|
|
1556
|
+
};
|
|
1557
|
+
var mergeSections = (existing, incoming) => {
|
|
1558
|
+
const knownIds = new Set(existing.map((section) => section.id));
|
|
1559
|
+
const newSections = incoming.filter((section) => !knownIds.has(section.id));
|
|
1560
|
+
const merged = existing.map((section) => {
|
|
1561
|
+
const match = incoming.find((s) => s.id === section.id);
|
|
1562
|
+
if (!match) return section;
|
|
1563
|
+
return __spreadProps(__spreadValues({}, section), { items: [...section.items, ...match.items] });
|
|
1564
|
+
});
|
|
1565
|
+
return [...merged, ...newSections];
|
|
1566
|
+
};
|
|
1567
|
+
|
|
1568
|
+
// src/domain/components/collectionComponent/CollectionComponent.ts
|
|
1569
|
+
var DEBOUNCE_TIME = 800;
|
|
1570
|
+
var createCollectionComponent = (props, onComponentUpdate, searchFunction) => {
|
|
1571
|
+
const { uid, analyticsId, control, margin, tags, url, method, state } = props;
|
|
1572
|
+
const update = getInputUpdateFunction(onComponentUpdate);
|
|
1573
|
+
let abortController = new AbortController();
|
|
1574
|
+
const query = (component2, cursor) => {
|
|
1575
|
+
var _a, _b;
|
|
1576
|
+
abortController.abort();
|
|
1577
|
+
abortController = new AbortController();
|
|
1578
|
+
const { signal } = abortController;
|
|
1579
|
+
searchFunction({
|
|
1580
|
+
searchParam: (_a = component2.state.search) == null ? void 0 : _a.param,
|
|
1581
|
+
query: (_b = component2.state.search) == null ? void 0 : _b.query,
|
|
1582
|
+
cursor,
|
|
1583
|
+
signal,
|
|
1584
|
+
filters: component2.state.filters
|
|
1585
|
+
}).then((response) => {
|
|
1586
|
+
if (!response) {
|
|
1587
|
+
return;
|
|
1588
|
+
}
|
|
1589
|
+
update(component2, (draft) => {
|
|
1590
|
+
const newState = applyCollectionResponse(draft.state, response, !!cursor);
|
|
1591
|
+
draft.state = __spreadProps(__spreadValues({}, newState), {
|
|
1592
|
+
filters: mapFilters(newState.filters),
|
|
1593
|
+
search: mapSearch(newState.search)
|
|
1594
|
+
});
|
|
1595
|
+
draft.status = {
|
|
1596
|
+
type: "idle",
|
|
1597
|
+
loadMore: newState.nextCursor ? () => query(component2, newState.nextCursor) : void 0
|
|
1598
|
+
};
|
|
1599
|
+
});
|
|
1600
|
+
}).catch(() => {
|
|
1601
|
+
if (!signal.aborted) {
|
|
1602
|
+
update(component2, (draft) => {
|
|
1603
|
+
draft.status = {
|
|
1604
|
+
type: "error",
|
|
1605
|
+
reason: cursor ? "pagination" : "search",
|
|
1606
|
+
retry: () => query(component2, cursor)
|
|
1607
|
+
};
|
|
1608
|
+
});
|
|
1609
|
+
}
|
|
1610
|
+
});
|
|
1611
|
+
};
|
|
1612
|
+
const debouncedQuery = debounce(
|
|
1613
|
+
(component2) => query(component2),
|
|
1614
|
+
DEBOUNCE_TIME
|
|
1615
|
+
);
|
|
1616
|
+
const selectFilter = (filterIndex, optionIndex) => {
|
|
1617
|
+
var _a;
|
|
1618
|
+
const filter = (_a = component.state.filters) == null ? void 0 : _a[filterIndex];
|
|
1619
|
+
if (!filter) {
|
|
1620
|
+
return;
|
|
1621
|
+
}
|
|
1622
|
+
const currentValue = filter.options[optionIndex].selected;
|
|
1623
|
+
update(component, (draft) => {
|
|
1624
|
+
if (!draft.state.filters) {
|
|
1625
|
+
return;
|
|
1626
|
+
}
|
|
1627
|
+
if (filter.multiSelect) {
|
|
1628
|
+
draft.state.filters[filterIndex].options[optionIndex].selected = !currentValue;
|
|
1629
|
+
} else {
|
|
1630
|
+
draft.state.filters[filterIndex].options = draft.state.filters[filterIndex].options.map(
|
|
1631
|
+
(option, index) => __spreadProps(__spreadValues({}, option), {
|
|
1632
|
+
selected: index === optionIndex ? !currentValue : false
|
|
1633
|
+
})
|
|
1634
|
+
);
|
|
1635
|
+
}
|
|
1636
|
+
draft.status = { type: "loading", reason: "search" };
|
|
1637
|
+
});
|
|
1638
|
+
query(component);
|
|
1639
|
+
};
|
|
1640
|
+
const mapFilters = (filters) => filters == null ? void 0 : filters.map((filter, i) => {
|
|
1641
|
+
var _a;
|
|
1642
|
+
return __spreadProps(__spreadValues({}, filter), {
|
|
1643
|
+
options: (_a = filter.options) == null ? void 0 : _a.map((option, j) => {
|
|
1644
|
+
var _a2;
|
|
1645
|
+
return __spreadProps(__spreadValues({}, option), {
|
|
1646
|
+
selected: (_a2 = option.selected) != null ? _a2 : false,
|
|
1647
|
+
onSelect: () => selectFilter(i, j)
|
|
1648
|
+
});
|
|
1649
|
+
})
|
|
1650
|
+
});
|
|
1651
|
+
});
|
|
1652
|
+
const mapSearch = (search) => search ? __spreadProps(__spreadValues({}, search), {
|
|
1653
|
+
onChange(value) {
|
|
1654
|
+
update(component, (draft) => {
|
|
1655
|
+
if (draft.state.search) {
|
|
1656
|
+
draft.state.search.query = value;
|
|
1657
|
+
draft.status = { type: "loading", reason: "search" };
|
|
1658
|
+
}
|
|
1659
|
+
});
|
|
1660
|
+
debouncedQuery(component);
|
|
1661
|
+
}
|
|
1662
|
+
}) : void 0;
|
|
1663
|
+
const component = {
|
|
1664
|
+
type: "collection",
|
|
1665
|
+
kind: "layout",
|
|
1666
|
+
uid,
|
|
1667
|
+
analyticsId,
|
|
1668
|
+
control,
|
|
1669
|
+
margin,
|
|
1670
|
+
method,
|
|
1671
|
+
url,
|
|
1672
|
+
tags,
|
|
1673
|
+
status: {
|
|
1674
|
+
type: "idle",
|
|
1675
|
+
loadMore: state.nextCursor ? () => query(component, state.nextCursor) : void 0
|
|
1676
|
+
},
|
|
1677
|
+
state: __spreadProps(__spreadValues({}, state), {
|
|
1678
|
+
filters: mapFilters(state.filters),
|
|
1679
|
+
search: mapSearch(props.search)
|
|
1680
|
+
})
|
|
1681
|
+
};
|
|
1682
|
+
return component;
|
|
1683
|
+
};
|
|
1684
|
+
|
|
1685
|
+
// src/domain/features/collection/getPerformCollectionQueryFunction.ts
|
|
1686
|
+
var getPerformCollectionQueryFunction = (httpClient, url, method, mapState) => {
|
|
1687
|
+
return async ({ searchParam, query, cursor, signal, filters = [] }) => {
|
|
1688
|
+
const headers = { "Content-Type": "application/json" };
|
|
1689
|
+
const filterValues = filters.map(
|
|
1690
|
+
(f) => {
|
|
1691
|
+
var _a;
|
|
1692
|
+
return [f.param, (_a = f.options.find((option) => option.selected)) == null ? void 0 : _a.value];
|
|
1693
|
+
}
|
|
1694
|
+
);
|
|
1695
|
+
const response = await (method === "GET" ? httpClient(
|
|
1696
|
+
addQueryParameters(url, [
|
|
1697
|
+
[searchParam, query != null ? query : void 0],
|
|
1698
|
+
["cursor", cursor],
|
|
1699
|
+
...filterValues
|
|
1700
|
+
]),
|
|
1701
|
+
{
|
|
1702
|
+
method,
|
|
1703
|
+
headers,
|
|
1704
|
+
signal
|
|
1705
|
+
}
|
|
1706
|
+
) : httpClient(url, {
|
|
1707
|
+
method,
|
|
1708
|
+
headers,
|
|
1709
|
+
signal,
|
|
1710
|
+
body: JSON.stringify(__spreadValues(__spreadProps(__spreadValues({}, searchParam && query ? { [searchParam]: query } : {}), {
|
|
1711
|
+
cursor
|
|
1712
|
+
}), filterValues.reduce((acc, [k, v]) => __spreadProps(__spreadValues({}, acc), { [k]: v }), {})))
|
|
1713
|
+
}));
|
|
1714
|
+
const results = await parseResponse(response);
|
|
1715
|
+
return mapState(results);
|
|
1716
|
+
};
|
|
1717
|
+
};
|
|
1718
|
+
var parseResponse = async (response) => {
|
|
1719
|
+
if (response.ok) {
|
|
1720
|
+
const body = await response.json().catch(() => null);
|
|
1721
|
+
return body;
|
|
1722
|
+
}
|
|
1723
|
+
throw Error("error response");
|
|
1724
|
+
};
|
|
1725
|
+
var addQueryParameters = (url, params) => {
|
|
1726
|
+
return params.reduce(
|
|
1727
|
+
(u, [key, param]) => key && param ? addQueryParameter(u, key, param) : u,
|
|
1728
|
+
url
|
|
1729
|
+
);
|
|
1730
|
+
};
|
|
1731
|
+
var addQueryParameter = (url, key, value) => {
|
|
1732
|
+
const [urlBase, urlQuery] = url.split("?");
|
|
1733
|
+
const urlQueryParams = new URLSearchParams(urlQuery);
|
|
1734
|
+
urlQueryParams.set(key, value);
|
|
1735
|
+
return `${urlBase}?${urlQueryParams.toString()}`;
|
|
1736
|
+
};
|
|
1737
|
+
|
|
1738
|
+
// src/domain/mappers/layout/collectionLayoutToComponent.ts
|
|
1739
|
+
var collectionLayoutToComponent = (uid, { analyticsId, control, initialState, margin, method, search, tags, url }, mapperProps) => {
|
|
1740
|
+
const { httpClient, onComponentUpdate } = mapperProps;
|
|
1741
|
+
const mapLayout = (layout, index) => mapLayoutToComponent(`${uid}-collection-response-${index}`, layout, mapperProps, []);
|
|
1742
|
+
const mapState = (state) => mapCollectionSpecToDomainState(state, mapperProps, mapLayout);
|
|
1743
|
+
const searchFunction = getPerformCollectionQueryFunction(httpClient, url, method, mapState);
|
|
1744
|
+
const component = createCollectionComponent(
|
|
1745
|
+
{
|
|
1746
|
+
uid,
|
|
1747
|
+
analyticsId,
|
|
1748
|
+
control,
|
|
1749
|
+
margin: margin != null ? margin : "md",
|
|
1750
|
+
tags,
|
|
1751
|
+
url,
|
|
1752
|
+
method,
|
|
1753
|
+
state: mapState(initialState),
|
|
1754
|
+
search: search ? {
|
|
1755
|
+
param: search == null ? void 0 : search.param,
|
|
1756
|
+
query: "",
|
|
1757
|
+
hint: search == null ? void 0 : search.hint
|
|
1758
|
+
} : void 0
|
|
1759
|
+
},
|
|
1760
|
+
onComponentUpdate,
|
|
1761
|
+
searchFunction
|
|
1762
|
+
);
|
|
1763
|
+
return component;
|
|
1764
|
+
};
|
|
1765
|
+
var mapCollectionSpecToDomainState = (specState, mapperProps, mapLayout) => {
|
|
1766
|
+
var _a, _b, _c;
|
|
1767
|
+
return {
|
|
1768
|
+
sections: specState.sections.map((section) => {
|
|
1769
|
+
return {
|
|
1770
|
+
id: section.id,
|
|
1771
|
+
title: section.title,
|
|
1772
|
+
callToAction: getDomainLayerCallToAction(section.callToAction, mapperProps),
|
|
1773
|
+
items: section.items.map((item) => {
|
|
1774
|
+
const behavior = getDomainLayerBehavior(
|
|
1775
|
+
{ behavior: item.primaryBehavior },
|
|
1776
|
+
[],
|
|
1777
|
+
mapperProps.registerSubmissionBehavior
|
|
1778
|
+
);
|
|
1779
|
+
return __spreadProps(__spreadValues({}, item), {
|
|
1780
|
+
onClick: item.primaryBehavior ? () => {
|
|
1781
|
+
void mapperProps.onBehavior(behavior);
|
|
1782
|
+
} : void 0,
|
|
1783
|
+
callToAction: getDomainLayerCallToAction(item.callToAction, mapperProps),
|
|
1784
|
+
inlineAlert: mapInlineAlert(item.inlineAlert)
|
|
1785
|
+
});
|
|
1786
|
+
})
|
|
1787
|
+
};
|
|
1788
|
+
}),
|
|
1789
|
+
filters: (_a = specState.filters) == null ? void 0 : _a.map((filter) => __spreadProps(__spreadValues({}, filter), {
|
|
1790
|
+
options: filter.options.map((option) => {
|
|
1791
|
+
var _a2;
|
|
1792
|
+
return __spreadProps(__spreadValues({}, option), {
|
|
1793
|
+
selected: (_a2 = option.selected) != null ? _a2 : false,
|
|
1794
|
+
onSelect: () => {
|
|
1795
|
+
}
|
|
1796
|
+
// todo: what goes here?
|
|
1797
|
+
});
|
|
1798
|
+
})
|
|
1799
|
+
})),
|
|
1800
|
+
beforeSections: (_b = specState.beforeSections) == null ? void 0 : _b.map(mapLayout),
|
|
1801
|
+
afterSections: (_c = specState.afterSections) == null ? void 0 : _c.map(mapLayout),
|
|
1802
|
+
nextCursor: specState.nextCursor
|
|
1803
|
+
};
|
|
1804
|
+
};
|
|
1805
|
+
|
|
1472
1806
|
// src/domain/components/ButtonComponent.ts
|
|
1473
1807
|
var createButtonComponent = (props) => __spreadValues({
|
|
1474
1808
|
type: "button",
|
|
@@ -1637,41 +1971,6 @@ var createDecisionComponent = (props) => __spreadValues({
|
|
|
1637
1971
|
// src/domain/mappers/utils/tags-utils.ts
|
|
1638
1972
|
var mapTags = ({ tag, tags }) => tags != null ? tags : tag != null ? [tag] : void 0;
|
|
1639
1973
|
|
|
1640
|
-
// src/domain/mappers/utils/utils.ts
|
|
1641
|
-
var mapInlineAlert = (alert) => {
|
|
1642
|
-
return alert ? {
|
|
1643
|
-
content: alert.content,
|
|
1644
|
-
context: alert.context ? mapLegacyContext(alert.context) : "neutral"
|
|
1645
|
-
} : void 0;
|
|
1646
|
-
};
|
|
1647
|
-
var mapAdditionalInfo = (info, mapperProps) => {
|
|
1648
|
-
const { onBehavior, trackEvent, registerSubmissionBehavior } = mapperProps;
|
|
1649
|
-
if (info) {
|
|
1650
|
-
const behavior = getDomainLayerBehavior(info, [], registerSubmissionBehavior);
|
|
1651
|
-
const isLink = behavior.type === "link";
|
|
1652
|
-
return {
|
|
1653
|
-
text: info.text,
|
|
1654
|
-
href: isLink ? behavior.url : void 0,
|
|
1655
|
-
hrefWithTracking: getHrefWithTracking({
|
|
1656
|
-
behavior,
|
|
1657
|
-
onBehavior,
|
|
1658
|
-
trackEvent
|
|
1659
|
-
}),
|
|
1660
|
-
accessibilityDescription: info.accessibilityDescription,
|
|
1661
|
-
onClick: behavior.type === "none" ? void 0 : () => {
|
|
1662
|
-
void onBehavior(behavior);
|
|
1663
|
-
}
|
|
1664
|
-
};
|
|
1665
|
-
}
|
|
1666
|
-
return void 0;
|
|
1667
|
-
};
|
|
1668
|
-
var mapSchemaAlert = (alert) => {
|
|
1669
|
-
return alert ? {
|
|
1670
|
-
content: alert.markdown,
|
|
1671
|
-
context: alert.context ? mapLegacyContext(alert.context) : "neutral"
|
|
1672
|
-
} : void 0;
|
|
1673
|
-
};
|
|
1674
|
-
|
|
1675
1974
|
// src/domain/mappers/layout/decisionLayoutToComponent.ts
|
|
1676
1975
|
var decisionLayoutToComponent = (uid, {
|
|
1677
1976
|
analyticsId,
|
|
@@ -2147,44 +2446,8 @@ var mapReviewField = (field, mapperProps) => {
|
|
|
2147
2446
|
});
|
|
2148
2447
|
};
|
|
2149
2448
|
|
|
2150
|
-
// src/domain/components/utils/debounce.ts
|
|
2151
|
-
var debounce = (callback, waitMs) => {
|
|
2152
|
-
let timeoutId = null;
|
|
2153
|
-
let lastArgs = null;
|
|
2154
|
-
const clearTimer = () => {
|
|
2155
|
-
if (timeoutId !== null) {
|
|
2156
|
-
clearTimeout(timeoutId);
|
|
2157
|
-
timeoutId = null;
|
|
2158
|
-
}
|
|
2159
|
-
lastArgs = null;
|
|
2160
|
-
};
|
|
2161
|
-
const debouncedFn = (...args) => {
|
|
2162
|
-
lastArgs = args;
|
|
2163
|
-
if (timeoutId !== null) {
|
|
2164
|
-
clearTimeout(timeoutId);
|
|
2165
|
-
}
|
|
2166
|
-
timeoutId = setTimeout(() => {
|
|
2167
|
-
callback(...lastArgs);
|
|
2168
|
-
timeoutId = null;
|
|
2169
|
-
lastArgs = null;
|
|
2170
|
-
}, waitMs);
|
|
2171
|
-
};
|
|
2172
|
-
debouncedFn.cancel = () => {
|
|
2173
|
-
if (timeoutId !== null) {
|
|
2174
|
-
clearTimer();
|
|
2175
|
-
}
|
|
2176
|
-
};
|
|
2177
|
-
debouncedFn.flush = () => {
|
|
2178
|
-
if (timeoutId !== null) {
|
|
2179
|
-
callback(...lastArgs);
|
|
2180
|
-
clearTimer();
|
|
2181
|
-
}
|
|
2182
|
-
};
|
|
2183
|
-
return debouncedFn;
|
|
2184
|
-
};
|
|
2185
|
-
|
|
2186
2449
|
// src/domain/components/searchComponent/SearchComponent.ts
|
|
2187
|
-
var
|
|
2450
|
+
var DEBOUNCE_TIME2 = 400;
|
|
2188
2451
|
var createSearchComponent = (props, performSearch, onBehavior, onComponentUpdate) => {
|
|
2189
2452
|
const { uid, analyticsId, control, emptyMessage, initialState, hint, margin, tags, title } = props;
|
|
2190
2453
|
const update = getInputUpdateFunction(onComponentUpdate);
|
|
@@ -2214,7 +2477,7 @@ var createSearchComponent = (props, performSearch, onBehavior, onComponentUpdate
|
|
|
2214
2477
|
}
|
|
2215
2478
|
});
|
|
2216
2479
|
};
|
|
2217
|
-
const debouncedSearch = debounce(search,
|
|
2480
|
+
const debouncedSearch = debounce(search, DEBOUNCE_TIME2);
|
|
2218
2481
|
const component = {
|
|
2219
2482
|
type: "search",
|
|
2220
2483
|
kind: "layout",
|
|
@@ -2276,7 +2539,7 @@ var getPerformSearchFunction = (httpClient, mapLayoutToDomainComponent, defaultC
|
|
|
2276
2539
|
if (requestHash !== latestSuccessfulRequestHash) {
|
|
2277
2540
|
const { method, param, url } = config;
|
|
2278
2541
|
const headers = { "Content-Type": "application/json" };
|
|
2279
|
-
const response = await (method === "GET" ? httpClient(
|
|
2542
|
+
const response = await (method === "GET" ? httpClient(addQueryParameter2(url, param, query), {
|
|
2280
2543
|
method,
|
|
2281
2544
|
headers,
|
|
2282
2545
|
signal
|
|
@@ -2286,7 +2549,7 @@ var getPerformSearchFunction = (httpClient, mapLayoutToDomainComponent, defaultC
|
|
|
2286
2549
|
signal,
|
|
2287
2550
|
body: JSON.stringify({ [param]: query })
|
|
2288
2551
|
}));
|
|
2289
|
-
const results = await
|
|
2552
|
+
const results = await parseResponse2(response);
|
|
2290
2553
|
latestSuccessfulRequestHash = requestHash;
|
|
2291
2554
|
if (results.type === "layout") {
|
|
2292
2555
|
const mappedLayoutResult = {
|
|
@@ -2302,7 +2565,7 @@ var getPerformSearchFunction = (httpClient, mapLayoutToDomainComponent, defaultC
|
|
|
2302
2565
|
return latestSuccessfulResults;
|
|
2303
2566
|
};
|
|
2304
2567
|
};
|
|
2305
|
-
var
|
|
2568
|
+
var parseResponse2 = async (response) => {
|
|
2306
2569
|
if (response.ok) {
|
|
2307
2570
|
const body = await response.json().catch(() => null);
|
|
2308
2571
|
if (isValidResponseBody(body)) {
|
|
@@ -2319,7 +2582,7 @@ var parseResponse = async (response) => {
|
|
|
2319
2582
|
}
|
|
2320
2583
|
throw Error("error response");
|
|
2321
2584
|
};
|
|
2322
|
-
var
|
|
2585
|
+
var addQueryParameter2 = (url, key, value) => {
|
|
2323
2586
|
const [urlBase, urlQuery] = url.split("?");
|
|
2324
2587
|
const urlQueryParams = new URLSearchParams(urlQuery);
|
|
2325
2588
|
urlQueryParams.set(key, value);
|
|
@@ -2525,6 +2788,8 @@ var mapLayoutToComponent = (uid, layout, mapperProps, schemaComponents) => {
|
|
|
2525
2788
|
return boxLayoutToComponent(uid, layout, mapperProps, schemaComponents);
|
|
2526
2789
|
case "button":
|
|
2527
2790
|
return buttonLayoutToComponent(uid, layout, mapperProps);
|
|
2791
|
+
case "collection":
|
|
2792
|
+
return collectionLayoutToComponent(uid, layout, mapperProps);
|
|
2528
2793
|
case "columns":
|
|
2529
2794
|
return columnsLayoutToComponent(uid, layout, mapperProps, schemaComponents);
|
|
2530
2795
|
case "decision":
|
|
@@ -3472,13 +3737,13 @@ var getBehaviorFromSchemaRefreshStepOnChange = (schema) => {
|
|
|
3472
3737
|
return void 0;
|
|
3473
3738
|
};
|
|
3474
3739
|
|
|
3475
|
-
// src/domain/features/validation/
|
|
3476
|
-
var
|
|
3740
|
+
// src/domain/features/validation/getPatternRegExp.ts
|
|
3741
|
+
var getPatternRegExp = (pattern, logEvent) => {
|
|
3477
3742
|
if (!pattern) {
|
|
3478
3743
|
return;
|
|
3479
3744
|
}
|
|
3480
3745
|
try {
|
|
3481
|
-
new RegExp(pattern, "u");
|
|
3746
|
+
return new RegExp(pattern, "u");
|
|
3482
3747
|
} catch (error) {
|
|
3483
3748
|
const message = `Invalid schema pattern. Failed to instantiate RegExp with Unicode support.`;
|
|
3484
3749
|
if (logEvent) {
|
|
@@ -3487,11 +3752,12 @@ var validateStringPattern = (pattern, logEvent) => {
|
|
|
3487
3752
|
error: error == null ? void 0 : error.toString()
|
|
3488
3753
|
});
|
|
3489
3754
|
} else {
|
|
3490
|
-
console.warn(`
|
|
3755
|
+
console.warn(`Dynamic Flow - ${message}`, {
|
|
3491
3756
|
pattern,
|
|
3492
3757
|
error: error == null ? void 0 : error.toString()
|
|
3493
3758
|
});
|
|
3494
3759
|
}
|
|
3760
|
+
return new RegExp(pattern);
|
|
3495
3761
|
}
|
|
3496
3762
|
};
|
|
3497
3763
|
|
|
@@ -3587,10 +3853,10 @@ var getBelowMinimumDateCheck = ({ minimum }, messageFunctions) => (value) => {
|
|
|
3587
3853
|
return null;
|
|
3588
3854
|
};
|
|
3589
3855
|
var getNotAdheringToPatternCheck = ({ pattern }, messageFunctions, options) => {
|
|
3590
|
-
|
|
3856
|
+
const regExp = getPatternRegExp(pattern, options == null ? void 0 : options.logEvent);
|
|
3591
3857
|
return (value) => {
|
|
3592
|
-
if (
|
|
3593
|
-
return
|
|
3858
|
+
if (regExp && isString(value) && value) {
|
|
3859
|
+
return (regExp == null ? void 0 : regExp.test(value)) ? null : messageFunctions.pattern();
|
|
3594
3860
|
}
|
|
3595
3861
|
return null;
|
|
3596
3862
|
};
|
|
@@ -7897,6 +8163,26 @@ var mapBoxControl = ({
|
|
|
7897
8163
|
return control;
|
|
7898
8164
|
};
|
|
7899
8165
|
|
|
8166
|
+
// src/renderers/mappers/collectionComponentToProps.ts
|
|
8167
|
+
var collectionComponentToProps = (component, rendererMapperProps) => {
|
|
8168
|
+
var _a, _b, _c;
|
|
8169
|
+
return __spreadProps(__spreadValues(__spreadValues({}, pick(component, "uid", "analyticsId", "type", "control", "margin", "tags", "url", "method")), rendererMapperProps), {
|
|
8170
|
+
status: component.status,
|
|
8171
|
+
state: __spreadProps(__spreadValues({}, component.state), {
|
|
8172
|
+
filters: (_a = component.state.filters) != null ? _a : [],
|
|
8173
|
+
sections: component.state.sections.map((section) => __spreadProps(__spreadValues({}, section), {
|
|
8174
|
+
callToAction: mapCallToActionOptional(section.callToAction),
|
|
8175
|
+
items: section.items.map((item) => __spreadProps(__spreadValues({}, item), {
|
|
8176
|
+
callToAction: mapCallToActionOptional(item.callToAction),
|
|
8177
|
+
additionalInfo: mapAdditionalInfo2(item.additionalInfo)
|
|
8178
|
+
}))
|
|
8179
|
+
})),
|
|
8180
|
+
beforeSections: (_b = component.state.beforeSections) == null ? void 0 : _b.map((child) => componentToRendererProps(child, rendererMapperProps)).map(rendererMapperProps.render),
|
|
8181
|
+
afterSections: (_c = component.state.afterSections) == null ? void 0 : _c.map((child) => componentToRendererProps(child, rendererMapperProps)).map(rendererMapperProps.render)
|
|
8182
|
+
})
|
|
8183
|
+
});
|
|
8184
|
+
};
|
|
8185
|
+
|
|
7900
8186
|
// src/renderers/mappers/buttonComponentToProps.ts
|
|
7901
8187
|
var buttonComponentToProps = (component, rendererMapperProps) => {
|
|
7902
8188
|
return __spreadValues(__spreadProps(__spreadValues({
|
|
@@ -8526,6 +8812,8 @@ var getComponentProps = (component, rendererMapperProps) => {
|
|
|
8526
8812
|
return boxComponentToProps(component, rendererMapperProps);
|
|
8527
8813
|
case "button":
|
|
8528
8814
|
return buttonComponentToProps(component, rendererMapperProps);
|
|
8815
|
+
case "collection":
|
|
8816
|
+
return collectionComponentToProps(component, rendererMapperProps);
|
|
8529
8817
|
case "columns":
|
|
8530
8818
|
return columnsComponentToProps(component, rendererMapperProps);
|
|
8531
8819
|
case "container":
|