@orangelogic/design-system 2.108.0 → 2.110.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/library/assets/design-system.css +1 -1
- package/library/chunks/{asset.BOex8mNF.js → asset.NgymQ3Zx.js} +139 -128
- package/library/chunks/{button.BgLgpUch.js → button.i88sSbTZ.js} +1 -1
- package/library/chunks/{color-swatch-group.CJR5NTAx.js → color-swatch-group.mIHaCJsh.js} +5 -5
- package/library/chunks/{color-swatch.LWXX_hoG.js → color-swatch.D9vkPoV2.js} +1 -1
- package/library/chunks/{confirm-popover.BzpCIDBx.js → confirm-popover.UuBhn8GA.js} +3 -3
- package/library/chunks/{content-builder.B-bd8FaV.js → content-builder.OsUmm8Wu.js} +15 -15
- package/library/chunks/{dialog.BTYaKnFg.js → dialog.Bso6gK-8.js} +2 -2
- package/library/chunks/document-viewer.C6eclRvd.js +25232 -0
- package/library/chunks/{dot-pagination.Do9tKlWY.js → dot-pagination.CNnUuI-Z.js} +1 -1
- package/library/chunks/{file-on-demand.DICkRgvk.js → file-on-demand.Cf2ujTeF.js} +8 -8
- package/library/chunks/{folder-select.DLjFwi4I.js → folder-select.ByNUfTia.js} +3 -3
- package/library/chunks/{header.CLZWpAF-.js → header.hj2Kw-N7.js} +1 -1
- package/library/chunks/{i18n.ju3y72qp.js → i18n.D6AYDPK-.js} +3 -0
- package/library/chunks/{icon-button.CLlmo1AF.js → icon-button.ztYU-DHy.js} +1 -1
- package/library/chunks/{iframe.CqtDcvOS.js → iframe.uLxZ6LsL.js} +1 -1
- package/library/chunks/{image.CfNFiNFB.js → image.DKB6yEQO.js} +187 -187
- package/library/chunks/inheritsLoose.BuSn_CvZ.js +27 -0
- package/library/chunks/{cropper.CMfBGsNv.js → jsx-runtime.CTpPVMxj.js} +9462 -10423
- package/library/chunks/{list-editor.zY8vlbde.js → list-editor.GT2kQsmR.js} +87 -86
- package/library/chunks/{option.BOZYPQZH.js → option.BAYtHIvG.js} +1 -1
- package/library/chunks/{pagination.BGjp2gVJ.js → pagination.CCJD61IB.js} +4 -4
- package/library/chunks/{resizable-component.styles.sAhMVN1H.js → resizable-component.styles.DpK0TTP5.js} +6 -6
- package/library/chunks/{responsive.Aigicabj.js → responsive.C8NCkfCG.js} +1 -1
- package/library/chunks/{tab-group.hmlZakLy.js → tab-group.BsR8tdVY.js} +3 -3
- package/library/chunks/{table.XsBhq1U3.js → table.DL_CEeYh.js} +5 -5
- package/library/chunks/{tree.DAhCAxwV.js → tree.KmZRWZ0F.js} +1 -1
- package/library/components/alert.js +2 -2
- package/library/components/asset-link-format.js +6 -6
- package/library/components/atoms.js +147 -145
- package/library/components/audio.js +3 -3
- package/library/components/border-input-group.js +1 -1
- package/library/components/breadcrumb.js +1 -1
- package/library/components/button.js +2 -2
- package/library/components/color-picker.js +2 -2
- package/library/components/color-swatch-group.js +6 -6
- package/library/components/color-swatch.js +2 -2
- package/library/components/confirm-popover.js +4 -4
- package/library/components/copy-button.js +1 -1
- package/library/components/corner-position-input-group.js +2 -2
- package/library/components/cropper.js +961 -10
- package/library/components/details.js +1 -1
- package/library/components/dialog.js +3 -3
- package/library/components/document-viewer.d.ts +3 -0
- package/library/components/document-viewer.js +17 -0
- package/library/components/dot-pagination.js +2 -2
- package/library/components/drawer.js +2 -2
- package/library/components/dropdown.js +1 -1
- package/library/components/dynamic-select.js +4 -4
- package/library/components/e-chart.js +1 -1
- package/library/components/element-clamp.js +2 -2
- package/library/components/file-on-demand.js +9 -9
- package/library/components/folder-select.js +3 -3
- package/library/components/format-bytes.js +1 -1
- package/library/components/format-date.js +1 -1
- package/library/components/format-number.js +1 -1
- package/library/components/format-time.js +1 -1
- package/library/components/header.js +2 -2
- package/library/components/icon-button.js +2 -2
- package/library/components/iframe.js +2 -2
- package/library/components/image-comparer.js +1 -1
- package/library/components/image.js +3 -3
- package/library/components/input.js +1 -1
- package/library/components/line-clamp.js +1 -1
- package/library/components/list-editor.js +6 -6
- package/library/components/masonry.js +2 -2
- package/library/components/menu-item.js +1 -1
- package/library/components/menu.js +1 -1
- package/library/components/molecules.js +7 -7
- package/library/components/option.js +2 -2
- package/library/components/organisms.js +2 -2
- package/library/components/pagination.js +5 -5
- package/library/components/popup.js +1 -1
- package/library/components/position-picker.js +1 -1
- package/library/components/progress-bar.js +1 -1
- package/library/components/progress-ring.js +1 -1
- package/library/components/range.js +1 -1
- package/library/components/rating.js +1 -1
- package/library/components/relative-time.js +1 -1
- package/library/components/select.js +2 -2
- package/library/components/share-option-list.js +1 -1
- package/library/components/sidebar.js +1 -1
- package/library/components/size-input-group.js +2 -2
- package/library/components/spinner.js +1 -1
- package/library/components/split-panel.js +1 -1
- package/library/components/tab-group.js +4 -4
- package/library/components/tab.js +2 -2
- package/library/components/table.js +5 -5
- package/library/components/tag.js +2 -2
- package/library/components/tooltip.js +1 -1
- package/library/components/tree-item.js +2 -2
- package/library/components/tree.js +2 -2
- package/library/components/typeface.js +2 -2
- package/library/components/types.js +17110 -17307
- package/library/components/video.js +3605 -3625
- package/library/package.json +1 -1
- package/library/packages/atoms/src/components/document-viewer/document-viewer.d.ts +60 -0
- package/library/packages/atoms/src/components/document-viewer/document-viewer.styles.d.ts +2 -0
- package/library/packages/atoms/src/index.d.ts +1 -0
- package/library/packages/events/src/cx-document-viewer-open-asset.d.ts +8 -0
- package/library/packages/events/src/events.d.ts +1 -0
- package/library/packages/hybrid/book-reader/src/book-reader/book-reader.d.ts +99 -0
- package/library/packages/hybrid/book-reader/src/book-reader/book-reader.styles.d.ts +2 -0
- package/library/packages/hybrid/book-reader/src/react/BookReader.d.ts +6 -0
- package/library/packages/hybrid/book-reader/src/react/components/Album/Album.d.ts +31 -0
- package/library/packages/hybrid/book-reader/src/react/components/Album/AlbumThumbnails.d.ts +17 -0
- package/library/packages/hybrid/book-reader/src/react/components/Album/ErrorImage.d.ts +5 -0
- package/library/packages/hybrid/book-reader/src/react/components/Album/Page.d.ts +21 -0
- package/library/packages/hybrid/book-reader/src/react/components/Album/index.d.ts +1 -0
- package/library/packages/hybrid/book-reader/src/react/components/Book/Book.d.ts +20 -0
- package/library/packages/hybrid/book-reader/src/react/components/Book/BookThumbnails.d.ts +17 -0
- package/library/packages/hybrid/book-reader/src/react/components/Book/Page.d.ts +20 -0
- package/library/packages/hybrid/book-reader/src/react/components/Book/PageError.d.ts +5 -0
- package/library/packages/hybrid/book-reader/src/react/components/Book/PageRenderer/PageRenderer.d.ts +8 -0
- package/library/packages/hybrid/book-reader/src/react/components/Book/PageRenderer/RendererContext.d.ts +5 -0
- package/library/packages/hybrid/book-reader/src/react/components/Book/PageRenderer/StructTree.d.ts +1 -0
- package/library/packages/hybrid/book-reader/src/react/components/Book/PageRenderer/StructTreeItem.d.ts +9 -0
- package/library/packages/hybrid/book-reader/src/react/components/Book/PageRenderer/index.d.ts +2 -0
- package/library/packages/hybrid/book-reader/src/react/components/ColdStorageAsset/ColdStorageAsset.d.ts +7 -0
- package/library/packages/hybrid/book-reader/src/react/components/ColdStorageAsset/ColdStorageAsset.styles.d.ts +2 -0
- package/library/packages/hybrid/book-reader/src/react/components/ColdStorageAsset/index.d.ts +1 -0
- package/library/packages/hybrid/book-reader/src/react/components/Container/Container.d.ts +7 -0
- package/library/packages/hybrid/book-reader/src/react/components/Container/index.d.ts +1 -0
- package/library/packages/hybrid/book-reader/src/react/components/Controller/Controller.d.ts +39 -0
- package/library/packages/hybrid/book-reader/src/react/components/Controller/Controller.styles.d.ts +2 -0
- package/library/packages/hybrid/book-reader/src/react/components/Controller/PageControl.d.ts +12 -0
- package/library/packages/hybrid/book-reader/src/react/components/Controller/ScaleControl.d.ts +10 -0
- package/library/packages/hybrid/book-reader/src/react/components/Controller/ToggleFullscreen.d.ts +7 -0
- package/library/packages/hybrid/book-reader/src/react/components/Controller/ToggleSearchBox.d.ts +7 -0
- package/library/packages/hybrid/book-reader/src/react/components/Controller/ToggleSidebar.d.ts +7 -0
- package/library/packages/hybrid/book-reader/src/react/components/Controller/ViewControl.d.ts +7 -0
- package/library/packages/hybrid/book-reader/src/react/components/Controller/index.d.ts +1 -0
- package/library/packages/hybrid/book-reader/src/react/components/Drawer/Drawer.d.ts +9 -0
- package/library/packages/hybrid/book-reader/src/react/components/Drawer/index.d.ts +1 -0
- package/library/packages/hybrid/book-reader/src/react/components/EmptyDocument/EmptyDocument.d.ts +2 -0
- package/library/packages/hybrid/book-reader/src/react/components/EmptyDocument/EmptyDocument.styles.d.ts +2 -0
- package/library/packages/hybrid/book-reader/src/react/components/EmptyDocument/index.d.ts +1 -0
- package/library/packages/hybrid/book-reader/src/react/components/Loading/DocumentLoading.d.ts +5 -0
- package/library/packages/hybrid/book-reader/src/react/components/Loading/Loading.styles.d.ts +2 -0
- package/library/packages/hybrid/book-reader/src/react/components/Loading/PageLoading.d.ts +5 -0
- package/library/packages/hybrid/book-reader/src/react/components/Loading/index.d.ts +2 -0
- package/library/packages/hybrid/book-reader/src/react/components/PPTProgressBar/PPTProgressBar.d.ts +5 -0
- package/library/packages/hybrid/book-reader/src/react/components/PPTProgressBar/index.d.ts +1 -0
- package/library/packages/hybrid/book-reader/src/react/components/PasswordInput/PasswordInput.d.ts +7 -0
- package/library/packages/hybrid/book-reader/src/react/components/PasswordInput/PasswordInput.styles.d.ts +2 -0
- package/library/packages/hybrid/book-reader/src/react/components/PasswordInput/index.d.ts +1 -0
- package/library/packages/hybrid/book-reader/src/react/components/ProgressBar/ProgressBar.d.ts +7 -0
- package/library/packages/hybrid/book-reader/src/react/components/ProgressBar/index.d.ts +1 -0
- package/library/packages/hybrid/book-reader/src/react/components/ScaleBox/ScaleBox.d.ts +21 -0
- package/library/packages/hybrid/book-reader/src/react/components/SearchBox/SearchBox.d.ts +18 -0
- package/library/packages/hybrid/book-reader/src/react/components/SearchBox/SearchBox.styles.d.ts +2 -0
- package/library/packages/hybrid/book-reader/src/react/components/SearchBox/index.d.ts +1 -0
- package/library/packages/hybrid/book-reader/src/react/components/TextHighlight/TextHighlight.d.ts +9 -0
- package/library/packages/hybrid/book-reader/src/react/components/TextHighlight/index.d.ts +1 -0
- package/library/packages/hybrid/book-reader/src/react/components/Thumbnails/Thumbnails.d.ts +32 -0
- package/library/packages/hybrid/book-reader/src/react/components/Thumbnails/index.d.ts +1 -0
- package/library/packages/hybrid/book-reader/src/react/components/ZoomPanPinchWrapper/ZoomPanPinchWrapper.d.ts +12 -0
- package/library/packages/hybrid/book-reader/src/react/components/ZoomPanPinchWrapper/ZoomPanPinchWrapper.styles.d.ts +2 -0
- package/library/packages/hybrid/book-reader/src/react/components/ZoomPanPinchWrapper/index.d.ts +1 -0
- package/library/packages/hybrid/book-reader/src/react/constant.d.ts +81 -0
- package/library/packages/hybrid/book-reader/src/react/contexts/AlbumContext.d.ts +8 -0
- package/library/packages/hybrid/book-reader/src/react/contexts/BookContext.d.ts +4 -0
- package/library/packages/hybrid/book-reader/src/react/contexts/BreakpointsContext.d.ts +4 -0
- package/library/packages/hybrid/book-reader/src/react/contexts/ComponentContext.d.ts +3 -0
- package/library/packages/hybrid/book-reader/src/react/contexts/TranslationContext.d.ts +7 -0
- package/library/packages/hybrid/book-reader/src/react/hooks/useAlbumContext.d.ts +1 -0
- package/library/packages/hybrid/book-reader/src/react/hooks/useBookContext.d.ts +1 -0
- package/library/packages/hybrid/book-reader/src/react/hooks/useBookEvents.d.ts +13 -0
- package/library/packages/hybrid/book-reader/src/react/hooks/useBreakpoint.d.ts +6 -0
- package/library/packages/hybrid/book-reader/src/react/hooks/useDrawer.d.ts +13 -0
- package/library/packages/hybrid/book-reader/src/react/hooks/useImageTextSearch.d.ts +4 -0
- package/library/packages/hybrid/book-reader/src/react/hooks/useKeyboardShortcuts.d.ts +12 -0
- package/library/packages/hybrid/book-reader/src/react/hooks/usePageFlip.d.ts +10 -0
- package/library/packages/hybrid/book-reader/src/react/hooks/usePdfTextSearch.d.ts +4 -0
- package/library/packages/hybrid/book-reader/src/react/hooks/usePopoverMenu.d.ts +7 -0
- package/library/packages/hybrid/book-reader/src/react/hooks/useRendererContext.d.ts +1 -0
- package/library/packages/hybrid/book-reader/src/react/hooks/useResolver.d.ts +21 -0
- package/library/packages/hybrid/book-reader/src/react/hooks/useScale.d.ts +19 -0
- package/library/packages/hybrid/book-reader/src/react/hooks/useSearch.d.ts +19 -0
- package/library/packages/hybrid/book-reader/src/react/page-flip/PageFlip.d.ts +215 -0
- package/library/packages/hybrid/book-reader/src/react/page-flip/Settings.d.ts +59 -0
- package/library/packages/hybrid/book-reader/src/react/page-flip/collection/HTMLPageCollection.d.ts +13 -0
- package/library/packages/hybrid/book-reader/src/react/page-flip/collection/ImagePageCollection.d.ts +12 -0
- package/library/packages/hybrid/book-reader/src/react/page-flip/collection/PageCollection.d.ts +116 -0
- package/library/packages/hybrid/book-reader/src/react/page-flip/event/EventObject.d.ts +34 -0
- package/library/packages/hybrid/book-reader/src/react/page-flip/flip/Flip.d.ts +126 -0
- package/library/packages/hybrid/book-reader/src/react/page-flip/flip/FlipCalculation.d.ts +99 -0
- package/library/packages/hybrid/book-reader/src/react/page-flip/index.d.ts +22 -0
- package/library/packages/hybrid/book-reader/src/react/page-flip/page/HTMLPage.d.ts +24 -0
- package/library/packages/hybrid/book-reader/src/react/page-flip/page/ImagePage.d.ts +19 -0
- package/library/packages/hybrid/book-reader/src/react/page-flip/page/Page.d.ts +123 -0
- package/library/packages/hybrid/book-reader/src/react/page-flip/render/CanvasRender.d.ts +19 -0
- package/library/packages/hybrid/book-reader/src/react/page-flip/render/HTMLRender.d.ts +58 -0
- package/library/packages/hybrid/book-reader/src/react/page-flip/render/Render.d.ts +233 -0
- package/library/packages/hybrid/book-reader/src/react/page-flip/ui/CanvasUI.d.ts +17 -0
- package/library/packages/hybrid/book-reader/src/react/page-flip/ui/HTMLUI.d.ts +19 -0
- package/library/packages/hybrid/book-reader/src/react/page-flip/ui/UI.d.ts +78 -0
- package/library/packages/hybrid/book-reader/src/react/types.d.ts +206 -0
- package/library/packages/hybrid/book-reader/src/react/utils/CalculateScale.d.ts +1 -0
- package/library/packages/hybrid/book-reader/src/react/utils/EscapeRegex.d.ts +2 -0
- package/library/packages/hybrid/book-reader/src/react/utils/Fullscreen.d.ts +4 -0
- package/library/packages/hybrid/book-reader/src/react/utils/GetActivePage.d.ts +1 -0
- package/library/packages/hybrid/book-reader/src/react/utils/GetIIIFImageUrl.d.ts +7 -0
- package/library/packages/hybrid/book-reader/src/react/utils/GetVisiblePageNumber.d.ts +1 -0
- package/library/packages/hybrid/book-reader/src/react/utils/IsImageBook.d.ts +3 -0
- package/library/packages/hybrid/book-reader/src/react/utils/IsPDFBook.d.ts +3 -0
- package/library/packages/hybrid/book-reader/src/react/utils/MergeRefs.d.ts +14 -0
- package/library/packages/hybrid/book-reader/src/react/utils/NormalizeString.d.ts +1 -0
- package/library/packages/hybrid/book-reader/src/react/utils/PageFlipGeometry.d.ts +86 -0
- package/library/packages/hybrid/book-reader/src/react/utils/PagePosition.d.ts +2 -0
- package/library/packages/hybrid/book-reader/src/react/utils/PageRendererUtil.d.ts +350 -0
- package/library/packages/hybrid/book-reader/src/react/utils/PdfWorker.d.ts +17 -0
- package/library/packages/hybrid/book-reader/src/react/utils/Random.d.ts +1 -0
- package/library/packages/hybrid/book-reader/src/react/utils/RenderingQueue.d.ts +8 -0
- package/library/packages/organisms/src/content-builder/configs/document-viewer.d.ts +24 -0
- package/library/packages/organisms/src/content-builder/configs/index.d.ts +1 -0
- package/library/packages/organisms/src/content-builder/configs-controller.d.ts +50 -24
- package/library/packages/organisms/src/content-builder/content-builder-config.d.ts +3 -0
- package/library/packages/organisms/src/content-builder/plugins/document-viewer.d.ts +5 -0
- package/library/packages/organisms/src/content-builder/plugins/index.d.ts +1 -0
- package/library/packages/react-web-component.d.ts +6581 -0
- package/library/packages/services/src/api/asset/asset.d.ts +10 -0
- package/library/packages/services/src/api/endpoints.d.ts +1 -0
- package/library/packages/types/src/book-reader.d.ts +9 -0
- package/library/packages/types/src/content-builder.d.ts +3 -1
- package/library/packages/utils/src/custom-element/i18n.d.ts +3 -0
- package/library/react-web-component.d.ts +110 -4
- package/library/utils.js +3 -3
- package/package.json +1 -1
|
@@ -1,12 +1,963 @@
|
|
|
1
|
-
import "../chunks/lib-cortex-element.CVMmyPMC.js";
|
|
2
|
-
import "../chunks/component.styles.CRO4Odto.js";
|
|
3
|
-
import "../chunks/asset-link-format.B0c92pSs.js";
|
|
4
|
-
import "../chunks/custom-element.L4WJXn1j.js";
|
|
5
|
-
import "../chunks/lit-element.jLBm65_O.js";
|
|
6
|
-
import "../chunks/state.CSDxrqLd.js";
|
|
7
|
-
import "../chunks/query.BBf1UFkC.js";
|
|
8
|
-
import "../chunks/when.Dr1es41R.js";
|
|
9
|
-
import {
|
|
1
|
+
import { n as S, C as be } from "../chunks/lib-cortex-element.CVMmyPMC.js";
|
|
2
|
+
import { c as ye } from "../chunks/component.styles.CRO4Odto.js";
|
|
3
|
+
import { U as N } from "../chunks/asset-link-format.B0c92pSs.js";
|
|
4
|
+
import { c as Re } from "../chunks/custom-element.L4WJXn1j.js";
|
|
5
|
+
import { i as _e, x as te } from "../chunks/lit-element.jLBm65_O.js";
|
|
6
|
+
import { r as ve } from "../chunks/state.CSDxrqLd.js";
|
|
7
|
+
import { e as De } from "../chunks/query.BBf1UFkC.js";
|
|
8
|
+
import { n as ae } from "../chunks/when.Dr1es41R.js";
|
|
9
|
+
import { r as w, j as f, w as Me, R as ke, a as ze } from "../chunks/jsx-runtime.CTpPVMxj.js";
|
|
10
|
+
import { c as He, r as je, a as Se } from "../chunks/image.9qwbjGNb.js";
|
|
11
|
+
import { r as $e } from "../chunks/number.B4PQLJIg.js";
|
|
12
|
+
import { d as se } from "../chunks/debounce.C_J-9zJi.js";
|
|
13
|
+
const Ie = _e`:host{--rc-drag-handle-size:12px;--rc-drag-handle-mobile-size:24px;--rc-drag-handle-bg-colour:#0003;--rc-drag-bar-size:6px;--rc-border-color:#ffffffb3;--rc-focus-color:#08f;width:100%;height:100%;display:block;position:relative}.cropper{justify-content:center;align-items:center;width:100%;height:100%;display:flex;position:relative;container-type:size}.loading-container{z-index:1000;background-color:#00000080;width:100%;height:100%;position:absolute;top:0;left:0}.loading-container .loading{width:100%;height:100%;position:absolute}.loading-container .loading__skeleton{--border-radius:0;width:100%;height:100%}.loading-container .loading__spinner{--track-width:.2rem;font-size:var(--cx-font-size-3x-large);position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.cropper--portrait .cropper__image{max-width:100cqw;max-height:100cqh}.cropper__image{width:auto;max-width:100%;height:auto;max-height:100%;display:block}.cropper__image--loading{opacity:0}@keyframes marching-ants{0%{background-position:0 0,0 100%,0 0,100% 0}to{background-position:20px 0,-20px 100%,0 -20px,100% 20px}}.ReactCrop{cursor:crosshair;isolation:isolate;max-width:100%;display:inline-block;position:relative}.cropper--multiple .ReactCrop:before{content:"";z-index:-1;background:var(--cx-color-neutral-300);border-radius:2px;position:absolute;inset:0;transform:translate(-8px,-8px)}.ReactCrop *,.ReactCrop :before,.ReactCrop :after{box-sizing:border-box}.ReactCrop--disabled,.ReactCrop--loading,.ReactCrop--locked{cursor:inherit}.ReactCrop__child-wrapper{max-height:inherit;justify-content:center;align-items:center;width:100%;height:100%;display:flex;overflow:hidden}.ReactCrop__child-wrapper>img,.ReactCrop__child-wrapper>video{width:auto;max-width:100%;height:auto;max-height:100%;display:block}.ReactCrop:not(.ReactCrop--disabled):not(.ReactCrop--loading) .ReactCrop__child-wrapper>img,.ReactCrop:not(.ReactCrop--disabled):not(.ReactCrop--loading) .ReactCrop__child-wrapper>video,.ReactCrop:not(.ReactCrop--disabled):not(.ReactCrop--loading) .ReactCrop__crop-selection{touch-action:none}.ReactCrop__crop-mask{pointer-events:none;width:calc(100% + .5px);height:calc(100% + .5px);position:absolute;inset:0}.ReactCrop__crop-selection{cursor:move;position:absolute;top:0;left:0;transform:translateZ(0)}.ReactCrop--disabled .ReactCrop__crop-selection{cursor:inherit;display:none}.ReactCrop--circular-crop .ReactCrop__crop-selection{border-radius:50%}.ReactCrop--circular-crop .ReactCrop__crop-selection:after{pointer-events:none;content:"";border:1px solid var(--rc-border-color);opacity:.3;position:absolute;inset:-1px}.ReactCrop--no-animate .ReactCrop__crop-selection,.ReactCrop--loading .ReactCrop__crop-selection{outline:1px dashed #fff}.ReactCrop__crop-selection:not(.ReactCrop--no-animate .ReactCrop__crop-selection,.ReactCrop--loading .ReactCrop__crop-selection){color:#fff;background-image:linear-gradient(90deg,#fff 50%,#444 50%),linear-gradient(90deg,#fff 50%,#444 50%),linear-gradient(#fff 50%,#444 50%),linear-gradient(#fff 50%,#444 50%);background-position:0 0,0 100%,0 0,100% 0;background-repeat:repeat-x,repeat-x,repeat-y,repeat-y;background-size:10px 1px,10px 1px,1px 10px,1px 10px;animation:1s linear infinite marching-ants}.ReactCrop__crop-selection:focus{outline:2px solid var(--rc-focus-color);outline-offset:-1px}.ReactCrop--disabled .ReactCrop__crop-mask,.ReactCrop--invisible-crop .ReactCrop__crop-mask,.ReactCrop--invisible-crop .ReactCrop__crop-selection{display:none}.ReactCrop__rule-of-thirds-vt:before,.ReactCrop__rule-of-thirds-vt:after,.ReactCrop__rule-of-thirds-hz:before,.ReactCrop__rule-of-thirds-hz:after{content:"";background-color:#fff6;display:block;position:absolute}.ReactCrop__rule-of-thirds-vt:before,.ReactCrop__rule-of-thirds-vt:after{width:1px;height:100%}.ReactCrop__rule-of-thirds-vt:before{left:33.3333%}.ReactCrop__rule-of-thirds-vt:after{left:66.6667%}.ReactCrop__rule-of-thirds-hz:before,.ReactCrop__rule-of-thirds-hz:after{width:100%;height:1px}.ReactCrop__rule-of-thirds-hz:before{top:33.3333%}.ReactCrop__rule-of-thirds-hz:after{top:66.6667%}.ReactCrop__drag-handle{width:var(--rc-drag-handle-size);height:var(--rc-drag-handle-size);background-color:var(--rc-drag-handle-bg-colour);border:1px solid var(--rc-border-color);position:absolute}.ReactCrop__drag-handle:focus{background:var(--rc-focus-color)}.ReactCrop .ord-nw{cursor:nw-resize;top:0;left:0;transform:translate(-50%,-50%)}.ReactCrop .ord-n{cursor:n-resize;top:0;left:50%;transform:translate(-50%,-50%)}.ReactCrop .ord-ne{cursor:ne-resize;top:0;right:0;transform:translate(50%,-50%)}.ReactCrop .ord-e{cursor:e-resize;top:50%;right:0;transform:translate(50%,-50%)}.ReactCrop .ord-se{cursor:se-resize;bottom:0;right:0;transform:translate(50%,50%)}.ReactCrop .ord-s{cursor:s-resize;bottom:0;left:50%;transform:translate(-50%,50%)}.ReactCrop .ord-sw{cursor:sw-resize;bottom:0;left:0;transform:translate(-50%,50%)}.ReactCrop .ord-w{cursor:w-resize;top:50%;left:0;transform:translate(-50%,-50%)}.ReactCrop__disabled .ReactCrop__drag-handle{cursor:inherit}.ReactCrop__drag-bar{position:absolute}.ReactCrop__drag-bar.ord-n{width:100%;height:var(--rc-drag-bar-size);top:0;left:0;transform:translateY(-50%)}.ReactCrop__drag-bar.ord-e{width:var(--rc-drag-bar-size);height:100%;top:0;right:0;transform:translate(50%)}.ReactCrop__drag-bar.ord-s{width:100%;height:var(--rc-drag-bar-size);bottom:0;left:0;transform:translateY(50%)}.ReactCrop__drag-bar.ord-w{width:var(--rc-drag-bar-size);height:100%;top:0;left:0;transform:translate(-50%)}.ReactCrop--new-crop .ReactCrop__drag-bar,.ReactCrop--new-crop .ReactCrop__drag-handle,.ReactCrop--fixed-aspect .ReactCrop__drag-bar,.ReactCrop--fixed-aspect .ReactCrop__drag-handle.ord-n,.ReactCrop--fixed-aspect .ReactCrop__drag-handle.ord-e,.ReactCrop--fixed-aspect .ReactCrop__drag-handle.ord-s,.ReactCrop--fixed-aspect .ReactCrop__drag-handle.ord-w{display:none}@media (pointer:coarse){.ReactCrop .ord-n,.ReactCrop .ord-e,.ReactCrop .ord-s,.ReactCrop .ord-w{display:none}.ReactCrop__drag-handle{width:var(--rc-drag-handle-mobile-size);height:var(--rc-drag-handle-mobile-size)}}`, q = {
|
|
14
|
+
height: 0,
|
|
15
|
+
unit: "px",
|
|
16
|
+
width: 0,
|
|
17
|
+
x: 0,
|
|
18
|
+
y: 0
|
|
19
|
+
}, W = (h, e, t) => Math.min(Math.max(h, e), t), Pe = (...h) => h.filter((e) => e && typeof e == "string").join(" "), he = (h, e) => h === e || h.width === e.width && h.height === e.height && h.x === e.x && h.y === e.y && h.unit === e.unit;
|
|
20
|
+
function Ye(h, e, t, r) {
|
|
21
|
+
const i = j(h, t, r);
|
|
22
|
+
return h.width && (i.height = i.width / e), h.height && (i.width = i.height * e), i.y + i.height > r && (i.height = r - i.y, i.width = i.height * e), i.x + i.width > t && (i.width = t - i.x, i.height = i.width / e), h.unit === "%" ? P(i, t, r) : i;
|
|
23
|
+
}
|
|
24
|
+
function Le(h, e, t) {
|
|
25
|
+
const r = j(h, e, t);
|
|
26
|
+
return r.x = (e - r.width) / 2, r.y = (t - r.height) / 2, h.unit === "%" ? P(r, e, t) : r;
|
|
27
|
+
}
|
|
28
|
+
function P(h, e, t) {
|
|
29
|
+
return h.unit === "%" ? { ...q, ...h, unit: "%" } : {
|
|
30
|
+
height: h.height ? h.height / t * 100 : 0,
|
|
31
|
+
unit: "%",
|
|
32
|
+
width: h.width ? h.width / e * 100 : 0,
|
|
33
|
+
x: h.x ? h.x / e * 100 : 0,
|
|
34
|
+
y: h.y ? h.y / t * 100 : 0
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function j(h, e, t) {
|
|
38
|
+
return h.unit ? h.unit === "px" ? { ...q, ...h, unit: "px" } : {
|
|
39
|
+
height: h.height ? h.height * t / 100 : 0,
|
|
40
|
+
unit: "px",
|
|
41
|
+
width: h.width ? h.width * e / 100 : 0,
|
|
42
|
+
x: h.x ? h.x * e / 100 : 0,
|
|
43
|
+
y: h.y ? h.y * t / 100 : 0
|
|
44
|
+
} : { ...q, ...h, unit: "px" };
|
|
45
|
+
}
|
|
46
|
+
function ce(h, e, t, r, i, s = 0, a = 0, l = r, c = i) {
|
|
47
|
+
const o = { ...h };
|
|
48
|
+
let d = Math.min(s, r), p = Math.min(a, i), g = Math.min(l, r), u = Math.min(c, i);
|
|
49
|
+
e && (e > 1 ? (d = a ? a * e : d, p = d / e, g = l * e) : (p = s ? s / e : p, d = p * e, u = c / e)), o.y < 0 && (o.height = Math.max(
|
|
50
|
+
o.height + o.y,
|
|
51
|
+
p
|
|
52
|
+
), o.y = 0), o.x < 0 && (o.width = Math.max(
|
|
53
|
+
o.width + o.x,
|
|
54
|
+
d
|
|
55
|
+
), o.x = 0);
|
|
56
|
+
const n = r - (o.x + o.width);
|
|
57
|
+
n < 0 && (o.x = Math.min(o.x, r - d), o.width += n);
|
|
58
|
+
const x = i - (o.y + o.height);
|
|
59
|
+
if (x < 0 && (o.y = Math.min(o.y, i - p), o.height += x), o.width < d && ((t === "sw" || t == "nw") && (o.x -= d - o.width), o.width = d), o.height < p && ((t === "nw" || t == "ne") && (o.y -= p - o.height), o.height = p), o.width > g && ((t === "sw" || t == "nw") && (o.x -= g - o.width), o.width = g), o.height > u && ((t === "nw" || t == "ne") && (o.y -= u - o.height), o.height = u), e) {
|
|
60
|
+
const b = o.width / o.height;
|
|
61
|
+
if (b < e) {
|
|
62
|
+
const v = Math.max(o.width / e, p);
|
|
63
|
+
(t === "nw" || t == "ne") && (o.y -= v - o.height), o.height = v;
|
|
64
|
+
} else if (b > e) {
|
|
65
|
+
const v = Math.max(o.height * e, d);
|
|
66
|
+
(t === "sw" || t == "nw") && (o.x -= v - o.width), o.width = v;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return o;
|
|
70
|
+
}
|
|
71
|
+
function Xe(h, e, t, r) {
|
|
72
|
+
const i = { ...h };
|
|
73
|
+
return e === "ArrowLeft" ? r === "nw" ? (i.x -= t, i.y -= t, i.width += t, i.height += t) : r === "w" ? (i.x -= t, i.width += t) : r === "sw" ? (i.x -= t, i.width += t, i.height += t) : r === "ne" ? (i.y += t, i.width -= t, i.height -= t) : r === "e" ? i.width -= t : r === "se" && (i.width -= t, i.height -= t) : e === "ArrowRight" && (r === "nw" ? (i.x += t, i.y += t, i.width -= t, i.height -= t) : r === "w" ? (i.x += t, i.width -= t) : r === "sw" ? (i.x += t, i.width -= t, i.height -= t) : r === "ne" ? (i.y -= t, i.width += t, i.height += t) : r === "e" ? i.width += t : r === "se" && (i.width += t, i.height += t)), e === "ArrowUp" ? r === "nw" ? (i.x -= t, i.y -= t, i.width += t, i.height += t) : r === "n" ? (i.y -= t, i.height += t) : r === "ne" ? (i.y -= t, i.width += t, i.height += t) : r === "sw" ? (i.x += t, i.width -= t, i.height -= t) : r === "s" ? i.height -= t : r === "se" && (i.width -= t, i.height -= t) : e === "ArrowDown" && (r === "nw" ? (i.x += t, i.y += t, i.width -= t, i.height -= t) : r === "n" ? (i.y += t, i.height -= t) : r === "ne" ? (i.y += t, i.width -= t, i.height -= t) : r === "sw" ? (i.x -= t, i.width += t, i.height += t) : r === "s" ? i.height += t : r === "se" && (i.width += t, i.height += t)), i;
|
|
74
|
+
}
|
|
75
|
+
const A = { capture: !0, passive: !1 };
|
|
76
|
+
let Ee = 0;
|
|
77
|
+
const _ = class _ extends w.PureComponent {
|
|
78
|
+
constructor() {
|
|
79
|
+
super(...arguments), this.docMoveBound = !1, this.mouseDownOnCrop = !1, this.dragStarted = !1, this.evData = {
|
|
80
|
+
clientX: 0,
|
|
81
|
+
clientY: 0,
|
|
82
|
+
isResize: !0,
|
|
83
|
+
startClientX: 0,
|
|
84
|
+
startClientY: 0,
|
|
85
|
+
startCropHeight: 0,
|
|
86
|
+
startCropWidth: 0,
|
|
87
|
+
startCropX: 0,
|
|
88
|
+
startCropY: 0
|
|
89
|
+
}, this.componentRef = w.createRef(), this.mediaRef = w.createRef(), this.initChangeCalled = !1, this.instanceId = `rc-${Ee++}`, this.state = {
|
|
90
|
+
cropIsActive: !1,
|
|
91
|
+
newCropIsBeingDrawn: !1
|
|
92
|
+
}, this.onCropPointerDown = (e) => {
|
|
93
|
+
const { crop: t, disabled: r, loading: i } = this.props, s = this.getBox();
|
|
94
|
+
if (!t)
|
|
95
|
+
return;
|
|
96
|
+
const a = j(t, s.width, s.height);
|
|
97
|
+
if (r || i)
|
|
98
|
+
return;
|
|
99
|
+
e.cancelable && e.preventDefault(), this.bindDocMove(), this.componentRef.current.focus({
|
|
100
|
+
preventScroll: !0
|
|
101
|
+
});
|
|
102
|
+
const l = e.target.dataset.ord, c = !!l;
|
|
103
|
+
let o = e.clientX, d = e.clientY, p = a.x, g = a.y;
|
|
104
|
+
if (l) {
|
|
105
|
+
const u = e.clientX - s.x, n = e.clientY - s.y;
|
|
106
|
+
let x = 0, b = 0;
|
|
107
|
+
l === "ne" || l == "e" ? (x = u - (a.x + a.width), b = n - a.y, p = a.x, g = a.y + a.height) : l === "se" || l === "s" ? (x = u - (a.x + a.width), b = n - (a.y + a.height), p = a.x, g = a.y) : l === "sw" || l == "w" ? (x = u - a.x, b = n - (a.y + a.height), p = a.x + a.width, g = a.y) : (l === "nw" || l == "n") && (x = u - a.x, b = n - a.y, p = a.x + a.width, g = a.y + a.height), o = p + s.x + x, d = g + s.y + b;
|
|
108
|
+
}
|
|
109
|
+
this.evData = {
|
|
110
|
+
clientX: e.clientX,
|
|
111
|
+
clientY: e.clientY,
|
|
112
|
+
isResize: c,
|
|
113
|
+
ord: l,
|
|
114
|
+
startClientX: o,
|
|
115
|
+
startClientY: d,
|
|
116
|
+
startCropHeight: a.height,
|
|
117
|
+
startCropWidth: a.width,
|
|
118
|
+
startCropX: p,
|
|
119
|
+
startCropY: g
|
|
120
|
+
}, this.mouseDownOnCrop = !0, this.setState({ cropIsActive: !0 });
|
|
121
|
+
}, this.onComponentPointerDown = (e) => {
|
|
122
|
+
const { crop: t, disabled: r, keepSelection: i, loading: s, locked: a, onChange: l } = this.props, c = this.getBox();
|
|
123
|
+
if (r || a || s || i && t)
|
|
124
|
+
return;
|
|
125
|
+
e.cancelable && e.preventDefault(), this.bindDocMove(), this.componentRef.current.focus({
|
|
126
|
+
preventScroll: !0
|
|
127
|
+
});
|
|
128
|
+
const o = e.clientX - c.x, d = e.clientY - c.y, p = {
|
|
129
|
+
height: 0,
|
|
130
|
+
unit: "px",
|
|
131
|
+
width: 0,
|
|
132
|
+
x: o,
|
|
133
|
+
y: d
|
|
134
|
+
};
|
|
135
|
+
this.evData = {
|
|
136
|
+
clientX: e.clientX,
|
|
137
|
+
clientY: e.clientY,
|
|
138
|
+
isResize: !0,
|
|
139
|
+
startClientX: e.clientX,
|
|
140
|
+
startClientY: e.clientY,
|
|
141
|
+
startCropHeight: 0,
|
|
142
|
+
startCropWidth: 0,
|
|
143
|
+
startCropX: o,
|
|
144
|
+
startCropY: d
|
|
145
|
+
}, this.mouseDownOnCrop = !0, l(
|
|
146
|
+
j(p, c.width, c.height),
|
|
147
|
+
P(p, c.width, c.height)
|
|
148
|
+
), this.setState({ cropIsActive: !0, newCropIsBeingDrawn: !0 });
|
|
149
|
+
}, this.onDocPointerMove = (e) => {
|
|
150
|
+
const { crop: t, disabled: r, loading: i, onChange: s, onDragStart: a } = this.props, l = this.getBox();
|
|
151
|
+
if (r || i || !t || !this.mouseDownOnCrop)
|
|
152
|
+
return;
|
|
153
|
+
e.cancelable && e.preventDefault(), this.dragStarted || (this.dragStarted = !0);
|
|
154
|
+
const { evData: c } = this;
|
|
155
|
+
c.clientX = e.clientX, c.clientY = e.clientY;
|
|
156
|
+
let o;
|
|
157
|
+
c.isResize ? o = this.resizeCrop() : (o = this.dragCrop(), a && a(e)), he(t, o) || s(
|
|
158
|
+
j(o, l.width, l.height),
|
|
159
|
+
P(o, l.width, l.height)
|
|
160
|
+
);
|
|
161
|
+
}, this.onComponentKeyDown = (e) => {
|
|
162
|
+
const { crop: t, disabled: r, loading: i, onChange: s, onComplete: a } = this.props;
|
|
163
|
+
if (r || i)
|
|
164
|
+
return;
|
|
165
|
+
const l = e.key;
|
|
166
|
+
let c = !1;
|
|
167
|
+
if (!t)
|
|
168
|
+
return;
|
|
169
|
+
const o = this.getBox(), d = this.makePixelCrop(o), g = (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey) ? _.nudgeStepLarge : e.shiftKey ? _.nudgeStepMedium : _.nudgeStep;
|
|
170
|
+
if (l === "ArrowLeft" ? (d.x -= g, c = !0) : l === "ArrowRight" ? (d.x += g, c = !0) : l === "ArrowUp" ? (d.y -= g, c = !0) : l === "ArrowDown" && (d.y += g, c = !0), c) {
|
|
171
|
+
e.cancelable && e.preventDefault(), d.x = W(d.x, 0, o.width - d.width), d.y = W(d.y, 0, o.height - d.height);
|
|
172
|
+
const u = j(d, o.width, o.height), n = P(d, o.width, o.height);
|
|
173
|
+
s(u, n), a && a(u, n);
|
|
174
|
+
}
|
|
175
|
+
}, this.onHandlerKeyDown = (e, t) => {
|
|
176
|
+
const {
|
|
177
|
+
aspect: r = 0,
|
|
178
|
+
crop: i,
|
|
179
|
+
disabled: s,
|
|
180
|
+
loading: a,
|
|
181
|
+
maxHeight: l,
|
|
182
|
+
maxWidth: c,
|
|
183
|
+
minHeight: o = 0,
|
|
184
|
+
minWidth: d = 0,
|
|
185
|
+
onChange: p,
|
|
186
|
+
onComplete: g
|
|
187
|
+
} = this.props, u = this.getBox();
|
|
188
|
+
if (s || a || !i)
|
|
189
|
+
return;
|
|
190
|
+
if (e.key === "ArrowUp" || e.key === "ArrowDown" || e.key === "ArrowLeft" || e.key === "ArrowRight")
|
|
191
|
+
e.stopPropagation(), e.preventDefault();
|
|
192
|
+
else
|
|
193
|
+
return;
|
|
194
|
+
const x = (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey) ? _.nudgeStepLarge : e.shiftKey ? _.nudgeStepMedium : _.nudgeStep, b = j(i, u.width, u.height), v = Xe(b, e.key, x, t), C = ce(
|
|
195
|
+
v,
|
|
196
|
+
r,
|
|
197
|
+
t,
|
|
198
|
+
u.width,
|
|
199
|
+
u.height,
|
|
200
|
+
d,
|
|
201
|
+
o,
|
|
202
|
+
c,
|
|
203
|
+
l
|
|
204
|
+
);
|
|
205
|
+
if (!he(i, C)) {
|
|
206
|
+
const D = P(
|
|
207
|
+
C,
|
|
208
|
+
u.width,
|
|
209
|
+
u.height
|
|
210
|
+
);
|
|
211
|
+
p(C, D), g && g(C, D);
|
|
212
|
+
}
|
|
213
|
+
}, this.onDocPointerDone = (e) => {
|
|
214
|
+
const { crop: t, disabled: r, loading: i, onComplete: s, onDragEnd: a } = this.props, l = this.getBox();
|
|
215
|
+
this.unbindDocMove(), !(r || i || !t) && this.mouseDownOnCrop && (this.mouseDownOnCrop = !1, this.dragStarted = !1, a && a(e), s && s(
|
|
216
|
+
j(t, l.width, l.height),
|
|
217
|
+
P(t, l.width, l.height)
|
|
218
|
+
), this.setState({ cropIsActive: !1, newCropIsBeingDrawn: !1 }));
|
|
219
|
+
}, this.onDragFocus = () => {
|
|
220
|
+
this.componentRef.current?.scrollTo(0, 0);
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
get document() {
|
|
224
|
+
return document;
|
|
225
|
+
}
|
|
226
|
+
// We unfortunately get the bounding box every time as x+y changes
|
|
227
|
+
// due to scrolling.
|
|
228
|
+
getBox() {
|
|
229
|
+
const e = this.mediaRef.current;
|
|
230
|
+
if (!e)
|
|
231
|
+
return { height: 0, width: 0, x: 0, y: 0 };
|
|
232
|
+
const { height: t, width: r, x: i, y: s } = e.getBoundingClientRect();
|
|
233
|
+
return { height: t, width: r, x: i, y: s };
|
|
234
|
+
}
|
|
235
|
+
componentDidUpdate(e) {
|
|
236
|
+
const { crop: t, onComplete: r } = this.props;
|
|
237
|
+
if (r && !e.crop && t) {
|
|
238
|
+
const { height: i, width: s } = this.getBox();
|
|
239
|
+
s && i && r(
|
|
240
|
+
j(t, s, i),
|
|
241
|
+
P(t, s, i)
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
componentWillUnmount() {
|
|
246
|
+
this.resizeObserver && this.resizeObserver.disconnect(), this.unbindDocMove();
|
|
247
|
+
}
|
|
248
|
+
bindDocMove() {
|
|
249
|
+
this.docMoveBound || (this.document.addEventListener(
|
|
250
|
+
"pointermove",
|
|
251
|
+
this.onDocPointerMove,
|
|
252
|
+
A
|
|
253
|
+
), this.document.addEventListener(
|
|
254
|
+
"pointerup",
|
|
255
|
+
this.onDocPointerDone,
|
|
256
|
+
A
|
|
257
|
+
), this.document.addEventListener(
|
|
258
|
+
"pointercancel",
|
|
259
|
+
this.onDocPointerDone,
|
|
260
|
+
A
|
|
261
|
+
), this.docMoveBound = !0);
|
|
262
|
+
}
|
|
263
|
+
unbindDocMove() {
|
|
264
|
+
this.docMoveBound && (this.document.removeEventListener(
|
|
265
|
+
"pointermove",
|
|
266
|
+
this.onDocPointerMove,
|
|
267
|
+
A
|
|
268
|
+
), this.document.removeEventListener(
|
|
269
|
+
"pointerup",
|
|
270
|
+
this.onDocPointerDone,
|
|
271
|
+
A
|
|
272
|
+
), this.document.removeEventListener(
|
|
273
|
+
"pointercancel",
|
|
274
|
+
this.onDocPointerDone,
|
|
275
|
+
A
|
|
276
|
+
), this.docMoveBound = !1);
|
|
277
|
+
}
|
|
278
|
+
getCropStyle() {
|
|
279
|
+
const { crop: e } = this.props;
|
|
280
|
+
if (e)
|
|
281
|
+
return {
|
|
282
|
+
height: `${e.height}${e.unit}`,
|
|
283
|
+
left: `${e.x}${e.unit}`,
|
|
284
|
+
top: `${e.y}${e.unit}`,
|
|
285
|
+
width: `${e.width}${e.unit}`
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
dragCrop() {
|
|
289
|
+
const { evData: e } = this, t = this.getBox(), r = this.makePixelCrop(t), i = e.clientX - e.startClientX, s = e.clientY - e.startClientY;
|
|
290
|
+
return r.x = W(
|
|
291
|
+
e.startCropX + i,
|
|
292
|
+
0,
|
|
293
|
+
t.width - r.width
|
|
294
|
+
), r.y = W(
|
|
295
|
+
e.startCropY + s,
|
|
296
|
+
0,
|
|
297
|
+
t.height - r.height
|
|
298
|
+
), r;
|
|
299
|
+
}
|
|
300
|
+
getPointRegion(e, t, r, i) {
|
|
301
|
+
const { evData: s } = this, a = s.clientX - e.x, l = s.clientY - e.y;
|
|
302
|
+
let c;
|
|
303
|
+
i && t ? c = t === "nw" || t === "n" || t === "ne" : c = l < s.startCropY;
|
|
304
|
+
let o;
|
|
305
|
+
return r && t ? o = t === "nw" || t === "w" || t === "sw" : o = a < s.startCropX, o ? c ? "nw" : "sw" : c ? "ne" : "se";
|
|
306
|
+
}
|
|
307
|
+
resolveMinDimensions(e, t, r = 0, i = 0) {
|
|
308
|
+
const s = Math.min(r, e.width), a = Math.min(i, e.height);
|
|
309
|
+
return !t || !s && !a ? [s, a] : t > 1 ? s ? [s, s / t] : [a * t, a] : a ? [a * t, a] : [s, s / t];
|
|
310
|
+
}
|
|
311
|
+
resizeCrop() {
|
|
312
|
+
const { evData: e } = this, {
|
|
313
|
+
aspect: t = 0,
|
|
314
|
+
centerCrop: r,
|
|
315
|
+
maxHeight: i,
|
|
316
|
+
maxWidth: s
|
|
317
|
+
} = this.props, a = this.getBox(), [l, c] = this.resolveMinDimensions(
|
|
318
|
+
a,
|
|
319
|
+
t,
|
|
320
|
+
this.props.minWidth,
|
|
321
|
+
this.props.minHeight
|
|
322
|
+
);
|
|
323
|
+
let o = this.makePixelCrop(a);
|
|
324
|
+
const d = this.getPointRegion(a, e.ord, l, c), p = e.ord || d;
|
|
325
|
+
let g = e.clientX - e.startClientX, u = e.clientY - e.startClientY;
|
|
326
|
+
(l && p === "nw" || p === "w" || p === "sw") && (g = Math.min(g, -l)), (c && p === "nw" || p === "n" || p === "ne") && (u = Math.min(u, -c));
|
|
327
|
+
const n = {
|
|
328
|
+
height: 0,
|
|
329
|
+
unit: "px",
|
|
330
|
+
width: 0,
|
|
331
|
+
x: 0,
|
|
332
|
+
y: 0
|
|
333
|
+
};
|
|
334
|
+
if (r) {
|
|
335
|
+
const b = a.width / 2, v = a.height / 2;
|
|
336
|
+
if (d === "ne") {
|
|
337
|
+
const C = e.startCropWidth + (g - e.startCropWidth) * 2, D = e.startCropHeight - (e.startCropHeight + u) * 2;
|
|
338
|
+
n.width = Math.min(Math.max(20, C), a.width), n.height = Math.min(Math.max(20, D), a.height), n.x = b - n.width / 2, n.y = v - n.height / 2;
|
|
339
|
+
} else if (d === "se") {
|
|
340
|
+
const C = e.startCropWidth + (g - e.startCropWidth) * 2, D = e.startCropHeight + (u - e.startCropHeight) * 2;
|
|
341
|
+
n.width = Math.min(Math.max(20, C), a.width), n.height = Math.min(Math.max(20, D), a.height), n.x = b - n.width / 2, n.y = v - n.height / 2;
|
|
342
|
+
} else if (d === "sw") {
|
|
343
|
+
const C = e.startCropWidth - (e.startCropWidth + g) * 2, D = e.startCropHeight - (e.startCropHeight - u) * 2;
|
|
344
|
+
n.width = Math.min(Math.max(20, C), a.width), n.height = Math.min(Math.max(20, D), a.height), n.x = b - n.width / 2, n.y = v - n.height / 2;
|
|
345
|
+
} else if (d === "nw") {
|
|
346
|
+
const C = e.startCropWidth - (e.startCropWidth + g) * 2, D = e.startCropHeight - (e.startCropHeight + u) * 2;
|
|
347
|
+
n.width = Math.min(Math.max(20, C), a.width), n.height = Math.min(Math.max(20, D), a.height), n.x = b - n.width / 2, n.y = v - n.height / 2;
|
|
348
|
+
}
|
|
349
|
+
if (t && n.width && n.height) {
|
|
350
|
+
const C = n.height * t, D = n.width / t;
|
|
351
|
+
C <= n.width ? n.width = C : n.height = D, n.x = b - n.width / 2, n.y = v - n.height / 2;
|
|
352
|
+
}
|
|
353
|
+
} else
|
|
354
|
+
d === "ne" ? (n.x = e.startCropX, n.width = g, t ? (n.height = n.width / t, n.y = e.startCropY - n.height) : (n.height = Math.abs(u), n.y = e.startCropY - n.height)) : d === "se" ? (n.x = e.startCropX, n.y = e.startCropY, n.width = g, t ? n.height = n.width / t : n.height = u) : d === "sw" ? (n.x = e.startCropX + g, n.y = e.startCropY, n.width = Math.abs(g), t ? n.height = n.width / t : n.height = u) : d === "nw" && (n.x = e.startCropX + g, n.width = Math.abs(g), t ? (n.height = n.width / t, n.y = e.startCropY - n.height) : (n.height = Math.abs(u), n.y = e.startCropY + u));
|
|
355
|
+
const x = ce(
|
|
356
|
+
n,
|
|
357
|
+
t,
|
|
358
|
+
d,
|
|
359
|
+
a.width,
|
|
360
|
+
a.height,
|
|
361
|
+
l,
|
|
362
|
+
c,
|
|
363
|
+
s,
|
|
364
|
+
i
|
|
365
|
+
);
|
|
366
|
+
return t || _.xyOrds.indexOf(p) > -1 ? o = x : _.xOrds.indexOf(p) > -1 ? (o.x = x.x, o.width = x.width) : _.yOrds.indexOf(p) > -1 && (o.y = x.y, o.height = x.height), o.x = W(o.x, 0, a.width - o.width), o.y = W(o.y, 0, a.height - o.height), o;
|
|
367
|
+
}
|
|
368
|
+
renderCropSelection() {
|
|
369
|
+
const {
|
|
370
|
+
ariaLabels: e = _.defaultProps.ariaLabels,
|
|
371
|
+
crop: t,
|
|
372
|
+
disabled: r,
|
|
373
|
+
locked: i,
|
|
374
|
+
renderSelectionAddon: s,
|
|
375
|
+
ruleOfThirds: a
|
|
376
|
+
} = this.props, l = this.getCropStyle();
|
|
377
|
+
if (t)
|
|
378
|
+
return /* @__PURE__ */ f.jsxs(
|
|
379
|
+
"div",
|
|
380
|
+
{
|
|
381
|
+
style: l,
|
|
382
|
+
className: "ReactCrop__crop-selection",
|
|
383
|
+
onPointerDown: this.onCropPointerDown,
|
|
384
|
+
"aria-label": e.cropArea,
|
|
385
|
+
tabIndex: 0,
|
|
386
|
+
onKeyDown: this.onComponentKeyDown,
|
|
387
|
+
role: "group",
|
|
388
|
+
children: [
|
|
389
|
+
!r && !i && /* @__PURE__ */ f.jsxs("div", { className: "ReactCrop__drag-elements", onFocus: this.onDragFocus, children: [
|
|
390
|
+
/* @__PURE__ */ f.jsx("div", { className: "ReactCrop__drag-bar ord-n", "data-ord": "n" }),
|
|
391
|
+
/* @__PURE__ */ f.jsx("div", { className: "ReactCrop__drag-bar ord-e", "data-ord": "e" }),
|
|
392
|
+
/* @__PURE__ */ f.jsx("div", { className: "ReactCrop__drag-bar ord-s", "data-ord": "s" }),
|
|
393
|
+
/* @__PURE__ */ f.jsx("div", { className: "ReactCrop__drag-bar ord-w", "data-ord": "w" }),
|
|
394
|
+
/* @__PURE__ */ f.jsx(
|
|
395
|
+
"div",
|
|
396
|
+
{
|
|
397
|
+
className: "ReactCrop__drag-handle ord-nw",
|
|
398
|
+
"data-ord": "nw",
|
|
399
|
+
tabIndex: 0,
|
|
400
|
+
"aria-label": e.nwDragHandle,
|
|
401
|
+
onKeyDown: (c) => this.onHandlerKeyDown(c, "nw"),
|
|
402
|
+
role: "button"
|
|
403
|
+
}
|
|
404
|
+
),
|
|
405
|
+
/* @__PURE__ */ f.jsx(
|
|
406
|
+
"div",
|
|
407
|
+
{
|
|
408
|
+
className: "ReactCrop__drag-handle ord-n",
|
|
409
|
+
"data-ord": "n",
|
|
410
|
+
tabIndex: 0,
|
|
411
|
+
"aria-label": e.nDragHandle,
|
|
412
|
+
onKeyDown: (c) => this.onHandlerKeyDown(c, "n"),
|
|
413
|
+
role: "button"
|
|
414
|
+
}
|
|
415
|
+
),
|
|
416
|
+
/* @__PURE__ */ f.jsx(
|
|
417
|
+
"div",
|
|
418
|
+
{
|
|
419
|
+
className: "ReactCrop__drag-handle ord-ne",
|
|
420
|
+
"data-ord": "ne",
|
|
421
|
+
tabIndex: 0,
|
|
422
|
+
"aria-label": e.neDragHandle,
|
|
423
|
+
onKeyDown: (c) => this.onHandlerKeyDown(c, "ne"),
|
|
424
|
+
role: "button"
|
|
425
|
+
}
|
|
426
|
+
),
|
|
427
|
+
/* @__PURE__ */ f.jsx(
|
|
428
|
+
"div",
|
|
429
|
+
{
|
|
430
|
+
className: "ReactCrop__drag-handle ord-e",
|
|
431
|
+
"data-ord": "e",
|
|
432
|
+
tabIndex: 0,
|
|
433
|
+
"aria-label": e.eDragHandle,
|
|
434
|
+
onKeyDown: (c) => this.onHandlerKeyDown(c, "e"),
|
|
435
|
+
role: "button"
|
|
436
|
+
}
|
|
437
|
+
),
|
|
438
|
+
/* @__PURE__ */ f.jsx(
|
|
439
|
+
"div",
|
|
440
|
+
{
|
|
441
|
+
className: "ReactCrop__drag-handle ord-se",
|
|
442
|
+
"data-ord": "se",
|
|
443
|
+
tabIndex: 0,
|
|
444
|
+
"aria-label": e.seDragHandle,
|
|
445
|
+
onKeyDown: (c) => this.onHandlerKeyDown(c, "se"),
|
|
446
|
+
role: "button"
|
|
447
|
+
}
|
|
448
|
+
),
|
|
449
|
+
/* @__PURE__ */ f.jsx(
|
|
450
|
+
"div",
|
|
451
|
+
{
|
|
452
|
+
className: "ReactCrop__drag-handle ord-s",
|
|
453
|
+
"data-ord": "s",
|
|
454
|
+
tabIndex: 0,
|
|
455
|
+
"aria-label": e.sDragHandle,
|
|
456
|
+
onKeyDown: (c) => this.onHandlerKeyDown(c, "s"),
|
|
457
|
+
role: "button"
|
|
458
|
+
}
|
|
459
|
+
),
|
|
460
|
+
/* @__PURE__ */ f.jsx(
|
|
461
|
+
"div",
|
|
462
|
+
{
|
|
463
|
+
className: "ReactCrop__drag-handle ord-sw",
|
|
464
|
+
"data-ord": "sw",
|
|
465
|
+
tabIndex: 0,
|
|
466
|
+
"aria-label": e.swDragHandle,
|
|
467
|
+
onKeyDown: (c) => this.onHandlerKeyDown(c, "sw"),
|
|
468
|
+
role: "button"
|
|
469
|
+
}
|
|
470
|
+
),
|
|
471
|
+
/* @__PURE__ */ f.jsx(
|
|
472
|
+
"div",
|
|
473
|
+
{
|
|
474
|
+
className: "ReactCrop__drag-handle ord-w",
|
|
475
|
+
"data-ord": "w",
|
|
476
|
+
tabIndex: 0,
|
|
477
|
+
"aria-label": e.wDragHandle,
|
|
478
|
+
onKeyDown: (c) => this.onHandlerKeyDown(c, "w"),
|
|
479
|
+
role: "button"
|
|
480
|
+
}
|
|
481
|
+
)
|
|
482
|
+
] }),
|
|
483
|
+
s && /* @__PURE__ */ f.jsx(
|
|
484
|
+
"div",
|
|
485
|
+
{
|
|
486
|
+
className: "ReactCrop__selection-addon",
|
|
487
|
+
onPointerDown: (c) => c.stopPropagation(),
|
|
488
|
+
children: s(this.state)
|
|
489
|
+
}
|
|
490
|
+
),
|
|
491
|
+
a && /* @__PURE__ */ f.jsxs(f.Fragment, { children: [
|
|
492
|
+
/* @__PURE__ */ f.jsx("div", { className: "ReactCrop__rule-of-thirds-hz" }),
|
|
493
|
+
/* @__PURE__ */ f.jsx("div", { className: "ReactCrop__rule-of-thirds-vt" })
|
|
494
|
+
] })
|
|
495
|
+
]
|
|
496
|
+
}
|
|
497
|
+
);
|
|
498
|
+
}
|
|
499
|
+
makePixelCrop(e) {
|
|
500
|
+
const t = { ...q, ...this.props.crop || {} };
|
|
501
|
+
return j(t, e.width, e.height);
|
|
502
|
+
}
|
|
503
|
+
render() {
|
|
504
|
+
const {
|
|
505
|
+
aspect: e,
|
|
506
|
+
children: t,
|
|
507
|
+
circularCrop: r,
|
|
508
|
+
className: i,
|
|
509
|
+
crop: s,
|
|
510
|
+
disabled: a,
|
|
511
|
+
loading: l,
|
|
512
|
+
locked: c,
|
|
513
|
+
ruleOfThirds: o,
|
|
514
|
+
style: d
|
|
515
|
+
} = this.props, { cropIsActive: p, newCropIsBeingDrawn: g } = this.state, u = s ? this.renderCropSelection() : null, n = Pe(
|
|
516
|
+
"ReactCrop",
|
|
517
|
+
i,
|
|
518
|
+
p && "ReactCrop--active",
|
|
519
|
+
a && "ReactCrop--disabled",
|
|
520
|
+
c && "ReactCrop--locked",
|
|
521
|
+
g && "ReactCrop--new-crop",
|
|
522
|
+
s && e && "ReactCrop--fixed-aspect",
|
|
523
|
+
s && r && "ReactCrop--circular-crop",
|
|
524
|
+
s && o && "ReactCrop--rule-of-thirds",
|
|
525
|
+
!this.dragStarted && s && !s.width && !s.height && "ReactCrop--invisible-crop",
|
|
526
|
+
r && "ReactCrop--no-animate",
|
|
527
|
+
l && "ReactCrop--loading"
|
|
528
|
+
);
|
|
529
|
+
let x;
|
|
530
|
+
if (s) {
|
|
531
|
+
let b = /* @__PURE__ */ f.jsx(
|
|
532
|
+
"rect",
|
|
533
|
+
{
|
|
534
|
+
x: `${s.x}${s.unit}`,
|
|
535
|
+
y: `${s.y}${s.unit}`,
|
|
536
|
+
width: `${s.width}${s.unit}`,
|
|
537
|
+
height: `${s.height}${s.unit}`,
|
|
538
|
+
fill: "black"
|
|
539
|
+
}
|
|
540
|
+
);
|
|
541
|
+
r && (b = /* @__PURE__ */ f.jsx(
|
|
542
|
+
"ellipse",
|
|
543
|
+
{
|
|
544
|
+
cx: `${s.x + s.width / 2}${s.unit}`,
|
|
545
|
+
cy: `${s.y + s.height / 2}${s.unit}`,
|
|
546
|
+
rx: `${s.width / 2}${s.unit}`,
|
|
547
|
+
ry: `${s.height / 2}${s.unit}`,
|
|
548
|
+
fill: "black"
|
|
549
|
+
}
|
|
550
|
+
)), x = /* @__PURE__ */ f.jsxs("svg", { className: "ReactCrop__crop-mask", width: "100%", height: "100%", children: [
|
|
551
|
+
/* @__PURE__ */ f.jsx("defs", { children: /* @__PURE__ */ f.jsxs("mask", { id: `hole-${this.instanceId}`, children: [
|
|
552
|
+
/* @__PURE__ */ f.jsx("rect", { width: "100%", height: "100%", fill: "white" }),
|
|
553
|
+
b
|
|
554
|
+
] }) }),
|
|
555
|
+
/* @__PURE__ */ f.jsx(
|
|
556
|
+
"rect",
|
|
557
|
+
{
|
|
558
|
+
fill: "black",
|
|
559
|
+
fillOpacity: 0.5,
|
|
560
|
+
width: "100%",
|
|
561
|
+
height: "100%",
|
|
562
|
+
mask: `url(#hole-${this.instanceId})`
|
|
563
|
+
}
|
|
564
|
+
)
|
|
565
|
+
] });
|
|
566
|
+
}
|
|
567
|
+
return /* @__PURE__ */ f.jsxs("div", { ref: this.componentRef, className: n, style: d, children: [
|
|
568
|
+
/* @__PURE__ */ f.jsx(
|
|
569
|
+
"div",
|
|
570
|
+
{
|
|
571
|
+
ref: this.mediaRef,
|
|
572
|
+
className: "ReactCrop__child-wrapper",
|
|
573
|
+
onPointerDown: this.onComponentPointerDown,
|
|
574
|
+
children: t
|
|
575
|
+
}
|
|
576
|
+
),
|
|
577
|
+
x,
|
|
578
|
+
u
|
|
579
|
+
] });
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
_.xOrds = ["e", "w"], _.yOrds = ["n", "s"], _.xyOrds = ["nw", "ne", "se", "sw"], _.nudgeStep = 1, _.nudgeStepMedium = 10, _.nudgeStepLarge = 100, _.defaultProps = {
|
|
583
|
+
ariaLabels: {
|
|
584
|
+
cropArea: "Use the arrow keys to move the crop selection area",
|
|
585
|
+
eDragHandle: "Use the up and down arrow keys to move the east drag handle to change the crop selection area",
|
|
586
|
+
nDragHandle: "Use the up and down arrow keys to move the north drag handle to change the crop selection area",
|
|
587
|
+
neDragHandle: "Use the arrow keys to move the north east drag handle to change the crop selection area",
|
|
588
|
+
nwDragHandle: "Use the arrow keys to move the north west drag handle to change the crop selection area",
|
|
589
|
+
sDragHandle: "Use the up and down arrow keys to move the south drag handle to change the crop selection area",
|
|
590
|
+
seDragHandle: "Use the arrow keys to move the south east drag handle to change the crop selection area",
|
|
591
|
+
swDragHandle: "Use the arrow keys to move the south west drag handle to change the crop selection area",
|
|
592
|
+
wDragHandle: "Use the up and down arrow keys to move the west drag handle to change the crop selection area"
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
let ie = _;
|
|
596
|
+
function le(h, e, t, r = 100) {
|
|
597
|
+
return Le(
|
|
598
|
+
Ye(
|
|
599
|
+
{
|
|
600
|
+
unit: "%",
|
|
601
|
+
width: r
|
|
602
|
+
},
|
|
603
|
+
t,
|
|
604
|
+
h,
|
|
605
|
+
e
|
|
606
|
+
),
|
|
607
|
+
h,
|
|
608
|
+
e
|
|
609
|
+
);
|
|
610
|
+
}
|
|
611
|
+
const We = w.forwardRef(
|
|
612
|
+
({
|
|
613
|
+
cropper: h,
|
|
614
|
+
disabled: e,
|
|
615
|
+
fillImage: t,
|
|
616
|
+
image: r,
|
|
617
|
+
loadable: i,
|
|
618
|
+
loading: s,
|
|
619
|
+
multiple: a,
|
|
620
|
+
resizer: l,
|
|
621
|
+
rotation: c,
|
|
622
|
+
useInternalLoading: o
|
|
623
|
+
}, d) => {
|
|
624
|
+
const [p, g] = w.useState(!1), [u, n] = w.useState(e), [x, b] = w.useState(!1), [v, C] = w.useState({
|
|
625
|
+
height: 0,
|
|
626
|
+
unit: N.AspectRatio,
|
|
627
|
+
width: 0,
|
|
628
|
+
x: 0,
|
|
629
|
+
y: 0
|
|
630
|
+
}), [D, B] = w.useState(r?.url ?? ""), [U, V] = w.useState({
|
|
631
|
+
height: 0,
|
|
632
|
+
width: 0
|
|
633
|
+
}), [de, pe] = w.useState({
|
|
634
|
+
height: r?.height ?? 0,
|
|
635
|
+
width: r?.width ?? 0
|
|
636
|
+
}), M = w.useRef(null), T = w.useRef(r?.url ?? ""), Z = w.useRef(null), G = w.useRef({
|
|
637
|
+
height: r?.height ?? 0,
|
|
638
|
+
width: r?.width ?? 0
|
|
639
|
+
}), $ = w.useRef(null);
|
|
640
|
+
G.current = { ...de };
|
|
641
|
+
const O = w.useCallback(() => {
|
|
642
|
+
$.current && clearTimeout($.current), $.current = setTimeout(() => {
|
|
643
|
+
$.current = null, g(!0);
|
|
644
|
+
}, 1e3);
|
|
645
|
+
}, []), L = w.useCallback(() => {
|
|
646
|
+
$.current ? (clearTimeout($.current), $.current = null) : g(!1);
|
|
647
|
+
}, []);
|
|
648
|
+
w.useEffect(() => () => {
|
|
649
|
+
$.current && clearTimeout($.current);
|
|
650
|
+
}, []);
|
|
651
|
+
const R = w.useMemo(() => r, [r.url, r.width, r.height, r.rotation, r.extension, r.originalUrl, r.x, r.y]), I = w.useMemo(() => l, [l.width, l.height, l.maxWidth, l.maxHeight]), J = w.useCallback(() => {
|
|
652
|
+
if (!M.current)
|
|
653
|
+
return { maxHeight: 0, maxWidth: 0 };
|
|
654
|
+
let m = 0, y = 0;
|
|
655
|
+
const H = R.width / R.height, X = M.current.clientWidth / M.current.clientHeight;
|
|
656
|
+
return H > X ? (m = M.current.clientWidth, y = m / H) : (y = M.current.clientHeight, m = y * H), { maxHeight: y, maxWidth: m };
|
|
657
|
+
}, [R.width, R.height]);
|
|
658
|
+
w.useEffect(() => {
|
|
659
|
+
C({
|
|
660
|
+
height: h.percentageHeight,
|
|
661
|
+
unit: N.AspectRatio,
|
|
662
|
+
width: h.percentageWidth,
|
|
663
|
+
x: h.x,
|
|
664
|
+
y: h.y
|
|
665
|
+
});
|
|
666
|
+
}, [h]), w.useEffect(() => {
|
|
667
|
+
const { height: m, width: y } = I, H = (Y, K) => e ? I.width !== G.current.width || I.height !== G.current.height : y < Y || m < K, E = se(async () => {
|
|
668
|
+
if (c !== 0)
|
|
669
|
+
return;
|
|
670
|
+
const { maxHeight: Y, maxWidth: K } = J(), fe = H(K, Y);
|
|
671
|
+
if (!i || !fe && T.current) {
|
|
672
|
+
B(R.url), n(e), L();
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
const ne = T.current !== R.url;
|
|
676
|
+
ne && O();
|
|
677
|
+
const F = e && !t, { height: me, width: Ce } = He(R.width, R.height, y, m), { url: xe } = await je(
|
|
678
|
+
R.url,
|
|
679
|
+
F && I.width || K,
|
|
680
|
+
F && I.height || Y,
|
|
681
|
+
M.current?.clientWidth ?? window.innerWidth,
|
|
682
|
+
M.current?.clientHeight ?? window.innerHeight
|
|
683
|
+
);
|
|
684
|
+
B(xe), V({
|
|
685
|
+
height: F ? I.height : me,
|
|
686
|
+
width: F ? I.width : Ce
|
|
687
|
+
}), n(e), ne || L(), T.current = R.url;
|
|
688
|
+
}, 300, { leading: !1 });
|
|
689
|
+
return E(), () => E.cancel();
|
|
690
|
+
}, [e, R, i, J, I, c, t, O, L, n]), w.useEffect(() => {
|
|
691
|
+
const y = se(async () => {
|
|
692
|
+
if (i && c !== 0) {
|
|
693
|
+
O();
|
|
694
|
+
const { height: X, width: E } = $e(
|
|
695
|
+
R.width,
|
|
696
|
+
R.height,
|
|
697
|
+
c
|
|
698
|
+
), Y = await Se(
|
|
699
|
+
{
|
|
700
|
+
height: R.height,
|
|
701
|
+
url: R.url,
|
|
702
|
+
width: R.width
|
|
703
|
+
},
|
|
704
|
+
c
|
|
705
|
+
);
|
|
706
|
+
B(Y), V({
|
|
707
|
+
height: X,
|
|
708
|
+
width: E
|
|
709
|
+
}), n(e), T.current = R.url;
|
|
710
|
+
} else
|
|
711
|
+
i ? O() : B(R.url);
|
|
712
|
+
}, 300, { leading: !1 });
|
|
713
|
+
return y(), () => y.cancel();
|
|
714
|
+
}, [R, i, c, e, J, O, L]);
|
|
715
|
+
const re = w.useCallback(() => {
|
|
716
|
+
C({
|
|
717
|
+
height: 100,
|
|
718
|
+
unit: "%",
|
|
719
|
+
width: 100,
|
|
720
|
+
x: 0,
|
|
721
|
+
y: 0
|
|
722
|
+
});
|
|
723
|
+
}, []), ge = w.useCallback(
|
|
724
|
+
(m, y) => {
|
|
725
|
+
e || C(y);
|
|
726
|
+
},
|
|
727
|
+
[e]
|
|
728
|
+
), oe = w.useCallback(
|
|
729
|
+
(m) => {
|
|
730
|
+
if (!Z.current)
|
|
731
|
+
return;
|
|
732
|
+
const { naturalHeight: y, naturalWidth: H } = m.currentTarget;
|
|
733
|
+
if (pe({
|
|
734
|
+
height: y,
|
|
735
|
+
width: H
|
|
736
|
+
}), V({
|
|
737
|
+
height: y,
|
|
738
|
+
width: H
|
|
739
|
+
}), h.unit === N.AspectRatio) {
|
|
740
|
+
const { height: X, width: E } = m.currentTarget;
|
|
741
|
+
C(
|
|
742
|
+
le(E, X, h.width / h.height)
|
|
743
|
+
);
|
|
744
|
+
} else
|
|
745
|
+
C({
|
|
746
|
+
height: 100,
|
|
747
|
+
unit: "%",
|
|
748
|
+
width: 100,
|
|
749
|
+
x: 0,
|
|
750
|
+
y: 0
|
|
751
|
+
});
|
|
752
|
+
L();
|
|
753
|
+
},
|
|
754
|
+
[h.height, h.unit, h.width, L]
|
|
755
|
+
);
|
|
756
|
+
w.useEffect(() => {
|
|
757
|
+
re();
|
|
758
|
+
}, [e, re]), w.useEffect(() => {
|
|
759
|
+
if (!M.current || !i)
|
|
760
|
+
return;
|
|
761
|
+
const m = new CustomEvent("cx-cropper-loading-change", {
|
|
762
|
+
bubbles: !0,
|
|
763
|
+
cancelable: !1,
|
|
764
|
+
composed: !0,
|
|
765
|
+
detail: p
|
|
766
|
+
});
|
|
767
|
+
M.current.dispatchEvent(m), p || b(!0);
|
|
768
|
+
}, [p, i]);
|
|
769
|
+
const Q = w.useMemo(() => h.focusMode === "center", [h.focusMode]), ee = w.useCallback(
|
|
770
|
+
(m, y) => {
|
|
771
|
+
const H = new CustomEvent("cx-cropper-crop-complete", {
|
|
772
|
+
bubbles: !0,
|
|
773
|
+
cancelable: !1,
|
|
774
|
+
composed: !0,
|
|
775
|
+
detail: {
|
|
776
|
+
croppedArea: y
|
|
777
|
+
}
|
|
778
|
+
});
|
|
779
|
+
M.current?.dispatchEvent(H);
|
|
780
|
+
},
|
|
781
|
+
[]
|
|
782
|
+
);
|
|
783
|
+
w.useEffect(() => {
|
|
784
|
+
if (Q) {
|
|
785
|
+
const m = le(
|
|
786
|
+
r.width,
|
|
787
|
+
r.height,
|
|
788
|
+
h.width / h.height,
|
|
789
|
+
h.percentageWidth
|
|
790
|
+
);
|
|
791
|
+
C(m), ee(void 0, m);
|
|
792
|
+
}
|
|
793
|
+
}, [
|
|
794
|
+
Q,
|
|
795
|
+
h.percentageWidth,
|
|
796
|
+
h.width,
|
|
797
|
+
h.height,
|
|
798
|
+
r.width,
|
|
799
|
+
r.height,
|
|
800
|
+
ee
|
|
801
|
+
]);
|
|
802
|
+
const ue = w.useCallback((m) => {
|
|
803
|
+
const y = new CustomEvent("cx-cropper-crop-drag-start", {
|
|
804
|
+
bubbles: !0,
|
|
805
|
+
cancelable: !1,
|
|
806
|
+
composed: !0,
|
|
807
|
+
detail: {
|
|
808
|
+
clientX: m.clientX,
|
|
809
|
+
clientY: m.clientY
|
|
810
|
+
}
|
|
811
|
+
});
|
|
812
|
+
M.current?.dispatchEvent(y);
|
|
813
|
+
}, []), we = w.useMemo(() => {
|
|
814
|
+
if (!M.current)
|
|
815
|
+
return !1;
|
|
816
|
+
const m = U.height / U.width, y = M.current.clientHeight / M.current.clientWidth;
|
|
817
|
+
return m > y;
|
|
818
|
+
}, [U.height, U.width]);
|
|
819
|
+
return /* @__PURE__ */ f.jsx(
|
|
820
|
+
"div",
|
|
821
|
+
{
|
|
822
|
+
ref: M,
|
|
823
|
+
className: `cropper cropper--${we ? "portrait" : "landscape"}${a ? " cropper--multiple" : ""}`,
|
|
824
|
+
children: i ? /* @__PURE__ */ f.jsx(
|
|
825
|
+
ie,
|
|
826
|
+
{
|
|
827
|
+
aspect: h.keepAspectRatio || h.unit === N.AspectRatio ? h.width / h.height : void 0,
|
|
828
|
+
crop: v,
|
|
829
|
+
centerCrop: Q,
|
|
830
|
+
disabled: u,
|
|
831
|
+
loading: s || o && p,
|
|
832
|
+
keepSelection: !0,
|
|
833
|
+
ruleOfThirds: !0,
|
|
834
|
+
onChange: ge,
|
|
835
|
+
onComplete: ee,
|
|
836
|
+
onDragStart: ue,
|
|
837
|
+
style: {
|
|
838
|
+
cursor: u ? "default" : "move",
|
|
839
|
+
pointerEvents: u ? "none" : "auto"
|
|
840
|
+
},
|
|
841
|
+
children: /* @__PURE__ */ f.jsx(
|
|
842
|
+
"img",
|
|
843
|
+
{
|
|
844
|
+
className: "cropper__image",
|
|
845
|
+
src: D,
|
|
846
|
+
alt: "Cropped",
|
|
847
|
+
ref: Z,
|
|
848
|
+
onLoad: oe
|
|
849
|
+
}
|
|
850
|
+
)
|
|
851
|
+
},
|
|
852
|
+
R.url
|
|
853
|
+
) : /* @__PURE__ */ f.jsx(
|
|
854
|
+
"img",
|
|
855
|
+
{
|
|
856
|
+
className: `cropper__image ${p && !x ? "cropper__image--loading" : ""}`,
|
|
857
|
+
src: D,
|
|
858
|
+
alt: "Cropped",
|
|
859
|
+
ref: Z,
|
|
860
|
+
onLoad: oe
|
|
861
|
+
}
|
|
862
|
+
)
|
|
863
|
+
}
|
|
864
|
+
);
|
|
865
|
+
}
|
|
866
|
+
);
|
|
867
|
+
var Ae = Object.defineProperty, Oe = Object.getOwnPropertyDescriptor, z = (h, e, t, r) => {
|
|
868
|
+
for (var i = r > 1 ? void 0 : r ? Oe(e, t) : e, s = h.length - 1, a; s >= 0; s--)
|
|
869
|
+
(a = h[s]) && (i = (r ? a(e, t, i) : a(i)) || i);
|
|
870
|
+
return r && i && Ae(e, t, i), i;
|
|
871
|
+
};
|
|
872
|
+
const Ke = Me(We, ze, ke, {
|
|
873
|
+
// @ts-expect-error type error
|
|
874
|
+
props: {
|
|
875
|
+
cropper: "object",
|
|
876
|
+
disabled: "boolean",
|
|
877
|
+
fillImage: "boolean",
|
|
878
|
+
image: "object",
|
|
879
|
+
loadable: "boolean",
|
|
880
|
+
loading: "boolean",
|
|
881
|
+
multiple: "boolean",
|
|
882
|
+
ref: "object",
|
|
883
|
+
resizer: "object",
|
|
884
|
+
rotation: "number",
|
|
885
|
+
useInternalLoading: "boolean"
|
|
886
|
+
}
|
|
887
|
+
});
|
|
888
|
+
customElements.get("custom-cropper") || customElements.define("custom-cropper", Ke);
|
|
889
|
+
let k = class extends be {
|
|
890
|
+
constructor() {
|
|
891
|
+
super(...arguments), this.cropper = {
|
|
892
|
+
height: 0,
|
|
893
|
+
keepAspectRatio: !0,
|
|
894
|
+
percentageHeight: 0,
|
|
895
|
+
percentageWidth: 0,
|
|
896
|
+
unit: N.Pixel,
|
|
897
|
+
width: 0,
|
|
898
|
+
x: 0,
|
|
899
|
+
y: 0
|
|
900
|
+
}, this.image = void 0, this.resizer = {
|
|
901
|
+
height: 0,
|
|
902
|
+
width: 0
|
|
903
|
+
}, this.rotation = 0, this.fillImage = !1, this.disabled = !1, this.loadable = !1, this.loading = !1, this.multiple = !1, this.useInternalLoading = !1, this.showLoading = !0;
|
|
904
|
+
}
|
|
905
|
+
handleLoadingChange(h) {
|
|
906
|
+
h.detail || (this.showLoading = h.detail);
|
|
907
|
+
}
|
|
908
|
+
render() {
|
|
909
|
+
return te`
|
|
910
|
+
${ae(
|
|
911
|
+
this.image,
|
|
912
|
+
() => te`<custom-cropper .ref=${this} .cropper=${this.cropper} .image=${this.image} .loadable=${this.loadable} .resizer=${this.resizer} .rotation=${this.rotation} .disabled=${this.disabled} .loading=${this.loading} .fillImage=${this.fillImage} .useInternalLoading=${this.useInternalLoading} .multiple=${this.multiple} @cx-cropper-loading-change=${this.handleLoadingChange}></custom-cropper>`
|
|
913
|
+
)}
|
|
914
|
+
${ae(
|
|
915
|
+
this.showLoading,
|
|
916
|
+
() => te`<div class="loading-container"><div class="loading"><cx-skeleton class="loading__skeleton"></cx-skeleton><cx-spinner class="loading__spinner"></cx-spinner></div></div>`
|
|
917
|
+
)}
|
|
918
|
+
`;
|
|
919
|
+
}
|
|
920
|
+
};
|
|
921
|
+
k.styles = [ye, Ie];
|
|
922
|
+
z([
|
|
923
|
+
De("custom-cropper")
|
|
924
|
+
], k.prototype, "cropperEl", 2);
|
|
925
|
+
z([
|
|
926
|
+
S({ type: Object })
|
|
927
|
+
], k.prototype, "cropper", 2);
|
|
928
|
+
z([
|
|
929
|
+
S({ type: Object })
|
|
930
|
+
], k.prototype, "image", 2);
|
|
931
|
+
z([
|
|
932
|
+
S({ type: Object })
|
|
933
|
+
], k.prototype, "resizer", 2);
|
|
934
|
+
z([
|
|
935
|
+
S({ reflect: !0, type: Number })
|
|
936
|
+
], k.prototype, "rotation", 2);
|
|
937
|
+
z([
|
|
938
|
+
S({ attribute: "fill-image", reflect: !0, type: Boolean })
|
|
939
|
+
], k.prototype, "fillImage", 2);
|
|
940
|
+
z([
|
|
941
|
+
S({ reflect: !0, type: Boolean })
|
|
942
|
+
], k.prototype, "disabled", 2);
|
|
943
|
+
z([
|
|
944
|
+
S({ reflect: !0, type: Boolean })
|
|
945
|
+
], k.prototype, "loadable", 2);
|
|
946
|
+
z([
|
|
947
|
+
S({ reflect: !0, type: Boolean })
|
|
948
|
+
], k.prototype, "loading", 2);
|
|
949
|
+
z([
|
|
950
|
+
S({ reflect: !0, type: Boolean })
|
|
951
|
+
], k.prototype, "multiple", 2);
|
|
952
|
+
z([
|
|
953
|
+
S({ attribute: "use-internal-loading", reflect: !0, type: Boolean })
|
|
954
|
+
], k.prototype, "useInternalLoading", 2);
|
|
955
|
+
z([
|
|
956
|
+
ve()
|
|
957
|
+
], k.prototype, "showLoading", 2);
|
|
958
|
+
k = z([
|
|
959
|
+
Re("cx-cropper")
|
|
960
|
+
], k);
|
|
10
961
|
export {
|
|
11
|
-
|
|
962
|
+
k as default
|
|
12
963
|
};
|