@wise/dynamic-flow-client 0.1.1 → 0.1.3
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/api/utils.d.ts +4 -0
- package/build/common/api/utils.js +13 -0
- package/build/common/contexts/dynamicFlowContext/dynamicFlowContext.d.ts +11 -0
- package/build/common/contexts/dynamicFlowContext/dynamicFlowContext.js +36 -0
- package/build/common/contexts/dynamicFlowContext/usePendingPromiseCounter.d.ts +4 -0
- package/build/common/contexts/dynamicFlowContext/usePendingPromiseCounter.js +13 -0
- package/build/common/contexts/fetcherContext/fetcherContext.d.ts +18 -0
- package/build/common/contexts/fetcherContext/fetcherContext.js +35 -0
- package/build/common/contexts/fetcherContext/index.d.ts +2 -0
- package/build/common/contexts/fetcherContext/index.js +2 -0
- package/build/common/contexts/fetcherContext/makeFetcher.d.ts +2 -0
- package/build/common/contexts/fetcherContext/makeFetcher.js +33 -0
- package/build/common/general/index.d.ts +2 -0
- package/build/common/general/index.js +22 -0
- package/build/common/hooks/useDebouncedFunction.d.ts +2 -0
- package/build/common/hooks/useDebouncedFunction.js +9 -0
- package/build/common/hooks/useDebouncedFunction.test.d.ts +1 -0
- package/build/common/hooks/useDebouncedFunction.test.js +59 -0
- package/build/common/hooks/usePersistAsync.d.ts +7 -0
- package/build/common/hooks/usePersistAsync.js +170 -0
- package/build/common/hooks/usePolling.d.ts +11 -0
- package/build/common/hooks/usePolling.js +48 -0
- package/build/common/hooks/usePrevious.d.ts +2 -0
- package/build/common/hooks/usePrevious.js +9 -0
- package/build/common/index.d.ts +4 -0
- package/build/common/index.js +4 -0
- package/build/common/logging/index.d.ts +22 -0
- package/build/common/logging/index.js +39 -0
- package/build/common/logging/spec.d.ts +1 -0
- package/build/common/logging/spec.js +45 -0
- package/build/common/messages.d.ts +8 -0
- package/build/common/messages.js +8 -0
- package/build/common/propsValues/dateMode.d.ts +4 -0
- package/build/common/propsValues/dateMode.js +4 -0
- package/build/common/propsValues/formControlType.d.ts +17 -0
- package/build/common/propsValues/formControlType.js +17 -0
- package/build/common/propsValues/monthFormat.d.ts +4 -0
- package/build/common/propsValues/monthFormat.js +4 -0
- package/build/common/propsValues/size.d.ts +7 -0
- package/build/common/propsValues/size.js +7 -0
- package/build/common/requirements.d.ts +10 -0
- package/build/common/requirements.js +50 -0
- package/build/common/schemaTypes/schemaTypes.d.ts +23 -0
- package/build/common/schemaTypes/schemaTypes.js +53 -0
- package/build/common/schemaTypes/shouldDebounceSchema.d.ts +2 -0
- package/build/common/schemaTypes/shouldDebounceSchema.js +6 -0
- package/build/common/stepTypes/stepTypes.d.ts +7 -0
- package/build/common/stepTypes/stepTypes.js +42 -0
- package/build/common/tracking/index.d.ts +15 -0
- package/build/common/tracking/index.js +33 -0
- package/build/common/tracking/spec.d.ts +1 -0
- package/build/common/tracking/spec.js +49 -0
- package/build/common/utils/file-utils.d.ts +4 -0
- package/build/common/utils/file-utils.js +45 -0
- package/build/common/utils/generate-random-id.d.ts +1 -0
- package/build/common/utils/generate-random-id.js +5 -0
- package/build/common/utils/generate-random-id.test.d.ts +1 -0
- package/build/common/utils/generate-random-id.test.js +12 -0
- package/build/common/validation/rule-validators/index.d.ts +10 -0
- package/build/common/validation/rule-validators/index.js +40 -0
- package/build/common/validation/rule-validators/spec.d.ts +1 -0
- package/build/common/validation/rule-validators/spec.js +145 -0
- package/build/common/validation/schema-validators/index.d.ts +9 -0
- package/build/common/validation/schema-validators/index.js +98 -0
- package/build/common/validation/schema-validators/spec.d.ts +1 -0
- package/build/common/validation/schema-validators/spec.js +137 -0
- package/build/common/validation/valid-model/index.d.ts +5 -0
- package/build/common/validation/valid-model/index.js +64 -0
- package/build/common/validation/valid-model/spec.d.ts +1 -0
- package/build/common/validation/valid-model/spec.js +605 -0
- package/build/common/validation/valid-model/utils.d.ts +11 -0
- package/build/common/validation/valid-model/utils.js +118 -0
- package/build/common/validation/validation-failures/index.d.ts +23 -0
- package/build/common/validation/validation-failures/index.js +140 -0
- package/build/common/validation/validation-failures/spec.d.ts +1 -0
- package/build/common/validation/validation-failures/spec.js +185 -0
- package/build/dynamic-flow-types/Action.d.ts +19 -0
- package/build/dynamic-flow-types/Action.js +1 -0
- package/build/dynamic-flow-types/FileUploadSchema.d.ts +23 -0
- package/build/dynamic-flow-types/FileUploadSchema.js +3 -0
- package/build/dynamic-flow-types/LayoutComponent.d.ts +129 -0
- package/build/dynamic-flow-types/LayoutComponent.js +1 -0
- package/build/dynamic-flow-types/Model.d.ts +12 -0
- package/build/dynamic-flow-types/Model.js +28 -0
- package/build/dynamic-flow-types/PersistAsync.d.ts +8 -0
- package/build/dynamic-flow-types/PersistAsync.js +1 -0
- package/build/dynamic-flow-types/Polling.d.ts +12 -0
- package/build/dynamic-flow-types/Polling.js +1 -0
- package/build/dynamic-flow-types/Promotion.d.ts +20 -0
- package/build/dynamic-flow-types/Promotion.js +1 -0
- package/build/dynamic-flow-types/Schema.d.ts +184 -0
- package/build/dynamic-flow-types/Schema.js +49 -0
- package/build/dynamic-flow-types/Step.d.ts +127 -0
- package/build/dynamic-flow-types/Step.js +4 -0
- package/build/dynamic-flow-types/ValidationAsync.d.ts +6 -0
- package/build/dynamic-flow-types/ValidationAsync.js +1 -0
- package/build/dynamic-flow-types/core.d.ts +29 -0
- package/build/dynamic-flow-types/core.js +1 -0
- package/build/dynamic-flow-types/index.d.ts +14 -0
- package/build/dynamic-flow-types/index.js +12 -0
- package/build/field/Field.d.ts +69 -0
- package/build/field/Field.js +311 -0
- package/build/field/index.d.ts +2 -0
- package/build/field/index.js +2 -0
- package/build/flow/DynamicFlow.d.ts +4 -0
- package/build/flow/DynamicFlow.js +368 -0
- package/build/flow/DynamicFlowStep.d.ts +9 -0
- package/build/flow/DynamicFlowStep.js +32 -0
- package/build/flow/errorBoundary/ErrorBoundary.d.ts +20 -0
- package/build/flow/errorBoundary/ErrorBoundary.js +45 -0
- package/build/flow/errorBoundary/ErrorBoundary.messages.d.ts +13 -0
- package/build/flow/errorBoundary/ErrorBoundary.messages.js +13 -0
- package/build/flow/errorBoundary/ErrorBoundaryAlert.d.ts +6 -0
- package/build/flow/errorBoundary/ErrorBoundaryAlert.js +12 -0
- package/build/flow/errorBoundary/index.d.ts +1 -0
- package/build/flow/errorBoundary/index.js +1 -0
- package/build/flow/fixtures/components/alert.d.ts +3 -0
- package/build/flow/fixtures/components/alert.js +31 -0
- package/build/flow/fixtures/components/box.d.ts +3 -0
- package/build/flow/fixtures/components/box.js +20 -0
- package/build/flow/fixtures/components/button.d.ts +3 -0
- package/build/flow/fixtures/components/button.js +65 -0
- package/build/flow/fixtures/components/columns.d.ts +3 -0
- package/build/flow/fixtures/components/columns.js +36 -0
- package/build/flow/fixtures/components/copyable.d.ts +3 -0
- package/build/flow/fixtures/components/copyable.js +22 -0
- package/build/flow/fixtures/components/decision.d.ts +3 -0
- package/build/flow/fixtures/components/decision.js +54 -0
- package/build/flow/fixtures/components/heading.d.ts +3 -0
- package/build/flow/fixtures/components/heading.js +14 -0
- package/build/flow/fixtures/components/image.d.ts +3 -0
- package/build/flow/fixtures/components/image.js +22 -0
- package/build/flow/fixtures/components/info.d.ts +3 -0
- package/build/flow/fixtures/components/info.js +17 -0
- package/build/flow/fixtures/components/list.d.ts +3 -0
- package/build/flow/fixtures/components/list.js +34 -0
- package/build/flow/fixtures/components/loading-indicator.d.ts +3 -0
- package/build/flow/fixtures/components/loading-indicator.js +16 -0
- package/build/flow/fixtures/components/paragraph.d.ts +3 -0
- package/build/flow/fixtures/components/paragraph.js +28 -0
- package/build/flow/fixtures/components/review.d.ts +3 -0
- package/build/flow/fixtures/components/review.js +60 -0
- package/build/flow/fixtures/examples/camera-capture.d.ts +3 -0
- package/build/flow/fixtures/examples/camera-capture.js +121 -0
- package/build/flow/fixtures/examples/recipient-update.d.ts +3 -0
- package/build/flow/fixtures/examples/recipient-update.js +250 -0
- package/build/flow/fixtures/examples/recipient.d.ts +3 -0
- package/build/flow/fixtures/examples/recipient.js +313 -0
- package/build/flow/fixtures/examples/single-file-upload.d.ts +3 -0
- package/build/flow/fixtures/examples/single-file-upload.js +96 -0
- package/build/flow/fixtures/examples/step-validation-errors.d.ts +3 -0
- package/build/flow/fixtures/examples/step-validation-errors.js +75 -0
- package/build/flow/fixtures/features/action-response.d.ts +3 -0
- package/build/flow/fixtures/features/action-response.js +29 -0
- package/build/flow/fixtures/features/external.d.ts +3 -0
- package/build/flow/fixtures/features/external.js +31 -0
- package/build/flow/fixtures/features/persist-async.d.ts +3 -0
- package/build/flow/fixtures/features/persist-async.js +44 -0
- package/build/flow/fixtures/features/polling.d.ts +3 -0
- package/build/flow/fixtures/features/polling.js +33 -0
- package/build/flow/fixtures/index.d.ts +42 -0
- package/build/flow/fixtures/index.js +66 -0
- package/build/flow/fixtures/responses/action-response-final.d.ts +3 -0
- package/build/flow/fixtures/responses/action-response-final.js +24 -0
- package/build/flow/fixtures/responses/action.d.ts +5 -0
- package/build/flow/fixtures/responses/action.js +2 -0
- package/build/flow/fixtures/responses/exit.d.ts +6 -0
- package/build/flow/fixtures/responses/exit.js +2 -0
- package/build/flow/fixtures/responses/recipient-update-final.d.ts +3 -0
- package/build/flow/fixtures/responses/recipient-update-final.js +24 -0
- package/build/flow/fixtures/schemas/basic-form.d.ts +3 -0
- package/build/flow/fixtures/schemas/basic-form.js +39 -0
- package/build/flow/fixtures/schemas/number-and-integer.d.ts +3 -0
- package/build/flow/fixtures/schemas/number-and-integer.js +41 -0
- package/build/flow/fixtures/schemas/one-of.d.ts +3 -0
- package/build/flow/fixtures/schemas/one-of.js +223 -0
- package/build/flow/fixtures/schemas/string-formats.d.ts +3 -0
- package/build/flow/fixtures/schemas/string-formats.js +58 -0
- package/build/flow/index.d.ts +1 -0
- package/build/flow/index.js +1 -0
- package/build/flow/response-parsers/index.d.ts +17 -0
- package/build/flow/response-parsers/index.js +112 -0
- package/build/flow/response-parsers/spec.d.ts +1 -0
- package/build/flow/response-parsers/spec.js +263 -0
- package/build/flow/stories/EditableDynamicFlow.d.ts +5 -0
- package/build/flow/stories/EditableDynamicFlow.js +61 -0
- package/build/flow/types.d.ts +77 -0
- package/build/flow/types.js +3 -0
- package/build/flow/useDebouncedRefresh/index.d.ts +1 -0
- package/build/flow/useDebouncedRefresh/index.js +1 -0
- package/build/flow/useDebouncedRefresh/useDebouncedRefresh.d.ts +5 -0
- package/build/flow/useDebouncedRefresh/useDebouncedRefresh.js +24 -0
- package/build/flow/useDynamicFlowState.d.ts +18 -0
- package/build/flow/useDynamicFlowState.js +111 -0
- package/build/flow/useLoader.d.ts +9 -0
- package/build/flow/useLoader.js +22 -0
- package/build/formControl/FormControl.d.ts +86 -0
- package/build/formControl/FormControl.js +241 -0
- package/build/formControl/index.d.ts +1 -0
- package/build/formControl/index.js +1 -0
- package/build/formControl/types.d.ts +57 -0
- package/build/formControl/types.js +1 -0
- package/build/formControl/value-utils.d.ts +9 -0
- package/build/formControl/value-utils.js +108 -0
- package/build/i18n/cs.json +8 -0
- package/build/i18n/de.json +34 -0
- package/build/i18n/en.json +38 -0
- package/build/i18n/es.json +34 -0
- package/build/i18n/fr.json +34 -0
- package/build/i18n/hu.json +34 -0
- package/build/i18n/id.json +34 -0
- package/build/i18n/index.d.ts +2 -0
- package/build/i18n/index.js +31 -0
- package/build/i18n/it.json +34 -0
- package/build/i18n/ja.json +34 -0
- package/build/i18n/pl.json +11 -0
- package/build/i18n/pt.json +34 -0
- package/build/i18n/ro.json +34 -0
- package/build/i18n/ru.json +34 -0
- package/build/i18n/th.json +34 -0
- package/build/i18n/tr.json +11 -0
- package/build/i18n/uk.json +8 -0
- package/build/i18n/zh-CN.json +34 -0
- package/build/i18n/zh.json +34 -0
- package/build/index.d.ts +12 -0
- package/build/index.js +11 -0
- package/build/jsonSchemaForm/JsonSchemaForm.d.ts +66 -0
- package/build/jsonSchemaForm/JsonSchemaForm.js +31 -0
- package/build/jsonSchemaForm/allOfSchema/AllOfSchema.d.ts +14 -0
- package/build/jsonSchemaForm/allOfSchema/AllOfSchema.js +54 -0
- package/build/jsonSchemaForm/allOfSchema/index.d.ts +2 -0
- package/build/jsonSchemaForm/allOfSchema/index.js +1 -0
- package/build/jsonSchemaForm/arrayTypeSchema/ArraySchema.d.ts +15 -0
- package/build/jsonSchemaForm/arrayTypeSchema/ArraySchema.js +25 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/ArrayListSchema.d.ts +16 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/ArrayListSchema.js +26 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/index.d.ts +1 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/index.js +1 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.d.ts +18 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.js +141 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.messages.d.ts +24 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.messages.js +18 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/index.d.ts +1 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/index.js +1 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/useFormattedDefaultErrorMessages.d.ts +9 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/useFormattedDefaultErrorMessages.js +14 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils.d.ts +6 -0
- package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils.js +85 -0
- package/build/jsonSchemaForm/arrayTypeSchema/index.d.ts +2 -0
- package/build/jsonSchemaForm/arrayTypeSchema/index.js +1 -0
- package/build/jsonSchemaForm/basicTypeSchema/BasicTypeSchema.d.ts +22 -0
- package/build/jsonSchemaForm/basicTypeSchema/BasicTypeSchema.js +105 -0
- package/build/jsonSchemaForm/basicTypeSchema/index.d.ts +2 -0
- package/build/jsonSchemaForm/basicTypeSchema/index.js +1 -0
- package/build/jsonSchemaForm/controlFeedback/ControlFeedback.d.ts +31 -0
- package/build/jsonSchemaForm/controlFeedback/ControlFeedback.js +79 -0
- package/build/jsonSchemaForm/controlFeedback/ControlFeedback.messages.d.ts +53 -0
- package/build/jsonSchemaForm/controlFeedback/ControlFeedback.messages.js +53 -0
- package/build/jsonSchemaForm/controlFeedback/index.d.ts +1 -0
- package/build/jsonSchemaForm/controlFeedback/index.js +1 -0
- package/build/jsonSchemaForm/genericSchema/GenericSchema.d.ts +19 -0
- package/build/jsonSchemaForm/genericSchema/GenericSchema.js +122 -0
- package/build/jsonSchemaForm/genericSchema/index.d.ts +1 -0
- package/build/jsonSchemaForm/genericSchema/index.js +1 -0
- package/build/jsonSchemaForm/help/Help.d.ts +8 -0
- package/build/jsonSchemaForm/help/Help.js +9 -0
- package/build/jsonSchemaForm/help/Help.messages.d.ts +8 -0
- package/build/jsonSchemaForm/help/Help.messages.js +8 -0
- package/build/jsonSchemaForm/help/index.d.ts +1 -0
- package/build/jsonSchemaForm/help/index.js +1 -0
- package/build/jsonSchemaForm/index.d.ts +1 -0
- package/build/jsonSchemaForm/index.js +1 -0
- package/build/jsonSchemaForm/objectSchema/ObjectSchema.d.ts +16 -0
- package/build/jsonSchemaForm/objectSchema/ObjectSchema.js +78 -0
- package/build/jsonSchemaForm/objectSchema/index.d.ts +2 -0
- package/build/jsonSchemaForm/objectSchema/index.js +1 -0
- package/build/jsonSchemaForm/oneOfSchema/OneOfSchema.d.ts +15 -0
- package/build/jsonSchemaForm/oneOfSchema/OneOfSchema.js +153 -0
- package/build/jsonSchemaForm/oneOfSchema/getActiveSchemaIndex.d.ts +3 -0
- package/build/jsonSchemaForm/oneOfSchema/getActiveSchemaIndex.js +40 -0
- package/build/jsonSchemaForm/oneOfSchema/getBestMatchingSchemaIndexForValue.d.ts +2 -0
- package/build/jsonSchemaForm/oneOfSchema/getBestMatchingSchemaIndexForValue.js +27 -0
- package/build/jsonSchemaForm/oneOfSchema/index.d.ts +2 -0
- package/build/jsonSchemaForm/oneOfSchema/index.js +1 -0
- package/build/jsonSchemaForm/oneOfSchema/isConstSchema.d.ts +3 -0
- package/build/jsonSchemaForm/oneOfSchema/isConstSchema.js +7 -0
- package/build/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.d.ts +16 -0
- package/build/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.js +26 -0
- package/build/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.messages.d.ts +8 -0
- package/build/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.messages.js +8 -0
- package/build/jsonSchemaForm/persistAsyncSchema/basic/PersistAsyncBasicSchema.d.ts +21 -0
- package/build/jsonSchemaForm/persistAsyncSchema/basic/PersistAsyncBasicSchema.js +168 -0
- package/build/jsonSchemaForm/persistAsyncSchema/basic/index.d.ts +1 -0
- package/build/jsonSchemaForm/persistAsyncSchema/basic/index.js +1 -0
- package/build/jsonSchemaForm/persistAsyncSchema/blob/PersistAsyncBlobSchema.d.ts +20 -0
- package/build/jsonSchemaForm/persistAsyncSchema/blob/PersistAsyncBlobSchema.js +127 -0
- package/build/jsonSchemaForm/persistAsyncSchema/blob/UploadInputAdapter.d.ts +17 -0
- package/build/jsonSchemaForm/persistAsyncSchema/blob/UploadInputAdapter.js +32 -0
- package/build/jsonSchemaForm/persistAsyncSchema/blob/index.d.ts +1 -0
- package/build/jsonSchemaForm/persistAsyncSchema/blob/index.js +1 -0
- package/build/jsonSchemaForm/persistAsyncSchema/index.d.ts +2 -0
- package/build/jsonSchemaForm/persistAsyncSchema/index.js +1 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/PromotedOneOfSchema.d.ts +9 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/PromotedOneOfSchema.js +72 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/PromotedOneOfSchemaModelMatcher.d.ts +2 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/PromotedOneOfSchemaModelMatcher.js +8 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/control/PromotedOneOfCheckboxControl.d.ts +7 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/control/PromotedOneOfCheckboxControl.js +27 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/control/PromotedOneOfControl.d.ts +23 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/control/PromotedOneOfControl.js +31 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/control/PromotedOneOfRadioControl.d.ts +9 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/control/PromotedOneOfRadioControl.js +32 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/index.d.ts +2 -0
- package/build/jsonSchemaForm/promotedOneOfSchema/index.js +1 -0
- package/build/jsonSchemaForm/readOnlySchema/ReadOnlySchema.d.ts +8 -0
- package/build/jsonSchemaForm/readOnlySchema/ReadOnlySchema.js +55 -0
- package/build/jsonSchemaForm/readOnlySchema/ReadOnlySchema.messages.d.ts +16 -0
- package/build/jsonSchemaForm/readOnlySchema/ReadOnlySchema.messages.js +13 -0
- package/build/jsonSchemaForm/readOnlySchema/index.d.ts +1 -0
- package/build/jsonSchemaForm/readOnlySchema/index.js +1 -0
- package/build/jsonSchemaForm/schemaFormControl/SchemaFormControl.d.ts +25 -0
- package/build/jsonSchemaForm/schemaFormControl/SchemaFormControl.js +106 -0
- package/build/jsonSchemaForm/schemaFormControl/availableCurrencyFlags.d.ts +3 -0
- package/build/jsonSchemaForm/schemaFormControl/availableCurrencyFlags.js +73 -0
- package/build/jsonSchemaForm/schemaFormControl/index.d.ts +1 -0
- package/build/jsonSchemaForm/schemaFormControl/index.js +1 -0
- package/build/jsonSchemaForm/schemaFormControl/optionMapper.d.ts +40 -0
- package/build/jsonSchemaForm/schemaFormControl/optionMapper.js +89 -0
- package/build/jsonSchemaForm/schemas/allOf.json.d.ts +3 -0
- package/build/jsonSchemaForm/schemas/allOf.json.js +119 -0
- package/build/jsonSchemaForm/schemas/audRecipient.json.d.ts +3 -0
- package/build/jsonSchemaForm/schemas/audRecipient.json.js +1104 -0
- package/build/jsonSchemaForm/schemas/base64Url_MultipleFileUpload.json.d.ts +3 -0
- package/build/jsonSchemaForm/schemas/base64Url_MultipleFileUpload.json.js +37 -0
- package/build/jsonSchemaForm/schemas/blob_MultipleFileUpload.json.d.ts +3 -0
- package/build/jsonSchemaForm/schemas/blob_MultipleFileUpload.json.js +36 -0
- package/build/jsonSchemaForm/schemas/currency.json.d.ts +3 -0
- package/build/jsonSchemaForm/schemas/currency.json.js +48 -0
- package/build/jsonSchemaForm/schemas/oneOf.json.d.ts +3 -0
- package/build/jsonSchemaForm/schemas/oneOf.json.js +119 -0
- package/build/jsonSchemaForm/schemas/oneOfTabs.json.d.ts +3 -0
- package/build/jsonSchemaForm/schemas/oneOfTabs.json.js +53 -0
- package/build/jsonSchemaForm/schemas/promotedOneOf.json.d.ts +3 -0
- package/build/jsonSchemaForm/schemas/promotedOneOf.json.js +56 -0
- package/build/jsonSchemaForm/schemas/promotedOneOfCheckbox.json.d.ts +3 -0
- package/build/jsonSchemaForm/schemas/promotedOneOfCheckbox.json.js +102 -0
- package/build/jsonSchemaForm/schemas/simple.json.d.ts +3 -0
- package/build/jsonSchemaForm/schemas/simple.json.js +48 -0
- package/build/jsonSchemaForm/schemas/uploadPersistAsync.json.d.ts +3 -0
- package/build/jsonSchemaForm/schemas/uploadPersistAsync.json.js +71 -0
- package/build/jsonSchemaForm/schemas/validationAsync.json.d.ts +3 -0
- package/build/jsonSchemaForm/schemas/validationAsync.json.js +23 -0
- package/build/jsonSchemaForm/validationAsyncSchema/ValidationAsyncSchema.d.ts +17 -0
- package/build/jsonSchemaForm/validationAsyncSchema/ValidationAsyncSchema.js +149 -0
- package/build/jsonSchemaForm/validationAsyncSchema/index.d.ts +2 -0
- package/build/jsonSchemaForm/validationAsyncSchema/index.js +1 -0
- package/build/layout/DynamicLayout.d.ts +17 -0
- package/build/layout/DynamicLayout.js +75 -0
- package/build/layout/alert/index.d.ts +6 -0
- package/build/layout/alert/index.js +29 -0
- package/build/layout/box/index.d.ts +8 -0
- package/build/layout/box/index.js +41 -0
- package/build/layout/button/index.d.ts +8 -0
- package/build/layout/button/index.js +58 -0
- package/build/layout/columns/index.d.ts +8 -0
- package/build/layout/columns/index.js +38 -0
- package/build/layout/decision/index.d.ts +9 -0
- package/build/layout/decision/index.js +38 -0
- package/build/layout/divider/index.d.ts +7 -0
- package/build/layout/divider/index.js +9 -0
- package/build/layout/external/DynamicExternal.d.ts +8 -0
- package/build/layout/external/DynamicExternal.js +30 -0
- package/build/layout/external/DynamicExternal.messages.d.ts +8 -0
- package/build/layout/external/DynamicExternal.messages.js +8 -0
- package/build/layout/external/index.d.ts +1 -0
- package/build/layout/external/index.js +1 -0
- package/build/layout/external/useExternalStepPolling.d.ts +11 -0
- package/build/layout/external/useExternalStepPolling.js +68 -0
- package/build/layout/form/index.d.ts +8 -0
- package/build/layout/form/index.js +22 -0
- package/build/layout/heading/index.d.ts +6 -0
- package/build/layout/heading/index.js +31 -0
- package/build/layout/icon/index.d.ts +7 -0
- package/build/layout/icon/index.js +22 -0
- package/build/layout/image/index.d.ts +6 -0
- package/build/layout/image/index.js +126 -0
- package/build/layout/index.d.ts +1 -0
- package/build/layout/index.js +1 -0
- package/build/layout/info/index.d.ts +7 -0
- package/build/layout/info/index.js +19 -0
- package/build/layout/layouts/all.json.d.ts +3 -0
- package/build/layout/layouts/all.json.js +176 -0
- package/build/layout/layouts/final-step-layout.json.d.ts +3 -0
- package/build/layout/layouts/final-step-layout.json.js +39 -0
- package/build/layout/layouts/finalStep.json.d.ts +3 -0
- package/build/layout/layouts/finalStep.json.js +24 -0
- package/build/layout/layouts/list.json.d.ts +3 -0
- package/build/layout/layouts/list.json.js +33 -0
- package/build/layout/layouts/pay-in.json.d.ts +3 -0
- package/build/layout/layouts/pay-in.json.js +97 -0
- package/build/layout/layouts/review.json.d.ts +3 -0
- package/build/layout/layouts/review.json.js +160 -0
- package/build/layout/layouts/success.json.d.ts +3 -0
- package/build/layout/layouts/success.json.js +66 -0
- package/build/layout/list/index.d.ts +8 -0
- package/build/layout/list/index.js +30 -0
- package/build/layout/loading-indicator/index.d.ts +7 -0
- package/build/layout/loading-indicator/index.js +10 -0
- package/build/layout/loading-indicator/spec.d.ts +1 -0
- package/build/layout/loading-indicator/spec.js +11 -0
- package/build/layout/paragraph/DynamicParagraph.d.ts +7 -0
- package/build/layout/paragraph/DynamicParagraph.js +42 -0
- package/build/layout/paragraph/DynamicParagraph.messages.d.ts +13 -0
- package/build/layout/paragraph/DynamicParagraph.messages.js +13 -0
- package/build/layout/paragraph/index.d.ts +1 -0
- package/build/layout/paragraph/index.js +1 -0
- package/build/layout/paragraph/useSnackBarIfAvailable.d.ts +10 -0
- package/build/layout/paragraph/useSnackBarIfAvailable.js +9 -0
- package/build/layout/review/index.d.ts +9 -0
- package/build/layout/review/index.js +33 -0
- package/build/layout/utils.d.ts +7 -0
- package/build/layout/utils.js +31 -0
- package/build/main.css +143 -0
- package/build/schema.d.ts +1 -0
- package/build/schema.js +1 -0
- package/build/step/cameraStep/CameraStep.d.ts +8 -0
- package/build/step/cameraStep/CameraStep.js +125 -0
- package/build/step/cameraStep/cameraCapture/CameraCapture.d.ts +16 -0
- package/build/step/cameraStep/cameraCapture/CameraCapture.js +122 -0
- package/build/step/cameraStep/cameraCapture/CameraCapture.messages.d.ts +18 -0
- package/build/step/cameraStep/cameraCapture/CameraCapture.messages.js +18 -0
- package/build/step/cameraStep/cameraCapture/components/index.d.ts +8 -0
- package/build/step/cameraStep/cameraCapture/components/index.js +28 -0
- package/build/step/cameraStep/cameraCapture/hooks/index.d.ts +4 -0
- package/build/step/cameraStep/cameraCapture/hooks/index.js +80 -0
- package/build/step/cameraStep/cameraCapture/index.d.ts +1 -0
- package/build/step/cameraStep/cameraCapture/index.js +1 -0
- package/build/step/cameraStep/cameraCapture/overlay/Overlay.d.ts +11 -0
- package/build/step/cameraStep/cameraCapture/overlay/Overlay.js +78 -0
- package/build/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.d.ts +3 -0
- package/build/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.js +19 -0
- package/build/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.messages.d.ts +13 -0
- package/build/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.messages.js +13 -0
- package/build/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.d.ts +6 -0
- package/build/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.js +21 -0
- package/build/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.messages.d.ts +18 -0
- package/build/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.messages.js +18 -0
- package/build/step/cameraStep/cameraCapture/screens/index.d.ts +2 -0
- package/build/step/cameraStep/cameraCapture/screens/index.js +2 -0
- package/build/step/cameraStep/cameraCapture/tracking/index.d.ts +7 -0
- package/build/step/cameraStep/cameraCapture/tracking/index.js +101 -0
- package/build/step/cameraStep/cameraCapture/utils/index.d.ts +8 -0
- package/build/step/cameraStep/cameraCapture/utils/index.js +103 -0
- package/build/step/cameraStep/index.d.ts +1 -0
- package/build/step/cameraStep/index.js +1 -0
- package/build/step/externalConfirmationStep/ExternalConfirmationStep.d.ts +7 -0
- package/build/step/externalConfirmationStep/ExternalConfirmationStep.js +64 -0
- package/build/step/externalConfirmationStep/ExternalConfirmationStep.messages.d.ts +23 -0
- package/build/step/externalConfirmationStep/ExternalConfirmationStep.messages.js +23 -0
- package/build/step/externalConfirmationStep/index.d.ts +1 -0
- package/build/step/externalConfirmationStep/index.js +1 -0
- package/build/step/features/external/useExternal.d.ts +4 -0
- package/build/step/features/external/useExternal.js +15 -0
- package/build/step/features/index.d.ts +2 -0
- package/build/step/features/index.js +2 -0
- package/build/step/features/polling/useStepPolling.d.ts +2 -0
- package/build/step/features/polling/useStepPolling.js +44 -0
- package/build/step/index.d.ts +3 -0
- package/build/step/index.js +3 -0
- package/build/step/layoutStep/LayoutStep.d.ts +11 -0
- package/build/step/layoutStep/LayoutStep.js +34 -0
- package/build/step/layoutStep/index.d.ts +1 -0
- package/build/step/layoutStep/index.js +1 -0
- package/build/step/layoutStep/layoutService/convertStepToLayout.d.ts +8 -0
- package/build/step/layoutStep/layoutService/convertStepToLayout.js +217 -0
- package/build/step/layoutStep/layoutService/index.d.ts +2 -0
- package/build/step/layoutStep/layoutService/index.js +2 -0
- package/build/step/layoutStep/layoutService/inlineReferences.d.ts +7 -0
- package/build/step/layoutStep/layoutService/inlineReferences.js +91 -0
- package/package.json +1 -1
|
@@ -0,0 +1,54 @@
|
|
|
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, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import classNames from 'classnames';
|
|
14
|
+
import { useState } from 'react';
|
|
15
|
+
import { getValidObjectModelParts } from '../../common/validation/valid-model';
|
|
16
|
+
import GenericSchema from '../genericSchema';
|
|
17
|
+
var splitModel = function (model, schemas) {
|
|
18
|
+
// If wew receive a model, break it down to parts valid for each schema
|
|
19
|
+
return schemas.map(function (schema) { return getValidObjectModelParts(model, schema) || {}; });
|
|
20
|
+
};
|
|
21
|
+
var combineModels = function (models) {
|
|
22
|
+
return models.reduce(function (current, combined) {
|
|
23
|
+
return __assign(__assign({}, combined), current);
|
|
24
|
+
}, {});
|
|
25
|
+
};
|
|
26
|
+
var getSchemaColumnClasses = function (width) {
|
|
27
|
+
return {
|
|
28
|
+
'col-xs-12': true,
|
|
29
|
+
'col-sm-6': width === 'md',
|
|
30
|
+
'col-sm-4': width === 'sm'
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
var AllOfSchema = function (props) {
|
|
34
|
+
var onChangeModelIndex = function (index, onChangeProps) {
|
|
35
|
+
var modelSchema = props.schema.allOf[index];
|
|
36
|
+
// FIXME we should not mutate models here
|
|
37
|
+
// eslint-disable-next-line fp/no-mutation
|
|
38
|
+
models[index] = getValidObjectModelParts(onChangeProps.model, modelSchema) || {};
|
|
39
|
+
setModels(models);
|
|
40
|
+
props.onChange(__assign(__assign({}, onChangeProps), { model: combineModels(models) }));
|
|
41
|
+
};
|
|
42
|
+
var _a = useState(splitModel(props.model, props.schema.allOf)), models = _a[0], setModels = _a[1];
|
|
43
|
+
return (_jsxs(_Fragment, { children: [props.schema.title && _jsx("h3", __assign({ className: "page-header" }, { children: props.schema.title })), props.schema.description && _jsx("p", { children: props.schema.description }), _jsx("div", __assign({ className: "row" }, { children: props.schema.allOf.map(function (schema, index) { return (
|
|
44
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
45
|
+
_jsx("div", __assign({ className: classNames(getSchemaColumnClasses(schema.width)) }, { children: _jsx(GenericSchema, { schema: schema, model: models[index], errors: props.errors, submitted: props.submitted, disabled: props.disabled, onChange: function (onChangeProps) {
|
|
46
|
+
return onChangeModelIndex(index, __assign(__assign({}, onChangeProps), {
|
|
47
|
+
// We can safely assume that the model here is going to be of the same type as the model prop
|
|
48
|
+
model: onChangeProps.model }));
|
|
49
|
+
}, onPersistAsync: props.onPersistAsync }) }), index)); }) }))] }));
|
|
50
|
+
};
|
|
51
|
+
AllOfSchema.defaultProps = {
|
|
52
|
+
disabled: false
|
|
53
|
+
};
|
|
54
|
+
export default AllOfSchema;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './AllOfSchema';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ArrayModel, ArraySchema as ArraySchemaType } from '../../dynamic-flow-types';
|
|
3
|
+
import { GenericSchemaProps } from '../genericSchema/GenericSchema';
|
|
4
|
+
declare const ArraySchema: {
|
|
5
|
+
(props: ArraySchemaProps): JSX.Element;
|
|
6
|
+
defaultProps: {
|
|
7
|
+
required: boolean;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export type ArraySchemaProps = GenericSchemaProps & {
|
|
11
|
+
schema: ArraySchemaType;
|
|
12
|
+
model: ArrayModel | null;
|
|
13
|
+
errors: string | null;
|
|
14
|
+
};
|
|
15
|
+
export default ArraySchema;
|
|
@@ -0,0 +1,25 @@
|
|
|
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 '../../dynamic-flow-types';
|
|
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;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ArrayModel, ArraySchema as ArraySchemaType } from '../../../dynamic-flow-types';
|
|
3
|
+
import { GenericSchemaProps } from '../../genericSchema/GenericSchema';
|
|
4
|
+
declare const ArrayListSchema: {
|
|
5
|
+
(props: Props): JSX.Element;
|
|
6
|
+
defaultProps: {
|
|
7
|
+
errors: null;
|
|
8
|
+
required: boolean;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
type Props = GenericSchemaProps & {
|
|
12
|
+
schema: ArraySchemaType;
|
|
13
|
+
errors?: string | null;
|
|
14
|
+
model: ArrayModel | null;
|
|
15
|
+
};
|
|
16
|
+
export default ArrayListSchema;
|
|
@@ -0,0 +1,26 @@
|
|
|
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 { isMultipleFileUploadSchema } from '../../../dynamic-flow-types/Schema';
|
|
14
|
+
import MultipleFileUploadSchema from './multipleFileUploadSchema';
|
|
15
|
+
var ArrayListSchema = function (props) {
|
|
16
|
+
var schema = props.schema;
|
|
17
|
+
if (isMultipleFileUploadSchema(schema)) {
|
|
18
|
+
return _jsx(MultipleFileUploadSchema, __assign({}, props, { schema: schema }));
|
|
19
|
+
}
|
|
20
|
+
throw new Error('Not implemented');
|
|
21
|
+
};
|
|
22
|
+
ArrayListSchema.defaultProps = {
|
|
23
|
+
errors: null,
|
|
24
|
+
required: false
|
|
25
|
+
};
|
|
26
|
+
export default ArrayListSchema;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ArrayListSchema';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ArrayListSchema';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ArrayModel } from '../../../../dynamic-flow-types';
|
|
3
|
+
import { MultipleFileUploadSchema as MultipleFileUploadSchemaType } from '../../../../dynamic-flow-types/Schema';
|
|
4
|
+
import { GenericSchemaProps } from '../../../genericSchema/GenericSchema';
|
|
5
|
+
declare const MultipleFileUploadSchema: {
|
|
6
|
+
(props: Props): JSX.Element;
|
|
7
|
+
defaultProps: {
|
|
8
|
+
errors: null;
|
|
9
|
+
required: boolean;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
type Props = Omit<GenericSchemaProps, 'model'> & {
|
|
13
|
+
schema: MultipleFileUploadSchemaType;
|
|
14
|
+
model: ArrayModel | null;
|
|
15
|
+
required?: boolean;
|
|
16
|
+
errors?: string | null;
|
|
17
|
+
};
|
|
18
|
+
export default MultipleFileUploadSchema;
|
|
@@ -0,0 +1,141 @@
|
|
|
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
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
49
|
+
import { Status, UploadInput } from '@transferwise/components';
|
|
50
|
+
import { isNumber, isString } from '@transferwise/neptune-validation';
|
|
51
|
+
import classNames from 'classnames';
|
|
52
|
+
import { useMemo, useState } from 'react';
|
|
53
|
+
import { usePersistAsync } from '../../../../common/hooks/usePersistAsync';
|
|
54
|
+
import { useTracking } from '../../../../common/tracking';
|
|
55
|
+
import { areFilesSame, toKilobytes } from '../../../../common/utils/file-utils';
|
|
56
|
+
import { generateRandomId } from '../../../../common/utils/generate-random-id';
|
|
57
|
+
import { filterOutNull } from '../../../../common/validation/valid-model/utils';
|
|
58
|
+
import { getArrayValidationFailures } from '../../../../common/validation/validation-failures';
|
|
59
|
+
import { isBlobSchema, } from '../../../../dynamic-flow-types/Schema';
|
|
60
|
+
import ControlFeedback from '../../../controlFeedback';
|
|
61
|
+
import { useFormattedDefaultErrorMessages } from './useFormattedDefaultErrorMessages';
|
|
62
|
+
import { constructUploadResponse, constructUploadError, createPayload } from './utils';
|
|
63
|
+
var MultipleFileUploadSchema = function (props) {
|
|
64
|
+
var _a, _b;
|
|
65
|
+
var onChange = props.onChange, schema = props.schema;
|
|
66
|
+
var trackEvent = useTracking();
|
|
67
|
+
var defaultErrorMessages = useFormattedDefaultErrorMessages(schema);
|
|
68
|
+
var uid = useMemo(function () { return schema.$id || generateRandomId(); }, [schema.$id]);
|
|
69
|
+
var _c = useState(false), inputChanged = _c[0], setInputChanged = _c[1];
|
|
70
|
+
var _d = useState(function () { return convertFileIdsToComponentFileObjects(props.model || []); }), files = _d[0], setFiles = _d[1];
|
|
71
|
+
var performPersistAsync = usePersistAsync(schema.items.persistAsync);
|
|
72
|
+
var fileSchemaDescriptor = schema.items.persistAsync.schema;
|
|
73
|
+
var isBlob = isBlobSchema(fileSchemaDescriptor);
|
|
74
|
+
var uploadFile = function (userUploadedFile) { return __awaiter(void 0, void 0, void 0, function () {
|
|
75
|
+
var payload, response, error_1;
|
|
76
|
+
return __generator(this, function (_a) {
|
|
77
|
+
switch (_a.label) {
|
|
78
|
+
case 0:
|
|
79
|
+
setInputChanged(true);
|
|
80
|
+
_a.label = 1;
|
|
81
|
+
case 1:
|
|
82
|
+
_a.trys.push([1, 4, , 5]);
|
|
83
|
+
return [4 /*yield*/, createPayload(userUploadedFile, isBlob)];
|
|
84
|
+
case 2:
|
|
85
|
+
payload = _a.sent();
|
|
86
|
+
trackEvent('Dynamic Flow - PersistAsync', { status: 'pending', schemaId: schema.$id });
|
|
87
|
+
return [4 /*yield*/, performPersistAsync(payload)];
|
|
88
|
+
case 3:
|
|
89
|
+
response = _a.sent();
|
|
90
|
+
trackEvent('Dynamic Flow - PersistAsync', { status: 'success', schemaId: schema.$id });
|
|
91
|
+
return [2 /*return*/, constructUploadResponse(response)];
|
|
92
|
+
case 4:
|
|
93
|
+
error_1 = _a.sent();
|
|
94
|
+
trackEvent('Dynamic Flow - PersistAsync', { status: 'failure', schemaId: schema.$id });
|
|
95
|
+
return [2 /*return*/, Promise.reject(constructUploadError(error_1))];
|
|
96
|
+
case 5: return [2 /*return*/];
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}); };
|
|
100
|
+
function onFilesChange(newFiles) {
|
|
101
|
+
if (areFilesSame(newFiles, files)) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
setFiles(newFiles);
|
|
105
|
+
var validFiles = getSuccessfullyProcessedFiles(newFiles);
|
|
106
|
+
var data = validFiles.map(function (file) { return file.id; });
|
|
107
|
+
onChange({
|
|
108
|
+
model: data,
|
|
109
|
+
triggerSchema: schema,
|
|
110
|
+
triggerModel: data
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
var validFiles = getSuccessfullyProcessedFiles(files);
|
|
114
|
+
var fileIds = validFiles.map(function (file) { return file.id; });
|
|
115
|
+
var fileListValidationFailures = getArrayValidationFailures(fileIds, schema, props.required);
|
|
116
|
+
var showError = Boolean(props.errors) ||
|
|
117
|
+
((inputChanged || props.submitted) && Boolean(fileListValidationFailures.length));
|
|
118
|
+
var accepts = 'accepts' in fileSchemaDescriptor && fileSchemaDescriptor.accepts;
|
|
119
|
+
var maxSize = 'maxSize' in fileSchemaDescriptor && fileSchemaDescriptor.maxSize;
|
|
120
|
+
var uploadInputProps = __assign(__assign(__assign({ multiple: true, className: 'form-control', files: files, fileInputName: uid, id: uid }, (accepts ? { fileTypes: accepts } : undefined)), (maxSize ? { sizeLimit: toKilobytes(maxSize) } : undefined)), { sizeLimitErrorMessage: ((_a = fileSchemaDescriptor.validationMessages) === null || _a === void 0 ? void 0 : _a.maxSize) ||
|
|
121
|
+
defaultErrorMessages.maxFileSizeErrorMessage, maxFiles: props.schema.maxItems, maxFilesErrorMessage: ((_b = props.schema.validationMessages) === null || _b === void 0 ? void 0 : _b.maxItems) || defaultErrorMessages.maxItemsErrorMessage, uploadButtonTitle: fileSchemaDescriptor.title, description: fileSchemaDescriptor.description, disabled: props.disabled, onUploadFile: function (formData) { return uploadFile(formData.get(uid)); }, onFilesChange: onFilesChange, onDeleteFile: function () { return Promise.resolve(); } });
|
|
122
|
+
return (_jsxs("div", __assign({ className: classNames('form-group', { 'has-error': showError }) }, { children: [_jsx("label", __assign({ className: "d-block control-label", htmlFor: uid }, { children: props.schema.title })), _jsx(UploadInput, __assign({}, uploadInputProps)), _jsx(ControlFeedback, { changed: inputChanged, submitted: props.submitted, errors: props.errors, schema: props.schema, validations: fileListValidationFailures, validationMessages: getValidationMessages(schema, Boolean(props.required), defaultErrorMessages), infoMessage: null, focused: false, blurred: true })] })));
|
|
123
|
+
};
|
|
124
|
+
MultipleFileUploadSchema.defaultProps = {
|
|
125
|
+
errors: null,
|
|
126
|
+
required: false
|
|
127
|
+
};
|
|
128
|
+
export default MultipleFileUploadSchema;
|
|
129
|
+
function getSuccessfullyProcessedFiles(allFiles) {
|
|
130
|
+
return allFiles.filter(function (file) { return !file.error && file.status === 'succeeded'; });
|
|
131
|
+
}
|
|
132
|
+
function convertFileIdsToComponentFileObjects(fileIds) {
|
|
133
|
+
return filterOutNull(fileIds.map(function (id) { return (isValidId(id) ? { id: id, status: Status.SUCCEEDED } : null); }));
|
|
134
|
+
}
|
|
135
|
+
function isValidId(id) {
|
|
136
|
+
return isNumber(id) || isString(id);
|
|
137
|
+
}
|
|
138
|
+
function getValidationMessages(schema, required, defaultErrorMessages) {
|
|
139
|
+
var minItems = schema.minItems, maxItems = schema.maxItems;
|
|
140
|
+
return __assign(__assign(__assign({}, (required && { required: defaultErrorMessages.requiredMessage })), (minItems && { minItems: defaultErrorMessages.minItemsErrorMessage })), (maxItems && { maxItems: defaultErrorMessages.maxItemsErrorMessage }));
|
|
141
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
declare namespace _default {
|
|
2
|
+
namespace minItemsError {
|
|
3
|
+
const id: string;
|
|
4
|
+
const defaultMessage: string;
|
|
5
|
+
const description: string;
|
|
6
|
+
}
|
|
7
|
+
namespace maxItemsError {
|
|
8
|
+
const id_1: string;
|
|
9
|
+
export { id_1 as id };
|
|
10
|
+
const defaultMessage_1: string;
|
|
11
|
+
export { defaultMessage_1 as defaultMessage };
|
|
12
|
+
const description_1: string;
|
|
13
|
+
export { description_1 as description };
|
|
14
|
+
}
|
|
15
|
+
namespace maxFileSizeError {
|
|
16
|
+
const id_2: string;
|
|
17
|
+
export { id_2 as id };
|
|
18
|
+
const defaultMessage_2: string;
|
|
19
|
+
export { defaultMessage_2 as defaultMessage };
|
|
20
|
+
const description_2: string;
|
|
21
|
+
export { description_2 as description };
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export default _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl';
|
|
2
|
+
export default defineMessages({
|
|
3
|
+
minItemsError: {
|
|
4
|
+
id: 'dynamicFlows.MultipleFileUploadSchema.minItemsError',
|
|
5
|
+
defaultMessage: 'Please upload at least {minItems} file(s).',
|
|
6
|
+
description: 'Customer has uploaded not enough files. To fix: upload more files.'
|
|
7
|
+
},
|
|
8
|
+
maxItemsError: {
|
|
9
|
+
id: 'dynamicFlows.MultipleFileUploadSchema.maxItemsError',
|
|
10
|
+
defaultMessage: 'Please upload {maxItems} or fewer files.',
|
|
11
|
+
description: 'Customer has uploaded too many files. To fix: upload fewer files.'
|
|
12
|
+
},
|
|
13
|
+
maxFileSizeError: {
|
|
14
|
+
id: 'dynamicFlows.MultipleFileUploadSchema.maxFileSizeError',
|
|
15
|
+
defaultMessage: 'Sorry, that file is too big. Please upload a smaller file.',
|
|
16
|
+
description: "Customer has uploaded a file that's too big. To fix: upload a smaller file."
|
|
17
|
+
}
|
|
18
|
+
});
|
package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './MultipleFileUploadSchema';
|
package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './MultipleFileUploadSchema';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function useFormattedDefaultErrorMessages({ maxItems, minItems, }: {
|
|
2
|
+
maxItems?: number;
|
|
3
|
+
minItems?: number;
|
|
4
|
+
}): {
|
|
5
|
+
maxFileSizeErrorMessage: string;
|
|
6
|
+
maxItemsErrorMessage: string;
|
|
7
|
+
minItemsErrorMessage: string;
|
|
8
|
+
requiredMessage: string;
|
|
9
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useIntl } from 'react-intl';
|
|
2
|
+
import CommonMessages from '../../../../common/messages';
|
|
3
|
+
import MultiFileUploadMessages from './MultipleFileUploadSchema.messages';
|
|
4
|
+
export function useFormattedDefaultErrorMessages(_a) {
|
|
5
|
+
var maxItems = _a.maxItems, minItems = _a.minItems;
|
|
6
|
+
var formatMessage = useIntl().formatMessage;
|
|
7
|
+
var maxFileSizeError = MultiFileUploadMessages.maxFileSizeError, maxItemsError = MultiFileUploadMessages.maxItemsError, minItemsError = MultiFileUploadMessages.minItemsError;
|
|
8
|
+
return {
|
|
9
|
+
maxFileSizeErrorMessage: formatMessage(maxFileSizeError),
|
|
10
|
+
maxItemsErrorMessage: formatMessage(maxItemsError, { maxItems: maxItems }),
|
|
11
|
+
minItemsErrorMessage: formatMessage(minItemsError, { minItems: minItems }),
|
|
12
|
+
requiredMessage: formatMessage(CommonMessages.required)
|
|
13
|
+
};
|
|
14
|
+
}
|
package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { UploadError, UploadResponse } from '@transferwise/components';
|
|
2
|
+
export declare function createPayload(userUploadedFile: Blob | string | null, isBlobSchema: boolean): Promise<string | Blob | null>;
|
|
3
|
+
export declare function constructUploadResponse(response: {
|
|
4
|
+
data: string | number;
|
|
5
|
+
}): UploadResponse;
|
|
6
|
+
export declare function constructUploadError(response: unknown): UploadError | undefined;
|
package/build/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/utils.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
import { isObject, isString } from '@transferwise/neptune-validation';
|
|
49
|
+
import { toBase64 } from '../../../../common/utils/file-utils';
|
|
50
|
+
import { generateRandomId } from '../../../../common/utils/generate-random-id';
|
|
51
|
+
export function createPayload(userUploadedFile, isBlobSchema) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
53
|
+
return __generator(this, function (_a) {
|
|
54
|
+
if (isBlobSchema) {
|
|
55
|
+
return [2 /*return*/, userUploadedFile];
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
if (userUploadedFile instanceof Blob) {
|
|
59
|
+
return [2 /*return*/, toBase64(userUploadedFile)];
|
|
60
|
+
}
|
|
61
|
+
throw new Error('Error creating payload for MultipleFileUploadSchema. Uploaded file is not an instance of Blob.');
|
|
62
|
+
}
|
|
63
|
+
return [2 /*return*/];
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
export function constructUploadResponse(response) {
|
|
68
|
+
var id = response.data;
|
|
69
|
+
return __assign({ id: id }, response);
|
|
70
|
+
}
|
|
71
|
+
export function constructUploadError(response) {
|
|
72
|
+
var isError = response instanceof Error;
|
|
73
|
+
var hasValidData = isObject(response) && 'data' in response;
|
|
74
|
+
var isInvalidResponseData = !hasValidData && !isError;
|
|
75
|
+
if (isInvalidResponseData) {
|
|
76
|
+
return isString(response) ? response : undefined;
|
|
77
|
+
}
|
|
78
|
+
if (isError) {
|
|
79
|
+
var error = response;
|
|
80
|
+
return { id: generateRandomId(), message: error.message };
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
return __assign({ message: isString(response.message) ? response.message : '' }, response);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ArraySchema';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BasicModel, BasicSchema } from '../../dynamic-flow-types';
|
|
3
|
+
import { OnChange } from '../JsonSchemaForm';
|
|
4
|
+
import { GenericSchemaProps } from '../genericSchema/GenericSchema';
|
|
5
|
+
declare const BasicTypeSchema: {
|
|
6
|
+
(props: BasicTypeSchemaProps): JSX.Element | null;
|
|
7
|
+
defaultProps: {
|
|
8
|
+
required: boolean;
|
|
9
|
+
disabled: boolean;
|
|
10
|
+
onBlur: null;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export type BasicTypeSchemaProps = Omit<GenericSchemaProps, 'schema' | 'model' | 'onChange' | 'errors' | 'onPersistAsync'> & {
|
|
14
|
+
schema: BasicSchema;
|
|
15
|
+
model: BasicModel | null;
|
|
16
|
+
errors: string | null;
|
|
17
|
+
required?: boolean;
|
|
18
|
+
infoMessage: string | null;
|
|
19
|
+
onBlur?: () => void;
|
|
20
|
+
onChange: OnChange;
|
|
21
|
+
};
|
|
22
|
+
export default BasicTypeSchema;
|
|
@@ -0,0 +1,105 @@
|
|
|
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, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
+
import { isNull, isUndefined } from '@transferwise/neptune-validation';
|
|
14
|
+
import classNames from 'classnames';
|
|
15
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
16
|
+
import { generateRandomId } from '../../common/utils/generate-random-id';
|
|
17
|
+
import { getValidBasicModelOrNull } from '../../common/validation/valid-model';
|
|
18
|
+
import { getValidationFailures } from '../../common/validation/validation-failures';
|
|
19
|
+
import DynamicAlert from '../../layout/alert';
|
|
20
|
+
import ControlFeedback from '../controlFeedback';
|
|
21
|
+
import Help from '../help';
|
|
22
|
+
import SchemaFormControl from '../schemaFormControl';
|
|
23
|
+
var isNullish = function (value) {
|
|
24
|
+
return isNull(value) || isUndefined(value);
|
|
25
|
+
};
|
|
26
|
+
var getDefaultValue = function (schema) {
|
|
27
|
+
return schema.type === 'boolean' && isNullish(schema["default"]) ? false : schema["default"];
|
|
28
|
+
};
|
|
29
|
+
var BasicTypeSchema = function (props) {
|
|
30
|
+
var _a, _b, _c;
|
|
31
|
+
var onChange = function (newModel) {
|
|
32
|
+
setChanged(true);
|
|
33
|
+
setModelAndBroadcast(sanitiseModel(newModel), 'user');
|
|
34
|
+
};
|
|
35
|
+
var getValidationKeys = function (newModel) {
|
|
36
|
+
return getValidationFailures(newModel, props.schema, props.required);
|
|
37
|
+
}; // TODO: LOW avoid type assertion
|
|
38
|
+
var setModelAndBroadcast = function (newModel, type) {
|
|
39
|
+
setModel(newModel);
|
|
40
|
+
var validationKeys = getValidationKeys(newModel);
|
|
41
|
+
setValidations(validationKeys);
|
|
42
|
+
var broadcastModel = newModel;
|
|
43
|
+
setLastModel(broadcastModel);
|
|
44
|
+
if (broadcastModel !== lastModel) {
|
|
45
|
+
props.onChange({
|
|
46
|
+
model: broadcastModel,
|
|
47
|
+
triggerSchema: props.schema,
|
|
48
|
+
triggerModel: broadcastModel,
|
|
49
|
+
lastTriggerModel: lastModel,
|
|
50
|
+
type: type
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
var sanitiseModel = function (newModel) {
|
|
55
|
+
return getValidBasicModelOrNull(newModel, props.schema);
|
|
56
|
+
};
|
|
57
|
+
var onFocus = function () { return setFocused(true); };
|
|
58
|
+
var onBlur = function () {
|
|
59
|
+
setFocused(false);
|
|
60
|
+
setBlurred(true);
|
|
61
|
+
if (props.onBlur) {
|
|
62
|
+
props.onBlur();
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
var _d = useState((_a = props.model) !== null && _a !== void 0 ? _a : null), model = _d[0], setModel = _d[1];
|
|
66
|
+
var _e = useState((_b = props.model) !== null && _b !== void 0 ? _b : null), lastModel = _e[0], setLastModel = _e[1];
|
|
67
|
+
var _f = useState(false), changed = _f[0], setChanged = _f[1];
|
|
68
|
+
var _g = useState(false), focused = _g[0], setFocused = _g[1];
|
|
69
|
+
var _h = useState(false), blurred = _h[0], setBlurred = _h[1];
|
|
70
|
+
var _j = useState([]), validations = _j[0], setValidations = _j[1];
|
|
71
|
+
var id = useMemo(function () { return props.schema.$id || generateRandomId(); }, [props.schema.$id]);
|
|
72
|
+
var onSchemaChange = function () {
|
|
73
|
+
var defaultValue = getDefaultValue(props.schema);
|
|
74
|
+
// if no model, change to the default, only run this when the schema changes
|
|
75
|
+
if (isNullish(model) && !isNullish(defaultValue)) {
|
|
76
|
+
setModelAndBroadcast(defaultValue, 'init');
|
|
77
|
+
}
|
|
78
|
+
if (props.schema["const"]) {
|
|
79
|
+
setModelAndBroadcast(props.schema["const"], 'init');
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
var refreshValidations = function () {
|
|
83
|
+
setValidations(getValidationKeys(model));
|
|
84
|
+
};
|
|
85
|
+
var isConst = props.schema["const"];
|
|
86
|
+
var isHidden = props.schema.hidden || isConst;
|
|
87
|
+
useEffect(refreshValidations, [props.model, props.submitted]);
|
|
88
|
+
useEffect(onSchemaChange, [props.schema]);
|
|
89
|
+
useEffect(function () { var _a; return setModel((_a = props.model) !== null && _a !== void 0 ? _a : null); }, [props.model]);
|
|
90
|
+
var formGroupClasses = {
|
|
91
|
+
'form-group': true,
|
|
92
|
+
'has-error': ((props.submitted || !changed) && !!props.errors) ||
|
|
93
|
+
((props.submitted || (changed && blurred)) && !!validations.length),
|
|
94
|
+
'has-info': (focused && !!props.schema.description) || !!props.infoMessage
|
|
95
|
+
};
|
|
96
|
+
var showLabel = props.schema.format !== 'file' && props.schema.type !== 'boolean';
|
|
97
|
+
var schemaHelp = props.schema.help;
|
|
98
|
+
return !isHidden ? (_jsxs(_Fragment, { children: [props.schema.alert && _jsx(DynamicAlert, { component: props.schema.alert }), _jsxs("div", __assign({ className: classNames(formGroupClasses) }, { children: [showLabel && (_jsxs("div", __assign({ className: "d-inline-block" }, { children: [_jsx("label", __assign({ className: "control-label d-inline", htmlFor: id }, { children: props.schema.title })), !!schemaHelp && _jsx(Help, { help: schemaHelp })] }))), !showLabel && !!schemaHelp && _jsx(Help, { help: schemaHelp }), _jsx(SchemaFormControl, { id: id, schema: props.schema, value: model, disabled: !!props.disabled, onChange: onChange, onFocus: onFocus, onBlur: onBlur }), _jsx(ControlFeedback, { changed: changed, focused: focused, blurred: blurred, submitted: props.submitted, errors: (_c = props.errors) !== null && _c !== void 0 ? _c : null, schema: props.schema, validations: validations, infoMessage: props.infoMessage })] }))] })) : null;
|
|
99
|
+
};
|
|
100
|
+
BasicTypeSchema.defaultProps = {
|
|
101
|
+
required: false,
|
|
102
|
+
disabled: false,
|
|
103
|
+
onBlur: null
|
|
104
|
+
};
|
|
105
|
+
export default BasicTypeSchema;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './BasicTypeSchema';
|