@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.mjs
CHANGED
|
@@ -852,7 +852,6 @@ var getChildren = (node) => {
|
|
|
852
852
|
return node.tabs.flatMap((c) => c.childrenProps);
|
|
853
853
|
case "alert":
|
|
854
854
|
case "button":
|
|
855
|
-
case "collection":
|
|
856
855
|
case "input-checkbox":
|
|
857
856
|
case "input-date":
|
|
858
857
|
case "decision":
|
|
@@ -1470,339 +1469,6 @@ var boxLayoutToComponent = (uid, { border = false, components, control, margin,
|
|
|
1470
1469
|
)
|
|
1471
1470
|
});
|
|
1472
1471
|
|
|
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
|
-
|
|
1806
1472
|
// src/domain/components/ButtonComponent.ts
|
|
1807
1473
|
var createButtonComponent = (props) => __spreadValues({
|
|
1808
1474
|
type: "button",
|
|
@@ -1971,6 +1637,41 @@ var createDecisionComponent = (props) => __spreadValues({
|
|
|
1971
1637
|
// src/domain/mappers/utils/tags-utils.ts
|
|
1972
1638
|
var mapTags = ({ tag, tags }) => tags != null ? tags : tag != null ? [tag] : void 0;
|
|
1973
1639
|
|
|
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
|
+
|
|
1974
1675
|
// src/domain/mappers/layout/decisionLayoutToComponent.ts
|
|
1975
1676
|
var decisionLayoutToComponent = (uid, {
|
|
1976
1677
|
analyticsId,
|
|
@@ -2446,8 +2147,44 @@ var mapReviewField = (field, mapperProps) => {
|
|
|
2446
2147
|
});
|
|
2447
2148
|
};
|
|
2448
2149
|
|
|
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
|
+
|
|
2449
2186
|
// src/domain/components/searchComponent/SearchComponent.ts
|
|
2450
|
-
var
|
|
2187
|
+
var DEBOUNCE_TIME = 400;
|
|
2451
2188
|
var createSearchComponent = (props, performSearch, onBehavior, onComponentUpdate) => {
|
|
2452
2189
|
const { uid, analyticsId, control, emptyMessage, initialState, hint, margin, tags, title } = props;
|
|
2453
2190
|
const update = getInputUpdateFunction(onComponentUpdate);
|
|
@@ -2477,7 +2214,7 @@ var createSearchComponent = (props, performSearch, onBehavior, onComponentUpdate
|
|
|
2477
2214
|
}
|
|
2478
2215
|
});
|
|
2479
2216
|
};
|
|
2480
|
-
const debouncedSearch = debounce(search,
|
|
2217
|
+
const debouncedSearch = debounce(search, DEBOUNCE_TIME);
|
|
2481
2218
|
const component = {
|
|
2482
2219
|
type: "search",
|
|
2483
2220
|
kind: "layout",
|
|
@@ -2539,7 +2276,7 @@ var getPerformSearchFunction = (httpClient, mapLayoutToDomainComponent, defaultC
|
|
|
2539
2276
|
if (requestHash !== latestSuccessfulRequestHash) {
|
|
2540
2277
|
const { method, param, url } = config;
|
|
2541
2278
|
const headers = { "Content-Type": "application/json" };
|
|
2542
|
-
const response = await (method === "GET" ? httpClient(
|
|
2279
|
+
const response = await (method === "GET" ? httpClient(addQueryParameter(url, param, query), {
|
|
2543
2280
|
method,
|
|
2544
2281
|
headers,
|
|
2545
2282
|
signal
|
|
@@ -2549,7 +2286,7 @@ var getPerformSearchFunction = (httpClient, mapLayoutToDomainComponent, defaultC
|
|
|
2549
2286
|
signal,
|
|
2550
2287
|
body: JSON.stringify({ [param]: query })
|
|
2551
2288
|
}));
|
|
2552
|
-
const results = await
|
|
2289
|
+
const results = await parseResponse(response);
|
|
2553
2290
|
latestSuccessfulRequestHash = requestHash;
|
|
2554
2291
|
if (results.type === "layout") {
|
|
2555
2292
|
const mappedLayoutResult = {
|
|
@@ -2565,7 +2302,7 @@ var getPerformSearchFunction = (httpClient, mapLayoutToDomainComponent, defaultC
|
|
|
2565
2302
|
return latestSuccessfulResults;
|
|
2566
2303
|
};
|
|
2567
2304
|
};
|
|
2568
|
-
var
|
|
2305
|
+
var parseResponse = async (response) => {
|
|
2569
2306
|
if (response.ok) {
|
|
2570
2307
|
const body = await response.json().catch(() => null);
|
|
2571
2308
|
if (isValidResponseBody(body)) {
|
|
@@ -2582,7 +2319,7 @@ var parseResponse2 = async (response) => {
|
|
|
2582
2319
|
}
|
|
2583
2320
|
throw Error("error response");
|
|
2584
2321
|
};
|
|
2585
|
-
var
|
|
2322
|
+
var addQueryParameter = (url, key, value) => {
|
|
2586
2323
|
const [urlBase, urlQuery] = url.split("?");
|
|
2587
2324
|
const urlQueryParams = new URLSearchParams(urlQuery);
|
|
2588
2325
|
urlQueryParams.set(key, value);
|
|
@@ -2788,8 +2525,6 @@ var mapLayoutToComponent = (uid, layout, mapperProps, schemaComponents) => {
|
|
|
2788
2525
|
return boxLayoutToComponent(uid, layout, mapperProps, schemaComponents);
|
|
2789
2526
|
case "button":
|
|
2790
2527
|
return buttonLayoutToComponent(uid, layout, mapperProps);
|
|
2791
|
-
case "collection":
|
|
2792
|
-
return collectionLayoutToComponent(uid, layout, mapperProps);
|
|
2793
2528
|
case "columns":
|
|
2794
2529
|
return columnsLayoutToComponent(uid, layout, mapperProps, schemaComponents);
|
|
2795
2530
|
case "decision":
|
|
@@ -8163,26 +7898,6 @@ var mapBoxControl = ({
|
|
|
8163
7898
|
return control;
|
|
8164
7899
|
};
|
|
8165
7900
|
|
|
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
|
-
|
|
8186
7901
|
// src/renderers/mappers/buttonComponentToProps.ts
|
|
8187
7902
|
var buttonComponentToProps = (component, rendererMapperProps) => {
|
|
8188
7903
|
return __spreadValues(__spreadProps(__spreadValues({
|
|
@@ -8812,8 +8527,6 @@ var getComponentProps = (component, rendererMapperProps) => {
|
|
|
8812
8527
|
return boxComponentToProps(component, rendererMapperProps);
|
|
8813
8528
|
case "button":
|
|
8814
8529
|
return buttonComponentToProps(component, rendererMapperProps);
|
|
8815
|
-
case "collection":
|
|
8816
|
-
return collectionComponentToProps(component, rendererMapperProps);
|
|
8817
8530
|
case "columns":
|
|
8818
8531
|
return columnsComponentToProps(component, rendererMapperProps);
|
|
8819
8532
|
case "container":
|