@wise/dynamic-flow-client 0.4.0 → 0.4.2
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/common/constants/DateMode.js +2 -2
- package/build/common/constants/FormControlType.js +2 -2
- package/build/common/constants/MonthFormat.js +2 -2
- package/build/common/constants/SchemaType.js +2 -2
- package/build/common/constants/Size.js +2 -2
- package/build/common/constants/index.js +1 -1
- package/build/common/contexts/dynamicFlowContexts/DynamicFlowContexts.js +15 -27
- package/build/common/contexts/dynamicFlowContexts/usePendingPromiseCounter.js +11 -9
- package/build/common/contexts/eventsContext/EventsContext.js +11 -28
- package/build/common/contexts/fetcherContexts/FetcherContexts.js +14 -27
- package/build/common/contexts/index.js +1 -1
- package/build/common/contexts/logContext/LogContext.js +12 -30
- package/build/common/hooks/index.js +1 -1
- package/build/common/hooks/useDebouncedFunction/useDebouncedFunction.js +3 -3
- package/build/common/hooks/useExternal/useExternal.js +8 -8
- package/build/common/hooks/useExternalStepPolling/useExternalStepPolling.js +20 -31
- package/build/common/hooks/usePersistAsync/usePersistAsync.js +60 -139
- package/build/common/hooks/usePolling/usePolling.js +20 -21
- package/build/common/hooks/usePrevious/usePrevious.js +5 -5
- package/build/common/hooks/useStepPolling/useStepPolling.js +15 -14
- package/build/common/makeFetcher/index.js +1 -1
- package/build/common/makeFetcher/makeFetcher.js +10 -24
- package/build/common/messages.js +5 -5
- package/build/common/utils/api-utils.js +3 -4
- package/build/common/utils/date-utils.js +11 -11
- package/build/common/utils/debounce.js +11 -15
- package/build/common/utils/file-utils.js +12 -25
- package/build/common/utils/id-utils.js +4 -5
- package/build/common/utils/index.js +1 -1
- package/build/common/utils/is-equal.js +8 -8
- package/build/common/utils/schema-utils.js +6 -6
- package/build/common/utils/step-utils.js +14 -14
- package/build/common/validators/index.js +7 -7
- package/build/common/validators/models/model-validators.js +8 -8
- package/build/common/validators/models/models.utils.js +29 -42
- package/build/common/validators/schemas/schema-validators.js +11 -13
- package/build/common/validators/types/type-validators.js +9 -13
- package/build/common/validators/validationFailures/validation-failures.js +14 -14
- package/build/common/validators/validationFailures/validation-failures.utils.js +5 -7
- package/build/common/validators/values/value-validators.js +4 -6
- package/build/dynamicFlow/DynamicFlow.js +185 -307
- package/build/dynamicFlow/DynamicFlowStep.js +12 -23
- package/build/dynamicFlow/DynamicFlowTypes.js +1 -1
- package/build/dynamicFlow/index.js +6 -14
- package/build/dynamicFlow/stories/DynamicFlow.story.js +20 -20
- package/build/dynamicFlow/stories/EditableDynamicFlow.js +20 -33
- package/build/dynamicFlow/stories/fixtureFetcher.js +46 -104
- package/build/dynamicFlow/utils/errorBoundary/ErrorBoundary.js +22 -40
- package/build/dynamicFlow/utils/errorBoundary/ErrorBoundary.messages.js +6 -6
- package/build/dynamicFlow/utils/errorBoundary/ErrorBoundaryAlert.js +10 -11
- package/build/dynamicFlow/utils/index.js +5 -2
- package/build/dynamicFlow/utils/responseParsers/response-parsers.js +53 -118
- package/build/dynamicFlow/utils/useDebouncedRefresh/useDebouncedRefresh.js +9 -9
- package/build/dynamicFlow/utils/useDynamicFlowState.js +51 -74
- package/build/dynamicFlow/utils/useLoader.js +9 -20
- package/build/fixtures/components/alert.js +8 -8
- package/build/fixtures/components/box.js +7 -7
- package/build/fixtures/components/button.js +25 -36
- package/build/fixtures/components/columns.js +10 -10
- package/build/fixtures/components/copyable.js +6 -6
- package/build/fixtures/components/decision.js +15 -15
- package/build/fixtures/components/heading.js +7 -7
- package/build/fixtures/components/image.js +10 -10
- package/build/fixtures/components/index.js +17 -25
- package/build/fixtures/components/info.js +22 -6
- package/build/fixtures/components/list.js +8 -8
- package/build/fixtures/components/loading-indicator.js +5 -5
- package/build/fixtures/components/paragraph.js +9 -9
- package/build/fixtures/components/review.js +11 -11
- package/build/fixtures/examples/camera-capture.js +29 -29
- package/build/fixtures/examples/index.js +9 -17
- package/build/fixtures/examples/recipient-update.js +69 -69
- package/build/fixtures/examples/recipient.js +63 -63
- package/build/fixtures/examples/single-file-upload.js +21 -21
- package/build/fixtures/examples/step-validation-errors.js +21 -21
- package/build/fixtures/features/action-response.js +8 -8
- package/build/fixtures/features/external.js +8 -8
- package/build/fixtures/features/index.js +9 -17
- package/build/fixtures/features/persist-async.js +11 -11
- package/build/fixtures/features/polling.js +9 -9
- package/build/fixtures/features/validation-async.js +10 -10
- package/build/fixtures/index.js +11 -22
- package/build/fixtures/jsonSchemaForm/allOf.js +30 -30
- package/build/fixtures/jsonSchemaForm/audRecipient.js +271 -271
- package/build/fixtures/jsonSchemaForm/currency.js +12 -12
- package/build/fixtures/jsonSchemaForm/multipleFileUploadBase64.js +11 -11
- package/build/fixtures/jsonSchemaForm/multipleFileUploadBlob.js +11 -11
- package/build/fixtures/jsonSchemaForm/oneOf.js +27 -27
- package/build/fixtures/jsonSchemaForm/oneOfTabs.js +16 -16
- package/build/fixtures/jsonSchemaForm/promotedOneOf.js +17 -17
- package/build/fixtures/jsonSchemaForm/promotedOneOfCheckbox.js +30 -30
- package/build/fixtures/jsonSchemaForm/simple.js +16 -16
- package/build/fixtures/jsonSchemaForm/uploadPersistAsync.js +19 -19
- package/build/fixtures/jsonSchemaForm/validationAsync.js +8 -8
- package/build/fixtures/layouts/all.js +37 -37
- package/build/fixtures/layouts/final-step-layout.js +9 -9
- package/build/fixtures/layouts/index.js +10 -18
- package/build/fixtures/layouts/list.js +10 -10
- package/build/fixtures/layouts/pay-in.js +23 -23
- package/build/fixtures/layouts/review.js +38 -38
- package/build/fixtures/layouts/success.js +15 -15
- package/build/fixtures/responses/action-response-final.js +8 -8
- package/build/fixtures/responses/action.js +3 -3
- package/build/fixtures/responses/exit.js +3 -3
- package/build/fixtures/responses/index.js +8 -16
- package/build/fixtures/responses/recipient-update-final.js +8 -8
- package/build/fixtures/schemas/basic-form.js +11 -11
- package/build/fixtures/schemas/index.js +8 -16
- package/build/fixtures/schemas/number-and-integer.js +11 -11
- package/build/fixtures/schemas/one-of.js +43 -46
- package/build/fixtures/schemas/string-formats.js +15 -15
- package/build/fixtures/utils/image-util.js +8 -8
- package/build/formControl/FormControl.js +118 -148
- package/build/formControl/index.js +6 -14
- package/build/formControl/utils/index.js +1 -1
- package/build/formControl/utils/value-utils.js +18 -23
- package/build/i18n/index.js +31 -31
- package/build/index.js +13 -10
- package/build/jsonSchemaForm/JsonSchemaForm.js +12 -24
- package/build/jsonSchemaForm/allOfSchema/AllOfSchema.js +24 -37
- package/build/jsonSchemaForm/allOfSchema/index.js +6 -14
- package/build/jsonSchemaForm/arrayTypeSchema/ArraySchema.js +9 -20
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/ArrayListSchema.js +9 -20
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/index.js +6 -14
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.js +56 -115
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.messages.js +7 -7
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/index.js +6 -14
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/index.js +1 -1
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/upload-utils.js +19 -71
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/useFormattedDefaultErrorMessages.js +10 -11
- package/build/jsonSchemaForm/arrayTypeSchema/index.js +6 -14
- package/build/jsonSchemaForm/basicTypeSchema/BasicTypeSchema.js +45 -62
- package/build/jsonSchemaForm/basicTypeSchema/index.js +6 -14
- package/build/jsonSchemaForm/controlFeedback/ControlFeedback.js +39 -50
- package/build/jsonSchemaForm/controlFeedback/ControlFeedback.messages.js +18 -18
- package/build/jsonSchemaForm/controlFeedback/index.js +6 -14
- package/build/jsonSchemaForm/genericSchema/GenericSchema.js +52 -61
- package/build/jsonSchemaForm/genericSchema/index.js +6 -14
- package/build/jsonSchemaForm/help/Help.js +9 -9
- package/build/jsonSchemaForm/help/Help.messages.js +5 -5
- package/build/jsonSchemaForm/help/index.js +6 -14
- package/build/jsonSchemaForm/index.js +6 -14
- package/build/jsonSchemaForm/objectSchema/ObjectSchema.js +28 -49
- package/build/jsonSchemaForm/objectSchema/index.js +6 -14
- package/build/jsonSchemaForm/oneOfSchema/OneOfSchema.js +54 -74
- package/build/jsonSchemaForm/oneOfSchema/index.js +6 -14
- package/build/jsonSchemaForm/oneOfSchema/utils/const-schema-utils.js +3 -3
- package/build/jsonSchemaForm/oneOfSchema/utils/index.js +1 -1
- package/build/jsonSchemaForm/oneOfSchema/utils/one-of-utils.js +19 -20
- package/build/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.js +11 -22
- package/build/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.messages.js +5 -5
- package/build/jsonSchemaForm/persistAsyncSchema/index.js +6 -14
- package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/PersistAsyncBasicSchema.js +73 -127
- package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/index.js +6 -14
- package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/PersistAsyncBlobSchema.js +45 -110
- package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/UploadInputAdapter.js +17 -17
- package/build/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/index.js +6 -14
- package/build/jsonSchemaForm/promotedOneOfSchema/PromotedOneOfSchema.js +28 -47
- package/build/jsonSchemaForm/promotedOneOfSchema/index.js +6 -14
- package/build/jsonSchemaForm/promotedOneOfSchema/promoted-one-of-utils.js +4 -4
- package/build/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfCheckboxControl.js +13 -24
- package/build/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfControl.js +11 -22
- package/build/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfRadioControl.js +12 -23
- package/build/jsonSchemaForm/readOnlySchema/ReadOnlySchema.js +24 -26
- package/build/jsonSchemaForm/readOnlySchema/ReadOnlySchema.messages.js +6 -6
- package/build/jsonSchemaForm/readOnlySchema/index.js +6 -14
- package/build/jsonSchemaForm/schemaFormControl/SchemaFormControl.js +26 -39
- package/build/jsonSchemaForm/schemaFormControl/index.js +6 -14
- package/build/jsonSchemaForm/schemaFormControl/utils/currency-utils.js +5 -5
- package/build/jsonSchemaForm/schemaFormControl/utils/index.js +1 -1
- package/build/jsonSchemaForm/schemaFormControl/utils/mapping-utils.js +30 -47
- package/build/jsonSchemaForm/validationAsyncSchema/ValidationAsyncSchema.js +57 -119
- package/build/jsonSchemaForm/validationAsyncSchema/index.js +6 -14
- package/build/layout/DynamicLayout.js +10 -21
- package/build/layout/alert/DynamicAlert.js +9 -9
- package/build/layout/box/DynamicBox.js +12 -23
- package/build/layout/button/DynamicButton.js +16 -27
- package/build/layout/columns/DynamicColumns.js +13 -24
- package/build/layout/decision/DynamicDecision.js +16 -27
- package/build/layout/divider/DynamicDivider.js +7 -8
- package/build/layout/external/DynamicExternal.js +16 -28
- package/build/layout/external/DynamicExternal.messages.js +5 -5
- package/build/layout/form/DynamicForm.js +10 -21
- package/build/layout/heading/DynamicHeading.js +12 -23
- package/build/layout/icon/DynamicIcon.js +9 -10
- package/build/layout/image/DynamicImage.js +43 -93
- package/build/layout/index.js +21 -29
- package/build/layout/info/DynamicInfo.js +7 -19
- package/build/layout/list/DynamicList.js +14 -26
- package/build/layout/loadingIndicator/DynamicLoadingIndicator.js +8 -9
- package/build/layout/paragraph/DynamicParagraph.js +19 -37
- package/build/layout/paragraph/DynamicParagraph.messages.js +6 -6
- package/build/layout/paragraph/useSnackBarIfAvailable.js +4 -4
- package/build/layout/review/DynamicReview.js +14 -26
- package/build/layout/utils.js +4 -6
- package/build/step/cameraStep/CameraStep.js +42 -88
- package/build/step/cameraStep/cameraCapture/CameraCapture.js +48 -105
- package/build/step/cameraStep/cameraCapture/CameraCapture.messages.js +7 -7
- package/build/step/cameraStep/cameraCapture/components/index.js +10 -28
- package/build/step/cameraStep/cameraCapture/hooks/index.js +17 -72
- package/build/step/cameraStep/cameraCapture/index.js +6 -14
- package/build/step/cameraStep/cameraCapture/overlay/Overlay.js +33 -45
- package/build/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.js +8 -19
- package/build/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.messages.js +6 -6
- package/build/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.js +9 -21
- package/build/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.messages.js +7 -7
- package/build/step/cameraStep/cameraCapture/screens/index.js +6 -14
- package/build/step/cameraStep/cameraCapture/tracking/index.js +17 -99
- package/build/step/cameraStep/cameraCapture/utils/index.js +33 -96
- package/build/step/cameraStep/index.js +6 -14
- package/build/step/externalConfirmationStep/ExternalConfirmationStep.js +20 -21
- package/build/step/externalConfirmationStep/ExternalConfirmationStep.messages.js +8 -8
- package/build/step/externalConfirmationStep/index.js +6 -14
- package/build/step/index.js +7 -15
- package/build/step/layoutStep/LayoutStep.js +19 -19
- package/build/step/layoutStep/index.js +6 -14
- package/build/step/layoutStep/utils/index.js +3 -14
- package/build/step/layoutStep/utils/inline-reference-utils.js +29 -46
- package/build/step/layoutStep/utils/layout-utils.js +34 -53
- package/build/types/common/FormControl.js +1 -1
- package/build/types/index.js +13 -13
- package/build/types/specification/Action.js +1 -1
- package/build/types/specification/FileUploadSchema.js +1 -1
- package/build/types/specification/LayoutComponent.js +1 -1
- package/build/types/specification/Model.js +9 -17
- package/build/types/specification/PersistAsync.js +1 -1
- package/build/types/specification/Polling.js +1 -1
- package/build/types/specification/Promotion.js +1 -1
- package/build/types/specification/Schema.js +8 -8
- package/build/types/specification/Step.js +3 -5
- package/build/types/specification/ValidationAsync.js +1 -1
- package/build/types/specification/core.js +1 -1
- package/package.json +1 -1
|
@@ -1,60 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
-
if (ar || !(i in from)) {
|
|
16
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
-
ar[i] = from[i];
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
-
};
|
|
22
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
4
|
};
|
|
25
|
-
exports
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const contexts_1 = require("../../common/contexts");
|
|
10
|
+
const hooks_1 = require("../../common/hooks");
|
|
11
|
+
const utils_1 = require("../../common/utils");
|
|
12
|
+
const validators_1 = require("../../common/validators");
|
|
13
|
+
const layout_1 = require("../../layout");
|
|
14
|
+
const controlFeedback_1 = __importDefault(require("../controlFeedback"));
|
|
15
|
+
const genericSchema_1 = __importDefault(require("../genericSchema"));
|
|
16
|
+
const help_1 = __importDefault(require("../help"));
|
|
17
|
+
const schemaFormControl_1 = __importDefault(require("../schemaFormControl"));
|
|
18
|
+
const utils_2 = require("./utils");
|
|
19
|
+
const OneOfSchema = (props) => {
|
|
20
|
+
const onEvent = (0, contexts_1.useEventDispatcher)();
|
|
21
|
+
const [changed, setChanged] = (0, react_1.useState)(false);
|
|
22
|
+
const [focused, setFocused] = (0, react_1.useState)(false);
|
|
23
|
+
const [blurred, setBlurred] = (0, react_1.useState)(false);
|
|
24
|
+
const id = (0, react_1.useMemo)(() => props.schema.$id || (0, utils_1.generateRandomId)(), [props.schema.$id]);
|
|
25
|
+
const [schemaIndex, setSchemaIndex] = (0, react_1.useState)((0, utils_2.getActiveSchemaIndex)(props.schema, props.model));
|
|
26
|
+
const [models, setModels] = (0, react_1.useState)(getModelPartsForSchemas(props.model, props.schema.oneOf));
|
|
27
|
+
const debouncedTrackEvent = (0, hooks_1.useDebouncedFunction)(onEvent, 200);
|
|
28
|
+
const onSearchChange = (searchValue) => {
|
|
49
29
|
debouncedTrackEvent('Dynamic Flow - OneOf Searched', {
|
|
50
30
|
oneOfId: props.schema.analyticsId,
|
|
51
|
-
searchValueLength: searchValue.length
|
|
31
|
+
searchValueLength: searchValue.length,
|
|
52
32
|
});
|
|
53
33
|
};
|
|
54
34
|
// When the schema we receive from parent changes
|
|
55
|
-
(0, react_1.useEffect)(
|
|
56
|
-
|
|
57
|
-
|
|
35
|
+
(0, react_1.useEffect)(() => {
|
|
36
|
+
const modelIndex = (0, utils_2.getValidIndexFromValue)(props.schema, props.model);
|
|
37
|
+
const defaultIndex = (0, utils_2.getValidIndexFromValue)(props.schema, props.schema.default);
|
|
58
38
|
if (modelIndex === -1 && defaultIndex >= 0) {
|
|
59
39
|
onChooseNewSchema(defaultIndex, 'init');
|
|
60
40
|
}
|
|
@@ -64,30 +44,30 @@ var OneOfSchema = function (props) {
|
|
|
64
44
|
console.error('Incorrect format', props.schema);
|
|
65
45
|
return null;
|
|
66
46
|
}
|
|
67
|
-
|
|
68
|
-
setModels(
|
|
47
|
+
const onChildModelChange = (index, onChangeParameters) => {
|
|
48
|
+
setModels([...models.slice(0, index), onChangeParameters.model, ...models.slice(index + 1)]);
|
|
69
49
|
setChanged(true);
|
|
70
50
|
props.onChange(onChangeParameters);
|
|
71
51
|
};
|
|
72
|
-
|
|
52
|
+
const onFocus = () => {
|
|
73
53
|
setFocused(true);
|
|
74
54
|
};
|
|
75
|
-
|
|
55
|
+
const onBlur = () => {
|
|
76
56
|
setFocused(false);
|
|
77
57
|
setBlurred(true);
|
|
78
58
|
};
|
|
79
59
|
// TODO: LOW avoid type assertion
|
|
80
|
-
|
|
60
|
+
const onChooseNewSchema = (index, type) => {
|
|
81
61
|
setSchemaIndex(index);
|
|
82
|
-
|
|
62
|
+
const newSchema = props.schema.oneOf[index];
|
|
83
63
|
if ((0, utils_2.isConstSchema)(newSchema)) {
|
|
84
64
|
// If new schema is a const we want to share the parent schema, not the const
|
|
85
|
-
|
|
65
|
+
const model = newSchema.const;
|
|
86
66
|
props.onChange({
|
|
87
|
-
model
|
|
67
|
+
model,
|
|
88
68
|
triggerSchema: props.schema,
|
|
89
69
|
triggerModel: model,
|
|
90
|
-
type
|
|
70
|
+
type,
|
|
91
71
|
});
|
|
92
72
|
}
|
|
93
73
|
else {
|
|
@@ -95,34 +75,34 @@ var OneOfSchema = function (props) {
|
|
|
95
75
|
model: models[index],
|
|
96
76
|
triggerSchema: newSchema,
|
|
97
77
|
triggerModel: models[index],
|
|
98
|
-
type
|
|
78
|
+
type,
|
|
99
79
|
});
|
|
100
80
|
}
|
|
101
81
|
if (type !== 'init' && props.schema.analyticsId) {
|
|
102
82
|
onEvent('Dynamic Flow - OneOf Selected', {
|
|
103
83
|
oneOfId: props.schema.analyticsId,
|
|
104
|
-
schemaId: newSchema === null || newSchema === void 0 ? void 0 : newSchema.analyticsId
|
|
84
|
+
schemaId: newSchema === null || newSchema === void 0 ? void 0 : newSchema.analyticsId,
|
|
105
85
|
});
|
|
106
86
|
}
|
|
107
87
|
};
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
88
|
+
const schemaForSelect = mapSchemasForSelect(props.schema);
|
|
89
|
+
const validations = getValidations(props, schemaIndex);
|
|
90
|
+
const formGroupClasses = {
|
|
111
91
|
'form-group': true,
|
|
112
92
|
'has-error': (!changed && props.errors && !(0, validators_1.isEmpty)(props.errors)) ||
|
|
113
|
-
((props.submitted || (changed && blurred)) && validations.length)
|
|
93
|
+
((props.submitted || (changed && blurred)) && validations.length),
|
|
114
94
|
};
|
|
115
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(props.schema.oneOf.length > 1 || (0, utils_2.isConstSchema)(props.schema.oneOf[0])) && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div",
|
|
95
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(props.schema.oneOf.length > 1 || (0, utils_2.isConstSchema)(props.schema.oneOf[0])) && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: (0, classnames_1.default)(formGroupClasses) }, { children: [getTitleAndHelp(props.schema, id), (0, jsx_runtime_1.jsx)(schemaFormControl_1.default, { id: id, schema: schemaForSelect, value: schemaIndex, disabled: props.disabled, onChange: onChooseNewSchema, onFocus: onFocus, onBlur: onBlur, onSearchChange: onSearchChange }), (0, jsx_runtime_1.jsx)(controlFeedback_1.default, { changed: changed, focused: focused, blurred: blurred, submitted: props.submitted, errors: errorsToString(props.errors), schema: props.schema, validations: validations, infoMessage: null })] })), props.schema.alert && (0, jsx_runtime_1.jsx)(layout_1.DynamicAlert, { component: props.schema.alert })] })), (0, utils_2.isNoNConstSchema)(props.schema.oneOf[schemaIndex]) && ((0, jsx_runtime_1.jsx)(genericSchema_1.default, { schema: props.schema.oneOf[schemaIndex], model: models[schemaIndex], errors: props.errors, submitted: props.submitted, hideTitle: true, disabled: props.disabled, onChange: (parameters) => onChildModelChange(schemaIndex, parameters), onPersistAsync: props.onPersistAsync }))] }));
|
|
116
96
|
};
|
|
117
97
|
function getTitleAndHelp(schema, id) {
|
|
118
|
-
|
|
119
|
-
|
|
98
|
+
const helpElement = schema.help ? (0, jsx_runtime_1.jsx)(help_1.default, { help: schema.help }) : null;
|
|
99
|
+
const titleElement = (0, utils_2.isConstSchema)(schema.oneOf[0]) ? ((0, jsx_runtime_1.jsxs)("label", Object.assign({ className: "control-label d-inline", htmlFor: id }, { children: [schema.title, " ", helpElement] }))) : ((0, jsx_runtime_1.jsxs)("h4", Object.assign({ className: "m-b-2" }, { children: [schema.title, " ", helpElement] })));
|
|
120
100
|
return schema.title ? titleElement : helpElement;
|
|
121
101
|
}
|
|
122
102
|
function getValidations(props, schemaIndex) {
|
|
123
|
-
|
|
103
|
+
const selectedSchema = props.schema.oneOf[schemaIndex !== null && schemaIndex !== void 0 ? schemaIndex : -1];
|
|
124
104
|
if ((0, utils_2.isConstSchema)(selectedSchema)) {
|
|
125
|
-
return (0, validators_1.getValidationFailures)(selectedSchema
|
|
105
|
+
return (0, validators_1.getValidationFailures)(selectedSchema.const, props.schema, !!props.required);
|
|
126
106
|
}
|
|
127
107
|
if (schemaIndex === null || schemaIndex < 0) {
|
|
128
108
|
return (0, validators_1.getValidationFailures)(null, props.schema, !!props.required);
|
|
@@ -137,19 +117,19 @@ function errorsToString(errors) {
|
|
|
137
117
|
return null;
|
|
138
118
|
}
|
|
139
119
|
function getModelPartsForSchemas(model, schemas) {
|
|
140
|
-
return schemas.map(
|
|
120
|
+
return schemas.map((schema) => (0, validators_1.getValidModelParts)(model, schema));
|
|
141
121
|
}
|
|
142
122
|
// We want our model to be the index, so alter the oneOf schemas to be a const
|
|
143
123
|
function mapSchemasForSelect(schema) {
|
|
144
|
-
return
|
|
124
|
+
return Object.assign(Object.assign({}, schema), { oneOf: schema.oneOf.map(mapOneOfToConst) });
|
|
145
125
|
}
|
|
146
126
|
function mapOneOfToConst(schema, index) {
|
|
147
|
-
|
|
127
|
+
const { title, description, disabled = false, icon, image, keywords } = schema;
|
|
148
128
|
// TODO LOW avoid type assertion below -- consider adding { type: 'integer' }
|
|
149
|
-
return { title
|
|
129
|
+
return { title, description, disabled, icon, image, const: index, keywords };
|
|
150
130
|
}
|
|
151
131
|
OneOfSchema.defaultProps = {
|
|
152
132
|
required: false,
|
|
153
|
-
disabled: false
|
|
133
|
+
disabled: false,
|
|
154
134
|
};
|
|
155
|
-
exports
|
|
135
|
+
exports.default = OneOfSchema;
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
exports.__esModule = true;
|
|
14
|
-
exports["default"] = void 0;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = void 0;
|
|
15
7
|
var OneOfSchema_1 = require("./OneOfSchema");
|
|
16
|
-
|
|
8
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(OneOfSchema_1).default; } });
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isNoNConstSchema = exports.isConstSchema = void 0;
|
|
4
|
-
|
|
4
|
+
const validators_1 = require("../../../common/validators");
|
|
5
5
|
// TODO HD Move this out of here
|
|
6
6
|
function isConstSchema(schema) {
|
|
7
|
-
return !(0, validators_1.isUndefined)(schema === null || schema === void 0 ? void 0 : schema
|
|
7
|
+
return !(0, validators_1.isUndefined)(schema === null || schema === void 0 ? void 0 : schema.const);
|
|
8
8
|
}
|
|
9
9
|
exports.isConstSchema = isConstSchema;
|
|
10
10
|
function isNoNConstSchema(schema) {
|
|
@@ -13,6 +13,6 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
|
-
exports
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./const-schema-utils"), exports);
|
|
18
18
|
__exportStar(require("./one-of-utils"), exports);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getBestMatchingSchemaIndexForValue = exports.getValidIndexFromValue = exports.getActiveSchemaIndex = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const validators_1 = require("../../../common/validators");
|
|
5
|
+
const types_1 = require("../../../types");
|
|
6
|
+
const Schema_1 = require("../../../types/specification/Schema");
|
|
7
|
+
const const_schema_utils_1 = require("./const-schema-utils");
|
|
8
|
+
const getActiveSchemaIndex = (schema, model) => {
|
|
9
|
+
const indexFromModel = (0, exports.getValidIndexFromValue)(schema, model);
|
|
10
10
|
// If our model satisfies one of the schemas, use that schema.
|
|
11
11
|
if (indexFromModel >= 0) {
|
|
12
12
|
return indexFromModel;
|
|
@@ -16,7 +16,7 @@ var getActiveSchemaIndex = function (schema, model) {
|
|
|
16
16
|
return 0;
|
|
17
17
|
}
|
|
18
18
|
if ((0, const_schema_utils_1.isConstSchema)(schema.oneOf[0])) {
|
|
19
|
-
|
|
19
|
+
const indexFromDefault = (0, exports.getValidIndexFromValue)(schema, schema.default);
|
|
20
20
|
// If the default value satisfies one of the schemas, use that schema.
|
|
21
21
|
if (indexFromDefault >= 0) {
|
|
22
22
|
return indexFromDefault;
|
|
@@ -27,28 +27,27 @@ var getActiveSchemaIndex = function (schema, model) {
|
|
|
27
27
|
return getBestMatchingSchemaIndexForValue(schema, model);
|
|
28
28
|
}
|
|
29
29
|
if ((0, Schema_1.isOneOfObjectSchema)(schema) &&
|
|
30
|
-
!(0, validators_1.isUndefined)(schema
|
|
31
|
-
(0, types_1.isObjectModel)(schema
|
|
32
|
-
Object.keys(schema
|
|
30
|
+
!(0, validators_1.isUndefined)(schema.default) &&
|
|
31
|
+
(0, types_1.isObjectModel)(schema.default) &&
|
|
32
|
+
Object.keys(schema.default).length >= 1) {
|
|
33
33
|
// Even if the default value does not satisfy any of the schemas, it may be closer to one of them.
|
|
34
|
-
return getBestMatchingSchemaIndexForValue(schema, schema
|
|
34
|
+
return getBestMatchingSchemaIndexForValue(schema, schema.default);
|
|
35
35
|
}
|
|
36
36
|
// Otherwise do not default
|
|
37
37
|
return null;
|
|
38
38
|
};
|
|
39
39
|
exports.getActiveSchemaIndex = getActiveSchemaIndex;
|
|
40
|
-
|
|
41
|
-
return schema.oneOf.findIndex(
|
|
40
|
+
const getValidIndexFromValue = (schema, value) => {
|
|
41
|
+
return schema.oneOf.findIndex((childSchema) => !(0, validators_1.isUndefined)(value) && (0, validators_1.isValidSchema)(value, childSchema));
|
|
42
42
|
};
|
|
43
43
|
exports.getValidIndexFromValue = getValidIndexFromValue;
|
|
44
44
|
function getBestMatchingSchemaIndexForValue(schema, value) {
|
|
45
45
|
if (value === null || value === undefined) {
|
|
46
46
|
return null;
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
return getSchemaProperties(childSchema).reduce(
|
|
50
|
-
|
|
51
|
-
if ((0, const_schema_utils_1.isConstSchema)(propertySchema) && propertySchema["const"] === value[key]) {
|
|
48
|
+
const schemaPoints = schema.oneOf.map((childSchema) => {
|
|
49
|
+
return getSchemaProperties(childSchema).reduce((total, [key, propertySchema]) => {
|
|
50
|
+
if ((0, const_schema_utils_1.isConstSchema)(propertySchema) && propertySchema.const === value[key]) {
|
|
52
51
|
return total + 2;
|
|
53
52
|
}
|
|
54
53
|
else if ((0, const_schema_utils_1.isNoNConstSchema)(propertySchema) && typeof value[key] !== 'undefined') {
|
|
@@ -57,10 +56,10 @@ function getBestMatchingSchemaIndexForValue(schema, value) {
|
|
|
57
56
|
return total;
|
|
58
57
|
}, 0);
|
|
59
58
|
});
|
|
60
|
-
if (schemaPoints.every(
|
|
59
|
+
if (schemaPoints.every((p) => p === schemaPoints[0])) {
|
|
61
60
|
return null;
|
|
62
61
|
}
|
|
63
|
-
return schemaPoints.indexOf(Math.max
|
|
62
|
+
return schemaPoints.indexOf(Math.max(...schemaPoints));
|
|
64
63
|
}
|
|
65
64
|
exports.getBestMatchingSchemaIndexForValue = getBestMatchingSchemaIndexForValue;
|
|
66
65
|
function getSchemaProperties(childSchema) {
|
|
@@ -1,31 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
4
|
};
|
|
16
|
-
exports
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const persistAsyncBasicSchema_1 = __importDefault(require("./persistAsyncBasicSchema"));
|
|
8
|
+
const persistAsyncBlobSchema_1 = __importDefault(require("./persistAsyncBlobSchema"));
|
|
9
|
+
const PersistAsyncSchema = (props) => {
|
|
10
|
+
const { schema } = props;
|
|
11
|
+
const persistAsyncSchemaType = schema.persistAsync.schema.type;
|
|
23
12
|
if (persistAsyncSchemaType === 'blob') {
|
|
24
|
-
return ((0, jsx_runtime_1.jsx)(persistAsyncBlobSchema_1
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)(persistAsyncBlobSchema_1.default, Object.assign({}, props)));
|
|
25
14
|
}
|
|
26
|
-
return (0, jsx_runtime_1.jsx)(persistAsyncBasicSchema_1
|
|
15
|
+
return (0, jsx_runtime_1.jsx)(persistAsyncBasicSchema_1.default, Object.assign({}, props));
|
|
27
16
|
};
|
|
28
17
|
PersistAsyncSchema.defaultProps = {
|
|
29
|
-
required: false
|
|
18
|
+
required: false,
|
|
30
19
|
};
|
|
31
|
-
exports
|
|
20
|
+
exports.default = PersistAsyncSchema;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
3
|
-
|
|
4
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const react_intl_1 = require("react-intl");
|
|
4
|
+
exports.default = (0, react_intl_1.defineMessages)({
|
|
5
5
|
genericError: {
|
|
6
6
|
id: 'dynamicFlows.PersistAsyncSchema.genericError',
|
|
7
7
|
defaultMessage: 'Something went wrong, please try again later!',
|
|
8
|
-
description: 'Generic error message for persist async schema'
|
|
9
|
-
}
|
|
8
|
+
description: 'Generic error message for persist async schema',
|
|
9
|
+
},
|
|
10
10
|
});
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
exports.__esModule = true;
|
|
14
|
-
exports["default"] = void 0;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = void 0;
|
|
15
7
|
var PersistAsyncSchema_1 = require("./PersistAsyncSchema");
|
|
16
|
-
|
|
8
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(PersistAsyncSchema_1).default; } });
|