@wise/dynamic-flow-client 3.4.1 → 3.5.0-experimental-6654c72
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/errorBoundary/ErrorBoundary.js +44 -0
- package/build/common/errorBoundary/ErrorBoundaryAlert.js +12 -0
- package/build/common/httpClientContext/HttpClientContext.js +35 -0
- package/build/common/httpClientContext/index.js +1 -0
- package/build/common/makeHttpClient/index.js +1 -0
- package/build/common/makeHttpClient/makeHttpClient.js +34 -0
- package/build/common/messages/external-confirmation.messages.js +23 -0
- package/build/common/messages/generic-error.messages.js +18 -0
- package/build/common/messages/help.messages.js +8 -0
- package/build/common/messages/multi-file-upload.messages.js +18 -0
- package/build/common/messages/multi-select.messages.js +8 -0
- package/build/common/messages/paragraph.messages.js +13 -0
- package/build/common/messages/repeatable.messages.js +23 -0
- package/build/common/messages/validation.array.messages.js +13 -0
- package/build/common/messages/validation.messages.js +53 -0
- package/build/common/utils/api-utils.js +4 -0
- package/build/i18n/index.js +36 -0
- package/build/legacy/common/constants/DateMode.js +4 -0
- package/build/legacy/common/constants/FeatureName.js +4 -0
- package/build/legacy/common/constants/FormControlType.js +21 -0
- package/build/legacy/common/constants/MonthFormat.js +4 -0
- package/build/legacy/common/constants/Size.js +7 -0
- package/build/legacy/common/constants/index.js +4 -0
- package/build/legacy/common/contexts/dynamicFlowContexts/DynamicFlowContexts.js +36 -0
- package/build/legacy/common/contexts/dynamicFlowContexts/usePendingPromiseCounter.js +13 -0
- package/build/legacy/common/contexts/eventsContext/EventsContext.js +38 -0
- package/build/legacy/common/contexts/featureContext/FeatureContext.js +22 -0
- package/build/legacy/common/contexts/index.js +3 -0
- package/build/legacy/common/contexts/logContext/LogContext.js +44 -0
- package/build/legacy/common/hooks/index.js +7 -0
- package/build/legacy/common/hooks/useDebouncedFunction/useDebouncedFunction.js +9 -0
- package/build/legacy/common/hooks/useExternal/useExternal.js +15 -0
- package/build/legacy/common/hooks/useExternalStepPolling/useExternalStepPolling.js +70 -0
- package/build/legacy/common/hooks/usePersistAsync/usePersistAsync.js +172 -0
- package/build/legacy/common/hooks/usePolling/usePolling.js +51 -0
- package/build/legacy/common/hooks/usePrevious/usePrevious.js +8 -0
- package/build/legacy/common/hooks/useStepPolling/useStepPolling.js +43 -0
- package/build/legacy/common/messages.js +8 -0
- package/build/legacy/common/utils/api-utils.js +6 -0
- package/build/legacy/common/utils/date-utils.js +22 -0
- package/build/legacy/common/utils/debounce.js +38 -0
- package/build/legacy/common/utils/file-utils.js +45 -0
- package/build/legacy/common/utils/id-utils.js +5 -0
- package/build/legacy/common/utils/index.js +11 -0
- package/build/legacy/common/utils/is-equal.js +21 -0
- package/build/legacy/common/utils/misc-utils.js +4 -0
- package/build/legacy/common/utils/mobile-utils.js +23 -0
- package/build/legacy/common/utils/model-utils.js +33 -0
- package/build/legacy/common/utils/schema-utils.js +113 -0
- package/build/legacy/common/utils/step-utils.js +32 -0
- package/build/legacy/common/validators/index.js +5 -0
- package/build/legacy/common/validators/models/model-utils.js +119 -0
- package/build/legacy/common/validators/models/model-validators.js +62 -0
- package/build/legacy/common/validators/schemas/schema-validators.js +101 -0
- package/build/legacy/common/validators/types/type-validators.js +14 -0
- package/build/legacy/common/validators/validationFailures/validation-failures.js +139 -0
- package/build/legacy/common/validators/validationFailures/validation-failures.utils.js +40 -0
- package/build/legacy/common/validators/values/value-validators.js +6 -0
- package/build/legacy/dynamic-flow-types.js +1 -0
- package/build/legacy/dynamicFlow/BackButton.js +22 -0
- package/build/legacy/dynamicFlow/DynamicFlow.js +346 -0
- package/build/legacy/dynamicFlow/DynamicFlowStep.js +37 -0
- package/build/legacy/dynamicFlow/DynamicFlowTypes.js +1 -0
- package/build/legacy/dynamicFlow/index.js +1 -0
- package/build/legacy/dynamicFlow/utils/index.js +5 -0
- package/build/legacy/dynamicFlow/utils/responseParsers/response-parsers.js +185 -0
- package/build/legacy/dynamicFlow/utils/useDebouncedRefresh/useDebouncedRefresh.js +26 -0
- package/build/legacy/dynamicFlow/utils/useDynamicFlowState.js +137 -0
- package/build/legacy/dynamicFlow/utils/useLoader.js +22 -0
- package/build/legacy/formControl/FormControl.js +266 -0
- package/build/legacy/formControl/index.js +1 -0
- package/build/legacy/formControl/utils/getAutocompleteString.js +80 -0
- package/build/legacy/formControl/utils/index.js +2 -0
- package/build/legacy/formControl/utils/value-utils.js +108 -0
- package/build/legacy/jsonSchemaForm/JsonSchemaForm.js +24 -0
- package/build/legacy/jsonSchemaForm/allOfSchema/AllOfSchema.js +50 -0
- package/build/legacy/jsonSchemaForm/allOfSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/ArraySchema.js +25 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/ArrayListSchema.js +34 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multiSelectSchema/MultiSelectSchema.js +84 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.js +141 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/index.js +2 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/upload-utils.js +79 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils/useFormattedDefaultErrorMessages.js +14 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/ItemSummary.js +7 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/RepeatableSchema.js +134 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/RepeatableSchemaStep.js +85 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/utils/summary-utils.js +135 -0
- package/build/legacy/jsonSchemaForm/arrayTypeSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/basicTypeSchema/BasicTypeSchema.js +111 -0
- package/build/legacy/jsonSchemaForm/basicTypeSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/controlFeedback/ControlFeedback.js +86 -0
- package/build/legacy/jsonSchemaForm/controlFeedback/index.js +1 -0
- package/build/legacy/jsonSchemaForm/genericSchema/GenericSchema.js +85 -0
- package/build/legacy/jsonSchemaForm/genericSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/help/Help.js +20 -0
- package/build/legacy/jsonSchemaForm/help/index.js +1 -0
- package/build/legacy/jsonSchemaForm/index.js +1 -0
- package/build/legacy/jsonSchemaForm/objectSchema/ObjectSchema.js +77 -0
- package/build/legacy/jsonSchemaForm/objectSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/oneOfSchema/OneOfSchema.js +155 -0
- package/build/legacy/jsonSchemaForm/oneOfSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/oneOfSchema/utils.js +68 -0
- package/build/legacy/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.js +26 -0
- package/build/legacy/jsonSchemaForm/persistAsyncSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/PersistAsyncBasicSchema.js +165 -0
- package/build/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/PersistAsyncBlobSchema.js +131 -0
- package/build/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/UploadInputAdapter.js +31 -0
- package/build/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/promotedOneOfSchema/PromotedOneOfSchema.js +72 -0
- package/build/legacy/jsonSchemaForm/promotedOneOfSchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/promotedOneOfSchema/promoted-one-of-utils.js +8 -0
- package/build/legacy/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfCheckboxControl.js +27 -0
- package/build/legacy/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfControl.js +31 -0
- package/build/legacy/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfRadioControl.js +32 -0
- package/build/legacy/jsonSchemaForm/readOnlySchema/ReadOnlySchema.js +54 -0
- package/build/legacy/jsonSchemaForm/readOnlySchema/ReadOnlySchema.messages.js +13 -0
- package/build/legacy/jsonSchemaForm/readOnlySchema/index.js +1 -0
- package/build/legacy/jsonSchemaForm/schemaFormControl/SchemaFormControl.js +133 -0
- package/build/legacy/jsonSchemaForm/schemaFormControl/index.js +1 -0
- package/build/legacy/jsonSchemaForm/schemaFormControl/utils/index.js +1 -0
- package/build/legacy/jsonSchemaForm/schemaFormControl/utils/mapping-utils.js +107 -0
- package/build/legacy/jsonSchemaForm/validationAsyncSchema/ValidationAsyncSchema.js +150 -0
- package/build/legacy/jsonSchemaForm/validationAsyncSchema/index.js +1 -0
- package/build/legacy/layout/DynamicLayout.js +68 -0
- package/build/legacy/layout/alert/DynamicAlert.js +29 -0
- package/build/legacy/layout/box/DynamicBox.js +41 -0
- package/build/legacy/layout/button/DynamicButton.js +27 -0
- package/build/legacy/layout/button/utils.js +45 -0
- package/build/legacy/layout/columns/DynamicColumns.js +38 -0
- package/build/legacy/layout/decision/DynamicDecision.js +21 -0
- package/build/legacy/layout/divider/DynamicDivider.js +9 -0
- package/build/legacy/layout/external/DynamicExternal.js +32 -0
- package/build/legacy/layout/external/DynamicExternal.messages.js +8 -0
- package/build/legacy/layout/form/DynamicForm.js +22 -0
- package/build/legacy/layout/heading/DynamicHeading.js +51 -0
- package/build/legacy/layout/icon/DynamicIcon.js +17 -0
- package/build/legacy/layout/icon/FlagIcon.js +198 -0
- package/build/legacy/layout/icon/NamedIcon.js +19 -0
- package/build/legacy/layout/image/DynamicImage.js +111 -0
- package/build/legacy/layout/index.js +20 -0
- package/build/legacy/layout/instructions/DynamicInstructions.js +30 -0
- package/build/legacy/layout/list/DynamicStatusList.js +37 -0
- package/build/legacy/layout/loadingIndicator/DynamicLoadingIndicator.js +11 -0
- package/build/legacy/layout/markdown/DynamicMarkdown.js +23 -0
- package/build/legacy/layout/modal/DynamicModal.js +26 -0
- package/build/legacy/layout/paragraph/DynamicParagraph.js +46 -0
- package/build/legacy/layout/paragraph/useSnackBarIfAvailable.js +9 -0
- package/build/legacy/layout/review/DynamicReview.js +58 -0
- package/build/legacy/layout/search/DynamicSearch.js +58 -0
- package/build/legacy/layout/search/SearchInput.js +17 -0
- package/build/legacy/layout/search/SearchResults.js +31 -0
- package/build/legacy/layout/search/useSearch.js +137 -0
- package/build/legacy/layout/utils/getNavigationOptionMedia.js +28 -0
- package/build/legacy/layout/utils/index.js +32 -0
- package/build/legacy/step/cameraStep/CameraStep.js +124 -0
- package/build/legacy/step/cameraStep/cameraCapture/CameraCapture.js +161 -0
- package/build/legacy/step/cameraStep/cameraCapture/CameraCapture.messages.js +58 -0
- package/build/legacy/step/cameraStep/cameraCapture/components/bottomBar/BottomBar.js +28 -0
- package/build/legacy/step/cameraStep/cameraCapture/components/index.js +3 -0
- package/build/legacy/step/cameraStep/cameraCapture/components/orientationLockOverlay/OrientationLockOverlay.js +19 -0
- package/build/legacy/step/cameraStep/cameraCapture/components/orientationLockOverlay/OrientationLockOverlay.messages.js +8 -0
- package/build/legacy/step/cameraStep/cameraCapture/hooks/useFullScreenOrientationLock.js +60 -0
- package/build/legacy/step/cameraStep/cameraCapture/hooks/useVideoConstraints.js +80 -0
- package/build/legacy/step/cameraStep/cameraCapture/index.js +1 -0
- package/build/legacy/step/cameraStep/cameraCapture/overlay/Overlay.js +77 -0
- package/build/legacy/step/cameraStep/cameraCapture/screens/cameraErrorScreen/CameraErrorScreen.js +18 -0
- package/build/legacy/step/cameraStep/cameraCapture/screens/index.js +1 -0
- package/build/legacy/step/cameraStep/cameraCapture/tracking/index.js +109 -0
- package/build/legacy/step/cameraStep/cameraCapture/types/index.js +7 -0
- package/build/legacy/step/cameraStep/cameraCapture/utils/index.js +107 -0
- package/build/legacy/step/cameraStep/index.js +1 -0
- package/build/legacy/step/externalConfirmationStep/ExternalConfirmationStep.js +64 -0
- package/build/legacy/step/externalConfirmationStep/index.js +1 -0
- package/build/legacy/step/index.js +3 -0
- package/build/legacy/step/layoutStep/LayoutStep.js +33 -0
- package/build/legacy/step/layoutStep/index.js +1 -0
- package/build/legacy/step/layoutStep/utils/index.js +2 -0
- package/build/legacy/step/layoutStep/utils/inline-reference-utils.js +105 -0
- package/build/legacy/step/layoutStep/utils/layout-utils.js +212 -0
- package/build/main.js +4775 -225
- package/build/main.min.js +1 -1
- package/build/main.mjs +4776 -226
- package/build/revamp/domain/components/AlertComponent.js +50 -0
- package/build/revamp/domain/components/AllOfComponent.js +72 -0
- package/build/revamp/domain/components/BooleanInputComponent.js +108 -0
- package/build/revamp/domain/components/BoxComponent.js +65 -0
- package/build/revamp/domain/components/ButtonComponent.js +50 -0
- package/build/revamp/domain/components/ColumnsComponent.js +74 -0
- package/build/revamp/domain/components/ConstComponent.js +50 -0
- package/build/revamp/domain/components/ContainerComponent.js +65 -0
- package/build/revamp/domain/components/DateInputComponent.js +127 -0
- package/build/revamp/domain/components/DecisionComponent.js +50 -0
- package/build/revamp/domain/components/DividerComponent.js +50 -0
- package/build/revamp/domain/components/FormComponent.js +65 -0
- package/build/revamp/domain/components/HeadingComponent.js +50 -0
- package/build/revamp/domain/components/ImageComponent.js +50 -0
- package/build/revamp/domain/components/InstructionsComponent.js +50 -0
- package/build/revamp/domain/components/IntegerInputComponent.js +125 -0
- package/build/revamp/domain/components/LoadingIndicatorComponent.js +50 -0
- package/build/revamp/domain/components/MarkdownComponent.js +50 -0
- package/build/revamp/domain/components/ModalComponent.js +65 -0
- package/build/revamp/domain/components/MultiUploadInputComponent.js +190 -0
- package/build/revamp/domain/components/NumberInputComponent.js +125 -0
- package/build/revamp/domain/components/ObjectComponent.js +104 -0
- package/build/revamp/domain/components/ParagraphComponent.js +50 -0
- package/build/revamp/domain/components/ReviewComponent.js +50 -0
- package/build/revamp/domain/components/SelectInputComponent.js +138 -0
- package/build/revamp/domain/components/StatusListComponent.js +50 -0
- package/build/revamp/domain/components/StepDomainComponent.js +93 -0
- package/build/revamp/domain/components/TextInputComponent.js +125 -0
- package/build/revamp/domain/components/UploadInputComponent.js +151 -0
- package/build/revamp/domain/components/repeatableComponent/RepeatableComponent.js +148 -0
- package/build/revamp/domain/components/searchComponent/SearchComponent.js +108 -0
- package/build/revamp/domain/components/utils/component-utils.js +18 -0
- package/build/revamp/domain/components/utils/debounce.js +38 -0
- package/build/revamp/domain/components/utils/file-utils.js +46 -0
- package/build/revamp/domain/components/utils/getComponentForLocalValueKey.js +31 -0
- package/build/revamp/domain/components/utils/isPartialLocalValueMatch.js +40 -0
- package/build/revamp/domain/features/events.js +1 -0
- package/build/revamp/domain/features/persistAsync/getComponentPersistAsync.js +133 -0
- package/build/revamp/domain/features/persistAsync/getPerformPersistAsync.js +103 -0
- package/build/revamp/domain/features/refresh/getPerformRefresh.js +53 -0
- package/build/revamp/domain/features/summary/summary-utils.js +39 -0
- package/build/revamp/domain/features/utils/http-utils.js +34 -0
- package/build/revamp/domain/features/utils/response-utils.js +9 -0
- package/build/revamp/domain/features/validation/validation-functions.js +12 -0
- package/build/revamp/domain/features/validation/value-checks.js +111 -0
- package/build/revamp/domain/features/validationAsync/getComponentValidationAsync.js +94 -0
- package/build/revamp/domain/features/validationAsync/getPerformValidationAsync.js +107 -0
- package/build/revamp/domain/mappers/types.js +1 -0
- package/build/revamp/domain/types.js +1 -0
- package/build/revamp/flow/response-utils.js +88 -0
- package/build/revamp/renderers/CoreContainerRenderer.js +8 -0
- package/build/revamp/renderers/LoadingContext.js +7 -0
- package/build/revamp/renderers/types.js +1 -0
- package/build/revamp/types.js +1 -0
- package/build/revamp/utils/component-utils.js +86 -0
- package/build/revamp/utils/type-utils.js +56 -0
- package/build/revamp/utils/type-validators.js +16 -0
- package/build/revamp/wise/renderers/AlertRenderer.js +11 -0
- package/build/revamp/wise/renderers/BooleanInputRenderer.js +34 -0
- package/build/revamp/wise/renderers/BoxRenderer.js +30 -0
- package/build/revamp/wise/renderers/ButtonRenderer.js +64 -0
- package/build/revamp/wise/renderers/ColumnsRenderer.js +25 -0
- package/build/revamp/wise/renderers/components/FieldInput.js +20 -0
- package/build/revamp/wise/renderers/components/Help.js +21 -0
- package/build/revamp/wise/renderers/components/LabelContentWithHelp.js +6 -0
- package/build/revamp/wise/renderers/utils/layout-utils.js +31 -0
- package/build/types/legacy/step/externalConfirmationStep/ExternalConfirmationStep.d.ts +1 -1
- package/build/types/revamp/domain/components/StepDomainComponent.d.ts +4 -2
- package/build/types/revamp/renderers/step/ExternalConfirmationDialog.d.ts +6 -0
- package/build/types/revamp/renderers/{StepRenderer.d.ts → step/StepRenderer.d.ts} +1 -1
- package/build/types/revamp/renderers/step/useExternal.d.ts +4 -0
- package/build/types/revamp/renderers/stepComponentToProps.d.ts +1 -1
- package/build/types/revamp/renderers/types.d.ts +3 -0
- package/package.json +13 -13
- /package/build/types/{legacy/step/externalConfirmationStep/ExternalConfirmationStep.messages.d.ts → common/messages/external-confirmation.messages.d.ts} +0 -0
|
@@ -0,0 +1,148 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
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;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
49
|
+
var t = {};
|
|
50
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
51
|
+
t[p] = s[p];
|
|
52
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
53
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
54
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
55
|
+
t[p[i]] = s[p[i]];
|
|
56
|
+
}
|
|
57
|
+
return t;
|
|
58
|
+
};
|
|
59
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
60
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
61
|
+
if (ar || !(i in from)) {
|
|
62
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
63
|
+
ar[i] = from[i];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
67
|
+
};
|
|
68
|
+
import { validateComponents, getLocalValueValidator, } from '../../features/validation/validation-functions';
|
|
69
|
+
import { getInputUpdateFunction } from '../utils/component-utils';
|
|
70
|
+
export var createRepeatableComponent = function (repeatableProps, updateComponent) {
|
|
71
|
+
var uid = repeatableProps.uid, id = repeatableProps.id, checks = repeatableProps.checks, components = repeatableProps.components, summary = repeatableProps.summary, createEditableComponent = repeatableProps.createEditableComponent, summariser = repeatableProps.summariser, componentProps = __rest(repeatableProps, ["uid", "id", "checks", "components", "summary", "createEditableComponent", "summariser"]);
|
|
72
|
+
var update = getInputUpdateFunction(uid, updateComponent);
|
|
73
|
+
var getValidationErrors = getLocalValueValidator(checks);
|
|
74
|
+
return __assign(__assign({ uid: uid, id: id, type: 'repeatable', components: components, editableComponent: null, editableIndex: null, summaryDefaults: {
|
|
75
|
+
title: summary === null || summary === void 0 ? void 0 : summary.defaultTitle,
|
|
76
|
+
description: summary === null || summary === void 0 ? void 0 : summary.defaultDescription,
|
|
77
|
+
icon: summary === null || summary === void 0 ? void 0 : summary.defaultIcon,
|
|
78
|
+
image: summary === null || summary === void 0 ? void 0 : summary.defaultImage
|
|
79
|
+
} }, componentProps), { onEdit: function (itemIndex) {
|
|
80
|
+
update(function (draft) {
|
|
81
|
+
draft.editableComponent = createEditableComponent(draft.components[itemIndex].getLocalValue());
|
|
82
|
+
draft.editableIndex = itemIndex;
|
|
83
|
+
});
|
|
84
|
+
}, onAdd: function () {
|
|
85
|
+
update(function (draft) {
|
|
86
|
+
draft.editableComponent = createEditableComponent(null);
|
|
87
|
+
draft.editableIndex = null;
|
|
88
|
+
draft.errors = [];
|
|
89
|
+
});
|
|
90
|
+
}, onSave: function () {
|
|
91
|
+
var _this = this;
|
|
92
|
+
var _a;
|
|
93
|
+
var isValid = (_a = this.editableComponent) === null || _a === void 0 ? void 0 : _a.validate();
|
|
94
|
+
if (!isValid) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
update(function (draft) {
|
|
98
|
+
if (draft.editableComponent === null) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (draft.editableIndex === null) {
|
|
102
|
+
// Adding a new item
|
|
103
|
+
var newComponent = __assign({}, draft.editableComponent);
|
|
104
|
+
draft.components = __spreadArray(__spreadArray([], _this.components, true), [newComponent], false);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
// Editing an item
|
|
108
|
+
draft.components[draft.editableIndex] = __assign(__assign({}, draft.editableComponent), { uid: draft.components[draft.editableIndex].uid });
|
|
109
|
+
}
|
|
110
|
+
draft.editableComponent = null;
|
|
111
|
+
draft.editableIndex = null;
|
|
112
|
+
});
|
|
113
|
+
return true;
|
|
114
|
+
}, onRemove: function () {
|
|
115
|
+
update(function (draft) {
|
|
116
|
+
if (draft.editableIndex === null) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
draft.components.splice(draft.editableIndex, 1);
|
|
120
|
+
draft.editableComponent = null;
|
|
121
|
+
draft.editableIndex = null;
|
|
122
|
+
});
|
|
123
|
+
}, getChildren: function () {
|
|
124
|
+
return this.editableComponent !== null
|
|
125
|
+
? __spreadArray(__spreadArray([], this.components, true), [this.editableComponent], false) : this.components;
|
|
126
|
+
}, getSubmittableValue: function () {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
128
|
+
var _this = this;
|
|
129
|
+
return __generator(this, function (_a) {
|
|
130
|
+
return [2 /*return*/, Promise.all(this.components.map(function (component) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
131
|
+
return [2 /*return*/, component.getSubmittableValue()];
|
|
132
|
+
}); }); }))];
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
}, getSummary: function () {
|
|
136
|
+
// It doesn't make sense to pass a value here
|
|
137
|
+
return summariser(null);
|
|
138
|
+
}, getLocalValue: function () {
|
|
139
|
+
return this.components.map(function (component) { return component.getLocalValue(); });
|
|
140
|
+
}, validate: function () {
|
|
141
|
+
var messages = getValidationErrors(this.getLocalValue());
|
|
142
|
+
var childComponentsValid = validateComponents(this.getChildren());
|
|
143
|
+
update(function (draft) {
|
|
144
|
+
draft.errors = messages;
|
|
145
|
+
});
|
|
146
|
+
return messages.length === 0 && childComponentsValid;
|
|
147
|
+
} });
|
|
148
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
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 { getInputUpdateFunction } from '../utils/component-utils';
|
|
38
|
+
import { debounce } from '../utils/debounce';
|
|
39
|
+
var DEBOUNCE_TIME = 400;
|
|
40
|
+
export var createSearchComponent = function (searchProps, performSearch, onAction, updateComponent) {
|
|
41
|
+
var uid = searchProps.uid, control = searchProps.control, emptyMessage = searchProps.emptyMessage, margin = searchProps.margin, title = searchProps.title;
|
|
42
|
+
var update = getInputUpdateFunction(uid, updateComponent);
|
|
43
|
+
var abortController = new AbortController();
|
|
44
|
+
var search = function (query, searchConfig) {
|
|
45
|
+
abortController.abort();
|
|
46
|
+
abortController = new AbortController();
|
|
47
|
+
var signal = abortController.signal;
|
|
48
|
+
performSearch({
|
|
49
|
+
signal: signal,
|
|
50
|
+
query: query,
|
|
51
|
+
config: searchConfig
|
|
52
|
+
})
|
|
53
|
+
.then(function (state) {
|
|
54
|
+
if (!signal.aborted) {
|
|
55
|
+
update(function (draft) {
|
|
56
|
+
draft.results = state;
|
|
57
|
+
draft.isLoading = false;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
})["catch"](function () {
|
|
61
|
+
if (!signal.aborted) {
|
|
62
|
+
update(function (draft) {
|
|
63
|
+
draft.error = 'No response';
|
|
64
|
+
draft.isLoading = false;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
var onSelect = function (_a) {
|
|
70
|
+
var type = _a.type, value = _a.value;
|
|
71
|
+
if (type === 'action') {
|
|
72
|
+
void onAction(value);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
update(function (draft) {
|
|
76
|
+
draft.query = value.query;
|
|
77
|
+
});
|
|
78
|
+
search(value.query, { method: value.method, param: value.param, url: value.url });
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
var debouncedSearch = debounce(search, DEBOUNCE_TIME);
|
|
82
|
+
var onChange = function (query) {
|
|
83
|
+
update(function (draft) {
|
|
84
|
+
draft.query = query;
|
|
85
|
+
draft.isLoading = true;
|
|
86
|
+
});
|
|
87
|
+
debouncedSearch(query);
|
|
88
|
+
};
|
|
89
|
+
return {
|
|
90
|
+
type: 'search',
|
|
91
|
+
uid: uid,
|
|
92
|
+
control: control,
|
|
93
|
+
emptyMessage: emptyMessage,
|
|
94
|
+
margin: margin,
|
|
95
|
+
title: title,
|
|
96
|
+
isLoading: false,
|
|
97
|
+
query: '',
|
|
98
|
+
results: [],
|
|
99
|
+
getSubmittableValue: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
100
|
+
return [2 /*return*/, null];
|
|
101
|
+
}); }); },
|
|
102
|
+
getLocalValue: function () { return null; },
|
|
103
|
+
getSummary: function () { return ({}); },
|
|
104
|
+
validate: function () { return true; },
|
|
105
|
+
onChange: onChange,
|
|
106
|
+
onSelect: onSelect
|
|
107
|
+
};
|
|
108
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper function to update a component.
|
|
3
|
+
*
|
|
4
|
+
* `updateComponent` is generic, meaning we have to specify the type of the draft whenever we use it. This function takes
|
|
5
|
+
* the component uid and type, and returns a typed function that will update the component without the need to type assert.
|
|
6
|
+
*
|
|
7
|
+
* @param uid uid of the component
|
|
8
|
+
* @param updateComponent the updateComponent function that will update the component with the given uid
|
|
9
|
+
* @returns a function that accepts a function that will update the component
|
|
10
|
+
*/
|
|
11
|
+
export var getInputUpdateFunction = function (uid, updateComponent) {
|
|
12
|
+
return function (updateFn) {
|
|
13
|
+
updateComponent(uid, function (draft) {
|
|
14
|
+
var draftState = draft;
|
|
15
|
+
updateFn(draftState);
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export var debounce = function (callback, waitMs) {
|
|
2
|
+
var timeoutId;
|
|
3
|
+
var lastArgs;
|
|
4
|
+
var clearTimer = function () {
|
|
5
|
+
if (timeoutId) {
|
|
6
|
+
clearTimeout(timeoutId);
|
|
7
|
+
timeoutId = null;
|
|
8
|
+
}
|
|
9
|
+
lastArgs = null;
|
|
10
|
+
};
|
|
11
|
+
var debouncedFn = function () {
|
|
12
|
+
var args = [];
|
|
13
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
14
|
+
args[_i] = arguments[_i];
|
|
15
|
+
}
|
|
16
|
+
lastArgs = args;
|
|
17
|
+
if (timeoutId !== null) {
|
|
18
|
+
clearTimeout(timeoutId);
|
|
19
|
+
}
|
|
20
|
+
timeoutId = setTimeout(function () {
|
|
21
|
+
callback.apply(void 0, lastArgs);
|
|
22
|
+
timeoutId = null;
|
|
23
|
+
lastArgs = null;
|
|
24
|
+
}, waitMs);
|
|
25
|
+
};
|
|
26
|
+
debouncedFn.cancel = function () {
|
|
27
|
+
if (timeoutId !== null) {
|
|
28
|
+
clearTimer();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
debouncedFn.flush = function () {
|
|
32
|
+
if (timeoutId !== null) {
|
|
33
|
+
callback.apply(void 0, lastArgs);
|
|
34
|
+
clearTimer();
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
return debouncedFn;
|
|
38
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
export var toBase64 = function (file) { return __awaiter(void 0, void 0, void 0, function () {
|
|
38
|
+
return __generator(this, function (_a) {
|
|
39
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
40
|
+
var reader = new FileReader();
|
|
41
|
+
reader.addEventListener('load', function () { return resolve(reader.result); });
|
|
42
|
+
reader.addEventListener('error', reject);
|
|
43
|
+
reader.readAsDataURL(file);
|
|
44
|
+
})];
|
|
45
|
+
});
|
|
46
|
+
}); };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
+
if (ar || !(i in from)) {
|
|
4
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
+
ar[i] = from[i];
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
+
};
|
|
10
|
+
import { hasChildren, isObjectLocalValue } from '../../../utils/type-utils';
|
|
11
|
+
/**
|
|
12
|
+
* Returns a component that is a child (or grandchild, etc.) of the given component,
|
|
13
|
+
* which is "responsible" for the value of the given key,
|
|
14
|
+
* or null if there isn't any.
|
|
15
|
+
*/
|
|
16
|
+
export var getComponentForLocalValueKey = function (key, component) {
|
|
17
|
+
if (component.type === 'object') {
|
|
18
|
+
return component.componentMap[key];
|
|
19
|
+
}
|
|
20
|
+
if (component.type === 'select') {
|
|
21
|
+
var selectedChild = component.getSelectedChild();
|
|
22
|
+
return selectedChild ? getComponentForLocalValueKey(key, selectedChild) : null;
|
|
23
|
+
}
|
|
24
|
+
var child = hasChildren(component)
|
|
25
|
+
? __spreadArray([], component.getChildren(), true).reverse().find(function (c) {
|
|
26
|
+
var v = c.getLocalValue();
|
|
27
|
+
return isObjectLocalValue(v) && key in v;
|
|
28
|
+
})
|
|
29
|
+
: undefined;
|
|
30
|
+
return child ? getComponentForLocalValueKey(key, child) : null;
|
|
31
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
+
if (ar || !(i in from)) {
|
|
4
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
+
ar[i] = from[i];
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
+
};
|
|
10
|
+
import { isObjectLocalValue } from '../../../utils/type-utils';
|
|
11
|
+
import { isArray, isNullish } from '../../../utils/type-validators';
|
|
12
|
+
import { getComponentForLocalValueKey } from './getComponentForLocalValueKey';
|
|
13
|
+
export var isPartialLocalValueMatch = function (partialValue, component) {
|
|
14
|
+
if (isArray(partialValue) && component.type === 'repeatable') {
|
|
15
|
+
var children_1 = component.getChildren();
|
|
16
|
+
return partialValue.every(function (value, index) {
|
|
17
|
+
var childComponent = children_1[index];
|
|
18
|
+
return childComponent ? isPartialLocalValueMatch(value, childComponent) : false;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
var componentValue = component.getLocalValue();
|
|
22
|
+
if (isObjectLocalValue(partialValue) && isObjectLocalValue(componentValue)) {
|
|
23
|
+
var allKeys = Array.from(new Set(__spreadArray(__spreadArray([], Object.keys(partialValue), true), Object.keys(componentValue), true)));
|
|
24
|
+
var matchingKeys = allKeys.filter(function (key) { return !isNullish(partialValue[key]) && !isNullish(componentValue[key]); });
|
|
25
|
+
return matchingKeys.every(function (key) {
|
|
26
|
+
var componentForKey = getComponentForLocalValueKey(key, component);
|
|
27
|
+
return componentForKey ? isPartialLocalValueMatch(partialValue[key], componentForKey) : false;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
if (partialValue instanceof File && componentValue instanceof File) {
|
|
31
|
+
return areEquivalentFiles(partialValue, componentValue);
|
|
32
|
+
}
|
|
33
|
+
if ('isPersisted' in component && component.isPersisted) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return partialValue === componentValue;
|
|
37
|
+
};
|
|
38
|
+
var areEquivalentFiles = function (fileA, fileB) {
|
|
39
|
+
return fileA.name === fileB.name && fileA.type === fileB.type && fileA.size === fileB.size;
|
|
40
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,133 @@
|
|
|
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
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
38
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
39
|
+
if (ar || !(i in from)) {
|
|
40
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
41
|
+
ar[i] = from[i];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
45
|
+
};
|
|
46
|
+
import { isNullish } from '../../../utils/type-validators';
|
|
47
|
+
import { abortAndResetController } from '../utils/http-utils';
|
|
48
|
+
/**
|
|
49
|
+
* Creates an onPersistAsync handler for a component.
|
|
50
|
+
*/
|
|
51
|
+
export var getComponentPersistAsync = function (update, performPersistAsync) {
|
|
52
|
+
/**
|
|
53
|
+
* Will update the persistedState when a new request is made, and will update
|
|
54
|
+
* the value or set errors when the request completes.
|
|
55
|
+
*/
|
|
56
|
+
return function (persistedState, currentValue) { return __awaiter(void 0, void 0, void 0, function () {
|
|
57
|
+
var abortController, lastSubmitted, submission, newAbortController, resolvedNull_1, signal, newSubmission;
|
|
58
|
+
return __generator(this, function (_a) {
|
|
59
|
+
abortController = persistedState.abortController, lastSubmitted = persistedState.lastSubmitted, submission = persistedState.submission;
|
|
60
|
+
// Ignore subsequent requests for the same value
|
|
61
|
+
if (lastSubmitted === currentValue) {
|
|
62
|
+
return [2 /*return*/, submission];
|
|
63
|
+
}
|
|
64
|
+
newAbortController = abortAndResetController(abortController);
|
|
65
|
+
if (isNullish(currentValue)) {
|
|
66
|
+
resolvedNull_1 = Promise.resolve(null);
|
|
67
|
+
update(function (draft) {
|
|
68
|
+
draft.persistedState.abortController = newAbortController;
|
|
69
|
+
draft.persistedState.lastSubmitted = currentValue;
|
|
70
|
+
draft.persistedState.submission = resolvedNull_1;
|
|
71
|
+
});
|
|
72
|
+
return [2 /*return*/, resolvedNull_1];
|
|
73
|
+
}
|
|
74
|
+
signal = newAbortController.signal;
|
|
75
|
+
newSubmission = performPersistAsync({ value: currentValue, signal: signal })["catch"](function (error) {
|
|
76
|
+
if (error instanceof DOMException && error.name === 'AbortError') {
|
|
77
|
+
// No op, the request was aborted
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
update(function (draft) {
|
|
81
|
+
draft.errors = [error.message];
|
|
82
|
+
draft.persistedState.lastSubmitted = null;
|
|
83
|
+
});
|
|
84
|
+
throw error;
|
|
85
|
+
});
|
|
86
|
+
update(function (draft) {
|
|
87
|
+
draft.persistedState = {
|
|
88
|
+
abortController: newAbortController,
|
|
89
|
+
lastSubmitted: currentValue,
|
|
90
|
+
submission: newSubmission
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
return [2 /*return*/, newSubmission];
|
|
94
|
+
});
|
|
95
|
+
}); };
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Creates an onPersistAsync handler for a component.
|
|
99
|
+
*/
|
|
100
|
+
export var getComponentMultiPersistAsync = function (update, performPersistAsync) {
|
|
101
|
+
/**
|
|
102
|
+
* Will update the persistedState when a new request is made, and will update
|
|
103
|
+
* the value or set errors when the request completes.
|
|
104
|
+
*/
|
|
105
|
+
return function (value, id) { return __awaiter(void 0, void 0, void 0, function () {
|
|
106
|
+
var newAbortController, signal, newSubmission;
|
|
107
|
+
return __generator(this, function (_a) {
|
|
108
|
+
if (isNullish(value)) {
|
|
109
|
+
throw new Error('Value must be a file or base64 string.');
|
|
110
|
+
}
|
|
111
|
+
newAbortController = new AbortController();
|
|
112
|
+
signal = newAbortController.signal;
|
|
113
|
+
newSubmission = performPersistAsync({ value: value, signal: signal })["catch"](function (error) {
|
|
114
|
+
update(function (draft) {
|
|
115
|
+
// The file was not persisted, so delete it
|
|
116
|
+
draft.persistedState = draft.persistedState.filter(function (state) { return state.id !== id; });
|
|
117
|
+
});
|
|
118
|
+
throw error;
|
|
119
|
+
});
|
|
120
|
+
update(function (draft) {
|
|
121
|
+
draft.persistedState = __spreadArray(__spreadArray([], draft.persistedState, true), [
|
|
122
|
+
{
|
|
123
|
+
id: id,
|
|
124
|
+
abortController: newAbortController,
|
|
125
|
+
lastSubmitted: null,
|
|
126
|
+
submission: newSubmission
|
|
127
|
+
},
|
|
128
|
+
], false);
|
|
129
|
+
});
|
|
130
|
+
return [2 /*return*/, newSubmission];
|
|
131
|
+
});
|
|
132
|
+
}); };
|
|
133
|
+
};
|