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,367 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div ref="item" class="vue-grid-layout" :style="mergedStyle">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
<grid-item class="vue-grid-placeholder" v-show="isDragging" :x="placeholder.x" :y="placeholder.y" :w="placeholder.w" :h="placeholder.h" :i="placeholder.i"></grid-item>
|
|
5
|
+
</div>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script>
|
|
9
|
+
import GridItem from './GridItem.vue'
|
|
10
|
+
|
|
11
|
+
import Vue from 'vue'
|
|
12
|
+
import { bottom, compact, getLayoutItem, moveElement, validateLayout, cloneLayout, getAllCollisions } from '../utils/utils.js'
|
|
13
|
+
import { getBreakpointFromWidth, getColsFromBreakpoint, findOrGenerateResponsiveLayout } from '../utils/responsiveUtils.js'
|
|
14
|
+
import { addWindowEventListener, removeWindowEventListener } from '../utils/DOM.js'
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
name: 'GridLayout',
|
|
18
|
+
provide() {
|
|
19
|
+
return {
|
|
20
|
+
eventBus: null,
|
|
21
|
+
layout: this,
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
components: { GridItem },
|
|
25
|
+
props: {
|
|
26
|
+
autoSize: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: true,
|
|
29
|
+
},
|
|
30
|
+
colNum: {
|
|
31
|
+
type: Number,
|
|
32
|
+
default: 12,
|
|
33
|
+
},
|
|
34
|
+
rowHeight: {
|
|
35
|
+
type: Number,
|
|
36
|
+
default: 150,
|
|
37
|
+
},
|
|
38
|
+
maxRows: {
|
|
39
|
+
type: Number,
|
|
40
|
+
default: Infinity,
|
|
41
|
+
},
|
|
42
|
+
margin: {
|
|
43
|
+
type: Array,
|
|
44
|
+
default: function () {
|
|
45
|
+
return [10, 10]
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
isDraggable: {
|
|
49
|
+
type: Boolean,
|
|
50
|
+
default: true,
|
|
51
|
+
},
|
|
52
|
+
isResizable: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
default: true,
|
|
55
|
+
},
|
|
56
|
+
isMirrored: {
|
|
57
|
+
type: Boolean,
|
|
58
|
+
default: false,
|
|
59
|
+
},
|
|
60
|
+
useCssTransforms: {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
default: true,
|
|
63
|
+
},
|
|
64
|
+
verticalCompact: {
|
|
65
|
+
type: Boolean,
|
|
66
|
+
default: true,
|
|
67
|
+
},
|
|
68
|
+
layout: {
|
|
69
|
+
type: Array,
|
|
70
|
+
required: true,
|
|
71
|
+
},
|
|
72
|
+
responsive: {
|
|
73
|
+
type: Boolean,
|
|
74
|
+
default: false,
|
|
75
|
+
},
|
|
76
|
+
responsiveLayouts: {
|
|
77
|
+
type: Object,
|
|
78
|
+
default: function () {
|
|
79
|
+
return {}
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
breakpoints: {
|
|
83
|
+
type: Object,
|
|
84
|
+
default: function () {
|
|
85
|
+
return { lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 }
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
cols: {
|
|
89
|
+
type: Object,
|
|
90
|
+
default: function () {
|
|
91
|
+
return { lg: 12, md: 10, sm: 6, xs: 4, xxs: 2 }
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
preventCollision: {
|
|
95
|
+
type: Boolean,
|
|
96
|
+
default: false,
|
|
97
|
+
},
|
|
98
|
+
useStyleCursor: {
|
|
99
|
+
type: Boolean,
|
|
100
|
+
default: true,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
data: function () {
|
|
104
|
+
return {
|
|
105
|
+
width: null,
|
|
106
|
+
mergedStyle: {},
|
|
107
|
+
lastLayoutLength: 0,
|
|
108
|
+
isDragging: false,
|
|
109
|
+
placeholder: {
|
|
110
|
+
x: 0,
|
|
111
|
+
y: 0,
|
|
112
|
+
w: 0,
|
|
113
|
+
h: 0,
|
|
114
|
+
i: -1,
|
|
115
|
+
},
|
|
116
|
+
layouts: {},
|
|
117
|
+
lastBreakpoint: null,
|
|
118
|
+
originalLayout: null,
|
|
119
|
+
layoutsCache: this.responsiveLayouts,
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
created() {
|
|
123
|
+
const self = this
|
|
124
|
+
self.resizeEventHandler = function (eventType, i, x, y, h, w) {
|
|
125
|
+
self.resizeEvent(eventType, i, x, y, h, w)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
self.dragEventHandler = function (eventType, i, x, y, h, w) {
|
|
129
|
+
self.dragEvent(eventType, i, x, y, h, w)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
self._provided.eventBus = new Vue()
|
|
133
|
+
self.eventBus = self._provided.eventBus
|
|
134
|
+
self.eventBus.$on('resizeEvent', self.resizeEventHandler)
|
|
135
|
+
self.eventBus.$on('dragEvent', self.dragEventHandler)
|
|
136
|
+
self.$emit('layout-created', self.layout)
|
|
137
|
+
},
|
|
138
|
+
beforeDestroy: function () {
|
|
139
|
+
this.eventBus.$off('resizeEvent', this.resizeEventHandler)
|
|
140
|
+
this.eventBus.$off('dragEvent', this.dragEventHandler)
|
|
141
|
+
this.eventBus.$destroy()
|
|
142
|
+
removeWindowEventListener('resize', this.onWindowResize)
|
|
143
|
+
if (this.erd) {
|
|
144
|
+
this.erd.uninstall(this.$refs.item)
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
beforeMount: function () {
|
|
148
|
+
this.$emit('layout-before-mount', this.layout)
|
|
149
|
+
},
|
|
150
|
+
mounted: function () {
|
|
151
|
+
this.$emit('layout-mounted', this.layout)
|
|
152
|
+
this.$nextTick(function () {
|
|
153
|
+
validateLayout(this.layout)
|
|
154
|
+
|
|
155
|
+
this.originalLayout = this.layout
|
|
156
|
+
const self = this
|
|
157
|
+
this.$nextTick(function () {
|
|
158
|
+
self.onWindowResize()
|
|
159
|
+
self.initResponsiveFeatures()
|
|
160
|
+
addWindowEventListener('resize', self.onWindowResize)
|
|
161
|
+
compact(self.layout, self.verticalCompact)
|
|
162
|
+
self.$emit('layout-updated', self.layout)
|
|
163
|
+
self.updateHeight()
|
|
164
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
165
|
+
self.onWindowResize()
|
|
166
|
+
})
|
|
167
|
+
resizeObserver.observe(self.$refs.item)
|
|
168
|
+
})
|
|
169
|
+
})
|
|
170
|
+
},
|
|
171
|
+
watch: {
|
|
172
|
+
width: function (newval, oldval) {
|
|
173
|
+
const self = this
|
|
174
|
+
this.$nextTick(function () {
|
|
175
|
+
this.eventBus.$emit('updateWidth', this.width)
|
|
176
|
+
if (oldval === null) {
|
|
177
|
+
this.$nextTick(() => {
|
|
178
|
+
this.$emit('layout-ready', self.layout)
|
|
179
|
+
})
|
|
180
|
+
}
|
|
181
|
+
this.updateHeight()
|
|
182
|
+
})
|
|
183
|
+
},
|
|
184
|
+
layout: function () {
|
|
185
|
+
this.layoutUpdate()
|
|
186
|
+
},
|
|
187
|
+
colNum: function (val) {
|
|
188
|
+
this.eventBus.$emit('setColNum', val)
|
|
189
|
+
},
|
|
190
|
+
rowHeight: function () {
|
|
191
|
+
this.eventBus.$emit('setRowHeight', this.rowHeight)
|
|
192
|
+
},
|
|
193
|
+
isDraggable: function () {
|
|
194
|
+
this.eventBus.$emit('setDraggable', this.isDraggable)
|
|
195
|
+
},
|
|
196
|
+
isResizable: function () {
|
|
197
|
+
this.eventBus.$emit('setResizable', this.isResizable)
|
|
198
|
+
},
|
|
199
|
+
responsive() {
|
|
200
|
+
if (!this.responsive) {
|
|
201
|
+
this.$emit('update:layout', this.originalLayout)
|
|
202
|
+
this.eventBus.$emit('setColNum', this.colNum)
|
|
203
|
+
}
|
|
204
|
+
this.onWindowResize()
|
|
205
|
+
},
|
|
206
|
+
maxRows: function () {
|
|
207
|
+
this.eventBus.$emit('setMaxRows', this.maxRows)
|
|
208
|
+
},
|
|
209
|
+
margin() {
|
|
210
|
+
this.updateHeight()
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
methods: {
|
|
214
|
+
layoutUpdate() {
|
|
215
|
+
if (this.layout !== undefined && this.originalLayout !== null) {
|
|
216
|
+
if (this.layout.length !== this.originalLayout.length) {
|
|
217
|
+
let diff = this.findDifference(this.layout, this.originalLayout)
|
|
218
|
+
if (diff.length > 0) {
|
|
219
|
+
if (this.layout.length > this.originalLayout.length) {
|
|
220
|
+
this.originalLayout = this.originalLayout.concat(diff)
|
|
221
|
+
} else {
|
|
222
|
+
this.originalLayout = this.originalLayout.filter((obj) => {
|
|
223
|
+
return !diff.some((obj2) => {
|
|
224
|
+
return obj.i === obj2.i
|
|
225
|
+
})
|
|
226
|
+
})
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
this.lastLayoutLength = this.layout.length
|
|
230
|
+
this.layoutsCache = {
|
|
231
|
+
[this.lastBreakpoint]: this.layout,
|
|
232
|
+
}
|
|
233
|
+
this.initResponsiveFeatures()
|
|
234
|
+
}
|
|
235
|
+
compact(this.layout, this.verticalCompact)
|
|
236
|
+
this.eventBus.$emit('updateWidth', this.width)
|
|
237
|
+
this.updateHeight()
|
|
238
|
+
this.$emit('layout-updated', this.layout)
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
updateHeight: function () {
|
|
242
|
+
this.mergedStyle = {
|
|
243
|
+
height: this.containerHeight(),
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
onWindowResize: function () {
|
|
247
|
+
if (this.$refs !== null && this.$refs.item !== null && this.$refs.item !== undefined) {
|
|
248
|
+
this.width = this.$refs.item.offsetWidth
|
|
249
|
+
}
|
|
250
|
+
this.eventBus.$emit('resizeEvent')
|
|
251
|
+
},
|
|
252
|
+
containerHeight: function () {
|
|
253
|
+
if (!this.autoSize) return
|
|
254
|
+
const containerHeight = bottom(this.layout) * (this.rowHeight + this.margin[1]) + this.margin[1] + 'px'
|
|
255
|
+
return containerHeight
|
|
256
|
+
},
|
|
257
|
+
dragEvent: function (eventName, id, x, y, h, w) {
|
|
258
|
+
let l = getLayoutItem(this.layout, id)
|
|
259
|
+
if (l === undefined || l === null) {
|
|
260
|
+
l = { x: 0, y: 0 }
|
|
261
|
+
}
|
|
262
|
+
if (eventName === 'dragmove' || eventName === 'dragstart') {
|
|
263
|
+
this.placeholder.i = id
|
|
264
|
+
this.placeholder.x = l.x
|
|
265
|
+
this.placeholder.y = l.y
|
|
266
|
+
this.placeholder.w = w
|
|
267
|
+
this.placeholder.h = h
|
|
268
|
+
this.$nextTick(function () {
|
|
269
|
+
this.isDragging = true
|
|
270
|
+
})
|
|
271
|
+
this.eventBus.$emit('updateWidth', this.width)
|
|
272
|
+
} else {
|
|
273
|
+
this.$nextTick(function () {
|
|
274
|
+
this.isDragging = false
|
|
275
|
+
})
|
|
276
|
+
}
|
|
277
|
+
const newLayout = moveElement(this.layout, l, x, y, true, this.preventCollision)
|
|
278
|
+
this.$emit('update:layout', newLayout)
|
|
279
|
+
compact(newLayout, this.verticalCompact)
|
|
280
|
+
this.eventBus.$emit('compact')
|
|
281
|
+
this.updateHeight()
|
|
282
|
+
if (eventName === 'dragend') this.$emit('layout-updated', newLayout)
|
|
283
|
+
},
|
|
284
|
+
resizeEvent: function (eventName, id, x, y, h, w) {
|
|
285
|
+
let l = getLayoutItem(this.layout, id)
|
|
286
|
+
if (l === undefined || l === null) {
|
|
287
|
+
l = { h: 0, w: 0 }
|
|
288
|
+
}
|
|
289
|
+
let hasCollisions
|
|
290
|
+
if (this.preventCollision) {
|
|
291
|
+
const collisions = getAllCollisions(this.layout, { ...l, w, h }).filter((layoutItem) => layoutItem.i !== l.i)
|
|
292
|
+
hasCollisions = collisions.length > 0
|
|
293
|
+
if (hasCollisions) {
|
|
294
|
+
let leastX = Infinity,
|
|
295
|
+
leastY = Infinity
|
|
296
|
+
collisions.forEach((layoutItem) => {
|
|
297
|
+
if (layoutItem.x > l.x) leastX = Math.min(leastX, layoutItem.x)
|
|
298
|
+
if (layoutItem.y > l.y) leastY = Math.min(leastY, layoutItem.y)
|
|
299
|
+
})
|
|
300
|
+
if (Number.isFinite(leastX)) l.w = leastX - l.x
|
|
301
|
+
if (Number.isFinite(leastY)) l.h = leastY - l.y
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
if (!hasCollisions) {
|
|
305
|
+
l.w = w
|
|
306
|
+
l.h = h
|
|
307
|
+
}
|
|
308
|
+
if (eventName === 'resizestart' || eventName === 'resizemove') {
|
|
309
|
+
this.placeholder.i = id
|
|
310
|
+
this.placeholder.x = x
|
|
311
|
+
this.placeholder.y = y
|
|
312
|
+
this.placeholder.w = l.w
|
|
313
|
+
this.placeholder.h = l.h
|
|
314
|
+
this.$nextTick(function () {
|
|
315
|
+
this.isDragging = true
|
|
316
|
+
})
|
|
317
|
+
this.eventBus.$emit('updateWidth', this.width)
|
|
318
|
+
} else {
|
|
319
|
+
this.$nextTick(function () {
|
|
320
|
+
this.isDragging = false
|
|
321
|
+
})
|
|
322
|
+
}
|
|
323
|
+
if (this.responsive) this.responsiveGridLayout()
|
|
324
|
+
compact(this.layout, this.verticalCompact)
|
|
325
|
+
this.eventBus.$emit('compact')
|
|
326
|
+
this.updateHeight()
|
|
327
|
+
if (eventName === 'resizeend') this.$emit('layout-updated', this.layout)
|
|
328
|
+
},
|
|
329
|
+
responsiveGridLayout() {
|
|
330
|
+
let newBreakpoint = getBreakpointFromWidth(this.breakpoints, this.width)
|
|
331
|
+
let newCols = getColsFromBreakpoint(newBreakpoint, this.cols)
|
|
332
|
+
if (this.lastBreakpoint != null && !this.layouts[this.lastBreakpoint]) this.layouts[this.lastBreakpoint] = cloneLayout(this.layout)
|
|
333
|
+
let layout = findOrGenerateResponsiveLayout(this.originalLayout, this.layouts, this.breakpoints, newBreakpoint, this.lastBreakpoint, newCols, this.verticalCompact)
|
|
334
|
+
this.layouts[newBreakpoint] = layout
|
|
335
|
+
if (this.lastBreakpoint !== newBreakpoint) {
|
|
336
|
+
this.$emit('breakpoint-changed', newBreakpoint, layout)
|
|
337
|
+
}
|
|
338
|
+
this.$emit('update:layout', layout)
|
|
339
|
+
this.lastBreakpoint = newBreakpoint
|
|
340
|
+
this.eventBus.$emit('setColNum', getColsFromBreakpoint(newBreakpoint, this.cols))
|
|
341
|
+
},
|
|
342
|
+
initResponsiveFeatures() {
|
|
343
|
+
this.layouts = Object.assign({}, this.layoutsCache)
|
|
344
|
+
},
|
|
345
|
+
findDifference(layout, originalLayout) {
|
|
346
|
+
let uniqueResultOne = layout.filter(function (obj) {
|
|
347
|
+
return !originalLayout.some(function (obj2) {
|
|
348
|
+
return obj.i === obj2.i
|
|
349
|
+
})
|
|
350
|
+
})
|
|
351
|
+
let uniqueResultTwo = originalLayout.filter(function (obj) {
|
|
352
|
+
return !layout.some(function (obj2) {
|
|
353
|
+
return obj.i === obj2.i
|
|
354
|
+
})
|
|
355
|
+
})
|
|
356
|
+
return uniqueResultOne.concat(uniqueResultTwo)
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
}
|
|
360
|
+
</script>
|
|
361
|
+
|
|
362
|
+
<style lang="scss" scoped>
|
|
363
|
+
.vue-grid-layout {
|
|
364
|
+
position: relative;
|
|
365
|
+
transition: height .2s ease;
|
|
366
|
+
}
|
|
367
|
+
</style>
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="['misp-auto-grid', ...extraClassName]" :style="styleProp" @click="clickHandler">
|
|
3
|
+
<div v-if="staticContainer" class="w-full h-full container-mask" />
|
|
4
|
+
<grid-layout
|
|
5
|
+
:style="containerStyleProp"
|
|
6
|
+
ref="gridlayout"
|
|
7
|
+
:layout.sync="instance.children"
|
|
8
|
+
v-bind="layoutConfig"
|
|
9
|
+
@layout-created="layoutCreatedEvent"
|
|
10
|
+
>
|
|
11
|
+
<grid-item
|
|
12
|
+
v-for="item in instance.children"
|
|
13
|
+
:key="item.i"
|
|
14
|
+
v-bind="item"
|
|
15
|
+
@move="moveEventHandler"
|
|
16
|
+
@moved="movedEventHandler"
|
|
17
|
+
@resize="resizeEventHandler"
|
|
18
|
+
@resized="resizedEventHandler"
|
|
19
|
+
>
|
|
20
|
+
<div class="w-full h-full grid-item-wrapper" style="user-select: none" @mouseenter="itemExnterHandler">
|
|
21
|
+
<component
|
|
22
|
+
:key="`component-${item.i}`"
|
|
23
|
+
:is="getClassName(item.instance)"
|
|
24
|
+
:instance="item.instance"
|
|
25
|
+
:is-dragging="isDragging"
|
|
26
|
+
:is-resizing="isResizing"
|
|
27
|
+
v-bind="$attrs"
|
|
28
|
+
v-on="$listeners"
|
|
29
|
+
/>
|
|
30
|
+
<div class="delete-wrapper">
|
|
31
|
+
123
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
</grid-item>
|
|
35
|
+
</grid-layout>
|
|
36
|
+
</div>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<script>
|
|
40
|
+
import GridItem from './components/GridItem.vue'
|
|
41
|
+
import GridLayout from './components/GridLayout.vue'
|
|
42
|
+
|
|
43
|
+
import { AutoGridLayout, AutoGridLayoutProp } from '../prop.js'
|
|
44
|
+
import elementMixins from '../../../playground/mixins/element.js'
|
|
45
|
+
import init from '../../../directives/init/index.js'
|
|
46
|
+
import resize from '../../../directives/resize/index.js'
|
|
47
|
+
|
|
48
|
+
export default {
|
|
49
|
+
name: 'UiAutoGridLayout',
|
|
50
|
+
components: { GridLayout, GridItem },
|
|
51
|
+
mixins: [elementMixins],
|
|
52
|
+
props: {
|
|
53
|
+
// instance: {},
|
|
54
|
+
isDragging: { type: Boolean, default: true },
|
|
55
|
+
isResizing: { type: Boolean, default: true },
|
|
56
|
+
},
|
|
57
|
+
data: () => ({
|
|
58
|
+
containerHeight: 0, // 容器实际高度
|
|
59
|
+
rowHeight: 0,// 单行高度
|
|
60
|
+
/**
|
|
61
|
+
* 布局中已满列索引缓存
|
|
62
|
+
* @type {Array<number>}
|
|
63
|
+
*/
|
|
64
|
+
fullCols: [],
|
|
65
|
+
beforeLayoutChildren: [], // 上一次布局缓存
|
|
66
|
+
|
|
67
|
+
/** @type {AutoGridLayoutProp} */
|
|
68
|
+
instance: new AutoGridLayout({ colNum: 4, rowNum: 3, margin: [0, 0] })
|
|
69
|
+
}),
|
|
70
|
+
filters: {},
|
|
71
|
+
computed: {
|
|
72
|
+
layoutConfig() {
|
|
73
|
+
return {
|
|
74
|
+
colNum: this.instance.colNum,
|
|
75
|
+
maxRows: this.instance.rowNum,
|
|
76
|
+
rowHeight: this.rowHeight,
|
|
77
|
+
margin: this.instance.margin,
|
|
78
|
+
isDraggable: this.instance.isDraggable,
|
|
79
|
+
isResizable: this.instance.isResizable,
|
|
80
|
+
verticalCompact: this.instance.verticalCompact,
|
|
81
|
+
useCssTransforms: this.instance.useCssTransforms,
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
children() {
|
|
85
|
+
return this.instance.children
|
|
86
|
+
},
|
|
87
|
+
containerStyleProp() {
|
|
88
|
+
return {
|
|
89
|
+
...this.styleProp,
|
|
90
|
+
width: '100%',
|
|
91
|
+
height: '100% !important',
|
|
92
|
+
overflow: 'hidden'
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
// 是否为静态容器 (不支持拖拽插入元素)
|
|
96
|
+
staticContainer() {
|
|
97
|
+
return !!(this.instance.extraCustom && this.instance.extraCustom.onlyContainer)
|
|
98
|
+
},
|
|
99
|
+
isCard() {
|
|
100
|
+
return this.instance && this.instance.extraCustom && this.instance.extraCustom.isCard
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
directives: { init, resize },
|
|
104
|
+
watch: {
|
|
105
|
+
'layoutConfig.maxRows'() {
|
|
106
|
+
this.containerHeightRefresh()
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
created() {
|
|
110
|
+
this.$nextTick(() => {
|
|
111
|
+
// 通过闭包捕获必要参数,避免直接引用 this
|
|
112
|
+
const gridRef = this.$refs.gridlayout
|
|
113
|
+
this.instance.assignProperty('extraCustom', {
|
|
114
|
+
// 方法改为接收显式参数
|
|
115
|
+
colFullCheck: () => this.colFullCheck(),
|
|
116
|
+
dragEvent: (...args) => gridRef ? gridRef.dragEvent(...args) : undefined,
|
|
117
|
+
gridChildrenHandler: (index, handler) => {
|
|
118
|
+
handler(gridRef ? gridRef.$children[index] : undefined)
|
|
119
|
+
},
|
|
120
|
+
})
|
|
121
|
+
})
|
|
122
|
+
},
|
|
123
|
+
mounted() {},
|
|
124
|
+
activated() {},
|
|
125
|
+
beforeDestroy() {},
|
|
126
|
+
methods: {
|
|
127
|
+
// 空方法, 刷新容器布局
|
|
128
|
+
containerHeightRefresh() {
|
|
129
|
+
const element = (this.instance && this.instance.extraCustom && this.instance.extraCustom.getElement) ? this.instance.extraCustom.getElement() : null
|
|
130
|
+
if (!element) return;
|
|
131
|
+
this.$nextTick(() => {
|
|
132
|
+
// 获取容器高度, 计算除间距外每行高度
|
|
133
|
+
const containerHeight = element.offsetHeight
|
|
134
|
+
const totalRowGap = (this.layoutConfig.maxRows + 1) * (this.layoutConfig.margin[1] || 0)
|
|
135
|
+
const rowHeight = Math.floor((containerHeight - totalRowGap) / this.layoutConfig.maxRows)
|
|
136
|
+
this.containerHeight = containerHeight
|
|
137
|
+
this.rowHeight = rowHeight
|
|
138
|
+
})
|
|
139
|
+
},
|
|
140
|
+
/**
|
|
141
|
+
* 检查布局中已满列
|
|
142
|
+
* @returns {Array<number>} 各列元素占比
|
|
143
|
+
*/
|
|
144
|
+
colFullCheck() {
|
|
145
|
+
// 按列统计各列中元素占据宽度
|
|
146
|
+
const colItemSizeMap = this.children.reduce(
|
|
147
|
+
(map, item) => map.map((h, i) => (i >= item.x && i < item.x + item.w) ? h + item.h : h),
|
|
148
|
+
Array(this.layoutConfig.colNum).fill(0)
|
|
149
|
+
)
|
|
150
|
+
// 提取已满列编号
|
|
151
|
+
const fullCols = colItemSizeMap.map((v, i) => [i, v]).filter(([x, count]) => count >= this.layoutConfig.maxRows).map(([x]) => x)
|
|
152
|
+
this.fullCols = fullCols
|
|
153
|
+
return colItemSizeMap
|
|
154
|
+
},
|
|
155
|
+
// 拖拽缩放元素时触发, 提交元素缩放加锁
|
|
156
|
+
resizeEventHandler() {
|
|
157
|
+
this.$emit('resize-lock')
|
|
158
|
+
},
|
|
159
|
+
/**
|
|
160
|
+
* 拖拽缩放元素结束触发
|
|
161
|
+
* @param {string} i 元素 key
|
|
162
|
+
*/
|
|
163
|
+
resizedEventHandler(i, newH, newW) {
|
|
164
|
+
// 获取指向元素
|
|
165
|
+
const item = this.children.find(p => p.i === i)
|
|
166
|
+
// 计算当前布局下的溢出参数
|
|
167
|
+
const colItemSizeMap = this.colFullCheck()
|
|
168
|
+
// 提取当前元素所跨列的列占宽度
|
|
169
|
+
const sizesInRange = colItemSizeMap.filter((s, i) => i >= item.x && i < item.x + item.w)
|
|
170
|
+
const hasOverCol = sizesInRange.some(s => s > this.layoutConfig.maxRows)
|
|
171
|
+
this.$nextTick(() => {
|
|
172
|
+
if (hasOverCol) {
|
|
173
|
+
// 如果存在溢出列, 计算所有元素不溢出时, 最小元素高度削减量
|
|
174
|
+
const splitHeight = Math.max(...sizesInRange.map(s => Math.max(0, s - this.layoutConfig.maxRows)))
|
|
175
|
+
if ((item.h - splitHeight) <= 0) {
|
|
176
|
+
// 如果元素削减后高度为 0, 即横向拉伸时跨过了已满列
|
|
177
|
+
// 还原回上一次合法布局
|
|
178
|
+
this.backPrepLayout()
|
|
179
|
+
} else {
|
|
180
|
+
// 元素高度削减
|
|
181
|
+
item.h -= splitHeight
|
|
182
|
+
// 被顶出容器的元素归位
|
|
183
|
+
this.$refs.gridlayout.layoutUpdate()
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
// 元素缩放解锁
|
|
187
|
+
this.$emit('resize-unlock')
|
|
188
|
+
// 刷新布局缓存
|
|
189
|
+
this.itemExnterHandler()
|
|
190
|
+
})
|
|
191
|
+
},
|
|
192
|
+
// 拖拽元素排序时触发, 提交元素拖拽加缩
|
|
193
|
+
moveEventHandler() {
|
|
194
|
+
this.$emit('move-lock')
|
|
195
|
+
},
|
|
196
|
+
/**
|
|
197
|
+
* 拖拽元素排序完毕触发
|
|
198
|
+
* @param {string} i 元素 key
|
|
199
|
+
*/
|
|
200
|
+
movedEventHandler(i) {
|
|
201
|
+
const colItemSizeMap = this.colFullCheck()
|
|
202
|
+
// 元素移动至非满列, 或元素在原有列间排序
|
|
203
|
+
const hasOverCol = colItemSizeMap.some(s => s > this.layoutConfig.maxRows)
|
|
204
|
+
this.$nextTick(() => {
|
|
205
|
+
if (hasOverCol) {
|
|
206
|
+
// 移动后出现列溢出, 恢复至上一布局
|
|
207
|
+
this.backPrepLayout()
|
|
208
|
+
}
|
|
209
|
+
// 元素拖拽解锁
|
|
210
|
+
this.$emit('move-unlock')
|
|
211
|
+
// 刷新布局缓存
|
|
212
|
+
this.itemExnterHandler()
|
|
213
|
+
})
|
|
214
|
+
},
|
|
215
|
+
layoutCreatedEvent() {
|
|
216
|
+
// this.beforeLayoutChildren = _.cloneDeep(this.children)
|
|
217
|
+
},
|
|
218
|
+
/**
|
|
219
|
+
* 鼠标进入元素时触发, 防抖 100ms 限制
|
|
220
|
+
*/
|
|
221
|
+
itemExnterHandler() {},
|
|
222
|
+
// itemExnterHandler: _.debounce(function () {
|
|
223
|
+
// if (this.isDragging || this.isResizing) return;
|
|
224
|
+
// this.colFullCheck()
|
|
225
|
+
// this.beforeLayoutChildren = _.cloneDeep(this.children)
|
|
226
|
+
// }, 100),
|
|
227
|
+
/**
|
|
228
|
+
* 回到上一次合法布局, old: this.beforeLayoutChildren, recovered: this.instance.children
|
|
229
|
+
*/
|
|
230
|
+
backPrepLayout() {
|
|
231
|
+
this.instance.children.forEach(item => {
|
|
232
|
+
const origin = this.beforeLayoutChildren.find(p => p.i === item.i)
|
|
233
|
+
item.x = origin.x
|
|
234
|
+
item.y = origin.y
|
|
235
|
+
item.w = origin.w
|
|
236
|
+
item.h = origin.h
|
|
237
|
+
})
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
</script>
|
|
243
|
+
|
|
244
|
+
<style lang="scss" scoped>
|
|
245
|
+
.misp-card {
|
|
246
|
+
border-radius: 8px;
|
|
247
|
+
background-color: var(--base-bg);
|
|
248
|
+
&.box-shadow {
|
|
249
|
+
box-shadow: var(--box-shadow-3);
|
|
250
|
+
}
|
|
251
|
+
&.hover-up {
|
|
252
|
+
transition: transform 0.2s ease-out;
|
|
253
|
+
&:hover {
|
|
254
|
+
transform: translateY(-4px);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
.cursor-pointer {
|
|
259
|
+
cursor: pointer;
|
|
260
|
+
}
|
|
261
|
+
.misp-auto-grid {
|
|
262
|
+
width: 100%;
|
|
263
|
+
height: 100%;
|
|
264
|
+
position: relative;
|
|
265
|
+
.container-mask {
|
|
266
|
+
z-index: 10;
|
|
267
|
+
position: absolute;
|
|
268
|
+
top: 0;
|
|
269
|
+
left: 0;
|
|
270
|
+
}
|
|
271
|
+
::v-deep .vue-grid-item {
|
|
272
|
+
transition: transform .15s ease;
|
|
273
|
+
}
|
|
274
|
+
.grid-item-wrapper {
|
|
275
|
+
position: relative;
|
|
276
|
+
> .delete-wrapper {
|
|
277
|
+
display: none;
|
|
278
|
+
position: absolute;
|
|
279
|
+
top: 0;
|
|
280
|
+
right: 0;
|
|
281
|
+
}
|
|
282
|
+
&:hover > .delete-wrapper {
|
|
283
|
+
display: flex;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
</style>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOM 工具函数
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
let currentDir = 'auto'
|
|
6
|
+
|
|
7
|
+
function hasDocument() {
|
|
8
|
+
return typeof document !== 'undefined'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function hasWindow() {
|
|
12
|
+
return typeof window !== 'undefined'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function getDocumentDir() {
|
|
16
|
+
if (!hasDocument()) {
|
|
17
|
+
return currentDir
|
|
18
|
+
}
|
|
19
|
+
const direction = typeof document.dir !== 'undefined' ? document.dir : document.getElementsByTagName('html')[0].getAttribute('dir')
|
|
20
|
+
return direction
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function setDocumentDir(dir) {
|
|
24
|
+
if (!hasDocument()) {
|
|
25
|
+
currentDir = dir
|
|
26
|
+
return
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const html = document.getElementsByTagName('html')[0]
|
|
30
|
+
html.setAttribute('dir', dir)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function addWindowEventListener(event, callback) {
|
|
34
|
+
if (!hasWindow()) {
|
|
35
|
+
callback()
|
|
36
|
+
return
|
|
37
|
+
}
|
|
38
|
+
window.addEventListener(event, callback)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function removeWindowEventListener(event, callback) {
|
|
42
|
+
if (!hasWindow()) {
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
window.removeEventListener(event, callback)
|
|
46
|
+
}
|