@zkwq/business 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/dist/index.css +1 -0
- package/dist/index.js +21861 -0
- package/dist/index.umd.cjs +46 -0
- package/package.json +27 -0
- package/src/components/base/ui/alert/Alert.vue +94 -0
- package/src/components/base/ui/autocomplete/autocomplete-suggestions.vue +77 -0
- package/src/components/base/ui/autocomplete/autocomplete.vue +305 -0
- package/src/components/base/ui/backtop/main.vue +112 -0
- package/src/components/base/ui/button/Button.vue +84 -0
- package/src/components/base/ui/button/ButtonGroup.vue +10 -0
- package/src/components/base/ui/carousel/Carousel.vue +304 -0
- package/src/components/base/ui/carousel/CarouselItem.vue +137 -0
- package/src/components/base/ui/cascader/cascader.vue +650 -0
- package/src/components/base/ui/cascader-panel/cascader-menu.vue +138 -0
- package/src/components/base/ui/cascader-panel/cascader-node.vue +246 -0
- package/src/components/base/ui/cascader-panel/cascader-panel.vue +382 -0
- package/src/components/base/ui/cascader-panel/node.js +166 -0
- package/src/components/base/ui/cascader-panel/store.js +62 -0
- package/src/components/base/ui/checkbox/checkbox-button.vue +199 -0
- package/src/components/base/ui/checkbox/checkbox-group.vue +48 -0
- package/src/components/base/ui/checkbox/checkbox.vue +222 -0
- package/src/components/base/ui/col/col.js +71 -0
- package/src/components/base/ui/collapse/collapse-item.vue +180 -0
- package/src/components/base/ui/collapse/collapse.vue +73 -0
- package/src/components/base/ui/color-picker/color.js +317 -0
- package/src/components/base/ui/color-picker/components/alpha-slider.vue +132 -0
- package/src/components/base/ui/color-picker/components/hue-slider.vue +123 -0
- package/src/components/base/ui/color-picker/components/picker-dropdown.vue +119 -0
- package/src/components/base/ui/color-picker/components/predefine.vue +61 -0
- package/src/components/base/ui/color-picker/components/sv-panel.vue +100 -0
- package/src/components/base/ui/color-picker/draggable.js +36 -0
- package/src/components/base/ui/color-picker/index.js +2 -0
- package/src/components/base/ui/color-picker/main.vue +188 -0
- package/src/components/base/ui/date-picker/basic/date-table.vue +441 -0
- package/src/components/base/ui/date-picker/basic/month-table.vue +254 -0
- package/src/components/base/ui/date-picker/basic/time-spinner.vue +304 -0
- package/src/components/base/ui/date-picker/basic/year-table.vue +101 -0
- package/src/components/base/ui/date-picker/panel/date-range.vue +680 -0
- package/src/components/base/ui/date-picker/panel/date.vue +597 -0
- package/src/components/base/ui/date-picker/panel/month-range.vue +289 -0
- package/src/components/base/ui/date-picker/panel/time-range.vue +248 -0
- package/src/components/base/ui/date-picker/panel/time-select.vue +178 -0
- package/src/components/base/ui/date-picker/panel/time.vue +186 -0
- package/src/components/base/ui/date-picker/picker/date-picker.js +43 -0
- package/src/components/base/ui/date-picker/picker/time-picker.js +39 -0
- package/src/components/base/ui/date-picker/picker/time-select.js +21 -0
- package/src/components/base/ui/date-picker/picker.vue +942 -0
- package/src/components/base/ui/dialog/Index.vue +212 -0
- package/src/components/base/ui/directive/repeat-click.js +24 -0
- package/src/components/base/ui/directive/ripple.js +303 -0
- package/src/components/base/ui/divider/Divider.vue +37 -0
- package/src/components/base/ui/drawer/Drawer.vue +202 -0
- package/src/components/base/ui/dropdown/dropdown-item.vue +39 -0
- package/src/components/base/ui/dropdown/dropdown-menu.vue +63 -0
- package/src/components/base/ui/dropdown/dropdown.vue +308 -0
- package/src/components/base/ui/form/Form.vue +167 -0
- package/src/components/base/ui/form/FormItem.vue +334 -0
- package/src/components/base/ui/form/LabelWrap.vue +69 -0
- package/src/components/base/ui/icon/icon.vue +13 -0
- package/src/components/base/ui/image/image-viewer.vue +302 -0
- package/src/components/base/ui/image/main.vue +248 -0
- package/src/components/base/ui/index.js +189 -0
- package/src/components/base/ui/input/Input.vue +438 -0
- package/src/components/base/ui/input/calcTextareaHeight.js +104 -0
- package/src/components/base/ui/input-number/input-number.vue +285 -0
- package/src/components/base/ui/locale/format.js +32 -0
- package/src/components/base/ui/locale/index.js +48 -0
- package/src/components/base/ui/locale/lang/zh-CN.js +120 -0
- package/src/components/base/ui/menu/menu-item-group.vue +45 -0
- package/src/components/base/ui/menu/menu-item.vue +112 -0
- package/src/components/base/ui/menu/menu-mixin.js +44 -0
- package/src/components/base/ui/menu/menu.vue +312 -0
- package/src/components/base/ui/menu/submenu.vue +408 -0
- package/src/components/base/ui/message/index.js +2 -0
- package/src/components/base/ui/message/main.js +87 -0
- package/src/components/base/ui/message/main.vue +110 -0
- package/src/components/base/ui/message-box/main.js +216 -0
- package/src/components/base/ui/message-box/main.vue +323 -0
- package/src/components/base/ui/mixin/emitter.js +31 -0
- package/src/components/base/ui/mixin/focus.js +9 -0
- package/src/components/base/ui/mixin/locale.js +9 -0
- package/src/components/base/ui/mixin/migrating.js +33 -0
- package/src/components/base/ui/pagination/pager.vue +163 -0
- package/src/components/base/ui/pagination/pagination.jsx +391 -0
- package/src/components/base/ui/popover/directive.js +20 -0
- package/src/components/base/ui/popover/index.js +14 -0
- package/src/components/base/ui/popover/main.vue +236 -0
- package/src/components/base/ui/progress/Progress.vue +227 -0
- package/src/components/base/ui/radio/radio-button.vue +114 -0
- package/src/components/base/ui/radio/radio-group.vue +111 -0
- package/src/components/base/ui/radio/radio.vue +134 -0
- package/src/components/base/ui/row/row.js +47 -0
- package/src/components/base/ui/scrollbar/bar.jsx +91 -0
- package/src/components/base/ui/scrollbar/index.jsx +203 -0
- package/src/components/base/ui/scrollbar/util.js +32 -0
- package/src/components/base/ui/select/Option.vue +168 -0
- package/src/components/base/ui/select/OptionGroup.vue +60 -0
- package/src/components/base/ui/select/Select.vue +920 -0
- package/src/components/base/ui/select/SelectDropdown.vue +74 -0
- package/src/components/base/ui/select/navigation-mixin.js +54 -0
- package/src/components/base/ui/skeleton/index.js +8 -0
- package/src/components/base/ui/skeleton/src/img-placeholder.vue +16 -0
- package/src/components/base/ui/skeleton/src/index.vue +80 -0
- package/src/components/base/ui/skeleton/src/item.vue +22 -0
- package/src/components/base/ui/skeleton-item/index.js +8 -0
- package/src/components/base/ui/slider/button.vue +238 -0
- package/src/components/base/ui/slider/main.vue +427 -0
- package/src/components/base/ui/slider/marker.js +18 -0
- package/src/components/base/ui/style/alert.scss +147 -0
- package/src/components/base/ui/style/animations.scss +65 -0
- package/src/components/base/ui/style/autocomplete.scss +81 -0
- package/src/components/base/ui/style/backtop.scss +20 -0
- package/src/components/base/ui/style/button-group.scss +0 -0
- package/src/components/base/ui/style/button.scss +380 -0
- package/src/components/base/ui/style/carousel-item.scss +50 -0
- package/src/components/base/ui/style/carousel.scss +161 -0
- package/src/components/base/ui/style/cascader-panel.scss +120 -0
- package/src/components/base/ui/style/cascader.scss +185 -0
- package/src/components/base/ui/style/checkbox-button.scss +0 -0
- package/src/components/base/ui/style/checkbox-group.scss +0 -0
- package/src/components/base/ui/style/checkbox.scss +360 -0
- package/src/components/base/ui/style/col.scss +156 -0
- package/src/components/base/ui/style/collapse-item.scss +0 -0
- package/src/components/base/ui/style/collapse.scss +114 -0
- package/src/components/base/ui/style/color-picker.scss +387 -0
- package/src/components/base/ui/style/config.scss +4 -0
- package/src/components/base/ui/style/date-picker/date-picker.scss +97 -0
- package/src/components/base/ui/style/date-picker/date-range-picker.scss +101 -0
- package/src/components/base/ui/style/date-picker/date-table.scss +151 -0
- package/src/components/base/ui/style/date-picker/month-table.scss +82 -0
- package/src/components/base/ui/style/date-picker/picker-panel.scss +117 -0
- package/src/components/base/ui/style/date-picker/picker.scss +197 -0
- package/src/components/base/ui/style/date-picker/time-picker.scss +85 -0
- package/src/components/base/ui/style/date-picker/time-range-picker.scss +31 -0
- package/src/components/base/ui/style/date-picker/time-spinner.scss +110 -0
- package/src/components/base/ui/style/date-picker/year-table.scss +51 -0
- package/src/components/base/ui/style/date-picker.scss +12 -0
- package/src/components/base/ui/style/dialog.scss +123 -0
- package/src/components/base/ui/style/divider.scss +47 -0
- package/src/components/base/ui/style/drawer.scss +218 -0
- package/src/components/base/ui/style/dropdown-item.scss +0 -0
- package/src/components/base/ui/style/dropdown-menu.scss +0 -0
- package/src/components/base/ui/style/dropdown.scss +185 -0
- package/src/components/base/ui/style/form-item.scss +0 -0
- package/src/components/base/ui/style/form.scss +203 -0
- package/src/components/base/ui/style/function.scss +43 -0
- package/src/components/base/ui/style/icon.scss +1167 -0
- package/src/components/base/ui/style/image.scss +184 -0
- package/src/components/base/ui/style/index.scss +57 -0
- package/src/components/base/ui/style/input-number.scss +187 -0
- package/src/components/base/ui/style/input.scss +477 -0
- package/src/components/base/ui/style/menu-item-group.scss +0 -0
- package/src/components/base/ui/style/menu-item.scss +0 -0
- package/src/components/base/ui/style/menu.scss +294 -0
- package/src/components/base/ui/style/message-box.scss +231 -0
- package/src/components/base/ui/style/message.scss +120 -0
- package/src/components/base/ui/style/mixins.scss +196 -0
- package/src/components/base/ui/style/option-group.scss +42 -0
- package/src/components/base/ui/style/option.scss +36 -0
- package/src/components/base/ui/style/pagination.scss +295 -0
- package/src/components/base/ui/style/popover.scss +40 -0
- package/src/components/base/ui/style/popper.scss +102 -0
- package/src/components/base/ui/style/popup.scss +42 -0
- package/src/components/base/ui/style/progress.scss +141 -0
- package/src/components/base/ui/style/radio-button.scss +113 -0
- package/src/components/base/ui/style/radio-group.scss +9 -0
- package/src/components/base/ui/style/radio.scss +203 -0
- package/src/components/base/ui/style/ripple.scss +35 -0
- package/src/components/base/ui/style/row.scss +39 -0
- package/src/components/base/ui/style/scrollbar.scss +75 -0
- package/src/components/base/ui/style/select-dropdown.scss +59 -0
- package/src/components/base/ui/style/select.scss +154 -0
- package/src/components/base/ui/style/skeleton-item.scss +84 -0
- package/src/components/base/ui/style/skeleton.scss +40 -0
- package/src/components/base/ui/style/slider.scss +250 -0
- package/src/components/base/ui/style/switch.scss +116 -0
- package/src/components/base/ui/style/tabs.scss +602 -0
- package/src/components/base/ui/style/tag.scss +174 -0
- package/src/components/base/ui/style/tooltip.scss +146 -0
- package/src/components/base/ui/style/transition.scss +138 -0
- package/src/components/base/ui/style/upload.scss +603 -0
- package/src/components/base/ui/style/utils.scss +39 -0
- package/src/components/base/ui/style/var.scss +1007 -0
- package/src/components/base/ui/switch/index.vue +174 -0
- package/src/components/base/ui/tabs/tab-bar.vue +57 -0
- package/src/components/base/ui/tabs/tab-nav.vue +294 -0
- package/src/components/base/ui/tabs/tab-pane.vue +56 -0
- package/src/components/base/ui/tabs/tabs.vue +191 -0
- package/src/components/base/ui/tag/Tag.vue +60 -0
- package/src/components/base/ui/tooltip/tooltip.jsx +234 -0
- package/src/components/base/ui/upload/Index.vue +340 -0
- package/src/components/base/ui/upload/Upload.vue +216 -0
- package/src/components/base/ui/upload/UploadDragger.vue +70 -0
- package/src/components/base/ui/upload/UploadList.vue +100 -0
- package/src/components/base/ui/upload/ajax.js +85 -0
- package/src/components/base/ui/util/aria-dialog.js +90 -0
- package/src/components/base/ui/util/aria-utils.js +122 -0
- package/src/components/base/ui/util/clickoutside.js +76 -0
- package/src/components/base/ui/util/date-util.js +292 -0
- package/src/components/base/ui/util/date.js +370 -0
- package/src/components/base/ui/util/debounce.js +21 -0
- package/src/components/base/ui/util/deepmerge.js +100 -0
- package/src/components/base/ui/util/dom.js +215 -0
- package/src/components/base/ui/util/index.js +262 -0
- package/src/components/base/ui/util/menu/aria-menubar.js +14 -0
- package/src/components/base/ui/util/menu/aria-menuitem.js +49 -0
- package/src/components/base/ui/util/menu/aria-submenu.js +59 -0
- package/src/components/base/ui/util/merge.js +14 -0
- package/src/components/base/ui/util/popper.js +1235 -0
- package/src/components/base/ui/util/popup/index.js +218 -0
- package/src/components/base/ui/util/popup/popup-manager.js +194 -0
- package/src/components/base/ui/util/resize-events.js +32 -0
- package/src/components/base/ui/util/scroll-into-view.js +27 -0
- package/src/components/base/ui/util/scrollbar-width.js +29 -0
- package/src/components/base/ui/util/shared.js +7 -0
- package/src/components/base/ui/util/throttle.js +91 -0
- package/src/components/base/ui/util/types.js +24 -0
- package/src/components/base/ui/util/vdom.js +5 -0
- package/src/components/base/ui/util/vue-popper.js +188 -0
- package/src/components/normal/AggsItemH.vue +139 -0
- package/src/index.js +10 -0
- package/src/static/base-icons.ttf +0 -0
- package/src/static/base-icons.woff +0 -0
- package/src/static/label_bg.png +0 -0
- package/src/static/term-label-bg.png +0 -0
- package/src/style/app-article.scss +698 -0
- package/src/style/app-comment.scss +259 -0
- package/src/style/app-recommend.scss +48 -0
- package/src/style/app-richtext.scss +176 -0
- package/src/style/index.scss +523 -0
- package/vite.config.js +38 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import Vue from 'vue'
|
|
2
|
+
import merge from '../merge'
|
|
3
|
+
import PopupManager from './popup-manager'
|
|
4
|
+
import getScrollBarWidth from '../scrollbar-width'
|
|
5
|
+
import { getStyle, addClass, removeClass, hasClass } from '../dom'
|
|
6
|
+
|
|
7
|
+
let idSeed = 1
|
|
8
|
+
|
|
9
|
+
let scrollBarWidth
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
props: {
|
|
13
|
+
visible: {
|
|
14
|
+
type: Boolean,
|
|
15
|
+
default: false
|
|
16
|
+
},
|
|
17
|
+
openDelay: {},
|
|
18
|
+
closeDelay: {},
|
|
19
|
+
zIndex: {},
|
|
20
|
+
modal: {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
default: false
|
|
23
|
+
},
|
|
24
|
+
modalFade: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: true
|
|
27
|
+
},
|
|
28
|
+
modalClass: {},
|
|
29
|
+
modalAppendToBody: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: false
|
|
32
|
+
},
|
|
33
|
+
lockScroll: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: true
|
|
36
|
+
},
|
|
37
|
+
closeOnPressEscape: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: false
|
|
40
|
+
},
|
|
41
|
+
closeOnClickModal: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
default: false
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
beforeMount() {
|
|
48
|
+
this._popupId = 'popup-' + idSeed++
|
|
49
|
+
PopupManager.register(this._popupId, this)
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
beforeDestroy() {
|
|
53
|
+
PopupManager.deregister(this._popupId)
|
|
54
|
+
PopupManager.closeModal(this._popupId)
|
|
55
|
+
|
|
56
|
+
this.restoreBodyStyle()
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
data() {
|
|
60
|
+
return {
|
|
61
|
+
opened: false,
|
|
62
|
+
bodyPaddingRight: null,
|
|
63
|
+
computedBodyPaddingRight: 0,
|
|
64
|
+
withoutHiddenClass: true,
|
|
65
|
+
rendered: false
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
watch: {
|
|
70
|
+
visible(val) {
|
|
71
|
+
if (val) {
|
|
72
|
+
if (this._opening) return
|
|
73
|
+
if (!this.rendered) {
|
|
74
|
+
this.rendered = true
|
|
75
|
+
Vue.nextTick(() => {
|
|
76
|
+
this.open()
|
|
77
|
+
})
|
|
78
|
+
} else {
|
|
79
|
+
this.open()
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
this.close()
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
methods: {
|
|
88
|
+
open(options) {
|
|
89
|
+
if (!this.rendered) {
|
|
90
|
+
this.rendered = true
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const props = merge({}, this.$props || this, options)
|
|
94
|
+
|
|
95
|
+
if (this._closeTimer) {
|
|
96
|
+
clearTimeout(this._closeTimer)
|
|
97
|
+
this._closeTimer = null
|
|
98
|
+
}
|
|
99
|
+
clearTimeout(this._openTimer)
|
|
100
|
+
|
|
101
|
+
const openDelay = Number(props.openDelay)
|
|
102
|
+
if (openDelay > 0) {
|
|
103
|
+
this._openTimer = setTimeout(() => {
|
|
104
|
+
this._openTimer = null
|
|
105
|
+
this.doOpen(props)
|
|
106
|
+
}, openDelay)
|
|
107
|
+
} else {
|
|
108
|
+
this.doOpen(props)
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
doOpen(props) {
|
|
113
|
+
if (this.$isServer) return
|
|
114
|
+
if (this.willOpen && !this.willOpen()) return
|
|
115
|
+
if (this.opened) return
|
|
116
|
+
|
|
117
|
+
this._opening = true
|
|
118
|
+
|
|
119
|
+
const dom = this.$el
|
|
120
|
+
|
|
121
|
+
const modal = props.modal
|
|
122
|
+
|
|
123
|
+
const zIndex = props.zIndex
|
|
124
|
+
if (zIndex) {
|
|
125
|
+
PopupManager.zIndex = zIndex
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (modal) {
|
|
129
|
+
if (this._closing) {
|
|
130
|
+
PopupManager.closeModal(this._popupId)
|
|
131
|
+
this._closing = false
|
|
132
|
+
}
|
|
133
|
+
PopupManager.openModal(this._popupId, PopupManager.nextZIndex(), this.modalAppendToBody ? undefined : dom, props.modalClass, props.modalFade)
|
|
134
|
+
if (props.lockScroll) {
|
|
135
|
+
this.withoutHiddenClass = !hasClass(document.body, 'base-popup-parent--hidden')
|
|
136
|
+
if (this.withoutHiddenClass) {
|
|
137
|
+
this.bodyPaddingRight = document.body.style.paddingRight
|
|
138
|
+
this.computedBodyPaddingRight = parseInt(getStyle(document.body, 'paddingRight'), 10)
|
|
139
|
+
}
|
|
140
|
+
scrollBarWidth = getScrollBarWidth()
|
|
141
|
+
let bodyHasOverflow = document.documentElement.clientHeight < document.body.scrollHeight
|
|
142
|
+
let bodyOverflowY = getStyle(document.body, 'overflowY')
|
|
143
|
+
if (scrollBarWidth > 0 && (bodyHasOverflow || bodyOverflowY === 'scroll') && this.withoutHiddenClass) {
|
|
144
|
+
document.body.style.paddingRight = this.computedBodyPaddingRight + scrollBarWidth + 'px'
|
|
145
|
+
}
|
|
146
|
+
addClass(document.body, 'base-popup-parent--hidden')
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (getComputedStyle(dom).position === 'static') {
|
|
151
|
+
dom.style.position = 'absolute'
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
dom.style.zIndex = PopupManager.nextZIndex()
|
|
155
|
+
this.opened = true
|
|
156
|
+
|
|
157
|
+
this.onOpen && this.onOpen()
|
|
158
|
+
|
|
159
|
+
this.doAfterOpen()
|
|
160
|
+
},
|
|
161
|
+
|
|
162
|
+
doAfterOpen() {
|
|
163
|
+
this._opening = false
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
close() {
|
|
167
|
+
if (this.willClose && !this.willClose()) return
|
|
168
|
+
|
|
169
|
+
if (this._openTimer !== null) {
|
|
170
|
+
clearTimeout(this._openTimer)
|
|
171
|
+
this._openTimer = null
|
|
172
|
+
}
|
|
173
|
+
clearTimeout(this._closeTimer)
|
|
174
|
+
|
|
175
|
+
const closeDelay = Number(this.closeDelay)
|
|
176
|
+
|
|
177
|
+
if (closeDelay > 0) {
|
|
178
|
+
this._closeTimer = setTimeout(() => {
|
|
179
|
+
this._closeTimer = null
|
|
180
|
+
this.doClose()
|
|
181
|
+
}, closeDelay)
|
|
182
|
+
} else {
|
|
183
|
+
this.doClose()
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
|
|
187
|
+
doClose() {
|
|
188
|
+
this._closing = true
|
|
189
|
+
|
|
190
|
+
this.onClose && this.onClose()
|
|
191
|
+
|
|
192
|
+
if (this.lockScroll) {
|
|
193
|
+
setTimeout(this.restoreBodyStyle, 200)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
this.opened = false
|
|
197
|
+
|
|
198
|
+
this.doAfterClose()
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
doAfterClose() {
|
|
202
|
+
PopupManager.closeModal(this._popupId)
|
|
203
|
+
this._closing = false
|
|
204
|
+
},
|
|
205
|
+
|
|
206
|
+
restoreBodyStyle() {
|
|
207
|
+
if (this.modal && this.withoutHiddenClass) {
|
|
208
|
+
document.body.style.paddingRight = this.bodyPaddingRight
|
|
209
|
+
removeClass(document.body, 'base-popup-parent--hidden')
|
|
210
|
+
}
|
|
211
|
+
this.withoutHiddenClass = true
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export {
|
|
217
|
+
PopupManager
|
|
218
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import Vue from 'vue'
|
|
2
|
+
import { addClass, removeClass } from '../dom'
|
|
3
|
+
|
|
4
|
+
let hasModal = false
|
|
5
|
+
let hasInitZIndex = false
|
|
6
|
+
let zIndex
|
|
7
|
+
|
|
8
|
+
const getModal = function() {
|
|
9
|
+
if (Vue.prototype.$isServer) return
|
|
10
|
+
let modalDom = PopupManager.modalDom
|
|
11
|
+
if (modalDom) {
|
|
12
|
+
hasModal = true
|
|
13
|
+
} else {
|
|
14
|
+
hasModal = false
|
|
15
|
+
modalDom = document.createElement('div')
|
|
16
|
+
PopupManager.modalDom = modalDom
|
|
17
|
+
|
|
18
|
+
modalDom.addEventListener('touchmove', function(event) {
|
|
19
|
+
event.preventDefault()
|
|
20
|
+
event.stopPropagation()
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
modalDom.addEventListener('click', function() {
|
|
24
|
+
PopupManager.doOnModalClick && PopupManager.doOnModalClick()
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return modalDom
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const instances = {}
|
|
32
|
+
|
|
33
|
+
const PopupManager = {
|
|
34
|
+
modalFade: true,
|
|
35
|
+
|
|
36
|
+
getInstance: function(id) {
|
|
37
|
+
return instances[id]
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
register: function(id, instance) {
|
|
41
|
+
if (id && instance) {
|
|
42
|
+
instances[id] = instance
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
deregister: function(id) {
|
|
47
|
+
if (id) {
|
|
48
|
+
instances[id] = null
|
|
49
|
+
delete instances[id]
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
nextZIndex: function() {
|
|
54
|
+
return PopupManager.zIndex++
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
modalStack: [],
|
|
58
|
+
|
|
59
|
+
doOnModalClick: function() {
|
|
60
|
+
const topItem = PopupManager.modalStack[PopupManager.modalStack.length - 1]
|
|
61
|
+
if (!topItem) return
|
|
62
|
+
|
|
63
|
+
const instance = PopupManager.getInstance(topItem.id)
|
|
64
|
+
if (instance && instance.closeOnClickModal) {
|
|
65
|
+
instance.close()
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
openModal: function(id, zIndex, dom, modalClass, modalFade) {
|
|
70
|
+
if (Vue.prototype.$isServer) return
|
|
71
|
+
if (!id || zIndex === undefined) return
|
|
72
|
+
this.modalFade = modalFade
|
|
73
|
+
|
|
74
|
+
const modalStack = this.modalStack
|
|
75
|
+
|
|
76
|
+
for (let i = 0, j = modalStack.length; i < j; i++) {
|
|
77
|
+
const item = modalStack[i]
|
|
78
|
+
if (item.id === id) {
|
|
79
|
+
return
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const modalDom = getModal()
|
|
84
|
+
|
|
85
|
+
addClass(modalDom, 'v-modal')
|
|
86
|
+
if (this.modalFade && !hasModal) {
|
|
87
|
+
addClass(modalDom, 'v-modal-enter')
|
|
88
|
+
}
|
|
89
|
+
if (modalClass) {
|
|
90
|
+
let classArr = modalClass.trim().split(/\s+/)
|
|
91
|
+
classArr.forEach(item => addClass(modalDom, item))
|
|
92
|
+
}
|
|
93
|
+
setTimeout(() => {
|
|
94
|
+
removeClass(modalDom, 'v-modal-enter')
|
|
95
|
+
}, 200)
|
|
96
|
+
|
|
97
|
+
if (dom && dom.parentNode && dom.parentNode.nodeType !== 11) {
|
|
98
|
+
dom.parentNode.appendChild(modalDom)
|
|
99
|
+
} else {
|
|
100
|
+
document.body.appendChild(modalDom)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (zIndex) {
|
|
104
|
+
modalDom.style.zIndex = zIndex
|
|
105
|
+
}
|
|
106
|
+
modalDom.tabIndex = 0
|
|
107
|
+
modalDom.style.display = ''
|
|
108
|
+
|
|
109
|
+
this.modalStack.push({ id: id, zIndex: zIndex, modalClass: modalClass })
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
closeModal: function(id) {
|
|
113
|
+
const modalStack = this.modalStack
|
|
114
|
+
const modalDom = getModal()
|
|
115
|
+
|
|
116
|
+
if (modalStack.length > 0) {
|
|
117
|
+
const topItem = modalStack[modalStack.length - 1]
|
|
118
|
+
if (topItem.id === id) {
|
|
119
|
+
if (topItem.modalClass) {
|
|
120
|
+
let classArr = topItem.modalClass.trim().split(/\s+/)
|
|
121
|
+
classArr.forEach(item => removeClass(modalDom, item))
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
modalStack.pop()
|
|
125
|
+
if (modalStack.length > 0) {
|
|
126
|
+
modalDom.style.zIndex = modalStack[modalStack.length - 1].zIndex
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
for (let i = modalStack.length - 1; i >= 0; i--) {
|
|
130
|
+
if (modalStack[i].id === id) {
|
|
131
|
+
modalStack.splice(i, 1)
|
|
132
|
+
break
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (modalStack.length === 0) {
|
|
139
|
+
if (this.modalFade) {
|
|
140
|
+
addClass(modalDom, 'v-modal-leave')
|
|
141
|
+
}
|
|
142
|
+
setTimeout(() => {
|
|
143
|
+
if (modalStack.length === 0) {
|
|
144
|
+
if (modalDom.parentNode) modalDom.parentNode.removeChild(modalDom)
|
|
145
|
+
modalDom.style.display = 'none'
|
|
146
|
+
PopupManager.modalDom = undefined
|
|
147
|
+
}
|
|
148
|
+
removeClass(modalDom, 'v-modal-leave')
|
|
149
|
+
}, 200)
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
Object.defineProperty(PopupManager, 'zIndex', {
|
|
155
|
+
configurable: true,
|
|
156
|
+
get() {
|
|
157
|
+
if (!hasInitZIndex) {
|
|
158
|
+
zIndex = zIndex || (Vue.prototype.$ELEMENT || {}).zIndex || 2000
|
|
159
|
+
hasInitZIndex = true
|
|
160
|
+
}
|
|
161
|
+
return zIndex
|
|
162
|
+
},
|
|
163
|
+
set(value) {
|
|
164
|
+
zIndex = value
|
|
165
|
+
}
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
const getTopPopup = function() {
|
|
169
|
+
if (Vue.prototype.$isServer) return
|
|
170
|
+
if (PopupManager.modalStack.length > 0) {
|
|
171
|
+
const topPopup = PopupManager.modalStack[PopupManager.modalStack.length - 1]
|
|
172
|
+
if (!topPopup) return
|
|
173
|
+
const instance = PopupManager.getInstance(topPopup.id)
|
|
174
|
+
|
|
175
|
+
return instance
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (!Vue.prototype.$isServer) {
|
|
180
|
+
// handle `esc` key when the popup is shown
|
|
181
|
+
window.addEventListener('keydown', function(event) {
|
|
182
|
+
if (event.keyCode === 27) {
|
|
183
|
+
const topPopup = getTopPopup()
|
|
184
|
+
|
|
185
|
+
if (topPopup && topPopup.closeOnPressEscape) {
|
|
186
|
+
topPopup.handleClose
|
|
187
|
+
? topPopup.handleClose()
|
|
188
|
+
: (topPopup.handleAction ? topPopup.handleAction('cancel') : topPopup.close())
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
})
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export default PopupManager
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import ResizeObserver from 'resize-observer-polyfill'
|
|
2
|
+
|
|
3
|
+
const isServer = typeof window === 'undefined'
|
|
4
|
+
|
|
5
|
+
const resizeHandler = function(entries) {
|
|
6
|
+
for (let entry of entries) {
|
|
7
|
+
const listeners = entry.target.__resizeListeners__ || []
|
|
8
|
+
if (listeners.length) {
|
|
9
|
+
listeners.forEach(fn => {
|
|
10
|
+
fn()
|
|
11
|
+
})
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const addResizeListener = function(element, fn) {
|
|
17
|
+
if (isServer) return
|
|
18
|
+
if (!element.__resizeListeners__) {
|
|
19
|
+
element.__resizeListeners__ = []
|
|
20
|
+
element.__ro__ = new ResizeObserver(resizeHandler)
|
|
21
|
+
element.__ro__.observe(element)
|
|
22
|
+
}
|
|
23
|
+
element.__resizeListeners__.push(fn)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const removeResizeListener = function(element, fn) {
|
|
27
|
+
if (!element || !element.__resizeListeners__) return
|
|
28
|
+
element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1)
|
|
29
|
+
if (!element.__resizeListeners__.length) {
|
|
30
|
+
element.__ro__.disconnect()
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import Vue from 'vue'
|
|
2
|
+
|
|
3
|
+
export default function scrollIntoView(container, selected) {
|
|
4
|
+
if (Vue.prototype.$isServer) return
|
|
5
|
+
|
|
6
|
+
if (!selected) {
|
|
7
|
+
container.scrollTop = 0
|
|
8
|
+
return
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const offsetParents = []
|
|
12
|
+
let pointer = selected.offsetParent
|
|
13
|
+
while (pointer && container !== pointer && container.contains(pointer)) {
|
|
14
|
+
offsetParents.push(pointer)
|
|
15
|
+
pointer = pointer.offsetParent
|
|
16
|
+
}
|
|
17
|
+
const top = selected.offsetTop + offsetParents.reduce((prev, curr) => (prev + curr.offsetTop), 0)
|
|
18
|
+
const bottom = top + selected.offsetHeight
|
|
19
|
+
const viewRectTop = container.scrollTop
|
|
20
|
+
const viewRectBottom = viewRectTop + container.clientHeight
|
|
21
|
+
|
|
22
|
+
if (top < viewRectTop) {
|
|
23
|
+
container.scrollTop = top
|
|
24
|
+
} else if (bottom > viewRectBottom) {
|
|
25
|
+
container.scrollTop = bottom - container.clientHeight
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import Vue from 'vue'
|
|
2
|
+
|
|
3
|
+
let scrollBarWidth
|
|
4
|
+
|
|
5
|
+
export default function() {
|
|
6
|
+
if (Vue.prototype.$isServer) return 0
|
|
7
|
+
if (scrollBarWidth !== undefined) return scrollBarWidth
|
|
8
|
+
|
|
9
|
+
const outer = document.createElement('div')
|
|
10
|
+
outer.className = 'base-scrollbar__wrap'
|
|
11
|
+
outer.style.visibility = 'hidden'
|
|
12
|
+
outer.style.width = '100px'
|
|
13
|
+
outer.style.position = 'absolute'
|
|
14
|
+
outer.style.top = '-9999px'
|
|
15
|
+
document.body.appendChild(outer)
|
|
16
|
+
|
|
17
|
+
const widthNoScroll = outer.offsetWidth
|
|
18
|
+
outer.style.overflow = 'scroll'
|
|
19
|
+
|
|
20
|
+
const inner = document.createElement('div')
|
|
21
|
+
inner.style.width = '100%'
|
|
22
|
+
outer.appendChild(inner)
|
|
23
|
+
|
|
24
|
+
const widthWithScroll = inner.offsetWidth
|
|
25
|
+
outer.parentNode.removeChild(outer)
|
|
26
|
+
scrollBarWidth = widthNoScroll - widthWithScroll
|
|
27
|
+
|
|
28
|
+
return scrollBarWidth
|
|
29
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/* eslint-disable no-undefined,no-param-reassign,no-shadow */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Throttle execution of a function. Especially useful for rate limiting
|
|
5
|
+
* execution of handlers on events like resize and scroll.
|
|
6
|
+
*
|
|
7
|
+
* @param {Number} delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
|
|
8
|
+
* @param {Boolean} [noTrailing] Optional, defaults to false. If noTrailing is true, callback will only execute every `delay` milliseconds while the
|
|
9
|
+
* throttled-function is being called. If noTrailing is false or unspecified, callback will be executed one final time
|
|
10
|
+
* after the last throttled-function call. (After the throttled-function has not been called for `delay` milliseconds,
|
|
11
|
+
* the internal counter is reset)
|
|
12
|
+
* @param {Function} callback A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,
|
|
13
|
+
* to `callback` when the throttled-function is executed.
|
|
14
|
+
* @param {Boolean} [debounceMode] If `debounceMode` is true (at begin), schedule `clear` to execute after `delay` ms. If `debounceMode` is false (at end),
|
|
15
|
+
* schedule `callback` to execute after `delay` ms.
|
|
16
|
+
*
|
|
17
|
+
* @return {Function} A new, throttled, function.
|
|
18
|
+
*/
|
|
19
|
+
export default function ( delay, noTrailing, callback, debounceMode ) {
|
|
20
|
+
|
|
21
|
+
// After wrapper has stopped being called, this timeout ensures that
|
|
22
|
+
// `callback` is executed at the proper times in `throttle` and `end`
|
|
23
|
+
// debounce modes.
|
|
24
|
+
var timeoutID;
|
|
25
|
+
|
|
26
|
+
// Keep track of the last time `callback` was executed.
|
|
27
|
+
var lastExec = 0;
|
|
28
|
+
|
|
29
|
+
// `noTrailing` defaults to falsy.
|
|
30
|
+
if ( typeof noTrailing !== 'boolean' ) {
|
|
31
|
+
debounceMode = callback;
|
|
32
|
+
callback = noTrailing;
|
|
33
|
+
noTrailing = undefined;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// The `wrapper` function encapsulates all of the throttling / debouncing
|
|
37
|
+
// functionality and when executed will limit the rate at which `callback`
|
|
38
|
+
// is executed.
|
|
39
|
+
function wrapper () {
|
|
40
|
+
|
|
41
|
+
var self = this;
|
|
42
|
+
var elapsed = Number(new Date()) - lastExec;
|
|
43
|
+
var args = arguments;
|
|
44
|
+
|
|
45
|
+
// Execute `callback` and update the `lastExec` timestamp.
|
|
46
|
+
function exec () {
|
|
47
|
+
lastExec = Number(new Date());
|
|
48
|
+
callback.apply(self, args);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// If `debounceMode` is true (at begin) this is used to clear the flag
|
|
52
|
+
// to allow future `callback` executions.
|
|
53
|
+
function clear () {
|
|
54
|
+
timeoutID = undefined;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if ( debounceMode && !timeoutID ) {
|
|
58
|
+
// Since `wrapper` is being called for the first time and
|
|
59
|
+
// `debounceMode` is true (at begin), execute `callback`.
|
|
60
|
+
exec();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Clear any existing timeout.
|
|
64
|
+
if ( timeoutID ) {
|
|
65
|
+
clearTimeout(timeoutID);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if ( debounceMode === undefined && elapsed > delay ) {
|
|
69
|
+
// In throttle mode, if `delay` time has been exceeded, execute
|
|
70
|
+
// `callback`.
|
|
71
|
+
exec();
|
|
72
|
+
|
|
73
|
+
} else if ( noTrailing !== true ) {
|
|
74
|
+
// In trailing throttle mode, since `delay` time has not been
|
|
75
|
+
// exceeded, schedule `callback` to execute `delay` ms after most
|
|
76
|
+
// recent execution.
|
|
77
|
+
//
|
|
78
|
+
// If `debounceMode` is true (at begin), schedule `clear` to execute
|
|
79
|
+
// after `delay` ms.
|
|
80
|
+
//
|
|
81
|
+
// If `debounceMode` is false (at end), schedule `callback` to
|
|
82
|
+
// execute after `delay` ms.
|
|
83
|
+
timeoutID = setTimeout(debounceMode ? clear : exec, debounceMode === undefined ? delay - elapsed : delay);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Return the wrapper function.
|
|
89
|
+
return wrapper;
|
|
90
|
+
|
|
91
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export function isString(obj) {
|
|
2
|
+
return Object.prototype.toString.call(obj) === '[object String]';
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function isObject(obj) {
|
|
6
|
+
return Object.prototype.toString.call(obj) === '[object Object]';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function isHtmlElement(node) {
|
|
10
|
+
return node && node.nodeType === Node.ELEMENT_NODE;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const isFunction = (functionToCheck) => {
|
|
14
|
+
var getType = {};
|
|
15
|
+
return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const isUndefined = (val)=> {
|
|
19
|
+
return val === void 0;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const isDefined = (val) => {
|
|
23
|
+
return val !== undefined && val !== null;
|
|
24
|
+
};
|