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