@wise/dynamic-flow-client 4.5.1 → 4.5.3-experimental-sca-error-handling-8133bb0

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 (25) hide show
  1. package/build/main.js +1368 -1361
  2. package/build/main.mjs +1400 -1393
  3. package/build/types/index.d.ts +1 -1
  4. package/build/types/revamp/domain/components/AllOfComponent.d.ts +3 -2
  5. package/build/types/revamp/domain/components/BooleanInputComponent.d.ts +1 -1
  6. package/build/types/revamp/domain/components/DateInputComponent.d.ts +1 -1
  7. package/build/types/revamp/domain/components/IntegerInputComponent.d.ts +1 -1
  8. package/build/types/revamp/domain/components/MultiSelectInputComponent.d.ts +1 -1
  9. package/build/types/revamp/domain/components/MultiUploadInputComponent.d.ts +1 -1
  10. package/build/types/revamp/domain/components/NumberInputComponent.d.ts +1 -1
  11. package/build/types/revamp/domain/components/ObjectComponent.d.ts +3 -2
  12. package/build/types/revamp/domain/components/RepeatableComponent.d.ts +3 -2
  13. package/build/types/revamp/domain/components/SelectInputComponent.d.ts +1 -1
  14. package/build/types/revamp/domain/components/TextInputComponent.d.ts +1 -1
  15. package/build/types/revamp/domain/components/TupleComponent.d.ts +3 -2
  16. package/build/types/revamp/domain/components/UploadInputComponent.d.ts +1 -1
  17. package/build/types/revamp/domain/mappers/schema/constSchemaToComponent.d.ts +1 -1
  18. package/build/types/revamp/domain/mappers/schema/utils/mapCommonSchemaProps.d.ts +1 -0
  19. package/build/types/revamp/domain/mappers/utils/utils.d.ts +2 -1
  20. package/build/types/revamp/domain/types.d.ts +2 -1
  21. package/build/types/revamp/renderers/mappers/allOfComponentToProps.d.ts +2 -2
  22. package/build/types/revamp/renderers/mappers/componentToRendererProps.d.ts +1 -1
  23. package/build/types/revamp/renderers/mappers/objectComponentToProps.d.ts +2 -2
  24. package/build/types/revamp/renderers/mappers/tupleComponentToProps.d.ts +2 -2
  25. package/package.json +6 -6
package/build/main.js CHANGED
@@ -1046,6 +1046,11 @@ var ErrorBoundary = class extends import_react.Component {
1046
1046
  };
1047
1047
  var ErrorBoundary_default = ErrorBoundary;
1048
1048
 
1049
+ // src/revamp/flow/getErrorMessage.ts
1050
+ var getErrorMessage = (error) => {
1051
+ return error instanceof Error ? error.message : typeof error === "string" ? error : `Unknown Error: type is ${typeof error}`;
1052
+ };
1053
+
1049
1054
  // src/revamp/renderers/CoreContainerRenderer.tsx
1050
1055
  var import_jsx_runtime3 = require("react/jsx-runtime");
