@wise/dynamic-flow-client 5.24.2 → 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 +263 -186
- package/build/main.mjs +263 -186
- 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/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/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",
|
|
@@ -3918,7 +3918,9 @@ var getBehaviorFromSchemaOnChange = (schema) => {
|
|
|
3918
3918
|
var getBehaviorFromSchemaRefreshStepOnChange = (schema) => {
|
|
3919
3919
|
var _a, _b, _c;
|
|
3920
3920
|
if ("refreshStepOnChange" in schema && ((_a = schema.refreshStepOnChange) != null ? _a : false) || "refreshFormOnChange" in schema && ((_b = schema.refreshFormOnChange) != null ? _b : false)) {
|
|
3921
|
-
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;
|
|
3922
3924
|
const behavior = {
|
|
3923
3925
|
type: "refresh",
|
|
3924
3926
|
analytics: { schema: (_c = analyticsId != null ? analyticsId : $id) != null ? _c : "" },
|
|
@@ -3930,6 +3932,65 @@ var getBehaviorFromSchemaRefreshStepOnChange = (schema) => {
|
|
|
3930
3932
|
return void 0;
|
|
3931
3933
|
};
|
|
3932
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
|
+
|
|
3933
3994
|
// src/domain/features/validation/getPatternRegExp.ts
|
|
3934
3995
|
var getPatternRegExp = (pattern, logEvent) => {
|
|
3935
3996
|
if (!pattern) {
|
|
@@ -4034,13 +4095,13 @@ var getBelowMinimumMoneyAmountCheck = ({ minimum }, messageFunctions) => (value)
|
|
|
4034
4095
|
return null;
|
|
4035
4096
|
};
|
|
4036
4097
|
var getAboveMaximumDateCheck = ({ maximum }, messageFunctions) => (value) => {
|
|
4037
|
-
if (isString(maximum) &&
|
|
4098
|
+
if (isString(maximum) && isValidDate(value) && value > maximum) {
|
|
4038
4099
|
return messageFunctions.maximumDate(maximum);
|
|
4039
4100
|
}
|
|
4040
4101
|
return null;
|
|
4041
4102
|
};
|
|
4042
4103
|
var getBelowMinimumDateCheck = ({ minimum }, messageFunctions) => (value) => {
|
|
4043
|
-
if (isString(minimum) &&
|
|
4104
|
+
if (isString(minimum) && isValidDate(value) && value < minimum) {
|
|
4044
4105
|
return messageFunctions.minimumDate(minimum);
|
|
4045
4106
|
}
|
|
4046
4107
|
return null;
|
|
@@ -4070,11 +4131,12 @@ var getStringRequiredCheck = (required, messageFunctions) => (value) => {
|
|
|
4070
4131
|
return isNullish(value) || value === "" ? messageFunctions.required() : null;
|
|
4071
4132
|
};
|
|
4072
4133
|
var getValidDateCheck = (required, messageFunctions) => (value) => {
|
|
4073
|
-
if (required && !isValidDate(value)) {
|
|
4074
|
-
return messageFunctions.
|
|
4134
|
+
if (required && value && !isValidDate(value)) {
|
|
4135
|
+
return messageFunctions.invalidDate();
|
|
4075
4136
|
}
|
|
4076
4137
|
return null;
|
|
4077
4138
|
};
|
|
4139
|
+
var getUnavailableDateCheck = ({ availability }) => (value) => isValidDate(value) ? getUnavailableDateReason(value, availability) : null;
|
|
4078
4140
|
|
|
4079
4141
|
// src/domain/mappers/utils/getAutocompleteString.ts
|
|
4080
4142
|
var getAutocompleteString = (hints) => {
|
|
@@ -4378,6 +4440,7 @@ var isAllOfSchema = (schema) => "allOf" in schema && !isNullish(schema.allOf);
|
|
|
4378
4440
|
var isBooleanSchema = (schema) => "type" in schema && schema.type === "boolean";
|
|
4379
4441
|
var isBlobSchema = (schema) => "type" in schema && schema.type === "blob";
|
|
4380
4442
|
var isConstSchema = (schema) => "const" in schema && schema.const !== void 0;
|
|
4443
|
+
var isDateSchema = (schema) => "type" in schema && schema.type === "date";
|
|
4381
4444
|
var isIntegerSchema = (schema) => "type" in schema && schema.type === "integer";
|
|
4382
4445
|
var isNumberSchema = (schema) => "type" in schema && schema.type === "number";
|
|
4383
4446
|
var isObjectSchema = (schema) => "type" in schema && schema.type === "object";
|
|
@@ -5520,6 +5583,177 @@ var getConstLayout = (uid, mapperProps, layout, alert) => {
|
|
|
5520
5583
|
);
|
|
5521
5584
|
};
|
|
5522
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
|
+
|
|
5523
5757
|
// src/domain/components/IntegerInputComponent.ts
|
|
5524
5758
|
var createIntegerInputComponent = (props, onComponentUpdate) => {
|
|
5525
5759
|
const _a = props, {
|
|
@@ -6387,175 +6621,6 @@ var persistAsyncSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
|
6387
6621
|
return paComponent;
|
|
6388
6622
|
};
|
|
6389
6623
|
|
|
6390
|
-
// src/domain/components/DateInputComponent.ts
|
|
6391
|
-
var createDateInputComponent = (props, onComponentUpdate) => {
|
|
6392
|
-
const _a = props, {
|
|
6393
|
-
uid,
|
|
6394
|
-
id,
|
|
6395
|
-
checks,
|
|
6396
|
-
schemaOnChange,
|
|
6397
|
-
performValidationAsync,
|
|
6398
|
-
onValueChange,
|
|
6399
|
-
onPersistAsync,
|
|
6400
|
-
summariser,
|
|
6401
|
-
value
|
|
6402
|
-
} = _a, rest = __objRest(_a, [
|
|
6403
|
-
"uid",
|
|
6404
|
-
"id",
|
|
6405
|
-
"checks",
|
|
6406
|
-
"schemaOnChange",
|
|
6407
|
-
"performValidationAsync",
|
|
6408
|
-
"onValueChange",
|
|
6409
|
-
"onPersistAsync",
|
|
6410
|
-
"summariser",
|
|
6411
|
-
"value"
|
|
6412
|
-
]);
|
|
6413
|
-
const update = getInputUpdateFunction(onComponentUpdate);
|
|
6414
|
-
const getValidationErrors = getLocalValueValidator(checks);
|
|
6415
|
-
const validateAsync = performValidationAsync ? getComponentValidationAsync(update, performValidationAsync) : void 0;
|
|
6416
|
-
const component = __spreadValues({
|
|
6417
|
-
type: "date",
|
|
6418
|
-
kind: "input",
|
|
6419
|
-
uid,
|
|
6420
|
-
id,
|
|
6421
|
-
value,
|
|
6422
|
-
onBlur() {
|
|
6423
|
-
const isValid = component.validate();
|
|
6424
|
-
if (isValid) {
|
|
6425
|
-
validateAsync == null ? void 0 : validateAsync(component, component.getLocalValue()).catch(() => {
|
|
6426
|
-
});
|
|
6427
|
-
}
|
|
6428
|
-
},
|
|
6429
|
-
onFocus() {
|
|
6430
|
-
},
|
|
6431
|
-
// Noop
|
|
6432
|
-
setValue(updatedValue) {
|
|
6433
|
-
const prevValue = component.value;
|
|
6434
|
-
update(component, (draft) => {
|
|
6435
|
-
draft.errors = [];
|
|
6436
|
-
draft.validationAsyncState.messages = {};
|
|
6437
|
-
draft.value = updatedValue;
|
|
6438
|
-
});
|
|
6439
|
-
if (isOrWasValid(getValidationErrors, prevValue, updatedValue)) {
|
|
6440
|
-
void (schemaOnChange == null ? void 0 : schemaOnChange());
|
|
6441
|
-
}
|
|
6442
|
-
onValueChange();
|
|
6443
|
-
if (getValidationErrors(updatedValue).length === 0) {
|
|
6444
|
-
void (onPersistAsync == null ? void 0 : onPersistAsync().catch(() => {
|
|
6445
|
-
}));
|
|
6446
|
-
}
|
|
6447
|
-
},
|
|
6448
|
-
async getSubmittableValue() {
|
|
6449
|
-
return component.getSubmittableValueSync();
|
|
6450
|
-
},
|
|
6451
|
-
getSubmittableValueSync() {
|
|
6452
|
-
if (isValidDate(component.getLocalValue())) {
|
|
6453
|
-
return component.getLocalValue();
|
|
6454
|
-
}
|
|
6455
|
-
return null;
|
|
6456
|
-
},
|
|
6457
|
-
getSummary() {
|
|
6458
|
-
return summariser(component.getLocalValue());
|
|
6459
|
-
},
|
|
6460
|
-
getLocalValue() {
|
|
6461
|
-
return component.value;
|
|
6462
|
-
},
|
|
6463
|
-
validate() {
|
|
6464
|
-
const errors = getValidationErrors(component.getLocalValue());
|
|
6465
|
-
update(component, (draft) => {
|
|
6466
|
-
draft.errors = errors;
|
|
6467
|
-
});
|
|
6468
|
-
return errors.length === 0;
|
|
6469
|
-
}
|
|
6470
|
-
}, rest);
|
|
6471
|
-
return component;
|
|
6472
|
-
};
|
|
6473
|
-
|
|
6474
|
-
// src/domain/mappers/utils/suggestions-utils.ts
|
|
6475
|
-
var mapStringSchemaSuggestions = (suggestions, logEvent) => {
|
|
6476
|
-
if (!suggestions) return void 0;
|
|
6477
|
-
return {
|
|
6478
|
-
values: suggestions.values.map((_a) => {
|
|
6479
|
-
var _b = _a, { icon, image, media, value } = _b, rest = __objRest(_b, ["icon", "image", "media", "value"]);
|
|
6480
|
-
if (typeof value !== "string") {
|
|
6481
|
-
logEvent(
|
|
6482
|
-
"warning",
|
|
6483
|
-
`Suggestion values for string schemas must be of type string. Found ${typeof value} instead.`
|
|
6484
|
-
);
|
|
6485
|
-
}
|
|
6486
|
-
return __spreadProps(__spreadValues({}, rest), {
|
|
6487
|
-
media: getDomainLayerMedia({ icon, image, media }),
|
|
6488
|
-
value,
|
|
6489
|
-
tags: mapTags(rest)
|
|
6490
|
-
});
|
|
6491
|
-
})
|
|
6492
|
-
};
|
|
6493
|
-
};
|
|
6494
|
-
|
|
6495
|
-
// src/domain/mappers/schema/stringSchemaToComponent/stringSchemaToDateInputComponent.ts
|
|
6496
|
-
var stringSchemaToDateInputComponent = (schemaMapperProps, mapperProps) => {
|
|
6497
|
-
var _a;
|
|
6498
|
-
const {
|
|
6499
|
-
schema,
|
|
6500
|
-
localValue,
|
|
6501
|
-
model,
|
|
6502
|
-
required = false,
|
|
6503
|
-
onPersistAsync,
|
|
6504
|
-
onValueChange
|
|
6505
|
-
} = schemaMapperProps;
|
|
6506
|
-
const {
|
|
6507
|
-
autocompleteHint,
|
|
6508
|
-
default: defaultValue,
|
|
6509
|
-
minimum: minimumDate,
|
|
6510
|
-
maximum: maximumDate,
|
|
6511
|
-
suggestions
|
|
6512
|
-
} = schema;
|
|
6513
|
-
const { getErrorMessageFunctions, onComponentUpdate, onBehavior } = mapperProps;
|
|
6514
|
-
const errorMessageFunctions = getErrorMessageFunctions(schema.validationMessages);
|
|
6515
|
-
const { performValidationAsync, validationAsyncState } = getValidationAsyncInitialState(
|
|
6516
|
-
schemaMapperProps,
|
|
6517
|
-
mapperProps
|
|
6518
|
-
);
|
|
6519
|
-
const validLocalValue = isString(localValue) ? localValue : null;
|
|
6520
|
-
const validModel = (_a = getValidDate(model)) != null ? _a : getValidDate(defaultValue != null ? defaultValue : null);
|
|
6521
|
-
const value = onPersistAsync ? validLocalValue : validModel;
|
|
6522
|
-
return createDateInputComponent(
|
|
6523
|
-
__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
|
|
6524
|
-
autoComplete: getAutocompleteString(autocompleteHint),
|
|
6525
|
-
checks: schema.hidden ? [] : [
|
|
6526
|
-
getStringRequiredCheck(required, errorMessageFunctions),
|
|
6527
|
-
getValidDateCheck(required, errorMessageFunctions),
|
|
6528
|
-
getAboveMaximumDateCheck(schema, errorMessageFunctions),
|
|
6529
|
-
getBelowMinimumDateCheck(schema, errorMessageFunctions)
|
|
6530
|
-
],
|
|
6531
|
-
minimumDate,
|
|
6532
|
-
maximumDate,
|
|
6533
|
-
suggestions: mapStringSchemaSuggestions(suggestions, mapperProps.logEvent),
|
|
6534
|
-
value,
|
|
6535
|
-
validationAsyncState,
|
|
6536
|
-
schemaOnChange: getSchemaOnChange(schema, onBehavior),
|
|
6537
|
-
performValidationAsync,
|
|
6538
|
-
onValueChange
|
|
6539
|
-
}),
|
|
6540
|
-
onComponentUpdate
|
|
6541
|
-
);
|
|
6542
|
-
};
|
|
6543
|
-
var getValidDate = (model) => {
|
|
6544
|
-
if (!isString(model)) {
|
|
6545
|
-
return null;
|
|
6546
|
-
}
|
|
6547
|
-
if (/^\d{4}-\d{2}$/.test(model)) {
|
|
6548
|
-
return model;
|
|
6549
|
-
}
|
|
6550
|
-
try {
|
|
6551
|
-
const date = new Date(model);
|
|
6552
|
-
const stringDate = date.toISOString();
|
|
6553
|
-
return stringDate.split("T")[0];
|
|
6554
|
-
} catch (e) {
|
|
6555
|
-
return null;
|
|
6556
|
-
}
|
|
6557
|
-
};
|
|
6558
|
-
|
|
6559
6624
|
// src/domain/mappers/schema/stringSchemaToComponent/stringSchemaToUploadInputComponent.ts
|
|
6560
6625
|
var stringSchemaToUploadInputComponent = (schemaMapperProps, mapperProps) => {
|
|
6561
6626
|
var _a;
|
|
@@ -6723,7 +6788,7 @@ var stringSchemaToTextInputComponent = (schemaMapperProps, mapperProps) => {
|
|
|
6723
6788
|
maxLength,
|
|
6724
6789
|
minLength,
|
|
6725
6790
|
pattern,
|
|
6726
|
-
suggestions:
|
|
6791
|
+
suggestions: mapSuggestions(suggestions, mapperProps.logEvent),
|
|
6727
6792
|
value,
|
|
6728
6793
|
validationAsyncState,
|
|
6729
6794
|
schemaOnChange: getSchemaOnChange(schema, onBehavior),
|
|
@@ -6748,7 +6813,12 @@ var stringSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
|
6748
6813
|
}
|
|
6749
6814
|
switch (schema.format) {
|
|
6750
6815
|
case "date":
|
|
6751
|
-
return
|
|
6816
|
+
return dateSchemaToComponent(
|
|
6817
|
+
__spreadProps(__spreadValues({}, schemaMapperProps), {
|
|
6818
|
+
schema: __spreadProps(__spreadValues({}, schema), { type: "date" })
|
|
6819
|
+
}),
|
|
6820
|
+
mapperProps
|
|
6821
|
+
);
|
|
6752
6822
|
default:
|
|
6753
6823
|
return stringSchemaToTextInputComponent(schemaMapperProps, mapperProps);
|
|
6754
6824
|
}
|
|
@@ -6775,6 +6845,9 @@ var mapSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
|
6775
6845
|
if (isBooleanSchema(schema)) {
|
|
6776
6846
|
return booleanSchemaToComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema }), mapperProps);
|
|
6777
6847
|
}
|
|
6848
|
+
if (isDateSchema(schema)) {
|
|
6849
|
+
return dateSchemaToComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema }), mapperProps);
|
|
6850
|
+
}
|
|
6778
6851
|
if (isObjectSchema(schema)) {
|
|
6779
6852
|
const { format } = schema;
|
|
6780
6853
|
if (format === "money") {
|
|
@@ -8037,7 +8110,7 @@ var validation_messages_default = defineMessages2({
|
|
|
8037
8110
|
},
|
|
8038
8111
|
patternDate: {
|
|
8039
8112
|
id: "dynamicFlows.ControlFeedback.patternDate",
|
|
8040
|
-
defaultMessage: "Please enter a date in the
|
|
8113
|
+
defaultMessage: "Please enter a date in the correct format.",
|
|
8041
8114
|
description: ""
|
|
8042
8115
|
},
|
|
8043
8116
|
required: {
|
|
@@ -8146,6 +8219,10 @@ var createErrorMessageFunctions = (validationMessages, formatMessage, locale) =>
|
|
|
8146
8219
|
maximum: formatDate(new Date(maximumDate), locale, formatDateOptions)
|
|
8147
8220
|
});
|
|
8148
8221
|
},
|
|
8222
|
+
invalidDate() {
|
|
8223
|
+
var _a;
|
|
8224
|
+
return (_a = validationMessages.invalidDate) != null ? _a : formatMessage(validation_messages_default.patternDate);
|
|
8225
|
+
},
|
|
8149
8226
|
minLength(minLength) {
|
|
8150
8227
|
var _a;
|
|
8151
8228
|
return (_a = validationMessages.minLength) != null ? _a : formatMessage(validation_messages_default.minLength, {
|
|
@@ -8476,7 +8553,7 @@ var containerComponentToProps = (component, rendererMapperProps) => {
|
|
|
8476
8553
|
};
|
|
8477
8554
|
|
|
8478
8555
|
// src/renderers/mappers/dateInputComponentToProps.ts
|
|
8479
|
-
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")), {
|
|
8480
8557
|
onChange: component.setValue
|
|
8481
8558
|
});
|
|
8482
8559
|
|