@wise/dynamic-flow-client 4.5.1 → 4.5.3-experimental-sca-error-handling-8133bb0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/main.js +1368 -1361
- package/build/main.mjs +1400 -1393
- package/build/types/index.d.ts +1 -1
- package/build/types/revamp/domain/components/AllOfComponent.d.ts +3 -2
- package/build/types/revamp/domain/components/BooleanInputComponent.d.ts +1 -1
- package/build/types/revamp/domain/components/DateInputComponent.d.ts +1 -1
- package/build/types/revamp/domain/components/IntegerInputComponent.d.ts +1 -1
- package/build/types/revamp/domain/components/MultiSelectInputComponent.d.ts +1 -1
- package/build/types/revamp/domain/components/MultiUploadInputComponent.d.ts +1 -1
- package/build/types/revamp/domain/components/NumberInputComponent.d.ts +1 -1
- package/build/types/revamp/domain/components/ObjectComponent.d.ts +3 -2
- package/build/types/revamp/domain/components/RepeatableComponent.d.ts +3 -2
- package/build/types/revamp/domain/components/SelectInputComponent.d.ts +1 -1
- package/build/types/revamp/domain/components/TextInputComponent.d.ts +1 -1
- package/build/types/revamp/domain/components/TupleComponent.d.ts +3 -2
- package/build/types/revamp/domain/components/UploadInputComponent.d.ts +1 -1
- package/build/types/revamp/domain/mappers/schema/constSchemaToComponent.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 +2 -1
- package/build/types/revamp/renderers/mappers/allOfComponentToProps.d.ts +2 -2
- package/build/types/revamp/renderers/mappers/componentToRendererProps.d.ts +1 -1
- package/build/types/revamp/renderers/mappers/objectComponentToProps.d.ts +2 -2
- package/build/types/revamp/renderers/mappers/tupleComponentToProps.d.ts +2 -2
- package/package.json +6 -6
package/build/main.mjs
CHANGED
|
@@ -1003,6 +1003,11 @@ var ErrorBoundary = class extends Component {
|
|
|
1003
1003
|
};
|
|
1004
1004
|
var ErrorBoundary_default = ErrorBoundary;
|
|
1005
1005
|
|
|
1006
|
+
// src/revamp/flow/getErrorMessage.ts
|
|
1007
|
+
var getErrorMessage = (error) => {
|
|
1008
|
+
return error instanceof Error ? error.message : typeof error === "string" ? error : `Unknown Error: type is ${typeof error}`;
|
|
1009
|
+
};
|
|
1010
|
+
|
|
1006
1011
|
// src/revamp/renderers/CoreContainerRenderer.tsx
|
|
1007
1012
|
import { Fragment as Fragment2, jsx as jsx3 } from "react/jsx-runtime";
|
|
1008
1013
|
var CoreContainerRenderer = {
|
|
@@ -1039,7 +1044,7 @@ function getChildren(node) {
|
|
|
1039
1044
|
case "box":
|
|
1040
1045
|
case "container":
|
|
1041
1046
|
case "form":
|
|
1042
|
-
case "section":
|
|
1047
|
+
case "form-section":
|
|
1043
1048
|
case "step":
|
|
1044
1049
|
case "modal-content":
|
|
1045
1050
|
return node.childrenProps;
|
|
@@ -1138,6 +1143,39 @@ var isStringSchema = (schema) => "type" in schema && schema.type === "string";
|
|
|
1138
1143
|
var isStringSchemaWithUpload = (schema) => isStringSchema(schema) && schema.format === "base64url";
|
|
1139
1144
|
var isSchemaWithPersistAsync = (schema) => "persistAsync" in schema && !isNullish(schema.persistAsync);
|
|
1140
1145
|
|
|
1146
|
+
// src/revamp/renderers/stepComponentToProps.ts
|
|
1147
|
+
var stepComponentToProps = (component, rendererMapperProps) => {
|
|
1148
|
+
const {
|
|
1149
|
+
uid,
|
|
1150
|
+
back,
|
|
1151
|
+
control,
|
|
1152
|
+
description,
|
|
1153
|
+
error,
|
|
1154
|
+
loadingState,
|
|
1155
|
+
step,
|
|
1156
|
+
title,
|
|
1157
|
+
onBehavior
|
|
1158
|
+
} = component;
|
|
1159
|
+
const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
|
|
1160
|
+
return __spreadValues({
|
|
1161
|
+
type: "step",
|
|
1162
|
+
id: step.id,
|
|
1163
|
+
uid,
|
|
1164
|
+
back,
|
|
1165
|
+
control,
|
|
1166
|
+
description,
|
|
1167
|
+
error,
|
|
1168
|
+
loadingState,
|
|
1169
|
+
step,
|
|
1170
|
+
title,
|
|
1171
|
+
children: childrenProps.map(rendererMapperProps.render),
|
|
1172
|
+
childrenProps,
|
|
1173
|
+
onAction: (action) => {
|
|
1174
|
+
void onBehavior({ type: "action", action });
|
|
1175
|
+
}
|
|
1176
|
+
}, rendererMapperProps);
|
|
1177
|
+
};
|
|
1178
|
+
|
|
1141
1179
|
// src/revamp/renderers/mappers/utils/pick.ts
|
|
1142
1180
|
function pick(obj, ...keys) {
|
|
1143
1181
|
const result = {};
|
|
@@ -1156,7 +1194,7 @@ var allOfComponentToProps = (component, rendererMapperProps) => {
|
|
|
1156
1194
|
(c) => componentToRendererProps(c, rendererMapperProps)
|
|
1157
1195
|
);
|
|
1158
1196
|
return __spreadProps(__spreadValues(__spreadValues({
|
|
1159
|
-
type: "section"
|
|
1197
|
+
type: "form-section"
|
|
1160
1198
|
}, pick(component, "uid", "control", "description", "help", "icon", "image", "title")), rendererMapperProps), {
|
|
1161
1199
|
children: childrenProps.map(rendererMapperProps.render),
|
|
1162
1200
|
childrenProps
|
|
@@ -1331,6 +1369,19 @@ var decisionComponentToProps = (component, rendererMapperProps) => __spreadProps
|
|
|
1331
1369
|
// src/revamp/renderers/mappers/dividerComponentToProps.ts
|
|
1332
1370
|
var dividerComponentToProps = (component, rendererMapperProps) => __spreadValues(__spreadValues({}, pick(component, "uid", "type", "control", "margin")), rendererMapperProps);
|
|
1333
1371
|
|
|
1372
|
+
// src/revamp/renderers/mappers/externalComponentToProps.ts
|
|
1373
|
+
var externalComponentToProps = (component, rendererMapperProps) => {
|
|
1374
|
+
return __spreadValues({
|
|
1375
|
+
type: "external-confirmation",
|
|
1376
|
+
uid: component.uid,
|
|
1377
|
+
url: component.url,
|
|
1378
|
+
status: component.status,
|
|
1379
|
+
onSuccess: component.onSuccess.bind(component),
|
|
1380
|
+
onFailure: component.onFailure.bind(component),
|
|
1381
|
+
onCancel: component.onCancel.bind(component)
|
|
1382
|
+
}, rendererMapperProps);
|
|
1383
|
+
};
|
|
1384
|
+
|
|
1334
1385
|
// src/revamp/renderers/mappers/formComponentToProps.ts
|
|
1335
1386
|
var formComponentToProps = (component, rendererMapperProps) => {
|
|
1336
1387
|
const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
|
|
@@ -1371,6 +1422,20 @@ var integerInputComponentToProps = (component, rendererMapperProps) => __spreadP
|
|
|
1371
1422
|
onChange: component.onChange.bind(component)
|
|
1372
1423
|
});
|
|
1373
1424
|
|
|
1425
|
+
// src/revamp/renderers/mappers/listComponentToProps.ts
|
|
1426
|
+
var listComponentToProps = (component, rendererMapperProps) => __spreadProps(__spreadValues(__spreadValues({}, pick(component, "uid", "type", "callToAction", "control", "margin", "title")), rendererMapperProps), {
|
|
1427
|
+
items: component.items.map(mapItem)
|
|
1428
|
+
});
|
|
1429
|
+
var mapItem = (item) => {
|
|
1430
|
+
var _a, _b;
|
|
1431
|
+
return __spreadProps(__spreadValues({}, item), {
|
|
1432
|
+
// populate deprecated fields
|
|
1433
|
+
subtitle: item.description,
|
|
1434
|
+
value: (_a = item.supportingValues) == null ? void 0 : _a.value,
|
|
1435
|
+
subvalue: (_b = item.supportingValues) == null ? void 0 : _b.subvalue
|
|
1436
|
+
});
|
|
1437
|
+
};
|
|
1438
|
+
|
|
1374
1439
|
// src/revamp/renderers/mappers/loadingIndicatorComponentToProps.ts
|
|
1375
1440
|
var loadingIndicatorComponentToProps = (component, rendererMapperProps) => __spreadValues(__spreadValues({}, pick(component, "uid", "type", "control", "margin", "size")), rendererMapperProps);
|
|
1376
1441
|
|
|
@@ -1395,6 +1460,35 @@ var modalComponentToProps = (component, rendererMapperProps) => {
|
|
|
1395
1460
|
}, rendererMapperProps);
|
|
1396
1461
|
};
|
|
1397
1462
|
|
|
1463
|
+
// src/revamp/renderers/mappers/modalContentComponentToProps.ts
|
|
1464
|
+
var modalContentComponentToProps = (component, rendererMapperProps) => {
|
|
1465
|
+
const { uid, open, title, close } = component;
|
|
1466
|
+
const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
|
|
1467
|
+
return __spreadValues({
|
|
1468
|
+
uid,
|
|
1469
|
+
type: "modal-content",
|
|
1470
|
+
open,
|
|
1471
|
+
title,
|
|
1472
|
+
children: childrenProps.map(rendererMapperProps.render),
|
|
1473
|
+
childrenProps,
|
|
1474
|
+
onClose: close.bind(component)
|
|
1475
|
+
}, rendererMapperProps);
|
|
1476
|
+
};
|
|
1477
|
+
|
|
1478
|
+
// src/revamp/renderers/mappers/multiSelectComponentToProps.ts
|
|
1479
|
+
var multiSelectInputComponentToProps = (component, rendererMapperProps) => {
|
|
1480
|
+
const { autoComplete, maxItems, minItems, options, selectedIndices, onSelect } = component;
|
|
1481
|
+
const _a = inputComponentToProps(component, "input-multi-select"), { required, value } = _a, props = __objRest(_a, ["required", "value"]);
|
|
1482
|
+
return __spreadProps(__spreadValues(__spreadValues({}, props), rendererMapperProps), {
|
|
1483
|
+
autoComplete,
|
|
1484
|
+
maxItems,
|
|
1485
|
+
minItems,
|
|
1486
|
+
options,
|
|
1487
|
+
selectedIndices,
|
|
1488
|
+
onSelect: onSelect.bind(component)
|
|
1489
|
+
});
|
|
1490
|
+
};
|
|
1491
|
+
|
|
1398
1492
|
// src/revamp/renderers/mappers/multiUploadInputComponentToProps.ts
|
|
1399
1493
|
var multiUploadInputComponentToProps = (component, rendererMapperProps) => {
|
|
1400
1494
|
const { accepts, cameraConfig, files, maxSize, minItems, maxItems, source, uploadLabel } = component;
|
|
@@ -1425,7 +1519,7 @@ var numberInputComponentToProps = (component, rendererMapperProps) => __spreadPr
|
|
|
1425
1519
|
var objectComponentToProps = (component, rendererMapperProps) => {
|
|
1426
1520
|
const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
|
|
1427
1521
|
return __spreadProps(__spreadValues(__spreadValues({
|
|
1428
|
-
type: "section"
|
|
1522
|
+
type: "form-section"
|
|
1429
1523
|
}, pick(component, "uid", "control", "description", "help", "icon", "image", "title")), rendererMapperProps), {
|
|
1430
1524
|
children: childrenProps.map(rendererMapperProps.render),
|
|
1431
1525
|
childrenProps
|
|
@@ -1502,6 +1596,17 @@ var reviewComponentToProps = (component, rendererMapperProps) => __spreadValues(
|
|
|
1502
1596
|
}), rendererMapperProps);
|
|
1503
1597
|
var mapField = (field) => __spreadValues({}, field);
|
|
1504
1598
|
|
|
1599
|
+
// src/revamp/renderers/mappers/rootComponentToProps.ts
|
|
1600
|
+
var rootComponentToProps = (rootComponent, rendererMapperProps) => {
|
|
1601
|
+
const childrenProps = rootComponent.getChildren().map((child) => componentToRendererProps(child, rendererMapperProps));
|
|
1602
|
+
return __spreadValues({
|
|
1603
|
+
type: "root",
|
|
1604
|
+
uid: rootComponent.uid,
|
|
1605
|
+
children: childrenProps.map(rendererMapperProps.render),
|
|
1606
|
+
childrenProps
|
|
1607
|
+
}, rendererMapperProps);
|
|
1608
|
+
};
|
|
1609
|
+
|
|
1505
1610
|
// src/revamp/domain/mappers/utils/image.ts
|
|
1506
1611
|
var mapSpecImage = (image) => {
|
|
1507
1612
|
var _a, _b, _c;
|
|
@@ -1597,17 +1702,14 @@ var textInputComponentToProps = (component, rendererMapperProps) => __spreadProp
|
|
|
1597
1702
|
onChange: component.onChange.bind(component)
|
|
1598
1703
|
});
|
|
1599
1704
|
|
|
1600
|
-
// src/revamp/renderers/mappers/
|
|
1601
|
-
var
|
|
1602
|
-
const
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
options,
|
|
1609
|
-
selectedIndices,
|
|
1610
|
-
onSelect: onSelect.bind(component)
|
|
1705
|
+
// src/revamp/renderers/mappers/tupleComponentToProps.ts
|
|
1706
|
+
var tupleComponentToProps = (component, rendererMapperProps) => {
|
|
1707
|
+
const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
|
|
1708
|
+
return __spreadProps(__spreadValues(__spreadValues({
|
|
1709
|
+
type: "form-section"
|
|
1710
|
+
}, pick(component, "uid", "control", "description", "help", "icon", "image", "title")), rendererMapperProps), {
|
|
1711
|
+
children: childrenProps.map(rendererMapperProps.render),
|
|
1712
|
+
childrenProps
|
|
1611
1713
|
});
|
|
1612
1714
|
};
|
|
1613
1715
|
|
|
@@ -1623,108 +1725,25 @@ var uploadInputComponentToProps = (component, rendererMapperProps) => {
|
|
|
1623
1725
|
});
|
|
1624
1726
|
};
|
|
1625
1727
|
|
|
1626
|
-
// src/revamp/renderers/mappers/tupleComponentToProps.ts
|
|
1627
|
-
var tupleComponentToProps = (component, rendererMapperProps) => {
|
|
1628
|
-
const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
|
|
1629
|
-
return __spreadProps(__spreadValues(__spreadValues({
|
|
1630
|
-
type: "section"
|
|
1631
|
-
}, pick(component, "uid", "control", "description", "help", "icon", "image", "title")), rendererMapperProps), {
|
|
1632
|
-
children: childrenProps.map(rendererMapperProps.render),
|
|
1633
|
-
childrenProps
|
|
1634
|
-
});
|
|
1635
|
-
};
|
|
1636
|
-
|
|
1637
|
-
// src/revamp/renderers/mappers/listComponentToProps.ts
|
|
1638
|
-
var listComponentToProps = (component, rendererMapperProps) => __spreadProps(__spreadValues(__spreadValues({}, pick(component, "uid", "type", "callToAction", "control", "margin", "title")), rendererMapperProps), {
|
|
1639
|
-
items: component.items.map(mapItem)
|
|
1640
|
-
});
|
|
1641
|
-
var mapItem = (item) => {
|
|
1642
|
-
var _a, _b;
|
|
1643
|
-
return __spreadProps(__spreadValues({}, item), {
|
|
1644
|
-
// populate deprecated fields
|
|
1645
|
-
subtitle: item.description,
|
|
1646
|
-
value: (_a = item.supportingValues) == null ? void 0 : _a.value,
|
|
1647
|
-
subvalue: (_b = item.supportingValues) == null ? void 0 : _b.subvalue
|
|
1648
|
-
});
|
|
1649
|
-
};
|
|
1650
|
-
|
|
1651
|
-
// src/revamp/renderers/stepComponentToProps.ts
|
|
1652
|
-
var stepComponentToProps = (component, rendererMapperProps) => {
|
|
1653
|
-
const {
|
|
1654
|
-
uid,
|
|
1655
|
-
back,
|
|
1656
|
-
control,
|
|
1657
|
-
description,
|
|
1658
|
-
error,
|
|
1659
|
-
loadingState,
|
|
1660
|
-
step,
|
|
1661
|
-
title,
|
|
1662
|
-
onBehavior
|
|
1663
|
-
} = component;
|
|
1664
|
-
const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
|
|
1665
|
-
return __spreadValues({
|
|
1666
|
-
type: "step",
|
|
1667
|
-
id: step.id,
|
|
1668
|
-
uid,
|
|
1669
|
-
back,
|
|
1670
|
-
control,
|
|
1671
|
-
description,
|
|
1672
|
-
error,
|
|
1673
|
-
loadingState,
|
|
1674
|
-
step,
|
|
1675
|
-
title,
|
|
1676
|
-
children: childrenProps.map(rendererMapperProps.render),
|
|
1677
|
-
childrenProps,
|
|
1678
|
-
onAction: (action) => {
|
|
1679
|
-
void onBehavior({ type: "action", action });
|
|
1680
|
-
}
|
|
1681
|
-
}, rendererMapperProps);
|
|
1682
|
-
};
|
|
1683
|
-
|
|
1684
|
-
// src/revamp/renderers/mappers/rootComponentToProps.ts
|
|
1685
|
-
var rootComponentToProps = (rootComponent, rendererMapperProps) => {
|
|
1686
|
-
const childrenProps = rootComponent.getChildren().map((child) => componentToRendererProps(child, rendererMapperProps));
|
|
1687
|
-
return __spreadValues({
|
|
1688
|
-
type: "root",
|
|
1689
|
-
uid: rootComponent.uid,
|
|
1690
|
-
children: childrenProps.map(rendererMapperProps.render),
|
|
1691
|
-
childrenProps
|
|
1692
|
-
}, rendererMapperProps);
|
|
1693
|
-
};
|
|
1694
|
-
|
|
1695
|
-
// src/revamp/renderers/mappers/modalContentComponentToProps.ts
|
|
1696
|
-
var modalContentComponentToProps = (component, rendererMapperProps) => {
|
|
1697
|
-
const { uid, open, title, close } = component;
|
|
1698
|
-
const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
|
|
1699
|
-
return __spreadValues({
|
|
1700
|
-
uid,
|
|
1701
|
-
type: "modal-content",
|
|
1702
|
-
open,
|
|
1703
|
-
title,
|
|
1704
|
-
children: childrenProps.map(rendererMapperProps.render),
|
|
1705
|
-
childrenProps,
|
|
1706
|
-
onClose: close.bind(component)
|
|
1707
|
-
}, rendererMapperProps);
|
|
1708
|
-
};
|
|
1709
|
-
|
|
1710
|
-
// src/revamp/renderers/mappers/externalComponentToProps.ts
|
|
1711
|
-
var externalComponentToProps = (component, rendererMapperProps) => {
|
|
1712
|
-
return __spreadValues({
|
|
1713
|
-
type: "external-confirmation",
|
|
1714
|
-
uid: component.uid,
|
|
1715
|
-
url: component.url,
|
|
1716
|
-
status: component.status,
|
|
1717
|
-
onSuccess: component.onSuccess.bind(component),
|
|
1718
|
-
onFailure: component.onFailure.bind(component),
|
|
1719
|
-
onCancel: component.onCancel.bind(component)
|
|
1720
|
-
}, rendererMapperProps);
|
|
1721
|
-
};
|
|
1722
|
-
|
|
1723
1728
|
// src/revamp/renderers/mappers/componentToRendererProps.ts
|
|
1724
1729
|
var componentToRendererProps = (component, rendererMapperProps) => {
|
|
1725
1730
|
if (isHiddenComponent(component)) {
|
|
1726
1731
|
return hiddenComponentToProps(component);
|
|
1727
1732
|
}
|
|
1733
|
+
const componentProps = getComponentProps(component, rendererMapperProps);
|
|
1734
|
+
const alertProps = getComponentAlertProps(component, rendererMapperProps);
|
|
1735
|
+
if (alertProps) {
|
|
1736
|
+
const childrenProps = [alertProps, componentProps];
|
|
1737
|
+
return __spreadValues({
|
|
1738
|
+
type: "container",
|
|
1739
|
+
uid: `${component.uid}-wrapper`,
|
|
1740
|
+
children: childrenProps.map(rendererMapperProps.render),
|
|
1741
|
+
childrenProps
|
|
1742
|
+
}, rendererMapperProps);
|
|
1743
|
+
}
|
|
1744
|
+
return componentProps;
|
|
1745
|
+
};
|
|
1746
|
+
var getComponentProps = (component, rendererMapperProps) => {
|
|
1728
1747
|
switch (component.type) {
|
|
1729
1748
|
case "root":
|
|
1730
1749
|
return rootComponentToProps(component, rendererMapperProps);
|
|
@@ -1804,6 +1823,13 @@ var componentToRendererProps = (component, rendererMapperProps) => {
|
|
|
1804
1823
|
throw new Error("Unknown component type");
|
|
1805
1824
|
}
|
|
1806
1825
|
};
|
|
1826
|
+
var getComponentAlertProps = (component, rendererMapperProps) => "alert" in component && component.alert ? __spreadValues({
|
|
1827
|
+
type: "alert",
|
|
1828
|
+
uid: `${component.uid}-alert`,
|
|
1829
|
+
margin: "md",
|
|
1830
|
+
context: component.alert.context,
|
|
1831
|
+
markdown: component.alert.content
|
|
1832
|
+
}, rendererMapperProps) : null;
|
|
1807
1833
|
|
|
1808
1834
|
// src/revamp/useDynamicFlowCore.tsx
|
|
1809
1835
|
import { validateStep } from "@wise/dynamic-flow-types";
|
|
@@ -2455,6 +2481,12 @@ var mapAdditionalInfo = (info, onBehavior) => {
|
|
|
2455
2481
|
}
|
|
2456
2482
|
return void 0;
|
|
2457
2483
|
};
|
|
2484
|
+
var mapSchemaAlert = (alert) => {
|
|
2485
|
+
return alert ? {
|
|
2486
|
+
content: alert.markdown,
|
|
2487
|
+
context: alert.context ? mapLegacyContext(alert.context) : "neutral"
|
|
2488
|
+
} : void 0;
|
|
2489
|
+
};
|
|
2458
2490
|
|
|
2459
2491
|
// src/revamp/domain/mappers/layout/decisionLayoutToComponent.ts
|
|
2460
2492
|
var decisionLayoutToComponent = (uid, {
|
|
@@ -3256,7 +3288,7 @@ var mapCommonSchemaProps = (schemaMapperProps) => {
|
|
|
3256
3288
|
var _a;
|
|
3257
3289
|
const { uid, schema, required, validationErrors } = schemaMapperProps;
|
|
3258
3290
|
const { $id, analyticsId, control, description, icon, image, keywords, title, hidden } = schema;
|
|
3259
|
-
return __spreadValues(__spreadValues({
|
|
3291
|
+
return __spreadValues(__spreadValues(__spreadValues({
|
|
3260
3292
|
uid,
|
|
3261
3293
|
id: $id != null ? $id : uid,
|
|
3262
3294
|
analyticsId: (_a = analyticsId != null ? analyticsId : $id) != null ? _a : "",
|
|
@@ -3271,7 +3303,7 @@ var mapCommonSchemaProps = (schemaMapperProps) => {
|
|
|
3271
3303
|
required: Boolean(required),
|
|
3272
3304
|
title,
|
|
3273
3305
|
summariser: getSummariser(schema)
|
|
3274
|
-
}, schemaHasHelp(schema) ? { help: schema.help.markdown } : {}), schemaHasPlaceholder(schema) ? { placeholder: schema.placeholder } : {});
|
|
3306
|
+
}, schemaHasHelp(schema) ? { help: schema.help.markdown } : {}), schemaHasPlaceholder(schema) ? { placeholder: schema.placeholder } : {}), schema.alert ? { alert: mapSchemaAlert(schema.alert) } : {});
|
|
3275
3307
|
};
|
|
3276
3308
|
var schemaHasDisabled = (schema) => Boolean("disabled" in schema && schema.disabled !== void 0);
|
|
3277
3309
|
var schemaHasHelp = (schema) => Boolean("help" in schema && schema.help);
|
|
@@ -3393,27 +3425,27 @@ var numberSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
|
3393
3425
|
);
|
|
3394
3426
|
};
|
|
3395
3427
|
|
|
3396
|
-
// src/revamp/domain/components/
|
|
3397
|
-
var
|
|
3428
|
+
// src/revamp/domain/components/AllOfComponent.ts
|
|
3429
|
+
var createAllOfComponent = (allOfProps) => {
|
|
3398
3430
|
const {
|
|
3399
3431
|
uid,
|
|
3400
3432
|
analyticsId,
|
|
3401
|
-
|
|
3433
|
+
alert,
|
|
3434
|
+
components,
|
|
3402
3435
|
control,
|
|
3403
3436
|
description,
|
|
3404
|
-
displayOrder,
|
|
3405
3437
|
help,
|
|
3406
3438
|
hidden,
|
|
3407
3439
|
icon,
|
|
3408
3440
|
image,
|
|
3409
|
-
summariser,
|
|
3410
3441
|
title
|
|
3411
|
-
} =
|
|
3442
|
+
} = allOfProps;
|
|
3412
3443
|
return {
|
|
3413
|
-
type: "
|
|
3444
|
+
type: "all-of",
|
|
3414
3445
|
uid,
|
|
3415
3446
|
analyticsId,
|
|
3416
|
-
|
|
3447
|
+
alert,
|
|
3448
|
+
components,
|
|
3417
3449
|
control,
|
|
3418
3450
|
description,
|
|
3419
3451
|
help,
|
|
@@ -3422,123 +3454,13 @@ var createObjectComponent = (objectProps) => {
|
|
|
3422
3454
|
image,
|
|
3423
3455
|
title,
|
|
3424
3456
|
getChildren() {
|
|
3425
|
-
return
|
|
3457
|
+
return this.components;
|
|
3458
|
+
},
|
|
3459
|
+
getSummary() {
|
|
3460
|
+
return summariseFromChildren(this.getChildren());
|
|
3426
3461
|
},
|
|
3427
3462
|
async getSubmittableValue() {
|
|
3428
|
-
return
|
|
3429
|
-
displayOrder.map(
|
|
3430
|
-
async (propName) => this.componentMap[propName].getSubmittableValue().then((value) => ({ value, propName }))
|
|
3431
|
-
)
|
|
3432
|
-
).then(
|
|
3433
|
-
(values) => values.reduce(
|
|
3434
|
-
(acc, { value, propName }) => __spreadValues(__spreadValues({}, acc), value === null ? {} : { [propName]: value }),
|
|
3435
|
-
{}
|
|
3436
|
-
)
|
|
3437
|
-
);
|
|
3438
|
-
},
|
|
3439
|
-
getSubmittableValueSync() {
|
|
3440
|
-
return mergeChildrenValues(
|
|
3441
|
-
displayOrder,
|
|
3442
|
-
(propName) => this.componentMap[propName].getSubmittableValueSync()
|
|
3443
|
-
);
|
|
3444
|
-
},
|
|
3445
|
-
getSummary() {
|
|
3446
|
-
const summary = summariser(this.getLocalValue());
|
|
3447
|
-
const childSummary = summariseFromChildren(this.getChildren());
|
|
3448
|
-
return mergeSummaries(summary, childSummary);
|
|
3449
|
-
},
|
|
3450
|
-
getLocalValue() {
|
|
3451
|
-
return mergeChildrenValues(
|
|
3452
|
-
displayOrder,
|
|
3453
|
-
(propName) => this.componentMap[propName].getLocalValue()
|
|
3454
|
-
);
|
|
3455
|
-
},
|
|
3456
|
-
validate() {
|
|
3457
|
-
return hidden ? true : validateComponents(this.getChildren());
|
|
3458
|
-
}
|
|
3459
|
-
};
|
|
3460
|
-
};
|
|
3461
|
-
var mergeChildrenValues = (displayOrder, getComponentValue) => displayOrder.reduce((acc, propName) => {
|
|
3462
|
-
const componentValue = getComponentValue(propName);
|
|
3463
|
-
return __spreadValues(__spreadValues({}, acc), componentValue === null ? {} : { [propName]: componentValue });
|
|
3464
|
-
}, {});
|
|
3465
|
-
|
|
3466
|
-
// src/revamp/domain/mappers/schema/objectSchemaToComponent/objectSchemaToComponent.ts
|
|
3467
|
-
var objectSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
3468
|
-
const { uid, localValue, schema, model, validationErrors } = schemaMapperProps;
|
|
3469
|
-
const { $id, displayOrder, properties, required } = schema;
|
|
3470
|
-
validateDisplayOrder($id, displayOrder, properties, mapperProps.logEvent);
|
|
3471
|
-
const componentMap = displayOrder.reduce((acc, propName) => {
|
|
3472
|
-
var _a;
|
|
3473
|
-
const propSchema = properties[propName];
|
|
3474
|
-
if (propSchema === void 0) {
|
|
3475
|
-
throw new Error(`Object schema ${$id} has no property named ${propName}`);
|
|
3476
|
-
}
|
|
3477
|
-
return __spreadProps(__spreadValues({}, acc), {
|
|
3478
|
-
[propName]: mapSchemaToComponent(
|
|
3479
|
-
{
|
|
3480
|
-
uid: `${uid}.obj-${propName}`,
|
|
3481
|
-
schema: propSchema,
|
|
3482
|
-
model: isObjectModel(model) ? model[propName] : null,
|
|
3483
|
-
localValue: isObjectLocalValue(localValue) ? localValue[propName] : null,
|
|
3484
|
-
required: (_a = required == null ? void 0 : required.includes(propName)) != null ? _a : false,
|
|
3485
|
-
validationErrors: isObject(validationErrors) ? validationErrors[propName] : void 0
|
|
3486
|
-
},
|
|
3487
|
-
mapperProps
|
|
3488
|
-
)
|
|
3489
|
-
});
|
|
3490
|
-
}, {});
|
|
3491
|
-
return createObjectComponent(__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
|
|
3492
|
-
componentMap,
|
|
3493
|
-
displayOrder
|
|
3494
|
-
}));
|
|
3495
|
-
};
|
|
3496
|
-
var validateDisplayOrder = ($id, displayOrder, properties, logEvent) => {
|
|
3497
|
-
if (!displayOrder) {
|
|
3498
|
-
const message = `Object schema ${$id} has no displayOrder property.`;
|
|
3499
|
-
logEvent("error", message);
|
|
3500
|
-
throw new Error(message);
|
|
3501
|
-
}
|
|
3502
|
-
const propertyNames = Object.keys(properties);
|
|
3503
|
-
displayOrder.forEach((propName) => {
|
|
3504
|
-
if (!properties[propName]) {
|
|
3505
|
-
const message = `Object schema ${$id} has no property named "${propName}", but it is listed in the displayOrder array.`;
|
|
3506
|
-
logEvent("error", message);
|
|
3507
|
-
throw new Error(message);
|
|
3508
|
-
}
|
|
3509
|
-
});
|
|
3510
|
-
propertyNames.forEach((propName) => {
|
|
3511
|
-
if (!displayOrder.includes(propName)) {
|
|
3512
|
-
const message = `Object schema ${$id} has a "${propName}" property which is missing in the displayOrder array.`;
|
|
3513
|
-
logEvent("error", message);
|
|
3514
|
-
throw new Error(message);
|
|
3515
|
-
}
|
|
3516
|
-
});
|
|
3517
|
-
};
|
|
3518
|
-
|
|
3519
|
-
// src/revamp/domain/components/AllOfComponent.ts
|
|
3520
|
-
var createAllOfComponent = (allOfProps) => {
|
|
3521
|
-
const { uid, analyticsId, components, control, description, help, hidden, icon, image, title } = allOfProps;
|
|
3522
|
-
return {
|
|
3523
|
-
type: "all-of",
|
|
3524
|
-
uid,
|
|
3525
|
-
analyticsId,
|
|
3526
|
-
components,
|
|
3527
|
-
control,
|
|
3528
|
-
description,
|
|
3529
|
-
help,
|
|
3530
|
-
hidden,
|
|
3531
|
-
icon,
|
|
3532
|
-
image,
|
|
3533
|
-
title,
|
|
3534
|
-
getChildren() {
|
|
3535
|
-
return this.components;
|
|
3536
|
-
},
|
|
3537
|
-
getSummary() {
|
|
3538
|
-
return summariseFromChildren(this.getChildren());
|
|
3539
|
-
},
|
|
3540
|
-
async getSubmittableValue() {
|
|
3541
|
-
return getSubmittableData(this.components);
|
|
3463
|
+
return getSubmittableData(this.components);
|
|
3542
3464
|
},
|
|
3543
3465
|
getSubmittableValueSync() {
|
|
3544
3466
|
return getSubmittableDataSync(this.components);
|
|
@@ -3574,415 +3496,456 @@ var allOfSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
|
3574
3496
|
}));
|
|
3575
3497
|
};
|
|
3576
3498
|
|
|
3577
|
-
// src/revamp/domain/components/
|
|
3578
|
-
var
|
|
3579
|
-
const
|
|
3580
|
-
return {
|
|
3581
|
-
type: "const",
|
|
3582
|
-
uid,
|
|
3583
|
-
analyticsId,
|
|
3584
|
-
getLocalValue: () => value,
|
|
3585
|
-
getSubmittableValue: async () => value,
|
|
3586
|
-
getSubmittableValueSync: () => value,
|
|
3587
|
-
getSummary: () => summary,
|
|
3588
|
-
validate: () => true
|
|
3589
|
-
};
|
|
3590
|
-
};
|
|
3591
|
-
|
|
3592
|
-
// src/revamp/domain/mappers/schema/constSchemaToComponent.ts
|
|
3593
|
-
var constSchemaToComponent = (uid, schemaMapperProps) => {
|
|
3594
|
-
var _a;
|
|
3595
|
-
const { schema } = schemaMapperProps;
|
|
3596
|
-
const { title, const: constValue, analyticsId, $id } = schema;
|
|
3597
|
-
const titleOrValue = (_a = title != null ? title : constValue) != null ? _a : null;
|
|
3598
|
-
return createConstComponent({
|
|
3599
|
-
uid,
|
|
3600
|
-
analyticsId: analyticsId != null ? analyticsId : $id,
|
|
3601
|
-
summary: getConstSummary(schema, titleOrValue),
|
|
3602
|
-
value: schema.const
|
|
3603
|
-
});
|
|
3604
|
-
};
|
|
3605
|
-
|
|
3606
|
-
// src/revamp/domain/components/IntegerInputComponent.ts
|
|
3607
|
-
var createIntegerInputComponent = (integerInputProps, updateComponent) => {
|
|
3608
|
-
const _a = integerInputProps, {
|
|
3499
|
+
// src/revamp/domain/components/RepeatableComponent.ts
|
|
3500
|
+
var createRepeatableComponent = (repeatableProps, updateComponent) => {
|
|
3501
|
+
const _a = repeatableProps, {
|
|
3609
3502
|
uid,
|
|
3610
3503
|
id,
|
|
3611
3504
|
checks,
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
performRefresh,
|
|
3615
|
-
performValidationAsync,
|
|
3505
|
+
components,
|
|
3506
|
+
summary,
|
|
3616
3507
|
onValueChange,
|
|
3508
|
+
createEditableComponent,
|
|
3617
3509
|
summariser
|
|
3618
|
-
} = _a,
|
|
3510
|
+
} = _a, componentProps = __objRest(_a, [
|
|
3619
3511
|
"uid",
|
|
3620
3512
|
"id",
|
|
3621
3513
|
"checks",
|
|
3622
|
-
"
|
|
3623
|
-
"
|
|
3624
|
-
"performRefresh",
|
|
3625
|
-
"performValidationAsync",
|
|
3514
|
+
"components",
|
|
3515
|
+
"summary",
|
|
3626
3516
|
"onValueChange",
|
|
3517
|
+
"createEditableComponent",
|
|
3627
3518
|
"summariser"
|
|
3628
3519
|
]);
|
|
3629
3520
|
const update = getInputUpdateFunction(updateComponent);
|
|
3630
3521
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
3631
|
-
const
|
|
3632
|
-
const integerComponent = __spreadValues({
|
|
3633
|
-
type: "integer",
|
|
3522
|
+
const repeatableComponent = __spreadProps(__spreadValues({
|
|
3634
3523
|
uid,
|
|
3635
3524
|
id,
|
|
3636
|
-
|
|
3525
|
+
type: "repeatable",
|
|
3526
|
+
components,
|
|
3527
|
+
editableComponent: null,
|
|
3528
|
+
editableIndex: null,
|
|
3529
|
+
summaryDefaults: {
|
|
3530
|
+
title: summary == null ? void 0 : summary.defaultTitle,
|
|
3531
|
+
description: summary == null ? void 0 : summary.defaultDescription,
|
|
3532
|
+
icon: summary == null ? void 0 : summary.defaultIcon,
|
|
3533
|
+
image: summary == null ? void 0 : summary.defaultImage
|
|
3534
|
+
}
|
|
3535
|
+
}, componentProps), {
|
|
3637
3536
|
_update(updateFn) {
|
|
3638
3537
|
update(this, updateFn);
|
|
3639
3538
|
},
|
|
3640
|
-
|
|
3641
|
-
this.
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3539
|
+
onEdit(itemIndex) {
|
|
3540
|
+
this._update((draft) => {
|
|
3541
|
+
draft.editableComponent = createEditableComponent(
|
|
3542
|
+
draft.components[itemIndex].getLocalValue()
|
|
3543
|
+
);
|
|
3544
|
+
draft.editableIndex = itemIndex;
|
|
3545
|
+
});
|
|
3645
3546
|
},
|
|
3646
|
-
|
|
3647
|
-
onChange(updatedValue) {
|
|
3648
|
-
const prevValue = this.value;
|
|
3547
|
+
onAdd() {
|
|
3649
3548
|
this._update((draft) => {
|
|
3549
|
+
draft.editableComponent = createEditableComponent(null);
|
|
3550
|
+
draft.editableIndex = null;
|
|
3650
3551
|
draft.errors = [];
|
|
3651
|
-
draft.validationAsyncState.messages = {};
|
|
3652
|
-
draft.value = updatedValue;
|
|
3653
3552
|
});
|
|
3654
|
-
|
|
3553
|
+
},
|
|
3554
|
+
onSave() {
|
|
3555
|
+
var _a2;
|
|
3556
|
+
const isValid = (_a2 = this.editableComponent) == null ? void 0 : _a2.validate();
|
|
3557
|
+
if (!isValid) {
|
|
3558
|
+
return false;
|
|
3559
|
+
}
|
|
3560
|
+
this._update((draft) => {
|
|
3561
|
+
if (draft.editableComponent === null) {
|
|
3562
|
+
return;
|
|
3563
|
+
}
|
|
3564
|
+
if (draft.editableIndex === null) {
|
|
3565
|
+
const newComponent = __spreadValues({}, draft.editableComponent);
|
|
3566
|
+
draft.components = [...this.components, newComponent];
|
|
3567
|
+
} else {
|
|
3568
|
+
draft.components[draft.editableIndex] = __spreadProps(__spreadValues({}, draft.editableComponent), {
|
|
3569
|
+
uid: draft.components[draft.editableIndex].uid
|
|
3570
|
+
});
|
|
3571
|
+
}
|
|
3572
|
+
draft.editableComponent = null;
|
|
3573
|
+
draft.editableIndex = null;
|
|
3574
|
+
});
|
|
3575
|
+
onValueChange();
|
|
3576
|
+
return true;
|
|
3577
|
+
},
|
|
3578
|
+
onRemove() {
|
|
3579
|
+
this._update((draft) => {
|
|
3580
|
+
if (draft.editableIndex === null) {
|
|
3581
|
+
return;
|
|
3582
|
+
}
|
|
3583
|
+
draft.components.splice(draft.editableIndex, 1);
|
|
3584
|
+
draft.editableComponent = null;
|
|
3585
|
+
draft.editableIndex = null;
|
|
3586
|
+
});
|
|
3655
3587
|
onValueChange();
|
|
3656
3588
|
},
|
|
3589
|
+
getChildren() {
|
|
3590
|
+
return this.editableComponent !== null ? [...this.components, this.editableComponent] : this.components;
|
|
3591
|
+
},
|
|
3657
3592
|
async getSubmittableValue() {
|
|
3658
|
-
return this.
|
|
3593
|
+
return Promise.all(this.components.map(async (component) => component.getSubmittableValue()));
|
|
3659
3594
|
},
|
|
3660
3595
|
getSubmittableValueSync() {
|
|
3661
|
-
|
|
3662
|
-
return (_a2 = this.getLocalValue()) != null ? _a2 : null;
|
|
3596
|
+
return this.components.map((component) => component.getSubmittableValueSync());
|
|
3663
3597
|
},
|
|
3664
3598
|
getSummary() {
|
|
3665
|
-
return summariser(
|
|
3599
|
+
return summariser(null);
|
|
3666
3600
|
},
|
|
3667
3601
|
getLocalValue() {
|
|
3668
|
-
return this.
|
|
3602
|
+
return this.components.map((component) => component.getLocalValue());
|
|
3669
3603
|
},
|
|
3670
3604
|
validate() {
|
|
3671
|
-
const
|
|
3605
|
+
const messages = getValidationErrors(this.getLocalValue());
|
|
3606
|
+
const childComponentsValid = validateComponents(this.getChildren());
|
|
3672
3607
|
this._update((draft) => {
|
|
3673
|
-
draft.errors =
|
|
3608
|
+
draft.errors = messages;
|
|
3674
3609
|
});
|
|
3675
|
-
return
|
|
3610
|
+
return messages.length === 0 && childComponentsValid;
|
|
3676
3611
|
}
|
|
3677
|
-
}
|
|
3678
|
-
|
|
3679
|
-
return integerComponent;
|
|
3680
|
-
}
|
|
3681
|
-
if (performPersistAsync) {
|
|
3682
|
-
const persist = getComponentPersistAsync(update, performPersistAsync);
|
|
3683
|
-
return __spreadProps(__spreadValues({}, integerComponent), {
|
|
3684
|
-
onBlur() {
|
|
3685
|
-
if (this.validate()) {
|
|
3686
|
-
persist(this, this.getLocalValue()).catch(() => {
|
|
3687
|
-
});
|
|
3688
|
-
}
|
|
3689
|
-
},
|
|
3690
|
-
async getSubmittableValue() {
|
|
3691
|
-
return persist(this, this.getLocalValue());
|
|
3692
|
-
},
|
|
3693
|
-
getSubmittableValueSync() {
|
|
3694
|
-
return this.persistedState.lastResponse;
|
|
3695
|
-
}
|
|
3696
|
-
});
|
|
3697
|
-
}
|
|
3698
|
-
if (performValidationAsync) {
|
|
3699
|
-
const validateAsync = getDebouncedComponentValidationAsync(update, performValidationAsync);
|
|
3700
|
-
return __spreadProps(__spreadValues({}, integerComponent), {
|
|
3701
|
-
onBlur() {
|
|
3702
|
-
if (this.validate()) {
|
|
3703
|
-
validateAsync.flush();
|
|
3704
|
-
}
|
|
3705
|
-
},
|
|
3706
|
-
onChange(updatedValue) {
|
|
3707
|
-
integerComponent.onChange.call(this, updatedValue);
|
|
3708
|
-
if (getValidationErrors(updatedValue).length === 0) {
|
|
3709
|
-
validateAsync(this, updatedValue);
|
|
3710
|
-
}
|
|
3711
|
-
}
|
|
3712
|
-
});
|
|
3713
|
-
}
|
|
3714
|
-
return integerComponent;
|
|
3612
|
+
});
|
|
3613
|
+
return repeatableComponent;
|
|
3715
3614
|
};
|
|
3716
3615
|
|
|
3717
|
-
// src/revamp/domain/mappers/schema/
|
|
3718
|
-
var
|
|
3719
|
-
const {
|
|
3720
|
-
const {
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3616
|
+
// src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToRepeatableComponent.ts
|
|
3617
|
+
var arraySchemaToRepeatableComponent = (schemaMapperProps, mapperProps) => {
|
|
3618
|
+
const { getErrorMessageFunctions } = mapperProps;
|
|
3619
|
+
const {
|
|
3620
|
+
uid,
|
|
3621
|
+
localValue,
|
|
3622
|
+
schema,
|
|
3623
|
+
model: initialModel,
|
|
3624
|
+
required = false,
|
|
3625
|
+
validationErrors
|
|
3626
|
+
} = schemaMapperProps;
|
|
3627
|
+
const { items, addItemTitle, editItemTitle, maxItems, minItems, summary } = schema;
|
|
3628
|
+
const value = isArray(localValue) ? localValue : [];
|
|
3629
|
+
const components = initialModel == null ? void 0 : initialModel.map(
|
|
3630
|
+
(item, index) => mapSchemaToComponent(
|
|
3631
|
+
{
|
|
3632
|
+
uid: `${uid}.arr-${index}`,
|
|
3633
|
+
schema: items,
|
|
3634
|
+
model: item,
|
|
3635
|
+
localValue: value == null ? void 0 : value[index],
|
|
3636
|
+
// TODO tests for this
|
|
3637
|
+
validationErrors
|
|
3638
|
+
},
|
|
3639
|
+
mapperProps
|
|
3640
|
+
)
|
|
3726
3641
|
);
|
|
3727
|
-
const
|
|
3728
|
-
|
|
3642
|
+
const createEditableComponent = (editableValue) => mapSchemaToComponent(
|
|
3643
|
+
{
|
|
3644
|
+
uid: `${uid}.arr-rnd-${getRandomInt()}`,
|
|
3645
|
+
schema: items,
|
|
3646
|
+
localValue: editableValue,
|
|
3647
|
+
model: localValueToJsonElement(editableValue),
|
|
3648
|
+
validationErrors: void 0,
|
|
3649
|
+
required: true
|
|
3650
|
+
},
|
|
3729
3651
|
mapperProps
|
|
3730
3652
|
);
|
|
3731
|
-
const
|
|
3732
|
-
const
|
|
3733
|
-
|
|
3734
|
-
const checks = [
|
|
3735
|
-
getRequiredCheck(required, errorMessageFunctions),
|
|
3736
|
-
getBelowMinimumCheck(schema, errorMessageFunctions),
|
|
3737
|
-
getAboveMaximumCheck(schema, errorMessageFunctions)
|
|
3738
|
-
];
|
|
3739
|
-
return createIntegerInputComponent(
|
|
3653
|
+
const { onValueChange } = mapperProps;
|
|
3654
|
+
const errorMessageFunctions = getErrorMessageFunctions(schema.validationMessages);
|
|
3655
|
+
return createRepeatableComponent(
|
|
3740
3656
|
__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
|
|
3741
|
-
|
|
3742
|
-
checks
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3657
|
+
addItemTitle,
|
|
3658
|
+
checks: schema.hidden ? [] : [
|
|
3659
|
+
getRequiredCheck(required, errorMessageFunctions),
|
|
3660
|
+
getAboveMaxItemsCheck(schema, errorMessageFunctions),
|
|
3661
|
+
getBelowMinItemsCheck(schema, errorMessageFunctions)
|
|
3662
|
+
],
|
|
3663
|
+
components: components != null ? components : [],
|
|
3664
|
+
editItemTitle,
|
|
3665
|
+
maxItems,
|
|
3666
|
+
minItems,
|
|
3667
|
+
summary: __spreadProps(__spreadValues({}, summary), {
|
|
3668
|
+
defaultImage: mapSpecImage(summary == null ? void 0 : summary.defaultImage)
|
|
3669
|
+
}),
|
|
3670
|
+
createEditableComponent,
|
|
3751
3671
|
onValueChange
|
|
3752
3672
|
}),
|
|
3753
|
-
updateComponent
|
|
3673
|
+
mapperProps.updateComponent
|
|
3754
3674
|
);
|
|
3755
3675
|
};
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
if (isArrayModel(localModel) && isArrayModel(incomingModel)) {
|
|
3760
|
-
return localModel.length === incomingModel.length && localModel.every((value, index) => isPartialModelMatch(value, incomingModel[index]));
|
|
3676
|
+
var localValueToJsonElement = (localValue) => {
|
|
3677
|
+
if (localValue instanceof Array) {
|
|
3678
|
+
return localValue.map(localValueToJsonElement);
|
|
3761
3679
|
}
|
|
3762
|
-
if (
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
}
|
|
3766
|
-
const nonNullishKeysInBoth = nonNullishKeys(localModel).filter(
|
|
3767
|
-
(key) => nonNullishKeys(incomingModel).includes(key)
|
|
3680
|
+
if (isObject(localValue)) {
|
|
3681
|
+
return Object.fromEntries(
|
|
3682
|
+
Object.entries(localValue).map(([key, value]) => [key, localValueToJsonElement(value)])
|
|
3768
3683
|
);
|
|
3769
|
-
return nonNullishKeysInBoth.length > 0 && nonNullishKeysInBoth.every((key) => isPartialModelMatch(localModel[key], incomingModel[key]));
|
|
3770
3684
|
}
|
|
3771
|
-
|
|
3685
|
+
if (localValue instanceof File) {
|
|
3686
|
+
return localValue.name;
|
|
3687
|
+
}
|
|
3688
|
+
return localValue;
|
|
3772
3689
|
};
|
|
3773
|
-
var
|
|
3690
|
+
var getRandomInt = () => Math.floor(Math.random() * 1e8);
|
|
3774
3691
|
|
|
3775
|
-
// src/revamp/domain/components/
|
|
3776
|
-
var
|
|
3777
|
-
const
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3692
|
+
// src/revamp/domain/components/utils/file-utils.ts
|
|
3693
|
+
var toBase64 = async (file) => new Promise((resolve, reject) => {
|
|
3694
|
+
const reader = new FileReader();
|
|
3695
|
+
reader.addEventListener("load", () => resolve(reader.result));
|
|
3696
|
+
reader.addEventListener("error", reject);
|
|
3697
|
+
reader.readAsDataURL(file);
|
|
3698
|
+
});
|
|
3699
|
+
var base64dataUrltoFile = (dataurl, filename) => {
|
|
3700
|
+
if (!isBase64DataUrl(dataurl)) {
|
|
3701
|
+
return null;
|
|
3702
|
+
}
|
|
3703
|
+
const [, base64data] = dataurl.split(",");
|
|
3704
|
+
return new File([base64ToBytes(base64data)], filename, { type: getMimeType(dataurl) });
|
|
3705
|
+
};
|
|
3706
|
+
var isBase64DataUrl = (dataurl) => dataurl.startsWith("data:") && dataurl.includes("base64") && dataurl.includes(",");
|
|
3707
|
+
var getMimeType = (base64dataUrl) => base64dataUrl.substring("data:".length).split(";")[0];
|
|
3708
|
+
var base64ToBytes = (base64) => {
|
|
3709
|
+
const charCodes = atob(base64).split("").map((m) => m.charCodeAt(0));
|
|
3710
|
+
return Uint8Array.from(charCodes);
|
|
3711
|
+
};
|
|
3712
|
+
|
|
3713
|
+
// src/revamp/domain/components/MultiUploadInputComponent.ts
|
|
3714
|
+
var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
3715
|
+
const _a = uploadInputProps, {
|
|
3716
|
+
uid,
|
|
3717
|
+
id,
|
|
3718
|
+
checks,
|
|
3719
|
+
fileChecks,
|
|
3720
|
+
format,
|
|
3721
|
+
performPersistAsync,
|
|
3722
|
+
onValueChange,
|
|
3723
|
+
summariser
|
|
3724
|
+
} = _a, rest = __objRest(_a, [
|
|
3725
|
+
"uid",
|
|
3726
|
+
"id",
|
|
3727
|
+
"checks",
|
|
3728
|
+
"fileChecks",
|
|
3729
|
+
"format",
|
|
3730
|
+
"performPersistAsync",
|
|
3731
|
+
"onValueChange",
|
|
3732
|
+
"summariser"
|
|
3733
|
+
]);
|
|
3783
3734
|
const update = getInputUpdateFunction(updateComponent);
|
|
3784
3735
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
3785
|
-
const
|
|
3736
|
+
const getFileValidationErrors = getLocalValueValidator(fileChecks);
|
|
3737
|
+
const uploadComponent = __spreadValues({
|
|
3738
|
+
type: "multi-upload",
|
|
3786
3739
|
uid,
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
selectedIndex,
|
|
3791
|
-
value: null
|
|
3792
|
-
}, rest), {
|
|
3740
|
+
id,
|
|
3741
|
+
format: "base64",
|
|
3742
|
+
files: [],
|
|
3793
3743
|
_update(updateFn) {
|
|
3794
3744
|
update(this, updateFn);
|
|
3795
3745
|
},
|
|
3796
|
-
|
|
3797
|
-
|
|
3746
|
+
onBlur() {
|
|
3747
|
+
this.validate();
|
|
3798
3748
|
},
|
|
3799
|
-
|
|
3800
|
-
|
|
3749
|
+
onFocus() {
|
|
3750
|
+
},
|
|
3751
|
+
// Noop
|
|
3752
|
+
async onRemoveFile(index) {
|
|
3753
|
+
this._update((draft) => {
|
|
3754
|
+
draft.value.splice(index, 1);
|
|
3755
|
+
draft.files.splice(index, 1);
|
|
3756
|
+
});
|
|
3757
|
+
},
|
|
3758
|
+
async onInsertFile(index, file) {
|
|
3759
|
+
const fileErrors = getFileValidationErrors(file);
|
|
3760
|
+
const fileId = getRandomId();
|
|
3761
|
+
this._update((draft) => {
|
|
3762
|
+
draft.value.splice(index, 0, file);
|
|
3763
|
+
draft.files.splice(index, 0, { file, id: fileId, errors: fileErrors });
|
|
3764
|
+
draft.errors = [];
|
|
3765
|
+
});
|
|
3766
|
+
onValueChange();
|
|
3767
|
+
return fileId;
|
|
3801
3768
|
},
|
|
3802
3769
|
async getSubmittableValue() {
|
|
3803
|
-
|
|
3804
|
-
return
|
|
3770
|
+
const files = this.getLocalValue();
|
|
3771
|
+
return files ? Promise.all(files.map(toBase64)) : null;
|
|
3805
3772
|
},
|
|
3806
3773
|
getSubmittableValueSync() {
|
|
3807
|
-
|
|
3808
|
-
return (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.getSubmittableValueSync()) != null ? _b : null;
|
|
3774
|
+
return null;
|
|
3809
3775
|
},
|
|
3810
3776
|
getSummary() {
|
|
3811
|
-
|
|
3812
|
-
return (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.getSummary()) != null ? _b : {};
|
|
3777
|
+
return summariser(this.getLocalValue().map(({ name }) => name));
|
|
3813
3778
|
},
|
|
3814
3779
|
getLocalValue() {
|
|
3815
|
-
|
|
3816
|
-
return (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.getLocalValue()) != null ? _b : null;
|
|
3817
|
-
},
|
|
3818
|
-
onBlur() {
|
|
3819
|
-
this.validate();
|
|
3820
|
-
},
|
|
3821
|
-
onFocus() {
|
|
3780
|
+
return this.value;
|
|
3822
3781
|
},
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
if (updatedIndex === this.selectedIndex) {
|
|
3826
|
-
return;
|
|
3827
|
-
}
|
|
3828
|
-
if (updatedIndex !== null && this.analyticsId) {
|
|
3829
|
-
selectProps.trackEvent("OneOf Selected", {
|
|
3830
|
-
oneOfId: this.analyticsId,
|
|
3831
|
-
schemaId: this.children[updatedIndex].analyticsId
|
|
3832
|
-
});
|
|
3833
|
-
}
|
|
3782
|
+
validate() {
|
|
3783
|
+
const errorMsgs = getValidationErrors(this.getLocalValue());
|
|
3834
3784
|
this._update((draft) => {
|
|
3835
|
-
draft.errors =
|
|
3836
|
-
draft.selectedIndex = updatedIndex;
|
|
3785
|
+
draft.errors = errorMsgs;
|
|
3837
3786
|
});
|
|
3838
|
-
|
|
3787
|
+
return errorMsgs.length === 0 && this.files.every(({ errors }) => errors.length === 0);
|
|
3788
|
+
}
|
|
3789
|
+
}, rest);
|
|
3790
|
+
if (!performPersistAsync) {
|
|
3791
|
+
return uploadComponent;
|
|
3792
|
+
}
|
|
3793
|
+
const persist = getComponentMultiPersistAsync(update, performPersistAsync);
|
|
3794
|
+
return __spreadProps(__spreadValues({}, uploadComponent), {
|
|
3795
|
+
format,
|
|
3796
|
+
async onInsertFile(index, file) {
|
|
3797
|
+
const fileId = await uploadComponent.onInsertFile.call(this, index, file);
|
|
3798
|
+
const submission = format === "blob" ? file : await toBase64(file);
|
|
3799
|
+
await persist(this, index, submission);
|
|
3839
3800
|
onValueChange();
|
|
3801
|
+
return fileId;
|
|
3840
3802
|
},
|
|
3841
|
-
|
|
3842
|
-
var _a2
|
|
3843
|
-
|
|
3844
|
-
|
|
3803
|
+
async onRemoveFile(index) {
|
|
3804
|
+
var _a2;
|
|
3805
|
+
await uploadComponent.onRemoveFile.call(this, index);
|
|
3806
|
+
(_a2 = this.persistedState[index]) == null ? void 0 : _a2.abortController.abort();
|
|
3845
3807
|
this._update((draft) => {
|
|
3846
|
-
draft.
|
|
3808
|
+
draft.persistedState = draft.persistedState.splice(index, 1);
|
|
3847
3809
|
});
|
|
3848
|
-
|
|
3810
|
+
},
|
|
3811
|
+
async getSubmittableValue() {
|
|
3812
|
+
return Promise.all(this.persistedState.map(async ({ submission }) => submission));
|
|
3813
|
+
},
|
|
3814
|
+
getSubmittableValueSync() {
|
|
3815
|
+
return this.persistedState.map(({ lastResponse }) => lastResponse);
|
|
3849
3816
|
}
|
|
3850
3817
|
});
|
|
3851
|
-
return component;
|
|
3852
3818
|
};
|
|
3853
3819
|
|
|
3854
|
-
// src/revamp/domain/mappers/schema/
|
|
3855
|
-
var
|
|
3820
|
+
// src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToMultiUploadComponent.ts
|
|
3821
|
+
var arraySchemaToMultiUploadComponent = (schemaMapperProps, mapperProps) => {
|
|
3856
3822
|
var _a;
|
|
3857
|
-
const {
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
)
|
|
3878
|
-
}
|
|
3879
|
-
const options = schema.oneOf.map((childSchema, index) => {
|
|
3880
|
-
const { title = "", description, image, icon, keywords = [] } = childSchema;
|
|
3881
|
-
return {
|
|
3882
|
-
title,
|
|
3883
|
-
description,
|
|
3884
|
-
image: mapSpecImage(image),
|
|
3885
|
-
icon,
|
|
3886
|
-
keywords,
|
|
3887
|
-
disabled: "disabled" in childSchema ? Boolean(childSchema.disabled) : false,
|
|
3888
|
-
component: mapSchemaToComponent(
|
|
3889
|
-
{
|
|
3890
|
-
uid: `${uid}.oneOf-${index}`,
|
|
3891
|
-
schema: isFormSectionSchema(childSchema) ? supressSchemaTitleAndDescription(childSchema) : childSchema,
|
|
3892
|
-
model: initialModel,
|
|
3893
|
-
localValue,
|
|
3894
|
-
validationErrors: initialError,
|
|
3895
|
-
required
|
|
3896
|
-
},
|
|
3897
|
-
mapperProps
|
|
3898
|
-
)
|
|
3899
|
-
};
|
|
3823
|
+
const { getErrorMessageFunctions } = mapperProps;
|
|
3824
|
+
const { localValue, model, schema, required = false } = schemaMapperProps;
|
|
3825
|
+
const uploadSchema = getUploadSchema(schema.items);
|
|
3826
|
+
const { accepts, cameraConfig, maxSize } = uploadSchema;
|
|
3827
|
+
const { minItems, maxItems, title, validationMessages } = schema;
|
|
3828
|
+
const arrayErrorMessageFunctions = getErrorMessageFunctions(validationMessages);
|
|
3829
|
+
const fileErrorMessageFunctions = getErrorMessageFunctions(uploadSchema.validationMessages);
|
|
3830
|
+
const checks = [
|
|
3831
|
+
getRequiredCheck(required, arrayErrorMessageFunctions),
|
|
3832
|
+
getAboveMaxFilesCheck(schema, arrayErrorMessageFunctions),
|
|
3833
|
+
getBelowMinFilesCheck(schema, arrayErrorMessageFunctions)
|
|
3834
|
+
];
|
|
3835
|
+
const fileChecks = [
|
|
3836
|
+
getFileSizeCheck(schema.items, fileErrorMessageFunctions),
|
|
3837
|
+
getFileTypeCheck(schema.items, fileErrorMessageFunctions)
|
|
3838
|
+
];
|
|
3839
|
+
const persistAsyncConfig = getPersistAsyncConfig(schema.items);
|
|
3840
|
+
const format = getFormat(schema.items);
|
|
3841
|
+
const combinedSchemaProps = __spreadProps(__spreadValues({}, schemaMapperProps), {
|
|
3842
|
+
persistAsyncConfig,
|
|
3843
|
+
schema: __spreadProps(__spreadValues({}, uploadSchema), { hidden: (_a = schema.hidden) != null ? _a : uploadSchema.hidden, alert: schema.alert })
|
|
3900
3844
|
});
|
|
3901
|
-
const {
|
|
3902
|
-
const {
|
|
3903
|
-
const
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3845
|
+
const { onValueChange } = mapperProps;
|
|
3846
|
+
const { performPersistAsync } = getPersistAsyncInitialState(combinedSchemaProps, mapperProps);
|
|
3847
|
+
const value = performPersistAsync ? getValueForPersistAsync(localValue) : [];
|
|
3848
|
+
const persistedState = performPersistAsync && isArray(model) ? model.map((itemModel) => getInitialPersistedState(null, itemModel)) : [];
|
|
3849
|
+
return createMultiUploadInputComponent(
|
|
3850
|
+
__spreadProps(__spreadValues({}, mapCommonSchemaProps(combinedSchemaProps)), {
|
|
3851
|
+
title,
|
|
3852
|
+
cameraConfig,
|
|
3853
|
+
uploadLabel: uploadSchema.title,
|
|
3854
|
+
accepts,
|
|
3855
|
+
autoComplete: "off",
|
|
3856
|
+
checks: schema.hidden ? [] : checks,
|
|
3857
|
+
fileChecks: schema.hidden ? [] : fileChecks,
|
|
3858
|
+
format,
|
|
3859
|
+
maxSize,
|
|
3860
|
+
minItems,
|
|
3861
|
+
maxItems,
|
|
3862
|
+
required,
|
|
3863
|
+
source: uploadSchema.source,
|
|
3864
|
+
value,
|
|
3865
|
+
persistedState,
|
|
3866
|
+
performPersistAsync,
|
|
3867
|
+
onValueChange
|
|
3913
3868
|
}),
|
|
3914
|
-
updateComponent
|
|
3869
|
+
mapperProps.updateComponent
|
|
3915
3870
|
);
|
|
3916
3871
|
};
|
|
3917
|
-
var
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3872
|
+
var getFormat = (schema) => {
|
|
3873
|
+
if (isStringSchemaWithUpload(schema)) {
|
|
3874
|
+
return "base64";
|
|
3875
|
+
}
|
|
3876
|
+
return isBlobSchema(schema.persistAsync.schema) ? "blob" : "base64";
|
|
3877
|
+
};
|
|
3878
|
+
var getUploadSchema = (schema) => {
|
|
3879
|
+
if (isStringSchemaWithUpload(schema)) {
|
|
3880
|
+
return schema;
|
|
3881
|
+
}
|
|
3882
|
+
return schema.persistAsync.schema;
|
|
3883
|
+
};
|
|
3884
|
+
var getPersistAsyncConfig = (schema) => {
|
|
3885
|
+
if (!isSchemaWithPersistAsync(schema)) {
|
|
3886
|
+
return void 0;
|
|
3887
|
+
}
|
|
3888
|
+
const { persistAsync } = schema;
|
|
3889
|
+
const { idProperty, method, param, url } = persistAsync;
|
|
3890
|
+
return { idProperty, method, param, url };
|
|
3921
3891
|
};
|
|
3892
|
+
var getValueForPersistAsync = (localValue) => isArray(localValue) && localValue.every(isFile) ? localValue : [];
|
|
3922
3893
|
|
|
3923
|
-
// src/revamp/domain/components/
|
|
3924
|
-
var
|
|
3925
|
-
const _a =
|
|
3894
|
+
// src/revamp/domain/components/MultiSelectInputComponent.ts
|
|
3895
|
+
var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
|
|
3896
|
+
const _a = multiSelectProps, {
|
|
3926
3897
|
uid,
|
|
3927
|
-
id,
|
|
3928
3898
|
checks,
|
|
3929
|
-
|
|
3930
|
-
|
|
3899
|
+
options,
|
|
3900
|
+
initialValue,
|
|
3931
3901
|
performValidationAsync,
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
value
|
|
3902
|
+
performRefresh,
|
|
3903
|
+
onValueChange
|
|
3935
3904
|
} = _a, rest = __objRest(_a, [
|
|
3936
3905
|
"uid",
|
|
3937
|
-
"id",
|
|
3938
3906
|
"checks",
|
|
3939
|
-
"
|
|
3940
|
-
"
|
|
3907
|
+
"options",
|
|
3908
|
+
"initialValue",
|
|
3941
3909
|
"performValidationAsync",
|
|
3942
|
-
"
|
|
3943
|
-
"
|
|
3944
|
-
"value"
|
|
3910
|
+
"performRefresh",
|
|
3911
|
+
"onValueChange"
|
|
3945
3912
|
]);
|
|
3946
3913
|
const update = getInputUpdateFunction(updateComponent);
|
|
3914
|
+
const children = options.map((option) => option.component);
|
|
3915
|
+
const selectedIndices = getInitialModelIndices(initialValue, children);
|
|
3947
3916
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
3948
|
-
const
|
|
3949
|
-
type: "date",
|
|
3917
|
+
const inputComponent = __spreadProps(__spreadValues({
|
|
3950
3918
|
uid,
|
|
3951
|
-
|
|
3952
|
-
|
|
3919
|
+
type: "multi-select",
|
|
3920
|
+
children,
|
|
3921
|
+
options,
|
|
3922
|
+
selectedIndices,
|
|
3923
|
+
value: null
|
|
3924
|
+
}, rest), {
|
|
3953
3925
|
_update(updateFn) {
|
|
3954
3926
|
update(this, updateFn);
|
|
3955
3927
|
},
|
|
3956
|
-
|
|
3957
|
-
this.validate();
|
|
3958
|
-
},
|
|
3959
|
-
onFocus() {
|
|
3960
|
-
},
|
|
3961
|
-
// Noop
|
|
3962
|
-
onChange(updatedValue) {
|
|
3963
|
-
const prevValue = this.value;
|
|
3928
|
+
onSelect(indices) {
|
|
3964
3929
|
this._update((draft) => {
|
|
3930
|
+
draft.selectedIndices = indices;
|
|
3965
3931
|
draft.errors = [];
|
|
3966
|
-
draft.validationAsyncState.messages = {};
|
|
3967
|
-
draft.value = updatedValue;
|
|
3968
3932
|
});
|
|
3969
|
-
|
|
3970
|
-
performRefresh == null ? void 0 : performRefresh();
|
|
3971
|
-
}
|
|
3933
|
+
performRefresh == null ? void 0 : performRefresh();
|
|
3972
3934
|
onValueChange();
|
|
3935
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
3936
|
+
this._update((draft) => {
|
|
3937
|
+
draft.errors = errors;
|
|
3938
|
+
});
|
|
3973
3939
|
},
|
|
3974
|
-
|
|
3975
|
-
return this.getSubmittableValueSync();
|
|
3976
|
-
},
|
|
3977
|
-
getSubmittableValueSync() {
|
|
3978
|
-
var _a2;
|
|
3979
|
-
return (_a2 = this.getLocalValue()) != null ? _a2 : null;
|
|
3940
|
+
onBlur() {
|
|
3980
3941
|
},
|
|
3981
|
-
|
|
3982
|
-
|
|
3942
|
+
// Noop
|
|
3943
|
+
onFocus() {
|
|
3983
3944
|
},
|
|
3945
|
+
// Noop
|
|
3984
3946
|
getLocalValue() {
|
|
3985
|
-
|
|
3947
|
+
var _a2, _b;
|
|
3948
|
+
return (_b = (_a2 = this.getSelectedChildren()) == null ? void 0 : _a2.map((child) => child.getLocalValue())) != null ? _b : null;
|
|
3986
3949
|
},
|
|
3987
3950
|
validate() {
|
|
3988
3951
|
const errors = getValidationErrors(this.getLocalValue());
|
|
@@ -3990,34 +3953,34 @@ var createDateInputComponent = (textInputProps, updateComponent) => {
|
|
|
3990
3953
|
draft.errors = errors;
|
|
3991
3954
|
});
|
|
3992
3955
|
return errors.length === 0;
|
|
3956
|
+
},
|
|
3957
|
+
async getSubmittableValue() {
|
|
3958
|
+
const selected = this.getSelectedChildren();
|
|
3959
|
+
if (selected) {
|
|
3960
|
+
return Promise.all(selected.map(async (child) => child.getSubmittableValue()));
|
|
3961
|
+
}
|
|
3962
|
+
return null;
|
|
3963
|
+
},
|
|
3964
|
+
getSubmittableValueSync() {
|
|
3965
|
+
var _a2, _b;
|
|
3966
|
+
return (_b = (_a2 = this.getSelectedChildren()) == null ? void 0 : _a2.map((child) => child.getSubmittableValueSync())) != null ? _b : null;
|
|
3967
|
+
},
|
|
3968
|
+
getSummary: () => ({}),
|
|
3969
|
+
getChildren() {
|
|
3970
|
+
return this.children;
|
|
3971
|
+
},
|
|
3972
|
+
getSelectedChildren() {
|
|
3973
|
+
return this.selectedIndices.map((i) => this.children[i]);
|
|
3993
3974
|
}
|
|
3994
|
-
}
|
|
3975
|
+
});
|
|
3995
3976
|
if (performRefresh) {
|
|
3996
|
-
return
|
|
3997
|
-
}
|
|
3998
|
-
if (performPersistAsync) {
|
|
3999
|
-
const persist = getComponentPersistAsync(update, performPersistAsync);
|
|
4000
|
-
return __spreadProps(__spreadValues({}, dateInputComponent), {
|
|
4001
|
-
onChange(updatedValue) {
|
|
4002
|
-
dateInputComponent.onChange.call(this, updatedValue);
|
|
4003
|
-
const isValid = getValidationErrors(updatedValue).length === 0;
|
|
4004
|
-
if (isValid) {
|
|
4005
|
-
persist(this, this.getLocalValue()).catch(() => {
|
|
4006
|
-
});
|
|
4007
|
-
}
|
|
4008
|
-
},
|
|
4009
|
-
async getSubmittableValue() {
|
|
4010
|
-
return persist(this, this.getLocalValue());
|
|
4011
|
-
},
|
|
4012
|
-
getSubmittableValueSync() {
|
|
4013
|
-
return this.persistedState.lastResponse;
|
|
4014
|
-
}
|
|
4015
|
-
});
|
|
3977
|
+
return inputComponent;
|
|
4016
3978
|
}
|
|
4017
3979
|
if (performValidationAsync) {
|
|
4018
3980
|
const validateAsync = getComponentValidationAsync(update, performValidationAsync);
|
|
4019
|
-
return __spreadProps(__spreadValues({},
|
|
4020
|
-
|
|
3981
|
+
return __spreadProps(__spreadValues({}, inputComponent), {
|
|
3982
|
+
onSelect(indices) {
|
|
3983
|
+
inputComponent.onSelect.call(this, indices);
|
|
4021
3984
|
if (this.validate()) {
|
|
4022
3985
|
validateAsync(this, this.getLocalValue()).catch(() => {
|
|
4023
3986
|
});
|
|
@@ -4025,79 +3988,181 @@ var createDateInputComponent = (textInputProps, updateComponent) => {
|
|
|
4025
3988
|
}
|
|
4026
3989
|
});
|
|
4027
3990
|
}
|
|
4028
|
-
return
|
|
3991
|
+
return inputComponent;
|
|
3992
|
+
};
|
|
3993
|
+
var getInitialModelIndices = (model, options) => {
|
|
3994
|
+
if (!isArray(model)) {
|
|
3995
|
+
return [];
|
|
3996
|
+
}
|
|
3997
|
+
return model.map((m) => options.findIndex((o) => o.getLocalValue() === m)).filter((n) => n >= 0);
|
|
4029
3998
|
};
|
|
4030
3999
|
|
|
4031
|
-
// src/revamp/domain/mappers/schema/
|
|
4032
|
-
var
|
|
4033
|
-
const { schema, localValue, model, required = false } = schemaMapperProps;
|
|
4000
|
+
// src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToMultiSelectComponent.ts
|
|
4001
|
+
var arraySchemaToMultiSelectComponent = (schemaMapperProps, mapperProps) => {
|
|
4034
4002
|
const {
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
const
|
|
4043
|
-
const
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4003
|
+
uid,
|
|
4004
|
+
localValue,
|
|
4005
|
+
schema,
|
|
4006
|
+
model,
|
|
4007
|
+
required = false,
|
|
4008
|
+
validationErrors: initialError
|
|
4009
|
+
} = schemaMapperProps;
|
|
4010
|
+
const initialModel = model != null ? model : null;
|
|
4011
|
+
const options = schema.items.oneOf.map((childSchema, index) => {
|
|
4012
|
+
const { title: title2 = "", description, image, icon, keywords = [] } = childSchema;
|
|
4013
|
+
return {
|
|
4014
|
+
title: title2,
|
|
4015
|
+
description,
|
|
4016
|
+
image: mapSpecImage(image),
|
|
4017
|
+
icon,
|
|
4018
|
+
keywords,
|
|
4019
|
+
disabled: "disabled" in childSchema ? Boolean(childSchema.disabled) : false,
|
|
4020
|
+
component: mapSchemaToComponent(
|
|
4021
|
+
{
|
|
4022
|
+
uid: `${uid}.oneOf-${index}`,
|
|
4023
|
+
schema: childSchema,
|
|
4024
|
+
model: initialModel,
|
|
4025
|
+
localValue,
|
|
4026
|
+
validationErrors: initialError,
|
|
4027
|
+
required
|
|
4028
|
+
},
|
|
4029
|
+
mapperProps
|
|
4030
|
+
)
|
|
4031
|
+
};
|
|
4032
|
+
});
|
|
4033
|
+
const { maxItems, minItems, title, validationMessages } = schema;
|
|
4034
|
+
const { getErrorMessageFunctions, onRefresh, onValueChange, updateComponent } = mapperProps;
|
|
4035
|
+
const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
|
|
4047
4036
|
const { performValidationAsync, validationAsyncState } = getValidationAsyncInitialState(
|
|
4048
4037
|
schemaMapperProps,
|
|
4049
4038
|
mapperProps
|
|
4050
4039
|
);
|
|
4051
|
-
const
|
|
4052
|
-
|
|
4053
|
-
const value = performPersistAsync ? validLocalValue : validModel;
|
|
4054
|
-
return createDateInputComponent(
|
|
4040
|
+
const initialValue = model != null ? model : null;
|
|
4041
|
+
return createMultiSelectComponent(
|
|
4055
4042
|
__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
|
|
4056
|
-
autoComplete:
|
|
4043
|
+
autoComplete: "off",
|
|
4057
4044
|
checks: schema.hidden ? [] : [
|
|
4058
4045
|
getRequiredCheck(required, errorMessageFunctions),
|
|
4059
|
-
|
|
4060
|
-
|
|
4046
|
+
getAboveMaxItemsCheck(schema, errorMessageFunctions),
|
|
4047
|
+
getBelowMinItemsCheck(schema, errorMessageFunctions)
|
|
4061
4048
|
],
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
} : void 0,
|
|
4069
|
-
value,
|
|
4070
|
-
persistedState,
|
|
4049
|
+
initialValue,
|
|
4050
|
+
maxItems,
|
|
4051
|
+
minItems,
|
|
4052
|
+
options,
|
|
4053
|
+
required,
|
|
4054
|
+
title,
|
|
4071
4055
|
validationAsyncState,
|
|
4072
|
-
performPersistAsync,
|
|
4073
|
-
performRefresh: getPerformRefresh(schema, onRefresh),
|
|
4074
4056
|
performValidationAsync,
|
|
4057
|
+
performRefresh: getPerformRefresh(schema, onRefresh),
|
|
4075
4058
|
onValueChange
|
|
4076
4059
|
}),
|
|
4077
4060
|
updateComponent
|
|
4078
4061
|
);
|
|
4079
4062
|
};
|
|
4080
4063
|
|
|
4081
|
-
// src/revamp/domain/components/
|
|
4082
|
-
var
|
|
4083
|
-
const
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4064
|
+
// src/revamp/domain/components/TupleComponent.ts
|
|
4065
|
+
var createTupleComponent = (tupleProps) => {
|
|
4066
|
+
const {
|
|
4067
|
+
uid,
|
|
4068
|
+
analyticsId,
|
|
4069
|
+
alert,
|
|
4070
|
+
components,
|
|
4071
|
+
control,
|
|
4072
|
+
description,
|
|
4073
|
+
help,
|
|
4074
|
+
hidden,
|
|
4075
|
+
icon,
|
|
4076
|
+
image,
|
|
4077
|
+
summariser,
|
|
4078
|
+
title
|
|
4079
|
+
} = tupleProps;
|
|
4080
|
+
return {
|
|
4081
|
+
type: "tuple",
|
|
4082
|
+
uid,
|
|
4083
|
+
analyticsId,
|
|
4084
|
+
alert,
|
|
4085
|
+
components,
|
|
4086
|
+
control,
|
|
4087
|
+
description,
|
|
4088
|
+
help,
|
|
4089
|
+
hidden,
|
|
4090
|
+
icon,
|
|
4091
|
+
image,
|
|
4092
|
+
title,
|
|
4093
|
+
getChildren() {
|
|
4094
|
+
return this.components;
|
|
4095
|
+
},
|
|
4096
|
+
async getSubmittableValue() {
|
|
4097
|
+
return Promise.all(this.components.map(async (child) => child.getSubmittableValue()));
|
|
4098
|
+
},
|
|
4099
|
+
getSubmittableValueSync() {
|
|
4100
|
+
return this.components.map((child) => child.getSubmittableValueSync());
|
|
4101
|
+
},
|
|
4102
|
+
getSummary() {
|
|
4103
|
+
const summary = summariser(this.getLocalValue());
|
|
4104
|
+
const childSummary = summariseFromChildren(this.getChildren());
|
|
4105
|
+
return mergeSummaries(summary, childSummary);
|
|
4106
|
+
},
|
|
4107
|
+
getLocalValue() {
|
|
4108
|
+
return this.components.map((child) => child.getLocalValue());
|
|
4109
|
+
},
|
|
4110
|
+
validate() {
|
|
4111
|
+
return hidden ? true : validateComponents(this.getChildren());
|
|
4112
|
+
}
|
|
4113
|
+
};
|
|
4094
4114
|
};
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
var
|
|
4098
|
-
const
|
|
4099
|
-
|
|
4115
|
+
|
|
4116
|
+
// src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToTupleComponent.ts
|
|
4117
|
+
var arraySchemaToTupleComponent = (schemaMapperProps, mapperProps) => {
|
|
4118
|
+
const {
|
|
4119
|
+
uid,
|
|
4120
|
+
localValue,
|
|
4121
|
+
schema,
|
|
4122
|
+
model: initialModel,
|
|
4123
|
+
required = false,
|
|
4124
|
+
validationErrors
|
|
4125
|
+
} = schemaMapperProps;
|
|
4126
|
+
const { items } = schema;
|
|
4127
|
+
const components = items.map(
|
|
4128
|
+
(childSchema, index) => {
|
|
4129
|
+
var _a, _b;
|
|
4130
|
+
return mapSchemaToComponent(
|
|
4131
|
+
{
|
|
4132
|
+
uid: `${uid}-arr.${index}`,
|
|
4133
|
+
schema: childSchema,
|
|
4134
|
+
model: isArray(initialModel) ? (_a = initialModel[index]) != null ? _a : null : null,
|
|
4135
|
+
localValue: isArray(localValue) ? (_b = localValue[index]) != null ? _b : null : null,
|
|
4136
|
+
validationErrors: isArray(validationErrors) ? validationErrors[index] : void 0,
|
|
4137
|
+
required
|
|
4138
|
+
},
|
|
4139
|
+
mapperProps
|
|
4140
|
+
);
|
|
4141
|
+
}
|
|
4142
|
+
);
|
|
4143
|
+
return createTupleComponent(__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
|
|
4144
|
+
components
|
|
4145
|
+
}));
|
|
4146
|
+
};
|
|
4147
|
+
|
|
4148
|
+
// src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToComponent.ts
|
|
4149
|
+
var arraySchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
4150
|
+
const { schema, model: originalModel } = schemaMapperProps;
|
|
4151
|
+
const model = isNullish(originalModel) || isArrayModel(originalModel) ? originalModel : null;
|
|
4152
|
+
if (isArraySchemaListWithMultiFileUpload(schema)) {
|
|
4153
|
+
return arraySchemaToMultiUploadComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
|
|
4154
|
+
}
|
|
4155
|
+
if (isArraySchemaListWithMultiSelect(schema)) {
|
|
4156
|
+
return arraySchemaToMultiSelectComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
|
|
4157
|
+
}
|
|
4158
|
+
if (isArrayTupleSchema(schema)) {
|
|
4159
|
+
return arraySchemaToTupleComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
|
|
4160
|
+
}
|
|
4161
|
+
return arraySchemaToRepeatableComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
|
|
4100
4162
|
};
|
|
4163
|
+
var isArraySchemaListWithMultiFileUpload = (schema) => isArrayListSchema(schema) && (isPersistAsyncWithUploadSchema(schema.items) || isStringSchemaWithUpload(schema.items));
|
|
4164
|
+
var isPersistAsyncWithUploadSchema = (schema) => isSchemaWithPersistAsync(schema) && (isBlobSchema(schema.persistAsync.schema) || isStringSchemaWithUpload(schema.persistAsync.schema));
|
|
4165
|
+
var isArraySchemaListWithMultiSelect = (schema) => isArrayListSchema(schema) && "oneOf" in schema.items && schema.items.oneOf.every(isConstSchema);
|
|
4101
4166
|
|
|
4102
4167
|
// src/revamp/domain/components/UploadInputComponent.ts
|
|
4103
4168
|
var createUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
@@ -4203,70 +4268,222 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
4203
4268
|
});
|
|
4204
4269
|
};
|
|
4205
4270
|
|
|
4206
|
-
// src/revamp/domain/mappers/schema/
|
|
4207
|
-
var
|
|
4208
|
-
var _a;
|
|
4271
|
+
// src/revamp/domain/mappers/schema/blobSchemaToComponent.ts
|
|
4272
|
+
var blobSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
4209
4273
|
const { schema, localValue, model, required = false } = schemaMapperProps;
|
|
4210
|
-
const { accepts,
|
|
4211
|
-
const { getErrorMessageFunctions, updateComponent,
|
|
4274
|
+
const { accepts, cameraConfig, maxSize, source, validationMessages } = schema;
|
|
4275
|
+
const { getErrorMessageFunctions, updateComponent, onValueChange } = mapperProps;
|
|
4212
4276
|
const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
|
|
4213
4277
|
const { performPersistAsync } = getPersistAsyncInitialState(schemaMapperProps, mapperProps);
|
|
4214
4278
|
const persistedState = performPersistAsync ? getInitialPersistedState(null, model) : getInitialPersistedState();
|
|
4215
4279
|
const validLocalValue = isFile(localValue) ? localValue : null;
|
|
4216
|
-
const value =
|
|
4217
|
-
const checks = hidden ? [] : [
|
|
4218
|
-
getRequiredCheck(required, errorMessageFunctions),
|
|
4219
|
-
getFileSizeCheck(schema, errorMessageFunctions),
|
|
4220
|
-
getFileTypeCheck(schema, errorMessageFunctions)
|
|
4221
|
-
];
|
|
4280
|
+
const value = performPersistAsync ? validLocalValue : null;
|
|
4222
4281
|
return createUploadInputComponent(
|
|
4223
4282
|
__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
|
|
4224
4283
|
accepts,
|
|
4225
|
-
autoComplete:
|
|
4284
|
+
autoComplete: "off",
|
|
4226
4285
|
cameraConfig,
|
|
4227
|
-
|
|
4228
|
-
format: "base64",
|
|
4286
|
+
format: "blob",
|
|
4229
4287
|
maxSize,
|
|
4230
4288
|
source,
|
|
4231
4289
|
value,
|
|
4232
4290
|
persistedState,
|
|
4233
4291
|
performPersistAsync,
|
|
4234
|
-
|
|
4292
|
+
checks: schema.hidden ? [] : [getRequiredCheck(required, errorMessageFunctions)],
|
|
4235
4293
|
onValueChange
|
|
4236
4294
|
}),
|
|
4237
4295
|
updateComponent
|
|
4238
4296
|
);
|
|
4239
4297
|
};
|
|
4240
|
-
var getFileFromModel = (model) => isString(model) ? base64dataUrltoFile(model, "") : null;
|
|
4241
4298
|
|
|
4242
|
-
// src/revamp/domain/components/
|
|
4243
|
-
var
|
|
4244
|
-
const _a =
|
|
4299
|
+
// src/revamp/domain/components/BooleanInputComponent.ts
|
|
4300
|
+
var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
|
|
4301
|
+
const _a = booleanInputProps, {
|
|
4302
|
+
uid,
|
|
4303
|
+
id,
|
|
4304
|
+
value,
|
|
4305
|
+
performPersistAsync,
|
|
4306
|
+
performRefresh,
|
|
4307
|
+
performValidationAsync,
|
|
4308
|
+
onValueChange,
|
|
4309
|
+
summariser
|
|
4310
|
+
} = _a, rest = __objRest(_a, [
|
|
4311
|
+
"uid",
|
|
4312
|
+
"id",
|
|
4313
|
+
"value",
|
|
4314
|
+
"performPersistAsync",
|
|
4315
|
+
"performRefresh",
|
|
4316
|
+
"performValidationAsync",
|
|
4317
|
+
"onValueChange",
|
|
4318
|
+
"summariser"
|
|
4319
|
+
]);
|
|
4320
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
4321
|
+
const booleanComponent = __spreadValues({
|
|
4322
|
+
type: "boolean",
|
|
4323
|
+
uid,
|
|
4324
|
+
id,
|
|
4325
|
+
autoComplete: "",
|
|
4326
|
+
value,
|
|
4327
|
+
_update(updateFn) {
|
|
4328
|
+
update(this, updateFn);
|
|
4329
|
+
},
|
|
4330
|
+
onBlur() {
|
|
4331
|
+
},
|
|
4332
|
+
// Noop
|
|
4333
|
+
onFocus() {
|
|
4334
|
+
},
|
|
4335
|
+
// Noop
|
|
4336
|
+
onChange(updatedValue) {
|
|
4337
|
+
this._update((draft) => {
|
|
4338
|
+
draft.errors = [];
|
|
4339
|
+
draft.value = updatedValue;
|
|
4340
|
+
});
|
|
4341
|
+
performRefresh == null ? void 0 : performRefresh();
|
|
4342
|
+
onValueChange();
|
|
4343
|
+
},
|
|
4344
|
+
async getSubmittableValue() {
|
|
4345
|
+
return this.getSubmittableValueSync();
|
|
4346
|
+
},
|
|
4347
|
+
getSubmittableValueSync() {
|
|
4348
|
+
return this.getLocalValue();
|
|
4349
|
+
},
|
|
4350
|
+
getSummary() {
|
|
4351
|
+
return summariser(this.getLocalValue());
|
|
4352
|
+
},
|
|
4353
|
+
getLocalValue() {
|
|
4354
|
+
return this.value;
|
|
4355
|
+
},
|
|
4356
|
+
validate: () => true
|
|
4357
|
+
}, rest);
|
|
4358
|
+
if (performRefresh) {
|
|
4359
|
+
return booleanComponent;
|
|
4360
|
+
}
|
|
4361
|
+
if (performPersistAsync) {
|
|
4362
|
+
const persist = getComponentPersistAsync(update, performPersistAsync);
|
|
4363
|
+
return __spreadProps(__spreadValues({}, booleanComponent), {
|
|
4364
|
+
onChange(updatedValue) {
|
|
4365
|
+
booleanComponent.onChange.call(this, updatedValue);
|
|
4366
|
+
persist(this, this.getLocalValue()).catch(() => {
|
|
4367
|
+
});
|
|
4368
|
+
},
|
|
4369
|
+
async getSubmittableValue() {
|
|
4370
|
+
return persist(this, this.getLocalValue());
|
|
4371
|
+
},
|
|
4372
|
+
getSubmittableValueSync() {
|
|
4373
|
+
return this.persistedState.lastResponse;
|
|
4374
|
+
}
|
|
4375
|
+
});
|
|
4376
|
+
}
|
|
4377
|
+
if (performValidationAsync) {
|
|
4378
|
+
const validateAsync = getComponentValidationAsync(update, performValidationAsync);
|
|
4379
|
+
return __spreadProps(__spreadValues({}, booleanComponent), {
|
|
4380
|
+
onChange(updatedValue) {
|
|
4381
|
+
booleanComponent.onChange.call(this, updatedValue);
|
|
4382
|
+
validateAsync(this, this.getLocalValue()).catch(() => {
|
|
4383
|
+
});
|
|
4384
|
+
}
|
|
4385
|
+
});
|
|
4386
|
+
}
|
|
4387
|
+
return booleanComponent;
|
|
4388
|
+
};
|
|
4389
|
+
|
|
4390
|
+
// src/revamp/domain/mappers/schema/booleanSchemaToComponent.ts
|
|
4391
|
+
var booleanSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
4392
|
+
const { schema, localValue, model } = schemaMapperProps;
|
|
4393
|
+
const { default: defaultValue } = schema;
|
|
4394
|
+
const { updateComponent, onRefresh, onValueChange } = mapperProps;
|
|
4395
|
+
const performRefresh = getPerformRefresh(schema, onRefresh);
|
|
4396
|
+
const { performPersistAsync, persistedState } = getPersistAsyncInitialState(
|
|
4397
|
+
schemaMapperProps,
|
|
4398
|
+
mapperProps
|
|
4399
|
+
);
|
|
4400
|
+
const { performValidationAsync, validationAsyncState } = getValidationAsyncInitialState(
|
|
4401
|
+
schemaMapperProps,
|
|
4402
|
+
mapperProps
|
|
4403
|
+
);
|
|
4404
|
+
const validLocalValue = isBoolean(localValue) ? localValue : false;
|
|
4405
|
+
const validModel = getValidModel(model, defaultValue);
|
|
4406
|
+
const value = performPersistAsync ? validLocalValue : validModel;
|
|
4407
|
+
return createBooleanInputComponent(
|
|
4408
|
+
__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
|
|
4409
|
+
value: value != null ? value : false,
|
|
4410
|
+
persistedState,
|
|
4411
|
+
validationAsyncState,
|
|
4412
|
+
performPersistAsync,
|
|
4413
|
+
performRefresh,
|
|
4414
|
+
performValidationAsync,
|
|
4415
|
+
onValueChange
|
|
4416
|
+
}),
|
|
4417
|
+
updateComponent
|
|
4418
|
+
);
|
|
4419
|
+
};
|
|
4420
|
+
var getValidModel = (model, defaultValue) => {
|
|
4421
|
+
if (isBoolean(model)) {
|
|
4422
|
+
return model;
|
|
4423
|
+
}
|
|
4424
|
+
if (isBoolean(defaultValue)) {
|
|
4425
|
+
return defaultValue;
|
|
4426
|
+
}
|
|
4427
|
+
return false;
|
|
4428
|
+
};
|
|
4429
|
+
|
|
4430
|
+
// src/revamp/domain/components/ConstComponent.ts
|
|
4431
|
+
var createConstComponent = (hiddenProps) => {
|
|
4432
|
+
const { uid, analyticsId, value, summary } = hiddenProps;
|
|
4433
|
+
return {
|
|
4434
|
+
type: "const",
|
|
4435
|
+
uid,
|
|
4436
|
+
analyticsId,
|
|
4437
|
+
getLocalValue: () => value,
|
|
4438
|
+
getSubmittableValue: async () => value,
|
|
4439
|
+
getSubmittableValueSync: () => value,
|
|
4440
|
+
getSummary: () => summary,
|
|
4441
|
+
validate: () => true
|
|
4442
|
+
};
|
|
4443
|
+
};
|
|
4444
|
+
|
|
4445
|
+
// src/revamp/domain/mappers/schema/constSchemaToComponent.ts
|
|
4446
|
+
var constSchemaToComponent = (uid, schemaMapperProps) => {
|
|
4447
|
+
var _a;
|
|
4448
|
+
const { schema } = schemaMapperProps;
|
|
4449
|
+
const { title, const: constValue, analyticsId, $id } = schema;
|
|
4450
|
+
const titleOrValue = (_a = title != null ? title : constValue) != null ? _a : null;
|
|
4451
|
+
return createConstComponent({
|
|
4452
|
+
uid,
|
|
4453
|
+
analyticsId: analyticsId != null ? analyticsId : $id,
|
|
4454
|
+
summary: getConstSummary(schema, titleOrValue),
|
|
4455
|
+
value: schema.const
|
|
4456
|
+
});
|
|
4457
|
+
};
|
|
4458
|
+
|
|
4459
|
+
// src/revamp/domain/components/IntegerInputComponent.ts
|
|
4460
|
+
var createIntegerInputComponent = (integerInputProps, updateComponent) => {
|
|
4461
|
+
const _a = integerInputProps, {
|
|
4245
4462
|
uid,
|
|
4246
4463
|
id,
|
|
4247
4464
|
checks,
|
|
4465
|
+
value,
|
|
4248
4466
|
performPersistAsync,
|
|
4249
4467
|
performRefresh,
|
|
4250
4468
|
performValidationAsync,
|
|
4251
4469
|
onValueChange,
|
|
4252
|
-
summariser
|
|
4253
|
-
value
|
|
4470
|
+
summariser
|
|
4254
4471
|
} = _a, rest = __objRest(_a, [
|
|
4255
4472
|
"uid",
|
|
4256
4473
|
"id",
|
|
4257
4474
|
"checks",
|
|
4475
|
+
"value",
|
|
4258
4476
|
"performPersistAsync",
|
|
4259
4477
|
"performRefresh",
|
|
4260
4478
|
"performValidationAsync",
|
|
4261
4479
|
"onValueChange",
|
|
4262
|
-
"summariser"
|
|
4263
|
-
"value"
|
|
4480
|
+
"summariser"
|
|
4264
4481
|
]);
|
|
4265
4482
|
const update = getInputUpdateFunction(updateComponent);
|
|
4266
4483
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
4267
4484
|
const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh, getValidationErrors);
|
|
4268
|
-
const
|
|
4269
|
-
type: "
|
|
4485
|
+
const integerComponent = __spreadValues({
|
|
4486
|
+
type: "integer",
|
|
4270
4487
|
uid,
|
|
4271
4488
|
id,
|
|
4272
4489
|
value,
|
|
@@ -4294,7 +4511,8 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
|
|
|
4294
4511
|
return this.getSubmittableValueSync();
|
|
4295
4512
|
},
|
|
4296
4513
|
getSubmittableValueSync() {
|
|
4297
|
-
|
|
4514
|
+
var _a2;
|
|
4515
|
+
return (_a2 = this.getLocalValue()) != null ? _a2 : null;
|
|
4298
4516
|
},
|
|
4299
4517
|
getSummary() {
|
|
4300
4518
|
return summariser(this.getLocalValue());
|
|
@@ -4311,11 +4529,11 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
|
|
|
4311
4529
|
}
|
|
4312
4530
|
}, rest);
|
|
4313
4531
|
if (performRefresh) {
|
|
4314
|
-
return
|
|
4532
|
+
return integerComponent;
|
|
4315
4533
|
}
|
|
4316
4534
|
if (performPersistAsync) {
|
|
4317
4535
|
const persist = getComponentPersistAsync(update, performPersistAsync);
|
|
4318
|
-
return __spreadProps(__spreadValues({},
|
|
4536
|
+
return __spreadProps(__spreadValues({}, integerComponent), {
|
|
4319
4537
|
onBlur() {
|
|
4320
4538
|
if (this.validate()) {
|
|
4321
4539
|
persist(this, this.getLocalValue()).catch(() => {
|
|
@@ -4332,43 +4550,28 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
|
|
|
4332
4550
|
}
|
|
4333
4551
|
if (performValidationAsync) {
|
|
4334
4552
|
const validateAsync = getDebouncedComponentValidationAsync(update, performValidationAsync);
|
|
4335
|
-
return __spreadProps(__spreadValues({},
|
|
4553
|
+
return __spreadProps(__spreadValues({}, integerComponent), {
|
|
4336
4554
|
onBlur() {
|
|
4337
4555
|
if (this.validate()) {
|
|
4338
4556
|
validateAsync.flush();
|
|
4339
4557
|
}
|
|
4340
4558
|
},
|
|
4341
4559
|
onChange(updatedValue) {
|
|
4342
|
-
|
|
4560
|
+
integerComponent.onChange.call(this, updatedValue);
|
|
4343
4561
|
if (getValidationErrors(updatedValue).length === 0) {
|
|
4344
4562
|
validateAsync(this, updatedValue);
|
|
4345
4563
|
}
|
|
4346
|
-
if (!updatedValue) {
|
|
4347
|
-
validateAsync.cancel();
|
|
4348
|
-
}
|
|
4349
4564
|
}
|
|
4350
4565
|
});
|
|
4351
4566
|
}
|
|
4352
|
-
return
|
|
4567
|
+
return integerComponent;
|
|
4353
4568
|
};
|
|
4354
4569
|
|
|
4355
|
-
// src/revamp/domain/mappers/schema/
|
|
4356
|
-
var
|
|
4570
|
+
// src/revamp/domain/mappers/schema/integerSchemaToComponent.ts
|
|
4571
|
+
var integerSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
4357
4572
|
const { schema, localValue, model, required = false } = schemaMapperProps;
|
|
4358
|
-
const {
|
|
4359
|
-
|
|
4360
|
-
autocompleteHint,
|
|
4361
|
-
control,
|
|
4362
|
-
default: defaultValue,
|
|
4363
|
-
displayFormat,
|
|
4364
|
-
format,
|
|
4365
|
-
maxLength,
|
|
4366
|
-
minLength,
|
|
4367
|
-
suggestions,
|
|
4368
|
-
validationMessages
|
|
4369
|
-
} = schema;
|
|
4370
|
-
const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange, logEvent } = mapperProps;
|
|
4371
|
-
const controlForLegacyFormat = getControlForLegacyFormat(format);
|
|
4573
|
+
const { autocompleteHint, validationMessages, default: defaultValue, maximum, minimum } = schema;
|
|
4574
|
+
const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange } = mapperProps;
|
|
4372
4575
|
const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
|
|
4373
4576
|
const { performPersistAsync, persistedState } = getPersistAsyncInitialState(
|
|
4374
4577
|
schemaMapperProps,
|
|
@@ -4378,30 +4581,22 @@ var stringSchemaToTextInputComponent = (schemaMapperProps, mapperProps) => {
|
|
|
4378
4581
|
schemaMapperProps,
|
|
4379
4582
|
mapperProps
|
|
4380
4583
|
);
|
|
4381
|
-
const validLocalValue =
|
|
4382
|
-
const validModel =
|
|
4584
|
+
const validLocalValue = isInteger(localValue) ? localValue : null;
|
|
4585
|
+
const validModel = isInteger(model) ? model : defaultValue != null ? defaultValue : null;
|
|
4383
4586
|
const value = performPersistAsync ? validLocalValue : validModel;
|
|
4384
|
-
|
|
4587
|
+
const checks = [
|
|
4588
|
+
getRequiredCheck(required, errorMessageFunctions),
|
|
4589
|
+
getBelowMinimumCheck(schema, errorMessageFunctions),
|
|
4590
|
+
getAboveMaximumCheck(schema, errorMessageFunctions)
|
|
4591
|
+
];
|
|
4592
|
+
return createIntegerInputComponent(
|
|
4385
4593
|
__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
|
|
4386
|
-
autocapitalization,
|
|
4387
4594
|
autoComplete: getAutocompleteString(autocompleteHint),
|
|
4388
|
-
checks
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
getBelowMinLengthCheck(schema, errorMessageFunctions),
|
|
4392
|
-
getNotAdheringToPatternCheck(schema, errorMessageFunctions, { logEvent })
|
|
4393
|
-
],
|
|
4394
|
-
control: control != null ? control : controlForLegacyFormat,
|
|
4395
|
-
displayFormat,
|
|
4396
|
-
maxLength,
|
|
4397
|
-
minLength,
|
|
4398
|
-
suggestions: suggestions ? {
|
|
4399
|
-
values: suggestions.values.map((suggestion) => __spreadProps(__spreadValues({}, suggestion), {
|
|
4400
|
-
image: mapSpecImage(suggestion.image)
|
|
4401
|
-
}))
|
|
4402
|
-
} : void 0,
|
|
4403
|
-
value,
|
|
4595
|
+
checks,
|
|
4596
|
+
maximum,
|
|
4597
|
+
minimum,
|
|
4404
4598
|
persistedState,
|
|
4599
|
+
value,
|
|
4405
4600
|
validationAsyncState,
|
|
4406
4601
|
performPersistAsync,
|
|
4407
4602
|
performRefresh: getPerformRefresh(schema, onRefresh),
|
|
@@ -4411,482 +4606,361 @@ var stringSchemaToTextInputComponent = (schemaMapperProps, mapperProps) => {
|
|
|
4411
4606
|
updateComponent
|
|
4412
4607
|
);
|
|
4413
4608
|
};
|
|
4414
|
-
var getControlForLegacyFormat = (format) => {
|
|
4415
|
-
if (format && ["numeric", "phone-number", "email", "password"].includes(format)) {
|
|
4416
|
-
return format;
|
|
4417
|
-
}
|
|
4418
|
-
return void 0;
|
|
4419
|
-
};
|
|
4420
4609
|
|
|
4421
|
-
// src/revamp/domain/
|
|
4422
|
-
var
|
|
4423
|
-
const {
|
|
4424
|
-
if (isStringSchemaWithBase64(schema)) {
|
|
4425
|
-
return stringSchemaToUploadInputComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema }), mapperProps);
|
|
4426
|
-
}
|
|
4427
|
-
switch (schema.format) {
|
|
4428
|
-
case "date":
|
|
4429
|
-
return stringSchemaToDateInputComponent(schemaMapperProps, mapperProps);
|
|
4430
|
-
default:
|
|
4431
|
-
return stringSchemaToTextInputComponent(schemaMapperProps, mapperProps);
|
|
4432
|
-
}
|
|
4433
|
-
};
|
|
4434
|
-
var isStringSchemaWithBase64 = (schema) => {
|
|
4435
|
-
return schema.format === "base64url" && !("persistAsync" in schema);
|
|
4436
|
-
};
|
|
4437
|
-
|
|
4438
|
-
// src/revamp/domain/components/ContainerComponent.ts
|
|
4439
|
-
var createContainerComponent = (containerProps) => __spreadProps(__spreadValues({}, containerProps), {
|
|
4440
|
-
type: "container",
|
|
4441
|
-
getChildren() {
|
|
4442
|
-
return this.components;
|
|
4443
|
-
},
|
|
4444
|
-
async getSubmittableValue() {
|
|
4445
|
-
return getSubmittableData(this.components);
|
|
4446
|
-
},
|
|
4447
|
-
getSubmittableValueSync() {
|
|
4448
|
-
return getSubmittableDataSync(this.components);
|
|
4449
|
-
},
|
|
4450
|
-
getSummary() {
|
|
4451
|
-
return summariseFromChildren(this.getChildren());
|
|
4452
|
-
},
|
|
4453
|
-
getLocalValue() {
|
|
4454
|
-
return getLocalValues(this.components);
|
|
4455
|
-
},
|
|
4456
|
-
validate() {
|
|
4457
|
-
return validateComponents(this.getChildren());
|
|
4458
|
-
}
|
|
4459
|
-
});
|
|
4460
|
-
|
|
4461
|
-
// src/revamp/domain/components/RepeatableComponent.ts
|
|
4462
|
-
var createRepeatableComponent = (repeatableProps, updateComponent) => {
|
|
4463
|
-
const _a = repeatableProps, {
|
|
4610
|
+
// src/revamp/domain/components/ObjectComponent.ts
|
|
4611
|
+
var createObjectComponent = (objectProps) => {
|
|
4612
|
+
const {
|
|
4464
4613
|
uid,
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
"
|
|
4480
|
-
"summariser"
|
|
4481
|
-
]);
|
|
4482
|
-
const update = getInputUpdateFunction(updateComponent);
|
|
4483
|
-
const getValidationErrors = getLocalValueValidator(checks);
|
|
4484
|
-
const repeatableComponent = __spreadProps(__spreadValues({
|
|
4614
|
+
analyticsId,
|
|
4615
|
+
alert,
|
|
4616
|
+
componentMap,
|
|
4617
|
+
control,
|
|
4618
|
+
description,
|
|
4619
|
+
displayOrder,
|
|
4620
|
+
help,
|
|
4621
|
+
hidden,
|
|
4622
|
+
icon,
|
|
4623
|
+
image,
|
|
4624
|
+
summariser,
|
|
4625
|
+
title
|
|
4626
|
+
} = objectProps;
|
|
4627
|
+
return {
|
|
4628
|
+
type: "object",
|
|
4485
4629
|
uid,
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
}
|
|
4497
|
-
}, componentProps), {
|
|
4498
|
-
_update(updateFn) {
|
|
4499
|
-
update(this, updateFn);
|
|
4500
|
-
},
|
|
4501
|
-
onEdit(itemIndex) {
|
|
4502
|
-
this._update((draft) => {
|
|
4503
|
-
draft.editableComponent = createEditableComponent(
|
|
4504
|
-
draft.components[itemIndex].getLocalValue()
|
|
4505
|
-
);
|
|
4506
|
-
draft.editableIndex = itemIndex;
|
|
4507
|
-
});
|
|
4508
|
-
},
|
|
4509
|
-
onAdd() {
|
|
4510
|
-
this._update((draft) => {
|
|
4511
|
-
draft.editableComponent = createEditableComponent(null);
|
|
4512
|
-
draft.editableIndex = null;
|
|
4513
|
-
draft.errors = [];
|
|
4514
|
-
});
|
|
4515
|
-
},
|
|
4516
|
-
onSave() {
|
|
4517
|
-
var _a2;
|
|
4518
|
-
const isValid = (_a2 = this.editableComponent) == null ? void 0 : _a2.validate();
|
|
4519
|
-
if (!isValid) {
|
|
4520
|
-
return false;
|
|
4521
|
-
}
|
|
4522
|
-
this._update((draft) => {
|
|
4523
|
-
if (draft.editableComponent === null) {
|
|
4524
|
-
return;
|
|
4525
|
-
}
|
|
4526
|
-
if (draft.editableIndex === null) {
|
|
4527
|
-
const newComponent = __spreadValues({}, draft.editableComponent);
|
|
4528
|
-
draft.components = [...this.components, newComponent];
|
|
4529
|
-
} else {
|
|
4530
|
-
draft.components[draft.editableIndex] = __spreadProps(__spreadValues({}, draft.editableComponent), {
|
|
4531
|
-
uid: draft.components[draft.editableIndex].uid
|
|
4532
|
-
});
|
|
4533
|
-
}
|
|
4534
|
-
draft.editableComponent = null;
|
|
4535
|
-
draft.editableIndex = null;
|
|
4536
|
-
});
|
|
4537
|
-
onValueChange();
|
|
4538
|
-
return true;
|
|
4539
|
-
},
|
|
4540
|
-
onRemove() {
|
|
4541
|
-
this._update((draft) => {
|
|
4542
|
-
if (draft.editableIndex === null) {
|
|
4543
|
-
return;
|
|
4544
|
-
}
|
|
4545
|
-
draft.components.splice(draft.editableIndex, 1);
|
|
4546
|
-
draft.editableComponent = null;
|
|
4547
|
-
draft.editableIndex = null;
|
|
4548
|
-
});
|
|
4549
|
-
onValueChange();
|
|
4550
|
-
},
|
|
4630
|
+
analyticsId,
|
|
4631
|
+
alert,
|
|
4632
|
+
componentMap,
|
|
4633
|
+
control,
|
|
4634
|
+
description,
|
|
4635
|
+
help,
|
|
4636
|
+
hidden,
|
|
4637
|
+
icon,
|
|
4638
|
+
image,
|
|
4639
|
+
title,
|
|
4551
4640
|
getChildren() {
|
|
4552
|
-
return
|
|
4641
|
+
return displayOrder.map((propName) => this.componentMap[propName]);
|
|
4553
4642
|
},
|
|
4554
4643
|
async getSubmittableValue() {
|
|
4555
|
-
return Promise.all(
|
|
4644
|
+
return Promise.all(
|
|
4645
|
+
displayOrder.map(
|
|
4646
|
+
async (propName) => this.componentMap[propName].getSubmittableValue().then((value) => ({ value, propName }))
|
|
4647
|
+
)
|
|
4648
|
+
).then(
|
|
4649
|
+
(values) => values.reduce(
|
|
4650
|
+
(acc, { value, propName }) => __spreadValues(__spreadValues({}, acc), value === null ? {} : { [propName]: value }),
|
|
4651
|
+
{}
|
|
4652
|
+
)
|
|
4653
|
+
);
|
|
4556
4654
|
},
|
|
4557
4655
|
getSubmittableValueSync() {
|
|
4558
|
-
return
|
|
4656
|
+
return mergeChildrenValues(
|
|
4657
|
+
displayOrder,
|
|
4658
|
+
(propName) => this.componentMap[propName].getSubmittableValueSync()
|
|
4659
|
+
);
|
|
4559
4660
|
},
|
|
4560
4661
|
getSummary() {
|
|
4561
|
-
|
|
4662
|
+
const summary = summariser(this.getLocalValue());
|
|
4663
|
+
const childSummary = summariseFromChildren(this.getChildren());
|
|
4664
|
+
return mergeSummaries(summary, childSummary);
|
|
4562
4665
|
},
|
|
4563
4666
|
getLocalValue() {
|
|
4564
|
-
return
|
|
4667
|
+
return mergeChildrenValues(
|
|
4668
|
+
displayOrder,
|
|
4669
|
+
(propName) => this.componentMap[propName].getLocalValue()
|
|
4670
|
+
);
|
|
4565
4671
|
},
|
|
4566
4672
|
validate() {
|
|
4567
|
-
|
|
4568
|
-
const childComponentsValid = validateComponents(this.getChildren());
|
|
4569
|
-
this._update((draft) => {
|
|
4570
|
-
draft.errors = messages;
|
|
4571
|
-
});
|
|
4572
|
-
return messages.length === 0 && childComponentsValid;
|
|
4673
|
+
return hidden ? true : validateComponents(this.getChildren());
|
|
4573
4674
|
}
|
|
4574
|
-
}
|
|
4575
|
-
return repeatableComponent;
|
|
4675
|
+
};
|
|
4576
4676
|
};
|
|
4677
|
+
var mergeChildrenValues = (displayOrder, getComponentValue) => displayOrder.reduce((acc, propName) => {
|
|
4678
|
+
const componentValue = getComponentValue(propName);
|
|
4679
|
+
return __spreadValues(__spreadValues({}, acc), componentValue === null ? {} : { [propName]: componentValue });
|
|
4680
|
+
}, {});
|
|
4577
4681
|
|
|
4578
|
-
// src/revamp/domain/mappers/schema/
|
|
4579
|
-
var
|
|
4580
|
-
const {
|
|
4581
|
-
const {
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
)
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
schema: items,
|
|
4608
|
-
localValue: editableValue,
|
|
4609
|
-
model: localValueToJsonElement(editableValue),
|
|
4610
|
-
validationErrors: void 0,
|
|
4611
|
-
required: true
|
|
4612
|
-
},
|
|
4613
|
-
mapperProps
|
|
4614
|
-
);
|
|
4615
|
-
const { onValueChange } = mapperProps;
|
|
4616
|
-
const errorMessageFunctions = getErrorMessageFunctions(schema.validationMessages);
|
|
4617
|
-
return createRepeatableComponent(
|
|
4618
|
-
__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
|
|
4619
|
-
addItemTitle,
|
|
4620
|
-
checks: schema.hidden ? [] : [
|
|
4621
|
-
getRequiredCheck(required, errorMessageFunctions),
|
|
4622
|
-
getAboveMaxItemsCheck(schema, errorMessageFunctions),
|
|
4623
|
-
getBelowMinItemsCheck(schema, errorMessageFunctions)
|
|
4624
|
-
],
|
|
4625
|
-
components: components != null ? components : [],
|
|
4626
|
-
editItemTitle,
|
|
4627
|
-
maxItems,
|
|
4628
|
-
minItems,
|
|
4629
|
-
summary: __spreadProps(__spreadValues({}, summary), {
|
|
4630
|
-
defaultImage: mapSpecImage(summary == null ? void 0 : summary.defaultImage)
|
|
4631
|
-
}),
|
|
4632
|
-
createEditableComponent,
|
|
4633
|
-
onValueChange
|
|
4634
|
-
}),
|
|
4635
|
-
mapperProps.updateComponent
|
|
4636
|
-
);
|
|
4682
|
+
// src/revamp/domain/mappers/schema/objectSchemaToComponent/objectSchemaToComponent.ts
|
|
4683
|
+
var objectSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
4684
|
+
const { uid, localValue, schema, model, validationErrors } = schemaMapperProps;
|
|
4685
|
+
const { $id, displayOrder, properties, required } = schema;
|
|
4686
|
+
validateDisplayOrder($id, displayOrder, properties, mapperProps.logEvent);
|
|
4687
|
+
const componentMap = displayOrder.reduce((acc, propName) => {
|
|
4688
|
+
var _a;
|
|
4689
|
+
const propSchema = properties[propName];
|
|
4690
|
+
if (propSchema === void 0) {
|
|
4691
|
+
throw new Error(`Object schema ${$id} has no property named ${propName}`);
|
|
4692
|
+
}
|
|
4693
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
4694
|
+
[propName]: mapSchemaToComponent(
|
|
4695
|
+
{
|
|
4696
|
+
uid: `${uid}.obj-${propName}`,
|
|
4697
|
+
schema: propSchema,
|
|
4698
|
+
model: isObjectModel(model) ? model[propName] : null,
|
|
4699
|
+
localValue: isObjectLocalValue(localValue) ? localValue[propName] : null,
|
|
4700
|
+
required: (_a = required == null ? void 0 : required.includes(propName)) != null ? _a : false,
|
|
4701
|
+
validationErrors: isObject(validationErrors) ? validationErrors[propName] : void 0
|
|
4702
|
+
},
|
|
4703
|
+
mapperProps
|
|
4704
|
+
)
|
|
4705
|
+
});
|
|
4706
|
+
}, {});
|
|
4707
|
+
return createObjectComponent(__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
|
|
4708
|
+
componentMap,
|
|
4709
|
+
displayOrder
|
|
4710
|
+
}));
|
|
4637
4711
|
};
|
|
4638
|
-
var
|
|
4639
|
-
if (
|
|
4640
|
-
|
|
4712
|
+
var validateDisplayOrder = ($id, displayOrder, properties, logEvent) => {
|
|
4713
|
+
if (!displayOrder) {
|
|
4714
|
+
const message = `Object schema ${$id} has no displayOrder property.`;
|
|
4715
|
+
logEvent("error", message);
|
|
4716
|
+
throw new Error(message);
|
|
4641
4717
|
}
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4718
|
+
const propertyNames = Object.keys(properties);
|
|
4719
|
+
displayOrder.forEach((propName) => {
|
|
4720
|
+
if (!properties[propName]) {
|
|
4721
|
+
const message = `Object schema ${$id} has no property named "${propName}", but it is listed in the displayOrder array.`;
|
|
4722
|
+
logEvent("error", message);
|
|
4723
|
+
throw new Error(message);
|
|
4724
|
+
}
|
|
4725
|
+
});
|
|
4726
|
+
propertyNames.forEach((propName) => {
|
|
4727
|
+
if (!displayOrder.includes(propName)) {
|
|
4728
|
+
const message = `Object schema ${$id} has a "${propName}" property which is missing in the displayOrder array.`;
|
|
4729
|
+
logEvent("error", message);
|
|
4730
|
+
throw new Error(message);
|
|
4731
|
+
}
|
|
4732
|
+
});
|
|
4733
|
+
};
|
|
4734
|
+
|
|
4735
|
+
// src/revamp/domain/components/utils/isPartialModelMatch.ts
|
|
4736
|
+
var isPartialModelMatch = (localModel, incomingModel) => {
|
|
4737
|
+
if (isArrayModel(localModel) && isArrayModel(incomingModel)) {
|
|
4738
|
+
return localModel.length === incomingModel.length && localModel.every((value, index) => isPartialModelMatch(value, incomingModel[index]));
|
|
4646
4739
|
}
|
|
4647
|
-
if (
|
|
4648
|
-
|
|
4740
|
+
if (isObjectModel(localModel) && isObjectModel(incomingModel)) {
|
|
4741
|
+
if (Object.keys(localModel).length === 0 && Object.keys(incomingModel).length === 0) {
|
|
4742
|
+
return true;
|
|
4743
|
+
}
|
|
4744
|
+
const nonNullishKeysInBoth = nonNullishKeys(localModel).filter(
|
|
4745
|
+
(key) => nonNullishKeys(incomingModel).includes(key)
|
|
4746
|
+
);
|
|
4747
|
+
return nonNullishKeysInBoth.length > 0 && nonNullishKeysInBoth.every((key) => isPartialModelMatch(localModel[key], incomingModel[key]));
|
|
4649
4748
|
}
|
|
4650
|
-
return
|
|
4749
|
+
return localModel === incomingModel;
|
|
4651
4750
|
};
|
|
4652
|
-
var
|
|
4751
|
+
var nonNullishKeys = (model) => Object.keys(model).filter((key) => !isNullish(model[key]));
|
|
4653
4752
|
|
|
4654
|
-
// src/revamp/domain/components/
|
|
4655
|
-
var
|
|
4656
|
-
const _a =
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
performPersistAsync,
|
|
4663
|
-
onValueChange,
|
|
4664
|
-
summariser
|
|
4665
|
-
} = _a, rest = __objRest(_a, [
|
|
4666
|
-
"uid",
|
|
4667
|
-
"id",
|
|
4668
|
-
"checks",
|
|
4669
|
-
"fileChecks",
|
|
4670
|
-
"format",
|
|
4671
|
-
"performPersistAsync",
|
|
4672
|
-
"onValueChange",
|
|
4673
|
-
"summariser"
|
|
4674
|
-
]);
|
|
4753
|
+
// src/revamp/domain/components/SelectInputComponent.ts
|
|
4754
|
+
var createSelectInputComponent = (selectProps, updateComponent) => {
|
|
4755
|
+
const _a = selectProps, { uid, checks, initialModel, options, performRefresh, onValueChange, summariser } = _a, rest = __objRest(_a, ["uid", "checks", "initialModel", "options", "performRefresh", "onValueChange", "summariser"]);
|
|
4756
|
+
const children = options.map((option) => option.component);
|
|
4757
|
+
const matchingOptions = options.map(
|
|
4758
|
+
(option) => isPartialModelMatch(option.component.getSubmittableValueSync(), initialModel)
|
|
4759
|
+
);
|
|
4760
|
+
const selectedIndex = matchingOptions.filter((match) => match).length === 1 ? matchingOptions.indexOf(true) : null;
|
|
4675
4761
|
const update = getInputUpdateFunction(updateComponent);
|
|
4676
4762
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
4677
|
-
const
|
|
4678
|
-
const uploadComponent = __spreadValues({
|
|
4679
|
-
type: "multi-upload",
|
|
4763
|
+
const component = __spreadProps(__spreadValues({
|
|
4680
4764
|
uid,
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4765
|
+
type: "select",
|
|
4766
|
+
children,
|
|
4767
|
+
options,
|
|
4768
|
+
selectedIndex,
|
|
4769
|
+
value: null
|
|
4770
|
+
}, rest), {
|
|
4684
4771
|
_update(updateFn) {
|
|
4685
4772
|
update(this, updateFn);
|
|
4686
4773
|
},
|
|
4687
|
-
|
|
4688
|
-
this.
|
|
4689
|
-
},
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
async onRemoveFile(index) {
|
|
4694
|
-
this._update((draft) => {
|
|
4695
|
-
draft.value.splice(index, 1);
|
|
4696
|
-
draft.files.splice(index, 1);
|
|
4697
|
-
});
|
|
4698
|
-
},
|
|
4699
|
-
async onInsertFile(index, file) {
|
|
4700
|
-
const fileErrors = getFileValidationErrors(file);
|
|
4701
|
-
const fileId = getRandomId();
|
|
4702
|
-
this._update((draft) => {
|
|
4703
|
-
draft.value.splice(index, 0, file);
|
|
4704
|
-
draft.files.splice(index, 0, { file, id: fileId, errors: fileErrors });
|
|
4705
|
-
draft.errors = [];
|
|
4706
|
-
});
|
|
4707
|
-
onValueChange();
|
|
4708
|
-
return fileId;
|
|
4709
|
-
},
|
|
4774
|
+
getChildren() {
|
|
4775
|
+
return this.children;
|
|
4776
|
+
},
|
|
4777
|
+
getSelectedChild() {
|
|
4778
|
+
return this.selectedIndex !== null ? this.children[this.selectedIndex] : null;
|
|
4779
|
+
},
|
|
4710
4780
|
async getSubmittableValue() {
|
|
4711
|
-
|
|
4712
|
-
return
|
|
4781
|
+
var _a2, _b;
|
|
4782
|
+
return (_b = await ((_a2 = this.getSelectedChild()) == null ? void 0 : _a2.getSubmittableValue())) != null ? _b : null;
|
|
4713
4783
|
},
|
|
4714
4784
|
getSubmittableValueSync() {
|
|
4715
|
-
|
|
4785
|
+
var _a2, _b;
|
|
4786
|
+
return (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.getSubmittableValueSync()) != null ? _b : null;
|
|
4716
4787
|
},
|
|
4717
4788
|
getSummary() {
|
|
4718
|
-
|
|
4789
|
+
var _a2, _b;
|
|
4790
|
+
return (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.getSummary()) != null ? _b : {};
|
|
4719
4791
|
},
|
|
4720
4792
|
getLocalValue() {
|
|
4721
|
-
|
|
4793
|
+
var _a2, _b;
|
|
4794
|
+
return (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.getLocalValue()) != null ? _b : null;
|
|
4722
4795
|
},
|
|
4723
|
-
|
|
4724
|
-
|
|
4796
|
+
onBlur() {
|
|
4797
|
+
this.validate();
|
|
4798
|
+
},
|
|
4799
|
+
onFocus() {
|
|
4800
|
+
},
|
|
4801
|
+
// noop
|
|
4802
|
+
onSelect(updatedIndex) {
|
|
4803
|
+
if (updatedIndex === this.selectedIndex) {
|
|
4804
|
+
return;
|
|
4805
|
+
}
|
|
4806
|
+
if (updatedIndex !== null && this.analyticsId) {
|
|
4807
|
+
selectProps.trackEvent("OneOf Selected", {
|
|
4808
|
+
oneOfId: this.analyticsId,
|
|
4809
|
+
schemaId: this.children[updatedIndex].analyticsId
|
|
4810
|
+
});
|
|
4811
|
+
}
|
|
4725
4812
|
this._update((draft) => {
|
|
4726
|
-
draft.errors =
|
|
4813
|
+
draft.errors = [];
|
|
4814
|
+
draft.selectedIndex = updatedIndex;
|
|
4727
4815
|
});
|
|
4728
|
-
|
|
4729
|
-
}
|
|
4730
|
-
}, rest);
|
|
4731
|
-
if (!performPersistAsync) {
|
|
4732
|
-
return uploadComponent;
|
|
4733
|
-
}
|
|
4734
|
-
const persist = getComponentMultiPersistAsync(update, performPersistAsync);
|
|
4735
|
-
return __spreadProps(__spreadValues({}, uploadComponent), {
|
|
4736
|
-
format,
|
|
4737
|
-
async onInsertFile(index, file) {
|
|
4738
|
-
const fileId = await uploadComponent.onInsertFile.call(this, index, file);
|
|
4739
|
-
const submission = format === "blob" ? file : await toBase64(file);
|
|
4740
|
-
await persist(this, index, submission);
|
|
4816
|
+
performRefresh == null ? void 0 : performRefresh();
|
|
4741
4817
|
onValueChange();
|
|
4742
|
-
return fileId;
|
|
4743
4818
|
},
|
|
4744
|
-
|
|
4745
|
-
var _a2;
|
|
4746
|
-
|
|
4747
|
-
|
|
4819
|
+
validate() {
|
|
4820
|
+
var _a2, _b;
|
|
4821
|
+
const validChild = (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.validate()) != null ? _b : true;
|
|
4822
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
4748
4823
|
this._update((draft) => {
|
|
4749
|
-
draft.
|
|
4824
|
+
draft.errors = errors;
|
|
4750
4825
|
});
|
|
4751
|
-
|
|
4752
|
-
async getSubmittableValue() {
|
|
4753
|
-
return Promise.all(this.persistedState.map(async ({ submission }) => submission));
|
|
4754
|
-
},
|
|
4755
|
-
getSubmittableValueSync() {
|
|
4756
|
-
return this.persistedState.map(({ lastResponse }) => lastResponse);
|
|
4826
|
+
return errors.length === 0 && validChild;
|
|
4757
4827
|
}
|
|
4758
4828
|
});
|
|
4829
|
+
return component;
|
|
4759
4830
|
};
|
|
4760
4831
|
|
|
4761
|
-
// src/revamp/domain/mappers/schema/
|
|
4762
|
-
var
|
|
4832
|
+
// src/revamp/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.ts
|
|
4833
|
+
var oneOfSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
4763
4834
|
var _a;
|
|
4764
|
-
const {
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
}
|
|
4786
|
-
const
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
const persistedState = performPersistAsync && isArray(model) ? model.map((itemModel) => getInitialPersistedState(null, itemModel)) : [];
|
|
4790
|
-
return createMultiUploadInputComponent(
|
|
4791
|
-
__spreadProps(__spreadValues({}, mapCommonSchemaProps(combinedSchemaProps)), {
|
|
4835
|
+
const {
|
|
4836
|
+
uid,
|
|
4837
|
+
localValue,
|
|
4838
|
+
schema,
|
|
4839
|
+
model,
|
|
4840
|
+
validationErrors: initialError,
|
|
4841
|
+
required = false
|
|
4842
|
+
} = schemaMapperProps;
|
|
4843
|
+
const initialModel = (_a = model != null ? model : schema.default) != null ? _a : null;
|
|
4844
|
+
if (schema.oneOf.length === 1 && isFormSectionSchema(schema.oneOf[0])) {
|
|
4845
|
+
return mapSchemaToComponent(
|
|
4846
|
+
{
|
|
4847
|
+
uid,
|
|
4848
|
+
schema: supressSchemaTitleAndDescription(schema.oneOf[0]),
|
|
4849
|
+
model: initialModel,
|
|
4850
|
+
localValue,
|
|
4851
|
+
validationErrors: initialError,
|
|
4852
|
+
required
|
|
4853
|
+
},
|
|
4854
|
+
mapperProps
|
|
4855
|
+
);
|
|
4856
|
+
}
|
|
4857
|
+
const options = schema.oneOf.map((childSchema, index) => {
|
|
4858
|
+
const { title = "", description, image, icon, keywords = [] } = childSchema;
|
|
4859
|
+
return {
|
|
4792
4860
|
title,
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4861
|
+
description,
|
|
4862
|
+
image: mapSpecImage(image),
|
|
4863
|
+
icon,
|
|
4864
|
+
keywords,
|
|
4865
|
+
disabled: "disabled" in childSchema ? Boolean(childSchema.disabled) : false,
|
|
4866
|
+
component: mapSchemaToComponent(
|
|
4867
|
+
{
|
|
4868
|
+
uid: `${uid}.oneOf-${index}`,
|
|
4869
|
+
schema: isFormSectionSchema(childSchema) ? supressSchemaTitleAndDescription(childSchema) : childSchema,
|
|
4870
|
+
model: initialModel,
|
|
4871
|
+
localValue,
|
|
4872
|
+
validationErrors: initialError,
|
|
4873
|
+
required
|
|
4874
|
+
},
|
|
4875
|
+
mapperProps
|
|
4876
|
+
)
|
|
4877
|
+
};
|
|
4878
|
+
});
|
|
4879
|
+
const { getErrorMessageFunctions, updateComponent, trackEvent, onRefresh, onValueChange } = mapperProps;
|
|
4880
|
+
const { validationMessages } = schema;
|
|
4881
|
+
const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
|
|
4882
|
+
return createSelectInputComponent(
|
|
4883
|
+
__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
|
|
4884
|
+
autoComplete: getAutocompleteString(schema.autocompleteHint),
|
|
4885
|
+
checks: schema.hidden ? [] : [getRequiredCheck(required, errorMessageFunctions)],
|
|
4886
|
+
options,
|
|
4887
|
+
initialModel,
|
|
4888
|
+
performRefresh: getPerformRefresh(schema, onRefresh),
|
|
4889
|
+
onValueChange,
|
|
4890
|
+
trackEvent
|
|
4809
4891
|
}),
|
|
4810
|
-
|
|
4892
|
+
updateComponent
|
|
4811
4893
|
);
|
|
4812
4894
|
};
|
|
4813
|
-
var
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
return isBlobSchema(schema.persistAsync.schema) ? "blob" : "base64";
|
|
4818
|
-
};
|
|
4819
|
-
var getUploadSchema = (schema) => {
|
|
4820
|
-
if (isStringSchemaWithUpload(schema)) {
|
|
4821
|
-
return schema;
|
|
4822
|
-
}
|
|
4823
|
-
return schema.persistAsync.schema;
|
|
4824
|
-
};
|
|
4825
|
-
var getPersistAsyncConfig = (schema) => {
|
|
4826
|
-
if (!isSchemaWithPersistAsync(schema)) {
|
|
4827
|
-
return void 0;
|
|
4828
|
-
}
|
|
4829
|
-
const { persistAsync } = schema;
|
|
4830
|
-
const { idProperty, method, param, url } = persistAsync;
|
|
4831
|
-
return { idProperty, method, param, url };
|
|
4895
|
+
var isFormSectionSchema = (schema) => isObjectSchema(schema) || isArrayTupleSchema(schema) || isAllOfSchema(schema);
|
|
4896
|
+
var supressSchemaTitleAndDescription = (schema) => {
|
|
4897
|
+
const _a = schema, { title, description } = _a, headlessSchema = __objRest(_a, ["title", "description"]);
|
|
4898
|
+
return headlessSchema;
|
|
4832
4899
|
};
|
|
4833
|
-
var getValueForPersistAsync = (localValue) => isArray(localValue) && localValue.every(isFile) ? localValue : [];
|
|
4834
4900
|
|
|
4835
|
-
// src/revamp/domain/components/
|
|
4836
|
-
var
|
|
4837
|
-
const _a =
|
|
4901
|
+
// src/revamp/domain/components/DateInputComponent.ts
|
|
4902
|
+
var createDateInputComponent = (textInputProps, updateComponent) => {
|
|
4903
|
+
const _a = textInputProps, {
|
|
4838
4904
|
uid,
|
|
4905
|
+
id,
|
|
4839
4906
|
checks,
|
|
4840
|
-
|
|
4841
|
-
initialValue,
|
|
4842
|
-
performValidationAsync,
|
|
4907
|
+
performPersistAsync,
|
|
4843
4908
|
performRefresh,
|
|
4844
|
-
|
|
4909
|
+
performValidationAsync,
|
|
4910
|
+
onValueChange,
|
|
4911
|
+
summariser,
|
|
4912
|
+
value
|
|
4845
4913
|
} = _a, rest = __objRest(_a, [
|
|
4846
4914
|
"uid",
|
|
4915
|
+
"id",
|
|
4847
4916
|
"checks",
|
|
4848
|
-
"
|
|
4849
|
-
"initialValue",
|
|
4850
|
-
"performValidationAsync",
|
|
4917
|
+
"performPersistAsync",
|
|
4851
4918
|
"performRefresh",
|
|
4852
|
-
"
|
|
4919
|
+
"performValidationAsync",
|
|
4920
|
+
"onValueChange",
|
|
4921
|
+
"summariser",
|
|
4922
|
+
"value"
|
|
4853
4923
|
]);
|
|
4854
4924
|
const update = getInputUpdateFunction(updateComponent);
|
|
4855
|
-
const children = options.map((option) => option.component);
|
|
4856
|
-
const selectedIndices = getInitialModelIndices(initialValue, children);
|
|
4857
4925
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
4858
|
-
const
|
|
4926
|
+
const dateInputComponent = __spreadValues({
|
|
4927
|
+
type: "date",
|
|
4859
4928
|
uid,
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
options,
|
|
4863
|
-
selectedIndices,
|
|
4864
|
-
value: null
|
|
4865
|
-
}, rest), {
|
|
4929
|
+
id,
|
|
4930
|
+
value,
|
|
4866
4931
|
_update(updateFn) {
|
|
4867
4932
|
update(this, updateFn);
|
|
4868
4933
|
},
|
|
4869
|
-
|
|
4934
|
+
onBlur() {
|
|
4935
|
+
this.validate();
|
|
4936
|
+
},
|
|
4937
|
+
onFocus() {
|
|
4938
|
+
},
|
|
4939
|
+
// Noop
|
|
4940
|
+
onChange(updatedValue) {
|
|
4941
|
+
const prevValue = this.value;
|
|
4870
4942
|
this._update((draft) => {
|
|
4871
|
-
draft.selectedIndices = indices;
|
|
4872
4943
|
draft.errors = [];
|
|
4944
|
+
draft.validationAsyncState.messages = {};
|
|
4945
|
+
draft.value = updatedValue;
|
|
4873
4946
|
});
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
draft.errors = errors;
|
|
4879
|
-
});
|
|
4947
|
+
if (isOrWasValid(getValidationErrors, prevValue, updatedValue)) {
|
|
4948
|
+
performRefresh == null ? void 0 : performRefresh();
|
|
4949
|
+
}
|
|
4950
|
+
onValueChange();
|
|
4880
4951
|
},
|
|
4881
|
-
|
|
4952
|
+
async getSubmittableValue() {
|
|
4953
|
+
return this.getSubmittableValueSync();
|
|
4882
4954
|
},
|
|
4883
|
-
|
|
4884
|
-
|
|
4955
|
+
getSubmittableValueSync() {
|
|
4956
|
+
var _a2;
|
|
4957
|
+
return (_a2 = this.getLocalValue()) != null ? _a2 : null;
|
|
4958
|
+
},
|
|
4959
|
+
getSummary() {
|
|
4960
|
+
return summariser(this.getLocalValue());
|
|
4885
4961
|
},
|
|
4886
|
-
// Noop
|
|
4887
4962
|
getLocalValue() {
|
|
4888
|
-
|
|
4889
|
-
return (_b = (_a2 = this.getSelectedChildren()) == null ? void 0 : _a2.map((child) => child.getLocalValue())) != null ? _b : null;
|
|
4963
|
+
return this.value;
|
|
4890
4964
|
},
|
|
4891
4965
|
validate() {
|
|
4892
4966
|
const errors = getValidationErrors(this.getLocalValue());
|
|
@@ -4894,34 +4968,34 @@ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
|
|
|
4894
4968
|
draft.errors = errors;
|
|
4895
4969
|
});
|
|
4896
4970
|
return errors.length === 0;
|
|
4897
|
-
},
|
|
4898
|
-
async getSubmittableValue() {
|
|
4899
|
-
const selected = this.getSelectedChildren();
|
|
4900
|
-
if (selected) {
|
|
4901
|
-
return Promise.all(selected.map(async (child) => child.getSubmittableValue()));
|
|
4902
|
-
}
|
|
4903
|
-
return null;
|
|
4904
|
-
},
|
|
4905
|
-
getSubmittableValueSync() {
|
|
4906
|
-
var _a2, _b;
|
|
4907
|
-
return (_b = (_a2 = this.getSelectedChildren()) == null ? void 0 : _a2.map((child) => child.getSubmittableValueSync())) != null ? _b : null;
|
|
4908
|
-
},
|
|
4909
|
-
getSummary: () => ({}),
|
|
4910
|
-
getChildren() {
|
|
4911
|
-
return this.children;
|
|
4912
|
-
},
|
|
4913
|
-
getSelectedChildren() {
|
|
4914
|
-
return this.selectedIndices.map((i) => this.children[i]);
|
|
4915
4971
|
}
|
|
4916
|
-
});
|
|
4972
|
+
}, rest);
|
|
4917
4973
|
if (performRefresh) {
|
|
4918
|
-
return
|
|
4974
|
+
return dateInputComponent;
|
|
4975
|
+
}
|
|
4976
|
+
if (performPersistAsync) {
|
|
4977
|
+
const persist = getComponentPersistAsync(update, performPersistAsync);
|
|
4978
|
+
return __spreadProps(__spreadValues({}, dateInputComponent), {
|
|
4979
|
+
onChange(updatedValue) {
|
|
4980
|
+
dateInputComponent.onChange.call(this, updatedValue);
|
|
4981
|
+
const isValid = getValidationErrors(updatedValue).length === 0;
|
|
4982
|
+
if (isValid) {
|
|
4983
|
+
persist(this, this.getLocalValue()).catch(() => {
|
|
4984
|
+
});
|
|
4985
|
+
}
|
|
4986
|
+
},
|
|
4987
|
+
async getSubmittableValue() {
|
|
4988
|
+
return persist(this, this.getLocalValue());
|
|
4989
|
+
},
|
|
4990
|
+
getSubmittableValueSync() {
|
|
4991
|
+
return this.persistedState.lastResponse;
|
|
4992
|
+
}
|
|
4993
|
+
});
|
|
4919
4994
|
}
|
|
4920
4995
|
if (performValidationAsync) {
|
|
4921
4996
|
const validateAsync = getComponentValidationAsync(update, performValidationAsync);
|
|
4922
|
-
return __spreadProps(__spreadValues({},
|
|
4923
|
-
|
|
4924
|
-
inputComponent.onSelect.call(this, indices);
|
|
4997
|
+
return __spreadProps(__spreadValues({}, dateInputComponent), {
|
|
4998
|
+
onBlur() {
|
|
4925
4999
|
if (this.validate()) {
|
|
4926
5000
|
validateAsync(this, this.getLocalValue()).catch(() => {
|
|
4927
5001
|
});
|
|
@@ -4929,230 +5003,151 @@ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
|
|
|
4929
5003
|
}
|
|
4930
5004
|
});
|
|
4931
5005
|
}
|
|
4932
|
-
return
|
|
4933
|
-
};
|
|
4934
|
-
var getInitialModelIndices = (model, options) => {
|
|
4935
|
-
if (!isArray(model)) {
|
|
4936
|
-
return [];
|
|
4937
|
-
}
|
|
4938
|
-
return model.map((m) => options.findIndex((o) => o.getLocalValue() === m)).filter((n) => n >= 0);
|
|
5006
|
+
return dateInputComponent;
|
|
4939
5007
|
};
|
|
4940
5008
|
|
|
4941
|
-
// src/revamp/domain/mappers/schema/
|
|
4942
|
-
var
|
|
5009
|
+
// src/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToDateInputComponent.ts
|
|
5010
|
+
var stringSchemaToDateInputComponent = (schemaMapperProps, mapperProps) => {
|
|
5011
|
+
const { schema, localValue, model, required = false } = schemaMapperProps;
|
|
4943
5012
|
const {
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
} =
|
|
4951
|
-
const
|
|
4952
|
-
const
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
description,
|
|
4957
|
-
image: mapSpecImage(image),
|
|
4958
|
-
icon,
|
|
4959
|
-
keywords,
|
|
4960
|
-
disabled: "disabled" in childSchema ? Boolean(childSchema.disabled) : false,
|
|
4961
|
-
component: mapSchemaToComponent(
|
|
4962
|
-
{
|
|
4963
|
-
uid: `${uid}.oneOf-${index}`,
|
|
4964
|
-
schema: childSchema,
|
|
4965
|
-
model: initialModel,
|
|
4966
|
-
localValue,
|
|
4967
|
-
validationErrors: initialError,
|
|
4968
|
-
required
|
|
4969
|
-
},
|
|
4970
|
-
mapperProps
|
|
4971
|
-
)
|
|
4972
|
-
};
|
|
4973
|
-
});
|
|
4974
|
-
const { maxItems, minItems, title, validationMessages } = schema;
|
|
4975
|
-
const { getErrorMessageFunctions, onRefresh, onValueChange, updateComponent } = mapperProps;
|
|
4976
|
-
const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
|
|
5013
|
+
autocompleteHint,
|
|
5014
|
+
default: defaultValue,
|
|
5015
|
+
minimum: minimumDate,
|
|
5016
|
+
maximum: maximumDate,
|
|
5017
|
+
suggestions
|
|
5018
|
+
} = schema;
|
|
5019
|
+
const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange } = mapperProps;
|
|
5020
|
+
const errorMessageFunctions = getErrorMessageFunctions(schema.validationMessages);
|
|
5021
|
+
const { performPersistAsync, persistedState } = getPersistAsyncInitialState(
|
|
5022
|
+
schemaMapperProps,
|
|
5023
|
+
mapperProps
|
|
5024
|
+
);
|
|
4977
5025
|
const { performValidationAsync, validationAsyncState } = getValidationAsyncInitialState(
|
|
4978
5026
|
schemaMapperProps,
|
|
4979
5027
|
mapperProps
|
|
4980
5028
|
);
|
|
4981
|
-
const
|
|
4982
|
-
|
|
5029
|
+
const validLocalValue = isString(localValue) ? localValue : null;
|
|
5030
|
+
const validModel = isString(model) ? model : defaultValue != null ? defaultValue : null;
|
|
5031
|
+
const value = performPersistAsync ? validLocalValue : validModel;
|
|
5032
|
+
return createDateInputComponent(
|
|
4983
5033
|
__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
|
|
4984
|
-
autoComplete:
|
|
5034
|
+
autoComplete: getAutocompleteString(autocompleteHint),
|
|
4985
5035
|
checks: schema.hidden ? [] : [
|
|
4986
5036
|
getRequiredCheck(required, errorMessageFunctions),
|
|
4987
|
-
|
|
4988
|
-
|
|
5037
|
+
getAboveMaximumDateCheck(schema, errorMessageFunctions),
|
|
5038
|
+
getBelowMinimumDateCheck(schema, errorMessageFunctions)
|
|
4989
5039
|
],
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
5040
|
+
minimumDate,
|
|
5041
|
+
maximumDate,
|
|
5042
|
+
suggestions: suggestions ? {
|
|
5043
|
+
values: suggestions.values.map((suggestion) => __spreadProps(__spreadValues({}, suggestion), {
|
|
5044
|
+
image: mapSpecImage(suggestion.image)
|
|
5045
|
+
}))
|
|
5046
|
+
} : void 0,
|
|
5047
|
+
value,
|
|
5048
|
+
persistedState,
|
|
4996
5049
|
validationAsyncState,
|
|
4997
|
-
|
|
5050
|
+
performPersistAsync,
|
|
4998
5051
|
performRefresh: getPerformRefresh(schema, onRefresh),
|
|
5052
|
+
performValidationAsync,
|
|
4999
5053
|
onValueChange
|
|
5000
5054
|
}),
|
|
5001
5055
|
updateComponent
|
|
5002
5056
|
);
|
|
5003
5057
|
};
|
|
5004
5058
|
|
|
5005
|
-
// src/revamp/domain/
|
|
5006
|
-
var
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
},
|
|
5038
|
-
getSubmittableValueSync() {
|
|
5039
|
-
return this.components.map((child) => child.getSubmittableValueSync());
|
|
5040
|
-
},
|
|
5041
|
-
getSummary() {
|
|
5042
|
-
const summary = summariser(this.getLocalValue());
|
|
5043
|
-
const childSummary = summariseFromChildren(this.getChildren());
|
|
5044
|
-
return mergeSummaries(summary, childSummary);
|
|
5045
|
-
},
|
|
5046
|
-
getLocalValue() {
|
|
5047
|
-
return this.components.map((child) => child.getLocalValue());
|
|
5048
|
-
},
|
|
5049
|
-
validate() {
|
|
5050
|
-
return hidden ? true : validateComponents(this.getChildren());
|
|
5051
|
-
}
|
|
5052
|
-
};
|
|
5053
|
-
};
|
|
5054
|
-
|
|
5055
|
-
// src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToTupleComponent.ts
|
|
5056
|
-
var arraySchemaToTupleComponent = (schemaMapperProps, mapperProps) => {
|
|
5057
|
-
const {
|
|
5058
|
-
uid,
|
|
5059
|
-
localValue,
|
|
5060
|
-
schema,
|
|
5061
|
-
model: initialModel,
|
|
5062
|
-
required = false,
|
|
5063
|
-
validationErrors
|
|
5064
|
-
} = schemaMapperProps;
|
|
5065
|
-
const { items } = schema;
|
|
5066
|
-
const components = items.map(
|
|
5067
|
-
(childSchema, index) => {
|
|
5068
|
-
var _a, _b;
|
|
5069
|
-
return mapSchemaToComponent(
|
|
5070
|
-
{
|
|
5071
|
-
uid: `${uid}-arr.${index}`,
|
|
5072
|
-
schema: childSchema,
|
|
5073
|
-
model: isArray(initialModel) ? (_a = initialModel[index]) != null ? _a : null : null,
|
|
5074
|
-
localValue: isArray(localValue) ? (_b = localValue[index]) != null ? _b : null : null,
|
|
5075
|
-
validationErrors: isArray(validationErrors) ? validationErrors[index] : void 0,
|
|
5076
|
-
required
|
|
5077
|
-
},
|
|
5078
|
-
mapperProps
|
|
5079
|
-
);
|
|
5080
|
-
}
|
|
5059
|
+
// src/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToUploadInputComponent.ts
|
|
5060
|
+
var stringSchemaToUploadInputComponent = (schemaMapperProps, mapperProps) => {
|
|
5061
|
+
var _a;
|
|
5062
|
+
const { schema, localValue, model, required = false } = schemaMapperProps;
|
|
5063
|
+
const { accepts, autocompleteHint, cameraConfig, hidden, maxSize, source, validationMessages } = schema;
|
|
5064
|
+
const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange } = mapperProps;
|
|
5065
|
+
const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
|
|
5066
|
+
const { performPersistAsync } = getPersistAsyncInitialState(schemaMapperProps, mapperProps);
|
|
5067
|
+
const persistedState = performPersistAsync ? getInitialPersistedState(null, model) : getInitialPersistedState();
|
|
5068
|
+
const validLocalValue = isFile(localValue) ? localValue : null;
|
|
5069
|
+
const value = (_a = getFileFromModel(model)) != null ? _a : validLocalValue;
|
|
5070
|
+
const checks = hidden ? [] : [
|
|
5071
|
+
getRequiredCheck(required, errorMessageFunctions),
|
|
5072
|
+
getFileSizeCheck(schema, errorMessageFunctions),
|
|
5073
|
+
getFileTypeCheck(schema, errorMessageFunctions)
|
|
5074
|
+
];
|
|
5075
|
+
return createUploadInputComponent(
|
|
5076
|
+
__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
|
|
5077
|
+
accepts,
|
|
5078
|
+
autoComplete: getAutocompleteString(autocompleteHint),
|
|
5079
|
+
cameraConfig,
|
|
5080
|
+
checks,
|
|
5081
|
+
format: "base64",
|
|
5082
|
+
maxSize,
|
|
5083
|
+
source,
|
|
5084
|
+
value,
|
|
5085
|
+
persistedState,
|
|
5086
|
+
performPersistAsync,
|
|
5087
|
+
performRefresh: getPerformRefresh(schema, onRefresh),
|
|
5088
|
+
onValueChange
|
|
5089
|
+
}),
|
|
5090
|
+
updateComponent
|
|
5081
5091
|
);
|
|
5082
|
-
return createTupleComponent(__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
|
|
5083
|
-
components
|
|
5084
|
-
}));
|
|
5085
|
-
};
|
|
5086
|
-
|
|
5087
|
-
// src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToComponent.ts
|
|
5088
|
-
var arraySchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
5089
|
-
const { schema, model: originalModel } = schemaMapperProps;
|
|
5090
|
-
const model = isNullish(originalModel) || isArrayModel(originalModel) ? originalModel : null;
|
|
5091
|
-
if (isArraySchemaListWithMultiFileUpload(schema)) {
|
|
5092
|
-
return arraySchemaToMultiUploadComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
|
|
5093
|
-
}
|
|
5094
|
-
if (isArraySchemaListWithMultiSelect(schema)) {
|
|
5095
|
-
return arraySchemaToMultiSelectComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
|
|
5096
|
-
}
|
|
5097
|
-
if (isArrayTupleSchema(schema)) {
|
|
5098
|
-
return arraySchemaToTupleComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
|
|
5099
|
-
}
|
|
5100
|
-
return arraySchemaToRepeatableComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema, model }), mapperProps);
|
|
5101
5092
|
};
|
|
5102
|
-
var
|
|
5103
|
-
var isPersistAsyncWithUploadSchema = (schema) => isSchemaWithPersistAsync(schema) && (isBlobSchema(schema.persistAsync.schema) || isStringSchemaWithUpload(schema.persistAsync.schema));
|
|
5104
|
-
var isArraySchemaListWithMultiSelect = (schema) => isArrayListSchema(schema) && "oneOf" in schema.items && schema.items.oneOf.every(isConstSchema);
|
|
5093
|
+
var getFileFromModel = (model) => isString(model) ? base64dataUrltoFile(model, "") : null;
|
|
5105
5094
|
|
|
5106
|
-
// src/revamp/domain/components/
|
|
5107
|
-
var
|
|
5108
|
-
const _a =
|
|
5095
|
+
// src/revamp/domain/components/TextInputComponent.ts
|
|
5096
|
+
var createTextInputComponent = (textInputProps, updateComponent) => {
|
|
5097
|
+
const _a = textInputProps, {
|
|
5109
5098
|
uid,
|
|
5110
5099
|
id,
|
|
5111
|
-
|
|
5100
|
+
checks,
|
|
5112
5101
|
performPersistAsync,
|
|
5113
5102
|
performRefresh,
|
|
5114
5103
|
performValidationAsync,
|
|
5115
5104
|
onValueChange,
|
|
5116
|
-
summariser
|
|
5105
|
+
summariser,
|
|
5106
|
+
value
|
|
5117
5107
|
} = _a, rest = __objRest(_a, [
|
|
5118
5108
|
"uid",
|
|
5119
5109
|
"id",
|
|
5120
|
-
"
|
|
5110
|
+
"checks",
|
|
5121
5111
|
"performPersistAsync",
|
|
5122
5112
|
"performRefresh",
|
|
5123
5113
|
"performValidationAsync",
|
|
5124
5114
|
"onValueChange",
|
|
5125
|
-
"summariser"
|
|
5115
|
+
"summariser",
|
|
5116
|
+
"value"
|
|
5126
5117
|
]);
|
|
5127
5118
|
const update = getInputUpdateFunction(updateComponent);
|
|
5128
|
-
const
|
|
5129
|
-
|
|
5119
|
+
const getValidationErrors = getLocalValueValidator(checks);
|
|
5120
|
+
const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh, getValidationErrors);
|
|
5121
|
+
const inputComponent = __spreadValues({
|
|
5122
|
+
type: "text",
|
|
5130
5123
|
uid,
|
|
5131
5124
|
id,
|
|
5132
|
-
autoComplete: "",
|
|
5133
5125
|
value,
|
|
5134
5126
|
_update(updateFn) {
|
|
5135
5127
|
update(this, updateFn);
|
|
5136
5128
|
},
|
|
5137
5129
|
onBlur() {
|
|
5130
|
+
this.validate();
|
|
5131
|
+
performDebouncedRefresh == null ? void 0 : performDebouncedRefresh.flush();
|
|
5138
5132
|
},
|
|
5139
|
-
// Noop
|
|
5140
5133
|
onFocus() {
|
|
5141
5134
|
},
|
|
5142
5135
|
// Noop
|
|
5143
5136
|
onChange(updatedValue) {
|
|
5137
|
+
const prevValue = this.value;
|
|
5144
5138
|
this._update((draft) => {
|
|
5145
5139
|
draft.errors = [];
|
|
5140
|
+
draft.validationAsyncState.messages = {};
|
|
5146
5141
|
draft.value = updatedValue;
|
|
5147
5142
|
});
|
|
5148
|
-
|
|
5143
|
+
performDebouncedRefresh == null ? void 0 : performDebouncedRefresh(prevValue, updatedValue);
|
|
5149
5144
|
onValueChange();
|
|
5150
5145
|
},
|
|
5151
5146
|
async getSubmittableValue() {
|
|
5152
5147
|
return this.getSubmittableValueSync();
|
|
5153
5148
|
},
|
|
5154
5149
|
getSubmittableValueSync() {
|
|
5155
|
-
return this.getLocalValue();
|
|
5150
|
+
return this.getLocalValue() || null;
|
|
5156
5151
|
},
|
|
5157
5152
|
getSummary() {
|
|
5158
5153
|
return summariser(this.getLocalValue());
|
|
@@ -5160,18 +5155,25 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
|
|
|
5160
5155
|
getLocalValue() {
|
|
5161
5156
|
return this.value;
|
|
5162
5157
|
},
|
|
5163
|
-
validate
|
|
5158
|
+
validate() {
|
|
5159
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
5160
|
+
this._update((draft) => {
|
|
5161
|
+
draft.errors = errors;
|
|
5162
|
+
});
|
|
5163
|
+
return errors.length === 0;
|
|
5164
|
+
}
|
|
5164
5165
|
}, rest);
|
|
5165
5166
|
if (performRefresh) {
|
|
5166
|
-
return
|
|
5167
|
+
return inputComponent;
|
|
5167
5168
|
}
|
|
5168
5169
|
if (performPersistAsync) {
|
|
5169
5170
|
const persist = getComponentPersistAsync(update, performPersistAsync);
|
|
5170
|
-
return __spreadProps(__spreadValues({},
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
|
|
5171
|
+
return __spreadProps(__spreadValues({}, inputComponent), {
|
|
5172
|
+
onBlur() {
|
|
5173
|
+
if (this.validate()) {
|
|
5174
|
+
persist(this, this.getLocalValue()).catch(() => {
|
|
5175
|
+
});
|
|
5176
|
+
}
|
|
5175
5177
|
},
|
|
5176
5178
|
async getSubmittableValue() {
|
|
5177
5179
|
return persist(this, this.getLocalValue());
|
|
@@ -5182,24 +5184,45 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
|
|
|
5182
5184
|
});
|
|
5183
5185
|
}
|
|
5184
5186
|
if (performValidationAsync) {
|
|
5185
|
-
const validateAsync =
|
|
5186
|
-
return __spreadProps(__spreadValues({},
|
|
5187
|
+
const validateAsync = getDebouncedComponentValidationAsync(update, performValidationAsync);
|
|
5188
|
+
return __spreadProps(__spreadValues({}, inputComponent), {
|
|
5189
|
+
onBlur() {
|
|
5190
|
+
if (this.validate()) {
|
|
5191
|
+
validateAsync.flush();
|
|
5192
|
+
}
|
|
5193
|
+
},
|
|
5187
5194
|
onChange(updatedValue) {
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5195
|
+
inputComponent.onChange.call(this, updatedValue);
|
|
5196
|
+
if (getValidationErrors(updatedValue).length === 0) {
|
|
5197
|
+
validateAsync(this, updatedValue);
|
|
5198
|
+
}
|
|
5199
|
+
if (!updatedValue) {
|
|
5200
|
+
validateAsync.cancel();
|
|
5201
|
+
}
|
|
5191
5202
|
}
|
|
5192
5203
|
});
|
|
5193
5204
|
}
|
|
5194
|
-
return
|
|
5205
|
+
return inputComponent;
|
|
5195
5206
|
};
|
|
5196
5207
|
|
|
5197
|
-
// src/revamp/domain/mappers/schema/
|
|
5198
|
-
var
|
|
5199
|
-
const { schema, localValue, model } = schemaMapperProps;
|
|
5200
|
-
const {
|
|
5201
|
-
|
|
5202
|
-
|
|
5208
|
+
// src/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToTextInputComponent.ts
|
|
5209
|
+
var stringSchemaToTextInputComponent = (schemaMapperProps, mapperProps) => {
|
|
5210
|
+
const { schema, localValue, model, required = false } = schemaMapperProps;
|
|
5211
|
+
const {
|
|
5212
|
+
autocapitalization,
|
|
5213
|
+
autocompleteHint,
|
|
5214
|
+
control,
|
|
5215
|
+
default: defaultValue,
|
|
5216
|
+
displayFormat,
|
|
5217
|
+
format,
|
|
5218
|
+
maxLength,
|
|
5219
|
+
minLength,
|
|
5220
|
+
suggestions,
|
|
5221
|
+
validationMessages
|
|
5222
|
+
} = schema;
|
|
5223
|
+
const { getErrorMessageFunctions, updateComponent, onRefresh, onValueChange, logEvent } = mapperProps;
|
|
5224
|
+
const controlForLegacyFormat = getControlForLegacyFormat(format);
|
|
5225
|
+
const errorMessageFunctions = getErrorMessageFunctions(validationMessages);
|
|
5203
5226
|
const { performPersistAsync, persistedState } = getPersistAsyncInitialState(
|
|
5204
5227
|
schemaMapperProps,
|
|
5205
5228
|
mapperProps
|
|
@@ -5208,76 +5231,65 @@ var booleanSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
|
5208
5231
|
schemaMapperProps,
|
|
5209
5232
|
mapperProps
|
|
5210
5233
|
);
|
|
5211
|
-
const validLocalValue =
|
|
5212
|
-
const validModel =
|
|
5234
|
+
const validLocalValue = isString(localValue) ? localValue : null;
|
|
5235
|
+
const validModel = isString(model) ? model : defaultValue != null ? defaultValue : null;
|
|
5213
5236
|
const value = performPersistAsync ? validLocalValue : validModel;
|
|
5214
|
-
return
|
|
5237
|
+
return createTextInputComponent(
|
|
5215
5238
|
__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
|
|
5216
|
-
|
|
5239
|
+
autocapitalization,
|
|
5240
|
+
autoComplete: getAutocompleteString(autocompleteHint),
|
|
5241
|
+
checks: schema.hidden ? [] : [
|
|
5242
|
+
getRequiredCheck(required, errorMessageFunctions),
|
|
5243
|
+
getAboveMaxLengthCheck(schema, errorMessageFunctions),
|
|
5244
|
+
getBelowMinLengthCheck(schema, errorMessageFunctions),
|
|
5245
|
+
getNotAdheringToPatternCheck(schema, errorMessageFunctions, { logEvent })
|
|
5246
|
+
],
|
|
5247
|
+
control: control != null ? control : controlForLegacyFormat,
|
|
5248
|
+
displayFormat,
|
|
5249
|
+
maxLength,
|
|
5250
|
+
minLength,
|
|
5251
|
+
suggestions: suggestions ? {
|
|
5252
|
+
values: suggestions.values.map((suggestion) => __spreadProps(__spreadValues({}, suggestion), {
|
|
5253
|
+
image: mapSpecImage(suggestion.image)
|
|
5254
|
+
}))
|
|
5255
|
+
} : void 0,
|
|
5256
|
+
value,
|
|
5217
5257
|
persistedState,
|
|
5218
5258
|
validationAsyncState,
|
|
5219
5259
|
performPersistAsync,
|
|
5220
|
-
performRefresh,
|
|
5260
|
+
performRefresh: getPerformRefresh(schema, onRefresh),
|
|
5221
5261
|
performValidationAsync,
|
|
5222
5262
|
onValueChange
|
|
5223
5263
|
}),
|
|
5224
5264
|
updateComponent
|
|
5225
5265
|
);
|
|
5226
5266
|
};
|
|
5227
|
-
var
|
|
5228
|
-
if (
|
|
5229
|
-
return
|
|
5230
|
-
}
|
|
5231
|
-
if (isBoolean(defaultValue)) {
|
|
5232
|
-
return defaultValue;
|
|
5267
|
+
var getControlForLegacyFormat = (format) => {
|
|
5268
|
+
if (format && ["numeric", "phone-number", "email", "password"].includes(format)) {
|
|
5269
|
+
return format;
|
|
5233
5270
|
}
|
|
5234
|
-
return
|
|
5271
|
+
return void 0;
|
|
5235
5272
|
};
|
|
5236
5273
|
|
|
5237
|
-
// src/revamp/domain/mappers/schema/
|
|
5238
|
-
var
|
|
5239
|
-
const { schema
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
format: "blob",
|
|
5253
|
-
maxSize,
|
|
5254
|
-
source,
|
|
5255
|
-
value,
|
|
5256
|
-
persistedState,
|
|
5257
|
-
performPersistAsync,
|
|
5258
|
-
checks: schema.hidden ? [] : [getRequiredCheck(required, errorMessageFunctions)],
|
|
5259
|
-
onValueChange
|
|
5260
|
-
}),
|
|
5261
|
-
updateComponent
|
|
5262
|
-
);
|
|
5274
|
+
// src/revamp/domain/mappers/schema/stringSchemaToComponent/stringSchemaToComponent.ts
|
|
5275
|
+
var stringSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
5276
|
+
const { schema } = schemaMapperProps;
|
|
5277
|
+
if (isStringSchemaWithBase64(schema)) {
|
|
5278
|
+
return stringSchemaToUploadInputComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema }), mapperProps);
|
|
5279
|
+
}
|
|
5280
|
+
switch (schema.format) {
|
|
5281
|
+
case "date":
|
|
5282
|
+
return stringSchemaToDateInputComponent(schemaMapperProps, mapperProps);
|
|
5283
|
+
default:
|
|
5284
|
+
return stringSchemaToTextInputComponent(schemaMapperProps, mapperProps);
|
|
5285
|
+
}
|
|
5286
|
+
};
|
|
5287
|
+
var isStringSchemaWithBase64 = (schema) => {
|
|
5288
|
+
return schema.format === "base64url" && !("persistAsync" in schema);
|
|
5263
5289
|
};
|
|
5264
5290
|
|
|
5265
5291
|
// src/revamp/domain/mappers/mapSchemaToComponent.ts
|
|
5266
5292
|
var mapSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
5267
|
-
const { uid, schema } = schemaMapperProps;
|
|
5268
|
-
const { alert } = schema;
|
|
5269
|
-
if (alert) {
|
|
5270
|
-
return createContainerComponent({
|
|
5271
|
-
uid,
|
|
5272
|
-
components: [
|
|
5273
|
-
alertLayoutToComponent(`${uid}.container.alert`, alert, mapperProps),
|
|
5274
|
-
getSchemaComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { uid: `${uid}.container` }), mapperProps)
|
|
5275
|
-
]
|
|
5276
|
-
});
|
|
5277
|
-
}
|
|
5278
|
-
return getSchemaComponent(schemaMapperProps, mapperProps);
|
|
5279
|
-
};
|
|
5280
|
-
var getSchemaComponent = (schemaMapperProps, mapperProps) => {
|
|
5281
5293
|
const { uid, schema } = schemaMapperProps;
|
|
5282
5294
|
if (isConstSchema(schema)) {
|
|
5283
5295
|
return constSchemaToComponent(uid, __spreadProps(__spreadValues({}, schemaMapperProps), { schema }));
|
|
@@ -6079,11 +6091,6 @@ var executePoll = async (props) => {
|
|
|
6079
6091
|
}
|
|
6080
6092
|
};
|
|
6081
6093
|
|
|
6082
|
-
// src/revamp/flow/getErrorMessage.ts
|
|
6083
|
-
var getErrorMessage = (error) => {
|
|
6084
|
-
return error instanceof Error ? error.message : typeof error === "string" ? error : `Unknown Error: type is ${typeof error}`;
|
|
6085
|
-
};
|
|
6086
|
-
|
|
6087
6094
|
// src/revamp/flow/executeRefresh.ts
|
|
6088
6095
|
var executeRefresh = async (props) => {
|
|
6089
6096
|
const { abortSignal, url, model, schemaId, etag, httpClient, trackEvent, logEvent } = props;
|
|
@@ -7195,7 +7202,7 @@ function isReference(block) {
|
|
|
7195
7202
|
}
|
|
7196
7203
|
|
|
7197
7204
|
// src/legacy/dynamicFlow/DynamicFlow.tsx
|
|
7198
|
-
import { useCallback as useCallback11, useEffect as
|
|
7205
|
+
import { useCallback as useCallback11, useEffect as useEffect21, useMemo as useMemo21, useState as useState26 } from "react";
|
|
7199
7206
|
import { useIntl as useIntl23 } from "react-intl";
|
|
7200
7207
|
|
|
7201
7208
|
// src/legacy/common/contexts/dynamicFlowContexts/DynamicFlowContexts.tsx
|
|
@@ -8052,12 +8059,12 @@ function useDebouncedFunction(callback, waitMs) {
|
|
|
8052
8059
|
}
|
|
8053
8060
|
|
|
8054
8061
|
// src/legacy/common/hooks/useExternal/useExternal.tsx
|
|
8055
|
-
import { useEffect as
|
|
8062
|
+
import { useEffect as useEffect2, useState as useState3 } from "react";
|
|
8056
8063
|
function useExternal(url) {
|
|
8057
8064
|
const [externalWindow, setExternalWindow] = useState3(null);
|
|
8058
8065
|
const [hasManuallyTriggered, setHasManuallyTriggered] = useState3(false);
|
|
8059
8066
|
const dismissConfirmation = () => setHasManuallyTriggered(true);
|
|
8060
|
-
|
|
8067
|
+
useEffect2(() => {
|
|
8061
8068
|
if (url) {
|
|
8062
8069
|
setHasManuallyTriggered(false);
|
|
8063
8070
|
setExternalWindow(window.open(url, "_blank"));
|
|
@@ -8130,7 +8137,7 @@ import { useState as useState20 } from "react";
|
|
|
8130
8137
|
import { useIntl as useIntl17 } from "react-intl";
|
|
8131
8138
|
|
|
8132
8139
|
// src/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/PersistAsyncBasicSchema.tsx
|
|
8133
|
-
import { useEffect as
|
|
8140
|
+
import { useEffect as useEffect13, useState as useState19 } from "react";
|
|
8134
8141
|
import { useIntl as useIntl16 } from "react-intl";
|
|
8135
8142
|
|
|
8136
8143
|
// src/legacy/common/constants/DateMode.ts
|
|
@@ -8179,7 +8186,7 @@ var Size = {
|
|
|
8179
8186
|
|
|
8180
8187
|
// src/legacy/jsonSchemaForm/basicTypeSchema/BasicTypeSchema.tsx
|
|
8181
8188
|
import classNames10 from "classnames";
|
|
8182
|
-
import { useEffect as
|
|
8189
|
+
import { useEffect as useEffect12, useMemo as useMemo16, useState as useState18 } from "react";
|
|
8183
8190
|
|
|
8184
8191
|
// src/legacy/layout/alert/DynamicAlert.tsx
|
|
8185
8192
|
import { Alert as Alert2 } from "@transferwise/components";
|
|
@@ -8646,7 +8653,7 @@ var DynamicDivider_default = DynamicDivider;
|
|
|
8646
8653
|
|
|
8647
8654
|
// src/legacy/layout/external/DynamicExternal.tsx
|
|
8648
8655
|
import { Button as Button2, Loader, Size as Size2 } from "@transferwise/components";
|
|
8649
|
-
import { useCallback as useCallback6, useEffect as
|
|
8656
|
+
import { useCallback as useCallback6, useEffect as useEffect3, useMemo as useMemo9 } from "react";
|
|
8650
8657
|
import { useIntl as useIntl3 } from "react-intl";
|
|
8651
8658
|
|
|
8652
8659
|
// src/legacy/layout/external/DynamicExternal.messages.ts
|
|
@@ -8668,7 +8675,7 @@ var DynamicExternal = ({ component, onAction }) => {
|
|
|
8668
8675
|
() => window.open(requestUrl, "df-external-window"),
|
|
8669
8676
|
[requestUrl]
|
|
8670
8677
|
);
|
|
8671
|
-
|
|
8678
|
+
useEffect3(() => {
|
|
8672
8679
|
openExternalUrl();
|
|
8673
8680
|
}, [openExternalUrl]);
|
|
8674
8681
|
const pollingConfiguration = useMemo9(() => {
|
|
@@ -8686,7 +8693,7 @@ var DynamicExternal = ({ component, onAction }) => {
|
|
|
8686
8693
|
var DynamicExternal_default = DynamicExternal;
|
|
8687
8694
|
|
|
8688
8695
|
// src/legacy/jsonSchemaForm/genericSchema/GenericSchema.tsx
|
|
8689
|
-
import { useEffect as
|
|
8696
|
+
import { useEffect as useEffect10 } from "react";
|
|
8690
8697
|
|
|
8691
8698
|
// src/legacy/jsonSchemaForm/allOfSchema/AllOfSchema.tsx
|
|
8692
8699
|
import { Header as Header2 } from "@transferwise/components";
|
|
@@ -8979,7 +8986,7 @@ function getValidationMessages(schema, required, defaultErrorMessages) {
|
|
|
8979
8986
|
// src/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multiSelectSchema/MultiSelectSchema.tsx
|
|
8980
8987
|
import { SelectInput, SelectInputOptionContent } from "@transferwise/components";
|
|
8981
8988
|
import classNames3 from "classnames";
|
|
8982
|
-
import { useEffect as
|
|
8989
|
+
import { useEffect as useEffect4, useMemo as useMemo11, useState as useState6 } from "react";
|
|
8983
8990
|
import { useIntl as useIntl6 } from "react-intl";
|
|
8984
8991
|
|
|
8985
8992
|
// src/legacy/jsonSchemaForm/schemaFormControl/utils/mapping-utils.tsx
|
|
@@ -9100,7 +9107,7 @@ function MultiSelectSchema({
|
|
|
9100
9107
|
const id = useMemo11(() => schema.$id || generateRandomId(), [schema.$id]);
|
|
9101
9108
|
const [changed, setChanged] = useState6(false);
|
|
9102
9109
|
const [selected, setSelected] = useState6(getInitialModelIndices2(model, options));
|
|
9103
|
-
|
|
9110
|
+
useEffect4(
|
|
9104
9111
|
() => {
|
|
9105
9112
|
if (selected) {
|
|
9106
9113
|
broadcastModelChange(selected);
|
|
@@ -9688,7 +9695,7 @@ var ArraySchema_default = ArraySchema;
|
|
|
9688
9695
|
// src/legacy/jsonSchemaForm/objectSchema/ObjectSchema.tsx
|
|
9689
9696
|
import { Header as Header4 } from "@transferwise/components";
|
|
9690
9697
|
import classNames5 from "classnames";
|
|
9691
|
-
import { useState as useState9, useEffect as
|
|
9698
|
+
import { useState as useState9, useEffect as useEffect5 } from "react";
|
|
9692
9699
|
import { Fragment as Fragment6, jsx as jsx33, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
9693
9700
|
var getSchemaColumnClasses2 = (width) => ({
|
|
9694
9701
|
"col-xs-12": true,
|
|
@@ -9708,7 +9715,7 @@ function ObjectSchema(props) {
|
|
|
9708
9715
|
props.onChange(__spreadProps(__spreadValues({}, onChangeProps), { model }));
|
|
9709
9716
|
};
|
|
9710
9717
|
const isRequired = (propertyName) => props.schema.required && props.schema.required.includes(propertyName);
|
|
9711
|
-
|
|
9718
|
+
useEffect5(() => {
|
|
9712
9719
|
const newModel = getValidObjectModelParts(model, props.schema) || {};
|
|
9713
9720
|
setModel(newModel);
|
|
9714
9721
|
if (!isEqual(newModel, model)) {
|
|
@@ -9765,7 +9772,7 @@ var ObjectSchema_default = ObjectSchema;
|
|
|
9765
9772
|
// src/legacy/jsonSchemaForm/oneOfSchema/OneOfSchema.tsx
|
|
9766
9773
|
import { Header as Header5 } from "@transferwise/components";
|
|
9767
9774
|
import classNames6 from "classnames";
|
|
9768
|
-
import { useEffect as
|
|
9775
|
+
import { useEffect as useEffect7, useMemo as useMemo13, useState as useState10 } from "react";
|
|
9769
9776
|
|
|
9770
9777
|
// src/legacy/jsonSchemaForm/help/Help.tsx
|
|
9771
9778
|
import { Markdown, Info } from "@transferwise/components";
|
|
@@ -9799,7 +9806,7 @@ function Help(props) {
|
|
|
9799
9806
|
var Help_default = Help;
|
|
9800
9807
|
|
|
9801
9808
|
// src/legacy/jsonSchemaForm/schemaFormControl/SchemaFormControl.tsx
|
|
9802
|
-
import { useEffect as
|
|
9809
|
+
import { useEffect as useEffect6 } from "react";
|
|
9803
9810
|
import { useIntl as useIntl10 } from "react-intl";
|
|
9804
9811
|
|
|
9805
9812
|
// src/legacy/formControl/FormControl.tsx
|
|
@@ -10521,7 +10528,7 @@ function SchemaFormControl(props) {
|
|
|
10521
10528
|
onChange(getValidBasicModelOrNull(value2, schema), type, metadata);
|
|
10522
10529
|
};
|
|
10523
10530
|
const controlType = getControlType(schema);
|
|
10524
|
-
|
|
10531
|
+
useEffect6(() => {
|
|
10525
10532
|
warnIfInvalidSchema(schema, log, controlType);
|
|
10526
10533
|
}, [JSON.stringify(schema), log, controlType]);
|
|
10527
10534
|
const options = schema.values || getOptions(schema, controlType);
|
|
@@ -10593,7 +10600,7 @@ function OneOfSchema(props) {
|
|
|
10593
10600
|
searchValueLength: searchValue.length
|
|
10594
10601
|
});
|
|
10595
10602
|
};
|
|
10596
|
-
|
|
10603
|
+
useEffect7(() => {
|
|
10597
10604
|
const modelIndex = getValidIndexFromValue(props.schema, props.model);
|
|
10598
10605
|
const defaultIndex = getValidIndexFromValue(props.schema, props.schema.default);
|
|
10599
10606
|
if (modelIndex === -1 && defaultIndex >= 0) {
|
|
@@ -10751,7 +10758,7 @@ var OneOfSchema_default = OneOfSchema;
|
|
|
10751
10758
|
|
|
10752
10759
|
// src/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/PersistAsyncBlobSchema.tsx
|
|
10753
10760
|
import classNames7 from "classnames";
|
|
10754
|
-
import { useEffect as
|
|
10761
|
+
import { useEffect as useEffect8, useState as useState11 } from "react";
|
|
10755
10762
|
import { useIntl as useIntl11 } from "react-intl";
|
|
10756
10763
|
|
|
10757
10764
|
// src/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/UploadInputAdapter.tsx
|
|
@@ -10822,7 +10829,7 @@ function PersistAsyncBlobSchema(props) {
|
|
|
10822
10829
|
const intl = useIntl11();
|
|
10823
10830
|
const httpClient = useHttpClient();
|
|
10824
10831
|
const onEvent = useEventDispatcher();
|
|
10825
|
-
|
|
10832
|
+
useEffect8(() => {
|
|
10826
10833
|
if (submitted) {
|
|
10827
10834
|
setValidations(getValidationFailures(model, schema, Boolean(required)));
|
|
10828
10835
|
} else {
|
|
@@ -11126,7 +11133,7 @@ function getValueFromOption(option) {
|
|
|
11126
11133
|
}
|
|
11127
11134
|
|
|
11128
11135
|
// src/legacy/jsonSchemaForm/validationAsyncSchema/ValidationAsyncSchema.tsx
|
|
11129
|
-
import { useEffect as
|
|
11136
|
+
import { useEffect as useEffect9, useRef as useRef3, useState as useState13 } from "react";
|
|
11130
11137
|
import { jsx as jsx46 } from "react/jsx-runtime";
|
|
11131
11138
|
function ValidationAsyncSchema(props) {
|
|
11132
11139
|
const { schema, model, required = false, submitted, errors, onChange } = props;
|
|
@@ -11141,7 +11148,7 @@ function ValidationAsyncSchema(props) {
|
|
|
11141
11148
|
const httpClient = useHttpClient();
|
|
11142
11149
|
const onEvent = useEventDispatcher();
|
|
11143
11150
|
const log = useLogger();
|
|
11144
|
-
|
|
11151
|
+
useEffect9(() => {
|
|
11145
11152
|
if (!schema.validationAsync.method) {
|
|
11146
11153
|
log.warning(
|
|
11147
11154
|
"Invalid schema or model",
|
|
@@ -11223,7 +11230,7 @@ function GenericSchemaForm(props) {
|
|
|
11223
11230
|
const schemaProps = __spreadProps(__spreadValues({}, props), { model, errors, hideTitle, disabled });
|
|
11224
11231
|
const type = getSchemaType(schema);
|
|
11225
11232
|
const log = useLogger();
|
|
11226
|
-
|
|
11233
|
+
useEffect10(() => {
|
|
11227
11234
|
if (!isValidGenericSchema(schema, model, errors)) {
|
|
11228
11235
|
log.error(
|
|
11229
11236
|
"Invalid schema or model",
|
|
@@ -11360,14 +11367,14 @@ var DynamicInfo = ({ component }) => {
|
|
|
11360
11367
|
|
|
11361
11368
|
// src/legacy/layout/image/DynamicImage.tsx
|
|
11362
11369
|
import { Image } from "@transferwise/components";
|
|
11363
|
-
import { useEffect as
|
|
11370
|
+
import { useEffect as useEffect11, useState as useState14 } from "react";
|
|
11364
11371
|
import { jsx as jsx51 } from "react/jsx-runtime";
|
|
11365
11372
|
function DynamicImage({ component: image }) {
|
|
11366
11373
|
var _a, _b, _c;
|
|
11367
11374
|
const { content, url, size, text, margin, accessibilityDescription } = image;
|
|
11368
11375
|
const httpClient = useHttpClient();
|
|
11369
11376
|
const [imageSource, setImageSource] = useState14("");
|
|
11370
|
-
|
|
11377
|
+
useEffect11(() => {
|
|
11371
11378
|
if (content) {
|
|
11372
11379
|
const { uri, url: contentUrl } = content;
|
|
11373
11380
|
if (uri && !uri.startsWith("urn:")) {
|
|
@@ -12168,9 +12175,9 @@ var BasicTypeSchema = (props) => {
|
|
|
12168
12175
|
};
|
|
12169
12176
|
const isConst = props.schema.const;
|
|
12170
12177
|
const isHidden = props.schema.hidden || isConst;
|
|
12171
|
-
|
|
12172
|
-
|
|
12173
|
-
|
|
12178
|
+
useEffect12(refreshValidations, [props.model, props.submitted]);
|
|
12179
|
+
useEffect12(onSchemaChange, [props.schema]);
|
|
12180
|
+
useEffect12(() => {
|
|
12174
12181
|
var _a2;
|
|
12175
12182
|
const newModel = (_a2 = props.model) != null ? _a2 : null;
|
|
12176
12183
|
if (newModel !== model) {
|
|
@@ -12251,7 +12258,7 @@ function PersistAsyncBasicSchema(props) {
|
|
|
12251
12258
|
const [persistAsyncError, setPersistAsyncError] = useState19(null);
|
|
12252
12259
|
const [fieldSubmitted, setFieldSubmitted] = useState19(false);
|
|
12253
12260
|
const [abortController, setAbortController] = useState19(null);
|
|
12254
|
-
|
|
12261
|
+
useEffect13(() => {
|
|
12255
12262
|
if (controlTypesWithPersistOnChange.has(
|
|
12256
12263
|
// TODO: LOW avoid type assertion below -- control type may be nullish. consider ?? ''
|
|
12257
12264
|
getControlType(schema.persistAsync.schema)
|
|
@@ -12413,7 +12420,7 @@ function hasStringMessage(value) {
|
|
|
12413
12420
|
}
|
|
12414
12421
|
|
|
12415
12422
|
// src/legacy/common/hooks/usePolling/usePolling.tsx
|
|
12416
|
-
import { useEffect as
|
|
12423
|
+
import { useEffect as useEffect14, useMemo as useMemo17, useRef as useRef5 } from "react";
|
|
12417
12424
|
function usePolling({
|
|
12418
12425
|
asyncFn,
|
|
12419
12426
|
delay,
|
|
@@ -12434,7 +12441,7 @@ function usePolling({
|
|
|
12434
12441
|
),
|
|
12435
12442
|
[asyncFn, maxAttempts, maxConsecutiveFails]
|
|
12436
12443
|
);
|
|
12437
|
-
|
|
12444
|
+
useEffect14(() => {
|
|
12438
12445
|
if (delay > 0) {
|
|
12439
12446
|
poll();
|
|
12440
12447
|
const intervalReference = setInterval(() => {
|
|
@@ -12443,7 +12450,7 @@ function usePolling({
|
|
|
12443
12450
|
return () => clearInterval(intervalReference);
|
|
12444
12451
|
}
|
|
12445
12452
|
}, [poll, delay]);
|
|
12446
|
-
|
|
12453
|
+
useEffect14(() => {
|
|
12447
12454
|
onPollingResponseReference.current = onPollingResponse;
|
|
12448
12455
|
onFailureReference.current = onFailure;
|
|
12449
12456
|
}, [onPollingResponse, onFailure]);
|
|
@@ -12474,10 +12481,10 @@ function createPollingClosure(asyncFn, maxAttempts, maxConsecutiveFails, onPolli
|
|
|
12474
12481
|
}
|
|
12475
12482
|
|
|
12476
12483
|
// src/legacy/common/hooks/usePrevious/usePrevious.js
|
|
12477
|
-
import { useEffect as
|
|
12484
|
+
import { useEffect as useEffect15, useRef as useRef6 } from "react";
|
|
12478
12485
|
var usePrevious = (value) => {
|
|
12479
12486
|
const reference = useRef6();
|
|
12480
|
-
|
|
12487
|
+
useEffect15(() => {
|
|
12481
12488
|
reference.current = value;
|
|
12482
12489
|
}, [value]);
|
|
12483
12490
|
return reference.current;
|
|
@@ -12571,10 +12578,10 @@ var LayoutStep = (props) => {
|
|
|
12571
12578
|
var LayoutStep_default = LayoutStep;
|
|
12572
12579
|
|
|
12573
12580
|
// src/legacy/step/cameraStep/CameraStep.tsx
|
|
12574
|
-
import { useEffect as
|
|
12581
|
+
import { useEffect as useEffect20, useState as useState23 } from "react";
|
|
12575
12582
|
|
|
12576
12583
|
// src/common/cameraCapture/CameraCapture.tsx
|
|
12577
|
-
import { useCallback as useCallback10, useEffect as
|
|
12584
|
+
import { useCallback as useCallback10, useEffect as useEffect19, useMemo as useMemo19, useRef as useRef8, useState as useState22 } from "react";
|
|
12578
12585
|
import { useIntl as useIntl20 } from "react-intl";
|
|
12579
12586
|
import Webcam from "react-webcam";
|
|
12580
12587
|
|
|
@@ -12719,7 +12726,7 @@ function OrientationLockOverlay() {
|
|
|
12719
12726
|
var OrientationLockOverlay_default = OrientationLockOverlay;
|
|
12720
12727
|
|
|
12721
12728
|
// src/common/cameraCapture/hooks/useFullScreenOrientationLock.ts
|
|
12722
|
-
import { useCallback as useCallback9, useEffect as
|
|
12729
|
+
import { useCallback as useCallback9, useEffect as useEffect16 } from "react";
|
|
12723
12730
|
import screenfull from "screenfull";
|
|
12724
12731
|
|
|
12725
12732
|
// src/common/cameraCapture/utils/index.ts
|
|
@@ -12836,7 +12843,7 @@ var useFullScreenOrientationLock = (shouldLockOrientation, onEvent) => {
|
|
|
12836
12843
|
},
|
|
12837
12844
|
[onEvent]
|
|
12838
12845
|
);
|
|
12839
|
-
|
|
12846
|
+
useEffect16(() => {
|
|
12840
12847
|
var _a, _b;
|
|
12841
12848
|
if (shouldLockOrientation) {
|
|
12842
12849
|
(_b = (_a = window.screen) == null ? void 0 : _a.orientation) == null ? void 0 : _b.addEventListener(
|
|
@@ -12859,10 +12866,10 @@ var noop5 = () => {
|
|
|
12859
12866
|
};
|
|
12860
12867
|
|
|
12861
12868
|
// src/common/cameraCapture/hooks/useVideoConstraints.ts
|
|
12862
|
-
import { useEffect as
|
|
12869
|
+
import { useEffect as useEffect17, useState as useState21 } from "react";
|
|
12863
12870
|
var useVideoConstraints = (direction) => {
|
|
12864
12871
|
const [videoConstraints, setVideoConstraints] = useState21();
|
|
12865
|
-
|
|
12872
|
+
useEffect17(() => {
|
|
12866
12873
|
void getVideoConstraints(direction).then(setVideoConstraints);
|
|
12867
12874
|
}, [direction]);
|
|
12868
12875
|
return { videoConstraints };
|
|
@@ -12887,7 +12894,7 @@ var getVideoConstraints = async (dir) => {
|
|
|
12887
12894
|
};
|
|
12888
12895
|
|
|
12889
12896
|
// src/common/cameraCapture/overlay/Overlay.tsx
|
|
12890
|
-
import { useEffect as
|
|
12897
|
+
import { useEffect as useEffect18, useRef as useRef7 } from "react";
|
|
12891
12898
|
import { Fragment as Fragment16, jsx as jsx67, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
12892
12899
|
var captureButtonHeight = 92;
|
|
12893
12900
|
var reviewButtonsHeight = 120;
|
|
@@ -12898,7 +12905,7 @@ var reviewInstructionsHeight = 40;
|
|
|
12898
12905
|
var overlayMaxWidth = 800;
|
|
12899
12906
|
function Overlay({ overlay, outline, imageUrl, title, instructions, reviewInstructions }) {
|
|
12900
12907
|
const svgReference = useRef7(null);
|
|
12901
|
-
|
|
12908
|
+
useEffect18(() => {
|
|
12902
12909
|
const listener = debounce2(() => {
|
|
12903
12910
|
var _a;
|
|
12904
12911
|
if ((_a = svgReference.current) == null ? void 0 : _a.innerHTML) {
|
|
@@ -13067,7 +13074,7 @@ function CameraCapture({
|
|
|
13067
13074
|
setReviewImage(void 0);
|
|
13068
13075
|
};
|
|
13069
13076
|
const handleRetryCameraAccess = () => setMode("CAPTURE" /* CAPTURE */);
|
|
13070
|
-
|
|
13077
|
+
useEffect19(() => {
|
|
13071
13078
|
if (mode !== "CAPTURE" /* CAPTURE */) {
|
|
13072
13079
|
exitFullScreen();
|
|
13073
13080
|
}
|
|
@@ -13146,7 +13153,7 @@ function CameraStep(props) {
|
|
|
13146
13153
|
const { overlay, outline } = assets || {};
|
|
13147
13154
|
const { url: imageUrl } = image || {};
|
|
13148
13155
|
const [captureClicked, setCaptureClicked] = useState23(false);
|
|
13149
|
-
|
|
13156
|
+
useEffect20(() => {
|
|
13150
13157
|
if (captureClicked) {
|
|
13151
13158
|
onAction(action);
|
|
13152
13159
|
}
|
|
@@ -13753,10 +13760,10 @@ var DynamicFlowComponent = ({
|
|
|
13753
13760
|
},
|
|
13754
13761
|
[onCompletion, dispatchEvent]
|
|
13755
13762
|
);
|
|
13756
|
-
|
|
13763
|
+
useEffect21(() => {
|
|
13757
13764
|
dispatchEvent("Dynamic Flow - Flow Started", {});
|
|
13758
13765
|
}, []);
|
|
13759
|
-
|
|
13766
|
+
useEffect21(() => {
|
|
13760
13767
|
if (!initialStep) {
|
|
13761
13768
|
const action = __spreadValues({
|
|
13762
13769
|
id: "#initial-step-request",
|