@wise/dynamic-flow-client 3.5.0-experimental-6654c72 → 3.5.0-experimental-b041af5
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 +14 -18
- package/build/main.min.js +1 -1
- package/build/main.mjs +14 -18
- package/package.json +2 -2
- package/build/common/errorBoundary/ErrorBoundary.js +0 -44
- package/build/common/errorBoundary/ErrorBoundaryAlert.js +0 -12
- package/build/common/messages/external-confirmation.messages.js +0 -23
- package/build/i18n/index.js +0 -36
- package/build/legacy/dynamicFlow/BackButton.js +0 -22
- package/build/legacy/dynamicFlow/DynamicFlow.js +0 -346
- package/build/legacy/dynamicFlow/DynamicFlowStep.js +0 -37
- package/build/legacy/dynamicFlow/DynamicFlowTypes.js +0 -1
- package/build/legacy/dynamicFlow/index.js +0 -1
- package/build/legacy/dynamicFlow/utils/index.js +0 -5
- package/build/legacy/dynamicFlow/utils/responseParsers/response-parsers.js +0 -185
- package/build/legacy/dynamicFlow/utils/useDebouncedRefresh/useDebouncedRefresh.js +0 -26
- package/build/legacy/dynamicFlow/utils/useDynamicFlowState.js +0 -137
- package/build/legacy/dynamicFlow/utils/useLoader.js +0 -22
- package/build/legacy/jsonSchemaForm/JsonSchemaForm.js +0 -24
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/ArraySchema.js +0 -25
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/ArrayListSchema.js +0 -34
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/RepeatableSchema.js +0 -134
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/RepeatableSchemaStep.js +0 -85
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/utils/summary-utils.js +0 -135
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/index.js +0 -1
- package/build/legacy/jsonSchemaForm/genericSchema/GenericSchema.js +0 -85
- package/build/legacy/jsonSchemaForm/genericSchema/index.js +0 -1
- package/build/legacy/jsonSchemaForm/index.js +0 -1
- package/build/legacy/jsonSchemaForm/objectSchema/ObjectSchema.js +0 -77
- package/build/legacy/jsonSchemaForm/objectSchema/index.js +0 -1
- package/build/legacy/jsonSchemaForm/oneOfSchema/OneOfSchema.js +0 -155
- package/build/legacy/jsonSchemaForm/oneOfSchema/index.js +0 -1
- package/build/legacy/jsonSchemaForm/oneOfSchema/utils.js +0 -68
- package/build/legacy/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.js +0 -26
- package/build/legacy/jsonSchemaForm/persistAsyncSchema/index.js +0 -1
- package/build/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/index.js +0 -1
- package/build/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/PersistAsyncBlobSchema.js +0 -131
- package/build/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/UploadInputAdapter.js +0 -31
- package/build/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/index.js +0 -1
- package/build/legacy/jsonSchemaForm/promotedOneOfSchema/PromotedOneOfSchema.js +0 -72
- package/build/legacy/jsonSchemaForm/promotedOneOfSchema/index.js +0 -1
- package/build/legacy/jsonSchemaForm/promotedOneOfSchema/promoted-one-of-utils.js +0 -8
- package/build/legacy/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfCheckboxControl.js +0 -27
- package/build/legacy/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfControl.js +0 -31
- package/build/legacy/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfRadioControl.js +0 -32
- package/build/legacy/jsonSchemaForm/readOnlySchema/ReadOnlySchema.js +0 -54
- package/build/legacy/jsonSchemaForm/readOnlySchema/ReadOnlySchema.messages.js +0 -13
- package/build/legacy/jsonSchemaForm/readOnlySchema/index.js +0 -1
- package/build/legacy/jsonSchemaForm/validationAsyncSchema/ValidationAsyncSchema.js +0 -150
- package/build/legacy/jsonSchemaForm/validationAsyncSchema/index.js +0 -1
- package/build/legacy/step/cameraStep/CameraStep.js +0 -124
- package/build/legacy/step/cameraStep/cameraCapture/CameraCapture.js +0 -161
- package/build/legacy/step/cameraStep/cameraCapture/hooks/useFullScreenOrientationLock.js +0 -60
- package/build/legacy/step/cameraStep/cameraCapture/hooks/useVideoConstraints.js +0 -80
- package/build/legacy/step/cameraStep/cameraCapture/index.js +0 -1
- package/build/legacy/step/cameraStep/cameraCapture/overlay/Overlay.js +0 -77
- package/build/legacy/step/cameraStep/cameraCapture/screens/cameraErrorScreen/CameraErrorScreen.js +0 -18
- package/build/legacy/step/cameraStep/cameraCapture/screens/index.js +0 -1
- package/build/legacy/step/cameraStep/cameraCapture/tracking/index.js +0 -109
- package/build/legacy/step/cameraStep/cameraCapture/utils/index.js +0 -107
- package/build/legacy/step/cameraStep/index.js +0 -1
- package/build/legacy/step/externalConfirmationStep/ExternalConfirmationStep.js +0 -64
- package/build/legacy/step/externalConfirmationStep/index.js +0 -1
- package/build/legacy/step/index.js +0 -3
- package/build/revamp/domain/components/AlertComponent.js +0 -50
- package/build/revamp/domain/components/AllOfComponent.js +0 -72
- package/build/revamp/domain/components/BooleanInputComponent.js +0 -108
- package/build/revamp/domain/components/BoxComponent.js +0 -65
- package/build/revamp/domain/components/ButtonComponent.js +0 -50
- package/build/revamp/domain/components/ColumnsComponent.js +0 -74
- package/build/revamp/domain/components/ConstComponent.js +0 -50
- package/build/revamp/domain/components/ContainerComponent.js +0 -65
- package/build/revamp/domain/components/DateInputComponent.js +0 -127
- package/build/revamp/domain/components/DecisionComponent.js +0 -50
- package/build/revamp/domain/components/DividerComponent.js +0 -50
- package/build/revamp/domain/components/FormComponent.js +0 -65
- package/build/revamp/domain/components/HeadingComponent.js +0 -50
- package/build/revamp/domain/components/ImageComponent.js +0 -50
- package/build/revamp/domain/components/InstructionsComponent.js +0 -50
- package/build/revamp/domain/components/IntegerInputComponent.js +0 -125
- package/build/revamp/domain/components/LoadingIndicatorComponent.js +0 -50
- package/build/revamp/domain/components/MarkdownComponent.js +0 -50
- package/build/revamp/domain/components/ModalComponent.js +0 -65
- package/build/revamp/domain/components/MultiUploadInputComponent.js +0 -190
- package/build/revamp/domain/components/NumberInputComponent.js +0 -125
- package/build/revamp/domain/components/ObjectComponent.js +0 -104
- package/build/revamp/domain/components/ParagraphComponent.js +0 -50
- package/build/revamp/domain/components/ReviewComponent.js +0 -50
- package/build/revamp/domain/components/SelectInputComponent.js +0 -138
- package/build/revamp/domain/components/StatusListComponent.js +0 -50
- package/build/revamp/domain/components/StepDomainComponent.js +0 -93
- package/build/revamp/domain/components/TextInputComponent.js +0 -125
- package/build/revamp/domain/components/UploadInputComponent.js +0 -151
- package/build/revamp/domain/components/repeatableComponent/RepeatableComponent.js +0 -148
- package/build/revamp/domain/components/searchComponent/SearchComponent.js +0 -108
- package/build/revamp/domain/components/utils/component-utils.js +0 -18
- package/build/revamp/domain/components/utils/debounce.js +0 -38
- package/build/revamp/domain/components/utils/file-utils.js +0 -46
- package/build/revamp/domain/components/utils/getComponentForLocalValueKey.js +0 -31
- package/build/revamp/domain/components/utils/isPartialLocalValueMatch.js +0 -40
- package/build/revamp/domain/features/events.js +0 -1
- package/build/revamp/domain/features/persistAsync/getComponentPersistAsync.js +0 -133
- package/build/revamp/domain/features/persistAsync/getPerformPersistAsync.js +0 -103
- package/build/revamp/domain/features/refresh/getPerformRefresh.js +0 -53
- package/build/revamp/domain/features/summary/summary-utils.js +0 -39
- package/build/revamp/domain/features/utils/http-utils.js +0 -34
- package/build/revamp/domain/features/utils/response-utils.js +0 -9
- package/build/revamp/domain/features/validation/validation-functions.js +0 -12
- package/build/revamp/domain/features/validation/value-checks.js +0 -111
- package/build/revamp/domain/features/validationAsync/getComponentValidationAsync.js +0 -94
- package/build/revamp/domain/features/validationAsync/getPerformValidationAsync.js +0 -107
- package/build/revamp/domain/mappers/types.js +0 -1
- package/build/revamp/domain/types.js +0 -1
- package/build/revamp/flow/response-utils.js +0 -88
- package/build/revamp/renderers/CoreContainerRenderer.js +0 -8
- package/build/revamp/renderers/LoadingContext.js +0 -7
- package/build/revamp/renderers/types.js +0 -1
- package/build/revamp/types.js +0 -1
- package/build/revamp/utils/component-utils.js +0 -86
- package/build/revamp/utils/type-utils.js +0 -56
- package/build/revamp/utils/type-validators.js +0 -16
- package/build/revamp/wise/renderers/AlertRenderer.js +0 -11
- package/build/revamp/wise/renderers/BooleanInputRenderer.js +0 -34
- package/build/revamp/wise/renderers/BoxRenderer.js +0 -30
- package/build/revamp/wise/renderers/ButtonRenderer.js +0 -64
- package/build/revamp/wise/renderers/ColumnsRenderer.js +0 -25
- package/build/revamp/wise/renderers/components/FieldInput.js +0 -20
- package/build/revamp/wise/renderers/components/Help.js +0 -21
- package/build/revamp/wise/renderers/components/LabelContentWithHelp.js +0 -6
- package/build/revamp/wise/renderers/utils/layout-utils.js +0 -31
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
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;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
import { isObject } from '../../../common/validators';
|
|
38
|
-
var parseFetchResponseByResponseType = function (response, type) { return __awaiter(void 0, void 0, void 0, function () {
|
|
39
|
-
return __generator(this, function (_a) {
|
|
40
|
-
switch (type) {
|
|
41
|
-
case 'step':
|
|
42
|
-
return [2 /*return*/, parseStepResponse(response)];
|
|
43
|
-
case 'exit':
|
|
44
|
-
return [2 /*return*/, parseExitResponse(response)];
|
|
45
|
-
case 'action':
|
|
46
|
-
return [2 /*return*/, parseActionResponse(response)];
|
|
47
|
-
default:
|
|
48
|
-
throw new Error("Unsupported X-Df-Response-Type. Allowed values are 'step', 'action', 'exit'.");
|
|
49
|
-
}
|
|
50
|
-
return [2 /*return*/];
|
|
51
|
-
});
|
|
52
|
-
}); };
|
|
53
|
-
var parseStepResponse = function (response) { return __awaiter(void 0, void 0, void 0, function () {
|
|
54
|
-
var jsonBody, etag;
|
|
55
|
-
return __generator(this, function (_a) {
|
|
56
|
-
switch (_a.label) {
|
|
57
|
-
case 0: return [4 /*yield*/, parseResponseJson(response)];
|
|
58
|
-
case 1:
|
|
59
|
-
jsonBody = _a.sent();
|
|
60
|
-
if (!isObject(jsonBody)) {
|
|
61
|
-
throw new Error('Incorrect response body in response. Expected an object.');
|
|
62
|
-
}
|
|
63
|
-
etag = response.headers.get('etag') || undefined;
|
|
64
|
-
return [2 /*return*/, { type: 'step', step: jsonBody, etag: etag }];
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}); };
|
|
68
|
-
var parseActionResponse = function (response) { return __awaiter(void 0, void 0, void 0, function () {
|
|
69
|
-
var jsonBody, action;
|
|
70
|
-
return __generator(this, function (_a) {
|
|
71
|
-
switch (_a.label) {
|
|
72
|
-
case 0: return [4 /*yield*/, parseResponseJson(response)];
|
|
73
|
-
case 1:
|
|
74
|
-
jsonBody = _a.sent();
|
|
75
|
-
if (!isObject(jsonBody)) {
|
|
76
|
-
throw new Error('Incorrect response body in response. Expected an object.');
|
|
77
|
-
}
|
|
78
|
-
if (!isObject(jsonBody.action)) {
|
|
79
|
-
throw new Error('Incorrect response body in action response. Expected an object satisfying the type { action: Action }.');
|
|
80
|
-
}
|
|
81
|
-
action = jsonBody.action;
|
|
82
|
-
if (action.exit === true && isObject(action.result)) {
|
|
83
|
-
return [2 /*return*/, { type: 'exit', result: action.result }];
|
|
84
|
-
}
|
|
85
|
-
return [2 /*return*/, { type: 'action', action: jsonBody.action }];
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
}); };
|
|
89
|
-
var parseExitResponse = function (response) { return __awaiter(void 0, void 0, void 0, function () {
|
|
90
|
-
var _a;
|
|
91
|
-
return __generator(this, function (_b) {
|
|
92
|
-
switch (_b.label) {
|
|
93
|
-
case 0:
|
|
94
|
-
_a = { type: 'exit' };
|
|
95
|
-
return [4 /*yield*/, getJsonObjectOrNull(response)];
|
|
96
|
-
case 1: return [2 /*return*/, (_a.result = _b.sent(), _a)];
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
}); };
|
|
100
|
-
export var parseFetchResponse = function (response) { return __awaiter(void 0, void 0, void 0, function () {
|
|
101
|
-
var type, jsonBody;
|
|
102
|
-
var _a, _b;
|
|
103
|
-
return __generator(this, function (_c) {
|
|
104
|
-
switch (_c.label) {
|
|
105
|
-
case 0:
|
|
106
|
-
assertResponseIsValid(response);
|
|
107
|
-
if ((_a = response.headers) === null || _a === void 0 ? void 0 : _a.has('X-Df-Response-Type')) {
|
|
108
|
-
type = response.headers.get('X-Df-Response-Type');
|
|
109
|
-
return [2 /*return*/, parseFetchResponseByResponseType(response, type)];
|
|
110
|
-
}
|
|
111
|
-
if ((_b = response.headers) === null || _b === void 0 ? void 0 : _b.has('X-Df-Exit')) {
|
|
112
|
-
return [2 /*return*/, parseExitResponse(response)];
|
|
113
|
-
}
|
|
114
|
-
return [4 /*yield*/, parseResponseJson(response.clone())];
|
|
115
|
-
case 1:
|
|
116
|
-
jsonBody = _c.sent();
|
|
117
|
-
if (isObject(jsonBody) && jsonBody.action) {
|
|
118
|
-
return [2 /*return*/, parseActionResponse(response)];
|
|
119
|
-
}
|
|
120
|
-
return [2 /*return*/, parseStepResponse(response)];
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
}); };
|
|
124
|
-
export var parseErrorResponse = function (response) { return __awaiter(void 0, void 0, void 0, function () {
|
|
125
|
-
var jsonBody;
|
|
126
|
-
return __generator(this, function (_a) {
|
|
127
|
-
switch (_a.label) {
|
|
128
|
-
case 0:
|
|
129
|
-
assertResponseIsValid(response);
|
|
130
|
-
return [4 /*yield*/, parseResponseJson(response)];
|
|
131
|
-
case 1:
|
|
132
|
-
jsonBody = _a.sent();
|
|
133
|
-
if (!isObject(jsonBody)) {
|
|
134
|
-
throw new Error('Incorrect response body in error response. Expected an object.');
|
|
135
|
-
}
|
|
136
|
-
if (!jsonBody.refreshFormUrl && !jsonBody.refreshUrl && !jsonBody.validation && !jsonBody.error) {
|
|
137
|
-
// eslint-disable-next-line @typescript-eslint/no-throw-literal
|
|
138
|
-
throw jsonBody;
|
|
139
|
-
}
|
|
140
|
-
return [2 /*return*/, jsonBody];
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
}); };
|
|
144
|
-
export var getJsonObjectOrNull = function (response) { return __awaiter(void 0, void 0, void 0, function () {
|
|
145
|
-
var result;
|
|
146
|
-
return __generator(this, function (_a) {
|
|
147
|
-
switch (_a.label) {
|
|
148
|
-
case 0:
|
|
149
|
-
assertResponseIsValid(response);
|
|
150
|
-
return [4 /*yield*/, parseResponseJson(response)];
|
|
151
|
-
case 1:
|
|
152
|
-
result = _a.sent();
|
|
153
|
-
return [2 /*return*/, isObject(result) ? result : null];
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
}); };
|
|
157
|
-
var parseResponseJson = function (response) { return __awaiter(void 0, void 0, void 0, function () {
|
|
158
|
-
var _a;
|
|
159
|
-
return __generator(this, function (_b) {
|
|
160
|
-
switch (_b.label) {
|
|
161
|
-
case 0:
|
|
162
|
-
_b.trys.push([0, 2, , 3]);
|
|
163
|
-
return [4 /*yield*/, response.json()];
|
|
164
|
-
case 1: return [2 /*return*/, (_b.sent())];
|
|
165
|
-
case 2:
|
|
166
|
-
_a = _b.sent();
|
|
167
|
-
return [2 /*return*/, null];
|
|
168
|
-
case 3: return [2 /*return*/];
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
}); };
|
|
172
|
-
var assertResponseIsValid = function (response) {
|
|
173
|
-
if (!isResponse(response)) {
|
|
174
|
-
throw new Error('Incorrect type of response from fetch. Expected object of type Response.');
|
|
175
|
-
}
|
|
176
|
-
if (response.bodyUsed) {
|
|
177
|
-
throw new Error('The body of the provided Response object has already been used. Every request must respond with a new Response object.');
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
var isResponse = function (response) {
|
|
181
|
-
return typeof response === 'object' &&
|
|
182
|
-
response !== null &&
|
|
183
|
-
'clone' in response &&
|
|
184
|
-
'bodyUsed' in response;
|
|
185
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { useRef } from 'react';
|
|
2
|
-
import { debounce, getSchemaType } from '../../../common/utils';
|
|
3
|
-
var DEBOUNCE_DELAY = 1000; // milliseconds
|
|
4
|
-
export function useDebouncedRefresh(fetchRefresh) {
|
|
5
|
-
var map = useRef(new Map());
|
|
6
|
-
var retrieveOrCreate = function (key) {
|
|
7
|
-
if (map.current.has(key)) {
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
9
|
-
return map.current.get(key);
|
|
10
|
-
}
|
|
11
|
-
var debouncedFetchRefresh = debounce(function (url, data, etag) { return fetchRefresh(url, data, etag); }, DEBOUNCE_DELAY);
|
|
12
|
-
map.current.set(key, debouncedFetchRefresh);
|
|
13
|
-
return debouncedFetchRefresh;
|
|
14
|
-
};
|
|
15
|
-
return function (url, data, etag, schema) {
|
|
16
|
-
var debouncedFetchRefresh = retrieveOrCreate(url);
|
|
17
|
-
debouncedFetchRefresh(url, data, etag);
|
|
18
|
-
if (!schema || !shouldDebounceSchema(schema)) {
|
|
19
|
-
debouncedFetchRefresh.flush();
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
// TODO: only exporting for testing. we should improve the tests
|
|
24
|
-
export var shouldDebounceSchema = function (schema) {
|
|
25
|
-
return getSchemaType(schema) === 'basic' && schema.type !== 'boolean' && schema.format !== 'base64url';
|
|
26
|
-
};
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
-
if (ar || !(i in from)) {
|
|
15
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
-
ar[i] = from[i];
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
-
};
|
|
21
|
-
import { useMemo, useState } from 'react';
|
|
22
|
-
import { isValidSchema, getValidObjectModelParts } from '../../common/validators';
|
|
23
|
-
export var useDynamicFlowState = function (initialStep) {
|
|
24
|
-
var _a, _b;
|
|
25
|
-
var _c = useState((_a = initialStep === null || initialStep === void 0 ? void 0 : initialStep.errors) === null || _a === void 0 ? void 0 : _a.validation), formErrors = _c[0], setFormErrors = _c[1];
|
|
26
|
-
var _d = useState((_b = initialStep === null || initialStep === void 0 ? void 0 : initialStep.errors) === null || _b === void 0 ? void 0 : _b.error), globalError = _d[0], setGlobalError = _d[1];
|
|
27
|
-
var _e = useState({
|
|
28
|
-
step: initialStep || undefined,
|
|
29
|
-
models: (initialStep === null || initialStep === void 0 ? void 0 : initialStep.model)
|
|
30
|
-
? buildInitialModels(initialStep.model, getAllSchemas(initialStep))
|
|
31
|
-
: {},
|
|
32
|
-
etag: undefined
|
|
33
|
-
}), stepAndModels = _e[0], setStepAndModels = _e[1];
|
|
34
|
-
var step = stepAndModels.step, models = stepAndModels.models, etag = stepAndModels.etag;
|
|
35
|
-
var setStepAndEtag = function (step, etag) {
|
|
36
|
-
var _a, _b, _c, _d;
|
|
37
|
-
setStepAndModels({
|
|
38
|
-
step: step,
|
|
39
|
-
models: step.model ? buildInitialModels(step.model, getAllSchemas(step)) : {},
|
|
40
|
-
etag: etag
|
|
41
|
-
});
|
|
42
|
-
setFormErrors((_b = (_a = step === null || step === void 0 ? void 0 : step.errors) === null || _a === void 0 ? void 0 : _a.validation) !== null && _b !== void 0 ? _b : null);
|
|
43
|
-
setGlobalError((_d = (_c = step === null || step === void 0 ? void 0 : step.errors) === null || _c === void 0 ? void 0 : _c.error) !== null && _d !== void 0 ? _d : null);
|
|
44
|
-
};
|
|
45
|
-
var setSchemaModel = function (schemaId, objectModel, onModelsUpdated) {
|
|
46
|
-
setStepAndModels(function (previous) {
|
|
47
|
-
var _a;
|
|
48
|
-
var updatedModels = __assign(__assign({}, previous.models), (_a = {}, _a[schemaId] = objectModel, _a));
|
|
49
|
-
var updatedState = {
|
|
50
|
-
step: previous.step,
|
|
51
|
-
models: updatedModels,
|
|
52
|
-
etag: previous.etag
|
|
53
|
-
};
|
|
54
|
-
onModelsUpdated(updatedModels);
|
|
55
|
-
return updatedState;
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
var modelIsValid = useMemo(function () { return areModelsValid(models, getAllValidatableSchemas(step)); }, [models, step]);
|
|
59
|
-
return {
|
|
60
|
-
formErrors: formErrors,
|
|
61
|
-
globalError: globalError,
|
|
62
|
-
step: step,
|
|
63
|
-
models: models,
|
|
64
|
-
etag: etag,
|
|
65
|
-
modelIsValid: modelIsValid,
|
|
66
|
-
setFormErrors: setFormErrors,
|
|
67
|
-
setGlobalError: setGlobalError,
|
|
68
|
-
setStepAndEtag: setStepAndEtag,
|
|
69
|
-
setSchemaModel: setSchemaModel
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
var buildInitialModels = function (model, schemas) {
|
|
73
|
-
if (schemas === void 0) { schemas = []; }
|
|
74
|
-
return schemas.reduce(function (acc, schema) {
|
|
75
|
-
var _a;
|
|
76
|
-
if (!schema.$id) {
|
|
77
|
-
// TODO: DF-473 - Remove type assertions once we're confident people have had time to fix any errors
|
|
78
|
-
// eslint-disable-next-line no-console
|
|
79
|
-
console.warn('Schema without $id property found.');
|
|
80
|
-
}
|
|
81
|
-
return __assign(__assign({}, acc), (_a = {}, _a[schema.$id || ''] = getValidObjectModelParts(model, schema) || {}, _a));
|
|
82
|
-
}, {});
|
|
83
|
-
};
|
|
84
|
-
var getAllSchemas = function (step) { return __spreadArray(__spreadArray([], getAllSchemasInLayout((step === null || step === void 0 ? void 0 : step.layout) || []), true), ((step === null || step === void 0 ? void 0 : step.schemas) || []), true); };
|
|
85
|
-
var getAllSchemasInLayout = function (components) {
|
|
86
|
-
return components.flatMap(function (component) {
|
|
87
|
-
switch (component.type) {
|
|
88
|
-
case 'columns':
|
|
89
|
-
return __spreadArray([], getAllSchemasInLayout(__spreadArray(__spreadArray([], component.left, true), component.right, true)), true);
|
|
90
|
-
case 'box':
|
|
91
|
-
return getAllSchemasInLayout(component.components);
|
|
92
|
-
case 'form':
|
|
93
|
-
return isInlineSchema(component.schema) ? [component.schema] : [];
|
|
94
|
-
default:
|
|
95
|
-
return [];
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
var getAllValidatableSchemas = function (step) { return __spreadArray(__spreadArray([], getAllReferencedSchemaIds((step === null || step === void 0 ? void 0 : step.layout) || [])
|
|
100
|
-
.map(function (id) { return ((step === null || step === void 0 ? void 0 : step.schemas) || []).find(function (schema) { return schema.$id === id; }); })
|
|
101
|
-
.filter(Boolean), true), getAllSchemasInLayout((step === null || step === void 0 ? void 0 : step.layout) || []), true); };
|
|
102
|
-
var getAllReferencedSchemaIds = function (components) {
|
|
103
|
-
return components
|
|
104
|
-
.flatMap(function (component) {
|
|
105
|
-
switch (component.type) {
|
|
106
|
-
case 'columns':
|
|
107
|
-
return __spreadArray([], getAllReferencedSchemaIds(__spreadArray(__spreadArray([], component.left, true), component.right, true)), true);
|
|
108
|
-
case 'box':
|
|
109
|
-
return getAllReferencedSchemaIds(component.components);
|
|
110
|
-
case 'form':
|
|
111
|
-
return [getSchemaReference(component)];
|
|
112
|
-
default:
|
|
113
|
-
return [];
|
|
114
|
-
}
|
|
115
|
-
})
|
|
116
|
-
.filter(Boolean);
|
|
117
|
-
};
|
|
118
|
-
var areModelsValid = function (formModels, schemas) {
|
|
119
|
-
if (schemas === void 0) { schemas = []; }
|
|
120
|
-
return !(schemas === null || schemas === void 0 ? void 0 : schemas.some(function (schema) {
|
|
121
|
-
if (!schema.$id) {
|
|
122
|
-
// TODO: DF-473
|
|
123
|
-
// eslint-disable-next-line no-console
|
|
124
|
-
console.warn('Schema without $id property found.');
|
|
125
|
-
}
|
|
126
|
-
return !isValidSchema(formModels[schema.$id || ''] || {}, schema);
|
|
127
|
-
}));
|
|
128
|
-
};
|
|
129
|
-
var getSchemaReference = function (component) {
|
|
130
|
-
if (component.schema && !isInlineSchema(component.schema)) {
|
|
131
|
-
return component.schema.$ref;
|
|
132
|
-
}
|
|
133
|
-
return component.schemaId;
|
|
134
|
-
};
|
|
135
|
-
var isInlineSchema = function (schema) {
|
|
136
|
-
return schema !== undefined && typeof schema === 'object' && !Object.hasOwnProperty.call(schema, '$ref');
|
|
137
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import { Loader, Size } from '@transferwise/components';
|
|
14
|
-
import { useState } from 'react';
|
|
15
|
-
export function useLoader(loaderConfig, initialState) {
|
|
16
|
-
var config = __assign({ size: Size.EXTRA_LARGE, initial: true, submission: false }, loaderConfig);
|
|
17
|
-
var _a = useState(initialState), loadingState = _a[0], setLoadingState = _a[1];
|
|
18
|
-
var shouldDisplayLoader = (config.initial && loadingState === 'initial') ||
|
|
19
|
-
(config.submission && loadingState === 'submission');
|
|
20
|
-
var loader = shouldDisplayLoader ? (_jsx(Loader, { size: config.size, classNames: { 'tw-loader': 'tw-loader m-x-auto' }, "data-testid": "loader" })) : null;
|
|
21
|
-
return { isLoading: loadingState !== 'idle', setLoadingState: setLoadingState, loader: loader };
|
|
22
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import { LogProvider, EventsContextProvider } from '../common/contexts';
|
|
14
|
-
import GenericSchema from './genericSchema';
|
|
15
|
-
import { HttpClientProviderFromBaseUrl } from '../../common/httpClientContext';
|
|
16
|
-
function JsonSchemaForm(props) {
|
|
17
|
-
var schemaProps = __assign({ model: null, errors: null }, props);
|
|
18
|
-
var _a = props.baseUrl, baseUrl = _a === void 0 ? '' : _a, _b = props.onEvent, onEvent = _b === void 0 ? noop : _b, _c = props.onLog, onLog = _c === void 0 ? noop : _c;
|
|
19
|
-
return (_jsx(LogProvider, __assign({ flowId: "JsonSchemaForm", stepId: "JsonSchemaForm", onLog: onLog }, { children: _jsx(EventsContextProvider, __assign({ metadata: { flowId: 'JsonSchemaForm', stepId: 'JsonSchemaForm' }, onEvent: onEvent }, { children: _jsx(HttpClientProviderFromBaseUrl, __assign({ baseUrl: baseUrl }, { children: _jsx(GenericSchema, __assign({}, schemaProps)) })) })) })));
|
|
20
|
-
}
|
|
21
|
-
export default JsonSchemaForm;
|
|
22
|
-
var noop = function () {
|
|
23
|
-
// noop
|
|
24
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import { isListArraySchema } from '../../common/utils';
|
|
14
|
-
import ArrayListSchema from './arrayListSchema/ArrayListSchema';
|
|
15
|
-
var ArraySchema = function (props) {
|
|
16
|
-
var schema = props.schema;
|
|
17
|
-
if (isListArraySchema(schema)) {
|
|
18
|
-
return _jsx(ArrayListSchema, __assign({}, props));
|
|
19
|
-
}
|
|
20
|
-
throw new Error('Not implemented'); // Tuple not implemented
|
|
21
|
-
};
|
|
22
|
-
ArraySchema.defaultProps = {
|
|
23
|
-
required: false
|
|
24
|
-
};
|
|
25
|
-
export default ArraySchema;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import { isListArraySchema, isMultipleFileUploadSchema, isMultiSelectConstSchema, } from '../../../common/utils';
|
|
14
|
-
import MultipleFileUploadSchema from './multipleFileUploadSchema';
|
|
15
|
-
import { MultiSelectSchema } from './multiSelectSchema/MultiSelectSchema';
|
|
16
|
-
import RepeatableSchema from './repeatableSchema/RepeatableSchema';
|
|
17
|
-
function ArrayListSchema(props) {
|
|
18
|
-
var schema = props.schema;
|
|
19
|
-
if (isMultipleFileUploadSchema(schema)) {
|
|
20
|
-
return _jsx(MultipleFileUploadSchema, __assign({}, props, { schema: schema }));
|
|
21
|
-
}
|
|
22
|
-
if (isMultiSelectConstSchema(schema)) {
|
|
23
|
-
return _jsx(MultiSelectSchema, __assign({}, props, { schema: schema }));
|
|
24
|
-
}
|
|
25
|
-
if (isListArraySchema(schema)) {
|
|
26
|
-
return _jsx(RepeatableSchema, __assign({}, props, { schema: schema }));
|
|
27
|
-
}
|
|
28
|
-
throw new Error('Invalid array list schema');
|
|
29
|
-
}
|
|
30
|
-
ArrayListSchema.defaultProps = {
|
|
31
|
-
errors: null,
|
|
32
|
-
required: false
|
|
33
|
-
};
|
|
34
|
-
export default ArrayListSchema;
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
-
if (ar || !(i in from)) {
|
|
15
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
-
ar[i] = from[i];
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
-
};
|
|
21
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
|
-
import { Header, Modal, NavigationOption } from '@transferwise/components';
|
|
23
|
-
import { Plus } from '@transferwise/icons';
|
|
24
|
-
import { useMemo, useState } from 'react';
|
|
25
|
-
import { useIntl } from 'react-intl';
|
|
26
|
-
import { getValidationFailures, isArray, isEmpty, isObject, isValidSchema, } from '../../../../common/validators';
|
|
27
|
-
import { ItemSummaryOption } from './ItemSummary';
|
|
28
|
-
import messages from '../../../../../common/messages/repeatable.messages';
|
|
29
|
-
import RepeatableSchemaStep from './RepeatableSchemaStep';
|
|
30
|
-
import { getItemSummaryFromSchema } from './utils/summary-utils';
|
|
31
|
-
import classNames from 'classnames';
|
|
32
|
-
import ControlFeedback from '../../../controlFeedback';
|
|
33
|
-
import { generateRandomId } from '../../../../common/utils';
|
|
34
|
-
import { useFormattedDefaultErrorMessages } from '../multipleFileUploadSchema/utils';
|
|
35
|
-
function RepeatableSchema(_a) {
|
|
36
|
-
var _b;
|
|
37
|
-
var schema = _a.schema, model = _a.model, errors = _a.errors, submitted = _a.submitted, _c = _a.required, required = _c === void 0 ? false : _c, onChange = _a.onChange;
|
|
38
|
-
var _d = useState(null), openModalType = _d[0], setOpenModalType = _d[1];
|
|
39
|
-
var _e = useState(false), changed = _e[0], setChanged = _e[1];
|
|
40
|
-
var _f = useState(function () {
|
|
41
|
-
if (isObject(model) && !isArray(model)) {
|
|
42
|
-
throw new Error('RepeatableSchema does not support object models. Ensure your array schema is wrapped inside an object schema.');
|
|
43
|
-
}
|
|
44
|
-
return model
|
|
45
|
-
? model.map(function (item) { return getItemSummaryFromSchema(schema.items, item, schema === null || schema === void 0 ? void 0 : schema.summary); })
|
|
46
|
-
: null;
|
|
47
|
-
}), itemSummaries = _f[0], setItemSummaries = _f[1];
|
|
48
|
-
var _g = useState({ item: null, model: null }), editableItem = _g[0], setEditableItem = _g[1];
|
|
49
|
-
var id = useMemo(function () { return schema.$id || generateRandomId(); }, [schema.$id]);
|
|
50
|
-
var broadcastModelChange = function (updatedItems) {
|
|
51
|
-
var updatedModel = updatedItems
|
|
52
|
-
? updatedItems.map(function (_a) {
|
|
53
|
-
var value = _a.value;
|
|
54
|
-
return value;
|
|
55
|
-
})
|
|
56
|
-
: null;
|
|
57
|
-
onChange({
|
|
58
|
-
model: updatedModel,
|
|
59
|
-
triggerSchema: schema.items,
|
|
60
|
-
triggerModel: updatedModel
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
var onAddItem = function () {
|
|
64
|
-
setOpenModalType('add');
|
|
65
|
-
};
|
|
66
|
-
var onEditItem = function (item) {
|
|
67
|
-
setEditableItem({ item: item, model: item.value });
|
|
68
|
-
setOpenModalType('edit');
|
|
69
|
-
};
|
|
70
|
-
var onSaveItem = function (action, summaryTextOverride) {
|
|
71
|
-
var _a;
|
|
72
|
-
setChanged(true);
|
|
73
|
-
var updatedItem = action === 'remove'
|
|
74
|
-
? null
|
|
75
|
-
: getItemSummaryFromSchema(schema.items, editableItem.model, schema.summary, summaryTextOverride);
|
|
76
|
-
if (action !== 'remove' && !isValidSchema((_a = updatedItem === null || updatedItem === void 0 ? void 0 : updatedItem.value) !== null && _a !== void 0 ? _a : null, schema.items)) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
var updatedItemSummaries = getUpdatedItemSummaries(action, {
|
|
80
|
-
originalItem: editableItem.item,
|
|
81
|
-
updatedItem: updatedItem,
|
|
82
|
-
itemSummaries: itemSummaries
|
|
83
|
-
});
|
|
84
|
-
setItemSummaries(updatedItemSummaries);
|
|
85
|
-
broadcastModelChange(updatedItemSummaries);
|
|
86
|
-
setEditableItem({ item: null, model: null });
|
|
87
|
-
setOpenModalType(null);
|
|
88
|
-
};
|
|
89
|
-
var onCancelEdit = function () {
|
|
90
|
-
setEditableItem({ item: null, model: null });
|
|
91
|
-
setOpenModalType(null);
|
|
92
|
-
};
|
|
93
|
-
var formatMessage = useIntl().formatMessage;
|
|
94
|
-
var validations = getValidationFailures(model, schema, required);
|
|
95
|
-
var base64ValidationMessages = useFormattedDefaultErrorMessages({
|
|
96
|
-
minItems: schema.minItems,
|
|
97
|
-
maxItems: schema.maxItems
|
|
98
|
-
});
|
|
99
|
-
var validationMessages = schema.items.type === 'string' && schema.items.format === 'base64url'
|
|
100
|
-
? {
|
|
101
|
-
minItems: base64ValidationMessages.minItemsErrorMessage,
|
|
102
|
-
maxItems: base64ValidationMessages.maxItemsErrorMessage,
|
|
103
|
-
required: base64ValidationMessages.requiredMessage
|
|
104
|
-
}
|
|
105
|
-
: undefined;
|
|
106
|
-
var formGroupClasses = {
|
|
107
|
-
'has-error': (_b = (errors && !isEmpty(errors))) !== null && _b !== void 0 ? _b : (submitted && validations.length)
|
|
108
|
-
};
|
|
109
|
-
return (_jsxs("div", __assign({ id: id, className: classNames(formGroupClasses) }, { children: [schema.title && _jsx(Header, { title: schema.title }), itemSummaries === null || itemSummaries === void 0 ? void 0 : itemSummaries.map(function (itemSummary) { return (_jsx(ItemSummaryOption, { item: itemSummary, onClick: function () { return onEditItem(itemSummary); } }, JSON.stringify(itemSummary))); }), _jsx(NavigationOption, { media: _jsx(Plus, {}), title: schema.addItemTitle || formatMessage(messages.addItemTitle), showMediaAtAllSizes: true, onClick: onAddItem }), _jsx(Modal, { open: openModalType !== null, title: (openModalType === 'add' ? schema.addItemTitle : schema.editItemTitle) ||
|
|
110
|
-
formatMessage(messages.addItemTitle), body: _jsx(RepeatableSchemaStep, { type: openModalType !== null && openModalType !== void 0 ? openModalType : 'add', schema: schema, model: editableItem.model, errors: errors, submitted: submitted, onAction: onSaveItem, onModelChange: function (_a) {
|
|
111
|
-
var model = _a.model;
|
|
112
|
-
return setEditableItem(__assign(__assign({}, editableItem), { model: model }));
|
|
113
|
-
} }), onClose: onCancelEdit }), _jsx(ControlFeedback, { id: "".concat(id, "-feedback"), changed: changed, focused: false, blurred: false, errors: typeof errors === 'string' ? errors : undefined, submitted: submitted, schema: schema, validations: validations, validationMessages: validationMessages, infoMessage: null })] })));
|
|
114
|
-
}
|
|
115
|
-
var getUpdatedItemSummaries = function (action, _a) {
|
|
116
|
-
var originalItem = _a.originalItem, updatedItem = _a.updatedItem, itemSummaries = _a.itemSummaries;
|
|
117
|
-
if (action === 'remove') {
|
|
118
|
-
return (itemSummaries || []).filter(function (itemSummary) { return itemSummary !== originalItem; });
|
|
119
|
-
}
|
|
120
|
-
if (!updatedItem) {
|
|
121
|
-
return itemSummaries;
|
|
122
|
-
}
|
|
123
|
-
switch (action) {
|
|
124
|
-
case 'add':
|
|
125
|
-
return __spreadArray(__spreadArray([], (itemSummaries || []), true), [updatedItem], false);
|
|
126
|
-
case 'edit':
|
|
127
|
-
return (itemSummaries || []).map(function (itemSummary) {
|
|
128
|
-
return itemSummary === originalItem ? updatedItem : itemSummary;
|
|
129
|
-
});
|
|
130
|
-
default:
|
|
131
|
-
return null;
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
export default RepeatableSchema;
|