@wise/dynamic-flow-client 5.24.2 → 5.25.1

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.
Files changed (39) hide show
  1. package/build/i18n/ar.json +1 -1
  2. package/build/i18n/cs.json +1 -1
  3. package/build/i18n/en.json +1 -1
  4. package/build/i18n/es.json +1 -1
  5. package/build/i18n/id.json +1 -1
  6. package/build/i18n/ko.json +1 -1
  7. package/build/i18n/nl.json +1 -1
  8. package/build/i18n/sv.json +1 -1
  9. package/build/i18n/th.json +1 -1
  10. package/build/i18n/zh_CN.json +1 -1
  11. package/build/i18n/zh_HK.json +1 -1
  12. package/build/main.css +80 -0
  13. package/build/main.js +264 -187
  14. package/build/main.mjs +264 -187
  15. package/build/tsconfig.types.tsbuildinfo +1 -1
  16. package/build/types/domain/components/DateInputComponent.d.ts +3 -1
  17. package/build/types/domain/components/DateInputComponent.d.ts.map +1 -1
  18. package/build/types/domain/features/validation/date-availability.d.ts +5 -0
  19. package/build/types/domain/features/validation/date-availability.d.ts.map +1 -0
  20. package/build/types/domain/features/validation/spec-utils.d.ts.map +1 -1
  21. package/build/types/domain/features/validation/value-checks.d.ts +4 -3
  22. package/build/types/domain/features/validation/value-checks.d.ts.map +1 -1
  23. package/build/types/domain/mappers/mapSchemaToComponent.d.ts.map +1 -1
  24. package/build/types/domain/mappers/schema/dateSchemaToComponent.d.ts +6 -0
  25. package/build/types/domain/mappers/schema/dateSchemaToComponent.d.ts.map +1 -0
  26. package/build/types/domain/mappers/schema/persistAsyncSchemaToComponent.d.ts +1 -0
  27. package/build/types/domain/mappers/schema/persistAsyncSchemaToComponent.d.ts.map +1 -1
  28. package/build/types/domain/mappers/schema/stringSchemaToComponent/stringSchemaToComponent.d.ts.map +1 -1
  29. package/build/types/domain/mappers/types.d.ts +1 -0
  30. package/build/types/domain/mappers/types.d.ts.map +1 -1
  31. package/build/types/domain/mappers/utils/suggestions-utils.d.ts +2 -2
  32. package/build/types/domain/mappers/utils/suggestions-utils.d.ts.map +1 -1
  33. package/build/types/utils/type-utils.d.ts +3 -2
  34. package/build/types/utils/type-utils.d.ts.map +1 -1
  35. package/build/types/utils/type-validators.d.ts +1 -1
  36. package/build/types/utils/type-validators.d.ts.map +1 -1
  37. package/package.json +27 -27
  38. package/build/types/domain/mappers/schema/stringSchemaToComponent/stringSchemaToDateInputComponent.d.ts +0 -6
  39. 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 pros\xEDm datum ve spr\xE1vn\xE9m form\xE1tu.",
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 corrrect format.",
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 un formato correcto.",
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": "Harap masukkan tanggal dalam format yang benar.",
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 indeling in.",
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\u0E1B\u0E49\u0E2D\u0E19\u0E27\u0E31\u0E19\u0E17\u0E35\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\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",
@@ -1357,7 +1357,7 @@ var normaliseBehavior = (behavior, stepActions) => {
1357
1357
  if (behavior.type === "delay") {
1358
1358
  return __spreadProps(__spreadValues({}, behavior), {
1359
1359
  behavior: normaliseBehavior(behavior.behavior, stepActions),
1360
- track: false
1360
+ track: true
1361
1361
  });
1362
1362
  }
1363
1363
  if (behavior.type === "dispatch-event") {
@@ -3949,7 +3949,9 @@ var getBehaviorFromSchemaOnChange = (schema) => {
3949
3949
  var getBehaviorFromSchemaRefreshStepOnChange = (schema) => {
3950
3950
  var _a, _b, _c;
3951
3951
  if ("refreshStepOnChange" in schema && ((_a = schema.refreshStepOnChange) != null ? _a : false) || "refreshFormOnChange" in schema && ((_b = schema.refreshFormOnChange) != null ? _b : false)) {
3952
- const { $id, analyticsId, refreshUrl, refreshFormUrl } = schema;
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;
3953
3955
  const behavior = {
3954
3956
  type: "refresh",
3955
3957
  analytics: { schema: (_c = analyticsId != null ? analyticsId : $id) != null ? _c : "" },
@@ -3961,6 +3963,65 @@ var getBehaviorFromSchemaRefreshStepOnChange = (schema) => {
3961
3963
  return void 0;
3962
3964
  };
3963
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
+
3964
4025
  // src/domain/features/validation/getPatternRegExp.ts
3965
4026
  var getPatternRegExp = (pattern, logEvent) => {
3966
4027
  if (!pattern) {
@@ -4065,13 +4126,13 @@ var getBelowMinimumMoneyAmountCheck = ({ minimum }, messageFunctions) => (value)
4065
4126
  return null;
4066
4127
  };
4067
4128
  var getAboveMaximumDateCheck = ({ maximum }, messageFunctions) => (value) => {
4068
- if (isString(maximum) && isString(value) && value > maximum) {
4129
+ if (isString(maximum) && isValidDate(value) && value > maximum) {
4069
4130
  return messageFunctions.maximumDate(maximum);
4070
4131
  }
4071
4132
  return null;
4072
4133
  };
4073
4134
  var getBelowMinimumDateCheck = ({ minimum }, messageFunctions) => (value) => {
4074
- if (isString(minimum) && isString(value) && value && value < minimum) {
4135
+ if (isString(minimum) && isValidDate(value) && value < minimum) {
4075
4136
  return messageFunctions.minimumDate(minimum);
4076
4137
  }
4077
4138
  return null;
@@ -4101,11 +4162,12 @@ var getStringRequiredCheck = (required, messageFunctions) => (value) => {
4101
4162
  return isNullish(value) || value === "" ? messageFunctions.required() : null;
4102
4163
  };
4103
4164
  var getValidDateCheck = (required, messageFunctions) => (value) => {
4104
- if (required && !isValidDate(value)) {
4105
- return messageFunctions.required();
4165
+ if (required && value && !isValidDate(value)) {
4166
+ return messageFunctions.invalidDate();
4106
4167
  }
4107
4168
  return null;
4108
4169
  };
4170
+ var getUnavailableDateCheck = ({ availability }) => (value) => isValidDate(value) ? getUnavailableDateReason(value, availability) : null;
4109
4171
 
4110
4172
  // src/domain/mappers/utils/getAutocompleteString.ts
4111
4173
  var getAutocompleteString = (hints) => {
@@ -4409,6 +4471,7 @@ var isAllOfSchema = (schema) => "allOf" in schema && !isNullish(schema.allOf);
4409
4471
  var isBooleanSchema = (schema) => "type" in schema && schema.type === "boolean";
4410
4472
  var isBlobSchema = (schema) => "type" in schema && schema.type === "blob";
4411
4473
  var isConstSchema = (schema) => "const" in schema && schema.const !== void 0;
4474
+ var isDateSchema = (schema) => "type" in schema && schema.type === "date";
4412
4475
  var isIntegerSchema = (schema) => "type" in schema && schema.type === "integer";
4413
4476
  var isNumberSchema = (schema) => "type" in schema && schema.type === "number";
4414
4477
  var isObjectSchema = (schema) => "type" in schema && schema.type === "object";
@@ -5551,6 +5614,177 @@ var getConstLayout = (uid, mapperProps, layout, alert) => {
5551
5614
  );
5552
5615
  };
5553
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
+
5554
5788
  // src/domain/components/IntegerInputComponent.ts
5555
5789
  var createIntegerInputComponent = (props, onComponentUpdate) => {
5556
5790
  const _a = props, {
@@ -6418,175 +6652,6 @@ var persistAsyncSchemaToComponent = (schemaMapperProps, mapperProps) => {
6418
6652
  return paComponent;
6419
6653
  };
6420
6654
 
6421
- // src/domain/components/DateInputComponent.ts
6422
- var createDateInputComponent = (props, onComponentUpdate) => {
6423
- const _a = props, {
6424
- uid,
6425
- id,
6426
- checks,
6427
- schemaOnChange,
6428
- performValidationAsync,
6429
- onValueChange,
6430
- onPersistAsync,
6431
- summariser,
6432
- value
6433
- } = _a, rest = __objRest(_a, [
6434
- "uid",
6435
- "id",
6436
- "checks",
6437
- "schemaOnChange",
6438
- "performValidationAsync",
6439
- "onValueChange",
6440
- "onPersistAsync",
6441
- "summariser",
6442
- "value"
6443
- ]);
6444
- const update = getInputUpdateFunction(onComponentUpdate);
6445
- const getValidationErrors = getLocalValueValidator(checks);
6446
- const validateAsync = performValidationAsync ? getComponentValidationAsync(update, performValidationAsync) : void 0;
6447
- const component = __spreadValues({
6448
- type: "date",
6449
- kind: "input",
6450
- uid,
6451
- id,
6452
- value,
6453
- onBlur() {
6454
- const isValid = component.validate();
6455
- if (isValid) {
6456
- validateAsync == null ? void 0 : validateAsync(component, component.getLocalValue()).catch(() => {
6457
- });
6458
- }
6459
- },
6460
- onFocus() {
6461
- },
6462
- // Noop
6463
- setValue(updatedValue) {
6464
- const prevValue = component.value;
6465
- update(component, (draft) => {
6466
- draft.errors = [];
6467
- draft.validationAsyncState.messages = {};
6468
- draft.value = updatedValue;
6469
- });
6470
- if (isOrWasValid(getValidationErrors, prevValue, updatedValue)) {
6471
- void (schemaOnChange == null ? void 0 : schemaOnChange());
6472
- }
6473
- onValueChange();
6474
- if (getValidationErrors(updatedValue).length === 0) {
6475
- void (onPersistAsync == null ? void 0 : onPersistAsync().catch(() => {
6476
- }));
6477
- }
6478
- },
6479
- async getSubmittableValue() {
6480
- return component.getSubmittableValueSync();
6481
- },
6482
- getSubmittableValueSync() {
6483
- if (isValidDate(component.getLocalValue())) {
6484
- return component.getLocalValue();
6485
- }
6486
- return null;
6487
- },
6488
- getSummary() {
6489
- return summariser(component.getLocalValue());
6490
- },
6491
- getLocalValue() {
6492
- return component.value;
6493
- },
6494
- validate() {
6495
- const errors = getValidationErrors(component.getLocalValue());
6496
- update(component, (draft) => {
6497
- draft.errors = errors;
6498
- });
6499
- return errors.length === 0;
6500
- }
6501
- }, rest);
6502
- return component;
6503
- };
6504
-
6505
- // src/domain/mappers/utils/suggestions-utils.ts
6506
- var mapStringSchemaSuggestions = (suggestions, logEvent) => {
6507
- if (!suggestions) return void 0;
6508
- return {
6509
- values: suggestions.values.map((_a) => {
6510
- var _b = _a, { icon, image, media, value } = _b, rest = __objRest(_b, ["icon", "image", "media", "value"]);
6511
- if (typeof value !== "string") {
6512
- logEvent(
6513
- "warning",
6514
- `Suggestion values for string schemas must be of type string. Found ${typeof value} instead.`
6515
- );
6516
- }
6517
- return __spreadProps(__spreadValues({}, rest), {
6518
- media: getDomainLayerMedia({ icon, image, media }),
6519
- value,
6520
- tags: mapTags(rest)
6521
- });
6522
- })
6523
- };
6524
- };
6525
-
6526
- // src/domain/mappers/schema/stringSchemaToComponent/stringSchemaToDateInputComponent.ts
6527
- var stringSchemaToDateInputComponent = (schemaMapperProps, mapperProps) => {
6528
- var _a;
6529
- const {
6530
- schema,
6531
- localValue,
6532
- model,
6533
- required = false,
6534
- onPersistAsync,
6535
- onValueChange
6536
- } = schemaMapperProps;
6537
- const {
6538
- autocompleteHint,
6539
- default: defaultValue,
6540
- minimum: minimumDate,
6541
- maximum: maximumDate,
6542
- suggestions
6543
- } = schema;
6544
- const { getErrorMessageFunctions, onComponentUpdate, onBehavior } = mapperProps;
6545
- const errorMessageFunctions = getErrorMessageFunctions(schema.validationMessages);
6546
- const { performValidationAsync, validationAsyncState } = getValidationAsyncInitialState(
6547
- schemaMapperProps,
6548
- mapperProps
6549
- );
6550
- const validLocalValue = isString(localValue) ? localValue : null;
6551
- const validModel = (_a = getValidDate(model)) != null ? _a : getValidDate(defaultValue != null ? defaultValue : null);
6552
- const value = onPersistAsync ? validLocalValue : validModel;
6553
- return createDateInputComponent(
6554
- __spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
6555
- autoComplete: getAutocompleteString(autocompleteHint),
6556
- checks: schema.hidden ? [] : [
6557
- getStringRequiredCheck(required, errorMessageFunctions),
6558
- getValidDateCheck(required, errorMessageFunctions),
6559
- getAboveMaximumDateCheck(schema, errorMessageFunctions),
6560
- getBelowMinimumDateCheck(schema, errorMessageFunctions)
6561
- ],
6562
- minimumDate,
6563
- maximumDate,
6564
- suggestions: mapStringSchemaSuggestions(suggestions, mapperProps.logEvent),
6565
- value,
6566
- validationAsyncState,
6567
- schemaOnChange: getSchemaOnChange(schema, onBehavior),
6568
- performValidationAsync,
6569
- onValueChange
6570
- }),
6571
- onComponentUpdate
6572
- );
6573
- };
6574
- var getValidDate = (model) => {
6575
- if (!isString(model)) {
6576
- return null;
6577
- }
6578
- if (/^\d{4}-\d{2}$/.test(model)) {
6579
- return model;
6580
- }
6581
- try {
6582
- const date = new Date(model);
6583
- const stringDate = date.toISOString();
6584
- return stringDate.split("T")[0];
6585
- } catch (e) {
6586
- return null;
6587
- }
6588
- };
6589
-
6590
6655
  // src/domain/mappers/schema/stringSchemaToComponent/stringSchemaToUploadInputComponent.ts
6591
6656
  var stringSchemaToUploadInputComponent = (schemaMapperProps, mapperProps) => {
6592
6657
  var _a;
@@ -6754,7 +6819,7 @@ var stringSchemaToTextInputComponent = (schemaMapperProps, mapperProps) => {
6754
6819
  maxLength,
6755
6820
  minLength,
6756
6821
  pattern,
6757
- suggestions: mapStringSchemaSuggestions(suggestions, mapperProps.logEvent),
6822
+ suggestions: mapSuggestions(suggestions, mapperProps.logEvent),
6758
6823
  value,
6759
6824
  validationAsyncState,
6760
6825
  schemaOnChange: getSchemaOnChange(schema, onBehavior),
@@ -6779,7 +6844,12 @@ var stringSchemaToComponent = (schemaMapperProps, mapperProps) => {
6779
6844
  }
6780
6845
  switch (schema.format) {
6781
6846
  case "date":
6782
- return stringSchemaToDateInputComponent(schemaMapperProps, mapperProps);
6847
+ return dateSchemaToComponent(
6848
+ __spreadProps(__spreadValues({}, schemaMapperProps), {
6849
+ schema: __spreadProps(__spreadValues({}, schema), { type: "date" })
6850
+ }),
6851
+ mapperProps
6852
+ );
6783
6853
  default:
6784
6854
  return stringSchemaToTextInputComponent(schemaMapperProps, mapperProps);
6785
6855
  }
@@ -6806,6 +6876,9 @@ var mapSchemaToComponent = (schemaMapperProps, mapperProps) => {
6806
6876
  if (isBooleanSchema(schema)) {
6807
6877
  return booleanSchemaToComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema }), mapperProps);
6808
6878
  }
6879
+ if (isDateSchema(schema)) {
6880
+ return dateSchemaToComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema }), mapperProps);
6881
+ }
6809
6882
  if (isObjectSchema(schema)) {
6810
6883
  const { format } = schema;
6811
6884
  if (format === "money") {
@@ -8068,7 +8141,7 @@ var validation_messages_default = (0, import_react_intl3.defineMessages)({
8068
8141
  },
8069
8142
  patternDate: {
8070
8143
  id: "dynamicFlows.ControlFeedback.patternDate",
8071
- defaultMessage: "Please enter a date in the corrrect format.",
8144
+ defaultMessage: "Please enter a date in the correct format.",
8072
8145
  description: ""
8073
8146
  },
8074
8147
  required: {
@@ -8177,6 +8250,10 @@ var createErrorMessageFunctions = (validationMessages, formatMessage, locale) =>
8177
8250
  maximum: (0, import_formatting.formatDate)(new Date(maximumDate), locale, formatDateOptions)
8178
8251
  });
8179
8252
  },
8253
+ invalidDate() {
8254
+ var _a;
8255
+ return (_a = validationMessages.invalidDate) != null ? _a : formatMessage(validation_messages_default.patternDate);
8256
+ },
8180
8257
  minLength(minLength) {
8181
8258
  var _a;
8182
8259
  return (_a = validationMessages.minLength) != null ? _a : formatMessage(validation_messages_default.minLength, {
@@ -8507,7 +8584,7 @@ var containerComponentToProps = (component, rendererMapperProps) => {
8507
8584
  };
8508
8585
 
8509
8586
  // src/renderers/mappers/dateInputComponentToProps.ts
8510
- 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")), {
8511
8588
  onChange: component.setValue
8512
8589
  });
8513
8590