@wise/dynamic-flow-client 4.5.2 → 4.5.3

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 (43) hide show
  1. package/build/i18n/cs.json +12 -12
  2. package/build/main.js +1361 -1354
  3. package/build/main.mjs +1361 -1354
  4. package/build/types/revamp/domain/components/AlertComponent.d.ts +2 -2
  5. package/build/types/revamp/domain/components/AllOfComponent.d.ts +3 -2
  6. package/build/types/revamp/domain/components/BooleanInputComponent.d.ts +3 -3
  7. package/build/types/revamp/domain/components/BoxComponent.d.ts +2 -2
  8. package/build/types/revamp/domain/components/ButtonComponent.d.ts +2 -2
  9. package/build/types/revamp/domain/components/ColumnsComponent.d.ts +2 -2
  10. package/build/types/revamp/domain/components/DateInputComponent.d.ts +3 -3
  11. package/build/types/revamp/domain/components/DecisionComponent.d.ts +2 -2
  12. package/build/types/revamp/domain/components/DividerComponent.d.ts +2 -2
  13. package/build/types/revamp/domain/components/FormComponent.d.ts +2 -2
  14. package/build/types/revamp/domain/components/HeadingComponent.d.ts +2 -2
  15. package/build/types/revamp/domain/components/ImageComponent.d.ts +2 -2
  16. package/build/types/revamp/domain/components/InstructionsComponent.d.ts +2 -2
  17. package/build/types/revamp/domain/components/IntegerInputComponent.d.ts +3 -3
  18. package/build/types/revamp/domain/components/ListComponent.d.ts +2 -2
  19. package/build/types/revamp/domain/components/LoadingIndicatorComponent.d.ts +2 -2
  20. package/build/types/revamp/domain/components/MarkdownComponent.d.ts +2 -2
  21. package/build/types/revamp/domain/components/ModalComponent.d.ts +2 -2
  22. package/build/types/revamp/domain/components/MultiSelectInputComponent.d.ts +3 -3
  23. package/build/types/revamp/domain/components/MultiUploadInputComponent.d.ts +3 -3
  24. package/build/types/revamp/domain/components/NumberInputComponent.d.ts +3 -3
  25. package/build/types/revamp/domain/components/ObjectComponent.d.ts +3 -2
  26. package/build/types/revamp/domain/components/ParagraphComponent.d.ts +2 -2
  27. package/build/types/revamp/domain/components/RepeatableComponent.d.ts +3 -2
  28. package/build/types/revamp/domain/components/ReviewComponent.d.ts +2 -2
  29. package/build/types/revamp/domain/components/SelectInputComponent.d.ts +3 -3
  30. package/build/types/revamp/domain/components/StatusListComponent.d.ts +2 -2
  31. package/build/types/revamp/domain/components/TextInputComponent.d.ts +3 -3
  32. package/build/types/revamp/domain/components/TupleComponent.d.ts +3 -2
  33. package/build/types/revamp/domain/components/UploadInputComponent.d.ts +3 -3
  34. package/build/types/revamp/domain/components/searchComponent/SearchComponent.d.ts +2 -2
  35. package/build/types/revamp/domain/mappers/mapSchemaToComponent.d.ts +2 -2
  36. package/build/types/revamp/domain/mappers/schema/constSchemaToComponent.d.ts +1 -1
  37. package/build/types/revamp/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.d.ts +1 -1
  38. package/build/types/revamp/domain/mappers/schema/utils/mapCommonSchemaProps.d.ts +1 -0
  39. package/build/types/revamp/domain/mappers/utils/utils.d.ts +2 -1
  40. package/build/types/revamp/domain/types.d.ts +10 -7
  41. package/build/types/revamp/renderers/mappers/componentToRendererProps.d.ts +1 -1
  42. package/build/types/revamp/renderers/mappers/utils/inputComponentToProps.d.ts +2 -2
  43. package/package.json +18 -18
package/build/main.mjs CHANGED
@@ -1143,6 +1143,39 @@ var isStringSchema = (schema) => "type" in schema && schema.type === "string";
1143
1143
  var isStringSchemaWithUpload = (schema) => isStringSchema(schema) && schema.format === "base64url";
1144
1144
  var isSchemaWithPersistAsync = (schema) => "persistAsync" in schema && !isNullish(schema.persistAsync);
1145
1145
 
1146
+ // src/revamp/renderers/stepComponentToProps.ts
1147
+ var stepComponentToProps = (component, rendererMapperProps) => {
1148
+ const {
1149
+ uid,
1150
+ back,
1151
+ control,
1152
+ description,
1153
+ error,
1154
+ loadingState,
1155
+ step,
1156
+ title,
1157
+ onBehavior
1158
+ } = component;
1159
+ const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
1160
+ return __spreadValues({
1161
+ type: "step",
1162
+ id: step.id,
1163
+ uid,
1164
+ back,
1165
+ control,
1166
+ description,
1167
+ error,
1168
+ loadingState,
1169
+ step,
1170
+ title,
1171
+ children: childrenProps.map(rendererMapperProps.render),
1172
+ childrenProps,
1173
+ onAction: (action) => {
1174
+ void onBehavior({ type: "action", action });
1175
+ }
1176
+ }, rendererMapperProps);
1177
+ };
1178
+
1146
1179
  // src/revamp/renderers/mappers/utils/pick.ts
1147
1180
  function pick(obj, ...keys) {
1148
1181
  const result = {};
@@ -1336,6 +1369,19 @@ var decisionComponentToProps = (component, rendererMapperProps) => __spreadProps
1336
1369
  // src/revamp/renderers/mappers/dividerComponentToProps.ts
1337
1370
  var dividerComponentToProps = (component, rendererMapperProps) => __spreadValues(__spreadValues({}, pick(component, "uid", "type", "control", "margin")), rendererMapperProps);
1338
1371
 
1372
+ // src/revamp/renderers/mappers/externalComponentToProps.ts
1373
+ var externalComponentToProps = (component, rendererMapperProps) => {
1374
+ return __spreadValues({
1375
+ type: "external-confirmation",
1376
+ uid: component.uid,
1377
+ url: component.url,
1378
+ status: component.status,
1379
+ onSuccess: component.onSuccess.bind(component),
1380
+ onFailure: component.onFailure.bind(component),
1381
+ onCancel: component.onCancel.bind(component)
1382
+ }, rendererMapperProps);
1383
+ };
1384
+
1339
1385
  // src/revamp/renderers/mappers/formComponentToProps.ts
1340
1386
  var formComponentToProps = (component, rendererMapperProps) => {
1341
1387
  const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
@@ -1376,6 +1422,20 @@ var integerInputComponentToProps = (component, rendererMapperProps) => __spreadP
1376
1422
  onChange: component.onChange.bind(component)
1377
1423
  });
1378
1424
 
1425
+ // src/revamp/renderers/mappers/listComponentToProps.ts
1426
+ var listComponentToProps = (component, rendererMapperProps) => __spreadProps(__spreadValues(__spreadValues({}, pick(component, "uid", "type", "callToAction", "control", "margin", "title")), rendererMapperProps), {
1427
+ items: component.items.map(mapItem)
1428
+ });
1429
+ var mapItem = (item) => {
1430
+ var _a, _b;
1431
+ return __spreadProps(__spreadValues({}, item), {
1432
+ // populate deprecated fields
1433
+ subtitle: item.description,
1434
+ value: (_a = item.supportingValues) == null ? void 0 : _a.value,
1435
+ subvalue: (_b = item.supportingValues) == null ? void 0 : _b.subvalue
1436
+ });
1437
+ };
1438
+
1379
1439
  // src/revamp/renderers/mappers/loadingIndicatorComponentToProps.ts
1380
1440
  var loadingIndicatorComponentToProps = (component, rendererMapperProps) => __spreadValues(__spreadValues({}, pick(component, "uid", "type", "control", "margin", "size")), rendererMapperProps);
1381
1441
 
@@ -1400,6 +1460,35 @@ var modalComponentToProps = (component, rendererMapperProps) => {
1400
1460
  }, rendererMapperProps);
1401
1461
  };
1402
1462
 
1463
+ // src/revamp/renderers/mappers/modalContentComponentToProps.ts
1464
+ var modalContentComponentToProps = (component, rendererMapperProps) => {
1465
+ const { uid, open, title, close } = component;
1466
+ const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
1467
+ return __spreadValues({
1468
+ uid,
1469
+ type: "modal-content",
1470
+ open,
1471
+ title,
1472
+ children: childrenProps.map(rendererMapperProps.render),
1473
+ childrenProps,
1474
+ onClose: close.bind(component)
1475
+ }, rendererMapperProps);
1476
+ };
1477
+
1478
+ // src/revamp/renderers/mappers/multiSelectComponentToProps.ts
1479
+ var multiSelectInputComponentToProps = (component, rendererMapperProps) => {
1480
+ const { autoComplete, maxItems, minItems, options, selectedIndices, onSelect } = component;
1481
+ const _a = inputComponentToProps(component, "input-multi-select"), { required, value } = _a, props = __objRest(_a, ["required", "value"]);
1482
+ return __spreadProps(__spreadValues(__spreadValues({}, props), rendererMapperProps), {
1483
+ autoComplete,
1484
+ maxItems,
1485
+ minItems,
1486
+ options,
1487
+ selectedIndices,
1488
+ onSelect: onSelect.bind(component)
1489
+ });
1490
+ };
1491
+
1403
1492
  // src/revamp/renderers/mappers/multiUploadInputComponentToProps.ts
1404
1493
  var multiUploadInputComponentToProps = (component, rendererMapperProps) => {
1405
1494
  const { accepts, cameraConfig, files, maxSize, minItems, maxItems, source, uploadLabel } = component;
@@ -1507,6 +1596,17 @@ var reviewComponentToProps = (component, rendererMapperProps) => __spreadValues(
1507
1596
  }), rendererMapperProps);
1508
1597
  var mapField = (field) => __spreadValues({}, field);
1509
1598
 
1599
+ // src/revamp/renderers/mappers/rootComponentToProps.ts
1600
+ var rootComponentToProps = (rootComponent, rendererMapperProps) => {
1601
+ const childrenProps = rootComponent.getChildren().map((child) => componentToRendererProps(child, rendererMapperProps));
1602
+ return __spreadValues({
1603
+ type: "root",
1604
+ uid: rootComponent.uid,
1605
+ children: childrenProps.map(rendererMapperProps.render),
1606
+ childrenProps
1607
+ }, rendererMapperProps);
1608
+ };
1609
+
1510
1610
  // src/revamp/domain/mappers/utils/image.ts
1511
1611
  var mapSpecImage = (image) => {
1512
1612
  var _a, _b, _c;
@@ -1602,17 +1702,14 @@ var textInputComponentToProps = (component, rendererMapperProps) => __spreadProp
1602
1702
  onChange: component.onChange.bind(component)
1603
1703
  });
1604
1704
 