1051
1056
  var CoreContainerRenderer = {
@@ -1082,7 +1087,7 @@ function getChildren(node) {
1082
1087
  case "box":
1083
1088
  case "container":
1084
1089
  case "form":
1085
- case "section":
1090
+ case "form-section":
1086
1091
  case "step":
1087
1092
  case "modal-content":
1088
1093
  return node.childrenProps;
@@ -1181,6 +1186,39 @@ var isStringSchema = (schema) => "type" in schema && schema.type === "string";
1181
1186
  var isStringSchemaWithUpload = (schema) => isStringSchema(schema) && schema.format === "base64url";
1182
1187
  var isSchemaWithPersistAsync = (schema) => "persistAsync" in schema && !isNullish(schema.persistAsync);
1183
1188
 
1189
+ // src/revamp/renderers/stepComponentToProps.ts
1190
+ var stepComponentToProps = (component, rendererMapperProps) => {
1191
+ const {
1192
+ uid,
1193
+ back,
1194
+ control,
1195
+ description,
1196
+ error,
1197
+ loadingState,
1198
+ step,
1199
+ title,
1200
+ onBehavior
1201
+ } = component;
1202
+ const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
1203
+ return __spreadValues({
1204
+ type: "step",
1205
+ id: step.id,
1206
+ uid,
1207
+ back,
1208
+ control,
1209
+ description,
1210
+ error,
1211
+ loadingState,
1212
+ step,
1213
+ title,
1214
+ children: childrenProps.map(rendererMapperProps.render),
1215
+ childrenProps,
1216
+ onAction: (action) => {
1217
+ void onBehavior({ type: "action", action });
1218
+ }
1219
+ }, rendererMapperProps);
1220
+ };
1221
+
1184
1222
  // src/revamp/renderers/mappers/utils/pick.ts
1185
1223
  function pick(obj, ...keys) {
1186
1224
  const result = {};
@@ -1199,7 +1237,7 @@ var allOfComponentToProps = (component, rendererMapperProps) => {
1199
1237
  (c) => componentToRendererProps(c, rendererMapperProps)
1200
1238
  );
1201
1239
  return __spreadProps(__spreadValues(__spreadValues({
1202
- type: "section"
1240
+ type: "form-section"
1203
1241
  }, pick(component, "uid", "control", "description", "help", "icon", "image", "title")), rendererMapperProps), {
1204
1242
  children: childrenProps.map(rendererMapperProps.render),
1205
1243
  childrenProps
@@ -1374,6 +1412,19 @@ var decisionComponentToProps = (component, rendererMapperProps) => __spreadProps
1374
1412
  // src/revamp/renderers/mappers/dividerComponentToProps.ts
1375
1413
  var dividerComponentToProps = (component, rendererMapperProps) => __spreadValues(__spreadValues({}, pick(component, "uid", "type", "control", "margin")), rendererMapperProps);
1376
1414
 
1415
+ // src/revamp/renderers/mappers/externalComponentToProps.ts
1416
+ var externalComponentToProps = (component, rendererMapperProps) => {
1417
+ return __spreadValues({
1418
+ type: "external-confirmation",
1419
+ uid: component.uid,
1420
+ url: component.url,
1421
+ status: component.status,
1422
+ onSuccess: component.onSuccess.bind(component),
1423
+ onFailure: component.onFailure.bind(component),
1424
+ onCancel: component.onCancel.bind(component)
1425
+ }, rendererMapperProps);
1426
+ };
1427
+
1377
1428
  // src/revamp/renderers/mappers/formComponentToProps.ts
1378
1429
  var formComponentToProps = (component, rendererMapperProps) => {
1379
1430
  const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
@@ -1414,6 +1465,20 @@ var integerInputComponentToProps = (component, rendererMapperProps) => __spreadP
1414
1465
  onChange: component.onChange.bind(component)
1415
1466
  });
1416
1467
 
1468
+ // src/revamp/renderers/mappers/listComponentToProps.ts
1469
+ var listComponentToProps = (component, rendererMapperProps) => __spreadProps(__spreadValues(__spreadValues({}, pick(component, "uid", "type", "callToAction", "control", "margin", "title")), rendererMapperProps), {
1470
+ items: component.items.map(mapItem)
1471
+ });
1472
+ var mapItem = (item) => {
1473
+ var _a, _b;
1474
+ return __spreadProps(__spreadValues({}, item), {
1475
+ // populate deprecated fields
1476
+ subtitle: item.description,
1477
+ value: (_a = item.supportingValues) == null ? void 0 : _a.value,
1478
+ subvalue: (_b = item.supportingValues) == null ? void 0 : _b.subvalue
1479
+ });
1480
+ };
1481
+
1417
1482
  // src/revamp/renderers/mappers/loadingIndicatorComponentToProps.ts
1418
1483
  var loadingIndicatorComponentToProps = (component, rendererMapperProps) => __spreadValues(__spreadValues({}, pick(component, "uid", "type", "control", "margin", "size")), rendererMapperProps);
1419
1484
 
@@ -1438,6 +1503,35 @@ var modalComponentToProps = (component, rendererMapperProps) => {
1438
1503
  }, rendererMapperProps);
1439
1504
  };
1440
1505
 
1506
+ // src/revamp/renderers/mappers/modalContentComponentToProps.ts
1507
+ var modalContentComponentToProps = (component, rendererMapperProps) => {
1508
+ const { uid, open, title, close } = component;
1509
+ const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
1510
+ return __spreadValues({
1511
+ uid,
1512
+ type: "modal-content",
1513
+ open,
1514
+ title,
1515
+ children: childrenProps.map(rendererMapperProps.render),
1516
+ childrenProps,
1517
+ onClose: close.bind(component)
1518
+ }, rendererMapperProps);
1519
+ };
1520
+
1521
+ // src/revamp/renderers/mappers/multiSelectComponentToProps.ts
1522
+ var multiSelectInputComponentToProps = (component, rendererMapperProps) => {
1523
+ const { autoComplete, maxItems, minItems, options, selectedIndices, onSelect } = component;
1524
+ const _a = inputComponentToProps(component, "input-multi-select"), { required, value } = _a, props = __objRest(_a, ["required", "value"]);
1525
+ return __spreadProps(__spreadValues(__spreadValues({}, props), rendererMapperProps), {
1526
+ autoComplete,
1527
+ maxItems,
1528
+ minItems,
1529
+ options,
1530
+ selectedIndices,
1531
+ onSelect: onSelect.bind(component)
1532
+ });
1533
+ };
1534
+
1441
1535
  // src/revamp/renderers/mappers/multiUploadInputComponentToProps.ts
1442
1536
  var multiUploadInputComponentToProps = (component, rendererMapperProps) => {
1443
1537
  const { accepts, cameraConfig, files, maxSize, minItems, maxItems, source, uploadLabel } = component;
@@ -1468,7 +1562,7 @@ var numberInputComponentToProps = (component, rendererMapperProps) => __spreadPr
1468
1562
  var objectComponentToProps = (component, rendererMapperProps) => {
1469
1563
  const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
1470
1564
  return __spreadProps(__spreadValues(__spreadValues({
1471
- type: "section"
1565
+ type: "form-section"
1472
1566
  }, pick(component, "uid", "control", "description", "help", "icon", "image", "title")), rendererMapperProps), {
1473
1567
  children: childrenProps.map(rendererMapperProps.render),
1474
1568
  childrenProps
@@ -1545,6 +1639,17 @@ var reviewComponentToProps = (component, rendererMapperProps) => __spreadValues(
1545
1639
  }), rendererMapperProps);
1546
1640
  var mapField = (field) => __spreadValues({}, field);
1547
1641
 
1642
+ // src/revamp/renderers/mappers/rootComponentToProps.ts
1643
+ var rootComponentToProps = (rootComponent, rendererMapperProps) => {
1644
+ const childrenProps = rootComponent.getChildren().map((child) => componentToRendererProps(child, rendererMapperProps));
1645
+ return __spreadValues({
1646
+ type: "root",
1647
+ uid: rootComponent.uid,
1648
+ children: childrenProps.map(rendererMapperProps.render),
1649
+ childrenProps
1650
+ }, rendererMapperProps);
1651
+ };
1652
+
1548
1653
  // src/revamp/domain/mappers/utils/image.ts
1549
1654
  var mapSpecImage = (image) => {
1550
1655
  var _a, _b, _c;
@@ -1640,17 +1745,14 @@ var textInputComponentToProps = (component, rendererMapperProps) => __spreadProp
1640
1745
  onChange: component.onChange.bind(component)
1641
1746
  });
1642
1747
 
1643
- // src/revamp/renderers/mappers/multiSelectComponentToProps.ts
1644
- var multiSelectInputComponentToProps = (component, rendererMapperProps) => {
1645
- const { autoComplete, maxItems, minItems, options, selectedIndices, onSelect } = component;
1646
- const _a = inputComponentToProps(component, "input-multi-select"), { required, value } = _a, props = __objRest(_a, ["required", "value"]);
1647
- return __spreadProps(__spreadValues(__spreadValues({}, props), rendererMapperProps), {
1648
- autoComplete,
1649
- maxItems,
1650
- minItems,
1651
- options,
1652
- selectedIndices,
1653
- onSelect: onSelect.bind(component)
1748
+ // src/revamp/renderers/mappers/tupleComponentToProps.ts
1749
+ var tupleComponentToProps = (component, rendererMapperProps) => {
1750
+ const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
1751
+ return __spreadProps(__spreadValues(__spreadValues({
1752
+ type: "form-section"
1753
+ }, pick(component, "uid", "control", "description", "help", "icon", "image", "title")), rendererMapperProps), {
1754
+ children: childrenProps.map(rendererMapperProps.render),
1755
+ childrenProps
1654
1756
  });
1655
1757
  };
1656
1758
 
@@ -1666,108 +1768,25 @@ var uploadInputComponentToProps = (component, rendererMapperProps) => {
1666
1768
  });
1667
1769
  };
1668
1770
 
1669
- // src/revamp/renderers/mappers/tupleComponentToProps.ts
1670
- var tupleComponentToProps = (component, rendererMapperProps) => {
1671
- const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
1672
- return __spreadProps(__spreadValues(__spreadValues({
1673
- type: "section"
1674
- }, pick(component, "uid", "control", "description", "help", "icon", "image", "title")), rendererMapperProps), {
1675
- children: childrenProps.map(rendererMapperProps.render),
1676
- childrenProps
1677
- });
1678
- };
1679
-
1680
- // src/revamp/renderers/mappers/listComponentToProps.ts
1681
- var listComponentToProps = (component, rendererMapperProps) => __spreadProps(__spreadValues(__spreadValues({}, pick(component, "uid", "type", "callToAction", "control", "margin", "title")), rendererMapperProps), {
1682
- items: component.items.map(mapItem)
1683
- });
1684
- var mapItem = (item) => {
1685
- var _a, _b;
1686
- return __spreadProps(__spreadValues({}, item), {
1687
- // populate deprecated fields
1688
- subtitle: item.description,
1689
- value: (_a = item.supportingValues) == null ? void 0 : _a.value,
1690
- subvalue: (_b = item.supportingValues) == null ? void 0 : _b.subvalue
1691
- });
1692
- };
1693
-
1694
- // src/revamp/renderers/stepComponentToProps.ts
1695
- var stepComponentToProps = (component, rendererMapperProps) => {
1696
- const {
1697
- uid,
1698
- back,
1699
- control,
1700
- description,
1701
- error,
1702
- loadingState,
1703
- step,
1704
- title,
1705
- onBehavior
1706
- } = component;
1707
- const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
1708
- return __spreadValues({
1709
- type: "step",
1710
- id: step.id,
1711
- uid,
1712
- back,
1713
- control,
1714
- description,
1715
- error,
1716
- loadingState,
1717
- step,
1718
- title,
1719
- children: childrenProps.map(rendererMapperProps.render),
1720
- childrenProps,
1721
- onAction: (action) => {
1722
- void onBehavior({ type: "action", action });
1723
- }
1724
- }, rendererMapperProps);
1725
- };
1726
-
1727
- // src/revamp/renderers/mappers/rootComponentToProps.ts
1728
- var rootComponentToProps = (rootComponent, rendererMapperProps) => {
1729
- const childrenProps = rootComponent.getChildren().map((child) => componentToRendererProps(child, rendererMapperProps));
1730
- return __spreadValues({
1731
- type: "root",
1732
- uid: rootComponent.uid,
1733
- children: childrenProps.map(rendererMapperProps.render),
1734
- childrenProps
1735
- }, rendererMapperProps);
1736
- };
1737
-
1738
- // src/revamp/renderers/mappers/modalContentComponentToProps.ts
1739
- var modalContentComponentToProps = (component, rendererMapperProps) => {
1740
- const { uid, open, title, close } = component;
1741
- const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
1742
- return __spreadValues({
1743
- uid,
1744
- type: "modal-content",
1745
- open,
1746
- title,
1747
- children: childrenProps.map(rendererMapperProps.render),
1748
- childrenProps,
1749
- onClose: close.bind(component)
1750
- }, rendererMapperProps);
1751
- };
1752
-
1753
- // src/revamp/renderers/mappers/externalComponentToProps.ts
1754
- var externalComponentToProps = (component, rendererMapperProps) => {
1755
- return __spreadValues({
1756
- type: "external-confirmation",
1757
- uid: component.uid,
1758
- url: component.url,
1759
- status: component.status,
1760
- onSuccess: component.onSuccess.bind(component),
1761
- onFailure: component.onFailure.bind(component),
1762
- onCancel: component.onCancel.bind(component)
1763
- }, rendererMapperProps);
1764
- };
1765
-
1766
1771
  // src/revamp/renderers/mappers/componentToRendererProps.ts
1767
1772
  var componentToRendererProps = (component, rendererMapperProps) => {
1768
1773
  if (isHiddenComponent(component)) {
1769
1774
  return hiddenComponentToProps(component);
1770
1775
  }
1776
+ const componentProps = getComponentProps(component, rendererMapperProps);
1777
+ const alertProps = getComponentAlertProps(component, rendererMapperProps);
1778
+ if (alertProps) {
1779
+ const childrenProps = [alertProps, componentProps];
1780
+ return __spreadValues({
1781
+ type: "container",
1782
+ uid: `${component.uid}-wrapper`,
1783
+ children: childrenProps.map(rendererMapperProps.render),
1784
+ childrenProps
1785
+ }, rendererMapperProps);
1786
+ }
1787
+ return componentProps;
1788
+ };
1789
+ var getComponentProps = (component, rendererMapperProps) => {
1771
1790
  switch (component.type) {
1772
1791
  case "root":
1773
1792
  return rootComponentToProps(component, rendererMapperProps);
@@ -1847,6 +1866,13 @@ var componentToRendererProps = (component, rendererMapperProps) => {
1847
1866
  throw new Error("Unknown component type");
1848
1867
  }
1849
1868
  };
1869
+ var getComponentAlertProps = (component, rendererMapperProps) => "alert" in component && component.alert ? __spreadValues({
1870
+ type: "alert",
1871
+ uid: `${component.uid}-alert`,
1872
+ margin: "md",
1873
+ context: component.alert.context,
1874
+ markdown: component.alert.content
1875
+ }, rendererMapperProps) : null;
1850
1876
 
1851
1877
  // src/revamp/useDynamicFlowCore.tsx
1852
1878
  var import_dynamic_flow_types2 = require("@wise/dynamic-flow-types");
@@ -2498,6 +2524,12 @@ var mapAdditionalInfo = (info, onBehavior) => {
2498
2524
  }
2499
2525
  return void 0;
2500
2526
  };
2527
+ var mapSchemaAlert = (alert) => {
2528
+ return alert ? {
2529
+ content: alert.markdown,
2530
+ context: alert.context ? mapLegacyContext(alert.context) : "neutral"
2531
+ } : void 0;
2532
+ };
2501
2533
 
2502
2534
  // src/revamp/domain/mappers/layout/decisionLayoutToComponent.ts
2503
2535
  var decisionLayoutToComponent = (uid, {
@@ -3299,7 +3331,7 @@ var mapCommonSchemaProps = (schemaMapperProps) => {
3299
3331
  var _a;
3300
3332
  const { uid, schema, required, validationErrors } = schemaMapperProps;
3301
3333
  const { $id, analyticsId, control, description, icon, image, keywords, title, hidden } = schema;
3302
- return __spreadValues(__spreadValues({
3334
+ return __spreadValues(__spreadValues(__spreadValues({
3303
3335
  uid,
3304
3336
  id: $id != null ? $id : uid,
3305
3337
  analyticsId: (_a = analyticsId != null ? analyticsId : $id) != null ? _a : "",
@@ -3314,7 +3346,7 @@ var mapCommonSchemaProps = (schemaMapperProps) => {
3314
3346
  required: Boolean(required),
3315
3347
  title,
3316
3348
  summariser: getSummariser(schema)
3317
- }, schemaHasHelp(schema) ? { help: schema.help.markdown } : {}), schemaHasPlaceholder(schema) ? { placeholder: schema.placeholder } : {});
3349
+ }, schemaHasHelp(schema) ? { help: schema.help.markdown } : {}), schemaHasPlaceholder(schema) ? { placeholder: schema.placeholder } : {}), schema.alert ? { alert: mapSchemaAlert(schema.alert) } : {});
3318
3350
  };
3319
3351
  var schemaHasDisabled = (schema) => Boolean("disabled" in schema && schema.disabled !== void 0);
3320
3352
  var schemaHasHelp = (schema) => Boolean("help" in schema && schema.help);
@@ -3436,27 +3468,27 @@ var numberSchemaToComponent = (schemaMapperProps, mapperProps) => {
3436
3468
  );
3437
3469
  };
3438
3470
 
3439
- // src/revamp/domain/components/ObjectComponent.ts
3440
- var createObjectComponent = (objectProps) => {
3471
+ // src/revamp/domain/components/AllOfComponent.ts
3472
+ var createAllOfComponent = (allOfProps) => {
3441
3473
  const {
3442
3474
  uid,
3443
3475
  analyticsId,
3444
- componentMap,
3476
+ alert,
3477
+ components,
3445
3478
  control,
3446
3479
  description,
3447
- displayOrder,
3448
3480
  help,
3449
3481
  hidden,
3450
3482
  icon,
3451
3483
  image,
3452
- summariser,
3453
3484
  title
3454
- } = objectProps;
3485
+ } = allOfProps;
3455
3486
  return {
3456
- type: "object",
3487
+ type: "all-of",
3457
3488
  uid,
3458
3489
  analyticsId,
3459
- componentMap,
3490
+ alert,
3491
+ components,
3460
3492
  control,
3461
3493
  description,
3462
3494
  help,
@@ -3465,123 +3497,13 @@ var createObjectComponent = (objectProps) => {
3465
3497
  image,
3466
3498
  title,
3467
3499
  getChildren() {
3468
- return displayOrder.map((propName) => this.componentMap[propName]);
3500
+ return this.components;
3501
+ },
3502
+ getSummary() {
3503
+ return summariseFromChildren(this.getChildren());
3469
3504
  },
3470
3505
  async getSubmittableValue() {
3471
- return Promise.all(
3472
- displayOrder.map(
3473
- async (propName) => this.componentMap[propName].getSubmittableValue().then((value) => ({ value, propName }))
3474
- )
3475
- ).then(
3476
- (values) => values.reduce(
3477
- (acc, { value, propName }) => __spreadValues(__spreadValues({}, acc), value === null ? {} : { [propName]: value }),
3478
- {}
3479
- )
3480
- );
3481
- },
3482
- getSubmittableValueSync() {
3483
- return mergeChildrenValues(
3484
- displayOrder,
3485
- (propName) => this.componentMap[propName].getSubmittableValueSync()
3486
- );
3487
- },
3488
- getSummary() {
3489
- const summary = summariser(this.getLocalValue());
3490
- const childSummary = summariseFromChildren(this.getChildren());
3491
- return mergeSummaries(summary, childSummary);
3492
- },
3493
- getLocalValue() {
3494
- return mergeChildrenValues(
3495
- displayOrder,
3496
- (propName) => this.componentMap[propName].getLocalValue()
3497
- );
3498
- },
3499
- validate() {
3500
- return hidden ? true : validateComponents(this.getChildren());
3501
- }
3502
- };
3503
- };
3504
- var mergeChildrenValues = (displayOrder, getComponentValue) => displayOrder.reduce((acc, propName) => {
3505
- const componentValue = getComponentValue(propName);
3506
- return __spreadValues(__spreadValues({}, acc), componentValue === null ? {} : { [propName]: componentValue });
3507
- }, {});
3508
-
3509
- // src/revamp/domain/mappers/schema/objectSchemaToComponent/objectSchemaToComponent.ts
3510
- var objectSchemaToComponent = (schemaMapperProps, mapperProps) => {
3511
- const { uid, localValue, schema, model, validationErrors } = schemaMapperProps;
3512
- const { $id, displayOrder, properties, required } = schema;
3513
- validateDisplayOrder($id, displayOrder, properties, mapperProps.logEvent);
3514
- const componentMap = displayOrder.reduce((acc, propName) => {
3515
- var _a;
3516
- const propSchema = properties[propName];
3517
- if (propSchema === void 0) {
3518
- throw new Error(`Object schema ${$id} has no property named ${propName}`);
3519
- }
3520
- return __spreadProps(__spreadValues({}, acc), {
3521
- [propName]: mapSchemaToComponent(
3522
- {
3523
- uid: `${uid}.obj-${propName}`,
3524
- schema: propSchema,
3525
- model: isObjectModel(model) ? model[propName] : null,
3526
- localValue: isObjectLocalValue(localValue) ? localValue[propName] : null,
3527
- required: (_a = required == null ? void 0 : required.includes(propName)) != null ? _a : false,
3528
- validationErrors: isObject(validationErrors) ? validationErrors[propName] : void 0
3529
- },
3530
- mapperProps
3531
- )
3532
- });
3533
- }, {});
3534
- return createObjectComponent(__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
3535
- componentMap,
3536
- displayOrder
3537
- }));
3538
- };
3539
- var validateDisplayOrder = ($id, displayOrder, properties, logEvent) => {
3540
- if (!displayOrder) {
3541
- const message = `Object schema ${$id} has no displayOrder property.`;
3542
- logEvent("error", message);
3543
- throw new Error(message);
3544
- }
3545
- const propertyNames = Object.keys(properties);
3546
- displayOrder.forEach((propName) => {
3547
- if (!properties[propName]) {
3548
- const message = `Object schema ${$id} has no property named "${propName}", but it is listed in the displayOrder array.`;
3549
- logEvent("error", message);
3550
- throw new Error(message);
3551
- }
3552
- });
3553
- propertyNames.forEach((propName) => {
3554
- if (!displayOrder.includes(propName)) {
3555
- const message = `Object schema ${$id} has a "${propName}" property which is missing in the displayOrder array.`;
3556
- logEvent("error", message);
3557
- throw new Error(message);
3558
- }
3559
- });
3560
- };
3561
-
3562
- // src/revamp/domain/components/AllOfComponent.ts
3563
- var createAllOfComponent = (allOfProps) => {
3564
- const { uid, analyticsId, components, control, description, help, hidden, icon, image, title } = allOfProps;
3565
- return {
3566
- type: "all-of",
3567
- uid,
3568
- analyticsId,
3569
- components,
3570
- control,
3571
- description,
3572
- help,
3573
- hidden,
3574
- icon,
3575
- image,
3576
- title,
3577
- getChildren() {
3578
- return this.components;
3579
- },
3580
- getSummary() {
3581
- return summariseFromChildren(this.getChildren());
3582
- },
3583
- async getSubmittableValue() {
3584
- return getSubmittableData(this.components);
3506
+ return getSubmittableData(this.components);
3585
3507
  },
3586
3508
  getSubmittableValueSync() {
3587
3509
  return getSubmittableDataSync(this.components);
@@ -3617,415 +3539,456 @@ var allOfSchemaToComponent = (schemaMapperProps, mapperProps) => {
3617
3539
  }));
3618
3540
  };
3619
3541
 
3620
- // src/revamp/domain/components/ConstComponent.ts
3621
- var createConstComponent = (hiddenProps) => {
3622
- const { uid, analyticsId, value, summary } = hiddenProps;
3623
- return {
3624
- type: "const",
3625
- uid,
3626
- analyticsId,
3627
- getLocalValue: () => value,
3628
- getSubmittableValue: async () => value,
3629
- getSubmittableValueSync: () => value,
3630
- getSummary: () => summary,
3631
- validate: () => true
3632
- };
3633
- };
3634
-
3635
- // src/revamp/domain/mappers/schema/constSchemaToComponent.ts
3636
- var constSchemaToComponent = (uid, schemaMapperProps) => {
3637
- var _a;
3638
- const { schema } = schemaMapperProps;
3639
- const { title, const: constValue, analyticsId, $id } = schema;
3640
- const titleOrValue = (_a = title != null ? title : constValue) != null ? _a : null;
3641
- return createConstComponent({
3642
- uid,
3643
- analyticsId: analyticsId != null ? analyticsId : $id,
3644
- summary: getConstSummary(schema, titleOrValue),
3645
- value: schema.const
3646
- });
3647
- };
3648
-
3649
- // src/revamp/domain/components/IntegerInputComponent.ts
3650
- var createIntegerInputComponent = (integerInputProps, updateComponent) => {
3651
- const _a = integerInputProps, {
3542
+ // src/revamp/domain/components/RepeatableComponent.ts
3543
+ var createRepeatableComponent = (repeatableProps, updateComponent) => {
3544
+ const _a = repeatableProps, {
3652
3545
  uid,
3653
3546
  id,
3654
3547
  checks,
3655
- value,
3656
- performPersistAsync,
3657
- performRefresh,
3658
- performValidationAsync,
3548
+ components,
3549
+ summary,
3659
3550
  onValueChange,
3551
+ createEditableComponent,
3660
3552
  summariser
3661
- } = _a, rest = __objRest(_a, [
3553
+ } = _a, componentProps = __objRest(_a, [
3662
3554
  "uid",
3663
3555
  "id",
3664
3556
  "checks",
3665
- "value",
3666
- "performPersistAsync",
3667
- "performRefresh",
3668
- "performValidationAsync",
3557
+ "components",
3558
+ "summary",
3669
3559
  "onValueChange",
3560
+ "createEditableComponent",
3670
3561
  "summariser"
3671
3562
  ]);
3672
3563
  const update = getInputUpdateFunction(updateComponent);
3673
3564
  const getValidationErrors = getLocalValueValidator(checks);
3674
- const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh, getValidationErrors);
3675
- const integerComponent = __spreadValues({
3676
- type: "integer",
3565
+ const repeatableComponent = __spreadProps(__spreadValues({
3677
3566
  uid,
3678
3567
  id,
3679
- value,
3568
+ type: "repeatable",
3569
+ components,
3570
+ editableComponent: null,
3571
+ editableIndex: null,
3572
+ summaryDefaults: {
3573
+ title: summary == null ? void 0 : summary.defaultTitle,
3574
+ description: summary == null ? void 0 : summary.defaultDescription,
3575
+ icon: summary == null ? void 0 : summary.defaultIcon,
3576
+ image: summary == null ? void 0 : summary.defaultImage
3577
+ }
3578
+ }, componentProps), {
3680
3579
  _update(updateFn) {
3681
3580
  update(this, updateFn);
3682
3581
  },
3683
- onBlur() {
3684
- this.validate();
3685
- performDebouncedRefresh == null ? void 0 : performDebouncedRefresh.flush();
3686
- },
3687
- onFocus() {
3582
+ onEdit(itemIndex) {
3583
+ this._update((draft) => {
3584
+ draft.editableComponent = createEditableComponent(
3585
+ draft.components[itemIndex].getLocalValue()
3586
+ );
3587
+ draft.editableIndex = itemIndex;
3588
+ });
3688
3589
  },
3689
- // Noop
3690
- onChange(updatedValue) {
3691
- const prevValue = this.value;
3590
+ onAdd() {
3692
3591
  this._update((draft) => {
3592
+ draft.editableComponent = createEditableComponent(null);
3593
+ draft.editableIndex = null;
3693
3594
  draft.errors = [];
3694
- draft.validationAsyncState.messages = {};
3695
- draft.value = updatedValue;
3696
3595
  });
3697
- performDebouncedRefresh == null ? void 0 : performDebouncedRefresh(prevValue, updatedValue);
3596
+ },
3597
+ onSave() {
3598
+ var _a2;
3599
+ const isValid = (_a2 = this.editableComponent) == null ? void 0 : _a2.validate();
3600
+ if (!isValid) {
3601
+ return false;
3602
+ }
3603
+ this._update((draft) => {
3604
+ if (draft.editableComponent === null) {
3605
+ return;
3606
+ }
3607
+ if (draft.editableIndex === null) {
3608
+ const newComponent = __spreadValues({}, draft.editableComponent);
3609
+ draft.components = [...this.components, newComponent];
3610
+ } else {
3611
+ draft.components[draft.editableIndex] = __spreadProps(__spreadValues({}, draft.editableComponent), {
3612
+ uid: draft.components[draft.editableIndex].uid
3613
+ });
3614
+ }
3615
+ draft.editableComponent = null;
3616
+ draft.editableIndex = null;
3617
+ });
3618
+ onValueChange();
3619
+ return true;
3620
+ },
3621
+ onRemove() {
3622
+ this._update((draft) => {
3623
+ if (draft.editableIndex === null) {
3624
+ return;
3625
+ }
3626
+ draft.components.splice(draft.editableIndex, 1);
3627
+ draft.editableComponent = null;
3628
+ draft.editableIndex = null;
3629
+ });
3698
3630
  onValueChange();
3699
3631
  },
3632
+ getChildren() {
3633
+ return this.editableComponent !== null ? [...this.components, this.editableComponent] : this.components;
3634
+ },
3700
3635
  async getSubmittableValue() {
3701
- return this.getSubmittableValueSync();
3636
+ return Promise.all(this.components.map(async (component) => component.getSubmittableValue()));
3702
3637
  },
3703
3638
  getSubmittableValueSync() {
3704
- var _a2;
3705
- return (_a2 = this.getLocalValue()) != null ? _a2 : null;
3639
+ return this.components.map((component) => component.getSubmittableValueSync());
3706
3640
  },
3707
3641
  getSummary() {
3708
- return summariser(this.getLocalValue());
3642
+ return summariser(null);
3709
3643
  },
3710
3644
  getLocalValue() {
3711
- return this.value;
3645
+ return this.components.map((component) => component.getLocalValue());
3712
3646
  },
3713
3647
  validate() {
3714
- const errors = getValidationErrors(this.getLocalValue());
3648
+ const messages = getValidationErrors(this.getLocalValue());
3649
+ const childComponentsValid = validateComponents(this.getChildren());
3715
3650
  this._update((draft) => {
3716
- draft.errors = errors;
3651
+ draft.errors = messages;
3717
3652
  });
3718
- return errors.length === 0;
3653
+ return messages.length === 0 && childComponentsValid;
3719
3654
  }
3720
- }, rest);
3721
- if (performRefresh) {
3722
- return integerComponent;
3723
- }
3724
- if (performPersistAsync) {
3725
- const persist = getComponentPersistAsync(update, performPersistAsync);
3726
- return __spreadProps(__spreadValues({}, integerComponent), {
3727
- onBlur() {
3728
- if (this.validate()) {
3729
- persist(this, this.getLocalValue()).catch(() => {
3730
- });
3731
- }
3732
- },
3733
- async getSubmittableValue() {
3734
- return persist(this, this.getLocalValue());
3735
- },
3736
- getSubmittableValueSync() {
3737
- return this.persistedState.lastResponse;
3738
- }
3739
- });
3740
- }
3741
- if (performValidationAsync) {
3742
- const validateAsync = getDebouncedComponentValidationAsync(update, performValidationAsync);
3743
- return __spreadProps(__spreadValues({}, integerComponent), {
3744
- onBlur() {
3745
- if (this.validate()) {
3746
- validateAsync.flush();
3747
- }
3748
- },
3749
- onChange(updatedValue) {
3750
- integerComponent.onChange.call(this, updatedValue);
3751
- if (getValidationErrors(updatedValue).length === 0) {
3752
- validateAsync(this, updatedValue);
3753
- }
3754
- }
3755
- });
3756
- }
3757
- return integerComponent;
3655
+ });
3656
+ return repeatableComponent;
3758
3657
  };
3759
3658
 
3760
- // src/revamp/domain/mappers/schema/integerSchemaToComponent.ts
3761
- var integerSchemaToComponent = (schemaMapperProps, mapperProps) => {
3762
- const { schema, localValue, model, required = false } = schemaMapperProps;
3763
- const { autocompleteHint, validationMessages, default: defaultValue, maximum, minimum } = schema;
3764
- const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange } = mapperProps;
3765
- const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
3766
- const { performPersistAsync, persistedState } = getPersistAsyncInitialState(
3767
- schemaMapperProps,
3768
- mapperProps
3659
+ // src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToRepeatableComponent.ts
3660
+ var arraySchemaToRepeatableComponent = (schemaMapperProps, mapperProps) => {
3661
+ const { getErrorMessageFunctions } = mapperProps;
3662
+ const {
3663
+ uid,
3664
+ localValue,
3665
+ schema,
3666
+ model: initialModel,
3667
+ required = false,
3668
+ validationErrors
3669
+ } = schemaMapperProps;
3670
+ const { items, addItemTitle, editItemTitle, maxItems, minItems, summary } = schema;
3671
+ const value = isArray(localValue) ? localValue : [];
3672
+ const components = initialModel == null ? void 0 : initialModel.map(
3673
+ (item, index) => mapSchemaToComponent(
3674
+ {
3675
+ uid: `${uid}.arr-${index}`,
3676
+ schema: items,
3677
+ model: item,
3678
+ localValue: value == null ? void 0 : value[index],
3679
+ // TODO tests for this
3680
+ validationErrors
3681
+ },
3682
+ mapperProps
3683
+ )
3769
3684
  );
3770
- const { performValidationAsync, validationAsyncState } = getValidationAsyncInitialState(
3771
- schemaMapperProps,
3685
+ const createEditableComponent = (editableValue) => mapSchemaToComponent(
3686
+ {
3687
+ uid: `${uid}.arr-rnd-${getRandomInt()}`,
3688
+ schema: items,
3689
+ localValue: editableValue,
3690
+ model: localValueToJsonElement(editableValue),
3691
+ validationErrors: void 0,
3692
+ required: true
3693
+ },
3772
3694
  mapperProps
3773
3695
  );
3774
- const validLocalValue = isInteger(localValue) ? localValue : null;
3775
- const validModel = isInteger(model) ? model : defaultValue != null ? defaultValue : null;
3776
- const value = performPersistAsync ? validLocalValue : validModel;
3777
- const checks = [
3778
- getRequiredCheck(required, errorMessageFunctions),
3779
- getBelowMinimumCheck(schema, errorMessageFunctions),
3780
- getAboveMaximumCheck(schema, errorMessageFunctions)
3781
- ];
3782
- return createIntegerInputComponent(
3696
+ const { onValueChange } = mapperProps;
3697
+ const errorMessageFunctions = getErrorMessageFunctions(schema.validationMessages);
3698
+ return createRepeatableComponent(
3783
3699
  __spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
3784
- autoComplete: getAutocompleteString(autocompleteHint),
3785
- checks,
3786
- maximum,
3787
- minimum,
3788
- persistedState,
3789
- value,
3790
- validationAsyncState,
3791
- performPersistAsync,
3792
- performRefresh: getPerformRefresh(schema, onRefresh),
3793
- performValidationAsync,
3700
+ addItemTitle,
3701
+ checks: schema.hidden ? [] : [
3702
+ getRequiredCheck(required, errorMessageFunctions),
3703
+ getAboveMaxItemsCheck(schema, errorMessageFunctions),
3704
+ getBelowMinItemsCheck(schema, errorMessageFunctions)
3705
+ ],
3706
+ components: components != null ? components : [],
3707
+ editItemTitle,
3708
+ maxItems,
3709
+ minItems,
3710
+ summary: __spreadProps(__spreadValues({}, summary), {
3711
+ defaultImage: mapSpecImage(summary == null ? void 0 : summary.defaultImage)
3712
+ }),
3713
+ createEditableComponent,
3794
3714
  onValueChange
3795
3715
  }),
3796
- updateComponent
3716
+ mapperProps.updateComponent
3797
3717
  );
3798
3718
  };
3799
-
3800
- // src/revamp/domain/components/utils/isPartialModelMatch.ts
3801
- var isPartialModelMatch = (localModel, incomingModel) => {
3802
- if (isArrayModel(localModel) && isArrayModel(incomingModel)) {
3803
- return localModel.length === incomingModel.length && localModel.every((value, index) => isPartialModelMatch(value, incomingModel[index]));
3719
+ var localValueToJsonElement = (localValue) => {
3720
+ if (localValue instanceof Array) {
3721
+ return localValue.map(localValueToJsonElement);
3804
3722
  }
3805
- if (isObjectModel(localModel) && isObjectModel(incomingModel)) {
3806
- if (Object.keys(localModel).length === 0 && Object.keys(incomingModel).length === 0) {
3807
- return true;
3808
- }
3809
- const nonNullishKeysInBoth = nonNullishKeys(localModel).filter(
3810
- (key) => nonNullishKeys(incomingModel).includes(key)
3723
+ if (isObject(localValue)) {
3724
+ return Object.fromEntries(
3725
+ Object.entries(localValue).map(([key, value]) => [key, localValueToJsonElement(value)])
3811
3726
  );
3812
- return nonNullishKeysInBoth.length > 0 && nonNullishKeysInBoth.every((key) => isPartialModelMatch(localModel[key], incomingModel[key]));
3813
3727
  }
3814
- return localModel === incomingModel;
3728
+ if (localValue instanceof File) {
3729
+ return localValue.name;
3730
+ }
3731
+ return localValue;
3815
3732
  };
3816
- var nonNullishKeys = (model) => Object.keys(model).filter((key) => !isNullish(model[key]));
3733
+ var getRandomInt = () => Math.floor(Math.random() * 1e8);
3817
3734
 
3818
- // src/revamp/domain/components/SelectInputComponent.ts
3819
- var createSelectInputComponent = (selectProps, updateComponent) => {
3820
- const _a = selectProps, { uid, checks, initialModel, options, performRefresh, onValueChange, summariser } = _a, rest = __objRest(_a, ["uid", "checks", "initialModel", "options", "performRefresh", "onValueChange", "summariser"]);
3821
- const children = options.map((option) => option.component);
3822
- const matchingOptions = options.map(
3823
- (option) => isPartialModelMatch(option.component.getSubmittableValueSync(), initialModel)
3824
- );
3825
- const selectedIndex = matchingOptions.filter((match) => match).length === 1 ? matchingOptions.indexOf(true) : null;
3735
+ // src/revamp/domain/components/utils/file-utils.ts
3736
+ var toBase64 = async (file) => new Promise((resolve, reject) => {
3737
+ const reader = new FileReader();
3738
+ reader.addEventListener("load", () => resolve(reader.result));
3739
+ reader.addEventListener("error", reject);
3740
+ reader.readAsDataURL(file);
3741
+ });
3742
+ var base64dataUrltoFile = (dataurl, filename) => {
3743
+ if (!isBase64DataUrl(dataurl)) {
3744
+ return null;
3745
+ }
3746
+ const [, base64data] = dataurl.split(",");
3747
+ return new File([base64ToBytes(base64data)], filename, { type: getMimeType(dataurl) });
3748
+ };
3749
+ var isBase64DataUrl = (dataurl) => dataurl.startsWith("data:") && dataurl.includes("base64") && dataurl.includes(",");
3750
+ var getMimeType = (base64dataUrl) => base64dataUrl.substring("data:".length).split(";")[0];
3751
+ var base64ToBytes = (base64) => {
3752
+ const charCodes = atob(base64).split("").map((m) => m.charCodeAt(0));
3753
+ return Uint8Array.from(charCodes);
3754
+ };
3755
+
3756
+ // src/revamp/domain/components/MultiUploadInputComponent.ts
3757
+ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
3758
+ const _a = uploadInputProps, {
3759
+ uid,
3760
+ id,
3761
+ checks,
3762
+ fileChecks,
3763
+ format,
3764
+ performPersistAsync,
3765
+ onValueChange,
3766
+ summariser
3767
+ } = _a, rest = __objRest(_a, [
3768
+ "uid",
3769
+ "id",
3770
+ "checks",
3771
+ "fileChecks",
3772
+ "format",
3773
+ "performPersistAsync",
3774
+ "onValueChange",
3775
+ "summariser"
3776
+ ]);
3826
3777
  const update = getInputUpdateFunction(updateComponent);
3827
3778
  const getValidationErrors = getLocalValueValidator(checks);
3828
- const component = __spreadProps(__spreadValues({
3779
+ const getFileValidationErrors = getLocalValueValidator(fileChecks);
3780
+ const uploadComponent = __spreadValues({
3781
+ type: "multi-upload",
3829
3782
  uid,
3830
- type: "select",
3831
- children,
3832
- options,
3833
- selectedIndex,
3834
- value: null
3835
- }, rest), {
3783
+ id,
3784
+ format: "base64",
3785
+ files: [],
3836
3786
  _update(updateFn) {
3837
3787
  update(this, updateFn);
3838
3788
  },
3839
- getChildren() {
3840
- return this.children;
3789
+ onBlur() {
3790
+ this.validate();
3841
3791
  },
3842
- getSelectedChild() {
3843
- return this.selectedIndex !== null ? this.children[this.selectedIndex] : null;
3792
+ onFocus() {
3793
+ },
3794
+ // Noop
3795
+ async onRemoveFile(index) {
3796
+ this._update((draft) => {
3797
+ draft.value.splice(index, 1);
3798
+ draft.files.splice(index, 1);
3799
+ });
3800
+ },
3801
+ async onInsertFile(index, file) {
3802
+ const fileErrors = getFileValidationErrors(file);
3803
+ const fileId = getRandomId();
3804
+ this._update((draft) => {
3805
+ draft.value.splice(index, 0, file);
3806
+ draft.files.splice(index, 0, { file, id: fileId, errors: fileErrors });
3807
+ draft.errors = [];
3808
+ });
3809
+ onValueChange();
3810
+ return fileId;
3844
3811
  },
3845
3812
  async getSubmittableValue() {
3846
- var _a2, _b;
3847
- return (_b = await ((_a2 = this.getSelectedChild()) == null ? void 0 : _a2.getSubmittableValue())) != null ? _b : null;
3813
+ const files = this.getLocalValue();
3814
+ return files ? Promise.all(files.map(toBase64)) : null;
3848
3815
  },
3849
3816
  getSubmittableValueSync() {
3850
- var _a2, _b;
3851
- return (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.getSubmittableValueSync()) != null ? _b : null;
3817
+ return null;
3852
3818
  },
3853
3819
  getSummary() {
3854
- var _a2, _b;
3855
- return (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.getSummary()) != null ? _b : {};
3820
+ return summariser(this.getLocalValue().map(({ name }) => name));
3856
3821
  },
3857
3822
  getLocalValue() {
3858
- var _a2, _b;
3859
- return (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.getLocalValue()) != null ? _b : null;
3860
- },
3861
- onBlur() {
3862
- this.validate();
3863
- },
3864
- onFocus() {
3823
+ return this.value;
3865
3824
  },
3866
- // noop
3867
- onSelect(updatedIndex) {
3868
- if (updatedIndex === this.selectedIndex) {
3869
- return;
3870
- }
3871
- if (updatedIndex !== null && this.analyticsId) {
3872
- selectProps.trackEvent("OneOf Selected", {
3873
- oneOfId: this.analyticsId,
3874
- schemaId: this.children[updatedIndex].analyticsId
3875
- });
3876
- }
3825
+ validate() {
3826
+ const errorMsgs = getValidationErrors(this.getLocalValue());
3877
3827
  this._update((draft) => {
3878
- draft.errors = [];
3879
- draft.selectedIndex = updatedIndex;
3828
+ draft.errors = errorMsgs;
3880
3829
  });
3881
- performRefresh == null ? void 0 : performRefresh();
3830
+ return errorMsgs.length === 0 && this.files.every(({ errors }) => errors.length === 0);
3831
+ }
3832
+ }, rest);
3833
+ if (!performPersistAsync) {
3834
+ return uploadComponent;
3835
+ }
3836
+ const persist = getComponentMultiPersistAsync(update, performPersistAsync);
3837
+ return __spreadProps(__spreadValues({}, uploadComponent), {
3838
+ format,
3839
+ async onInsertFile(index, file) {
3840
+ const fileId = await uploadComponent.onInsertFile.call(this, index, file);
3841
+ const submission = format === "blob" ? file : await toBase64(file);
3842
+ await persist(this, index, submission);
3882
3843
  onValueChange();
3844
+ return fileId;
3883
3845
  },
3884
- validate() {
3885
- var _a2, _b;
3886
- const validChild = (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.validate()) != null ? _b : true;
3887
- const errors = getValidationErrors(this.getLocalValue());
3846
+ async onRemoveFile(index) {
3847
+ var _a2;
3848
+ await uploadComponent.onRemoveFile.call(this, index);
3849
+ (_a2 = this.persistedState[index]) == null ? void 0 : _a2.abortController.abort();
3888
3850
  this._update((draft) => {
3889
- draft.errors = errors;
3851
+ draft.persistedState = draft.persistedState.splice(index, 1);
3890
3852
  });
3891
- return errors.length === 0 && validChild;
3853
+ },
3854
+ async getSubmittableValue() {
3855
+ return Promise.all(this.persistedState.map(async ({ submission }) => submission));
3856
+ },
3857
+ getSubmittableValueSync() {
3858
+ return this.persistedState.map(({ lastResponse }) => lastResponse);
3892
3859
  }
3893
3860
  });
3894
- return component;
3895
3861
  };
3896
3862
 
3897
- // src/revamp/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.ts
3898
- var oneOfSchemaToComponent = (schemaMapperProps, mapperProps) => {
3863
+ // src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToMultiUploadComponent.ts
3864
+ var arraySchemaToMultiUploadComponent = (schemaMapperProps, mapperProps) => {
3899
3865
  var _a;
3900
- const {
3901
- uid,
3902
- localValue,
3903
- schema,
3904
- model,
3905
- validationErrors: initialError,
3906
- required = false
3907
- } = schemaMapperProps;
3908
- const initialModel = (_a = model != null ? model : schema.default) != null ? _a : null;
3909
- if (schema.oneOf.length === 1 && isFormSectionSchema(schema.oneOf[0])) {
3910
- return mapSchemaToComponent(
3911
- {
3912
- uid,
3913
- schema: supressSchemaTitleAndDescription(schema.oneOf[0]),
3914
- model: initialModel,
3915
- localValue,
3916
- validationErrors: initialError,
3917
- required
3918
- },
3919
- mapperProps
3920
- );
3921
- }
3922
- const options = schema.oneOf.map((childSchema, index) => {
3923
- const { title = "", description, image, icon, keywords = [] } = childSchema;
3924
- return {
3925
- title,
3926
- description,
3927
- image: mapSpecImage(image),
3928
- icon,
3929
- keywords,
3930
- disabled: "disabled" in childSchema ? Boolean(childSchema.disabled) : false,
3931
- component: mapSchemaToComponent(
3932
- {
3933
- uid: `${uid}.oneOf-${index}`,
3934
- schema: isFormSectionSchema(childSchema) ? supressSchemaTitleAndDescription(childSchema) : childSchema,
3935
- model: initialModel,
3936
- localValue,
3937
- validationErrors: initialError,
3938
- required
3939
- },
3940
- mapperProps
3941
- )
3942
- };
3866
+ const { getErrorMessageFunctions } = mapperProps;
3867
+ const { localValue, model, schema, required = false } = schemaMapperProps;
3868
+ const uploadSchema = getUploadSchema(schema.items);
3869
+ const { accepts, cameraConfig, maxSize } = uploadSchema;
3870
+ const { minItems, maxItems, title, validationMessages } = schema;
3871
+ const arrayErrorMessageFunctions = getErrorMessageFunctions(validationMessages);
3872
+ const fileErrorMessageFunctions = getErrorMessageFunctions(uploadSchema.validationMessages);
3873
+ const checks = [
3874
+ getRequiredCheck(required, arrayErrorMessageFunctions),
3875
+ getAboveMaxFilesCheck(schema, arrayErrorMessageFunctions),
3876
+ getBelowMinFilesCheck(schema, arrayErrorMessageFunctions)
3877
+ ];
3878
+ const fileChecks = [
3879
+ getFileSizeCheck(schema.items, fileErrorMessageFunctions),
3880
+ getFileTypeCheck(schema.items, fileErrorMessageFunctions)
3881
+ ];
3882
+ const persistAsyncConfig = getPersistAsyncConfig(schema.items);
3883
+ const format = getFormat(schema.items);
3884
+ const combinedSchemaProps = __spreadProps(__spreadValues({}, schemaMapperProps), {
3885
+ persistAsyncConfig,
3886
+ schema: __spreadProps(__spreadValues({}, uploadSchema), { hidden: (_a = schema.hidden) != null ? _a : uploadSchema.hidden, alert: schema.alert })
3943
3887
  });
3944
- const { getErrorMessageFunctions, updateComponent, trackEvent, onRefresh, onValueChange } = mapperProps;
3945
- const { validationMessages } = schema;
3946
- const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
3947
- return createSelectInputComponent(
3948
- __spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
3949
- autoComplete: getAutocompleteString(schema.autocompleteHint),
3950
- checks: schema.hidden ? [] : [getRequiredCheck(required, errorMessageFunctions)],
3951
- options,
3952
- initialModel,
3953
- performRefresh: getPerformRefresh(schema, onRefresh),
3954
- onValueChange,
3955
- trackEvent
3888
+ const { onValueChange } = mapperProps;
3889
+ const { performPersistAsync } = getPersistAsyncInitialState(combinedSchemaProps, mapperProps);
3890
+ const value = performPersistAsync ? getValueForPersistAsync(localValue) : [];
3891
+ const persistedState = performPersistAsync && isArray(model) ? model.map((itemModel) => getInitialPersistedState(null, itemModel)) : [];
3892
+ return createMultiUploadInputComponent(
3893
+ __spreadProps(__spreadValues({}, mapCommonSchemaProps(combinedSchemaProps)), {
3894
+ title,
3895
+ cameraConfig,
3896
+ uploadLabel: uploadSchema.title,
3897
+ accepts,
3898
+ autoComplete: "off",
3899
+ checks: schema.hidden ? [] : checks,
3900
+ fileChecks: schema.hidden ? [] : fileChecks,
3901
+ format,
3902
+ maxSize,
3903
+ minItems,
3904
+ maxItems,
3905
+ required,
3906
+ source: uploadSchema.source,
3907
+ value,
3908
+ persistedState,
3909
+ performPersistAsync,
3910
+ onValueChange
3956
3911
  }),
3957
- updateComponent
3912
+ mapperProps.updateComponent
3958
3913
  );
3959
3914
  };
3960
- var isFormSectionSchema = (schema) => isObjectSchema(schema) || isArrayTupleSchema(schema) || isAllOfSchema(schema);
3961
- var supressSchemaTitleAndDescription = (schema) => {
3962
- const _a = schema, { title, description } = _a, headlessSchema = __objRest(_a, ["title", "description"]);
3963
- return headlessSchema;
3915
+ var getFormat = (schema) => {
3916
+ if (isStringSchemaWithUpload(schema)) {
3917
+ return "base64";
3918
+ }
3919
+ return isBlobSchema(schema.persistAsync.schema) ? "blob" : "base64";
3920
+ };
3921
+ var getUploadSchema = (schema) => {
3922
+ if (isStringSchemaWithUpload(schema)) {
3923
+ return schema;
3924
+ }
3925
+ return schema.persistAsync.schema;
3926
+ };
3927
+ var getPersistAsyncConfig = (schema) => {
3928
+ if (!isSchemaWithPersistAsync(schema)) {
3929
+ return void 0;
3930
+ }
3931
+ const { persistAsync } = schema;
3932
+ const { idProperty, method, param, url } = persistAsync;
3933
+ return { idProperty, method, param, url };
3964
3934
  };
3935
+ var getValueForPersistAsync = (localValue) => isArray(localValue) && localValue.every(isFile) ? localValue : [];
3965
3936
 
3966
- // src/revamp/domain/components/DateInputComponent.ts
3967
- var createDateInputComponent = (textInputProps, updateComponent) => {
3968
- const _a = textInputProps, {
3937
+ // src/revamp/domain/components/MultiSelectInputComponent.ts
3938
+ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
3939
+ const _a = multiSelectProps, {
3969
3940
  uid,
3970
- id,
3971
3941
  checks,
3972
- performPersistAsync,
3973
- performRefresh,
3942
+ options,
3943
+ initialValue,
3974
3944
  performValidationAsync,
3975
- onValueChange,
3976
- summariser,
3977
- value
3945
+ performRefresh,
3946
+ onValueChange
3978
3947
  } = _a, rest = __objRest(_a, [
3979
3948
  "uid",
3980
- "id",
3981
3949
  "checks",
3982
- "performPersistAsync",
3983
- "performRefresh",
3950
+ "options",
3951
+ "initialValue",
3984
3952
  "performValidationAsync",
3985
- "onValueChange",
3986
- "summariser",
3987
- "value"
3953
+ "performRefresh",
3954
+ "onValueChange"
3988
3955
  ]);
3989
3956
  const update = getInputUpdateFunction(updateComponent);
3957
+ const children = options.map((option) => option.component);
3958
+ const selectedIndices = getInitialModelIndices(initialValue, children);
3990
3959
  const getValidationErrors = getLocalValueValidator(checks);
3991
- const dateInputComponent = __spreadValues({
3992
- type: "date",
3960
+ const inputComponent = __spreadProps(__spreadValues({
3993
3961
  uid,
3994
- id,
3995
- value,
3962
+ type: "multi-select",
3963
+ children,
3964
+ options,
3965
+ selectedIndices,
3966
+ value: null
3967
+ }, rest), {
3996
3968
  _update(updateFn) {
3997
3969
  update(this, updateFn);
3998
3970
  },
3999
- onBlur() {
4000
- this.validate();
4001
- },
4002
- onFocus() {
4003
- },
4004
- // Noop
4005
- onChange(updatedValue) {
4006
- const prevValue = this.value;
3971
+ onSelect(indices) {
4007
3972
  this._update((draft) => {
3973
+ draft.selectedIndices = indices;
4008
3974
  draft.errors = [];
4009
- draft.validationAsyncState.messages = {};
4010
- draft.value = updatedValue;
4011
3975
  });
4012
- if (isOrWasValid(getValidationErrors, prevValue, updatedValue)) {
4013
- performRefresh == null ? void 0 : performRefresh();
4014
- }
3976
+ performRefresh == null ? void 0 : performRefresh();
4015
3977
  onValueChange();
3978
+ const errors = getValidationErrors(this.getLocalValue());
3979
+ this._update((draft) => {
3980
+ draft.errors = errors;
3981
+ });
4016
3982
  },
4017
- async getSubmittableValue() {
4018
- return this.getSubmittableValueSync();
4019
- },
4020
- getSubmittableValueSync() {
4021
- var _a2;
4022
- return (_a2 = this.getLocalValue()) != null ? _a2 : null;
3983
+ onBlur() {
4023
3984
  },
4024
- getSummary() {
4025
- return summariser(this.getLocalValue());
3985
+ // Noop
3986
+ onFocus() {
4026
3987
  },
3988
+ // Noop
4027
3989
  getLocalValue() {
4028
- return this.value;
3990
+ var _a2, _b;
3991
+ return (_b = (_a2 = this.getSelectedChildren()) == null ? void 0 : _a2.map((child) => child.getLocalValue())) != null ? _b : null;
4029
3992
  },
4030
3993
  validate() {
4031
3994
  const errors = getValidationErrors(this.getLocalValue());
@@ -4033,34 +3996,34 @@ var createDateInputComponent = (textInputProps, updateComponent) => {
4033
3996
  draft.errors = errors;
4034
3997
  });
4035
3998
  return errors.length === 0;
3999
+ },
4000
+ async getSubmittableValue() {
4001
+ const selected = this.getSelectedChildren();
4002
+ if (selected) {
4003
+ return Promise.all(selected.map(async (child) => child.getSubmittableValue()));
4004
+ }
4005
+ return null;
4006
+ },
4007
+ getSubmittableValueSync() {
4008
+ var _a2, _b;
4009
+ return (_b = (_a2 = this.getSelectedChildren()) == null ? void 0 : _a2.map((child) => child.getSubmittableValueSync())) != null ? _b : null;
4010
+ },
4011
+ getSummary: () => ({}),
4012
+ getChildren() {
4013
+ return this.children;
4014
+ },
4015
+ getSelectedChildren() {
4016
+ return this.selectedIndices.map((i) => this.children[i]);
4036
4017
  }
4037
- }, rest);
4018
+ });
4038
4019
  if (performRefresh) {
4039
- return dateInputComponent;
4040
- }
4041
- if (performPersistAsync) {
4042
- const persist = getComponentPersistAsync(update, performPersistAsync);
4043
- return __spreadProps(__spreadValues({}, dateInputComponent), {
4044
- onChange(updatedValue) {
4045
- dateInputComponent.onChange.call(this, updatedValue);
4046
- const isValid = getValidationErrors(updatedValue).length === 0;
4047
- if (isValid) {
4048
- persist(this, this.getLocalValue()).catch(() => {
4049
- });
4050
- }
4051
- },
4052
- async getSubmittableValue() {
4053
- return persist(this, this.getLocalValue());
4054
- },
4055
- getSubmittableValueSync() {
4056
- return this.persistedState.lastResponse;
4057
- }
4058
- });
4020
+ return inputComponent;
4059
4021
  }
4060
4022
  if (performValidationAsync) {
4061
4023
  const validateAsync = getComponentValidationAsync(update, performValidationAsync);
4062
- return __spreadProps(__spreadValues({}, dateInputComponent), {
4063
- onBlur() {
4024
+ return __spreadProps(__spreadValues({}, inputComponent), {
4025
+ onSelect(indices) {
4026
+ inputComponent.onSelect.call(this, indices);
4064
4027
  if (this.validate()) {
4065
4028
  validateAsync(this, this.getLocalValue()).catch(() => {
4066
4029
  });
@@ -4068,79 +4031,181 @@ var createDateInputComponent = (textInputProps, updateComponent) => {
4068
4031
  }
4069
4032
  });
4070
4033
  }
4071
- return dateInputComponent;
4034
+ return inputComponent;
4035
+ };
4036
+ var getInitialModelIndices = (model, options) => {
4037
+ if (!isArray(model)) {
4038
+ return [];
4039
+ }
4040
+ return model.map((m) => options.findIndex((o) => o.getLocalValue() === m)).filter((n) => n >= 0);
4072
4041
  };
4073
4042
 
4074
- // src/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToDateInputComponent.ts
4075
- var stringSchemaToDateInputComponent = (schemaMapperProps, mapperProps) => {
4076
- const { schema, localValue, model, required = false } = schemaMapperProps;
4043
+ // src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToMultiSelectComponent.ts
4044
+ var arraySchemaToMultiSelectComponent = (schemaMapperProps, mapperProps) => {
4077
4045
  const {
4078
- autocompleteHint,
4079
- default: defaultValue,
4080
- minimum: minimumDate,
4081
- maximum: maximumDate,
4082
- suggestions
4083
- } = schema;
4084
- const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange } = mapperProps;
4085
- const errorMessageFunctions = getErrorMessageFunctions(schema.validationMessages);
4086
- const { performPersistAsync, persistedState } = getPersistAsyncInitialState(
4087
- schemaMapperProps,
4088
- mapperProps
4089
- );
4046
+ uid,
4047
+ localValue,
4048
+ schema,
4049
+ model,
4050
+ required = false,
4051
+ validationErrors: initialError
4052
+ } = schemaMapperProps;
4053
+ const initialModel = model != null ? model : null;
4054
+ const options = schema.items.oneOf.map((childSchema, index) => {
4055
+ const { title: title2 = "", description, image, icon, keywords = [] } = childSchema;
4056
+ return {
4057
+ title: title2,
4058
+ description,
4059
+ image: mapSpecImage(image),
4060
+ icon,
4061
+ keywords,
4062
+ disabled: "disabled" in childSchema ? Boolean(childSchema.disabled) : false,
4063
+ component: mapSchemaToComponent(
4064
+ {
4065
+ uid: `${uid}.oneOf-${index}`,
4066
+ schema: childSchema,
4067
+ model: initialModel,
4068
+ localValue,
4069
+ validationErrors: initialError,
4070
+ required
4071
+ },
4072
+ mapperProps
4073
+ )
4074
+ };
4075
+ });
4076
+ const { maxItems, minItems, title, validationMessages } = schema;
4077
+ const { getErrorMessageFunctions, onRefresh, onValueChange, updateComponent } = mapperProps;
4078
+ const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
4090
4079
  const { performValidationAsync, validationAsyncState } = getValidationAsyncInitialState(
4091
4080
  schemaMapperProps,
4092
4081
  mapperProps
4093
4082
  );
4094
- const validLocalValue = isString(localValue) ? localValue : null;
4095
- const validModel = isString(model) ? model : defaultValue != null ? defaultValue : null;
4096
- const value = performPersistAsync ? validLocalValue : validModel;
4097
- return createDateInputComponent(
4083
+ const initialValue = model != null ? model : null;
4084
+ return createMultiSelectComponent(
4098
4085
  __spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
4099
- autoComplete: getAutocompleteString(autocompleteHint),
4086
+ autoComplete: "off",
4100
4087
  checks: schema.hidden ? [] : [
4101
4088
  getRequiredCheck(required, errorMessageFunctions),
4102
- getAboveMaximumDateCheck(schema, errorMessageFunctions),
4103
- getBelowMinimumDateCheck(schema, errorMessageFunctions)
4089
+ getAboveMaxItemsCheck(schema, errorMessageFunctions),
4090
+ getBelowMinItemsCheck(schema, errorMessageFunctions)
4104
4091
  ],
4105
- minimumDate,
4106
- maximumDate,
4107
- suggestions: suggestions ? {
4108
- values: suggestions.values.map((suggestion) => __spreadProps(__spreadValues({}, suggestion), {
4109
- image: mapSpecImage(suggestion.image)
4110
- }))
4111
- } : void 0,
4112
- value,
4113
- persistedState,
4092
+ initialValue,
4093
+ maxItems,
4094
+ minItems,
4095
+ options,
4096
+ required,
4097
+ title,
4114
4098
  validationAsyncState,
4115
- performPersistAsync,
4116
- performRefresh: getPerformRefresh(schema, onRefresh),
4117
4099
  performValidationAsync,
4100
+ performRefresh: getPerformRefresh(schema, onRefresh),
4118
4101
  onValueChange
4119
4102
  }),
4120
4103
  updateComponent
4121
4104
  );
4122
4105
  };
4123
4106
 
4124
- // src/revamp/domain/components/utils/file-utils.ts
4125
- var toBase64 = async (file) => new Promise((resolve, reject) => {
4126
- const reader = new FileReader();
4127
- reader.addEventListener("load", () => resolve(reader.result));
4128
- reader.addEventListener("error", reject);
4129
- reader.readAsDataURL(file);
4130
- });
4131
- var base64dataUrltoFile = (dataurl, filename) => {
4132
- if (!isBase64DataUrl(dataurl)) {
4133
- return null;
4134
- }
4135
- const [, base64data] = dataurl.split(",");
4136
- return new File([base64ToBytes(base64data)], filename, { type: getMimeType(dataurl) });
4107
+ // src/revamp/domain/components/TupleComponent.ts
4108
+ var createTupleComponent = (tupleProps) => {
4109
+ const {
4110
+ uid,
4111
+ analyticsId,
4112
+ alert,
4113
+ components,
4114
+ control,
4115
+ description,
4116
+ help,
4117
+ hidden,
4118
+ icon,
4119
+ image,
4120
+ summariser,
4121
+ title
4122
+ } = tupleProps;
4123
+ return {
4124
+ type: "tuple",
4125
+ uid,
4126
+ analyticsId,
4127
+ alert,
4128
+ components,
4129
+ control,
4130
+ description,
4131
+ help,
4132
+ hidden,
4133
+ icon,
4134
+ image,
4135
+ title,
4136
+ getChildren() {
4137
+ return this.components;
4138
+ },
4139
+ async getSubmittableValue() {
4140
+ return Promise.all(this.components.map(async (child) => child.getSubmittableValue()));
4141
+ },
4142
+ getSubmittableValueSync() {
4143
+ return this.components.map((child) => child.getSubmittableValueSync());
4144
+ },
4145
+ getSummary() {
4146
+ const summary = summariser(this.getLocalValue());
4147
+ const childSummary = summariseFromChildren(this.getChildren());
4148
+ return mergeSummaries(summary, childSummary);
4149
+ },
4150
+ getLocalValue() {
4151
+ return this.components.map((child) => child.getLocalValue());
4152
+ },
4153
+ validate() {
4154
+ return hidden ? true : validateComponents(this.getChildren());
4155
+ }
4156
+ };
4137
4157
  };
4138
- var isBase64DataUrl = (dataurl) => dataurl.startsWith("data:") && dataurl.includes("base64") && dataurl.includes(",");
4139
- var getMimeType = (base64dataUrl) => base64dataUrl.substring("data:".length).split(";")[0];
4140
- var base64ToBytes = (base64) => {
4141
- const charCodes = atob(base64).split("").map((m) => m.charCodeAt(0));
4142
- return Uint8Array.from(charCodes);
4158
+
4159
+ // src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToTupleComponent.ts
4160
+ var arraySchemaToTupleComponent = (schemaMapperProps, mapperProps) => {
4161
+ const {
4162
+ uid,
4163
+ localValue,
4164
+ schema,
4165
+ model: initialModel,
4166
+ required = false,
4167
+ validationErrors
4168
+ } = schemaMapperProps;
4169
+ const { items } = schema;
4170
+ const components = items.map(
4171
+ (childSchema, index) => {
4172
+ var _a, _b;
4173
+ return mapSchemaToComponent(
4174
+ {
4175
+ uid: `${uid}-arr.${index}`,
4176
+ schema: childSchema,
4177
+ model: isArray(initialModel) ? (_a = initialModel[index]) != null ? _a : null : null,
4178
+ localValue: isArray(localValue) ? (_b = localValue[index]) != null ? _b : null : null,
4179
+ validationErrors: isArray(validationErrors) ? validationErrors[index] : void 0,
4180
+ required
4181
+ },
4182
+ mapperProps
4183
+ );
4184
+ }
4185
+ );
4186
+ return createTupleComponent(__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
4187
+ components
4188
+ }));
4189
+ };
4190
+
4191
+ // src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToComponent.ts
4192
+ var arraySchemaToComponent = (schemaMapperProps, mapperProps) => {
4193
+ const { schema, model: originalModel } = schemaMapperProps;
4194
+ const model = isNullish(originalModel) || isArrayModel(originalModel) ? originalModel : null;
4195
+ if (isArraySchemaListWithMultiFileUpload(schema)) {
4196
+ return arraySchemaToMultiUploadComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
4197
+ }
4198
+ if (isArraySchemaListWithMultiSelect(schema)) {
4199
+ return arraySchemaToMultiSelectComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
4200
+ }
4201
+ if (isArrayTupleSchema(schema)) {
4202
+ return arraySchemaToTupleComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
4203
+ }
4204
+ return arraySchemaToRepeatableComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
4143
4205
  };
4206
+ var isArraySchemaListWithMultiFileUpload = (schema) => isArrayListSchema(schema) && (isPersistAsyncWithUploadSchema(schema.items) || isStringSchemaWithUpload(schema.items));
4207
+ var isPersistAsyncWithUploadSchema = (schema) => isSchemaWithPersistAsync(schema) && (isBlobSchema(schema.persistAsync.schema) || isStringSchemaWithUpload(schema.persistAsync.schema));
4208
+ var isArraySchemaListWithMultiSelect = (schema) => isArrayListSchema(schema) && "oneOf" in schema.items && schema.items.oneOf.every(isConstSchema);
4144
4209
 
4145
4210
  // src/revamp/domain/components/UploadInputComponent.ts
4146
4211
  var createUploadInputComponent = (uploadInputProps, updateComponent) => {
@@ -4246,70 +4311,222 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
4246
4311
  });
4247
4312
  };
4248
4313
 
4249
- // src/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToUploadInputComponent.ts
4250
- var stringSchemaToUploadInputComponent = (schemaMapperProps, mapperProps) => {
4251
- var _a;
4314
+ // src/revamp/domain/mappers/schema/blobSchemaToComponent.ts
4315
+ var blobSchemaToComponent = (schemaMapperProps, mapperProps) => {
4252
4316
  const { schema, localValue, model, required = false } = schemaMapperProps;
4253
- const { accepts, autocompleteHint, cameraConfig, hidden, maxSize, source, validationMessages } = schema;
4254
- const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange } = mapperProps;
4317
+ const { accepts, cameraConfig, maxSize, source, validationMessages } = schema;
4318
+ const { getErrorMessageFunctions, updateComponent, onValueChange } = mapperProps;
4255
4319
  const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
4256
4320
  const { performPersistAsync } = getPersistAsyncInitialState(schemaMapperProps, mapperProps);
4257
4321
  const persistedState = performPersistAsync ? getInitialPersistedState(null, model) : getInitialPersistedState();
4258
4322
  const validLocalValue = isFile(localValue) ? localValue : null;
4259
- const value = (_a = getFileFromModel(model)) != null ? _a : validLocalValue;
4260
- const checks = hidden ? [] : [
4261
- getRequiredCheck(required, errorMessageFunctions),
4262
- getFileSizeCheck(schema, errorMessageFunctions),
4263
- getFileTypeCheck(schema, errorMessageFunctions)
4264
- ];
4323
+ const value = performPersistAsync ? validLocalValue : null;
4265
4324
  return createUploadInputComponent(
4266
4325
  __spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
4267
4326
  accepts,
4268
- autoComplete: getAutocompleteString(autocompleteHint),
4327
+ autoComplete: "off",
4269
4328
  cameraConfig,
4270
- checks,
4271
- format: "base64",
4329
+ format: "blob",
4272
4330
  maxSize,
4273
4331
  source,
4274
4332
  value,
4275
4333
  persistedState,
4276
4334
  performPersistAsync,
4277
- performRefresh: getPerformRefresh(schema, onRefresh),
4335
+ checks: schema.hidden ? [] : [getRequiredCheck(required, errorMessageFunctions)],
4278
4336
  onValueChange
4279
4337
  }),
4280
4338
  updateComponent
4281
4339
  );
4282
4340
  };
4283
- var getFileFromModel = (model) => isString(model) ? base64dataUrltoFile(model, "") : null;
4284
4341
 
4285
- // src/revamp/domain/components/TextInputComponent.ts
4286
- var createTextInputComponent = (textInputProps, updateComponent) => {
4287
- const _a = textInputProps, {
4342
+ // src/revamp/domain/components/BooleanInputComponent.ts
4343
+ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
4344
+ const _a = booleanInputProps, {
4345
+ uid,
4346
+ id,
4347
+ value,
4348
+ performPersistAsync,
4349
+ performRefresh,
4350
+ performValidationAsync,
4351
+ onValueChange,
4352
+ summariser
4353
+ } = _a, rest = __objRest(_a, [
4354
+ "uid",
4355
+ "id",
4356
+ "value",
4357
+ "performPersistAsync",
4358
+ "performRefresh",
4359
+ "performValidationAsync",
4360
+ "onValueChange",
4361
+ "summariser"
4362
+ ]);
4363
+ const update = getInputUpdateFunction(updateComponent);
4364
+ const booleanComponent = __spreadValues({
4365
+ type: "boolean",
4366
+ uid,
4367
+ id,
4368
+ autoComplete: "",
4369
+ value,
4370
+ _update(updateFn) {
4371
+ update(this, updateFn);
4372
+ },
4373
+ onBlur() {
4374
+ },
4375
+ // Noop
4376
+ onFocus() {
4377
+ },
4378
+ // Noop
4379
+ onChange(updatedValue) {
4380
+ this._update((draft) => {
4381
+ draft.errors = [];
4382
+ draft.value = updatedValue;
4383
+ });
4384
+ performRefresh == null ? void 0 : performRefresh();
4385
+ onValueChange();
4386
+ },
4387
+ async getSubmittableValue() {
4388
+ return this.getSubmittableValueSync();
4389
+ },
4390
+ getSubmittableValueSync() {
4391
+ return this.getLocalValue();
4392
+ },
4393
+ getSummary() {
4394
+ return summariser(this.getLocalValue());
4395
+ },
4396
+ getLocalValue() {
4397
+ return this.value;
4398
+ },
4399
+ validate: () => true
4400
+ }, rest);
4401
+ if (performRefresh) {
4402
+ return booleanComponent;
4403
+ }
4404
+ if (performPersistAsync) {
4405
+ const persist = getComponentPersistAsync(update, performPersistAsync);
4406
+ return __spreadProps(__spreadValues({}, booleanComponent), {
4407
+ onChange(updatedValue) {
4408
+ booleanComponent.onChange.call(this, updatedValue);
4409
+ persist(this, this.getLocalValue()).catch(() => {
4410
+ });
4411
+ },
4412
+ async getSubmittableValue() {
4413
+ return persist(this, this.getLocalValue());
4414
+ },
4415
+ getSubmittableValueSync() {
4416
+ return this.persistedState.lastResponse;
4417
+ }
4418
+ });
4419
+ }
4420
+ if (performValidationAsync) {
4421
+ const validateAsync = getComponentValidationAsync(update, performValidationAsync);
4422
+ return __spreadProps(__spreadValues({}, booleanComponent), {
4423
+ onChange(updatedValue) {
4424
+ booleanComponent.onChange.call(this, updatedValue);
4425
+ validateAsync(this, this.getLocalValue()).catch(() => {
4426
+ });
4427
+ }
4428
+ });
4429
+ }
4430
+ return booleanComponent;
4431
+ };
4432
+
4433
+ // src/revamp/domain/mappers/schema/booleanSchemaToComponent.ts
4434
+ var booleanSchemaToComponent = (schemaMapperProps, mapperProps) => {
4435
+ const { schema, localValue, model } = schemaMapperProps;
4436
+ const { default: defaultValue } = schema;
4437
+ const { updateComponent, onRefresh, onValueChange } = mapperProps;
4438
+ const performRefresh = getPerformRefresh(schema, onRefresh);
4439
+ const { performPersistAsync, persistedState } = getPersistAsyncInitialState(
4440
+ schemaMapperProps,
4441
+ mapperProps
4442
+ );
4443
+ const { performValidationAsync, validationAsyncState } = getValidationAsyncInitialState(
4444
+ schemaMapperProps,
4445
+ mapperProps
4446
+ );
4447
+ const validLocalValue = isBoolean(localValue) ? localValue : false;
4448
+ const validModel = getValidModel(model, defaultValue);
4449
+ const value = performPersistAsync ? validLocalValue : validModel;
4450
+ return createBooleanInputComponent(
4451
+ __spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
4452
+ value: value != null ? value : false,
4453
+ persistedState,
4454
+ validationAsyncState,
4455
+ performPersistAsync,
4456
+ performRefresh,
4457
+ performValidationAsync,
4458
+ onValueChange
4459
+ }),
4460
+ updateComponent
4461
+ );
4462
+ };
4463
+ var getValidModel = (model, defaultValue) => {
4464
+ if (isBoolean(model)) {
4465
+ return model;
4466
+ }
4467
+ if (isBoolean(defaultValue)) {
4468
+ return defaultValue;
4469
+ }
4470
+ return false;
4471
+ };
4472
+
4473
+ // src/revamp/domain/components/ConstComponent.ts
4474
+ var createConstComponent = (hiddenProps) => {
4475
+ const { uid, analyticsId, value, summary } = hiddenProps;
4476
+ return {
4477
+ type: "const",
4478
+ uid,
4479
+ analyticsId,
4480
+ getLocalValue: () => value,
4481
+ getSubmittableValue: async () => value,
4482
+ getSubmittableValueSync: () => value,
4483
+ getSummary: () => summary,
4484
+ validate: () => true
4485
+ };
4486
+ };
4487
+
4488
+ // src/revamp/domain/mappers/schema/constSchemaToComponent.ts
4489
+ var constSchemaToComponent = (uid, schemaMapperProps) => {
4490
+ var _a;
4491
+ const { schema } = schemaMapperProps;
4492
+ const { title, const: constValue, analyticsId, $id } = schema;
4493
+ const titleOrValue = (_a = title != null ? title : constValue) != null ? _a : null;
4494
+ return createConstComponent({
4495
+ uid,
4496
+ analyticsId: analyticsId != null ? analyticsId : $id,
4497
+ summary: getConstSummary(schema, titleOrValue),
4498
+ value: schema.const
4499
+ });
4500
+ };
4501
+
4502
+ // src/revamp/domain/components/IntegerInputComponent.ts
4503
+ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
4504
+ const _a = integerInputProps, {
4288
4505
  uid,
4289
4506
  id,
4290
4507
  checks,
4508
+ value,
4291
4509
  performPersistAsync,
4292
4510
  performRefresh,
4293
4511
  performValidationAsync,
4294
4512
  onValueChange,
4295
- summariser,
4296
- value
4513
+ summariser
4297
4514
  } = _a, rest = __objRest(_a, [
4298
4515
  "uid",
4299
4516
  "id",
4300
4517
  "checks",
4518
+ "value",
4301
4519
  "performPersistAsync",
4302
4520
  "performRefresh",
4303
4521
  "performValidationAsync",
4304
4522
  "onValueChange",
4305
- "summariser",
4306
- "value"
4523
+ "summariser"
4307
4524
  ]);
4308
4525
  const update = getInputUpdateFunction(updateComponent);
4309
4526
  const getValidationErrors = getLocalValueValidator(checks);
4310
4527
  const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh, getValidationErrors);
4311
- const inputComponent = __spreadValues({
4312
- type: "text",
4528
+ const integerComponent = __spreadValues({
4529
+ type: "integer",
4313
4530
  uid,
4314
4531
  id,
4315
4532
  value,
@@ -4337,7 +4554,8 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
4337
4554
  return this.getSubmittableValueSync();
4338
4555
  },
4339
4556
  getSubmittableValueSync() {
4340
- return this.getLocalValue() || null;
4557
+ var _a2;
4558
+ return (_a2 = this.getLocalValue()) != null ? _a2 : null;
4341
4559
  },
4342
4560
  getSummary() {
4343
4561
  return summariser(this.getLocalValue());
@@ -4354,11 +4572,11 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
4354
4572
  }
4355
4573
  }, rest);
4356
4574
  if (performRefresh) {
4357
- return inputComponent;
4575
+ return integerComponent;
4358
4576
  }
4359
4577
  if (performPersistAsync) {
4360
4578
  const persist = getComponentPersistAsync(update, performPersistAsync);
4361
- return __spreadProps(__spreadValues({}, inputComponent), {
4579
+ return __spreadProps(__spreadValues({}, integerComponent), {
4362
4580
  onBlur() {
4363
4581
  if (this.validate()) {
4364
4582
  persist(this, this.getLocalValue()).catch(() => {
@@ -4375,43 +4593,28 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
4375
4593
  }
4376
4594
  if (performValidationAsync) {
4377
4595
  const validateAsync = getDebouncedComponentValidationAsync(update, performValidationAsync);
4378
- return __spreadProps(__spreadValues({}, inputComponent), {
4596
+ return __spreadProps(__spreadValues({}, integerComponent), {
4379
4597
  onBlur() {
4380
4598
  if (this.validate()) {
4381
4599
  validateAsync.flush();
4382
4600
  }
4383
4601
  },
4384
4602
  onChange(updatedValue) {
4385
- inputComponent.onChange.call(this, updatedValue);
4603
+ integerComponent.onChange.call(this, updatedValue);
4386
4604
  if (getValidationErrors(updatedValue).length === 0) {
4387
4605
  validateAsync(this, updatedValue);
4388
4606
  }
4389
- if (!updatedValue) {
4390
- validateAsync.cancel();
4391
- }
4392
4607
  }
4393
4608
  });
4394
4609
  }
4395
- return inputComponent;
4610
+ return integerComponent;
4396
4611
  };
4397
4612
 
4398
- // src/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToTextInputComponent.ts
4399
- var stringSchemaToTextInputComponent = (schemaMapperProps, mapperProps) => {
4613
+ // src/revamp/domain/mappers/schema/integerSchemaToComponent.ts
4614
+ var integerSchemaToComponent = (schemaMapperProps, mapperProps) => {
4400
4615
  const { schema, localValue, model, required = false } = schemaMapperProps;
4401
- const {
4402
- autocapitalization,
4403
- autocompleteHint,
4404
- control,
4405
- default: defaultValue,
4406
- displayFormat,
4407
- format,
4408
- maxLength,
4409
- minLength,
4410
- suggestions,
4411
- validationMessages
4412
- } = schema;
4413
- const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange, logEvent } = mapperProps;
4414
- const controlForLegacyFormat = getControlForLegacyFormat(format);
4616
+ const { autocompleteHint, validationMessages, default: defaultValue, maximum, minimum } = schema;
4617
+ const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange } = mapperProps;
4415
4618
  const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
4416
4619
  const { performPersistAsync, persistedState } = getPersistAsyncInitialState(
4417
4620
  schemaMapperProps,
@@ -4421,30 +4624,22 @@ var stringSchemaToTextInputComponent = (schemaMapperProps, mapperProps) => {
4421
4624
  schemaMapperProps,
4422
4625
  mapperProps
4423
4626
  );
4424
- const validLocalValue = isString(localValue) ? localValue : null;
4425
- const validModel = isString(model) ? model : defaultValue != null ? defaultValue : null;
4627
+ const validLocalValue = isInteger(localValue) ? localValue : null;
4628
+ const validModel = isInteger(model) ? model : defaultValue != null ? defaultValue : null;
4426
4629
  const value = performPersistAsync ? validLocalValue : validModel;
4427
- return createTextInputComponent(
4630
+ const checks = [
4631
+ getRequiredCheck(required, errorMessageFunctions),
4632
+ getBelowMinimumCheck(schema, errorMessageFunctions),
4633
+ getAboveMaximumCheck(schema, errorMessageFunctions)
4634
+ ];
4635
+ return createIntegerInputComponent(
4428
4636
  __spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
4429
- autocapitalization,
4430
4637
  autoComplete: getAutocompleteString(autocompleteHint),
4431
- checks: schema.hidden ? [] : [
4432
- getRequiredCheck(required, errorMessageFunctions),
4433
- getAboveMaxLengthCheck(schema, errorMessageFunctions),
4434
- getBelowMinLengthCheck(schema, errorMessageFunctions),
4435
- getNotAdheringToPatternCheck(schema, errorMessageFunctions, { logEvent })
4436
- ],
4437
- control: control != null ? control : controlForLegacyFormat,
4438
- displayFormat,
4439
- maxLength,
4440
- minLength,
4441
- suggestions: suggestions ? {
4442
- values: suggestions.values.map((suggestion) => __spreadProps(__spreadValues({}, suggestion), {
4443
- image: mapSpecImage(suggestion.image)
4444
- }))
4445
- } : void 0,
4446
- value,
4638
+ checks,
4639
+ maximum,
4640
+ minimum,
4447
4641
  persistedState,
4642
+ value,
4448
4643
  validationAsyncState,
4449
4644
  performPersistAsync,
4450
4645
  performRefresh: getPerformRefresh(schema, onRefresh),
@@ -4454,548 +4649,258 @@ var stringSchemaToTextInputComponent = (schemaMapperProps, mapperProps) => {
4454
4649
  updateComponent
4455
4650
  );
4456
4651
  };
4457
- var getControlForLegacyFormat = (format) => {
4458
- if (format && ["numeric", "phone-number", "email", "password"].includes(format)) {
4459
- return format;
4460
- }
4461
- return void 0;
4462
- };
4463
4652
 
4464
- // src/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToComponent.ts
4465
- var stringSchemaToComponent = (schemaMapperProps, mapperProps) => {
4466
- const { schema } = schemaMapperProps;
4467
- if (isStringSchemaWithBase64(schema)) {
4468
- return stringSchemaToUploadInputComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema }), mapperProps);
4469
- }
4470
- switch (schema.format) {
4471
- case "date":
4472
- return stringSchemaToDateInputComponent(schemaMapperProps, mapperProps);
4473
- default:
4474
- return stringSchemaToTextInputComponent(schemaMapperProps, mapperProps);
4475
- }
4476
- };
4477
- var isStringSchemaWithBase64 = (schema) => {
4478
- return schema.format === "base64url" && !("persistAsync" in schema);
4479
- };
4480
-
4481
- // src/revamp/domain/components/ContainerComponent.ts
4482
- var createContainerComponent = (containerProps) => __spreadProps(__spreadValues({}, containerProps), {
4483
- type: "container",
4484
- getChildren() {
4485
- return this.components;
4486
- },
4487
- async getSubmittableValue() {
4488
- return getSubmittableData(this.components);
4489
- },
4490
- getSubmittableValueSync() {
4491
- return getSubmittableDataSync(this.components);
4492
- },
4493
- getSummary() {
4494
- return summariseFromChildren(this.getChildren());
4495
- },
4496
- getLocalValue() {
4497
- return getLocalValues(this.components);
4498
- },
4499
- validate() {
4500
- return validateComponents(this.getChildren());
4501
- }
4502
- });
4503
-
4504
- // src/revamp/domain/components/RepeatableComponent.ts
4505
- var createRepeatableComponent = (repeatableProps, updateComponent) => {
4506
- const _a = repeatableProps, {
4653
+ // src/revamp/domain/components/ObjectComponent.ts
4654
+ var createObjectComponent = (objectProps) => {
4655
+ const {
4507
4656
  uid,
4508
- id,
4509
- checks,
4510
- components,
4511
- summary,
4512
- onValueChange,
4513
- createEditableComponent,
4514
- summariser
4515
- } = _a, componentProps = __objRest(_a, [
4516
- "uid",
4517
- "id",
4518
- "checks",
4519
- "components",
4520
- "summary",
4521
- "onValueChange",
4522
- "createEditableComponent",
4523
- "summariser"
4524
- ]);
4525
- const update = getInputUpdateFunction(updateComponent);
4526
- const getValidationErrors = getLocalValueValidator(checks);
4527
- const repeatableComponent = __spreadProps(__spreadValues({
4657
+ analyticsId,
4658
+ alert,
4659
+ componentMap,
4660
+ control,
4661
+ description,
4662
+ displayOrder,
4663
+ help,
4664
+ hidden,
4665
+ icon,
4666
+ image,
4667
+ summariser,
4668
+ title
4669
+ } = objectProps;
4670
+ return {
4671
+ type: "object",
4528
4672
  uid,
4529
- id,
4530
- type: "repeatable",
4531
- components,
4532
- editableComponent: null,
4533
- editableIndex: null,
4534
- summaryDefaults: {
4535
- title: summary == null ? void 0 : summary.defaultTitle,
4536
- description: summary == null ? void 0 : summary.defaultDescription,
4537
- icon: summary == null ? void 0 : summary.defaultIcon,
4538
- image: summary == null ? void 0 : summary.defaultImage
4539
- }
4540
- }, componentProps), {
4541
- _update(updateFn) {
4542
- update(this, updateFn);
4543
- },
4544
- onEdit(itemIndex) {
4545
- this._update((draft) => {
4546
- draft.editableComponent = createEditableComponent(
4547
- draft.components[itemIndex].getLocalValue()
4548
- );
4549
- draft.editableIndex = itemIndex;
4550
- });
4551
- },
4552
- onAdd() {
4553
- this._update((draft) => {
4554
- draft.editableComponent = createEditableComponent(null);
4555
- draft.editableIndex = null;
4556
- draft.errors = [];
4557
- });
4558
- },
4559
- onSave() {
4560
- var _a2;
4561
- const isValid = (_a2 = this.editableComponent) == null ? void 0 : _a2.validate();
4562
- if (!isValid) {
4563
- return false;
4564
- }
4565
- this._update((draft) => {
4566
- if (draft.editableComponent === null) {
4567
- return;
4568
- }
4569
- if (draft.editableIndex === null) {
4570
- const newComponent = __spreadValues({}, draft.editableComponent);
4571
- draft.components = [...this.components, newComponent];
4572
- } else {
4573
- draft.components[draft.editableIndex] = __spreadProps(__spreadValues({}, draft.editableComponent), {
4574
- uid: draft.components[draft.editableIndex].uid
4575
- });
4576
- }
4577
- draft.editableComponent = null;
4578
- draft.editableIndex = null;
4579
- });
4580
- onValueChange();
4581
- return true;
4582
- },
4583
- onRemove() {
4584
- this._update((draft) => {
4585
- if (draft.editableIndex === null) {
4586
- return;
4587
- }
4588
- draft.components.splice(draft.editableIndex, 1);
4589
- draft.editableComponent = null;
4590
- draft.editableIndex = null;
4591
- });
4592
- onValueChange();
4593
- },
4673
+ analyticsId,
4674
+ alert,
4675
+ componentMap,
4676
+ control,
4677
+ description,
4678
+ help,
4679
+ hidden,
4680
+ icon,
4681
+ image,
4682
+ title,
4594
4683
  getChildren() {
4595
- return this.editableComponent !== null ? [...this.components, this.editableComponent] : this.components;
4684
+ return displayOrder.map((propName) => this.componentMap[propName]);
4596
4685
  },
4597
4686
  async getSubmittableValue() {
4598
- return Promise.all(this.components.map(async (component) => component.getSubmittableValue()));
4687
+ return Promise.all(
4688
+ displayOrder.map(
4689
+ async (propName) => this.componentMap[propName].getSubmittableValue().then((value) => ({ value, propName }))
4690
+ )
4691
+ ).then(
4692
+ (values) => values.reduce(
4693
+ (acc, { value, propName }) => __spreadValues(__spreadValues({}, acc), value === null ? {} : { [propName]: value }),
4694
+ {}
4695
+ )
4696
+ );
4599
4697
  },
4600
4698
  getSubmittableValueSync() {
4601
- return this.components.map((component) => component.getSubmittableValueSync());
4699
+ return mergeChildrenValues(
4700
+ displayOrder,
4701
+ (propName) => this.componentMap[propName].getSubmittableValueSync()
4702
+ );
4602
4703
  },
4603
4704
  getSummary() {
4604
- return summariser(null);
4705
+ const summary = summariser(this.getLocalValue());
4706
+ const childSummary = summariseFromChildren(this.getChildren());
4707
+ return mergeSummaries(summary, childSummary);
4605
4708
  },
4606
4709
  getLocalValue() {
4607
- return this.components.map((component) => component.getLocalValue());
4710
+ return mergeChildrenValues(
4711
+ displayOrder,
4712
+ (propName) => this.componentMap[propName].getLocalValue()
4713
+ );
4608
4714
  },
4609
4715
  validate() {
4610
- const messages = getValidationErrors(this.getLocalValue());
4611
- const childComponentsValid = validateComponents(this.getChildren());
4612
- this._update((draft) => {
4613
- draft.errors = messages;
4614
- });
4615
- return messages.length === 0 && childComponentsValid;
4716
+ return hidden ? true : validateComponents(this.getChildren());
4616
4717
  }
4617
- });
4618
- return repeatableComponent;
4619
- };
4620
-
4621
- // src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToRepeatableComponent.ts
4622
- var arraySchemaToRepeatableComponent = (schemaMapperProps, mapperProps) => {
4623
- const { getErrorMessageFunctions } = mapperProps;
4624
- const {
4625
- uid,
4626
- localValue,
4627
- schema,
4628
- model: initialModel,
4629
- required = false,
4630
- validationErrors
4631
- } = schemaMapperProps;
4632
- const { items, addItemTitle, editItemTitle, maxItems, minItems, summary } = schema;
4633
- const value = isArray(localValue) ? localValue : [];
4634
- const components = initialModel == null ? void 0 : initialModel.map(
4635
- (item, index) => mapSchemaToComponent(
4636
- {
4637
- uid: `${uid}.arr-${index}`,
4638
- schema: items,
4639
- model: item,
4640
- localValue: value == null ? void 0 : value[index],
4641
- // TODO tests for this
4642
- validationErrors
4643
- },
4644
- mapperProps
4645
- )
4646
- );
4647
- const createEditableComponent = (editableValue) => mapSchemaToComponent(
4648
- {
4649
- uid: `${uid}.arr-rnd-${getRandomInt()}`,
4650
- schema: items,
4651
- localValue: editableValue,
4652
- model: localValueToJsonElement(editableValue),
4653
- validationErrors: void 0,
4654
- required: true
4655
- },
4656
- mapperProps
4657
- );
4658
- const { onValueChange } = mapperProps;
4659
- const errorMessageFunctions = getErrorMessageFunctions(schema.validationMessages);
4660
- return createRepeatableComponent(
4661
- __spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
4662
- addItemTitle,
4663
- checks: schema.hidden ? [] : [
4664
- getRequiredCheck(required, errorMessageFunctions),
4665
- getAboveMaxItemsCheck(schema, errorMessageFunctions),
4666
- getBelowMinItemsCheck(schema, errorMessageFunctions)
4667
- ],
4668
- components: components != null ? components : [],
4669
- editItemTitle,
4670
- maxItems,
4671
- minItems,
4672
- summary: __spreadProps(__spreadValues({}, summary), {
4673
- defaultImage: mapSpecImage(summary == null ? void 0 : summary.defaultImage)
4674
- }),
4675
- createEditableComponent,
4676
- onValueChange
4677
- }),
4678
- mapperProps.updateComponent
4679
- );
4680
- };
4681
- var localValueToJsonElement = (localValue) => {
4682
- if (localValue instanceof Array) {
4683
- return localValue.map(localValueToJsonElement);
4684
- }
4685
- if (isObject(localValue)) {
4686
- return Object.fromEntries(
4687
- Object.entries(localValue).map(([key, value]) => [key, localValueToJsonElement(value)])
4688
- );
4689
- }
4690
- if (localValue instanceof File) {
4691
- return localValue.name;
4692
- }
4693
- return localValue;
4718
+ };
4694
4719
  };
4695
- var getRandomInt = () => Math.floor(Math.random() * 1e8);
4720
+ var mergeChildrenValues = (displayOrder, getComponentValue) => displayOrder.reduce((acc, propName) => {
4721
+ const componentValue = getComponentValue(propName);
4722
+ return __spreadValues(__spreadValues({}, acc), componentValue === null ? {} : { [propName]: componentValue });
4723
+ }, {});
4696
4724
 
4697
- // src/revamp/domain/components/MultiUploadInputComponent.ts
4698
- var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
4699
- const _a = uploadInputProps, {
4700
- uid,
4701
- id,
4702
- checks,
4703
- fileChecks,
4704
- format,
4705
- performPersistAsync,
4706
- onValueChange,
4707
- summariser
4708
- } = _a, rest = __objRest(_a, [
4709
- "uid",
4710
- "id",
4711
- "checks",
4712
- "fileChecks",
4713
- "format",
4714
- "performPersistAsync",
4715
- "onValueChange",
4716
- "summariser"
4717
- ]);
4718
- const update = getInputUpdateFunction(updateComponent);
4719
- const getValidationErrors = getLocalValueValidator(checks);
4720
- const getFileValidationErrors = getLocalValueValidator(fileChecks);
4721
- const uploadComponent = __spreadValues({
4722
- type: "multi-upload",
4723
- uid,
4724
- id,
4725
- format: "base64",
4726
- files: [],
4727
- _update(updateFn) {
4728
- update(this, updateFn);
4729
- },
4730
- onBlur() {
4731
- this.validate();
4732
- },
4733
- onFocus() {
4734
- },
4735
- // Noop
4736
- async onRemoveFile(index) {
4737
- this._update((draft) => {
4738
- draft.value.splice(index, 1);
4739
- draft.files.splice(index, 1);
4740
- });
4741
- },
4742
- async onInsertFile(index, file) {
4743
- const fileErrors = getFileValidationErrors(file);
4744
- const fileId = getRandomId();
4745
- this._update((draft) => {
4746
- draft.value.splice(index, 0, file);
4747
- draft.files.splice(index, 0, { file, id: fileId, errors: fileErrors });
4748
- draft.errors = [];
4749
- });
4750
- onValueChange();
4751
- return fileId;
4752
- },
4753
- async getSubmittableValue() {
4754
- const files = this.getLocalValue();
4755
- return files ? Promise.all(files.map(toBase64)) : null;
4756
- },
4757
- getSubmittableValueSync() {
4758
- return null;
4759
- },
4760
- getSummary() {
4761
- return summariser(this.getLocalValue().map(({ name }) => name));
4762
- },
4763
- getLocalValue() {
4764
- return this.value;
4765
- },
4766
- validate() {
4767
- const errorMsgs = getValidationErrors(this.getLocalValue());
4768
- this._update((draft) => {
4769
- draft.errors = errorMsgs;
4770
- });
4771
- return errorMsgs.length === 0 && this.files.every(({ errors }) => errors.length === 0);
4725
+ // src/revamp/domain/mappers/schema/objectSchemaToComponent/objectSchemaToComponent.ts
4726
+ var objectSchemaToComponent = (schemaMapperProps, mapperProps) => {
4727
+ const { uid, localValue, schema, model, validationErrors } = schemaMapperProps;
4728
+ const { $id, displayOrder, properties, required } = schema;
4729
+ validateDisplayOrder($id, displayOrder, properties, mapperProps.logEvent);
4730
+ const componentMap = displayOrder.reduce((acc, propName) => {
4731
+ var _a;
4732
+ const propSchema = properties[propName];
4733
+ if (propSchema === void 0) {
4734
+ throw new Error(`Object schema ${$id} has no property named ${propName}`);
4772
4735
  }
4773
- }, rest);
4774
- if (!performPersistAsync) {
4775
- return uploadComponent;
4736
+ return __spreadProps(__spreadValues({}, acc), {
4737
+ [propName]: mapSchemaToComponent(
4738
+ {
4739
+ uid: `${uid}.obj-${propName}`,
4740
+ schema: propSchema,
4741
+ model: isObjectModel(model) ? model[propName] : null,
4742
+ localValue: isObjectLocalValue(localValue) ? localValue[propName] : null,
4743
+ required: (_a = required == null ? void 0 : required.includes(propName)) != null ? _a : false,
4744
+ validationErrors: isObject(validationErrors) ? validationErrors[propName] : void 0
4745
+ },
4746
+ mapperProps
4747
+ )
4748
+ });
4749
+ }, {});
4750
+ return createObjectComponent(__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
4751
+ componentMap,
4752
+ displayOrder
4753
+ }));
4754
+ };
4755
+ var validateDisplayOrder = ($id, displayOrder, properties, logEvent) => {
4756
+ if (!displayOrder) {
4757
+ const message = `Object schema ${$id} has no displayOrder property.`;
4758
+ logEvent("error", message);
4759
+ throw new Error(message);
4776
4760
  }
4777
- const persist = getComponentMultiPersistAsync(update, performPersistAsync);
4778
- return __spreadProps(__spreadValues({}, uploadComponent), {
4779
- format,
4780
- async onInsertFile(index, file) {
4781
- const fileId = await uploadComponent.onInsertFile.call(this, index, file);
4782
- const submission = format === "blob" ? file : await toBase64(file);
4783
- await persist(this, index, submission);
4784
- onValueChange();
4785
- return fileId;
4786
- },
4787
- async onRemoveFile(index) {
4788
- var _a2;
4789
- await uploadComponent.onRemoveFile.call(this, index);
4790
- (_a2 = this.persistedState[index]) == null ? void 0 : _a2.abortController.abort();
4791
- this._update((draft) => {
4792
- draft.persistedState = draft.persistedState.splice(index, 1);
4793
- });
4794
- },
4795
- async getSubmittableValue() {
4796
- return Promise.all(this.persistedState.map(async ({ submission }) => submission));
4797
- },
4798
- getSubmittableValueSync() {
4799
- return this.persistedState.map(({ lastResponse }) => lastResponse);
4761
+ const propertyNames = Object.keys(properties);
4762
+ displayOrder.forEach((propName) => {
4763
+ if (!properties[propName]) {
4764
+ const message = `Object schema ${$id} has no property named "${propName}", but it is listed in the displayOrder array.`;
4765
+ logEvent("error", message);
4766
+ throw new Error(message);
4800
4767
  }
4801
4768
  });
4802
- };
4803
-
4804
- // src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToMultiUploadComponent.ts
4805
- var arraySchemaToMultiUploadComponent = (schemaMapperProps, mapperProps) => {
4806
- var _a;
4807
- const { getErrorMessageFunctions } = mapperProps;
4808
- const { localValue, model, schema, required = false } = schemaMapperProps;
4809
- const uploadSchema = getUploadSchema(schema.items);
4810
- const { accepts, cameraConfig, maxSize } = uploadSchema;
4811
- const { minItems, maxItems, title, validationMessages } = schema;
4812
- const arrayErrorMessageFunctions = getErrorMessageFunctions(validationMessages);
4813
- const fileErrorMessageFunctions = getErrorMessageFunctions(uploadSchema.validationMessages);
4814
- const checks = [
4815
- getRequiredCheck(required, arrayErrorMessageFunctions),
4816
- getAboveMaxFilesCheck(schema, arrayErrorMessageFunctions),
4817
- getBelowMinFilesCheck(schema, arrayErrorMessageFunctions)
4818
- ];
4819
- const fileChecks = [
4820
- getFileSizeCheck(schema.items, fileErrorMessageFunctions),
4821
- getFileTypeCheck(schema.items, fileErrorMessageFunctions)
4822
- ];
4823
- const persistAsyncConfig = getPersistAsyncConfig(schema.items);
4824
- const format = getFormat(schema.items);
4825
- const combinedSchemaProps = __spreadProps(__spreadValues({}, schemaMapperProps), {
4826
- persistAsyncConfig,
4827
- schema: __spreadProps(__spreadValues({}, uploadSchema), { hidden: (_a = schema.hidden) != null ? _a : uploadSchema.hidden })
4769
+ propertyNames.forEach((propName) => {
4770
+ if (!displayOrder.includes(propName)) {
4771
+ const message = `Object schema ${$id} has a "${propName}" property which is missing in the displayOrder array.`;
4772
+ logEvent("error", message);
4773
+ throw new Error(message);
4774
+ }
4828
4775
  });
4829
- const { onValueChange } = mapperProps;
4830
- const { performPersistAsync } = getPersistAsyncInitialState(combinedSchemaProps, mapperProps);
4831
- const value = performPersistAsync ? getValueForPersistAsync(localValue) : [];
4832
- const persistedState = performPersistAsync && isArray(model) ? model.map((itemModel) => getInitialPersistedState(null, itemModel)) : [];
4833
- return createMultiUploadInputComponent(
4834
- __spreadProps(__spreadValues({}, mapCommonSchemaProps(combinedSchemaProps)), {
4835
- title,
4836
- cameraConfig,
4837
- uploadLabel: uploadSchema.title,
4838
- accepts,
4839
- autoComplete: "off",
4840
- checks: schema.hidden ? [] : checks,
4841
- fileChecks: schema.hidden ? [] : fileChecks,
4842
- format,
4843
- maxSize,
4844
- minItems,
4845
- maxItems,
4846
- required,
4847
- source: uploadSchema.source,
4848
- value,
4849
- persistedState,
4850
- performPersistAsync,
4851
- onValueChange
4852
- }),
4853
- mapperProps.updateComponent
4854
- );
4855
- };
4856
- var getFormat = (schema) => {
4857
- if (isStringSchemaWithUpload(schema)) {
4858
- return "base64";
4859
- }
4860
- return isBlobSchema(schema.persistAsync.schema) ? "blob" : "base64";
4861
4776
  };
4862
- var getUploadSchema = (schema) => {
4863
- if (isStringSchemaWithUpload(schema)) {
4864
- return schema;
4777
+
4778
+ // src/revamp/domain/components/utils/isPartialModelMatch.ts
4779
+ var isPartialModelMatch = (localModel, incomingModel) => {
4780
+ if (isArrayModel(localModel) && isArrayModel(incomingModel)) {
4781
+ return localModel.length === incomingModel.length && localModel.every((value, index) => isPartialModelMatch(value, incomingModel[index]));
4865
4782
  }
4866
- return schema.persistAsync.schema;
4867
- };
4868
- var getPersistAsyncConfig = (schema) => {
4869
- if (!isSchemaWithPersistAsync(schema)) {
4870
- return void 0;
4783
+ if (isObjectModel(localModel) && isObjectModel(incomingModel)) {
4784
+ if (Object.keys(localModel).length === 0 && Object.keys(incomingModel).length === 0) {
4785
+ return true;
4786
+ }
4787
+ const nonNullishKeysInBoth = nonNullishKeys(localModel).filter(
4788
+ (key) => nonNullishKeys(incomingModel).includes(key)
4789
+ );
4790
+ return nonNullishKeysInBoth.length > 0 && nonNullishKeysInBoth.every((key) => isPartialModelMatch(localModel[key], incomingModel[key]));
4871
4791
  }
4872
- const { persistAsync } = schema;
4873
- const { idProperty, method, param, url } = persistAsync;
4874
- return { idProperty, method, param, url };
4792
+ return localModel === incomingModel;
4875
4793
  };
4876
- var getValueForPersistAsync = (localValue) => isArray(localValue) && localValue.every(isFile) ? localValue : [];
4794
+ var nonNullishKeys = (model) => Object.keys(model).filter((key) => !isNullish(model[key]));
4877
4795
 
4878
- // src/revamp/domain/components/MultiSelectInputComponent.ts
4879
- var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
4880
- const _a = multiSelectProps, {
4881
- uid,
4882
- checks,
4883
- options,
4884
- initialValue,
4885
- performValidationAsync,
4886
- performRefresh,
4887
- onValueChange
4888
- } = _a, rest = __objRest(_a, [
4889
- "uid",
4890
- "checks",
4891
- "options",
4892
- "initialValue",
4893
- "performValidationAsync",
4894
- "performRefresh",
4895
- "onValueChange"
4896
- ]);
4897
- const update = getInputUpdateFunction(updateComponent);
4796
+ // src/revamp/domain/components/SelectInputComponent.ts
4797
+ var createSelectInputComponent = (selectProps, updateComponent) => {
4798
+ const _a = selectProps, { uid, checks, initialModel, options, performRefresh, onValueChange, summariser } = _a, rest = __objRest(_a, ["uid", "checks", "initialModel", "options", "performRefresh", "onValueChange", "summariser"]);
4898
4799
  const children = options.map((option) => option.component);
4899
- const selectedIndices = getInitialModelIndices(initialValue, children);
4800
+ const matchingOptions = options.map(
4801
+ (option) => isPartialModelMatch(option.component.getSubmittableValueSync(), initialModel)
4802
+ );
4803
+ const selectedIndex = matchingOptions.filter((match) => match).length === 1 ? matchingOptions.indexOf(true) : null;
4804
+ const update = getInputUpdateFunction(updateComponent);
4900
4805
  const getValidationErrors = getLocalValueValidator(checks);
4901
- const inputComponent = __spreadProps(__spreadValues({
4806
+ const component = __spreadProps(__spreadValues({
4902
4807
  uid,
4903
- type: "multi-select",
4808
+ type: "select",
4904
4809
  children,
4905
4810
  options,
4906
- selectedIndices,
4811
+ selectedIndex,
4907
4812
  value: null
4908
4813
  }, rest), {
4909
4814
  _update(updateFn) {
4910
4815
  update(this, updateFn);
4911
4816
  },
4912
- onSelect(indices) {
4913
- this._update((draft) => {
4914
- draft.selectedIndices = indices;
4915
- draft.errors = [];
4916
- });
4917
- performRefresh == null ? void 0 : performRefresh();
4918
- onValueChange();
4919
- const errors = getValidationErrors(this.getLocalValue());
4920
- this._update((draft) => {
4921
- draft.errors = errors;
4922
- });
4923
- },
4924
- onBlur() {
4817
+ getChildren() {
4818
+ return this.children;
4925
4819
  },
4926
- // Noop
4927
- onFocus() {
4820
+ getSelectedChild() {
4821
+ return this.selectedIndex !== null ? this.children[this.selectedIndex] : null;
4928
4822
  },
4929
- // Noop
4930
- getLocalValue() {
4823
+ async getSubmittableValue() {
4931
4824
  var _a2, _b;
4932
- return (_b = (_a2 = this.getSelectedChildren()) == null ? void 0 : _a2.map((child) => child.getLocalValue())) != null ? _b : null;
4825
+ return (_b = await ((_a2 = this.getSelectedChild()) == null ? void 0 : _a2.getSubmittableValue())) != null ? _b : null;
4933
4826
  },
4934
- validate() {
4935
- const errors = getValidationErrors(this.getLocalValue());
4936
- this._update((draft) => {
4937
- draft.errors = errors;
4938
- });
4939
- return errors.length === 0;
4827
+ getSubmittableValueSync() {
4828
+ var _a2, _b;
4829
+ return (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.getSubmittableValueSync()) != null ? _b : null;
4940
4830
  },
4941
- async getSubmittableValue() {
4942
- const selected = this.getSelectedChildren();
4943
- if (selected) {
4944
- return Promise.all(selected.map(async (child) => child.getSubmittableValue()));
4945
- }
4946
- return null;
4831
+ getSummary() {
4832
+ var _a2, _b;
4833
+ return (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.getSummary()) != null ? _b : {};
4947
4834
  },
4948
- getSubmittableValueSync() {
4835
+ getLocalValue() {
4949
4836
  var _a2, _b;
4950
- return (_b = (_a2 = this.getSelectedChildren()) == null ? void 0 : _a2.map((child) => child.getSubmittableValueSync())) != null ? _b : null;
4837
+ return (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.getLocalValue()) != null ? _b : null;
4951
4838
  },
4952
- getSummary: () => ({}),
4953
- getChildren() {
4954
- return this.children;
4839
+ onBlur() {
4840
+ this.validate();
4955
4841
  },
4956
- getSelectedChildren() {
4957
- return this.selectedIndices.map((i) => this.children[i]);
4958
- }
4959
- });
4960
- if (performRefresh) {
4961
- return inputComponent;
4962
- }
4963
- if (performValidationAsync) {
4964
- const validateAsync = getComponentValidationAsync(update, performValidationAsync);
4965
- return __spreadProps(__spreadValues({}, inputComponent), {
4966
- onSelect(indices) {
4967
- inputComponent.onSelect.call(this, indices);
4968
- if (this.validate()) {
4969
- validateAsync(this, this.getLocalValue()).catch(() => {
4970
- });
4971
- }
4842
+ onFocus() {
4843
+ },
4844
+ // noop
4845
+ onSelect(updatedIndex) {
4846
+ if (updatedIndex === this.selectedIndex) {
4847
+ return;
4972
4848
  }
4973
- });
4974
- }
4975
- return inputComponent;
4976
- };
4977
- var getInitialModelIndices = (model, options) => {
4978
- if (!isArray(model)) {
4979
- return [];
4980
- }
4981
- return model.map((m) => options.findIndex((o) => o.getLocalValue() === m)).filter((n) => n >= 0);
4849
+ if (updatedIndex !== null && this.analyticsId) {
4850
+ selectProps.trackEvent("OneOf Selected", {
4851
+ oneOfId: this.analyticsId,
4852
+ schemaId: this.children[updatedIndex].analyticsId
4853
+ });
4854
+ }
4855
+ this._update((draft) => {
4856
+ draft.errors = [];
4857
+ draft.selectedIndex = updatedIndex;
4858
+ });
4859
+ performRefresh == null ? void 0 : performRefresh();
4860
+ onValueChange();
4861
+ },
4862
+ validate() {
4863
+ var _a2, _b;
4864
+ const validChild = (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.validate()) != null ? _b : true;
4865
+ const errors = getValidationErrors(this.getLocalValue());
4866
+ this._update((draft) => {
4867
+ draft.errors = errors;
4868
+ });
4869
+ return errors.length === 0 && validChild;
4870
+ }
4871
+ });
4872
+ return component;
4982
4873
  };
4983
4874
 
4984
- // src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToMultiSelectComponent.ts
4985
- var arraySchemaToMultiSelectComponent = (schemaMapperProps, mapperProps) => {
4875
+ // src/revamp/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.ts
4876
+ var oneOfSchemaToComponent = (schemaMapperProps, mapperProps) => {
4877
+ var _a;
4986
4878
  const {
4987
4879
  uid,
4988
4880
  localValue,
4989
4881
  schema,
4990
4882
  model,
4991
- required = false,
4992
- validationErrors: initialError
4883
+ validationErrors: initialError,
4884
+ required = false
4993
4885
  } = schemaMapperProps;
4994
- const initialModel = model != null ? model : null;
4995
- const options = schema.items.oneOf.map((childSchema, index) => {
4996
- const { title: title2 = "", description, image, icon, keywords = [] } = childSchema;
4886
+ const initialModel = (_a = model != null ? model : schema.default) != null ? _a : null;
4887
+ if (schema.oneOf.length === 1 && isFormSectionSchema(schema.oneOf[0])) {
4888
+ return mapSchemaToComponent(
4889
+ {
4890
+ uid,
4891
+ schema: supressSchemaTitleAndDescription(schema.oneOf[0]),
4892
+ model: initialModel,
4893
+ localValue,
4894
+ validationErrors: initialError,
4895
+ required
4896
+ },
4897
+ mapperProps
4898
+ );
4899
+ }
4900
+ const options = schema.oneOf.map((childSchema, index) => {
4901
+ const { title = "", description, image, icon, keywords = [] } = childSchema;
4997
4902
  return {
4998
- title: title2,
4903
+ title,
4999
4904
  description,
5000
4905
  image: mapSpecImage(image),
5001
4906
  icon,
@@ -5004,7 +4909,7 @@ var arraySchemaToMultiSelectComponent = (schemaMapperProps, mapperProps) => {
5004
4909
  component: mapSchemaToComponent(
5005
4910
  {
5006
4911
  uid: `${uid}.oneOf-${index}`,
5007
- schema: childSchema,
4912
+ schema: isFormSectionSchema(childSchema) ? supressSchemaTitleAndDescription(childSchema) : childSchema,
5008
4913
  model: initialModel,
5009
4914
  localValue,
5010
4915
  validationErrors: initialError,
@@ -5014,188 +4919,278 @@ var arraySchemaToMultiSelectComponent = (schemaMapperProps, mapperProps) => {
5014
4919
  )
5015
4920
  };
5016
4921
  });
5017
- const { maxItems, minItems, title, validationMessages } = schema;
5018
- const { getErrorMessageFunctions, onRefresh, onValueChange, updateComponent } = mapperProps;
4922
+ const { getErrorMessageFunctions, updateComponent, trackEvent, onRefresh, onValueChange } = mapperProps;
4923
+ const { validationMessages } = schema;
5019
4924
  const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
5020
- const { performValidationAsync, validationAsyncState } = getValidationAsyncInitialState(
5021
- schemaMapperProps,
5022
- mapperProps
5023
- );
5024
- const initialValue = model != null ? model : null;
5025
- return createMultiSelectComponent(
4925
+ return createSelectInputComponent(
5026
4926
  __spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
5027
- autoComplete: "off",
5028
- checks: schema.hidden ? [] : [
5029
- getRequiredCheck(required, errorMessageFunctions),
5030
- getAboveMaxItemsCheck(schema, errorMessageFunctions),
5031
- getBelowMinItemsCheck(schema, errorMessageFunctions)
5032
- ],
5033
- initialValue,
5034
- maxItems,
5035
- minItems,
4927
+ autoComplete: getAutocompleteString(schema.autocompleteHint),
4928
+ checks: schema.hidden ? [] : [getRequiredCheck(required, errorMessageFunctions)],
5036
4929
  options,
5037
- required,
5038
- title,
5039
- validationAsyncState,
5040
- performValidationAsync,
4930
+ initialModel,
5041
4931
  performRefresh: getPerformRefresh(schema, onRefresh),
5042
- onValueChange
4932
+ onValueChange,
4933
+ trackEvent
5043
4934
  }),
5044
4935
  updateComponent
5045
4936
  );
5046
4937
  };
4938
+ var isFormSectionSchema = (schema) => isObjectSchema(schema) || isArrayTupleSchema(schema) || isAllOfSchema(schema);
4939
+ var supressSchemaTitleAndDescription = (schema) => {
4940
+ const _a = schema, { title, description } = _a, headlessSchema = __objRest(_a, ["title", "description"]);
4941
+ return headlessSchema;
4942
+ };
5047
4943
 
5048
- // src/revamp/domain/components/TupleComponent.ts
5049
- var createTupleComponent = (tupleProps) => {
5050
- const {
4944
+ // src/revamp/domain/components/DateInputComponent.ts
4945
+ var createDateInputComponent = (textInputProps, updateComponent) => {
4946
+ const _a = textInputProps, {
5051
4947
  uid,
5052
- analyticsId,
5053
- components,
5054
- control,
5055
- description,
5056
- help,
5057
- hidden,
5058
- icon,
5059
- image,
4948
+ id,
4949
+ checks,
4950
+ performPersistAsync,
4951
+ performRefresh,
4952
+ performValidationAsync,
4953
+ onValueChange,
5060
4954
  summariser,
5061
- title
5062
- } = tupleProps;
5063
- return {
5064
- type: "tuple",
4955
+ value
4956
+ } = _a, rest = __objRest(_a, [
4957
+ "uid",
4958
+ "id",
4959
+ "checks",
4960
+ "performPersistAsync",
4961
+ "performRefresh",
4962
+ "performValidationAsync",
4963
+ "onValueChange",
4964
+ "summariser",
4965
+ "value"
4966
+ ]);
4967
+ const update = getInputUpdateFunction(updateComponent);
4968
+ const getValidationErrors = getLocalValueValidator(checks);
4969
+ const dateInputComponent = __spreadValues({
4970
+ type: "date",
5065
4971
  uid,
5066
- analyticsId,
5067
- components,
5068
- control,
5069
- description,
5070
- help,
5071
- hidden,
5072
- icon,
5073
- image,
5074
- title,
5075
- getChildren() {
5076
- return this.components;
4972
+ id,
4973
+ value,
4974
+ _update(updateFn) {
4975
+ update(this, updateFn);
4976
+ },
4977
+ onBlur() {
4978
+ this.validate();
4979
+ },
4980
+ onFocus() {
4981
+ },
4982
+ // Noop
4983
+ onChange(updatedValue) {
4984
+ const prevValue = this.value;
4985
+ this._update((draft) => {
4986
+ draft.errors = [];
4987
+ draft.validationAsyncState.messages = {};
4988
+ draft.value = updatedValue;
4989
+ });
4990
+ if (isOrWasValid(getValidationErrors, prevValue, updatedValue)) {
4991
+ performRefresh == null ? void 0 : performRefresh();
4992
+ }
4993
+ onValueChange();
5077
4994
  },
5078
4995
  async getSubmittableValue() {
5079
- return Promise.all(this.components.map(async (child) => child.getSubmittableValue()));
4996
+ return this.getSubmittableValueSync();
5080
4997
  },
5081
4998
  getSubmittableValueSync() {
5082
- return this.components.map((child) => child.getSubmittableValueSync());
4999
+ var _a2;
5000
+ return (_a2 = this.getLocalValue()) != null ? _a2 : null;
5083
5001
  },
5084
5002
  getSummary() {
5085
- const summary = summariser(this.getLocalValue());
5086
- const childSummary = summariseFromChildren(this.getChildren());
5087
- return mergeSummaries(summary, childSummary);
5003
+ return summariser(this.getLocalValue());
5088
5004
  },
5089
5005
  getLocalValue() {
5090
- return this.components.map((child) => child.getLocalValue());
5006
+ return this.value;
5091
5007
  },
5092
5008
  validate() {
5093
- return hidden ? true : validateComponents(this.getChildren());
5009
+ const errors = getValidationErrors(this.getLocalValue());
5010
+ this._update((draft) => {
5011
+ draft.errors = errors;
5012
+ });
5013
+ return errors.length === 0;
5094
5014
  }
5095
- };
5015
+ }, rest);
5016
+ if (performRefresh) {
5017
+ return dateInputComponent;
5018
+ }
5019
+ if (performPersistAsync) {
5020
+ const persist = getComponentPersistAsync(update, performPersistAsync);
5021
+ return __spreadProps(__spreadValues({}, dateInputComponent), {
5022
+ onChange(updatedValue) {
5023
+ dateInputComponent.onChange.call(this, updatedValue);
5024
+ const isValid = getValidationErrors(updatedValue).length === 0;
5025
+ if (isValid) {
5026
+ persist(this, this.getLocalValue()).catch(() => {
5027
+ });
5028
+ }
5029
+ },
5030
+ async getSubmittableValue() {
5031
+ return persist(this, this.getLocalValue());
5032
+ },
5033
+ getSubmittableValueSync() {
5034
+ return this.persistedState.lastResponse;
5035
+ }
5036
+ });
5037
+ }
5038
+ if (performValidationAsync) {
5039
+ const validateAsync = getComponentValidationAsync(update, performValidationAsync);
5040
+ return __spreadProps(__spreadValues({}, dateInputComponent), {
5041
+ onBlur() {
5042
+ if (this.validate()) {
5043
+ validateAsync(this, this.getLocalValue()).catch(() => {
5044
+ });
5045
+ }
5046
+ }
5047
+ });
5048
+ }
5049
+ return dateInputComponent;
5096
5050
  };
5097
5051
 
5098
- // src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToTupleComponent.ts
5099
- var arraySchemaToTupleComponent = (schemaMapperProps, mapperProps) => {
5052
+ // src/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToDateInputComponent.ts
5053
+ var stringSchemaToDateInputComponent = (schemaMapperProps, mapperProps) => {
5054
+ const { schema, localValue, model, required = false } = schemaMapperProps;
5100
5055
  const {
5101
- uid,
5102
- localValue,
5103
- schema,
5104
- model: initialModel,
5105
- required = false,
5106
- validationErrors
5107
- } = schemaMapperProps;
5108
- const { items } = schema;
5109
- const components = items.map(
5110
- (childSchema, index) => {
5111
- var _a, _b;
5112
- return mapSchemaToComponent(
5113
- {
5114
- uid: `${uid}-arr.${index}`,
5115
- schema: childSchema,
5116
- model: isArray(initialModel) ? (_a = initialModel[index]) != null ? _a : null : null,
5117
- localValue: isArray(localValue) ? (_b = localValue[index]) != null ? _b : null : null,
5118
- validationErrors: isArray(validationErrors) ? validationErrors[index] : void 0,
5119
- required
5120
- },
5121
- mapperProps
5122
- );
5123
- }
5056
+ autocompleteHint,
5057
+ default: defaultValue,
5058
+ minimum: minimumDate,
5059
+ maximum: maximumDate,
5060
+ suggestions
5061
+ } = schema;
5062
+ const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange } = mapperProps;
5063
+ const errorMessageFunctions = getErrorMessageFunctions(schema.validationMessages);
5064
+ const { performPersistAsync, persistedState } = getPersistAsyncInitialState(
5065
+ schemaMapperProps,
5066
+ mapperProps
5067
+ );
5068
+ const { performValidationAsync, validationAsyncState } = getValidationAsyncInitialState(
5069
+ schemaMapperProps,
5070
+ mapperProps
5071
+ );
5072
+ const validLocalValue = isString(localValue) ? localValue : null;
5073
+ const validModel = isString(model) ? model : defaultValue != null ? defaultValue : null;
5074
+ const value = performPersistAsync ? validLocalValue : validModel;
5075
+ return createDateInputComponent(
5076
+ __spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
5077
+ autoComplete: getAutocompleteString(autocompleteHint),
5078
+ checks: schema.hidden ? [] : [
5079
+ getRequiredCheck(required, errorMessageFunctions),
5080
+ getAboveMaximumDateCheck(schema, errorMessageFunctions),
5081
+ getBelowMinimumDateCheck(schema, errorMessageFunctions)
5082
+ ],
5083
+ minimumDate,
5084
+ maximumDate,
5085
+ suggestions: suggestions ? {
5086
+ values: suggestions.values.map((suggestion) => __spreadProps(__spreadValues({}, suggestion), {
5087
+ image: mapSpecImage(suggestion.image)
5088
+ }))
5089
+ } : void 0,
5090
+ value,
5091
+ persistedState,
5092
+ validationAsyncState,
5093
+ performPersistAsync,
5094
+ performRefresh: getPerformRefresh(schema, onRefresh),
5095
+ performValidationAsync,
5096
+ onValueChange
5097
+ }),
5098
+ updateComponent
5124
5099
  );
5125
- return createTupleComponent(__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
5126
- components
5127
- }));
5128
5100
  };
5129
5101
 
5130
- // src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToComponent.ts
5131
- var arraySchemaToComponent = (schemaMapperProps, mapperProps) => {
5132
- const { schema, model: originalModel } = schemaMapperProps;
5133
- const model = isNullish(originalModel) || isArrayModel(originalModel) ? originalModel : null;
5134
- if (isArraySchemaListWithMultiFileUpload(schema)) {
5135
- return arraySchemaToMultiUploadComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
5136
- }
5137
- if (isArraySchemaListWithMultiSelect(schema)) {
5138
- return arraySchemaToMultiSelectComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
5139
- }
5140
- if (isArrayTupleSchema(schema)) {
5141
- return arraySchemaToTupleComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
5142
- }
5143
- return arraySchemaToRepeatableComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
5102
+ // src/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToUploadInputComponent.ts
5103
+ var stringSchemaToUploadInputComponent = (schemaMapperProps, mapperProps) => {
5104
+ var _a;
5105
+ const { schema, localValue, model, required = false } = schemaMapperProps;
5106
+ const { accepts, autocompleteHint, cameraConfig, hidden, maxSize, source, validationMessages } = schema;
5107
+ const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange } = mapperProps;
5108
+ const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
5109
+ const { performPersistAsync } = getPersistAsyncInitialState(schemaMapperProps, mapperProps);
5110
+ const persistedState = performPersistAsync ? getInitialPersistedState(null, model) : getInitialPersistedState();
5111
+ const validLocalValue = isFile(localValue) ? localValue : null;
5112
+ const value = (_a = getFileFromModel(model)) != null ? _a : validLocalValue;
5113
+ const checks = hidden ? [] : [
5114
+ getRequiredCheck(required, errorMessageFunctions),
5115
+ getFileSizeCheck(schema, errorMessageFunctions),
5116
+ getFileTypeCheck(schema, errorMessageFunctions)
5117
+ ];
5118
+ return createUploadInputComponent(
5119
+ __spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
5120
+ accepts,
5121
+ autoComplete: getAutocompleteString(autocompleteHint),
5122
+ cameraConfig,
5123
+ checks,
5124
+ format: "base64",
5125
+ maxSize,
5126
+ source,
5127
+ value,
5128
+ persistedState,
5129
+ performPersistAsync,
5130
+ performRefresh: getPerformRefresh(schema, onRefresh),
5131
+ onValueChange
5132
+ }),
5133
+ updateComponent
5134
+ );
5144
5135
  };
5145
- var isArraySchemaListWithMultiFileUpload = (schema) => isArrayListSchema(schema) && (isPersistAsyncWithUploadSchema(schema.items) || isStringSchemaWithUpload(schema.items));
5146
- var isPersistAsyncWithUploadSchema = (schema) => isSchemaWithPersistAsync(schema) && (isBlobSchema(schema.persistAsync.schema) || isStringSchemaWithUpload(schema.persistAsync.schema));
5147
- var isArraySchemaListWithMultiSelect = (schema) => isArrayListSchema(schema) && "oneOf" in schema.items && schema.items.oneOf.every(isConstSchema);
5136
+ var getFileFromModel = (model) => isString(model) ? base64dataUrltoFile(model, "") : null;
5148
5137
 
5149
- // src/revamp/domain/components/BooleanInputComponent.ts
5150
- var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
5151
- const _a = booleanInputProps, {
5138
+ // src/revamp/domain/components/TextInputComponent.ts
5139
+ var createTextInputComponent = (textInputProps, updateComponent) => {
5140
+ const _a = textInputProps, {
5152
5141
  uid,
5153
5142
  id,
5154
- value,
5143
+ checks,
5155
5144
  performPersistAsync,
5156
5145
  performRefresh,
5157
5146
  performValidationAsync,
5158
5147
  onValueChange,
5159
- summariser
5148
+ summariser,
5149
+ value
5160
5150
  } = _a, rest = __objRest(_a, [
5161
5151
  "uid",
5162
5152
  "id",
5163
- "value",
5153
+ "checks",
5164
5154
  "performPersistAsync",
5165
5155
  "performRefresh",
5166
5156
  "performValidationAsync",
5167
5157
  "onValueChange",
5168
- "summariser"
5158
+ "summariser",
5159
+ "value"
5169
5160
  ]);
5170
5161
  const update = getInputUpdateFunction(updateComponent);
5171
- const booleanComponent = __spreadValues({
5172
- type: "boolean",
5162
+ const getValidationErrors = getLocalValueValidator(checks);
5163
+ const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh, getValidationErrors);
5164
+ const inputComponent = __spreadValues({
5165
+ type: "text",
5173
5166
  uid,
5174
5167
  id,
5175
- autoComplete: "",
5176
5168
  value,
5177
5169
  _update(updateFn) {
5178
5170
  update(this, updateFn);
5179
5171
  },
5180
5172
  onBlur() {
5173
+ this.validate();
5174
+ performDebouncedRefresh == null ? void 0 : performDebouncedRefresh.flush();
5181
5175
  },
5182
- // Noop
5183
5176
  onFocus() {
5184
5177
  },
5185
5178
  // Noop
5186
5179
  onChange(updatedValue) {
5180
+ const prevValue = this.value;
5187
5181
  this._update((draft) => {
5188
5182
  draft.errors = [];
5183
+ draft.validationAsyncState.messages = {};
5189
5184
  draft.value = updatedValue;
5190
5185
  });
5191
- performRefresh == null ? void 0 : performRefresh();
5186
+ performDebouncedRefresh == null ? void 0 : performDebouncedRefresh(prevValue, updatedValue);
5192
5187
  onValueChange();
5193
5188
  },
5194
5189
  async getSubmittableValue() {
5195
5190
  return this.getSubmittableValueSync();
5196
5191
  },
5197
5192
  getSubmittableValueSync() {
5198
- return this.getLocalValue();
5193
+ return this.getLocalValue() || null;
5199
5194
  },
5200
5195
  getSummary() {
5201
5196
  return summariser(this.getLocalValue());
@@ -5203,18 +5198,25 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
5203
5198
  getLocalValue() {
5204
5199
  return this.value;
5205
5200
  },
5206
- validate: () => true
5201
+ validate() {
5202
+ const errors = getValidationErrors(this.getLocalValue());
5203
+ this._update((draft) => {
5204
+ draft.errors = errors;
5205
+ });
5206
+ return errors.length === 0;
5207
+ }
5207
5208
  }, rest);
5208
5209
  if (performRefresh) {
5209
- return booleanComponent;
5210
+ return inputComponent;
5210
5211
  }
5211
5212
  if (performPersistAsync) {
5212
5213
  const persist = getComponentPersistAsync(update, performPersistAsync);
5213
- return __spreadProps(__spreadValues({}, booleanComponent), {
5214
- onChange(updatedValue) {
5215
- booleanComponent.onChange.call(this, updatedValue);
5216
- persist(this, this.getLocalValue()).catch(() => {
5217
- });
5214
+ return __spreadProps(__spreadValues({}, inputComponent), {
5215
+ onBlur() {
5216
+ if (this.validate()) {
5217
+ persist(this, this.getLocalValue()).catch(() => {
5218
+ });
5219
+ }
5218
5220
  },
5219
5221
  async getSubmittableValue() {
5220
5222
  return persist(this, this.getLocalValue());
@@ -5225,24 +5227,45 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
5225
5227
  });
5226
5228
  }
5227
5229
  if (performValidationAsync) {
5228
- const validateAsync = getComponentValidationAsync(update, performValidationAsync);
5229
- return __spreadProps(__spreadValues({}, booleanComponent), {
5230
+ const validateAsync = getDebouncedComponentValidationAsync(update, performValidationAsync);
5231
+ return __spreadProps(__spreadValues({}, inputComponent), {
5232
+ onBlur() {
5233
+ if (this.validate()) {
5234
+ validateAsync.flush();
5235
+ }
5236
+ },
5230
5237
  onChange(updatedValue) {
5231
- booleanComponent.onChange.call(this, updatedValue);
5232
- validateAsync(this, this.getLocalValue()).catch(() => {
5233
- });
5238
+ inputComponent.onChange.call(this, updatedValue);
5239
+ if (getValidationErrors(updatedValue).length === 0) {
5240
+ validateAsync(this, updatedValue);
5241
+ }
5242
+ if (!updatedValue) {
5243
+ validateAsync.cancel();
5244
+ }
5234
5245
  }
5235
5246
  });
5236
5247
  }
5237
- return booleanComponent;
5248
+ return inputComponent;
5238
5249
  };
5239
5250
 
5240
- // src/revamp/domain/mappers/schema/booleanSchemaToComponent.ts
5241
- var booleanSchemaToComponent = (schemaMapperProps, mapperProps) => {
5242
- const { schema, localValue, model } = schemaMapperProps;
5243
- const { default: defaultValue } = schema;
5244
- const { updateComponent, onRefresh, onValueChange } = mapperProps;
5245
- const performRefresh = getPerformRefresh(schema, onRefresh);
5251
+ // src/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToTextInputComponent.ts
5252
+ var stringSchemaToTextInputComponent = (schemaMapperProps, mapperProps) => {
5253
+ const { schema, localValue, model, required = false } = schemaMapperProps;
5254
+ const {
5255
+ autocapitalization,
5256
+ autocompleteHint,
5257
+ control,
5258
+ default: defaultValue,
5259
+ displayFormat,
5260
+ format,
5261
+ maxLength,
5262
+ minLength,
5263
+ suggestions,
5264
+ validationMessages
5265
+ } = schema;
5266
+ const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange, logEvent } = mapperProps;
5267
+ const controlForLegacyFormat = getControlForLegacyFormat(format);
5268
+ const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
5246
5269
  const { performPersistAsync, persistedState } = getPersistAsyncInitialState(
5247
5270
  schemaMapperProps,
5248
5271
  mapperProps
@@ -5251,76 +5274,65 @@ var booleanSchemaToComponent = (schemaMapperProps, mapperProps) => {
5251
5274
  schemaMapperProps,
5252
5275
  mapperProps
5253
5276
  );
5254
- const validLocalValue = isBoolean(localValue) ? localValue : false;
5255
- const validModel = getValidModel(model, defaultValue);
5277
+ const validLocalValue = isString(localValue) ? localValue : null;
5278
+ const validModel = isString(model) ? model : defaultValue != null ? defaultValue : null;
5256
5279
  const value = performPersistAsync ? validLocalValue : validModel;
5257
- return createBooleanInputComponent(
5280
+ return createTextInputComponent(
5258
5281
  __spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
5259
- value: value != null ? value : false,
5282
+ autocapitalization,
5283
+ autoComplete: getAutocompleteString(autocompleteHint),
5284
+ checks: schema.hidden ? [] : [
5285
+ getRequiredCheck(required, errorMessageFunctions),
5286
+ getAboveMaxLengthCheck(schema, errorMessageFunctions),
5287
+ getBelowMinLengthCheck(schema, errorMessageFunctions),
5288
+ getNotAdheringToPatternCheck(schema, errorMessageFunctions, { logEvent })
5289
+ ],
5290
+ control: control != null ? control : controlForLegacyFormat,
5291
+ displayFormat,
5292
+ maxLength,
5293
+ minLength,
5294
+ suggestions: suggestions ? {
5295
+ values: suggestions.values.map((suggestion) => __spreadProps(__spreadValues({}, suggestion), {
5296
+ image: mapSpecImage(suggestion.image)
5297
+ }))
5298
+ } : void 0,
5299
+ value,
5260
5300
  persistedState,
5261
5301
  validationAsyncState,
5262
5302
  performPersistAsync,
5263
- performRefresh,
5303
+ performRefresh: getPerformRefresh(schema, onRefresh),
5264
5304
  performValidationAsync,
5265
5305
  onValueChange
5266
5306
  }),
5267
5307
  updateComponent
5268
5308
  );
5269
5309
  };
5270
- var getValidModel = (model, defaultValue) => {
5271
- if (isBoolean(model)) {
5272
- return model;
5273
- }
5274
- if (isBoolean(defaultValue)) {
5275
- return defaultValue;
5310
+ var getControlForLegacyFormat = (format) => {
5311
+ if (format && ["numeric", "phone-number", "email", "password"].includes(format)) {
5312
+ return format;
5276
5313
  }
5277
- return false;
5314
+ return void 0;
5278
5315
  };
5279
5316
 
5280
- // src/revamp/domain/mappers/schema/blobSchemaToComponent.ts
5281
- var blobSchemaToComponent = (schemaMapperProps, mapperProps) => {
5282
- const { schema, localValue, model, required = false } = schemaMapperProps;
5283
- const { accepts, cameraConfig, maxSize, source, validationMessages } = schema;
5284
- const { getErrorMessageFunctions, updateComponent, onValueChange } = mapperProps;
5285
- const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
5286
- const { performPersistAsync } = getPersistAsyncInitialState(schemaMapperProps, mapperProps);
5287
- const persistedState = performPersistAsync ? getInitialPersistedState(null, model) : getInitialPersistedState();
5288
- const validLocalValue = isFile(localValue) ? localValue : null;
5289
- const value = performPersistAsync ? validLocalValue : null;
5290
- return createUploadInputComponent(
5291
- __spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
5292
- accepts,
5293
- autoComplete: "off",
5294
- cameraConfig,
5295
- format: "blob",
5296
- maxSize,
5297
- source,
5298
- value,
5299
- persistedState,
5300
- performPersistAsync,
5301
- checks: schema.hidden ? [] : [getRequiredCheck(required, errorMessageFunctions)],
5302
- onValueChange
5303
- }),
5304
- updateComponent
5305
- );
5317
+ // src/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToComponent.ts
5318
+ var stringSchemaToComponent = (schemaMapperProps, mapperProps) => {
5319
+ const { schema } = schemaMapperProps;
5320
+ if (isStringSchemaWithBase64(schema)) {
5321
+ return stringSchemaToUploadInputComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema }), mapperProps);
5322
+ }
5323
+ switch (schema.format) {
5324
+ case "date":
5325
+ return stringSchemaToDateInputComponent(schemaMapperProps, mapperProps);
5326
+ default:
5327
+ return stringSchemaToTextInputComponent(schemaMapperProps, mapperProps);
5328
+ }
5329
+ };
5330
+ var isStringSchemaWithBase64 = (schema) => {
5331
+ return schema.format === "base64url" && !("persistAsync" in schema);
5306
5332
  };
5307
5333
 
5308
5334
  // src/revamp/domain/mappers/mapSchemaToComponent.ts
5309
5335
  var mapSchemaToComponent = (schemaMapperProps, mapperProps) => {
5310
- const { uid, schema } = schemaMapperProps;
5311
- const { alert } = schema;
5312
- if (alert) {
5313
- return createContainerComponent({
5314
- uid,
5315
- components: [
5316
- alertLayoutToComponent(`${uid}.container.alert`, alert, mapperProps),
5317
- getSchemaComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { uid: `${uid}.container` }), mapperProps)
5318
- ]
5319
- });
5320
- }
5321
- return getSchemaComponent(schemaMapperProps, mapperProps);
5322
- };
5323
- var getSchemaComponent = (schemaMapperProps, mapperProps) => {
5324
5336
  const { uid, schema } = schemaMapperProps;
5325
5337
  if (isConstSchema(schema)) {
5326
5338
  return constSchemaToComponent(uid, __spreadProps(__spreadValues({}, schemaMapperProps), { schema }));
@@ -6122,11 +6134,6 @@ var executePoll = async (props) => {
6122
6134
  }
6123
6135
  };
6124
6136
 
6125
- // src/revamp/flow/getErrorMessage.ts
6126
- var getErrorMessage = (error) => {
6127
- return error instanceof Error ? error.message : typeof error === "string" ? error : `Unknown Error: type is ${typeof error}`;
6128
- };
6129
-
6130
6137
  // src/revamp/flow/executeRefresh.ts
6131
6138
  var executeRefresh = async (props) => {
6132
6139
  const { abortSignal, url, model, schemaId, etag, httpClient, trackEvent, logEvent } = props;