@wise/dynamic-flow-client 5.24.1 → 5.25.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 +1 -1
- package/build/i18n/cs.json +1 -1
- package/build/i18n/en.json +1 -1
- package/build/i18n/es.json +1 -1
- package/build/i18n/id.json +1 -1
- package/build/i18n/ko.json +1 -1
- package/build/i18n/nl.json +1 -1
- package/build/i18n/sv.json +1 -1
- package/build/i18n/th.json +1 -1
- package/build/i18n/zh_CN.json +1 -1
- package/build/i18n/zh_HK.json +1 -1
- package/build/main.css +80 -0
- package/build/main.js +359 -243
- package/build/main.mjs +359 -243
- package/build/tsconfig.types.tsbuildinfo +1 -1
- package/build/types/domain/components/DateInputComponent.d.ts +3 -1
- package/build/types/domain/components/DateInputComponent.d.ts.map +1 -1
- package/build/types/domain/components/collectionComponent/CollectionComponent.d.ts +3 -1
- package/build/types/domain/components/collectionComponent/CollectionComponent.d.ts.map +1 -1
- package/build/types/domain/components/collectionComponent/types.d.ts +1 -0
- package/build/types/domain/components/collectionComponent/types.d.ts.map +1 -1
- package/build/types/domain/features/eventNames.d.ts +1 -1
- package/build/types/domain/features/eventNames.d.ts.map +1 -1
- package/build/types/domain/features/validation/date-availability.d.ts +5 -0
- package/build/types/domain/features/validation/date-availability.d.ts.map +1 -0
- package/build/types/domain/features/validation/spec-utils.d.ts.map +1 -1
- package/build/types/domain/features/validation/value-checks.d.ts +4 -3
- package/build/types/domain/features/validation/value-checks.d.ts.map +1 -1
- package/build/types/domain/mappers/layout/collectionLayoutToComponent.d.ts.map +1 -1
- package/build/types/domain/mappers/mapSchemaToComponent.d.ts.map +1 -1
- package/build/types/domain/mappers/schema/dateSchemaToComponent.d.ts +6 -0
- package/build/types/domain/mappers/schema/dateSchemaToComponent.d.ts.map +1 -0
- package/build/types/domain/mappers/schema/persistAsyncSchemaToComponent.d.ts +1 -0
- package/build/types/domain/mappers/schema/persistAsyncSchemaToComponent.d.ts.map +1 -1
- package/build/types/domain/mappers/schema/stringSchemaToComponent/stringSchemaToComponent.d.ts.map +1 -1
- package/build/types/domain/mappers/types.d.ts +1 -0
- package/build/types/domain/mappers/types.d.ts.map +1 -1
- package/build/types/domain/mappers/utils/suggestions-utils.d.ts +2 -2
- package/build/types/domain/mappers/utils/suggestions-utils.d.ts.map +1 -1
- package/build/types/utils/type-utils.d.ts +3 -2
- package/build/types/utils/type-utils.d.ts.map +1 -1
- package/build/types/utils/type-validators.d.ts +1 -1
- package/build/types/utils/type-validators.d.ts.map +1 -1
- package/package.json +27 -27
- package/build/types/domain/mappers/schema/stringSchemaToComponent/stringSchemaToDateInputComponent.d.ts +0 -6
- package/build/types/domain/mappers/schema/stringSchemaToComponent/stringSchemaToDateInputComponent.d.ts.map +0 -1
package/build/main.js
CHANGED
|
@@ -107,7 +107,7 @@ var cs_default = {
|
|
|
107
107
|
"dynamicFlows.ControlFeedback.minimum": "Zadejte \u010D\xEDslo, kter\xE9 je {minimum} nebo vy\u0161\u0161\xED.",
|
|
108
108
|
"dynamicFlows.ControlFeedback.minimumDate": "Zadejte datum, kter\xE9 je {minimum} nebo potom.",
|
|
109
109
|
"dynamicFlows.ControlFeedback.pattern": "Zadejte to pros\xEDm ve spr\xE1vn\xE9m form\xE1tu.",
|
|
110
|
-
"dynamicFlows.ControlFeedback.patternDate": "Zadejte
|
|
110
|
+
"dynamicFlows.ControlFeedback.patternDate": "Zadejte datum ve spr\xE1vn\xE9m form\xE1tu.",
|
|
111
111
|
"dynamicFlows.ControlFeedback.required": "Vypl\u0148te pros\xEDm toto pole.",
|
|
112
112
|
"dynamicFlows.ControlFeedback.type": "Nespr\xE1vn\xFD typ",
|
|
113
113
|
"dynamicFlows.DownloadFeedback.failed": "Stahov\xE1n\xED se nezda\u0159ilo",
|
|
@@ -187,7 +187,7 @@ var en_default = {
|
|
|
187
187
|
"dynamicFlows.ControlFeedback.minimum": "Please enter a number that's {minimum} or more.",
|
|
188
188
|
"dynamicFlows.ControlFeedback.minimumDate": "Please enter a date that's on or after {minimum}.",
|
|
189
189
|
"dynamicFlows.ControlFeedback.pattern": "Please enter this in the correct format.",
|
|
190
|
-
"dynamicFlows.ControlFeedback.patternDate": "Please enter a date in the
|
|
190
|
+
"dynamicFlows.ControlFeedback.patternDate": "Please enter a date in the correct format.",
|
|
191
191
|
"dynamicFlows.ControlFeedback.required": "Please fill out this field.",
|
|
192
192
|
"dynamicFlows.ControlFeedback.type": "Incorrect type",
|
|
193
193
|
"dynamicFlows.DownloadFeedback.failed": "Download failed",
|
|
@@ -227,7 +227,7 @@ var es_default = {
|
|
|
227
227
|
"dynamicFlows.ControlFeedback.minimum": "Introduce una cifra igual o inferior a {minimum}.",
|
|
228
228
|
"dynamicFlows.ControlFeedback.minimumDate": "Introduce una fecha que sea igual o posterior al {minimum}.",
|
|
229
229
|
"dynamicFlows.ControlFeedback.pattern": "Utiliza el formato correcto.",
|
|
230
|
-
"dynamicFlows.ControlFeedback.patternDate": "Introduce la fecha en
|
|
230
|
+
"dynamicFlows.ControlFeedback.patternDate": "Introduce la fecha en el formato correcto.",
|
|
231
231
|
"dynamicFlows.ControlFeedback.required": "Completa este campo.",
|
|
232
232
|
"dynamicFlows.ControlFeedback.type": "Tipo incorrecto",
|
|
233
233
|
"dynamicFlows.DownloadFeedback.failed": "Descarga fallida",
|
|
@@ -347,7 +347,7 @@ var id_default = {
|
|
|
347
347
|
"dynamicFlows.ControlFeedback.minimum": "Harap masukkan angka paling kecil {minimum} atau lebih dari itu.",
|
|
348
348
|
"dynamicFlows.ControlFeedback.minimumDate": "Harap masukkan tanggal pada atau setelah {minimum}.",
|
|
349
349
|
"dynamicFlows.ControlFeedback.pattern": "Mohon masukkan ini dalam format yang benar.",
|
|
350
|
-
"dynamicFlows.ControlFeedback.patternDate": "
|
|
350
|
+
"dynamicFlows.ControlFeedback.patternDate": "Mohon masukkan tanggal dengan format yang benar.",
|
|
351
351
|
"dynamicFlows.ControlFeedback.required": "Harap isi kolom ini.",
|
|
352
352
|
"dynamicFlows.ControlFeedback.type": "Tipe salah",
|
|
353
353
|
"dynamicFlows.DownloadFeedback.failed": "Pengunduhan gagal",
|
|
@@ -467,7 +467,7 @@ var nl_default = {
|
|
|
467
467
|
"dynamicFlows.ControlFeedback.minimum": "Voer een getal in dat {minimum} of hoger is.",
|
|
468
468
|
"dynamicFlows.ControlFeedback.minimumDate": "Voer een datum in die op of na {minimum} is.",
|
|
469
469
|
"dynamicFlows.ControlFeedback.pattern": "Voer dit in de juiste indeling in.",
|
|
470
|
-
"dynamicFlows.ControlFeedback.patternDate": "Voer een datum in de juiste
|
|
470
|
+
"dynamicFlows.ControlFeedback.patternDate": "Voer een datum in met de juiste notatie.",
|
|
471
471
|
"dynamicFlows.ControlFeedback.required": "Vul dit veld in.",
|
|
472
472
|
"dynamicFlows.ControlFeedback.type": "Onjuist type",
|
|
473
473
|
"dynamicFlows.DownloadFeedback.failed": "Downloaden mislukt",
|
|
@@ -667,7 +667,7 @@ var th_default = {
|
|
|
667
667
|
"dynamicFlows.ControlFeedback.minimum": "\u0E42\u0E1B\u0E23\u0E14\u0E1B\u0E49\u0E2D\u0E19\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02 {minimum} \u0E2B\u0E23\u0E37\u0E2D\u0E21\u0E32\u0E01\u0E01\u0E27\u0E48\u0E32",
|
|
668
668
|
"dynamicFlows.ControlFeedback.minimumDate": "\u0E42\u0E1B\u0E23\u0E14\u0E43\u0E2A\u0E48\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E40\u0E1B\u0E47\u0E19 {minimum} \u0E2B\u0E23\u0E37\u0E2D\u0E2B\u0E25\u0E31\u0E07\u0E08\u0E32\u0E01\u0E19\u0E31\u0E49\u0E19",
|
|
669
669
|
"dynamicFlows.ControlFeedback.pattern": "\u0E42\u0E1B\u0E23\u0E14\u0E43\u0E2A\u0E48\u0E43\u0E19\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07",
|
|
670
|
-
"dynamicFlows.ControlFeedback.patternDate": "\u0E42\u0E1B\u0E23\u0E14\
|
|
670
|
+
"dynamicFlows.ControlFeedback.patternDate": "\u0E42\u0E1B\u0E23\u0E14\u0E43\u0E2A\u0E48\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E43\u0E19\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E17\u0E35\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07",
|
|
671
671
|
"dynamicFlows.ControlFeedback.required": "\u0E42\u0E1B\u0E23\u0E14\u0E43\u0E2A\u0E48\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E43\u0E19\u0E0A\u0E48\u0E2D\u0E07\u0E19\u0E35\u0E49",
|
|
672
672
|
"dynamicFlows.ControlFeedback.type": "\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07",
|
|
673
673
|
"dynamicFlows.DownloadFeedback.failed": "\u0E14\u0E32\u0E27\u0E19\u0E4C\u0E42\u0E2B\u0E25\u0E14\u0E25\u0E49\u0E21\u0E40\u0E2B\u0E25\u0E27",
|
|
@@ -747,7 +747,7 @@ var zh_CN_default = {
|
|
|
747
747
|
"dynamicFlows.ControlFeedback.minimum": "\u8BF7\u8F93\u5165\u4E00\u4E2A\u5927\u4E8E\u6216\u7B49\u4E8E {minimum} \u7684\u6570\u5B57",
|
|
748
748
|
"dynamicFlows.ControlFeedback.minimumDate": "\u8BF7\u8F93\u5165 {minimum} \u6216\u4E4B\u540E\u7684\u65E5\u671F",
|
|
749
749
|
"dynamicFlows.ControlFeedback.pattern": "\u8BF7\u4EE5\u6B63\u786E\u7684\u683C\u5F0F\u8F93\u5165",
|
|
750
|
-
"dynamicFlows.ControlFeedback.patternDate": "\u8BF7\u4EE5\u6B63\u786E\u7684\u683C\u5F0F\u8F93\u5165\u65E5\u671F",
|
|
750
|
+
"dynamicFlows.ControlFeedback.patternDate": "\u8BF7\u4EE5\u6B63\u786E\u7684\u683C\u5F0F\u8F93\u5165\u65E5\u671F\u3002",
|
|
751
751
|
"dynamicFlows.ControlFeedback.required": "\u8BF7\u586B\u5199\u6B64\u5B57\u6BB5\u3002",
|
|
752
752
|
"dynamicFlows.ControlFeedback.type": "\u7C7B\u578B\u9519\u8BEF",
|
|
753
753
|
"dynamicFlows.DownloadFeedback.failed": "\u4E0B\u8F7D\u5931\u8D25",
|
|
@@ -787,7 +787,7 @@ var zh_HK_default = {
|
|
|
787
787
|
"dynamicFlows.ControlFeedback.minimum": "\u8ACB\u8F38\u5165\u4E00\u500B\u5927\u65BC\u6216\u7B49\u65BC{minimum}\u7684\u6578\u5B57\u3002",
|
|
788
788
|
"dynamicFlows.ControlFeedback.minimumDate": "\u8ACB\u8F38\u5165{minimum}\u6216\u4E4B\u5F8C\u7684\u65E5\u671F\u3002",
|
|
789
789
|
"dynamicFlows.ControlFeedback.pattern": "\u8ACB\u4EE5\u6B63\u78BA\u683C\u5F0F\u8F38\u5165\u5185\u5BB9\u3002",
|
|
790
|
-
"dynamicFlows.ControlFeedback.patternDate": "\u8ACB\u4EE5\u6B63\u78BA\u683C\u5F0F\u8F38\u5165\u65E5\u671F\u3002",
|
|
790
|
+
"dynamicFlows.ControlFeedback.patternDate": "\u8ACB\u4EE5\u6B63\u78BA\u7684\u683C\u5F0F\u8F38\u5165\u65E5\u671F\u3002",
|
|
791
791
|
"dynamicFlows.ControlFeedback.required": "\u8ACB\u586B\u5BEB\u6B64\u6B04\u4F4D\u3002",
|
|
792
792
|
"dynamicFlows.ControlFeedback.type": "\u932F\u8AA4\u7684\u985E\u578B",
|
|
793
793
|
"dynamicFlows.DownloadFeedback.failed": "\u4E0B\u8F09\u5931\u6557",
|
|
@@ -1651,17 +1651,58 @@ var debounce = (callback, waitMs) => {
|
|
|
1651
1651
|
return debouncedFn;
|
|
1652
1652
|
};
|
|
1653
1653
|
|
|
1654
|
+
// src/utils/recursiveMerge.ts
|
|
1655
|
+
function recursiveMerge(valueA, valueB) {
|
|
1656
|
+
if (valueA === null) {
|
|
1657
|
+
return valueB;
|
|
1658
|
+
}
|
|
1659
|
+
if (valueB === null) {
|
|
1660
|
+
return valueA;
|
|
1661
|
+
}
|
|
1662
|
+
if (isObject2(valueA) && isObject2(valueB)) {
|
|
1663
|
+
return mergeObjects(valueA, valueB);
|
|
1664
|
+
}
|
|
1665
|
+
if (Array.isArray(valueA) && Array.isArray(valueB)) {
|
|
1666
|
+
return mergeArrays(valueA, valueB);
|
|
1667
|
+
}
|
|
1668
|
+
return valueB;
|
|
1669
|
+
}
|
|
1670
|
+
function isObject2(value) {
|
|
1671
|
+
return value != null && typeof value === "object" && !Array.isArray(value) && !(value instanceof File);
|
|
1672
|
+
}
|
|
1673
|
+
function mergeObjects(valueA, valueB) {
|
|
1674
|
+
const allKeys = /* @__PURE__ */ new Set([...Object.keys(valueA), ...Object.keys(valueB)]);
|
|
1675
|
+
const entries = Array.from(allKeys).map((key) => {
|
|
1676
|
+
var _a, _b;
|
|
1677
|
+
const value = recursiveMerge((_a = valueA[key]) != null ? _a : null, (_b = valueB[key]) != null ? _b : null);
|
|
1678
|
+
return [key, value];
|
|
1679
|
+
});
|
|
1680
|
+
return Object.fromEntries(entries);
|
|
1681
|
+
}
|
|
1682
|
+
function mergeArrays(valueA, valueB) {
|
|
1683
|
+
const length = Math.max(valueA.length, valueB.length);
|
|
1684
|
+
return Array.from(
|
|
1685
|
+
{ length },
|
|
1686
|
+
(_, index) => {
|
|
1687
|
+
var _a, _b;
|
|
1688
|
+
return recursiveMerge((_a = valueA[index]) != null ? _a : null, (_b = valueB[index]) != null ? _b : null);
|
|
1689
|
+
}
|
|
1690
|
+
);
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1654
1693
|
// src/domain/components/collectionComponent/CollectionComponent.ts
|
|
1655
1694
|
var DEBOUNCE_TIME = 800;
|
|
1656
|
-
var createCollectionComponent = (props, onComponentUpdate, queryFunction) => {
|
|
1695
|
+
var createCollectionComponent = (props, onComponentUpdate, queryFunction, trackEvent) => {
|
|
1657
1696
|
const { uid, analyticsId, control, margin, tags, state } = props;
|
|
1658
1697
|
const update = getInputUpdateFunction(onComponentUpdate);
|
|
1659
1698
|
let abortController = new AbortController();
|
|
1660
|
-
const
|
|
1699
|
+
const trackCollectionEvent = (source, status) => trackEvent(getEventName(source, status), component.state.analytics);
|
|
1700
|
+
const query = (mode, source) => {
|
|
1661
1701
|
var _a, _b;
|
|
1662
1702
|
abortController.abort();
|
|
1663
1703
|
abortController = new AbortController();
|
|
1664
1704
|
const { signal } = abortController;
|
|
1705
|
+
trackCollectionEvent(source != null ? source : mode, "Triggered");
|
|
1665
1706
|
queryFunction({
|
|
1666
1707
|
searchParam: (_a = component.state.search) == null ? void 0 : _a.param,
|
|
1667
1708
|
query: (_b = component.state.search) == null ? void 0 : _b.query,
|
|
@@ -1673,27 +1714,20 @@ var createCollectionComponent = (props, onComponentUpdate, queryFunction) => {
|
|
|
1673
1714
|
return;
|
|
1674
1715
|
}
|
|
1675
1716
|
update(component, (draft) => {
|
|
1676
|
-
|
|
1677
|
-
draft.state = {
|
|
1678
|
-
sections: mode === "pagination" ? mergeSections(component.state.sections, response.sections) : response.sections,
|
|
1679
|
-
nextCursor: response.nextCursor,
|
|
1680
|
-
filters: response.filters ? mapFilters(response.filters) : component.state.filters,
|
|
1681
|
-
search: response.search ? mapSearch(response.search) : component.state.search,
|
|
1682
|
-
beforeSections: (_a2 = response.beforeSections) != null ? _a2 : component.state.beforeSections,
|
|
1683
|
-
afterSections: (_b2 = response.afterSections) != null ? _b2 : component.state.afterSections
|
|
1684
|
-
};
|
|
1717
|
+
draft.state = mergeState(mode, component.state, response);
|
|
1685
1718
|
draft.status = {
|
|
1686
1719
|
type: "idle",
|
|
1687
1720
|
loadMore: response.nextCursor ? paginate : void 0
|
|
1688
1721
|
};
|
|
1689
1722
|
});
|
|
1723
|
+
trackCollectionEvent(source != null ? source : mode, "Succeeded");
|
|
1690
1724
|
}).catch(() => {
|
|
1691
1725
|
if (!signal.aborted) {
|
|
1692
1726
|
const retry = () => {
|
|
1693
1727
|
update(component, (draft) => {
|
|
1694
1728
|
draft.status = { type: "loading", reason: mode };
|
|
1695
1729
|
});
|
|
1696
|
-
query(mode);
|
|
1730
|
+
query(mode, source);
|
|
1697
1731
|
};
|
|
1698
1732
|
update(component, (draft) => {
|
|
1699
1733
|
if (mode === "search") {
|
|
@@ -1701,6 +1735,7 @@ var createCollectionComponent = (props, onComponentUpdate, queryFunction) => {
|
|
|
1701
1735
|
}
|
|
1702
1736
|
draft.status = { type: "error", reason: mode, retry };
|
|
1703
1737
|
});
|
|
1738
|
+
trackCollectionEvent(source != null ? source : mode, "Failed");
|
|
1704
1739
|
}
|
|
1705
1740
|
});
|
|
1706
1741
|
};
|
|
@@ -1710,10 +1745,22 @@ var createCollectionComponent = (props, onComponentUpdate, queryFunction) => {
|
|
|
1710
1745
|
debouncedQuery("search");
|
|
1711
1746
|
};
|
|
1712
1747
|
const filter = () => {
|
|
1713
|
-
debouncedQuery("search");
|
|
1748
|
+
debouncedQuery("search", "filter");
|
|
1714
1749
|
debouncedQuery.flush();
|
|
1715
1750
|
};
|
|
1716
1751
|
const paginate = () => query("pagination");
|
|
1752
|
+
const mergeState = (mode, original, incoming) => {
|
|
1753
|
+
var _a, _b;
|
|
1754
|
+
return {
|
|
1755
|
+
sections: mode === "pagination" ? mergeSections(original.sections, incoming.sections) : incoming.sections,
|
|
1756
|
+
nextCursor: incoming.nextCursor,
|
|
1757
|
+
filters: incoming.filters ? mapFilters(incoming.filters) : original.filters,
|
|
1758
|
+
search: incoming.search ? mapSearch(incoming.search) : original.search,
|
|
1759
|
+
beforeSections: (_a = incoming.beforeSections) != null ? _a : original.beforeSections,
|
|
1760
|
+
afterSections: (_b = incoming.afterSections) != null ? _b : original.afterSections,
|
|
1761
|
+
analytics: mode === "pagination" ? recursiveMerge(original.analytics, incoming.analytics) : incoming.analytics
|
|
1762
|
+
};
|
|
1763
|
+
};
|
|
1717
1764
|
const selectFilter = (filterIndex, optionIndex) => {
|
|
1718
1765
|
var _a;
|
|
1719
1766
|
const selected = (_a = component.state.filters) == null ? void 0 : _a[filterIndex];
|
|
@@ -1799,6 +1846,19 @@ var mergeSections = (existing, incoming) => {
|
|
|
1799
1846
|
});
|
|
1800
1847
|
return [...merged, ...newSections];
|
|
1801
1848
|
};
|
|
1849
|
+
var getEventName = (mode, state) => {
|
|
1850
|
+
const getMode = () => {
|
|
1851
|
+
switch (mode) {
|
|
1852
|
+
case "pagination":
|
|
1853
|
+
return "Pagination";
|
|
1854
|
+
case "search":
|
|
1855
|
+
return "Search";
|
|
1856
|
+
case "filter":
|
|
1857
|
+
return "Filter";
|
|
1858
|
+
}
|
|
1859
|
+
};
|
|
1860
|
+
return `Collection ${getMode()} ${state}`;
|
|
1861
|
+
};
|
|
1802
1862
|
|
|
1803
1863
|
// src/domain/features/collection/getPerformCollectionQuery.ts
|
|
1804
1864
|
var getPerformCollectionQuery = (httpClient, baseRequest, mapState) => {
|
|
@@ -1892,7 +1952,7 @@ var hashRequest = ({
|
|
|
1892
1952
|
|
|
1893
1953
|
// src/domain/mappers/layout/collectionLayoutToComponent.ts
|
|
1894
1954
|
var collectionLayoutToComponent = (uid, { analyticsId, control, initialState, margin, search, tags, baseRequest }, mapperProps) => {
|
|
1895
|
-
const { httpClient, onComponentUpdate } = mapperProps;
|
|
1955
|
+
const { httpClient, onComponentUpdate, trackEvent } = mapperProps;
|
|
1896
1956
|
const mapLayout = (layout, index) => mapLayoutToComponent(`${uid}-collection-response-${index}`, layout, mapperProps, []);
|
|
1897
1957
|
const mapState = (state) => mapCollectionSpecToDomainState(state, mapperProps, mapLayout);
|
|
1898
1958
|
const queryFunction = getPerformCollectionQuery(httpClient, baseRequest, mapState);
|
|
@@ -1907,12 +1967,20 @@ var collectionLayoutToComponent = (uid, { analyticsId, control, initialState, ma
|
|
|
1907
1967
|
search
|
|
1908
1968
|
},
|
|
1909
1969
|
onComponentUpdate,
|
|
1910
|
-
queryFunction
|
|
1970
|
+
queryFunction,
|
|
1971
|
+
trackEvent
|
|
1911
1972
|
);
|
|
1912
1973
|
return component;
|
|
1913
1974
|
};
|
|
1914
1975
|
var mapCollectionSpecToDomainState = (specState, mapperProps, mapLayout) => {
|
|
1915
|
-
const {
|
|
1976
|
+
const {
|
|
1977
|
+
sections,
|
|
1978
|
+
filters,
|
|
1979
|
+
beforeSections,
|
|
1980
|
+
afterSections,
|
|
1981
|
+
nextCursor,
|
|
1982
|
+
analytics = {}
|
|
1983
|
+
} = specState;
|
|
1916
1984
|
return {
|
|
1917
1985
|
sections: sections.map((section) => {
|
|
1918
1986
|
var _a;
|
|
@@ -1940,7 +2008,8 @@ var mapCollectionSpecToDomainState = (specState, mapperProps, mapLayout) => {
|
|
|
1940
2008
|
filters: filters == null ? void 0 : filters.map(mapFilter),
|
|
1941
2009
|
beforeSections: beforeSections == null ? void 0 : beforeSections.map(mapLayout),
|
|
1942
2010
|
afterSections: afterSections == null ? void 0 : afterSections.map(mapLayout),
|
|
1943
|
-
nextCursor
|
|
2011
|
+
nextCursor,
|
|
2012
|
+
analytics
|
|
1944
2013
|
};
|
|
1945
2014
|
};
|
|
1946
2015
|
var mapFilter = (filter) => {
|
|
@@ -3012,45 +3081,6 @@ var createExternalConfirmation = (uid, url, onLink, onComponentUpdate) => {
|
|
|
3012
3081
|
return component;
|
|
3013
3082
|
};
|
|
3014
3083
|
|
|
3015
|
-
// src/utils/recursiveMerge.ts
|
|
3016
|
-
function recursiveMerge(valueA, valueB) {
|
|
3017
|
-
if (valueA === null) {
|
|
3018
|
-
return valueB;
|
|
3019
|
-
}
|
|
3020
|
-
if (valueB === null) {
|
|
3021
|
-
return valueA;
|
|
3022
|
-
}
|
|
3023
|
-
if (isObject2(valueA) && isObject2(valueB)) {
|
|
3024
|
-
return mergeObjects(valueA, valueB);
|
|
3025
|
-
}
|
|
3026
|
-
if (Array.isArray(valueA) && Array.isArray(valueB)) {
|
|
3027
|
-
return mergeArrays(valueA, valueB);
|
|
3028
|
-
}
|
|
3029
|
-
return valueB;
|
|
3030
|
-
}
|
|
3031
|
-
function isObject2(value) {
|
|
3032
|
-
return value != null && typeof value === "object" && !Array.isArray(value) && !(value instanceof File);
|
|
3033
|
-
}
|
|
3034
|
-
function mergeObjects(valueA, valueB) {
|
|
3035
|
-
const allKeys = /* @__PURE__ */ new Set([...Object.keys(valueA), ...Object.keys(valueB)]);
|
|
3036
|
-
const entries = Array.from(allKeys).map((key) => {
|
|
3037
|
-
var _a, _b;
|
|
3038
|
-
const value = recursiveMerge((_a = valueA[key]) != null ? _a : null, (_b = valueB[key]) != null ? _b : null);
|
|
3039
|
-
return [key, value];
|
|
3040
|
-
});
|
|
3041
|
-
return Object.fromEntries(entries);
|
|
3042
|
-
}
|
|
3043
|
-
function mergeArrays(valueA, valueB) {
|
|
3044
|
-
const length = Math.max(valueA.length, valueB.length);
|
|
3045
|
-
return Array.from(
|
|
3046
|
-
{ length },
|
|
3047
|
-
(_, index) => {
|
|
3048
|
-
var _a, _b;
|
|
3049
|
-
return recursiveMerge((_a = valueA[index]) != null ? _a : null, (_b = valueB[index]) != null ? _b : null);
|
|
3050
|
-
}
|
|
3051
|
-
);
|
|
3052
|
-
}
|
|
3053
|
-
|
|
3054
3084
|
// src/utils/component-utils.ts
|
|
3055
3085
|
var getSubmittableData = async (components) => Promise.all(components.map(async (component) => component.getSubmittableValue())).then(
|
|
3056
3086
|
(values) => values.reduce((acc, value) => recursiveMerge(acc, value), null)
|
|
@@ -3919,7 +3949,9 @@ var getBehaviorFromSchemaOnChange = (schema) => {
|
|
|
3919
3949
|
var getBehaviorFromSchemaRefreshStepOnChange = (schema) => {
|
|
3920
3950
|
var _a, _b, _c;
|
|
3921
3951
|
if ("refreshStepOnChange" in schema && ((_a = schema.refreshStepOnChange) != null ? _a : false) || "refreshFormOnChange" in schema && ((_b = schema.refreshFormOnChange) != null ? _b : false)) {
|
|
3922
|
-
const { $id, analyticsId
|
|
3952
|
+
const { $id, analyticsId } = schema;
|
|
3953
|
+
const refreshUrl = "refreshUrl" in schema ? schema.refreshUrl : void 0;
|
|
3954
|
+
const refreshFormUrl = "refreshFormUrl" in schema ? schema.refreshFormUrl : void 0;
|
|
3923
3955
|
const behavior = {
|
|
3924
3956
|
type: "refresh",
|
|
3925
3957
|
analytics: { schema: (_c = analyticsId != null ? analyticsId : $id) != null ? _c : "" },
|
|
@@ -3931,6 +3963,65 @@ var getBehaviorFromSchemaRefreshStepOnChange = (schema) => {
|
|
|
3931
3963
|
return void 0;
|
|
3932
3964
|
};
|
|
3933
3965
|
|
|
3966
|
+
// src/domain/features/validation/date-availability.ts
|
|
3967
|
+
var WEEKDAYS = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
|
|
3968
|
+
var normaliseDateAvailability = (availability, logEvent) => {
|
|
3969
|
+
if (!availability) {
|
|
3970
|
+
return void 0;
|
|
3971
|
+
}
|
|
3972
|
+
const unavailable = availability.unavailable.flatMap((rule) => {
|
|
3973
|
+
if (rule.type === "weekdays") {
|
|
3974
|
+
return [rule];
|
|
3975
|
+
}
|
|
3976
|
+
if (rule.type === "dates") {
|
|
3977
|
+
const dates = rule.dates.filter((date) => {
|
|
3978
|
+
const valid = isCanonicalDate(date);
|
|
3979
|
+
if (!valid) {
|
|
3980
|
+
logInvalidRule(date, logEvent);
|
|
3981
|
+
}
|
|
3982
|
+
return valid;
|
|
3983
|
+
});
|
|
3984
|
+
return dates.length > 0 ? [__spreadProps(__spreadValues({}, rule), { dates })] : [];
|
|
3985
|
+
}
|
|
3986
|
+
if (!isCanonicalDate(rule.start) || !isCanonicalDate(rule.end) || rule.start > rule.end) {
|
|
3987
|
+
logInvalidRule(`${rule.start}/${rule.end}`, logEvent);
|
|
3988
|
+
return [];
|
|
3989
|
+
}
|
|
3990
|
+
return [rule];
|
|
3991
|
+
});
|
|
3992
|
+
return __spreadProps(__spreadValues({}, availability), { unavailable });
|
|
3993
|
+
};
|
|
3994
|
+
var getUnavailableDateReason = (date, availability) => {
|
|
3995
|
+
var _a, _b;
|
|
3996
|
+
return (_b = (_a = availability == null ? void 0 : availability.unavailable.find((rule) => matchesDateRule(date, rule))) == null ? void 0 : _a.reason) != null ? _b : null;
|
|
3997
|
+
};
|
|
3998
|
+
var matchesDateRule = (date, rule) => {
|
|
3999
|
+
switch (rule.type) {
|
|
4000
|
+
case "dates":
|
|
4001
|
+
return rule.dates.includes(date);
|
|
4002
|
+
case "weekdays": {
|
|
4003
|
+
const weekday = WEEKDAYS[(/* @__PURE__ */ new Date(`${date}T00:00:00Z`)).getUTCDay()];
|
|
4004
|
+
return rule.weekdays.includes(weekday);
|
|
4005
|
+
}
|
|
4006
|
+
case "range":
|
|
4007
|
+
return date >= rule.start && date <= rule.end;
|
|
4008
|
+
}
|
|
4009
|
+
};
|
|
4010
|
+
var isCanonicalDate = (value) => {
|
|
4011
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
|
|
4012
|
+
if (!match) {
|
|
4013
|
+
return false;
|
|
4014
|
+
}
|
|
4015
|
+
const [, year, month, day] = match.map(Number);
|
|
4016
|
+
const date = /* @__PURE__ */ new Date(0);
|
|
4017
|
+
date.setUTCHours(0, 0, 0, 0);
|
|
4018
|
+
date.setUTCFullYear(year, month - 1, day);
|
|
4019
|
+
return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
|
|
4020
|
+
};
|
|
4021
|
+
var logInvalidRule = (value, logEvent) => {
|
|
4022
|
+
logEvent("warning", "Ignoring invalid date availability rule value", { value });
|
|
4023
|
+
};
|
|
4024
|
+
|
|
3934
4025
|
// src/domain/features/validation/getPatternRegExp.ts
|
|
3935
4026
|
var getPatternRegExp = (pattern, logEvent) => {
|
|
3936
4027
|
if (!pattern) {
|
|
@@ -4035,13 +4126,13 @@ var getBelowMinimumMoneyAmountCheck = ({ minimum }, messageFunctions) => (value)
|
|
|
4035
4126
|
return null;
|
|
4036
4127
|
};
|
|
4037
4128
|
var getAboveMaximumDateCheck = ({ maximum }, messageFunctions) => (value) => {
|
|
4038
|
-
if (isString(maximum) &&
|
|
4129
|
+
if (isString(maximum) && isValidDate(value) && value > maximum) {
|
|
4039
4130
|
return messageFunctions.maximumDate(maximum);
|
|
4040
4131
|
}
|
|
4041
4132
|
return null;
|
|
4042
4133
|
};
|
|
4043
4134
|
var getBelowMinimumDateCheck = ({ minimum }, messageFunctions) => (value) => {
|
|
4044
|
-
if (isString(minimum) &&
|
|
4135
|
+
if (isString(minimum) && isValidDate(value) && value < minimum) {
|
|
4045
4136
|
return messageFunctions.minimumDate(minimum);
|
|
4046
4137
|
}
|
|
4047
4138
|
return null;
|
|
@@ -4071,11 +4162,12 @@ var getStringRequiredCheck = (required, messageFunctions) => (value) => {
|
|
|
4071
4162
|
return isNullish(value) || value === "" ? messageFunctions.required() : null;
|
|
4072
4163
|
};
|
|
4073
4164
|
var getValidDateCheck = (required, messageFunctions) => (value) => {
|
|
4074
|
-
if (required && !isValidDate(value)) {
|
|
4075
|
-
return messageFunctions.
|
|
4165
|
+
if (required && value && !isValidDate(value)) {
|
|
4166
|
+
return messageFunctions.invalidDate();
|
|
4076
4167
|
}
|
|
4077
4168
|
return null;
|
|
4078
4169
|
};
|
|
4170
|
+
var getUnavailableDateCheck = ({ availability }) => (value) => isValidDate(value) ? getUnavailableDateReason(value, availability) : null;
|
|
4079
4171
|
|
|
4080
4172
|
// src/domain/mappers/utils/getAutocompleteString.ts
|
|
4081
4173
|
var getAutocompleteString = (hints) => {
|
|
@@ -4379,6 +4471,7 @@ var isAllOfSchema = (schema) => "allOf" in schema && !isNullish(schema.allOf);
|
|
|
4379
4471
|
var isBooleanSchema = (schema) => "type" in schema && schema.type === "boolean";
|
|
4380
4472
|
var isBlobSchema = (schema) => "type" in schema && schema.type === "blob";
|
|
4381
4473
|
var isConstSchema = (schema) => "const" in schema && schema.const !== void 0;
|
|
4474
|
+
var isDateSchema = (schema) => "type" in schema && schema.type === "date";
|
|
4382
4475
|
var isIntegerSchema = (schema) => "type" in schema && schema.type === "integer";
|
|
4383
4476
|
var isNumberSchema = (schema) => "type" in schema && schema.type === "number";
|
|
4384
4477
|
var isObjectSchema = (schema) => "type" in schema && schema.type === "object";
|
|
@@ -5521,6 +5614,177 @@ var getConstLayout = (uid, mapperProps, layout, alert) => {
|
|
|
5521
5614
|
);
|
|
5522
5615
|
};
|
|
5523
5616
|
|
|
5617
|
+
// src/domain/components/DateInputComponent.ts
|
|
5618
|
+
var createDateInputComponent = (props, onComponentUpdate) => {
|
|
5619
|
+
const _a = props, {
|
|
5620
|
+
uid,
|
|
5621
|
+
id,
|
|
5622
|
+
checks,
|
|
5623
|
+
schemaOnChange,
|
|
5624
|
+
performValidationAsync,
|
|
5625
|
+
onValueChange,
|
|
5626
|
+
onPersistAsync,
|
|
5627
|
+
summariser,
|
|
5628
|
+
value
|
|
5629
|
+
} = _a, rest = __objRest(_a, [
|
|
5630
|
+
"uid",
|
|
5631
|
+
"id",
|
|
5632
|
+
"checks",
|
|
5633
|
+
"schemaOnChange",
|
|
5634
|
+
"performValidationAsync",
|
|
5635
|
+
"onValueChange",
|
|
5636
|
+
"onPersistAsync",
|
|
5637
|
+
"summariser",
|
|
5638
|
+
"value"
|
|
5639
|
+
]);
|
|
5640
|
+
const update = getInputUpdateFunction(onComponentUpdate);
|
|
5641
|
+
const getValidationErrors = getLocalValueValidator(checks);
|
|
5642
|
+
const validateAsync = performValidationAsync ? getComponentValidationAsync(update, performValidationAsync) : void 0;
|
|
5643
|
+
const component = __spreadValues({
|
|
5644
|
+
type: "date",
|
|
5645
|
+
kind: "input",
|
|
5646
|
+
uid,
|
|
5647
|
+
id,
|
|
5648
|
+
value,
|
|
5649
|
+
onBlur() {
|
|
5650
|
+
const isValid = component.validate();
|
|
5651
|
+
if (isValid) {
|
|
5652
|
+
validateAsync == null ? void 0 : validateAsync(component, component.getLocalValue()).catch(() => {
|
|
5653
|
+
});
|
|
5654
|
+
}
|
|
5655
|
+
},
|
|
5656
|
+
onFocus() {
|
|
5657
|
+
},
|
|
5658
|
+
// Noop
|
|
5659
|
+
setValue(updatedValue) {
|
|
5660
|
+
const prevValue = component.value;
|
|
5661
|
+
update(component, (draft) => {
|
|
5662
|
+
draft.errors = [];
|
|
5663
|
+
draft.validationAsyncState.messages = {};
|
|
5664
|
+
draft.value = updatedValue;
|
|
5665
|
+
});
|
|
5666
|
+
if (isOrWasValid(getValidationErrors, prevValue, updatedValue)) {
|
|
5667
|
+
void (schemaOnChange == null ? void 0 : schemaOnChange());
|
|
5668
|
+
}
|
|
5669
|
+
onValueChange();
|
|
5670
|
+
if (getValidationErrors(updatedValue).length === 0) {
|
|
5671
|
+
void (onPersistAsync == null ? void 0 : onPersistAsync().catch(() => {
|
|
5672
|
+
}));
|
|
5673
|
+
}
|
|
5674
|
+
},
|
|
5675
|
+
async getSubmittableValue() {
|
|
5676
|
+
return component.getSubmittableValueSync();
|
|
5677
|
+
},
|
|
5678
|
+
getSubmittableValueSync() {
|
|
5679
|
+
if (isValidDate(component.getLocalValue())) {
|
|
5680
|
+
return component.getLocalValue();
|
|
5681
|
+
}
|
|
5682
|
+
return null;
|
|
5683
|
+
},
|
|
5684
|
+
getSummary() {
|
|
5685
|
+
return summariser(component.getLocalValue());
|
|
5686
|
+
},
|
|
5687
|
+
getLocalValue() {
|
|
5688
|
+
return component.value;
|
|
5689
|
+
},
|
|
5690
|
+
validate() {
|
|
5691
|
+
const errors = getValidationErrors(component.getLocalValue());
|
|
5692
|
+
update(component, (draft) => {
|
|
5693
|
+
draft.errors = errors;
|
|
5694
|
+
});
|
|
5695
|
+
return errors.length === 0;
|
|
5696
|
+
}
|
|
5697
|
+
}, rest);
|
|
5698
|
+
return component;
|
|
5699
|
+
};
|
|
5700
|
+
|
|
5701
|
+
// src/domain/mappers/utils/suggestions-utils.ts
|
|
5702
|
+
var mapSuggestions = (suggestions, logEvent) => {
|
|
5703
|
+
if (!suggestions) return void 0;
|
|
5704
|
+
return {
|
|
5705
|
+
values: suggestions.values.map((_a) => {
|
|
5706
|
+
var _b = _a, { icon, image, media, value } = _b, rest = __objRest(_b, ["icon", "image", "media", "value"]);
|
|
5707
|
+
if (typeof value !== "string") {
|
|
5708
|
+
logEvent(
|
|
5709
|
+
"warning",
|
|
5710
|
+
`Suggestion values must be of type string. Found ${typeof value} instead.`
|
|
5711
|
+
);
|
|
5712
|
+
}
|
|
5713
|
+
return __spreadProps(__spreadValues({}, rest), {
|
|
5714
|
+
media: getDomainLayerMedia({ icon, image, media }),
|
|
5715
|
+
value,
|
|
5716
|
+
tags: mapTags(rest)
|
|
5717
|
+
});
|
|
5718
|
+
})
|
|
5719
|
+
};
|
|
5720
|
+
};
|
|
5721
|
+
|
|
5722
|
+
// src/domain/mappers/schema/dateSchemaToComponent.ts
|
|
5723
|
+
var dateSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
5724
|
+
var _a;
|
|
5725
|
+
const {
|
|
5726
|
+
schema,
|
|
5727
|
+
localValue,
|
|
5728
|
+
model,
|
|
5729
|
+
required = false,
|
|
5730
|
+
onPersistAsync,
|
|
5731
|
+
onValueChange
|
|
5732
|
+
} = schemaMapperProps;
|
|
5733
|
+
const {
|
|
5734
|
+
autocompleteHint,
|
|
5735
|
+
default: defaultValue,
|
|
5736
|
+
minimum: minimumDate,
|
|
5737
|
+
maximum: maximumDate,
|
|
5738
|
+
suggestions
|
|
5739
|
+
} = schema;
|
|
5740
|
+
const { getErrorMessageFunctions, onComponentUpdate, onBehavior } = mapperProps;
|
|
5741
|
+
const availability = schema.type === "date" ? normaliseDateAvailability(schema.availability, mapperProps.logEvent) : void 0;
|
|
5742
|
+
const errorMessageFunctions = getErrorMessageFunctions(schema.validationMessages);
|
|
5743
|
+
const { performValidationAsync, validationAsyncState } = getValidationAsyncInitialState(
|
|
5744
|
+
schemaMapperProps,
|
|
5745
|
+
mapperProps
|
|
5746
|
+
);
|
|
5747
|
+
const validLocalValue = isString(localValue) ? localValue : null;
|
|
5748
|
+
const value = onPersistAsync ? validLocalValue : (_a = normaliseDateValue(model)) != null ? _a : normaliseDateValue(defaultValue != null ? defaultValue : null);
|
|
5749
|
+
return createDateInputComponent(
|
|
5750
|
+
__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
|
|
5751
|
+
autoComplete: getAutocompleteString(autocompleteHint),
|
|
5752
|
+
availability,
|
|
5753
|
+
checks: schema.hidden ? [] : [
|
|
5754
|
+
getStringRequiredCheck(required, errorMessageFunctions),
|
|
5755
|
+
getValidDateCheck(required, errorMessageFunctions),
|
|
5756
|
+
getAboveMaximumDateCheck(schema, errorMessageFunctions),
|
|
5757
|
+
getBelowMinimumDateCheck(schema, errorMessageFunctions),
|
|
5758
|
+
...schema.type === "date" ? [getUnavailableDateCheck(__spreadProps(__spreadValues({}, schema), { availability }))] : []
|
|
5759
|
+
],
|
|
5760
|
+
minimumDate,
|
|
5761
|
+
maximumDate,
|
|
5762
|
+
suggestions: mapSuggestions(suggestions, mapperProps.logEvent),
|
|
5763
|
+
value,
|
|
5764
|
+
validationAsyncState,
|
|
5765
|
+
schemaOnChange: getSchemaOnChange(schema, onBehavior),
|
|
5766
|
+
performValidationAsync,
|
|
5767
|
+
onValueChange
|
|
5768
|
+
}),
|
|
5769
|
+
onComponentUpdate
|
|
5770
|
+
);
|
|
5771
|
+
};
|
|
5772
|
+
var normaliseDateValue = (value) => {
|
|
5773
|
+
if (!isString(value)) {
|
|
5774
|
+
return null;
|
|
5775
|
+
}
|
|
5776
|
+
if (/^\d{4}-\d{2}$/.test(value)) {
|
|
5777
|
+
return value;
|
|
5778
|
+
}
|
|
5779
|
+
try {
|
|
5780
|
+
const date = new Date(value);
|
|
5781
|
+
const stringDate = date.toISOString();
|
|
5782
|
+
return stringDate.split("T")[0];
|
|
5783
|
+
} catch (e) {
|
|
5784
|
+
return null;
|
|
5785
|
+
}
|
|
5786
|
+
};
|
|
5787
|
+
|
|
5524
5788
|
// src/domain/components/IntegerInputComponent.ts
|
|
5525
5789
|
var createIntegerInputComponent = (props, onComponentUpdate) => {
|
|
5526
5790
|
const _a = props, {
|
|
@@ -6388,175 +6652,6 @@ var persistAsyncSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
|
6388
6652
|
return paComponent;
|
|
6389
6653
|
};
|
|
6390
6654
|
|
|
6391
|
-
// src/domain/components/DateInputComponent.ts
|
|
6392
|
-
var createDateInputComponent = (props, onComponentUpdate) => {
|
|
6393
|
-
const _a = props, {
|
|
6394
|
-
uid,
|
|
6395
|
-
id,
|
|
6396
|
-
checks,
|
|
6397
|
-
schemaOnChange,
|
|
6398
|
-
performValidationAsync,
|
|
6399
|
-
onValueChange,
|
|
6400
|
-
onPersistAsync,
|
|
6401
|
-
summariser,
|
|
6402
|
-
value
|
|
6403
|
-
} = _a, rest = __objRest(_a, [
|
|
6404
|
-
"uid",
|
|
6405
|
-
"id",
|
|
6406
|
-
"checks",
|
|
6407
|
-
"schemaOnChange",
|
|
6408
|
-
"performValidationAsync",
|
|
6409
|
-
"onValueChange",
|
|
6410
|
-
"onPersistAsync",
|
|
6411
|
-
"summariser",
|
|
6412
|
-
"value"
|
|
6413
|
-
]);
|
|
6414
|
-
const update = getInputUpdateFunction(onComponentUpdate);
|
|
6415
|
-
const getValidationErrors = getLocalValueValidator(checks);
|
|
6416
|
-
const validateAsync = performValidationAsync ? getComponentValidationAsync(update, performValidationAsync) : void 0;
|
|
6417
|
-
const component = __spreadValues({
|
|
6418
|
-
type: "date",
|
|
6419
|
-
kind: "input",
|
|
6420
|
-
uid,
|
|
6421
|
-
id,
|
|
6422
|
-
value,
|
|
6423
|
-
onBlur() {
|
|
6424
|
-
const isValid = component.validate();
|
|
6425
|
-
if (isValid) {
|
|
6426
|
-
validateAsync == null ? void 0 : validateAsync(component, component.getLocalValue()).catch(() => {
|
|
6427
|
-
});
|
|
6428
|
-
}
|
|
6429
|
-
},
|
|
6430
|
-
onFocus() {
|
|
6431
|
-
},
|
|
6432
|
-
// Noop
|
|
6433
|
-
setValue(updatedValue) {
|
|
6434
|
-
const prevValue = component.value;
|
|
6435
|
-
update(component, (draft) => {
|
|
6436
|
-
draft.errors = [];
|
|
6437
|
-
draft.validationAsyncState.messages = {};
|
|
6438
|
-
draft.value = updatedValue;
|
|
6439
|
-
});
|
|
6440
|
-
if (isOrWasValid(getValidationErrors, prevValue, updatedValue)) {
|
|
6441
|
-
void (schemaOnChange == null ? void 0 : schemaOnChange());
|
|
6442
|
-
}
|
|
6443
|
-
onValueChange();
|
|
6444
|
-
if (getValidationErrors(updatedValue).length === 0) {
|
|
6445
|
-
void (onPersistAsync == null ? void 0 : onPersistAsync().catch(() => {
|
|
6446
|
-
}));
|
|
6447
|
-
}
|
|
6448
|
-
},
|
|
6449
|
-
async getSubmittableValue() {
|
|
6450
|
-
return component.getSubmittableValueSync();
|
|
6451
|
-
},
|
|
6452
|
-
getSubmittableValueSync() {
|
|
6453
|
-
if (isValidDate(component.getLocalValue())) {
|
|
6454
|
-
return component.getLocalValue();
|
|
6455
|
-
}
|
|
6456
|
-
return null;
|
|
6457
|
-
},
|
|
6458
|
-
getSummary() {
|
|
6459
|
-
return summariser(component.getLocalValue());
|
|
6460
|
-
},
|
|
6461
|
-
getLocalValue() {
|
|
6462
|
-
return component.value;
|
|
6463
|
-
},
|
|
6464
|
-
validate() {
|
|
6465
|
-
const errors = getValidationErrors(component.getLocalValue());
|
|
6466
|
-
update(component, (draft) => {
|
|
6467
|
-
draft.errors = errors;
|
|
6468
|
-
});
|
|
6469
|
-
return errors.length === 0;
|
|
6470
|
-
}
|
|
6471
|
-
}, rest);
|
|
6472
|
-
return component;
|
|
6473
|
-
};
|
|
6474
|
-
|
|
6475
|
-
// src/domain/mappers/utils/suggestions-utils.ts
|
|
6476
|
-
var mapStringSchemaSuggestions = (suggestions, logEvent) => {
|
|
6477
|
-
if (!suggestions) return void 0;
|
|
6478
|
-
return {
|
|
6479
|
-
values: suggestions.values.map((_a) => {
|
|
6480
|
-
var _b = _a, { icon, image, media, value } = _b, rest = __objRest(_b, ["icon", "image", "media", "value"]);
|
|
6481
|
-
if (typeof value !== "string") {
|
|
6482
|
-
logEvent(
|
|
6483
|
-
"warning",
|
|
6484
|
-
`Suggestion values for string schemas must be of type string. Found ${typeof value} instead.`
|
|
6485
|
-
);
|
|
6486
|
-
}
|
|
6487
|
-
return __spreadProps(__spreadValues({}, rest), {
|
|
6488
|
-
media: getDomainLayerMedia({ icon, image, media }),
|
|
6489
|
-
value,
|
|
6490
|
-
tags: mapTags(rest)
|
|
6491
|
-
});
|
|
6492
|
-
})
|
|
6493
|
-
};
|
|
6494
|
-
};
|
|
6495
|
-
|
|
6496
|
-
// src/domain/mappers/schema/stringSchemaToComponent/stringSchemaToDateInputComponent.ts
|
|
6497
|
-
var stringSchemaToDateInputComponent = (schemaMapperProps, mapperProps) => {
|
|
6498
|
-
var _a;
|
|
6499
|
-
const {
|
|
6500
|
-
schema,
|
|
6501
|
-
localValue,
|
|
6502
|
-
model,
|
|
6503
|
-
required = false,
|
|
6504
|
-
onPersistAsync,
|
|
6505
|
-
onValueChange
|
|
6506
|
-
} = schemaMapperProps;
|
|
6507
|
-
const {
|
|
6508
|
-
autocompleteHint,
|
|
6509
|
-
default: defaultValue,
|
|
6510
|
-
minimum: minimumDate,
|
|
6511
|
-
maximum: maximumDate,
|
|
6512
|
-
suggestions
|
|
6513
|
-
} = schema;
|
|
6514
|
-
const { getErrorMessageFunctions, onComponentUpdate, onBehavior } = mapperProps;
|
|
6515
|
-
const errorMessageFunctions = getErrorMessageFunctions(schema.validationMessages);
|
|
6516
|
-
const { performValidationAsync, validationAsyncState } = getValidationAsyncInitialState(
|
|
6517
|
-
schemaMapperProps,
|
|
6518
|
-
mapperProps
|
|
6519
|
-
);
|
|
6520
|
-
const validLocalValue = isString(localValue) ? localValue : null;
|
|
6521
|
-
const validModel = (_a = getValidDate(model)) != null ? _a : getValidDate(defaultValue != null ? defaultValue : null);
|
|
6522
|
-
const value = onPersistAsync ? validLocalValue : validModel;
|
|
6523
|
-
return createDateInputComponent(
|
|
6524
|
-
__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
|
|
6525
|
-
autoComplete: getAutocompleteString(autocompleteHint),
|
|
6526
|
-
checks: schema.hidden ? [] : [
|
|
6527
|
-
getStringRequiredCheck(required, errorMessageFunctions),
|
|
6528
|
-
getValidDateCheck(required, errorMessageFunctions),
|
|
6529
|
-
getAboveMaximumDateCheck(schema, errorMessageFunctions),
|
|
6530
|
-
getBelowMinimumDateCheck(schema, errorMessageFunctions)
|
|
6531
|
-
],
|
|
6532
|
-
minimumDate,
|
|
6533
|
-
maximumDate,
|
|
6534
|
-
suggestions: mapStringSchemaSuggestions(suggestions, mapperProps.logEvent),
|
|
6535
|
-
value,
|
|
6536
|
-
validationAsyncState,
|
|
6537
|
-
schemaOnChange: getSchemaOnChange(schema, onBehavior),
|
|
6538
|
-
performValidationAsync,
|
|
6539
|
-
onValueChange
|
|
6540
|
-
}),
|
|
6541
|
-
onComponentUpdate
|
|
6542
|
-
);
|
|
6543
|
-
};
|
|
6544
|
-
var getValidDate = (model) => {
|
|
6545
|
-
if (!isString(model)) {
|
|
6546
|
-
return null;
|
|
6547
|
-
}
|
|
6548
|
-
if (/^\d{4}-\d{2}$/.test(model)) {
|
|
6549
|
-
return model;
|
|
6550
|
-
}
|
|
6551
|
-
try {
|
|
6552
|
-
const date = new Date(model);
|
|
6553
|
-
const stringDate = date.toISOString();
|
|
6554
|
-
return stringDate.split("T")[0];
|
|
6555
|
-
} catch (e) {
|
|
6556
|
-
return null;
|
|
6557
|
-
}
|
|
6558
|
-
};
|
|
6559
|
-
|
|
6560
6655
|
// src/domain/mappers/schema/stringSchemaToComponent/stringSchemaToUploadInputComponent.ts
|
|
6561
6656
|
var stringSchemaToUploadInputComponent = (schemaMapperProps, mapperProps) => {
|
|
6562
6657
|
var _a;
|
|
@@ -6724,7 +6819,7 @@ var stringSchemaToTextInputComponent = (schemaMapperProps, mapperProps) => {
|
|
|
6724
6819
|
maxLength,
|
|
6725
6820
|
minLength,
|
|
6726
6821
|
pattern,
|
|
6727
|
-
suggestions:
|
|
6822
|
+
suggestions: mapSuggestions(suggestions, mapperProps.logEvent),
|
|
6728
6823
|
value,
|
|
6729
6824
|
validationAsyncState,
|
|
6730
6825
|
schemaOnChange: getSchemaOnChange(schema, onBehavior),
|
|
@@ -6749,7 +6844,12 @@ var stringSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
|
6749
6844
|
}
|
|
6750
6845
|
switch (schema.format) {
|
|
6751
6846
|
case "date":
|
|
6752
|
-
return
|
|
6847
|
+
return dateSchemaToComponent(
|
|
6848
|
+
__spreadProps(__spreadValues({}, schemaMapperProps), {
|
|
6849
|
+
schema: __spreadProps(__spreadValues({}, schema), { type: "date" })
|
|
6850
|
+
}),
|
|
6851
|
+
mapperProps
|
|
6852
|
+
);
|
|
6753
6853
|
default:
|
|
6754
6854
|
return stringSchemaToTextInputComponent(schemaMapperProps, mapperProps);
|
|
6755
6855
|
}
|
|
@@ -6776,6 +6876,9 @@ var mapSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
|
6776
6876
|
if (isBooleanSchema(schema)) {
|
|
6777
6877
|
return booleanSchemaToComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema }), mapperProps);
|
|
6778
6878
|
}
|
|
6879
|
+
if (isDateSchema(schema)) {
|
|
6880
|
+
return dateSchemaToComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema }), mapperProps);
|
|
6881
|
+
}
|
|
6779
6882
|
if (isObjectSchema(schema)) {
|
|
6780
6883
|
const { format } = schema;
|
|
6781
6884
|
if (format === "money") {
|
|
@@ -8038,7 +8141,7 @@ var validation_messages_default = (0, import_react_intl3.defineMessages)({
|
|
|
8038
8141
|
},
|
|
8039
8142
|
patternDate: {
|
|
8040
8143
|
id: "dynamicFlows.ControlFeedback.patternDate",
|
|
8041
|
-
defaultMessage: "Please enter a date in the
|
|
8144
|
+
defaultMessage: "Please enter a date in the correct format.",
|
|
8042
8145
|
description: ""
|
|
8043
8146
|
},
|
|
8044
8147
|
required: {
|
|
@@ -8147,6 +8250,10 @@ var createErrorMessageFunctions = (validationMessages, formatMessage, locale) =>
|
|
|
8147
8250
|
maximum: (0, import_formatting.formatDate)(new Date(maximumDate), locale, formatDateOptions)
|
|
8148
8251
|
});
|
|
8149
8252
|
},
|
|
8253
|
+
invalidDate() {
|
|
8254
|
+
var _a;
|
|
8255
|
+
return (_a = validationMessages.invalidDate) != null ? _a : formatMessage(validation_messages_default.patternDate);
|
|
8256
|
+
},
|
|
8150
8257
|
minLength(minLength) {
|
|
8151
8258
|
var _a;
|
|
8152
8259
|
return (_a = validationMessages.minLength) != null ? _a : formatMessage(validation_messages_default.minLength, {
|
|
@@ -8477,7 +8584,7 @@ var containerComponentToProps = (component, rendererMapperProps) => {
|
|
|
8477
8584
|
};
|
|
8478
8585
|
|
|
8479
8586
|
// src/renderers/mappers/dateInputComponentToProps.ts
|
|
8480
|
-
var dateInputComponentToProps = (component, rendererMapperProps) => __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, inputComponentToProps(component, "input-date")), rendererMapperProps), pick(component, "autoComplete", "minimumDate", "maximumDate", "suggestions")), {
|
|
8587
|
+
var dateInputComponentToProps = (component, rendererMapperProps) => __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, inputComponentToProps(component, "input-date")), rendererMapperProps), pick(component, "autoComplete", "minimumDate", "maximumDate", "availability", "suggestions")), {
|
|
8481
8588
|
onChange: component.setValue
|
|
8482
8589
|
});
|
|
8483
8590
|
|
|
@@ -9524,7 +9631,16 @@ var eventNames = [
|
|
|
9524
9631
|
"Native Subflow Succeeded",
|
|
9525
9632
|
"Native Subflow Failed",
|
|
9526
9633
|
"Native Subflow Cancelled",
|
|
9527
|
-
"Behavior Triggered"
|
|
9634
|
+
"Behavior Triggered",
|
|
9635
|
+
"Collection Search Triggered",
|
|
9636
|
+
"Collection Search Succeeded",
|
|
9637
|
+
"Collection Search Failed",
|
|
9638
|
+
"Collection Filter Triggered",
|
|
9639
|
+
"Collection Filter Succeeded",
|
|
9640
|
+
"Collection Filter Failed",
|
|
9641
|
+
"Collection Pagination Triggered",
|
|
9642
|
+
"Collection Pagination Succeeded",
|
|
9643
|
+
"Collection Pagination Failed"
|
|
9528
9644
|
];
|
|
9529
9645
|
|
|
9530
9646
|
// src/renderers/subflow/getDynamicSubflowRenderer.tsx
|