@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.mjs
CHANGED
|
@@ -76,7 +76,7 @@ var cs_default = {
|
|
|
76
76
|
"dynamicFlows.ControlFeedback.minimum": "Zadejte \u010D\xEDslo, kter\xE9 je {minimum} nebo vy\u0161\u0161\xED.",
|
|
77
77
|
"dynamicFlows.ControlFeedback.minimumDate": "Zadejte datum, kter\xE9 je {minimum} nebo potom.",
|
|
78
78
|
"dynamicFlows.ControlFeedback.pattern": "Zadejte to pros\xEDm ve spr\xE1vn\xE9m form\xE1tu.",
|
|
79
|
-
"dynamicFlows.ControlFeedback.patternDate": "Zadejte
|
|
79
|
+
"dynamicFlows.ControlFeedback.patternDate": "Zadejte datum ve spr\xE1vn\xE9m form\xE1tu.",
|
|
80
80
|
"dynamicFlows.ControlFeedback.required": "Vypl\u0148te pros\xEDm toto pole.",
|
|
81
81
|
"dynamicFlows.ControlFeedback.type": "Nespr\xE1vn\xFD typ",
|
|
82
82
|
"dynamicFlows.DownloadFeedback.failed": "Stahov\xE1n\xED se nezda\u0159ilo",
|
|
@@ -156,7 +156,7 @@ var en_default = {
|
|
|
156
156
|
"dynamicFlows.ControlFeedback.minimum": "Please enter a number that's {minimum} or more.",
|
|
157
157
|
"dynamicFlows.ControlFeedback.minimumDate": "Please enter a date that's on or after {minimum}.",
|
|
158
158
|
"dynamicFlows.ControlFeedback.pattern": "Please enter this in the correct format.",
|
|
159
|
-
"dynamicFlows.ControlFeedback.patternDate": "Please enter a date in the
|
|
159
|
+
"dynamicFlows.ControlFeedback.patternDate": "Please enter a date in the correct format.",
|
|
160
160
|
"dynamicFlows.ControlFeedback.required": "Please fill out this field.",
|
|
161
161
|
"dynamicFlows.ControlFeedback.type": "Incorrect type",
|
|
162
162
|
"dynamicFlows.DownloadFeedback.failed": "Download failed",
|
|
@@ -196,7 +196,7 @@ var es_default = {
|
|
|
196
196
|
"dynamicFlows.ControlFeedback.minimum": "Introduce una cifra igual o inferior a {minimum}.",
|
|
197
197
|
"dynamicFlows.ControlFeedback.minimumDate": "Introduce una fecha que sea igual o posterior al {minimum}.",
|
|
198
198
|
"dynamicFlows.ControlFeedback.pattern": "Utiliza el formato correcto.",
|
|
199
|
-
"dynamicFlows.ControlFeedback.patternDate": "Introduce la fecha en
|
|
199
|
+
"dynamicFlows.ControlFeedback.patternDate": "Introduce la fecha en el formato correcto.",
|
|
200
200
|
"dynamicFlows.ControlFeedback.required": "Completa este campo.",
|
|
201
201
|
"dynamicFlows.ControlFeedback.type": "Tipo incorrecto",
|
|
202
202
|
"dynamicFlows.DownloadFeedback.failed": "Descarga fallida",
|
|
@@ -316,7 +316,7 @@ var id_default = {
|
|
|
316
316
|
"dynamicFlows.ControlFeedback.minimum": "Harap masukkan angka paling kecil {minimum} atau lebih dari itu.",
|
|
317
317
|
"dynamicFlows.ControlFeedback.minimumDate": "Harap masukkan tanggal pada atau setelah {minimum}.",
|
|
318
318
|
"dynamicFlows.ControlFeedback.pattern": "Mohon masukkan ini dalam format yang benar.",
|
|
319
|
-
"dynamicFlows.ControlFeedback.patternDate": "
|
|
319
|
+
"dynamicFlows.ControlFeedback.patternDate": "Mohon masukkan tanggal dengan format yang benar.",
|
|
320
320
|
"dynamicFlows.ControlFeedback.required": "Harap isi kolom ini.",
|
|
321
321
|
"dynamicFlows.ControlFeedback.type": "Tipe salah",
|
|
322
322
|
"dynamicFlows.DownloadFeedback.failed": "Pengunduhan gagal",
|
|
@@ -436,7 +436,7 @@ var nl_default = {
|
|
|
436
436
|
"dynamicFlows.ControlFeedback.minimum": "Voer een getal in dat {minimum} of hoger is.",
|
|
437
437
|
"dynamicFlows.ControlFeedback.minimumDate": "Voer een datum in die op of na {minimum} is.",
|
|
438
438
|
"dynamicFlows.ControlFeedback.pattern": "Voer dit in de juiste indeling in.",
|
|
439
|
-
"dynamicFlows.ControlFeedback.patternDate": "Voer een datum in de juiste
|
|
439
|
+
"dynamicFlows.ControlFeedback.patternDate": "Voer een datum in met de juiste notatie.",
|
|
440
440
|
"dynamicFlows.ControlFeedback.required": "Vul dit veld in.",
|
|
441
441
|
"dynamicFlows.ControlFeedback.type": "Onjuist type",
|
|
442
442
|
"dynamicFlows.DownloadFeedback.failed": "Downloaden mislukt",
|
|
@@ -636,7 +636,7 @@ var th_default = {
|
|
|
636
636
|
"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",
|
|
637
637
|
"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",
|
|
638
638
|
"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",
|
|
639
|
-
"dynamicFlows.ControlFeedback.patternDate": "\u0E42\u0E1B\u0E23\u0E14\
|
|
639
|
+
"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",
|
|
640
640
|
"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",
|
|
641
641
|
"dynamicFlows.ControlFeedback.type": "\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07",
|
|
642
642
|
"dynamicFlows.DownloadFeedback.failed": "\u0E14\u0E32\u0E27\u0E19\u0E4C\u0E42\u0E2B\u0E25\u0E14\u0E25\u0E49\u0E21\u0E40\u0E2B\u0E25\u0E27",
|
|
@@ -716,7 +716,7 @@ var zh_CN_default = {
|
|
|
716
716
|
"dynamicFlows.ControlFeedback.minimum": "\u8BF7\u8F93\u5165\u4E00\u4E2A\u5927\u4E8E\u6216\u7B49\u4E8E {minimum} \u7684\u6570\u5B57",
|
|
717
717
|
"dynamicFlows.ControlFeedback.minimumDate": "\u8BF7\u8F93\u5165 {minimum} \u6216\u4E4B\u540E\u7684\u65E5\u671F",
|
|
718
718
|
"dynamicFlows.ControlFeedback.pattern": "\u8BF7\u4EE5\u6B63\u786E\u7684\u683C\u5F0F\u8F93\u5165",
|
|
719
|
-
"dynamicFlows.ControlFeedback.patternDate": "\u8BF7\u4EE5\u6B63\u786E\u7684\u683C\u5F0F\u8F93\u5165\u65E5\u671F",
|
|
719
|
+
"dynamicFlows.ControlFeedback.patternDate": "\u8BF7\u4EE5\u6B63\u786E\u7684\u683C\u5F0F\u8F93\u5165\u65E5\u671F\u3002",
|
|
720
720
|
"dynamicFlows.ControlFeedback.required": "\u8BF7\u586B\u5199\u6B64\u5B57\u6BB5\u3002",
|
|
721
721
|
"dynamicFlows.ControlFeedback.type": "\u7C7B\u578B\u9519\u8BEF",
|
|
722
722
|
"dynamicFlows.DownloadFeedback.failed": "\u4E0B\u8F7D\u5931\u8D25",
|
|
@@ -756,7 +756,7 @@ var zh_HK_default = {
|
|
|
756
756
|
"dynamicFlows.ControlFeedback.minimum": "\u8ACB\u8F38\u5165\u4E00\u500B\u5927\u65BC\u6216\u7B49\u65BC{minimum}\u7684\u6578\u5B57\u3002",
|
|
757
757
|
"dynamicFlows.ControlFeedback.minimumDate": "\u8ACB\u8F38\u5165{minimum}\u6216\u4E4B\u5F8C\u7684\u65E5\u671F\u3002",
|
|
758
758
|
"dynamicFlows.ControlFeedback.pattern": "\u8ACB\u4EE5\u6B63\u78BA\u683C\u5F0F\u8F38\u5165\u5185\u5BB9\u3002",
|
|
759
|
-
"dynamicFlows.ControlFeedback.patternDate": "\u8ACB\u4EE5\u6B63\u78BA\u683C\u5F0F\u8F38\u5165\u65E5\u671F\u3002",
|
|
759
|
+
"dynamicFlows.ControlFeedback.patternDate": "\u8ACB\u4EE5\u6B63\u78BA\u7684\u683C\u5F0F\u8F38\u5165\u65E5\u671F\u3002",
|
|
760
760
|
"dynamicFlows.ControlFeedback.required": "\u8ACB\u586B\u5BEB\u6B64\u6B04\u4F4D\u3002",
|
|
761
761
|
"dynamicFlows.ControlFeedback.type": "\u932F\u8AA4\u7684\u985E\u578B",
|
|
762
762
|
"dynamicFlows.DownloadFeedback.failed": "\u4E0B\u8F09\u5931\u6557",
|
|
@@ -1620,17 +1620,58 @@ var debounce = (callback, waitMs) => {
|
|
|
1620
1620
|
return debouncedFn;
|
|
1621
1621
|
};
|
|
1622
1622
|
|
|
1623
|
+
// src/utils/recursiveMerge.ts
|
|
1624
|
+
function recursiveMerge(valueA, valueB) {
|
|
1625
|
+
if (valueA === null) {
|
|
1626
|
+
return valueB;
|
|
1627
|
+
}
|
|
1628
|
+
if (valueB === null) {
|
|
1629
|
+
return valueA;
|
|
1630
|
+
}
|
|
1631
|
+
if (isObject2(valueA) && isObject2(valueB)) {
|
|
1632
|
+
return mergeObjects(valueA, valueB);
|
|
1633
|
+
}
|
|
1634
|
+
if (Array.isArray(valueA) && Array.isArray(valueB)) {
|
|
1635
|
+
return mergeArrays(valueA, valueB);
|
|
1636
|
+
}
|
|
1637
|
+
return valueB;
|
|
1638
|
+
}
|
|
1639
|
+
function isObject2(value) {
|
|
1640
|
+
return value != null && typeof value === "object" && !Array.isArray(value) && !(value instanceof File);
|
|
1641
|
+
}
|
|
1642
|
+
function mergeObjects(valueA, valueB) {
|
|
1643
|
+
const allKeys = /* @__PURE__ */ new Set([...Object.keys(valueA), ...Object.keys(valueB)]);
|
|
1644
|
+
const entries = Array.from(allKeys).map((key) => {
|
|
1645
|
+
var _a, _b;
|
|
1646
|
+
const value = recursiveMerge((_a = valueA[key]) != null ? _a : null, (_b = valueB[key]) != null ? _b : null);
|
|
1647
|
+
return [key, value];
|
|
1648
|
+
});
|
|
1649
|
+
return Object.fromEntries(entries);
|
|
1650
|
+
}
|
|
1651
|
+
function mergeArrays(valueA, valueB) {
|
|
1652
|
+
const length = Math.max(valueA.length, valueB.length);
|
|
1653
|
+
return Array.from(
|
|
1654
|
+
{ length },
|
|
1655
|
+
(_, index) => {
|
|
1656
|
+
var _a, _b;
|
|
1657
|
+
return recursiveMerge((_a = valueA[index]) != null ? _a : null, (_b = valueB[index]) != null ? _b : null);
|
|
1658
|
+
}
|
|
1659
|
+
);
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1623
1662
|
// src/domain/components/collectionComponent/CollectionComponent.ts
|
|
1624
1663
|
var DEBOUNCE_TIME = 800;
|
|
1625
|
-
var createCollectionComponent = (props, onComponentUpdate, queryFunction) => {
|
|
1664
|
+
var createCollectionComponent = (props, onComponentUpdate, queryFunction, trackEvent) => {
|
|
1626
1665
|
const { uid, analyticsId, control, margin, tags, state } = props;
|
|
1627
1666
|
const update = getInputUpdateFunction(onComponentUpdate);
|
|
1628
1667
|
let abortController = new AbortController();
|
|
1629
|
-
const
|
|
1668
|
+
const trackCollectionEvent = (source, status) => trackEvent(getEventName(source, status), component.state.analytics);
|
|
1669
|
+
const query = (mode, source) => {
|
|
1630
1670
|
var _a, _b;
|
|
1631
1671
|
abortController.abort();
|
|
1632
1672
|
abortController = new AbortController();
|
|
1633
1673
|
const { signal } = abortController;
|
|
1674
|
+
trackCollectionEvent(source != null ? source : mode, "Triggered");
|
|
1634
1675
|
queryFunction({
|
|
1635
1676
|
searchParam: (_a = component.state.search) == null ? void 0 : _a.param,
|
|
1636
1677
|
query: (_b = component.state.search) == null ? void 0 : _b.query,
|
|
@@ -1642,27 +1683,20 @@ var createCollectionComponent = (props, onComponentUpdate, queryFunction) => {
|
|
|
1642
1683
|
return;
|
|
1643
1684
|
}
|
|
1644
1685
|
update(component, (draft) => {
|
|
1645
|
-
|
|
1646
|
-
draft.state = {
|
|
1647
|
-
sections: mode === "pagination" ? mergeSections(component.state.sections, response.sections) : response.sections,
|
|
1648
|
-
nextCursor: response.nextCursor,
|
|
1649
|
-
filters: response.filters ? mapFilters(response.filters) : component.state.filters,
|
|
1650
|
-
search: response.search ? mapSearch(response.search) : component.state.search,
|
|
1651
|
-
beforeSections: (_a2 = response.beforeSections) != null ? _a2 : component.state.beforeSections,
|
|
1652
|
-
afterSections: (_b2 = response.afterSections) != null ? _b2 : component.state.afterSections
|
|
1653
|
-
};
|
|
1686
|
+
draft.state = mergeState(mode, component.state, response);
|
|
1654
1687
|
draft.status = {
|
|
1655
1688
|
type: "idle",
|
|
1656
1689
|
loadMore: response.nextCursor ? paginate : void 0
|
|
1657
1690
|
};
|
|
1658
1691
|
});
|
|
1692
|
+
trackCollectionEvent(source != null ? source : mode, "Succeeded");
|
|
1659
1693
|
}).catch(() => {
|
|
1660
1694
|
if (!signal.aborted) {
|
|
1661
1695
|
const retry = () => {
|
|
1662
1696
|
update(component, (draft) => {
|
|
1663
1697
|
draft.status = { type: "loading", reason: mode };
|
|
1664
1698
|
});
|
|
1665
|
-
query(mode);
|
|
1699
|
+
query(mode, source);
|
|
1666
1700
|
};
|
|
1667
1701
|
update(component, (draft) => {
|
|
1668
1702
|
if (mode === "search") {
|
|
@@ -1670,6 +1704,7 @@ var createCollectionComponent = (props, onComponentUpdate, queryFunction) => {
|
|
|
1670
1704
|
}
|
|
1671
1705
|
draft.status = { type: "error", reason: mode, retry };
|
|
1672
1706
|
});
|
|
1707
|
+
trackCollectionEvent(source != null ? source : mode, "Failed");
|
|
1673
1708
|
}
|
|
1674
1709
|
});
|
|
1675
1710
|
};
|
|
@@ -1679,10 +1714,22 @@ var createCollectionComponent = (props, onComponentUpdate, queryFunction) => {
|
|
|
1679
1714
|
debouncedQuery("search");
|
|
1680
1715
|
};
|
|
1681
1716
|
const filter = () => {
|
|
1682
|
-
debouncedQuery("search");
|
|
1717
|
+
debouncedQuery("search", "filter");
|
|
1683
1718
|
debouncedQuery.flush();
|
|
1684
1719
|
};
|
|
1685
1720
|
const paginate = () => query("pagination");
|
|
1721
|
+
const mergeState = (mode, original, incoming) => {
|
|
1722
|
+
var _a, _b;
|
|
1723
|
+
return {
|
|
1724
|
+
sections: mode === "pagination" ? mergeSections(original.sections, incoming.sections) : incoming.sections,
|
|
1725
|
+
nextCursor: incoming.nextCursor,
|
|
1726
|
+
filters: incoming.filters ? mapFilters(incoming.filters) : original.filters,
|
|
1727
|
+
search: incoming.search ? mapSearch(incoming.search) : original.search,
|
|
1728
|
+
beforeSections: (_a = incoming.beforeSections) != null ? _a : original.beforeSections,
|
|
1729
|
+
afterSections: (_b = incoming.afterSections) != null ? _b : original.afterSections,
|
|
1730
|
+
analytics: mode === "pagination" ? recursiveMerge(original.analytics, incoming.analytics) : incoming.analytics
|
|
1731
|
+
};
|
|
1732
|
+
};
|
|
1686
1733
|
const selectFilter = (filterIndex, optionIndex) => {
|
|
1687
1734
|
var _a;
|
|
1688
1735
|
const selected = (_a = component.state.filters) == null ? void 0 : _a[filterIndex];
|
|
@@ -1768,6 +1815,19 @@ var mergeSections = (existing, incoming) => {
|
|
|
1768
1815
|
});
|
|
1769
1816
|
return [...merged, ...newSections];
|
|
1770
1817
|
};
|
|
1818
|
+
var getEventName = (mode, state) => {
|
|
1819
|
+
const getMode = () => {
|
|
1820
|
+
switch (mode) {
|
|
1821
|
+
case "pagination":
|
|
1822
|
+
return "Pagination";
|
|
1823
|
+
case "search":
|
|
1824
|
+
return "Search";
|
|
1825
|
+
case "filter":
|
|
1826
|
+
return "Filter";
|
|
1827
|
+
}
|
|
1828
|
+
};
|
|
1829
|
+
return `Collection ${getMode()} ${state}`;
|
|
1830
|
+
};
|
|
1771
1831
|
|
|
1772
1832
|
// src/domain/features/collection/getPerformCollectionQuery.ts
|
|
1773
1833
|
var getPerformCollectionQuery = (httpClient, baseRequest, mapState) => {
|
|
@@ -1861,7 +1921,7 @@ var hashRequest = ({
|
|
|
1861
1921
|
|
|
1862
1922
|
// src/domain/mappers/layout/collectionLayoutToComponent.ts
|
|
1863
1923
|
var collectionLayoutToComponent = (uid, { analyticsId, control, initialState, margin, search, tags, baseRequest }, mapperProps) => {
|
|
1864
|
-
const { httpClient, onComponentUpdate } = mapperProps;
|
|
1924
|
+
const { httpClient, onComponentUpdate, trackEvent } = mapperProps;
|
|
1865
1925
|
const mapLayout = (layout, index) => mapLayoutToComponent(`${uid}-collection-response-${index}`, layout, mapperProps, []);
|
|
1866
1926
|
const mapState = (state) => mapCollectionSpecToDomainState(state, mapperProps, mapLayout);
|
|
1867
1927
|
const queryFunction = getPerformCollectionQuery(httpClient, baseRequest, mapState);
|
|
@@ -1876,12 +1936,20 @@ var collectionLayoutToComponent = (uid, { analyticsId, control, initialState, ma
|
|
|
1876
1936
|
search
|
|
1877
1937
|
},
|
|
1878
1938
|
onComponentUpdate,
|
|
1879
|
-
queryFunction
|
|
1939
|
+
queryFunction,
|
|
1940
|
+
trackEvent
|
|
1880
1941
|
);
|
|
1881
1942
|
return component;
|
|
1882
1943
|
};
|
|
1883
1944
|
var mapCollectionSpecToDomainState = (specState, mapperProps, mapLayout) => {
|
|
1884
|
-
const {
|
|
1945
|
+
const {
|
|
1946
|
+
sections,
|
|
1947
|
+
filters,
|
|
1948
|
+
beforeSections,
|
|
1949
|
+
afterSections,
|
|
1950
|
+
nextCursor,
|
|
1951
|
+
analytics = {}
|
|
1952
|
+
} = specState;
|
|
1885
1953
|
return {
|
|
1886
1954
|
sections: sections.map((section) => {
|
|
1887
1955
|
var _a;
|
|
@@ -1909,7 +1977,8 @@ var mapCollectionSpecToDomainState = (specState, mapperProps, mapLayout) => {
|
|
|
1909
1977
|
filters: filters == null ? void 0 : filters.map(mapFilter),
|
|
1910
1978
|
beforeSections: beforeSections == null ? void 0 : beforeSections.map(mapLayout),
|
|
1911
1979
|
afterSections: afterSections == null ? void 0 : afterSections.map(mapLayout),
|
|
1912
|
-
nextCursor
|
|
1980
|
+
nextCursor,
|
|
1981
|
+
analytics
|
|
1913
1982
|
};
|
|
1914
1983
|
};
|
|
1915
1984
|
var mapFilter = (filter) => {
|
|
@@ -2981,45 +3050,6 @@ var createExternalConfirmation = (uid, url, onLink, onComponentUpdate) => {
|
|
|
2981
3050
|
return component;
|
|
2982
3051
|
};
|
|
2983
3052
|
|
|
2984
|
-
// src/utils/recursiveMerge.ts
|
|
2985
|
-
function recursiveMerge(valueA, valueB) {
|
|
2986
|
-
if (valueA === null) {
|
|
2987
|
-
return valueB;
|
|
2988
|
-
}
|
|
2989
|
-
if (valueB === null) {
|
|
2990
|
-
return valueA;
|
|
2991
|
-
}
|
|
2992
|
-
if (isObject2(valueA) && isObject2(valueB)) {
|
|
2993
|
-
return mergeObjects(valueA, valueB);
|
|
2994
|
-
}
|
|
2995
|
-
if (Array.isArray(valueA) && Array.isArray(valueB)) {
|
|
2996
|
-
return mergeArrays(valueA, valueB);
|
|
2997
|
-
}
|
|
2998
|
-
return valueB;
|
|
2999
|
-
}
|
|
3000
|
-
function isObject2(value) {
|
|
3001
|
-
return value != null && typeof value === "object" && !Array.isArray(value) && !(value instanceof File);
|
|
3002
|
-
}
|
|
3003
|
-
function mergeObjects(valueA, valueB) {
|
|
3004
|
-
const allKeys = /* @__PURE__ */ new Set([...Object.keys(valueA), ...Object.keys(valueB)]);
|
|
3005
|
-
const entries = Array.from(allKeys).map((key) => {
|
|
3006
|
-
var _a, _b;
|
|
3007
|
-
const value = recursiveMerge((_a = valueA[key]) != null ? _a : null, (_b = valueB[key]) != null ? _b : null);
|
|
3008
|
-
return [key, value];
|
|
3009
|
-
});
|
|
3010
|
-
return Object.fromEntries(entries);
|
|
3011
|
-
}
|
|
3012
|
-
function mergeArrays(valueA, valueB) {
|
|
3013
|
-
const length = Math.max(valueA.length, valueB.length);
|
|
3014
|
-
return Array.from(
|
|
3015
|
-
{ length },
|
|
3016
|
-
(_, index) => {
|
|
3017
|
-
var _a, _b;
|
|
3018
|
-
return recursiveMerge((_a = valueA[index]) != null ? _a : null, (_b = valueB[index]) != null ? _b : null);
|
|
3019
|
-
}
|
|
3020
|
-
);
|
|
3021
|
-
}
|
|
3022
|
-
|
|
3023
3053
|
// src/utils/component-utils.ts
|
|
3024
3054
|
var getSubmittableData = async (components) => Promise.all(components.map(async (component) => component.getSubmittableValue())).then(
|
|
3025
3055
|
(values) => values.reduce((acc, value) => recursiveMerge(acc, value), null)
|
|
@@ -3888,7 +3918,9 @@ var getBehaviorFromSchemaOnChange = (schema) => {
|
|
|
3888
3918
|
var getBehaviorFromSchemaRefreshStepOnChange = (schema) => {
|
|
3889
3919
|
var _a, _b, _c;
|
|
3890
3920
|
if ("refreshStepOnChange" in schema && ((_a = schema.refreshStepOnChange) != null ? _a : false) || "refreshFormOnChange" in schema && ((_b = schema.refreshFormOnChange) != null ? _b : false)) {
|
|
3891
|
-
const { $id, analyticsId
|
|
3921
|
+
const { $id, analyticsId } = schema;
|
|
3922
|
+
const refreshUrl = "refreshUrl" in schema ? schema.refreshUrl : void 0;
|
|
3923
|
+
const refreshFormUrl = "refreshFormUrl" in schema ? schema.refreshFormUrl : void 0;
|
|
3892
3924
|
const behavior = {
|
|
3893
3925
|
type: "refresh",
|
|
3894
3926
|
analytics: { schema: (_c = analyticsId != null ? analyticsId : $id) != null ? _c : "" },
|
|
@@ -3900,6 +3932,65 @@ var getBehaviorFromSchemaRefreshStepOnChange = (schema) => {
|
|
|
3900
3932
|
return void 0;
|
|
3901
3933
|
};
|
|
3902
3934
|
|
|
3935
|
+
// src/domain/features/validation/date-availability.ts
|
|
3936
|
+
var WEEKDAYS = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
|
|
3937
|
+
var normaliseDateAvailability = (availability, logEvent) => {
|
|
3938
|
+
if (!availability) {
|
|
3939
|
+
return void 0;
|
|
3940
|
+
}
|
|
3941
|
+
const unavailable = availability.unavailable.flatMap((rule) => {
|
|
3942
|
+
if (rule.type === "weekdays") {
|
|
3943
|
+
return [rule];
|
|
3944
|
+
}
|
|
3945
|
+
if (rule.type === "dates") {
|
|
3946
|
+
const dates = rule.dates.filter((date) => {
|
|
3947
|
+
const valid = isCanonicalDate(date);
|
|
3948
|
+
if (!valid) {
|
|
3949
|
+
logInvalidRule(date, logEvent);
|
|
3950
|
+
}
|
|
3951
|
+
return valid;
|
|
3952
|
+
});
|
|
3953
|
+
return dates.length > 0 ? [__spreadProps(__spreadValues({}, rule), { dates })] : [];
|
|
3954
|
+
}
|
|
3955
|
+
if (!isCanonicalDate(rule.start) || !isCanonicalDate(rule.end) || rule.start > rule.end) {
|
|
3956
|
+
logInvalidRule(`${rule.start}/${rule.end}`, logEvent);
|
|
3957
|
+
return [];
|
|
3958
|
+
}
|
|
3959
|
+
return [rule];
|
|
3960
|
+
});
|
|
3961
|
+
return __spreadProps(__spreadValues({}, availability), { unavailable });
|
|
3962
|
+
};
|
|
3963
|
+
var getUnavailableDateReason = (date, availability) => {
|
|
3964
|
+
var _a, _b;
|
|
3965
|
+
return (_b = (_a = availability == null ? void 0 : availability.unavailable.find((rule) => matchesDateRule(date, rule))) == null ? void 0 : _a.reason) != null ? _b : null;
|
|
3966
|
+
};
|
|
3967
|
+
var matchesDateRule = (date, rule) => {
|
|
3968
|
+
switch (rule.type) {
|
|
3969
|
+
case "dates":
|
|
3970
|
+
return rule.dates.includes(date);
|
|
3971
|
+
case "weekdays": {
|
|
3972
|
+
const weekday = WEEKDAYS[(/* @__PURE__ */ new Date(`${date}T00:00:00Z`)).getUTCDay()];
|
|
3973
|
+
return rule.weekdays.includes(weekday);
|
|
3974
|
+
}
|
|
3975
|
+
case "range":
|
|
3976
|
+
return date >= rule.start && date <= rule.end;
|
|
3977
|
+
}
|
|
3978
|
+
};
|
|
3979
|
+
var isCanonicalDate = (value) => {
|
|
3980
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
|
|
3981
|
+
if (!match) {
|
|
3982
|
+
return false;
|
|
3983
|
+
}
|
|
3984
|
+
const [, year, month, day] = match.map(Number);
|
|
3985
|
+
const date = /* @__PURE__ */ new Date(0);
|
|
3986
|
+
date.setUTCHours(0, 0, 0, 0);
|
|
3987
|
+
date.setUTCFullYear(year, month - 1, day);
|
|
3988
|
+
return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
|
|
3989
|
+
};
|
|
3990
|
+
var logInvalidRule = (value, logEvent) => {
|
|
3991
|
+
logEvent("warning", "Ignoring invalid date availability rule value", { value });
|
|
3992
|
+
};
|
|
3993
|
+
|
|
3903
3994
|
// src/domain/features/validation/getPatternRegExp.ts
|
|
3904
3995
|
var getPatternRegExp = (pattern, logEvent) => {
|
|
3905
3996
|
if (!pattern) {
|
|
@@ -4004,13 +4095,13 @@ var getBelowMinimumMoneyAmountCheck = ({ minimum }, messageFunctions) => (value)
|
|
|
4004
4095
|
return null;
|
|
4005
4096
|
};
|
|
4006
4097
|
var getAboveMaximumDateCheck = ({ maximum }, messageFunctions) => (value) => {
|
|
4007
|
-
if (isString(maximum) &&
|
|
4098
|
+
if (isString(maximum) && isValidDate(value) && value > maximum) {
|
|
4008
4099
|
return messageFunctions.maximumDate(maximum);
|
|
4009
4100
|
}
|
|
4010
4101
|
return null;
|
|
4011
4102
|
};
|
|
4012
4103
|
var getBelowMinimumDateCheck = ({ minimum }, messageFunctions) => (value) => {
|
|
4013
|
-
if (isString(minimum) &&
|
|
4104
|
+
if (isString(minimum) && isValidDate(value) && value < minimum) {
|
|
4014
4105
|
return messageFunctions.minimumDate(minimum);
|
|
4015
4106
|
}
|
|
4016
4107
|
return null;
|
|
@@ -4040,11 +4131,12 @@ var getStringRequiredCheck = (required, messageFunctions) => (value) => {
|
|
|
4040
4131
|
return isNullish(value) || value === "" ? messageFunctions.required() : null;
|
|
4041
4132
|
};
|
|
4042
4133
|
var getValidDateCheck = (required, messageFunctions) => (value) => {
|
|
4043
|
-
if (required && !isValidDate(value)) {
|
|
4044
|
-
return messageFunctions.
|
|
4134
|
+
if (required && value && !isValidDate(value)) {
|
|
4135
|
+
return messageFunctions.invalidDate();
|
|
4045
4136
|
}
|
|
4046
4137
|
return null;
|
|
4047
4138
|
};
|
|
4139
|
+
var getUnavailableDateCheck = ({ availability }) => (value) => isValidDate(value) ? getUnavailableDateReason(value, availability) : null;
|
|
4048
4140
|
|
|
4049
4141
|
// src/domain/mappers/utils/getAutocompleteString.ts
|
|
4050
4142
|
var getAutocompleteString = (hints) => {
|
|
@@ -4348,6 +4440,7 @@ var isAllOfSchema = (schema) => "allOf" in schema && !isNullish(schema.allOf);
|
|
|
4348
4440
|
var isBooleanSchema = (schema) => "type" in schema && schema.type === "boolean";
|
|
4349
4441
|
var isBlobSchema = (schema) => "type" in schema && schema.type === "blob";
|
|
4350
4442
|
var isConstSchema = (schema) => "const" in schema && schema.const !== void 0;
|
|
4443
|
+
var isDateSchema = (schema) => "type" in schema && schema.type === "date";
|
|
4351
4444
|
var isIntegerSchema = (schema) => "type" in schema && schema.type === "integer";
|
|
4352
4445
|
var isNumberSchema = (schema) => "type" in schema && schema.type === "number";
|
|
4353
4446
|
var isObjectSchema = (schema) => "type" in schema && schema.type === "object";
|
|
@@ -5490,6 +5583,177 @@ var getConstLayout = (uid, mapperProps, layout, alert) => {
|
|
|
5490
5583
|
);
|
|
5491
5584
|
};
|
|
5492
5585
|
|
|
5586
|
+
// src/domain/components/DateInputComponent.ts
|
|
5587
|
+
var createDateInputComponent = (props, onComponentUpdate) => {
|
|
5588
|
+
const _a = props, {
|
|
5589
|
+
uid,
|
|
5590
|
+
id,
|
|
5591
|
+
checks,
|
|
5592
|
+
schemaOnChange,
|
|
5593
|
+
performValidationAsync,
|
|
5594
|
+
onValueChange,
|
|
5595
|
+
onPersistAsync,
|
|
5596
|
+
summariser,
|
|
5597
|
+
value
|
|
5598
|
+
} = _a, rest = __objRest(_a, [
|
|
5599
|
+
"uid",
|
|
5600
|
+
"id",
|
|
5601
|
+
"checks",
|
|
5602
|
+
"schemaOnChange",
|
|
5603
|
+
"performValidationAsync",
|
|
5604
|
+
"onValueChange",
|
|
5605
|
+
"onPersistAsync",
|
|
5606
|
+
"summariser",
|
|
5607
|
+
"value"
|
|
5608
|
+
]);
|
|
5609
|
+
const update = getInputUpdateFunction(onComponentUpdate);
|
|
5610
|
+
const getValidationErrors = getLocalValueValidator(checks);
|
|
5611
|
+
const validateAsync = performValidationAsync ? getComponentValidationAsync(update, performValidationAsync) : void 0;
|
|
5612
|
+
const component = __spreadValues({
|
|
5613
|
+
type: "date",
|
|
5614
|
+
kind: "input",
|
|
5615
|
+
uid,
|
|
5616
|
+
id,
|
|
5617
|
+
value,
|
|
5618
|
+
onBlur() {
|
|
5619
|
+
const isValid = component.validate();
|
|
5620
|
+
if (isValid) {
|
|
5621
|
+
validateAsync == null ? void 0 : validateAsync(component, component.getLocalValue()).catch(() => {
|
|
5622
|
+
});
|
|
5623
|
+
}
|
|
5624
|
+
},
|
|
5625
|
+
onFocus() {
|
|
5626
|
+
},
|
|
5627
|
+
// Noop
|
|
5628
|
+
setValue(updatedValue) {
|
|
5629
|
+
const prevValue = component.value;
|
|
5630
|
+
update(component, (draft) => {
|
|
5631
|
+
draft.errors = [];
|
|
5632
|
+
draft.validationAsyncState.messages = {};
|
|
5633
|
+
draft.value = updatedValue;
|
|
5634
|
+
});
|
|
5635
|
+
if (isOrWasValid(getValidationErrors, prevValue, updatedValue)) {
|
|
5636
|
+
void (schemaOnChange == null ? void 0 : schemaOnChange());
|
|
5637
|
+
}
|
|
5638
|
+
onValueChange();
|
|
5639
|
+
if (getValidationErrors(updatedValue).length === 0) {
|
|
5640
|
+
void (onPersistAsync == null ? void 0 : onPersistAsync().catch(() => {
|
|
5641
|
+
}));
|
|
5642
|
+
}
|
|
5643
|
+
},
|
|
5644
|
+
async getSubmittableValue() {
|
|
5645
|
+
return component.getSubmittableValueSync();
|
|
5646
|
+
},
|
|
5647
|
+
getSubmittableValueSync() {
|
|
5648
|
+
if (isValidDate(component.getLocalValue())) {
|
|
5649
|
+
return component.getLocalValue();
|
|
5650
|
+
}
|
|
5651
|
+
return null;
|
|
5652
|
+
},
|
|
5653
|
+
getSummary() {
|
|
5654
|
+
return summariser(component.getLocalValue());
|
|
5655
|
+
},
|
|
5656
|
+
getLocalValue() {
|
|
5657
|
+
return component.value;
|
|
5658
|
+
},
|
|
5659
|
+
validate() {
|
|
5660
|
+
const errors = getValidationErrors(component.getLocalValue());
|
|
5661
|
+
update(component, (draft) => {
|
|
5662
|
+
draft.errors = errors;
|
|
5663
|
+
});
|
|
5664
|
+
return errors.length === 0;
|
|
5665
|
+
}
|
|
5666
|
+
}, rest);
|
|
5667
|
+
return component;
|
|
5668
|
+
};
|
|
5669
|
+
|
|
5670
|
+
// src/domain/mappers/utils/suggestions-utils.ts
|
|
5671
|
+
var mapSuggestions = (suggestions, logEvent) => {
|
|
5672
|
+
if (!suggestions) return void 0;
|
|
5673
|
+
return {
|
|
5674
|
+
values: suggestions.values.map((_a) => {
|
|
5675
|
+
var _b = _a, { icon, image, media, value } = _b, rest = __objRest(_b, ["icon", "image", "media", "value"]);
|
|
5676
|
+
if (typeof value !== "string") {
|
|
5677
|
+
logEvent(
|
|
5678
|
+
"warning",
|
|
5679
|
+
`Suggestion values must be of type string. Found ${typeof value} instead.`
|
|
5680
|
+
);
|
|
5681
|
+
}
|
|
5682
|
+
return __spreadProps(__spreadValues({}, rest), {
|
|
5683
|
+
media: getDomainLayerMedia({ icon, image, media }),
|
|
5684
|
+
value,
|
|
5685
|
+
tags: mapTags(rest)
|
|
5686
|
+
});
|
|
5687
|
+
})
|
|
5688
|
+
};
|
|
5689
|
+
};
|
|
5690
|
+
|
|
5691
|
+
// src/domain/mappers/schema/dateSchemaToComponent.ts
|
|
5692
|
+
var dateSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
5693
|
+
var _a;
|
|
5694
|
+
const {
|
|
5695
|
+
schema,
|
|
5696
|
+
localValue,
|
|
5697
|
+
model,
|
|
5698
|
+
required = false,
|
|
5699
|
+
onPersistAsync,
|
|
5700
|
+
onValueChange
|
|
5701
|
+
} = schemaMapperProps;
|
|
5702
|
+
const {
|
|
5703
|
+
autocompleteHint,
|
|
5704
|
+
default: defaultValue,
|
|
5705
|
+
minimum: minimumDate,
|
|
5706
|
+
maximum: maximumDate,
|
|
5707
|
+
suggestions
|
|
5708
|
+
} = schema;
|
|
5709
|
+
const { getErrorMessageFunctions, onComponentUpdate, onBehavior } = mapperProps;
|
|
5710
|
+
const availability = schema.type === "date" ? normaliseDateAvailability(schema.availability, mapperProps.logEvent) : void 0;
|
|
5711
|
+
const errorMessageFunctions = getErrorMessageFunctions(schema.validationMessages);
|
|
5712
|
+
const { performValidationAsync, validationAsyncState } = getValidationAsyncInitialState(
|
|
5713
|
+
schemaMapperProps,
|
|
5714
|
+
mapperProps
|
|
5715
|
+
);
|
|
5716
|
+
const validLocalValue = isString(localValue) ? localValue : null;
|
|
5717
|
+
const value = onPersistAsync ? validLocalValue : (_a = normaliseDateValue(model)) != null ? _a : normaliseDateValue(defaultValue != null ? defaultValue : null);
|
|
5718
|
+
return createDateInputComponent(
|
|
5719
|
+
__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
|
|
5720
|
+
autoComplete: getAutocompleteString(autocompleteHint),
|
|
5721
|
+
availability,
|
|
5722
|
+
checks: schema.hidden ? [] : [
|
|
5723
|
+
getStringRequiredCheck(required, errorMessageFunctions),
|
|
5724
|
+
getValidDateCheck(required, errorMessageFunctions),
|
|
5725
|
+
getAboveMaximumDateCheck(schema, errorMessageFunctions),
|
|
5726
|
+
getBelowMinimumDateCheck(schema, errorMessageFunctions),
|
|
5727
|
+
...schema.type === "date" ? [getUnavailableDateCheck(__spreadProps(__spreadValues({}, schema), { availability }))] : []
|
|
5728
|
+
],
|
|
5729
|
+
minimumDate,
|
|
5730
|
+
maximumDate,
|
|
5731
|
+
suggestions: mapSuggestions(suggestions, mapperProps.logEvent),
|
|
5732
|
+
value,
|
|
5733
|
+
validationAsyncState,
|
|
5734
|
+
schemaOnChange: getSchemaOnChange(schema, onBehavior),
|
|
5735
|
+
performValidationAsync,
|
|
5736
|
+
onValueChange
|
|
5737
|
+
}),
|
|
5738
|
+
onComponentUpdate
|
|
5739
|
+
);
|
|
5740
|
+
};
|
|
5741
|
+
var normaliseDateValue = (value) => {
|
|
5742
|
+
if (!isString(value)) {
|
|
5743
|
+
return null;
|
|
5744
|
+
}
|
|
5745
|
+
if (/^\d{4}-\d{2}$/.test(value)) {
|
|
5746
|
+
return value;
|
|
5747
|
+
}
|
|
5748
|
+
try {
|
|
5749
|
+
const date = new Date(value);
|
|
5750
|
+
const stringDate = date.toISOString();
|
|
5751
|
+
return stringDate.split("T")[0];
|
|
5752
|
+
} catch (e) {
|
|
5753
|
+
return null;
|
|
5754
|
+
}
|
|
5755
|
+
};
|
|
5756
|
+
|
|
5493
5757
|
// src/domain/components/IntegerInputComponent.ts
|
|
5494
5758
|
var createIntegerInputComponent = (props, onComponentUpdate) => {
|
|
5495
5759
|
const _a = props, {
|
|
@@ -6357,175 +6621,6 @@ var persistAsyncSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
|
6357
6621
|
return paComponent;
|
|
6358
6622
|
};
|
|
6359
6623
|
|
|
6360
|
-
// src/domain/components/DateInputComponent.ts
|
|
6361
|
-
var createDateInputComponent = (props, onComponentUpdate) => {
|
|
6362
|
-
const _a = props, {
|
|
6363
|
-
uid,
|
|
6364
|
-
id,
|
|
6365
|
-
checks,
|
|
6366
|
-
schemaOnChange,
|
|
6367
|
-
performValidationAsync,
|
|
6368
|
-
onValueChange,
|
|
6369
|
-
onPersistAsync,
|
|
6370
|
-
summariser,
|
|
6371
|
-
value
|
|
6372
|
-
} = _a, rest = __objRest(_a, [
|
|
6373
|
-
"uid",
|
|
6374
|
-
"id",
|
|
6375
|
-
"checks",
|
|
6376
|
-
"schemaOnChange",
|
|
6377
|
-
"performValidationAsync",
|
|
6378
|
-
"onValueChange",
|
|
6379
|
-
"onPersistAsync",
|
|
6380
|
-
"summariser",
|
|
6381
|
-
"value"
|
|
6382
|
-
]);
|
|
6383
|
-
const update = getInputUpdateFunction(onComponentUpdate);
|
|
6384
|
-
const getValidationErrors = getLocalValueValidator(checks);
|
|
6385
|
-
const validateAsync = performValidationAsync ? getComponentValidationAsync(update, performValidationAsync) : void 0;
|
|
6386
|
-
const component = __spreadValues({
|
|
6387
|
-
type: "date",
|
|
6388
|
-
kind: "input",
|
|
6389
|
-
uid,
|
|
6390
|
-
id,
|
|
6391
|
-
value,
|
|
6392
|
-
onBlur() {
|
|
6393
|
-
const isValid = component.validate();
|
|
6394
|
-
if (isValid) {
|
|
6395
|
-
validateAsync == null ? void 0 : validateAsync(component, component.getLocalValue()).catch(() => {
|
|
6396
|
-
});
|
|
6397
|
-
}
|
|
6398
|
-
},
|
|
6399
|
-
onFocus() {
|
|
6400
|
-
},
|
|
6401
|
-
// Noop
|
|
6402
|
-
setValue(updatedValue) {
|
|
6403
|
-
const prevValue = component.value;
|
|
6404
|
-
update(component, (draft) => {
|
|
6405
|
-
draft.errors = [];
|
|
6406
|
-
draft.validationAsyncState.messages = {};
|
|
6407
|
-
draft.value = updatedValue;
|
|
6408
|
-
});
|
|
6409
|
-
if (isOrWasValid(getValidationErrors, prevValue, updatedValue)) {
|
|
6410
|
-
void (schemaOnChange == null ? void 0 : schemaOnChange());
|
|
6411
|
-
}
|
|
6412
|
-
onValueChange();
|
|
6413
|
-
if (getValidationErrors(updatedValue).length === 0) {
|
|
6414
|
-
void (onPersistAsync == null ? void 0 : onPersistAsync().catch(() => {
|
|
6415
|
-
}));
|
|
6416
|
-
}
|
|
6417
|
-
},
|
|
6418
|
-
async getSubmittableValue() {
|
|
6419
|
-
return component.getSubmittableValueSync();
|
|
6420
|
-
},
|
|
6421
|
-
getSubmittableValueSync() {
|
|
6422
|
-
if (isValidDate(component.getLocalValue())) {
|
|
6423
|
-
return component.getLocalValue();
|
|
6424
|
-
}
|
|
6425
|
-
return null;
|
|
6426
|
-
},
|
|
6427
|
-
getSummary() {
|
|
6428
|
-
return summariser(component.getLocalValue());
|
|
6429
|
-
},
|
|
6430
|
-
getLocalValue() {
|
|
6431
|
-
return component.value;
|
|
6432
|
-
},
|
|
6433
|
-
validate() {
|
|
6434
|
-
const errors = getValidationErrors(component.getLocalValue());
|
|
6435
|
-
update(component, (draft) => {
|
|
6436
|
-
draft.errors = errors;
|
|
6437
|
-
});
|
|
6438
|
-
return errors.length === 0;
|
|
6439
|
-
}
|
|
6440
|
-
}, rest);
|
|
6441
|
-
return component;
|
|
6442
|
-
};
|
|
6443
|
-
|
|
6444
|
-
// src/domain/mappers/utils/suggestions-utils.ts
|
|
6445
|
-
var mapStringSchemaSuggestions = (suggestions, logEvent) => {
|
|
6446
|
-
if (!suggestions) return void 0;
|
|
6447
|
-
return {
|
|
6448
|
-
values: suggestions.values.map((_a) => {
|
|
6449
|
-
var _b = _a, { icon, image, media, value } = _b, rest = __objRest(_b, ["icon", "image", "media", "value"]);
|
|
6450
|
-
if (typeof value !== "string") {
|
|
6451
|
-
logEvent(
|
|
6452
|
-
"warning",
|
|
6453
|
-
`Suggestion values for string schemas must be of type string. Found ${typeof value} instead.`
|
|
6454
|
-
);
|
|
6455
|
-
}
|
|
6456
|
-
return __spreadProps(__spreadValues({}, rest), {
|
|
6457
|
-
media: getDomainLayerMedia({ icon, image, media }),
|
|
6458
|
-
value,
|
|
6459
|
-
tags: mapTags(rest)
|
|
6460
|
-
});
|
|
6461
|
-
})
|
|
6462
|
-
};
|
|
6463
|
-
};
|
|
6464
|
-
|
|
6465
|
-
// src/domain/mappers/schema/stringSchemaToComponent/stringSchemaToDateInputComponent.ts
|
|
6466
|
-
var stringSchemaToDateInputComponent = (schemaMapperProps, mapperProps) => {
|
|
6467
|
-
var _a;
|
|
6468
|
-
const {
|
|
6469
|
-
schema,
|
|
6470
|
-
localValue,
|
|
6471
|
-
model,
|
|
6472
|
-
required = false,
|
|
6473
|
-
onPersistAsync,
|
|
6474
|
-
onValueChange
|
|
6475
|
-
} = schemaMapperProps;
|
|
6476
|
-
const {
|
|
6477
|
-
autocompleteHint,
|
|
6478
|
-
default: defaultValue,
|
|
6479
|
-
minimum: minimumDate,
|
|
6480
|
-
maximum: maximumDate,
|
|
6481
|
-
suggestions
|
|
6482
|
-
} = schema;
|
|
6483
|
-
const { getErrorMessageFunctions, onComponentUpdate, onBehavior } = mapperProps;
|
|
6484
|
-
const errorMessageFunctions = getErrorMessageFunctions(schema.validationMessages);
|
|
6485
|
-
const { performValidationAsync, validationAsyncState } = getValidationAsyncInitialState(
|
|
6486
|
-
schemaMapperProps,
|
|
6487
|
-
mapperProps
|
|
6488
|
-
);
|
|
6489
|
-
const validLocalValue = isString(localValue) ? localValue : null;
|
|
6490
|
-
const validModel = (_a = getValidDate(model)) != null ? _a : getValidDate(defaultValue != null ? defaultValue : null);
|
|
6491
|
-
const value = onPersistAsync ? validLocalValue : validModel;
|
|
6492
|
-
return createDateInputComponent(
|
|
6493
|
-
__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
|
|
6494
|
-
autoComplete: getAutocompleteString(autocompleteHint),
|
|
6495
|
-
checks: schema.hidden ? [] : [
|
|
6496
|
-
getStringRequiredCheck(required, errorMessageFunctions),
|
|
6497
|
-
getValidDateCheck(required, errorMessageFunctions),
|
|
6498
|
-
getAboveMaximumDateCheck(schema, errorMessageFunctions),
|
|
6499
|
-
getBelowMinimumDateCheck(schema, errorMessageFunctions)
|
|
6500
|
-
],
|
|
6501
|
-
minimumDate,
|
|
6502
|
-
maximumDate,
|
|
6503
|
-
suggestions: mapStringSchemaSuggestions(suggestions, mapperProps.logEvent),
|
|
6504
|
-
value,
|
|
6505
|
-
validationAsyncState,
|
|
6506
|
-
schemaOnChange: getSchemaOnChange(schema, onBehavior),
|
|
6507
|
-
performValidationAsync,
|
|
6508
|
-
onValueChange
|
|
6509
|
-
}),
|
|
6510
|
-
onComponentUpdate
|
|
6511
|
-
);
|
|
6512
|
-
};
|
|
6513
|
-
var getValidDate = (model) => {
|
|
6514
|
-
if (!isString(model)) {
|
|
6515
|
-
return null;
|
|
6516
|
-
}
|
|
6517
|
-
if (/^\d{4}-\d{2}$/.test(model)) {
|
|
6518
|
-
return model;
|
|
6519
|
-
}
|
|
6520
|
-
try {
|
|
6521
|
-
const date = new Date(model);
|
|
6522
|
-
const stringDate = date.toISOString();
|
|
6523
|
-
return stringDate.split("T")[0];
|
|
6524
|
-
} catch (e) {
|
|
6525
|
-
return null;
|
|
6526
|
-
}
|
|
6527
|
-
};
|
|
6528
|
-
|
|
6529
6624
|
// src/domain/mappers/schema/stringSchemaToComponent/stringSchemaToUploadInputComponent.ts
|
|
6530
6625
|
var stringSchemaToUploadInputComponent = (schemaMapperProps, mapperProps) => {
|
|
6531
6626
|
var _a;
|
|
@@ -6693,7 +6788,7 @@ var stringSchemaToTextInputComponent = (schemaMapperProps, mapperProps) => {
|
|
|
6693
6788
|
maxLength,
|
|
6694
6789
|
minLength,
|
|
6695
6790
|
pattern,
|
|
6696
|
-
suggestions:
|
|
6791
|
+
suggestions: mapSuggestions(suggestions, mapperProps.logEvent),
|
|
6697
6792
|
value,
|
|
6698
6793
|
validationAsyncState,
|
|
6699
6794
|
schemaOnChange: getSchemaOnChange(schema, onBehavior),
|
|
@@ -6718,7 +6813,12 @@ var stringSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
|
6718
6813
|
}
|
|
6719
6814
|
switch (schema.format) {
|
|
6720
6815
|
case "date":
|
|
6721
|
-
return
|
|
6816
|
+
return dateSchemaToComponent(
|
|
6817
|
+
__spreadProps(__spreadValues({}, schemaMapperProps), {
|
|
6818
|
+
schema: __spreadProps(__spreadValues({}, schema), { type: "date" })
|
|
6819
|
+
}),
|
|
6820
|
+
mapperProps
|
|
6821
|
+
);
|
|
6722
6822
|
default:
|
|
6723
6823
|
return stringSchemaToTextInputComponent(schemaMapperProps, mapperProps);
|
|
6724
6824
|
}
|
|
@@ -6745,6 +6845,9 @@ var mapSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
|
6745
6845
|
if (isBooleanSchema(schema)) {
|
|
6746
6846
|
return booleanSchemaToComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema }), mapperProps);
|
|
6747
6847
|
}
|
|
6848
|
+
if (isDateSchema(schema)) {
|
|
6849
|
+
return dateSchemaToComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema }), mapperProps);
|
|
6850
|
+
}
|
|
6748
6851
|
if (isObjectSchema(schema)) {
|
|
6749
6852
|
const { format } = schema;
|
|
6750
6853
|
if (format === "money") {
|
|
@@ -8007,7 +8110,7 @@ var validation_messages_default = defineMessages2({
|
|
|
8007
8110
|
},
|
|
8008
8111
|
patternDate: {
|
|
8009
8112
|
id: "dynamicFlows.ControlFeedback.patternDate",
|
|
8010
|
-
defaultMessage: "Please enter a date in the
|
|
8113
|
+
defaultMessage: "Please enter a date in the correct format.",
|
|
8011
8114
|
description: ""
|
|
8012
8115
|
},
|
|
8013
8116
|
required: {
|
|
@@ -8116,6 +8219,10 @@ var createErrorMessageFunctions = (validationMessages, formatMessage, locale) =>
|
|
|
8116
8219
|
maximum: formatDate(new Date(maximumDate), locale, formatDateOptions)
|
|
8117
8220
|
});
|
|
8118
8221
|
},
|
|
8222
|
+
invalidDate() {
|
|
8223
|
+
var _a;
|
|
8224
|
+
return (_a = validationMessages.invalidDate) != null ? _a : formatMessage(validation_messages_default.patternDate);
|
|
8225
|
+
},
|
|
8119
8226
|
minLength(minLength) {
|
|
8120
8227
|
var _a;
|
|
8121
8228
|
return (_a = validationMessages.minLength) != null ? _a : formatMessage(validation_messages_default.minLength, {
|
|
@@ -8446,7 +8553,7 @@ var containerComponentToProps = (component, rendererMapperProps) => {
|
|
|
8446
8553
|
};
|
|
8447
8554
|
|
|
8448
8555
|
// src/renderers/mappers/dateInputComponentToProps.ts
|
|
8449
|
-
var dateInputComponentToProps = (component, rendererMapperProps) => __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, inputComponentToProps(component, "input-date")), rendererMapperProps), pick(component, "autoComplete", "minimumDate", "maximumDate", "suggestions")), {
|
|
8556
|
+
var dateInputComponentToProps = (component, rendererMapperProps) => __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, inputComponentToProps(component, "input-date")), rendererMapperProps), pick(component, "autoComplete", "minimumDate", "maximumDate", "availability", "suggestions")), {
|
|
8450
8557
|
onChange: component.setValue
|
|
8451
8558
|
});
|
|
8452
8559
|
|
|
@@ -9493,7 +9600,16 @@ var eventNames = [
|
|
|
9493
9600
|
"Native Subflow Succeeded",
|
|
9494
9601
|
"Native Subflow Failed",
|
|
9495
9602
|
"Native Subflow Cancelled",
|
|
9496
|
-
"Behavior Triggered"
|
|
9603
|
+
"Behavior Triggered",
|
|
9604
|
+
"Collection Search Triggered",
|
|
9605
|
+
"Collection Search Succeeded",
|
|
9606
|
+
"Collection Search Failed",
|
|
9607
|
+
"Collection Filter Triggered",
|
|
9608
|
+
"Collection Filter Succeeded",
|
|
9609
|
+
"Collection Filter Failed",
|
|
9610
|
+
"Collection Pagination Triggered",
|
|
9611
|
+
"Collection Pagination Succeeded",
|
|
9612
|
+
"Collection Pagination Failed"
|
|
9497
9613
|
];
|
|
9498
9614
|
|
|
9499
9615
|
// src/renderers/subflow/getDynamicSubflowRenderer.tsx
|