@jenesei-software/jenesei-kit-react 1.0.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/LICENSE +21 -0
- package/README.md +102 -0
- package/build/area-9NUxwBGc.cjs +2 -0
- package/build/area-9NUxwBGc.cjs.map +1 -0
- package/build/area-BnAddPtl.js +114 -0
- package/build/area-BnAddPtl.js.map +1 -0
- package/build/area-C2sWYH-e.js +47 -0
- package/build/area-C2sWYH-e.js.map +1 -0
- package/build/area-CD10k19W.cjs +27 -0
- package/build/area-CD10k19W.cjs.map +1 -0
- package/build/area-ClrrGVJG.cjs +40 -0
- package/build/area-ClrrGVJG.cjs.map +1 -0
- package/build/area-D7906bXA.cjs +2 -0
- package/build/area-D7906bXA.cjs.map +1 -0
- package/build/area-DRqAofd0.js +35 -0
- package/build/area-DRqAofd0.js.map +1 -0
- package/build/area-DfCAwCiZ.js +69 -0
- package/build/area-DfCAwCiZ.js.map +1 -0
- package/build/area-outside.cjs.js +2 -0
- package/build/area-outside.cjs.js.map +1 -0
- package/build/area-outside.d.ts +28 -0
- package/build/area-outside.es.js +5 -0
- package/build/area-outside.es.js.map +1 -0
- package/build/area-preview.cjs.js +2 -0
- package/build/area-preview.cjs.js.map +1 -0
- package/build/area-preview.d.ts +48 -0
- package/build/area-preview.es.js +7 -0
- package/build/area-preview.es.js.map +1 -0
- package/build/area-scroll.cjs.js +2 -0
- package/build/area-scroll.cjs.js.map +1 -0
- package/build/area-scroll.d.ts +58 -0
- package/build/area-scroll.es.js +6 -0
- package/build/area-scroll.es.js.map +1 -0
- package/build/area-skeleton.cjs.js +2 -0
- package/build/area-skeleton.cjs.js.map +1 -0
- package/build/area-skeleton.d.ts +64 -0
- package/build/area-skeleton.es.js +6 -0
- package/build/area-skeleton.es.js.map +1 -0
- package/build/area-smooth.cjs.js +2 -0
- package/build/area-smooth.cjs.js.map +1 -0
- package/build/area-smooth.d.ts +37 -0
- package/build/area-smooth.es.js +5 -0
- package/build/area-smooth.es.js.map +1 -0
- package/build/area.hooks-Bk04M7mk.js +26 -0
- package/build/area.hooks-Bk04M7mk.js.map +1 -0
- package/build/area.hooks-C_UKZzcb.cjs +2 -0
- package/build/area.hooks-C_UKZzcb.cjs.map +1 -0
- package/build/build-info.txt +3 -0
- package/build/component--Oo5_3xq.cjs +2 -0
- package/build/component--Oo5_3xq.cjs.map +1 -0
- package/build/component-BV_7tGiu.cjs +28 -0
- package/build/component-BV_7tGiu.cjs.map +1 -0
- package/build/component-BcHiCCC9.js +23 -0
- package/build/component-BcHiCCC9.js.map +1 -0
- package/build/component-BnI7BIp-.cjs +2 -0
- package/build/component-BnI7BIp-.cjs.map +1 -0
- package/build/component-ByY_9Ryc.js +65 -0
- package/build/component-ByY_9Ryc.js.map +1 -0
- package/build/component-C2JFFh-k.js +2372 -0
- package/build/component-C2JFFh-k.js.map +1 -0
- package/build/component-C52VCES6.cjs +247 -0
- package/build/component-C52VCES6.cjs.map +1 -0
- package/build/component-CBshLNEf.js +50 -0
- package/build/component-CBshLNEf.js.map +1 -0
- package/build/component-CFMlaYj1.js +66 -0
- package/build/component-CFMlaYj1.js.map +1 -0
- package/build/component-CuiUpH8H.js +207 -0
- package/build/component-CuiUpH8H.js.map +1 -0
- package/build/component-D1NPhRuV.cjs +90 -0
- package/build/component-D1NPhRuV.cjs.map +1 -0
- package/build/component-DZxbW_Jz.js +237 -0
- package/build/component-DZxbW_Jz.js.map +1 -0
- package/build/component-UW1VzyvB.cjs +52 -0
- package/build/component-UW1VzyvB.cjs.map +1 -0
- package/build/component-accordion.cjs.js +2 -0
- package/build/component-accordion.cjs.js.map +1 -0
- package/build/component-accordion.d.ts +94 -0
- package/build/component-accordion.es.js +10 -0
- package/build/component-accordion.es.js.map +1 -0
- package/build/component-button-group.cjs.js +2 -0
- package/build/component-button-group.cjs.js.map +1 -0
- package/build/component-button-group.d.ts +320 -0
- package/build/component-button-group.es.js +6 -0
- package/build/component-button-group.es.js.map +1 -0
- package/build/component-button.cjs.js +2 -0
- package/build/component-button.cjs.js.map +1 -0
- package/build/component-button.d.ts +347 -0
- package/build/component-button.es.js +9 -0
- package/build/component-button.es.js.map +1 -0
- package/build/component-checkbox-group.cjs.js +2 -0
- package/build/component-checkbox-group.cjs.js.map +1 -0
- package/build/component-checkbox-group.d.ts +337 -0
- package/build/component-checkbox-group.es.js +11 -0
- package/build/component-checkbox-group.es.js.map +1 -0
- package/build/component-checkbox.cjs.js +2 -0
- package/build/component-checkbox.cjs.js.map +1 -0
- package/build/component-checkbox.d.ts +342 -0
- package/build/component-checkbox.es.js +10 -0
- package/build/component-checkbox.es.js.map +1 -0
- package/build/component-date-picker.cjs.js +2 -0
- package/build/component-date-picker.cjs.js.map +1 -0
- package/build/component-date-picker.d.ts +415 -0
- package/build/component-date-picker.es.js +17 -0
- package/build/component-date-picker.es.js.map +1 -0
- package/build/component-icon.cjs.js +2 -0
- package/build/component-icon.cjs.js.map +1 -0
- package/build/component-icon.d.ts +198 -0
- package/build/component-icon.es.js +12 -0
- package/build/component-icon.es.js.map +1 -0
- package/build/component-image-button.cjs.js +2 -0
- package/build/component-image-button.cjs.js.map +1 -0
- package/build/component-image-button.d.ts +340 -0
- package/build/component-image-button.es.js +5 -0
- package/build/component-image-button.es.js.map +1 -0
- package/build/component-image-select.cjs.js +2 -0
- package/build/component-image-select.cjs.js.map +1 -0
- package/build/component-image-select.d.ts +436 -0
- package/build/component-image-select.es.js +11 -0
- package/build/component-image-select.es.js.map +1 -0
- package/build/component-image-slider.cjs.js +2 -0
- package/build/component-image-slider.cjs.js.map +1 -0
- package/build/component-image-slider.d.ts +108 -0
- package/build/component-image-slider.es.js +8 -0
- package/build/component-image-slider.es.js.map +1 -0
- package/build/component-image.cjs.js +2 -0
- package/build/component-image.cjs.js.map +1 -0
- package/build/component-image.d.ts +51 -0
- package/build/component-image.es.js +6 -0
- package/build/component-image.es.js.map +1 -0
- package/build/component-input-otp.cjs.js +2 -0
- package/build/component-input-otp.cjs.js.map +1 -0
- package/build/component-input-otp.d.ts +150 -0
- package/build/component-input-otp.es.js +8 -0
- package/build/component-input-otp.es.js.map +1 -0
- package/build/component-input.cjs.js +2 -0
- package/build/component-input.cjs.js.map +1 -0
- package/build/component-input.d.ts +226 -0
- package/build/component-input.es.js +20 -0
- package/build/component-input.es.js.map +1 -0
- package/build/component-jPZYT5iL.js +76 -0
- package/build/component-jPZYT5iL.js.map +1 -0
- package/build/component-map.cjs.js +2 -0
- package/build/component-map.cjs.js.map +1 -0
- package/build/component-map.d.ts +97 -0
- package/build/component-map.es.js +18 -0
- package/build/component-map.es.js.map +1 -0
- package/build/component-nFn_uOy_.cjs +2 -0
- package/build/component-nFn_uOy_.cjs.map +1 -0
- package/build/component-pagination.cjs.js +2 -0
- package/build/component-pagination.cjs.js.map +1 -0
- package/build/component-pagination.d.ts +321 -0
- package/build/component-pagination.es.js +6 -0
- package/build/component-pagination.es.js.map +1 -0
- package/build/component-range.cjs.js +2 -0
- package/build/component-range.cjs.js.map +1 -0
- package/build/component-range.d.ts +153 -0
- package/build/component-range.es.js +8 -0
- package/build/component-range.es.js.map +1 -0
- package/build/component-ripple.cjs.js +2 -0
- package/build/component-ripple.cjs.js.map +1 -0
- package/build/component-ripple.d.ts +45 -0
- package/build/component-ripple.es.js +12 -0
- package/build/component-ripple.es.js.map +1 -0
- package/build/component-select.cjs.js +2 -0
- package/build/component-select.cjs.js.map +1 -0
- package/build/component-select.d.ts +406 -0
- package/build/component-select.es.js +25 -0
- package/build/component-select.es.js.map +1 -0
- package/build/component-separator.cjs.js +2 -0
- package/build/component-separator.cjs.js.map +1 -0
- package/build/component-separator.d.ts +46 -0
- package/build/component-separator.es.js +6 -0
- package/build/component-separator.es.js.map +1 -0
- package/build/component-stack.cjs.js +2 -0
- package/build/component-stack.cjs.js.map +1 -0
- package/build/component-stack.d.ts +72 -0
- package/build/component-stack.es.js +8 -0
- package/build/component-stack.es.js.map +1 -0
- package/build/component-textarea.cjs.js +2 -0
- package/build/component-textarea.cjs.js.map +1 -0
- package/build/component-textarea.d.ts +131 -0
- package/build/component-textarea.es.js +12 -0
- package/build/component-textarea.es.js.map +1 -0
- package/build/component-toggle.cjs.js +2 -0
- package/build/component-toggle.cjs.js.map +1 -0
- package/build/component-toggle.d.ts +101 -0
- package/build/component-toggle.es.js +7 -0
- package/build/component-toggle.es.js.map +1 -0
- package/build/component-tooltip.cjs.js +2 -0
- package/build/component-tooltip.cjs.js.map +1 -0
- package/build/component-tooltip.d.ts +170 -0
- package/build/component-tooltip.es.js +12 -0
- package/build/component-tooltip.es.js.map +1 -0
- package/build/component-typography.cjs.js +2 -0
- package/build/component-typography.cjs.js.map +1 -0
- package/build/component-typography.d.ts +183 -0
- package/build/component-typography.es.js +10 -0
- package/build/component-typography.es.js.map +1 -0
- package/build/component-xnEaYd4a.cjs +2 -0
- package/build/component-xnEaYd4a.cjs.map +1 -0
- package/build/component.components-BAAT5GTH.js +363 -0
- package/build/component.components-BAAT5GTH.js.map +1 -0
- package/build/component.components-CaR5gfQW.cjs +16 -0
- package/build/component.components-CaR5gfQW.cjs.map +1 -0
- package/build/component.constants-BeWW8Ijx.cjs +2 -0
- package/build/component.constants-BeWW8Ijx.cjs.map +1 -0
- package/build/component.constants-D9wVZ3zy.cjs +22 -0
- package/build/component.constants-D9wVZ3zy.cjs.map +1 -0
- package/build/component.constants-DRvp5Bez.js +142 -0
- package/build/component.constants-DRvp5Bez.js.map +1 -0
- package/build/component.constants-DbNhxh0k.js +759 -0
- package/build/component.constants-DbNhxh0k.js.map +1 -0
- package/build/component.styles-B0L4jbOO.js +59 -0
- package/build/component.styles-B0L4jbOO.js.map +1 -0
- package/build/component.styles-B1DIataj.cjs +10 -0
- package/build/component.styles-B1DIataj.cjs.map +1 -0
- package/build/component.styles-BFwkFWkd.cjs +39 -0
- package/build/component.styles-BFwkFWkd.cjs.map +1 -0
- package/build/component.styles-BSEA2Dqn.cjs +8 -0
- package/build/component.styles-BSEA2Dqn.cjs.map +1 -0
- package/build/component.styles-BapdQNhL.js +2166 -0
- package/build/component.styles-BapdQNhL.js.map +1 -0
- package/build/component.styles-BfvB83xM.cjs +22 -0
- package/build/component.styles-BfvB83xM.cjs.map +1 -0
- package/build/component.styles-Bn6ylF83.js +859 -0
- package/build/component.styles-Bn6ylF83.js.map +1 -0
- package/build/component.styles-BsZIuwWJ.cjs +140 -0
- package/build/component.styles-BsZIuwWJ.cjs.map +1 -0
- package/build/component.styles-C6LohBfF.js +81 -0
- package/build/component.styles-C6LohBfF.js.map +1 -0
- package/build/component.styles-CEBh8X5q.js +20 -0
- package/build/component.styles-CEBh8X5q.js.map +1 -0
- package/build/component.styles-CPsxMKVK.cjs +73 -0
- package/build/component.styles-CPsxMKVK.cjs.map +1 -0
- package/build/component.styles-CTo5NC52.js +71 -0
- package/build/component.styles-CTo5NC52.js.map +1 -0
- package/build/component.styles-CV7jTFCg.js +758 -0
- package/build/component.styles-CV7jTFCg.js.map +1 -0
- package/build/component.styles-CVBpx4fw.js +474 -0
- package/build/component.styles-CVBpx4fw.js.map +1 -0
- package/build/component.styles-CZu2m0O4.cjs +21 -0
- package/build/component.styles-CZu2m0O4.cjs.map +1 -0
- package/build/component.styles-CmBcHREH.cjs +13 -0
- package/build/component.styles-CmBcHREH.cjs.map +1 -0
- package/build/component.styles-CmEFZfA5.js +120 -0
- package/build/component.styles-CmEFZfA5.js.map +1 -0
- package/build/component.styles-DHIw8p8e.cjs +158 -0
- package/build/component.styles-DHIw8p8e.cjs.map +1 -0
- package/build/component.styles-DOPCUXcr.js +158 -0
- package/build/component.styles-DOPCUXcr.js.map +1 -0
- package/build/component.styles-Dj3h7jd9.cjs +165 -0
- package/build/component.styles-Dj3h7jd9.cjs.map +1 -0
- package/build/component.styles-Do1NYZEO.js +86 -0
- package/build/component.styles-Do1NYZEO.js.map +1 -0
- package/build/component.styles-Dok17vPl.js +126 -0
- package/build/component.styles-Dok17vPl.js.map +1 -0
- package/build/component.styles-Dpg-__rn.cjs +43 -0
- package/build/component.styles-Dpg-__rn.cjs.map +1 -0
- package/build/component.styles-DpkFoWEh.cjs +81 -0
- package/build/component.styles-DpkFoWEh.cjs.map +1 -0
- package/build/component.styles-DqsBDAEo.js +202 -0
- package/build/component.styles-DqsBDAEo.js.map +1 -0
- package/build/component.styles-Du2y0R4W.js +177 -0
- package/build/component.styles-Du2y0R4W.js.map +1 -0
- package/build/component.styles-DxeG9Opm.cjs +47 -0
- package/build/component.styles-DxeG9Opm.cjs.map +1 -0
- package/build/component.styles-DyGfo9t0.cjs +32 -0
- package/build/component.styles-DyGfo9t0.cjs.map +1 -0
- package/build/component.styles-RkQwTlwG.js +170 -0
- package/build/component.styles-RkQwTlwG.js.map +1 -0
- package/build/component.styles-ZtwHuL4x.cjs +75 -0
- package/build/component.styles-ZtwHuL4x.cjs.map +1 -0
- package/build/component.types-D05KdxnZ.js +132 -0
- package/build/component.types-D05KdxnZ.js.map +1 -0
- package/build/component.types-gy5Q9qHX.cjs +2 -0
- package/build/component.types-gy5Q9qHX.cjs.map +1 -0
- package/build/consts.cjs.js +2 -0
- package/build/consts.cjs.js.map +1 -0
- package/build/consts.d.ts +86 -0
- package/build/consts.es.js +177 -0
- package/build/consts.es.js.map +1 -0
- package/build/context-app.cjs.js +2 -0
- package/build/context-app.cjs.js.map +1 -0
- package/build/context-app.d.ts +223 -0
- package/build/context-app.es.js +20 -0
- package/build/context-app.es.js.map +1 -0
- package/build/context-cookie.cjs.js +2 -0
- package/build/context-cookie.cjs.js.map +1 -0
- package/build/context-cookie.d.ts +67 -0
- package/build/context-cookie.es.js +9 -0
- package/build/context-cookie.es.js.map +1 -0
- package/build/context-dialog.cjs.js +2 -0
- package/build/context-dialog.cjs.js.map +1 -0
- package/build/context-dialog.d.ts +92 -0
- package/build/context-dialog.es.js +18 -0
- package/build/context-dialog.es.js.map +1 -0
- package/build/context-geolocation.cjs.js +2 -0
- package/build/context-geolocation.cjs.js.map +1 -0
- package/build/context-geolocation.d.ts +22 -0
- package/build/context-geolocation.es.js +7 -0
- package/build/context-geolocation.es.js.map +1 -0
- package/build/context-local-storage.cjs.js +2 -0
- package/build/context-local-storage.cjs.js.map +1 -0
- package/build/context-local-storage.d.ts +54 -0
- package/build/context-local-storage.es.js +9 -0
- package/build/context-local-storage.es.js.map +1 -0
- package/build/context-permission.cjs.js +2 -0
- package/build/context-permission.cjs.js.map +1 -0
- package/build/context-permission.d.ts +28 -0
- package/build/context-permission.es.js +9 -0
- package/build/context-permission.es.js.map +1 -0
- package/build/context-screen-width.cjs.js +2 -0
- package/build/context-screen-width.cjs.js.map +1 -0
- package/build/context-screen-width.d.ts +34 -0
- package/build/context-screen-width.es.js +7 -0
- package/build/context-screen-width.es.js.map +1 -0
- package/build/context-sonner.cjs.js +2 -0
- package/build/context-sonner.cjs.js.map +1 -0
- package/build/context-sonner.d.ts +449 -0
- package/build/context-sonner.es.js +21 -0
- package/build/context-sonner.es.js.map +1 -0
- package/build/context.constants-B29-_8v3.cjs +32 -0
- package/build/context.constants-B29-_8v3.cjs.map +1 -0
- package/build/context.constants-BaD7xj_m.cjs +100 -0
- package/build/context.constants-BaD7xj_m.cjs.map +1 -0
- package/build/context.constants-CsZRZ7gH.js +228 -0
- package/build/context.constants-CsZRZ7gH.js.map +1 -0
- package/build/context.constants-DqYjo5m4.js +375 -0
- package/build/context.constants-DqYjo5m4.js.map +1 -0
- package/build/context.functions-80N-5MqM.cjs +2 -0
- package/build/context.functions-80N-5MqM.cjs.map +1 -0
- package/build/context.functions-B8FDl7nJ.js +14 -0
- package/build/context.functions-B8FDl7nJ.js.map +1 -0
- package/build/context.functions-BD15C8_y.js +128 -0
- package/build/context.functions-BD15C8_y.js.map +1 -0
- package/build/context.functions-CQ9GerPb.js +147 -0
- package/build/context.functions-CQ9GerPb.js.map +1 -0
- package/build/context.functions-ar41xFVo.cjs +2 -0
- package/build/context.functions-ar41xFVo.cjs.map +1 -0
- package/build/context.functions-ohI9H54j.cjs +2 -0
- package/build/context.functions-ohI9H54j.cjs.map +1 -0
- package/build/context.hooks-7ydA7mGj.js +117 -0
- package/build/context.hooks-7ydA7mGj.js.map +1 -0
- package/build/context.hooks-BIsapq-0.cjs +2 -0
- package/build/context.hooks-BIsapq-0.cjs.map +1 -0
- package/build/context.hooks-BmwyZ1p3.js +68 -0
- package/build/context.hooks-BmwyZ1p3.js.map +1 -0
- package/build/context.hooks-BzMTkJNv.js +52 -0
- package/build/context.hooks-BzMTkJNv.js.map +1 -0
- package/build/context.hooks-CTi-CVKx.cjs +72 -0
- package/build/context.hooks-CTi-CVKx.cjs.map +1 -0
- package/build/context.hooks-D13tbrva.cjs +2 -0
- package/build/context.hooks-D13tbrva.cjs.map +1 -0
- package/build/context.hooks-gyzZSaVi.js +527 -0
- package/build/context.hooks-gyzZSaVi.js.map +1 -0
- package/build/context.hooks-u408Pxw8.cjs +2 -0
- package/build/context.hooks-u408Pxw8.cjs.map +1 -0
- package/build/functions.cjs.js +2 -0
- package/build/functions.cjs.js.map +1 -0
- package/build/functions.d.ts +22 -0
- package/build/functions.es.js +47 -0
- package/build/functions.es.js.map +1 -0
- package/build/hooks-use-debounced-callback.cjs.js +2 -0
- package/build/hooks-use-debounced-callback.cjs.js.map +1 -0
- package/build/hooks-use-debounced-callback.d.ts +3 -0
- package/build/hooks-use-debounced-callback.es.js +5 -0
- package/build/hooks-use-debounced-callback.es.js.map +1 -0
- package/build/hooks-use-deep-compare-memoize.cjs.js +2 -0
- package/build/hooks-use-deep-compare-memoize.cjs.js.map +1 -0
- package/build/hooks-use-deep-compare-memoize.d.ts +3 -0
- package/build/hooks-use-deep-compare-memoize.es.js +5 -0
- package/build/hooks-use-deep-compare-memoize.es.js.map +1 -0
- package/build/index.cjs.js +2 -0
- package/build/index.cjs.js.map +1 -0
- package/build/index.d.ts +2540 -0
- package/build/index.es.js +329 -0
- package/build/index.es.js.map +1 -0
- package/build/jsx-runtime-BcGej2Kr.cjs +11 -0
- package/build/jsx-runtime-BcGej2Kr.cjs.map +1 -0
- package/build/jsx-runtime-BrDlu8eK.js +320 -0
- package/build/jsx-runtime-BrDlu8eK.js.map +1 -0
- package/build/motion-CIQfrLky.js +85 -0
- package/build/motion-CIQfrLky.js.map +1 -0
- package/build/motion-DgB7M2Hn.cjs +2 -0
- package/build/motion-DgB7M2Hn.cjs.map +1 -0
- package/build/style-CEGJOjRW.js +107 -0
- package/build/style-CEGJOjRW.js.map +1 -0
- package/build/style-CtGd1JVB.cjs +32 -0
- package/build/style-CtGd1JVB.cjs.map +1 -0
- package/build/style-DeAgDHyI.js +52 -0
- package/build/style-DeAgDHyI.js.map +1 -0
- package/build/style-Dm74EPGE.cjs +87 -0
- package/build/style-Dm74EPGE.cjs.map +1 -0
- package/build/style-add.cjs.js +2 -0
- package/build/style-add.cjs.js.map +1 -0
- package/build/style-add.d.ts +21 -0
- package/build/style-add.es.js +13 -0
- package/build/style-add.es.js.map +1 -0
- package/build/style-error.cjs.js +2 -0
- package/build/style-error.cjs.js.map +1 -0
- package/build/style-error.d.ts +56 -0
- package/build/style-error.es.js +7 -0
- package/build/style-error.es.js.map +1 -0
- package/build/style-fRZ6xrVp.cjs +10 -0
- package/build/style-fRZ6xrVp.cjs.map +1 -0
- package/build/style-motion.cjs.js +2 -0
- package/build/style-motion.cjs.js.map +1 -0
- package/build/style-motion.d.ts +20 -0
- package/build/style-motion.es.js +8 -0
- package/build/style-motion.es.js.map +1 -0
- package/build/style-plT9Ah7t.js +33 -0
- package/build/style-plT9Ah7t.js.map +1 -0
- package/build/style-sx.cjs.js +2 -0
- package/build/style-sx.cjs.js.map +1 -0
- package/build/style-sx.d.ts +31 -0
- package/build/style-sx.es.js +5 -0
- package/build/style-sx.es.js.map +1 -0
- package/build/style-theme.cjs.js +2 -0
- package/build/style-theme.cjs.js.map +1 -0
- package/build/style-theme.d.ts +263 -0
- package/build/style-theme.es.js +10 -0
- package/build/style-theme.es.js.map +1 -0
- package/build/style.css +1 -0
- package/build/theme.global-D6XU05Et.cjs +169 -0
- package/build/theme.global-D6XU05Et.cjs.map +1 -0
- package/build/theme.global-bN9HlSWE.js +1080 -0
- package/build/theme.global-bN9HlSWE.js.map +1 -0
- package/build/types.cjs.js +2 -0
- package/build/types.cjs.js.map +1 -0
- package/build/types.d.ts +27 -0
- package/build/types.es.js +2 -0
- package/build/types.es.js.map +1 -0
- package/build/use-BVj4dgbW.js +1547 -0
- package/build/use-BVj4dgbW.js.map +1 -0
- package/build/use-BhofoOgk.cjs +16 -0
- package/build/use-BhofoOgk.cjs.map +1 -0
- package/build/use-Bp8UVw4Y.js +16 -0
- package/build/use-Bp8UVw4Y.js.map +1 -0
- package/build/use-C1l0O0Qo.cjs +2 -0
- package/build/use-C1l0O0Qo.cjs.map +1 -0
- package/build/use-DT0XgvJT.js +25 -0
- package/build/use-DT0XgvJT.js.map +1 -0
- package/build/use-IhzeVumv.cjs +2 -0
- package/build/use-IhzeVumv.cjs.map +1 -0
- package/package.json +360 -0
|
@@ -0,0 +1,1547 @@
|
|
|
1
|
+
import { j as jsxRuntimeExports } from "./jsx-runtime-BrDlu8eK.js";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { useMemo, useCallback, useState, useEffect } from "react";
|
|
4
|
+
import { useTheme } from "styled-components";
|
|
5
|
+
import { P as Preview } from "./area-BnAddPtl.js";
|
|
6
|
+
import { c as Button } from "./component-DZxbW_Jz.js";
|
|
7
|
+
import { P as Pagination } from "./component.constants-DRvp5Bez.js";
|
|
8
|
+
import { b as Stack } from "./component-jPZYT5iL.js";
|
|
9
|
+
import { ImageSupportedFormats } from "./consts.es.js";
|
|
10
|
+
import { a as useDialog } from "./context.constants-CsZRZ7gH.js";
|
|
11
|
+
import { K as KEY_SIZE_DATA } from "./theme.global-bN9HlSWE.js";
|
|
12
|
+
function getDefaultExportFromCjs(x) {
|
|
13
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
14
|
+
}
|
|
15
|
+
var extendStatics = function(d, b) {
|
|
16
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
17
|
+
d2.__proto__ = b2;
|
|
18
|
+
} || function(d2, b2) {
|
|
19
|
+
for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p];
|
|
20
|
+
};
|
|
21
|
+
return extendStatics(d, b);
|
|
22
|
+
};
|
|
23
|
+
function __extends(d, b) {
|
|
24
|
+
if (typeof b !== "function" && b !== null)
|
|
25
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
26
|
+
extendStatics(d, b);
|
|
27
|
+
function __() {
|
|
28
|
+
this.constructor = d;
|
|
29
|
+
}
|
|
30
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
31
|
+
}
|
|
32
|
+
var __assign = function() {
|
|
33
|
+
__assign = Object.assign || function __assign2(t) {
|
|
34
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
35
|
+
s = arguments[i];
|
|
36
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
37
|
+
}
|
|
38
|
+
return t;
|
|
39
|
+
};
|
|
40
|
+
return __assign.apply(this, arguments);
|
|
41
|
+
};
|
|
42
|
+
typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
|
|
43
|
+
var e = new Error(message);
|
|
44
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
45
|
+
};
|
|
46
|
+
var _populated = false;
|
|
47
|
+
var _ie, _firefox, _opera, _webkit, _chrome;
|
|
48
|
+
var _ie_real_version;
|
|
49
|
+
var _osx, _windows, _linux, _android;
|
|
50
|
+
var _win64;
|
|
51
|
+
var _iphone, _ipad, _native;
|
|
52
|
+
var _mobile;
|
|
53
|
+
function _populate() {
|
|
54
|
+
if (_populated) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
_populated = true;
|
|
58
|
+
var uas = navigator.userAgent;
|
|
59
|
+
var agent = /(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(uas);
|
|
60
|
+
var os = /(Mac OS X)|(Windows)|(Linux)/.exec(uas);
|
|
61
|
+
_iphone = /\b(iPhone|iP[ao]d)/.exec(uas);
|
|
62
|
+
_ipad = /\b(iP[ao]d)/.exec(uas);
|
|
63
|
+
_android = /Android/i.exec(uas);
|
|
64
|
+
_native = /FBAN\/\w+;/i.exec(uas);
|
|
65
|
+
_mobile = /Mobile/i.exec(uas);
|
|
66
|
+
_win64 = !!/Win64/.exec(uas);
|
|
67
|
+
if (agent) {
|
|
68
|
+
_ie = agent[1] ? parseFloat(agent[1]) : agent[5] ? parseFloat(agent[5]) : NaN;
|
|
69
|
+
if (_ie && document && document.documentMode) {
|
|
70
|
+
_ie = document.documentMode;
|
|
71
|
+
}
|
|
72
|
+
var trident = /(?:Trident\/(\d+.\d+))/.exec(uas);
|
|
73
|
+
_ie_real_version = trident ? parseFloat(trident[1]) + 4 : _ie;
|
|
74
|
+
_firefox = agent[2] ? parseFloat(agent[2]) : NaN;
|
|
75
|
+
_opera = agent[3] ? parseFloat(agent[3]) : NaN;
|
|
76
|
+
_webkit = agent[4] ? parseFloat(agent[4]) : NaN;
|
|
77
|
+
if (_webkit) {
|
|
78
|
+
agent = /(?:Chrome\/(\d+\.\d+))/.exec(uas);
|
|
79
|
+
_chrome = agent && agent[1] ? parseFloat(agent[1]) : NaN;
|
|
80
|
+
} else {
|
|
81
|
+
_chrome = NaN;
|
|
82
|
+
}
|
|
83
|
+
} else {
|
|
84
|
+
_ie = _firefox = _opera = _chrome = _webkit = NaN;
|
|
85
|
+
}
|
|
86
|
+
if (os) {
|
|
87
|
+
if (os[1]) {
|
|
88
|
+
var ver = /(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(uas);
|
|
89
|
+
_osx = ver ? parseFloat(ver[1].replace("_", ".")) : true;
|
|
90
|
+
} else {
|
|
91
|
+
_osx = false;
|
|
92
|
+
}
|
|
93
|
+
_windows = !!os[2];
|
|
94
|
+
_linux = !!os[3];
|
|
95
|
+
} else {
|
|
96
|
+
_osx = _windows = _linux = false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
var UserAgent_DEPRECATED$1 = {
|
|
100
|
+
/**
|
|
101
|
+
* Check if the UA is Internet Explorer.
|
|
102
|
+
*
|
|
103
|
+
*
|
|
104
|
+
* @return float|NaN Version number (if match) or NaN.
|
|
105
|
+
*/
|
|
106
|
+
ie: function() {
|
|
107
|
+
return _populate() || _ie;
|
|
108
|
+
},
|
|
109
|
+
/**
|
|
110
|
+
* Check if we're in Internet Explorer compatibility mode.
|
|
111
|
+
*
|
|
112
|
+
* @return bool true if in compatibility mode, false if
|
|
113
|
+
* not compatibility mode or not ie
|
|
114
|
+
*/
|
|
115
|
+
ieCompatibilityMode: function() {
|
|
116
|
+
return _populate() || _ie_real_version > _ie;
|
|
117
|
+
},
|
|
118
|
+
/**
|
|
119
|
+
* Whether the browser is 64-bit IE. Really, this is kind of weak sauce; we
|
|
120
|
+
* only need this because Skype can't handle 64-bit IE yet. We need to remove
|
|
121
|
+
* this when we don't need it -- tracked by #601957.
|
|
122
|
+
*/
|
|
123
|
+
ie64: function() {
|
|
124
|
+
return UserAgent_DEPRECATED$1.ie() && _win64;
|
|
125
|
+
},
|
|
126
|
+
/**
|
|
127
|
+
* Check if the UA is Firefox.
|
|
128
|
+
*
|
|
129
|
+
*
|
|
130
|
+
* @return float|NaN Version number (if match) or NaN.
|
|
131
|
+
*/
|
|
132
|
+
firefox: function() {
|
|
133
|
+
return _populate() || _firefox;
|
|
134
|
+
},
|
|
135
|
+
/**
|
|
136
|
+
* Check if the UA is Opera.
|
|
137
|
+
*
|
|
138
|
+
*
|
|
139
|
+
* @return float|NaN Version number (if match) or NaN.
|
|
140
|
+
*/
|
|
141
|
+
opera: function() {
|
|
142
|
+
return _populate() || _opera;
|
|
143
|
+
},
|
|
144
|
+
/**
|
|
145
|
+
* Check if the UA is WebKit.
|
|
146
|
+
*
|
|
147
|
+
*
|
|
148
|
+
* @return float|NaN Version number (if match) or NaN.
|
|
149
|
+
*/
|
|
150
|
+
webkit: function() {
|
|
151
|
+
return _populate() || _webkit;
|
|
152
|
+
},
|
|
153
|
+
/**
|
|
154
|
+
* For Push
|
|
155
|
+
* WILL BE REMOVED VERY SOON. Use UserAgent_DEPRECATED.webkit
|
|
156
|
+
*/
|
|
157
|
+
safari: function() {
|
|
158
|
+
return UserAgent_DEPRECATED$1.webkit();
|
|
159
|
+
},
|
|
160
|
+
/**
|
|
161
|
+
* Check if the UA is a Chrome browser.
|
|
162
|
+
*
|
|
163
|
+
*
|
|
164
|
+
* @return float|NaN Version number (if match) or NaN.
|
|
165
|
+
*/
|
|
166
|
+
chrome: function() {
|
|
167
|
+
return _populate() || _chrome;
|
|
168
|
+
},
|
|
169
|
+
/**
|
|
170
|
+
* Check if the user is running Windows.
|
|
171
|
+
*
|
|
172
|
+
* @return bool `true' if the user's OS is Windows.
|
|
173
|
+
*/
|
|
174
|
+
windows: function() {
|
|
175
|
+
return _populate() || _windows;
|
|
176
|
+
},
|
|
177
|
+
/**
|
|
178
|
+
* Check if the user is running Mac OS X.
|
|
179
|
+
*
|
|
180
|
+
* @return float|bool Returns a float if a version number is detected,
|
|
181
|
+
* otherwise true/false.
|
|
182
|
+
*/
|
|
183
|
+
osx: function() {
|
|
184
|
+
return _populate() || _osx;
|
|
185
|
+
},
|
|
186
|
+
/**
|
|
187
|
+
* Check if the user is running Linux.
|
|
188
|
+
*
|
|
189
|
+
* @return bool `true' if the user's OS is some flavor of Linux.
|
|
190
|
+
*/
|
|
191
|
+
linux: function() {
|
|
192
|
+
return _populate() || _linux;
|
|
193
|
+
},
|
|
194
|
+
/**
|
|
195
|
+
* Check if the user is running on an iPhone or iPod platform.
|
|
196
|
+
*
|
|
197
|
+
* @return bool `true' if the user is running some flavor of the
|
|
198
|
+
* iPhone OS.
|
|
199
|
+
*/
|
|
200
|
+
iphone: function() {
|
|
201
|
+
return _populate() || _iphone;
|
|
202
|
+
},
|
|
203
|
+
mobile: function() {
|
|
204
|
+
return _populate() || (_iphone || _ipad || _android || _mobile);
|
|
205
|
+
},
|
|
206
|
+
nativeApp: function() {
|
|
207
|
+
return _populate() || _native;
|
|
208
|
+
},
|
|
209
|
+
android: function() {
|
|
210
|
+
return _populate() || _android;
|
|
211
|
+
},
|
|
212
|
+
ipad: function() {
|
|
213
|
+
return _populate() || _ipad;
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
var UserAgent_DEPRECATED_1 = UserAgent_DEPRECATED$1;
|
|
217
|
+
var canUseDOM = !!(typeof window !== "undefined" && window.document && window.document.createElement);
|
|
218
|
+
var ExecutionEnvironment$1 = {
|
|
219
|
+
canUseDOM
|
|
220
|
+
};
|
|
221
|
+
var ExecutionEnvironment_1 = ExecutionEnvironment$1;
|
|
222
|
+
var ExecutionEnvironment = ExecutionEnvironment_1;
|
|
223
|
+
var useHasFeature;
|
|
224
|
+
if (ExecutionEnvironment.canUseDOM) {
|
|
225
|
+
useHasFeature = document.implementation && document.implementation.hasFeature && // always returns true in newer browsers as per the standard.
|
|
226
|
+
// @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature
|
|
227
|
+
document.implementation.hasFeature("", "") !== true;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Checks if an event is supported in the current execution environment.
|
|
231
|
+
*
|
|
232
|
+
* NOTE: This will not work correctly for non-generic events such as `change`,
|
|
233
|
+
* `reset`, `load`, `error`, and `select`.
|
|
234
|
+
*
|
|
235
|
+
* Borrows from Modernizr.
|
|
236
|
+
*
|
|
237
|
+
* @param {string} eventNameSuffix Event name, e.g. "click".
|
|
238
|
+
* @param {?boolean} capture Check if the capture phase is supported.
|
|
239
|
+
* @return {boolean} True if the event is supported.
|
|
240
|
+
* @internal
|
|
241
|
+
* @license Modernizr 3.0.0pre (Custom Build) | MIT
|
|
242
|
+
*/
|
|
243
|
+
function isEventSupported$1(eventNameSuffix, capture) {
|
|
244
|
+
if (!ExecutionEnvironment.canUseDOM || capture && !("addEventListener" in document)) {
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
var eventName = "on" + eventNameSuffix;
|
|
248
|
+
var isSupported = eventName in document;
|
|
249
|
+
if (!isSupported) {
|
|
250
|
+
var element = document.createElement("div");
|
|
251
|
+
element.setAttribute(eventName, "return;");
|
|
252
|
+
isSupported = typeof element[eventName] === "function";
|
|
253
|
+
}
|
|
254
|
+
if (!isSupported && useHasFeature && eventNameSuffix === "wheel") {
|
|
255
|
+
isSupported = document.implementation.hasFeature("Events.wheel", "3.0");
|
|
256
|
+
}
|
|
257
|
+
return isSupported;
|
|
258
|
+
}
|
|
259
|
+
var isEventSupported_1 = isEventSupported$1;
|
|
260
|
+
var UserAgent_DEPRECATED = UserAgent_DEPRECATED_1;
|
|
261
|
+
var isEventSupported = isEventSupported_1;
|
|
262
|
+
var PIXEL_STEP = 10;
|
|
263
|
+
var LINE_HEIGHT = 40;
|
|
264
|
+
var PAGE_HEIGHT = 800;
|
|
265
|
+
function normalizeWheel$2(event) {
|
|
266
|
+
var sX = 0, sY = 0, pX = 0, pY = 0;
|
|
267
|
+
if ("detail" in event) {
|
|
268
|
+
sY = event.detail;
|
|
269
|
+
}
|
|
270
|
+
if ("wheelDelta" in event) {
|
|
271
|
+
sY = -event.wheelDelta / 120;
|
|
272
|
+
}
|
|
273
|
+
if ("wheelDeltaY" in event) {
|
|
274
|
+
sY = -event.wheelDeltaY / 120;
|
|
275
|
+
}
|
|
276
|
+
if ("wheelDeltaX" in event) {
|
|
277
|
+
sX = -event.wheelDeltaX / 120;
|
|
278
|
+
}
|
|
279
|
+
if ("axis" in event && event.axis === event.HORIZONTAL_AXIS) {
|
|
280
|
+
sX = sY;
|
|
281
|
+
sY = 0;
|
|
282
|
+
}
|
|
283
|
+
pX = sX * PIXEL_STEP;
|
|
284
|
+
pY = sY * PIXEL_STEP;
|
|
285
|
+
if ("deltaY" in event) {
|
|
286
|
+
pY = event.deltaY;
|
|
287
|
+
}
|
|
288
|
+
if ("deltaX" in event) {
|
|
289
|
+
pX = event.deltaX;
|
|
290
|
+
}
|
|
291
|
+
if ((pX || pY) && event.deltaMode) {
|
|
292
|
+
if (event.deltaMode == 1) {
|
|
293
|
+
pX *= LINE_HEIGHT;
|
|
294
|
+
pY *= LINE_HEIGHT;
|
|
295
|
+
} else {
|
|
296
|
+
pX *= PAGE_HEIGHT;
|
|
297
|
+
pY *= PAGE_HEIGHT;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
if (pX && !sX) {
|
|
301
|
+
sX = pX < 1 ? -1 : 1;
|
|
302
|
+
}
|
|
303
|
+
if (pY && !sY) {
|
|
304
|
+
sY = pY < 1 ? -1 : 1;
|
|
305
|
+
}
|
|
306
|
+
return {
|
|
307
|
+
spinX: sX,
|
|
308
|
+
spinY: sY,
|
|
309
|
+
pixelX: pX,
|
|
310
|
+
pixelY: pY
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
normalizeWheel$2.getEventType = function() {
|
|
314
|
+
return UserAgent_DEPRECATED.firefox() ? "DOMMouseScroll" : isEventSupported("wheel") ? "wheel" : "mousewheel";
|
|
315
|
+
};
|
|
316
|
+
var normalizeWheel_1 = normalizeWheel$2;
|
|
317
|
+
var normalizeWheel = normalizeWheel_1;
|
|
318
|
+
const normalizeWheel$1 = /* @__PURE__ */ getDefaultExportFromCjs(normalizeWheel);
|
|
319
|
+
function getCropSize(mediaWidth, mediaHeight, containerWidth, containerHeight, aspect, rotation) {
|
|
320
|
+
if (rotation === void 0) {
|
|
321
|
+
rotation = 0;
|
|
322
|
+
}
|
|
323
|
+
var _a = rotateSize(mediaWidth, mediaHeight, rotation), width = _a.width, height = _a.height;
|
|
324
|
+
var fittingWidth = Math.min(width, containerWidth);
|
|
325
|
+
var fittingHeight = Math.min(height, containerHeight);
|
|
326
|
+
if (fittingWidth > fittingHeight * aspect) {
|
|
327
|
+
return {
|
|
328
|
+
width: fittingHeight * aspect,
|
|
329
|
+
height: fittingHeight
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
return {
|
|
333
|
+
width: fittingWidth,
|
|
334
|
+
height: fittingWidth / aspect
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
function getMediaZoom(mediaSize) {
|
|
338
|
+
return mediaSize.width > mediaSize.height ? mediaSize.width / mediaSize.naturalWidth : mediaSize.height / mediaSize.naturalHeight;
|
|
339
|
+
}
|
|
340
|
+
function restrictPosition(position, mediaSize, cropSize, zoom, rotation) {
|
|
341
|
+
if (rotation === void 0) {
|
|
342
|
+
rotation = 0;
|
|
343
|
+
}
|
|
344
|
+
var _a = rotateSize(mediaSize.width, mediaSize.height, rotation), width = _a.width, height = _a.height;
|
|
345
|
+
return {
|
|
346
|
+
x: restrictPositionCoord(position.x, width, cropSize.width, zoom),
|
|
347
|
+
y: restrictPositionCoord(position.y, height, cropSize.height, zoom)
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
function restrictPositionCoord(position, mediaSize, cropSize, zoom) {
|
|
351
|
+
var maxPosition = mediaSize * zoom / 2 - cropSize / 2;
|
|
352
|
+
return clamp(position, -maxPosition, maxPosition);
|
|
353
|
+
}
|
|
354
|
+
function getDistanceBetweenPoints(pointA, pointB) {
|
|
355
|
+
return Math.sqrt(Math.pow(pointA.y - pointB.y, 2) + Math.pow(pointA.x - pointB.x, 2));
|
|
356
|
+
}
|
|
357
|
+
function getRotationBetweenPoints(pointA, pointB) {
|
|
358
|
+
return Math.atan2(pointB.y - pointA.y, pointB.x - pointA.x) * 180 / Math.PI;
|
|
359
|
+
}
|
|
360
|
+
function computeCroppedArea(crop, mediaSize, cropSize, aspect, zoom, rotation, restrictPosition2) {
|
|
361
|
+
if (rotation === void 0) {
|
|
362
|
+
rotation = 0;
|
|
363
|
+
}
|
|
364
|
+
if (restrictPosition2 === void 0) {
|
|
365
|
+
restrictPosition2 = true;
|
|
366
|
+
}
|
|
367
|
+
var limitAreaFn = restrictPosition2 ? limitArea : noOp;
|
|
368
|
+
var mediaBBoxSize = rotateSize(mediaSize.width, mediaSize.height, rotation);
|
|
369
|
+
var mediaNaturalBBoxSize = rotateSize(mediaSize.naturalWidth, mediaSize.naturalHeight, rotation);
|
|
370
|
+
var croppedAreaPercentages = {
|
|
371
|
+
x: limitAreaFn(100, ((mediaBBoxSize.width - cropSize.width / zoom) / 2 - crop.x / zoom) / mediaBBoxSize.width * 100),
|
|
372
|
+
y: limitAreaFn(100, ((mediaBBoxSize.height - cropSize.height / zoom) / 2 - crop.y / zoom) / mediaBBoxSize.height * 100),
|
|
373
|
+
width: limitAreaFn(100, cropSize.width / mediaBBoxSize.width * 100 / zoom),
|
|
374
|
+
height: limitAreaFn(100, cropSize.height / mediaBBoxSize.height * 100 / zoom)
|
|
375
|
+
};
|
|
376
|
+
var widthInPixels = Math.round(limitAreaFn(mediaNaturalBBoxSize.width, croppedAreaPercentages.width * mediaNaturalBBoxSize.width / 100));
|
|
377
|
+
var heightInPixels = Math.round(limitAreaFn(mediaNaturalBBoxSize.height, croppedAreaPercentages.height * mediaNaturalBBoxSize.height / 100));
|
|
378
|
+
var isImgWiderThanHigh = mediaNaturalBBoxSize.width >= mediaNaturalBBoxSize.height * aspect;
|
|
379
|
+
var sizePixels = isImgWiderThanHigh ? {
|
|
380
|
+
width: Math.round(heightInPixels * aspect),
|
|
381
|
+
height: heightInPixels
|
|
382
|
+
} : {
|
|
383
|
+
width: widthInPixels,
|
|
384
|
+
height: Math.round(widthInPixels / aspect)
|
|
385
|
+
};
|
|
386
|
+
var croppedAreaPixels = __assign(__assign({}, sizePixels), {
|
|
387
|
+
x: Math.round(limitAreaFn(mediaNaturalBBoxSize.width - sizePixels.width, croppedAreaPercentages.x * mediaNaturalBBoxSize.width / 100)),
|
|
388
|
+
y: Math.round(limitAreaFn(mediaNaturalBBoxSize.height - sizePixels.height, croppedAreaPercentages.y * mediaNaturalBBoxSize.height / 100))
|
|
389
|
+
});
|
|
390
|
+
return {
|
|
391
|
+
croppedAreaPercentages,
|
|
392
|
+
croppedAreaPixels
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
function limitArea(max, value) {
|
|
396
|
+
return Math.min(max, Math.max(0, value));
|
|
397
|
+
}
|
|
398
|
+
function noOp(_max, value) {
|
|
399
|
+
return value;
|
|
400
|
+
}
|
|
401
|
+
function getInitialCropFromCroppedAreaPercentages(croppedAreaPercentages, mediaSize, rotation, cropSize, minZoom, maxZoom) {
|
|
402
|
+
var mediaBBoxSize = rotateSize(mediaSize.width, mediaSize.height, rotation);
|
|
403
|
+
var zoom = clamp(cropSize.width / mediaBBoxSize.width * (100 / croppedAreaPercentages.width), minZoom, maxZoom);
|
|
404
|
+
var crop = {
|
|
405
|
+
x: zoom * mediaBBoxSize.width / 2 - cropSize.width / 2 - mediaBBoxSize.width * zoom * (croppedAreaPercentages.x / 100),
|
|
406
|
+
y: zoom * mediaBBoxSize.height / 2 - cropSize.height / 2 - mediaBBoxSize.height * zoom * (croppedAreaPercentages.y / 100)
|
|
407
|
+
};
|
|
408
|
+
return {
|
|
409
|
+
crop,
|
|
410
|
+
zoom
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
function getZoomFromCroppedAreaPixels(croppedAreaPixels, mediaSize, cropSize) {
|
|
414
|
+
var mediaZoom = getMediaZoom(mediaSize);
|
|
415
|
+
return cropSize.height > cropSize.width ? cropSize.height / (croppedAreaPixels.height * mediaZoom) : cropSize.width / (croppedAreaPixels.width * mediaZoom);
|
|
416
|
+
}
|
|
417
|
+
function getInitialCropFromCroppedAreaPixels(croppedAreaPixels, mediaSize, rotation, cropSize, minZoom, maxZoom) {
|
|
418
|
+
if (rotation === void 0) {
|
|
419
|
+
rotation = 0;
|
|
420
|
+
}
|
|
421
|
+
var mediaNaturalBBoxSize = rotateSize(mediaSize.naturalWidth, mediaSize.naturalHeight, rotation);
|
|
422
|
+
var zoom = clamp(getZoomFromCroppedAreaPixels(croppedAreaPixels, mediaSize, cropSize), minZoom, maxZoom);
|
|
423
|
+
var cropZoom = cropSize.height > cropSize.width ? cropSize.height / croppedAreaPixels.height : cropSize.width / croppedAreaPixels.width;
|
|
424
|
+
var crop = {
|
|
425
|
+
x: ((mediaNaturalBBoxSize.width - croppedAreaPixels.width) / 2 - croppedAreaPixels.x) * cropZoom,
|
|
426
|
+
y: ((mediaNaturalBBoxSize.height - croppedAreaPixels.height) / 2 - croppedAreaPixels.y) * cropZoom
|
|
427
|
+
};
|
|
428
|
+
return {
|
|
429
|
+
crop,
|
|
430
|
+
zoom
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
function getCenter(a, b) {
|
|
434
|
+
return {
|
|
435
|
+
x: (b.x + a.x) / 2,
|
|
436
|
+
y: (b.y + a.y) / 2
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
function getRadianAngle(degreeValue) {
|
|
440
|
+
return degreeValue * Math.PI / 180;
|
|
441
|
+
}
|
|
442
|
+
function rotateSize(width, height, rotation) {
|
|
443
|
+
var rotRad = getRadianAngle(rotation);
|
|
444
|
+
return {
|
|
445
|
+
width: Math.abs(Math.cos(rotRad) * width) + Math.abs(Math.sin(rotRad) * height),
|
|
446
|
+
height: Math.abs(Math.sin(rotRad) * width) + Math.abs(Math.cos(rotRad) * height)
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
function clamp(value, min, max) {
|
|
450
|
+
return Math.min(Math.max(value, min), max);
|
|
451
|
+
}
|
|
452
|
+
function classNames() {
|
|
453
|
+
var args = [];
|
|
454
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
455
|
+
args[_i] = arguments[_i];
|
|
456
|
+
}
|
|
457
|
+
return args.filter(function(value) {
|
|
458
|
+
if (typeof value === "string" && value.length > 0) {
|
|
459
|
+
return true;
|
|
460
|
+
}
|
|
461
|
+
return false;
|
|
462
|
+
}).join(" ").trim();
|
|
463
|
+
}
|
|
464
|
+
var css_248z = ".reactEasyCrop_Container {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n overflow: hidden;\n user-select: none;\n touch-action: none;\n cursor: move;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.reactEasyCrop_Image,\n.reactEasyCrop_Video {\n will-change: transform; /* this improves performances and prevent painting issues on iOS Chrome */\n}\n\n.reactEasyCrop_Contain {\n max-width: 100%;\n max-height: 100%;\n margin: auto;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n}\n.reactEasyCrop_Cover_Horizontal {\n width: 100%;\n height: auto;\n}\n.reactEasyCrop_Cover_Vertical {\n width: auto;\n height: 100%;\n}\n\n.reactEasyCrop_CropArea {\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n border: 1px solid rgba(255, 255, 255, 0.5);\n box-sizing: border-box;\n box-shadow: 0 0 0 9999em;\n color: rgba(0, 0, 0, 0.5);\n overflow: hidden;\n}\n\n.reactEasyCrop_CropAreaRound {\n border-radius: 50%;\n}\n\n.reactEasyCrop_CropAreaGrid::before {\n content: ' ';\n box-sizing: border-box;\n position: absolute;\n border: 1px solid rgba(255, 255, 255, 0.5);\n top: 0;\n bottom: 0;\n left: 33.33%;\n right: 33.33%;\n border-top: 0;\n border-bottom: 0;\n}\n\n.reactEasyCrop_CropAreaGrid::after {\n content: ' ';\n box-sizing: border-box;\n position: absolute;\n border: 1px solid rgba(255, 255, 255, 0.5);\n top: 33.33%;\n bottom: 33.33%;\n left: 0;\n right: 0;\n border-left: 0;\n border-right: 0;\n}\n";
|
|
465
|
+
var MIN_ZOOM = 1;
|
|
466
|
+
var MAX_ZOOM = 3;
|
|
467
|
+
var KEYBOARD_STEP = 1;
|
|
468
|
+
var Cropper = (
|
|
469
|
+
/** @class */
|
|
470
|
+
function(_super) {
|
|
471
|
+
__extends(Cropper2, _super);
|
|
472
|
+
function Cropper2() {
|
|
473
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
474
|
+
_this.cropperRef = React.createRef();
|
|
475
|
+
_this.imageRef = React.createRef();
|
|
476
|
+
_this.videoRef = React.createRef();
|
|
477
|
+
_this.containerPosition = {
|
|
478
|
+
x: 0,
|
|
479
|
+
y: 0
|
|
480
|
+
};
|
|
481
|
+
_this.containerRef = null;
|
|
482
|
+
_this.styleRef = null;
|
|
483
|
+
_this.containerRect = null;
|
|
484
|
+
_this.mediaSize = {
|
|
485
|
+
width: 0,
|
|
486
|
+
height: 0,
|
|
487
|
+
naturalWidth: 0,
|
|
488
|
+
naturalHeight: 0
|
|
489
|
+
};
|
|
490
|
+
_this.dragStartPosition = {
|
|
491
|
+
x: 0,
|
|
492
|
+
y: 0
|
|
493
|
+
};
|
|
494
|
+
_this.dragStartCrop = {
|
|
495
|
+
x: 0,
|
|
496
|
+
y: 0
|
|
497
|
+
};
|
|
498
|
+
_this.gestureZoomStart = 0;
|
|
499
|
+
_this.gestureRotationStart = 0;
|
|
500
|
+
_this.isTouching = false;
|
|
501
|
+
_this.lastPinchDistance = 0;
|
|
502
|
+
_this.lastPinchRotation = 0;
|
|
503
|
+
_this.rafDragTimeout = null;
|
|
504
|
+
_this.rafPinchTimeout = null;
|
|
505
|
+
_this.wheelTimer = null;
|
|
506
|
+
_this.currentDoc = typeof document !== "undefined" ? document : null;
|
|
507
|
+
_this.currentWindow = typeof window !== "undefined" ? window : null;
|
|
508
|
+
_this.resizeObserver = null;
|
|
509
|
+
_this.state = {
|
|
510
|
+
cropSize: null,
|
|
511
|
+
hasWheelJustStarted: false,
|
|
512
|
+
mediaObjectFit: void 0
|
|
513
|
+
};
|
|
514
|
+
_this.initResizeObserver = function() {
|
|
515
|
+
if (typeof window.ResizeObserver === "undefined" || !_this.containerRef) {
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
var isFirstResize = true;
|
|
519
|
+
_this.resizeObserver = new window.ResizeObserver(function(entries) {
|
|
520
|
+
if (isFirstResize) {
|
|
521
|
+
isFirstResize = false;
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
_this.computeSizes();
|
|
525
|
+
});
|
|
526
|
+
_this.resizeObserver.observe(_this.containerRef);
|
|
527
|
+
};
|
|
528
|
+
_this.preventZoomSafari = function(e) {
|
|
529
|
+
return e.preventDefault();
|
|
530
|
+
};
|
|
531
|
+
_this.cleanEvents = function() {
|
|
532
|
+
if (!_this.currentDoc) return;
|
|
533
|
+
_this.currentDoc.removeEventListener("mousemove", _this.onMouseMove);
|
|
534
|
+
_this.currentDoc.removeEventListener("mouseup", _this.onDragStopped);
|
|
535
|
+
_this.currentDoc.removeEventListener("touchmove", _this.onTouchMove);
|
|
536
|
+
_this.currentDoc.removeEventListener("touchend", _this.onDragStopped);
|
|
537
|
+
_this.currentDoc.removeEventListener("gesturechange", _this.onGestureChange);
|
|
538
|
+
_this.currentDoc.removeEventListener("gestureend", _this.onGestureEnd);
|
|
539
|
+
_this.currentDoc.removeEventListener("scroll", _this.onScroll);
|
|
540
|
+
};
|
|
541
|
+
_this.clearScrollEvent = function() {
|
|
542
|
+
if (_this.containerRef) _this.containerRef.removeEventListener("wheel", _this.onWheel);
|
|
543
|
+
if (_this.wheelTimer) {
|
|
544
|
+
clearTimeout(_this.wheelTimer);
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
_this.onMediaLoad = function() {
|
|
548
|
+
var cropSize = _this.computeSizes();
|
|
549
|
+
if (cropSize) {
|
|
550
|
+
_this.emitCropData();
|
|
551
|
+
_this.setInitialCrop(cropSize);
|
|
552
|
+
}
|
|
553
|
+
if (_this.props.onMediaLoaded) {
|
|
554
|
+
_this.props.onMediaLoaded(_this.mediaSize);
|
|
555
|
+
}
|
|
556
|
+
};
|
|
557
|
+
_this.setInitialCrop = function(cropSize) {
|
|
558
|
+
if (_this.props.initialCroppedAreaPercentages) {
|
|
559
|
+
var _a = getInitialCropFromCroppedAreaPercentages(_this.props.initialCroppedAreaPercentages, _this.mediaSize, _this.props.rotation, cropSize, _this.props.minZoom, _this.props.maxZoom), crop = _a.crop, zoom = _a.zoom;
|
|
560
|
+
_this.props.onCropChange(crop);
|
|
561
|
+
_this.props.onZoomChange && _this.props.onZoomChange(zoom);
|
|
562
|
+
} else if (_this.props.initialCroppedAreaPixels) {
|
|
563
|
+
var _b = getInitialCropFromCroppedAreaPixels(_this.props.initialCroppedAreaPixels, _this.mediaSize, _this.props.rotation, cropSize, _this.props.minZoom, _this.props.maxZoom), crop = _b.crop, zoom = _b.zoom;
|
|
564
|
+
_this.props.onCropChange(crop);
|
|
565
|
+
_this.props.onZoomChange && _this.props.onZoomChange(zoom);
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
_this.computeSizes = function() {
|
|
569
|
+
var _a, _b, _c, _d, _e, _f;
|
|
570
|
+
var mediaRef = _this.imageRef.current || _this.videoRef.current;
|
|
571
|
+
if (mediaRef && _this.containerRef) {
|
|
572
|
+
_this.containerRect = _this.containerRef.getBoundingClientRect();
|
|
573
|
+
_this.saveContainerPosition();
|
|
574
|
+
var containerAspect = _this.containerRect.width / _this.containerRect.height;
|
|
575
|
+
var naturalWidth = ((_a = _this.imageRef.current) === null || _a === void 0 ? void 0 : _a.naturalWidth) || ((_b = _this.videoRef.current) === null || _b === void 0 ? void 0 : _b.videoWidth) || 0;
|
|
576
|
+
var naturalHeight = ((_c = _this.imageRef.current) === null || _c === void 0 ? void 0 : _c.naturalHeight) || ((_d = _this.videoRef.current) === null || _d === void 0 ? void 0 : _d.videoHeight) || 0;
|
|
577
|
+
var isMediaScaledDown = mediaRef.offsetWidth < naturalWidth || mediaRef.offsetHeight < naturalHeight;
|
|
578
|
+
var mediaAspect = naturalWidth / naturalHeight;
|
|
579
|
+
var renderedMediaSize = void 0;
|
|
580
|
+
if (isMediaScaledDown) {
|
|
581
|
+
switch (_this.state.mediaObjectFit) {
|
|
582
|
+
default:
|
|
583
|
+
case "contain":
|
|
584
|
+
renderedMediaSize = containerAspect > mediaAspect ? {
|
|
585
|
+
width: _this.containerRect.height * mediaAspect,
|
|
586
|
+
height: _this.containerRect.height
|
|
587
|
+
} : {
|
|
588
|
+
width: _this.containerRect.width,
|
|
589
|
+
height: _this.containerRect.width / mediaAspect
|
|
590
|
+
};
|
|
591
|
+
break;
|
|
592
|
+
case "horizontal-cover":
|
|
593
|
+
renderedMediaSize = {
|
|
594
|
+
width: _this.containerRect.width,
|
|
595
|
+
height: _this.containerRect.width / mediaAspect
|
|
596
|
+
};
|
|
597
|
+
break;
|
|
598
|
+
case "vertical-cover":
|
|
599
|
+
renderedMediaSize = {
|
|
600
|
+
width: _this.containerRect.height * mediaAspect,
|
|
601
|
+
height: _this.containerRect.height
|
|
602
|
+
};
|
|
603
|
+
break;
|
|
604
|
+
}
|
|
605
|
+
} else {
|
|
606
|
+
renderedMediaSize = {
|
|
607
|
+
width: mediaRef.offsetWidth,
|
|
608
|
+
height: mediaRef.offsetHeight
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
_this.mediaSize = __assign(__assign({}, renderedMediaSize), {
|
|
612
|
+
naturalWidth,
|
|
613
|
+
naturalHeight
|
|
614
|
+
});
|
|
615
|
+
if (_this.props.setMediaSize) {
|
|
616
|
+
_this.props.setMediaSize(_this.mediaSize);
|
|
617
|
+
}
|
|
618
|
+
var cropSize = _this.props.cropSize ? _this.props.cropSize : getCropSize(_this.mediaSize.width, _this.mediaSize.height, _this.containerRect.width, _this.containerRect.height, _this.props.aspect, _this.props.rotation);
|
|
619
|
+
if (((_e = _this.state.cropSize) === null || _e === void 0 ? void 0 : _e.height) !== cropSize.height || ((_f = _this.state.cropSize) === null || _f === void 0 ? void 0 : _f.width) !== cropSize.width) {
|
|
620
|
+
_this.props.onCropSizeChange && _this.props.onCropSizeChange(cropSize);
|
|
621
|
+
}
|
|
622
|
+
_this.setState({
|
|
623
|
+
cropSize
|
|
624
|
+
}, _this.recomputeCropPosition);
|
|
625
|
+
if (_this.props.setCropSize) {
|
|
626
|
+
_this.props.setCropSize(cropSize);
|
|
627
|
+
}
|
|
628
|
+
return cropSize;
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
_this.saveContainerPosition = function() {
|
|
632
|
+
if (_this.containerRef) {
|
|
633
|
+
var bounds = _this.containerRef.getBoundingClientRect();
|
|
634
|
+
_this.containerPosition = {
|
|
635
|
+
x: bounds.left,
|
|
636
|
+
y: bounds.top
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
_this.onMouseDown = function(e) {
|
|
641
|
+
if (!_this.currentDoc) return;
|
|
642
|
+
e.preventDefault();
|
|
643
|
+
_this.currentDoc.addEventListener("mousemove", _this.onMouseMove);
|
|
644
|
+
_this.currentDoc.addEventListener("mouseup", _this.onDragStopped);
|
|
645
|
+
_this.saveContainerPosition();
|
|
646
|
+
_this.onDragStart(Cropper2.getMousePoint(e));
|
|
647
|
+
};
|
|
648
|
+
_this.onMouseMove = function(e) {
|
|
649
|
+
return _this.onDrag(Cropper2.getMousePoint(e));
|
|
650
|
+
};
|
|
651
|
+
_this.onScroll = function(e) {
|
|
652
|
+
if (!_this.currentDoc) return;
|
|
653
|
+
e.preventDefault();
|
|
654
|
+
_this.saveContainerPosition();
|
|
655
|
+
};
|
|
656
|
+
_this.onTouchStart = function(e) {
|
|
657
|
+
if (!_this.currentDoc) return;
|
|
658
|
+
_this.isTouching = true;
|
|
659
|
+
if (_this.props.onTouchRequest && !_this.props.onTouchRequest(e)) {
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
_this.currentDoc.addEventListener("touchmove", _this.onTouchMove, {
|
|
663
|
+
passive: false
|
|
664
|
+
});
|
|
665
|
+
_this.currentDoc.addEventListener("touchend", _this.onDragStopped);
|
|
666
|
+
_this.saveContainerPosition();
|
|
667
|
+
if (e.touches.length === 2) {
|
|
668
|
+
_this.onPinchStart(e);
|
|
669
|
+
} else if (e.touches.length === 1) {
|
|
670
|
+
_this.onDragStart(Cropper2.getTouchPoint(e.touches[0]));
|
|
671
|
+
}
|
|
672
|
+
};
|
|
673
|
+
_this.onTouchMove = function(e) {
|
|
674
|
+
e.preventDefault();
|
|
675
|
+
if (e.touches.length === 2) {
|
|
676
|
+
_this.onPinchMove(e);
|
|
677
|
+
} else if (e.touches.length === 1) {
|
|
678
|
+
_this.onDrag(Cropper2.getTouchPoint(e.touches[0]));
|
|
679
|
+
}
|
|
680
|
+
};
|
|
681
|
+
_this.onGestureStart = function(e) {
|
|
682
|
+
if (!_this.currentDoc) return;
|
|
683
|
+
e.preventDefault();
|
|
684
|
+
_this.currentDoc.addEventListener("gesturechange", _this.onGestureChange);
|
|
685
|
+
_this.currentDoc.addEventListener("gestureend", _this.onGestureEnd);
|
|
686
|
+
_this.gestureZoomStart = _this.props.zoom;
|
|
687
|
+
_this.gestureRotationStart = _this.props.rotation;
|
|
688
|
+
};
|
|
689
|
+
_this.onGestureChange = function(e) {
|
|
690
|
+
e.preventDefault();
|
|
691
|
+
if (_this.isTouching) {
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
var point = Cropper2.getMousePoint(e);
|
|
695
|
+
var newZoom = _this.gestureZoomStart - 1 + e.scale;
|
|
696
|
+
_this.setNewZoom(newZoom, point, {
|
|
697
|
+
shouldUpdatePosition: true
|
|
698
|
+
});
|
|
699
|
+
if (_this.props.onRotationChange) {
|
|
700
|
+
var newRotation = _this.gestureRotationStart + e.rotation;
|
|
701
|
+
_this.props.onRotationChange(newRotation);
|
|
702
|
+
}
|
|
703
|
+
};
|
|
704
|
+
_this.onGestureEnd = function(e) {
|
|
705
|
+
_this.cleanEvents();
|
|
706
|
+
};
|
|
707
|
+
_this.onDragStart = function(_a) {
|
|
708
|
+
var _b, _c;
|
|
709
|
+
var x = _a.x, y = _a.y;
|
|
710
|
+
_this.dragStartPosition = {
|
|
711
|
+
x,
|
|
712
|
+
y
|
|
713
|
+
};
|
|
714
|
+
_this.dragStartCrop = __assign({}, _this.props.crop);
|
|
715
|
+
(_c = (_b = _this.props).onInteractionStart) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
716
|
+
};
|
|
717
|
+
_this.onDrag = function(_a) {
|
|
718
|
+
var x = _a.x, y = _a.y;
|
|
719
|
+
if (!_this.currentWindow) return;
|
|
720
|
+
if (_this.rafDragTimeout) _this.currentWindow.cancelAnimationFrame(_this.rafDragTimeout);
|
|
721
|
+
_this.rafDragTimeout = _this.currentWindow.requestAnimationFrame(function() {
|
|
722
|
+
if (!_this.state.cropSize) return;
|
|
723
|
+
if (x === void 0 || y === void 0) return;
|
|
724
|
+
var offsetX = x - _this.dragStartPosition.x;
|
|
725
|
+
var offsetY = y - _this.dragStartPosition.y;
|
|
726
|
+
var requestedPosition = {
|
|
727
|
+
x: _this.dragStartCrop.x + offsetX,
|
|
728
|
+
y: _this.dragStartCrop.y + offsetY
|
|
729
|
+
};
|
|
730
|
+
var newPosition = _this.props.restrictPosition ? restrictPosition(requestedPosition, _this.mediaSize, _this.state.cropSize, _this.props.zoom, _this.props.rotation) : requestedPosition;
|
|
731
|
+
_this.props.onCropChange(newPosition);
|
|
732
|
+
});
|
|
733
|
+
};
|
|
734
|
+
_this.onDragStopped = function() {
|
|
735
|
+
var _a, _b;
|
|
736
|
+
_this.isTouching = false;
|
|
737
|
+
_this.cleanEvents();
|
|
738
|
+
_this.emitCropData();
|
|
739
|
+
(_b = (_a = _this.props).onInteractionEnd) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
740
|
+
};
|
|
741
|
+
_this.onWheel = function(e) {
|
|
742
|
+
if (!_this.currentWindow) return;
|
|
743
|
+
if (_this.props.onWheelRequest && !_this.props.onWheelRequest(e)) {
|
|
744
|
+
return;
|
|
745
|
+
}
|
|
746
|
+
e.preventDefault();
|
|
747
|
+
var point = Cropper2.getMousePoint(e);
|
|
748
|
+
var pixelY = normalizeWheel$1(e).pixelY;
|
|
749
|
+
var newZoom = _this.props.zoom - pixelY * _this.props.zoomSpeed / 200;
|
|
750
|
+
_this.setNewZoom(newZoom, point, {
|
|
751
|
+
shouldUpdatePosition: true
|
|
752
|
+
});
|
|
753
|
+
if (!_this.state.hasWheelJustStarted) {
|
|
754
|
+
_this.setState({
|
|
755
|
+
hasWheelJustStarted: true
|
|
756
|
+
}, function() {
|
|
757
|
+
var _a, _b;
|
|
758
|
+
return (_b = (_a = _this.props).onInteractionStart) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
if (_this.wheelTimer) {
|
|
762
|
+
clearTimeout(_this.wheelTimer);
|
|
763
|
+
}
|
|
764
|
+
_this.wheelTimer = _this.currentWindow.setTimeout(function() {
|
|
765
|
+
return _this.setState({
|
|
766
|
+
hasWheelJustStarted: false
|
|
767
|
+
}, function() {
|
|
768
|
+
var _a, _b;
|
|
769
|
+
return (_b = (_a = _this.props).onInteractionEnd) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
770
|
+
});
|
|
771
|
+
}, 250);
|
|
772
|
+
};
|
|
773
|
+
_this.getPointOnContainer = function(_a, containerTopLeft) {
|
|
774
|
+
var x = _a.x, y = _a.y;
|
|
775
|
+
if (!_this.containerRect) {
|
|
776
|
+
throw new Error("The Cropper is not mounted");
|
|
777
|
+
}
|
|
778
|
+
return {
|
|
779
|
+
x: _this.containerRect.width / 2 - (x - containerTopLeft.x),
|
|
780
|
+
y: _this.containerRect.height / 2 - (y - containerTopLeft.y)
|
|
781
|
+
};
|
|
782
|
+
};
|
|
783
|
+
_this.getPointOnMedia = function(_a) {
|
|
784
|
+
var x = _a.x, y = _a.y;
|
|
785
|
+
var _b = _this.props, crop = _b.crop, zoom = _b.zoom;
|
|
786
|
+
return {
|
|
787
|
+
x: (x + crop.x) / zoom,
|
|
788
|
+
y: (y + crop.y) / zoom
|
|
789
|
+
};
|
|
790
|
+
};
|
|
791
|
+
_this.setNewZoom = function(zoom, point, _a) {
|
|
792
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.shouldUpdatePosition, shouldUpdatePosition = _c === void 0 ? true : _c;
|
|
793
|
+
if (!_this.state.cropSize || !_this.props.onZoomChange) return;
|
|
794
|
+
var newZoom = clamp(zoom, _this.props.minZoom, _this.props.maxZoom);
|
|
795
|
+
if (shouldUpdatePosition) {
|
|
796
|
+
var zoomPoint = _this.getPointOnContainer(point, _this.containerPosition);
|
|
797
|
+
var zoomTarget = _this.getPointOnMedia(zoomPoint);
|
|
798
|
+
var requestedPosition = {
|
|
799
|
+
x: zoomTarget.x * newZoom - zoomPoint.x,
|
|
800
|
+
y: zoomTarget.y * newZoom - zoomPoint.y
|
|
801
|
+
};
|
|
802
|
+
var newPosition = _this.props.restrictPosition ? restrictPosition(requestedPosition, _this.mediaSize, _this.state.cropSize, newZoom, _this.props.rotation) : requestedPosition;
|
|
803
|
+
_this.props.onCropChange(newPosition);
|
|
804
|
+
}
|
|
805
|
+
_this.props.onZoomChange(newZoom);
|
|
806
|
+
};
|
|
807
|
+
_this.getCropData = function() {
|
|
808
|
+
if (!_this.state.cropSize) {
|
|
809
|
+
return null;
|
|
810
|
+
}
|
|
811
|
+
var restrictedPosition = _this.props.restrictPosition ? restrictPosition(_this.props.crop, _this.mediaSize, _this.state.cropSize, _this.props.zoom, _this.props.rotation) : _this.props.crop;
|
|
812
|
+
return computeCroppedArea(restrictedPosition, _this.mediaSize, _this.state.cropSize, _this.getAspect(), _this.props.zoom, _this.props.rotation, _this.props.restrictPosition);
|
|
813
|
+
};
|
|
814
|
+
_this.emitCropData = function() {
|
|
815
|
+
var cropData = _this.getCropData();
|
|
816
|
+
if (!cropData) return;
|
|
817
|
+
var croppedAreaPercentages = cropData.croppedAreaPercentages, croppedAreaPixels = cropData.croppedAreaPixels;
|
|
818
|
+
if (_this.props.onCropComplete) {
|
|
819
|
+
_this.props.onCropComplete(croppedAreaPercentages, croppedAreaPixels);
|
|
820
|
+
}
|
|
821
|
+
if (_this.props.onCropAreaChange) {
|
|
822
|
+
_this.props.onCropAreaChange(croppedAreaPercentages, croppedAreaPixels);
|
|
823
|
+
}
|
|
824
|
+
};
|
|
825
|
+
_this.emitCropAreaChange = function() {
|
|
826
|
+
var cropData = _this.getCropData();
|
|
827
|
+
if (!cropData) return;
|
|
828
|
+
var croppedAreaPercentages = cropData.croppedAreaPercentages, croppedAreaPixels = cropData.croppedAreaPixels;
|
|
829
|
+
if (_this.props.onCropAreaChange) {
|
|
830
|
+
_this.props.onCropAreaChange(croppedAreaPercentages, croppedAreaPixels);
|
|
831
|
+
}
|
|
832
|
+
};
|
|
833
|
+
_this.recomputeCropPosition = function() {
|
|
834
|
+
if (!_this.state.cropSize) return;
|
|
835
|
+
var newPosition = _this.props.restrictPosition ? restrictPosition(_this.props.crop, _this.mediaSize, _this.state.cropSize, _this.props.zoom, _this.props.rotation) : _this.props.crop;
|
|
836
|
+
_this.props.onCropChange(newPosition);
|
|
837
|
+
_this.emitCropData();
|
|
838
|
+
};
|
|
839
|
+
_this.onKeyDown = function(event) {
|
|
840
|
+
var _a, _b;
|
|
841
|
+
var _c = _this.props, crop = _c.crop, onCropChange = _c.onCropChange, keyboardStep = _c.keyboardStep, zoom = _c.zoom, rotation = _c.rotation;
|
|
842
|
+
var step = keyboardStep;
|
|
843
|
+
if (!_this.state.cropSize) return;
|
|
844
|
+
if (event.shiftKey) {
|
|
845
|
+
step *= 0.2;
|
|
846
|
+
}
|
|
847
|
+
var newCrop = __assign({}, crop);
|
|
848
|
+
switch (event.key) {
|
|
849
|
+
case "ArrowUp":
|
|
850
|
+
newCrop.y -= step;
|
|
851
|
+
event.preventDefault();
|
|
852
|
+
break;
|
|
853
|
+
case "ArrowDown":
|
|
854
|
+
newCrop.y += step;
|
|
855
|
+
event.preventDefault();
|
|
856
|
+
break;
|
|
857
|
+
case "ArrowLeft":
|
|
858
|
+
newCrop.x -= step;
|
|
859
|
+
event.preventDefault();
|
|
860
|
+
break;
|
|
861
|
+
case "ArrowRight":
|
|
862
|
+
newCrop.x += step;
|
|
863
|
+
event.preventDefault();
|
|
864
|
+
break;
|
|
865
|
+
default:
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
if (_this.props.restrictPosition) {
|
|
869
|
+
newCrop = restrictPosition(newCrop, _this.mediaSize, _this.state.cropSize, zoom, rotation);
|
|
870
|
+
}
|
|
871
|
+
if (!event.repeat) {
|
|
872
|
+
(_b = (_a = _this.props).onInteractionStart) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
873
|
+
}
|
|
874
|
+
onCropChange(newCrop);
|
|
875
|
+
};
|
|
876
|
+
_this.onKeyUp = function(event) {
|
|
877
|
+
var _a, _b;
|
|
878
|
+
switch (event.key) {
|
|
879
|
+
case "ArrowUp":
|
|
880
|
+
case "ArrowDown":
|
|
881
|
+
case "ArrowLeft":
|
|
882
|
+
case "ArrowRight":
|
|
883
|
+
event.preventDefault();
|
|
884
|
+
break;
|
|
885
|
+
default:
|
|
886
|
+
return;
|
|
887
|
+
}
|
|
888
|
+
_this.emitCropData();
|
|
889
|
+
(_b = (_a = _this.props).onInteractionEnd) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
890
|
+
};
|
|
891
|
+
return _this;
|
|
892
|
+
}
|
|
893
|
+
Cropper2.prototype.componentDidMount = function() {
|
|
894
|
+
if (!this.currentDoc || !this.currentWindow) return;
|
|
895
|
+
if (this.containerRef) {
|
|
896
|
+
if (this.containerRef.ownerDocument) {
|
|
897
|
+
this.currentDoc = this.containerRef.ownerDocument;
|
|
898
|
+
}
|
|
899
|
+
if (this.currentDoc.defaultView) {
|
|
900
|
+
this.currentWindow = this.currentDoc.defaultView;
|
|
901
|
+
}
|
|
902
|
+
this.initResizeObserver();
|
|
903
|
+
if (typeof window.ResizeObserver === "undefined") {
|
|
904
|
+
this.currentWindow.addEventListener("resize", this.computeSizes);
|
|
905
|
+
}
|
|
906
|
+
this.props.zoomWithScroll && this.containerRef.addEventListener("wheel", this.onWheel, {
|
|
907
|
+
passive: false
|
|
908
|
+
});
|
|
909
|
+
this.containerRef.addEventListener("gesturestart", this.onGestureStart);
|
|
910
|
+
}
|
|
911
|
+
this.currentDoc.addEventListener("scroll", this.onScroll);
|
|
912
|
+
if (!this.props.disableAutomaticStylesInjection) {
|
|
913
|
+
this.styleRef = this.currentDoc.createElement("style");
|
|
914
|
+
this.styleRef.setAttribute("type", "text/css");
|
|
915
|
+
if (this.props.nonce) {
|
|
916
|
+
this.styleRef.setAttribute("nonce", this.props.nonce);
|
|
917
|
+
}
|
|
918
|
+
this.styleRef.innerHTML = css_248z;
|
|
919
|
+
this.currentDoc.head.appendChild(this.styleRef);
|
|
920
|
+
}
|
|
921
|
+
if (this.imageRef.current && this.imageRef.current.complete) {
|
|
922
|
+
this.onMediaLoad();
|
|
923
|
+
}
|
|
924
|
+
if (this.props.setImageRef) {
|
|
925
|
+
this.props.setImageRef(this.imageRef);
|
|
926
|
+
}
|
|
927
|
+
if (this.props.setVideoRef) {
|
|
928
|
+
this.props.setVideoRef(this.videoRef);
|
|
929
|
+
}
|
|
930
|
+
if (this.props.setCropperRef) {
|
|
931
|
+
this.props.setCropperRef(this.cropperRef);
|
|
932
|
+
}
|
|
933
|
+
};
|
|
934
|
+
Cropper2.prototype.componentWillUnmount = function() {
|
|
935
|
+
var _a, _b;
|
|
936
|
+
if (!this.currentDoc || !this.currentWindow) return;
|
|
937
|
+
if (typeof window.ResizeObserver === "undefined") {
|
|
938
|
+
this.currentWindow.removeEventListener("resize", this.computeSizes);
|
|
939
|
+
}
|
|
940
|
+
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
941
|
+
if (this.containerRef) {
|
|
942
|
+
this.containerRef.removeEventListener("gesturestart", this.preventZoomSafari);
|
|
943
|
+
}
|
|
944
|
+
if (this.styleRef) {
|
|
945
|
+
(_b = this.styleRef.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(this.styleRef);
|
|
946
|
+
}
|
|
947
|
+
this.cleanEvents();
|
|
948
|
+
this.props.zoomWithScroll && this.clearScrollEvent();
|
|
949
|
+
};
|
|
950
|
+
Cropper2.prototype.componentDidUpdate = function(prevProps) {
|
|
951
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
952
|
+
if (prevProps.rotation !== this.props.rotation) {
|
|
953
|
+
this.computeSizes();
|
|
954
|
+
this.recomputeCropPosition();
|
|
955
|
+
} else if (prevProps.aspect !== this.props.aspect) {
|
|
956
|
+
this.computeSizes();
|
|
957
|
+
} else if (prevProps.objectFit !== this.props.objectFit) {
|
|
958
|
+
this.computeSizes();
|
|
959
|
+
} else if (prevProps.zoom !== this.props.zoom) {
|
|
960
|
+
this.recomputeCropPosition();
|
|
961
|
+
} else if (((_a = prevProps.cropSize) === null || _a === void 0 ? void 0 : _a.height) !== ((_b = this.props.cropSize) === null || _b === void 0 ? void 0 : _b.height) || ((_c = prevProps.cropSize) === null || _c === void 0 ? void 0 : _c.width) !== ((_d = this.props.cropSize) === null || _d === void 0 ? void 0 : _d.width)) {
|
|
962
|
+
this.computeSizes();
|
|
963
|
+
} else if (((_e = prevProps.crop) === null || _e === void 0 ? void 0 : _e.x) !== ((_f = this.props.crop) === null || _f === void 0 ? void 0 : _f.x) || ((_g = prevProps.crop) === null || _g === void 0 ? void 0 : _g.y) !== ((_h = this.props.crop) === null || _h === void 0 ? void 0 : _h.y)) {
|
|
964
|
+
this.emitCropAreaChange();
|
|
965
|
+
}
|
|
966
|
+
if (prevProps.zoomWithScroll !== this.props.zoomWithScroll && this.containerRef) {
|
|
967
|
+
this.props.zoomWithScroll ? this.containerRef.addEventListener("wheel", this.onWheel, {
|
|
968
|
+
passive: false
|
|
969
|
+
}) : this.clearScrollEvent();
|
|
970
|
+
}
|
|
971
|
+
if (prevProps.video !== this.props.video) {
|
|
972
|
+
(_j = this.videoRef.current) === null || _j === void 0 ? void 0 : _j.load();
|
|
973
|
+
}
|
|
974
|
+
var objectFit = this.getObjectFit();
|
|
975
|
+
if (objectFit !== this.state.mediaObjectFit) {
|
|
976
|
+
this.setState({
|
|
977
|
+
mediaObjectFit: objectFit
|
|
978
|
+
}, this.computeSizes);
|
|
979
|
+
}
|
|
980
|
+
};
|
|
981
|
+
Cropper2.prototype.getAspect = function() {
|
|
982
|
+
var _a = this.props, cropSize = _a.cropSize, aspect = _a.aspect;
|
|
983
|
+
if (cropSize) {
|
|
984
|
+
return cropSize.width / cropSize.height;
|
|
985
|
+
}
|
|
986
|
+
return aspect;
|
|
987
|
+
};
|
|
988
|
+
Cropper2.prototype.getObjectFit = function() {
|
|
989
|
+
var _a, _b, _c, _d;
|
|
990
|
+
if (this.props.objectFit === "cover") {
|
|
991
|
+
var mediaRef = this.imageRef.current || this.videoRef.current;
|
|
992
|
+
if (mediaRef && this.containerRef) {
|
|
993
|
+
this.containerRect = this.containerRef.getBoundingClientRect();
|
|
994
|
+
var containerAspect = this.containerRect.width / this.containerRect.height;
|
|
995
|
+
var naturalWidth = ((_a = this.imageRef.current) === null || _a === void 0 ? void 0 : _a.naturalWidth) || ((_b = this.videoRef.current) === null || _b === void 0 ? void 0 : _b.videoWidth) || 0;
|
|
996
|
+
var naturalHeight = ((_c = this.imageRef.current) === null || _c === void 0 ? void 0 : _c.naturalHeight) || ((_d = this.videoRef.current) === null || _d === void 0 ? void 0 : _d.videoHeight) || 0;
|
|
997
|
+
var mediaAspect = naturalWidth / naturalHeight;
|
|
998
|
+
return mediaAspect < containerAspect ? "horizontal-cover" : "vertical-cover";
|
|
999
|
+
}
|
|
1000
|
+
return "horizontal-cover";
|
|
1001
|
+
}
|
|
1002
|
+
return this.props.objectFit;
|
|
1003
|
+
};
|
|
1004
|
+
Cropper2.prototype.onPinchStart = function(e) {
|
|
1005
|
+
var pointA = Cropper2.getTouchPoint(e.touches[0]);
|
|
1006
|
+
var pointB = Cropper2.getTouchPoint(e.touches[1]);
|
|
1007
|
+
this.lastPinchDistance = getDistanceBetweenPoints(pointA, pointB);
|
|
1008
|
+
this.lastPinchRotation = getRotationBetweenPoints(pointA, pointB);
|
|
1009
|
+
this.onDragStart(getCenter(pointA, pointB));
|
|
1010
|
+
};
|
|
1011
|
+
Cropper2.prototype.onPinchMove = function(e) {
|
|
1012
|
+
var _this = this;
|
|
1013
|
+
if (!this.currentDoc || !this.currentWindow) return;
|
|
1014
|
+
var pointA = Cropper2.getTouchPoint(e.touches[0]);
|
|
1015
|
+
var pointB = Cropper2.getTouchPoint(e.touches[1]);
|
|
1016
|
+
var center = getCenter(pointA, pointB);
|
|
1017
|
+
this.onDrag(center);
|
|
1018
|
+
if (this.rafPinchTimeout) this.currentWindow.cancelAnimationFrame(this.rafPinchTimeout);
|
|
1019
|
+
this.rafPinchTimeout = this.currentWindow.requestAnimationFrame(function() {
|
|
1020
|
+
var distance = getDistanceBetweenPoints(pointA, pointB);
|
|
1021
|
+
var newZoom = _this.props.zoom * (distance / _this.lastPinchDistance);
|
|
1022
|
+
_this.setNewZoom(newZoom, center, {
|
|
1023
|
+
shouldUpdatePosition: false
|
|
1024
|
+
});
|
|
1025
|
+
_this.lastPinchDistance = distance;
|
|
1026
|
+
var rotation = getRotationBetweenPoints(pointA, pointB);
|
|
1027
|
+
var newRotation = _this.props.rotation + (rotation - _this.lastPinchRotation);
|
|
1028
|
+
_this.props.onRotationChange && _this.props.onRotationChange(newRotation);
|
|
1029
|
+
_this.lastPinchRotation = rotation;
|
|
1030
|
+
});
|
|
1031
|
+
};
|
|
1032
|
+
Cropper2.prototype.render = function() {
|
|
1033
|
+
var _this = this;
|
|
1034
|
+
var _a;
|
|
1035
|
+
var _b = this.props, image = _b.image, video = _b.video, mediaProps = _b.mediaProps, cropperProps = _b.cropperProps, transform = _b.transform, _c = _b.crop, x = _c.x, y = _c.y, rotation = _b.rotation, zoom = _b.zoom, cropShape = _b.cropShape, showGrid = _b.showGrid, _d = _b.style, containerStyle = _d.containerStyle, cropAreaStyle = _d.cropAreaStyle, mediaStyle = _d.mediaStyle, _e = _b.classes, containerClassName = _e.containerClassName, cropAreaClassName = _e.cropAreaClassName, mediaClassName = _e.mediaClassName;
|
|
1036
|
+
var objectFit = (_a = this.state.mediaObjectFit) !== null && _a !== void 0 ? _a : this.getObjectFit();
|
|
1037
|
+
return React.createElement("div", {
|
|
1038
|
+
onMouseDown: this.onMouseDown,
|
|
1039
|
+
onTouchStart: this.onTouchStart,
|
|
1040
|
+
ref: function ref(el) {
|
|
1041
|
+
return _this.containerRef = el;
|
|
1042
|
+
},
|
|
1043
|
+
"data-testid": "container",
|
|
1044
|
+
style: containerStyle,
|
|
1045
|
+
className: classNames("reactEasyCrop_Container", containerClassName)
|
|
1046
|
+
}, image ? React.createElement("img", __assign({
|
|
1047
|
+
alt: "",
|
|
1048
|
+
className: classNames("reactEasyCrop_Image", objectFit === "contain" && "reactEasyCrop_Contain", objectFit === "horizontal-cover" && "reactEasyCrop_Cover_Horizontal", objectFit === "vertical-cover" && "reactEasyCrop_Cover_Vertical", mediaClassName)
|
|
1049
|
+
}, mediaProps, {
|
|
1050
|
+
src: image,
|
|
1051
|
+
ref: this.imageRef,
|
|
1052
|
+
style: __assign(__assign({}, mediaStyle), {
|
|
1053
|
+
transform: transform || "translate(".concat(x, "px, ").concat(y, "px) rotate(").concat(rotation, "deg) scale(").concat(zoom, ")")
|
|
1054
|
+
}),
|
|
1055
|
+
onLoad: this.onMediaLoad
|
|
1056
|
+
})) : video && React.createElement("video", __assign({
|
|
1057
|
+
autoPlay: true,
|
|
1058
|
+
playsInline: true,
|
|
1059
|
+
loop: true,
|
|
1060
|
+
muted: true,
|
|
1061
|
+
className: classNames("reactEasyCrop_Video", objectFit === "contain" && "reactEasyCrop_Contain", objectFit === "horizontal-cover" && "reactEasyCrop_Cover_Horizontal", objectFit === "vertical-cover" && "reactEasyCrop_Cover_Vertical", mediaClassName)
|
|
1062
|
+
}, mediaProps, {
|
|
1063
|
+
ref: this.videoRef,
|
|
1064
|
+
onLoadedMetadata: this.onMediaLoad,
|
|
1065
|
+
style: __assign(__assign({}, mediaStyle), {
|
|
1066
|
+
transform: transform || "translate(".concat(x, "px, ").concat(y, "px) rotate(").concat(rotation, "deg) scale(").concat(zoom, ")")
|
|
1067
|
+
}),
|
|
1068
|
+
controls: false
|
|
1069
|
+
}), (Array.isArray(video) ? video : [{
|
|
1070
|
+
src: video
|
|
1071
|
+
}]).map(function(item) {
|
|
1072
|
+
return React.createElement("source", __assign({
|
|
1073
|
+
key: item.src
|
|
1074
|
+
}, item));
|
|
1075
|
+
})), this.state.cropSize && React.createElement("div", __assign({
|
|
1076
|
+
ref: this.cropperRef,
|
|
1077
|
+
style: __assign(__assign({}, cropAreaStyle), {
|
|
1078
|
+
width: this.state.cropSize.width,
|
|
1079
|
+
height: this.state.cropSize.height
|
|
1080
|
+
}),
|
|
1081
|
+
tabIndex: 0,
|
|
1082
|
+
onKeyDown: this.onKeyDown,
|
|
1083
|
+
onKeyUp: this.onKeyUp,
|
|
1084
|
+
"data-testid": "cropper",
|
|
1085
|
+
className: classNames("reactEasyCrop_CropArea", cropShape === "round" && "reactEasyCrop_CropAreaRound", showGrid && "reactEasyCrop_CropAreaGrid", cropAreaClassName)
|
|
1086
|
+
}, cropperProps)));
|
|
1087
|
+
};
|
|
1088
|
+
Cropper2.defaultProps = {
|
|
1089
|
+
zoom: 1,
|
|
1090
|
+
rotation: 0,
|
|
1091
|
+
aspect: 4 / 3,
|
|
1092
|
+
maxZoom: MAX_ZOOM,
|
|
1093
|
+
minZoom: MIN_ZOOM,
|
|
1094
|
+
cropShape: "rect",
|
|
1095
|
+
objectFit: "contain",
|
|
1096
|
+
showGrid: true,
|
|
1097
|
+
style: {},
|
|
1098
|
+
classes: {},
|
|
1099
|
+
mediaProps: {},
|
|
1100
|
+
cropperProps: {},
|
|
1101
|
+
zoomSpeed: 1,
|
|
1102
|
+
restrictPosition: true,
|
|
1103
|
+
zoomWithScroll: true,
|
|
1104
|
+
keyboardStep: KEYBOARD_STEP
|
|
1105
|
+
};
|
|
1106
|
+
Cropper2.getMousePoint = function(e) {
|
|
1107
|
+
return {
|
|
1108
|
+
x: Number(e.clientX),
|
|
1109
|
+
y: Number(e.clientY)
|
|
1110
|
+
};
|
|
1111
|
+
};
|
|
1112
|
+
Cropper2.getTouchPoint = function(touch) {
|
|
1113
|
+
return {
|
|
1114
|
+
x: Number(touch.clientX),
|
|
1115
|
+
y: Number(touch.clientY)
|
|
1116
|
+
};
|
|
1117
|
+
};
|
|
1118
|
+
return Cropper2;
|
|
1119
|
+
}(React.Component)
|
|
1120
|
+
);
|
|
1121
|
+
const useImageCrop = (props) => {
|
|
1122
|
+
const size = useMemo(() => KEY_SIZE_DATA[props.dialog.button.size], [props.dialog.button.size]);
|
|
1123
|
+
const br = useMemo(() => `${size.radius}px`, [size.radius]);
|
|
1124
|
+
const { add } = useDialog({
|
|
1125
|
+
br,
|
|
1126
|
+
imageSettings: props.imageSettings,
|
|
1127
|
+
onSave: props.onSave,
|
|
1128
|
+
dialog: props.dialog,
|
|
1129
|
+
locale: props.locale,
|
|
1130
|
+
propsDialog: {
|
|
1131
|
+
borderRadius: br,
|
|
1132
|
+
padding: "0",
|
|
1133
|
+
background: "transparent"
|
|
1134
|
+
}
|
|
1135
|
+
});
|
|
1136
|
+
const handleAdd = useCallback(
|
|
1137
|
+
(images) => {
|
|
1138
|
+
add({
|
|
1139
|
+
content: (params, remove, isAnimating) => /* @__PURE__ */ jsxRuntimeExports.jsx(CropperWrapper, { images, params, remove, isAnimating })
|
|
1140
|
+
});
|
|
1141
|
+
},
|
|
1142
|
+
[add]
|
|
1143
|
+
);
|
|
1144
|
+
const handleAddFiles = useCallback(
|
|
1145
|
+
(files) => {
|
|
1146
|
+
const validFiles = Array.from(files).filter((file) => {
|
|
1147
|
+
if (file.size > props.imageSettings.maxSize) {
|
|
1148
|
+
console.warn(`File ${file.name} exceeds the allowed size of ${props.imageSettings.maxSize} bytes`);
|
|
1149
|
+
return false;
|
|
1150
|
+
}
|
|
1151
|
+
return true;
|
|
1152
|
+
});
|
|
1153
|
+
const newImages = validFiles.map((file, idx) => ({
|
|
1154
|
+
id: Date.now() + idx,
|
|
1155
|
+
file,
|
|
1156
|
+
url: URL.createObjectURL(file),
|
|
1157
|
+
index: idx,
|
|
1158
|
+
isNew: true,
|
|
1159
|
+
name: file.name,
|
|
1160
|
+
format: file.type
|
|
1161
|
+
}));
|
|
1162
|
+
if (props.refInput && "current" in props.refInput && props.refInput.current) {
|
|
1163
|
+
props.refInput.current.value = "";
|
|
1164
|
+
}
|
|
1165
|
+
if (newImages.length) handleAdd(newImages);
|
|
1166
|
+
},
|
|
1167
|
+
[handleAdd, props.imageSettings.maxSize, props.refInput]
|
|
1168
|
+
);
|
|
1169
|
+
return { handleAdd, handleAddFiles };
|
|
1170
|
+
};
|
|
1171
|
+
function getCroppedImg(imageSrc, crop, format = "image/png") {
|
|
1172
|
+
const mimeType = ImageSupportedFormats.includes(format) ? format : "image/png";
|
|
1173
|
+
return new Promise((resolve, reject) => {
|
|
1174
|
+
const image = new Image();
|
|
1175
|
+
image.src = imageSrc;
|
|
1176
|
+
image.crossOrigin = "anonymous";
|
|
1177
|
+
image.onload = () => {
|
|
1178
|
+
const canvas = document.createElement("canvas");
|
|
1179
|
+
const ctx = canvas.getContext("2d");
|
|
1180
|
+
canvas.width = crop.width;
|
|
1181
|
+
canvas.height = crop.height;
|
|
1182
|
+
ctx.drawImage(image, crop.x, crop.y, crop.width, crop.height, 0, 0, crop.width, crop.height);
|
|
1183
|
+
canvas.toBlob((blob) => {
|
|
1184
|
+
if (blob) resolve(blob);
|
|
1185
|
+
else reject(new Error("Canvas is empty"));
|
|
1186
|
+
}, mimeType);
|
|
1187
|
+
};
|
|
1188
|
+
image.onerror = () => reject(new Error("Failed to load image"));
|
|
1189
|
+
});
|
|
1190
|
+
}
|
|
1191
|
+
const CropperWrapper = (props) => {
|
|
1192
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1193
|
+
const [index, setIndex] = useState(0);
|
|
1194
|
+
const [newImages, setNewImages] = useState([]);
|
|
1195
|
+
const [newImagesCroppedArea, setNewImagesCroppedArea] = useState([]);
|
|
1196
|
+
const theme = useTheme();
|
|
1197
|
+
const isMulti = useMemo(() => props.images.length > 1, [props.images.length]);
|
|
1198
|
+
const newImageIndex = useMemo(() => newImages == null ? void 0 : newImages[index], [newImages, index]);
|
|
1199
|
+
const onSave = useCallback(
|
|
1200
|
+
async (images) => {
|
|
1201
|
+
var _a2, _b2, _c2;
|
|
1202
|
+
const saveImages = await Promise.all(
|
|
1203
|
+
images.map(async (image) => {
|
|
1204
|
+
const imageCroppedArea = newImagesCroppedArea[image.index] ?? null;
|
|
1205
|
+
if (image.isDeleted || !image.isCropped || !image.url || !image.name || !imageCroppedArea) return null;
|
|
1206
|
+
const blob = await getCroppedImg(image.url, imageCroppedArea, image.format);
|
|
1207
|
+
const croppedFile = new File([blob], image.name, { type: image.format });
|
|
1208
|
+
const newImage = {
|
|
1209
|
+
...image,
|
|
1210
|
+
file: croppedFile,
|
|
1211
|
+
url: URL.createObjectURL(croppedFile)
|
|
1212
|
+
};
|
|
1213
|
+
return newImage;
|
|
1214
|
+
})
|
|
1215
|
+
);
|
|
1216
|
+
(_b2 = (_a2 = props.params) == null ? void 0 : _a2.onSave) == null ? void 0 : _b2.call(_a2, saveImages.filter(Boolean));
|
|
1217
|
+
(_c2 = props.remove) == null ? void 0 : _c2.call(props);
|
|
1218
|
+
},
|
|
1219
|
+
[newImagesCroppedArea, props]
|
|
1220
|
+
);
|
|
1221
|
+
const onChange = useCallback(
|
|
1222
|
+
async (params) => {
|
|
1223
|
+
var _a2;
|
|
1224
|
+
const image = (_a2 = props.images) == null ? void 0 : _a2[params.index];
|
|
1225
|
+
if (image) {
|
|
1226
|
+
const newImage = {
|
|
1227
|
+
...image,
|
|
1228
|
+
id: Date.now() + params.index,
|
|
1229
|
+
index: params.index,
|
|
1230
|
+
croppedArea: params.croppedArea ?? image.croppedArea,
|
|
1231
|
+
zoom: params.zoom ?? image.zoom,
|
|
1232
|
+
crop: params.crop ?? image.crop,
|
|
1233
|
+
isNew: true,
|
|
1234
|
+
isCropped: params.isCropped ?? image.isCropped,
|
|
1235
|
+
isDeleted: params.isDeleted ?? image.isDeleted
|
|
1236
|
+
};
|
|
1237
|
+
setNewImages((prev) => {
|
|
1238
|
+
const arr = [...prev];
|
|
1239
|
+
arr[params.index] = newImage;
|
|
1240
|
+
return arr;
|
|
1241
|
+
});
|
|
1242
|
+
if (params.isNext) {
|
|
1243
|
+
const newIndex = params.index + 1 >= props.images.length ? 0 : params.index + 1;
|
|
1244
|
+
setIndex(newIndex);
|
|
1245
|
+
}
|
|
1246
|
+
if (params.isSave) {
|
|
1247
|
+
onSave([newImage]);
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
},
|
|
1251
|
+
[onSave, props.images]
|
|
1252
|
+
);
|
|
1253
|
+
useEffect(() => {
|
|
1254
|
+
setNewImages(props.images);
|
|
1255
|
+
setNewImagesCroppedArea(props.images.map((image) => image.croppedArea ?? null));
|
|
1256
|
+
}, [props.images]);
|
|
1257
|
+
useEffect(() => {
|
|
1258
|
+
return () => {
|
|
1259
|
+
setIndex(0);
|
|
1260
|
+
setNewImages([]);
|
|
1261
|
+
setNewImagesCroppedArea([]);
|
|
1262
|
+
};
|
|
1263
|
+
}, []);
|
|
1264
|
+
const lengthData = useMemo(() => {
|
|
1265
|
+
return newImages.reduce((acc, image) => {
|
|
1266
|
+
if (acc && (image == null ? void 0 : image.index) !== void 0)
|
|
1267
|
+
acc[image.index] = {
|
|
1268
|
+
genre: image.isDeleted ? "redTransparent" : image.isCropped ? "greenTransparent" : "white",
|
|
1269
|
+
icons: image.isDeleted ? [{ type: "id", name: "CloseMini" }] : image.isCropped ? [{ type: "id", name: "TickMini" }] : []
|
|
1270
|
+
};
|
|
1271
|
+
return acc;
|
|
1272
|
+
}, {});
|
|
1273
|
+
}, [newImages]);
|
|
1274
|
+
const isDisabledSave = useMemo(() => {
|
|
1275
|
+
return newImages.every((image) => (image == null ? void 0 : image.isDeleted) || !(image == null ? void 0 : image.isCropped));
|
|
1276
|
+
}, [newImages]);
|
|
1277
|
+
const genre = useMemo(() => {
|
|
1278
|
+
var _a2;
|
|
1279
|
+
return ((_a2 = props.params) == null ? void 0 : _a2.dialog.button.genre) || "product";
|
|
1280
|
+
}, [(_a = props.params) == null ? void 0 : _a.dialog.button.genre]);
|
|
1281
|
+
const size = useMemo(() => {
|
|
1282
|
+
var _a2;
|
|
1283
|
+
return ((_a2 = props.params) == null ? void 0 : _a2.dialog.button.size) || "medium";
|
|
1284
|
+
}, [(_b = props.params) == null ? void 0 : _b.dialog.button.size]);
|
|
1285
|
+
const genreDelete = useMemo(
|
|
1286
|
+
() => {
|
|
1287
|
+
var _a2;
|
|
1288
|
+
return ((_a2 = props.params) == null ? void 0 : _a2.dialog.buttonDelete.genre) || "product";
|
|
1289
|
+
},
|
|
1290
|
+
[(_c = props.params) == null ? void 0 : _c.dialog.buttonDelete.genre]
|
|
1291
|
+
);
|
|
1292
|
+
const sizeDelete = useMemo(() => {
|
|
1293
|
+
var _a2;
|
|
1294
|
+
return ((_a2 = props.params) == null ? void 0 : _a2.dialog.button.size) || "medium";
|
|
1295
|
+
}, [(_d = props.params) == null ? void 0 : _d.dialog.button.size]);
|
|
1296
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1297
|
+
Stack,
|
|
1298
|
+
{
|
|
1299
|
+
sx: (theme2) => {
|
|
1300
|
+
var _a2, _b2, _c2;
|
|
1301
|
+
return {
|
|
1302
|
+
default: {
|
|
1303
|
+
position: "relative",
|
|
1304
|
+
overflow: "hidden",
|
|
1305
|
+
aspectRatio: ((_a2 = props.params) == null ? void 0 : _a2.imageSettings.aspect) ? `${((_b2 = props.params) == null ? void 0 : _b2.imageSettings.aspect) * 2} / 2` : void 0,
|
|
1306
|
+
width: "auto",
|
|
1307
|
+
maxWidth: "70dvw",
|
|
1308
|
+
height: "85dvh",
|
|
1309
|
+
borderRadius: (_c2 = props.params) == null ? void 0 : _c2.br,
|
|
1310
|
+
backgroundColor: theme2.palette.whiteStandard
|
|
1311
|
+
},
|
|
1312
|
+
tablet: {
|
|
1313
|
+
maxWidth: "95dvw"
|
|
1314
|
+
}
|
|
1315
|
+
};
|
|
1316
|
+
},
|
|
1317
|
+
children: [
|
|
1318
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(Preview, { visible: !props.isAnimating, minTime: 500, children: [
|
|
1319
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1320
|
+
Stack,
|
|
1321
|
+
{
|
|
1322
|
+
sx: {
|
|
1323
|
+
default: {
|
|
1324
|
+
position: "absolute",
|
|
1325
|
+
top: 0,
|
|
1326
|
+
left: 0,
|
|
1327
|
+
right: 0,
|
|
1328
|
+
bottom: 0
|
|
1329
|
+
}
|
|
1330
|
+
},
|
|
1331
|
+
children: newImageIndex && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1332
|
+
Cropper,
|
|
1333
|
+
{
|
|
1334
|
+
style: {
|
|
1335
|
+
containerStyle: {
|
|
1336
|
+
backgroundColor: theme.palette.black80
|
|
1337
|
+
}
|
|
1338
|
+
},
|
|
1339
|
+
image: newImageIndex.url,
|
|
1340
|
+
crop: (newImageIndex == null ? void 0 : newImageIndex.crop) ?? { x: 0, y: 0 },
|
|
1341
|
+
zoom: (newImageIndex == null ? void 0 : newImageIndex.zoom) ?? 1,
|
|
1342
|
+
aspect: (_e = props.params) == null ? void 0 : _e.imageSettings.aspect,
|
|
1343
|
+
onCropChange: (crop) => {
|
|
1344
|
+
onChange({
|
|
1345
|
+
...newImageIndex,
|
|
1346
|
+
crop
|
|
1347
|
+
});
|
|
1348
|
+
},
|
|
1349
|
+
onZoomChange: (zoom) => {
|
|
1350
|
+
onChange({
|
|
1351
|
+
...newImageIndex,
|
|
1352
|
+
zoom
|
|
1353
|
+
});
|
|
1354
|
+
},
|
|
1355
|
+
onCropComplete: (_, croppedArea) => {
|
|
1356
|
+
setNewImagesCroppedArea((prev) => {
|
|
1357
|
+
const arr = [...prev];
|
|
1358
|
+
arr[index] = croppedArea;
|
|
1359
|
+
return arr;
|
|
1360
|
+
});
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
)
|
|
1364
|
+
}
|
|
1365
|
+
),
|
|
1366
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1367
|
+
Stack,
|
|
1368
|
+
{
|
|
1369
|
+
sx: {
|
|
1370
|
+
default: {
|
|
1371
|
+
position: "absolute",
|
|
1372
|
+
top: 15,
|
|
1373
|
+
right: 15,
|
|
1374
|
+
gap: "10px"
|
|
1375
|
+
}
|
|
1376
|
+
},
|
|
1377
|
+
children: [
|
|
1378
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { genre: genreDelete, size: sizeDelete, isHiddenBorder: true, isRadius: true, onClick: () => {
|
|
1379
|
+
var _a2;
|
|
1380
|
+
return (_a2 = props.remove) == null ? void 0 : _a2.call(props);
|
|
1381
|
+
}, children: (_f = props.params) == null ? void 0 : _f.locale.dialogCancel }),
|
|
1382
|
+
isMulti && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1383
|
+
Button,
|
|
1384
|
+
{
|
|
1385
|
+
genre,
|
|
1386
|
+
size,
|
|
1387
|
+
isHiddenBorder: true,
|
|
1388
|
+
isRadius: true,
|
|
1389
|
+
onClick: () => onSave(newImages),
|
|
1390
|
+
isHidden: isDisabledSave,
|
|
1391
|
+
isDisabled: isDisabledSave,
|
|
1392
|
+
children: (_g = props.params) == null ? void 0 : _g.locale.dialogSave
|
|
1393
|
+
}
|
|
1394
|
+
)
|
|
1395
|
+
]
|
|
1396
|
+
}
|
|
1397
|
+
)
|
|
1398
|
+
] }),
|
|
1399
|
+
isMulti && index !== props.images.length && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1400
|
+
Button,
|
|
1401
|
+
{
|
|
1402
|
+
sx: {
|
|
1403
|
+
default: {
|
|
1404
|
+
position: "absolute",
|
|
1405
|
+
top: 15,
|
|
1406
|
+
left: 15
|
|
1407
|
+
}
|
|
1408
|
+
},
|
|
1409
|
+
genre,
|
|
1410
|
+
size,
|
|
1411
|
+
isHiddenBorder: true,
|
|
1412
|
+
isWidthAsHeight: true,
|
|
1413
|
+
isRadius: true,
|
|
1414
|
+
isDisabled: true,
|
|
1415
|
+
children: index + 1
|
|
1416
|
+
}
|
|
1417
|
+
),
|
|
1418
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1419
|
+
Stack,
|
|
1420
|
+
{
|
|
1421
|
+
sx: (theme2) => ({
|
|
1422
|
+
default: {
|
|
1423
|
+
position: "absolute",
|
|
1424
|
+
bottom: isMulti ? 5 : 15,
|
|
1425
|
+
left: isMulti ? 5 : void 0,
|
|
1426
|
+
right: isMulti ? void 0 : 15,
|
|
1427
|
+
width: isMulti ? "calc(100% - 10px)" : "fit-content",
|
|
1428
|
+
backgroundColor: isMulti ? theme2.palette.whiteStandard : theme2.palette.transparent,
|
|
1429
|
+
padding: "10px",
|
|
1430
|
+
borderRadius: "50px",
|
|
1431
|
+
flexDirection: "row",
|
|
1432
|
+
justifyContent: "space-between",
|
|
1433
|
+
alignItems: "center",
|
|
1434
|
+
gap: "10px"
|
|
1435
|
+
},
|
|
1436
|
+
mobile: {
|
|
1437
|
+
borderRadius: "24px",
|
|
1438
|
+
flexDirection: "column",
|
|
1439
|
+
alignItems: "stretch",
|
|
1440
|
+
gap: "10px"
|
|
1441
|
+
}
|
|
1442
|
+
}),
|
|
1443
|
+
children: [
|
|
1444
|
+
isMulti && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1445
|
+
Pagination,
|
|
1446
|
+
{
|
|
1447
|
+
sx: {
|
|
1448
|
+
default: {},
|
|
1449
|
+
mobile: {
|
|
1450
|
+
justifyContent: "space-between"
|
|
1451
|
+
}
|
|
1452
|
+
},
|
|
1453
|
+
lengthData,
|
|
1454
|
+
length: props.images.length,
|
|
1455
|
+
index,
|
|
1456
|
+
changeIndex: (newIndex) => {
|
|
1457
|
+
setIndex(newIndex);
|
|
1458
|
+
},
|
|
1459
|
+
isInfinity: true,
|
|
1460
|
+
viewQuantity: 4,
|
|
1461
|
+
buttonControl: {
|
|
1462
|
+
genre,
|
|
1463
|
+
size,
|
|
1464
|
+
isRadius: true,
|
|
1465
|
+
isWidthAsHeight: true
|
|
1466
|
+
},
|
|
1467
|
+
buttonCount: {
|
|
1468
|
+
active: {
|
|
1469
|
+
genre,
|
|
1470
|
+
size,
|
|
1471
|
+
isRadius: true,
|
|
1472
|
+
isPlaystationEffect: true
|
|
1473
|
+
},
|
|
1474
|
+
inactive: {
|
|
1475
|
+
genre: "white",
|
|
1476
|
+
size,
|
|
1477
|
+
isRadius: true
|
|
1478
|
+
}
|
|
1479
|
+
},
|
|
1480
|
+
locale: {
|
|
1481
|
+
next: "Next",
|
|
1482
|
+
prev: "Prev"
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
),
|
|
1486
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1487
|
+
Stack,
|
|
1488
|
+
{
|
|
1489
|
+
sx: {
|
|
1490
|
+
default: {
|
|
1491
|
+
gap: "10px"
|
|
1492
|
+
},
|
|
1493
|
+
mobile: {
|
|
1494
|
+
justifyContent: "center"
|
|
1495
|
+
}
|
|
1496
|
+
},
|
|
1497
|
+
children: [
|
|
1498
|
+
isMulti && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1499
|
+
Button,
|
|
1500
|
+
{
|
|
1501
|
+
genre: genreDelete,
|
|
1502
|
+
size: sizeDelete,
|
|
1503
|
+
isHiddenBorder: true,
|
|
1504
|
+
isRadius: true,
|
|
1505
|
+
onClick: () => {
|
|
1506
|
+
onChange({
|
|
1507
|
+
...newImageIndex,
|
|
1508
|
+
isDeleted: true,
|
|
1509
|
+
isNext: isMulti
|
|
1510
|
+
});
|
|
1511
|
+
},
|
|
1512
|
+
children: (_h = props.params) == null ? void 0 : _h.locale.dialogDeleteImage
|
|
1513
|
+
}
|
|
1514
|
+
),
|
|
1515
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1516
|
+
Button,
|
|
1517
|
+
{
|
|
1518
|
+
genre,
|
|
1519
|
+
size,
|
|
1520
|
+
isHiddenBorder: true,
|
|
1521
|
+
isRadius: true,
|
|
1522
|
+
onClick: () => {
|
|
1523
|
+
onChange({
|
|
1524
|
+
...newImageIndex,
|
|
1525
|
+
isDeleted: false,
|
|
1526
|
+
isCropped: true,
|
|
1527
|
+
isNext: isMulti,
|
|
1528
|
+
isSave: !isMulti
|
|
1529
|
+
});
|
|
1530
|
+
},
|
|
1531
|
+
children: isMulti ? (_i = props.params) == null ? void 0 : _i.locale.dialogAddImage : (_j = props.params) == null ? void 0 : _j.locale.dialogSave
|
|
1532
|
+
}
|
|
1533
|
+
)
|
|
1534
|
+
]
|
|
1535
|
+
}
|
|
1536
|
+
)
|
|
1537
|
+
]
|
|
1538
|
+
}
|
|
1539
|
+
)
|
|
1540
|
+
]
|
|
1541
|
+
}
|
|
1542
|
+
);
|
|
1543
|
+
};
|
|
1544
|
+
export {
|
|
1545
|
+
useImageCrop as u
|
|
1546
|
+
};
|
|
1547
|
+
//# sourceMappingURL=use-BVj4dgbW.js.map
|