vue-devui 0.1.3 → 1.0.0-alpha.10
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/README.md +161 -59
- package/alert/index.d.ts +7 -0
- package/alert/index.es.js +204 -0
- package/alert/index.umd.js +1 -0
- package/alert/package.json +7 -0
- package/alert/style.css +1 -0
- package/auto-complete/index.d.ts +7 -0
- package/auto-complete/index.es.js +9051 -0
- package/auto-complete/index.umd.js +40 -0
- package/auto-complete/package.json +7 -0
- package/auto-complete/style.css +1 -0
- package/avatar/index.d.ts +7 -0
- package/avatar/index.es.js +308 -0
- package/avatar/index.umd.js +1 -0
- package/avatar/package.json +7 -0
- package/avatar/style.css +1 -0
- package/badge/index.d.ts +7 -0
- package/badge/index.es.js +120 -0
- package/badge/index.umd.js +1 -0
- package/badge/package.json +7 -0
- package/badge/style.css +1 -0
- package/button/index.d.ts +7 -0
- package/button/index.es.js +5964 -0
- package/button/index.umd.js +27 -0
- package/button/package.json +7 -0
- package/button/style.css +1 -0
- package/card/index.d.ts +7 -0
- package/card/index.es.js +89 -0
- package/card/index.umd.js +1 -0
- package/card/package.json +7 -0
- package/card/style.css +1 -0
- package/checkbox/index.d.ts +7 -0
- package/checkbox/index.es.js +8207 -0
- package/checkbox/index.umd.js +38 -0
- package/checkbox/package.json +7 -0
- package/checkbox/style.css +1 -0
- package/collapse/index.d.ts +7 -0
- package/collapse/index.es.js +195 -0
- package/collapse/index.umd.js +1 -0
- package/collapse/package.json +7 -0
- package/collapse/style.css +1 -0
- package/countdown/index.d.ts +7 -0
- package/countdown/index.es.js +217 -0
- package/countdown/index.umd.js +1 -0
- package/countdown/package.json +7 -0
- package/countdown/style.css +1 -0
- package/date-picker-pro/index.d.ts +7 -0
- package/date-picker-pro/index.es.js +12031 -0
- package/date-picker-pro/index.umd.js +38 -0
- package/date-picker-pro/package.json +7 -0
- package/date-picker-pro/style.css +1 -0
- package/drawer/index.d.ts +7 -0
- package/drawer/index.es.js +248 -0
- package/drawer/index.umd.js +1 -0
- package/drawer/package.json +7 -0
- package/drawer/style.css +1 -0
- package/dropdown/index.d.ts +7 -0
- package/dropdown/index.es.js +743 -0
- package/dropdown/index.umd.js +1 -0
- package/dropdown/package.json +7 -0
- package/dropdown/style.css +1 -0
- package/editable-select/index.d.ts +7 -0
- package/editable-select/index.es.js +991 -0
- package/editable-select/index.umd.js +1 -0
- package/editable-select/package.json +7 -0
- package/editable-select/style.css +1 -0
- package/form/index.d.ts +7 -0
- package/form/index.es.js +7751 -0
- package/form/index.umd.js +38 -0
- package/form/package.json +7 -0
- package/form/style.css +1 -0
- package/fullscreen/index.d.ts +7 -0
- package/fullscreen/index.es.js +166 -0
- package/fullscreen/index.umd.js +1 -0
- package/fullscreen/package.json +7 -0
- package/fullscreen/style.css +1 -0
- package/grid/index.d.ts +7 -0
- package/grid/index.es.js +271 -0
- package/grid/index.umd.js +1 -0
- package/grid/package.json +7 -0
- package/grid/style.css +1 -0
- package/icon/index.d.ts +7 -0
- package/icon/index.es.js +218 -0
- package/icon/index.umd.js +1 -0
- package/icon/package.json +7 -0
- package/icon/style.css +1 -0
- package/image-preview/index.d.ts +7 -0
- package/image-preview/index.es.js +511 -0
- package/image-preview/index.umd.js +1 -0
- package/image-preview/package.json +7 -0
- package/image-preview/style.css +1 -0
- package/index.d.ts +7 -0
- package/input/index.d.ts +7 -0
- package/input/index.es.js +8311 -0
- package/input/index.umd.js +38 -0
- package/input/package.json +7 -0
- package/input/style.css +1 -0
- package/input-number/index.d.ts +7 -0
- package/input-number/index.es.js +308 -0
- package/input-number/index.umd.js +1 -0
- package/input-number/package.json +7 -0
- package/input-number/style.css +1 -0
- package/layout/index.d.ts +7 -0
- package/layout/index.es.js +115 -0
- package/layout/index.umd.js +1 -0
- package/layout/package.json +7 -0
- package/layout/style.css +1 -0
- package/loading/index.d.ts +7 -0
- package/loading/index.es.js +272 -0
- package/loading/index.umd.js +1 -0
- package/loading/package.json +7 -0
- package/loading/style.css +1 -0
- package/message/index.d.ts +7 -0
- package/message/index.es.js +534 -0
- package/message/index.umd.js +1 -0
- package/message/package.json +7 -0
- package/message/style.css +1 -0
- package/modal/index.d.ts +7 -0
- package/modal/index.es.js +741 -0
- package/modal/index.umd.js +1 -0
- package/modal/package.json +7 -0
- package/modal/style.css +1 -0
- package/notification/index.d.ts +7 -0
- package/notification/index.es.js +528 -0
- package/notification/index.umd.js +1 -0
- package/notification/package.json +7 -0
- package/notification/style.css +1 -0
- package/nuxt/components/Alert.js +3 -0
- package/nuxt/components/Aside.js +3 -0
- package/nuxt/components/AutoComplete.js +3 -0
- package/nuxt/components/Avatar.js +3 -0
- package/nuxt/components/Badge.js +3 -0
- package/nuxt/components/Button.js +3 -0
- package/nuxt/components/ButtonGroup.js +3 -0
- package/nuxt/components/Card.js +3 -0
- package/nuxt/components/Checkbox.js +3 -0
- package/nuxt/components/CheckboxButton.js +3 -0
- package/nuxt/components/CheckboxGroup.js +3 -0
- package/nuxt/components/Col.js +3 -0
- package/nuxt/components/Collapse.js +3 -0
- package/nuxt/components/CollapseItem.js +3 -0
- package/nuxt/components/Column.js +3 -0
- package/nuxt/components/Content.js +3 -0
- package/nuxt/components/Countdown.js +3 -0
- package/nuxt/components/DRangeDatePickerPro.js +3 -0
- package/nuxt/components/DatePickerPro.js +3 -0
- package/nuxt/components/Drawer.js +3 -0
- package/nuxt/components/DrawerService.js +3 -0
- package/nuxt/components/Dropdown.js +3 -0
- package/nuxt/components/DropdownMenu.js +3 -0
- package/nuxt/components/DropdownPropsKey.js +3 -0
- package/nuxt/components/EditableSelect.js +3 -0
- package/nuxt/components/FORM_ITEM_TOKEN.js +3 -0
- package/nuxt/components/FORM_TOKEN.js +3 -0
- package/nuxt/components/FixedOverlay.js +3 -0
- package/nuxt/components/FlexibleOverlay.js +3 -0
- package/nuxt/components/Footer.js +3 -0
- package/nuxt/components/Form.js +3 -0
- package/nuxt/components/FormItem.js +3 -0
- package/nuxt/components/FormOperation.js +3 -0
- package/nuxt/components/Fullscreen.js +3 -0
- package/nuxt/components/Header.js +3 -0
- package/nuxt/components/IFileOptions.js +3 -0
- package/nuxt/components/IUploadOptions.js +3 -0
- package/nuxt/components/Icon.js +3 -0
- package/nuxt/components/IconGroup.js +3 -0
- package/nuxt/components/ImagePreviewService.js +3 -0
- package/nuxt/components/Input.js +3 -0
- package/nuxt/components/InputNumber.js +3 -0
- package/nuxt/components/LABEL_DATA.js +3 -0
- package/nuxt/components/Layout.js +3 -0
- package/nuxt/components/Loading.js +3 -0
- package/nuxt/components/LoadingOptions.js +3 -0
- package/nuxt/components/LoadingService.js +3 -0
- package/nuxt/components/Message.js +3 -0
- package/nuxt/components/Modal.js +3 -0
- package/nuxt/components/Notification.js +3 -0
- package/nuxt/components/NotificationService.js +3 -0
- package/nuxt/components/Option.js +3 -0
- package/nuxt/components/OptionGroup.js +3 -0
- package/nuxt/components/Pagination.js +3 -0
- package/nuxt/components/Panel.js +3 -0
- package/nuxt/components/PanelBody.js +3 -0
- package/nuxt/components/PanelFooter.js +3 -0
- package/nuxt/components/PanelHeader.js +3 -0
- package/nuxt/components/Popover.js +3 -0
- package/nuxt/components/Progress.js +3 -0
- package/nuxt/components/Radio.js +3 -0
- package/nuxt/components/RadioButton.js +3 -0
- package/nuxt/components/RadioGroup.js +3 -0
- package/nuxt/components/Rate.js +3 -0
- package/nuxt/components/Result.js +3 -0
- package/nuxt/components/Row.js +3 -0
- package/nuxt/components/Search.js +3 -0
- package/nuxt/components/Select.js +3 -0
- package/nuxt/components/Skeleton.js +3 -0
- package/nuxt/components/SkeletonItem.js +3 -0
- package/nuxt/components/Slider.js +3 -0
- package/nuxt/components/Splitter.js +3 -0
- package/nuxt/components/Statistic.js +3 -0
- package/nuxt/components/Status.js +3 -0
- package/nuxt/components/Step.js +3 -0
- package/nuxt/components/Steps.js +3 -0
- package/nuxt/components/Switch.js +3 -0
- package/nuxt/components/TABLE_TOKEN.js +3 -0
- package/nuxt/components/Tab.js +3 -0
- package/nuxt/components/Table.js +3 -0
- package/nuxt/components/Tabs.js +3 -0
- package/nuxt/components/Tag.js +3 -0
- package/nuxt/components/Textarea.js +3 -0
- package/nuxt/components/TimePicker.js +3 -0
- package/nuxt/components/TimeSelect.js +3 -0
- package/nuxt/components/Timeline.js +3 -0
- package/nuxt/components/TimelineItem.js +3 -0
- package/nuxt/components/Tooltip.js +3 -0
- package/nuxt/components/Tree.js +3 -0
- package/nuxt/components/Upload.js +3 -0
- package/nuxt/components/UploadStatus.js +3 -0
- package/nuxt/components/alertProps.js +3 -0
- package/nuxt/components/animationInjectionKey.js +3 -0
- package/nuxt/components/autoCompleteProps.js +3 -0
- package/nuxt/components/avatarProps.js +3 -0
- package/nuxt/components/badgeProps.js +3 -0
- package/nuxt/components/buttonGroupInjectionKey.js +3 -0
- package/nuxt/components/buttonGroupProps.js +3 -0
- package/nuxt/components/buttonProps.js +3 -0
- package/nuxt/components/cardProps.js +3 -0
- package/nuxt/components/checkboxGroupInjectionKey.js +3 -0
- package/nuxt/components/checkboxGroupProps.js +3 -0
- package/nuxt/components/checkboxProps.js +3 -0
- package/nuxt/components/colProps.js +3 -0
- package/nuxt/components/colPropsBaseClass.js +3 -0
- package/nuxt/components/colPropsBaseStyle.js +3 -0
- package/nuxt/components/collapseItemProps.js +3 -0
- package/nuxt/components/collapseProps.js +3 -0
- package/nuxt/components/countdownProps.js +3 -0
- package/nuxt/components/datePickerProCommonProps.js +3 -0
- package/nuxt/components/datePickerProPanelProps.js +3 -0
- package/nuxt/components/datePickerProProps.js +3 -0
- package/nuxt/components/dropdownMenuProps.js +3 -0
- package/nuxt/components/editableSelectProps.js +3 -0
- package/nuxt/components/fixedOverlayProps.js +3 -0
- package/nuxt/components/flexibleOverlayProps.js +3 -0
- package/nuxt/components/formItemProps.js +3 -0
- package/nuxt/components/formProps.js +3 -0
- package/nuxt/components/fullscreenProps.js +3 -0
- package/nuxt/components/iconProps.js +3 -0
- package/nuxt/components/imagePreviewProps.js +3 -0
- package/nuxt/components/inputProps.js +3 -0
- package/nuxt/components/loadingProps.js +3 -0
- package/nuxt/components/messageProps.js +3 -0
- package/nuxt/components/modalProps.js +3 -0
- package/nuxt/components/notificationProps.js +3 -0
- package/nuxt/components/paginationProps.js +3 -0
- package/nuxt/components/panelProps.js +3 -0
- package/nuxt/components/popoverProps.js +3 -0
- package/nuxt/components/progressProps.js +3 -0
- package/nuxt/components/rateProps.js +3 -0
- package/nuxt/components/resultProps.js +3 -0
- package/nuxt/components/roundInjectionKey.js +3 -0
- package/nuxt/components/rowProps.js +3 -0
- package/nuxt/components/screenSizes.js +3 -0
- package/nuxt/components/searchProps.js +3 -0
- package/nuxt/components/skeletonItemProps.js +3 -0
- package/nuxt/components/skeletonProps.js +3 -0
- package/nuxt/components/sliderProps.js +3 -0
- package/nuxt/components/splitterProps.js +3 -0
- package/nuxt/components/statisticProps.js +3 -0
- package/nuxt/components/stepProps.js +3 -0
- package/nuxt/components/stepsProps.js +3 -0
- package/nuxt/components/svgIconProps.js +3 -0
- package/nuxt/components/switchProps.js +3 -0
- package/nuxt/components/tableProps.js +3 -0
- package/nuxt/components/tabsProps.js +3 -0
- package/nuxt/components/tagProps.js +3 -0
- package/nuxt/components/textareaProps.js +3 -0
- package/nuxt/components/timeAxisProps.js +3 -0
- package/nuxt/components/timerPickerPanelProps.js +3 -0
- package/nuxt/components/tooltipProps.js +3 -0
- package/nuxt/components/treeProps.js +3 -0
- package/nuxt/components/uploadProps.js +3 -0
- package/nuxt/index.js +13 -0
- package/overlay/index.d.ts +7 -0
- package/overlay/index.es.js +293 -0
- package/overlay/index.umd.js +1 -0
- package/overlay/package.json +7 -0
- package/overlay/style.css +1 -0
- package/package.json +17 -77
- package/pagination/index.d.ts +7 -0
- package/pagination/index.es.js +820 -0
- package/pagination/index.umd.js +1 -0
- package/pagination/package.json +7 -0
- package/pagination/style.css +1 -0
- package/panel/index.d.ts +7 -0
- package/panel/index.es.js +218 -0
- package/panel/index.umd.js +1 -0
- package/panel/package.json +7 -0
- package/panel/style.css +1 -0
- package/popover/index.d.ts +7 -0
- package/popover/index.es.js +6062 -0
- package/popover/index.umd.js +27 -0
- package/popover/package.json +7 -0
- package/popover/style.css +1 -0
- package/progress/index.d.ts +7 -0
- package/progress/index.es.js +207 -0
- package/progress/index.umd.js +3 -0
- package/progress/package.json +7 -0
- package/progress/style.css +1 -0
- package/radio/index.d.ts +7 -0
- package/radio/index.es.js +8056 -0
- package/radio/index.umd.js +38 -0
- package/radio/package.json +7 -0
- package/radio/style.css +1 -0
- package/rate/index.d.ts +7 -0
- package/rate/index.es.js +242 -0
- package/rate/index.umd.js +1 -0
- package/rate/package.json +7 -0
- package/rate/style.css +1 -0
- package/result/index.d.ts +7 -0
- package/result/index.es.js +248 -0
- package/result/index.umd.js +1 -0
- package/result/package.json +7 -0
- package/result/style.css +1 -0
- package/ripple/index.d.ts +7 -0
- package/ripple/index.es.js +173 -0
- package/ripple/index.umd.js +1 -0
- package/ripple/package.json +7 -0
- package/search/index.d.ts +7 -0
- package/search/index.es.js +8512 -0
- package/search/index.umd.js +38 -0
- package/search/package.json +7 -0
- package/search/style.css +1 -0
- package/select/index.d.ts +7 -0
- package/select/index.es.js +9423 -0
- package/select/index.umd.js +38 -0
- package/select/package.json +7 -0
- package/select/style.css +1 -0
- package/skeleton/index.d.ts +7 -0
- package/skeleton/index.es.js +145 -0
- package/skeleton/index.umd.js +1 -0
- package/skeleton/package.json +7 -0
- package/skeleton/style.css +1 -0
- package/slider/index.d.ts +7 -0
- package/slider/index.es.js +203 -0
- package/slider/index.umd.js +1 -0
- package/slider/package.json +7 -0
- package/slider/style.css +1 -0
- package/splitter/index.d.ts +7 -0
- package/splitter/index.es.js +6754 -0
- package/splitter/index.umd.js +27 -0
- package/splitter/package.json +7 -0
- package/splitter/style.css +1 -0
- package/statistic/index.d.ts +7 -0
- package/statistic/index.es.js +253 -0
- package/statistic/index.umd.js +1 -0
- package/statistic/package.json +7 -0
- package/statistic/style.css +1 -0
- package/status/index.d.ts +7 -0
- package/status/index.es.js +63 -0
- package/status/index.umd.js +1 -0
- package/status/package.json +7 -0
- package/status/style.css +1 -0
- package/steps/index.d.ts +7 -0
- package/steps/index.es.js +386 -0
- package/steps/index.umd.js +1 -0
- package/steps/package.json +7 -0
- package/steps/style.css +1 -0
- package/style.css +1 -1
- package/switch/index.d.ts +7 -0
- package/switch/index.es.js +7852 -0
- package/switch/index.umd.js +38 -0
- package/switch/package.json +7 -0
- package/switch/style.css +1 -0
- package/table/index.d.ts +7 -0
- package/table/index.es.js +11527 -0
- package/table/index.umd.js +38 -0
- package/table/package.json +7 -0
- package/table/style.css +1 -0
- package/tabs/index.d.ts +7 -0
- package/tabs/index.es.js +407 -0
- package/tabs/index.umd.js +1 -0
- package/tabs/package.json +7 -0
- package/tabs/style.css +1 -0
- package/tag/index.d.ts +7 -0
- package/tag/index.es.js +156 -0
- package/tag/index.umd.js +1 -0
- package/tag/package.json +7 -0
- package/tag/style.css +1 -0
- package/textarea/index.d.ts +7 -0
- package/textarea/index.es.js +7986 -0
- package/textarea/index.umd.js +46 -0
- package/textarea/package.json +7 -0
- package/textarea/style.css +1 -0
- package/theme/theme.scss +121 -0
- package/time-picker/index.d.ts +7 -0
- package/time-picker/index.es.js +9556 -0
- package/time-picker/index.umd.js +38 -0
- package/time-picker/package.json +7 -0
- package/time-picker/style.css +1 -0
- package/time-select/index.d.ts +7 -0
- package/time-select/index.es.js +9604 -0
- package/time-select/index.umd.js +38 -0
- package/time-select/package.json +7 -0
- package/time-select/style.css +1 -0
- package/timeline/index.d.ts +7 -0
- package/timeline/index.es.js +427 -0
- package/timeline/index.umd.js +1 -0
- package/timeline/package.json +7 -0
- package/timeline/style.css +1 -0
- package/tooltip/index.d.ts +7 -0
- package/tooltip/index.es.js +5900 -0
- package/tooltip/index.umd.js +27 -0
- package/tooltip/package.json +7 -0
- package/tooltip/style.css +1 -0
- package/tree/index.d.ts +7 -0
- package/tree/index.es.js +10336 -0
- package/tree/index.umd.js +38 -0
- package/tree/package.json +7 -0
- package/tree/style.css +1 -0
- package/upload/index.d.ts +7 -0
- package/upload/index.es.js +1398 -0
- package/upload/index.umd.js +1 -0
- package/upload/package.json +7 -0
- package/upload/style.css +1 -0
- package/vue-devui.es.js +27451 -1
- package/vue-devui.umd.js +50 -1
- package/favicon.ico +0 -0
- package/logo.svg +0 -30
|
@@ -0,0 +1,511 @@
|
|
|
1
|
+
import { defineComponent, ref, computed, onMounted, onUnmounted, createVNode, Fragment, createTextVNode, createApp } from "vue";
|
|
2
|
+
const imagePreviewProps = {
|
|
3
|
+
url: {
|
|
4
|
+
type: String,
|
|
5
|
+
default: "",
|
|
6
|
+
required: true
|
|
7
|
+
},
|
|
8
|
+
previewUrlList: {
|
|
9
|
+
type: Array,
|
|
10
|
+
default: () => [],
|
|
11
|
+
required: true
|
|
12
|
+
},
|
|
13
|
+
zIndex: {
|
|
14
|
+
type: Number,
|
|
15
|
+
required: false
|
|
16
|
+
},
|
|
17
|
+
backDropZIndex: {
|
|
18
|
+
type: Number,
|
|
19
|
+
required: false
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
class Transform {
|
|
23
|
+
constructor(el, options = {}) {
|
|
24
|
+
this.oTransformX = 0;
|
|
25
|
+
this.oTransformY = 0;
|
|
26
|
+
this.STEP = 0.25;
|
|
27
|
+
this.MIN_SCALE = 0.2;
|
|
28
|
+
this.MAX_SCALE = 2.5;
|
|
29
|
+
this.TRANSFORMX = 0;
|
|
30
|
+
this.TRANSFORMY = 0;
|
|
31
|
+
this.ZOOM = 1;
|
|
32
|
+
this.ROTATE = 0;
|
|
33
|
+
this.el = el;
|
|
34
|
+
this.transformX = options.transformX || this.TRANSFORMX;
|
|
35
|
+
this.transformY = options.transformY || this.TRANSFORMY;
|
|
36
|
+
this.zoom = options.zoom || this.ZOOM;
|
|
37
|
+
this.rotate = options.rotate || this.ROTATE;
|
|
38
|
+
this.handleDefaultDraggable();
|
|
39
|
+
this.onDraggable();
|
|
40
|
+
this.onMouseWheel();
|
|
41
|
+
}
|
|
42
|
+
handleDefaultDraggable() {
|
|
43
|
+
document.body.ondragstart = () => {
|
|
44
|
+
window.event.returnValue = false;
|
|
45
|
+
return false;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
onDraggable() {
|
|
49
|
+
this.el.onmousedown = (e) => {
|
|
50
|
+
const ox = e.clientX;
|
|
51
|
+
const oy = e.clientY;
|
|
52
|
+
document.onmousemove = (e1) => {
|
|
53
|
+
const disX = e1.clientX - ox;
|
|
54
|
+
const disY = e1.clientY - oy;
|
|
55
|
+
this.transformX = this.oTransformX + disX;
|
|
56
|
+
this.transformY = this.oTransformY + disY;
|
|
57
|
+
this.el.style.cursor = "grabbing";
|
|
58
|
+
this.setPosition();
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
document.onmouseup = () => {
|
|
62
|
+
document.onmousemove = null;
|
|
63
|
+
this.oTransformX = this.transformX;
|
|
64
|
+
this.oTransformY = this.transformY;
|
|
65
|
+
this.el.style.cursor = "grab";
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
onMouseWheel() {
|
|
69
|
+
const handleWheel = this.throttle(this.setMouseWheel, 100);
|
|
70
|
+
this.el.onmousewheel = (e) => {
|
|
71
|
+
const value = -e.wheelDelta || e.deltaY || e.detail;
|
|
72
|
+
handleWheel(value);
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
throttle(fn, t) {
|
|
76
|
+
let timer = null;
|
|
77
|
+
return (...args) => {
|
|
78
|
+
if (!timer) {
|
|
79
|
+
setTimeout(() => {
|
|
80
|
+
timer = null;
|
|
81
|
+
fn.apply(this, args);
|
|
82
|
+
}, t);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
setMouseWheel(value) {
|
|
87
|
+
if (value < 0) {
|
|
88
|
+
if (this.zoom >= this.MAX_SCALE) {
|
|
89
|
+
this.el.style.cursor = "not-allowed";
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
this.el.style.cursor = "zoom-in";
|
|
93
|
+
this.setZoomIn(this.STEP);
|
|
94
|
+
} else {
|
|
95
|
+
if (this.zoom <= this.MIN_SCALE) {
|
|
96
|
+
this.el.style.cursor = "not-allowed";
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
this.el.style.cursor = "zoom-out";
|
|
100
|
+
this.setZoomOut(this.STEP);
|
|
101
|
+
}
|
|
102
|
+
this.setPosition();
|
|
103
|
+
}
|
|
104
|
+
setZoomIn(step = this.STEP) {
|
|
105
|
+
this.zoom = Math.min(this.MAX_SCALE, this.zoom + step);
|
|
106
|
+
this.setPosition();
|
|
107
|
+
}
|
|
108
|
+
setZoomOut(step = this.STEP) {
|
|
109
|
+
this.zoom = Math.max(this.MIN_SCALE, this.zoom - step);
|
|
110
|
+
this.setPosition();
|
|
111
|
+
}
|
|
112
|
+
setZoomBest() {
|
|
113
|
+
this.reset();
|
|
114
|
+
this.setPosition();
|
|
115
|
+
}
|
|
116
|
+
setZoomOriginal() {
|
|
117
|
+
this.reset();
|
|
118
|
+
this.setPosition();
|
|
119
|
+
}
|
|
120
|
+
setRotate() {
|
|
121
|
+
this.rotate += 0.25;
|
|
122
|
+
this.setPosition();
|
|
123
|
+
}
|
|
124
|
+
reset() {
|
|
125
|
+
this.transformX = this.TRANSFORMX;
|
|
126
|
+
this.transformY = this.TRANSFORMY;
|
|
127
|
+
this.zoom = this.ZOOM;
|
|
128
|
+
}
|
|
129
|
+
setPosition() {
|
|
130
|
+
this.el.style.transform = `translate(${this.transformX}px, ${this.transformY}px) scale(${this.zoom}) rotate(${this.rotate}turn)`;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function createBem(namespace, element, modifier) {
|
|
134
|
+
let cls = namespace;
|
|
135
|
+
if (element) {
|
|
136
|
+
cls += `__${element}`;
|
|
137
|
+
}
|
|
138
|
+
if (modifier) {
|
|
139
|
+
cls += `--${modifier}`;
|
|
140
|
+
}
|
|
141
|
+
return cls;
|
|
142
|
+
}
|
|
143
|
+
function useNamespace(block, needDot = false) {
|
|
144
|
+
const namespace = needDot ? `.devui-${block}` : `devui-${block}`;
|
|
145
|
+
const b = () => createBem(namespace);
|
|
146
|
+
const e = (element) => element ? createBem(namespace, element) : "";
|
|
147
|
+
const m = (modifier) => modifier ? createBem(namespace, "", modifier) : "";
|
|
148
|
+
const em = (element, modifier) => element && modifier ? createBem(namespace, element, modifier) : "";
|
|
149
|
+
return {
|
|
150
|
+
b,
|
|
151
|
+
e,
|
|
152
|
+
m,
|
|
153
|
+
em
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
var imagePreview$1 = "";
|
|
157
|
+
var imagePreview = defineComponent({
|
|
158
|
+
name: "DImagePreview",
|
|
159
|
+
props: imagePreviewProps,
|
|
160
|
+
emits: [],
|
|
161
|
+
setup(props) {
|
|
162
|
+
const ns = useNamespace("image-preview");
|
|
163
|
+
let transform = null;
|
|
164
|
+
const index2 = ref(0);
|
|
165
|
+
const url = computed(() => props.previewUrlList[index2.value]);
|
|
166
|
+
const imageStyle = props.zIndex ? {
|
|
167
|
+
zIndex: props.zIndex
|
|
168
|
+
} : {};
|
|
169
|
+
const bgStyle = props.backDropZIndex ? {
|
|
170
|
+
zIndex: props.backDropZIndex
|
|
171
|
+
} : {};
|
|
172
|
+
function initTransform() {
|
|
173
|
+
const imageElement = document.querySelector(`.${ns.e("main-image")}`);
|
|
174
|
+
transform = new Transform(imageElement);
|
|
175
|
+
}
|
|
176
|
+
function initIndex() {
|
|
177
|
+
index2.value = props.previewUrlList.findIndex((curUrl) => curUrl === props.url);
|
|
178
|
+
}
|
|
179
|
+
function onPrev() {
|
|
180
|
+
index2.value = index2.value <= 0 ? props.previewUrlList.length - 1 : index2.value - 1;
|
|
181
|
+
}
|
|
182
|
+
function onNext() {
|
|
183
|
+
index2.value = index2.value >= props.previewUrlList.length - 1 ? 0 : index2.value + 1;
|
|
184
|
+
}
|
|
185
|
+
function onClose() {
|
|
186
|
+
ImagePreviewService.close();
|
|
187
|
+
}
|
|
188
|
+
function onZoomIn() {
|
|
189
|
+
transform.setZoomIn();
|
|
190
|
+
}
|
|
191
|
+
function onZoomOut() {
|
|
192
|
+
transform.setZoomOut();
|
|
193
|
+
}
|
|
194
|
+
function onRotate() {
|
|
195
|
+
transform.setRotate();
|
|
196
|
+
}
|
|
197
|
+
function onZoomBest() {
|
|
198
|
+
transform.setZoomBest();
|
|
199
|
+
}
|
|
200
|
+
function onZoomOriginal() {
|
|
201
|
+
transform.setZoomOriginal();
|
|
202
|
+
}
|
|
203
|
+
function onKeyDown(event) {
|
|
204
|
+
if (event.defaultPrevented) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (event.code === "Escape") {
|
|
208
|
+
onClose();
|
|
209
|
+
} else if (event.code === "ArrowLeft") {
|
|
210
|
+
onPrev();
|
|
211
|
+
} else if (event.code === "ArrowRight") {
|
|
212
|
+
onNext();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function initKeyboard() {
|
|
216
|
+
document.addEventListener("keydown", onKeyDown, false);
|
|
217
|
+
}
|
|
218
|
+
function unKeyBoard() {
|
|
219
|
+
document.removeEventListener("keydown", onKeyDown, false);
|
|
220
|
+
}
|
|
221
|
+
onMounted(() => {
|
|
222
|
+
initIndex();
|
|
223
|
+
initTransform();
|
|
224
|
+
initKeyboard();
|
|
225
|
+
});
|
|
226
|
+
onUnmounted(() => {
|
|
227
|
+
unKeyBoard();
|
|
228
|
+
});
|
|
229
|
+
return () => {
|
|
230
|
+
return createVNode(Fragment, null, [createVNode("div", {
|
|
231
|
+
"class": ns.b(),
|
|
232
|
+
"style": imageStyle
|
|
233
|
+
}, [createVNode("img", {
|
|
234
|
+
"class": ns.e("main-image"),
|
|
235
|
+
"src": url.value
|
|
236
|
+
}, null), createVNode("button", {
|
|
237
|
+
"class": ns.e("close-btn"),
|
|
238
|
+
"onClick": onClose
|
|
239
|
+
}, [createVNode("svg", {
|
|
240
|
+
"width": "16px",
|
|
241
|
+
"height": "16px",
|
|
242
|
+
"viewBox": "0 0 16 16",
|
|
243
|
+
"version": "1.1"
|
|
244
|
+
}, [createVNode("g", {
|
|
245
|
+
"stroke": "none",
|
|
246
|
+
"stroke-width": "1",
|
|
247
|
+
"fill": "none",
|
|
248
|
+
"fill-rule": "evenodd"
|
|
249
|
+
}, [createVNode("polygon", {
|
|
250
|
+
"fill": "#293040",
|
|
251
|
+
"fill-rule": "nonzero",
|
|
252
|
+
"points": "8 6.58578644 12.2426407 2.34314575 13.6568542 3.75735931 9.41421356 8 13.6568542 12.2426407 12.2426407 13.6568542 8 9.41421356 3.75735931 13.6568542 2.34314575 12.2426407 6.58578644 8 2.34314575 3.75735931 3.75735931 2.34314575"
|
|
253
|
+
}, null)])])]), createVNode("button", {
|
|
254
|
+
"class": ns.e("arrow-left"),
|
|
255
|
+
"onClick": onPrev
|
|
256
|
+
}, [createVNode("svg", {
|
|
257
|
+
"width": "18px",
|
|
258
|
+
"height": "18px",
|
|
259
|
+
"viewBox": "0 0 16 16",
|
|
260
|
+
"version": "1.1"
|
|
261
|
+
}, [createVNode("g", {
|
|
262
|
+
"stroke": "none",
|
|
263
|
+
"stroke-width": "1",
|
|
264
|
+
"fill": "none",
|
|
265
|
+
"fill-rule": "evenodd"
|
|
266
|
+
}, [createVNode("polygon", {
|
|
267
|
+
"fill": "#293040",
|
|
268
|
+
"fill-rule": "nonzero",
|
|
269
|
+
"points": "10.7071068 12.2928932 9.29289322 13.7071068 3.58578644 8 9.29289322 2.29289322 10.7071068 3.70710678 6.41421356 8"
|
|
270
|
+
}, null)])])]), createVNode("button", {
|
|
271
|
+
"class": ns.e("arrow-right"),
|
|
272
|
+
"onClick": onNext
|
|
273
|
+
}, [createVNode("svg", {
|
|
274
|
+
"width": "18px",
|
|
275
|
+
"height": "18px",
|
|
276
|
+
"viewBox": "0 0 16 16",
|
|
277
|
+
"version": "1.1"
|
|
278
|
+
}, [createVNode("g", {
|
|
279
|
+
"stroke": "none",
|
|
280
|
+
"stroke-width": "1",
|
|
281
|
+
"fill": "none",
|
|
282
|
+
"fill-rule": "evenodd"
|
|
283
|
+
}, [createVNode("polygon", {
|
|
284
|
+
"fill": "#293040",
|
|
285
|
+
"fill-rule": "nonzero",
|
|
286
|
+
"transform": "translate(8.146447, 8.000000) scale(-1, 1) translate(-8.146447, -8.000000) ",
|
|
287
|
+
"points": "11.7071068 12.2928932 10.2928932 13.7071068 4.58578644 8 10.2928932 2.29289322 11.7071068 3.70710678 7.41421356 8"
|
|
288
|
+
}, null)])])]), createVNode("div", {
|
|
289
|
+
"class": ns.e("toolbar")
|
|
290
|
+
}, [createVNode("button", {
|
|
291
|
+
"onClick": onZoomIn
|
|
292
|
+
}, [createVNode("svg", {
|
|
293
|
+
"width": "18px",
|
|
294
|
+
"height": "18px",
|
|
295
|
+
"viewBox": "0 0 16 16"
|
|
296
|
+
}, [createVNode("g", {
|
|
297
|
+
"stroke": "none",
|
|
298
|
+
"stroke-width": "1",
|
|
299
|
+
"fill": "none",
|
|
300
|
+
"fill-rule": "evenodd"
|
|
301
|
+
}, [createVNode("g", {
|
|
302
|
+
"fill": "#293040",
|
|
303
|
+
"fill-rule": "nonzero"
|
|
304
|
+
}, [createVNode("path", {
|
|
305
|
+
"d": "M6,6 L6,4 L8,4 L8,6 L10,6 L10,8 L8,8 L8,10 L6,10 L6,8 L4,8 L4,6 L6,6 Z M12.6063847,11.1921711 L15.6568542,14.2426407 L14.2426407,15.6568542 L11.1921711,12.6063847 C10.0235906,13.4815965 8.5723351,14 7,14 C3.13400675,14 0,10.8659932 0,7 C0,3.13400675 3.13400675,0 7,0 C10.8659932,0 14,3.13400675 14,7 C14,8.5723351 13.4815965,10.0235906 12.6063847,11.1921711 L12.6063847,11.1921711 Z M7,12 C9.76142375,12 12,9.76142375 12,7 C12,4.23857625 9.76142375,2 7,2 C4.23857625,2 2,4.23857625 2,7 C2,9.76142375 4.23857625,12 7,12 Z"
|
|
306
|
+
}, null)])])])]), createVNode("button", {
|
|
307
|
+
"onClick": onZoomOut
|
|
308
|
+
}, [createVNode("svg", {
|
|
309
|
+
"width": "18px",
|
|
310
|
+
"height": "18px",
|
|
311
|
+
"viewBox": "0 0 16 16"
|
|
312
|
+
}, [createVNode("g", {
|
|
313
|
+
"stroke": "none",
|
|
314
|
+
"stroke-width": "1",
|
|
315
|
+
"fill": "none",
|
|
316
|
+
"fill-rule": "evenodd"
|
|
317
|
+
}, [createVNode("g", {
|
|
318
|
+
"fill": "#293040",
|
|
319
|
+
"fill-rule": "nonzero"
|
|
320
|
+
}, [createVNode("path", {
|
|
321
|
+
"d": "M12.6063847,11.1921711 L15.6568542,14.2426407 L14.2426407,15.6568542 L11.1921711,12.6063847 C10.0235906,13.4815965 8.5723351,14 7,14 C3.13400675,14 0,10.8659932 0,7 C0,3.13400675 3.13400675,0 7,0 C10.8659932,0 14,3.13400675 14,7 C14,8.5723351 13.4815965,10.0235906 12.6063847,11.1921711 L12.6063847,11.1921711 Z M7,12 C9.76142375,12 12,9.76142375 12,7 C12,4.23857625 9.76142375,2 7,2 C4.23857625,2 2,4.23857625 2,7 C2,9.76142375 4.23857625,12 7,12 Z M4,6 L10,6 L10,8 L4,8 L4,6 Z"
|
|
322
|
+
}, null)])])])]), createVNode("button", {
|
|
323
|
+
"onClick": onRotate
|
|
324
|
+
}, [createVNode("svg", {
|
|
325
|
+
"width": "18px",
|
|
326
|
+
"height": "18px",
|
|
327
|
+
"viewBox": "0 0 16 16",
|
|
328
|
+
"version": "1.1"
|
|
329
|
+
}, [createVNode("g", {
|
|
330
|
+
"stroke": "none",
|
|
331
|
+
"stroke-width": "1",
|
|
332
|
+
"fill": "none",
|
|
333
|
+
"fill-rule": "evenodd"
|
|
334
|
+
}, [createVNode("path", {
|
|
335
|
+
"d": "M7.5,3.02242151 L7.5,4 L4.5,2 L7.5,0 L7.5,1.01640228 C7.66526181,1.00552468 7.83198572,1 8,1 C12.1421356,1 15.5,4.35786438 15.5,8.5 C15.5,12.6421356 12.1421356,16 8,16 C3.85786438,16 0.5,12.6421356 0.5,8.5 C0.5,6.9828355 0.950484514,5.5708873 1.72499011,4.39061882 L3.42173231,5.4510827 C2.83944149,6.32371289 2.5,7.37221604 2.5,8.5 C2.5,11.5375661 4.96243388,14 8,14 C11.0375661,14 13.5,11.5375661 13.5,8.5 C13.5,5.46243388 11.0375661,3 8,3 C7.83145515,3 7.66468102,3.00758131 7.5,3.02242151 Z M8,11 C6.61928813,11 5.5,9.88071187 5.5,8.5 C5.5,7.11928813 6.61928813,6 8,6 C9.38071187,6 10.5,7.11928813 10.5,8.5 C10.5,9.88071187 9.38071187,11 8,11 Z M8,10 C8.82842712,10 9.5,9.32842712 9.5,8.5 C9.5,7.67157288 8.82842712,7 8,7 C7.17157288,7 6.5,7.67157288 6.5,8.5 C6.5,9.32842712 7.17157288,10 8,10 Z",
|
|
336
|
+
"fill": "#293040"
|
|
337
|
+
}, null)])])]), createVNode("button", {
|
|
338
|
+
"onClick": onPrev
|
|
339
|
+
}, [createVNode("svg", {
|
|
340
|
+
"width": "16px",
|
|
341
|
+
"height": "16px",
|
|
342
|
+
"viewBox": "0 0 16 16",
|
|
343
|
+
"version": "1.1"
|
|
344
|
+
}, [createVNode("g", {
|
|
345
|
+
"stroke": "none",
|
|
346
|
+
"stroke-width": "1",
|
|
347
|
+
"fill": "none",
|
|
348
|
+
"fill-rule": "evenodd"
|
|
349
|
+
}, [createVNode("polygon", {
|
|
350
|
+
"fill": "#293040",
|
|
351
|
+
"fill-rule": "nonzero",
|
|
352
|
+
"points": "10.7071068 12.2928932 9.29289322 13.7071068 3.58578644 8 9.29289322 2.29289322 10.7071068 3.70710678 6.41421356 8"
|
|
353
|
+
}, null)])])]), createVNode("span", {
|
|
354
|
+
"class": ns.e("index")
|
|
355
|
+
}, [index2.value + 1, createTextVNode(":"), props.previewUrlList.length]), createVNode("button", {
|
|
356
|
+
"onClick": onNext
|
|
357
|
+
}, [createVNode("svg", {
|
|
358
|
+
"width": "16px",
|
|
359
|
+
"height": "16px",
|
|
360
|
+
"viewBox": "0 0 16 16",
|
|
361
|
+
"version": "1.1"
|
|
362
|
+
}, [createVNode("g", {
|
|
363
|
+
"stroke": "none",
|
|
364
|
+
"stroke-width": "1",
|
|
365
|
+
"fill": "none",
|
|
366
|
+
"fill-rule": "evenodd"
|
|
367
|
+
}, [createVNode("polygon", {
|
|
368
|
+
"fill": "#293040",
|
|
369
|
+
"fill-rule": "nonzero",
|
|
370
|
+
"transform": "translate(8.146447, 8.000000) scale(-1, 1) translate(-8.146447, -8.000000) ",
|
|
371
|
+
"points": "11.7071068 12.2928932 10.2928932 13.7071068 4.58578644 8 10.2928932 2.29289322 11.7071068 3.70710678 7.41421356 8"
|
|
372
|
+
}, null)])])]), createVNode("button", {
|
|
373
|
+
"onClick": onZoomBest
|
|
374
|
+
}, [createVNode("svg", {
|
|
375
|
+
"width": "18px",
|
|
376
|
+
"height": "18px",
|
|
377
|
+
"viewBox": "0 0 16 16"
|
|
378
|
+
}, [createVNode("g", {
|
|
379
|
+
"stroke": "none",
|
|
380
|
+
"stroke-width": "1",
|
|
381
|
+
"fill": "none",
|
|
382
|
+
"fill-rule": "evenodd"
|
|
383
|
+
}, [createVNode("path", {
|
|
384
|
+
"d": "M16,16 L11.429,16 L11.429,15 L14.456,15 L11.006,11.226 L11.652,10.519 L15.086,14.275 L15.086,11 L16,11 L16,16 Z M15.164,1.544 L12.009,4.994 L11.418,4.348 L14.558,0.914 L11.82,0.914 L11.82,0 L16,0 L16,4.571 L15.164,4.571 L15.164,1.544 Z M5,15 L5,16 L0,16 L0,11 L1,11 L1,14.275 L4.756,10.519 L5.463,11.226 L1.689,15 L5,15 Z M4.365,4.994 L0.914,1.544 L0.914,4.571 L3.41060513e-13,4.571 L3.41060513e-13,0 L4.571,0 L4.571,0.914 L1.578,0.914 L5.011,4.348 L4.365,4.994 Z",
|
|
385
|
+
"fill": "#293040",
|
|
386
|
+
"fill-rule": "nonzero"
|
|
387
|
+
}, null)])])]), createVNode("button", {
|
|
388
|
+
"onClick": onZoomOriginal
|
|
389
|
+
}, [createVNode("span", null, [createTextVNode("1:1")])])])]), createVNode("div", {
|
|
390
|
+
"class": ns.e("bg"),
|
|
391
|
+
"style": bgStyle
|
|
392
|
+
}, null)]);
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
function createComponent(props) {
|
|
397
|
+
return createApp(imagePreview, props);
|
|
398
|
+
}
|
|
399
|
+
class ImagePreviewService {
|
|
400
|
+
static open(props) {
|
|
401
|
+
this.$body = document.body;
|
|
402
|
+
this.$div = document.createElement("div");
|
|
403
|
+
this.$overflow = this.$body.style.overflow;
|
|
404
|
+
this.$body.appendChild(this.$div);
|
|
405
|
+
createComponent(props).mount(this.$div);
|
|
406
|
+
this.$body.style.setProperty("overflow", "hidden", "important");
|
|
407
|
+
}
|
|
408
|
+
static close() {
|
|
409
|
+
var _a;
|
|
410
|
+
(_a = this.$body) == null ? void 0 : _a.style.setProperty("overflow", this.$overflow);
|
|
411
|
+
this.$overflow = null;
|
|
412
|
+
this.$div && this.$body.removeChild(this.$div);
|
|
413
|
+
this.$body = null;
|
|
414
|
+
this.$div = null;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
ImagePreviewService.$body = null;
|
|
418
|
+
ImagePreviewService.$div = null;
|
|
419
|
+
ImagePreviewService.$overflow = "";
|
|
420
|
+
function mountedPreviewImages(props) {
|
|
421
|
+
ImagePreviewService.open({
|
|
422
|
+
url: props.url,
|
|
423
|
+
previewUrlList: props.previewUrlList,
|
|
424
|
+
zIndex: props.zIndex,
|
|
425
|
+
backDropZIndex: props.backDropZIndex
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
function unmountedPreviewImages() {
|
|
429
|
+
ImagePreviewService.close();
|
|
430
|
+
}
|
|
431
|
+
function getImgByEl(el) {
|
|
432
|
+
const urlList = [...el.querySelectorAll("img")].map((item) => item.getAttribute("src"));
|
|
433
|
+
return urlList;
|
|
434
|
+
}
|
|
435
|
+
function handleImg(e) {
|
|
436
|
+
var _a;
|
|
437
|
+
e.stopPropagation();
|
|
438
|
+
const el = e.currentTarget;
|
|
439
|
+
const target = e.target;
|
|
440
|
+
if (((_a = target == null ? void 0 : target.nodeName) == null ? void 0 : _a.toLowerCase()) === "img") {
|
|
441
|
+
const urlList = getImgByEl(el);
|
|
442
|
+
const url = target.getAttribute("src");
|
|
443
|
+
mountedPreviewImages({
|
|
444
|
+
url,
|
|
445
|
+
previewUrlList: urlList,
|
|
446
|
+
zIndex: el == null ? void 0 : el.zIndex,
|
|
447
|
+
backDropZIndex: el == null ? void 0 : el.backDropZIndex
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
function handleImgByEl(el) {
|
|
452
|
+
el.addEventListener("click", handleImg);
|
|
453
|
+
}
|
|
454
|
+
function removeHandle(el) {
|
|
455
|
+
el.removeEventListener("click", handleImg);
|
|
456
|
+
}
|
|
457
|
+
var ImagePreviewDirective = {
|
|
458
|
+
mounted(el, binding) {
|
|
459
|
+
if (!binding.value) {
|
|
460
|
+
return handleImgByEl(el);
|
|
461
|
+
}
|
|
462
|
+
const { custom, disableDefault } = binding.value;
|
|
463
|
+
if (custom instanceof Object) {
|
|
464
|
+
custom.open = () => {
|
|
465
|
+
const urlList = getImgByEl(el);
|
|
466
|
+
mountedPreviewImages({
|
|
467
|
+
url: urlList == null ? void 0 : urlList[0],
|
|
468
|
+
previewUrlList: urlList,
|
|
469
|
+
zIndex: el == null ? void 0 : el.zIndex,
|
|
470
|
+
backDropZIndex: el == null ? void 0 : el.backDropZIndex
|
|
471
|
+
});
|
|
472
|
+
};
|
|
473
|
+
custom.close = () => unmountedPreviewImages();
|
|
474
|
+
}
|
|
475
|
+
if (disableDefault) {
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
handleImgByEl(el);
|
|
479
|
+
},
|
|
480
|
+
unmounted() {
|
|
481
|
+
unmountedPreviewImages();
|
|
482
|
+
},
|
|
483
|
+
updated(el, binding) {
|
|
484
|
+
var _a, _b;
|
|
485
|
+
el.zIndex = (_a = binding.value) == null ? void 0 : _a.zIndex;
|
|
486
|
+
el.backDropZIndex = (_b = binding.value) == null ? void 0 : _b.backDropZIndex;
|
|
487
|
+
if (binding.value) {
|
|
488
|
+
const {
|
|
489
|
+
value: { disableDefault },
|
|
490
|
+
oldValue: { disableDefault: oldDisableDefault }
|
|
491
|
+
} = binding;
|
|
492
|
+
if (disableDefault !== oldDisableDefault) {
|
|
493
|
+
if (disableDefault) {
|
|
494
|
+
removeHandle(el);
|
|
495
|
+
} else {
|
|
496
|
+
handleImgByEl(el);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
var index = {
|
|
503
|
+
title: "ImagePreview \u56FE\u7247\u9884\u89C8",
|
|
504
|
+
category: "\u6570\u636E\u5C55\u793A",
|
|
505
|
+
status: "100%",
|
|
506
|
+
install(app) {
|
|
507
|
+
app.directive("d-image-preview", ImagePreviewDirective);
|
|
508
|
+
app.config.globalProperties.$imagePreviewService = ImagePreviewService;
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
export { ImagePreviewDirective, ImagePreviewService, index as default, imagePreviewProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(s,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(s=typeof globalThis!="undefined"?globalThis:s||self,e(s.index={},s.Vue))})(this,function(s,e){"use strict";const w={url:{type:String,default:"",required:!0},previewUrlList:{type:Array,default:()=>[],required:!0},zIndex:{type:Number,required:!1},backDropZIndex:{type:Number,required:!1}};class V{constructor(o,n={}){this.oTransformX=0,this.oTransformY=0,this.STEP=.25,this.MIN_SCALE=.2,this.MAX_SCALE=2.5,this.TRANSFORMX=0,this.TRANSFORMY=0,this.ZOOM=1,this.ROTATE=0,this.el=o,this.transformX=n.transformX||this.TRANSFORMX,this.transformY=n.transformY||this.TRANSFORMY,this.zoom=n.zoom||this.ZOOM,this.rotate=n.rotate||this.ROTATE,this.handleDefaultDraggable(),this.onDraggable(),this.onMouseWheel()}handleDefaultDraggable(){document.body.ondragstart=()=>(window.event.returnValue=!1,!1)}onDraggable(){this.el.onmousedown=o=>{const n=o.clientX,i=o.clientY;document.onmousemove=r=>{const d=r.clientX-n,u=r.clientY-i;this.transformX=this.oTransformX+d,this.transformY=this.oTransformY+u,this.el.style.cursor="grabbing",this.setPosition()}},document.onmouseup=()=>{document.onmousemove=null,this.oTransformX=this.transformX,this.oTransformY=this.transformY,this.el.style.cursor="grab"}}onMouseWheel(){const o=this.throttle(this.setMouseWheel,100);this.el.onmousewheel=n=>{const i=-n.wheelDelta||n.deltaY||n.detail;o(i)}}throttle(o,n){let i=null;return(...r)=>{i||setTimeout(()=>{i=null,o.apply(this,r)},n)}}setMouseWheel(o){if(o<0){if(this.zoom>=this.MAX_SCALE){this.el.style.cursor="not-allowed";return}this.el.style.cursor="zoom-in",this.setZoomIn(this.STEP)}else{if(this.zoom<=this.MIN_SCALE){this.el.style.cursor="not-allowed";return}this.el.style.cursor="zoom-out",this.setZoomOut(this.STEP)}this.setPosition()}setZoomIn(o=this.STEP){this.zoom=Math.min(this.MAX_SCALE,this.zoom+o),this.setPosition()}setZoomOut(o=this.STEP){this.zoom=Math.max(this.MIN_SCALE,this.zoom-o),this.setPosition()}setZoomBest(){this.reset(),this.setPosition()}setZoomOriginal(){this.reset(),this.setPosition()}setRotate(){this.rotate+=.25,this.setPosition()}reset(){this.transformX=this.TRANSFORMX,this.transformY=this.TRANSFORMY,this.zoom=this.ZOOM}setPosition(){this.el.style.transform=`translate(${this.transformX}px, ${this.transformY}px) scale(${this.zoom}) rotate(${this.rotate}turn)`}}function h(t,o,n){let i=t;return o&&(i+=`__${o}`),n&&(i+=`--${n}`),i}function I(t,o=!1){const n=o?`.devui-${t}`:`devui-${t}`;return{b:()=>h(n),e:l=>l?h(n,l):"",m:l=>l?h(n,"",l):"",em:(l,f)=>l&&f?h(n,l,f):""}}var O="",k=e.defineComponent({name:"DImagePreview",props:w,emits:[],setup(t){const o=I("image-preview");let n=null;const i=e.ref(0),r=e.computed(()=>t.previewUrlList[i.value]),d=t.zIndex?{zIndex:t.zIndex}:{},u=t.backDropZIndex?{zIndex:t.backDropZIndex}:{};function l(){const c=document.querySelector(`.${o.e("main-image")}`);n=new V(c)}function f(){i.value=t.previewUrlList.findIndex(c=>c===t.url)}function L(){i.value=i.value<=0?t.previewUrlList.length-1:i.value-1}function g(){i.value=i.value>=t.previewUrlList.length-1?0:i.value+1}function b(){a.close()}function z(){n.setZoomIn()}function T(){n.setZoomOut()}function $(){n.setRotate()}function D(){n.setZoomBest()}function S(){n.setZoomOriginal()}function y(c){c.defaultPrevented||(c.code==="Escape"?b():c.code==="ArrowLeft"?L():c.code==="ArrowRight"&&g())}function A(){document.addEventListener("keydown",y,!1)}function E(){document.removeEventListener("keydown",y,!1)}return e.onMounted(()=>{f(),l(),A()}),e.onUnmounted(()=>{E()}),()=>e.createVNode(e.Fragment,null,[e.createVNode("div",{class:o.b(),style:d},[e.createVNode("img",{class:o.e("main-image"),src:r.value},null),e.createVNode("button",{class:o.e("close-btn"),onClick:b},[e.createVNode("svg",{width:"16px",height:"16px",viewBox:"0 0 16 16",version:"1.1"},[e.createVNode("g",{stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},[e.createVNode("polygon",{fill:"#293040","fill-rule":"nonzero",points:"8 6.58578644 12.2426407 2.34314575 13.6568542 3.75735931 9.41421356 8 13.6568542 12.2426407 12.2426407 13.6568542 8 9.41421356 3.75735931 13.6568542 2.34314575 12.2426407 6.58578644 8 2.34314575 3.75735931 3.75735931 2.34314575"},null)])])]),e.createVNode("button",{class:o.e("arrow-left"),onClick:L},[e.createVNode("svg",{width:"18px",height:"18px",viewBox:"0 0 16 16",version:"1.1"},[e.createVNode("g",{stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},[e.createVNode("polygon",{fill:"#293040","fill-rule":"nonzero",points:"10.7071068 12.2928932 9.29289322 13.7071068 3.58578644 8 9.29289322 2.29289322 10.7071068 3.70710678 6.41421356 8"},null)])])]),e.createVNode("button",{class:o.e("arrow-right"),onClick:g},[e.createVNode("svg",{width:"18px",height:"18px",viewBox:"0 0 16 16",version:"1.1"},[e.createVNode("g",{stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},[e.createVNode("polygon",{fill:"#293040","fill-rule":"nonzero",transform:"translate(8.146447, 8.000000) scale(-1, 1) translate(-8.146447, -8.000000) ",points:"11.7071068 12.2928932 10.2928932 13.7071068 4.58578644 8 10.2928932 2.29289322 11.7071068 3.70710678 7.41421356 8"},null)])])]),e.createVNode("div",{class:o.e("toolbar")},[e.createVNode("button",{onClick:z},[e.createVNode("svg",{width:"18px",height:"18px",viewBox:"0 0 16 16"},[e.createVNode("g",{stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},[e.createVNode("g",{fill:"#293040","fill-rule":"nonzero"},[e.createVNode("path",{d:"M6,6 L6,4 L8,4 L8,6 L10,6 L10,8 L8,8 L8,10 L6,10 L6,8 L4,8 L4,6 L6,6 Z M12.6063847,11.1921711 L15.6568542,14.2426407 L14.2426407,15.6568542 L11.1921711,12.6063847 C10.0235906,13.4815965 8.5723351,14 7,14 C3.13400675,14 0,10.8659932 0,7 C0,3.13400675 3.13400675,0 7,0 C10.8659932,0 14,3.13400675 14,7 C14,8.5723351 13.4815965,10.0235906 12.6063847,11.1921711 L12.6063847,11.1921711 Z M7,12 C9.76142375,12 12,9.76142375 12,7 C12,4.23857625 9.76142375,2 7,2 C4.23857625,2 2,4.23857625 2,7 C2,9.76142375 4.23857625,12 7,12 Z"},null)])])])]),e.createVNode("button",{onClick:T},[e.createVNode("svg",{width:"18px",height:"18px",viewBox:"0 0 16 16"},[e.createVNode("g",{stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},[e.createVNode("g",{fill:"#293040","fill-rule":"nonzero"},[e.createVNode("path",{d:"M12.6063847,11.1921711 L15.6568542,14.2426407 L14.2426407,15.6568542 L11.1921711,12.6063847 C10.0235906,13.4815965 8.5723351,14 7,14 C3.13400675,14 0,10.8659932 0,7 C0,3.13400675 3.13400675,0 7,0 C10.8659932,0 14,3.13400675 14,7 C14,8.5723351 13.4815965,10.0235906 12.6063847,11.1921711 L12.6063847,11.1921711 Z M7,12 C9.76142375,12 12,9.76142375 12,7 C12,4.23857625 9.76142375,2 7,2 C4.23857625,2 2,4.23857625 2,7 C2,9.76142375 4.23857625,12 7,12 Z M4,6 L10,6 L10,8 L4,8 L4,6 Z"},null)])])])]),e.createVNode("button",{onClick:$},[e.createVNode("svg",{width:"18px",height:"18px",viewBox:"0 0 16 16",version:"1.1"},[e.createVNode("g",{stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},[e.createVNode("path",{d:"M7.5,3.02242151 L7.5,4 L4.5,2 L7.5,0 L7.5,1.01640228 C7.66526181,1.00552468 7.83198572,1 8,1 C12.1421356,1 15.5,4.35786438 15.5,8.5 C15.5,12.6421356 12.1421356,16 8,16 C3.85786438,16 0.5,12.6421356 0.5,8.5 C0.5,6.9828355 0.950484514,5.5708873 1.72499011,4.39061882 L3.42173231,5.4510827 C2.83944149,6.32371289 2.5,7.37221604 2.5,8.5 C2.5,11.5375661 4.96243388,14 8,14 C11.0375661,14 13.5,11.5375661 13.5,8.5 C13.5,5.46243388 11.0375661,3 8,3 C7.83145515,3 7.66468102,3.00758131 7.5,3.02242151 Z M8,11 C6.61928813,11 5.5,9.88071187 5.5,8.5 C5.5,7.11928813 6.61928813,6 8,6 C9.38071187,6 10.5,7.11928813 10.5,8.5 C10.5,9.88071187 9.38071187,11 8,11 Z M8,10 C8.82842712,10 9.5,9.32842712 9.5,8.5 C9.5,7.67157288 8.82842712,7 8,7 C7.17157288,7 6.5,7.67157288 6.5,8.5 C6.5,9.32842712 7.17157288,10 8,10 Z",fill:"#293040"},null)])])]),e.createVNode("button",{onClick:L},[e.createVNode("svg",{width:"16px",height:"16px",viewBox:"0 0 16 16",version:"1.1"},[e.createVNode("g",{stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},[e.createVNode("polygon",{fill:"#293040","fill-rule":"nonzero",points:"10.7071068 12.2928932 9.29289322 13.7071068 3.58578644 8 9.29289322 2.29289322 10.7071068 3.70710678 6.41421356 8"},null)])])]),e.createVNode("span",{class:o.e("index")},[i.value+1,e.createTextVNode(":"),t.previewUrlList.length]),e.createVNode("button",{onClick:g},[e.createVNode("svg",{width:"16px",height:"16px",viewBox:"0 0 16 16",version:"1.1"},[e.createVNode("g",{stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},[e.createVNode("polygon",{fill:"#293040","fill-rule":"nonzero",transform:"translate(8.146447, 8.000000) scale(-1, 1) translate(-8.146447, -8.000000) ",points:"11.7071068 12.2928932 10.2928932 13.7071068 4.58578644 8 10.2928932 2.29289322 11.7071068 3.70710678 7.41421356 8"},null)])])]),e.createVNode("button",{onClick:D},[e.createVNode("svg",{width:"18px",height:"18px",viewBox:"0 0 16 16"},[e.createVNode("g",{stroke:"none","stroke-width":"1",fill:"none","fill-rule":"evenodd"},[e.createVNode("path",{d:"M16,16 L11.429,16 L11.429,15 L14.456,15 L11.006,11.226 L11.652,10.519 L15.086,14.275 L15.086,11 L16,11 L16,16 Z M15.164,1.544 L12.009,4.994 L11.418,4.348 L14.558,0.914 L11.82,0.914 L11.82,0 L16,0 L16,4.571 L15.164,4.571 L15.164,1.544 Z M5,15 L5,16 L0,16 L0,11 L1,11 L1,14.275 L4.756,10.519 L5.463,11.226 L1.689,15 L5,15 Z M4.365,4.994 L0.914,1.544 L0.914,4.571 L3.41060513e-13,4.571 L3.41060513e-13,0 L4.571,0 L4.571,0.914 L1.578,0.914 L5.011,4.348 L4.365,4.994 Z",fill:"#293040","fill-rule":"nonzero"},null)])])]),e.createVNode("button",{onClick:S},[e.createVNode("span",null,[e.createTextVNode("1:1")])])])]),e.createVNode("div",{class:o.e("bg"),style:u},null)])}});function Z(t){return e.createApp(k,t)}class a{static open(o){this.$body=document.body,this.$div=document.createElement("div"),this.$overflow=this.$body.style.overflow,this.$body.appendChild(this.$div),Z(o).mount(this.$div),this.$body.style.setProperty("overflow","hidden","important")}static close(){var o;(o=this.$body)==null||o.style.setProperty("overflow",this.$overflow),this.$overflow=null,this.$div&&this.$body.removeChild(this.$div),this.$body=null,this.$div=null}}a.$body=null,a.$div=null,a.$overflow="";function p(t){a.open({url:t.url,previewUrlList:t.previewUrlList,zIndex:t.zIndex,backDropZIndex:t.backDropZIndex})}function v(){a.close()}function x(t){return[...t.querySelectorAll("img")].map(n=>n.getAttribute("src"))}function N(t){var i;t.stopPropagation();const o=t.currentTarget,n=t.target;if(((i=n==null?void 0:n.nodeName)==null?void 0:i.toLowerCase())==="img"){const r=x(o),d=n.getAttribute("src");p({url:d,previewUrlList:r,zIndex:o==null?void 0:o.zIndex,backDropZIndex:o==null?void 0:o.backDropZIndex})}}function m(t){t.addEventListener("click",N)}function M(t){t.removeEventListener("click",N)}var C={mounted(t,o){if(!o.value)return m(t);const{custom:n,disableDefault:i}=o.value;n instanceof Object&&(n.open=()=>{const r=x(t);p({url:r==null?void 0:r[0],previewUrlList:r,zIndex:t==null?void 0:t.zIndex,backDropZIndex:t==null?void 0:t.backDropZIndex})},n.close=()=>v()),!i&&m(t)},unmounted(){v()},updated(t,o){var n,i;if(t.zIndex=(n=o.value)==null?void 0:n.zIndex,t.backDropZIndex=(i=o.value)==null?void 0:i.backDropZIndex,o.value){const{value:{disableDefault:r},oldValue:{disableDefault:d}}=o;r!==d&&(r?M(t):m(t))}}},P={title:"ImagePreview \u56FE\u7247\u9884\u89C8",category:"\u6570\u636E\u5C55\u793A",status:"100%",install(t){t.directive("d-image-preview",C),t.config.globalProperties.$imagePreviewService=a}};s.ImagePreviewDirective=C,s.ImagePreviewService=a,s.default=P,s.imagePreviewProps=w,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.devui-image-preview{position:fixed;left:0;top:0;right:0;bottom:0;z-index:calc(var(--devui-z-index-modal, 1050));display:flex;align-items:center;justify-content:center;overflow:hidden}.devui-image-preview svg,.devui-image-preview polygon,.devui-image-preview g,.devui-image-preview path{fill:var(--devui-icon-text, #71757f)}.devui-image-preview__main-image{width:auto;height:auto;max-width:90%;max-height:90%;margin-top:-20px;cursor:grab}.devui-image-preview__close-btn{position:fixed;z-index:var(--devui-z-index-modal, 1050);cursor:pointer;width:36px;height:36px;border-radius:50%;border:none;background:var(--devui-highlight-overlay, rgba(255, 255, 255, .8));box-shadow:var(--devui-shadow-length-base, 0 1px 4px 0) var(--devui-light-shadow, rgba(37, 43, 58, .1));display:inline-flex;align-items:center;justify-content:center;top:15px;right:20px}.devui-image-preview__close-btn:hover{background:var(--devui-area, #f8f8f8)}.devui-image-preview__close-btn svg{width:38px;height:18px}.devui-image-preview__arrow-left{position:fixed;z-index:var(--devui-z-index-modal, 1050);cursor:pointer;width:36px;height:36px;border-radius:50%;border:none;background:var(--devui-highlight-overlay, rgba(255, 255, 255, .8));box-shadow:var(--devui-shadow-length-base, 0 1px 4px 0) var(--devui-light-shadow, rgba(37, 43, 58, .1));display:inline-flex;align-items:center;justify-content:center;top:50%;left:20px;transform:translateY(-50%)}.devui-image-preview__arrow-left:hover{background:var(--devui-area, #f8f8f8)}.devui-image-preview__arrow-left svg{width:38px;height:18px}.devui-image-preview__arrow-right{position:fixed;z-index:var(--devui-z-index-modal, 1050);cursor:pointer;width:36px;height:36px;border-radius:50%;border:none;background:var(--devui-highlight-overlay, rgba(255, 255, 255, .8));box-shadow:var(--devui-shadow-length-base, 0 1px 4px 0) var(--devui-light-shadow, rgba(37, 43, 58, .1));display:inline-flex;align-items:center;justify-content:center;top:50%;right:20px;transform:translateY(-50%)}.devui-image-preview__arrow-right:hover{background:var(--devui-area, #f8f8f8)}.devui-image-preview__arrow-right svg{width:38px;height:18px}.devui-image-preview__toolbar{position:fixed;bottom:0;left:0;width:100%;height:50px;display:flex;align-items:center;justify-content:center;background:var(--devui-highlight-overlay, rgba(255, 255, 255, .8));box-shadow:var(--devui-shadow-length-fullscreen-overlay, 0 12px 24px 0) var(--devui-light-shadow, rgba(37, 43, 58, .1))}.devui-image-preview__toolbar button{display:inline-flex;width:24px;height:24px;align-items:center;justify-content:center;color:var(--devui-text, #252b3a);border:none;background-color:transparent;cursor:pointer;outline:0;padding:0}.devui-image-preview__toolbar .devui-image-preview__index{display:inline-flex;width:100px;justify-content:center;align-items:center;cursor:pointer}.devui-image-preview__toolbar>:not(:first-child){margin-left:20px}.devui-image-preview__bg{position:fixed;left:0;top:0;right:0;bottom:0;z-index:calc(var(--devui-z-index-modal, 1050) - 1);background:var(--devui-shadow, rgba(37, 43, 58, .2))}
|
package/index.d.ts
ADDED