1605
- // src/revamp/renderers/mappers/multiSelectComponentToProps.ts
1606
- var multiSelectInputComponentToProps = (component, rendererMapperProps) => {
1607
- const { autoComplete, maxItems, minItems, options, selectedIndices, onSelect } = component;
1608
- const _a = inputComponentToProps(component, "input-multi-select"), { required, value } = _a, props = __objRest(_a, ["required", "value"]);
1609
- return __spreadProps(__spreadValues(__spreadValues({}, props), rendererMapperProps), {
1610
- autoComplete,
1611
- maxItems,
1612
- minItems,
1613
- options,
1614
- selectedIndices,
1615
- onSelect: onSelect.bind(component)
1705
+ // src/revamp/renderers/mappers/tupleComponentToProps.ts
1706
+ var tupleComponentToProps = (component, rendererMapperProps) => {
1707
+ const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
1708
+ return __spreadProps(__spreadValues(__spreadValues({
1709
+ type: "form-section"
1710
+ }, pick(component, "uid", "control", "description", "help", "icon", "image", "title")), rendererMapperProps), {
1711
+ children: childrenProps.map(rendererMapperProps.render),
1712
+ childrenProps
1616
1713
  });
1617
1714
  };
1618
1715
 
@@ -1628,108 +1725,25 @@ var uploadInputComponentToProps = (component, rendererMapperProps) => {
1628
1725
  });
1629
1726
  };
1630
1727
 
1631
- // src/revamp/renderers/mappers/tupleComponentToProps.ts
1632
- var tupleComponentToProps = (component, rendererMapperProps) => {
1633
- const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
1634
- return __spreadProps(__spreadValues(__spreadValues({
1635
- type: "form-section"
1636
- }, pick(component, "uid", "control", "description", "help", "icon", "image", "title")), rendererMapperProps), {
1637
- children: childrenProps.map(rendererMapperProps.render),
1638
- childrenProps
1639
- });
1640
- };
1641
-
1642
- // src/revamp/renderers/mappers/listComponentToProps.ts
1643
- var listComponentToProps = (component, rendererMapperProps) => __spreadProps(__spreadValues(__spreadValues({}, pick(component, "uid", "type", "callToAction", "control", "margin", "title")), rendererMapperProps), {
1644
- items: component.items.map(mapItem)
1645
- });
1646
- var mapItem = (item) => {
1647
- var _a, _b;
1648
- return __spreadProps(__spreadValues({}, item), {
1649
- // populate deprecated fields
1650
- subtitle: item.description,
1651
- value: (_a = item.supportingValues) == null ? void 0 : _a.value,
1652
- subvalue: (_b = item.supportingValues) == null ? void 0 : _b.subvalue
1653
- });
1654
- };
1655
-
1656
- // src/revamp/renderers/stepComponentToProps.ts
1657
- var stepComponentToProps = (component, rendererMapperProps) => {
1658
- const {
1659
- uid,
1660
- back,
1661
- control,
1662
- description,
1663
- error,
1664
- loadingState,
1665
- step,
1666
- title,
1667
- onBehavior
1668
- } = component;
1669
- const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
1670
- return __spreadValues({
1671
- type: "step",
1672
- id: step.id,
1673
- uid,
1674
- back,
1675
- control,
1676
- description,
1677
- error,
1678
- loadingState,
1679
- step,
1680
- title,
1681
- children: childrenProps.map(rendererMapperProps.render),
1682
- childrenProps,
1683
- onAction: (action) => {
1684
- void onBehavior({ type: "action", action });
1685
- }
1686
- }, rendererMapperProps);
1687
- };
1688
-
1689
- // src/revamp/renderers/mappers/rootComponentToProps.ts
1690
- var rootComponentToProps = (rootComponent, rendererMapperProps) => {
1691
- const childrenProps = rootComponent.getChildren().map((child) => componentToRendererProps(child, rendererMapperProps));
1692
- return __spreadValues({
1693
- type: "root",
1694
- uid: rootComponent.uid,
1695
- children: childrenProps.map(rendererMapperProps.render),
1696
- childrenProps
1697
- }, rendererMapperProps);
1698
- };
1699
-
1700
- // src/revamp/renderers/mappers/modalContentComponentToProps.ts
1701
- var modalContentComponentToProps = (component, rendererMapperProps) => {
1702
- const { uid, open, title, close } = component;
1703
- const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
1704
- return __spreadValues({
1705
- uid,
1706
- type: "modal-content",
1707
- open,
1708
- title,
1709
- children: childrenProps.map(rendererMapperProps.render),
1710
- childrenProps,
1711
- onClose: close.bind(component)
1712
- }, rendererMapperProps);
1713
- };
1714
-
1715
- // src/revamp/renderers/mappers/externalComponentToProps.ts
1716
- var externalComponentToProps = (component, rendererMapperProps) => {
1717
- return __spreadValues({
1718
- type: "external-confirmation",
1719
- uid: component.uid,
1720
- url: component.url,
1721
- status: component.status,
1722
- onSuccess: component.onSuccess.bind(component),
1723
- onFailure: component.onFailure.bind(component),
1724
- onCancel: component.onCancel.bind(component)
1725
- }, rendererMapperProps);
1726
- };
1727
-
1728
1728
  // src/revamp/renderers/mappers/componentToRendererProps.ts
1729
1729
  var componentToRendererProps = (component, rendererMapperProps) => {
1730
1730
  if (isHiddenComponent(component)) {
1731
1731
  return hiddenComponentToProps(component);
1732
1732
  }
1733
+ const componentProps = getComponentProps(component, rendererMapperProps);
1734
+ const alertProps = getComponentAlertProps(component, rendererMapperProps);
1735
+ if (alertProps) {
1736
+ const childrenProps = [alertProps, componentProps];
1737
+ return __spreadValues({
1738
+ type: "container",
1739
+ uid: `${component.uid}-wrapper`,
1740
+ children: childrenProps.map(rendererMapperProps.render),
1741
+ childrenProps
1742
+ }, rendererMapperProps);
1743
+ }
1744
+ return componentProps;
1745
+ };
1746
+ var getComponentProps = (component, rendererMapperProps) => {
1733
1747
  switch (component.type) {
1734
1748
  case "root":
1735
1749
  return rootComponentToProps(component, rendererMapperProps);
@@ -1809,6 +1823,13 @@ var componentToRendererProps = (component, rendererMapperProps) => {
1809
1823
  throw new Error("Unknown component type");
1810
1824
  }
1811
1825
  };
1826
+ var getComponentAlertProps = (component, rendererMapperProps) => "alert" in component && component.alert ? __spreadValues({
1827
+ type: "alert",
1828
+ uid: `${component.uid}-alert`,
1829
+ margin: "md",
1830
+ context: component.alert.context,
1831
+ markdown: component.alert.content
1832
+ }, rendererMapperProps) : null;
1812
1833
 
1813
1834
  // src/revamp/useDynamicFlowCore.tsx
1814
1835
  import { validateStep } from "@wise/dynamic-flow-types";
@@ -2460,6 +2481,12 @@ var mapAdditionalInfo = (info, onBehavior) => {
2460
2481
  }
2461
2482
  return void 0;
2462
2483
  };
2484
+ var mapSchemaAlert = (alert) => {
2485
+ return alert ? {
2486
+ content: alert.markdown,
2487
+ context: alert.context ? mapLegacyContext(alert.context) : "neutral"
2488
+ } : void 0;
2489
+ };
2463
2490
 
2464
2491
  // src/revamp/domain/mappers/layout/decisionLayoutToComponent.ts
2465
2492
  var decisionLayoutToComponent = (uid, {
@@ -3261,7 +3288,7 @@ var mapCommonSchemaProps = (schemaMapperProps) => {
3261
3288
  var _a;
3262
3289
  const { uid, schema, required, validationErrors } = schemaMapperProps;
3263
3290
  const { $id, analyticsId, control, description, icon, image, keywords, title, hidden } = schema;
3264
- return __spreadValues(__spreadValues({
3291
+ return __spreadValues(__spreadValues(__spreadValues({
3265
3292
  uid,
3266
3293
  id: $id != null ? $id : uid,
3267
3294
  analyticsId: (_a = analyticsId != null ? analyticsId : $id) != null ? _a : "",
@@ -3276,7 +3303,7 @@ var mapCommonSchemaProps = (schemaMapperProps) => {
3276
3303
  required: Boolean(required),
3277
3304
  title,
3278
3305
  summariser: getSummariser(schema)
3279
- }, schemaHasHelp(schema) ? { help: schema.help.markdown } : {}), schemaHasPlaceholder(schema) ? { placeholder: schema.placeholder } : {});
3306
+ }, schemaHasHelp(schema) ? { help: schema.help.markdown } : {}), schemaHasPlaceholder(schema) ? { placeholder: schema.placeholder } : {}), schema.alert ? { alert: mapSchemaAlert(schema.alert) } : {});
3280
3307
  };
3281
3308
  var schemaHasDisabled = (schema) => Boolean("disabled" in schema && schema.disabled !== void 0);
3282
3309
  var schemaHasHelp = (schema) => Boolean("help" in schema && schema.help);
@@ -3398,27 +3425,27 @@ var numberSchemaToComponent = (schemaMapperProps, mapperProps) => {
3398
3425
  );
3399
3426
  };
3400
3427
 
3401
- // src/revamp/domain/components/ObjectComponent.ts
3402
- var createObjectComponent = (objectProps) => {
3428
+ // src/revamp/domain/components/AllOfComponent.ts
3429
+ var createAllOfComponent = (allOfProps) => {
3403
3430
  const {
3404
3431
  uid,
3405
3432
  analyticsId,
3406
- componentMap,
3433
+ alert,
3434
+ components,
3407
3435
  control,
3408
3436
  description,
3409
- displayOrder,
3410
3437
  help,
3411
3438
  hidden,
3412
3439
  icon,
3413
3440
  image,
3414
- summariser,
3415
3441
  title
3416
- } = objectProps;
3442
+ } = allOfProps;
3417
3443
  return {
3418
- type: "object",
3444
+ type: "all-of",
3419
3445
  uid,
3420
3446
  analyticsId,
3421
- componentMap,
3447
+ alert,
3448
+ components,
3422
3449
  control,
3423
3450
  description,
3424
3451
  help,
@@ -3427,123 +3454,13 @@ var createObjectComponent = (objectProps) => {
3427
3454
  image,
3428
3455
  title,
3429
3456
  getChildren() {
3430
- return displayOrder.map((propName) => this.componentMap[propName]);
3457
+ return this.components;
3458
+ },
3459
+ getSummary() {
3460
+ return summariseFromChildren(this.getChildren());
3431
3461
  },
3432
3462
  async getSubmittableValue() {
3433
- return Promise.all(
3434
- displayOrder.map(
3435
- async (propName) => this.componentMap[propName].getSubmittableValue().then((value) => ({ value, propName }))
3436
- )
3437
- ).then(
3438
- (values) => values.reduce(
3439
- (acc, { value, propName }) => __spreadValues(__spreadValues({}, acc), value === null ? {} : { [propName]: value }),
3440
- {}
3441
- )
3442
- );
3443
- },
3444
- getSubmittableValueSync() {
3445
- return mergeChildrenValues(
3446
- displayOrder,
3447
- (propName) => this.componentMap[propName].getSubmittableValueSync()
3448
- );
3449
- },
3450
- getSummary() {
3451
- const summary = summariser(this.getLocalValue());
3452
- const childSummary = summariseFromChildren(this.getChildren());
3453
- return mergeSummaries(summary, childSummary);
3454
- },
3455
- getLocalValue() {
3456
- return mergeChildrenValues(
3457
- displayOrder,
3458
- (propName) => this.componentMap[propName].getLocalValue()
3459
- );
3460
- },
3461
- validate() {
3462
- return hidden ? true : validateComponents(this.getChildren());
3463
- }
3464
- };
3465
- };
3466
- var mergeChildrenValues = (displayOrder, getComponentValue) => displayOrder.reduce((acc, propName) => {
3467
- const componentValue = getComponentValue(propName);
3468
- return __spreadValues(__spreadValues({}, acc), componentValue === null ? {} : { [propName]: componentValue });
3469
- }, {});
3470
-
3471
- // src/revamp/domain/mappers/schema/objectSchemaToComponent/objectSchemaToComponent.ts
3472
- var objectSchemaToComponent = (schemaMapperProps, mapperProps) => {
3473
- const { uid, localValue, schema, model, validationErrors } = schemaMapperProps;
3474
- const { $id, displayOrder, properties, required } = schema;
3475
- validateDisplayOrder($id, displayOrder, properties, mapperProps.logEvent);
3476
- const componentMap = displayOrder.reduce((acc, propName) => {
3477
- var _a;
3478
- const propSchema = properties[propName];
3479
- if (propSchema === void 0) {
3480
- throw new Error(`Object schema ${$id} has no property named ${propName}`);
3481
- }
3482
- return __spreadProps(__spreadValues({}, acc), {
3483
- [propName]: mapSchemaToComponent(
3484
- {
3485
- uid: `${uid}.obj-${propName}`,
3486
- schema: propSchema,
3487
- model: isObjectModel(model) ? model[propName] : null,
3488
- localValue: isObjectLocalValue(localValue) ? localValue[propName] : null,
3489
- required: (_a = required == null ? void 0 : required.includes(propName)) != null ? _a : false,
3490
- validationErrors: isObject(validationErrors) ? validationErrors[propName] : void 0
3491
- },
3492
- mapperProps
3493
- )
3494
- });
3495
- }, {});
3496
- return createObjectComponent(__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
3497
- componentMap,
3498
- displayOrder
3499
- }));
3500
- };
3501
- var validateDisplayOrder = ($id, displayOrder, properties, logEvent) => {
3502
- if (!displayOrder) {
3503
- const message = `Object schema ${$id} has no displayOrder property.`;
3504
- logEvent("error", message);
3505
- throw new Error(message);
3506
- }
3507
- const propertyNames = Object.keys(properties);
3508
- displayOrder.forEach((propName) => {
3509
- if (!properties[propName]) {
3510
- const message = `Object schema ${$id} has no property named "${propName}", but it is listed in the displayOrder array.`;
3511
- logEvent("error", message);
3512
- throw new Error(message);
3513
- }
3514
- });
3515
- propertyNames.forEach((propName) => {
3516
- if (!displayOrder.includes(propName)) {
3517
- const message = `Object schema ${$id} has a "${propName}" property which is missing in the displayOrder array.`;
3518
- logEvent("error", message);
3519
- throw new Error(message);
3520
- }
3521
- });
3522
- };
3523
-
3524
- // src/revamp/domain/components/AllOfComponent.ts
3525
- var createAllOfComponent = (allOfProps) => {
3526
- const { uid, analyticsId, components, control, description, help, hidden, icon, image, title } = allOfProps;
3527
- return {
3528
- type: "all-of",
3529
- uid,
3530
- analyticsId,
3531
- components,
3532
- control,
3533
- description,
3534
- help,
3535
- hidden,
3536
- icon,
3537
- image,
3538
- title,
3539
- getChildren() {
3540
- return this.components;
3541
- },
3542
- getSummary() {
3543
- return summariseFromChildren(this.getChildren());
3544
- },
3545
- async getSubmittableValue() {
3546
- return getSubmittableData(this.components);
3463
+ return getSubmittableData(this.components);
3547
3464
  },
3548
3465
  getSubmittableValueSync() {
3549
3466
  return getSubmittableDataSync(this.components);
@@ -3579,415 +3496,456 @@ var allOfSchemaToComponent = (schemaMapperProps, mapperProps) => {
3579
3496
  }));
3580
3497
  };
3581
3498
 
3582
- // src/revamp/domain/components/ConstComponent.ts
3583
- var createConstComponent = (hiddenProps) => {
3584
- const { uid, analyticsId, value, summary } = hiddenProps;
3585
- return {
3586
- type: "const",
3587
- uid,
3588
- analyticsId,
3589
- getLocalValue: () => value,
3590
- getSubmittableValue: async () => value,
3591
- getSubmittableValueSync: () => value,
3592
- getSummary: () => summary,
3593
- validate: () => true
3594
- };
3595
- };
3596
-
3597
- // src/revamp/domain/mappers/schema/constSchemaToComponent.ts
3598
- var constSchemaToComponent = (uid, schemaMapperProps) => {
3599
- var _a;
3600
- const { schema } = schemaMapperProps;
3601
- const { title, const: constValue, analyticsId, $id } = schema;
3602
- const titleOrValue = (_a = title != null ? title : constValue) != null ? _a : null;
3603
- return createConstComponent({
3604
- uid,
3605
- analyticsId: analyticsId != null ? analyticsId : $id,
3606
- summary: getConstSummary(schema, titleOrValue),
3607
- value: schema.const
3608
- });
3609
- };
3610
-
3611
- // src/revamp/domain/components/IntegerInputComponent.ts
3612
- var createIntegerInputComponent = (integerInputProps, updateComponent) => {
3613
- const _a = integerInputProps, {
3499
+ // src/revamp/domain/components/RepeatableComponent.ts
3500
+ var createRepeatableComponent = (repeatableProps, updateComponent) => {
3501
+ const _a = repeatableProps, {
3614
3502
  uid,
3615
3503
  id,
3616
3504
  checks,
3617
- value,
3618
- performPersistAsync,
3619
- performRefresh,
3620
- performValidationAsync,
3505
+ components,
3506
+ summary,
3621
3507
  onValueChange,
3508
+ createEditableComponent,
3622
3509
  summariser
3623
- } = _a, rest = __objRest(_a, [
3510
+ } = _a, componentProps = __objRest(_a, [
3624
3511
  "uid",
3625
3512
  "id",
3626
3513
  "checks",
3627
- "value",
3628
- "performPersistAsync",
3629
- "performRefresh",
3630
- "performValidationAsync",
3514
+ "components",
3515
+ "summary",
3631
3516
  "onValueChange",
3517
+ "createEditableComponent",
3632
3518
  "summariser"
3633
3519
  ]);
3634
3520
  const update = getInputUpdateFunction(updateComponent);
3635
3521
  const getValidationErrors = getLocalValueValidator(checks);
3636
- const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh, getValidationErrors);
3637
- const integerComponent = __spreadValues({
3638
- type: "integer",
3522
+ const repeatableComponent = __spreadProps(__spreadValues({
3639
3523
  uid,
3640
3524
  id,
3641
- value,
3525
+ type: "repeatable",
3526
+ components,
3527
+ editableComponent: null,
3528
+ editableIndex: null,
3529
+ summaryDefaults: {
3530
+ title: summary == null ? void 0 : summary.defaultTitle,
3531
+ description: summary == null ? void 0 : summary.defaultDescription,
3532
+ icon: summary == null ? void 0 : summary.defaultIcon,
3533
+ image: summary == null ? void 0 : summary.defaultImage
3534
+ }
3535
+ }, componentProps), {
3642
3536
  _update(updateFn) {
3643
3537
  update(this, updateFn);
3644
3538
  },
3645
- onBlur() {
3646
- this.validate();
3647
- performDebouncedRefresh == null ? void 0 : performDebouncedRefresh.flush();
3648
- },
3649
- onFocus() {
3539
+ onEdit(itemIndex) {
3540
+ this._update((draft) => {
3541
+ draft.editableComponent = createEditableComponent(
3542
+ draft.components[itemIndex].getLocalValue()
3543
+ );
3544
+ draft.editableIndex = itemIndex;
3545
+ });
3650
3546
  },
3651
- // Noop
3652
- onChange(updatedValue) {
3653
- const prevValue = this.value;
3547
+ onAdd() {
3654
3548
  this._update((draft) => {
3549
+ draft.editableComponent = createEditableComponent(null);
3550
+ draft.editableIndex = null;
3655
3551
  draft.errors = [];
3656
- draft.validationAsyncState.messages = {};
3657
- draft.value = updatedValue;
3658
3552
  });
3659
- performDebouncedRefresh == null ? void 0 : performDebouncedRefresh(prevValue, updatedValue);
3553
+ },
3554
+ onSave() {
3555
+ var _a2;
3556
+ const isValid = (_a2 = this.editableComponent) == null ? void 0 : _a2.validate();
3557
+ if (!isValid) {
3558
+ return false;
3559
+ }
3560
+ this._update((draft) => {
3561
+ if (draft.editableComponent === null) {
3562
+ return;
3563
+ }
3564
+ if (draft.editableIndex === null) {
3565
+ const newComponent = __spreadValues({}, draft.editableComponent);
3566
+ draft.components = [...this.components, newComponent];
3567
+ } else {
3568
+ draft.components[draft.editableIndex] = __spreadProps(__spreadValues({}, draft.editableComponent), {
3569
+ uid: draft.components[draft.editableIndex].uid
3570
+ });
3571
+ }
3572
+ draft.editableComponent = null;
3573
+ draft.editableIndex = null;
3574
+ });
3575
+ onValueChange();
3576
+ return true;
3577
+ },
3578
+ onRemove() {
3579
+ this._update((draft) => {
3580
+ if (draft.editableIndex === null) {
3581
+ return;
3582
+ }
3583
+ draft.components.splice(draft.editableIndex, 1);
3584
+ draft.editableComponent = null;
3585
+ draft.editableIndex = null;
3586
+ });
3660
3587
  onValueChange();
3661
3588
  },
3589
+ getChildren() {
3590
+ return this.editableComponent !== null ? [...this.components, this.editableComponent] : this.components;
3591
+ },
3662
3592
  async getSubmittableValue() {
3663
- return this.getSubmittableValueSync();
3593
+ return Promise.all(this.components.map(async (component) => component.getSubmittableValue()));
3664
3594
  },
3665
3595
  getSubmittableValueSync() {
3666
- var _a2;
3667
- return (_a2 = this.getLocalValue()) != null ? _a2 : null;
3596
+ return this.components.map((component) => component.getSubmittableValueSync());
3668
3597
  },
3669
3598
  getSummary() {
3670
- return summariser(this.getLocalValue());
3599
+ return summariser(null);
3671
3600
  },
3672
3601
  getLocalValue() {
3673
- return this.value;
3602
+ return this.components.map((component) => component.getLocalValue());
3674
3603
  },
3675
3604
  validate() {
3676
- const errors = getValidationErrors(this.getLocalValue());
3605
+ const messages = getValidationErrors(this.getLocalValue());
3606
+ const childComponentsValid = validateComponents(this.getChildren());
3677
3607
  this._update((draft) => {
3678
- draft.errors = errors;
3608
+ draft.errors = messages;
3679
3609
  });
3680
- return errors.length === 0;
3610
+ return messages.length === 0 && childComponentsValid;
3681
3611
  }
3682
- }, rest);
3683
- if (performRefresh) {
3684
- return integerComponent;
3685
- }
3686
- if (performPersistAsync) {
3687
- const persist = getComponentPersistAsync(update, performPersistAsync);
3688
- return __spreadProps(__spreadValues({}, integerComponent), {
3689
- onBlur() {
3690
- if (this.validate()) {
3691
- persist(this, this.getLocalValue()).catch(() => {
3692
- });
3693
- }
3694
- },
3695
- async getSubmittableValue() {
3696
- return persist(this, this.getLocalValue());
3697
- },
3698
- getSubmittableValueSync() {
3699
- return this.persistedState.lastResponse;
3700
- }
3701
- });
3702
- }
3703
- if (performValidationAsync) {
3704
- const validateAsync = getDebouncedComponentValidationAsync(update, performValidationAsync);
3705
- return __spreadProps(__spreadValues({}, integerComponent), {
3706
- onBlur() {
3707
- if (this.validate()) {
3708
- validateAsync.flush();
3709
- }
3710
- },
3711
- onChange(updatedValue) {
3712
- integerComponent.onChange.call(this, updatedValue);
3713
- if (getValidationErrors(updatedValue).length === 0) {
3714
- validateAsync(this, updatedValue);
3715
- }
3716
- }
3717
- });
3718
- }
3719
- return integerComponent;
3612
+ });
3613
+ return repeatableComponent;
3720
3614
  };
3721
3615
 
3722
- // src/revamp/domain/mappers/schema/integerSchemaToComponent.ts
3723
- var integerSchemaToComponent = (schemaMapperProps, mapperProps) => {
3724
- const { schema, localValue, model, required = false } = schemaMapperProps;
3725
- const { autocompleteHint, validationMessages, default: defaultValue, maximum, minimum } = schema;
3726
- const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange } = mapperProps;
3727
- const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
3728
- const { performPersistAsync, persistedState } = getPersistAsyncInitialState(
3729
- schemaMapperProps,
3730
- mapperProps
3616
+ // src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToRepeatableComponent.ts
3617
+ var arraySchemaToRepeatableComponent = (schemaMapperProps, mapperProps) => {
3618
+ const { getErrorMessageFunctions } = mapperProps;
3619
+ const {
3620
+ uid,
3621
+ localValue,
3622
+ schema,
3623
+ model: initialModel,
3624
+ required = false,
3625
+ validationErrors
3626
+ } = schemaMapperProps;
3627
+ const { items, addItemTitle, editItemTitle, maxItems, minItems, summary } = schema;
3628
+ const value = isArray(localValue) ? localValue : [];
3629
+ const components = initialModel == null ? void 0 : initialModel.map(
3630
+ (item, index) => mapSchemaToComponent(
3631
+ {
3632
+ uid: `${uid}.arr-${index}`,
3633
+ schema: items,
3634
+ model: item,
3635
+ localValue: value == null ? void 0 : value[index],
3636
+ // TODO tests for this
3637
+ validationErrors
3638
+ },
3639
+ mapperProps
3640
+ )
3731
3641
  );
3732
- const { performValidationAsync, validationAsyncState } = getValidationAsyncInitialState(
3733
- schemaMapperProps,
3642
+ const createEditableComponent = (editableValue) => mapSchemaToComponent(
3643
+ {
3644
+ uid: `${uid}.arr-rnd-${getRandomInt()}`,
3645
+ schema: items,
3646
+ localValue: editableValue,
3647
+ model: localValueToJsonElement(editableValue),
3648
+ validationErrors: void 0,
3649
+ required: true
3650
+ },
3734
3651
  mapperProps
3735
3652
  );
3736
- const validLocalValue = isInteger(localValue) ? localValue : null;
3737
- const validModel = isInteger(model) ? model : defaultValue != null ? defaultValue : null;
3738
- const value = performPersistAsync ? validLocalValue : validModel;
3739
- const checks = [
3740
- getRequiredCheck(required, errorMessageFunctions),
3741
- getBelowMinimumCheck(schema, errorMessageFunctions),
3742
- getAboveMaximumCheck(schema, errorMessageFunctions)
3743
- ];
3744
- return createIntegerInputComponent(
3653
+ const { onValueChange } = mapperProps;
3654
+ const errorMessageFunctions = getErrorMessageFunctions(schema.validationMessages);
3655
+ return createRepeatableComponent(
3745
3656
  __spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
3746
- autoComplete: getAutocompleteString(autocompleteHint),
3747
- checks,
3748
- maximum,
3749
- minimum,
3750
- persistedState,
3751
- value,
3752
- validationAsyncState,
3753
- performPersistAsync,
3754
- performRefresh: getPerformRefresh(schema, onRefresh),
3755
- performValidationAsync,
3657
+ addItemTitle,
3658
+ checks: schema.hidden ? [] : [
3659
+ getRequiredCheck(required, errorMessageFunctions),
3660
+ getAboveMaxItemsCheck(schema, errorMessageFunctions),
3661
+ getBelowMinItemsCheck(schema, errorMessageFunctions)
3662
+ ],
3663
+ components: components != null ? components : [],
3664
+ editItemTitle,
3665
+ maxItems,
3666
+ minItems,
3667
+ summary: __spreadProps(__spreadValues({}, summary), {
3668
+ defaultImage: mapSpecImage(summary == null ? void 0 : summary.defaultImage)
3669
+ }),
3670
+ createEditableComponent,
3756
3671
  onValueChange
3757
3672
  }),
3758
- updateComponent
3673
+ mapperProps.updateComponent
3759
3674
  );
3760
3675
  };
3761
-
3762
- // src/revamp/domain/components/utils/isPartialModelMatch.ts
3763
- var isPartialModelMatch = (localModel, incomingModel) => {
3764
- if (isArrayModel(localModel) && isArrayModel(incomingModel)) {
3765
- return localModel.length === incomingModel.length && localModel.every((value, index) => isPartialModelMatch(value, incomingModel[index]));
3676
+ var localValueToJsonElement = (localValue) => {
3677
+ if (localValue instanceof Array) {
3678
+ return localValue.map(localValueToJsonElement);
3766
3679
  }
3767
- if (isObjectModel(localModel) && isObjectModel(incomingModel)) {
3768
- if (Object.keys(localModel).length === 0 && Object.keys(incomingModel).length === 0) {
3769
- return true;
3770
- }
3771
- const nonNullishKeysInBoth = nonNullishKeys(localModel).filter(
3772
- (key) => nonNullishKeys(incomingModel).includes(key)
3680
+ if (isObject(localValue)) {
3681
+ return Object.fromEntries(
3682
+ Object.entries(localValue).map(([key, value]) => [key, localValueToJsonElement(value)])
3773
3683
  );
3774
- return nonNullishKeysInBoth.length > 0 && nonNullishKeysInBoth.every((key) => isPartialModelMatch(localModel[key], incomingModel[key]));
3775
3684
  }
3776
- return localModel === incomingModel;
3685
+ if (localValue instanceof File) {
3686
+ return localValue.name;
3687
+ }
3688
+ return localValue;
3777
3689
  };
3778
- var nonNullishKeys = (model) => Object.keys(model).filter((key) => !isNullish(model[key]));
3690
+ var getRandomInt = () => Math.floor(Math.random() * 1e8);
3779
3691
 
3780
- // src/revamp/domain/components/SelectInputComponent.ts
3781
- var createSelectInputComponent = (selectProps, updateComponent) => {
3782
- const _a = selectProps, { uid, checks, initialModel, options, performRefresh, onValueChange, summariser } = _a, rest = __objRest(_a, ["uid", "checks", "initialModel", "options", "performRefresh", "onValueChange", "summariser"]);
3783
- const children = options.map((option) => option.component);
3784
- const matchingOptions = options.map(
3785
- (option) => isPartialModelMatch(option.component.getSubmittableValueSync(), initialModel)
3786
- );
3787
- const selectedIndex = matchingOptions.filter((match) => match).length === 1 ? matchingOptions.indexOf(true) : null;
3692
+ // src/revamp/domain/components/utils/file-utils.ts
3693
+ var toBase64 = async (file) => new Promise((resolve, reject) => {
3694
+ const reader = new FileReader();
3695
+ reader.addEventListener("load", () => resolve(reader.result));
3696
+ reader.addEventListener("error", reject);
3697
+ reader.readAsDataURL(file);
3698
+ });
3699
+ var base64dataUrltoFile = (dataurl, filename) => {
3700
+ if (!isBase64DataUrl(dataurl)) {
3701
+ return null;
3702
+ }
3703
+ const [, base64data] = dataurl.split(",");
3704
+ return new File([base64ToBytes(base64data)], filename, { type: getMimeType(dataurl) });
3705
+ };
3706
+ var isBase64DataUrl = (dataurl) => dataurl.startsWith("data:") && dataurl.includes("base64") && dataurl.includes(",");
3707
+ var getMimeType = (base64dataUrl) => base64dataUrl.substring("data:".length).split(";")[0];
3708
+ var base64ToBytes = (base64) => {
3709
+ const charCodes = atob(base64).split("").map((m) => m.charCodeAt(0));
3710
+ return Uint8Array.from(charCodes);
3711
+ };
3712
+
3713
+ // src/revamp/domain/components/MultiUploadInputComponent.ts
3714
+ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
3715
+ const _a = uploadInputProps, {
3716
+ uid,
3717
+ id,
3718
+ checks,
3719
+ fileChecks,
3720
+ format,
3721
+ performPersistAsync,
3722
+ onValueChange,
3723
+ summariser
3724
+ } = _a, rest = __objRest(_a, [
3725
+ "uid",
3726
+ "id",
3727
+ "checks",
3728
+ "fileChecks",
3729
+ "format",
3730
+ "performPersistAsync",
3731
+ "onValueChange",
3732
+ "summariser"
3733
+ ]);
3788
3734
  const update = getInputUpdateFunction(updateComponent);
3789
3735
  const getValidationErrors = getLocalValueValidator(checks);
3790
- const component = __spreadProps(__spreadValues({
3736
+ const getFileValidationErrors = getLocalValueValidator(fileChecks);
3737
+ const uploadComponent = __spreadValues({
3738
+ type: "multi-upload",
3791
3739
  uid,
3792
- type: "select",
3793
- children,
3794
- options,
3795
- selectedIndex,
3796
- value: null
3797
- }, rest), {
3740
+ id,
3741
+ format: "base64",
3742
+ files: [],
3798
3743
  _update(updateFn) {
3799
3744
  update(this, updateFn);
3800
3745
  },
3801
- getChildren() {
3802
- return this.children;
3746
+ onBlur() {
3747
+ this.validate();
3803
3748
  },
3804
- getSelectedChild() {
3805
- return this.selectedIndex !== null ? this.children[this.selectedIndex] : null;
3749
+ onFocus() {
3750
+ },
3751
+ // Noop
3752
+ async onRemoveFile(index) {
3753
+ this._update((draft) => {
3754
+ draft.value.splice(index, 1);
3755
+ draft.files.splice(index, 1);
3756
+ });
3757
+ },
3758
+ async onInsertFile(index, file) {
3759
+ const fileErrors = getFileValidationErrors(file);
3760
+ const fileId = getRandomId();
3761
+ this._update((draft) => {
3762
+ draft.value.splice(index, 0, file);
3763
+ draft.files.splice(index, 0, { file, id: fileId, errors: fileErrors });
3764
+ draft.errors = [];
3765
+ });
3766
+ onValueChange();
3767
+ return fileId;
3806
3768
  },
3807
3769
  async getSubmittableValue() {
3808
- var _a2, _b;
3809
- return (_b = await ((_a2 = this.getSelectedChild()) == null ? void 0 : _a2.getSubmittableValue())) != null ? _b : null;
3770
+ const files = this.getLocalValue();
3771
+ return files ? Promise.all(files.map(toBase64)) : null;
3810
3772
  },
3811
3773
  getSubmittableValueSync() {
3812
- var _a2, _b;
3813
- return (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.getSubmittableValueSync()) != null ? _b : null;
3774
+ return null;
3814
3775
  },
3815
3776
  getSummary() {
3816
- var _a2, _b;
3817
- return (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.getSummary()) != null ? _b : {};
3777
+ return summariser(this.getLocalValue().map(({ name }) => name));
3818
3778
  },
3819
3779
  getLocalValue() {
3820
- var _a2, _b;
3821
- return (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.getLocalValue()) != null ? _b : null;
3822
- },
3823
- onBlur() {
3824
- this.validate();
3825
- },
3826
- onFocus() {
3780
+ return this.value;
3827
3781
  },
3828
- // noop
3829
- onSelect(updatedIndex) {
3830
- if (updatedIndex === this.selectedIndex) {
3831
- return;
3832
- }
3833
- if (updatedIndex !== null && this.analyticsId) {
3834
- selectProps.trackEvent("OneOf Selected", {
3835
- oneOfId: this.analyticsId,
3836
- schemaId: this.children[updatedIndex].analyticsId
3837
- });
3838
- }
3782
+ validate() {
3783
+ const errorMsgs = getValidationErrors(this.getLocalValue());
3839
3784
  this._update((draft) => {
3840
- draft.errors = [];
3841
- draft.selectedIndex = updatedIndex;
3785
+ draft.errors = errorMsgs;
3842
3786
  });
3843
- performRefresh == null ? void 0 : performRefresh();
3844
- onValueChange();
3787
+ return errorMsgs.length === 0 && this.files.every(({ errors }) => errors.length === 0);
3788
+ }
3789
+ }, rest);
3790
+ if (!performPersistAsync) {
3791
+ return uploadComponent;
3792
+ }
3793
+ const persist = getComponentMultiPersistAsync(update, performPersistAsync);
3794
+ return __spreadProps(__spreadValues({}, uploadComponent), {
3795
+ format,
3796
+ async onInsertFile(index, file) {
3797
+ const fileId = await uploadComponent.onInsertFile.call(this, index, file);
3798
+ const submission = format === "blob" ? file : await toBase64(file);
3799
+ await persist(this, index, submission);
3800
+ onValueChange();
3801
+ return fileId;
3845
3802
  },
3846
- validate() {
3847
- var _a2, _b;
3848
- const validChild = (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.validate()) != null ? _b : true;
3849
- const errors = getValidationErrors(this.getLocalValue());
3803
+ async onRemoveFile(index) {
3804
+ var _a2;
3805
+ await uploadComponent.onRemoveFile.call(this, index);
3806
+ (_a2 = this.persistedState[index]) == null ? void 0 : _a2.abortController.abort();
3850
3807
  this._update((draft) => {
3851
- draft.errors = errors;
3808
+ draft.persistedState = draft.persistedState.splice(index, 1);
3852
3809
  });
3853
- return errors.length === 0 && validChild;
3810
+ },
3811
+ async getSubmittableValue() {
3812
+ return Promise.all(this.persistedState.map(async ({ submission }) => submission));
3813
+ },
3814
+ getSubmittableValueSync() {
3815
+ return this.persistedState.map(({ lastResponse }) => lastResponse);
3854
3816
  }
3855
3817
  });
3856
- return component;
3857
3818
  };
3858
3819
 
3859
- // src/revamp/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.ts
3860
- var oneOfSchemaToComponent = (schemaMapperProps, mapperProps) => {
3820
+ // src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToMultiUploadComponent.ts
3821
+ var arraySchemaToMultiUploadComponent = (schemaMapperProps, mapperProps) => {
3861
3822
  var _a;
3862
- const {
3863
- uid,
3864
- localValue,
3865
- schema,
3866
- model,
3867
- validationErrors: initialError,
3868
- required = false
3869
- } = schemaMapperProps;
3870
- const initialModel = (_a = model != null ? model : schema.default) != null ? _a : null;
3871
- if (schema.oneOf.length === 1 && isFormSectionSchema(schema.oneOf[0])) {
3872
- return mapSchemaToComponent(
3873
- {
3874
- uid,
3875
- schema: supressSchemaTitleAndDescription(schema.oneOf[0]),
3876
- model: initialModel,
3877
- localValue,
3878
- validationErrors: initialError,
3879
- required
3880
- },
3881
- mapperProps
3882
- );
3883
- }
3884
- const options = schema.oneOf.map((childSchema, index) => {
3885
- const { title = "", description, image, icon, keywords = [] } = childSchema;
3886
- return {
3887
- title,
3888
- description,
3889
- image: mapSpecImage(image),
3890
- icon,
3891
- keywords,
3892
- disabled: "disabled" in childSchema ? Boolean(childSchema.disabled) : false,
3893
- component: mapSchemaToComponent(
3894
- {
3895
- uid: `${uid}.oneOf-${index}`,
3896
- schema: isFormSectionSchema(childSchema) ? supressSchemaTitleAndDescription(childSchema) : childSchema,
3897
- model: initialModel,
3898
- localValue,
3899
- validationErrors: initialError,
3900
- required
3901
- },
3902
- mapperProps
3903
- )
3904
- };
3823
+ const { getErrorMessageFunctions } = mapperProps;
3824
+ const { localValue, model, schema, required = false } = schemaMapperProps;
3825
+ const uploadSchema = getUploadSchema(schema.items);
3826
+ const { accepts, cameraConfig, maxSize } = uploadSchema;
3827
+ const { minItems, maxItems, title, validationMessages } = schema;
3828
+ const arrayErrorMessageFunctions = getErrorMessageFunctions(validationMessages);
3829
+ const fileErrorMessageFunctions = getErrorMessageFunctions(uploadSchema.validationMessages);
3830
+ const checks = [
3831
+ getRequiredCheck(required, arrayErrorMessageFunctions),
3832
+ getAboveMaxFilesCheck(schema, arrayErrorMessageFunctions),
3833
+ getBelowMinFilesCheck(schema, arrayErrorMessageFunctions)
3834
+ ];
3835
+ const fileChecks = [
3836
+ getFileSizeCheck(schema.items, fileErrorMessageFunctions),
3837
+ getFileTypeCheck(schema.items, fileErrorMessageFunctions)
3838
+ ];
3839
+ const persistAsyncConfig = getPersistAsyncConfig(schema.items);
3840
+ const format = getFormat(schema.items);
3841
+ const combinedSchemaProps = __spreadProps(__spreadValues({}, schemaMapperProps), {
3842
+ persistAsyncConfig,
3843
+ schema: __spreadProps(__spreadValues({}, uploadSchema), { hidden: (_a = schema.hidden) != null ? _a : uploadSchema.hidden, alert: schema.alert })
3905
3844
  });
3906
- const { getErrorMessageFunctions, updateComponent, trackEvent, onRefresh, onValueChange } = mapperProps;
3907
- const { validationMessages } = schema;
3908
- const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
3909
- return createSelectInputComponent(
3910
- __spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
3911
- autoComplete: getAutocompleteString(schema.autocompleteHint),
3912
- checks: schema.hidden ? [] : [getRequiredCheck(required, errorMessageFunctions)],
3913
- options,
3914
- initialModel,
3915
- performRefresh: getPerformRefresh(schema, onRefresh),
3916
- onValueChange,
3917
- trackEvent
3845
+ const { onValueChange } = mapperProps;
3846
+ const { performPersistAsync } = getPersistAsyncInitialState(combinedSchemaProps, mapperProps);
3847
+ const value = performPersistAsync ? getValueForPersistAsync(localValue) : [];
3848
+ const persistedState = performPersistAsync && isArray(model) ? model.map((itemModel) => getInitialPersistedState(null, itemModel)) : [];
3849
+ return createMultiUploadInputComponent(
3850
+ __spreadProps(__spreadValues({}, mapCommonSchemaProps(combinedSchemaProps)), {
3851
+ title,
3852
+ cameraConfig,
3853
+ uploadLabel: uploadSchema.title,
3854
+ accepts,
3855
+ autoComplete: "off",
3856
+ checks: schema.hidden ? [] : checks,
3857
+ fileChecks: schema.hidden ? [] : fileChecks,
3858
+ format,
3859
+ maxSize,
3860
+ minItems,
3861
+ maxItems,
3862
+ required,
3863
+ source: uploadSchema.source,
3864
+ value,
3865
+ persistedState,
3866
+ performPersistAsync,
3867
+ onValueChange
3918
3868
  }),
3919
- updateComponent
3869
+ mapperProps.updateComponent
3920
3870
  );
3921
3871
  };
3922
- var isFormSectionSchema = (schema) => isObjectSchema(schema) || isArrayTupleSchema(schema) || isAllOfSchema(schema);
3923
- var supressSchemaTitleAndDescription = (schema) => {
3924
- const _a = schema, { title, description } = _a, headlessSchema = __objRest(_a, ["title", "description"]);
3925
- return headlessSchema;
3872
+ var getFormat = (schema) => {
3873
+ if (isStringSchemaWithUpload(schema)) {
3874
+ return "base64";
3875
+ }
3876
+ return isBlobSchema(schema.persistAsync.schema) ? "blob" : "base64";
3877
+ };
3878
+ var getUploadSchema = (schema) => {
3879
+ if (isStringSchemaWithUpload(schema)) {
3880
+ return schema;
3881
+ }
3882
+ return schema.persistAsync.schema;
3883
+ };
3884
+ var getPersistAsyncConfig = (schema) => {
3885
+ if (!isSchemaWithPersistAsync(schema)) {
3886
+ return void 0;
3887
+ }
3888
+ const { persistAsync } = schema;
3889
+ const { idProperty, method, param, url } = persistAsync;
3890
+ return { idProperty, method, param, url };
3926
3891
  };
3892
+ var getValueForPersistAsync = (localValue) => isArray(localValue) && localValue.every(isFile) ? localValue : [];
3927
3893
 
3928
- // src/revamp/domain/components/DateInputComponent.ts
3929
- var createDateInputComponent = (textInputProps, updateComponent) => {
3930
- const _a = textInputProps, {
3894
+ // src/revamp/domain/components/MultiSelectInputComponent.ts
3895
+ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
3896
+ const _a = multiSelectProps, {
3931
3897
  uid,
3932
- id,
3933
3898
  checks,
3934
- performPersistAsync,
3935
- performRefresh,
3899
+ options,
3900
+ initialValue,
3936
3901
  performValidationAsync,
3937
- onValueChange,
3938
- summariser,
3939
- value
3902
+ performRefresh,
3903
+ onValueChange
3940
3904
  } = _a, rest = __objRest(_a, [
3941
3905
  "uid",
3942
- "id",
3943
3906
  "checks",
3944
- "performPersistAsync",
3945
- "performRefresh",
3907
+ "options",
3908
+ "initialValue",
3946
3909
  "performValidationAsync",
3947
- "onValueChange",
3948
- "summariser",
3949
- "value"
3910
+ "performRefresh",
3911
+ "onValueChange"
3950
3912
  ]);
3951
3913
  const update = getInputUpdateFunction(updateComponent);
3914
+ const children = options.map((option) => option.component);
3915
+ const selectedIndices = getInitialModelIndices(initialValue, children);
3952
3916
  const getValidationErrors = getLocalValueValidator(checks);
3953
- const dateInputComponent = __spreadValues({
3954
- type: "date",
3917
+ const inputComponent = __spreadProps(__spreadValues({
3955
3918
  uid,
3956
- id,
3957
- value,
3919
+ type: "multi-select",
3920
+ children,
3921
+ options,
3922
+ selectedIndices,
3923
+ value: null
3924
+ }, rest), {
3958
3925
  _update(updateFn) {
3959
3926
  update(this, updateFn);
3960
3927
  },
3961
- onBlur() {
3962
- this.validate();
3963
- },
3964
- onFocus() {
3965
- },
3966
- // Noop
3967
- onChange(updatedValue) {
3968
- const prevValue = this.value;
3928
+ onSelect(indices) {
3969
3929
  this._update((draft) => {
3930
+ draft.selectedIndices = indices;
3970
3931
  draft.errors = [];
3971
- draft.validationAsyncState.messages = {};
3972
- draft.value = updatedValue;
3973
3932
  });
3974
- if (isOrWasValid(getValidationErrors, prevValue, updatedValue)) {
3975
- performRefresh == null ? void 0 : performRefresh();
3976
- }
3933
+ performRefresh == null ? void 0 : performRefresh();
3977
3934
  onValueChange();
3935
+ const errors = getValidationErrors(this.getLocalValue());
3936
+ this._update((draft) => {
3937
+ draft.errors = errors;
3938
+ });
3978
3939
  },
3979
- async getSubmittableValue() {
3980
- return this.getSubmittableValueSync();
3981
- },
3982
- getSubmittableValueSync() {
3983
- var _a2;
3984
- return (_a2 = this.getLocalValue()) != null ? _a2 : null;
3940
+ onBlur() {
3985
3941
  },
3986
- getSummary() {
3987
- return summariser(this.getLocalValue());
3942
+ // Noop
3943
+ onFocus() {
3988
3944
  },
3945
+ // Noop
3989
3946
  getLocalValue() {
3990
- return this.value;
3947
+ var _a2, _b;
3948
+ return (_b = (_a2 = this.getSelectedChildren()) == null ? void 0 : _a2.map((child) => child.getLocalValue())) != null ? _b : null;
3991
3949
  },
3992
3950
  validate() {
3993
3951
  const errors = getValidationErrors(this.getLocalValue());
@@ -3995,34 +3953,34 @@ var createDateInputComponent = (textInputProps, updateComponent) => {
3995
3953
  draft.errors = errors;
3996
3954
  });
3997
3955
  return errors.length === 0;
3956
+ },
3957
+ async getSubmittableValue() {
3958
+ const selected = this.getSelectedChildren();
3959
+ if (selected) {
3960
+ return Promise.all(selected.map(async (child) => child.getSubmittableValue()));
3961
+ }
3962
+ return null;
3963
+ },
3964
+ getSubmittableValueSync() {
3965
+ var _a2, _b;
3966
+ return (_b = (_a2 = this.getSelectedChildren()) == null ? void 0 : _a2.map((child) => child.getSubmittableValueSync())) != null ? _b : null;
3967
+ },
3968
+ getSummary: () => ({}),
3969
+ getChildren() {
3970
+ return this.children;
3971
+ },
3972
+ getSelectedChildren() {
3973
+ return this.selectedIndices.map((i) => this.children[i]);
3998
3974
  }
3999
- }, rest);
3975
+ });
4000
3976
  if (performRefresh) {
4001
- return dateInputComponent;
4002
- }
4003
- if (performPersistAsync) {
4004
- const persist = getComponentPersistAsync(update, performPersistAsync);
4005
- return __spreadProps(__spreadValues({}, dateInputComponent), {
4006
- onChange(updatedValue) {
4007
- dateInputComponent.onChange.call(this, updatedValue);
4008
- const isValid = getValidationErrors(updatedValue).length === 0;
4009
- if (isValid) {
4010
- persist(this, this.getLocalValue()).catch(() => {
4011
- });
4012
- }
4013
- },
4014
- async getSubmittableValue() {
4015
- return persist(this, this.getLocalValue());
4016
- },
4017
- getSubmittableValueSync() {
4018
- return this.persistedState.lastResponse;
4019
- }
4020
- });
3977
+ return inputComponent;
4021
3978
  }
4022
3979
  if (performValidationAsync) {
4023
3980
  const validateAsync = getComponentValidationAsync(update, performValidationAsync);
4024
- return __spreadProps(__spreadValues({}, dateInputComponent), {
4025
- onBlur() {
3981
+ return __spreadProps(__spreadValues({}, inputComponent), {
3982
+ onSelect(indices) {
3983
+ inputComponent.onSelect.call(this, indices);
4026
3984
  if (this.validate()) {
4027
3985
  validateAsync(this, this.getLocalValue()).catch(() => {
4028
3986
  });
@@ -4030,79 +3988,181 @@ var createDateInputComponent = (textInputProps, updateComponent) => {
4030
3988
  }
4031
3989
  });
4032
3990
  }
4033
- return dateInputComponent;
3991
+ return inputComponent;
3992
+ };
3993
+ var getInitialModelIndices = (model, options) => {
3994
+ if (!isArray(model)) {
3995
+ return [];
3996
+ }
3997
+ return model.map((m) => options.findIndex((o) => o.getLocalValue() === m)).filter((n) => n >= 0);
4034
3998
  };
4035
3999
 
4036
- // src/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToDateInputComponent.ts
4037
- var stringSchemaToDateInputComponent = (schemaMapperProps, mapperProps) => {
4038
- const { schema, localValue, model, required = false } = schemaMapperProps;
4000
+ // src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToMultiSelectComponent.ts
4001
+ var arraySchemaToMultiSelectComponent = (schemaMapperProps, mapperProps) => {
4039
4002
  const {
4040
- autocompleteHint,
4041
- default: defaultValue,
4042
- minimum: minimumDate,
4043
- maximum: maximumDate,
4044
- suggestions
4045
- } = schema;
4046
- const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange } = mapperProps;
4047
- const errorMessageFunctions = getErrorMessageFunctions(schema.validationMessages);
4048
- const { performPersistAsync, persistedState } = getPersistAsyncInitialState(
4049
- schemaMapperProps,
4050
- mapperProps
4051
- );
4003
+ uid,
4004
+ localValue,
4005
+ schema,
4006
+ model,
4007
+ required = false,
4008
+ validationErrors: initialError
4009
+ } = schemaMapperProps;
4010
+ const initialModel = model != null ? model : null;
4011
+ const options = schema.items.oneOf.map((childSchema, index) => {
4012
+ const { title: title2 = "", description, image, icon, keywords = [] } = childSchema;
4013
+ return {
4014
+ title: title2,
4015
+ description,
4016
+ image: mapSpecImage(image),
4017
+ icon,
4018
+ keywords,
4019
+ disabled: "disabled" in childSchema ? Boolean(childSchema.disabled) : false,
4020
+ component: mapSchemaToComponent(
4021
+ {
4022
+ uid: `${uid}.oneOf-${index}`,
4023
+ schema: childSchema,
4024
+ model: initialModel,
4025
+ localValue,
4026
+ validationErrors: initialError,
4027
+ required
4028
+ },
4029
+ mapperProps
4030
+ )
4031
+ };
4032
+ });
4033
+ const { maxItems, minItems, title, validationMessages } = schema;
4034
+ const { getErrorMessageFunctions, onRefresh, onValueChange, updateComponent } = mapperProps;
4035
+ const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
4052
4036
  const { performValidationAsync, validationAsyncState } = getValidationAsyncInitialState(
4053
4037
  schemaMapperProps,
4054
4038
  mapperProps
4055
4039
  );
4056
- const validLocalValue = isString(localValue) ? localValue : null;
4057
- const validModel = isString(model) ? model : defaultValue != null ? defaultValue : null;
4058
- const value = performPersistAsync ? validLocalValue : validModel;
4059
- return createDateInputComponent(
4040
+ const initialValue = model != null ? model : null;
4041
+ return createMultiSelectComponent(
4060
4042
  __spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
4061
- autoComplete: getAutocompleteString(autocompleteHint),
4043
+ autoComplete: "off",
4062
4044
  checks: schema.hidden ? [] : [
4063
4045
  getRequiredCheck(required, errorMessageFunctions),
4064
- getAboveMaximumDateCheck(schema, errorMessageFunctions),
4065
- getBelowMinimumDateCheck(schema, errorMessageFunctions)
4046
+ getAboveMaxItemsCheck(schema, errorMessageFunctions),
4047
+ getBelowMinItemsCheck(schema, errorMessageFunctions)
4066
4048
  ],
4067
- minimumDate,
4068
- maximumDate,
4069
- suggestions: suggestions ? {
4070
- values: suggestions.values.map((suggestion) => __spreadProps(__spreadValues({}, suggestion), {
4071
- image: mapSpecImage(suggestion.image)
4072
- }))
4073
- } : void 0,
4074
- value,
4075
- persistedState,
4049
+ initialValue,
4050
+ maxItems,
4051
+ minItems,
4052
+ options,
4053
+ required,
4054
+ title,
4076
4055
  validationAsyncState,
4077
- performPersistAsync,
4078
- performRefresh: getPerformRefresh(schema, onRefresh),
4079
4056
  performValidationAsync,
4057
+ performRefresh: getPerformRefresh(schema, onRefresh),
4080
4058
  onValueChange
4081
4059
  }),
4082
4060
  updateComponent
4083
4061
  );
4084
4062
  };
4085
4063
 
4086
- // src/revamp/domain/components/utils/file-utils.ts
4087
- var toBase64 = async (file) => new Promise((resolve, reject) => {
4088
- const reader = new FileReader();
4089
- reader.addEventListener("load", () => resolve(reader.result));
4090
- reader.addEventListener("error", reject);
4091
- reader.readAsDataURL(file);
4092
- });
4093
- var base64dataUrltoFile = (dataurl, filename) => {
4094
- if (!isBase64DataUrl(dataurl)) {
4095
- return null;
4096
- }
4097
- const [, base64data] = dataurl.split(",");
4098
- return new File([base64ToBytes(base64data)], filename, { type: getMimeType(dataurl) });
4064
+ // src/revamp/domain/components/TupleComponent.ts
4065
+ var createTupleComponent = (tupleProps) => {
4066
+ const {
4067
+ uid,
4068
+ analyticsId,
4069
+ alert,
4070
+ components,
4071
+ control,
4072
+ description,
4073
+ help,
4074
+ hidden,
4075
+ icon,
4076
+ image,
4077
+ summariser,
4078
+ title
4079
+ } = tupleProps;
4080
+ return {
4081
+ type: "tuple",
4082
+ uid,
4083
+ analyticsId,
4084
+ alert,
4085
+ components,
4086
+ control,
4087
+ description,
4088
+ help,
4089
+ hidden,
4090
+ icon,
4091
+ image,
4092
+ title,
4093
+ getChildren() {
4094
+ return this.components;
4095
+ },
4096
+ async getSubmittableValue() {
4097
+ return Promise.all(this.components.map(async (child) => child.getSubmittableValue()));
4098
+ },
4099
+ getSubmittableValueSync() {
4100
+ return this.components.map((child) => child.getSubmittableValueSync());
4101
+ },
4102
+ getSummary() {
4103
+ const summary = summariser(this.getLocalValue());
4104
+ const childSummary = summariseFromChildren(this.getChildren());
4105
+ return mergeSummaries(summary, childSummary);
4106
+ },
4107
+ getLocalValue() {
4108
+ return this.components.map((child) => child.getLocalValue());
4109
+ },
4110
+ validate() {
4111
+ return hidden ? true : validateComponents(this.getChildren());
4112
+ }
4113
+ };
4099
4114
  };
4100
- var isBase64DataUrl = (dataurl) => dataurl.startsWith("data:") && dataurl.includes("base64") && dataurl.includes(",");
4101
- var getMimeType = (base64dataUrl) => base64dataUrl.substring("data:".length).split(";")[0];
4102
- var base64ToBytes = (base64) => {
4103
- const charCodes = atob(base64).split("").map((m) => m.charCodeAt(0));
4104
- return Uint8Array.from(charCodes);
4115
+
4116
+ // src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToTupleComponent.ts
4117
+ var arraySchemaToTupleComponent = (schemaMapperProps, mapperProps) => {
4118
+ const {
4119
+ uid,
4120
+ localValue,
4121
+ schema,
4122
+ model: initialModel,
4123
+ required = false,
4124
+ validationErrors
4125
+ } = schemaMapperProps;
4126
+ const { items } = schema;
4127
+ const components = items.map(
4128
+ (childSchema, index) => {
4129
+ var _a, _b;
4130
+ return mapSchemaToComponent(
4131
+ {
4132
+ uid: `${uid}-arr.${index}`,
4133
+ schema: childSchema,
4134
+ model: isArray(initialModel) ? (_a = initialModel[index]) != null ? _a : null : null,
4135
+ localValue: isArray(localValue) ? (_b = localValue[index]) != null ? _b : null : null,
4136
+ validationErrors: isArray(validationErrors) ? validationErrors[index] : void 0,
4137
+ required
4138
+ },
4139
+ mapperProps
4140
+ );
4141
+ }
4142
+ );
4143
+ return createTupleComponent(__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
4144
+ components
4145
+ }));
4146
+ };
4147
+
4148
+ // src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToComponent.ts
4149
+ var arraySchemaToComponent = (schemaMapperProps, mapperProps) => {
4150
+ const { schema, model: originalModel } = schemaMapperProps;
4151
+ const model = isNullish(originalModel) || isArrayModel(originalModel) ? originalModel : null;
4152
+ if (isArraySchemaListWithMultiFileUpload(schema)) {
4153
+ return arraySchemaToMultiUploadComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
4154
+ }
4155
+ if (isArraySchemaListWithMultiSelect(schema)) {
4156
+ return arraySchemaToMultiSelectComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
4157
+ }
4158
+ if (isArrayTupleSchema(schema)) {
4159
+ return arraySchemaToTupleComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
4160
+ }
4161
+ return arraySchemaToRepeatableComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
4105
4162
  };
4163
+ var isArraySchemaListWithMultiFileUpload = (schema) => isArrayListSchema(schema) && (isPersistAsyncWithUploadSchema(schema.items) || isStringSchemaWithUpload(schema.items));
4164
+ var isPersistAsyncWithUploadSchema = (schema) => isSchemaWithPersistAsync(schema) && (isBlobSchema(schema.persistAsync.schema) || isStringSchemaWithUpload(schema.persistAsync.schema));
4165
+ var isArraySchemaListWithMultiSelect = (schema) => isArrayListSchema(schema) && "oneOf" in schema.items && schema.items.oneOf.every(isConstSchema);
4106
4166
 
4107
4167
  // src/revamp/domain/components/UploadInputComponent.ts
4108
4168
  var createUploadInputComponent = (uploadInputProps, updateComponent) => {
@@ -4208,70 +4268,222 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
4208
4268
  });
4209
4269
  };
4210
4270
 
4211
- // src/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToUploadInputComponent.ts
4212
- var stringSchemaToUploadInputComponent = (schemaMapperProps, mapperProps) => {
4213
- var _a;
4271
+ // src/revamp/domain/mappers/schema/blobSchemaToComponent.ts
4272
+ var blobSchemaToComponent = (schemaMapperProps, mapperProps) => {
4214
4273
  const { schema, localValue, model, required = false } = schemaMapperProps;
4215
- const { accepts, autocompleteHint, cameraConfig, hidden, maxSize, source, validationMessages } = schema;
4216
- const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange } = mapperProps;
4274
+ const { accepts, cameraConfig, maxSize, source, validationMessages } = schema;
4275
+ const { getErrorMessageFunctions, updateComponent, onValueChange } = mapperProps;
4217
4276
  const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
4218
4277
  const { performPersistAsync } = getPersistAsyncInitialState(schemaMapperProps, mapperProps);
4219
4278
  const persistedState = performPersistAsync ? getInitialPersistedState(null, model) : getInitialPersistedState();
4220
4279
  const validLocalValue = isFile(localValue) ? localValue : null;
4221
- const value = (_a = getFileFromModel(model)) != null ? _a : validLocalValue;
4222
- const checks = hidden ? [] : [
4223
- getRequiredCheck(required, errorMessageFunctions),
4224
- getFileSizeCheck(schema, errorMessageFunctions),
4225
- getFileTypeCheck(schema, errorMessageFunctions)
4226
- ];
4280
+ const value = performPersistAsync ? validLocalValue : null;
4227
4281
  return createUploadInputComponent(
4228
4282
  __spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
4229
4283
  accepts,
4230
- autoComplete: getAutocompleteString(autocompleteHint),
4284
+ autoComplete: "off",
4231
4285
  cameraConfig,
4232
- checks,
4233
- format: "base64",
4286
+ format: "blob",
4234
4287
  maxSize,
4235
4288
  source,
4236
4289
  value,
4237
4290
  persistedState,
4238
4291
  performPersistAsync,
4239
- performRefresh: getPerformRefresh(schema, onRefresh),
4292
+ checks: schema.hidden ? [] : [getRequiredCheck(required, errorMessageFunctions)],
4240
4293
  onValueChange
4241
4294
  }),
4242
4295
  updateComponent
4243
4296
  );
4244
4297
  };
4245
- var getFileFromModel = (model) => isString(model) ? base64dataUrltoFile(model, "") : null;
4246
4298
 
4247
- // src/revamp/domain/components/TextInputComponent.ts
4248
- var createTextInputComponent = (textInputProps, updateComponent) => {
4249
- const _a = textInputProps, {
4299
+ // src/revamp/domain/components/BooleanInputComponent.ts
4300
+ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
4301
+ const _a = booleanInputProps, {
4302
+ uid,
4303
+ id,
4304
+ value,
4305
+ performPersistAsync,
4306
+ performRefresh,
4307
+ performValidationAsync,
4308
+ onValueChange,
4309
+ summariser
4310
+ } = _a, rest = __objRest(_a, [
4311
+ "uid",
4312
+ "id",
4313
+ "value",
4314
+ "performPersistAsync",
4315
+ "performRefresh",
4316
+ "performValidationAsync",
4317
+ "onValueChange",
4318
+ "summariser"
4319
+ ]);
4320
+ const update = getInputUpdateFunction(updateComponent);
4321
+ const booleanComponent = __spreadValues({
4322
+ type: "boolean",
4323
+ uid,
4324
+ id,
4325
+ autoComplete: "",
4326
+ value,
4327
+ _update(updateFn) {
4328
+ update(this, updateFn);
4329
+ },
4330
+ onBlur() {
4331
+ },
4332
+ // Noop
4333
+ onFocus() {
4334
+ },
4335
+ // Noop
4336
+ onChange(updatedValue) {
4337
+ this._update((draft) => {
4338
+ draft.errors = [];
4339
+ draft.value = updatedValue;
4340
+ });
4341
+ performRefresh == null ? void 0 : performRefresh();
4342
+ onValueChange();
4343
+ },
4344
+ async getSubmittableValue() {
4345
+ return this.getSubmittableValueSync();
4346
+ },
4347
+ getSubmittableValueSync() {
4348
+ return this.getLocalValue();
4349
+ },
4350
+ getSummary() {
4351
+ return summariser(this.getLocalValue());
4352
+ },
4353
+ getLocalValue() {
4354
+ return this.value;
4355
+ },
4356
+ validate: () => true
4357
+ }, rest);
4358
+ if (performRefresh) {
4359
+ return booleanComponent;
4360
+ }
4361
+ if (performPersistAsync) {
4362
+ const persist = getComponentPersistAsync(update, performPersistAsync);
4363
+ return __spreadProps(__spreadValues({}, booleanComponent), {
4364
+ onChange(updatedValue) {
4365
+ booleanComponent.onChange.call(this, updatedValue);
4366
+ persist(this, this.getLocalValue()).catch(() => {
4367
+ });
4368
+ },
4369
+ async getSubmittableValue() {
4370
+ return persist(this, this.getLocalValue());
4371
+ },
4372
+ getSubmittableValueSync() {
4373
+ return this.persistedState.lastResponse;
4374
+ }
4375
+ });
4376
+ }
4377
+ if (performValidationAsync) {
4378
+ const validateAsync = getComponentValidationAsync(update, performValidationAsync);
4379
+ return __spreadProps(__spreadValues({}, booleanComponent), {
4380
+ onChange(updatedValue) {
4381
+ booleanComponent.onChange.call(this, updatedValue);
4382
+ validateAsync(this, this.getLocalValue()).catch(() => {
4383
+ });
4384
+ }
4385
+ });
4386
+ }
4387
+ return booleanComponent;
4388
+ };
4389
+
4390
+ // src/revamp/domain/mappers/schema/booleanSchemaToComponent.ts
4391
+ var booleanSchemaToComponent = (schemaMapperProps, mapperProps) => {
4392
+ const { schema, localValue, model } = schemaMapperProps;
4393
+ const { default: defaultValue } = schema;
4394
+ const { updateComponent, onRefresh, onValueChange } = mapperProps;
4395
+ const performRefresh = getPerformRefresh(schema, onRefresh);
4396
+ const { performPersistAsync, persistedState } = getPersistAsyncInitialState(
4397
+ schemaMapperProps,
4398
+ mapperProps
4399
+ );
4400
+ const { performValidationAsync, validationAsyncState } = getValidationAsyncInitialState(
4401
+ schemaMapperProps,
4402
+ mapperProps
4403
+ );
4404
+ const validLocalValue = isBoolean(localValue) ? localValue : false;
4405
+ const validModel = getValidModel(model, defaultValue);
4406
+ const value = performPersistAsync ? validLocalValue : validModel;
4407
+ return createBooleanInputComponent(
4408
+ __spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
4409
+ value: value != null ? value : false,
4410
+ persistedState,
4411
+ validationAsyncState,
4412
+ performPersistAsync,
4413
+ performRefresh,
4414
+ performValidationAsync,
4415
+ onValueChange
4416
+ }),
4417
+ updateComponent
4418
+ );
4419
+ };
4420
+ var getValidModel = (model, defaultValue) => {
4421
+ if (isBoolean(model)) {
4422
+ return model;
4423
+ }
4424
+ if (isBoolean(defaultValue)) {
4425
+ return defaultValue;
4426
+ }
4427
+ return false;
4428
+ };
4429
+
4430
+ // src/revamp/domain/components/ConstComponent.ts
4431
+ var createConstComponent = (hiddenProps) => {
4432
+ const { uid, analyticsId, value, summary } = hiddenProps;
4433
+ return {
4434
+ type: "const",
4435
+ uid,
4436
+ analyticsId,
4437
+ getLocalValue: () => value,
4438
+ getSubmittableValue: async () => value,
4439
+ getSubmittableValueSync: () => value,
4440
+ getSummary: () => summary,
4441
+ validate: () => true
4442
+ };
4443
+ };
4444
+
4445
+ // src/revamp/domain/mappers/schema/constSchemaToComponent.ts
4446
+ var constSchemaToComponent = (uid, schemaMapperProps) => {
4447
+ var _a;
4448
+ const { schema } = schemaMapperProps;
4449
+ const { title, const: constValue, analyticsId, $id } = schema;
4450
+ const titleOrValue = (_a = title != null ? title : constValue) != null ? _a : null;
4451
+ return createConstComponent({
4452
+ uid,
4453
+ analyticsId: analyticsId != null ? analyticsId : $id,
4454
+ summary: getConstSummary(schema, titleOrValue),
4455
+ value: schema.const
4456
+ });
4457
+ };
4458
+
4459
+ // src/revamp/domain/components/IntegerInputComponent.ts
4460
+ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
4461
+ const _a = integerInputProps, {
4250
4462
  uid,
4251
4463
  id,
4252
4464
  checks,
4465
+ value,
4253
4466
  performPersistAsync,
4254
4467
  performRefresh,
4255
4468
  performValidationAsync,
4256
4469
  onValueChange,
4257
- summariser,
4258
- value
4470
+ summariser
4259
4471
  } = _a, rest = __objRest(_a, [
4260
4472
  "uid",
4261
4473
  "id",
4262
4474
  "checks",
4475
+ "value",
4263
4476
  "performPersistAsync",
4264
4477
  "performRefresh",
4265
4478
  "performValidationAsync",
4266
4479
  "onValueChange",
4267
- "summariser",
4268
- "value"
4480
+ "summariser"
4269
4481
  ]);
4270
4482
  const update = getInputUpdateFunction(updateComponent);
4271
4483
  const getValidationErrors = getLocalValueValidator(checks);
4272
4484
  const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh, getValidationErrors);
4273
- const inputComponent = __spreadValues({
4274
- type: "text",
4485
+ const integerComponent = __spreadValues({
4486
+ type: "integer",
4275
4487
  uid,
4276
4488
  id,
4277
4489
  value,
@@ -4299,7 +4511,8 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
4299
4511
  return this.getSubmittableValueSync();
4300
4512
  },
4301
4513
  getSubmittableValueSync() {
4302
- return this.getLocalValue() || null;
4514
+ var _a2;
4515
+ return (_a2 = this.getLocalValue()) != null ? _a2 : null;
4303
4516
  },
4304
4517
  getSummary() {
4305
4518
  return summariser(this.getLocalValue());
@@ -4316,11 +4529,11 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
4316
4529
  }
4317
4530
  }, rest);
4318
4531
  if (performRefresh) {
4319
- return inputComponent;
4532
+ return integerComponent;
4320
4533
  }
4321
4534
  if (performPersistAsync) {
4322
4535
  const persist = getComponentPersistAsync(update, performPersistAsync);
4323
- return __spreadProps(__spreadValues({}, inputComponent), {
4536
+ return __spreadProps(__spreadValues({}, integerComponent), {
4324
4537
  onBlur() {
4325
4538
  if (this.validate()) {
4326
4539
  persist(this, this.getLocalValue()).catch(() => {
@@ -4337,43 +4550,28 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
4337
4550
  }
4338
4551
  if (performValidationAsync) {
4339
4552
  const validateAsync = getDebouncedComponentValidationAsync(update, performValidationAsync);
4340
- return __spreadProps(__spreadValues({}, inputComponent), {
4553
+ return __spreadProps(__spreadValues({}, integerComponent), {
4341
4554
  onBlur() {
4342
4555
  if (this.validate()) {
4343
4556
  validateAsync.flush();
4344
4557
  }
4345
4558
  },
4346
4559
  onChange(updatedValue) {
4347
- inputComponent.onChange.call(this, updatedValue);
4560
+ integerComponent.onChange.call(this, updatedValue);
4348
4561
  if (getValidationErrors(updatedValue).length === 0) {
4349
4562
  validateAsync(this, updatedValue);
4350
4563
  }
4351
- if (!updatedValue) {
4352
- validateAsync.cancel();
4353
- }
4354
4564
  }
4355
4565
  });
4356
4566
  }
4357
- return inputComponent;
4567
+ return integerComponent;
4358
4568
  };
4359
4569
 
4360
- // src/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToTextInputComponent.ts
4361
- var stringSchemaToTextInputComponent = (schemaMapperProps, mapperProps) => {
4570
+ // src/revamp/domain/mappers/schema/integerSchemaToComponent.ts
4571
+ var integerSchemaToComponent = (schemaMapperProps, mapperProps) => {
4362
4572
  const { schema, localValue, model, required = false } = schemaMapperProps;
4363
- const {
4364
- autocapitalization,
4365
- autocompleteHint,
4366
- control,
4367
- default: defaultValue,
4368
- displayFormat,
4369
- format,
4370
- maxLength,
4371
- minLength,
4372
- suggestions,
4373
- validationMessages
4374
- } = schema;
4375
- const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange, logEvent } = mapperProps;
4376
- const controlForLegacyFormat = getControlForLegacyFormat(format);
4573
+ const { autocompleteHint, validationMessages, default: defaultValue, maximum, minimum } = schema;
4574
+ const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange } = mapperProps;
4377
4575
  const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
4378
4576
  const { performPersistAsync, persistedState } = getPersistAsyncInitialState(
4379
4577
  schemaMapperProps,
@@ -4383,30 +4581,22 @@ var stringSchemaToTextInputComponent = (schemaMapperProps, mapperProps) => {
4383
4581
  schemaMapperProps,
4384
4582
  mapperProps
4385
4583
  );
4386
- const validLocalValue = isString(localValue) ? localValue : null;
4387
- const validModel = isString(model) ? model : defaultValue != null ? defaultValue : null;
4584
+ const validLocalValue = isInteger(localValue) ? localValue : null;
4585
+ const validModel = isInteger(model) ? model : defaultValue != null ? defaultValue : null;
4388
4586
  const value = performPersistAsync ? validLocalValue : validModel;
4389
- return createTextInputComponent(
4587
+ const checks = [
4588
+ getRequiredCheck(required, errorMessageFunctions),
4589
+ getBelowMinimumCheck(schema, errorMessageFunctions),
4590
+ getAboveMaximumCheck(schema, errorMessageFunctions)
4591
+ ];
4592
+ return createIntegerInputComponent(
4390
4593
  __spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
4391
- autocapitalization,
4392
4594
  autoComplete: getAutocompleteString(autocompleteHint),
4393
- checks: schema.hidden ? [] : [
4394
- getRequiredCheck(required, errorMessageFunctions),
4395
- getAboveMaxLengthCheck(schema, errorMessageFunctions),
4396
- getBelowMinLengthCheck(schema, errorMessageFunctions),
4397
- getNotAdheringToPatternCheck(schema, errorMessageFunctions, { logEvent })
4398
- ],
4399
- control: control != null ? control : controlForLegacyFormat,
4400
- displayFormat,
4401
- maxLength,
4402
- minLength,
4403
- suggestions: suggestions ? {
4404
- values: suggestions.values.map((suggestion) => __spreadProps(__spreadValues({}, suggestion), {
4405
- image: mapSpecImage(suggestion.image)
4406
- }))
4407
- } : void 0,
4408
- value,
4595
+ checks,
4596
+ maximum,
4597
+ minimum,
4409
4598
  persistedState,
4599
+ value,
4410
4600
  validationAsyncState,
4411
4601
  performPersistAsync,
4412
4602
  performRefresh: getPerformRefresh(schema, onRefresh),
@@ -4416,548 +4606,258 @@ var stringSchemaToTextInputComponent = (schemaMapperProps, mapperProps) => {
4416
4606
  updateComponent
4417
4607
  );
4418
4608
  };
4419
- var getControlForLegacyFormat = (format) => {
4420
- if (format && ["numeric", "phone-number", "email", "password"].includes(format)) {
4421
- return format;
4422
- }
4423
- return void 0;
4424
- };
4425
4609
 
4426
- // src/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToComponent.ts
4427
- var stringSchemaToComponent = (schemaMapperProps, mapperProps) => {
4428
- const { schema } = schemaMapperProps;
4429
- if (isStringSchemaWithBase64(schema)) {
4430
- return stringSchemaToUploadInputComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema }), mapperProps);
4431
- }
4432
- switch (schema.format) {
4433
- case "date":
4434
- return stringSchemaToDateInputComponent(schemaMapperProps, mapperProps);
4435
- default:
4436
- return stringSchemaToTextInputComponent(schemaMapperProps, mapperProps);
4437
- }
4438
- };
4439
- var isStringSchemaWithBase64 = (schema) => {
4440
- return schema.format === "base64url" && !("persistAsync" in schema);
4441
- };
4442
-
4443
- // src/revamp/domain/components/ContainerComponent.ts
4444
- var createContainerComponent = (containerProps) => __spreadProps(__spreadValues({}, containerProps), {
4445
- type: "container",
4446
- getChildren() {
4447
- return this.components;
4448
- },
4449
- async getSubmittableValue() {
4450
- return getSubmittableData(this.components);
4451
- },
4452
- getSubmittableValueSync() {
4453
- return getSubmittableDataSync(this.components);
4454
- },
4455
- getSummary() {
4456
- return summariseFromChildren(this.getChildren());
4457
- },
4458
- getLocalValue() {
4459
- return getLocalValues(this.components);
4460
- },
4461
- validate() {
4462
- return validateComponents(this.getChildren());
4463
- }
4464
- });
4465
-
4466
- // src/revamp/domain/components/RepeatableComponent.ts
4467
- var createRepeatableComponent = (repeatableProps, updateComponent) => {
4468
- const _a = repeatableProps, {
4610
+ // src/revamp/domain/components/ObjectComponent.ts
4611
+ var createObjectComponent = (objectProps) => {
4612
+ const {
4469
4613
  uid,
4470
- id,
4471
- checks,
4472
- components,
4473
- summary,
4474
- onValueChange,
4475
- createEditableComponent,
4476
- summariser
4477
- } = _a, componentProps = __objRest(_a, [
4478
- "uid",
4479
- "id",
4480
- "checks",
4481
- "components",
4482
- "summary",
4483
- "onValueChange",
4484
- "createEditableComponent",
4485
- "summariser"
4486
- ]);
4487
- const update = getInputUpdateFunction(updateComponent);
4488
- const getValidationErrors = getLocalValueValidator(checks);
4489
- const repeatableComponent = __spreadProps(__spreadValues({
4614
+ analyticsId,
4615
+ alert,
4616
+ componentMap,
4617
+ control,
4618
+ description,
4619
+ displayOrder,
4620
+ help,
4621
+ hidden,
4622
+ icon,
4623
+ image,
4624
+ summariser,
4625
+ title
4626
+ } = objectProps;
4627
+ return {
4628
+ type: "object",
4490
4629
  uid,
4491
- id,
4492
- type: "repeatable",
4493
- components,
4494
- editableComponent: null,
4495
- editableIndex: null,
4496
- summaryDefaults: {
4497
- title: summary == null ? void 0 : summary.defaultTitle,
4498
- description: summary == null ? void 0 : summary.defaultDescription,
4499
- icon: summary == null ? void 0 : summary.defaultIcon,
4500
- image: summary == null ? void 0 : summary.defaultImage
4501
- }
4502
- }, componentProps), {
4503
- _update(updateFn) {
4504
- update(this, updateFn);
4505
- },
4506
- onEdit(itemIndex) {
4507
- this._update((draft) => {
4508
- draft.editableComponent = createEditableComponent(
4509
- draft.components[itemIndex].getLocalValue()
4510
- );
4511
- draft.editableIndex = itemIndex;
4512
- });
4513
- },
4514
- onAdd() {
4515
- this._update((draft) => {
4516
- draft.editableComponent = createEditableComponent(null);
4517
- draft.editableIndex = null;
4518
- draft.errors = [];
4519
- });
4520
- },
4521
- onSave() {
4522
- var _a2;
4523
- const isValid = (_a2 = this.editableComponent) == null ? void 0 : _a2.validate();
4524
- if (!isValid) {
4525
- return false;
4526
- }
4527
- this._update((draft) => {
4528
- if (draft.editableComponent === null) {
4529
- return;
4530
- }
4531
- if (draft.editableIndex === null) {
4532
- const newComponent = __spreadValues({}, draft.editableComponent);
4533
- draft.components = [...this.components, newComponent];
4534
- } else {
4535
- draft.components[draft.editableIndex] = __spreadProps(__spreadValues({}, draft.editableComponent), {
4536
- uid: draft.components[draft.editableIndex].uid
4537
- });
4538
- }
4539
- draft.editableComponent = null;
4540
- draft.editableIndex = null;
4541
- });
4542
- onValueChange();
4543
- return true;
4544
- },
4545
- onRemove() {
4546
- this._update((draft) => {
4547
- if (draft.editableIndex === null) {
4548
- return;
4549
- }
4550
- draft.components.splice(draft.editableIndex, 1);
4551
- draft.editableComponent = null;
4552
- draft.editableIndex = null;
4553
- });
4554
- onValueChange();
4555
- },
4630
+ analyticsId,
4631
+ alert,
4632
+ componentMap,
4633
+ control,
4634
+ description,
4635
+ help,
4636
+ hidden,
4637
+ icon,
4638
+ image,
4639
+ title,
4556
4640
  getChildren() {
4557
- return this.editableComponent !== null ? [...this.components, this.editableComponent] : this.components;
4641
+ return displayOrder.map((propName) => this.componentMap[propName]);
4558
4642
  },
4559
4643
  async getSubmittableValue() {
4560
- return Promise.all(this.components.map(async (component) => component.getSubmittableValue()));
4644
+ return Promise.all(
4645
+ displayOrder.map(
4646
+ async (propName) => this.componentMap[propName].getSubmittableValue().then((value) => ({ value, propName }))
4647
+ )
4648
+ ).then(
4649
+ (values) => values.reduce(
4650
+ (acc, { value, propName }) => __spreadValues(__spreadValues({}, acc), value === null ? {} : { [propName]: value }),
4651
+ {}
4652
+ )
4653
+ );
4561
4654
  },
4562
4655
  getSubmittableValueSync() {
4563
- return this.components.map((component) => component.getSubmittableValueSync());
4656
+ return mergeChildrenValues(
4657
+ displayOrder,
4658
+ (propName) => this.componentMap[propName].getSubmittableValueSync()
4659
+ );
4564
4660
  },
4565
4661
  getSummary() {
4566
- return summariser(null);
4662
+ const summary = summariser(this.getLocalValue());
4663
+ const childSummary = summariseFromChildren(this.getChildren());
4664
+ return mergeSummaries(summary, childSummary);
4567
4665
  },
4568
4666
  getLocalValue() {
4569
- return this.components.map((component) => component.getLocalValue());
4667
+ return mergeChildrenValues(
4668
+ displayOrder,
4669
+ (propName) => this.componentMap[propName].getLocalValue()
4670
+ );
4570
4671
  },
4571
4672
  validate() {
4572
- const messages = getValidationErrors(this.getLocalValue());
4573
- const childComponentsValid = validateComponents(this.getChildren());
4574
- this._update((draft) => {
4575
- draft.errors = messages;
4576
- });
4577
- return messages.length === 0 && childComponentsValid;
4673
+ return hidden ? true : validateComponents(this.getChildren());
4578
4674
  }
4579
- });
4580
- return repeatableComponent;
4581
- };
4582
-
4583
- // src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToRepeatableComponent.ts
4584
- var arraySchemaToRepeatableComponent = (schemaMapperProps, mapperProps) => {
4585
- const { getErrorMessageFunctions } = mapperProps;
4586
- const {
4587
- uid,
4588
- localValue,
4589
- schema,
4590
- model: initialModel,
4591
- required = false,
4592
- validationErrors
4593
- } = schemaMapperProps;
4594
- const { items, addItemTitle, editItemTitle, maxItems, minItems, summary } = schema;
4595
- const value = isArray(localValue) ? localValue : [];
4596
- const components = initialModel == null ? void 0 : initialModel.map(
4597
- (item, index) => mapSchemaToComponent(
4598
- {
4599
- uid: `${uid}.arr-${index}`,
4600
- schema: items,
4601
- model: item,
4602
- localValue: value == null ? void 0 : value[index],
4603
- // TODO tests for this
4604
- validationErrors
4605
- },
4606
- mapperProps
4607
- )
4608
- );
4609
- const createEditableComponent = (editableValue) => mapSchemaToComponent(
4610
- {
4611
- uid: `${uid}.arr-rnd-${getRandomInt()}`,
4612
- schema: items,
4613
- localValue: editableValue,
4614
- model: localValueToJsonElement(editableValue),
4615
- validationErrors: void 0,
4616
- required: true
4617
- },
4618
- mapperProps
4619
- );
4620
- const { onValueChange } = mapperProps;
4621
- const errorMessageFunctions = getErrorMessageFunctions(schema.validationMessages);
4622
- return createRepeatableComponent(
4623
- __spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
4624
- addItemTitle,
4625
- checks: schema.hidden ? [] : [
4626
- getRequiredCheck(required, errorMessageFunctions),
4627
- getAboveMaxItemsCheck(schema, errorMessageFunctions),
4628
- getBelowMinItemsCheck(schema, errorMessageFunctions)
4629
- ],
4630
- components: components != null ? components : [],
4631
- editItemTitle,
4632
- maxItems,
4633
- minItems,
4634
- summary: __spreadProps(__spreadValues({}, summary), {
4635
- defaultImage: mapSpecImage(summary == null ? void 0 : summary.defaultImage)
4636
- }),
4637
- createEditableComponent,
4638
- onValueChange
4639
- }),
4640
- mapperProps.updateComponent
4641
- );
4642
- };
4643
- var localValueToJsonElement = (localValue) => {
4644
- if (localValue instanceof Array) {
4645
- return localValue.map(localValueToJsonElement);
4646
- }
4647
- if (isObject(localValue)) {
4648
- return Object.fromEntries(
4649
- Object.entries(localValue).map(([key, value]) => [key, localValueToJsonElement(value)])
4650
- );
4651
- }
4652
- if (localValue instanceof File) {
4653
- return localValue.name;
4654
- }
4655
- return localValue;
4675
+ };
4656
4676
  };
4657
- var getRandomInt = () => Math.floor(Math.random() * 1e8);
4677
+ var mergeChildrenValues = (displayOrder, getComponentValue) => displayOrder.reduce((acc, propName) => {
4678
+ const componentValue = getComponentValue(propName);
4679
+ return __spreadValues(__spreadValues({}, acc), componentValue === null ? {} : { [propName]: componentValue });
4680
+ }, {});
4658
4681
 
4659
- // src/revamp/domain/components/MultiUploadInputComponent.ts
4660
- var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
4661
- const _a = uploadInputProps, {
4662
- uid,
4663
- id,
4664
- checks,
4665
- fileChecks,
4666
- format,
4667
- performPersistAsync,
4668
- onValueChange,
4669
- summariser
4670
- } = _a, rest = __objRest(_a, [
4671
- "uid",
4672
- "id",
4673
- "checks",
4674
- "fileChecks",
4675
- "format",
4676
- "performPersistAsync",
4677
- "onValueChange",
4678
- "summariser"
4679
- ]);
4680
- const update = getInputUpdateFunction(updateComponent);
4681
- const getValidationErrors = getLocalValueValidator(checks);
4682
- const getFileValidationErrors = getLocalValueValidator(fileChecks);
4683
- const uploadComponent = __spreadValues({
4684
- type: "multi-upload",
4685
- uid,
4686
- id,
4687
- format: "base64",
4688
- files: [],
4689
- _update(updateFn) {
4690
- update(this, updateFn);
4691
- },
4692
- onBlur() {
4693
- this.validate();
4694
- },
4695
- onFocus() {
4696
- },
4697
- // Noop
4698
- async onRemoveFile(index) {
4699
- this._update((draft) => {
4700
- draft.value.splice(index, 1);
4701
- draft.files.splice(index, 1);
4702
- });
4703
- },
4704
- async onInsertFile(index, file) {
4705
- const fileErrors = getFileValidationErrors(file);
4706
- const fileId = getRandomId();
4707
- this._update((draft) => {
4708
- draft.value.splice(index, 0, file);
4709
- draft.files.splice(index, 0, { file, id: fileId, errors: fileErrors });
4710
- draft.errors = [];
4711
- });
4712
- onValueChange();
4713
- return fileId;
4714
- },
4715
- async getSubmittableValue() {
4716
- const files = this.getLocalValue();
4717
- return files ? Promise.all(files.map(toBase64)) : null;
4718
- },
4719
- getSubmittableValueSync() {
4720
- return null;
4721
- },
4722
- getSummary() {
4723
- return summariser(this.getLocalValue().map(({ name }) => name));
4724
- },
4725
- getLocalValue() {
4726
- return this.value;
4727
- },
4728
- validate() {
4729
- const errorMsgs = getValidationErrors(this.getLocalValue());
4730
- this._update((draft) => {
4731
- draft.errors = errorMsgs;
4732
- });
4733
- return errorMsgs.length === 0 && this.files.every(({ errors }) => errors.length === 0);
4682
+ // src/revamp/domain/mappers/schema/objectSchemaToComponent/objectSchemaToComponent.ts
4683
+ var objectSchemaToComponent = (schemaMapperProps, mapperProps) => {
4684
+ const { uid, localValue, schema, model, validationErrors } = schemaMapperProps;
4685
+ const { $id, displayOrder, properties, required } = schema;
4686
+ validateDisplayOrder($id, displayOrder, properties, mapperProps.logEvent);
4687
+ const componentMap = displayOrder.reduce((acc, propName) => {
4688
+ var _a;
4689
+ const propSchema = properties[propName];
4690
+ if (propSchema === void 0) {
4691
+ throw new Error(`Object schema ${$id} has no property named ${propName}`);
4734
4692
  }
4735
- }, rest);
4736
- if (!performPersistAsync) {
4737
- return uploadComponent;
4693
+ return __spreadProps(__spreadValues({}, acc), {
4694
+ [propName]: mapSchemaToComponent(
4695
+ {
4696
+ uid: `${uid}.obj-${propName}`,
4697
+ schema: propSchema,
4698
+ model: isObjectModel(model) ? model[propName] : null,
4699
+ localValue: isObjectLocalValue(localValue) ? localValue[propName] : null,
4700
+ required: (_a = required == null ? void 0 : required.includes(propName)) != null ? _a : false,
4701
+ validationErrors: isObject(validationErrors) ? validationErrors[propName] : void 0
4702
+ },
4703
+ mapperProps
4704
+ )
4705
+ });
4706
+ }, {});
4707
+ return createObjectComponent(__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
4708
+ componentMap,
4709
+ displayOrder
4710
+ }));
4711
+ };
4712
+ var validateDisplayOrder = ($id, displayOrder, properties, logEvent) => {
4713
+ if (!displayOrder) {
4714
+ const message = `Object schema ${$id} has no displayOrder property.`;
4715
+ logEvent("error", message);
4716
+ throw new Error(message);
4738
4717
  }
4739
- const persist = getComponentMultiPersistAsync(update, performPersistAsync);
4740
- return __spreadProps(__spreadValues({}, uploadComponent), {
4741
- format,
4742
- async onInsertFile(index, file) {
4743
- const fileId = await uploadComponent.onInsertFile.call(this, index, file);
4744
- const submission = format === "blob" ? file : await toBase64(file);
4745
- await persist(this, index, submission);
4746
- onValueChange();
4747
- return fileId;
4748
- },
4749
- async onRemoveFile(index) {
4750
- var _a2;
4751
- await uploadComponent.onRemoveFile.call(this, index);
4752
- (_a2 = this.persistedState[index]) == null ? void 0 : _a2.abortController.abort();
4753
- this._update((draft) => {
4754
- draft.persistedState = draft.persistedState.splice(index, 1);
4755
- });
4756
- },
4757
- async getSubmittableValue() {
4758
- return Promise.all(this.persistedState.map(async ({ submission }) => submission));
4759
- },
4760
- getSubmittableValueSync() {
4761
- return this.persistedState.map(({ lastResponse }) => lastResponse);
4718
+ const propertyNames = Object.keys(properties);
4719
+ displayOrder.forEach((propName) => {
4720
+ if (!properties[propName]) {
4721
+ const message = `Object schema ${$id} has no property named "${propName}", but it is listed in the displayOrder array.`;
4722
+ logEvent("error", message);
4723
+ throw new Error(message);
4762
4724
  }
4763
4725
  });
4764
- };
4765
-
4766
- // src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToMultiUploadComponent.ts
4767
- var arraySchemaToMultiUploadComponent = (schemaMapperProps, mapperProps) => {
4768
- var _a;
4769
- const { getErrorMessageFunctions } = mapperProps;
4770
- const { localValue, model, schema, required = false } = schemaMapperProps;
4771
- const uploadSchema = getUploadSchema(schema.items);
4772
- const { accepts, cameraConfig, maxSize } = uploadSchema;
4773
- const { minItems, maxItems, title, validationMessages } = schema;
4774
- const arrayErrorMessageFunctions = getErrorMessageFunctions(validationMessages);
4775
- const fileErrorMessageFunctions = getErrorMessageFunctions(uploadSchema.validationMessages);
4776
- const checks = [
4777
- getRequiredCheck(required, arrayErrorMessageFunctions),
4778
- getAboveMaxFilesCheck(schema, arrayErrorMessageFunctions),
4779
- getBelowMinFilesCheck(schema, arrayErrorMessageFunctions)
4780
- ];
4781
- const fileChecks = [
4782
- getFileSizeCheck(schema.items, fileErrorMessageFunctions),
4783
- getFileTypeCheck(schema.items, fileErrorMessageFunctions)
4784
- ];
4785
- const persistAsyncConfig = getPersistAsyncConfig(schema.items);
4786
- const format = getFormat(schema.items);
4787
- const combinedSchemaProps = __spreadProps(__spreadValues({}, schemaMapperProps), {
4788
- persistAsyncConfig,
4789
- schema: __spreadProps(__spreadValues({}, uploadSchema), { hidden: (_a = schema.hidden) != null ? _a : uploadSchema.hidden })
4726
+ propertyNames.forEach((propName) => {
4727
+ if (!displayOrder.includes(propName)) {
4728
+ const message = `Object schema ${$id} has a "${propName}" property which is missing in the displayOrder array.`;
4729
+ logEvent("error", message);
4730
+ throw new Error(message);
4731
+ }
4790
4732
  });
4791
- const { onValueChange } = mapperProps;
4792
- const { performPersistAsync } = getPersistAsyncInitialState(combinedSchemaProps, mapperProps);
4793
- const value = performPersistAsync ? getValueForPersistAsync(localValue) : [];
4794
- const persistedState = performPersistAsync && isArray(model) ? model.map((itemModel) => getInitialPersistedState(null, itemModel)) : [];
4795
- return createMultiUploadInputComponent(
4796
- __spreadProps(__spreadValues({}, mapCommonSchemaProps(combinedSchemaProps)), {
4797
- title,
4798
- cameraConfig,
4799
- uploadLabel: uploadSchema.title,
4800
- accepts,
4801
- autoComplete: "off",
4802
- checks: schema.hidden ? [] : checks,
4803
- fileChecks: schema.hidden ? [] : fileChecks,
4804
- format,
4805
- maxSize,
4806
- minItems,
4807
- maxItems,
4808
- required,
4809
- source: uploadSchema.source,
4810
- value,
4811
- persistedState,
4812
- performPersistAsync,
4813
- onValueChange
4814
- }),
4815
- mapperProps.updateComponent
4816
- );
4817
- };
4818
- var getFormat = (schema) => {
4819
- if (isStringSchemaWithUpload(schema)) {
4820
- return "base64";
4821
- }
4822
- return isBlobSchema(schema.persistAsync.schema) ? "blob" : "base64";
4823
4733
  };
4824
- var getUploadSchema = (schema) => {
4825
- if (isStringSchemaWithUpload(schema)) {
4826
- return schema;
4734
+
4735
+ // src/revamp/domain/components/utils/isPartialModelMatch.ts
4736
+ var isPartialModelMatch = (localModel, incomingModel) => {
4737
+ if (isArrayModel(localModel) && isArrayModel(incomingModel)) {
4738
+ return localModel.length === incomingModel.length && localModel.every((value, index) => isPartialModelMatch(value, incomingModel[index]));
4827
4739
  }
4828
- return schema.persistAsync.schema;
4829
- };
4830
- var getPersistAsyncConfig = (schema) => {
4831
- if (!isSchemaWithPersistAsync(schema)) {
4832
- return void 0;
4740
+ if (isObjectModel(localModel) && isObjectModel(incomingModel)) {
4741
+ if (Object.keys(localModel).length === 0 && Object.keys(incomingModel).length === 0) {
4742
+ return true;
4743
+ }
4744
+ const nonNullishKeysInBoth = nonNullishKeys(localModel).filter(
4745
+ (key) => nonNullishKeys(incomingModel).includes(key)
4746
+ );
4747
+ return nonNullishKeysInBoth.length > 0 && nonNullishKeysInBoth.every((key) => isPartialModelMatch(localModel[key], incomingModel[key]));
4833
4748
  }
4834
- const { persistAsync } = schema;
4835
- const { idProperty, method, param, url } = persistAsync;
4836
- return { idProperty, method, param, url };
4749
+ return localModel === incomingModel;
4837
4750
  };
4838
- var getValueForPersistAsync = (localValue) => isArray(localValue) && localValue.every(isFile) ? localValue : [];
4751
+ var nonNullishKeys = (model) => Object.keys(model).filter((key) => !isNullish(model[key]));
4839
4752
 
4840
- // src/revamp/domain/components/MultiSelectInputComponent.ts
4841
- var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
4842
- const _a = multiSelectProps, {
4843
- uid,
4844
- checks,
4845
- options,
4846
- initialValue,
4847
- performValidationAsync,
4848
- performRefresh,
4849
- onValueChange
4850
- } = _a, rest = __objRest(_a, [
4851
- "uid",
4852
- "checks",
4853
- "options",
4854
- "initialValue",
4855
- "performValidationAsync",
4856
- "performRefresh",
4857
- "onValueChange"
4858
- ]);
4859
- const update = getInputUpdateFunction(updateComponent);
4753
+ // src/revamp/domain/components/SelectInputComponent.ts
4754
+ var createSelectInputComponent = (selectProps, updateComponent) => {
4755
+ const _a = selectProps, { uid, checks, initialModel, options, performRefresh, onValueChange, summariser } = _a, rest = __objRest(_a, ["uid", "checks", "initialModel", "options", "performRefresh", "onValueChange", "summariser"]);
4860
4756
  const children = options.map((option) => option.component);
4861
- const selectedIndices = getInitialModelIndices(initialValue, children);
4757
+ const matchingOptions = options.map(
4758
+ (option) => isPartialModelMatch(option.component.getSubmittableValueSync(), initialModel)
4759
+ );
4760
+ const selectedIndex = matchingOptions.filter((match) => match).length === 1 ? matchingOptions.indexOf(true) : null;
4761
+ const update = getInputUpdateFunction(updateComponent);
4862
4762
  const getValidationErrors = getLocalValueValidator(checks);
4863
- const inputComponent = __spreadProps(__spreadValues({
4763
+ const component = __spreadProps(__spreadValues({
4864
4764
  uid,
4865
- type: "multi-select",
4765
+ type: "select",
4866
4766
  children,
4867
4767
  options,
4868
- selectedIndices,
4768
+ selectedIndex,
4869
4769
  value: null
4870
4770
  }, rest), {
4871
4771
  _update(updateFn) {
4872
4772
  update(this, updateFn);
4873
4773
  },
4874
- onSelect(indices) {
4875
- this._update((draft) => {
4876
- draft.selectedIndices = indices;
4877
- draft.errors = [];
4878
- });
4879
- performRefresh == null ? void 0 : performRefresh();
4880
- onValueChange();
4881
- const errors = getValidationErrors(this.getLocalValue());
4882
- this._update((draft) => {
4883
- draft.errors = errors;
4884
- });
4885
- },
4886
- onBlur() {
4774
+ getChildren() {
4775
+ return this.children;
4887
4776
  },
4888
- // Noop
4889
- onFocus() {
4777
+ getSelectedChild() {
4778
+ return this.selectedIndex !== null ? this.children[this.selectedIndex] : null;
4890
4779
  },
4891
- // Noop
4892
- getLocalValue() {
4780
+ async getSubmittableValue() {
4893
4781
  var _a2, _b;
4894
- return (_b = (_a2 = this.getSelectedChildren()) == null ? void 0 : _a2.map((child) => child.getLocalValue())) != null ? _b : null;
4782
+ return (_b = await ((_a2 = this.getSelectedChild()) == null ? void 0 : _a2.getSubmittableValue())) != null ? _b : null;
4895
4783
  },
4896
- validate() {
4897
- const errors = getValidationErrors(this.getLocalValue());
4898
- this._update((draft) => {
4899
- draft.errors = errors;
4900
- });
4901
- return errors.length === 0;
4784
+ getSubmittableValueSync() {
4785
+ var _a2, _b;
4786
+ return (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.getSubmittableValueSync()) != null ? _b : null;
4902
4787
  },
4903
- async getSubmittableValue() {
4904
- const selected = this.getSelectedChildren();
4905
- if (selected) {
4906
- return Promise.all(selected.map(async (child) => child.getSubmittableValue()));
4907
- }
4908
- return null;
4788
+ getSummary() {
4789
+ var _a2, _b;
4790
+ return (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.getSummary()) != null ? _b : {};
4909
4791
  },
4910
- getSubmittableValueSync() {
4792
+ getLocalValue() {
4911
4793
  var _a2, _b;
4912
- return (_b = (_a2 = this.getSelectedChildren()) == null ? void 0 : _a2.map((child) => child.getSubmittableValueSync())) != null ? _b : null;
4794
+ return (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.getLocalValue()) != null ? _b : null;
4913
4795
  },
4914
- getSummary: () => ({}),
4915
- getChildren() {
4916
- return this.children;
4796
+ onBlur() {
4797
+ this.validate();
4917
4798
  },
4918
- getSelectedChildren() {
4919
- return this.selectedIndices.map((i) => this.children[i]);
4920
- }
4921
- });
4922
- if (performRefresh) {
4923
- return inputComponent;
4924
- }
4925
- if (performValidationAsync) {
4926
- const validateAsync = getComponentValidationAsync(update, performValidationAsync);
4927
- return __spreadProps(__spreadValues({}, inputComponent), {
4928
- onSelect(indices) {
4929
- inputComponent.onSelect.call(this, indices);
4930
- if (this.validate()) {
4931
- validateAsync(this, this.getLocalValue()).catch(() => {
4932
- });
4933
- }
4799
+ onFocus() {
4800
+ },
4801
+ // noop
4802
+ onSelect(updatedIndex) {
4803
+ if (updatedIndex === this.selectedIndex) {
4804
+ return;
4934
4805
  }
4935
- });
4936
- }
4937
- return inputComponent;
4938
- };
4939
- var getInitialModelIndices = (model, options) => {
4940
- if (!isArray(model)) {
4941
- return [];
4942
- }
4943
- return model.map((m) => options.findIndex((o) => o.getLocalValue() === m)).filter((n) => n >= 0);
4806
+ if (updatedIndex !== null && this.analyticsId) {
4807
+ selectProps.trackEvent("OneOf Selected", {
4808
+ oneOfId: this.analyticsId,
4809
+ schemaId: this.children[updatedIndex].analyticsId
4810
+ });
4811
+ }
4812
+ this._update((draft) => {
4813
+ draft.errors = [];
4814
+ draft.selectedIndex = updatedIndex;
4815
+ });
4816
+ performRefresh == null ? void 0 : performRefresh();
4817
+ onValueChange();
4818
+ },
4819
+ validate() {
4820
+ var _a2, _b;
4821
+ const validChild = (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.validate()) != null ? _b : true;
4822
+ const errors = getValidationErrors(this.getLocalValue());
4823
+ this._update((draft) => {
4824
+ draft.errors = errors;
4825
+ });
4826
+ return errors.length === 0 && validChild;
4827
+ }
4828
+ });
4829
+ return component;
4944
4830
  };
4945
4831
 
4946
- // src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToMultiSelectComponent.ts
4947
- var arraySchemaToMultiSelectComponent = (schemaMapperProps, mapperProps) => {
4832
+ // src/revamp/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.ts
4833
+ var oneOfSchemaToComponent = (schemaMapperProps, mapperProps) => {
4834
+ var _a;
4948
4835
  const {
4949
4836
  uid,
4950
4837
  localValue,
4951
4838
  schema,
4952
4839
  model,
4953
- required = false,
4954
- validationErrors: initialError
4840
+ validationErrors: initialError,
4841
+ required = false
4955
4842
  } = schemaMapperProps;
4956
- const initialModel = model != null ? model : null;
4957
- const options = schema.items.oneOf.map((childSchema, index) => {
4958
- const { title: title2 = "", description, image, icon, keywords = [] } = childSchema;
4843
+ const initialModel = (_a = model != null ? model : schema.default) != null ? _a : null;
4844
+ if (schema.oneOf.length === 1 && isFormSectionSchema(schema.oneOf[0])) {
4845
+ return mapSchemaToComponent(
4846
+ {
4847
+ uid,
4848
+ schema: supressSchemaTitleAndDescription(schema.oneOf[0]),
4849
+ model: initialModel,
4850
+ localValue,
4851
+ validationErrors: initialError,
4852
+ required
4853
+ },
4854
+ mapperProps
4855
+ );
4856
+ }
4857
+ const options = schema.oneOf.map((childSchema, index) => {
4858
+ const { title = "", description, image, icon, keywords = [] } = childSchema;
4959
4859
  return {
4960
- title: title2,
4860
+ title,
4961
4861
  description,
4962
4862
  image: mapSpecImage(image),
4963
4863
  icon,
@@ -4966,7 +4866,7 @@ var arraySchemaToMultiSelectComponent = (schemaMapperProps, mapperProps) => {
4966
4866
  component: mapSchemaToComponent(
4967
4867
  {
4968
4868
  uid: `${uid}.oneOf-${index}`,
4969
- schema: childSchema,
4869
+ schema: isFormSectionSchema(childSchema) ? supressSchemaTitleAndDescription(childSchema) : childSchema,
4970
4870
  model: initialModel,
4971
4871
  localValue,
4972
4872
  validationErrors: initialError,
@@ -4976,188 +4876,278 @@ var arraySchemaToMultiSelectComponent = (schemaMapperProps, mapperProps) => {
4976
4876
  )
4977
4877
  };
4978
4878
  });
4979
- const { maxItems, minItems, title, validationMessages } = schema;
4980
- const { getErrorMessageFunctions, onRefresh, onValueChange, updateComponent } = mapperProps;
4879
+ const { getErrorMessageFunctions, updateComponent, trackEvent, onRefresh, onValueChange } = mapperProps;
4880
+ const { validationMessages } = schema;
4981
4881
  const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
4982
- const { performValidationAsync, validationAsyncState } = getValidationAsyncInitialState(
4983
- schemaMapperProps,
4984
- mapperProps
4985
- );
4986
- const initialValue = model != null ? model : null;
4987
- return createMultiSelectComponent(
4882
+ return createSelectInputComponent(
4988
4883
  __spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
4989
- autoComplete: "off",
4990
- checks: schema.hidden ? [] : [
4991
- getRequiredCheck(required, errorMessageFunctions),
4992
- getAboveMaxItemsCheck(schema, errorMessageFunctions),
4993
- getBelowMinItemsCheck(schema, errorMessageFunctions)
4994
- ],
4995
- initialValue,
4996
- maxItems,
4997
- minItems,
4884
+ autoComplete: getAutocompleteString(schema.autocompleteHint),
4885
+ checks: schema.hidden ? [] : [getRequiredCheck(required, errorMessageFunctions)],
4998
4886
  options,
4999
- required,
5000
- title,
5001
- validationAsyncState,
5002
- performValidationAsync,
4887
+ initialModel,
5003
4888
  performRefresh: getPerformRefresh(schema, onRefresh),
5004
- onValueChange
4889
+ onValueChange,
4890
+ trackEvent
5005
4891
  }),
5006
4892
  updateComponent
5007
4893
  );
5008
4894
  };
4895
+ var isFormSectionSchema = (schema) => isObjectSchema(schema) || isArrayTupleSchema(schema) || isAllOfSchema(schema);
4896
+ var supressSchemaTitleAndDescription = (schema) => {
4897
+ const _a = schema, { title, description } = _a, headlessSchema = __objRest(_a, ["title", "description"]);
4898
+ return headlessSchema;
4899
+ };
5009
4900
 
5010
- // src/revamp/domain/components/TupleComponent.ts
5011
- var createTupleComponent = (tupleProps) => {
5012
- const {
4901
+ // src/revamp/domain/components/DateInputComponent.ts
4902
+ var createDateInputComponent = (textInputProps, updateComponent) => {
4903
+ const _a = textInputProps, {
5013
4904
  uid,
5014
- analyticsId,
5015
- components,
5016
- control,
5017
- description,
5018
- help,
5019
- hidden,
5020
- icon,
5021
- image,
4905
+ id,
4906
+ checks,
4907
+ performPersistAsync,
4908
+ performRefresh,
4909
+ performValidationAsync,
4910
+ onValueChange,
5022
4911
  summariser,
5023
- title
5024
- } = tupleProps;
5025
- return {
5026
- type: "tuple",
4912
+ value
4913
+ } = _a, rest = __objRest(_a, [
4914
+ "uid",
4915
+ "id",
4916
+ "checks",
4917
+ "performPersistAsync",
4918
+ "performRefresh",
4919
+ "performValidationAsync",
4920
+ "onValueChange",
4921
+ "summariser",
4922
+ "value"
4923
+ ]);
4924
+ const update = getInputUpdateFunction(updateComponent);
4925
+ const getValidationErrors = getLocalValueValidator(checks);
4926
+ const dateInputComponent = __spreadValues({
4927
+ type: "date",
5027
4928
  uid,
5028
- analyticsId,
5029
- components,
5030
- control,
5031
- description,
5032
- help,
5033
- hidden,
5034
- icon,
5035
- image,
5036
- title,
5037
- getChildren() {
5038
- return this.components;
4929
+ id,
4930
+ value,
4931
+ _update(updateFn) {
4932
+ update(this, updateFn);
4933
+ },
4934
+ onBlur() {
4935
+ this.validate();
4936
+ },
4937
+ onFocus() {
4938
+ },
4939
+ // Noop
4940
+ onChange(updatedValue) {
4941
+ const prevValue = this.value;
4942
+ this._update((draft) => {
4943
+ draft.errors = [];
4944
+ draft.validationAsyncState.messages = {};
4945
+ draft.value = updatedValue;
4946
+ });
4947
+ if (isOrWasValid(getValidationErrors, prevValue, updatedValue)) {
4948
+ performRefresh == null ? void 0 : performRefresh();
4949
+ }
4950
+ onValueChange();
5039
4951
  },
5040
4952
  async getSubmittableValue() {
5041
- return Promise.all(this.components.map(async (child) => child.getSubmittableValue()));
4953
+ return this.getSubmittableValueSync();
5042
4954
  },
5043
4955
  getSubmittableValueSync() {
5044
- return this.components.map((child) => child.getSubmittableValueSync());
4956
+ var _a2;
4957
+ return (_a2 = this.getLocalValue()) != null ? _a2 : null;
5045
4958
  },
5046
4959
  getSummary() {
5047
- const summary = summariser(this.getLocalValue());
5048
- const childSummary = summariseFromChildren(this.getChildren());
5049
- return mergeSummaries(summary, childSummary);
4960
+ return summariser(this.getLocalValue());
5050
4961
  },
5051
4962
  getLocalValue() {
5052
- return this.components.map((child) => child.getLocalValue());
4963
+ return this.value;
5053
4964
  },
5054
4965
  validate() {
5055
- return hidden ? true : validateComponents(this.getChildren());
4966
+ const errors = getValidationErrors(this.getLocalValue());
4967
+ this._update((draft) => {
4968
+ draft.errors = errors;
4969
+ });
4970
+ return errors.length === 0;
5056
4971
  }
5057
- };
4972
+ }, rest);
4973
+ if (performRefresh) {
4974
+ return dateInputComponent;
4975
+ }
4976
+ if (performPersistAsync) {
4977
+ const persist = getComponentPersistAsync(update, performPersistAsync);
4978
+ return __spreadProps(__spreadValues({}, dateInputComponent), {
4979
+ onChange(updatedValue) {
4980
+ dateInputComponent.onChange.call(this, updatedValue);
4981
+ const isValid = getValidationErrors(updatedValue).length === 0;
4982
+ if (isValid) {
4983
+ persist(this, this.getLocalValue()).catch(() => {
4984
+ });
4985
+ }
4986
+ },
4987
+ async getSubmittableValue() {
4988
+ return persist(this, this.getLocalValue());
4989
+ },
4990
+ getSubmittableValueSync() {
4991
+ return this.persistedState.lastResponse;
4992
+ }
4993
+ });
4994
+ }
4995
+ if (performValidationAsync) {
4996
+ const validateAsync = getComponentValidationAsync(update, performValidationAsync);
4997
+ return __spreadProps(__spreadValues({}, dateInputComponent), {
4998
+ onBlur() {
4999
+ if (this.validate()) {
5000
+ validateAsync(this, this.getLocalValue()).catch(() => {
5001
+ });
5002
+ }
5003
+ }
5004
+ });
5005
+ }
5006
+ return dateInputComponent;
5058
5007
  };
5059
5008
 
5060
- // src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToTupleComponent.ts
5061
- var arraySchemaToTupleComponent = (schemaMapperProps, mapperProps) => {
5009
+ // src/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToDateInputComponent.ts
5010
+ var stringSchemaToDateInputComponent = (schemaMapperProps, mapperProps) => {
5011
+ const { schema, localValue, model, required = false } = schemaMapperProps;
5062
5012
  const {
5063
- uid,
5064
- localValue,
5065
- schema,
5066
- model: initialModel,
5067
- required = false,
5068
- validationErrors
5069
- } = schemaMapperProps;
5070
- const { items } = schema;
5071
- const components = items.map(
5072
- (childSchema, index) => {
5073
- var _a, _b;
5074
- return mapSchemaToComponent(
5075
- {
5076
- uid: `${uid}-arr.${index}`,
5077
- schema: childSchema,
5078
- model: isArray(initialModel) ? (_a = initialModel[index]) != null ? _a : null : null,
5079
- localValue: isArray(localValue) ? (_b = localValue[index]) != null ? _b : null : null,
5080
- validationErrors: isArray(validationErrors) ? validationErrors[index] : void 0,
5081
- required
5082
- },
5083
- mapperProps
5084
- );
5085
- }
5013
+ autocompleteHint,
5014
+ default: defaultValue,
5015
+ minimum: minimumDate,
5016
+ maximum: maximumDate,
5017
+ suggestions
5018
+ } = schema;
5019
+ const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange } = mapperProps;
5020
+ const errorMessageFunctions = getErrorMessageFunctions(schema.validationMessages);
5021
+ const { performPersistAsync, persistedState } = getPersistAsyncInitialState(
5022
+ schemaMapperProps,
5023
+ mapperProps
5024
+ );
5025
+ const { performValidationAsync, validationAsyncState } = getValidationAsyncInitialState(
5026
+ schemaMapperProps,
5027
+ mapperProps
5028
+ );
5029
+ const validLocalValue = isString(localValue) ? localValue : null;
5030
+ const validModel = isString(model) ? model : defaultValue != null ? defaultValue : null;
5031
+ const value = performPersistAsync ? validLocalValue : validModel;
5032
+ return createDateInputComponent(
5033
+ __spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
5034
+ autoComplete: getAutocompleteString(autocompleteHint),
5035
+ checks: schema.hidden ? [] : [
5036
+ getRequiredCheck(required, errorMessageFunctions),
5037
+ getAboveMaximumDateCheck(schema, errorMessageFunctions),
5038
+ getBelowMinimumDateCheck(schema, errorMessageFunctions)
5039
+ ],
5040
+ minimumDate,
5041
+ maximumDate,
5042
+ suggestions: suggestions ? {
5043
+ values: suggestions.values.map((suggestion) => __spreadProps(__spreadValues({}, suggestion), {
5044
+ image: mapSpecImage(suggestion.image)
5045
+ }))
5046
+ } : void 0,
5047
+ value,
5048
+ persistedState,
5049
+ validationAsyncState,
5050
+ performPersistAsync,
5051
+ performRefresh: getPerformRefresh(schema, onRefresh),
5052
+ performValidationAsync,
5053
+ onValueChange
5054
+ }),
5055
+ updateComponent
5086
5056
  );
5087
- return createTupleComponent(__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
5088
- components
5089
- }));
5090
5057
  };
5091
5058
 
5092
- // src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToComponent.ts
5093
- var arraySchemaToComponent = (schemaMapperProps, mapperProps) => {
5094
- const { schema, model: originalModel } = schemaMapperProps;
5095
- const model = isNullish(originalModel) || isArrayModel(originalModel) ? originalModel : null;
5096
- if (isArraySchemaListWithMultiFileUpload(schema)) {
5097
- return arraySchemaToMultiUploadComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
5098
- }
5099
- if (isArraySchemaListWithMultiSelect(schema)) {
5100
- return arraySchemaToMultiSelectComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
5101
- }
5102
- if (isArrayTupleSchema(schema)) {
5103
- return arraySchemaToTupleComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
5104
- }
5105
- return arraySchemaToRepeatableComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
5059
+ // src/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToUploadInputComponent.ts
5060
+ var stringSchemaToUploadInputComponent = (schemaMapperProps, mapperProps) => {
5061
+ var _a;
5062
+ const { schema, localValue, model, required = false } = schemaMapperProps;
5063
+ const { accepts, autocompleteHint, cameraConfig, hidden, maxSize, source, validationMessages } = schema;
5064
+ const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange } = mapperProps;
5065
+ const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
5066
+ const { performPersistAsync } = getPersistAsyncInitialState(schemaMapperProps, mapperProps);
5067
+ const persistedState = performPersistAsync ? getInitialPersistedState(null, model) : getInitialPersistedState();
5068
+ const validLocalValue = isFile(localValue) ? localValue : null;
5069
+ const value = (_a = getFileFromModel(model)) != null ? _a : validLocalValue;
5070
+ const checks = hidden ? [] : [
5071
+ getRequiredCheck(required, errorMessageFunctions),
5072
+ getFileSizeCheck(schema, errorMessageFunctions),
5073
+ getFileTypeCheck(schema, errorMessageFunctions)
5074
+ ];
5075
+ return createUploadInputComponent(
5076
+ __spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
5077
+ accepts,
5078
+ autoComplete: getAutocompleteString(autocompleteHint),
5079
+ cameraConfig,
5080
+ checks,
5081
+ format: "base64",
5082
+ maxSize,
5083
+ source,
5084
+ value,
5085
+ persistedState,
5086
+ performPersistAsync,
5087
+ performRefresh: getPerformRefresh(schema, onRefresh),
5088
+ onValueChange
5089
+ }),
5090
+ updateComponent
5091
+ );
5106
5092
  };
5107
- var isArraySchemaListWithMultiFileUpload = (schema) => isArrayListSchema(schema) && (isPersistAsyncWithUploadSchema(schema.items) || isStringSchemaWithUpload(schema.items));
5108
- var isPersistAsyncWithUploadSchema = (schema) => isSchemaWithPersistAsync(schema) && (isBlobSchema(schema.persistAsync.schema) || isStringSchemaWithUpload(schema.persistAsync.schema));
5109
- var isArraySchemaListWithMultiSelect = (schema) => isArrayListSchema(schema) && "oneOf" in schema.items && schema.items.oneOf.every(isConstSchema);
5093
+ var getFileFromModel = (model) => isString(model) ? base64dataUrltoFile(model, "") : null;
5110
5094
 
5111
- // src/revamp/domain/components/BooleanInputComponent.ts
5112
- var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
5113
- const _a = booleanInputProps, {
5095
+ // src/revamp/domain/components/TextInputComponent.ts
5096
+ var createTextInputComponent = (textInputProps, updateComponent) => {
5097
+ const _a = textInputProps, {
5114
5098
  uid,
5115
5099
  id,
5116
- value,
5100
+ checks,
5117
5101
  performPersistAsync,
5118
5102
  performRefresh,
5119
5103
  performValidationAsync,
5120
5104
  onValueChange,
5121
- summariser
5105
+ summariser,
5106
+ value
5122
5107
  } = _a, rest = __objRest(_a, [
5123
5108
  "uid",
5124
5109
  "id",
5125
- "value",
5110
+ "checks",
5126
5111
  "performPersistAsync",
5127
5112
  "performRefresh",
5128
5113
  "performValidationAsync",
5129
5114
  "onValueChange",
5130
- "summariser"
5115
+ "summariser",
5116
+ "value"
5131
5117
  ]);
5132
5118
  const update = getInputUpdateFunction(updateComponent);
5133
- const booleanComponent = __spreadValues({
5134
- type: "boolean",
5119
+ const getValidationErrors = getLocalValueValidator(checks);
5120
+ const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh, getValidationErrors);
5121
+ const inputComponent = __spreadValues({
5122
+ type: "text",
5135
5123
  uid,
5136
5124
  id,
5137
- autoComplete: "",
5138
5125
  value,
5139
5126
  _update(updateFn) {
5140
5127
  update(this, updateFn);
5141
5128
  },
5142
5129
  onBlur() {
5130
+ this.validate();
5131
+ performDebouncedRefresh == null ? void 0 : performDebouncedRefresh.flush();
5143
5132
  },
5144
- // Noop
5145
5133
  onFocus() {
5146
5134
  },
5147
5135
  // Noop
5148
5136
  onChange(updatedValue) {
5137
+ const prevValue = this.value;
5149
5138
  this._update((draft) => {
5150
5139
  draft.errors = [];
5140
+ draft.validationAsyncState.messages = {};
5151
5141
  draft.value = updatedValue;
5152
5142
  });
5153
- performRefresh == null ? void 0 : performRefresh();
5143
+ performDebouncedRefresh == null ? void 0 : performDebouncedRefresh(prevValue, updatedValue);
5154
5144
  onValueChange();
5155
5145
  },
5156
5146
  async getSubmittableValue() {
5157
5147
  return this.getSubmittableValueSync();
5158
5148
  },
5159
5149
  getSubmittableValueSync() {
5160
- return this.getLocalValue();
5150
+ return this.getLocalValue() || null;
5161
5151
  },
5162
5152
  getSummary() {
5163
5153
  return summariser(this.getLocalValue());
@@ -5165,18 +5155,25 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
5165
5155
  getLocalValue() {
5166
5156
  return this.value;
5167
5157
  },
5168
- validate: () => true
5158
+ validate() {
5159
+ const errors = getValidationErrors(this.getLocalValue());
5160
+ this._update((draft) => {
5161
+ draft.errors = errors;
5162
+ });
5163
+ return errors.length === 0;
5164
+ }
5169
5165
  }, rest);
5170
5166
  if (performRefresh) {
5171
- return booleanComponent;
5167
+ return inputComponent;
5172
5168
  }
5173
5169
  if (performPersistAsync) {
5174
5170
  const persist = getComponentPersistAsync(update, performPersistAsync);
5175
- return __spreadProps(__spreadValues({}, booleanComponent), {
5176
- onChange(updatedValue) {
5177
- booleanComponent.onChange.call(this, updatedValue);
5178
- persist(this, this.getLocalValue()).catch(() => {
5179
- });
5171
+ return __spreadProps(__spreadValues({}, inputComponent), {
5172
+ onBlur() {
5173
+ if (this.validate()) {
5174
+ persist(this, this.getLocalValue()).catch(() => {
5175
+ });
5176
+ }
5180
5177
  },
5181
5178
  async getSubmittableValue() {
5182
5179
  return persist(this, this.getLocalValue());
@@ -5187,24 +5184,45 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
5187
5184
  });
5188
5185
  }
5189
5186
  if (performValidationAsync) {
5190
- const validateAsync = getComponentValidationAsync(update, performValidationAsync);
5191
- return __spreadProps(__spreadValues({}, booleanComponent), {
5187
+ const validateAsync = getDebouncedComponentValidationAsync(update, performValidationAsync);
5188
+ return __spreadProps(__spreadValues({}, inputComponent), {
5189
+ onBlur() {
5190
+ if (this.validate()) {
5191
+ validateAsync.flush();
5192
+ }
5193
+ },
5192
5194
  onChange(updatedValue) {
5193
- booleanComponent.onChange.call(this, updatedValue);
5194
- validateAsync(this, this.getLocalValue()).catch(() => {
5195
- });
5195
+ inputComponent.onChange.call(this, updatedValue);
5196
+ if (getValidationErrors(updatedValue).length === 0) {
5197
+ validateAsync(this, updatedValue);
5198
+ }
5199
+ if (!updatedValue) {
5200
+ validateAsync.cancel();
5201
+ }
5196
5202
  }
5197
5203
  });
5198
5204
  }
5199
- return booleanComponent;
5205
+ return inputComponent;
5200
5206
  };
5201
5207
 
5202
- // src/revamp/domain/mappers/schema/booleanSchemaToComponent.ts
5203
- var booleanSchemaToComponent = (schemaMapperProps, mapperProps) => {
5204
- const { schema, localValue, model } = schemaMapperProps;
5205
- const { default: defaultValue } = schema;
5206
- const { updateComponent, onRefresh, onValueChange } = mapperProps;
5207
- const performRefresh = getPerformRefresh(schema, onRefresh);
5208
+ // src/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToTextInputComponent.ts
5209
+ var stringSchemaToTextInputComponent = (schemaMapperProps, mapperProps) => {
5210
+ const { schema, localValue, model, required = false } = schemaMapperProps;
5211
+ const {
5212
+ autocapitalization,
5213
+ autocompleteHint,
5214
+ control,
5215
+ default: defaultValue,
5216
+ displayFormat,
5217
+ format,
5218
+ maxLength,
5219
+ minLength,
5220
+ suggestions,
5221
+ validationMessages
5222
+ } = schema;
5223
+ const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange, logEvent } = mapperProps;
5224
+ const controlForLegacyFormat = getControlForLegacyFormat(format);
5225
+ const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
5208
5226
  const { performPersistAsync, persistedState } = getPersistAsyncInitialState(
5209
5227
  schemaMapperProps,
5210
5228
  mapperProps
@@ -5213,76 +5231,65 @@ var booleanSchemaToComponent = (schemaMapperProps, mapperProps) => {
5213
5231
  schemaMapperProps,
5214
5232
  mapperProps
5215
5233
  );
5216
- const validLocalValue = isBoolean(localValue) ? localValue : false;
5217
- const validModel = getValidModel(model, defaultValue);
5234
+ const validLocalValue = isString(localValue) ? localValue : null;
5235
+ const validModel = isString(model) ? model : defaultValue != null ? defaultValue : null;
5218
5236
  const value = performPersistAsync ? validLocalValue : validModel;
5219
- return createBooleanInputComponent(
5237
+ return createTextInputComponent(
5220
5238
  __spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
5221
- value: value != null ? value : false,
5239
+ autocapitalization,
5240
+ autoComplete: getAutocompleteString(autocompleteHint),
5241
+ checks: schema.hidden ? [] : [
5242
+ getRequiredCheck(required, errorMessageFunctions),
5243
+ getAboveMaxLengthCheck(schema, errorMessageFunctions),
5244
+ getBelowMinLengthCheck(schema, errorMessageFunctions),
5245
+ getNotAdheringToPatternCheck(schema, errorMessageFunctions, { logEvent })
5246
+ ],
5247
+ control: control != null ? control : controlForLegacyFormat,
5248
+ displayFormat,
5249
+ maxLength,
5250
+ minLength,
5251
+ suggestions: suggestions ? {
5252
+ values: suggestions.values.map((suggestion) => __spreadProps(__spreadValues({}, suggestion), {
5253
+ image: mapSpecImage(suggestion.image)
5254
+ }))
5255
+ } : void 0,
5256
+ value,
5222
5257
  persistedState,
5223
5258
  validationAsyncState,
5224
5259
  performPersistAsync,
5225
- performRefresh,
5260
+ performRefresh: getPerformRefresh(schema, onRefresh),
5226
5261
  performValidationAsync,
5227
5262
  onValueChange
5228
5263
  }),
5229
5264
  updateComponent
5230
5265
  );
5231
5266
  };
5232
- var getValidModel = (model, defaultValue) => {
5233
- if (isBoolean(model)) {
5234
- return model;
5235
- }
5236
- if (isBoolean(defaultValue)) {
5237
- return defaultValue;
5267
+ var getControlForLegacyFormat = (format) => {
5268
+ if (format && ["numeric", "phone-number", "email", "password"].includes(format)) {
5269
+ return format;
5238
5270
  }
5239
- return false;
5271
+ return void 0;
5240
5272
  };
5241
5273
 
5242
- // src/revamp/domain/mappers/schema/blobSchemaToComponent.ts
5243
- var blobSchemaToComponent = (schemaMapperProps, mapperProps) => {
5244
- const { schema, localValue, model, required = false } = schemaMapperProps;
5245
- const { accepts, cameraConfig, maxSize, source, validationMessages } = schema;
5246
- const { getErrorMessageFunctions, updateComponent, onValueChange } = mapperProps;
5247
- const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
5248
- const { performPersistAsync } = getPersistAsyncInitialState(schemaMapperProps, mapperProps);
5249
- const persistedState = performPersistAsync ? getInitialPersistedState(null, model) : getInitialPersistedState();
5250
- const validLocalValue = isFile(localValue) ? localValue : null;
5251
- const value = performPersistAsync ? validLocalValue : null;
5252
- return createUploadInputComponent(
5253
- __spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
5254
- accepts,
5255
- autoComplete: "off",
5256
- cameraConfig,
5257
- format: "blob",
5258
- maxSize,
5259
- source,
5260
- value,
5261
- persistedState,
5262
- performPersistAsync,
5263
- checks: schema.hidden ? [] : [getRequiredCheck(required, errorMessageFunctions)],
5264
- onValueChange
5265
- }),
5266
- updateComponent
5267
- );
5274
+ // src/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToComponent.ts
5275
+ var stringSchemaToComponent = (schemaMapperProps, mapperProps) => {
5276
+ const { schema } = schemaMapperProps;
5277
+ if (isStringSchemaWithBase64(schema)) {
5278
+ return stringSchemaToUploadInputComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema }), mapperProps);
5279
+ }
5280
+ switch (schema.format) {
5281
+ case "date":
5282
+ return stringSchemaToDateInputComponent(schemaMapperProps, mapperProps);
5283
+ default:
5284
+ return stringSchemaToTextInputComponent(schemaMapperProps, mapperProps);
5285
+ }
5286
+ };
5287
+ var isStringSchemaWithBase64 = (schema) => {
5288
+ return schema.format === "base64url" && !("persistAsync" in schema);
5268
5289
  };
5269
5290
 
5270
5291
  // src/revamp/domain/mappers/mapSchemaToComponent.ts
5271
5292
  var mapSchemaToComponent = (schemaMapperProps, mapperProps) => {
5272
- const { uid, schema } = schemaMapperProps;
5273
- const { alert } = schema;
5274
- if (alert) {
5275
- return createContainerComponent({
5276
- uid,
5277
- components: [
5278
- alertLayoutToComponent(`${uid}.container.alert`, alert, mapperProps),
5279
- getSchemaComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { uid: `${uid}.container` }), mapperProps)
5280
- ]
5281
- });
5282
- }
5283
- return getSchemaComponent(schemaMapperProps, mapperProps);
5284
- };
5285
- var getSchemaComponent = (schemaMapperProps, mapperProps) => {
5286
5293
  const { uid, schema } = schemaMapperProps;
5287
5294
  if (isConstSchema(schema)) {
5288
5295
  return constSchemaToComponent(uid, __spreadProps(__spreadValues({}, schemaMapperProps), { schema }));