@lifesg/web-frontend-engine 2.2.4 → 2.2.5
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/chunks/file-upload-manager.817b80cc.js +2 -0
- package/chunks/file-upload-manager.817b80cc.js.map +1 -0
- package/chunks/{index.ac3b6195.js → index.44b5e2a5.js} +10 -10
- package/chunks/{index.ac3b6195.js.map → index.44b5e2a5.js.map} +1 -1
- package/chunks/{index.a24b1857.js → index.51ad1607.js} +2 -2
- package/chunks/{index.a24b1857.js.map → index.51ad1607.js.map} +1 -1
- package/chunks/{index.8edac70b.js → index.f1de2e77.js} +2 -2
- package/chunks/{index.8edac70b.js.map → index.f1de2e77.js.map} +1 -1
- package/chunks/{location-modal.6475a4db.js → location-modal.1859f93a.js} +2 -2
- package/chunks/{location-modal.6475a4db.js.map → location-modal.1859f93a.js.map} +1 -1
- package/cjs/chunks/file-upload-manager.85af8429.js +2 -0
- package/cjs/chunks/file-upload-manager.85af8429.js.map +1 -0
- package/cjs/chunks/{index.d136a8bd.js → index.48f1a1f1.js} +2 -2
- package/cjs/chunks/{index.d136a8bd.js.map → index.48f1a1f1.js.map} +1 -1
- package/cjs/chunks/{index.6a929030.js → index.c2370225.js} +7 -7
- package/cjs/chunks/{index.6a929030.js.map → index.c2370225.js.map} +1 -1
- package/cjs/chunks/{index.6e0e20f7.js → index.efc005fc.js} +2 -2
- package/cjs/chunks/{index.6e0e20f7.js.map → index.efc005fc.js.map} +1 -1
- package/cjs/chunks/{location-modal.e5989ca3.js → location-modal.6885ccea.js} +2 -2
- package/cjs/chunks/{location-modal.e5989ca3.js.map → location-modal.6885ccea.js.map} +1 -1
- package/cjs/index.js +1 -1
- package/components/custom/array-field/array-field-element.d.ts +10 -11
- package/components/custom/array-field/array-field.d.ts +3 -3
- package/components/custom/array-field/array-field.styles.d.ts +22 -23
- package/components/custom/array-field/index.d.ts +2 -2
- package/components/custom/array-field/types.d.ts +39 -39
- package/components/custom/filter/filter/filter.d.ts +3 -3
- package/components/custom/filter/filter/types.d.ts +12 -12
- package/components/custom/filter/filter-checkbox/filter-checkbox.d.ts +3 -3
- package/components/custom/filter/filter-checkbox/types.d.ts +23 -23
- package/components/custom/filter/filter-helper.d.ts +8 -8
- package/components/custom/filter/filter-item/filter-item.d.ts +3 -3
- package/components/custom/filter/filter-item/types.d.ts +13 -13
- package/components/custom/filter/index.d.ts +3 -3
- package/components/custom/filter/types.d.ts +11 -11
- package/components/custom/iframe/iframe.d.ts +3 -3
- package/components/custom/iframe/index.d.ts +2 -2
- package/components/custom/iframe/types.d.ts +28 -29
- package/components/custom/index.d.ts +6 -6
- package/components/custom/review/index.d.ts +2 -2
- package/components/custom/review/review.d.ts +3 -3
- package/components/custom/review/review.styles.d.ts +12 -13
- package/components/custom/review/types.d.ts +60 -60
- package/components/custom/timeline/index.d.ts +2 -2
- package/components/custom/timeline/timeline.d.ts +3 -3
- package/components/custom/timeline/types.d.ts +19 -19
- package/components/custom/types.d.ts +87 -87
- package/components/elements/accordion/accordion.d.ts +6 -6
- package/components/elements/accordion/accordion.styles.d.ts +1 -2
- package/components/elements/accordion/index.d.ts +2 -2
- package/components/elements/accordion/types.d.ts +27 -27
- package/components/elements/alert/alert.d.ts +3 -3
- package/components/elements/alert/index.d.ts +2 -2
- package/components/elements/alert/types.d.ts +9 -10
- package/components/elements/divider/divider.d.ts +3 -3
- package/components/elements/divider/index.d.ts +2 -2
- package/components/elements/divider/types.d.ts +6 -6
- package/components/elements/grid/grid.d.ts +3 -3
- package/components/elements/grid/index.d.ts +2 -2
- package/components/elements/grid/types.d.ts +11 -11
- package/components/elements/index.d.ts +9 -9
- package/components/elements/list/data.d.ts +3 -3
- package/components/elements/list/index.d.ts +3 -3
- package/components/elements/list/list-item.d.ts +3 -3
- package/components/elements/list/list.d.ts +3 -3
- package/components/elements/list/types.d.ts +17 -17
- package/components/elements/popover/index.d.ts +2 -2
- package/components/elements/popover/popover.d.ts +3 -3
- package/components/elements/popover/types.d.ts +15 -15
- package/components/elements/section/index.d.ts +2 -2
- package/components/elements/section/section.d.ts +2 -2
- package/components/elements/section/section.styles.d.ts +11 -12
- package/components/elements/section/types.d.ts +16 -16
- package/components/elements/sections/index.d.ts +1 -1
- package/components/elements/sections/sections.d.ts +13 -13
- package/components/elements/tab/index.d.ts +2 -2
- package/components/elements/tab/tab.d.ts +3 -3
- package/components/elements/tab/types.d.ts +23 -23
- package/components/elements/text/data.d.ts +121 -122
- package/components/elements/text/index.d.ts +2 -2
- package/components/elements/text/text.d.ts +3 -3
- package/components/elements/text/types.d.ts +18 -18
- package/components/elements/types.d.ts +97 -97
- package/components/elements/wrapper/col-wrapper.d.ts +12 -12
- package/components/elements/wrapper/conditional-renderer.d.ts +16 -16
- package/components/elements/wrapper/field-wrapper.d.ts +9 -10
- package/components/elements/wrapper/index.d.ts +2 -2
- package/components/elements/wrapper/types.d.ts +29 -30
- package/components/elements/wrapper/wrapper.d.ts +2 -3
- package/components/fields/button/button.d.ts +3 -3
- package/components/fields/button/index.d.ts +2 -2
- package/components/fields/button/types.d.ts +17 -17
- package/components/fields/checkbox-group/checkbox-group.d.ts +3 -3
- package/components/fields/checkbox-group/checkbox-group.styles.d.ts +23 -24
- package/components/fields/checkbox-group/index.d.ts +2 -2
- package/components/fields/checkbox-group/types.d.ts +33 -33
- package/components/fields/chips/chips.d.ts +3 -3
- package/components/fields/chips/chips.styles.d.ts +5 -6
- package/components/fields/chips/index.d.ts +2 -2
- package/components/fields/chips/types.d.ts +18 -19
- package/components/fields/contact-field/contact-field.d.ts +3 -3
- package/components/fields/contact-field/data.d.ts +6 -6
- package/components/fields/contact-field/index.d.ts +2 -2
- package/components/fields/contact-field/types.d.ts +31 -31
- package/components/fields/contact-field/utils.d.ts +7 -7
- package/components/fields/date-field/date-field.d.ts +3 -3
- package/components/fields/date-field/index.d.ts +2 -2
- package/components/fields/date-field/types.d.ts +20 -20
- package/components/fields/date-range-field/date-range-field.d.ts +3 -3
- package/components/fields/date-range-field/index.d.ts +2 -2
- package/components/fields/date-range-field/types.d.ts +32 -32
- package/components/fields/e-signature-field/e-signature-field.d.ts +3 -3
- package/components/fields/e-signature-field/e-signature-field.styles.d.ts +4 -5
- package/components/fields/e-signature-field/index.d.ts +2 -2
- package/components/fields/e-signature-field/types.d.ts +22 -22
- package/components/fields/error-field/error-field.d.ts +3 -3
- package/components/fields/error-field/index.d.ts +2 -2
- package/components/fields/error-field/types.d.ts +11 -11
- package/components/fields/file-upload/file-upload-context.d.ts +14 -14
- package/components/fields/file-upload/file-upload-helper.d.ts +10 -10
- package/components/fields/file-upload/file-upload-manager.d.ts +14 -14
- package/components/fields/file-upload/file-upload.d.ts +4 -4
- package/components/fields/file-upload/index.d.ts +2 -2
- package/components/fields/file-upload/types.d.ts +78 -78
- package/components/fields/hidden-field/hidden-field.d.ts +3 -3
- package/components/fields/hidden-field/index.d.ts +2 -2
- package/components/fields/hidden-field/types.d.ts +29 -29
- package/components/fields/histogram-slider/histogram-slider.d.ts +3 -3
- package/components/fields/histogram-slider/index.d.ts +2 -2
- package/components/fields/histogram-slider/types.d.ts +20 -20
- package/components/fields/image-upload/image-context/image-context.d.ts +16 -16
- package/components/fields/image-upload/image-context/index.d.ts +1 -1
- package/components/fields/image-upload/image-input/drag-upload/drag-upload.d.ts +2 -3
- package/components/fields/image-upload/image-input/drag-upload/drag-upload.styles.d.ts +14 -15
- package/components/fields/image-upload/image-input/drag-upload/index.d.ts +2 -2
- package/components/fields/image-upload/image-input/drag-upload/types.d.ts +15 -16
- package/components/fields/image-upload/image-input/file-item/file-item.d.ts +11 -11
- package/components/fields/image-upload/image-input/file-item/file-item.styles.d.ts +48 -49
- package/components/fields/image-upload/image-input/file-item/index.d.ts +1 -1
- package/components/fields/image-upload/image-input/image-input.d.ts +26 -26
- package/components/fields/image-upload/image-input/image-input.styles.d.ts +47 -48
- package/components/fields/image-upload/image-input/index.d.ts +1 -1
- package/components/fields/image-upload/image-manager/image-manager.d.ts +25 -25
- package/components/fields/image-upload/image-manager/index.d.ts +2 -2
- package/components/fields/image-upload/image-review/image-editor/image-editor.d.ts +2 -3
- package/components/fields/image-upload/image-review/image-editor/image-editor.styles.d.ts +6 -7
- package/components/fields/image-upload/image-review/image-editor/index.d.ts +3 -3
- package/components/fields/image-upload/image-review/image-editor/types.d.ts +17 -17
- package/components/fields/image-upload/image-review/image-error/image-error.d.ts +10 -10
- package/components/fields/image-upload/image-review/image-error/image-error.styles.d.ts +31 -32
- package/components/fields/image-upload/image-review/image-error/index.d.ts +1 -1
- package/components/fields/image-upload/image-review/image-prompts/image-prompts.d.ts +11 -11
- package/components/fields/image-upload/image-review/image-prompts/index.d.ts +1 -1
- package/components/fields/image-upload/image-review/image-review.d.ts +18 -18
- package/components/fields/image-upload/image-review/image-review.styles.d.ts +128 -129
- package/components/fields/image-upload/image-review/image-thumbnails/image-thumbnails.d.ts +11 -11
- package/components/fields/image-upload/image-review/image-thumbnails/image-thumbnails.styles.d.ts +29 -30
- package/components/fields/image-upload/image-review/image-thumbnails/index.d.ts +1 -1
- package/components/fields/image-upload/image-review/index.d.ts +1 -1
- package/components/fields/image-upload/image-upload-helper.d.ts +12 -10
- package/components/fields/image-upload/image-upload.d.ts +4 -4
- package/components/fields/image-upload/index.d.ts +2 -2
- package/components/fields/image-upload/types.d.ts +151 -151
- package/components/fields/index.d.ts +30 -30
- package/components/fields/location-field/index.d.ts +2 -2
- package/components/fields/location-field/location-field.d.ts +3 -3
- package/components/fields/location-field/location-helper.d.ts +38 -39
- package/components/fields/location-field/location-input/dummy-location-field.d.ts +13 -14
- package/components/fields/location-field/location-input/index.d.ts +1 -1
- package/components/fields/location-field/location-input/location-input.d.ts +6 -7
- package/components/fields/location-field/location-input/location-input.styles.d.ts +22 -23
- package/components/fields/location-field/location-modal/infinite-scroll/index.d.ts +1 -1
- package/components/fields/location-field/location-modal/infinite-scroll/infinite-scroll.d.ts +11 -12
- package/components/fields/location-field/location-modal/infinite-scroll/infinite-scroll.style.d.ts +1 -2
- package/components/fields/location-field/location-modal/infinite-scroll/loading-indicator/config.d.ts +5 -5
- package/components/fields/location-field/location-modal/infinite-scroll/loading-indicator/index.d.ts +1 -1
- package/components/fields/location-field/location-modal/infinite-scroll/loading-indicator/loading-indicator.d.ts +5 -5
- package/components/fields/location-field/location-modal/infinite-scroll/loading-indicator/loading-indicator.styles.d.ts +2 -3
- package/components/fields/location-field/location-modal/location-modal.d.ts +8 -8
- package/components/fields/location-field/location-modal/location-modal.data.d.ts +3 -3
- package/components/fields/location-field/location-modal/location-modal.styles.d.ts +16 -17
- package/components/fields/location-field/location-modal/location-picker/helper.d.ts +4 -4
- package/components/fields/location-field/location-modal/location-picker/index.d.ts +1 -1
- package/components/fields/location-field/location-modal/location-picker/legend/index.d.ts +1 -1
- package/components/fields/location-field/location-modal/location-picker/legend/legend.d.ts +8 -8
- package/components/fields/location-field/location-modal/location-picker/legend/legend.styles.d.ts +10 -11
- package/components/fields/location-field/location-modal/location-picker/location-picker.d.ts +3 -3
- package/components/fields/location-field/location-modal/location-picker/location-picker.styles.d.ts +17 -18
- package/components/fields/location-field/location-modal/location-picker/types.d.ts +34 -35
- package/components/fields/location-field/location-modal/location-search/helper.d.ts +14 -14
- package/components/fields/location-field/location-modal/location-search/index.d.ts +1 -1
- package/components/fields/location-field/location-modal/location-search/location-search.d.ts +2 -2
- package/components/fields/location-field/location-modal/location-search/location-search.styles.d.ts +84 -85
- package/components/fields/location-field/location-modal/location-search/types.d.ts +30 -30
- package/components/fields/location-field/location-modal/no-network-modal/no-network-modal.d.ts +7 -7
- package/components/fields/location-field/location-modal/no-network-modal/no-network-modal.styles.d.ts +29 -30
- package/components/fields/location-field/location-modal/types.d.ts +18 -18
- package/components/fields/location-field/types.d.ts +163 -163
- package/components/fields/masked-field/index.d.ts +2 -2
- package/components/fields/masked-field/masked-field.d.ts +3 -3
- package/components/fields/masked-field/types.d.ts +12 -12
- package/components/fields/multi-select/index.d.ts +2 -2
- package/components/fields/multi-select/multi-select.d.ts +3 -3
- package/components/fields/multi-select/types.d.ts +9 -9
- package/components/fields/nested-multi-select/index.d.ts +2 -2
- package/components/fields/nested-multi-select/nested-multi-select.d.ts +3 -3
- package/components/fields/nested-multi-select/types.d.ts +33 -34
- package/components/fields/otp-verification-field/index.d.ts +2 -2
- package/components/fields/otp-verification-field/otp-verification-field.d.ts +3 -3
- package/components/fields/otp-verification-field/types.d.ts +46 -46
- package/components/fields/radio-button/index.d.ts +2 -2
- package/components/fields/radio-button/radio-button.d.ts +3 -3
- package/components/fields/radio-button/radio-button.styles.d.ts +29 -30
- package/components/fields/radio-button/types.d.ts +41 -41
- package/components/fields/range-select/index.d.ts +2 -2
- package/components/fields/range-select/range-select.d.ts +3 -3
- package/components/fields/range-select/types.d.ts +9 -9
- package/components/fields/reset-button/index.d.ts +2 -2
- package/components/fields/reset-button/reset-button.d.ts +3 -3
- package/components/fields/reset-button/types.d.ts +8 -8
- package/components/fields/select/index.d.ts +2 -2
- package/components/fields/select/select.d.ts +3 -3
- package/components/fields/select/types.d.ts +9 -9
- package/components/fields/select-histogram/index.d.ts +2 -2
- package/components/fields/select-histogram/select-histogram.d.ts +3 -3
- package/components/fields/select-histogram/types.d.ts +17 -17
- package/components/fields/slider/index.d.ts +2 -2
- package/components/fields/slider/slider.d.ts +3 -3
- package/components/fields/slider/types.d.ts +11 -11
- package/components/fields/submit-button/index.d.ts +2 -2
- package/components/fields/submit-button/submit-button.d.ts +3 -3
- package/components/fields/submit-button/types.d.ts +7 -7
- package/components/fields/switch/index.d.ts +2 -2
- package/components/fields/switch/switch.d.ts +3 -3
- package/components/fields/switch/switch.styles.d.ts +1 -2
- package/components/fields/switch/types.d.ts +10 -10
- package/components/fields/text-field/index.d.ts +2 -2
- package/components/fields/text-field/text-field.d.ts +3 -3
- package/components/fields/text-field/types.d.ts +37 -37
- package/components/fields/textarea/index.d.ts +2 -2
- package/components/fields/textarea/textarea.d.ts +3 -3
- package/components/fields/textarea/textarea.styles.d.ts +19 -20
- package/components/fields/textarea/types.d.ts +8 -8
- package/components/fields/time-field/index.d.ts +2 -2
- package/components/fields/time-field/time-field.d.ts +3 -3
- package/components/fields/time-field/types.d.ts +7 -7
- package/components/fields/types.d.ts +122 -122
- package/components/fields/unit-number-field/index.d.ts +2 -2
- package/components/fields/unit-number-field/types.d.ts +8 -8
- package/components/fields/unit-number-field/unit-number-field.d.ts +3 -3
- package/components/frontend-engine/frontend-engine.d.ts +23 -23
- package/components/frontend-engine/index.d.ts +2 -2
- package/components/frontend-engine/types.d.ts +213 -214
- package/components/frontend-engine/use-form-change.d.ts +12 -12
- package/components/index.d.ts +2 -2
- package/components/shared/chip/chip.d.ts +6 -6
- package/components/shared/chip/chip.styles.d.ts +16 -17
- package/components/shared/chip/index.d.ts +2 -2
- package/components/shared/chip/types.d.ts +4 -4
- package/components/shared/error-messages.d.ts +102 -102
- package/components/shared/index.d.ts +6 -6
- package/components/shared/prompt/index.d.ts +2 -2
- package/components/shared/prompt/prompt.d.ts +2 -2
- package/components/shared/prompt/prompt.styles.d.ts +40 -41
- package/components/shared/prompt/types.d.ts +16 -16
- package/components/shared/sanitize/index.d.ts +1 -1
- package/components/shared/sanitize/sanitize.d.ts +13 -14
- package/components/shared/static-map/index.d.ts +1 -1
- package/components/shared/static-map/static-map.d.ts +12 -12
- package/components/shared/static-map/static-map.styles.d.ts +12 -13
- package/components/shared/warning/index.d.ts +1 -1
- package/components/shared/warning/warning.d.ts +6 -6
- package/components/types.d.ts +4 -4
- package/context-providers/context-providers.d.ts +7 -7
- package/context-providers/custom-components/context-provider.d.ts +14 -14
- package/context-providers/custom-components/index.d.ts +1 -1
- package/context-providers/event/context-provider.d.ts +14 -14
- package/context-providers/event/index.d.ts +2 -2
- package/context-providers/event/types.d.ts +10 -10
- package/context-providers/form-schema/context-provider.d.ts +12 -12
- package/context-providers/form-schema/index.d.ts +1 -1
- package/context-providers/form-values/context-provider.d.ts +23 -23
- package/context-providers/form-values/index.d.ts +1 -1
- package/context-providers/frontend-engine-form/context-provider.d.ts +13 -13
- package/context-providers/frontend-engine-form/index.d.ts +1 -1
- package/context-providers/index.d.ts +7 -7
- package/context-providers/recaptcha/index.d.ts +3 -3
- package/context-providers/recaptcha/recaptcha-hook.d.ts +5 -5
- package/context-providers/recaptcha/recaptcha-provider.d.ts +10 -11
- package/context-providers/recaptcha/types.d.ts +14 -14
- package/context-providers/yup/context-provider.d.ts +16 -16
- package/context-providers/yup/custom-conditions/html-safe.d.ts +1 -1
- package/context-providers/yup/custom-conditions/index.d.ts +3 -3
- package/context-providers/yup/custom-conditions/uen.d.ts +1 -1
- package/context-providers/yup/custom-conditions/uinfin.d.ts +1 -1
- package/context-providers/yup/helper.d.ts +44 -44
- package/context-providers/yup/index.d.ts +4 -4
- package/context-providers/yup/types.d.ts +82 -82
- package/index.d.ts +3 -3
- package/index.js +1 -1
- package/package.json +1 -1
- package/services/index.d.ts +1 -1
- package/services/onemap/onemap-service.d.ts +21 -21
- package/services/onemap/types.d.ts +48 -48
- package/utils/api-client/api-client.d.ts +65 -65
- package/utils/api-client/index.d.ts +1 -1
- package/utils/date-time-helper.d.ts +22 -22
- package/utils/file-helper.d.ts +45 -47
- package/utils/geolocation-helper.d.ts +17 -17
- package/utils/hooks/index.d.ts +12 -12
- package/utils/hooks/use-custom-components.d.ts +5 -6
- package/utils/hooks/use-deep-layout-effect.d.ts +3 -3
- package/utils/hooks/use-field-event.d.ts +10 -10
- package/utils/hooks/use-form-schema.d.ts +6 -7
- package/utils/hooks/use-form-values.d.ts +11 -12
- package/utils/hooks/use-frontend-engine-component.d.ts +17 -17
- package/utils/hooks/use-frontend-engine-form.d.ts +6 -7
- package/utils/hooks/use-iframe-message.d.ts +5 -5
- package/utils/hooks/use-previous.d.ts +4 -4
- package/utils/hooks/use-validation-config.d.ts +10 -10
- package/utils/hooks/use-validation-schema.d.ts +15 -15
- package/utils/hooks/use-window-helper.d.ts +1 -1
- package/utils/id-helper.d.ts +1 -1
- package/utils/image-helper.d.ts +49 -49
- package/utils/index.d.ts +11 -11
- package/utils/math-helper.d.ts +5 -5
- package/utils/object-helper.d.ts +15 -15
- package/utils/prop-helper.d.ts +8 -8
- package/utils/test-helper.d.ts +4 -4
- package/utils/ts-helper.d.ts +1 -1
- package/utils/types.d.ts +9 -9
- package/chunks/file-upload-manager.ddb44c1f.js +0 -2
- package/chunks/file-upload-manager.ddb44c1f.js.map +0 -1
- package/cjs/chunks/file-upload-manager.b22d56d4.js +0 -2
- package/cjs/chunks/file-upload-manager.b22d56d4.js.map +0 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import * as Yup from "yup";
|
|
2
|
-
import { ObjectShape } from "yup/lib/object";
|
|
3
|
-
import { TFrontendEngineValues, TWarningPayload } from "../../components/frontend-engine/types";
|
|
4
|
-
/**
|
|
5
|
-
* Hook that handles the generation of the validationSchema
|
|
6
|
-
*/
|
|
7
|
-
export declare const useValidationSchema: () => {
|
|
8
|
-
warnings: TWarningPayload;
|
|
9
|
-
softValidationSchema: Yup.ObjectSchema<ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<ObjectShape>, import("yup/lib/object").AssertsShape<ObjectShape>>;
|
|
10
|
-
hardValidationSchema: Yup.ObjectSchema<ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<ObjectShape>, import("yup/lib/object").AssertsShape<ObjectShape>>;
|
|
11
|
-
rebuildValidationSchema: () => void;
|
|
12
|
-
performSoftValidation: (schema: Yup.ObjectSchema<ObjectShape>, data: TFrontendEngineValues) => void;
|
|
13
|
-
addWarnings: (warningPayload: TWarningPayload) => void;
|
|
14
|
-
yupId: string;
|
|
15
|
-
};
|
|
1
|
+
import * as Yup from "yup";
|
|
2
|
+
import { ObjectShape } from "yup/lib/object";
|
|
3
|
+
import { TFrontendEngineValues, TWarningPayload } from "../../components/frontend-engine/types";
|
|
4
|
+
/**
|
|
5
|
+
* Hook that handles the generation of the validationSchema
|
|
6
|
+
*/
|
|
7
|
+
export declare const useValidationSchema: () => {
|
|
8
|
+
warnings: TWarningPayload;
|
|
9
|
+
softValidationSchema: Yup.ObjectSchema<ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<ObjectShape>, import("yup/lib/object").AssertsShape<ObjectShape>>;
|
|
10
|
+
hardValidationSchema: Yup.ObjectSchema<ObjectShape, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<ObjectShape>, import("yup/lib/object").AssertsShape<ObjectShape>>;
|
|
11
|
+
rebuildValidationSchema: () => void;
|
|
12
|
+
performSoftValidation: (schema: Yup.ObjectSchema<ObjectShape>, data: TFrontendEngineValues) => void;
|
|
13
|
+
addWarnings: (warningPayload: TWarningPayload) => void;
|
|
14
|
+
yupId: string;
|
|
15
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useWindowHelper: () => () => boolean;
|
|
1
|
+
export declare const useWindowHelper: () => () => boolean;
|
package/utils/id-helper.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const generateRandomId: () => string;
|
|
1
|
+
export declare const generateRandomId: () => string;
|
package/utils/image-helper.d.ts
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import { IImageMetadata } from "../components/fields/image-upload";
|
|
2
|
-
export declare namespace ImageHelper {
|
|
3
|
-
/**
|
|
4
|
-
* convert image type
|
|
5
|
-
*/
|
|
6
|
-
export const convertBlob: (blob: File | Blob, outputMimeType?: string) => Promise<string>;
|
|
7
|
-
/**
|
|
8
|
-
* converts dataURL to HTMLImageElement
|
|
9
|
-
*/
|
|
10
|
-
export const dataUrlToImage: (dataURL: string) => Promise<HTMLImageElement>;
|
|
11
|
-
/**
|
|
12
|
-
* converts blob to HTMLImageElement
|
|
13
|
-
*/
|
|
14
|
-
export const blobToImage: (blob: Blob) => Promise<HTMLImageElement>;
|
|
15
|
-
interface IBaseResampleOptions {
|
|
16
|
-
quality?: number;
|
|
17
|
-
type?: string;
|
|
18
|
-
}
|
|
19
|
-
interface IResampleOptionsWithScale extends IBaseResampleOptions {
|
|
20
|
-
scale: number;
|
|
21
|
-
crop?: never | undefined;
|
|
22
|
-
width?: never | undefined;
|
|
23
|
-
height?: never | undefined;
|
|
24
|
-
}
|
|
25
|
-
interface IResampleOptionsWithDimensions extends IBaseResampleOptions {
|
|
26
|
-
scale?: never | undefined;
|
|
27
|
-
width: number;
|
|
28
|
-
height: number;
|
|
29
|
-
crop?: boolean | undefined;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* resamples image by rendering it on canvas
|
|
33
|
-
*/
|
|
34
|
-
export const resampleImage: (image: HTMLImageElement, options: IResampleOptionsWithScale | IResampleOptionsWithDimensions) => Promise<Blob>;
|
|
35
|
-
/**
|
|
36
|
-
* rescursively attempt to compress image till the desired filesize or lowest quality is reached
|
|
37
|
-
*
|
|
38
|
-
* fileSize is in kb
|
|
39
|
-
* optional `maxAttempts` to limit the attempts, if file size still exceeds at the end of it, return the best compressed image
|
|
40
|
-
*/
|
|
41
|
-
export const compressImage: (file: File | Blob, options: {
|
|
42
|
-
quality?: number;
|
|
43
|
-
fileSize: number;
|
|
44
|
-
attempts?: number;
|
|
45
|
-
maxAttempts?: number;
|
|
46
|
-
}) => any;
|
|
47
|
-
export const getMetadata: (file: File) => Promise<IImageMetadata>;
|
|
48
|
-
export {};
|
|
49
|
-
}
|
|
1
|
+
import { IImageMetadata } from "../components/fields/image-upload";
|
|
2
|
+
export declare namespace ImageHelper {
|
|
3
|
+
/**
|
|
4
|
+
* convert image type
|
|
5
|
+
*/
|
|
6
|
+
export const convertBlob: (blob: File | Blob, outputMimeType?: string) => Promise<string>;
|
|
7
|
+
/**
|
|
8
|
+
* converts dataURL to HTMLImageElement
|
|
9
|
+
*/
|
|
10
|
+
export const dataUrlToImage: (dataURL: string) => Promise<HTMLImageElement>;
|
|
11
|
+
/**
|
|
12
|
+
* converts blob to HTMLImageElement
|
|
13
|
+
*/
|
|
14
|
+
export const blobToImage: (blob: Blob) => Promise<HTMLImageElement>;
|
|
15
|
+
interface IBaseResampleOptions {
|
|
16
|
+
quality?: number;
|
|
17
|
+
type?: string;
|
|
18
|
+
}
|
|
19
|
+
interface IResampleOptionsWithScale extends IBaseResampleOptions {
|
|
20
|
+
scale: number;
|
|
21
|
+
crop?: never | undefined;
|
|
22
|
+
width?: never | undefined;
|
|
23
|
+
height?: never | undefined;
|
|
24
|
+
}
|
|
25
|
+
interface IResampleOptionsWithDimensions extends IBaseResampleOptions {
|
|
26
|
+
scale?: never | undefined;
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
crop?: boolean | undefined;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* resamples image by rendering it on canvas
|
|
33
|
+
*/
|
|
34
|
+
export const resampleImage: (image: HTMLImageElement, options: IResampleOptionsWithScale | IResampleOptionsWithDimensions) => Promise<Blob>;
|
|
35
|
+
/**
|
|
36
|
+
* rescursively attempt to compress image till the desired filesize or lowest quality is reached
|
|
37
|
+
*
|
|
38
|
+
* fileSize is in kb
|
|
39
|
+
* optional `maxAttempts` to limit the attempts, if file size still exceeds at the end of it, return the best compressed image
|
|
40
|
+
*/
|
|
41
|
+
export const compressImage: (file: File | Blob, options: {
|
|
42
|
+
quality?: number;
|
|
43
|
+
fileSize: number;
|
|
44
|
+
attempts?: number;
|
|
45
|
+
maxAttempts?: number;
|
|
46
|
+
}) => any;
|
|
47
|
+
export const getMetadata: (file: File) => Promise<IImageMetadata>;
|
|
48
|
+
export {};
|
|
49
|
+
}
|
package/utils/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export * from "./api-client";
|
|
2
|
-
export * from "./date-time-helper";
|
|
3
|
-
export * from "./file-helper";
|
|
4
|
-
export * from "./geolocation-helper";
|
|
5
|
-
export * from "./id-helper";
|
|
6
|
-
export * from "./image-helper";
|
|
7
|
-
export * from "./math-helper";
|
|
8
|
-
export * from "./object-helper";
|
|
9
|
-
export * from "./test-helper";
|
|
10
|
-
export * from "./types";
|
|
11
|
-
export * from "./prop-helper";
|
|
1
|
+
export * from "./api-client";
|
|
2
|
+
export * from "./date-time-helper";
|
|
3
|
+
export * from "./file-helper";
|
|
4
|
+
export * from "./geolocation-helper";
|
|
5
|
+
export * from "./id-helper";
|
|
6
|
+
export * from "./image-helper";
|
|
7
|
+
export * from "./math-helper";
|
|
8
|
+
export * from "./object-helper";
|
|
9
|
+
export * from "./test-helper";
|
|
10
|
+
export * from "./types";
|
|
11
|
+
export * from "./prop-helper";
|
package/utils/math-helper.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare namespace MathHelper {
|
|
2
|
-
const degreesToRadians: (degrees: number) => number;
|
|
3
|
-
const radiansToDegrees: (radians: number) => number;
|
|
4
|
-
const nauticalMilesToMetres: (nauticalMiles: number) => number;
|
|
5
|
-
}
|
|
1
|
+
export declare namespace MathHelper {
|
|
2
|
+
const degreesToRadians: (degrees: number) => number;
|
|
3
|
+
const radiansToDegrees: (radians: number) => number;
|
|
4
|
+
const nauticalMilesToMetres: (nauticalMiles: number) => number;
|
|
5
|
+
}
|
package/utils/object-helper.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export declare namespace ObjectHelper {
|
|
2
|
-
export const upsert: <T>(data: Record<string, T>, key: string, value: T) => Record<string, T>;
|
|
3
|
-
interface GetNestedValueByKeyOptions {
|
|
4
|
-
/** whether to skip searching at root level */
|
|
5
|
-
skipRoot?: boolean | undefined;
|
|
6
|
-
/** restrict which nested keys to find in */
|
|
7
|
-
searchIn?: string[] | undefined;
|
|
8
|
-
}
|
|
9
|
-
export const getNestedValueByKey: <T>(data: Record<string, T>, key: string, options?: GetNestedValueByKeyOptions) => Record<string, T>;
|
|
10
|
-
/**
|
|
11
|
-
* removes undefined, null, {}, []
|
|
12
|
-
*/
|
|
13
|
-
export const removeNil: (data: unknown) => any;
|
|
14
|
-
export {};
|
|
15
|
-
}
|
|
1
|
+
export declare namespace ObjectHelper {
|
|
2
|
+
export const upsert: <T>(data: Record<string, T>, key: string, value: T) => Record<string, T>;
|
|
3
|
+
interface GetNestedValueByKeyOptions {
|
|
4
|
+
/** whether to skip searching at root level */
|
|
5
|
+
skipRoot?: boolean | undefined;
|
|
6
|
+
/** restrict which nested keys to find in */
|
|
7
|
+
searchIn?: string[] | undefined;
|
|
8
|
+
}
|
|
9
|
+
export const getNestedValueByKey: <T>(data: Record<string, T>, key: string, options?: GetNestedValueByKeyOptions) => Record<string, T>;
|
|
10
|
+
/**
|
|
11
|
+
* removes undefined, null, {}, []
|
|
12
|
+
*/
|
|
13
|
+
export const removeNil: (data: unknown) => any;
|
|
14
|
+
export {};
|
|
15
|
+
}
|
package/utils/prop-helper.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
declare const COMMON_SCHEMA_PROP_KEYS: readonly ["columns", "customOptions", "label", "referenceKey", "showIf", "uiType", "validation"];
|
|
2
|
-
type CommonSchemaPropKey = (typeof COMMON_SCHEMA_PROP_KEYS)[number];
|
|
3
|
-
type ExistingCommonSchemaPropKey<T extends object> = Extract<CommonSchemaPropKey, keyof T>;
|
|
4
|
-
export declare const filterSchemaProps: <T extends object>(schema: T) => {
|
|
5
|
-
commonSchema: Pick<T, ExistingCommonSchemaPropKey<T>>;
|
|
6
|
-
customSchema: Omit<T, ExistingCommonSchemaPropKey<T>>;
|
|
7
|
-
};
|
|
8
|
-
export {};
|
|
1
|
+
declare const COMMON_SCHEMA_PROP_KEYS: readonly ["columns", "customOptions", "label", "referenceKey", "showIf", "uiType", "validation"];
|
|
2
|
+
type CommonSchemaPropKey = (typeof COMMON_SCHEMA_PROP_KEYS)[number];
|
|
3
|
+
type ExistingCommonSchemaPropKey<T extends object> = Extract<CommonSchemaPropKey, keyof T>;
|
|
4
|
+
export declare const filterSchemaProps: <T extends object>(schema: T) => {
|
|
5
|
+
commonSchema: Pick<T, ExistingCommonSchemaPropKey<T>>;
|
|
6
|
+
customSchema: Omit<T, ExistingCommonSchemaPropKey<T>>;
|
|
7
|
+
};
|
|
8
|
+
export {};
|
package/utils/test-helper.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare namespace TestHelper {
|
|
2
|
-
const generateId: (block: string, element?: string | undefined, modifier?: string | number | undefined) => string;
|
|
3
|
-
const getError: (fn: () => unknown) => any;
|
|
4
|
-
}
|
|
1
|
+
export declare namespace TestHelper {
|
|
2
|
+
const generateId: (block: string, element?: string | undefined, modifier?: string | number | undefined) => string;
|
|
3
|
+
const getError: (fn: () => unknown) => any;
|
|
4
|
+
}
|
package/utils/ts-helper.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type TDistributiveOmit<T, K extends PropertyKey> = T extends T ? Omit<T, K> : never;
|
|
1
|
+
export type TDistributiveOmit<T, K extends PropertyKey> = T extends T ? Omit<T, K> : never;
|
package/utils/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* prevents inferrence
|
|
3
|
-
* https://stackoverflow.com/questions/56687668/a-way-to-disable-type-argument-inference-in-generics
|
|
4
|
-
*/
|
|
5
|
-
export type TNoInfer<T, U> = [T][T extends U ? 0 : never];
|
|
6
|
-
export type RecursivePartial<T> = {
|
|
7
|
-
[P in keyof T]?: RecursivePartial<T[P]>;
|
|
8
|
-
};
|
|
9
|
-
export type TFieldEventListener<T = undefined> = (event: CustomEvent<T>) => void;
|
|
1
|
+
/**
|
|
2
|
+
* prevents inferrence
|
|
3
|
+
* https://stackoverflow.com/questions/56687668/a-way-to-disable-type-argument-inference-in-generics
|
|
4
|
+
*/
|
|
5
|
+
export type TNoInfer<T, U> = [T][T extends U ? 0 : never];
|
|
6
|
+
export type RecursivePartial<T> = {
|
|
7
|
+
[P in keyof T]?: RecursivePartial<T[P]>;
|
|
8
|
+
};
|
|
9
|
+
export type TFieldEventListener<T = undefined> = (event: CustomEvent<T>) => void;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{useContext as e,useRef as t,useEffect as i}from"react";import{F as s,u as a,a as r,b as l,g as o,E as n,c as m,A as p,I as c,d}from"./index.ac3b6195.js";import"react/jsx-runtime";import"@lifesg/react-design-system/theme";import"styled-components";import"@lifesg/react-design-system/markup";import"react-dom/server";import"@lifesg/react-design-system/typography";import"@lifesg/react-design-system/button";import"@lifesg/react-design-system/modal";import"@lifesg/react-design-system/alert";import"@lifesg/react-design-system/layout";import"@lifesg/react-design-system/box-container";import"@lifesg/react-design-system/divider";import"@lifesg/react-design-system/v2_media";import"@lifesg/react-design-system/text-list";import"@lifesg/react-design-system/popover-v2";import"@lifesg/react-icons";import"@lifesg/react-design-system/tab";import"@lifesg/react-icons/plus-circle-fill";import"@lifesg/react-design-system/button-with-icon";import"@lifesg/react-design-system/error-display";import"@lifesg/react-design-system/filter";import"@lifesg/react-design-system/uneditable-section";import"@lifesg/react-design-system/timeline";import"@lifesg/react-design-system/form";import"@lifesg/react-design-system/checkbox";import"@lifesg/react-design-system/toggle";import"@lifesg/react-icons/exclamation-circle-fill";import"@lifesg/react-design-system/file-upload";import"@lifesg/react-icons/cross";import"@lifesg/react-design-system/icon-button";import"@lifesg/react-icons/bin";import"@lifesg/react-icons/eraser";import"@lifesg/react-icons/pencil";import"@lifesg/react-icons/pencil-stroke";import"@lifesg/react-icons/plus";import"@lifesg/react-icons/exclamation-triangle";import"@lifesg/react-icons/pin-fill";import"@lifesg/react-design-system/image-button";import"@lifesg/react-design-system/radio-button";import"@lifesg/react-design-system/v2_layout";const f=["image/jpeg","image/gif","image/png"],g=g=>{const{compressImages:u,fileTypeRule:y,fileExtensionRule:I,hideThumbnail:w,id:F,maxFileSizeRule:E,upload:R,uploadRule:T,value:U}=g,{files:b,setFiles:h,setCurrentFileIds:D}=e(s),L=a(U),{setValue:x}=r(),{dispatchFieldEvent:O}=l(),M=t(!1),z=t(),A=e=>{M.current&&h(e)};i(()=>(M.current=!0,z.current=o(),()=>{M.current=!1}),[]),i(()=>{b.forEach(async(e,t)=>{try{switch(e.status){case n.INJECTED:await k(e,t);break;case n.NONE:await K(e,t);break;case n.UPLOAD_READY:await j(e,t);break;case n.TO_DELETE:G(t)}}catch(e){N(t)}});const e=b.filter(({status:e})=>e===n.UPLOADED),t=e.filter(({addedFrom:e})=>"schema"!==e).length>0,i=b.filter(({status:e})=>e===n.TO_DELETE).length>0,s=t||i;D(e.map(({fileItem:e})=>e.id)),x(F,e.map(({dataURL:e,fileItem:t,fileUrl:i,uploadResponse:s})=>({..."base64"===R.type?{dataURL:e}:{},fileId:t.id,fileName:t.name,fileUrl:i,uploadResponse:s})),{shouldDirty:s,shouldTouch:t})},[b.map(({fileItem:e,status:t})=>`${e?.id}-${t}`).join(",")]),i(()=>{void 0!==L&&void 0===U&&b.length&&h([])},[b,L,h,U]);const N=e=>{A(t=>{const i=[...t],s=t[e];return i[e]={...s,fileItem:{...s.fileItem,id:s.fileItem?.id||o(),name:s.rawFile.name,errorMessage:T?.errorMessage||d.UPLOAD().GENERIC},status:n.ERROR_GENERIC},i})},v=async(e,t)=>{if(!0!==w&&f.includes(t||e.fileItem?.type)){const t=await c.dataUrlToImage(e.dataURL),i=await c.resampleImage(t,{width:94,height:94,crop:!0});return await m.fileToDataUrl(i)}return""},_=async e=>{const{addedFrom:t,dataURL:i,rawFile:s}=e,a=await m.getType(s),r=P(a);if(r?.status<0)return r;if(y.fileType&&I.fileExtension){const e=S(s.name);if(e?.status<0)return{...e,fileType:a}}const l="base64"===R.type?m.getFilesizeFromBase64(i):s.size,{errorMessage:o,status:p}=C(l);return p<0?{errorMessage:o,fileType:a,status:p}:"schema"===t?{fileType:a,status:n.UPLOADED}:{fileType:a,status:n.UPLOAD_READY}},P=e=>!y.fileType?.length||y.fileType?.includes(e.ext)?{}:{errorMessage:y.errorMessage||d.UPLOAD().FILE_TYPE(y.fileType||[]),fileType:e,status:n.ERROR_FORMAT},S=e=>{const t=e?.includes(".")?e.split(".").pop().toLowerCase():void 0;return t&&I?.fileExtension?.includes(t)?{}:{errorMessage:I.errorMessage||d.UPLOAD().FILE_EXTENSION(y.fileType||[]),fileName:e,status:n.ERROR_FORMAT}},C=e=>{if(E.maxSizeInKb>0){if(e>1024*E.maxSizeInKb)return{errorMessage:E.errorMessage||d.UPLOAD().MAX_FILE_SIZE(E.maxSizeInKb),status:n.ERROR_SIZE}}return{}},k=async(e,t)=>{let i;if(A(e=>{const i=[...e];return i[t]={...e[t],status:n.INJECTING},i}),e.dataURL){const t=await m.dataUrlToBlob(e.dataURL);i=new File([t],e.rawFile.name)}else if(e.fileUrl){const t=await new p("",void 0,void 0,!1,{responseType:"blob"}).get(e.fileUrl),s=await m.getType(new File([t],e.rawFile.name));i=new File([t],e.rawFile.name,{type:s.mime}),e.dataURL=await m.fileToDataUrl(i)}const s=e.uploadResponse?.data||e.uploadResponse,{errorMessage:a,fileType:r}=i?await _({...e,rawFile:i}):P({mime:s?.mimeType,ext:s?.ext});let l=i?.size||s?.fileSize||0;isNaN(l)&&(l=0);const{errorMessage:c}=C(l),d=i?await v(e,r?.mime):void 0;A(p=>{const f=[...p];return f[t]={...e,fileItem:{errorMessage:a||c,id:e.fileItem?.id||o(),name:m.deduplicateFileName(b.map(({fileItem:e})=>e.name),t,i?.name||e.rawFile.name),progress:1,size:l,type:r?.mime||s?.mimeType,thumbnailImageDataUrl:d},rawFile:i,status:n.UPLOADED},f})},K=async(e,t)=>{const i=await B(e),s=await m.fileToDataUrl(i.rawFile),{errorMessage:a,fileType:r,status:l}=await _({dataURL:s,...i});A(e=>{const n=[...e];return n[t]={...i,dataURL:s,fileItem:{errorMessage:a,id:o(),name:m.deduplicateFileName(b.map(({fileItem:e})=>e?.name),t,m.sanitizeFileName(i.rawFile.name)),size:i.rawFile.size,type:r.mime,progress:0},status:l},n})},j=async(e,t)=>{A(e=>{const i=[...e];return i[t]={...e[t],status:n.UPLOADING},i});const i=new FormData;i.append("sessionId",R?.sessionId||z.current||""),i.append("fileId",e.fileItem.id),i.append("slot",e.slot.toString()),"base64"===R.type?i.append("dataURL",e.dataURL):"multipart"===R.type&&i.append("file",e.rawFile,e.fileItem?.name);try{const s=await new p("",void 0,void 0,!0).post(R.url,i,{headers:{"Content-Type":"base64"===R.type?"application/json":"multipart/form-data",...R.headers},onUploadProgress:e=>{const{loaded:i,total:s}=e;A(e=>{if(!e[t])return e;const a=[...e];return a[t]={...e[t],fileItem:{...e[t].fileItem,progress:i/s}},a})}}),a=await v(e);A(e=>{if(!e[t])return e;const i=[...e];return i[t]={...e[t],fileItem:{...e[t].fileItem,progress:1,thumbnailImageDataUrl:a},fileUrl:s?.data?.fileUrl,status:n.UPLOADED,uploadResponse:s},i})}catch(t){throw O("upload-error",F,{fileId:e.fileItem.id,errorData:t?.response?.data}),t}},G=e=>{A(t=>t.filter((t,i)=>i!==e))},B=async e=>{if(E.maxSizeInKb>0&&u){const t=1024*E.maxSizeInKb;if(e.rawFile.size>t){const t=await m.getType(e.rawFile);if(f.includes(t.mime)){let t=await c.compressImage(e.rawFile,{fileSize:E.maxSizeInKb});return t instanceof Blob&&(t=m.blobToFile(t,{name:e.rawFile.name,lastModified:e.rawFile.lastModified})),{...e,rawFile:t}}}}return e};return null};export{g as default};
|
|
2
|
-
//# sourceMappingURL=file-upload-manager.ddb44c1f.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-upload-manager.ddb44c1f.js","sources":["../../src/components/fields/file-upload/file-upload-manager.ts"],"sourcesContent":["import { AxiosError } from \"axios\";\nimport { useContext, useEffect, useRef } from \"react\";\nimport { useFormContext } from \"react-hook-form\";\nimport { AxiosApiClient, FileHelper, ImageHelper, generateRandomId } from \"../../../utils\";\nimport { useFieldEvent, usePrevious } from \"../../../utils/hooks\";\nimport { ERROR_MESSAGES } from \"../../shared\";\nimport { FileUploadContext } from \"./file-upload-context\";\nimport {\n\tEFileStatus,\n\tIFile,\n\tIFileUploadSchema,\n\tIFileUploadValidationRule,\n\tIFileUploadValue,\n\tTUploadErrorDetail,\n} from \"./types\";\n\ninterface IProps {\n\tcompressImages: boolean;\n\tfileTypeRule: IFileUploadValidationRule;\n\tfileExtensionRule: IFileUploadValidationRule;\n\thideThumbnail?: boolean | undefined;\n\tid: string;\n\tmaxFileSizeRule: IFileUploadValidationRule;\n\tupload: IFileUploadSchema[\"uploadOnAddingFile\"];\n\tuploadRule: IFileUploadValidationRule;\n\tvalue: IFileUploadValue[];\n}\n\nconst RESIZEABLE_IMAGE_TYPES = [\"image/jpeg\", \"image/gif\", \"image/png\"];\n\nconst FileUploadManager = (props: IProps) => {\n\t// =============================================================================\n\t// CONST, STATE, REFS\n\t// =============================================================================\n\tconst {\n\t\tcompressImages,\n\t\tfileTypeRule,\n\t\tfileExtensionRule,\n\t\thideThumbnail,\n\t\tid,\n\t\tmaxFileSizeRule,\n\t\tupload,\n\t\tuploadRule,\n\t\tvalue,\n\t} = props;\n\tconst { files, setFiles, setCurrentFileIds } = useContext(FileUploadContext);\n\tconst previousValue = usePrevious(value);\n\tconst { setValue } = useFormContext();\n\tconst { dispatchFieldEvent } = useFieldEvent();\n\tconst isMounted = useRef(false);\n\tconst sessionId = useRef<string>();\n\tconst setFilesIfMounted: typeof setFiles = (value) => {\n\t\tif (isMounted.current) {\n\t\t\tsetFiles(value);\n\t\t}\n\t};\n\n\t// =============================================================================\n\t// EFFECTS\n\t// =============================================================================\n\tuseEffect(() => {\n\t\tisMounted.current = true;\n\t\tsessionId.current = generateRandomId();\n\n\t\treturn () => {\n\t\t\tisMounted.current = false;\n\t\t};\n\t}, []);\n\n\tuseEffect(\n\t\t() => {\n\t\t\t// handle file status\n\t\t\tfiles.forEach(async (file, index) => {\n\t\t\t\ttry {\n\t\t\t\t\tswitch (file.status) {\n\t\t\t\t\t\tcase EFileStatus.INJECTED:\n\t\t\t\t\t\t\tawait injectFile(file, index);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase EFileStatus.NONE:\n\t\t\t\t\t\t\tawait parseFile(file, index);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase EFileStatus.UPLOAD_READY:\n\t\t\t\t\t\t\tawait uploadFile(file, index);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase EFileStatus.TO_DELETE:\n\t\t\t\t\t\t\tdeleteFile(index);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\thandleGenericError(index);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// track / update values\n\t\t\tconst uploadedFiles = files.filter(({ status }) => status === EFileStatus.UPLOADED);\n\t\t\tconst notPrefilledFiles = uploadedFiles.filter(({ addedFrom }) => addedFrom !== \"schema\");\n\t\t\tconst hasNotPrefilledFiles = notPrefilledFiles.length > 0;\n\t\t\tconst gotDeleteFiles = files.filter(({ status }) => status === EFileStatus.TO_DELETE).length > 0;\n\n\t\t\t/**\n\t\t\t * should dirty if\n\t\t\t * - it is dirty in the first place\n\t\t\t * - there are non-prefilled files\n\t\t\t * - user deleted file (differentiated from reset)\n\t\t\t */\n\t\t\tconst shouldDirty = hasNotPrefilledFiles || gotDeleteFiles;\n\n\t\t\tsetCurrentFileIds(uploadedFiles.map(({ fileItem }) => fileItem.id));\n\n\t\t\tsetValue(\n\t\t\t\tid,\n\t\t\t\tuploadedFiles.map(({ dataURL, fileItem, fileUrl, uploadResponse }) => ({\n\t\t\t\t\t...(upload.type === \"base64\" ? { dataURL } : {}),\n\t\t\t\t\tfileId: fileItem.id,\n\t\t\t\t\tfileName: fileItem.name,\n\t\t\t\t\tfileUrl,\n\t\t\t\t\tuploadResponse,\n\t\t\t\t})),\n\t\t\t\t{ shouldDirty, shouldTouch: hasNotPrefilledFiles }\n\t\t\t);\n\t\t}, // eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[files.map(({ fileItem, status }) => `${fileItem?.id}-${status}`).join(\",\")]\n\t);\n\n\t// for reset\n\tuseEffect(() => {\n\t\tif (previousValue !== undefined && value === undefined && files.length) {\n\t\t\tsetFiles([]);\n\t\t}\n\t}, [files, previousValue, setFiles, value]);\n\n\t// =============================================================================\n\t// HELPER FUNCTIONS\n\t// =============================================================================\n\n\tconst handleGenericError = (index: number) => {\n\t\tsetFilesIfMounted((prev) => {\n\t\t\tconst updatedFiles = [...prev];\n\t\t\tconst file = prev[index];\n\t\t\tupdatedFiles[index] = {\n\t\t\t\t...file,\n\t\t\t\tfileItem: {\n\t\t\t\t\t...file.fileItem,\n\t\t\t\t\tid: file.fileItem?.id || generateRandomId(),\n\t\t\t\t\tname: file.rawFile.name,\n\t\t\t\t\terrorMessage: uploadRule?.errorMessage || ERROR_MESSAGES.UPLOAD().GENERIC,\n\t\t\t\t},\n\t\t\t\tstatus: EFileStatus.ERROR_GENERIC,\n\t\t\t};\n\t\t\treturn updatedFiles;\n\t\t});\n\t};\n\n\tconst generateThumbnail = async (file: IFile, fileType?: string | undefined) => {\n\t\tif (hideThumbnail !== true && RESIZEABLE_IMAGE_TYPES.includes(fileType || file.fileItem?.type)) {\n\t\t\tconst image = await ImageHelper.dataUrlToImage(file.dataURL);\n\t\t\tconst thumbnail = await ImageHelper.resampleImage(image, { width: 94, height: 94, crop: true });\n\t\t\treturn await FileHelper.fileToDataUrl(thumbnail);\n\t\t}\n\t\treturn \"\";\n\t};\n\n\tconst readFile = async (fileToRead: IFile) => {\n\t\tconst { addedFrom, dataURL, rawFile } = fileToRead;\n\t\tconst fileType = await FileHelper.getType(rawFile);\n\t\tconst fileTypeResult = validateFileType(fileType);\n\n\t\tif (fileTypeResult?.status < 0) {\n\t\t\treturn fileTypeResult;\n\t\t}\n\n\t\tif (fileTypeRule.fileType && fileExtensionRule.fileExtension) {\n\t\t\tconst fileExtensionResult = validateFileExtension(rawFile.name);\n\t\t\tif (fileExtensionResult?.status < 0) {\n\t\t\t\treturn { ...fileExtensionResult, fileType };\n\t\t\t}\n\t\t}\n\n\t\tconst fileSize = upload.type === \"base64\" ? FileHelper.getFilesizeFromBase64(dataURL) : rawFile.size;\n\t\tconst { errorMessage, status } = validateFileSize(fileSize);\n\t\tif (status < 0) {\n\t\t\treturn { errorMessage, fileType, status };\n\t\t}\n\n\t\tif (addedFrom === \"schema\") {\n\t\t\treturn {\n\t\t\t\tfileType,\n\t\t\t\tstatus: EFileStatus.UPLOADED,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tfileType,\n\t\t\tstatus: EFileStatus.UPLOAD_READY,\n\t\t};\n\t};\n\n\tconst validateFileType = (fileType: { mime: string; ext: string }) => {\n\t\tconst validFileType = fileTypeRule.fileType?.length ? fileTypeRule.fileType?.includes(fileType.ext) : true;\n\n\t\tif (!validFileType) {\n\t\t\treturn {\n\t\t\t\terrorMessage:\n\t\t\t\t\tfileTypeRule.errorMessage || ERROR_MESSAGES.UPLOAD().FILE_TYPE(fileTypeRule.fileType || []),\n\t\t\t\tfileType,\n\t\t\t\tstatus: EFileStatus.ERROR_FORMAT,\n\t\t\t};\n\t\t}\n\n\t\treturn {};\n\t};\n\n\tconst validateFileExtension = (fileName: string) => {\n\t\tconst extensionFromFilename = fileName?.includes(\".\") ? fileName.split(\".\").pop().toLowerCase() : undefined;\n\n\t\tif (!extensionFromFilename || !fileExtensionRule?.fileExtension?.includes(extensionFromFilename)) {\n\t\t\treturn {\n\t\t\t\terrorMessage:\n\t\t\t\t\tfileExtensionRule.errorMessage ||\n\t\t\t\t\tERROR_MESSAGES.UPLOAD().FILE_EXTENSION(fileTypeRule.fileType || []),\n\t\t\t\tfileName,\n\t\t\t\tstatus: EFileStatus.ERROR_FORMAT,\n\t\t\t};\n\t\t}\n\t\treturn {};\n\t};\n\n\tconst validateFileSize = (fileSizeInKb: number) => {\n\t\tif (maxFileSizeRule.maxSizeInKb > 0) {\n\t\t\tconst maxSizeInB = maxFileSizeRule.maxSizeInKb * 1024;\n\t\t\tif (fileSizeInKb > maxSizeInB) {\n\t\t\t\treturn {\n\t\t\t\t\terrorMessage:\n\t\t\t\t\t\tmaxFileSizeRule.errorMessage ||\n\t\t\t\t\t\tERROR_MESSAGES.UPLOAD().MAX_FILE_SIZE(maxFileSizeRule.maxSizeInKb),\n\t\t\t\t\tstatus: EFileStatus.ERROR_SIZE,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\treturn {};\n\t};\n\n\t// =============================================================================\n\t// FILE STATUS HANDLERS\n\t// =============================================================================\n\tconst injectFile = async (fileToInject: IFile, index: number) => {\n\t\tsetFilesIfMounted((prev) => {\n\t\t\tconst updatedFiles = [...prev];\n\t\t\tupdatedFiles[index] = {\n\t\t\t\t...prev[index],\n\t\t\t\tstatus: EFileStatus.INJECTING,\n\t\t\t};\n\t\t\treturn updatedFiles;\n\t\t});\n\n\t\tlet rawFile: File;\n\t\tif (fileToInject.dataURL) {\n\t\t\tconst blob = await FileHelper.dataUrlToBlob(fileToInject.dataURL);\n\t\t\trawFile = new File([blob], fileToInject.rawFile.name);\n\t\t} else if (fileToInject.fileUrl) {\n\t\t\tconst response: Blob = await new AxiosApiClient(\"\", undefined, undefined, false, {\n\t\t\t\tresponseType: \"blob\",\n\t\t\t}).get(fileToInject.fileUrl);\n\t\t\tconst fileType = await FileHelper.getType(new File([response], fileToInject.rawFile.name));\n\t\t\trawFile = new File([response], fileToInject.rawFile.name, { type: fileType.mime });\n\t\t\tfileToInject.dataURL = await FileHelper.fileToDataUrl(rawFile);\n\t\t}\n\n\t\t// rawFile may not be available because some use cases is not able to return dataURL / fileUrl due to security concerns\n\t\t// in such cases, we will rely on the uploadResponse for file info\n\t\tconst uploadData = fileToInject.uploadResponse?.[\"data\"] || fileToInject.uploadResponse;\n\t\tconst { errorMessage, fileType } = rawFile\n\t\t\t? await readFile({ ...fileToInject, rawFile })\n\t\t\t: validateFileType({\n\t\t\t\t\tmime: uploadData?.[\"mimeType\"],\n\t\t\t\t\text: uploadData?.[\"ext\"],\n\t\t\t });\n\n\t\tlet size = rawFile?.size || uploadData?.[\"fileSize\"] || 0;\n\t\tif (isNaN(size)) {\n\t\t\tsize = 0;\n\t\t}\n\t\tconst { errorMessage: filesizeErrorMessage } = validateFileSize(size);\n\n\t\tconst thumbnailImageDataUrl = rawFile ? await generateThumbnail(fileToInject, fileType?.mime) : undefined;\n\n\t\tsetFilesIfMounted((prev) => {\n\t\t\tconst updatedFiles = [...prev];\n\t\t\tupdatedFiles[index] = {\n\t\t\t\t...fileToInject,\n\t\t\t\tfileItem: {\n\t\t\t\t\terrorMessage: errorMessage || filesizeErrorMessage,\n\t\t\t\t\tid: fileToInject.fileItem?.id || generateRandomId(),\n\t\t\t\t\tname: FileHelper.deduplicateFileName(\n\t\t\t\t\t\tfiles.map(({ fileItem }) => fileItem.name),\n\t\t\t\t\t\tindex,\n\t\t\t\t\t\trawFile?.name || fileToInject.rawFile.name\n\t\t\t\t\t),\n\t\t\t\t\tprogress: 1,\n\t\t\t\t\tsize,\n\t\t\t\t\ttype: fileType?.mime || uploadData?.[\"mimeType\"],\n\t\t\t\t\tthumbnailImageDataUrl,\n\t\t\t\t},\n\t\t\t\trawFile,\n\t\t\t\tstatus: EFileStatus.UPLOADED,\n\t\t\t};\n\t\t\treturn updatedFiles;\n\t\t});\n\t};\n\n\tconst parseFile = async (fileToParse: IFile, index: number) => {\n\t\tconst compressedFile = await compressImageFile(fileToParse);\n\t\tconst dataURL = await FileHelper.fileToDataUrl(compressedFile.rawFile);\n\t\tconst { errorMessage, fileType, status } = await readFile({ dataURL, ...compressedFile });\n\n\t\tsetFilesIfMounted((prev) => {\n\t\t\tconst updatedFiles = [...prev];\n\t\t\tupdatedFiles[index] = {\n\t\t\t\t...compressedFile,\n\t\t\t\tdataURL,\n\t\t\t\tfileItem: {\n\t\t\t\t\terrorMessage,\n\t\t\t\t\tid: generateRandomId(),\n\t\t\t\t\tname: FileHelper.deduplicateFileName(\n\t\t\t\t\t\tfiles.map(({ fileItem }) => fileItem?.name),\n\t\t\t\t\t\tindex,\n\t\t\t\t\t\tFileHelper.sanitizeFileName(compressedFile.rawFile.name)\n\t\t\t\t\t),\n\t\t\t\t\tsize: compressedFile.rawFile.size,\n\t\t\t\t\ttype: fileType.mime,\n\t\t\t\t\tprogress: 0,\n\t\t\t\t},\n\t\t\t\tstatus,\n\t\t\t};\n\t\t\treturn updatedFiles;\n\t\t});\n\t};\n\n\tconst uploadFile = async (fileToUpload: IFile, index: number) => {\n\t\tsetFilesIfMounted((prev) => {\n\t\t\tconst updatedFiles = [...prev];\n\t\t\tupdatedFiles[index] = {\n\t\t\t\t...prev[index],\n\t\t\t\tstatus: EFileStatus.UPLOADING,\n\t\t\t};\n\t\t\treturn updatedFiles;\n\t\t});\n\n\t\tconst formData = new FormData();\n\t\tformData.append(\"sessionId\", upload?.sessionId || sessionId.current || \"\");\n\t\tformData.append(\"fileId\", fileToUpload.fileItem.id);\n\t\tformData.append(\"slot\", fileToUpload.slot.toString());\n\t\tif (upload.type === \"base64\") {\n\t\t\tformData.append(\"dataURL\", fileToUpload.dataURL);\n\t\t} else if (upload.type === \"multipart\") {\n\t\t\tformData.append(\"file\", fileToUpload.rawFile, fileToUpload.fileItem?.name);\n\t\t}\n\n\t\ttry {\n\t\t\tconst response = await new AxiosApiClient(\"\", undefined, undefined, true).post(upload.url, formData, {\n\t\t\t\theaders: {\n\t\t\t\t\t\"Content-Type\": upload.type === \"base64\" ? \"application/json\" : \"multipart/form-data\",\n\t\t\t\t\t...upload.headers,\n\t\t\t\t},\n\t\t\t\tonUploadProgress: (progressEvent) => {\n\t\t\t\t\tconst { loaded, total } = progressEvent;\n\t\t\t\t\tsetFilesIfMounted((prev) => {\n\t\t\t\t\t\tif (!prev[index]) return prev;\n\t\t\t\t\t\tconst updatedFiles = [...prev];\n\t\t\t\t\t\tupdatedFiles[index] = {\n\t\t\t\t\t\t\t...prev[index],\n\t\t\t\t\t\t\tfileItem: {\n\t\t\t\t\t\t\t\t...prev[index].fileItem,\n\t\t\t\t\t\t\t\tprogress: loaded / total,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\treturn updatedFiles;\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tconst thumbnailImageDataUrl = await generateThumbnail(fileToUpload);\n\t\t\tsetFilesIfMounted((prev) => {\n\t\t\t\tif (!prev[index]) return prev;\n\t\t\t\tconst updatedFiles = [...prev];\n\t\t\t\tupdatedFiles[index] = {\n\t\t\t\t\t...prev[index],\n\t\t\t\t\tfileItem: {\n\t\t\t\t\t\t...prev[index].fileItem,\n\t\t\t\t\t\tprogress: 1,\n\t\t\t\t\t\tthumbnailImageDataUrl,\n\t\t\t\t\t},\n\t\t\t\t\tfileUrl: response?.[\"data\"]?.[\"fileUrl\"],\n\t\t\t\t\tstatus: EFileStatus.UPLOADED,\n\t\t\t\t\tuploadResponse: response,\n\t\t\t\t};\n\t\t\t\treturn updatedFiles;\n\t\t\t});\n\t\t} catch (err) {\n\t\t\tdispatchFieldEvent<TUploadErrorDetail>(\"upload-error\", id, {\n\t\t\t\tfileId: fileToUpload.fileItem.id,\n\t\t\t\terrorData: (err as AxiosError)?.response?.data,\n\t\t\t});\n\n\t\t\tthrow err;\n\t\t}\n\t};\n\n\tconst deleteFile = (index: number) => {\n\t\tsetFilesIfMounted((prev) => prev.filter((_file, i) => i !== index));\n\t};\n\n\tconst compressImageFile = async (fileToCompress: IFile) => {\n\t\tif (maxFileSizeRule.maxSizeInKb > 0 && compressImages) {\n\t\t\tconst maxSizeInB = maxFileSizeRule.maxSizeInKb * 1024;\n\t\t\tif (fileToCompress.rawFile.size > maxSizeInB) {\n\t\t\t\tconst fileType = await FileHelper.getType(fileToCompress.rawFile);\n\t\t\t\tif (RESIZEABLE_IMAGE_TYPES.includes(fileType.mime)) {\n\t\t\t\t\tlet fileOrBlob = await ImageHelper.compressImage(fileToCompress.rawFile, {\n\t\t\t\t\t\tfileSize: maxFileSizeRule.maxSizeInKb,\n\t\t\t\t\t});\n\t\t\t\t\tif (fileOrBlob instanceof Blob) {\n\t\t\t\t\t\tfileOrBlob = FileHelper.blobToFile(fileOrBlob, {\n\t\t\t\t\t\t\tname: fileToCompress.rawFile.name,\n\t\t\t\t\t\t\tlastModified: fileToCompress.rawFile.lastModified,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...fileToCompress,\n\t\t\t\t\t\trawFile: fileOrBlob,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn fileToCompress;\n\t};\n\n\t// =============================================================================\n\t// RENDER FUNCTIONS\n\t// =============================================================================\n\treturn null;\n};\n\nexport default FileUploadManager;\n"],"names":["RESIZEABLE_IMAGE_TYPES","FileUploadManager","props","compressImages","fileTypeRule","fileExtensionRule","hideThumbnail","id","maxFileSizeRule","upload","uploadRule","value","files","setFiles","setCurrentFileIds","useContext","FileUploadContext","previousValue","usePrevious","setValue","useFormContext","dispatchFieldEvent","useFieldEvent","isMounted","useRef","sessionId","setFilesIfMounted","current","useEffect","generateRandomId","forEach","async","file","index","status","EFileStatus","INJECTED","injectFile","NONE","parseFile","UPLOAD_READY","uploadFile","TO_DELETE","deleteFile","err","handleGenericError","uploadedFiles","filter","UPLOADED","hasNotPrefilledFiles","addedFrom","length","gotDeleteFiles","shouldDirty","map","fileItem","dataURL","fileUrl","uploadResponse","type","fileId","fileName","name","shouldTouch","join","undefined","prev","updatedFiles","rawFile","errorMessage","ERROR_MESSAGES","UPLOAD","GENERIC","ERROR_GENERIC","generateThumbnail","fileType","includes","image","ImageHelper","dataUrlToImage","thumbnail","resampleImage","width","height","crop","FileHelper","fileToDataUrl","readFile","fileToRead","getType","fileTypeResult","validateFileType","fileExtension","fileExtensionResult","validateFileExtension","fileSize","getFilesizeFromBase64","size","validateFileSize","ext","FILE_TYPE","ERROR_FORMAT","extensionFromFilename","split","pop","toLowerCase","FILE_EXTENSION","fileSizeInKb","maxSizeInKb","MAX_FILE_SIZE","ERROR_SIZE","fileToInject","INJECTING","blob","dataUrlToBlob","File","response","AxiosApiClient","responseType","get","mime","uploadData","isNaN","filesizeErrorMessage","thumbnailImageDataUrl","deduplicateFileName","progress","fileToParse","compressedFile","compressImageFile","sanitizeFileName","fileToUpload","UPLOADING","formData","FormData","append","slot","toString","post","url","headers","onUploadProgress","progressEvent","loaded","total","errorData","data","_file","i","fileToCompress","maxSizeInB","fileOrBlob","compressImage","Blob","blobToFile","lastModified"],"mappings":"wzDA4BA,MAAMA,EAAyB,CAAC,aAAc,YAAa,aAErDC,EAAqBC,IAI1B,MAAMC,eACLA,EAAcC,aACdA,EAAYC,kBACZA,EAAiBC,cACjBA,EAAaC,GACbA,EAAEC,gBACFA,EAAeC,OACfA,EAAMC,WACNA,EAAUC,MACVA,GACGT,GACEU,MAAEA,EAAKC,SAAEA,EAAQC,kBAAEA,GAAsBC,EAAWC,GACpDC,EAAgBC,EAAYP,IAC5BQ,SAAEA,GAAaC,KACfC,mBAAEA,GAAuBC,IACzBC,EAAYC,GAAO,GACnBC,EAAYD,IACZE,EAAsCf,IACvCY,EAAUI,SACbd,EAASF,IAOXiB,EAAU,KACTL,EAAUI,SAAU,EACpBF,EAAUE,QAAUE,IAEb,KACNN,EAAUI,SAAU,IAEnB,IAEHC,EACC,KAEChB,EAAMkB,QAAQC,MAAOC,EAAMC,KAC1B,IACC,OAAQD,EAAKE,QACZ,KAAKC,EAAYC,eACVC,EAAWL,EAAMC,GACvB,MACD,KAAKE,EAAYG,WACVC,EAAUP,EAAMC,GACtB,MACD,KAAKE,EAAYK,mBACVC,EAAWT,EAAMC,GACvB,MACD,KAAKE,EAAYO,UAChBC,EAAWV,GAGb,CAAC,MAAOW,GACRC,EAAmBZ,EACnB,IAIF,MAAMa,EAAgBlC,EAAMmC,OAAO,EAAGb,YAAaA,IAAWC,EAAYa,UAEpEC,EADoBH,EAAcC,OAAO,EAAGG,eAA8B,WAAdA,GACnBC,OAAS,EAClDC,EAAiBxC,EAAMmC,OAAO,EAAGb,YAAaA,IAAWC,EAAYO,WAAWS,OAAS,EAQzFE,EAAcJ,GAAwBG,EAE5CtC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-1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var e=require("react"),i=require("./index.6a929030.js");require("react/jsx-runtime"),require("@lifesg/react-design-system/theme"),require("styled-components"),require("@lifesg/react-design-system/markup"),require("react-dom/server"),require("@lifesg/react-design-system/typography"),require("@lifesg/react-design-system/button"),require("@lifesg/react-design-system/modal"),require("@lifesg/react-design-system/alert"),require("@lifesg/react-design-system/layout"),require("@lifesg/react-design-system/box-container"),require("@lifesg/react-design-system/divider"),require("@lifesg/react-design-system/v2_media"),require("@lifesg/react-design-system/text-list"),require("@lifesg/react-design-system/popover-v2"),require("@lifesg/react-icons"),require("@lifesg/react-design-system/tab"),require("@lifesg/react-icons/plus-circle-fill"),require("@lifesg/react-design-system/button-with-icon"),require("@lifesg/react-design-system/error-display"),require("@lifesg/react-design-system/filter"),require("@lifesg/react-design-system/uneditable-section"),require("@lifesg/react-design-system/timeline"),require("@lifesg/react-design-system/form"),require("@lifesg/react-design-system/checkbox"),require("@lifesg/react-design-system/toggle"),require("@lifesg/react-icons/exclamation-circle-fill"),require("@lifesg/react-design-system/file-upload"),require("@lifesg/react-icons/cross"),require("@lifesg/react-design-system/icon-button"),require("@lifesg/react-icons/bin"),require("@lifesg/react-icons/eraser"),require("@lifesg/react-icons/pencil"),require("@lifesg/react-icons/pencil-stroke"),require("@lifesg/react-icons/plus"),require("@lifesg/react-icons/exclamation-triangle"),require("@lifesg/react-icons/pin-fill"),require("@lifesg/react-design-system/image-button"),require("@lifesg/react-design-system/radio-button"),require("@lifesg/react-design-system/v2_layout");const t=["image/jpeg","image/gif","image/png"];exports.default=s=>{const{compressImages:r,fileTypeRule:a,fileExtensionRule:l,hideThumbnail:n,id:o,maxFileSizeRule:u,upload:m,uploadRule:c,value:d}=s,{files:f,setFiles:g,setCurrentFileIds:p}=e.useContext(i.FileUploadContext),y=i.usePrevious(d),{setValue:F}=i.useFormContext(),{dispatchFieldEvent:E}=i.useFieldEvent(),I=e.useRef(!1),R=e.useRef(),w=e=>{I.current&&g(e)};e.useEffect(()=>(I.current=!0,R.current=i.generateRandomId(),()=>{I.current=!1}),[]),e.useEffect(()=>{f.forEach(async(e,t)=>{try{switch(e.status){case i.EFileStatus.INJECTED:await D(e,t);break;case i.EFileStatus.NONE:await L(e,t);break;case i.EFileStatus.UPLOAD_READY:await x(e,t);break;case i.EFileStatus.TO_DELETE:O(t)}}catch(e){q(t)}});const e=f.filter(({status:e})=>e===i.EFileStatus.UPLOADED),t=e.filter(({addedFrom:e})=>"schema"!==e).length>0,s=f.filter(({status:e})=>e===i.EFileStatus.TO_DELETE).length>0,r=t||s;p(e.map(({fileItem:e})=>e.id)),F(o,e.map(({dataURL:e,fileItem:i,fileUrl:t,uploadResponse:s})=>({..."base64"===m.type?{dataURL:e}:{},fileId:i.id,fileName:i.name,fileUrl:t,uploadResponse:s})),{shouldDirty:r,shouldTouch:t})},[f.map(({fileItem:e,status:i})=>`${e?.id}-${i}`).join(",")]),e.useEffect(()=>{void 0!==y&&void 0===d&&f.length&&g([])},[f,y,g,d]);const q=e=>{w(t=>{const s=[...t],r=t[e];return s[e]={...r,fileItem:{...r.fileItem,id:r.fileItem?.id||i.generateRandomId(),name:r.rawFile.name,errorMessage:c?.errorMessage||i.ERROR_MESSAGES.UPLOAD().GENERIC},status:i.EFileStatus.ERROR_GENERIC},s})},S=async(e,s)=>{if(!0!==n&&t.includes(s||e.fileItem?.type)){const t=await i.ImageHelper.dataUrlToImage(e.dataURL),s=await i.ImageHelper.resampleImage(t,{width:94,height:94,crop:!0});return await i.FileHelper.fileToDataUrl(s)}return""},T=async e=>{const{addedFrom:t,dataURL:s,rawFile:r}=e,n=await i.FileHelper.getType(r),o=U(n);if(o?.status<0)return o;if(a.fileType&&l.fileExtension){const e=b(r.name);if(e?.status<0)return{...e,fileType:n}}const u="base64"===m.type?i.FileHelper.getFilesizeFromBase64(s):r.size,{errorMessage:c,status:d}=h(u);return d<0?{errorMessage:c,fileType:n,status:d}:"schema"===t?{fileType:n,status:i.EFileStatus.UPLOADED}:{fileType:n,status:i.EFileStatus.UPLOAD_READY}},U=e=>!a.fileType?.length||a.fileType?.includes(e.ext)?{}:{errorMessage:a.errorMessage||i.ERROR_MESSAGES.UPLOAD().FILE_TYPE(a.fileType||[]),fileType:e,status:i.EFileStatus.ERROR_FORMAT},b=e=>{const t=e?.includes(".")?e.split(".").pop().toLowerCase():void 0;return t&&l?.fileExtension?.includes(t)?{}:{errorMessage:l.errorMessage||i.ERROR_MESSAGES.UPLOAD().FILE_EXTENSION(a.fileType||[]),fileName:e,status:i.EFileStatus.ERROR_FORMAT}},h=e=>{if(u.maxSizeInKb>0){if(e>1024*u.maxSizeInKb)return{errorMessage:u.errorMessage||i.ERROR_MESSAGES.UPLOAD().MAX_FILE_SIZE(u.maxSizeInKb),status:i.EFileStatus.ERROR_SIZE}}return{}},D=async(e,t)=>{let s;if(w(e=>{const s=[...e];return s[t]={...e[t],status:i.EFileStatus.INJECTING},s}),e.dataURL){const t=await i.FileHelper.dataUrlToBlob(e.dataURL);s=new File([t],e.rawFile.name)}else if(e.fileUrl){const t=await new i.AxiosApiClient("",void 0,void 0,!1,{responseType:"blob"}).get(e.fileUrl),r=await i.FileHelper.getType(new File([t],e.rawFile.name));s=new File([t],e.rawFile.name,{type:r.mime}),e.dataURL=await i.FileHelper.fileToDataUrl(s)}const r=e.uploadResponse?.data||e.uploadResponse,{errorMessage:a,fileType:l}=s?await T({...e,rawFile:s}):U({mime:r?.mimeType,ext:r?.ext});let n=s?.size||r?.fileSize||0;isNaN(n)&&(n=0);const{errorMessage:o}=h(n),u=s?await S(e,l?.mime):void 0;w(m=>{const c=[...m];return c[t]={...e,fileItem:{errorMessage:a||o,id:e.fileItem?.id||i.generateRandomId(),name:i.FileHelper.deduplicateFileName(f.map(({fileItem:e})=>e.name),t,s?.name||e.rawFile.name),progress:1,size:n,type:l?.mime||r?.mimeType,thumbnailImageDataUrl:u},rawFile:s,status:i.EFileStatus.UPLOADED},c})},L=async(e,t)=>{const s=await A(e),r=await i.FileHelper.fileToDataUrl(s.rawFile),{errorMessage:a,fileType:l,status:n}=await T({dataURL:r,...s});w(e=>{const o=[...e];return o[t]={...s,dataURL:r,fileItem:{errorMessage:a,id:i.generateRandomId(),name:i.FileHelper.deduplicateFileName(f.map(({fileItem:e})=>e?.name),t,i.FileHelper.sanitizeFileName(s.rawFile.name)),size:s.rawFile.size,type:l.mime,progress:0},status:n},o})},x=async(e,t)=>{w(e=>{const s=[...e];return s[t]={...e[t],status:i.EFileStatus.UPLOADING},s});const s=new FormData;s.append("sessionId",m?.sessionId||R.current||""),s.append("fileId",e.fileItem.id),s.append("slot",e.slot.toString()),"base64"===m.type?s.append("dataURL",e.dataURL):"multipart"===m.type&&s.append("file",e.rawFile,e.fileItem?.name);try{const r=await new i.AxiosApiClient("",void 0,void 0,!0).post(m.url,s,{headers:{"Content-Type":"base64"===m.type?"application/json":"multipart/form-data",...m.headers},onUploadProgress:e=>{const{loaded:i,total:s}=e;w(e=>{if(!e[t])return e;const r=[...e];return r[t]={...e[t],fileItem:{...e[t].fileItem,progress:i/s}},r})}}),a=await S(e);w(e=>{if(!e[t])return e;const s=[...e];return s[t]={...e[t],fileItem:{...e[t].fileItem,progress:1,thumbnailImageDataUrl:a},fileUrl:r?.data?.fileUrl,status:i.EFileStatus.UPLOADED,uploadResponse:r},s})}catch(i){throw E("upload-error",o,{fileId:e.fileItem.id,errorData:i?.response?.data}),i}},O=e=>{w(i=>i.filter((i,t)=>t!==e))},A=async e=>{if(u.maxSizeInKb>0&&r){const s=1024*u.maxSizeInKb;if(e.rawFile.size>s){const s=await i.FileHelper.getType(e.rawFile);if(t.includes(s.mime)){let t=await i.ImageHelper.compressImage(e.rawFile,{fileSize:u.maxSizeInKb});return t instanceof Blob&&(t=i.FileHelper.blobToFile(t,{name:e.rawFile.name,lastModified:e.rawFile.lastModified})),{...e,rawFile:t}}}}return e};return null};
|
|
2
|
-
//# sourceMappingURL=file-upload-manager.b22d56d4.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-upload-manager.b22d56d4.js","sources":["../../../src/components/fields/file-upload/file-upload-manager.ts"],"sourcesContent":["import { AxiosError } from \"axios\";\nimport { useContext, useEffect, useRef } from \"react\";\nimport { useFormContext } from \"react-hook-form\";\nimport { AxiosApiClient, FileHelper, ImageHelper, generateRandomId } from \"../../../utils\";\nimport { useFieldEvent, usePrevious } from \"../../../utils/hooks\";\nimport { ERROR_MESSAGES } from \"../../shared\";\nimport { FileUploadContext } from \"./file-upload-context\";\nimport {\n\tEFileStatus,\n\tIFile,\n\tIFileUploadSchema,\n\tIFileUploadValidationRule,\n\tIFileUploadValue,\n\tTUploadErrorDetail,\n} from \"./types\";\n\ninterface IProps {\n\tcompressImages: boolean;\n\tfileTypeRule: IFileUploadValidationRule;\n\tfileExtensionRule: IFileUploadValidationRule;\n\thideThumbnail?: boolean | undefined;\n\tid: string;\n\tmaxFileSizeRule: IFileUploadValidationRule;\n\tupload: IFileUploadSchema[\"uploadOnAddingFile\"];\n\tuploadRule: IFileUploadValidationRule;\n\tvalue: IFileUploadValue[];\n}\n\nconst RESIZEABLE_IMAGE_TYPES = [\"image/jpeg\", \"image/gif\", \"image/png\"];\n\nconst FileUploadManager = (props: IProps) => {\n\t// =============================================================================\n\t// CONST, STATE, REFS\n\t// =============================================================================\n\tconst {\n\t\tcompressImages,\n\t\tfileTypeRule,\n\t\tfileExtensionRule,\n\t\thideThumbnail,\n\t\tid,\n\t\tmaxFileSizeRule,\n\t\tupload,\n\t\tuploadRule,\n\t\tvalue,\n\t} = props;\n\tconst { files, setFiles, setCurrentFileIds } = useContext(FileUploadContext);\n\tconst previousValue = usePrevious(value);\n\tconst { setValue } = useFormContext();\n\tconst { dispatchFieldEvent } = useFieldEvent();\n\tconst isMounted = useRef(false);\n\tconst sessionId = useRef<string>();\n\tconst setFilesIfMounted: typeof setFiles = (value) => {\n\t\tif (isMounted.current) {\n\t\t\tsetFiles(value);\n\t\t}\n\t};\n\n\t// =============================================================================\n\t// EFFECTS\n\t// =============================================================================\n\tuseEffect(() => {\n\t\tisMounted.current = true;\n\t\tsessionId.current = generateRandomId();\n\n\t\treturn () => {\n\t\t\tisMounted.current = false;\n\t\t};\n\t}, []);\n\n\tuseEffect(\n\t\t() => {\n\t\t\t// handle file status\n\t\t\tfiles.forEach(async (file, index) => {\n\t\t\t\ttry {\n\t\t\t\t\tswitch (file.status) {\n\t\t\t\t\t\tcase EFileStatus.INJECTED:\n\t\t\t\t\t\t\tawait injectFile(file, index);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase EFileStatus.NONE:\n\t\t\t\t\t\t\tawait parseFile(file, index);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase EFileStatus.UPLOAD_READY:\n\t\t\t\t\t\t\tawait uploadFile(file, index);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase EFileStatus.TO_DELETE:\n\t\t\t\t\t\t\tdeleteFile(index);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\thandleGenericError(index);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// track / update values\n\t\t\tconst uploadedFiles = files.filter(({ status }) => status === EFileStatus.UPLOADED);\n\t\t\tconst notPrefilledFiles = uploadedFiles.filter(({ addedFrom }) => addedFrom !== \"schema\");\n\t\t\tconst hasNotPrefilledFiles = notPrefilledFiles.length > 0;\n\t\t\tconst gotDeleteFiles = files.filter(({ status }) => status === EFileStatus.TO_DELETE).length > 0;\n\n\t\t\t/**\n\t\t\t * should dirty if\n\t\t\t * - it is dirty in the first place\n\t\t\t * - there are non-prefilled files\n\t\t\t * - user deleted file (differentiated from reset)\n\t\t\t */\n\t\t\tconst shouldDirty = hasNotPrefilledFiles || gotDeleteFiles;\n\n\t\t\tsetCurrentFileIds(uploadedFiles.map(({ fileItem }) => fileItem.id));\n\n\t\t\tsetValue(\n\t\t\t\tid,\n\t\t\t\tuploadedFiles.map(({ dataURL, fileItem, fileUrl, uploadResponse }) => ({\n\t\t\t\t\t...(upload.type === \"base64\" ? { dataURL } : {}),\n\t\t\t\t\tfileId: fileItem.id,\n\t\t\t\t\tfileName: fileItem.name,\n\t\t\t\t\tfileUrl,\n\t\t\t\t\tuploadResponse,\n\t\t\t\t})),\n\t\t\t\t{ shouldDirty, shouldTouch: hasNotPrefilledFiles }\n\t\t\t);\n\t\t}, // eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[files.map(({ fileItem, status }) => `${fileItem?.id}-${status}`).join(\",\")]\n\t);\n\n\t// for reset\n\tuseEffect(() => {\n\t\tif (previousValue !== undefined && value === undefined && files.length) {\n\t\t\tsetFiles([]);\n\t\t}\n\t}, [files, previousValue, setFiles, value]);\n\n\t// =============================================================================\n\t// HELPER FUNCTIONS\n\t// =============================================================================\n\n\tconst handleGenericError = (index: number) => {\n\t\tsetFilesIfMounted((prev) => {\n\t\t\tconst updatedFiles = [...prev];\n\t\t\tconst file = prev[index];\n\t\t\tupdatedFiles[index] = {\n\t\t\t\t...file,\n\t\t\t\tfileItem: {\n\t\t\t\t\t...file.fileItem,\n\t\t\t\t\tid: file.fileItem?.id || generateRandomId(),\n\t\t\t\t\tname: file.rawFile.name,\n\t\t\t\t\terrorMessage: uploadRule?.errorMessage || ERROR_MESSAGES.UPLOAD().GENERIC,\n\t\t\t\t},\n\t\t\t\tstatus: EFileStatus.ERROR_GENERIC,\n\t\t\t};\n\t\t\treturn updatedFiles;\n\t\t});\n\t};\n\n\tconst generateThumbnail = async (file: IFile, fileType?: string | undefined) => {\n\t\tif (hideThumbnail !== true && RESIZEABLE_IMAGE_TYPES.includes(fileType || file.fileItem?.type)) {\n\t\t\tconst image = await ImageHelper.dataUrlToImage(file.dataURL);\n\t\t\tconst thumbnail = await ImageHelper.resampleImage(image, { width: 94, height: 94, crop: true });\n\t\t\treturn await FileHelper.fileToDataUrl(thumbnail);\n\t\t}\n\t\treturn \"\";\n\t};\n\n\tconst readFile = async (fileToRead: IFile) => {\n\t\tconst { addedFrom, dataURL, rawFile } = fileToRead;\n\t\tconst fileType = await FileHelper.getType(rawFile);\n\t\tconst fileTypeResult = validateFileType(fileType);\n\n\t\tif (fileTypeResult?.status < 0) {\n\t\t\treturn fileTypeResult;\n\t\t}\n\n\t\tif (fileTypeRule.fileType && fileExtensionRule.fileExtension) {\n\t\t\tconst fileExtensionResult = validateFileExtension(rawFile.name);\n\t\t\tif (fileExtensionResult?.status < 0) {\n\t\t\t\treturn { ...fileExtensionResult, fileType };\n\t\t\t}\n\t\t}\n\n\t\tconst fileSize = upload.type === \"base64\" ? FileHelper.getFilesizeFromBase64(dataURL) : rawFile.size;\n\t\tconst { errorMessage, status } = validateFileSize(fileSize);\n\t\tif (status < 0) {\n\t\t\treturn { errorMessage, fileType, status };\n\t\t}\n\n\t\tif (addedFrom === \"schema\") {\n\t\t\treturn {\n\t\t\t\tfileType,\n\t\t\t\tstatus: EFileStatus.UPLOADED,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tfileType,\n\t\t\tstatus: EFileStatus.UPLOAD_READY,\n\t\t};\n\t};\n\n\tconst validateFileType = (fileType: { mime: string; ext: string }) => {\n\t\tconst validFileType = fileTypeRule.fileType?.length ? fileTypeRule.fileType?.includes(fileType.ext) : true;\n\n\t\tif (!validFileType) {\n\t\t\treturn {\n\t\t\t\terrorMessage:\n\t\t\t\t\tfileTypeRule.errorMessage || ERROR_MESSAGES.UPLOAD().FILE_TYPE(fileTypeRule.fileType || []),\n\t\t\t\tfileType,\n\t\t\t\tstatus: EFileStatus.ERROR_FORMAT,\n\t\t\t};\n\t\t}\n\n\t\treturn {};\n\t};\n\n\tconst validateFileExtension = (fileName: string) => {\n\t\tconst extensionFromFilename = fileName?.includes(\".\") ? fileName.split(\".\").pop().toLowerCase() : undefined;\n\n\t\tif (!extensionFromFilename || !fileExtensionRule?.fileExtension?.includes(extensionFromFilename)) {\n\t\t\treturn {\n\t\t\t\terrorMessage:\n\t\t\t\t\tfileExtensionRule.errorMessage ||\n\t\t\t\t\tERROR_MESSAGES.UPLOAD().FILE_EXTENSION(fileTypeRule.fileType || []),\n\t\t\t\tfileName,\n\t\t\t\tstatus: EFileStatus.ERROR_FORMAT,\n\t\t\t};\n\t\t}\n\t\treturn {};\n\t};\n\n\tconst validateFileSize = (fileSizeInKb: number) => {\n\t\tif (maxFileSizeRule.maxSizeInKb > 0) {\n\t\t\tconst maxSizeInB = maxFileSizeRule.maxSizeInKb * 1024;\n\t\t\tif (fileSizeInKb > maxSizeInB) {\n\t\t\t\treturn {\n\t\t\t\t\terrorMessage:\n\t\t\t\t\t\tmaxFileSizeRule.errorMessage ||\n\t\t\t\t\t\tERROR_MESSAGES.UPLOAD().MAX_FILE_SIZE(maxFileSizeRule.maxSizeInKb),\n\t\t\t\t\tstatus: EFileStatus.ERROR_SIZE,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\treturn {};\n\t};\n\n\t// =============================================================================\n\t// FILE STATUS HANDLERS\n\t// =============================================================================\n\tconst injectFile = async (fileToInject: IFile, index: number) => {\n\t\tsetFilesIfMounted((prev) => {\n\t\t\tconst updatedFiles = [...prev];\n\t\t\tupdatedFiles[index] = {\n\t\t\t\t...prev[index],\n\t\t\t\tstatus: EFileStatus.INJECTING,\n\t\t\t};\n\t\t\treturn updatedFiles;\n\t\t});\n\n\t\tlet rawFile: File;\n\t\tif (fileToInject.dataURL) {\n\t\t\tconst blob = await FileHelper.dataUrlToBlob(fileToInject.dataURL);\n\t\t\trawFile = new File([blob], fileToInject.rawFile.name);\n\t\t} else if (fileToInject.fileUrl) {\n\t\t\tconst response: Blob = await new AxiosApiClient(\"\", undefined, undefined, false, {\n\t\t\t\tresponseType: \"blob\",\n\t\t\t}).get(fileToInject.fileUrl);\n\t\t\tconst fileType = await FileHelper.getType(new File([response], fileToInject.rawFile.name));\n\t\t\trawFile = new File([response], fileToInject.rawFile.name, { type: fileType.mime });\n\t\t\tfileToInject.dataURL = await FileHelper.fileToDataUrl(rawFile);\n\t\t}\n\n\t\t// rawFile may not be available because some use cases is not able to return dataURL / fileUrl due to security concerns\n\t\t// in such cases, we will rely on the uploadResponse for file info\n\t\tconst uploadData = fileToInject.uploadResponse?.[\"data\"] || fileToInject.uploadResponse;\n\t\tconst { errorMessage, fileType } = rawFile\n\t\t\t? await readFile({ ...fileToInject, rawFile })\n\t\t\t: validateFileType({\n\t\t\t\t\tmime: uploadData?.[\"mimeType\"],\n\t\t\t\t\text: uploadData?.[\"ext\"],\n\t\t\t });\n\n\t\tlet size = rawFile?.size || uploadData?.[\"fileSize\"] || 0;\n\t\tif (isNaN(size)) {\n\t\t\tsize = 0;\n\t\t}\n\t\tconst { errorMessage: filesizeErrorMessage } = validateFileSize(size);\n\n\t\tconst thumbnailImageDataUrl = rawFile ? await generateThumbnail(fileToInject, fileType?.mime) : undefined;\n\n\t\tsetFilesIfMounted((prev) => {\n\t\t\tconst updatedFiles = [...prev];\n\t\t\tupdatedFiles[index] = {\n\t\t\t\t...fileToInject,\n\t\t\t\tfileItem: {\n\t\t\t\t\terrorMessage: errorMessage || filesizeErrorMessage,\n\t\t\t\t\tid: fileToInject.fileItem?.id || generateRandomId(),\n\t\t\t\t\tname: FileHelper.deduplicateFileName(\n\t\t\t\t\t\tfiles.map(({ fileItem }) => fileItem.name),\n\t\t\t\t\t\tindex,\n\t\t\t\t\t\trawFile?.name || fileToInject.rawFile.name\n\t\t\t\t\t),\n\t\t\t\t\tprogress: 1,\n\t\t\t\t\tsize,\n\t\t\t\t\ttype: fileType?.mime || uploadData?.[\"mimeType\"],\n\t\t\t\t\tthumbnailImageDataUrl,\n\t\t\t\t},\n\t\t\t\trawFile,\n\t\t\t\tstatus: EFileStatus.UPLOADED,\n\t\t\t};\n\t\t\treturn updatedFiles;\n\t\t});\n\t};\n\n\tconst parseFile = async (fileToParse: IFile, index: number) => {\n\t\tconst compressedFile = await compressImageFile(fileToParse);\n\t\tconst dataURL = await FileHelper.fileToDataUrl(compressedFile.rawFile);\n\t\tconst { errorMessage, fileType, status } = await readFile({ dataURL, ...compressedFile });\n\n\t\tsetFilesIfMounted((prev) => {\n\t\t\tconst updatedFiles = [...prev];\n\t\t\tupdatedFiles[index] = {\n\t\t\t\t...compressedFile,\n\t\t\t\tdataURL,\n\t\t\t\tfileItem: {\n\t\t\t\t\terrorMessage,\n\t\t\t\t\tid: generateRandomId(),\n\t\t\t\t\tname: FileHelper.deduplicateFileName(\n\t\t\t\t\t\tfiles.map(({ fileItem }) => fileItem?.name),\n\t\t\t\t\t\tindex,\n\t\t\t\t\t\tFileHelper.sanitizeFileName(compressedFile.rawFile.name)\n\t\t\t\t\t),\n\t\t\t\t\tsize: compressedFile.rawFile.size,\n\t\t\t\t\ttype: fileType.mime,\n\t\t\t\t\tprogress: 0,\n\t\t\t\t},\n\t\t\t\tstatus,\n\t\t\t};\n\t\t\treturn updatedFiles;\n\t\t});\n\t};\n\n\tconst uploadFile = async (fileToUpload: IFile, index: number) => {\n\t\tsetFilesIfMounted((prev) => {\n\t\t\tconst updatedFiles = [...prev];\n\t\t\tupdatedFiles[index] = {\n\t\t\t\t...prev[index],\n\t\t\t\tstatus: EFileStatus.UPLOADING,\n\t\t\t};\n\t\t\treturn updatedFiles;\n\t\t});\n\n\t\tconst formData = new FormData();\n\t\tformData.append(\"sessionId\", upload?.sessionId || sessionId.current || \"\");\n\t\tformData.append(\"fileId\", fileToUpload.fileItem.id);\n\t\tformData.append(\"slot\", fileToUpload.slot.toString());\n\t\tif (upload.type === \"base64\") {\n\t\t\tformData.append(\"dataURL\", fileToUpload.dataURL);\n\t\t} else if (upload.type === \"multipart\") {\n\t\t\tformData.append(\"file\", fileToUpload.rawFile, fileToUpload.fileItem?.name);\n\t\t}\n\n\t\ttry {\n\t\t\tconst response = await new AxiosApiClient(\"\", undefined, undefined, true).post(upload.url, formData, {\n\t\t\t\theaders: {\n\t\t\t\t\t\"Content-Type\": upload.type === \"base64\" ? \"application/json\" : \"multipart/form-data\",\n\t\t\t\t\t...upload.headers,\n\t\t\t\t},\n\t\t\t\tonUploadProgress: (progressEvent) => {\n\t\t\t\t\tconst { loaded, total } = progressEvent;\n\t\t\t\t\tsetFilesIfMounted((prev) => {\n\t\t\t\t\t\tif (!prev[index]) return prev;\n\t\t\t\t\t\tconst updatedFiles = [...prev];\n\t\t\t\t\t\tupdatedFiles[index] = {\n\t\t\t\t\t\t\t...prev[index],\n\t\t\t\t\t\t\tfileItem: {\n\t\t\t\t\t\t\t\t...prev[index].fileItem,\n\t\t\t\t\t\t\t\tprogress: loaded / total,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\treturn updatedFiles;\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tconst thumbnailImageDataUrl = await generateThumbnail(fileToUpload);\n\t\t\tsetFilesIfMounted((prev) => {\n\t\t\t\tif (!prev[index]) return prev;\n\t\t\t\tconst updatedFiles = [...prev];\n\t\t\t\tupdatedFiles[index] = {\n\t\t\t\t\t...prev[index],\n\t\t\t\t\tfileItem: {\n\t\t\t\t\t\t...prev[index].fileItem,\n\t\t\t\t\t\tprogress: 1,\n\t\t\t\t\t\tthumbnailImageDataUrl,\n\t\t\t\t\t},\n\t\t\t\t\tfileUrl: response?.[\"data\"]?.[\"fileUrl\"],\n\t\t\t\t\tstatus: EFileStatus.UPLOADED,\n\t\t\t\t\tuploadResponse: response,\n\t\t\t\t};\n\t\t\t\treturn updatedFiles;\n\t\t\t});\n\t\t} catch (err) {\n\t\t\tdispatchFieldEvent<TUploadErrorDetail>(\"upload-error\", id, {\n\t\t\t\tfileId: fileToUpload.fileItem.id,\n\t\t\t\terrorData: (err as AxiosError)?.response?.data,\n\t\t\t});\n\n\t\t\tthrow err;\n\t\t}\n\t};\n\n\tconst deleteFile = (index: number) => {\n\t\tsetFilesIfMounted((prev) => prev.filter((_file, i) => i !== index));\n\t};\n\n\tconst compressImageFile = async (fileToCompress: IFile) => {\n\t\tif (maxFileSizeRule.maxSizeInKb > 0 && compressImages) {\n\t\t\tconst maxSizeInB = maxFileSizeRule.maxSizeInKb * 1024;\n\t\t\tif (fileToCompress.rawFile.size > maxSizeInB) {\n\t\t\t\tconst fileType = await FileHelper.getType(fileToCompress.rawFile);\n\t\t\t\tif (RESIZEABLE_IMAGE_TYPES.includes(fileType.mime)) {\n\t\t\t\t\tlet fileOrBlob = await ImageHelper.compressImage(fileToCompress.rawFile, {\n\t\t\t\t\t\tfileSize: maxFileSizeRule.maxSizeInKb,\n\t\t\t\t\t});\n\t\t\t\t\tif (fileOrBlob instanceof Blob) {\n\t\t\t\t\t\tfileOrBlob = FileHelper.blobToFile(fileOrBlob, {\n\t\t\t\t\t\t\tname: fileToCompress.rawFile.name,\n\t\t\t\t\t\t\tlastModified: fileToCompress.rawFile.lastModified,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...fileToCompress,\n\t\t\t\t\t\trawFile: fileOrBlob,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn fileToCompress;\n\t};\n\n\t// =============================================================================\n\t// RENDER FUNCTIONS\n\t// =============================================================================\n\treturn null;\n};\n\nexport default FileUploadManager;\n"],"names":["RESIZEABLE_IMAGE_TYPES","props","compressImages","fileTypeRule","fileExtensionRule","hideThumbnail","id","maxFileSizeRule","upload","uploadRule","value","files","setFiles","setCurrentFileIds","useContext","FileUploadContext","previousValue","usePrevious","setValue","useFormContext","dispatchFieldEvent","useFieldEvent","isMounted","useRef","sessionId","setFilesIfMounted","current","useEffect","generateRandomId","forEach","async","file","index","status","EFileStatus","INJECTED","injectFile","NONE","parseFile","UPLOAD_READY","uploadFile","TO_DELETE","deleteFile","err","handleGenericError","uploadedFiles","filter","UPLOADED","hasNotPrefilledFiles","addedFrom","length","gotDeleteFiles","shouldDirty","map","fileItem","dataURL","fileUrl","uploadResponse","type","fileId","fileName","name","shouldTouch","join","undefined","prev","updatedFiles","rawFile","errorMessage","ERROR_MESSAGES","UPLOAD","GENERIC","ERROR_GENERIC","generateThumbnail","fileType","includes","image","ImageHelper","dataUrlToImage","thumbnail","resampleImage","width","height","crop","FileHelper","fileToDataUrl","readFile","fileToRead","getType","fileTypeResult","validateFileType","fileExtension","fileExtensionResult","validateFileExtension","fileSize","getFilesizeFromBase64","size","validateFileSize","ext","FILE_TYPE","ERROR_FORMAT","extensionFromFilename","split","pop","toLowerCase","FILE_EXTENSION","fileSizeInKb","maxSizeInKb","MAX_FILE_SIZE","ERROR_SIZE","fileToInject","INJECTING","blob","dataUrlToBlob","File","response","AxiosApiClient","responseType","get","mime","uploadData","isNaN","filesizeErrorMessage","thumbnailImageDataUrl","deduplicateFileName","progress","fileToParse","compressedFile","compressImageFile","sanitizeFileName","fileToUpload","UPLOADING","formData","FormData","append","slot","toString","post","url","headers","onUploadProgress","progressEvent","loaded","total","errorData","data","_file","i","fileToCompress","maxSizeInB","fileOrBlob","compressImage","Blob","blobToFile","lastModified"],"mappings":"q1DA4BA,MAAMA,EAAyB,CAAC,aAAc,YAAa,6BAEhCC,IAI1B,MAAMC,eACLA,EAAcC,aACdA,EAAYC,kBACZA,EAAiBC,cACjBA,EAAaC,GACbA,EAAEC,gBACFA,EAAeC,OACfA,EAAMC,WACNA,EAAUC,MACVA,GACGT,GACEU,MAAEA,EAAKC,SAAEA,EAAQC,kBAAEA,GAAsBC,EAAAA,WAAWC,EAAAA,mBACpDC,EAAgBC,cAAYP,IAC5BQ,SAAEA,GAAaC,EAAAA,kBACfC,mBAAEA,GAAuBC,EAAAA,gBACzBC,EAAYC,UAAO,GACnBC,EAAYD,EAAAA,SACZE,EAAsCf,IACvCY,EAAUI,SACbd,EAASF,IAOXiB,EAAAA,UAAU,KACTL,EAAUI,SAAU,EACpBF,EAAUE,QAAUE,EAAAA,mBAEb,KACNN,EAAUI,SAAU,IAEnB,IAEHC,EAAAA,UACC,KAEChB,EAAMkB,QAAQC,MAAOC,EAAMC,KAC1B,IAC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