misp-ui-library-test 0.0.1
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 +113 -0
- package/dist/theme-chalk/alert/index.scss +152 -0
- package/dist/theme-chalk/avatar/index.scss +51 -0
- package/dist/theme-chalk/backtop/index.scss +38 -0
- package/dist/theme-chalk/badge/index.scss +63 -0
- package/dist/theme-chalk/breadcrumb/index.scss +36 -0
- package/dist/theme-chalk/breadcrumb-item/index.scss +36 -0
- package/dist/theme-chalk/button/index.scss +157 -0
- package/dist/theme-chalk/card/index.scss +38 -0
- package/dist/theme-chalk/chart/index.scss +21 -0
- package/dist/theme-chalk/checkbox/index.scss +358 -0
- package/dist/theme-chalk/col/index.scss +131 -0
- package/dist/theme-chalk/container/index.scss +40 -0
- package/dist/theme-chalk/css/alert.css +484 -0
- package/dist/theme-chalk/css/avatar.css +409 -0
- package/dist/theme-chalk/css/backtop.css +401 -0
- package/dist/theme-chalk/css/badge.css +419 -0
- package/dist/theme-chalk/css/breadcrumb-item.css +395 -0
- package/dist/theme-chalk/css/breadcrumb.css +395 -0
- package/dist/theme-chalk/css/button.css +587 -0
- package/dist/theme-chalk/css/card.css +397 -0
- package/dist/theme-chalk/css/chart.css +386 -0
- package/dist/theme-chalk/css/checkbox.css +648 -0
- package/dist/theme-chalk/css/col.css +2111 -0
- package/dist/theme-chalk/css/container.css +404 -0
- package/dist/theme-chalk/css/dialog.css +505 -0
- package/dist/theme-chalk/css/divider.css +405 -0
- package/dist/theme-chalk/css/drawer.css +546 -0
- package/dist/theme-chalk/css/empty.css +394 -0
- package/dist/theme-chalk/css/form.css +561 -0
- package/dist/theme-chalk/css/icon.css +1534 -0
- package/dist/theme-chalk/css/image.css +400 -0
- package/dist/theme-chalk/css/input-number.css +424 -0
- package/dist/theme-chalk/css/input.css +721 -0
- package/dist/theme-chalk/css/link.css +424 -0
- package/dist/theme-chalk/css/loading.css +483 -0
- package/dist/theme-chalk/css/message-box.css +479 -0
- package/dist/theme-chalk/css/message.css +456 -0
- package/dist/theme-chalk/css/no-data.css +397 -0
- package/dist/theme-chalk/css/notification.css +431 -0
- package/dist/theme-chalk/css/page-header.css +396 -0
- package/dist/theme-chalk/css/pagination.css +565 -0
- package/dist/theme-chalk/css/popover.css +421 -0
- package/dist/theme-chalk/css/popper.css +454 -0
- package/dist/theme-chalk/css/progress.css +451 -0
- package/dist/theme-chalk/css/radio.css +626 -0
- package/dist/theme-chalk/css/rate.css +414 -0
- package/dist/theme-chalk/css/result.css +403 -0
- package/dist/theme-chalk/css/row.css +433 -0
- package/dist/theme-chalk/css/scrollbar.css +422 -0
- package/dist/theme-chalk/css/select.css +1897 -0
- package/dist/theme-chalk/css/skeleton-item.css +407 -0
- package/dist/theme-chalk/css/skeleton.css +390 -0
- package/dist/theme-chalk/css/slider.css +460 -0
- package/dist/theme-chalk/css/spinner.css +403 -0
- package/dist/theme-chalk/css/statistic.css +396 -0
- package/dist/theme-chalk/css/status-timeline-chart.css +388 -0
- package/dist/theme-chalk/css/step.css +496 -0
- package/dist/theme-chalk/css/steps.css +496 -0
- package/dist/theme-chalk/css/switch.css +507 -0
- package/dist/theme-chalk/css/tab-pane.css +457 -0
- package/dist/theme-chalk/css/table.css +461 -0
- package/dist/theme-chalk/css/tabs-navigation.css +925 -0
- package/dist/theme-chalk/css/tabs.css +457 -0
- package/dist/theme-chalk/css/tag.css +599 -0
- package/dist/theme-chalk/css/time-picker.css +683 -0
- package/dist/theme-chalk/css/timeline-item.css +459 -0
- package/dist/theme-chalk/css/timeline.css +459 -0
- package/dist/theme-chalk/css/tooltip.css +485 -0
- package/dist/theme-chalk/css/tree.css +473 -0
- package/dist/theme-chalk/css/upload.css +665 -0
- package/dist/theme-chalk/dialog/index.scss +168 -0
- package/dist/theme-chalk/divider/index.scss +46 -0
- package/dist/theme-chalk/drawer/index.scss +172 -0
- package/dist/theme-chalk/empty/index.scss +36 -0
- package/dist/theme-chalk/fonts/element-icons.ttf +0 -0
- package/dist/theme-chalk/fonts/element-icons.woff +0 -0
- package/dist/theme-chalk/form/index.scss +220 -0
- package/dist/theme-chalk/icon/index.scss +1171 -0
- package/dist/theme-chalk/image/index.scss +39 -0
- package/dist/theme-chalk/index.scss +127 -0
- package/dist/theme-chalk/input/index.scss +363 -0
- package/dist/theme-chalk/input-number/index.scss +71 -0
- package/dist/theme-chalk/link/index.scss +75 -0
- package/dist/theme-chalk/loading/index.scss +131 -0
- package/dist/theme-chalk/message/index.scss +100 -0
- package/dist/theme-chalk/message-box/index.scss +131 -0
- package/dist/theme-chalk/mixins.scss +203 -0
- package/dist/theme-chalk/no-data/index.scss +36 -0
- package/dist/theme-chalk/notification/index.scss +76 -0
- package/dist/theme-chalk/page-header/index.scss +36 -0
- package/dist/theme-chalk/pagination/index.scss +225 -0
- package/dist/theme-chalk/popover/index.scss +56 -0
- package/dist/theme-chalk/popper/index.scss +89 -0
- package/dist/theme-chalk/progress/index.scss +105 -0
- package/dist/theme-chalk/radio/index.scss +328 -0
- package/dist/theme-chalk/rate/index.scss +56 -0
- package/dist/theme-chalk/reset.scss +262 -0
- package/dist/theme-chalk/result/index.scss +46 -0
- package/dist/theme-chalk/row/index.scss +88 -0
- package/dist/theme-chalk/scrollbar/index.scss +67 -0
- package/dist/theme-chalk/select/index.scss +223 -0
- package/dist/theme-chalk/skeleton/index.scss +30 -0
- package/dist/theme-chalk/skeleton-item/index.scss +49 -0
- package/dist/theme-chalk/slider/index.scss +113 -0
- package/dist/theme-chalk/spinner/index.scss +40 -0
- package/dist/theme-chalk/statistic/index.scss +38 -0
- package/dist/theme-chalk/status-timeline-chart/index.scss +23 -0
- package/dist/theme-chalk/step/index.scss +160 -0
- package/dist/theme-chalk/steps/index.scss +160 -0
- package/dist/theme-chalk/switch/index.scss +153 -0
- package/dist/theme-chalk/tab-pane/index.scss +112 -0
- package/dist/theme-chalk/table/index.scss +110 -0
- package/dist/theme-chalk/tabs/index.scss +112 -0
- package/dist/theme-chalk/tabs-navigation/index.scss +631 -0
- package/dist/theme-chalk/tag/index.scss +138 -0
- package/dist/theme-chalk/themes/blue.scss +76 -0
- package/dist/theme-chalk/themes/dark.scss +99 -0
- package/dist/theme-chalk/themes/index.scss +260 -0
- package/dist/theme-chalk/themes/light.scss +99 -0
- package/dist/theme-chalk/time-picker/index.scss +332 -0
- package/dist/theme-chalk/timeline/index.scss +119 -0
- package/dist/theme-chalk/timeline-item/index.scss +119 -0
- package/dist/theme-chalk/tooltip/index.scss +122 -0
- package/dist/theme-chalk/tree/index.scss +125 -0
- package/dist/theme-chalk/upload/index.scss +348 -0
- package/dist/theme-chalk/variables.scss +93 -0
- package/dist/vue2-ui-library.cjs.temp.js.map +1 -0
- package/dist/vue2-ui-library.common.js +28 -0
- package/dist/vue2-ui-library.common.js.map +1 -0
- package/dist/vue2-ui-library.esm.js +29 -0
- package/dist/vue2-ui-library.umd.js +27 -0
- package/package.json +161 -0
- package/src/directives/clickoutside/index.js +111 -0
- package/src/directives/init/index.js +50 -0
- package/src/directives/resize/index.js +69 -0
- package/src/index.js +174 -0
- package/src/mixins/emitter.js +47 -0
- package/src/mixins/focus.js +42 -0
- package/src/mixins/locale.js +24 -0
- package/src/mixins/migrating.js +46 -0
- package/src/packages/alert/index.js +12 -0
- package/src/packages/alert/src/main.vue +98 -0
- package/src/packages/aside/index.js +12 -0
- package/src/packages/aside/src/main.vue +20 -0
- package/src/packages/auto-grid-layout/index.js +18 -0
- package/src/packages/auto-grid-layout/prop.js +92 -0
- package/src/packages/auto-grid-layout/src/components/GridItem.vue +759 -0
- package/src/packages/auto-grid-layout/src/components/GridLayout.vue +367 -0
- package/src/packages/auto-grid-layout/src/main.vue +287 -0
- package/src/packages/auto-grid-layout/src/utils/DOM.js +46 -0
- package/src/packages/auto-grid-layout/src/utils/interact.js +333 -0
- package/src/packages/auto-grid-layout/src/utils/responsiveUtils.js +75 -0
- package/src/packages/auto-grid-layout/src/utils/utils.js +339 -0
- package/src/packages/autocomplete/index.js +12 -0
- package/src/packages/autocomplete/src/main.vue +170 -0
- package/src/packages/avatar/index.js +12 -0
- package/src/packages/avatar/src/main.vue +87 -0
- package/src/packages/backtop/index.js +12 -0
- package/src/packages/backtop/src/main.vue +120 -0
- package/src/packages/badge/index.js +12 -0
- package/src/packages/badge/src/main.vue +53 -0
- package/src/packages/breadcrumb/index.js +12 -0
- package/src/packages/breadcrumb/src/main.vue +34 -0
- package/src/packages/breadcrumb-item/index.js +12 -0
- package/src/packages/breadcrumb-item/src/main.vue +41 -0
- package/src/packages/button/index.js +13 -0
- package/src/packages/button/src/main.vue +106 -0
- package/src/packages/calendar/index.js +12 -0
- package/src/packages/calendar/src/main.vue +173 -0
- package/src/packages/card/index.js +12 -0
- package/src/packages/card/src/main.vue +26 -0
- package/src/packages/carousel/index.js +12 -0
- package/src/packages/carousel/src/main.vue +186 -0
- package/src/packages/carousel-item/index.js +12 -0
- package/src/packages/carousel-item/src/main.vue +34 -0
- package/src/packages/cascader/index.js +12 -0
- package/src/packages/cascader/src/main.vue +232 -0
- package/src/packages/chart/index.js +7 -0
- package/src/packages/chart/src/axis-chart.js +700 -0
- package/src/packages/chart/src/main.vue +828 -0
- package/src/packages/chart/src/utils.js +21 -0
- package/src/packages/checkbox/index.js +44 -0
- package/src/packages/checkbox/src/main.vue +312 -0
- package/src/packages/col/index.js +12 -0
- package/src/packages/col/src/main.vue +85 -0
- package/src/packages/collapse/index.js +12 -0
- package/src/packages/collapse/src/main.vue +69 -0
- package/src/packages/collapse-item/index.js +12 -0
- package/src/packages/collapse-item/src/main.vue +75 -0
- package/src/packages/color-picker/index.js +12 -0
- package/src/packages/color-picker/src/main.vue +206 -0
- package/src/packages/container/index.js +12 -0
- package/src/packages/container/src/main.vue +33 -0
- package/src/packages/date-picker/index.js +12 -0
- package/src/packages/date-picker/src/main.vue +246 -0
- package/src/packages/descriptions/index.js +12 -0
- package/src/packages/descriptions/src/main.vue +89 -0
- package/src/packages/descriptions-item/index.js +12 -0
- package/src/packages/descriptions-item/src/main.vue +26 -0
- package/src/packages/dialog/index.js +12 -0
- package/src/packages/dialog/src/main.vue +336 -0
- package/src/packages/divider/index.js +12 -0
- package/src/packages/divider/src/main.vue +37 -0
- package/src/packages/drawer/index.js +7 -0
- package/src/packages/drawer/src/main.vue +310 -0
- package/src/packages/dropdown/index.js +12 -0
- package/src/packages/dropdown/src/main.vue +82 -0
- package/src/packages/dropdown-menu-item/index.js +12 -0
- package/src/packages/dropdown-menu-item/src/main.vue +29 -0
- package/src/packages/empty/index.js +12 -0
- package/src/packages/empty/src/img-empty.vue +12 -0
- package/src/packages/empty/src/main.vue +49 -0
- package/src/packages/footer/index.js +12 -0
- package/src/packages/footer/src/main.vue +20 -0
- package/src/packages/form/index.js +13 -0
- package/src/packages/form/src/form-field.vue +790 -0
- package/src/packages/form/src/form-item.vue +464 -0
- package/src/packages/form/src/label-wrap.vue +127 -0
- package/src/packages/form/src/main.vue +442 -0
- package/src/packages/form-item/index.js +11 -0
- package/src/packages/header/index.js +12 -0
- package/src/packages/header/src/main.vue +20 -0
- package/src/packages/icon/index.js +12 -0
- package/src/packages/icon/src/main.vue +48 -0
- package/src/packages/image/index.js +12 -0
- package/src/packages/image/src/main.vue +224 -0
- package/src/packages/input/index.js +13 -0
- package/src/packages/input/src/calcTextareaHeight.js +123 -0
- package/src/packages/input/src/main.vue +510 -0
- package/src/packages/input-number/index.js +12 -0
- package/src/packages/input-number/src/main.vue +121 -0
- package/src/packages/link/index.js +12 -0
- package/src/packages/link/src/main.vue +53 -0
- package/src/packages/loading/index.js +17 -0
- package/src/packages/loading/src/directive.js +54 -0
- package/src/packages/loading/src/main.vue +38 -0
- package/src/packages/loading/src/service.js +63 -0
- package/src/packages/main/index.js +12 -0
- package/src/packages/main/src/main.vue +12 -0
- package/src/packages/menu/index.js +12 -0
- package/src/packages/menu/src/main.vue +117 -0
- package/src/packages/menu-item/index.js +12 -0
- package/src/packages/menu-item/src/main.vue +61 -0
- package/src/packages/message/index.js +95 -0
- package/src/packages/message/src/main.vue +131 -0
- package/src/packages/message-box/index.js +75 -0
- package/src/packages/message-box/src/main.vue +207 -0
- package/src/packages/no-data/index.js +8 -0
- package/src/packages/no-data/src/main.vue +23 -0
- package/src/packages/notification/index.js +72 -0
- package/src/packages/notification/src/main.vue +139 -0
- package/src/packages/option/index.js +13 -0
- package/src/packages/page-header/index.js +12 -0
- package/src/packages/page-header/src/main.vue +27 -0
- package/src/packages/pagination/index.js +12 -0
- package/src/packages/pagination/src/main.vue +255 -0
- package/src/packages/popconfirm/index.js +12 -0
- package/src/packages/popconfirm/src/main.vue +89 -0
- package/src/packages/popover/index.js +12 -0
- package/src/packages/popover/src/main.vue +452 -0
- package/src/packages/progress/index.js +12 -0
- package/src/packages/progress/src/main.vue +236 -0
- package/src/packages/radio/index.js +44 -0
- package/src/packages/radio/src/main.vue +291 -0
- package/src/packages/rate/index.js +12 -0
- package/src/packages/rate/src/main.vue +129 -0
- package/src/packages/result/index.js +12 -0
- package/src/packages/result/src/main.vue +52 -0
- package/src/packages/row/index.js +12 -0
- package/src/packages/row/src/main.vue +57 -0
- package/src/packages/scrollbar/index.js +12 -0
- package/src/packages/scrollbar/src/bar.vue +116 -0
- package/src/packages/scrollbar/src/main.vue +124 -0
- package/src/packages/select/index.js +15 -0
- package/src/packages/select/src/clickoutside.js +20 -0
- package/src/packages/select/src/main.vue +1055 -0
- package/src/packages/select/src/navigation-mixin.js +49 -0
- package/src/packages/select/src/option.vue +249 -0
- package/src/packages/select/src/select-dropdown.vue +95 -0
- package/src/packages/select/src/utils.js +5 -0
- package/src/packages/skeleton/index.js +12 -0
- package/src/packages/skeleton/src/main.vue +76 -0
- package/src/packages/skeleton-item/index.js +12 -0
- package/src/packages/skeleton-item/src/img-placeholder.vue +13 -0
- package/src/packages/skeleton-item/src/main.vue +22 -0
- package/src/packages/slider/index.js +12 -0
- package/src/packages/slider/src/main.vue +176 -0
- package/src/packages/spinner/index.js +12 -0
- package/src/packages/spinner/src/main.vue +27 -0
- package/src/packages/statistic/index.js +12 -0
- package/src/packages/statistic/src/main.vue +100 -0
- package/src/packages/status-timeline-chart/index.js +7 -0
- package/src/packages/status-timeline-chart/src/constants.js +20 -0
- package/src/packages/status-timeline-chart/src/main.vue +499 -0
- package/src/packages/status-timeline-chart/src/option-builder.js +475 -0
- package/src/packages/step/index.js +12 -0
- package/src/packages/step/src/main.vue +183 -0
- package/src/packages/steps/index.js +12 -0
- package/src/packages/steps/src/main.vue +57 -0
- package/src/packages/submenu/index.js +12 -0
- package/src/packages/submenu/src/main.vue +68 -0
- package/src/packages/switch/index.js +12 -0
- package/src/packages/switch/src/main.vue +166 -0
- package/src/packages/tab-pane/index.js +12 -0
- package/src/packages/tab-pane/src/main.vue +74 -0
- package/src/packages/table/index.js +8 -0
- package/src/packages/table/src/components/PagePagination.vue +82 -0
- package/src/packages/table/src/main.vue +153 -0
- package/src/packages/tabs/index.js +12 -0
- package/src/packages/tabs/src/main.vue +167 -0
- package/src/packages/tabs-navigation/index.js +7 -0
- package/src/packages/tabs-navigation/src/main.vue +462 -0
- package/src/packages/tag/index.js +12 -0
- package/src/packages/tag/src/main.vue +194 -0
- package/src/packages/time-picker/index.js +17 -0
- package/src/packages/time-picker/src/date-utils.js +455 -0
- package/src/packages/time-picker/src/main.vue +321 -0
- package/src/packages/time-picker/src/pane/date-range.vue +193 -0
- package/src/packages/time-picker/src/pane/date-time-range.vue +362 -0
- package/src/packages/time-picker/src/pane/date-time.vue +362 -0
- package/src/packages/time-picker/src/pane/date.vue +441 -0
- package/src/packages/time-picker/src/pane/time.vue +260 -0
- package/src/packages/time-picker/src/time-input.vue +203 -0
- package/src/packages/time-picker/src/time-range-input.vue +170 -0
- package/src/packages/timeline/index.js +12 -0
- package/src/packages/timeline/src/main.vue +24 -0
- package/src/packages/timeline-item/index.js +12 -0
- package/src/packages/timeline-item/src/main.vue +78 -0
- package/src/packages/tooltip/index.js +12 -0
- package/src/packages/tooltip/src/main.js +367 -0
- package/src/packages/transfer/index.js +8 -0
- package/src/packages/transfer/src/main.vue +229 -0
- package/src/packages/transfer/src/transfer-panel.vue +245 -0
- package/src/packages/transitions/collapse-transition.js +75 -0
- package/src/packages/tree/index.js +12 -0
- package/src/packages/tree/src/main.vue +322 -0
- package/src/packages/tree/src/model/node.js +348 -0
- package/src/packages/tree/src/model/tree-store.js +354 -0
- package/src/packages/tree/src/model/util.js +10 -0
- package/src/packages/tree/src/tree-node.vue +262 -0
- package/src/packages/upload/index.js +9 -0
- package/src/packages/upload/src/main.vue +415 -0
- package/src/playground/mixins/element.js +98 -0
- package/src/playground/types/element.js +197 -0
- package/src/playground/types/layout.js +80 -0
- package/src/plugins/i18n.js +125 -0
- package/src/styles/fonts/element-icons.ttf +0 -0
- package/src/styles/fonts/element-icons.woff +0 -0
- package/src/styles/index.scss +138 -0
- package/src/styles/reset.scss +257 -0
- package/src/styles/themes/blue.scss +75 -0
- package/src/styles/themes/dark.scss +98 -0
- package/src/styles/themes/index.scss +34 -0
- package/src/styles/themes/light.scss +98 -0
- package/src/styles/themes/variables.scss +233 -0
- package/src/styles/variables.scss +146 -0
- package/src/utils/async-validator/index.js +659 -0
- package/src/utils/browser/index.js +39 -0
- package/src/utils/color.js +76 -0
- package/src/utils/dom/index.js +421 -0
- package/src/utils/dom/scrollbar-width.js +49 -0
- package/src/utils/draggable/core.js +379 -0
- package/src/utils/draggable/draggable.js +478 -0
- package/src/utils/draggable/index.js +61 -0
- package/src/utils/draggable/sortable.js +751 -0
- package/src/utils/lodash/index.js +2395 -0
- package/src/utils/moment/index.js +909 -0
- package/src/utils/playground/index.js +37 -0
- package/src/utils/popper/index.js +308 -0
- package/src/utils/popper/popper.js +1132 -0
- package/src/utils/popper/popup-manager.js +288 -0
- package/src/utils/popper/popup.js +344 -0
|
@@ -0,0 +1,759 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div ref="item" class="vue-grid-item" :class="classObj" :style="style">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
<span v-if="resizableAndNotStatic" ref="handle" :class="resizableHandleClass">
|
|
5
|
+
<svg viewBox="0 0 6 6" width="6px" height="6px">
|
|
6
|
+
<g opacity="0.302">
|
|
7
|
+
<path d="M 6 6 L 0 6 L 0 4.2 L 4 4.2 L 4.2 4.2 L 4.2 0 L 6 0 L 6 6 Z" />
|
|
8
|
+
</g>
|
|
9
|
+
</svg>
|
|
10
|
+
</span>
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
import { setTopLeft, setTopRight, setTransformRtl, setTransform } from '../utils/utils.js'
|
|
16
|
+
import { getControlPosition, createCoreData } from '../utils/interact.js'
|
|
17
|
+
import { getColsFromBreakpoint } from '../utils/responsiveUtils.js'
|
|
18
|
+
import { getDocumentDir } from '../utils/DOM.js'
|
|
19
|
+
import interact from '../utils/interact.js'
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
name: 'GridItem',
|
|
23
|
+
props: {
|
|
24
|
+
isDraggable: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
required: false,
|
|
27
|
+
default: null,
|
|
28
|
+
},
|
|
29
|
+
isResizable: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
required: false,
|
|
32
|
+
default: null,
|
|
33
|
+
},
|
|
34
|
+
static: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
required: false,
|
|
37
|
+
default: false,
|
|
38
|
+
},
|
|
39
|
+
minH: {
|
|
40
|
+
type: Number,
|
|
41
|
+
required: false,
|
|
42
|
+
default: 1,
|
|
43
|
+
},
|
|
44
|
+
minW: {
|
|
45
|
+
type: Number,
|
|
46
|
+
required: false,
|
|
47
|
+
default: 1,
|
|
48
|
+
},
|
|
49
|
+
maxH: {
|
|
50
|
+
type: Number,
|
|
51
|
+
required: false,
|
|
52
|
+
default: Infinity,
|
|
53
|
+
},
|
|
54
|
+
maxW: {
|
|
55
|
+
type: Number,
|
|
56
|
+
required: false,
|
|
57
|
+
default: Infinity,
|
|
58
|
+
},
|
|
59
|
+
x: {
|
|
60
|
+
type: Number,
|
|
61
|
+
required: true,
|
|
62
|
+
},
|
|
63
|
+
y: {
|
|
64
|
+
type: Number,
|
|
65
|
+
required: true,
|
|
66
|
+
},
|
|
67
|
+
w: {
|
|
68
|
+
type: Number,
|
|
69
|
+
required: true,
|
|
70
|
+
},
|
|
71
|
+
h: {
|
|
72
|
+
type: Number,
|
|
73
|
+
required: true,
|
|
74
|
+
},
|
|
75
|
+
i: {
|
|
76
|
+
required: true,
|
|
77
|
+
},
|
|
78
|
+
dragIgnoreFrom: {
|
|
79
|
+
type: String,
|
|
80
|
+
required: false,
|
|
81
|
+
default: 'a, button',
|
|
82
|
+
},
|
|
83
|
+
dragAllowFrom: {
|
|
84
|
+
type: String,
|
|
85
|
+
required: false,
|
|
86
|
+
default: null,
|
|
87
|
+
},
|
|
88
|
+
resizeIgnoreFrom: {
|
|
89
|
+
type: String,
|
|
90
|
+
required: false,
|
|
91
|
+
default: 'a, button',
|
|
92
|
+
},
|
|
93
|
+
preserveAspectRatio: {
|
|
94
|
+
type: Boolean,
|
|
95
|
+
required: false,
|
|
96
|
+
default: false,
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
inject: ['eventBus', 'layout'],
|
|
100
|
+
data: function () {
|
|
101
|
+
return {
|
|
102
|
+
cols: 1,
|
|
103
|
+
containerWidth: 100,
|
|
104
|
+
rowHeight: 30,
|
|
105
|
+
margin: [10, 10],
|
|
106
|
+
maxRows: Infinity,
|
|
107
|
+
draggable: null,
|
|
108
|
+
resizable: null,
|
|
109
|
+
useCssTransforms: true,
|
|
110
|
+
useStyleCursor: true,
|
|
111
|
+
|
|
112
|
+
isDragging: false,
|
|
113
|
+
dragging: null,
|
|
114
|
+
isResizing: false,
|
|
115
|
+
resizing: null,
|
|
116
|
+
lastX: NaN,
|
|
117
|
+
lastY: NaN,
|
|
118
|
+
lastW: NaN,
|
|
119
|
+
lastH: NaN,
|
|
120
|
+
style: {},
|
|
121
|
+
rtl: false,
|
|
122
|
+
|
|
123
|
+
dragEventSet: false,
|
|
124
|
+
resizeEventSet: false,
|
|
125
|
+
|
|
126
|
+
previousW: null,
|
|
127
|
+
previousH: null,
|
|
128
|
+
previousX: null,
|
|
129
|
+
previousY: null,
|
|
130
|
+
innerX: this.x,
|
|
131
|
+
innerY: this.y,
|
|
132
|
+
innerW: this.w,
|
|
133
|
+
innerH: this.h,
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
created() {
|
|
137
|
+
let self = this
|
|
138
|
+
|
|
139
|
+
self.updateWidthHandler = function (width) {
|
|
140
|
+
self.updateWidth(width)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
self.compactHandler = function (layout) {
|
|
144
|
+
self.compact(layout)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
self.setDraggableHandler = function (isDraggable) {
|
|
148
|
+
if (self.isDraggable === null) {
|
|
149
|
+
self.draggable = isDraggable
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
self.setResizableHandler = function (isResizable) {
|
|
154
|
+
if (self.isResizable === null) {
|
|
155
|
+
self.resizable = isResizable
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
self.setRowHeightHandler = function (rowHeight) {
|
|
160
|
+
self.rowHeight = rowHeight
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
self.setMaxRowsHandler = function (maxRows) {
|
|
164
|
+
self.maxRows = maxRows
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
self.directionchangeHandler = () => {
|
|
168
|
+
this.rtl = getDocumentDir() === 'rtl'
|
|
169
|
+
this.compact()
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
self.setColNum = (colNum) => {
|
|
173
|
+
self.cols = parseInt(colNum)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
this.eventBus.$on('updateWidth', self.updateWidthHandler)
|
|
177
|
+
this.eventBus.$on('compact', self.compactHandler)
|
|
178
|
+
this.eventBus.$on('setDraggable', self.setDraggableHandler)
|
|
179
|
+
this.eventBus.$on('setResizable', self.setResizableHandler)
|
|
180
|
+
this.eventBus.$on('setRowHeight', self.setRowHeightHandler)
|
|
181
|
+
this.eventBus.$on('setMaxRows', self.setMaxRowsHandler)
|
|
182
|
+
this.eventBus.$on('directionchange', self.directionchangeHandler)
|
|
183
|
+
this.eventBus.$on('setColNum', self.setColNum)
|
|
184
|
+
|
|
185
|
+
this.rtl = getDocumentDir() === 'rtl'
|
|
186
|
+
},
|
|
187
|
+
beforeDestroy: function () {
|
|
188
|
+
let self = this
|
|
189
|
+
this.eventBus.$off('updateWidth', self.updateWidthHandler)
|
|
190
|
+
this.eventBus.$off('compact', self.compactHandler)
|
|
191
|
+
this.eventBus.$off('setDraggable', self.setDraggableHandler)
|
|
192
|
+
this.eventBus.$off('setResizable', self.setResizableHandler)
|
|
193
|
+
this.eventBus.$off('setRowHeight', self.setRowHeightHandler)
|
|
194
|
+
this.eventBus.$off('setMaxRows', self.setMaxRowsHandler)
|
|
195
|
+
this.eventBus.$off('directionchange', self.directionchangeHandler)
|
|
196
|
+
this.eventBus.$off('setColNum', self.setColNum)
|
|
197
|
+
if (this.interactObj) {
|
|
198
|
+
this.interactObj.unset()
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
mounted: function () {
|
|
202
|
+
if (this.layout.responsive && this.layout.lastBreakpoint) {
|
|
203
|
+
this.cols = getColsFromBreakpoint(this.layout.lastBreakpoint, this.layout.cols)
|
|
204
|
+
} else {
|
|
205
|
+
this.cols = this.layout.colNum
|
|
206
|
+
}
|
|
207
|
+
this.rowHeight = this.layout.rowHeight
|
|
208
|
+
this.containerWidth = this.layout.width !== null ? this.layout.width : 100
|
|
209
|
+
this.margin = this.layout.margin !== undefined ? this.layout.margin : [10, 10]
|
|
210
|
+
this.maxRows = this.layout.maxRows
|
|
211
|
+
|
|
212
|
+
if (this.isDraggable === null) {
|
|
213
|
+
this.draggable = this.layout.isDraggable
|
|
214
|
+
} else {
|
|
215
|
+
this.draggable = this.isDraggable
|
|
216
|
+
}
|
|
217
|
+
if (this.isResizable === null) {
|
|
218
|
+
this.resizable = this.layout.isResizable
|
|
219
|
+
} else {
|
|
220
|
+
this.resizable = this.isResizable
|
|
221
|
+
}
|
|
222
|
+
this.useCssTransforms = this.layout.useCssTransforms
|
|
223
|
+
this.useStyleCursor = this.layout.useStyleCursor
|
|
224
|
+
this.createStyle()
|
|
225
|
+
},
|
|
226
|
+
watch: {
|
|
227
|
+
isDraggable: function () {
|
|
228
|
+
this.draggable = this.isDraggable
|
|
229
|
+
},
|
|
230
|
+
static: function () {
|
|
231
|
+
this.tryMakeDraggable()
|
|
232
|
+
this.tryMakeResizable()
|
|
233
|
+
},
|
|
234
|
+
draggable: function () {
|
|
235
|
+
this.tryMakeDraggable()
|
|
236
|
+
},
|
|
237
|
+
isResizable: function () {
|
|
238
|
+
this.resizable = this.isResizable
|
|
239
|
+
},
|
|
240
|
+
resizable: function () {
|
|
241
|
+
this.tryMakeResizable()
|
|
242
|
+
},
|
|
243
|
+
rowHeight: function () {
|
|
244
|
+
this.createStyle()
|
|
245
|
+
this.emitContainerResized()
|
|
246
|
+
},
|
|
247
|
+
cols: function () {
|
|
248
|
+
this.tryMakeResizable()
|
|
249
|
+
this.createStyle()
|
|
250
|
+
this.emitContainerResized()
|
|
251
|
+
},
|
|
252
|
+
containerWidth: function () {
|
|
253
|
+
this.tryMakeResizable()
|
|
254
|
+
this.createStyle()
|
|
255
|
+
this.emitContainerResized()
|
|
256
|
+
},
|
|
257
|
+
x: function (newVal) {
|
|
258
|
+
this.innerX = newVal
|
|
259
|
+
this.createStyle()
|
|
260
|
+
},
|
|
261
|
+
y: function (newVal) {
|
|
262
|
+
this.innerY = newVal
|
|
263
|
+
this.createStyle()
|
|
264
|
+
},
|
|
265
|
+
h: function (newVal) {
|
|
266
|
+
this.innerH = newVal
|
|
267
|
+
this.createStyle()
|
|
268
|
+
},
|
|
269
|
+
w: function (newVal) {
|
|
270
|
+
this.innerW = newVal
|
|
271
|
+
this.createStyle()
|
|
272
|
+
},
|
|
273
|
+
renderRtl: function () {
|
|
274
|
+
this.tryMakeResizable()
|
|
275
|
+
this.createStyle()
|
|
276
|
+
},
|
|
277
|
+
minH: function () {
|
|
278
|
+
this.tryMakeResizable()
|
|
279
|
+
},
|
|
280
|
+
maxH: function () {
|
|
281
|
+
this.tryMakeResizable()
|
|
282
|
+
},
|
|
283
|
+
minW: function () {
|
|
284
|
+
this.tryMakeResizable()
|
|
285
|
+
},
|
|
286
|
+
maxW: function () {
|
|
287
|
+
this.tryMakeResizable()
|
|
288
|
+
},
|
|
289
|
+
'$parent.margin': function (margin) {
|
|
290
|
+
if (!margin || (margin[0] == this.margin[0] && margin[1] == this.margin[1])) {
|
|
291
|
+
return
|
|
292
|
+
}
|
|
293
|
+
this.margin = margin.map((m) => Number(m))
|
|
294
|
+
this.createStyle()
|
|
295
|
+
this.emitContainerResized()
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
computed: {
|
|
299
|
+
classObj() {
|
|
300
|
+
return {
|
|
301
|
+
'vue-resizable': this.resizableAndNotStatic,
|
|
302
|
+
static: this.static,
|
|
303
|
+
resizing: this.isResizing,
|
|
304
|
+
'vue-draggable-dragging': this.isDragging,
|
|
305
|
+
cssTransforms: this.useCssTransforms,
|
|
306
|
+
'render-rtl': this.renderRtl,
|
|
307
|
+
'disable-userselect': this.isDragging,
|
|
308
|
+
'no-touch': this.isAndroid && this.draggableOrResizableAndNotStatic,
|
|
309
|
+
}
|
|
310
|
+
},
|
|
311
|
+
resizableAndNotStatic() {
|
|
312
|
+
return this.resizable && !this.static
|
|
313
|
+
},
|
|
314
|
+
draggableOrResizableAndNotStatic() {
|
|
315
|
+
return (this.draggable || this.resizable) && !this.static
|
|
316
|
+
},
|
|
317
|
+
isAndroid() {
|
|
318
|
+
return navigator.userAgent.toLowerCase().indexOf('android') !== -1
|
|
319
|
+
},
|
|
320
|
+
renderRtl() {
|
|
321
|
+
return this.layout.isMirrored ? !this.rtl : this.rtl
|
|
322
|
+
},
|
|
323
|
+
resizableHandleClass() {
|
|
324
|
+
if (this.renderRtl) {
|
|
325
|
+
return 'vue-resizable-handle vue-rtl-resizable-handle'
|
|
326
|
+
} else {
|
|
327
|
+
return 'vue-resizable-handle'
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
},
|
|
331
|
+
methods: {
|
|
332
|
+
createStyle: function () {
|
|
333
|
+
if (this.x + this.w > this.cols) {
|
|
334
|
+
this.innerX = 0
|
|
335
|
+
this.innerW = this.w > this.cols ? this.cols : this.w
|
|
336
|
+
} else {
|
|
337
|
+
this.innerX = this.x
|
|
338
|
+
this.innerW = this.w
|
|
339
|
+
}
|
|
340
|
+
let pos = this.calcPosition(this.innerX, this.innerY, this.innerW, this.innerH)
|
|
341
|
+
|
|
342
|
+
if (this.isDragging) {
|
|
343
|
+
pos.top = this.dragging.top
|
|
344
|
+
if (this.renderRtl) {
|
|
345
|
+
pos.right = this.dragging.left
|
|
346
|
+
} else {
|
|
347
|
+
pos.left = this.dragging.left
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
if (this.isResizing) {
|
|
351
|
+
pos.width = this.resizing.width
|
|
352
|
+
pos.height = this.resizing.height
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
let style
|
|
356
|
+
if (this.useCssTransforms) {
|
|
357
|
+
if (this.renderRtl) {
|
|
358
|
+
style = setTransformRtl(pos.top, pos.right, pos.width, pos.height)
|
|
359
|
+
} else {
|
|
360
|
+
style = setTransform(pos.top, pos.left, pos.width, pos.height)
|
|
361
|
+
}
|
|
362
|
+
} else {
|
|
363
|
+
if (this.renderRtl) {
|
|
364
|
+
style = setTopRight(pos.top, pos.right, pos.width, pos.height)
|
|
365
|
+
} else {
|
|
366
|
+
style = setTopLeft(pos.top, pos.left, pos.width, pos.height)
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
this.style = style
|
|
370
|
+
},
|
|
371
|
+
emitContainerResized() {
|
|
372
|
+
let styleProps = {}
|
|
373
|
+
for (let prop of ['width', 'height']) {
|
|
374
|
+
let val = this.style[prop]
|
|
375
|
+
let matches = val.match(/^(\d+)px$/)
|
|
376
|
+
if (!matches) return
|
|
377
|
+
styleProps[prop] = matches[1]
|
|
378
|
+
}
|
|
379
|
+
this.$emit('container-resized', this.i, this.h, this.w, styleProps.height, styleProps.width)
|
|
380
|
+
},
|
|
381
|
+
handleResize: function (event) {
|
|
382
|
+
if (this.static) return
|
|
383
|
+
const position = getControlPosition(event)
|
|
384
|
+
if (position == null) return;
|
|
385
|
+
const { x, y } = position
|
|
386
|
+
|
|
387
|
+
const newSize = { width: 0, height: 0 }
|
|
388
|
+
let pos
|
|
389
|
+
switch (event.type) {
|
|
390
|
+
case 'resizestart': {
|
|
391
|
+
this.previousW = this.innerW
|
|
392
|
+
this.previousH = this.innerH
|
|
393
|
+
pos = this.calcPosition(this.innerX, this.innerY, this.innerW, this.innerH)
|
|
394
|
+
newSize.width = pos.width
|
|
395
|
+
newSize.height = pos.height
|
|
396
|
+
this.resizing = newSize
|
|
397
|
+
this.isResizing = true
|
|
398
|
+
break
|
|
399
|
+
}
|
|
400
|
+
case 'resizemove': {
|
|
401
|
+
const coreEvent = createCoreData(this.lastW, this.lastH, x, y)
|
|
402
|
+
if (this.renderRtl) {
|
|
403
|
+
newSize.width = this.resizing.width - coreEvent.deltaX
|
|
404
|
+
} else {
|
|
405
|
+
newSize.width = this.resizing.width + coreEvent.deltaX
|
|
406
|
+
}
|
|
407
|
+
newSize.height = this.resizing.height + coreEvent.deltaY
|
|
408
|
+
this.resizing = newSize
|
|
409
|
+
break
|
|
410
|
+
}
|
|
411
|
+
case 'resizeend': {
|
|
412
|
+
pos = this.calcPosition(this.innerX, this.innerY, this.innerW, this.innerH)
|
|
413
|
+
newSize.width = pos.width
|
|
414
|
+
newSize.height = pos.height
|
|
415
|
+
this.resizing = null
|
|
416
|
+
this.isResizing = false
|
|
417
|
+
break
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// Get new WH
|
|
422
|
+
pos = this.calcWH(newSize.height, newSize.width)
|
|
423
|
+
if (pos.w < this.minW) {
|
|
424
|
+
pos.w = this.minW
|
|
425
|
+
}
|
|
426
|
+
if (pos.w > this.maxW) {
|
|
427
|
+
pos.w = this.maxW
|
|
428
|
+
}
|
|
429
|
+
if (pos.h < this.minH) {
|
|
430
|
+
pos.h = this.minH
|
|
431
|
+
}
|
|
432
|
+
if (pos.h > this.maxH) {
|
|
433
|
+
pos.h = this.maxH
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
if (pos.h < 1) {
|
|
437
|
+
pos.h = 1
|
|
438
|
+
}
|
|
439
|
+
if (pos.w < 1) {
|
|
440
|
+
pos.w = 1
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
this.lastW = x
|
|
444
|
+
this.lastH = y
|
|
445
|
+
|
|
446
|
+
if (this.innerW !== pos.w || this.innerH !== pos.h) {
|
|
447
|
+
this.$emit('resize', this.i, pos.h, pos.w, newSize.height, newSize.width)
|
|
448
|
+
}
|
|
449
|
+
if (event.type === 'resizeend' && (this.previousW !== this.innerW || this.previousH !== this.innerH)) {
|
|
450
|
+
this.$emit('resized', this.i, pos.h, pos.w, newSize.height, newSize.width)
|
|
451
|
+
}
|
|
452
|
+
this.eventBus.$emit('resizeEvent', event.type, this.i, this.innerX, this.innerY, pos.h, pos.w)
|
|
453
|
+
},
|
|
454
|
+
handleDrag(event) {
|
|
455
|
+
if (this.static) return
|
|
456
|
+
if (this.isResizing) return
|
|
457
|
+
const position = getControlPosition(event)
|
|
458
|
+
if (position === null) return;
|
|
459
|
+
const { x, y } = position
|
|
460
|
+
let newPosition = { top: 0, left: 0 }
|
|
461
|
+
switch (event.type) {
|
|
462
|
+
case 'dragstart': {
|
|
463
|
+
this.previousX = this.innerX
|
|
464
|
+
this.previousY = this.innerY
|
|
465
|
+
|
|
466
|
+
let parentRect = event.target.offsetParent.getBoundingClientRect()
|
|
467
|
+
let clientRect = event.target.getBoundingClientRect()
|
|
468
|
+
if (this.renderRtl) {
|
|
469
|
+
newPosition.left = (clientRect.right - parentRect.right) * -1
|
|
470
|
+
} else {
|
|
471
|
+
newPosition.left = clientRect.left - parentRect.left
|
|
472
|
+
}
|
|
473
|
+
newPosition.top = clientRect.top - parentRect.top
|
|
474
|
+
this.dragging = newPosition
|
|
475
|
+
this.isDragging = true
|
|
476
|
+
break
|
|
477
|
+
}
|
|
478
|
+
case 'dragend': {
|
|
479
|
+
if (!this.isDragging) return
|
|
480
|
+
let parentRect = event.target.offsetParent.getBoundingClientRect()
|
|
481
|
+
let clientRect = event.target.getBoundingClientRect()
|
|
482
|
+
if (this.renderRtl) {
|
|
483
|
+
newPosition.left = (clientRect.right - parentRect.right) * -1
|
|
484
|
+
} else {
|
|
485
|
+
newPosition.left = clientRect.left - parentRect.left
|
|
486
|
+
}
|
|
487
|
+
newPosition.top = clientRect.top - parentRect.top
|
|
488
|
+
this.dragging = null
|
|
489
|
+
this.isDragging = false
|
|
490
|
+
break
|
|
491
|
+
}
|
|
492
|
+
case 'dragmove': {
|
|
493
|
+
const coreEvent = createCoreData(this.lastX, this.lastY, x, y)
|
|
494
|
+
if (this.renderRtl) {
|
|
495
|
+
newPosition.left = this.dragging.left - coreEvent.deltaX
|
|
496
|
+
} else {
|
|
497
|
+
newPosition.left = this.dragging.left + coreEvent.deltaX
|
|
498
|
+
}
|
|
499
|
+
newPosition.top = this.dragging.top + coreEvent.deltaY
|
|
500
|
+
this.dragging = newPosition
|
|
501
|
+
break
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
// Get new XY
|
|
506
|
+
let pos
|
|
507
|
+
if (this.renderRtl) {
|
|
508
|
+
pos = this.calcXY(newPosition.top, newPosition.left)
|
|
509
|
+
} else {
|
|
510
|
+
pos = this.calcXY(newPosition.top, newPosition.left)
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
this.lastX = x
|
|
514
|
+
this.lastY = y
|
|
515
|
+
|
|
516
|
+
if (this.innerX !== pos.x || this.innerY !== pos.y) {
|
|
517
|
+
this.$emit('move', this.i, pos.x, pos.y)
|
|
518
|
+
}
|
|
519
|
+
if (event.type === 'dragend' && (this.previousX !== this.innerX || this.previousY !== this.innerY)) {
|
|
520
|
+
this.$emit('moved', this.i, pos.x, pos.y)
|
|
521
|
+
}
|
|
522
|
+
this.eventBus.$emit('dragEvent', event.type, this.i, pos.x, pos.y, this.innerH, this.innerW)
|
|
523
|
+
},
|
|
524
|
+
calcPosition: function (x, y, w, h) {
|
|
525
|
+
const colWidth = this.calcColWidth()
|
|
526
|
+
let out
|
|
527
|
+
if (this.renderRtl) {
|
|
528
|
+
out = {
|
|
529
|
+
right: Math.round(colWidth * x + (x + 1) * this.margin[0]),
|
|
530
|
+
top: Math.round(this.rowHeight * y + (y + 1) * this.margin[1]),
|
|
531
|
+
width: w === Infinity ? w : Math.round(colWidth * w + Math.max(0, w - 1) * this.margin[0]),
|
|
532
|
+
height: h === Infinity ? h : Math.round(this.rowHeight * h + Math.max(0, h - 1) * this.margin[1]),
|
|
533
|
+
}
|
|
534
|
+
} else {
|
|
535
|
+
out = {
|
|
536
|
+
left: Math.round(colWidth * x + (x + 1) * this.margin[0]),
|
|
537
|
+
top: Math.round(this.rowHeight * y + (y + 1) * this.margin[1]),
|
|
538
|
+
width: w === Infinity ? w : Math.round(colWidth * w + Math.max(0, w - 1) * this.margin[0]),
|
|
539
|
+
height: h === Infinity ? h : Math.round(this.rowHeight * h + Math.max(0, h - 1) * this.margin[1]),
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
return out
|
|
544
|
+
},
|
|
545
|
+
calcXY(top, left) {
|
|
546
|
+
const colWidth = this.calcColWidth()
|
|
547
|
+
let x = Math.round((left - this.margin[0]) / (colWidth + this.margin[0]))
|
|
548
|
+
let y = Math.round((top - this.margin[1]) / (this.rowHeight + this.margin[1]))
|
|
549
|
+
x = Math.max(Math.min(x, this.cols - this.innerW), 0)
|
|
550
|
+
y = Math.max(Math.min(y, this.maxRows - this.innerH), 0)
|
|
551
|
+
|
|
552
|
+
return { x, y }
|
|
553
|
+
},
|
|
554
|
+
calcColWidth() {
|
|
555
|
+
const colWidth = (this.containerWidth - this.margin[0] * (this.cols + 1)) / this.cols
|
|
556
|
+
return colWidth
|
|
557
|
+
},
|
|
558
|
+
|
|
559
|
+
calcWH(height, width, autoSizeFlag = false) {
|
|
560
|
+
const colWidth = this.calcColWidth()
|
|
561
|
+
let w = Math.round((width + this.margin[0]) / (colWidth + this.margin[0]))
|
|
562
|
+
let h = 0
|
|
563
|
+
if (!autoSizeFlag) {
|
|
564
|
+
h = Math.round((height + this.margin[1]) / (this.rowHeight + this.margin[1]))
|
|
565
|
+
} else {
|
|
566
|
+
h = Math.ceil((height + this.margin[1]) / (this.rowHeight + this.margin[1]))
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
// Capping
|
|
570
|
+
w = Math.max(Math.min(w, this.cols - this.innerX), 0)
|
|
571
|
+
h = Math.max(Math.min(h, this.maxRows - this.innerY), 0)
|
|
572
|
+
return { w, h }
|
|
573
|
+
},
|
|
574
|
+
updateWidth: function (width, colNum) {
|
|
575
|
+
this.containerWidth = width
|
|
576
|
+
if (colNum !== undefined && colNum !== null) {
|
|
577
|
+
this.cols = colNum
|
|
578
|
+
}
|
|
579
|
+
},
|
|
580
|
+
compact: function () {
|
|
581
|
+
this.createStyle()
|
|
582
|
+
},
|
|
583
|
+
tryMakeDraggable: function () {
|
|
584
|
+
const self = this
|
|
585
|
+
if (this.interactObj === null || this.interactObj === undefined) {
|
|
586
|
+
this.interactObj = interact(this.$refs.item)
|
|
587
|
+
if (!this.useStyleCursor) {
|
|
588
|
+
this.interactObj.styleCursor(false)
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
if (this.draggable && !this.static) {
|
|
592
|
+
const opts = {
|
|
593
|
+
ignoreFrom: this.dragIgnoreFrom,
|
|
594
|
+
allowFrom: this.dragAllowFrom,
|
|
595
|
+
enabled: true,
|
|
596
|
+
}
|
|
597
|
+
this.interactObj.draggable(opts)
|
|
598
|
+
if (!this.dragEventSet) {
|
|
599
|
+
this.dragEventSet = true
|
|
600
|
+
this.interactObj.on('dragstart', function (event) {
|
|
601
|
+
self.handleDrag({ type: 'dragstart', target: event.target, clientX: event.clientX, clientY: event.clientY })
|
|
602
|
+
})
|
|
603
|
+
this.interactObj.on('dragmove', function (event) {
|
|
604
|
+
self.handleDrag({ type: 'dragmove', target: event.target, clientX: event.clientX, clientY: event.clientY })
|
|
605
|
+
})
|
|
606
|
+
this.interactObj.on('dragend', function (event) {
|
|
607
|
+
self.handleDrag({ type: 'dragend', target: event.target, clientX: event.clientX, clientY: event.clientY })
|
|
608
|
+
})
|
|
609
|
+
}
|
|
610
|
+
} else {
|
|
611
|
+
this.interactObj.dragEnabled = false
|
|
612
|
+
}
|
|
613
|
+
},
|
|
614
|
+
tryMakeResizable: function () {
|
|
615
|
+
const self = this
|
|
616
|
+
if (this.interactObj === null || this.interactObj === undefined) {
|
|
617
|
+
this.interactObj = interact(this.$refs.item)
|
|
618
|
+
if (!this.useStyleCursor) {
|
|
619
|
+
this.interactObj.styleCursor(false)
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
if (this.resizable && !this.static) {
|
|
623
|
+
let maximum = this.calcPosition(0, 0, this.maxW, this.maxH)
|
|
624
|
+
let minimum = this.calcPosition(0, 0, this.minW, this.minH)
|
|
625
|
+
|
|
626
|
+
const resizeHandleSelector = '.' + this.resizableHandleClass.trim().replace(/\s+/g, '.')
|
|
627
|
+
|
|
628
|
+
const opts = {
|
|
629
|
+
edges: {
|
|
630
|
+
left: false,
|
|
631
|
+
right: resizeHandleSelector,
|
|
632
|
+
bottom: resizeHandleSelector,
|
|
633
|
+
top: false,
|
|
634
|
+
},
|
|
635
|
+
ignoreFrom: this.resizeIgnoreFrom,
|
|
636
|
+
enabled: true,
|
|
637
|
+
restrictSize: {
|
|
638
|
+
min: {
|
|
639
|
+
height: minimum.height,
|
|
640
|
+
width: minimum.width,
|
|
641
|
+
},
|
|
642
|
+
max: {
|
|
643
|
+
height: maximum.height,
|
|
644
|
+
width: maximum.width,
|
|
645
|
+
},
|
|
646
|
+
},
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
if (this.preserveAspectRatio) {
|
|
650
|
+
opts.preserveAspectRatio = true
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
this.interactObj.resizable(opts)
|
|
654
|
+
if (!this.resizeEventSet) {
|
|
655
|
+
this.resizeEventSet = true
|
|
656
|
+
this.interactObj.on('resizestart', function (event) {
|
|
657
|
+
self.handleResize({ type: 'resizestart', target: event.target, clientX: event.clientX, clientY: event.clientY })
|
|
658
|
+
})
|
|
659
|
+
this.interactObj.on('resizemove', function (event) {
|
|
660
|
+
self.handleResize({ type: 'resizemove', target: event.target, clientX: event.clientX, clientY: event.clientY })
|
|
661
|
+
})
|
|
662
|
+
this.interactObj.on('resizeend', function (event) {
|
|
663
|
+
self.handleResize({ type: 'resizeend', target: event.target, clientX: event.clientX, clientY: event.clientY })
|
|
664
|
+
})
|
|
665
|
+
}
|
|
666
|
+
} else {
|
|
667
|
+
this.interactObj.resizeEnabled = false
|
|
668
|
+
}
|
|
669
|
+
},
|
|
670
|
+
autoSize: function () {
|
|
671
|
+
this.previousW = this.innerW
|
|
672
|
+
this.previousH = this.innerH
|
|
673
|
+
|
|
674
|
+
let newSize = this.$slots.default[0].elm.getBoundingClientRect()
|
|
675
|
+
let pos = this.calcWH(newSize.height, newSize.width, true)
|
|
676
|
+
if (pos.w < this.minW) {
|
|
677
|
+
pos.w = this.minW
|
|
678
|
+
}
|
|
679
|
+
if (pos.w > this.maxW) {
|
|
680
|
+
pos.w = this.maxW
|
|
681
|
+
}
|
|
682
|
+
if (pos.h < this.minH) {
|
|
683
|
+
pos.h = this.minH
|
|
684
|
+
}
|
|
685
|
+
if (pos.h > this.maxH) {
|
|
686
|
+
pos.h = this.maxH
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
if (pos.h < 1) {
|
|
690
|
+
pos.h = 1
|
|
691
|
+
}
|
|
692
|
+
if (pos.w < 1) {
|
|
693
|
+
pos.w = 1
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
if (this.innerW !== pos.w || this.innerH !== pos.h) {
|
|
697
|
+
this.$emit('resize', this.i, pos.h, pos.w, newSize.height, newSize.width)
|
|
698
|
+
}
|
|
699
|
+
if (this.previousW !== pos.w || this.previousH !== pos.h) {
|
|
700
|
+
this.$emit('resized', this.i, pos.h, pos.w, newSize.height, newSize.width)
|
|
701
|
+
this.eventBus.$emit('resizeEvent', 'resizeend', this.i, this.innerX, this.innerY, pos.h, pos.w)
|
|
702
|
+
}
|
|
703
|
+
},
|
|
704
|
+
},
|
|
705
|
+
}
|
|
706
|
+
</script>
|
|
707
|
+
|
|
708
|
+
<style lang="scss" scoped>
|
|
709
|
+
.vue-grid-item {
|
|
710
|
+
transition: all .2s ease;
|
|
711
|
+
transition-property: left, top, right;
|
|
712
|
+
&.no-touch {
|
|
713
|
+
-ms-touch-action: none;
|
|
714
|
+
touch-action: none;
|
|
715
|
+
}
|
|
716
|
+
&.cssTransforms {
|
|
717
|
+
transition-property: transform;
|
|
718
|
+
left: 0;
|
|
719
|
+
right: auto;
|
|
720
|
+
&.render-rtl {
|
|
721
|
+
left: auto;
|
|
722
|
+
right: 0;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
&.resizing {
|
|
726
|
+
opacity: 0.6;
|
|
727
|
+
z-index: 3;
|
|
728
|
+
}
|
|
729
|
+
&.vue-draggable-dragging {
|
|
730
|
+
transition: none;
|
|
731
|
+
z-index: 3;
|
|
732
|
+
}
|
|
733
|
+
&.vue-grid-placeholder {
|
|
734
|
+
opacity: 0.2;
|
|
735
|
+
transition-duration: 100ms;
|
|
736
|
+
z-index: 2;
|
|
737
|
+
user-select: none;
|
|
738
|
+
}
|
|
739
|
+
&.disable-userselect {
|
|
740
|
+
user-select: none;
|
|
741
|
+
}
|
|
742
|
+
> .vue-resizable-handle {
|
|
743
|
+
position: absolute;
|
|
744
|
+
width: 20px;
|
|
745
|
+
height: 20px;
|
|
746
|
+
bottom: 0;
|
|
747
|
+
right: 0;
|
|
748
|
+
padding: 0 3px 3px 0;
|
|
749
|
+
box-sizing: border-box;
|
|
750
|
+
cursor: se-resize;
|
|
751
|
+
> svg {
|
|
752
|
+
position: absolute;
|
|
753
|
+
right: 10%;
|
|
754
|
+
bottom: 10%;
|
|
755
|
+
fill: var(--primary-blue);
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
</style>
|