@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,15 +1,4 @@
|
|
|
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
3
|
if (k2 === undefined) k2 = k;
|
|
15
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -33,14 +22,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
33
22
|
__setModuleDefault(result, mod);
|
|
34
23
|
return result;
|
|
35
24
|
};
|
|
36
|
-
exports
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
26
|
exports.mapSchemaToUploadOptions = exports.mapAvatar = exports.mapIconToAvatar = exports.mapIcon = exports.mapImage = exports.mapConstSchemaToOption = void 0;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
27
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
28
|
+
const components_1 = require("@transferwise/components");
|
|
29
|
+
const validators_1 = require("../../../common/validators");
|
|
30
|
+
const DynamicIcon_1 = __importStar(require("../../../layout/icon/DynamicIcon"));
|
|
31
|
+
const currency_utils_1 = require("./currency-utils");
|
|
32
|
+
const mapConstSchemaToOption = (schema, controlType) => {
|
|
44
33
|
switch (controlType) {
|
|
45
34
|
case 'select':
|
|
46
35
|
return mapConstSchemaToSelectOption(schema);
|
|
@@ -50,33 +39,31 @@ var mapConstSchemaToOption = function (schema, controlType) {
|
|
|
50
39
|
}
|
|
51
40
|
};
|
|
52
41
|
exports.mapConstSchemaToOption = mapConstSchemaToOption;
|
|
53
|
-
|
|
54
|
-
return
|
|
42
|
+
const mapConstSchemaToRadioOption = (schema) => {
|
|
43
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({
|
|
55
44
|
// TODO: LOW avoid type assertion -- using || '' would fail some tests
|
|
56
|
-
label: schema.title, value: schema
|
|
45
|
+
label: schema.title, value: schema.const }, getOptionDescription(schema.title, schema.description)), (0, exports.mapIconToAvatar)(schema.icon)), mapCurrency(schema.icon)), (0, exports.mapAvatar)(schema.image)), getDisabled(schema.disabled));
|
|
57
46
|
};
|
|
58
|
-
|
|
59
|
-
return
|
|
47
|
+
const mapConstSchemaToSelectOption = (schema) => {
|
|
48
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({
|
|
60
49
|
// TODO: LOW avoid type assertion -- using || '' would fail some tests
|
|
61
|
-
label: schema.title, value: schema
|
|
50
|
+
label: schema.title, value: schema.const }, getOptionDescription(schema.title, schema.description)), (0, exports.mapIcon)(schema.icon)), mapCurrency(schema.icon)), (0, exports.mapImage)(schema.image)), getDisabled(schema.disabled)), mapKeywordsToSearchStrings(schema.keywords));
|
|
62
51
|
};
|
|
63
52
|
// TODO: LOW avoid type assertion below -- icon.name may be undefined
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
};
|
|
68
|
-
var mapImage = function (image) {
|
|
53
|
+
const mapCurrency = (icon) => (icon ? (0, currency_utils_1.getCurrencyFlag)(icon.name) : null);
|
|
54
|
+
const mapKeywordsToSearchStrings = (searchStrings) => (0, validators_1.isArray)(searchStrings) ? { searchStrings } : {};
|
|
55
|
+
const mapImage = (image) => {
|
|
69
56
|
if (image === null || image === void 0 ? void 0 : image.url) {
|
|
70
57
|
return {
|
|
71
|
-
icon: ((0, jsx_runtime_1.jsx)("div",
|
|
58
|
+
icon: ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "media" }, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ className: "np-option__no-media-circle" }, { children: (0, jsx_runtime_1.jsx)("img", { src: image.url, alt: image.name || '' }) })) }))),
|
|
72
59
|
};
|
|
73
60
|
}
|
|
74
61
|
return null;
|
|
75
62
|
};
|
|
76
63
|
exports.mapImage = mapImage;
|
|
77
|
-
|
|
64
|
+
const mapIcon = (icon) => {
|
|
78
65
|
if ((icon === null || icon === void 0 ? void 0 : icon.name) && (0, DynamicIcon_1.isValidIconName)(icon.name)) {
|
|
79
|
-
return { icon: (0, jsx_runtime_1.jsx)(DynamicIcon_1
|
|
66
|
+
return { icon: (0, jsx_runtime_1.jsx)(DynamicIcon_1.default, { type: icon.name }) };
|
|
80
67
|
}
|
|
81
68
|
if (icon === null || icon === void 0 ? void 0 : icon.text) {
|
|
82
69
|
return { icon: (0, jsx_runtime_1.jsx)("span", { children: icon.text }) };
|
|
@@ -84,44 +71,40 @@ var mapIcon = function (icon) {
|
|
|
84
71
|
return null;
|
|
85
72
|
};
|
|
86
73
|
exports.mapIcon = mapIcon;
|
|
87
|
-
|
|
74
|
+
const mapIconToAvatar = (icon) => {
|
|
88
75
|
if ((icon === null || icon === void 0 ? void 0 : icon.name) && (0, DynamicIcon_1.isValidIconName)(icon.name)) {
|
|
89
76
|
return {
|
|
90
|
-
avatar: ((0, jsx_runtime_1.jsx)(components_1.Avatar,
|
|
77
|
+
avatar: ((0, jsx_runtime_1.jsx)(components_1.Avatar, Object.assign({ type: components_1.AvatarType.ICON }, { children: (0, jsx_runtime_1.jsx)(DynamicIcon_1.default, { type: icon.name }) }))),
|
|
91
78
|
};
|
|
92
79
|
}
|
|
93
80
|
if (icon === null || icon === void 0 ? void 0 : icon.text) {
|
|
94
81
|
return {
|
|
95
|
-
avatar: (0, jsx_runtime_1.jsx)(components_1.Avatar,
|
|
82
|
+
avatar: (0, jsx_runtime_1.jsx)(components_1.Avatar, Object.assign({ type: components_1.AvatarType.INITIALS }, { children: icon.text })),
|
|
96
83
|
};
|
|
97
84
|
}
|
|
98
85
|
return null;
|
|
99
86
|
};
|
|
100
87
|
exports.mapIconToAvatar = mapIconToAvatar;
|
|
101
|
-
|
|
88
|
+
const mapAvatar = (image) => {
|
|
102
89
|
return image && image.url
|
|
103
90
|
? {
|
|
104
|
-
avatar: ((0, jsx_runtime_1.jsx)(components_1.Avatar,
|
|
91
|
+
avatar: ((0, jsx_runtime_1.jsx)(components_1.Avatar, Object.assign({ type: components_1.AvatarType.THUMBNAIL }, { children: (0, jsx_runtime_1.jsx)("img", { src: image.url, alt: "User avatar" }) }))),
|
|
105
92
|
}
|
|
106
93
|
: null;
|
|
107
94
|
};
|
|
108
95
|
exports.mapAvatar = mapAvatar;
|
|
109
|
-
|
|
110
|
-
var accepts = _a.accepts;
|
|
111
|
-
return (__assign({}, ((0, validators_1.isArray)(accepts) && { usAccept: accepts.join(',') })));
|
|
112
|
-
};
|
|
96
|
+
const mapSchemaToUploadOptions = ({ accepts }) => (Object.assign({}, ((0, validators_1.isArray)(accepts) && { usAccept: accepts.join(',') })));
|
|
113
97
|
exports.mapSchemaToUploadOptions = mapSchemaToUploadOptions;
|
|
114
|
-
|
|
115
|
-
var _a;
|
|
98
|
+
const getOptionDescription = (title, description) => {
|
|
116
99
|
if (title && description) {
|
|
117
|
-
|
|
118
|
-
return
|
|
100
|
+
const keyForDescription = (title + description).length > 50 ? 'secondary' : 'note';
|
|
101
|
+
return { [keyForDescription]: description };
|
|
119
102
|
}
|
|
120
103
|
return undefined;
|
|
121
104
|
};
|
|
122
|
-
|
|
105
|
+
const getDisabled = (disabled) => {
|
|
123
106
|
if (!(0, validators_1.isUndefined)(disabled) && !(0, validators_1.isNull)(disabled)) {
|
|
124
|
-
return { disabled
|
|
107
|
+
return { disabled };
|
|
125
108
|
}
|
|
126
109
|
return undefined;
|
|
127
110
|
};
|
|
@@ -1,141 +1,79 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
4
|
};
|
|
52
|
-
exports
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return [4 /*yield*/, fetcher(validationAsyncSpec.url, {
|
|
84
|
-
method: validationAsyncSpec.method || 'POST',
|
|
85
|
-
headers: { 'Content-Type': 'application/json' },
|
|
86
|
-
body: validationAsyncSpec.method === 'GET' ? undefined : JSON.stringify(requestBody),
|
|
87
|
-
signal: signal
|
|
88
|
-
})];
|
|
89
|
-
case 1:
|
|
90
|
-
response = _c.sent();
|
|
91
|
-
_c.label = 2;
|
|
92
|
-
case 2:
|
|
93
|
-
_c.trys.push([2, 4, , 5]);
|
|
94
|
-
return [4 /*yield*/, response.json()];
|
|
95
|
-
case 3:
|
|
96
|
-
jsonResponse = _c.sent();
|
|
97
|
-
if (!(0, validators_1.isObject)(jsonResponse)) {
|
|
98
|
-
throw new Error('Response body is not an object');
|
|
99
|
-
}
|
|
100
|
-
onEvent('Dynamic Flow - ValidationAsync', { status: 'success' });
|
|
101
|
-
if (response.status === 200) {
|
|
102
|
-
setValidationAsyncSuccessMessage((0, validators_1.isString)(jsonResponse.message) ? jsonResponse.message : null);
|
|
103
|
-
}
|
|
104
|
-
else if (response.status === 422) {
|
|
105
|
-
setValidationAsyncErrors((0, validators_1.isString)(jsonResponse.message) ? jsonResponse.message : null);
|
|
106
|
-
}
|
|
107
|
-
return [3 /*break*/, 5];
|
|
108
|
-
case 4:
|
|
109
|
-
_a = _c.sent();
|
|
110
|
-
onEvent('Dynamic Flow - ValidationAsync', { status: 'failure' });
|
|
111
|
-
return [3 /*break*/, 5];
|
|
112
|
-
case 5: return [2 /*return*/];
|
|
113
|
-
}
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const contexts_1 = require("../../common/contexts");
|
|
9
|
+
const utils_1 = require("../../common/utils");
|
|
10
|
+
const validators_1 = require("../../common/validators");
|
|
11
|
+
const basicTypeSchema_1 = __importDefault(require("../basicTypeSchema"));
|
|
12
|
+
const ValidationAsyncSchema = (props) => {
|
|
13
|
+
const [validationAsyncModel, setValidationAsyncModel] = (0, react_1.useState)(props.model);
|
|
14
|
+
const previousRequestedModelReference = (0, react_1.useRef)(null);
|
|
15
|
+
const [validationAsyncSuccessMessage, setValidationAsyncSuccessMessage] = (0, react_1.useState)(null);
|
|
16
|
+
const [validationAsyncErrors, setValidationAsyncErrors] = (0, react_1.useState)(null);
|
|
17
|
+
const [fieldSubmitted, setFieldSubmitted] = (0, react_1.useState)(false);
|
|
18
|
+
const [abortController, setAbortController] = (0, react_1.useState)(null);
|
|
19
|
+
const fetcher = (0, contexts_1.useFetcher)();
|
|
20
|
+
const onEvent = (0, contexts_1.useEventDispatcher)();
|
|
21
|
+
const logger = (0, contexts_1.useLogger)();
|
|
22
|
+
const getValidationAsyncResponse = async (currentValidationAsyncModel, validationAsyncSpec) => {
|
|
23
|
+
const signal = abortCurrentRequestAndGetNewAbortSignal();
|
|
24
|
+
const requestBody = { [validationAsyncSpec.param]: currentValidationAsyncModel };
|
|
25
|
+
previousRequestedModelReference.current = currentValidationAsyncModel;
|
|
26
|
+
setFieldSubmitted(true);
|
|
27
|
+
if (!validationAsyncSpec.method) {
|
|
28
|
+
logger.warning('Invalid schema or model', 'ValidationAsyncSchema without a "method" property would have defaulted to "GET" in previous versions. Now defaults to "POST".', {});
|
|
29
|
+
}
|
|
30
|
+
onEvent('Dynamic Flow - ValidationAsync', { status: 'pending' });
|
|
31
|
+
const response = await fetcher(validationAsyncSpec.url, {
|
|
32
|
+
method: validationAsyncSpec.method || 'POST',
|
|
33
|
+
headers: { 'Content-Type': 'application/json' },
|
|
34
|
+
body: validationAsyncSpec.method === 'GET' ? undefined : JSON.stringify(requestBody),
|
|
35
|
+
signal,
|
|
114
36
|
});
|
|
115
|
-
|
|
116
|
-
|
|
37
|
+
try {
|
|
38
|
+
const jsonResponse = await response.json();
|
|
39
|
+
if (!(0, validators_1.isObject)(jsonResponse)) {
|
|
40
|
+
throw new Error('Response body is not an object');
|
|
41
|
+
}
|
|
42
|
+
onEvent('Dynamic Flow - ValidationAsync', { status: 'success' });
|
|
43
|
+
if (response.status === 200) {
|
|
44
|
+
setValidationAsyncSuccessMessage((0, validators_1.isString)(jsonResponse.message) ? jsonResponse.message : null);
|
|
45
|
+
}
|
|
46
|
+
else if (response.status === 422) {
|
|
47
|
+
setValidationAsyncErrors((0, validators_1.isString)(jsonResponse.message) ? jsonResponse.message : null);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch (_a) {
|
|
51
|
+
onEvent('Dynamic Flow - ValidationAsync', { status: 'failure' });
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const abortCurrentRequestAndGetNewAbortSignal = () => {
|
|
117
55
|
if (abortController) {
|
|
118
56
|
abortController.abort();
|
|
119
57
|
}
|
|
120
|
-
|
|
58
|
+
const newAbortController = new AbortController();
|
|
121
59
|
setAbortController(newAbortController);
|
|
122
60
|
return newAbortController.signal;
|
|
123
61
|
};
|
|
124
|
-
|
|
62
|
+
const onBlur = () => {
|
|
125
63
|
if (!(0, validators_1.isNull)(validationAsyncModel) &&
|
|
126
64
|
!(0, utils_1.isEqual)(validationAsyncModel, previousRequestedModelReference.current)) {
|
|
127
65
|
void getValidationAsyncResponse(validationAsyncModel, props.schema.validationAsync);
|
|
128
66
|
}
|
|
129
67
|
};
|
|
130
|
-
|
|
131
|
-
props.onChange(
|
|
68
|
+
const validationAsyncOnChange = (parameters) => {
|
|
69
|
+
props.onChange(Object.assign(Object.assign({}, parameters), { triggerSchema: props.schema, triggerModel: parameters.model }));
|
|
132
70
|
setValidationAsyncErrors(null);
|
|
133
71
|
setValidationAsyncSuccessMessage(null);
|
|
134
72
|
if ((0, validators_1.isValidSchema)(parameters.model, props.schema)) {
|
|
135
73
|
setValidationAsyncModel(parameters.model);
|
|
136
74
|
}
|
|
137
75
|
};
|
|
138
|
-
|
|
76
|
+
const basicTypeSchemaProps = {
|
|
139
77
|
required: props.required,
|
|
140
78
|
submitted: props.submitted || fieldSubmitted,
|
|
141
79
|
schema: props.schema,
|
|
@@ -143,9 +81,9 @@ var ValidationAsyncSchema = function (props) {
|
|
|
143
81
|
errors: validationAsyncErrors || props.errors,
|
|
144
82
|
onChange: validationAsyncOnChange,
|
|
145
83
|
onBlur: onBlur,
|
|
146
|
-
infoMessage: validationAsyncSuccessMessage
|
|
84
|
+
infoMessage: validationAsyncSuccessMessage,
|
|
147
85
|
};
|
|
148
|
-
return (0, jsx_runtime_1.jsx)(basicTypeSchema_1
|
|
86
|
+
return (0, jsx_runtime_1.jsx)(basicTypeSchema_1.default, Object.assign({}, basicTypeSchemaProps));
|
|
149
87
|
};
|
|
150
88
|
ValidationAsyncSchema.defaultProps = { required: false };
|
|
151
|
-
exports
|
|
89
|
+
exports.default = ValidationAsyncSchema;
|
|
@@ -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 ValidationAsyncSchema_1 = require("./ValidationAsyncSchema");
|
|
16
|
-
|
|
8
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(ValidationAsyncSchema_1).default; } });
|
|
@@ -1,23 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
exports.__esModule = true;
|
|
14
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
15
|
-
var contexts_1 = require("../common/contexts");
|
|
16
|
-
var _1 = require(".");
|
|
17
|
-
var getKey = function (component) { return JSON.stringify(component); };
|
|
18
|
-
var DynamicLayout = function (props) {
|
|
19
|
-
var components = props.components, model = props.model, submitted = props.submitted, errors = props.errors, onModelChange = props.onModelChange, onAction = props.onAction, onPersistAsync = props.onPersistAsync, baseUrl = props.baseUrl;
|
|
20
|
-
var renderComponent = function (component) {
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const contexts_1 = require("../common/contexts");
|
|
5
|
+
const _1 = require(".");
|
|
6
|
+
const getKey = (component) => JSON.stringify(component);
|
|
7
|
+
const DynamicLayout = (props) => {
|
|
8
|
+
const { components, model, submitted, errors, onModelChange, onAction, onPersistAsync, baseUrl } = props;
|
|
9
|
+
const renderComponent = (component) => {
|
|
21
10
|
switch (component.type) {
|
|
22
11
|
case 'heading':
|
|
23
12
|
return (0, jsx_runtime_1.jsx)(_1.DynamicHeading, { component: component }, getKey(component));
|
|
@@ -57,7 +46,7 @@ var DynamicLayout = function (props) {
|
|
|
57
46
|
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: components.map(renderComponent) });
|
|
58
47
|
}
|
|
59
48
|
else {
|
|
60
|
-
return ((0, jsx_runtime_1.jsx)(contexts_1.FetcherProviderFromBaseUrl,
|
|
49
|
+
return ((0, jsx_runtime_1.jsx)(contexts_1.FetcherProviderFromBaseUrl, Object.assign({ baseUrl: baseUrl }, { children: components.map(renderComponent) })));
|
|
61
50
|
}
|
|
62
51
|
};
|
|
63
|
-
exports
|
|
52
|
+
exports.default = DynamicLayout;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const components_1 = require("@transferwise/components");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const DynamicAlert = (props) => {
|
|
7
|
+
const alert = props.component;
|
|
8
8
|
return ((0, jsx_runtime_1.jsx)(components_1.Alert, { type: mapContextToAlertType(legacy_mapContext(alert.context)), className: (0, utils_1.getMarginBottom)(alert.margin), message: alert.markdown }));
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
const legacy_mapContext = (context) => {
|
|
11
11
|
switch (context) {
|
|
12
12
|
case 'success':
|
|
13
13
|
return 'positive';
|
|
@@ -22,10 +22,10 @@ var legacy_mapContext = function (context) {
|
|
|
22
22
|
return context;
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
|
-
|
|
25
|
+
const mapContextToAlertType = (context) => {
|
|
26
26
|
if (!context || !['neutral', 'warning', 'negative', 'positive'].includes(context)) {
|
|
27
27
|
return 'neutral';
|
|
28
28
|
}
|
|
29
29
|
return context;
|
|
30
30
|
};
|
|
31
|
-
exports
|
|
31
|
+
exports.default = DynamicAlert;
|
|
@@ -1,31 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
exports.__esModule = true;
|
|
14
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
15
|
-
var __1 = require("..");
|
|
16
|
-
var utils_1 = require("../utils");
|
|
17
|
-
var DynamicBox = function (props) {
|
|
18
|
-
var box = props.component;
|
|
19
|
-
var margin = (0, utils_1.getMarginBottom)(box.margin || box.border ? 'lg' : 'xs');
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const __1 = require("..");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const DynamicBox = (props) => {
|
|
7
|
+
const box = props.component;
|
|
8
|
+
const margin = (0, utils_1.getMarginBottom)(box.margin || box.border ? 'lg' : 'xs');
|
|
20
9
|
if (!box.width || box.width === 'xl') {
|
|
21
|
-
return ((0, jsx_runtime_1.jsx)("div",
|
|
10
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: margin + getBorderClass(box.border) }, { children: (0, jsx_runtime_1.jsx)(__1.DynamicLayout, { components: box.components, model: props.model, submitted: props.submitted, errors: props.errors, onModelChange: props.onModelChange, onAction: props.onAction, onPersistAsync: props.onPersistAsync }) })));
|
|
22
11
|
}
|
|
23
|
-
return ((0, jsx_runtime_1.jsx)("div",
|
|
12
|
+
return ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: "row" }, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ className: margin + getBoxWidthClasses(box) }, { children: (0, jsx_runtime_1.jsx)("div", Object.assign({ className: getBorderClass(box.border) }, { children: (0, jsx_runtime_1.jsx)(__1.DynamicLayout, { components: box.components, model: props.model, submitted: props.submitted, errors: props.errors, onModelChange: props.onModelChange, onAction: props.onAction, onPersistAsync: props.onPersistAsync }) })) })) })));
|
|
24
13
|
};
|
|
25
|
-
|
|
14
|
+
const getBorderClass = (border) => {
|
|
26
15
|
return border ? ' well p-b-0' : '';
|
|
27
16
|
};
|
|
28
|
-
|
|
17
|
+
const getBoxWidthClasses = (component) => {
|
|
29
18
|
switch (component.width) {
|
|
30
19
|
case 'xs':
|
|
31
20
|
return ' col-md-4 col-md-offset-4';
|
|
@@ -40,4 +29,4 @@ var getBoxWidthClasses = function (component) {
|
|
|
40
29
|
return ' col-xs-12';
|
|
41
30
|
}
|
|
42
31
|
};
|
|
43
|
-
exports
|
|
32
|
+
exports.default = DynamicBox;
|
|
@@ -1,34 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
exports.__esModule = true;
|
|
14
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
15
|
-
var components_1 = require("@transferwise/components");
|
|
16
|
-
var contexts_1 = require("../../common/contexts");
|
|
17
|
-
var utils_1 = require("../utils");
|
|
18
|
-
var DynamicButton = function (props) {
|
|
19
|
-
var component = props.component, onAction = props.onAction;
|
|
20
|
-
var componentAction = component.action; // there should be no $ref at this point
|
|
21
|
-
var _a = getButtonTypeAndPriority(componentAction), type = _a.type, priority = _a.priority;
|
|
22
|
-
var loading = (0, contexts_1.useDynamicFlow)().loading;
|
|
23
|
-
var className = (0, utils_1.getMarginBottom)(component.margin || 'md') +
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const components_1 = require("@transferwise/components");
|
|
5
|
+
const contexts_1 = require("../../common/contexts");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
const DynamicButton = (props) => {
|
|
8
|
+
const { component, onAction } = props;
|
|
9
|
+
const componentAction = component.action; // there should be no $ref at this point
|
|
10
|
+
const { type, priority } = getButtonTypeAndPriority(componentAction);
|
|
11
|
+
const { loading } = (0, contexts_1.useDynamicFlow)();
|
|
12
|
+
const className = (0, utils_1.getMarginBottom)(component.margin || 'md') +
|
|
24
13
|
' ' +
|
|
25
14
|
getActionClasses(componentAction); // this can probably be removed
|
|
26
|
-
return ((0, jsx_runtime_1.jsx)(components_1.Button,
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)(components_1.Button, Object.assign({ size: getButtonSize(component.size), type: type, priority: priority, block: true, className: className, disabled: componentAction.disabled || loading, onClick: () => onAction(componentAction) }, { children: componentAction.title })));
|
|
27
16
|
};
|
|
28
|
-
|
|
17
|
+
const getActionClasses = (action) => {
|
|
29
18
|
return action.primary ? 'btn-primary' : '';
|
|
30
19
|
};
|
|
31
|
-
|
|
20
|
+
const getButtonSize = (size) => {
|
|
32
21
|
switch (size) {
|
|
33
22
|
case 'xs':
|
|
34
23
|
case 'sm':
|
|
@@ -41,7 +30,7 @@ var getButtonSize = function (size) {
|
|
|
41
30
|
return 'md';
|
|
42
31
|
}
|
|
43
32
|
};
|
|
44
|
-
|
|
33
|
+
const getButtonTypeAndPriority = (action) => {
|
|
45
34
|
switch (action.type) {
|
|
46
35
|
case 'link':
|
|
47
36
|
return { type: 'accent', priority: 'tertiary' };
|
|
@@ -57,4 +46,4 @@ var getButtonTypeAndPriority = function (action) {
|
|
|
57
46
|
return { type: 'accent', priority: 'secondary' };
|
|
58
47
|
}
|
|
59
48
|
};
|
|
60
|
-
exports
|
|
49
|
+
exports.default = DynamicButton;
|
|
@@ -1,40 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
exports.__esModule = true;
|
|
14
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
15
|
-
var __1 = require("..");
|
|
16
|
-
var utils_1 = require("../utils");
|
|
17
|
-
var DynamicColumns = function (props) {
|
|
18
|
-
var columns = props.component;
|
|
19
|
-
var _a = getWidth(columns.bias), leftWidth = _a.leftWidth, rightWidth = _a.rightWidth;
|
|
20
|
-
return ((0, jsx_runtime_1.jsxs)("div", __assign({ className: "".concat((0, utils_1.getMarginBottom)(columns.margin || 'xs'), " row") }, { children: [(0, jsx_runtime_1.jsx)("div", __assign({ className: "".concat(leftWidth, " m-b-0") }, { children: (0, jsx_runtime_1.jsx)(__1.DynamicLayout, { components: columns.left, model: props.model, submitted: props.submitted, errors: props.errors, onModelChange: props.onModelChange, onAction: props.onAction, onPersistAsync: props.onPersistAsync }) })), (0, jsx_runtime_1.jsx)("div", __assign({ className: "".concat(rightWidth, " m-b-0") }, { children: (0, jsx_runtime_1.jsx)(__1.DynamicLayout, { components: columns.right, model: props.model, submitted: props.submitted, errors: props.errors, onModelChange: props.onModelChange, onAction: props.onAction, onPersistAsync: props.onPersistAsync }) }))] })));
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const __1 = require("..");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const DynamicColumns = (props) => {
|
|
7
|
+
const columns = props.component;
|
|
8
|
+
const { leftWidth, rightWidth } = getWidth(columns.bias);
|
|
9
|
+
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: `${(0, utils_1.getMarginBottom)(columns.margin || 'xs')} row` }, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: `${leftWidth} m-b-0` }, { children: (0, jsx_runtime_1.jsx)(__1.DynamicLayout, { components: columns.left, model: props.model, submitted: props.submitted, errors: props.errors, onModelChange: props.onModelChange, onAction: props.onAction, onPersistAsync: props.onPersistAsync }) })), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: `${rightWidth} m-b-0` }, { children: (0, jsx_runtime_1.jsx)(__1.DynamicLayout, { components: columns.right, model: props.model, submitted: props.submitted, errors: props.errors, onModelChange: props.onModelChange, onAction: props.onAction, onPersistAsync: props.onPersistAsync }) }))] })));
|
|
21
10
|
};
|
|
22
|
-
|
|
11
|
+
const getWidth = (bias) => {
|
|
23
12
|
if (bias === 'left') {
|
|
24
13
|
return {
|
|
25
14
|
leftWidth: 'col-md-8',
|
|
26
|
-
rightWidth: 'col-md-4'
|
|
15
|
+
rightWidth: 'col-md-4',
|
|
27
16
|
};
|
|
28
17
|
}
|
|
29
18
|
if (bias === 'right') {
|
|
30
19
|
return {
|
|
31
20
|
leftWidth: 'col-md-4',
|
|
32
|
-
rightWidth: 'col-md-8'
|
|
21
|
+
rightWidth: 'col-md-8',
|
|
33
22
|
};
|
|
34
23
|
}
|
|
35
24
|
return {
|
|
36
25
|
leftWidth: 'col-md-6',
|
|
37
|
-
rightWidth: 'col-md-6'
|
|
26
|
+
rightWidth: 'col-md-6',
|
|
38
27
|
};
|
|
39
28
|
};
|
|
40
|
-
exports
|
|
29
|
+
exports.default = DynamicColumns;
|