cbvirtua 1.0.6 → 1.0.7
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/menu/wzc-option.vue +74 -0
- package/menu/wzc-select.vue +209 -0
- package/package.json +1 -1
- package/v2/App.vue +0 -56
- package/v2/components/Dropdown.vue +0 -28
- package/v2/components/Menu.vue +0 -9
- package/v2/components/Popper.js +0 -1011
- package/v2/components/PopperContent.vue +0 -270
- package/v2/components/PopperMethods.js +0 -17
- package/v2/components/PopperWrapper.vue +0 -101
- package/v2/components/ResizeObserver.vue +0 -151
- package/v2/components/ThemeClass.js +0 -9
- package/v2/components/Tooltip.vue +0 -22
- package/v2/components/TooltipDirective.vue +0 -171
- package/v2/config.js +0 -133
- package/v2/directives/v-close-popper.js +0 -67
- package/v2/directives/v-tooltip.js +0 -116
- package/v2/floating-ui/core/computeCoordsFromPlacement.js +0 -39
- package/v2/floating-ui/core/computePosition.js +0 -52
- package/v2/floating-ui/core/detectOverflow.js +0 -36
- package/v2/floating-ui/core/enums.js +0 -7
- package/v2/floating-ui/core/index.js +0 -11
- package/v2/floating-ui/core/middleware/arrow.js +0 -52
- package/v2/floating-ui/core/middleware/autoPlacement.js +0 -84
- package/v2/floating-ui/core/middleware/flip.js +0 -82
- package/v2/floating-ui/core/middleware/hide.js +0 -36
- package/v2/floating-ui/core/middleware/inline.js +0 -100
- package/v2/floating-ui/core/middleware/offset.js +0 -26
- package/v2/floating-ui/core/middleware/shift.js +0 -99
- package/v2/floating-ui/core/middleware/size.js +0 -58
- package/v2/floating-ui/core/types.js +0 -11
- package/v2/floating-ui/core/utils/expandPaddingObject.js +0 -3
- package/v2/floating-ui/core/utils/getAlignment.js +0 -3
- package/v2/floating-ui/core/utils/getAlignmentSides.js +0 -23
- package/v2/floating-ui/core/utils/getBasePlacement.js +0 -3
- package/v2/floating-ui/core/utils/getCrossAxis.js +0 -3
- package/v2/floating-ui/core/utils/getExpandedPlacements.js +0 -10
- package/v2/floating-ui/core/utils/getLengthFromAxis.js +0 -3
- package/v2/floating-ui/core/utils/getMainAxisFromPlacement.js +0 -4
- package/v2/floating-ui/core/utils/getOppositeAlignmentPlacement.js +0 -4
- package/v2/floating-ui/core/utils/getOppositePlacement.js +0 -4
- package/v2/floating-ui/core/utils/getPaddingObject.js +0 -6
- package/v2/floating-ui/core/utils/math.js +0 -2
- package/v2/floating-ui/core/utils/rectToClientRect.js +0 -9
- package/v2/floating-ui/core/utils/within.js +0 -4
- package/v2/floating-ui/dom/index.js +0 -5
- package/v2/floating-ui/dom/platform.js +0 -20
- package/v2/floating-ui/dom/utils/contains.js +0 -22
- package/v2/floating-ui/dom/utils/convertOffsetParentRelativeRectToViewportRelativeRect.js +0 -35
- package/v2/floating-ui/dom/utils/getBoundingClientRect.js +0 -27
- package/v2/floating-ui/dom/utils/getClippingClientRect.js +0 -76
- package/v2/floating-ui/dom/utils/getComputedStyle.js +0 -4
- package/v2/floating-ui/dom/utils/getDimensions.js +0 -6
- package/v2/floating-ui/dom/utils/getDocumentElement.js +0 -4
- package/v2/floating-ui/dom/utils/getDocumentRect.js +0 -21
- package/v2/floating-ui/dom/utils/getNodeName.js +0 -4
- package/v2/floating-ui/dom/utils/getNodeScroll.js +0 -13
- package/v2/floating-ui/dom/utils/getOffsetParent.js +0 -43
- package/v2/floating-ui/dom/utils/getParentNode.js +0 -16
- package/v2/floating-ui/dom/utils/getRectRelativeToOffsetParent.js +0 -40
- package/v2/floating-ui/dom/utils/getScrollParent.js +0 -13
- package/v2/floating-ui/dom/utils/getScrollParents.js +0 -18
- package/v2/floating-ui/dom/utils/getViewportRect.js +0 -25
- package/v2/floating-ui/dom/utils/getWindowScrollBarX.js +0 -9
- package/v2/floating-ui/dom/utils/is.js +0 -38
- package/v2/floating-ui/dom/utils/math.js +0 -3
- package/v2/floating-ui/dom/utils/window.js +0 -13
- package/v2/index.js +0 -75
- package/v2/util/assign-deep.js +0 -12
- package/v2/util/env.js +0 -18
- package/v2/util/events.js +0 -12
- package/v2/util/frame.js +0 -5
- package/v2/util/lang.js +0 -6
- package/v2/util/popper.js +0 -5
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<Popper
|
|
3
|
-
ref="popper"
|
|
4
|
-
v-slot="{
|
|
5
|
-
popperId,
|
|
6
|
-
isShown,
|
|
7
|
-
shouldMountContent,
|
|
8
|
-
skipTransition,
|
|
9
|
-
autoHide,
|
|
10
|
-
hide,
|
|
11
|
-
handleResize,
|
|
12
|
-
onResize,
|
|
13
|
-
classes,
|
|
14
|
-
result,
|
|
15
|
-
}"
|
|
16
|
-
v-bind="$attrs"
|
|
17
|
-
:theme="theme"
|
|
18
|
-
:popper-node="() => $refs.popperContent.$el"
|
|
19
|
-
v-on="$listeners"
|
|
20
|
-
@apply-show="onShow"
|
|
21
|
-
@apply-hide="onHide"
|
|
22
|
-
>
|
|
23
|
-
<PopperContent
|
|
24
|
-
ref="popperContent"
|
|
25
|
-
:class="{
|
|
26
|
-
'v-popper--tooltip-loading': loading,
|
|
27
|
-
}"
|
|
28
|
-
:popper-id="popperId"
|
|
29
|
-
:theme="theme"
|
|
30
|
-
:shown="isShown"
|
|
31
|
-
:mounted="shouldMountContent"
|
|
32
|
-
:skip-transition="skipTransition"
|
|
33
|
-
:auto-hide="autoHide"
|
|
34
|
-
:handle-resize="handleResize"
|
|
35
|
-
:classes="classes"
|
|
36
|
-
:result="result"
|
|
37
|
-
@hide="hide"
|
|
38
|
-
@resize="onResize"
|
|
39
|
-
>
|
|
40
|
-
<div
|
|
41
|
-
v-if="html"
|
|
42
|
-
v-html="finalContent"
|
|
43
|
-
/>
|
|
44
|
-
<div
|
|
45
|
-
v-else
|
|
46
|
-
v-text="finalContent"
|
|
47
|
-
/>
|
|
48
|
-
</PopperContent>
|
|
49
|
-
</Popper>
|
|
50
|
-
</template>
|
|
51
|
-
|
|
52
|
-
<script lang="ts">
|
|
53
|
-
import Popper from './Popper'
|
|
54
|
-
import PopperContent from './PopperContent.vue'
|
|
55
|
-
import { getDefaultConfig } from '../config'
|
|
56
|
-
import PopperMethods from './PopperMethods'
|
|
57
|
-
|
|
58
|
-
export default {
|
|
59
|
-
name: 'VTooltipDirective',
|
|
60
|
-
|
|
61
|
-
components: {
|
|
62
|
-
Popper: Popper(),
|
|
63
|
-
PopperContent,
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
mixins: [
|
|
67
|
-
PopperMethods,
|
|
68
|
-
],
|
|
69
|
-
|
|
70
|
-
inheritAttrs: false,
|
|
71
|
-
|
|
72
|
-
props: {
|
|
73
|
-
theme: {
|
|
74
|
-
type: String,
|
|
75
|
-
default: 'tooltip',
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
html: {
|
|
79
|
-
type: Boolean,
|
|
80
|
-
default () {
|
|
81
|
-
return getDefaultConfig(this.theme, 'html')
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
content: {
|
|
86
|
-
type: [String, Number, Function],
|
|
87
|
-
default: null,
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
loadingContent: {
|
|
91
|
-
type: String,
|
|
92
|
-
default () {
|
|
93
|
-
return getDefaultConfig(this.theme, 'loadingContent')
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
data () {
|
|
99
|
-
return {
|
|
100
|
-
asyncContent: null,
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
computed: {
|
|
105
|
-
isContentAsync () {
|
|
106
|
-
return typeof this.content === 'function'
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
loading () {
|
|
110
|
-
return this.isContentAsync && this.asyncContent == null
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
finalContent () {
|
|
114
|
-
if (this.isContentAsync) {
|
|
115
|
-
return this.loading ? this.loadingContent : this.asyncContent
|
|
116
|
-
}
|
|
117
|
-
return this.content
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
|
|
121
|
-
watch: {
|
|
122
|
-
content: {
|
|
123
|
-
handler () {
|
|
124
|
-
this.fetchContent(true)
|
|
125
|
-
},
|
|
126
|
-
immediate: true,
|
|
127
|
-
},
|
|
128
|
-
|
|
129
|
-
async finalContent (value) {
|
|
130
|
-
await this.$nextTick()
|
|
131
|
-
this.$refs.popper.onResize()
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
|
|
135
|
-
created () {
|
|
136
|
-
this.$_fetchId = 0
|
|
137
|
-
},
|
|
138
|
-
|
|
139
|
-
methods: {
|
|
140
|
-
fetchContent (force) {
|
|
141
|
-
if (typeof this.content === 'function' && this.$_isShown &&
|
|
142
|
-
(force || (!this.$_loading && this.asyncContent == null))) {
|
|
143
|
-
this.asyncContent = null
|
|
144
|
-
this.$_loading = true
|
|
145
|
-
const fetchId = ++this.$_fetchId
|
|
146
|
-
const result = this.content(this)
|
|
147
|
-
if (result.then) {
|
|
148
|
-
result.then(res => this.onResult(fetchId, res))
|
|
149
|
-
} else {
|
|
150
|
-
this.onResult(fetchId, result)
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
|
|
155
|
-
onResult (fetchId, result) {
|
|
156
|
-
if (fetchId !== this.$_fetchId) return
|
|
157
|
-
this.$_loading = false
|
|
158
|
-
this.asyncContent = result
|
|
159
|
-
},
|
|
160
|
-
|
|
161
|
-
onShow () {
|
|
162
|
-
this.$_isShown = true
|
|
163
|
-
this.fetchContent()
|
|
164
|
-
},
|
|
165
|
-
|
|
166
|
-
onHide () {
|
|
167
|
-
this.$_isShown = false
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
}
|
|
171
|
-
</script>
|
package/v2/config.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
export const config = {
|
|
2
|
-
// Disable popper components
|
|
3
|
-
disabled: false,
|
|
4
|
-
// Default position offset along main axis (px)
|
|
5
|
-
distance: 5,
|
|
6
|
-
// Default position offset along cross axis (px)
|
|
7
|
-
skidding: 0,
|
|
8
|
-
// Default container where the tooltip will be appended
|
|
9
|
-
container: 'body',
|
|
10
|
-
// Element used to compute position and size boundaries
|
|
11
|
-
boundary: undefined,
|
|
12
|
-
// Skip delay & CSS transitions when another popper is shown, so that the popper appear to instanly move to the new position.
|
|
13
|
-
instantMove: false,
|
|
14
|
-
// Auto destroy tooltip DOM nodes (ms)
|
|
15
|
-
disposeTimeout: 5000,
|
|
16
|
-
// Triggers on the popper itself
|
|
17
|
-
popperTriggers: [],
|
|
18
|
-
// Positioning strategy
|
|
19
|
-
strategy: 'absolute',
|
|
20
|
-
// Prevent overflow
|
|
21
|
-
preventOverflow: true,
|
|
22
|
-
// Flip to the opposite placement if needed
|
|
23
|
-
flip: true,
|
|
24
|
-
// Shift on the cross axis to prevent the popper from overflowing
|
|
25
|
-
shift: true,
|
|
26
|
-
// Overflow padding (px)
|
|
27
|
-
overflowPadding: 0,
|
|
28
|
-
// Arrow padding (px)
|
|
29
|
-
arrowPadding: 0,
|
|
30
|
-
// Compute arrow overflow (useful to hide it)
|
|
31
|
-
arrowOverflow: true,
|
|
32
|
-
// Themes
|
|
33
|
-
themes: {
|
|
34
|
-
tooltip: {
|
|
35
|
-
// Default tooltip placement relative to target element
|
|
36
|
-
placement: 'top',
|
|
37
|
-
// Default events that trigger the tooltip
|
|
38
|
-
triggers: ['hover', 'focus', 'touch'],
|
|
39
|
-
// Close tooltip on click on tooltip target
|
|
40
|
-
hideTriggers: events => [...events, 'click'],
|
|
41
|
-
// Delay (ms)
|
|
42
|
-
delay: {
|
|
43
|
-
show: 200,
|
|
44
|
-
hide: 0,
|
|
45
|
-
},
|
|
46
|
-
// Update popper on content resize
|
|
47
|
-
handleResize: false,
|
|
48
|
-
// Enable HTML content in directive
|
|
49
|
-
html: false,
|
|
50
|
-
// Displayed when tooltip content is loading
|
|
51
|
-
loadingContent: '...',
|
|
52
|
-
},
|
|
53
|
-
dropdown: {
|
|
54
|
-
// Default dropdown placement relative to target element
|
|
55
|
-
placement: 'bottom',
|
|
56
|
-
// Default events that trigger the dropdown
|
|
57
|
-
triggers: ['click'],
|
|
58
|
-
// Delay (ms)
|
|
59
|
-
delay: 0,
|
|
60
|
-
// Update popper on content resize
|
|
61
|
-
handleResize: true,
|
|
62
|
-
// Hide on clock outside
|
|
63
|
-
autoHide: true,
|
|
64
|
-
},
|
|
65
|
-
menu: {
|
|
66
|
-
$extend: 'dropdown',
|
|
67
|
-
triggers: ['hover', 'focus'],
|
|
68
|
-
popperTriggers: ['hover', 'focus'],
|
|
69
|
-
delay: {
|
|
70
|
-
show: 0,
|
|
71
|
-
hide: 400,
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* Get default config value depending on theme
|
|
78
|
-
*/
|
|
79
|
-
export function getDefaultConfig(theme, key) {
|
|
80
|
-
let themeConfig = config.themes[theme] || {};
|
|
81
|
-
let value;
|
|
82
|
-
do {
|
|
83
|
-
value = themeConfig[key];
|
|
84
|
-
if (typeof value === 'undefined') {
|
|
85
|
-
// Support theme extend
|
|
86
|
-
if (themeConfig.$extend) {
|
|
87
|
-
themeConfig = config.themes[themeConfig.$extend] || {};
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
// Base config
|
|
91
|
-
themeConfig = null;
|
|
92
|
-
value = config[key];
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
themeConfig = null;
|
|
97
|
-
}
|
|
98
|
-
} while (themeConfig);
|
|
99
|
-
return value;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Theme CSS inheritance
|
|
103
|
-
*/
|
|
104
|
-
export function getThemeClasses(theme) {
|
|
105
|
-
const result = [theme];
|
|
106
|
-
let themeConfig = config.themes[theme] || {};
|
|
107
|
-
do {
|
|
108
|
-
// Support theme extend
|
|
109
|
-
if (themeConfig.$extend && !themeConfig.$resetCss) {
|
|
110
|
-
result.push(themeConfig.$extend);
|
|
111
|
-
themeConfig = config.themes[themeConfig.$extend] || {};
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
themeConfig = null;
|
|
115
|
-
}
|
|
116
|
-
} while (themeConfig);
|
|
117
|
-
return result.map(c => `v-popper--theme-${c}`);
|
|
118
|
-
}
|
|
119
|
-
export function getAllParentThemes(theme) {
|
|
120
|
-
const result = [theme];
|
|
121
|
-
let themeConfig = config.themes[theme] || {};
|
|
122
|
-
do {
|
|
123
|
-
// Support theme extend
|
|
124
|
-
if (themeConfig.$extend) {
|
|
125
|
-
result.push(themeConfig.$extend);
|
|
126
|
-
themeConfig = config.themes[themeConfig.$extend] || {};
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
themeConfig = null;
|
|
130
|
-
}
|
|
131
|
-
} while (themeConfig);
|
|
132
|
-
return result;
|
|
133
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { supportsPassive } from '../util/env';
|
|
2
|
-
function addListeners(el) {
|
|
3
|
-
el.addEventListener('click', onClick);
|
|
4
|
-
el.addEventListener('touchstart', onTouchStart, supportsPassive
|
|
5
|
-
? {
|
|
6
|
-
passive: true,
|
|
7
|
-
}
|
|
8
|
-
: false);
|
|
9
|
-
}
|
|
10
|
-
function removeListeners(el) {
|
|
11
|
-
el.removeEventListener('click', onClick);
|
|
12
|
-
el.removeEventListener('touchstart', onTouchStart);
|
|
13
|
-
el.removeEventListener('touchend', onTouchEnd);
|
|
14
|
-
el.removeEventListener('touchcancel', onTouchCancel);
|
|
15
|
-
}
|
|
16
|
-
function onClick(event) {
|
|
17
|
-
const el = event.currentTarget;
|
|
18
|
-
event.closePopover = !el.$_vclosepopover_touch;
|
|
19
|
-
event.closeAllPopover = el.$_closePopoverModifiers && !!el.$_closePopoverModifiers.all;
|
|
20
|
-
}
|
|
21
|
-
function onTouchStart(event) {
|
|
22
|
-
if (event.changedTouches.length === 1) {
|
|
23
|
-
const el = event.currentTarget;
|
|
24
|
-
el.$_vclosepopover_touch = true;
|
|
25
|
-
const touch = event.changedTouches[0];
|
|
26
|
-
el.$_vclosepopover_touchPoint = touch;
|
|
27
|
-
el.addEventListener('touchend', onTouchEnd);
|
|
28
|
-
el.addEventListener('touchcancel', onTouchCancel);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
function onTouchEnd(event) {
|
|
32
|
-
const el = event.currentTarget;
|
|
33
|
-
el.$_vclosepopover_touch = false;
|
|
34
|
-
if (event.changedTouches.length === 1) {
|
|
35
|
-
const touch = event.changedTouches[0];
|
|
36
|
-
const firstTouch = el.$_vclosepopover_touchPoint;
|
|
37
|
-
event.closePopover = (Math.abs(touch.screenY - firstTouch.screenY) < 20 &&
|
|
38
|
-
Math.abs(touch.screenX - firstTouch.screenX) < 20);
|
|
39
|
-
event.closeAllPopover = el.$_closePopoverModifiers && !!el.$_closePopoverModifiers.all;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function onTouchCancel(event) {
|
|
43
|
-
const el = event.currentTarget;
|
|
44
|
-
el.$_vclosepopover_touch = false;
|
|
45
|
-
}
|
|
46
|
-
export default {
|
|
47
|
-
bind(el, { value, modifiers }) {
|
|
48
|
-
el.$_closePopoverModifiers = modifiers;
|
|
49
|
-
if (typeof value === 'undefined' || value) {
|
|
50
|
-
addListeners(el);
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
update(el, { value, oldValue, modifiers }) {
|
|
54
|
-
el.$_closePopoverModifiers = modifiers;
|
|
55
|
-
if (value !== oldValue) {
|
|
56
|
-
if (typeof value === 'undefined' || value) {
|
|
57
|
-
addListeners(el);
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
removeListeners(el);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
unbind(el) {
|
|
65
|
-
removeListeners(el);
|
|
66
|
-
},
|
|
67
|
-
};
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import Vue from 'vue';
|
|
2
|
-
import TooltipDirective from '../components/TooltipDirective.vue';
|
|
3
|
-
import { getDefaultConfig } from '../config';
|
|
4
|
-
import PopperMethods from '../components/PopperMethods';
|
|
5
|
-
import { placements } from '../util/popper';
|
|
6
|
-
const TARGET_CLASS = 'v-popper--has-tooltip';
|
|
7
|
-
/**
|
|
8
|
-
* Support placement as directive modifier
|
|
9
|
-
*/
|
|
10
|
-
export function getPlacement(options, modifiers) {
|
|
11
|
-
let result = options.placement;
|
|
12
|
-
if (!result && modifiers) {
|
|
13
|
-
for (const pos of placements) {
|
|
14
|
-
if (modifiers[pos]) {
|
|
15
|
-
result = pos;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
if (!result) {
|
|
20
|
-
result = getDefaultConfig(options.theme || 'tooltip', 'placement');
|
|
21
|
-
}
|
|
22
|
-
return result;
|
|
23
|
-
}
|
|
24
|
-
export function getOptions(el, value, modifiers) {
|
|
25
|
-
let options;
|
|
26
|
-
const type = typeof value;
|
|
27
|
-
if (type === 'string') {
|
|
28
|
-
options = { content: value };
|
|
29
|
-
}
|
|
30
|
-
else if (value && type === 'object') {
|
|
31
|
-
options = value;
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
options = { content: false };
|
|
35
|
-
}
|
|
36
|
-
options.placement = getPlacement(options, modifiers);
|
|
37
|
-
options.targetNodes = () => [el];
|
|
38
|
-
options.referenceNode = () => el;
|
|
39
|
-
return options;
|
|
40
|
-
}
|
|
41
|
-
export function createTooltip(el, value, modifiers) {
|
|
42
|
-
const options = getOptions(el, value, modifiers);
|
|
43
|
-
const tooltipApp = el.$_popper = new Vue({
|
|
44
|
-
mixins: [
|
|
45
|
-
PopperMethods,
|
|
46
|
-
],
|
|
47
|
-
data() {
|
|
48
|
-
return {
|
|
49
|
-
options,
|
|
50
|
-
};
|
|
51
|
-
},
|
|
52
|
-
render(h) {
|
|
53
|
-
const { theme, html, content, loadingContent, ...otherOptions } = this.options;
|
|
54
|
-
return h(TooltipDirective, {
|
|
55
|
-
props: {
|
|
56
|
-
theme,
|
|
57
|
-
html,
|
|
58
|
-
content,
|
|
59
|
-
loadingContent,
|
|
60
|
-
},
|
|
61
|
-
attrs: otherOptions,
|
|
62
|
-
ref: 'popper',
|
|
63
|
-
});
|
|
64
|
-
},
|
|
65
|
-
// @ts-expect-error custom option
|
|
66
|
-
devtools: {
|
|
67
|
-
hide: true,
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
const mountTarget = document.createElement('div');
|
|
71
|
-
document.body.appendChild(mountTarget);
|
|
72
|
-
tooltipApp.$mount(mountTarget);
|
|
73
|
-
// Class on target
|
|
74
|
-
if (el.classList) {
|
|
75
|
-
el.classList.add(TARGET_CLASS);
|
|
76
|
-
}
|
|
77
|
-
return tooltipApp;
|
|
78
|
-
}
|
|
79
|
-
export function destroyTooltip(el) {
|
|
80
|
-
if (el.$_popper) {
|
|
81
|
-
el.$_popper.$destroy();
|
|
82
|
-
delete el.$_popper;
|
|
83
|
-
delete el.$_popperOldShown;
|
|
84
|
-
}
|
|
85
|
-
if (el.classList) {
|
|
86
|
-
el.classList.remove(TARGET_CLASS);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
export function bind(el, { value, oldValue, modifiers }) {
|
|
90
|
-
const options = getOptions(el, value, modifiers);
|
|
91
|
-
if (!options.content || getDefaultConfig(options.theme || 'tooltip', 'disabled')) {
|
|
92
|
-
destroyTooltip(el);
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
let tooltipApp;
|
|
96
|
-
if (el.$_popper) {
|
|
97
|
-
tooltipApp = el.$_popper;
|
|
98
|
-
tooltipApp.options = options;
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
tooltipApp = createTooltip(el, value, modifiers);
|
|
102
|
-
}
|
|
103
|
-
// Manual show
|
|
104
|
-
if (typeof value.shown !== 'undefined' && value.shown !== el.$_popperOldShown) {
|
|
105
|
-
el.$_popperOldShown = value.shown;
|
|
106
|
-
value.shown ? tooltipApp.show() : tooltipApp.hide();
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
export default {
|
|
111
|
-
bind,
|
|
112
|
-
update: bind,
|
|
113
|
-
unbind(el) {
|
|
114
|
-
destroyTooltip(el);
|
|
115
|
-
},
|
|
116
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { getBasePlacement } from './utils/getBasePlacement';
|
|
2
|
-
import { getAlignment } from './utils/getAlignment';
|
|
3
|
-
import { getMainAxisFromPlacement } from './utils/getMainAxisFromPlacement';
|
|
4
|
-
import { getLengthFromAxis } from './utils/getLengthFromAxis';
|
|
5
|
-
export function computeCoordsFromPlacement({ reference, floating, placement, }) {
|
|
6
|
-
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
7
|
-
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
8
|
-
let coords;
|
|
9
|
-
switch (getBasePlacement(placement)) {
|
|
10
|
-
case 'top':
|
|
11
|
-
coords = { x: commonX, y: reference.y - floating.height };
|
|
12
|
-
break;
|
|
13
|
-
case 'bottom':
|
|
14
|
-
coords = { x: commonX, y: reference.y + reference.height };
|
|
15
|
-
break;
|
|
16
|
-
case 'right':
|
|
17
|
-
coords = { x: reference.x + reference.width, y: commonY };
|
|
18
|
-
break;
|
|
19
|
-
case 'left':
|
|
20
|
-
coords = { x: reference.x - floating.width, y: commonY };
|
|
21
|
-
break;
|
|
22
|
-
default:
|
|
23
|
-
coords = { x: reference.x, y: reference.y };
|
|
24
|
-
}
|
|
25
|
-
const mainAxis = getMainAxisFromPlacement(placement);
|
|
26
|
-
const length = getLengthFromAxis(mainAxis);
|
|
27
|
-
switch (getAlignment(placement)) {
|
|
28
|
-
case 'start':
|
|
29
|
-
coords[mainAxis] =
|
|
30
|
-
coords[mainAxis] - (reference[length] / 2 - floating[length] / 2);
|
|
31
|
-
break;
|
|
32
|
-
case 'end':
|
|
33
|
-
coords[mainAxis] =
|
|
34
|
-
coords[mainAxis] + (reference[length] / 2 - floating[length] / 2);
|
|
35
|
-
break;
|
|
36
|
-
default:
|
|
37
|
-
}
|
|
38
|
-
return coords;
|
|
39
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { computeCoordsFromPlacement } from './computeCoordsFromPlacement';
|
|
2
|
-
export const computePosition = async (reference, floating, config) => {
|
|
3
|
-
const { placement = 'bottom', strategy = 'absolute', middleware = [], platform, } = config;
|
|
4
|
-
let rects = await platform.getElementRects({ reference, floating, strategy });
|
|
5
|
-
let { x, y } = computeCoordsFromPlacement({ ...rects, placement });
|
|
6
|
-
let statefulPlacement = placement;
|
|
7
|
-
let middlewareData = {};
|
|
8
|
-
let _debug_loop_count_ = 0;
|
|
9
|
-
for (let i = 0; i < middleware.length; i++) {
|
|
10
|
-
const { name, fn } = middleware[i];
|
|
11
|
-
const { x: nextX, y: nextY, data, reset, } = await fn({
|
|
12
|
-
x,
|
|
13
|
-
y,
|
|
14
|
-
initialPlacement: placement,
|
|
15
|
-
placement: statefulPlacement,
|
|
16
|
-
strategy,
|
|
17
|
-
middlewareData,
|
|
18
|
-
rects,
|
|
19
|
-
platform,
|
|
20
|
-
elements: { reference, floating },
|
|
21
|
-
});
|
|
22
|
-
x = nextX !== null && nextX !== void 0 ? nextX : x;
|
|
23
|
-
y = nextY !== null && nextY !== void 0 ? nextY : y;
|
|
24
|
-
middlewareData = { ...middlewareData, [name]: data !== null && data !== void 0 ? data : {} };
|
|
25
|
-
if (reset) {
|
|
26
|
-
if (typeof reset === 'object') {
|
|
27
|
-
if (reset.placement) {
|
|
28
|
-
statefulPlacement = reset.placement;
|
|
29
|
-
}
|
|
30
|
-
if (reset.rects) {
|
|
31
|
-
rects =
|
|
32
|
-
reset.rects === true
|
|
33
|
-
? await platform.getElementRects({ reference, floating, strategy })
|
|
34
|
-
: reset.rects;
|
|
35
|
-
}
|
|
36
|
-
({ x, y } = computeCoordsFromPlacement({
|
|
37
|
-
...rects,
|
|
38
|
-
placement: statefulPlacement,
|
|
39
|
-
}));
|
|
40
|
-
}
|
|
41
|
-
i = -1;
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
x,
|
|
47
|
-
y,
|
|
48
|
-
placement: statefulPlacement,
|
|
49
|
-
strategy,
|
|
50
|
-
middlewareData,
|
|
51
|
-
};
|
|
52
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { getSideObjectFromPadding } from './utils/getPaddingObject';
|
|
2
|
-
import { rectToClientRect } from './utils/rectToClientRect';
|
|
3
|
-
export async function detectOverflow(middlewareArguments, options = {}) {
|
|
4
|
-
const { x, y, platform, rects, elements, strategy } = middlewareArguments;
|
|
5
|
-
const { boundary = 'clippingParents', rootBoundary = 'viewport', elementContext = 'floating', altBoundary = false, padding = 0, } = options;
|
|
6
|
-
const paddingObject = getSideObjectFromPadding(padding);
|
|
7
|
-
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
|
8
|
-
const element = elements[altBoundary ? altContext : elementContext];
|
|
9
|
-
const clippingClientRect = await platform.getClippingClientRect({
|
|
10
|
-
element: (await platform.isElement(element))
|
|
11
|
-
? element
|
|
12
|
-
: element.contextElement ||
|
|
13
|
-
(await platform.getDocumentElement({ element: elements.floating })),
|
|
14
|
-
boundary,
|
|
15
|
-
rootBoundary,
|
|
16
|
-
});
|
|
17
|
-
const elementClientRect = rectToClientRect(await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
18
|
-
rect: elementContext === 'floating'
|
|
19
|
-
? { ...rects.floating, x, y }
|
|
20
|
-
: rects.reference,
|
|
21
|
-
offsetParent: await platform.getOffsetParent({
|
|
22
|
-
element: elements.floating,
|
|
23
|
-
}),
|
|
24
|
-
strategy,
|
|
25
|
-
}));
|
|
26
|
-
// positive = overflowing the clipping rect
|
|
27
|
-
// 0 or negative = within the clipping rect
|
|
28
|
-
return {
|
|
29
|
-
top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
|
|
30
|
-
bottom: elementClientRect.bottom -
|
|
31
|
-
clippingClientRect.bottom +
|
|
32
|
-
paddingObject.bottom,
|
|
33
|
-
left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
|
|
34
|
-
right: elementClientRect.right - clippingClientRect.right + paddingObject.right,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export { computePosition } from './computePosition';
|
|
2
|
-
export { detectOverflow } from './detectOverflow';
|
|
3
|
-
export { arrow } from './middleware/arrow';
|
|
4
|
-
export { autoPlacement } from './middleware/autoPlacement';
|
|
5
|
-
export { flip } from './middleware/flip';
|
|
6
|
-
export { hide } from './middleware/hide';
|
|
7
|
-
export { offset } from './middleware/offset';
|
|
8
|
-
export { shift, limitShift } from './middleware/shift';
|
|
9
|
-
export { size } from './middleware/size';
|
|
10
|
-
export { inline } from './middleware/inline';
|
|
11
|
-
export { rectToClientRect } from './utils/rectToClientRect';
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { getBasePlacement } from '../utils/getBasePlacement';
|
|
2
|
-
import { getLengthFromAxis } from '../utils/getLengthFromAxis';
|
|
3
|
-
import { getMainAxisFromPlacement } from '../utils/getMainAxisFromPlacement';
|
|
4
|
-
import { getSideObjectFromPadding } from '../utils/getPaddingObject';
|
|
5
|
-
import { within } from '../utils/within';
|
|
6
|
-
export const arrow = (options) => ({
|
|
7
|
-
name: 'arrow',
|
|
8
|
-
options,
|
|
9
|
-
async fn(middlewareArguments) {
|
|
10
|
-
// Since `element` is required, we don't Partial<> the type
|
|
11
|
-
const { element, padding = 0 } = options !== null && options !== void 0 ? options : {};
|
|
12
|
-
const { x, y, placement, rects, platform } = middlewareArguments;
|
|
13
|
-
if (element == null) {
|
|
14
|
-
if (__DEV__) {
|
|
15
|
-
console.warn('Floating UI: No `element` was passed to the `arrow` middleware.');
|
|
16
|
-
}
|
|
17
|
-
return {};
|
|
18
|
-
}
|
|
19
|
-
const paddingObject = getSideObjectFromPadding(padding);
|
|
20
|
-
const coords = { x, y };
|
|
21
|
-
const basePlacement = getBasePlacement(placement);
|
|
22
|
-
const axis = getMainAxisFromPlacement(basePlacement);
|
|
23
|
-
const length = getLengthFromAxis(axis);
|
|
24
|
-
const arrowDimensions = await platform.getDimensions({ element });
|
|
25
|
-
const minProp = axis === 'y' ? 'top' : 'left';
|
|
26
|
-
const maxProp = axis === 'y' ? 'bottom' : 'right';
|
|
27
|
-
const endDiff = rects.reference[length] +
|
|
28
|
-
rects.reference[axis] -
|
|
29
|
-
coords[axis] -
|
|
30
|
-
rects.floating[length];
|
|
31
|
-
const startDiff = coords[axis] - rects.reference[axis];
|
|
32
|
-
const arrowOffsetParent = await platform.getOffsetParent({ element });
|
|
33
|
-
const clientSize = arrowOffsetParent
|
|
34
|
-
? axis === 'y'
|
|
35
|
-
? arrowOffsetParent.clientHeight || 0
|
|
36
|
-
: arrowOffsetParent.clientWidth || 0
|
|
37
|
-
: 0;
|
|
38
|
-
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
39
|
-
// Make sure the arrow doesn't overflow the floating element if the center
|
|
40
|
-
// point is outside of the floating element's bounds
|
|
41
|
-
const min = paddingObject[minProp];
|
|
42
|
-
const max = clientSize - arrowDimensions[length] - paddingObject[maxProp];
|
|
43
|
-
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
44
|
-
const offset = within(min, center, max);
|
|
45
|
-
return {
|
|
46
|
-
data: {
|
|
47
|
-
[axis]: offset,
|
|
48
|
-
centerOffset: center - offset,
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
},
|
|
52
|
-
});
|