@wise/dynamic-flow-client 5.20.0-experimental-2dcb025 → 5.20.0
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/i18n/ar.json +38 -0
- package/build/i18n/ko.json +38 -0
- package/build/main.css +33 -0
- package/build/main.js +77 -364
- package/build/main.mjs +77 -364
- package/build/tsconfig.types.tsbuildinfo +1 -1
- package/build/types/domain/mappers/mapLayoutToComponent.d.ts.map +1 -1
- package/build/types/domain/types.d.ts +2 -3
- package/build/types/domain/types.d.ts.map +1 -1
- 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 +18 -18
- package/build/types/domain/components/collectionComponent/CollectionComponent.d.ts +0 -7
- package/build/types/domain/components/collectionComponent/CollectionComponent.d.ts.map +0 -1
- package/build/types/domain/components/collectionComponent/applyCollectionResponse.d.ts +0 -3
- package/build/types/domain/components/collectionComponent/applyCollectionResponse.d.ts.map +0 -1
- package/build/types/domain/components/collectionComponent/types.d.ts +0 -73
- package/build/types/domain/components/collectionComponent/types.d.ts.map +0 -1
- package/build/types/domain/features/collection/getPerformCollectionQueryFunction.d.ts +0 -12
- package/build/types/domain/features/collection/getPerformCollectionQueryFunction.d.ts.map +0 -1
- package/build/types/domain/mappers/layout/collectionLayoutToComponent.d.ts +0 -7
- package/build/types/domain/mappers/layout/collectionLayoutToComponent.d.ts.map +0 -1
- package/build/types/renderers/mappers/collectionComponentToProps.d.ts +0 -5
- package/build/types/renderers/mappers/collectionComponentToProps.d.ts.map +0 -1
package/build/main.js
CHANGED
|
@@ -883,7 +883,6 @@ var getChildren = (node) => {
|
|
|
883
883
|
return node.tabs.flatMap((c) => c.childrenProps);
|
|
884
884
|
case "alert":
|
|
885
885
|
case "button":
|
|
886
|
-
case "collection":
|
|
887
886
|
case "input-checkbox":
|
|
888
887
|
case "input-date":
|
|
889
888
|
case "decision":
|
|
@@ -1501,339 +1500,6 @@ var boxLayoutToComponent = (uid, { border = false, components, control, margin,
|
|
|
1501
1500
|
)
|
|
1502
1501
|
});
|
|
1503
1502
|
|
|
1504
|
-
// src/domain/mappers/utils/utils.ts
|
|
1505
|
-
var mapInlineAlert = (alert) => {
|
|
1506
|
-
return alert ? {
|
|
1507
|
-
content: alert.content,
|
|
1508
|
-
context: alert.context ? mapLegacyContext(alert.context) : "neutral"
|
|
1509
|
-
} : void 0;
|
|
1510
|
-
};
|
|
1511
|
-
var mapAdditionalInfo = (info, mapperProps) => {
|
|
1512
|
-
const { onBehavior, trackEvent, registerSubmissionBehavior } = mapperProps;
|
|
1513
|
-
if (info) {
|
|
1514
|
-
const behavior = getDomainLayerBehavior(info, [], registerSubmissionBehavior);
|
|
1515
|
-
const isLink = behavior.type === "link";
|
|
1516
|
-
return {
|
|
1517
|
-
text: info.text,
|
|
1518
|
-
href: isLink ? behavior.url : void 0,
|
|
1519
|
-
hrefWithTracking: getHrefWithTracking({
|
|
1520
|
-
behavior,
|
|
1521
|
-
onBehavior,
|
|
1522
|
-
trackEvent
|
|
1523
|
-
}),
|
|
1524
|
-
accessibilityDescription: info.accessibilityDescription,
|
|
1525
|
-
onClick: behavior.type === "none" ? void 0 : () => {
|
|
1526
|
-
void onBehavior(behavior);
|
|
1527
|
-
}
|
|
1528
|
-
};
|
|
1529
|
-
}
|
|
1530
|
-
return void 0;
|
|
1531
|
-
};
|
|
1532
|
-
var mapSchemaAlert = (alert) => {
|
|
1533
|
-
return alert ? {
|
|
1534
|
-
content: alert.markdown,
|
|
1535
|
-
context: alert.context ? mapLegacyContext(alert.context) : "neutral"
|
|
1536
|
-
} : void 0;
|
|
1537
|
-
};
|
|
1538
|
-
|
|
1539
|
-
// src/domain/components/utils/debounce.ts
|
|
1540
|
-
var debounce = (callback, waitMs) => {
|
|
1541
|
-
let timeoutId = null;
|
|
1542
|
-
let lastArgs = null;
|
|
1543
|
-
const clearTimer = () => {
|
|
1544
|
-
if (timeoutId !== null) {
|
|
1545
|
-
clearTimeout(timeoutId);
|
|
1546
|
-
timeoutId = null;
|
|
1547
|
-
}
|
|
1548
|
-
lastArgs = null;
|
|
1549
|
-
};
|
|
1550
|
-
const debouncedFn = (...args) => {
|
|
1551
|
-
lastArgs = args;
|
|
1552
|
-
if (timeoutId !== null) {
|
|
1553
|
-
clearTimeout(timeoutId);
|
|
1554
|
-
}
|
|
1555
|
-
timeoutId = setTimeout(() => {
|
|
1556
|
-
callback(...lastArgs);
|
|
1557
|
-
timeoutId = null;
|
|
1558
|
-
lastArgs = null;
|
|
1559
|
-
}, waitMs);
|
|
1560
|
-
};
|
|
1561
|
-
debouncedFn.cancel = () => {
|
|
1562
|
-
if (timeoutId !== null) {
|
|
1563
|
-
clearTimer();
|
|
1564
|
-
}
|
|
1565
|
-
};
|
|
1566
|
-
debouncedFn.flush = () => {
|
|
1567
|
-
if (timeoutId !== null) {
|
|
1568
|
-
callback(...lastArgs);
|
|
1569
|
-
clearTimer();
|
|
1570
|
-
}
|
|
1571
|
-
};
|
|
1572
|
-
return debouncedFn;
|
|
1573
|
-
};
|
|
1574
|
-
|
|
1575
|
-
// src/domain/components/collectionComponent/applyCollectionResponse.ts
|
|
1576
|
-
var applyCollectionResponse = (currentState, response, isPaginated) => {
|
|
1577
|
-
var _a, _b, _c, _d;
|
|
1578
|
-
const sections = isPaginated ? mergeSections(currentState.sections, response.sections) : response.sections;
|
|
1579
|
-
return {
|
|
1580
|
-
sections,
|
|
1581
|
-
nextCursor: response.nextCursor,
|
|
1582
|
-
filters: (_a = response.filters) != null ? _a : currentState.filters,
|
|
1583
|
-
search: (_b = response.search) != null ? _b : currentState.search,
|
|
1584
|
-
beforeSections: (_c = response.beforeSections) != null ? _c : currentState.beforeSections,
|
|
1585
|
-
afterSections: (_d = response.afterSections) != null ? _d : currentState.afterSections
|
|
1586
|
-
};
|
|
1587
|
-
};
|
|
1588
|
-
var mergeSections = (existing, incoming) => {
|
|
1589
|
-
const knownIds = new Set(existing.map((section) => section.id));
|
|
1590
|
-
const newSections = incoming.filter((section) => !knownIds.has(section.id));
|
|
1591
|
-
const merged = existing.map((section) => {
|
|
1592
|
-
const match = incoming.find((s) => s.id === section.id);
|
|
1593
|
-
if (!match) return section;
|
|
1594
|
-
return __spreadProps(__spreadValues({}, section), { items: [...section.items, ...match.items] });
|
|
1595
|
-
});
|
|
1596
|
-
return [...merged, ...newSections];
|
|
1597
|
-
};
|
|
1598
|
-
|
|
1599
|
-
// src/domain/components/collectionComponent/CollectionComponent.ts
|
|
1600
|
-
var DEBOUNCE_TIME = 800;
|
|
1601
|
-
var createCollectionComponent = (props, onComponentUpdate, searchFunction) => {
|
|
1602
|
-
const { uid, analyticsId, control, margin, tags, url, method, state } = props;
|
|
1603
|
-
const update = getInputUpdateFunction(onComponentUpdate);
|
|
1604
|
-
let abortController = new AbortController();
|
|
1605
|
-
const query = (component2, cursor) => {
|
|
1606
|
-
var _a, _b;
|
|
1607
|
-
abortController.abort();
|
|
1608
|
-
abortController = new AbortController();
|
|
1609
|
-
const { signal } = abortController;
|
|
1610
|
-
searchFunction({
|
|
1611
|
-
searchParam: (_a = component2.state.search) == null ? void 0 : _a.param,
|
|
1612
|
-
query: (_b = component2.state.search) == null ? void 0 : _b.query,
|
|
1613
|
-
cursor,
|
|
1614
|
-
signal,
|
|
1615
|
-
filters: component2.state.filters
|
|
1616
|
-
}).then((response) => {
|
|
1617
|
-
if (!response) {
|
|
1618
|
-
return;
|
|
1619
|
-
}
|
|
1620
|
-
update(component2, (draft) => {
|
|
1621
|
-
const newState = applyCollectionResponse(draft.state, response, !!cursor);
|
|
1622
|
-
draft.state = __spreadProps(__spreadValues({}, newState), {
|
|
1623
|
-
filters: mapFilters(newState.filters),
|
|
1624
|
-
search: mapSearch(newState.search)
|
|
1625
|
-
});
|
|
1626
|
-
draft.status = {
|
|
1627
|
-
type: "idle",
|
|
1628
|
-
loadMore: newState.nextCursor ? () => query(component2, newState.nextCursor) : void 0
|
|
1629
|
-
};
|
|
1630
|
-
});
|
|
1631
|
-
}).catch(() => {
|
|
1632
|
-
if (!signal.aborted) {
|
|
1633
|
-
update(component2, (draft) => {
|
|
1634
|
-
draft.status = {
|
|
1635
|
-
type: "error",
|
|
1636
|
-
reason: cursor ? "pagination" : "search",
|
|
1637
|
-
retry: () => query(component2, cursor)
|
|
1638
|
-
};
|
|
1639
|
-
});
|
|
1640
|
-
}
|
|
1641
|
-
});
|
|
1642
|
-
};
|
|
1643
|
-
const debouncedQuery = debounce(
|
|
1644
|
-
(component2) => query(component2),
|
|
1645
|
-
DEBOUNCE_TIME
|
|
1646
|
-
);
|
|
1647
|
-
const selectFilter = (filterIndex, optionIndex) => {
|
|
1648
|
-
var _a;
|
|
1649
|
-
const filter = (_a = component.state.filters) == null ? void 0 : _a[filterIndex];
|
|
1650
|
-
if (!filter) {
|
|
1651
|
-
return;
|
|
1652
|
-
}
|
|
1653
|
-
const currentValue = filter.options[optionIndex].selected;
|
|
1654
|
-
update(component, (draft) => {
|
|
1655
|
-
if (!draft.state.filters) {
|
|
1656
|
-
return;
|
|
1657
|
-
}
|
|
1658
|
-
if (filter.multiSelect) {
|
|
1659
|
-
draft.state.filters[filterIndex].options[optionIndex].selected = !currentValue;
|
|
1660
|
-
} else {
|
|
1661
|
-
draft.state.filters[filterIndex].options = draft.state.filters[filterIndex].options.map(
|
|
1662
|
-
(option, index) => __spreadProps(__spreadValues({}, option), {
|
|
1663
|
-
selected: index === optionIndex ? !currentValue : false
|
|
1664
|
-
})
|
|
1665
|
-
);
|
|
1666
|
-
}
|
|
1667
|
-
draft.status = { type: "loading", reason: "search" };
|
|
1668
|
-
});
|
|
1669
|
-
query(component);
|
|
1670
|
-
};
|
|
1671
|
-
const mapFilters = (filters) => filters == null ? void 0 : filters.map((filter, i) => {
|
|
1672
|
-
var _a;
|
|
1673
|
-
return __spreadProps(__spreadValues({}, filter), {
|
|
1674
|
-
options: (_a = filter.options) == null ? void 0 : _a.map((option, j) => {
|
|
1675
|
-
var _a2;
|
|
1676
|
-
return __spreadProps(__spreadValues({}, option), {
|
|
1677
|
-
selected: (_a2 = option.selected) != null ? _a2 : false,
|
|
1678
|
-
onSelect: () => selectFilter(i, j)
|
|
1679
|
-
});
|
|
1680
|
-
})
|
|
1681
|
-
});
|
|
1682
|
-
});
|
|
1683
|
-
const mapSearch = (search) => search ? __spreadProps(__spreadValues({}, search), {
|
|
1684
|
-
onChange(value) {
|
|
1685
|
-
update(component, (draft) => {
|
|
1686
|
-
if (draft.state.search) {
|
|
1687
|
-
draft.state.search.query = value;
|
|
1688
|
-
draft.status = { type: "loading", reason: "search" };
|
|
1689
|
-
}
|
|
1690
|
-
});
|
|
1691
|
-
debouncedQuery(component);
|
|
1692
|
-
}
|
|
1693
|
-
}) : void 0;
|
|
1694
|
-
const component = {
|
|
1695
|
-
type: "collection",
|
|
1696
|
-
kind: "layout",
|
|
1697
|
-
uid,
|
|
1698
|
-
analyticsId,
|
|
1699
|
-
control,
|
|
1700
|
-
margin,
|
|
1701
|
-
method,
|
|
1702
|
-
url,
|
|
1703
|
-
tags,
|
|
1704
|
-
status: {
|
|
1705
|
-
type: "idle",
|
|
1706
|
-
loadMore: state.nextCursor ? () => query(component, state.nextCursor) : void 0
|
|
1707
|
-
},
|
|
1708
|
-
state: __spreadProps(__spreadValues({}, state), {
|
|
1709
|
-
filters: mapFilters(state.filters),
|
|
1710
|
-
search: mapSearch(props.search)
|
|
1711
|
-
})
|
|
1712
|
-
};
|
|
1713
|
-
return component;
|
|
1714
|
-
};
|
|
1715
|
-
|
|
1716
|
-
// src/domain/features/collection/getPerformCollectionQueryFunction.ts
|
|
1717
|
-
var getPerformCollectionQueryFunction = (httpClient, url, method, mapState) => {
|
|
1718
|
-
return async ({ searchParam, query, cursor, signal, filters = [] }) => {
|
|
1719
|
-
const headers = { "Content-Type": "application/json" };
|
|
1720
|
-
const filterValues = filters.map(
|
|
1721
|
-
(f) => {
|
|
1722
|
-
var _a;
|
|
1723
|
-
return [f.param, (_a = f.options.find((option) => option.selected)) == null ? void 0 : _a.value];
|
|
1724
|
-
}
|
|
1725
|
-
);
|
|
1726
|
-
const response = await (method === "GET" ? httpClient(
|
|
1727
|
-
addQueryParameters(url, [
|
|
1728
|
-
[searchParam, query != null ? query : void 0],
|
|
1729
|
-
["cursor", cursor],
|
|
1730
|
-
...filterValues
|
|
1731
|
-
]),
|
|
1732
|
-
{
|
|
1733
|
-
method,
|
|
1734
|
-
headers,
|
|
1735
|
-
signal
|
|
1736
|
-
}
|
|
1737
|
-
) : httpClient(url, {
|
|
1738
|
-
method,
|
|
1739
|
-
headers,
|
|
1740
|
-
signal,
|
|
1741
|
-
body: JSON.stringify(__spreadValues(__spreadProps(__spreadValues({}, searchParam && query ? { [searchParam]: query } : {}), {
|
|
1742
|
-
cursor
|
|
1743
|
-
}), filterValues.reduce((acc, [k, v]) => __spreadProps(__spreadValues({}, acc), { [k]: v }), {})))
|
|
1744
|
-
}));
|
|
1745
|
-
const results = await parseResponse(response);
|
|
1746
|
-
return mapState(results);
|
|
1747
|
-
};
|
|
1748
|
-
};
|
|
1749
|
-
var parseResponse = async (response) => {
|
|
1750
|
-
if (response.ok) {
|
|
1751
|
-
const body = await response.json().catch(() => null);
|
|
1752
|
-
return body;
|
|
1753
|
-
}
|
|
1754
|
-
throw Error("error response");
|
|
1755
|
-
};
|
|
1756
|
-
var addQueryParameters = (url, params) => {
|
|
1757
|
-
return params.reduce(
|
|
1758
|
-
(u, [key, param]) => key && param ? addQueryParameter(u, key, param) : u,
|
|
1759
|
-
url
|
|
1760
|
-
);
|
|
1761
|
-
};
|
|
1762
|
-
var addQueryParameter = (url, key, value) => {
|
|
1763
|
-
const [urlBase, urlQuery] = url.split("?");
|
|
1764
|
-
const urlQueryParams = new URLSearchParams(urlQuery);
|
|
1765
|
-
urlQueryParams.set(key, value);
|
|
1766
|
-
return `${urlBase}?${urlQueryParams.toString()}`;
|
|
1767
|
-
};
|
|
1768
|
-
|
|
1769
|
-
// src/domain/mappers/layout/collectionLayoutToComponent.ts
|
|
1770
|
-
var collectionLayoutToComponent = (uid, { analyticsId, control, initialState, margin, method, search, tags, url }, mapperProps) => {
|
|
1771
|
-
const { httpClient, onComponentUpdate } = mapperProps;
|
|
1772
|
-
const mapLayout = (layout, index) => mapLayoutToComponent(`${uid}-collection-response-${index}`, layout, mapperProps, []);
|
|
1773
|
-
const mapState = (state) => mapCollectionSpecToDomainState(state, mapperProps, mapLayout);
|
|
1774
|
-
const searchFunction = getPerformCollectionQueryFunction(httpClient, url, method, mapState);
|
|
1775
|
-
const component = createCollectionComponent(
|
|
1776
|
-
{
|
|
1777
|
-
uid,
|
|
1778
|
-
analyticsId,
|
|
1779
|
-
control,
|
|
1780
|
-
margin: margin != null ? margin : "md",
|
|
1781
|
-
tags,
|
|
1782
|
-
url,
|
|
1783
|
-
method,
|
|
1784
|
-
state: mapState(initialState),
|
|
1785
|
-
search: search ? {
|
|
1786
|
-
param: search == null ? void 0 : search.param,
|
|
1787
|
-
query: "",
|
|
1788
|
-
hint: search == null ? void 0 : search.hint
|
|
1789
|
-
} : void 0
|
|
1790
|
-
},
|
|
1791
|
-
onComponentUpdate,
|
|
1792
|
-
searchFunction
|
|
1793
|
-
);
|
|
1794
|
-
return component;
|
|
1795
|
-
};
|
|
1796
|
-
var mapCollectionSpecToDomainState = (specState, mapperProps, mapLayout) => {
|
|
1797
|
-
var _a, _b, _c;
|
|
1798
|
-
return {
|
|
1799
|
-
sections: specState.sections.map((section) => {
|
|
1800
|
-
return {
|
|
1801
|
-
id: section.id,
|
|
1802
|
-
title: section.title,
|
|
1803
|
-
callToAction: getDomainLayerCallToAction(section.callToAction, mapperProps),
|
|
1804
|
-
items: section.items.map((item) => {
|
|
1805
|
-
const behavior = getDomainLayerBehavior(
|
|
1806
|
-
{ behavior: item.primaryBehavior },
|
|
1807
|
-
[],
|
|
1808
|
-
mapperProps.registerSubmissionBehavior
|
|
1809
|
-
);
|
|
1810
|
-
return __spreadProps(__spreadValues({}, item), {
|
|
1811
|
-
onClick: item.primaryBehavior ? () => {
|
|
1812
|
-
void mapperProps.onBehavior(behavior);
|
|
1813
|
-
} : void 0,
|
|
1814
|
-
callToAction: getDomainLayerCallToAction(item.callToAction, mapperProps),
|
|
1815
|
-
inlineAlert: mapInlineAlert(item.inlineAlert)
|
|
1816
|
-
});
|
|
1817
|
-
})
|
|
1818
|
-
};
|
|
1819
|
-
}),
|
|
1820
|
-
filters: (_a = specState.filters) == null ? void 0 : _a.map((filter) => __spreadProps(__spreadValues({}, filter), {
|
|
1821
|
-
options: filter.options.map((option) => {
|
|
1822
|
-
var _a2;
|
|
1823
|
-
return __spreadProps(__spreadValues({}, option), {
|
|
1824
|
-
selected: (_a2 = option.selected) != null ? _a2 : false,
|
|
1825
|
-
onSelect: () => {
|
|
1826
|
-
}
|
|
1827
|
-
// todo: what goes here?
|
|
1828
|
-
});
|
|
1829
|
-
})
|
|
1830
|
-
})),
|
|
1831
|
-
beforeSections: (_b = specState.beforeSections) == null ? void 0 : _b.map(mapLayout),
|
|
1832
|
-
afterSections: (_c = specState.afterSections) == null ? void 0 : _c.map(mapLayout),
|
|
1833
|
-
nextCursor: specState.nextCursor
|
|
1834
|
-
};
|
|
1835
|
-
};
|
|
1836
|
-
|
|
1837
1503
|
// src/domain/components/ButtonComponent.ts
|
|
1838
1504
|
var createButtonComponent = (props) => __spreadValues({
|
|
1839
1505
|
type: "button",
|
|
@@ -2002,6 +1668,41 @@ var createDecisionComponent = (props) => __spreadValues({
|
|
|
2002
1668
|
// src/domain/mappers/utils/tags-utils.ts
|
|
2003
1669
|
var mapTags = ({ tag, tags }) => tags != null ? tags : tag != null ? [tag] : void 0;
|
|
2004
1670
|
|
|
1671
|
+
// src/domain/mappers/utils/utils.ts
|
|
1672
|
+
var mapInlineAlert = (alert) => {
|
|
1673
|
+
return alert ? {
|
|
1674
|
+
content: alert.content,
|
|
1675
|
+
context: alert.context ? mapLegacyContext(alert.context) : "neutral"
|
|
1676
|
+
} : void 0;
|
|
1677
|
+
};
|
|
1678
|
+
var mapAdditionalInfo = (info, mapperProps) => {
|
|
1679
|
+
const { onBehavior, trackEvent, registerSubmissionBehavior } = mapperProps;
|
|
1680
|
+
if (info) {
|
|
1681
|
+
const behavior = getDomainLayerBehavior(info, [], registerSubmissionBehavior);
|
|
1682
|
+
const isLink = behavior.type === "link";
|
|
1683
|
+
return {
|
|
1684
|
+
text: info.text,
|
|
1685
|
+
href: isLink ? behavior.url : void 0,
|
|
1686
|
+
hrefWithTracking: getHrefWithTracking({
|
|
1687
|
+
behavior,
|
|
1688
|
+
onBehavior,
|
|
1689
|
+
trackEvent
|
|
1690
|
+
}),
|
|
1691
|
+
accessibilityDescription: info.accessibilityDescription,
|
|
1692
|
+
onClick: behavior.type === "none" ? void 0 : () => {
|
|
1693
|
+
void onBehavior(behavior);
|
|
1694
|
+
}
|
|
1695
|
+
};
|
|
1696
|
+
}
|
|
1697
|
+
return void 0;
|
|
1698
|
+
};
|
|
1699
|
+
var mapSchemaAlert = (alert) => {
|
|
1700
|
+
return alert ? {
|
|
1701
|
+
content: alert.markdown,
|
|
1702
|
+
context: alert.context ? mapLegacyContext(alert.context) : "neutral"
|
|
1703
|
+
} : void 0;
|
|
1704
|
+
};
|
|
1705
|
+
|
|
2005
1706
|
// src/domain/mappers/layout/decisionLayoutToComponent.ts
|
|
2006
1707
|
var decisionLayoutToComponent = (uid, {
|
|
2007
1708
|
analyticsId,
|
|
@@ -2477,8 +2178,44 @@ var mapReviewField = (field, mapperProps) => {
|
|
|
2477
2178
|
});
|
|
2478
2179
|
};
|
|
2479
2180
|
|
|
2181
|
+
// src/domain/components/utils/debounce.ts
|
|
2182
|
+
var debounce = (callback, waitMs) => {
|
|
2183
|
+
let timeoutId = null;
|
|
2184
|
+
let lastArgs = null;
|
|
2185
|
+
const clearTimer = () => {
|
|
2186
|
+
if (timeoutId !== null) {
|
|
2187
|
+
clearTimeout(timeoutId);
|
|
2188
|
+
timeoutId = null;
|
|
2189
|
+
}
|
|
2190
|
+
lastArgs = null;
|
|
2191
|
+
};
|
|
2192
|
+
const debouncedFn = (...args) => {
|
|
2193
|
+
lastArgs = args;
|
|
2194
|
+
if (timeoutId !== null) {
|
|
2195
|
+
clearTimeout(timeoutId);
|
|
2196
|
+
}
|
|
2197
|
+
timeoutId = setTimeout(() => {
|
|
2198
|
+
callback(...lastArgs);
|
|
2199
|
+
timeoutId = null;
|
|
2200
|
+
lastArgs = null;
|
|
2201
|
+
}, waitMs);
|
|
2202
|
+
};
|
|
2203
|
+
debouncedFn.cancel = () => {
|
|
2204
|
+
if (timeoutId !== null) {
|
|
2205
|
+
clearTimer();
|
|
2206
|
+
}
|
|
2207
|
+
};
|
|
2208
|
+
debouncedFn.flush = () => {
|
|
2209
|
+
if (timeoutId !== null) {
|
|
2210
|
+
callback(...lastArgs);
|
|
2211
|
+
clearTimer();
|
|
2212
|
+
}
|
|
2213
|
+
};
|
|
2214
|
+
return debouncedFn;
|
|
2215
|
+
};
|
|
2216
|
+
|
|
2480
2217
|
// src/domain/components/searchComponent/SearchComponent.ts
|
|
2481
|
-
var
|
|
2218
|
+
var DEBOUNCE_TIME = 400;
|
|
2482
2219
|
var createSearchComponent = (props, performSearch, onBehavior, onComponentUpdate) => {
|
|
2483
2220
|
const { uid, analyticsId, control, emptyMessage, initialState, hint, margin, tags, title } = props;
|
|
2484
2221
|
const update = getInputUpdateFunction(onComponentUpdate);
|
|
@@ -2508,7 +2245,7 @@ var createSearchComponent = (props, performSearch, onBehavior, onComponentUpdate
|
|
|
2508
2245
|
}
|
|
2509
2246
|
});
|
|
2510
2247
|
};
|
|
2511
|
-
const debouncedSearch = debounce(search,
|
|
2248
|
+
const debouncedSearch = debounce(search, DEBOUNCE_TIME);
|
|
2512
2249
|
const component = {
|
|
2513
2250
|
type: "search",
|
|
2514
2251
|
kind: "layout",
|
|
@@ -2570,7 +2307,7 @@ var getPerformSearchFunction = (httpClient, mapLayoutToDomainComponent, defaultC
|
|
|
2570
2307
|
if (requestHash !== latestSuccessfulRequestHash) {
|
|
2571
2308
|
const { method, param, url } = config;
|
|
2572
2309
|
const headers = { "Content-Type": "application/json" };
|
|
2573
|
-
const response = await (method === "GET" ? httpClient(
|
|
2310
|
+
const response = await (method === "GET" ? httpClient(addQueryParameter(url, param, query), {
|
|
2574
2311
|
method,
|
|
2575
2312
|
headers,
|
|
2576
2313
|
signal
|
|
@@ -2580,7 +2317,7 @@ var getPerformSearchFunction = (httpClient, mapLayoutToDomainComponent, defaultC
|
|
|
2580
2317
|
signal,
|
|
2581
2318
|
body: JSON.stringify({ [param]: query })
|
|
2582
2319
|
}));
|
|
2583
|
-
const results = await
|
|
2320
|
+
const results = await parseResponse(response);
|
|
2584
2321
|
latestSuccessfulRequestHash = requestHash;
|
|
2585
2322
|
if (results.type === "layout") {
|
|
2586
2323
|
const mappedLayoutResult = {
|
|
@@ -2596,7 +2333,7 @@ var getPerformSearchFunction = (httpClient, mapLayoutToDomainComponent, defaultC
|
|
|
2596
2333
|
return latestSuccessfulResults;
|
|
2597
2334
|
};
|
|
2598
2335
|
};
|
|
2599
|
-
var
|
|
2336
|
+
var parseResponse = async (response) => {
|
|
2600
2337
|
if (response.ok) {
|
|
2601
2338
|
const body = await response.json().catch(() => null);
|
|
2602
2339
|
if (isValidResponseBody(body)) {
|
|
@@ -2613,7 +2350,7 @@ var parseResponse2 = async (response) => {
|
|
|
2613
2350
|
}
|
|
2614
2351
|
throw Error("error response");
|
|
2615
2352
|
};
|
|
2616
|
-
var
|
|
2353
|
+
var addQueryParameter = (url, key, value) => {
|
|
2617
2354
|
const [urlBase, urlQuery] = url.split("?");
|
|
2618
2355
|
const urlQueryParams = new URLSearchParams(urlQuery);
|
|
2619
2356
|
urlQueryParams.set(key, value);
|
|
@@ -2819,8 +2556,6 @@ var mapLayoutToComponent = (uid, layout, mapperProps, schemaComponents) => {
|
|
|
2819
2556
|
return boxLayoutToComponent(uid, layout, mapperProps, schemaComponents);
|
|
2820
2557
|
case "button":
|
|
2821
2558
|
return buttonLayoutToComponent(uid, layout, mapperProps);
|
|
2822
|
-
case "collection":
|
|
2823
|
-
return collectionLayoutToComponent(uid, layout, mapperProps);
|
|
2824
2559
|
case "columns":
|
|
2825
2560
|
return columnsLayoutToComponent(uid, layout, mapperProps, schemaComponents);
|
|
2826
2561
|
case "decision":
|
|
@@ -8194,26 +7929,6 @@ var mapBoxControl = ({
|
|
|
8194
7929
|
return control;
|
|
8195
7930
|
};
|
|
8196
7931
|
|
|
8197
|
-
// src/renderers/mappers/collectionComponentToProps.ts
|
|
8198
|
-
var collectionComponentToProps = (component, rendererMapperProps) => {
|
|
8199
|
-
var _a, _b, _c;
|
|
8200
|
-
return __spreadProps(__spreadValues(__spreadValues({}, pick(component, "uid", "analyticsId", "type", "control", "margin", "tags", "url", "method")), rendererMapperProps), {
|
|
8201
|
-
status: component.status,
|
|
8202
|
-
state: __spreadProps(__spreadValues({}, component.state), {
|
|
8203
|
-
filters: (_a = component.state.filters) != null ? _a : [],
|
|
8204
|
-
sections: component.state.sections.map((section) => __spreadProps(__spreadValues({}, section), {
|
|
8205
|
-
callToAction: mapCallToActionOptional(section.callToAction),
|
|
8206
|
-
items: section.items.map((item) => __spreadProps(__spreadValues({}, item), {
|
|
8207
|
-
callToAction: mapCallToActionOptional(item.callToAction),
|
|
8208
|
-
additionalInfo: mapAdditionalInfo2(item.additionalInfo)
|
|
8209
|
-
}))
|
|
8210
|
-
})),
|
|
8211
|
-
beforeSections: (_b = component.state.beforeSections) == null ? void 0 : _b.map((child) => componentToRendererProps(child, rendererMapperProps)).map(rendererMapperProps.render),
|
|
8212
|
-
afterSections: (_c = component.state.afterSections) == null ? void 0 : _c.map((child) => componentToRendererProps(child, rendererMapperProps)).map(rendererMapperProps.render)
|
|
8213
|
-
})
|
|
8214
|
-
});
|
|
8215
|
-
};
|
|
8216
|
-
|
|
8217
7932
|
// src/renderers/mappers/buttonComponentToProps.ts
|
|
8218
7933
|
var buttonComponentToProps = (component, rendererMapperProps) => {
|
|
8219
7934
|
return __spreadValues(__spreadProps(__spreadValues({
|
|
@@ -8843,8 +8558,6 @@ var getComponentProps = (component, rendererMapperProps) => {
|
|
|
8843
8558
|
return boxComponentToProps(component, rendererMapperProps);
|
|
8844
8559
|
case "button":
|
|
8845
8560
|
return buttonComponentToProps(component, rendererMapperProps);
|
|
8846
|
-
case "collection":
|
|
8847
|
-
return collectionComponentToProps(component, rendererMapperProps);
|
|
8848
8561
|
case "columns":
|
|
8849
8562
|
return columnsComponentToProps(component, rendererMapperProps);
|
|
8850
8563
|
case "container":
|