@trebired/frontend 0.3.0
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/CHANGELOG.md +30 -0
- package/LICENSE +661 -0
- package/README.md +212 -0
- package/dist/actions/buttons.d.ts +8 -0
- package/dist/actions/buttons.d.ts.map +1 -0
- package/dist/actions/buttons.js +116 -0
- package/dist/actions/buttons.js.map +1 -0
- package/dist/actions/components/index.d.ts +26 -0
- package/dist/actions/components/index.d.ts.map +1 -0
- package/dist/actions/components/index.js +25 -0
- package/dist/actions/components/index.js.map +1 -0
- package/dist/actions/confetti.d.ts +12 -0
- package/dist/actions/confetti.d.ts.map +1 -0
- package/dist/actions/confetti.js +36 -0
- package/dist/actions/confetti.js.map +1 -0
- package/dist/actions/forms.d.ts +12 -0
- package/dist/actions/forms.d.ts.map +1 -0
- package/dist/actions/forms.js +159 -0
- package/dist/actions/forms.js.map +1 -0
- package/dist/actions/index.d.ts +8 -0
- package/dist/actions/index.d.ts.map +1 -0
- package/dist/actions/index.js +7 -0
- package/dist/actions/index.js.map +1 -0
- package/dist/actions/request.d.ts +13 -0
- package/dist/actions/request.d.ts.map +1 -0
- package/dist/actions/request.js +83 -0
- package/dist/actions/request.js.map +1 -0
- package/dist/actions/response.d.ts +18 -0
- package/dist/actions/response.d.ts.map +1 -0
- package/dist/actions/response.js +104 -0
- package/dist/actions/response.js.map +1 -0
- package/dist/actions/styles/index.scss +42 -0
- package/dist/actions/triggers.d.ts +24 -0
- package/dist/actions/triggers.d.ts.map +1 -0
- package/dist/actions/triggers.js +107 -0
- package/dist/actions/triggers.js.map +1 -0
- package/dist/actions/types.d.ts +63 -0
- package/dist/actions/types.d.ts.map +1 -0
- package/dist/actions/types.js +2 -0
- package/dist/actions/types.js.map +1 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +11 -0
- package/dist/components/index.js.map +1 -0
- package/dist/dom/index.d.ts +26 -0
- package/dist/dom/index.d.ts.map +1 -0
- package/dist/dom/index.js +164 -0
- package/dist/dom/index.js.map +1 -0
- package/dist/flash/components/index.d.ts +28 -0
- package/dist/flash/components/index.d.ts.map +1 -0
- package/dist/flash/components/index.js +27 -0
- package/dist/flash/components/index.js.map +1 -0
- package/dist/flash/dialogs.d.ts +6 -0
- package/dist/flash/dialogs.d.ts.map +1 -0
- package/dist/flash/dialogs.js +120 -0
- package/dist/flash/dialogs.js.map +1 -0
- package/dist/flash/duration.d.ts +8 -0
- package/dist/flash/duration.d.ts.map +1 -0
- package/dist/flash/duration.js +20 -0
- package/dist/flash/duration.js.map +1 -0
- package/dist/flash/elements.d.ts +14 -0
- package/dist/flash/elements.d.ts.map +1 -0
- package/dist/flash/elements.js +67 -0
- package/dist/flash/elements.js.map +1 -0
- package/dist/flash/index.d.ts +8 -0
- package/dist/flash/index.d.ts.map +1 -0
- package/dist/flash/index.js +18 -0
- package/dist/flash/index.js.map +1 -0
- package/dist/flash/stack.d.ts +6 -0
- package/dist/flash/stack.d.ts.map +1 -0
- package/dist/flash/stack.js +56 -0
- package/dist/flash/stack.js.map +1 -0
- package/dist/flash/styles/index.scss +118 -0
- package/dist/flash/toast.d.ts +24 -0
- package/dist/flash/toast.d.ts.map +1 -0
- package/dist/flash/toast.js +67 -0
- package/dist/flash/toast.js.map +1 -0
- package/dist/flash/types.d.ts +29 -0
- package/dist/flash/types.d.ts.map +1 -0
- package/dist/flash/types.js +2 -0
- package/dist/flash/types.js.map +1 -0
- package/dist/http/index.d.ts +30 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/http/index.js +104 -0
- package/dist/http/index.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +104 -0
- package/dist/index.js.map +1 -0
- package/dist/inputs/components/index.d.ts +16 -0
- package/dist/inputs/components/index.d.ts.map +1 -0
- package/dist/inputs/components/index.js +112 -0
- package/dist/inputs/components/index.js.map +1 -0
- package/dist/inputs/index.d.ts +17 -0
- package/dist/inputs/index.d.ts.map +1 -0
- package/dist/inputs/index.js +54 -0
- package/dist/inputs/index.js.map +1 -0
- package/dist/inputs/styles/cropper.scss +244 -0
- package/dist/inputs/styles/field.scss +15 -0
- package/dist/inputs/styles/index.scss +3 -0
- package/dist/inputs/styles/upload.scss +125 -0
- package/dist/inputs/upload/config.d.ts +57 -0
- package/dist/inputs/upload/config.d.ts.map +1 -0
- package/dist/inputs/upload/config.js +61 -0
- package/dist/inputs/upload/config.js.map +1 -0
- package/dist/inputs/upload/crop-session.d.ts +6 -0
- package/dist/inputs/upload/crop-session.d.ts.map +1 -0
- package/dist/inputs/upload/crop-session.js +204 -0
- package/dist/inputs/upload/crop-session.js.map +1 -0
- package/dist/inputs/upload/crop.d.ts +20 -0
- package/dist/inputs/upload/crop.d.ts.map +1 -0
- package/dist/inputs/upload/crop.js +124 -0
- package/dist/inputs/upload/crop.js.map +1 -0
- package/dist/inputs/upload/dom.d.ts +19 -0
- package/dist/inputs/upload/dom.d.ts.map +1 -0
- package/dist/inputs/upload/dom.js +74 -0
- package/dist/inputs/upload/dom.js.map +1 -0
- package/dist/inputs/upload/drop.d.ts +10 -0
- package/dist/inputs/upload/drop.d.ts.map +1 -0
- package/dist/inputs/upload/drop.js +92 -0
- package/dist/inputs/upload/drop.js.map +1 -0
- package/dist/inputs/upload/files.d.ts +14 -0
- package/dist/inputs/upload/files.d.ts.map +1 -0
- package/dist/inputs/upload/files.js +82 -0
- package/dist/inputs/upload/files.js.map +1 -0
- package/dist/inputs/upload/manager.d.ts +36 -0
- package/dist/inputs/upload/manager.d.ts.map +1 -0
- package/dist/inputs/upload/manager.js +236 -0
- package/dist/inputs/upload/manager.js.map +1 -0
- package/dist/inputs/upload/markup.d.ts +30 -0
- package/dist/inputs/upload/markup.d.ts.map +1 -0
- package/dist/inputs/upload/markup.js +118 -0
- package/dist/inputs/upload/markup.js.map +1 -0
- package/dist/inputs/upload/model.d.ts +41 -0
- package/dist/inputs/upload/model.d.ts.map +1 -0
- package/dist/inputs/upload/model.js +76 -0
- package/dist/inputs/upload/model.js.map +1 -0
- package/dist/inputs/upload/state.d.ts +16 -0
- package/dist/inputs/upload/state.d.ts.map +1 -0
- package/dist/inputs/upload/state.js +181 -0
- package/dist/inputs/upload/state.js.map +1 -0
- package/dist/inputs/upload/text.d.ts +7 -0
- package/dist/inputs/upload/text.d.ts.map +1 -0
- package/dist/inputs/upload/text.js +29 -0
- package/dist/inputs/upload/text.js.map +1 -0
- package/dist/inputs/upload/types.d.ts +86 -0
- package/dist/inputs/upload/types.d.ts.map +1 -0
- package/dist/inputs/upload/types.js +2 -0
- package/dist/inputs/upload/types.js.map +1 -0
- package/dist/layer/components/index.d.ts +12 -0
- package/dist/layer/components/index.d.ts.map +1 -0
- package/dist/layer/components/index.js +12 -0
- package/dist/layer/components/index.js.map +1 -0
- package/dist/layer/index.d.ts +22 -0
- package/dist/layer/index.d.ts.map +1 -0
- package/dist/layer/index.js +159 -0
- package/dist/layer/index.js.map +1 -0
- package/dist/layer/styles/index.scss +6 -0
- package/dist/live/components/index.d.ts +15 -0
- package/dist/live/components/index.d.ts.map +1 -0
- package/dist/live/components/index.js +12 -0
- package/dist/live/components/index.js.map +1 -0
- package/dist/live/index.d.ts +29 -0
- package/dist/live/index.d.ts.map +1 -0
- package/dist/live/index.js +103 -0
- package/dist/live/index.js.map +1 -0
- package/dist/logging/index.d.ts +17 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/index.js +68 -0
- package/dist/logging/index.js.map +1 -0
- package/dist/modal/components/index.d.ts +18 -0
- package/dist/modal/components/index.d.ts.map +1 -0
- package/dist/modal/components/index.js +20 -0
- package/dist/modal/components/index.js.map +1 -0
- package/dist/modal/index.d.ts +24 -0
- package/dist/modal/index.d.ts.map +1 -0
- package/dist/modal/index.js +184 -0
- package/dist/modal/index.js.map +1 -0
- package/dist/modal/styles/index.scss +50 -0
- package/dist/popover/components/index.d.ts +14 -0
- package/dist/popover/components/index.d.ts.map +1 -0
- package/dist/popover/components/index.js +16 -0
- package/dist/popover/components/index.js.map +1 -0
- package/dist/popover/index.d.ts +16 -0
- package/dist/popover/index.d.ts.map +1 -0
- package/dist/popover/index.js +140 -0
- package/dist/popover/index.js.map +1 -0
- package/dist/popover/styles/index.scss +24 -0
- package/dist/progress/components/index.d.ts +10 -0
- package/dist/progress/components/index.d.ts.map +1 -0
- package/dist/progress/components/index.js +14 -0
- package/dist/progress/components/index.js.map +1 -0
- package/dist/progress/index.d.ts +18 -0
- package/dist/progress/index.d.ts.map +1 -0
- package/dist/progress/index.js +89 -0
- package/dist/progress/index.js.map +1 -0
- package/dist/progress/styles/index.scss +16 -0
- package/dist/react/index.d.ts +17 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +47 -0
- package/dist/react/index.js.map +1 -0
- package/dist/src/actions/buttons.d.ts +8 -0
- package/dist/src/actions/buttons.d.ts.map +1 -0
- package/dist/src/actions/buttons.js +116 -0
- package/dist/src/actions/buttons.js.map +1 -0
- package/dist/src/actions/components/index.d.ts +26 -0
- package/dist/src/actions/components/index.d.ts.map +1 -0
- package/dist/src/actions/components/index.js +25 -0
- package/dist/src/actions/components/index.js.map +1 -0
- package/dist/src/actions/confetti.d.ts +12 -0
- package/dist/src/actions/confetti.d.ts.map +1 -0
- package/dist/src/actions/confetti.js +36 -0
- package/dist/src/actions/confetti.js.map +1 -0
- package/dist/src/actions/forms.d.ts +12 -0
- package/dist/src/actions/forms.d.ts.map +1 -0
- package/dist/src/actions/forms.js +159 -0
- package/dist/src/actions/forms.js.map +1 -0
- package/dist/src/actions/index.d.ts +8 -0
- package/dist/src/actions/index.d.ts.map +1 -0
- package/dist/src/actions/index.js +7 -0
- package/dist/src/actions/index.js.map +1 -0
- package/dist/src/actions/request.d.ts +13 -0
- package/dist/src/actions/request.d.ts.map +1 -0
- package/dist/src/actions/request.js +83 -0
- package/dist/src/actions/request.js.map +1 -0
- package/dist/src/actions/response.d.ts +18 -0
- package/dist/src/actions/response.d.ts.map +1 -0
- package/dist/src/actions/response.js +104 -0
- package/dist/src/actions/response.js.map +1 -0
- package/dist/src/actions/triggers.d.ts +24 -0
- package/dist/src/actions/triggers.d.ts.map +1 -0
- package/dist/src/actions/triggers.js +107 -0
- package/dist/src/actions/triggers.js.map +1 -0
- package/dist/src/actions/types.d.ts +63 -0
- package/dist/src/actions/types.d.ts.map +1 -0
- package/dist/src/actions/types.js +2 -0
- package/dist/src/actions/types.js.map +1 -0
- package/dist/src/components/index.d.ts +5 -0
- package/dist/src/components/index.d.ts.map +1 -0
- package/dist/src/components/index.js +11 -0
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/dom/index.d.ts +26 -0
- package/dist/src/dom/index.d.ts.map +1 -0
- package/dist/src/dom/index.js +164 -0
- package/dist/src/dom/index.js.map +1 -0
- package/dist/src/flash/components/index.d.ts +28 -0
- package/dist/src/flash/components/index.d.ts.map +1 -0
- package/dist/src/flash/components/index.js +27 -0
- package/dist/src/flash/components/index.js.map +1 -0
- package/dist/src/flash/dialogs.d.ts +6 -0
- package/dist/src/flash/dialogs.d.ts.map +1 -0
- package/dist/src/flash/dialogs.js +120 -0
- package/dist/src/flash/dialogs.js.map +1 -0
- package/dist/src/flash/duration.d.ts +8 -0
- package/dist/src/flash/duration.d.ts.map +1 -0
- package/dist/src/flash/duration.js +20 -0
- package/dist/src/flash/duration.js.map +1 -0
- package/dist/src/flash/elements.d.ts +14 -0
- package/dist/src/flash/elements.d.ts.map +1 -0
- package/dist/src/flash/elements.js +67 -0
- package/dist/src/flash/elements.js.map +1 -0
- package/dist/src/flash/index.d.ts +8 -0
- package/dist/src/flash/index.d.ts.map +1 -0
- package/dist/src/flash/index.js +18 -0
- package/dist/src/flash/index.js.map +1 -0
- package/dist/src/flash/stack.d.ts +6 -0
- package/dist/src/flash/stack.d.ts.map +1 -0
- package/dist/src/flash/stack.js +56 -0
- package/dist/src/flash/stack.js.map +1 -0
- package/dist/src/flash/toast.d.ts +24 -0
- package/dist/src/flash/toast.d.ts.map +1 -0
- package/dist/src/flash/toast.js +67 -0
- package/dist/src/flash/toast.js.map +1 -0
- package/dist/src/flash/types.d.ts +29 -0
- package/dist/src/flash/types.d.ts.map +1 -0
- package/dist/src/flash/types.js +2 -0
- package/dist/src/flash/types.js.map +1 -0
- package/dist/src/http/index.d.ts +30 -0
- package/dist/src/http/index.d.ts.map +1 -0
- package/dist/src/http/index.js +104 -0
- package/dist/src/http/index.js.map +1 -0
- package/dist/src/index.d.ts +40 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +104 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/inputs/components/index.d.ts +16 -0
- package/dist/src/inputs/components/index.d.ts.map +1 -0
- package/dist/src/inputs/components/index.js +112 -0
- package/dist/src/inputs/components/index.js.map +1 -0
- package/dist/src/inputs/index.d.ts +17 -0
- package/dist/src/inputs/index.d.ts.map +1 -0
- package/dist/src/inputs/index.js +54 -0
- package/dist/src/inputs/index.js.map +1 -0
- package/dist/src/inputs/upload/config.d.ts +57 -0
- package/dist/src/inputs/upload/config.d.ts.map +1 -0
- package/dist/src/inputs/upload/config.js +61 -0
- package/dist/src/inputs/upload/config.js.map +1 -0
- package/dist/src/inputs/upload/crop-session.d.ts +6 -0
- package/dist/src/inputs/upload/crop-session.d.ts.map +1 -0
- package/dist/src/inputs/upload/crop-session.js +204 -0
- package/dist/src/inputs/upload/crop-session.js.map +1 -0
- package/dist/src/inputs/upload/crop.d.ts +20 -0
- package/dist/src/inputs/upload/crop.d.ts.map +1 -0
- package/dist/src/inputs/upload/crop.js +124 -0
- package/dist/src/inputs/upload/crop.js.map +1 -0
- package/dist/src/inputs/upload/dom.d.ts +19 -0
- package/dist/src/inputs/upload/dom.d.ts.map +1 -0
- package/dist/src/inputs/upload/dom.js +74 -0
- package/dist/src/inputs/upload/dom.js.map +1 -0
- package/dist/src/inputs/upload/drop.d.ts +10 -0
- package/dist/src/inputs/upload/drop.d.ts.map +1 -0
- package/dist/src/inputs/upload/drop.js +92 -0
- package/dist/src/inputs/upload/drop.js.map +1 -0
- package/dist/src/inputs/upload/files.d.ts +14 -0
- package/dist/src/inputs/upload/files.d.ts.map +1 -0
- package/dist/src/inputs/upload/files.js +82 -0
- package/dist/src/inputs/upload/files.js.map +1 -0
- package/dist/src/inputs/upload/manager.d.ts +36 -0
- package/dist/src/inputs/upload/manager.d.ts.map +1 -0
- package/dist/src/inputs/upload/manager.js +236 -0
- package/dist/src/inputs/upload/manager.js.map +1 -0
- package/dist/src/inputs/upload/markup.d.ts +30 -0
- package/dist/src/inputs/upload/markup.d.ts.map +1 -0
- package/dist/src/inputs/upload/markup.js +118 -0
- package/dist/src/inputs/upload/markup.js.map +1 -0
- package/dist/src/inputs/upload/model.d.ts +41 -0
- package/dist/src/inputs/upload/model.d.ts.map +1 -0
- package/dist/src/inputs/upload/model.js +76 -0
- package/dist/src/inputs/upload/model.js.map +1 -0
- package/dist/src/inputs/upload/state.d.ts +16 -0
- package/dist/src/inputs/upload/state.d.ts.map +1 -0
- package/dist/src/inputs/upload/state.js +181 -0
- package/dist/src/inputs/upload/state.js.map +1 -0
- package/dist/src/inputs/upload/text.d.ts +7 -0
- package/dist/src/inputs/upload/text.d.ts.map +1 -0
- package/dist/src/inputs/upload/text.js +29 -0
- package/dist/src/inputs/upload/text.js.map +1 -0
- package/dist/src/inputs/upload/types.d.ts +86 -0
- package/dist/src/inputs/upload/types.d.ts.map +1 -0
- package/dist/src/inputs/upload/types.js +2 -0
- package/dist/src/inputs/upload/types.js.map +1 -0
- package/dist/src/layer/components/index.d.ts +12 -0
- package/dist/src/layer/components/index.d.ts.map +1 -0
- package/dist/src/layer/components/index.js +12 -0
- package/dist/src/layer/components/index.js.map +1 -0
- package/dist/src/layer/index.d.ts +22 -0
- package/dist/src/layer/index.d.ts.map +1 -0
- package/dist/src/layer/index.js +159 -0
- package/dist/src/layer/index.js.map +1 -0
- package/dist/src/live/components/index.d.ts +15 -0
- package/dist/src/live/components/index.d.ts.map +1 -0
- package/dist/src/live/components/index.js +12 -0
- package/dist/src/live/components/index.js.map +1 -0
- package/dist/src/live/index.d.ts +29 -0
- package/dist/src/live/index.d.ts.map +1 -0
- package/dist/src/live/index.js +103 -0
- package/dist/src/live/index.js.map +1 -0
- package/dist/src/logging/index.d.ts +17 -0
- package/dist/src/logging/index.d.ts.map +1 -0
- package/dist/src/logging/index.js +68 -0
- package/dist/src/logging/index.js.map +1 -0
- package/dist/src/modal/components/index.d.ts +18 -0
- package/dist/src/modal/components/index.d.ts.map +1 -0
- package/dist/src/modal/components/index.js +20 -0
- package/dist/src/modal/components/index.js.map +1 -0
- package/dist/src/modal/index.d.ts +24 -0
- package/dist/src/modal/index.d.ts.map +1 -0
- package/dist/src/modal/index.js +184 -0
- package/dist/src/modal/index.js.map +1 -0
- package/dist/src/popover/components/index.d.ts +14 -0
- package/dist/src/popover/components/index.d.ts.map +1 -0
- package/dist/src/popover/components/index.js +16 -0
- package/dist/src/popover/components/index.js.map +1 -0
- package/dist/src/popover/index.d.ts +16 -0
- package/dist/src/popover/index.d.ts.map +1 -0
- package/dist/src/popover/index.js +140 -0
- package/dist/src/popover/index.js.map +1 -0
- package/dist/src/progress/components/index.d.ts +10 -0
- package/dist/src/progress/components/index.d.ts.map +1 -0
- package/dist/src/progress/components/index.js +14 -0
- package/dist/src/progress/components/index.js.map +1 -0
- package/dist/src/progress/index.d.ts +18 -0
- package/dist/src/progress/index.d.ts.map +1 -0
- package/dist/src/progress/index.js +89 -0
- package/dist/src/progress/index.js.map +1 -0
- package/dist/src/react/index.d.ts +17 -0
- package/dist/src/react/index.d.ts.map +1 -0
- package/dist/src/react/index.js +47 -0
- package/dist/src/react/index.js.map +1 -0
- package/dist/src/styles/index.d.ts +3 -0
- package/dist/src/styles/index.d.ts.map +1 -0
- package/dist/src/styles/index.js +14 -0
- package/dist/src/styles/index.js.map +1 -0
- package/dist/src/theme/components/index.d.ts +14 -0
- package/dist/src/theme/components/index.d.ts.map +1 -0
- package/dist/src/theme/components/index.js +13 -0
- package/dist/src/theme/components/index.js.map +1 -0
- package/dist/src/theme/index.d.ts +26 -0
- package/dist/src/theme/index.d.ts.map +1 -0
- package/dist/src/theme/index.js +119 -0
- package/dist/src/theme/index.js.map +1 -0
- package/dist/src/tooltip/components/index.d.ts +17 -0
- package/dist/src/tooltip/components/index.d.ts.map +1 -0
- package/dist/src/tooltip/components/index.js +20 -0
- package/dist/src/tooltip/components/index.js.map +1 -0
- package/dist/src/tooltip/index.d.ts +10 -0
- package/dist/src/tooltip/index.d.ts.map +1 -0
- package/dist/src/tooltip/index.js +171 -0
- package/dist/src/tooltip/index.js.map +1 -0
- package/dist/styles/index.d.ts +3 -0
- package/dist/styles/index.d.ts.map +1 -0
- package/dist/styles/index.js +14 -0
- package/dist/styles/index.js.map +1 -0
- package/dist/styles/tokens.scss +22 -0
- package/dist/styles/utils.scss +220 -0
- package/dist/theme/components/index.d.ts +14 -0
- package/dist/theme/components/index.d.ts.map +1 -0
- package/dist/theme/components/index.js +13 -0
- package/dist/theme/components/index.js.map +1 -0
- package/dist/theme/index.d.ts +26 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +119 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/tooltip/components/index.d.ts +17 -0
- package/dist/tooltip/components/index.d.ts.map +1 -0
- package/dist/tooltip/components/index.js +20 -0
- package/dist/tooltip/components/index.js.map +1 -0
- package/dist/tooltip/index.d.ts +10 -0
- package/dist/tooltip/index.d.ts.map +1 -0
- package/dist/tooltip/index.js +171 -0
- package/dist/tooltip/index.js.map +1 -0
- package/dist/tooltip/styles/index.scss +17 -0
- package/package.json +232 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { dispatchInputChange, queryAll, resolveDocumentTarget, } from "../../dom/index.js";
|
|
2
|
+
import { UPLOAD_SELECTOR, bindUploadRoot, bindUploads, bootUploadManager, clearUpload, getUploadEntries, getUploadFiles, openUploadCropSession, setSelectedEntries, setUploadFiles, uploadManager, } from "./upload/manager.js";
|
|
3
|
+
import { createUploadField, uploadConfigPayload, uploadFieldHtml, } from "./upload/markup.js";
|
|
4
|
+
import { matchesAccept, parseAcceptList } from "./upload/files.js";
|
|
5
|
+
const AUTOSIZE_SELECTOR = "textarea[data-tbf-autosize]";
|
|
6
|
+
const CLEAR_SELECTOR = "[data-tbf-clear]";
|
|
7
|
+
const PASSWORD_TOGGLE_SELECTOR = "[data-tbf-password-toggle][aria-controls]";
|
|
8
|
+
function resizeTextarea(textarea) {
|
|
9
|
+
textarea.style.height = "auto";
|
|
10
|
+
textarea.style.height = `${textarea.scrollHeight}px`;
|
|
11
|
+
}
|
|
12
|
+
function bindAutosizeTextarea(textarea) {
|
|
13
|
+
if (textarea.hasAttribute("data-tbf-autosize-bound"))
|
|
14
|
+
return false;
|
|
15
|
+
textarea.setAttribute("data-tbf-autosize-bound", "true");
|
|
16
|
+
textarea.addEventListener("input", () => resizeTextarea(textarea));
|
|
17
|
+
resizeTextarea(textarea);
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
function bindClearButton(button) {
|
|
21
|
+
if (button.hasAttribute("data-tbf-clear-bound"))
|
|
22
|
+
return false;
|
|
23
|
+
button.setAttribute("data-tbf-clear-bound", "true");
|
|
24
|
+
button.addEventListener("click", () => {
|
|
25
|
+
const target = resolveDocumentTarget(button.getAttribute("data-tbf-clear"));
|
|
26
|
+
if (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement) {
|
|
27
|
+
target.value = "";
|
|
28
|
+
dispatchInputChange(target);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
function bindPasswordToggle(button) {
|
|
34
|
+
if (button.hasAttribute("data-tbf-password-bound"))
|
|
35
|
+
return false;
|
|
36
|
+
button.setAttribute("data-tbf-password-bound", "true");
|
|
37
|
+
button.addEventListener("click", () => {
|
|
38
|
+
const input = resolveDocumentTarget(button.getAttribute("aria-controls"));
|
|
39
|
+
if (!(input instanceof HTMLInputElement))
|
|
40
|
+
return;
|
|
41
|
+
const show = input.type === "password";
|
|
42
|
+
input.type = show ? "text" : "password";
|
|
43
|
+
button.setAttribute("aria-pressed", show ? "true" : "false");
|
|
44
|
+
});
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
function bindInputControllers(root = document, options = {}) {
|
|
48
|
+
queryAll(root, AUTOSIZE_SELECTOR).forEach(bindAutosizeTextarea);
|
|
49
|
+
queryAll(root, CLEAR_SELECTOR).forEach(bindClearButton);
|
|
50
|
+
queryAll(root, PASSWORD_TOGGLE_SELECTOR).forEach(bindPasswordToggle);
|
|
51
|
+
bindUploads(root, options);
|
|
52
|
+
}
|
|
53
|
+
export { AUTOSIZE_SELECTOR, CLEAR_SELECTOR, PASSWORD_TOGGLE_SELECTOR, UPLOAD_SELECTOR, bindAutosizeTextarea, bindClearButton, bindInputControllers, bindPasswordToggle, bindUploadRoot, bindUploads, bootUploadManager, clearUpload, createUploadField, getUploadEntries, getUploadFiles, matchesAccept, openUploadCropSession, parseAcceptList, setSelectedEntries, setUploadFiles, uploadConfigPayload, uploadFieldHtml, uploadManager, };
|
|
54
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/inputs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,QAAQ,EACR,qBAAqB,GAEtB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,eAAe,EACf,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACd,aAAa,GACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MA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AChB,cAAc,EACd,aAAa,EACb,qBAAqB,EACrB,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,aAAa,GACd,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { UploadRootConfig } from "./types.js";
|
|
2
|
+
declare const UPLOAD_CONFIG_SELECTOR = "script[type=\"application/json\"][data-tbf-upload-config]";
|
|
3
|
+
declare const DEFAULT_EMPTY_LABEL = "No file selected";
|
|
4
|
+
declare function normalizeUploadConfig(config?: UploadRootConfig): {
|
|
5
|
+
allowDirectory: boolean;
|
|
6
|
+
allowDrop: boolean;
|
|
7
|
+
allowDropDirectory: boolean;
|
|
8
|
+
allowMixedPicker: boolean;
|
|
9
|
+
allowMultiple: boolean;
|
|
10
|
+
aspect: string;
|
|
11
|
+
canClearCurrentPreview: boolean;
|
|
12
|
+
crop: boolean;
|
|
13
|
+
cropFailedMessage: string;
|
|
14
|
+
cropImageOnlyDescription: string;
|
|
15
|
+
cropImageOnlyMessage: string;
|
|
16
|
+
currentPreviewUrl: string;
|
|
17
|
+
emptyLabel: string;
|
|
18
|
+
emptyToggleValue: string;
|
|
19
|
+
formatNotAllowedDescription: string;
|
|
20
|
+
formatNotAllowedMessage: string;
|
|
21
|
+
formats: string;
|
|
22
|
+
modalDescription: string;
|
|
23
|
+
modalTitle: string;
|
|
24
|
+
noPreview: boolean;
|
|
25
|
+
skipDirs: string;
|
|
26
|
+
useImageLabel: string;
|
|
27
|
+
};
|
|
28
|
+
declare function readUploadConfig(root: HTMLElement | null): {
|
|
29
|
+
allowDirectory: boolean;
|
|
30
|
+
allowDrop: boolean;
|
|
31
|
+
allowDropDirectory: boolean;
|
|
32
|
+
allowMixedPicker: boolean;
|
|
33
|
+
allowMultiple: boolean;
|
|
34
|
+
aspect: string;
|
|
35
|
+
canClearCurrentPreview: boolean;
|
|
36
|
+
crop: boolean;
|
|
37
|
+
cropFailedMessage: string;
|
|
38
|
+
cropImageOnlyDescription: string;
|
|
39
|
+
cropImageOnlyMessage: string;
|
|
40
|
+
currentPreviewUrl: string;
|
|
41
|
+
emptyLabel: string;
|
|
42
|
+
emptyToggleValue: string;
|
|
43
|
+
formatNotAllowedDescription: string;
|
|
44
|
+
formatNotAllowedMessage: string;
|
|
45
|
+
formats: string;
|
|
46
|
+
modalDescription: string;
|
|
47
|
+
modalTitle: string;
|
|
48
|
+
noPreview: boolean;
|
|
49
|
+
skipDirs: string;
|
|
50
|
+
useImageLabel: string;
|
|
51
|
+
};
|
|
52
|
+
declare function setUploadRootConfig(root: HTMLElement | null, config?: UploadRootConfig): boolean;
|
|
53
|
+
declare function uploadRootConfig(root: HTMLElement | null): UploadRootConfig;
|
|
54
|
+
declare function isUploadDropRoot(element: Element | null): boolean;
|
|
55
|
+
export { DEFAULT_EMPTY_LABEL, UPLOAD_CONFIG_SELECTOR, isUploadDropRoot, normalizeUploadConfig, readUploadConfig, setUploadRootConfig, uploadRootConfig, };
|
|
56
|
+
export type { UploadRootConfig };
|
|
57
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/inputs/upload/config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,QAAA,MAAM,sBAAsB,8DAC+B,CAAC;AAE5D,QAAA,MAAM,mBAAmB,qBAAqB,CAAC;AAI/C,iBAAS,qBAAqB,CAAC,MAAM,GAAE,gBAAqB;;;;;;;;;;;;;;;;;;;;;;;EAyB3D;AAED,iBAAS,gBAAgB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;;;;;;;;;;;;;;;;;;;;;;;EAKjD;AAED,iBAAS,mBAAmB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,EAAE,MAAM,GAAE,gBAAqB,WAInF;AAED,iBAAS,gBAAgB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,oBAOjD;AAED,iBAAS,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,WAIhD;AAED,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,GACjB,CAAC;AACF,YAAY,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { parseJsonText, readElementJson } from "../../../dom/index.js";
|
|
2
|
+
import { bool, toText } from "./text.js";
|
|
3
|
+
const UPLOAD_CONFIG_SELECTOR = 'script[type="application/json"][data-tbf-upload-config]';
|
|
4
|
+
const DEFAULT_EMPTY_LABEL = "No file selected";
|
|
5
|
+
const uploadConfigs = new WeakMap();
|
|
6
|
+
function normalizeUploadConfig(config = {}) {
|
|
7
|
+
return {
|
|
8
|
+
allowDirectory: bool(config.allowDirectory),
|
|
9
|
+
allowDrop: bool(config.allowDrop),
|
|
10
|
+
allowDropDirectory: bool(config.allowDropDirectory),
|
|
11
|
+
allowMixedPicker: bool(config.allowMixedPicker),
|
|
12
|
+
allowMultiple: bool(config.allowMultiple),
|
|
13
|
+
aspect: toText(config.aspect),
|
|
14
|
+
canClearCurrentPreview: bool(config.canClearCurrentPreview),
|
|
15
|
+
crop: bool(config.crop),
|
|
16
|
+
cropFailedMessage: toText(config.cropFailedMessage, "Failed to crop the selected image."),
|
|
17
|
+
cropImageOnlyDescription: toText(config.cropImageOnlyDescription, "Choose an accepted image file."),
|
|
18
|
+
cropImageOnlyMessage: toText(config.cropImageOnlyMessage, "Only image files can be cropped."),
|
|
19
|
+
currentPreviewUrl: toText(config.currentPreviewUrl),
|
|
20
|
+
emptyLabel: toText(config.emptyLabel, DEFAULT_EMPTY_LABEL),
|
|
21
|
+
emptyToggleValue: toText(config.emptyToggleValue, "1"),
|
|
22
|
+
formatNotAllowedDescription: toText(config.formatNotAllowedDescription, "Choose an accepted file format."),
|
|
23
|
+
formatNotAllowedMessage: toText(config.formatNotAllowedMessage, "File format not allowed."),
|
|
24
|
+
formats: toText(config.formats),
|
|
25
|
+
modalDescription: toText(config.modalDescription, "Adjust the crop before saving."),
|
|
26
|
+
modalTitle: toText(config.modalTitle, "Crop image"),
|
|
27
|
+
noPreview: bool(config.noPreview),
|
|
28
|
+
skipDirs: toText(config.skipDirs),
|
|
29
|
+
useImageLabel: toText(config.useImageLabel, "Use image"),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function readUploadConfig(root) {
|
|
33
|
+
if (!(root instanceof HTMLElement))
|
|
34
|
+
return normalizeUploadConfig();
|
|
35
|
+
const fromScript = readElementJson(root, UPLOAD_CONFIG_SELECTOR, {});
|
|
36
|
+
const fromAttr = parseJsonText(root.getAttribute("data-tbf-upload-config") || "", {});
|
|
37
|
+
return normalizeUploadConfig({ ...fromScript, ...fromAttr });
|
|
38
|
+
}
|
|
39
|
+
function setUploadRootConfig(root, config = {}) {
|
|
40
|
+
if (!(root instanceof HTMLElement))
|
|
41
|
+
return false;
|
|
42
|
+
uploadConfigs.set(root, normalizeUploadConfig(config));
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
function uploadRootConfig(root) {
|
|
46
|
+
if (!(root instanceof HTMLElement))
|
|
47
|
+
return normalizeUploadConfig();
|
|
48
|
+
const config = uploadConfigs.get(root);
|
|
49
|
+
if (config)
|
|
50
|
+
return config;
|
|
51
|
+
const next = readUploadConfig(root);
|
|
52
|
+
uploadConfigs.set(root, next);
|
|
53
|
+
return next;
|
|
54
|
+
}
|
|
55
|
+
function isUploadDropRoot(element) {
|
|
56
|
+
return element instanceof HTMLElement
|
|
57
|
+
? uploadRootConfig(element).allowDrop === true
|
|
58
|
+
: false;
|
|
59
|
+
}
|
|
60
|
+
export { DEFAULT_EMPTY_LABEL, UPLOAD_CONFIG_SELECTOR, isUploadDropRoot, normalizeUploadConfig, readUploadConfig, setUploadRootConfig, uploadRootConfig, };
|
|
61
|
+
//# sourceMappingUR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,IAAI,CAAC;AACd,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAwB;IAChD,IAAI,CAAC,CAAC,IAAI,YAAY,WAAW,CAAC;QAAE,OAAO,qBAAqB,EAAE,CAAC;IACnE,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACvC,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1B,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACpC,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC9B,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,gBAAgB,CAAC,OAAuB;IAC/C,OAAO,OAAO,YAAY,WAAW;QACnC,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,SAAS,KAAK,IAAI;QAC9C,CAAC,CAAC,KAAK,CAAC;AACZ,CAAC;AAED,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,GACjB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { UploadRuntimeOptions } from "./types.js";
|
|
2
|
+
declare const CROP_MODAL_ID = "tbf_upload_crop_modal";
|
|
3
|
+
declare const CROP_MODAL_CONTENT_ID = "tbf_upload_crop_modal_content";
|
|
4
|
+
declare function openUploadCropSession(root: HTMLElement, input: HTMLInputElement | null, file: File, trigger: HTMLElement | null, options?: UploadRuntimeOptions): Promise<boolean>;
|
|
5
|
+
export { CROP_MODAL_CONTENT_ID, CROP_MODAL_ID, openUploadCropSession };
|
|
6
|
+
//# sourceMappingURL=crop-session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crop-session.d.ts","sourceRoot":"","sources":["../../../../src/inputs/upload/crop-session.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AA0BvD,QAAA,MAAM,aAAa,0BAA0B,CAAC;AAC9C,QAAA,MAAM,qBAAqB,kCAAkC,CAAC;AAoL9D,iBAAe,qBAAqB,CAClC,IAAI,EAAE,WAAW,EACjB,KAAK,EAAE,gBAAgB,GAAG,IAAI,EAC9B,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,WAAW,GAAG,IAAI,EAC3B,OAAO,GAAE,oBAAyB,oBAyBnC;AAED,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import Cropper from "cropperjs";
|
|
2
|
+
import { createElement as h, useEffect, useRef, } from "react";
|
|
3
|
+
import { flushSync } from "react-dom";
|
|
4
|
+
import { createRoot } from "react-dom/client";
|
|
5
|
+
import { flash as defaultFlash } from "../../../flash/index.js";
|
|
6
|
+
import { closeModal, openModal, prepareModal } from "../../../modal/index.js";
|
|
7
|
+
import { resolveFrontendLogger } from "../../../logging/index.js";
|
|
8
|
+
import { uploadRootConfig } from "./config.js";
|
|
9
|
+
import { buildCropData, canvasToPreviewUrl, parseAspectRatio, prepareCropSource, } from "./crop.js";
|
|
10
|
+
import { dispatchUploadChange, setUploadFile } from "./state.js";
|
|
11
|
+
const CROP_MODAL_ID = "tbf_upload_crop_modal";
|
|
12
|
+
const CROP_MODAL_CONTENT_ID = "tbf_upload_crop_modal_content";
|
|
13
|
+
let modalElement = null;
|
|
14
|
+
let modalContentElement = null;
|
|
15
|
+
let modalRoot = null;
|
|
16
|
+
let activeCropper = null;
|
|
17
|
+
let activeSession = null;
|
|
18
|
+
function loggerFor(options = {}) {
|
|
19
|
+
return resolveFrontendLogger(options.logging);
|
|
20
|
+
}
|
|
21
|
+
function flashFor(options = {}) {
|
|
22
|
+
return options.flash || defaultFlash;
|
|
23
|
+
}
|
|
24
|
+
function patchSession(patch) {
|
|
25
|
+
if (!activeSession)
|
|
26
|
+
return;
|
|
27
|
+
activeSession = { ...activeSession, ...patch };
|
|
28
|
+
renderCropModal();
|
|
29
|
+
}
|
|
30
|
+
function useUploadCropper(props, imageRef) {
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (!props.imageUrl || !imageRef.current)
|
|
33
|
+
return undefined;
|
|
34
|
+
const cropper = new Cropper(imageRef.current, {
|
|
35
|
+
aspectRatio: Number.isFinite(props.aspectRatio) ? props.aspectRatio : Number.NaN,
|
|
36
|
+
autoCropArea: 1,
|
|
37
|
+
background: false,
|
|
38
|
+
checkOrientation: false,
|
|
39
|
+
dragMode: "move",
|
|
40
|
+
guides: true,
|
|
41
|
+
modal: true,
|
|
42
|
+
responsive: true,
|
|
43
|
+
restore: false,
|
|
44
|
+
toggleDragModeOnDblclick: false,
|
|
45
|
+
viewMode: 1,
|
|
46
|
+
zoomable: true,
|
|
47
|
+
ready() {
|
|
48
|
+
props.onReadyChange(true);
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
props.registerCropper(cropper);
|
|
52
|
+
return () => {
|
|
53
|
+
props.onReadyChange(false);
|
|
54
|
+
props.registerCropper(null);
|
|
55
|
+
cropper.destroy();
|
|
56
|
+
};
|
|
57
|
+
}, [imageRef, props.aspectRatio, props.imageUrl]);
|
|
58
|
+
}
|
|
59
|
+
function CropperView(props) {
|
|
60
|
+
const imageRef = useRef(null);
|
|
61
|
+
useUploadCropper(props, imageRef);
|
|
62
|
+
return h("div", { className: "tbf-upload-crop" }, h("div", { className: "tbf-upload-crop__header" }, h("h2", { className: "tbf-upload-crop__title" }, props.title), props.description
|
|
63
|
+
? h("p", { className: "tbf-upload-crop__description" }, props.description)
|
|
64
|
+
: null), h("div", { className: "tbf-upload-crop__stage" }, h("img", {
|
|
65
|
+
alt: props.title,
|
|
66
|
+
className: "tbf-upload-crop__image",
|
|
67
|
+
ref: imageRef,
|
|
68
|
+
src: props.imageUrl,
|
|
69
|
+
})), h("div", { className: "tbf-upload-crop__actions" }, h("button", {
|
|
70
|
+
className: "tbf-upload__button",
|
|
71
|
+
disabled: props.busy,
|
|
72
|
+
onClick: props.onCancel,
|
|
73
|
+
type: "button",
|
|
74
|
+
}, "Cancel"), h("button", {
|
|
75
|
+
className: "tbf-upload__button tbf-upload__button--strong",
|
|
76
|
+
disabled: props.busy || !props.ready,
|
|
77
|
+
onClick: props.onConfirm,
|
|
78
|
+
type: "button",
|
|
79
|
+
}, props.busy ? "Saving" : uploadRootConfig(props.root).useImageLabel)));
|
|
80
|
+
}
|
|
81
|
+
function ensureCropModalHost() {
|
|
82
|
+
if (modalElement && modalContentElement && modalRoot)
|
|
83
|
+
return true;
|
|
84
|
+
modalElement = document.getElementById(CROP_MODAL_ID);
|
|
85
|
+
modalContentElement = document.getElementById(CROP_MODAL_CONTENT_ID);
|
|
86
|
+
if (!modalElement)
|
|
87
|
+
createCropModalHost();
|
|
88
|
+
if (modalElement && !modalContentElement) {
|
|
89
|
+
modalContentElement = modalElement.querySelector("[data-tbf-modal-content]");
|
|
90
|
+
}
|
|
91
|
+
if (!modalElement || !modalContentElement)
|
|
92
|
+
return false;
|
|
93
|
+
prepareModal(modalElement);
|
|
94
|
+
modalRoot || (modalRoot = createRoot(modalContentElement));
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
function createCropModalHost() {
|
|
98
|
+
modalElement = document.createElement("div");
|
|
99
|
+
modalElement.id = CROP_MODAL_ID;
|
|
100
|
+
modalElement.className = "tbf-modal tbf-upload-cropper-modal";
|
|
101
|
+
modalElement.setAttribute("data-tbf-modal", "");
|
|
102
|
+
modalContentElement = document.createElement("div");
|
|
103
|
+
modalContentElement.id = CROP_MODAL_CONTENT_ID;
|
|
104
|
+
modalContentElement.className = "tbf-modal__content tbf-upload-cropper-modal__content";
|
|
105
|
+
modalContentElement.setAttribute("data-tbf-modal-content", "");
|
|
106
|
+
modalElement.appendChild(modalContentElement);
|
|
107
|
+
document.body.appendChild(modalElement);
|
|
108
|
+
}
|
|
109
|
+
function renderCropModal(sync = false) {
|
|
110
|
+
if (!modalRoot || !activeSession)
|
|
111
|
+
return;
|
|
112
|
+
const node = h(CropperView, {
|
|
113
|
+
...activeSession,
|
|
114
|
+
onCancel: cancelCropSession,
|
|
115
|
+
onConfirm: () => void confirmCropSession(),
|
|
116
|
+
onReadyChange(ready) {
|
|
117
|
+
patchSession({ ready });
|
|
118
|
+
},
|
|
119
|
+
registerCropper(cropper) {
|
|
120
|
+
activeCropper = cropper;
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
if (sync)
|
|
124
|
+
flushSync(() => modalRoot?.render(node));
|
|
125
|
+
else
|
|
126
|
+
modalRoot.render(node);
|
|
127
|
+
}
|
|
128
|
+
function closeCropSession() {
|
|
129
|
+
activeSession?.revoke();
|
|
130
|
+
activeSession = null;
|
|
131
|
+
activeCropper = null;
|
|
132
|
+
closeModal(modalElement);
|
|
133
|
+
}
|
|
134
|
+
function cancelCropSession() {
|
|
135
|
+
closeCropSession();
|
|
136
|
+
}
|
|
137
|
+
function croppedCanvas(cropper) {
|
|
138
|
+
return cropper.getCroppedCanvas({
|
|
139
|
+
fillColor: "#fff",
|
|
140
|
+
imageSmoothingEnabled: true,
|
|
141
|
+
imageSmoothingQuality: "high",
|
|
142
|
+
maxHeight: 1024,
|
|
143
|
+
maxWidth: 1024,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
async function confirmCropSession() {
|
|
147
|
+
const session = activeSession;
|
|
148
|
+
const cropper = activeCropper;
|
|
149
|
+
if (!session || !cropper)
|
|
150
|
+
return;
|
|
151
|
+
patchSession({ busy: true });
|
|
152
|
+
try {
|
|
153
|
+
const cropData = buildCropData(cropper, session.scale);
|
|
154
|
+
if (!cropData || cropData.width <= 0 || cropData.height <= 0) {
|
|
155
|
+
throw new Error(uploadRootConfig(session.root).cropFailedMessage);
|
|
156
|
+
}
|
|
157
|
+
const previewUrl = await canvasToPreviewUrl(croppedCanvas(cropper), session.file.type || "image/png");
|
|
158
|
+
setUploadFile(session.root, session.input, session.file, { cropData, previewUrl });
|
|
159
|
+
dispatchUploadChange(session.root);
|
|
160
|
+
loggerFor(session.options).info("upload.crop", "confirmed", { file: session.file.name });
|
|
161
|
+
closeCropSession();
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
reportCropFailure(session, error);
|
|
165
|
+
patchSession({ busy: false });
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function reportCropFailure(session, error) {
|
|
169
|
+
const config = uploadRootConfig(session.root);
|
|
170
|
+
loggerFor(session.options).warn("upload.crop", "failed", {
|
|
171
|
+
error: error instanceof Error ? error.message : String(error),
|
|
172
|
+
file: session.file.name,
|
|
173
|
+
});
|
|
174
|
+
flashFor(session.options).error?.(config.cropFailedMessage, "");
|
|
175
|
+
}
|
|
176
|
+
async function openUploadCropSession(root, input, file, trigger, options = {}) {
|
|
177
|
+
if (!ensureCropModalHost())
|
|
178
|
+
return false;
|
|
179
|
+
const prepared = await prepareCropSource(file);
|
|
180
|
+
if (!prepared.imageUrl)
|
|
181
|
+
return false;
|
|
182
|
+
const config = uploadRootConfig(root);
|
|
183
|
+
activeSession = {
|
|
184
|
+
aspectRatio: parseAspectRatio(config.aspect),
|
|
185
|
+
busy: false,
|
|
186
|
+
description: String(config.modalDescription || ""),
|
|
187
|
+
file,
|
|
188
|
+
imageUrl: prepared.imageUrl,
|
|
189
|
+
input,
|
|
190
|
+
options,
|
|
191
|
+
ready: false,
|
|
192
|
+
revoke: prepared.revoke,
|
|
193
|
+
root,
|
|
194
|
+
scale: { scaleX: prepared.scaleX, scaleY: prepared.scaleY },
|
|
195
|
+
title: String(config.modalTitle || "Crop image"),
|
|
196
|
+
trigger,
|
|
197
|
+
};
|
|
198
|
+
renderCropModal(true);
|
|
199
|
+
openModal(modalElement, trigger);
|
|
200
|
+
loggerFor(options).info("upload.crop", "opened", { file: file.name });
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
export { CROP_MODAL_CONTENT_ID, CROP_MODAL_ID, openUploadCropSession };
|
|
204
|
+
//# sourceMappingURL=crop-session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crop-session.js","sourceRoot":"","sources":["../../../../src/inputs/upload/crop-session.tsx"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,EACL,aAAa,IAAI,CAAC,EAClB,SAAS,EACT,MAAM,GAEP,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,UAAU,EAAa,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AA2BjE,MAAM,aAAa,GAAG,uBAAuB,CAAC;AAC9C,MAAM,qBAAqB,GAAG,+BAA+B,CAAC;AAC9D,IAAI,YAAY,GAAuB,IAAI,CAAC;AAC5C,IAAI,mBAAmB,GAAuB,IAAI,CAAC;AACnD,IAAI,SAAS,GAAgB,IAAI,CAAC;AAClC,IAAI,aAAa,GAA2B,IAAI,CAAC;AACjD,IAAI,aAAa,GAAuB,IAAI,CAAC;AAE7C,SAAS,SAAS,CAAC,UAAgC,EAAE;IACnD,OAAO,qBAAqB,CAAC,OAAO,CAAC,OAAc,CAAC,CAAC;AACvD,CAAC;AAED,SAAS,QAAQ,CAAC,UAAgC,EAAE;IAClD,OAAO,OAAO,CAAC,KAAK,IAAI,YAAY,CAAC;A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;IACtB,SAAS,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IACjC,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IACtE,OAAO,IAAI,CAAC;AACd,CAAC;AAED,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare function shouldCrop(root: HTMLElement, file: File): boolean;
|
|
2
|
+
declare function parseAspectRatio(value: unknown): number;
|
|
3
|
+
declare function buildCropData(cropper: any, scale?: {
|
|
4
|
+
scaleX?: number;
|
|
5
|
+
scaleY?: number;
|
|
6
|
+
} | null): {
|
|
7
|
+
height: number;
|
|
8
|
+
width: number;
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
};
|
|
12
|
+
declare function prepareCropSource(file: File): Promise<{
|
|
13
|
+
imageUrl: string;
|
|
14
|
+
revoke(): void;
|
|
15
|
+
scaleX: number;
|
|
16
|
+
scaleY: number;
|
|
17
|
+
}>;
|
|
18
|
+
declare function canvasToPreviewUrl(canvas: HTMLCanvasElement, type: string): Promise<string>;
|
|
19
|
+
export { buildCropData, canvasToPreviewUrl, parseAspectRatio, prepareCropSource, shouldCrop, };
|
|
20
|
+
//# sourceMappingURL=crop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crop.d.ts","sourceRoot":"","sources":["../../../../src/inputs/upload/crop.ts"],"names":[],"mappings":"AAMA,iBAAS,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,WAIhD;AAED,iBAAS,gBAAgB,CAAC,KAAK,EAAE,OAAO,UASvC;AAED,iBAAS,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAW;;;;;EAY7F;AAsDD,iBAAe,iBAAiB,CAAC,IAAI,EAAE,IAAI;;;;;GAqB1C;AAED,iBAAe,kBAAkB,CAAC,MAAM,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,mBAQxE;AAED,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,GACX,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { uploadRootConfig } from "./config.js";
|
|
2
|
+
import { isImageFileObject } from "./files.js";
|
|
3
|
+
const MAX_CROP_WORKING_DIMENSION = 2048;
|
|
4
|
+
const MAX_CROP_PREVIEW_DIMENSION = 512;
|
|
5
|
+
function shouldCrop(root, file) {
|
|
6
|
+
if (!isImageFileObject(file))
|
|
7
|
+
return false;
|
|
8
|
+
const config = uploadRootConfig(root);
|
|
9
|
+
return config.crop === true || Number.isFinite(parseAspectRatio(config.aspect));
|
|
10
|
+
}
|
|
11
|
+
function parseAspectRatio(value) {
|
|
12
|
+
const text = String(value ?? "").trim();
|
|
13
|
+
if (!text)
|
|
14
|
+
return Number.NaN;
|
|
15
|
+
const parts = text.split(":").map(Number);
|
|
16
|
+
if (parts.length === 2 && parts[0] > 0 && parts[1] > 0) {
|
|
17
|
+
return parts[0] / parts[1];
|
|
18
|
+
}
|
|
19
|
+
const number = Number(text);
|
|
20
|
+
return Number.isFinite(number) && number > 0 ? number : Number.NaN;
|
|
21
|
+
}
|
|
22
|
+
function buildCropData(cropper, scale = null) {
|
|
23
|
+
if (!cropper || typeof cropper.getData !== "function")
|
|
24
|
+
return null;
|
|
25
|
+
const data = cropper.getData();
|
|
26
|
+
if (!data || typeof data !== "object")
|
|
27
|
+
return null;
|
|
28
|
+
const scaleX = Number(scale?.scaleX) > 0 ? Number(scale?.scaleX) : 1;
|
|
29
|
+
const scaleY = Number(scale?.scaleY) > 0 ? Number(scale?.scaleY) : 1;
|
|
30
|
+
return {
|
|
31
|
+
height: Math.max(0, (Number(data.height) || 0) * scaleY),
|
|
32
|
+
width: Math.max(0, (Number(data.width) || 0) * scaleX),
|
|
33
|
+
x: (Number(data.x) || 0) * scaleX,
|
|
34
|
+
y: (Number(data.y) || 0) * scaleY,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function fitDimensions(width, height, maxDimension) {
|
|
38
|
+
if (!(width > 0) || !(height > 0))
|
|
39
|
+
return null;
|
|
40
|
+
const scale = Math.min(1, maxDimension / Math.max(width, height));
|
|
41
|
+
return {
|
|
42
|
+
height: Math.max(1, Math.round(height * scale)),
|
|
43
|
+
width: Math.max(1, Math.round(width * scale)),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function canvasToBlob(canvas, type = "image/png", quality) {
|
|
47
|
+
return new Promise((resolve) => {
|
|
48
|
+
try {
|
|
49
|
+
canvas.toBlob((blob) => resolve(blob || null), type, quality);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
resolve(null);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function safeObjectUrl(blob) {
|
|
57
|
+
if (!(blob instanceof Blob))
|
|
58
|
+
return "";
|
|
59
|
+
if (typeof URL.createObjectURL !== "function")
|
|
60
|
+
return "";
|
|
61
|
+
try {
|
|
62
|
+
return URL.createObjectURL(blob);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return "";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function renderResizedCanvas(source, width, height) {
|
|
69
|
+
const canvas = document.createElement("canvas");
|
|
70
|
+
canvas.width = width;
|
|
71
|
+
canvas.height = height;
|
|
72
|
+
const context = canvas.getContext("2d");
|
|
73
|
+
if (!context)
|
|
74
|
+
return null;
|
|
75
|
+
context.imageSmoothingEnabled = true;
|
|
76
|
+
context.imageSmoothingQuality = "high";
|
|
77
|
+
context.drawImage(source, 0, 0, width, height);
|
|
78
|
+
return canvas;
|
|
79
|
+
}
|
|
80
|
+
function cropSourceResult(imageUrl, scaleX = 1, scaleY = 1) {
|
|
81
|
+
return {
|
|
82
|
+
imageUrl,
|
|
83
|
+
revoke() {
|
|
84
|
+
if (imageUrl && typeof URL.revokeObjectURL === "function")
|
|
85
|
+
URL.revokeObjectURL(imageUrl);
|
|
86
|
+
},
|
|
87
|
+
scaleX,
|
|
88
|
+
scaleY,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
async function prepareCropSource(file) {
|
|
92
|
+
const fallbackUrl = safeObjectUrl(file);
|
|
93
|
+
if (typeof createImageBitmap !== "function")
|
|
94
|
+
return cropSourceResult(fallbackUrl);
|
|
95
|
+
const bitmap = await createImageBitmap(file);
|
|
96
|
+
try {
|
|
97
|
+
const size = fitDimensions(bitmap.width, bitmap.height, MAX_CROP_WORKING_DIMENSION);
|
|
98
|
+
if (!size || (size.width === bitmap.width && size.height === bitmap.height)) {
|
|
99
|
+
return cropSourceResult(fallbackUrl);
|
|
100
|
+
}
|
|
101
|
+
const canvas = renderResizedCanvas(bitmap, size.width, size.height);
|
|
102
|
+
const blob = canvas ? await canvasToBlob(canvas, file.type || "image/png") : null;
|
|
103
|
+
if (!(blob instanceof Blob))
|
|
104
|
+
return cropSourceResult(fallbackUrl);
|
|
105
|
+
if (fallbackUrl && typeof URL.revokeObjectURL === "function")
|
|
106
|
+
URL.revokeObjectURL(fallbackUrl);
|
|
107
|
+
return cropSourceResult(safeObjectUrl(blob), bitmap.width / size.width, bitmap.height / size.height);
|
|
108
|
+
}
|
|
109
|
+
finally {
|
|
110
|
+
bitmap.close?.();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
async function canvasToPreviewUrl(canvas, type) {
|
|
114
|
+
const size = fitDimensions(canvas.width, canvas.height, MAX_CROP_PREVIEW_DIMENSION);
|
|
115
|
+
const preview = size && (size.width !== canvas.width || size.height !== canvas.height)
|
|
116
|
+
? renderResizedCanvas(canvas, size.width, size.height)
|
|
117
|
+
: canvas;
|
|
118
|
+
const blob = preview ? await canvasToBlob(preview, type || "image/png") : null;
|
|
119
|
+
if (!(blob instanceof Blob))
|
|
120
|
+
throw new Error("Missing crop preview.");
|
|
121
|
+
return safeObjectUrl(blob);
|
|
122
|
+
}
|
|
123
|
+
export { buildCropData, canvasToPreviewUrl, parseAspectRatio, prepareCropSource, shouldCrop, };
|
|
124
|
+
//# sourceMappingURL=crop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crop.js","sourceRoot":"","sources":["../../../../src/inputs/upload/crop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,0BAA0B,GAAG,IAAI,CAAC;AACxC,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAEvC,SAAS,UAAU,CAAC,IAAiB,EAAE,IAAU;IAC/C,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3C,MAAM,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACtC,OAAO,MAAM,CAAC,IAAI,KAAK,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;AAClF,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAc;IACtC,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACxC,IAAI,CAAC,IAAI;QAAE,OAAO,MAAM,CAAC,GAAG,CAAC;IAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,KAAK,CA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G,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC;QACpF,CAAC,CAAC,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC;QACtD,CAAC,CAAC,MAAM,CAAC;IACX,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,MAAM,YAAY,CAAC,OAAO,EAAE,IAAI,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC/E,IAAI,CAAC,CAAC,IAAI,YAAY,IAAI,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IACtE,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAED,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,GACX,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { UploadEntry } from "./types.js";
|
|
2
|
+
declare function uploadSlot(root: HTMLElement, ...slots: string[]): HTMLElement;
|
|
3
|
+
declare function getUploadFileInput(root: HTMLElement): HTMLInputElement | null;
|
|
4
|
+
declare function getDirectoryInput(root: HTMLElement): HTMLInputElement | null;
|
|
5
|
+
declare function getTrigger(root: HTMLElement): HTMLElement;
|
|
6
|
+
declare function getFileTrigger(root: HTMLElement): HTMLElement;
|
|
7
|
+
declare function getDirectoryTrigger(root: HTMLElement): HTMLElement;
|
|
8
|
+
declare function getClear(root: HTMLElement): HTMLElement;
|
|
9
|
+
declare function getFileNameNode(root: HTMLElement): HTMLElement;
|
|
10
|
+
declare function getListNode(root: HTMLElement): HTMLElement;
|
|
11
|
+
declare function getPreviewNode(root: HTMLElement): HTMLElement;
|
|
12
|
+
declare function getPreviewImage(root: HTMLElement): HTMLImageElement | null;
|
|
13
|
+
declare function getPreviewEmpty(root: HTMLElement): HTMLElement;
|
|
14
|
+
declare function getCropField(root: HTMLElement): HTMLInputElement | null;
|
|
15
|
+
declare function getEmptyToggle(root: HTMLElement): HTMLInputElement | null;
|
|
16
|
+
declare function setNativeInputFiles(input: HTMLInputElement | null, entries: UploadEntry[]): boolean;
|
|
17
|
+
declare function clearNativeInputs(root: HTMLElement, except?: HTMLInputElement | null): void;
|
|
18
|
+
export { clearNativeInputs, getClear, getCropField, getDirectoryInput, getDirectoryTrigger, getEmptyToggle, getFileNameNode, getFileTrigger, getListNode, getPreviewEmpty, getPreviewImage, getPreviewNode, getTrigger, getUploadFileInput, setNativeInputFiles, uploadSlot, };
|
|
19
|
+
//# sourceMappingURL=dom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../../../src/inputs/upload/dom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,iBAAS,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,eAMxD;AAED,iBAAS,kBAAkB,CAAC,IAAI,EAAE,WAAW,GACQ,gBAAgB,GAAG,IAAI,CAC3E;AAED,iBAAS,iBAAiB,CAAC,IAAI,EAAE,WAAW,GACK,gBAAgB,GAAG,IAAI,CACvE;AAED,iBAAS,UAAU,CAAC,IAAI,EAAE,WAAW,eAEpC;AAED,iBAAS,cAAc,CAAC,IAAI,EAAE,WAAW,eAExC;AAED,iBAAS,mBAAmB,CAAC,IAAI,EAAE,WAAW,eAE7C;AAED,iBAAS,QAAQ,CAAC,IAAI,EAAE,WAAW,eAElC;AAED,iBAAS,eAAe,CAAC,IAAI,EAAE,WAAW,eAEzC;AAED,iBAAS,WAAW,CAAC,IAAI,EAAE,WAAW,eAErC;AAED,iBAAS,cAAc,CAAC,IAAI,EAAE,WAAW,eAExC;AAED,iBAAS,eAAe,CAAC,IAAI,EAAE,WAAW,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