rx-compo 1.0.52 → 1.0.54
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/entry/types/index.d.ts +0 -1
- package/es/components/RxButton/index.js +16 -25
- package/es/components/RxCheckbox/index.js +3712 -0
- package/es/components/RxCheckboxGroup/index.js +6430 -0
- package/es/components/RxDatePicker/index.js +13042 -0
- package/es/components/RxInput/index.js +1560 -0
- package/es/components/RxOption/index.js +8859 -0
- package/es/components/RxRadio/index.js +646 -0
- package/es/components/RxRadioButton/index.js +646 -0
- package/es/components/RxRadioGroup/index.js +1117 -0
- package/es/components/RxScrollbar/index.js +867 -0
- package/es/components/RxSelect/index.js +9022 -0
- package/es/components/RxSelectPlus/index.js +17471 -0
- package/es/components/RxSuperCondition/index.js +8690 -0
- package/es/components/RxTooltip/index.js +2470 -0
- package/es/components/index.js +13 -0
- package/es/index.d.ts +0 -1
- package/es/index.js +0 -1
- package/es/utils/useContext.d.ts +10 -0
- package/es/utils/useContext.js +13 -0
- package/es/utils/useTextOverflow.d.ts +4 -0
- package/es/utils/useTextOverflow.js +13 -0
- package/es/utils/with-install.d.ts +3 -0
- package/es/utils/with-install.js +7 -0
- package/index.esm.js +43171 -1577
- package/index.js +43192 -1585
- package/lib/components/RxButton/index.js +15 -24
- package/lib/components/RxCheckbox/index.js +3717 -0
- package/lib/components/RxCheckboxGroup/index.js +6435 -0
- package/lib/components/RxDatePicker/index.js +13047 -0
- package/lib/components/RxInput/index.js +1565 -0
- package/lib/components/RxOption/index.js +8864 -0
- package/lib/components/RxRadio/index.js +651 -0
- package/lib/components/RxRadioButton/index.js +651 -0
- package/lib/components/RxRadioGroup/index.js +1122 -0
- package/lib/components/RxScrollbar/index.js +872 -0
- package/lib/components/RxSelect/index.js +9027 -0
- package/lib/components/RxSelectPlus/index.js +17476 -0
- package/lib/components/RxSuperCondition/index.js +8695 -0
- package/lib/components/RxTooltip/index.js +2475 -0
- package/lib/components/index.js +91 -0
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/utils/useContext.d.ts +10 -0
- package/lib/utils/useContext.js +18 -0
- package/lib/utils/useTextOverflow.d.ts +4 -0
- package/lib/utils/useTextOverflow.js +17 -0
- package/lib/utils/with-install.d.ts +3 -0
- package/lib/utils/with-install.js +11 -0
- package/package.json +4 -2
- package/theme-chalk/css/index.css +1 -1
- package/theme-chalk/css/rx-button.css +1 -0
- package/theme-chalk/css/rx-checkbox-group.css +1 -0
- package/theme-chalk/css/rx-checkbox.css +1 -0
- package/theme-chalk/css/rx-date-picker.css +0 -0
- package/theme-chalk/css/rx-input.css +1 -0
- package/theme-chalk/css/rx-option.css +1 -0
- package/theme-chalk/css/rx-radio-button.css +0 -0
- package/theme-chalk/css/rx-radio-group.css +1 -0
- package/theme-chalk/css/rx-radio.css +1 -0
- package/theme-chalk/css/rx-scrollbar.css +0 -0
- package/theme-chalk/css/rx-select.css +1 -0
- package/theme-chalk/css/rx-super-condition.css +0 -0
- package/theme-chalk/css/rx-tooltip.css +0 -0
- package/es/components/RxButton/index.d.ts +0 -3
- package/es/components/RxButton/src/index.d.ts +0 -3
- package/es/components/RxButton/src/index.vue.d.ts +0 -10
- package/es/components/index.d.ts +0 -2
- package/lib/components/RxButton/index.d.ts +0 -3
- package/lib/components/RxButton/src/index.d.ts +0 -3
- package/lib/components/RxButton/src/index.vue.d.ts +0 -10
- package/lib/components/index.d.ts +0 -2
- package/types/components/RxButton/index.d.ts +0 -3
- package/types/components/RxButton/src/index.d.ts +0 -3
- package/types/components/RxButton/src/index.vue.d.ts +0 -10
- package/types/components/index.d.ts +0 -2
- package/types/utils/with-install.d.ts +0 -3
|
@@ -0,0 +1,2475 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var withInstall$1 = require('rx-compo/lib/utils/with-install');
|
|
6
|
+
var vue = require('vue');
|
|
7
|
+
var vueDemi = require('vue-demi');
|
|
8
|
+
|
|
9
|
+
const RxTooltipProps = {};
|
|
10
|
+
|
|
11
|
+
const composeEventHandlers = (theirsHandler, oursHandler, { checkForDefaultPrevented = true } = {}) => {
|
|
12
|
+
const handleEvent = (event) => {
|
|
13
|
+
const shouldPrevent = theirsHandler == null ? void 0 : theirsHandler(event);
|
|
14
|
+
if (checkForDefaultPrevented === false || !shouldPrevent) {
|
|
15
|
+
return oursHandler == null ? void 0 : oursHandler(event);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
return handleEvent;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
var _a;
|
|
22
|
+
const isClient = typeof window !== "undefined";
|
|
23
|
+
const isString$1 = (val) => typeof val === "string";
|
|
24
|
+
const noop = () => {
|
|
25
|
+
};
|
|
26
|
+
const isIOS = isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
|
|
27
|
+
|
|
28
|
+
function resolveUnref(r) {
|
|
29
|
+
return typeof r === "function" ? r() : vueDemi.unref(r);
|
|
30
|
+
}
|
|
31
|
+
function identity(arg) {
|
|
32
|
+
return arg;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function tryOnScopeDispose(fn) {
|
|
36
|
+
if (vueDemi.getCurrentScope()) {
|
|
37
|
+
vueDemi.onScopeDispose(fn);
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function unrefElement(elRef) {
|
|
44
|
+
var _a;
|
|
45
|
+
const plain = resolveUnref(elRef);
|
|
46
|
+
return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const defaultWindow = isClient ? window : void 0;
|
|
50
|
+
|
|
51
|
+
function useEventListener(...args) {
|
|
52
|
+
let target;
|
|
53
|
+
let events;
|
|
54
|
+
let listeners;
|
|
55
|
+
let options;
|
|
56
|
+
if (isString$1(args[0]) || Array.isArray(args[0])) {
|
|
57
|
+
[events, listeners, options] = args;
|
|
58
|
+
target = defaultWindow;
|
|
59
|
+
} else {
|
|
60
|
+
[target, events, listeners, options] = args;
|
|
61
|
+
}
|
|
62
|
+
if (!target)
|
|
63
|
+
return noop;
|
|
64
|
+
if (!Array.isArray(events))
|
|
65
|
+
events = [events];
|
|
66
|
+
if (!Array.isArray(listeners))
|
|
67
|
+
listeners = [listeners];
|
|
68
|
+
const cleanups = [];
|
|
69
|
+
const cleanup = () => {
|
|
70
|
+
cleanups.forEach((fn) => fn());
|
|
71
|
+
cleanups.length = 0;
|
|
72
|
+
};
|
|
73
|
+
const register = (el, event, listener, options2) => {
|
|
74
|
+
el.addEventListener(event, listener, options2);
|
|
75
|
+
return () => el.removeEventListener(event, listener, options2);
|
|
76
|
+
};
|
|
77
|
+
const stopWatch = vueDemi.watch(() => [unrefElement(target), resolveUnref(options)], ([el, options2]) => {
|
|
78
|
+
cleanup();
|
|
79
|
+
if (!el)
|
|
80
|
+
return;
|
|
81
|
+
cleanups.push(...events.flatMap((event) => {
|
|
82
|
+
return listeners.map((listener) => register(el, event, listener, options2));
|
|
83
|
+
}));
|
|
84
|
+
}, { immediate: true, flush: "post" });
|
|
85
|
+
const stop = () => {
|
|
86
|
+
stopWatch();
|
|
87
|
+
cleanup();
|
|
88
|
+
};
|
|
89
|
+
tryOnScopeDispose(stop);
|
|
90
|
+
return stop;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
let _iOSWorkaround = false;
|
|
94
|
+
function onClickOutside(target, handler, options = {}) {
|
|
95
|
+
const { window = defaultWindow, ignore = [], capture = true, detectIframe = false } = options;
|
|
96
|
+
if (!window)
|
|
97
|
+
return;
|
|
98
|
+
if (isIOS && !_iOSWorkaround) {
|
|
99
|
+
_iOSWorkaround = true;
|
|
100
|
+
Array.from(window.document.body.children).forEach((el) => el.addEventListener("click", noop));
|
|
101
|
+
}
|
|
102
|
+
let shouldListen = true;
|
|
103
|
+
const shouldIgnore = (event) => {
|
|
104
|
+
return ignore.some((target2) => {
|
|
105
|
+
if (typeof target2 === "string") {
|
|
106
|
+
return Array.from(window.document.querySelectorAll(target2)).some((el) => el === event.target || event.composedPath().includes(el));
|
|
107
|
+
} else {
|
|
108
|
+
const el = unrefElement(target2);
|
|
109
|
+
return el && (event.target === el || event.composedPath().includes(el));
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
const listener = (event) => {
|
|
114
|
+
const el = unrefElement(target);
|
|
115
|
+
if (!el || el === event.target || event.composedPath().includes(el))
|
|
116
|
+
return;
|
|
117
|
+
if (event.detail === 0)
|
|
118
|
+
shouldListen = !shouldIgnore(event);
|
|
119
|
+
if (!shouldListen) {
|
|
120
|
+
shouldListen = true;
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
handler(event);
|
|
124
|
+
};
|
|
125
|
+
const cleanup = [
|
|
126
|
+
useEventListener(window, "click", listener, { passive: true, capture }),
|
|
127
|
+
useEventListener(window, "pointerdown", (e) => {
|
|
128
|
+
const el = unrefElement(target);
|
|
129
|
+
if (el)
|
|
130
|
+
shouldListen = !e.composedPath().includes(el) && !shouldIgnore(e);
|
|
131
|
+
}, { passive: true }),
|
|
132
|
+
detectIframe && useEventListener(window, "blur", (event) => {
|
|
133
|
+
var _a;
|
|
134
|
+
const el = unrefElement(target);
|
|
135
|
+
if (((_a = window.document.activeElement) == null ? void 0 : _a.tagName) === "IFRAME" && !(el == null ? void 0 : el.contains(window.document.activeElement)))
|
|
136
|
+
handler(event);
|
|
137
|
+
})
|
|
138
|
+
].filter(Boolean);
|
|
139
|
+
const stop = () => cleanup.forEach((fn) => fn());
|
|
140
|
+
return stop;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
144
|
+
const globalKey = "__vueuse_ssr_handlers__";
|
|
145
|
+
_global[globalKey] = _global[globalKey] || {};
|
|
146
|
+
_global[globalKey];
|
|
147
|
+
|
|
148
|
+
var SwipeDirection;
|
|
149
|
+
(function(SwipeDirection2) {
|
|
150
|
+
SwipeDirection2["UP"] = "UP";
|
|
151
|
+
SwipeDirection2["RIGHT"] = "RIGHT";
|
|
152
|
+
SwipeDirection2["DOWN"] = "DOWN";
|
|
153
|
+
SwipeDirection2["LEFT"] = "LEFT";
|
|
154
|
+
SwipeDirection2["NONE"] = "NONE";
|
|
155
|
+
})(SwipeDirection || (SwipeDirection = {}));
|
|
156
|
+
|
|
157
|
+
var __defProp = Object.defineProperty;
|
|
158
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
159
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
160
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
161
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
162
|
+
var __spreadValues = (a, b) => {
|
|
163
|
+
for (var prop in b || (b = {}))
|
|
164
|
+
if (__hasOwnProp.call(b, prop))
|
|
165
|
+
__defNormalProp(a, prop, b[prop]);
|
|
166
|
+
if (__getOwnPropSymbols)
|
|
167
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
168
|
+
if (__propIsEnum.call(b, prop))
|
|
169
|
+
__defNormalProp(a, prop, b[prop]);
|
|
170
|
+
}
|
|
171
|
+
return a;
|
|
172
|
+
};
|
|
173
|
+
const _TransitionPresets = {
|
|
174
|
+
easeInSine: [0.12, 0, 0.39, 0],
|
|
175
|
+
easeOutSine: [0.61, 1, 0.88, 1],
|
|
176
|
+
easeInOutSine: [0.37, 0, 0.63, 1],
|
|
177
|
+
easeInQuad: [0.11, 0, 0.5, 0],
|
|
178
|
+
easeOutQuad: [0.5, 1, 0.89, 1],
|
|
179
|
+
easeInOutQuad: [0.45, 0, 0.55, 1],
|
|
180
|
+
easeInCubic: [0.32, 0, 0.67, 0],
|
|
181
|
+
easeOutCubic: [0.33, 1, 0.68, 1],
|
|
182
|
+
easeInOutCubic: [0.65, 0, 0.35, 1],
|
|
183
|
+
easeInQuart: [0.5, 0, 0.75, 0],
|
|
184
|
+
easeOutQuart: [0.25, 1, 0.5, 1],
|
|
185
|
+
easeInOutQuart: [0.76, 0, 0.24, 1],
|
|
186
|
+
easeInQuint: [0.64, 0, 0.78, 0],
|
|
187
|
+
easeOutQuint: [0.22, 1, 0.36, 1],
|
|
188
|
+
easeInOutQuint: [0.83, 0, 0.17, 1],
|
|
189
|
+
easeInExpo: [0.7, 0, 0.84, 0],
|
|
190
|
+
easeOutExpo: [0.16, 1, 0.3, 1],
|
|
191
|
+
easeInOutExpo: [0.87, 0, 0.13, 1],
|
|
192
|
+
easeInCirc: [0.55, 0, 1, 0.45],
|
|
193
|
+
easeOutCirc: [0, 0.55, 0.45, 1],
|
|
194
|
+
easeInOutCirc: [0.85, 0, 0.15, 1],
|
|
195
|
+
easeInBack: [0.36, 0, 0.66, -0.56],
|
|
196
|
+
easeOutBack: [0.34, 1.56, 0.64, 1],
|
|
197
|
+
easeInOutBack: [0.68, -0.6, 0.32, 1.6]
|
|
198
|
+
};
|
|
199
|
+
__spreadValues({
|
|
200
|
+
linear: identity
|
|
201
|
+
}, _TransitionPresets);
|
|
202
|
+
|
|
203
|
+
!!(process.env.NODE_ENV !== "production") ? Object.freeze({}) : {};
|
|
204
|
+
!!(process.env.NODE_ENV !== "production") ? Object.freeze([]) : [];
|
|
205
|
+
const NOOP = () => {
|
|
206
|
+
};
|
|
207
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
208
|
+
const hasOwn = (val, key) => hasOwnProperty.call(val, key);
|
|
209
|
+
const isArray = Array.isArray;
|
|
210
|
+
const isFunction = (val) => typeof val === "function";
|
|
211
|
+
const isString = (val) => typeof val === "string";
|
|
212
|
+
const isObject = (val) => val !== null && typeof val === "object";
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* The inverse of `_.toPairs`; this method returns an object composed
|
|
216
|
+
* from key-value `pairs`.
|
|
217
|
+
*
|
|
218
|
+
* @static
|
|
219
|
+
* @memberOf _
|
|
220
|
+
* @since 4.0.0
|
|
221
|
+
* @category Array
|
|
222
|
+
* @param {Array} pairs The key-value pairs.
|
|
223
|
+
* @returns {Object} Returns the new object.
|
|
224
|
+
* @example
|
|
225
|
+
*
|
|
226
|
+
* _.fromPairs([['a', 1], ['b', 2]]);
|
|
227
|
+
* // => { 'a': 1, 'b': 2 }
|
|
228
|
+
*/
|
|
229
|
+
function fromPairs(pairs) {
|
|
230
|
+
var index = -1,
|
|
231
|
+
length = pairs == null ? 0 : pairs.length,
|
|
232
|
+
result = {};
|
|
233
|
+
|
|
234
|
+
while (++index < length) {
|
|
235
|
+
var pair = pairs[index];
|
|
236
|
+
result[pair[0]] = pair[1];
|
|
237
|
+
}
|
|
238
|
+
return result;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Checks if `value` is `null` or `undefined`.
|
|
243
|
+
*
|
|
244
|
+
* @static
|
|
245
|
+
* @memberOf _
|
|
246
|
+
* @since 4.0.0
|
|
247
|
+
* @category Lang
|
|
248
|
+
* @param {*} value The value to check.
|
|
249
|
+
* @returns {boolean} Returns `true` if `value` is nullish, else `false`.
|
|
250
|
+
* @example
|
|
251
|
+
*
|
|
252
|
+
* _.isNil(null);
|
|
253
|
+
* // => true
|
|
254
|
+
*
|
|
255
|
+
* _.isNil(void 0);
|
|
256
|
+
* // => true
|
|
257
|
+
*
|
|
258
|
+
* _.isNil(NaN);
|
|
259
|
+
* // => false
|
|
260
|
+
*/
|
|
261
|
+
function isNil(value) {
|
|
262
|
+
return value == null;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Checks if `value` is `undefined`.
|
|
267
|
+
*
|
|
268
|
+
* @static
|
|
269
|
+
* @since 0.1.0
|
|
270
|
+
* @memberOf _
|
|
271
|
+
* @category Lang
|
|
272
|
+
* @param {*} value The value to check.
|
|
273
|
+
* @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
|
|
274
|
+
* @example
|
|
275
|
+
*
|
|
276
|
+
* _.isUndefined(void 0);
|
|
277
|
+
* // => true
|
|
278
|
+
*
|
|
279
|
+
* _.isUndefined(null);
|
|
280
|
+
* // => false
|
|
281
|
+
*/
|
|
282
|
+
function isUndefined(value) {
|
|
283
|
+
return value === undefined;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
const isBoolean = (val) => typeof val === "boolean";
|
|
287
|
+
const isNumber = (val) => typeof val === "number";
|
|
288
|
+
const isElement = (e) => {
|
|
289
|
+
if (typeof Element === "undefined")
|
|
290
|
+
return false;
|
|
291
|
+
return e instanceof Element;
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
class ElementPlusError extends Error {
|
|
295
|
+
constructor(m) {
|
|
296
|
+
super(m);
|
|
297
|
+
this.name = "ElementPlusError";
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
function debugWarn(scope, message) {
|
|
301
|
+
if (process.env.NODE_ENV !== "production") {
|
|
302
|
+
const error = isString(scope) ? new ElementPlusError(`[${scope}] ${message}`) : scope;
|
|
303
|
+
console.warn(error);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const epPropKey = "__epPropKey";
|
|
308
|
+
const definePropType = (val) => val;
|
|
309
|
+
const isEpProp = (val) => isObject(val) && !!val[epPropKey];
|
|
310
|
+
const buildProp = (prop, key) => {
|
|
311
|
+
if (!isObject(prop) || isEpProp(prop))
|
|
312
|
+
return prop;
|
|
313
|
+
const { values, required, default: defaultValue, type, validator } = prop;
|
|
314
|
+
const _validator = values || validator ? (val) => {
|
|
315
|
+
let valid = false;
|
|
316
|
+
let allowedValues = [];
|
|
317
|
+
if (values) {
|
|
318
|
+
allowedValues = Array.from(values);
|
|
319
|
+
if (hasOwn(prop, "default")) {
|
|
320
|
+
allowedValues.push(defaultValue);
|
|
321
|
+
}
|
|
322
|
+
valid || (valid = allowedValues.includes(val));
|
|
323
|
+
}
|
|
324
|
+
if (validator)
|
|
325
|
+
valid || (valid = validator(val));
|
|
326
|
+
if (!valid && allowedValues.length > 0) {
|
|
327
|
+
const allowValuesText = [...new Set(allowedValues)].map((value) => JSON.stringify(value)).join(", ");
|
|
328
|
+
vue.warn(`Invalid prop: validation failed${key ? ` for prop "${key}"` : ""}. Expected one of [${allowValuesText}], got value ${JSON.stringify(val)}.`);
|
|
329
|
+
}
|
|
330
|
+
return valid;
|
|
331
|
+
} : void 0;
|
|
332
|
+
const epProp = {
|
|
333
|
+
type,
|
|
334
|
+
required: !!required,
|
|
335
|
+
validator: _validator,
|
|
336
|
+
[epPropKey]: true
|
|
337
|
+
};
|
|
338
|
+
if (hasOwn(prop, "default"))
|
|
339
|
+
epProp.default = defaultValue;
|
|
340
|
+
return epProp;
|
|
341
|
+
};
|
|
342
|
+
const buildProps = (props) => fromPairs(Object.entries(props).map(([key, option]) => [
|
|
343
|
+
key,
|
|
344
|
+
buildProp(option, key)
|
|
345
|
+
]));
|
|
346
|
+
|
|
347
|
+
const withInstall = (main, extra) => {
|
|
348
|
+
main.install = (app) => {
|
|
349
|
+
for (const comp of [main, ...Object.values(extra != null ? extra : {})]) {
|
|
350
|
+
app.component(comp.name, comp);
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
if (extra) {
|
|
354
|
+
for (const [key, comp] of Object.entries(extra)) {
|
|
355
|
+
main[key] = comp;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
return main;
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
const EVENT_CODE = {
|
|
362
|
+
tab: "Tab",
|
|
363
|
+
enter: "Enter",
|
|
364
|
+
space: "Space",
|
|
365
|
+
left: "ArrowLeft",
|
|
366
|
+
up: "ArrowUp",
|
|
367
|
+
right: "ArrowRight",
|
|
368
|
+
down: "ArrowDown",
|
|
369
|
+
esc: "Escape",
|
|
370
|
+
delete: "Delete",
|
|
371
|
+
backspace: "Backspace",
|
|
372
|
+
numpadEnter: "NumpadEnter",
|
|
373
|
+
pageUp: "PageUp",
|
|
374
|
+
pageDown: "PageDown",
|
|
375
|
+
home: "Home",
|
|
376
|
+
end: "End"
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
const defaultNamespace = "el";
|
|
380
|
+
const statePrefix = "is-";
|
|
381
|
+
const _bem = (namespace, block, blockSuffix, element, modifier) => {
|
|
382
|
+
let cls = `${namespace}-${block}`;
|
|
383
|
+
if (blockSuffix) {
|
|
384
|
+
cls += `-${blockSuffix}`;
|
|
385
|
+
}
|
|
386
|
+
if (element) {
|
|
387
|
+
cls += `__${element}`;
|
|
388
|
+
}
|
|
389
|
+
if (modifier) {
|
|
390
|
+
cls += `--${modifier}`;
|
|
391
|
+
}
|
|
392
|
+
return cls;
|
|
393
|
+
};
|
|
394
|
+
const namespaceContextKey = Symbol("namespaceContextKey");
|
|
395
|
+
const useGetDerivedNamespace = (namespaceOverrides) => {
|
|
396
|
+
const derivedNamespace = namespaceOverrides || vue.inject(namespaceContextKey, vue.ref(defaultNamespace));
|
|
397
|
+
const namespace = vue.computed(() => {
|
|
398
|
+
return vue.unref(derivedNamespace) || defaultNamespace;
|
|
399
|
+
});
|
|
400
|
+
return namespace;
|
|
401
|
+
};
|
|
402
|
+
const useNamespace = (block, namespaceOverrides) => {
|
|
403
|
+
const namespace = useGetDerivedNamespace(namespaceOverrides);
|
|
404
|
+
const b = (blockSuffix = "") => _bem(namespace.value, block, blockSuffix, "", "");
|
|
405
|
+
const e = (element) => element ? _bem(namespace.value, block, "", element, "") : "";
|
|
406
|
+
const m = (modifier) => modifier ? _bem(namespace.value, block, "", "", modifier) : "";
|
|
407
|
+
const be = (blockSuffix, element) => blockSuffix && element ? _bem(namespace.value, block, blockSuffix, element, "") : "";
|
|
408
|
+
const em = (element, modifier) => element && modifier ? _bem(namespace.value, block, "", element, modifier) : "";
|
|
409
|
+
const bm = (blockSuffix, modifier) => blockSuffix && modifier ? _bem(namespace.value, block, blockSuffix, "", modifier) : "";
|
|
410
|
+
const bem = (blockSuffix, element, modifier) => blockSuffix && element && modifier ? _bem(namespace.value, block, blockSuffix, element, modifier) : "";
|
|
411
|
+
const is = (name, ...args) => {
|
|
412
|
+
const state = args.length >= 1 ? args[0] : true;
|
|
413
|
+
return name && state ? `${statePrefix}${name}` : "";
|
|
414
|
+
};
|
|
415
|
+
const cssVar = (object) => {
|
|
416
|
+
const styles = {};
|
|
417
|
+
for (const key in object) {
|
|
418
|
+
if (object[key]) {
|
|
419
|
+
styles[`--${namespace.value}-${key}`] = object[key];
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
return styles;
|
|
423
|
+
};
|
|
424
|
+
const cssVarBlock = (object) => {
|
|
425
|
+
const styles = {};
|
|
426
|
+
for (const key in object) {
|
|
427
|
+
if (object[key]) {
|
|
428
|
+
styles[`--${namespace.value}-${block}-${key}`] = object[key];
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
return styles;
|
|
432
|
+
};
|
|
433
|
+
const cssVarName = (name) => `--${namespace.value}-${name}`;
|
|
434
|
+
const cssVarBlockName = (name) => `--${namespace.value}-${block}-${name}`;
|
|
435
|
+
return {
|
|
436
|
+
namespace,
|
|
437
|
+
b,
|
|
438
|
+
e,
|
|
439
|
+
m,
|
|
440
|
+
be,
|
|
441
|
+
em,
|
|
442
|
+
bm,
|
|
443
|
+
bem,
|
|
444
|
+
is,
|
|
445
|
+
cssVar,
|
|
446
|
+
cssVarName,
|
|
447
|
+
cssVarBlock,
|
|
448
|
+
cssVarBlockName
|
|
449
|
+
};
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
const _prop = buildProp({
|
|
453
|
+
type: definePropType(Boolean),
|
|
454
|
+
default: null
|
|
455
|
+
});
|
|
456
|
+
const _event = buildProp({
|
|
457
|
+
type: definePropType(Function)
|
|
458
|
+
});
|
|
459
|
+
const createModelToggleComposable = (name) => {
|
|
460
|
+
const updateEventKey = `update:${name}`;
|
|
461
|
+
const updateEventKeyRaw = `onUpdate:${name}`;
|
|
462
|
+
const useModelToggleEmits2 = [updateEventKey];
|
|
463
|
+
const useModelToggleProps2 = {
|
|
464
|
+
[name]: _prop,
|
|
465
|
+
[updateEventKeyRaw]: _event
|
|
466
|
+
};
|
|
467
|
+
const useModelToggle2 = ({
|
|
468
|
+
indicator,
|
|
469
|
+
toggleReason,
|
|
470
|
+
shouldHideWhenRouteChanges,
|
|
471
|
+
shouldProceed,
|
|
472
|
+
onShow,
|
|
473
|
+
onHide
|
|
474
|
+
}) => {
|
|
475
|
+
const instance = vue.getCurrentInstance();
|
|
476
|
+
const { emit } = instance;
|
|
477
|
+
const props = instance.props;
|
|
478
|
+
const hasUpdateHandler = vue.computed(() => isFunction(props[updateEventKeyRaw]));
|
|
479
|
+
const isModelBindingAbsent = vue.computed(() => props[name] === null);
|
|
480
|
+
const doShow = (event) => {
|
|
481
|
+
if (indicator.value === true) {
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
indicator.value = true;
|
|
485
|
+
if (toggleReason) {
|
|
486
|
+
toggleReason.value = event;
|
|
487
|
+
}
|
|
488
|
+
if (isFunction(onShow)) {
|
|
489
|
+
onShow(event);
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
const doHide = (event) => {
|
|
493
|
+
if (indicator.value === false) {
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
indicator.value = false;
|
|
497
|
+
if (toggleReason) {
|
|
498
|
+
toggleReason.value = event;
|
|
499
|
+
}
|
|
500
|
+
if (isFunction(onHide)) {
|
|
501
|
+
onHide(event);
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
const show = (event) => {
|
|
505
|
+
if (props.disabled === true || isFunction(shouldProceed) && !shouldProceed())
|
|
506
|
+
return;
|
|
507
|
+
const shouldEmit = hasUpdateHandler.value && isClient;
|
|
508
|
+
if (shouldEmit) {
|
|
509
|
+
emit(updateEventKey, true);
|
|
510
|
+
}
|
|
511
|
+
if (isModelBindingAbsent.value || !shouldEmit) {
|
|
512
|
+
doShow(event);
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
const hide = (event) => {
|
|
516
|
+
if (props.disabled === true || !isClient)
|
|
517
|
+
return;
|
|
518
|
+
const shouldEmit = hasUpdateHandler.value && isClient;
|
|
519
|
+
if (shouldEmit) {
|
|
520
|
+
emit(updateEventKey, false);
|
|
521
|
+
}
|
|
522
|
+
if (isModelBindingAbsent.value || !shouldEmit) {
|
|
523
|
+
doHide(event);
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
const onChange = (val) => {
|
|
527
|
+
if (!isBoolean(val))
|
|
528
|
+
return;
|
|
529
|
+
if (props.disabled && val) {
|
|
530
|
+
if (hasUpdateHandler.value) {
|
|
531
|
+
emit(updateEventKey, false);
|
|
532
|
+
}
|
|
533
|
+
} else if (indicator.value !== val) {
|
|
534
|
+
if (val) {
|
|
535
|
+
doShow();
|
|
536
|
+
} else {
|
|
537
|
+
doHide();
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
const toggle = () => {
|
|
542
|
+
if (indicator.value) {
|
|
543
|
+
hide();
|
|
544
|
+
} else {
|
|
545
|
+
show();
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
vue.watch(() => props[name], onChange);
|
|
549
|
+
if (shouldHideWhenRouteChanges && instance.appContext.config.globalProperties.$route !== void 0) {
|
|
550
|
+
vue.watch(() => ({
|
|
551
|
+
...instance.proxy.$route
|
|
552
|
+
}), () => {
|
|
553
|
+
if (shouldHideWhenRouteChanges.value && indicator.value) {
|
|
554
|
+
hide();
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
vue.onMounted(() => {
|
|
559
|
+
onChange(props[name]);
|
|
560
|
+
});
|
|
561
|
+
return {
|
|
562
|
+
hide,
|
|
563
|
+
show,
|
|
564
|
+
toggle,
|
|
565
|
+
hasUpdateHandler
|
|
566
|
+
};
|
|
567
|
+
};
|
|
568
|
+
return {
|
|
569
|
+
useModelToggle: useModelToggle2,
|
|
570
|
+
useModelToggleProps: useModelToggleProps2,
|
|
571
|
+
useModelToggleEmits: useModelToggleEmits2
|
|
572
|
+
};
|
|
573
|
+
};
|
|
574
|
+
|
|
575
|
+
var E="top",R="bottom",W="right",P="left",me="auto",G=[E,R,W,P],U="start",J="end",Xe="clippingParents",je="viewport",K="popper",Ye="reference",De=G.reduce(function(t,e){return t.concat([e+"-"+U,e+"-"+J])},[]),Ee=[].concat(G,[me]).reduce(function(t,e){return t.concat([e,e+"-"+U,e+"-"+J])},[]),Ge="beforeRead",Je="read",Ke="afterRead",Qe="beforeMain",Ze="main",et="afterMain",tt="beforeWrite",nt="write",rt="afterWrite",ot=[Ge,Je,Ke,Qe,Ze,et,tt,nt,rt];function C(t){return t?(t.nodeName||"").toLowerCase():null}function H(t){if(t==null)return window;if(t.toString()!=="[object Window]"){var e=t.ownerDocument;return e&&e.defaultView||window}return t}function Q(t){var e=H(t).Element;return t instanceof e||t instanceof Element}function B(t){var e=H(t).HTMLElement;return t instanceof e||t instanceof HTMLElement}function Pe(t){if(typeof ShadowRoot=="undefined")return !1;var e=H(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function Mt(t){var e=t.state;Object.keys(e.elements).forEach(function(n){var r=e.styles[n]||{},o=e.attributes[n]||{},i=e.elements[n];!B(i)||!C(i)||(Object.assign(i.style,r),Object.keys(o).forEach(function(a){var s=o[a];s===!1?i.removeAttribute(a):i.setAttribute(a,s===!0?"":s);}));});}function Rt(t){var e=t.state,n={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,n.popper),e.styles=n,e.elements.arrow&&Object.assign(e.elements.arrow.style,n.arrow),function(){Object.keys(e.elements).forEach(function(r){var o=e.elements[r],i=e.attributes[r]||{},a=Object.keys(e.styles.hasOwnProperty(r)?e.styles[r]:n[r]),s=a.reduce(function(f,c){return f[c]="",f},{});!B(o)||!C(o)||(Object.assign(o.style,s),Object.keys(i).forEach(function(f){o.removeAttribute(f);}));});}}var Ae={name:"applyStyles",enabled:!0,phase:"write",fn:Mt,effect:Rt,requires:["computeStyles"]};function q(t){return t.split("-")[0]}var X=Math.max,ve=Math.min,Z=Math.round;function ee(t,e){e===void 0&&(e=!1);var n=t.getBoundingClientRect(),r=1,o=1;if(B(t)&&e){var i=t.offsetHeight,a=t.offsetWidth;a>0&&(r=Z(n.width)/a||1),i>0&&(o=Z(n.height)/i||1);}return {width:n.width/r,height:n.height/o,top:n.top/o,right:n.right/r,bottom:n.bottom/o,left:n.left/r,x:n.left/r,y:n.top/o}}function ke(t){var e=ee(t),n=t.offsetWidth,r=t.offsetHeight;return Math.abs(e.width-n)<=1&&(n=e.width),Math.abs(e.height-r)<=1&&(r=e.height),{x:t.offsetLeft,y:t.offsetTop,width:n,height:r}}function it(t,e){var n=e.getRootNode&&e.getRootNode();if(t.contains(e))return !0;if(n&&Pe(n)){var r=e;do{if(r&&t.isSameNode(r))return !0;r=r.parentNode||r.host;}while(r)}return !1}function N(t){return H(t).getComputedStyle(t)}function Wt(t){return ["table","td","th"].indexOf(C(t))>=0}function I(t){return ((Q(t)?t.ownerDocument:t.document)||window.document).documentElement}function ge(t){return C(t)==="html"?t:t.assignedSlot||t.parentNode||(Pe(t)?t.host:null)||I(t)}function at(t){return !B(t)||N(t).position==="fixed"?null:t.offsetParent}function Bt(t){var e=navigator.userAgent.toLowerCase().indexOf("firefox")!==-1,n=navigator.userAgent.indexOf("Trident")!==-1;if(n&&B(t)){var r=N(t);if(r.position==="fixed")return null}var o=ge(t);for(Pe(o)&&(o=o.host);B(o)&&["html","body"].indexOf(C(o))<0;){var i=N(o);if(i.transform!=="none"||i.perspective!=="none"||i.contain==="paint"||["transform","perspective"].indexOf(i.willChange)!==-1||e&&i.willChange==="filter"||e&&i.filter&&i.filter!=="none")return o;o=o.parentNode;}return null}function se(t){for(var e=H(t),n=at(t);n&&Wt(n)&&N(n).position==="static";)n=at(n);return n&&(C(n)==="html"||C(n)==="body"&&N(n).position==="static")?e:n||Bt(t)||e}function Le(t){return ["top","bottom"].indexOf(t)>=0?"x":"y"}function fe(t,e,n){return X(t,ve(e,n))}function St(t,e,n){var r=fe(t,e,n);return r>n?n:r}function st(){return {top:0,right:0,bottom:0,left:0}}function ft(t){return Object.assign({},st(),t)}function ct(t,e){return e.reduce(function(n,r){return n[r]=t,n},{})}var Tt=function(t,e){return t=typeof t=="function"?t(Object.assign({},e.rects,{placement:e.placement})):t,ft(typeof t!="number"?t:ct(t,G))};function Ht(t){var e,n=t.state,r=t.name,o=t.options,i=n.elements.arrow,a=n.modifiersData.popperOffsets,s=q(n.placement),f=Le(s),c=[P,W].indexOf(s)>=0,u=c?"height":"width";if(!(!i||!a)){var m=Tt(o.padding,n),v=ke(i),l=f==="y"?E:P,h=f==="y"?R:W,p=n.rects.reference[u]+n.rects.reference[f]-a[f]-n.rects.popper[u],g=a[f]-n.rects.reference[f],x=se(i),y=x?f==="y"?x.clientHeight||0:x.clientWidth||0:0,$=p/2-g/2,d=m[l],b=y-v[u]-m[h],w=y/2-v[u]/2+$,O=fe(d,w,b),j=f;n.modifiersData[r]=(e={},e[j]=O,e.centerOffset=O-w,e);}}function Ct(t){var e=t.state,n=t.options,r=n.element,o=r===void 0?"[data-popper-arrow]":r;o!=null&&(typeof o=="string"&&(o=e.elements.popper.querySelector(o),!o)||!it(e.elements.popper,o)||(e.elements.arrow=o));}var pt={name:"arrow",enabled:!0,phase:"main",fn:Ht,effect:Ct,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function te(t){return t.split("-")[1]}var qt={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Vt(t){var e=t.x,n=t.y,r=window,o=r.devicePixelRatio||1;return {x:Z(e*o)/o||0,y:Z(n*o)/o||0}}function ut(t){var e,n=t.popper,r=t.popperRect,o=t.placement,i=t.variation,a=t.offsets,s=t.position,f=t.gpuAcceleration,c=t.adaptive,u=t.roundOffsets,m=t.isFixed,v=a.x,l=v===void 0?0:v,h=a.y,p=h===void 0?0:h,g=typeof u=="function"?u({x:l,y:p}):{x:l,y:p};l=g.x,p=g.y;var x=a.hasOwnProperty("x"),y=a.hasOwnProperty("y"),$=P,d=E,b=window;if(c){var w=se(n),O="clientHeight",j="clientWidth";if(w===H(n)&&(w=I(n),N(w).position!=="static"&&s==="absolute"&&(O="scrollHeight",j="scrollWidth")),w=w,o===E||(o===P||o===W)&&i===J){d=R;var A=m&&w===b&&b.visualViewport?b.visualViewport.height:w[O];p-=A-r.height,p*=f?1:-1;}if(o===P||(o===E||o===R)&&i===J){$=W;var k=m&&w===b&&b.visualViewport?b.visualViewport.width:w[j];l-=k-r.width,l*=f?1:-1;}}var D=Object.assign({position:s},c&&qt),S=u===!0?Vt({x:l,y:p}):{x:l,y:p};if(l=S.x,p=S.y,f){var L;return Object.assign({},D,(L={},L[d]=y?"0":"",L[$]=x?"0":"",L.transform=(b.devicePixelRatio||1)<=1?"translate("+l+"px, "+p+"px)":"translate3d("+l+"px, "+p+"px, 0)",L))}return Object.assign({},D,(e={},e[d]=y?p+"px":"",e[$]=x?l+"px":"",e.transform="",e))}function Nt(t){var e=t.state,n=t.options,r=n.gpuAcceleration,o=r===void 0?!0:r,i=n.adaptive,a=i===void 0?!0:i,s=n.roundOffsets,f=s===void 0?!0:s,c={placement:q(e.placement),variation:te(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:o,isFixed:e.options.strategy==="fixed"};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,ut(Object.assign({},c,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:a,roundOffsets:f})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,ut(Object.assign({},c,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:f})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement});}var Me={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:Nt,data:{}},ye={passive:!0};function It(t){var e=t.state,n=t.instance,r=t.options,o=r.scroll,i=o===void 0?!0:o,a=r.resize,s=a===void 0?!0:a,f=H(e.elements.popper),c=[].concat(e.scrollParents.reference,e.scrollParents.popper);return i&&c.forEach(function(u){u.addEventListener("scroll",n.update,ye);}),s&&f.addEventListener("resize",n.update,ye),function(){i&&c.forEach(function(u){u.removeEventListener("scroll",n.update,ye);}),s&&f.removeEventListener("resize",n.update,ye);}}var Re={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:It,data:{}},_t={left:"right",right:"left",bottom:"top",top:"bottom"};function be(t){return t.replace(/left|right|bottom|top/g,function(e){return _t[e]})}var zt={start:"end",end:"start"};function lt(t){return t.replace(/start|end/g,function(e){return zt[e]})}function We(t){var e=H(t),n=e.pageXOffset,r=e.pageYOffset;return {scrollLeft:n,scrollTop:r}}function Be(t){return ee(I(t)).left+We(t).scrollLeft}function Ft(t){var e=H(t),n=I(t),r=e.visualViewport,o=n.clientWidth,i=n.clientHeight,a=0,s=0;return r&&(o=r.width,i=r.height,/^((?!chrome|android).)*safari/i.test(navigator.userAgent)||(a=r.offsetLeft,s=r.offsetTop)),{width:o,height:i,x:a+Be(t),y:s}}function Ut(t){var e,n=I(t),r=We(t),o=(e=t.ownerDocument)==null?void 0:e.body,i=X(n.scrollWidth,n.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),a=X(n.scrollHeight,n.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),s=-r.scrollLeft+Be(t),f=-r.scrollTop;return N(o||n).direction==="rtl"&&(s+=X(n.clientWidth,o?o.clientWidth:0)-i),{width:i,height:a,x:s,y:f}}function Se(t){var e=N(t),n=e.overflow,r=e.overflowX,o=e.overflowY;return /auto|scroll|overlay|hidden/.test(n+o+r)}function dt(t){return ["html","body","#document"].indexOf(C(t))>=0?t.ownerDocument.body:B(t)&&Se(t)?t:dt(ge(t))}function ce(t,e){var n;e===void 0&&(e=[]);var r=dt(t),o=r===((n=t.ownerDocument)==null?void 0:n.body),i=H(r),a=o?[i].concat(i.visualViewport||[],Se(r)?r:[]):r,s=e.concat(a);return o?s:s.concat(ce(ge(a)))}function Te(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function Xt(t){var e=ee(t);return e.top=e.top+t.clientTop,e.left=e.left+t.clientLeft,e.bottom=e.top+t.clientHeight,e.right=e.left+t.clientWidth,e.width=t.clientWidth,e.height=t.clientHeight,e.x=e.left,e.y=e.top,e}function ht(t,e){return e===je?Te(Ft(t)):Q(e)?Xt(e):Te(Ut(I(t)))}function Yt(t){var e=ce(ge(t)),n=["absolute","fixed"].indexOf(N(t).position)>=0,r=n&&B(t)?se(t):t;return Q(r)?e.filter(function(o){return Q(o)&&it(o,r)&&C(o)!=="body"}):[]}function Gt(t,e,n){var r=e==="clippingParents"?Yt(t):[].concat(e),o=[].concat(r,[n]),i=o[0],a=o.reduce(function(s,f){var c=ht(t,f);return s.top=X(c.top,s.top),s.right=ve(c.right,s.right),s.bottom=ve(c.bottom,s.bottom),s.left=X(c.left,s.left),s},ht(t,i));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function mt(t){var e=t.reference,n=t.element,r=t.placement,o=r?q(r):null,i=r?te(r):null,a=e.x+e.width/2-n.width/2,s=e.y+e.height/2-n.height/2,f;switch(o){case E:f={x:a,y:e.y-n.height};break;case R:f={x:a,y:e.y+e.height};break;case W:f={x:e.x+e.width,y:s};break;case P:f={x:e.x-n.width,y:s};break;default:f={x:e.x,y:e.y};}var c=o?Le(o):null;if(c!=null){var u=c==="y"?"height":"width";switch(i){case U:f[c]=f[c]-(e[u]/2-n[u]/2);break;case J:f[c]=f[c]+(e[u]/2-n[u]/2);break}}return f}function ne(t,e){e===void 0&&(e={});var n=e,r=n.placement,o=r===void 0?t.placement:r,i=n.boundary,a=i===void 0?Xe:i,s=n.rootBoundary,f=s===void 0?je:s,c=n.elementContext,u=c===void 0?K:c,m=n.altBoundary,v=m===void 0?!1:m,l=n.padding,h=l===void 0?0:l,p=ft(typeof h!="number"?h:ct(h,G)),g=u===K?Ye:K,x=t.rects.popper,y=t.elements[v?g:u],$=Gt(Q(y)?y:y.contextElement||I(t.elements.popper),a,f),d=ee(t.elements.reference),b=mt({reference:d,element:x,strategy:"absolute",placement:o}),w=Te(Object.assign({},x,b)),O=u===K?w:d,j={top:$.top-O.top+p.top,bottom:O.bottom-$.bottom+p.bottom,left:$.left-O.left+p.left,right:O.right-$.right+p.right},A=t.modifiersData.offset;if(u===K&&A){var k=A[o];Object.keys(j).forEach(function(D){var S=[W,R].indexOf(D)>=0?1:-1,L=[E,R].indexOf(D)>=0?"y":"x";j[D]+=k[L]*S;});}return j}function Jt(t,e){e===void 0&&(e={});var n=e,r=n.placement,o=n.boundary,i=n.rootBoundary,a=n.padding,s=n.flipVariations,f=n.allowedAutoPlacements,c=f===void 0?Ee:f,u=te(r),m=u?s?De:De.filter(function(h){return te(h)===u}):G,v=m.filter(function(h){return c.indexOf(h)>=0});v.length===0&&(v=m);var l=v.reduce(function(h,p){return h[p]=ne(t,{placement:p,boundary:o,rootBoundary:i,padding:a})[q(p)],h},{});return Object.keys(l).sort(function(h,p){return l[h]-l[p]})}function Kt(t){if(q(t)===me)return [];var e=be(t);return [lt(t),e,lt(e)]}function Qt(t){var e=t.state,n=t.options,r=t.name;if(!e.modifiersData[r]._skip){for(var o=n.mainAxis,i=o===void 0?!0:o,a=n.altAxis,s=a===void 0?!0:a,f=n.fallbackPlacements,c=n.padding,u=n.boundary,m=n.rootBoundary,v=n.altBoundary,l=n.flipVariations,h=l===void 0?!0:l,p=n.allowedAutoPlacements,g=e.options.placement,x=q(g),y=x===g,$=f||(y||!h?[be(g)]:Kt(g)),d=[g].concat($).reduce(function(z,V){return z.concat(q(V)===me?Jt(e,{placement:V,boundary:u,rootBoundary:m,padding:c,flipVariations:h,allowedAutoPlacements:p}):V)},[]),b=e.rects.reference,w=e.rects.popper,O=new Map,j=!0,A=d[0],k=0;k<d.length;k++){var D=d[k],S=q(D),L=te(D)===U,re=[E,R].indexOf(S)>=0,oe=re?"width":"height",M=ne(e,{placement:D,boundary:u,rootBoundary:m,altBoundary:v,padding:c}),T=re?L?W:P:L?R:E;b[oe]>w[oe]&&(T=be(T));var pe=be(T),_=[];if(i&&_.push(M[S]<=0),s&&_.push(M[T]<=0,M[pe]<=0),_.every(function(z){return z})){A=D,j=!1;break}O.set(D,_);}if(j)for(var ue=h?3:1,xe=function(z){var V=d.find(function(de){var ae=O.get(de);if(ae)return ae.slice(0,z).every(function(Y){return Y})});if(V)return A=V,"break"},ie=ue;ie>0;ie--){var le=xe(ie);if(le==="break")break}e.placement!==A&&(e.modifiersData[r]._skip=!0,e.placement=A,e.reset=!0);}}var vt={name:"flip",enabled:!0,phase:"main",fn:Qt,requiresIfExists:["offset"],data:{_skip:!1}};function gt(t,e,n){return n===void 0&&(n={x:0,y:0}),{top:t.top-e.height-n.y,right:t.right-e.width+n.x,bottom:t.bottom-e.height+n.y,left:t.left-e.width-n.x}}function yt(t){return [E,W,R,P].some(function(e){return t[e]>=0})}function Zt(t){var e=t.state,n=t.name,r=e.rects.reference,o=e.rects.popper,i=e.modifiersData.preventOverflow,a=ne(e,{elementContext:"reference"}),s=ne(e,{altBoundary:!0}),f=gt(a,r),c=gt(s,o,i),u=yt(f),m=yt(c);e.modifiersData[n]={referenceClippingOffsets:f,popperEscapeOffsets:c,isReferenceHidden:u,hasPopperEscaped:m},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":m});}var bt={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:Zt};function en(t,e,n){var r=q(t),o=[P,E].indexOf(r)>=0?-1:1,i=typeof n=="function"?n(Object.assign({},e,{placement:t})):n,a=i[0],s=i[1];return a=a||0,s=(s||0)*o,[P,W].indexOf(r)>=0?{x:s,y:a}:{x:a,y:s}}function tn(t){var e=t.state,n=t.options,r=t.name,o=n.offset,i=o===void 0?[0,0]:o,a=Ee.reduce(function(u,m){return u[m]=en(m,e.rects,i),u},{}),s=a[e.placement],f=s.x,c=s.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=f,e.modifiersData.popperOffsets.y+=c),e.modifiersData[r]=a;}var wt={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:tn};function nn(t){var e=t.state,n=t.name;e.modifiersData[n]=mt({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement});}var He={name:"popperOffsets",enabled:!0,phase:"read",fn:nn,data:{}};function rn(t){return t==="x"?"y":"x"}function on(t){var e=t.state,n=t.options,r=t.name,o=n.mainAxis,i=o===void 0?!0:o,a=n.altAxis,s=a===void 0?!1:a,f=n.boundary,c=n.rootBoundary,u=n.altBoundary,m=n.padding,v=n.tether,l=v===void 0?!0:v,h=n.tetherOffset,p=h===void 0?0:h,g=ne(e,{boundary:f,rootBoundary:c,padding:m,altBoundary:u}),x=q(e.placement),y=te(e.placement),$=!y,d=Le(x),b=rn(d),w=e.modifiersData.popperOffsets,O=e.rects.reference,j=e.rects.popper,A=typeof p=="function"?p(Object.assign({},e.rects,{placement:e.placement})):p,k=typeof A=="number"?{mainAxis:A,altAxis:A}:Object.assign({mainAxis:0,altAxis:0},A),D=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,S={x:0,y:0};if(w){if(i){var L,re=d==="y"?E:P,oe=d==="y"?R:W,M=d==="y"?"height":"width",T=w[d],pe=T+g[re],_=T-g[oe],ue=l?-j[M]/2:0,xe=y===U?O[M]:j[M],ie=y===U?-j[M]:-O[M],le=e.elements.arrow,z=l&&le?ke(le):{width:0,height:0},V=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:st(),de=V[re],ae=V[oe],Y=fe(0,O[M],z[M]),jt=$?O[M]/2-ue-Y-de-k.mainAxis:xe-Y-de-k.mainAxis,Dt=$?-O[M]/2+ue+Y+ae+k.mainAxis:ie+Y+ae+k.mainAxis,Oe=e.elements.arrow&&se(e.elements.arrow),Et=Oe?d==="y"?Oe.clientTop||0:Oe.clientLeft||0:0,Ce=(L=D==null?void 0:D[d])!=null?L:0,Pt=T+jt-Ce-Et,At=T+Dt-Ce,qe=fe(l?ve(pe,Pt):pe,T,l?X(_,At):_);w[d]=qe,S[d]=qe-T;}if(s){var Ve,kt=d==="x"?E:P,Lt=d==="x"?R:W,F=w[b],he=b==="y"?"height":"width",Ne=F+g[kt],Ie=F-g[Lt],$e=[E,P].indexOf(x)!==-1,_e=(Ve=D==null?void 0:D[b])!=null?Ve:0,ze=$e?Ne:F-O[he]-j[he]-_e+k.altAxis,Fe=$e?F+O[he]+j[he]-_e-k.altAxis:Ie,Ue=l&&$e?St(ze,F,Fe):fe(l?ze:Ne,F,l?Fe:Ie);w[b]=Ue,S[b]=Ue-F;}e.modifiersData[r]=S;}}var xt={name:"preventOverflow",enabled:!0,phase:"main",fn:on,requiresIfExists:["offset"]};function an(t){return {scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}}function sn(t){return t===H(t)||!B(t)?We(t):an(t)}function fn(t){var e=t.getBoundingClientRect(),n=Z(e.width)/t.offsetWidth||1,r=Z(e.height)/t.offsetHeight||1;return n!==1||r!==1}function cn(t,e,n){n===void 0&&(n=!1);var r=B(e),o=B(e)&&fn(e),i=I(e),a=ee(t,o),s={scrollLeft:0,scrollTop:0},f={x:0,y:0};return (r||!r&&!n)&&((C(e)!=="body"||Se(i))&&(s=sn(e)),B(e)?(f=ee(e,!0),f.x+=e.clientLeft,f.y+=e.clientTop):i&&(f.x=Be(i))),{x:a.left+s.scrollLeft-f.x,y:a.top+s.scrollTop-f.y,width:a.width,height:a.height}}function pn(t){var e=new Map,n=new Set,r=[];t.forEach(function(i){e.set(i.name,i);});function o(i){n.add(i.name);var a=[].concat(i.requires||[],i.requiresIfExists||[]);a.forEach(function(s){if(!n.has(s)){var f=e.get(s);f&&o(f);}}),r.push(i);}return t.forEach(function(i){n.has(i.name)||o(i);}),r}function un(t){var e=pn(t);return ot.reduce(function(n,r){return n.concat(e.filter(function(o){return o.phase===r}))},[])}function ln(t){var e;return function(){return e||(e=new Promise(function(n){Promise.resolve().then(function(){e=void 0,n(t());});})),e}}function dn(t){var e=t.reduce(function(n,r){var o=n[r.name];return n[r.name]=o?Object.assign({},o,r,{options:Object.assign({},o.options,r.options),data:Object.assign({},o.data,r.data)}):r,n},{});return Object.keys(e).map(function(n){return e[n]})}var Ot={placement:"bottom",modifiers:[],strategy:"absolute"};function $t(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return !e.some(function(r){return !(r&&typeof r.getBoundingClientRect=="function")})}function we(t){t===void 0&&(t={});var e=t,n=e.defaultModifiers,r=n===void 0?[]:n,o=e.defaultOptions,i=o===void 0?Ot:o;return function(a,s,f){f===void 0&&(f=i);var c={placement:"bottom",orderedModifiers:[],options:Object.assign({},Ot,i),modifiersData:{},elements:{reference:a,popper:s},attributes:{},styles:{}},u=[],m=!1,v={state:c,setOptions:function(p){var g=typeof p=="function"?p(c.options):p;h(),c.options=Object.assign({},i,c.options,g),c.scrollParents={reference:Q(a)?ce(a):a.contextElement?ce(a.contextElement):[],popper:ce(s)};var x=un(dn([].concat(r,c.options.modifiers)));return c.orderedModifiers=x.filter(function(y){return y.enabled}),l(),v.update()},forceUpdate:function(){if(!m){var p=c.elements,g=p.reference,x=p.popper;if($t(g,x)){c.rects={reference:cn(g,se(x),c.options.strategy==="fixed"),popper:ke(x)},c.reset=!1,c.placement=c.options.placement,c.orderedModifiers.forEach(function(j){return c.modifiersData[j.name]=Object.assign({},j.data)});for(var y=0;y<c.orderedModifiers.length;y++){if(c.reset===!0){c.reset=!1,y=-1;continue}var $=c.orderedModifiers[y],d=$.fn,b=$.options,w=b===void 0?{}:b,O=$.name;typeof d=="function"&&(c=d({state:c,options:w,name:O,instance:v})||c);}}}},update:ln(function(){return new Promise(function(p){v.forceUpdate(),p(c);})}),destroy:function(){h(),m=!0;}};if(!$t(a,s))return v;v.setOptions(f).then(function(p){!m&&f.onFirstUpdate&&f.onFirstUpdate(p);});function l(){c.orderedModifiers.forEach(function(p){var g=p.name,x=p.options,y=x===void 0?{}:x,$=p.effect;if(typeof $=="function"){var d=$({state:c,name:g,instance:v,options:y}),b=function(){};u.push(d||b);}});}function h(){u.forEach(function(p){return p()}),u=[];}return v}}we();var mn=[Re,He,Me,Ae];we({defaultModifiers:mn});var gn=[Re,He,Me,Ae,wt,vt,xt,pt,bt],yn=we({defaultModifiers:gn});
|
|
576
|
+
|
|
577
|
+
const usePopper = (referenceElementRef, popperElementRef, opts = {}) => {
|
|
578
|
+
const stateUpdater = {
|
|
579
|
+
name: "updateState",
|
|
580
|
+
enabled: true,
|
|
581
|
+
phase: "write",
|
|
582
|
+
fn: ({ state }) => {
|
|
583
|
+
const derivedState = deriveState(state);
|
|
584
|
+
Object.assign(states.value, derivedState);
|
|
585
|
+
},
|
|
586
|
+
requires: ["computeStyles"]
|
|
587
|
+
};
|
|
588
|
+
const options = vue.computed(() => {
|
|
589
|
+
const { onFirstUpdate, placement, strategy, modifiers } = vue.unref(opts);
|
|
590
|
+
return {
|
|
591
|
+
onFirstUpdate,
|
|
592
|
+
placement: placement || "bottom",
|
|
593
|
+
strategy: strategy || "absolute",
|
|
594
|
+
modifiers: [
|
|
595
|
+
...modifiers || [],
|
|
596
|
+
stateUpdater,
|
|
597
|
+
{ name: "applyStyles", enabled: false }
|
|
598
|
+
]
|
|
599
|
+
};
|
|
600
|
+
});
|
|
601
|
+
const instanceRef = vue.shallowRef();
|
|
602
|
+
const states = vue.ref({
|
|
603
|
+
styles: {
|
|
604
|
+
popper: {
|
|
605
|
+
position: vue.unref(options).strategy,
|
|
606
|
+
left: "0",
|
|
607
|
+
top: "0"
|
|
608
|
+
},
|
|
609
|
+
arrow: {
|
|
610
|
+
position: "absolute"
|
|
611
|
+
}
|
|
612
|
+
},
|
|
613
|
+
attributes: {}
|
|
614
|
+
});
|
|
615
|
+
const destroy = () => {
|
|
616
|
+
if (!instanceRef.value)
|
|
617
|
+
return;
|
|
618
|
+
instanceRef.value.destroy();
|
|
619
|
+
instanceRef.value = void 0;
|
|
620
|
+
};
|
|
621
|
+
vue.watch(options, (newOptions) => {
|
|
622
|
+
const instance = vue.unref(instanceRef);
|
|
623
|
+
if (instance) {
|
|
624
|
+
instance.setOptions(newOptions);
|
|
625
|
+
}
|
|
626
|
+
}, {
|
|
627
|
+
deep: true
|
|
628
|
+
});
|
|
629
|
+
vue.watch([referenceElementRef, popperElementRef], ([referenceElement, popperElement]) => {
|
|
630
|
+
destroy();
|
|
631
|
+
if (!referenceElement || !popperElement)
|
|
632
|
+
return;
|
|
633
|
+
instanceRef.value = yn(referenceElement, popperElement, vue.unref(options));
|
|
634
|
+
});
|
|
635
|
+
vue.onBeforeUnmount(() => {
|
|
636
|
+
destroy();
|
|
637
|
+
});
|
|
638
|
+
return {
|
|
639
|
+
state: vue.computed(() => {
|
|
640
|
+
var _a;
|
|
641
|
+
return { ...((_a = vue.unref(instanceRef)) == null ? void 0 : _a.state) || {} };
|
|
642
|
+
}),
|
|
643
|
+
styles: vue.computed(() => vue.unref(states).styles),
|
|
644
|
+
attributes: vue.computed(() => vue.unref(states).attributes),
|
|
645
|
+
update: () => {
|
|
646
|
+
var _a;
|
|
647
|
+
return (_a = vue.unref(instanceRef)) == null ? void 0 : _a.update();
|
|
648
|
+
},
|
|
649
|
+
forceUpdate: () => {
|
|
650
|
+
var _a;
|
|
651
|
+
return (_a = vue.unref(instanceRef)) == null ? void 0 : _a.forceUpdate();
|
|
652
|
+
},
|
|
653
|
+
instanceRef: vue.computed(() => vue.unref(instanceRef))
|
|
654
|
+
};
|
|
655
|
+
};
|
|
656
|
+
function deriveState(state) {
|
|
657
|
+
const elements = Object.keys(state.elements);
|
|
658
|
+
const styles = fromPairs(elements.map((element) => [element, state.styles[element] || {}]));
|
|
659
|
+
const attributes = fromPairs(elements.map((element) => [element, state.attributes[element]]));
|
|
660
|
+
return {
|
|
661
|
+
styles,
|
|
662
|
+
attributes
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
function useTimeout() {
|
|
667
|
+
let timeoutHandle;
|
|
668
|
+
const registerTimeout = (fn, delay) => {
|
|
669
|
+
cancelTimeout();
|
|
670
|
+
timeoutHandle = window.setTimeout(fn, delay);
|
|
671
|
+
};
|
|
672
|
+
const cancelTimeout = () => window.clearTimeout(timeoutHandle);
|
|
673
|
+
tryOnScopeDispose(() => cancelTimeout());
|
|
674
|
+
return {
|
|
675
|
+
registerTimeout,
|
|
676
|
+
cancelTimeout
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
const defaultIdInjection = {
|
|
681
|
+
prefix: Math.floor(Math.random() * 1e4),
|
|
682
|
+
current: 0
|
|
683
|
+
};
|
|
684
|
+
const ID_INJECTION_KEY = Symbol("elIdInjection");
|
|
685
|
+
const useIdInjection = () => {
|
|
686
|
+
return vue.getCurrentInstance() ? vue.inject(ID_INJECTION_KEY, defaultIdInjection) : defaultIdInjection;
|
|
687
|
+
};
|
|
688
|
+
const useId = (deterministicId) => {
|
|
689
|
+
const idInjection = useIdInjection();
|
|
690
|
+
if (!isClient && idInjection === defaultIdInjection) {
|
|
691
|
+
debugWarn("IdInjection", `Looks like you are using server rendering, you must provide a id provider to ensure the hydration process to be succeed
|
|
692
|
+
usage: app.provide(ID_INJECTION_KEY, {
|
|
693
|
+
prefix: number,
|
|
694
|
+
current: number,
|
|
695
|
+
})`);
|
|
696
|
+
}
|
|
697
|
+
const namespace = useGetDerivedNamespace();
|
|
698
|
+
const idRef = vue.computed(() => vue.unref(deterministicId) || `${namespace.value}-id-${idInjection.prefix}-${idInjection.current++}`);
|
|
699
|
+
return idRef;
|
|
700
|
+
};
|
|
701
|
+
|
|
702
|
+
let registeredEscapeHandlers = [];
|
|
703
|
+
const cachedHandler = (e) => {
|
|
704
|
+
const event = e;
|
|
705
|
+
if (event.key === EVENT_CODE.esc) {
|
|
706
|
+
registeredEscapeHandlers.forEach((registeredHandler) => registeredHandler(event));
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
const useEscapeKeydown = (handler) => {
|
|
710
|
+
vue.onMounted(() => {
|
|
711
|
+
if (registeredEscapeHandlers.length === 0) {
|
|
712
|
+
document.addEventListener("keydown", cachedHandler);
|
|
713
|
+
}
|
|
714
|
+
if (isClient)
|
|
715
|
+
registeredEscapeHandlers.push(handler);
|
|
716
|
+
});
|
|
717
|
+
vue.onBeforeUnmount(() => {
|
|
718
|
+
registeredEscapeHandlers = registeredEscapeHandlers.filter((registeredHandler) => registeredHandler !== handler);
|
|
719
|
+
if (registeredEscapeHandlers.length === 0) {
|
|
720
|
+
if (isClient)
|
|
721
|
+
document.removeEventListener("keydown", cachedHandler);
|
|
722
|
+
}
|
|
723
|
+
});
|
|
724
|
+
};
|
|
725
|
+
|
|
726
|
+
let cachedContainer;
|
|
727
|
+
const usePopperContainerId = () => {
|
|
728
|
+
const namespace = useGetDerivedNamespace();
|
|
729
|
+
const idInjection = useIdInjection();
|
|
730
|
+
const id = vue.computed(() => {
|
|
731
|
+
return `${namespace.value}-popper-container-${idInjection.prefix}`;
|
|
732
|
+
});
|
|
733
|
+
const selector = vue.computed(() => `#${id.value}`);
|
|
734
|
+
return {
|
|
735
|
+
id,
|
|
736
|
+
selector
|
|
737
|
+
};
|
|
738
|
+
};
|
|
739
|
+
const createContainer = (id) => {
|
|
740
|
+
const container = document.createElement("div");
|
|
741
|
+
container.id = id;
|
|
742
|
+
document.body.appendChild(container);
|
|
743
|
+
return container;
|
|
744
|
+
};
|
|
745
|
+
const usePopperContainer = () => {
|
|
746
|
+
const { id, selector } = usePopperContainerId();
|
|
747
|
+
vue.onBeforeMount(() => {
|
|
748
|
+
if (!isClient)
|
|
749
|
+
return;
|
|
750
|
+
if (process.env.NODE_ENV === "test" || !cachedContainer && !document.body.querySelector(selector.value)) {
|
|
751
|
+
cachedContainer = createContainer(id.value);
|
|
752
|
+
}
|
|
753
|
+
});
|
|
754
|
+
return {
|
|
755
|
+
id,
|
|
756
|
+
selector
|
|
757
|
+
};
|
|
758
|
+
};
|
|
759
|
+
|
|
760
|
+
const useDelayedToggleProps = buildProps({
|
|
761
|
+
showAfter: {
|
|
762
|
+
type: Number,
|
|
763
|
+
default: 0
|
|
764
|
+
},
|
|
765
|
+
hideAfter: {
|
|
766
|
+
type: Number,
|
|
767
|
+
default: 200
|
|
768
|
+
},
|
|
769
|
+
autoClose: {
|
|
770
|
+
type: Number,
|
|
771
|
+
default: 0
|
|
772
|
+
}
|
|
773
|
+
});
|
|
774
|
+
const useDelayedToggle = ({
|
|
775
|
+
showAfter,
|
|
776
|
+
hideAfter,
|
|
777
|
+
autoClose,
|
|
778
|
+
open,
|
|
779
|
+
close
|
|
780
|
+
}) => {
|
|
781
|
+
const { registerTimeout } = useTimeout();
|
|
782
|
+
const {
|
|
783
|
+
registerTimeout: registerTimeoutForAutoClose,
|
|
784
|
+
cancelTimeout: cancelTimeoutForAutoClose
|
|
785
|
+
} = useTimeout();
|
|
786
|
+
const onOpen = (event) => {
|
|
787
|
+
registerTimeout(() => {
|
|
788
|
+
open(event);
|
|
789
|
+
const _autoClose = vue.unref(autoClose);
|
|
790
|
+
if (isNumber(_autoClose) && _autoClose > 0) {
|
|
791
|
+
registerTimeoutForAutoClose(() => {
|
|
792
|
+
close(event);
|
|
793
|
+
}, _autoClose);
|
|
794
|
+
}
|
|
795
|
+
}, vue.unref(showAfter));
|
|
796
|
+
};
|
|
797
|
+
const onClose = (event) => {
|
|
798
|
+
cancelTimeoutForAutoClose();
|
|
799
|
+
registerTimeout(() => {
|
|
800
|
+
close(event);
|
|
801
|
+
}, vue.unref(hideAfter));
|
|
802
|
+
};
|
|
803
|
+
return {
|
|
804
|
+
onOpen,
|
|
805
|
+
onClose
|
|
806
|
+
};
|
|
807
|
+
};
|
|
808
|
+
|
|
809
|
+
const FORWARD_REF_INJECTION_KEY = Symbol("elForwardRef");
|
|
810
|
+
const useForwardRef = (forwardRef) => {
|
|
811
|
+
const setForwardRef = (el) => {
|
|
812
|
+
forwardRef.value = el;
|
|
813
|
+
};
|
|
814
|
+
vue.provide(FORWARD_REF_INJECTION_KEY, {
|
|
815
|
+
setForwardRef
|
|
816
|
+
});
|
|
817
|
+
};
|
|
818
|
+
const useForwardRefDirective = (setForwardRef) => {
|
|
819
|
+
return {
|
|
820
|
+
mounted(el) {
|
|
821
|
+
setForwardRef(el);
|
|
822
|
+
},
|
|
823
|
+
updated(el) {
|
|
824
|
+
setForwardRef(el);
|
|
825
|
+
},
|
|
826
|
+
unmounted() {
|
|
827
|
+
setForwardRef(null);
|
|
828
|
+
}
|
|
829
|
+
};
|
|
830
|
+
};
|
|
831
|
+
|
|
832
|
+
const zIndex = vue.ref(0);
|
|
833
|
+
const defaultInitialZIndex = 2e3;
|
|
834
|
+
const zIndexContextKey = Symbol("zIndexContextKey");
|
|
835
|
+
const useZIndex = (zIndexOverrides) => {
|
|
836
|
+
const zIndexInjection = zIndexOverrides || vue.inject(zIndexContextKey, void 0);
|
|
837
|
+
const initialZIndex = vue.computed(() => {
|
|
838
|
+
const zIndexFromInjection = vue.unref(zIndexInjection);
|
|
839
|
+
return isNumber(zIndexFromInjection) ? zIndexFromInjection : defaultInitialZIndex;
|
|
840
|
+
});
|
|
841
|
+
const currentZIndex = vue.computed(() => initialZIndex.value + zIndex.value);
|
|
842
|
+
const nextZIndex = () => {
|
|
843
|
+
zIndex.value++;
|
|
844
|
+
return currentZIndex.value;
|
|
845
|
+
};
|
|
846
|
+
return {
|
|
847
|
+
initialZIndex,
|
|
848
|
+
currentZIndex,
|
|
849
|
+
nextZIndex
|
|
850
|
+
};
|
|
851
|
+
};
|
|
852
|
+
|
|
853
|
+
var _export_sfc = (sfc, props) => {
|
|
854
|
+
const target = sfc.__vccOpts || sfc;
|
|
855
|
+
for (const [key, val] of props) {
|
|
856
|
+
target[key] = val;
|
|
857
|
+
}
|
|
858
|
+
return target;
|
|
859
|
+
};
|
|
860
|
+
|
|
861
|
+
const formItemContextKey = Symbol("formItemContextKey");
|
|
862
|
+
|
|
863
|
+
const POPPER_INJECTION_KEY = Symbol("popper");
|
|
864
|
+
const POPPER_CONTENT_INJECTION_KEY = Symbol("popperContent");
|
|
865
|
+
|
|
866
|
+
const roleTypes = [
|
|
867
|
+
"dialog",
|
|
868
|
+
"grid",
|
|
869
|
+
"group",
|
|
870
|
+
"listbox",
|
|
871
|
+
"menu",
|
|
872
|
+
"navigation",
|
|
873
|
+
"tooltip",
|
|
874
|
+
"tree"
|
|
875
|
+
];
|
|
876
|
+
const popperProps = buildProps({
|
|
877
|
+
role: {
|
|
878
|
+
type: String,
|
|
879
|
+
values: roleTypes,
|
|
880
|
+
default: "tooltip"
|
|
881
|
+
}
|
|
882
|
+
});
|
|
883
|
+
|
|
884
|
+
const __default__$6 = vue.defineComponent({
|
|
885
|
+
name: "ElPopper",
|
|
886
|
+
inheritAttrs: false
|
|
887
|
+
});
|
|
888
|
+
const _sfc_main$7 = /* @__PURE__ */ vue.defineComponent({
|
|
889
|
+
...__default__$6,
|
|
890
|
+
props: popperProps,
|
|
891
|
+
setup(__props, { expose }) {
|
|
892
|
+
const props = __props;
|
|
893
|
+
const triggerRef = vue.ref();
|
|
894
|
+
const popperInstanceRef = vue.ref();
|
|
895
|
+
const contentRef = vue.ref();
|
|
896
|
+
const referenceRef = vue.ref();
|
|
897
|
+
const role = vue.computed(() => props.role);
|
|
898
|
+
const popperProvides = {
|
|
899
|
+
triggerRef,
|
|
900
|
+
popperInstanceRef,
|
|
901
|
+
contentRef,
|
|
902
|
+
referenceRef,
|
|
903
|
+
role
|
|
904
|
+
};
|
|
905
|
+
expose(popperProvides);
|
|
906
|
+
vue.provide(POPPER_INJECTION_KEY, popperProvides);
|
|
907
|
+
return (_ctx, _cache) => {
|
|
908
|
+
return vue.renderSlot(_ctx.$slots, "default");
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
});
|
|
912
|
+
var Popper = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/popper/src/popper.vue"]]);
|
|
913
|
+
|
|
914
|
+
const popperArrowProps = buildProps({
|
|
915
|
+
arrowOffset: {
|
|
916
|
+
type: Number,
|
|
917
|
+
default: 5
|
|
918
|
+
}
|
|
919
|
+
});
|
|
920
|
+
|
|
921
|
+
const __default__$5 = vue.defineComponent({
|
|
922
|
+
name: "ElPopperArrow",
|
|
923
|
+
inheritAttrs: false
|
|
924
|
+
});
|
|
925
|
+
const _sfc_main$6 = /* @__PURE__ */ vue.defineComponent({
|
|
926
|
+
...__default__$5,
|
|
927
|
+
props: popperArrowProps,
|
|
928
|
+
setup(__props, { expose }) {
|
|
929
|
+
const props = __props;
|
|
930
|
+
const ns = useNamespace("popper");
|
|
931
|
+
const { arrowOffset, arrowRef, arrowStyle } = vue.inject(POPPER_CONTENT_INJECTION_KEY, void 0);
|
|
932
|
+
vue.watch(() => props.arrowOffset, (val) => {
|
|
933
|
+
arrowOffset.value = val;
|
|
934
|
+
});
|
|
935
|
+
vue.onBeforeUnmount(() => {
|
|
936
|
+
arrowRef.value = void 0;
|
|
937
|
+
});
|
|
938
|
+
expose({
|
|
939
|
+
arrowRef
|
|
940
|
+
});
|
|
941
|
+
return (_ctx, _cache) => {
|
|
942
|
+
return vue.openBlock(), vue.createElementBlock("span", {
|
|
943
|
+
ref_key: "arrowRef",
|
|
944
|
+
ref: arrowRef,
|
|
945
|
+
class: vue.normalizeClass(vue.unref(ns).e("arrow")),
|
|
946
|
+
style: vue.normalizeStyle(vue.unref(arrowStyle)),
|
|
947
|
+
"data-popper-arrow": ""
|
|
948
|
+
}, null, 6);
|
|
949
|
+
};
|
|
950
|
+
}
|
|
951
|
+
});
|
|
952
|
+
var ElPopperArrow = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/popper/src/arrow.vue"]]);
|
|
953
|
+
|
|
954
|
+
const NAME = "ElOnlyChild";
|
|
955
|
+
const OnlyChild = vue.defineComponent({
|
|
956
|
+
name: NAME,
|
|
957
|
+
setup(_, {
|
|
958
|
+
slots,
|
|
959
|
+
attrs
|
|
960
|
+
}) {
|
|
961
|
+
var _a;
|
|
962
|
+
const forwardRefInjection = vue.inject(FORWARD_REF_INJECTION_KEY);
|
|
963
|
+
const forwardRefDirective = useForwardRefDirective((_a = forwardRefInjection == null ? void 0 : forwardRefInjection.setForwardRef) != null ? _a : NOOP);
|
|
964
|
+
return () => {
|
|
965
|
+
var _a2;
|
|
966
|
+
const defaultSlot = (_a2 = slots.default) == null ? void 0 : _a2.call(slots, attrs);
|
|
967
|
+
if (!defaultSlot)
|
|
968
|
+
return null;
|
|
969
|
+
if (defaultSlot.length > 1) {
|
|
970
|
+
debugWarn(NAME, "requires exact only one valid child.");
|
|
971
|
+
return null;
|
|
972
|
+
}
|
|
973
|
+
const firstLegitNode = findFirstLegitChild(defaultSlot);
|
|
974
|
+
if (!firstLegitNode) {
|
|
975
|
+
debugWarn(NAME, "no valid child node found");
|
|
976
|
+
return null;
|
|
977
|
+
}
|
|
978
|
+
return vue.withDirectives(vue.cloneVNode(firstLegitNode, attrs), [[forwardRefDirective]]);
|
|
979
|
+
};
|
|
980
|
+
}
|
|
981
|
+
});
|
|
982
|
+
function findFirstLegitChild(node) {
|
|
983
|
+
if (!node)
|
|
984
|
+
return null;
|
|
985
|
+
const children = node;
|
|
986
|
+
for (const child of children) {
|
|
987
|
+
if (isObject(child)) {
|
|
988
|
+
switch (child.type) {
|
|
989
|
+
case vue.Comment:
|
|
990
|
+
continue;
|
|
991
|
+
case vue.Text:
|
|
992
|
+
case "svg":
|
|
993
|
+
return wrapTextContent(child);
|
|
994
|
+
case vue.Fragment:
|
|
995
|
+
return findFirstLegitChild(child.children);
|
|
996
|
+
default:
|
|
997
|
+
return child;
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
return wrapTextContent(child);
|
|
1001
|
+
}
|
|
1002
|
+
return null;
|
|
1003
|
+
}
|
|
1004
|
+
function wrapTextContent(s) {
|
|
1005
|
+
const ns = useNamespace("only-child");
|
|
1006
|
+
return vue.createVNode("span", {
|
|
1007
|
+
"class": ns.e("content")
|
|
1008
|
+
}, [s]);
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
const popperTriggerProps = buildProps({
|
|
1012
|
+
virtualRef: {
|
|
1013
|
+
type: definePropType(Object)
|
|
1014
|
+
},
|
|
1015
|
+
virtualTriggering: Boolean,
|
|
1016
|
+
onMouseenter: {
|
|
1017
|
+
type: definePropType(Function)
|
|
1018
|
+
},
|
|
1019
|
+
onMouseleave: {
|
|
1020
|
+
type: definePropType(Function)
|
|
1021
|
+
},
|
|
1022
|
+
onClick: {
|
|
1023
|
+
type: definePropType(Function)
|
|
1024
|
+
},
|
|
1025
|
+
onKeydown: {
|
|
1026
|
+
type: definePropType(Function)
|
|
1027
|
+
},
|
|
1028
|
+
onFocus: {
|
|
1029
|
+
type: definePropType(Function)
|
|
1030
|
+
},
|
|
1031
|
+
onBlur: {
|
|
1032
|
+
type: definePropType(Function)
|
|
1033
|
+
},
|
|
1034
|
+
onContextmenu: {
|
|
1035
|
+
type: definePropType(Function)
|
|
1036
|
+
},
|
|
1037
|
+
id: String,
|
|
1038
|
+
open: Boolean
|
|
1039
|
+
});
|
|
1040
|
+
|
|
1041
|
+
const __default__$4 = vue.defineComponent({
|
|
1042
|
+
name: "ElPopperTrigger",
|
|
1043
|
+
inheritAttrs: false
|
|
1044
|
+
});
|
|
1045
|
+
const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
|
|
1046
|
+
...__default__$4,
|
|
1047
|
+
props: popperTriggerProps,
|
|
1048
|
+
setup(__props, { expose }) {
|
|
1049
|
+
const props = __props;
|
|
1050
|
+
const { role, triggerRef } = vue.inject(POPPER_INJECTION_KEY, void 0);
|
|
1051
|
+
useForwardRef(triggerRef);
|
|
1052
|
+
const ariaControls = vue.computed(() => {
|
|
1053
|
+
return ariaHaspopup.value ? props.id : void 0;
|
|
1054
|
+
});
|
|
1055
|
+
const ariaDescribedby = vue.computed(() => {
|
|
1056
|
+
if (role && role.value === "tooltip") {
|
|
1057
|
+
return props.open && props.id ? props.id : void 0;
|
|
1058
|
+
}
|
|
1059
|
+
return void 0;
|
|
1060
|
+
});
|
|
1061
|
+
const ariaHaspopup = vue.computed(() => {
|
|
1062
|
+
if (role && role.value !== "tooltip") {
|
|
1063
|
+
return role.value;
|
|
1064
|
+
}
|
|
1065
|
+
return void 0;
|
|
1066
|
+
});
|
|
1067
|
+
const ariaExpanded = vue.computed(() => {
|
|
1068
|
+
return ariaHaspopup.value ? `${props.open}` : void 0;
|
|
1069
|
+
});
|
|
1070
|
+
let virtualTriggerAriaStopWatch = void 0;
|
|
1071
|
+
vue.onMounted(() => {
|
|
1072
|
+
vue.watch(() => props.virtualRef, (virtualEl) => {
|
|
1073
|
+
if (virtualEl) {
|
|
1074
|
+
triggerRef.value = unrefElement(virtualEl);
|
|
1075
|
+
}
|
|
1076
|
+
}, {
|
|
1077
|
+
immediate: true
|
|
1078
|
+
});
|
|
1079
|
+
vue.watch(triggerRef, (el, prevEl) => {
|
|
1080
|
+
virtualTriggerAriaStopWatch == null ? void 0 : virtualTriggerAriaStopWatch();
|
|
1081
|
+
virtualTriggerAriaStopWatch = void 0;
|
|
1082
|
+
if (isElement(el)) {
|
|
1083
|
+
[
|
|
1084
|
+
"onMouseenter",
|
|
1085
|
+
"onMouseleave",
|
|
1086
|
+
"onClick",
|
|
1087
|
+
"onKeydown",
|
|
1088
|
+
"onFocus",
|
|
1089
|
+
"onBlur",
|
|
1090
|
+
"onContextmenu"
|
|
1091
|
+
].forEach((eventName) => {
|
|
1092
|
+
var _a;
|
|
1093
|
+
const handler = props[eventName];
|
|
1094
|
+
if (handler) {
|
|
1095
|
+
el.addEventListener(eventName.slice(2).toLowerCase(), handler);
|
|
1096
|
+
(_a = prevEl == null ? void 0 : prevEl.removeEventListener) == null ? void 0 : _a.call(prevEl, eventName.slice(2).toLowerCase(), handler);
|
|
1097
|
+
}
|
|
1098
|
+
});
|
|
1099
|
+
virtualTriggerAriaStopWatch = vue.watch([ariaControls, ariaDescribedby, ariaHaspopup, ariaExpanded], (watches) => {
|
|
1100
|
+
[
|
|
1101
|
+
"aria-controls",
|
|
1102
|
+
"aria-describedby",
|
|
1103
|
+
"aria-haspopup",
|
|
1104
|
+
"aria-expanded"
|
|
1105
|
+
].forEach((key, idx) => {
|
|
1106
|
+
isNil(watches[idx]) ? el.removeAttribute(key) : el.setAttribute(key, watches[idx]);
|
|
1107
|
+
});
|
|
1108
|
+
}, { immediate: true });
|
|
1109
|
+
}
|
|
1110
|
+
if (isElement(prevEl)) {
|
|
1111
|
+
[
|
|
1112
|
+
"aria-controls",
|
|
1113
|
+
"aria-describedby",
|
|
1114
|
+
"aria-haspopup",
|
|
1115
|
+
"aria-expanded"
|
|
1116
|
+
].forEach((key) => prevEl.removeAttribute(key));
|
|
1117
|
+
}
|
|
1118
|
+
}, {
|
|
1119
|
+
immediate: true
|
|
1120
|
+
});
|
|
1121
|
+
});
|
|
1122
|
+
vue.onBeforeUnmount(() => {
|
|
1123
|
+
virtualTriggerAriaStopWatch == null ? void 0 : virtualTriggerAriaStopWatch();
|
|
1124
|
+
virtualTriggerAriaStopWatch = void 0;
|
|
1125
|
+
});
|
|
1126
|
+
expose({
|
|
1127
|
+
triggerRef
|
|
1128
|
+
});
|
|
1129
|
+
return (_ctx, _cache) => {
|
|
1130
|
+
return !_ctx.virtualTriggering ? (vue.openBlock(), vue.createBlock(vue.unref(OnlyChild), vue.mergeProps({ key: 0 }, _ctx.$attrs, {
|
|
1131
|
+
"aria-controls": vue.unref(ariaControls),
|
|
1132
|
+
"aria-describedby": vue.unref(ariaDescribedby),
|
|
1133
|
+
"aria-expanded": vue.unref(ariaExpanded),
|
|
1134
|
+
"aria-haspopup": vue.unref(ariaHaspopup)
|
|
1135
|
+
}), {
|
|
1136
|
+
default: vue.withCtx(() => [
|
|
1137
|
+
vue.renderSlot(_ctx.$slots, "default")
|
|
1138
|
+
]),
|
|
1139
|
+
_: 3
|
|
1140
|
+
}, 16, ["aria-controls", "aria-describedby", "aria-expanded", "aria-haspopup"])) : vue.createCommentVNode("v-if", true);
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1143
|
+
});
|
|
1144
|
+
var ElPopperTrigger = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/popper/src/trigger.vue"]]);
|
|
1145
|
+
|
|
1146
|
+
const FOCUS_AFTER_TRAPPED = "focus-trap.focus-after-trapped";
|
|
1147
|
+
const FOCUS_AFTER_RELEASED = "focus-trap.focus-after-released";
|
|
1148
|
+
const FOCUSOUT_PREVENTED = "focus-trap.focusout-prevented";
|
|
1149
|
+
const FOCUS_AFTER_TRAPPED_OPTS = {
|
|
1150
|
+
cancelable: true,
|
|
1151
|
+
bubbles: false
|
|
1152
|
+
};
|
|
1153
|
+
const FOCUSOUT_PREVENTED_OPTS = {
|
|
1154
|
+
cancelable: true,
|
|
1155
|
+
bubbles: false
|
|
1156
|
+
};
|
|
1157
|
+
const ON_TRAP_FOCUS_EVT = "focusAfterTrapped";
|
|
1158
|
+
const ON_RELEASE_FOCUS_EVT = "focusAfterReleased";
|
|
1159
|
+
const FOCUS_TRAP_INJECTION_KEY = Symbol("elFocusTrap");
|
|
1160
|
+
|
|
1161
|
+
const focusReason = vue.ref();
|
|
1162
|
+
const lastUserFocusTimestamp = vue.ref(0);
|
|
1163
|
+
const lastAutomatedFocusTimestamp = vue.ref(0);
|
|
1164
|
+
let focusReasonUserCount = 0;
|
|
1165
|
+
const obtainAllFocusableElements = (element) => {
|
|
1166
|
+
const nodes = [];
|
|
1167
|
+
const walker = document.createTreeWalker(element, NodeFilter.SHOW_ELEMENT, {
|
|
1168
|
+
acceptNode: (node) => {
|
|
1169
|
+
const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
|
|
1170
|
+
if (node.disabled || node.hidden || isHiddenInput)
|
|
1171
|
+
return NodeFilter.FILTER_SKIP;
|
|
1172
|
+
return node.tabIndex >= 0 || node === document.activeElement ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
1173
|
+
}
|
|
1174
|
+
});
|
|
1175
|
+
while (walker.nextNode())
|
|
1176
|
+
nodes.push(walker.currentNode);
|
|
1177
|
+
return nodes;
|
|
1178
|
+
};
|
|
1179
|
+
const getVisibleElement = (elements, container) => {
|
|
1180
|
+
for (const element of elements) {
|
|
1181
|
+
if (!isHidden(element, container))
|
|
1182
|
+
return element;
|
|
1183
|
+
}
|
|
1184
|
+
};
|
|
1185
|
+
const isHidden = (element, container) => {
|
|
1186
|
+
if (process.env.NODE_ENV === "test")
|
|
1187
|
+
return false;
|
|
1188
|
+
if (getComputedStyle(element).visibility === "hidden")
|
|
1189
|
+
return true;
|
|
1190
|
+
while (element) {
|
|
1191
|
+
if (container && element === container)
|
|
1192
|
+
return false;
|
|
1193
|
+
if (getComputedStyle(element).display === "none")
|
|
1194
|
+
return true;
|
|
1195
|
+
element = element.parentElement;
|
|
1196
|
+
}
|
|
1197
|
+
return false;
|
|
1198
|
+
};
|
|
1199
|
+
const getEdges = (container) => {
|
|
1200
|
+
const focusable = obtainAllFocusableElements(container);
|
|
1201
|
+
const first = getVisibleElement(focusable, container);
|
|
1202
|
+
const last = getVisibleElement(focusable.reverse(), container);
|
|
1203
|
+
return [first, last];
|
|
1204
|
+
};
|
|
1205
|
+
const isSelectable = (element) => {
|
|
1206
|
+
return element instanceof HTMLInputElement && "select" in element;
|
|
1207
|
+
};
|
|
1208
|
+
const tryFocus = (element, shouldSelect) => {
|
|
1209
|
+
if (element && element.focus) {
|
|
1210
|
+
const prevFocusedElement = document.activeElement;
|
|
1211
|
+
element.focus({ preventScroll: true });
|
|
1212
|
+
lastAutomatedFocusTimestamp.value = window.performance.now();
|
|
1213
|
+
if (element !== prevFocusedElement && isSelectable(element) && shouldSelect) {
|
|
1214
|
+
element.select();
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
};
|
|
1218
|
+
function removeFromStack(list, item) {
|
|
1219
|
+
const copy = [...list];
|
|
1220
|
+
const idx = list.indexOf(item);
|
|
1221
|
+
if (idx !== -1) {
|
|
1222
|
+
copy.splice(idx, 1);
|
|
1223
|
+
}
|
|
1224
|
+
return copy;
|
|
1225
|
+
}
|
|
1226
|
+
const createFocusableStack = () => {
|
|
1227
|
+
let stack = [];
|
|
1228
|
+
const push = (layer) => {
|
|
1229
|
+
const currentLayer = stack[0];
|
|
1230
|
+
if (currentLayer && layer !== currentLayer) {
|
|
1231
|
+
currentLayer.pause();
|
|
1232
|
+
}
|
|
1233
|
+
stack = removeFromStack(stack, layer);
|
|
1234
|
+
stack.unshift(layer);
|
|
1235
|
+
};
|
|
1236
|
+
const remove = (layer) => {
|
|
1237
|
+
var _a, _b;
|
|
1238
|
+
stack = removeFromStack(stack, layer);
|
|
1239
|
+
(_b = (_a = stack[0]) == null ? void 0 : _a.resume) == null ? void 0 : _b.call(_a);
|
|
1240
|
+
};
|
|
1241
|
+
return {
|
|
1242
|
+
push,
|
|
1243
|
+
remove
|
|
1244
|
+
};
|
|
1245
|
+
};
|
|
1246
|
+
const focusFirstDescendant = (elements, shouldSelect = false) => {
|
|
1247
|
+
const prevFocusedElement = document.activeElement;
|
|
1248
|
+
for (const element of elements) {
|
|
1249
|
+
tryFocus(element, shouldSelect);
|
|
1250
|
+
if (document.activeElement !== prevFocusedElement)
|
|
1251
|
+
return;
|
|
1252
|
+
}
|
|
1253
|
+
};
|
|
1254
|
+
const focusableStack = createFocusableStack();
|
|
1255
|
+
const isFocusCausedByUserEvent = () => {
|
|
1256
|
+
return lastUserFocusTimestamp.value > lastAutomatedFocusTimestamp.value;
|
|
1257
|
+
};
|
|
1258
|
+
const notifyFocusReasonPointer = () => {
|
|
1259
|
+
focusReason.value = "pointer";
|
|
1260
|
+
lastUserFocusTimestamp.value = window.performance.now();
|
|
1261
|
+
};
|
|
1262
|
+
const notifyFocusReasonKeydown = () => {
|
|
1263
|
+
focusReason.value = "keyboard";
|
|
1264
|
+
lastUserFocusTimestamp.value = window.performance.now();
|
|
1265
|
+
};
|
|
1266
|
+
const useFocusReason = () => {
|
|
1267
|
+
vue.onMounted(() => {
|
|
1268
|
+
if (focusReasonUserCount === 0) {
|
|
1269
|
+
document.addEventListener("mousedown", notifyFocusReasonPointer);
|
|
1270
|
+
document.addEventListener("touchstart", notifyFocusReasonPointer);
|
|
1271
|
+
document.addEventListener("keydown", notifyFocusReasonKeydown);
|
|
1272
|
+
}
|
|
1273
|
+
focusReasonUserCount++;
|
|
1274
|
+
});
|
|
1275
|
+
vue.onBeforeUnmount(() => {
|
|
1276
|
+
focusReasonUserCount--;
|
|
1277
|
+
if (focusReasonUserCount <= 0) {
|
|
1278
|
+
document.removeEventListener("mousedown", notifyFocusReasonPointer);
|
|
1279
|
+
document.removeEventListener("touchstart", notifyFocusReasonPointer);
|
|
1280
|
+
document.removeEventListener("keydown", notifyFocusReasonKeydown);
|
|
1281
|
+
}
|
|
1282
|
+
});
|
|
1283
|
+
return {
|
|
1284
|
+
focusReason,
|
|
1285
|
+
lastUserFocusTimestamp,
|
|
1286
|
+
lastAutomatedFocusTimestamp
|
|
1287
|
+
};
|
|
1288
|
+
};
|
|
1289
|
+
const createFocusOutPreventedEvent = (detail) => {
|
|
1290
|
+
return new CustomEvent(FOCUSOUT_PREVENTED, {
|
|
1291
|
+
...FOCUSOUT_PREVENTED_OPTS,
|
|
1292
|
+
detail
|
|
1293
|
+
});
|
|
1294
|
+
};
|
|
1295
|
+
|
|
1296
|
+
const _sfc_main$4 = vue.defineComponent({
|
|
1297
|
+
name: "ElFocusTrap",
|
|
1298
|
+
inheritAttrs: false,
|
|
1299
|
+
props: {
|
|
1300
|
+
loop: Boolean,
|
|
1301
|
+
trapped: Boolean,
|
|
1302
|
+
focusTrapEl: Object,
|
|
1303
|
+
focusStartEl: {
|
|
1304
|
+
type: [Object, String],
|
|
1305
|
+
default: "first"
|
|
1306
|
+
}
|
|
1307
|
+
},
|
|
1308
|
+
emits: [
|
|
1309
|
+
ON_TRAP_FOCUS_EVT,
|
|
1310
|
+
ON_RELEASE_FOCUS_EVT,
|
|
1311
|
+
"focusin",
|
|
1312
|
+
"focusout",
|
|
1313
|
+
"focusout-prevented",
|
|
1314
|
+
"release-requested"
|
|
1315
|
+
],
|
|
1316
|
+
setup(props, { emit }) {
|
|
1317
|
+
const forwardRef = vue.ref();
|
|
1318
|
+
let lastFocusBeforeTrapped;
|
|
1319
|
+
let lastFocusAfterTrapped;
|
|
1320
|
+
const { focusReason } = useFocusReason();
|
|
1321
|
+
useEscapeKeydown((event) => {
|
|
1322
|
+
if (props.trapped && !focusLayer.paused) {
|
|
1323
|
+
emit("release-requested", event);
|
|
1324
|
+
}
|
|
1325
|
+
});
|
|
1326
|
+
const focusLayer = {
|
|
1327
|
+
paused: false,
|
|
1328
|
+
pause() {
|
|
1329
|
+
this.paused = true;
|
|
1330
|
+
},
|
|
1331
|
+
resume() {
|
|
1332
|
+
this.paused = false;
|
|
1333
|
+
}
|
|
1334
|
+
};
|
|
1335
|
+
const onKeydown = (e) => {
|
|
1336
|
+
if (!props.loop && !props.trapped)
|
|
1337
|
+
return;
|
|
1338
|
+
if (focusLayer.paused)
|
|
1339
|
+
return;
|
|
1340
|
+
const { key, altKey, ctrlKey, metaKey, currentTarget, shiftKey } = e;
|
|
1341
|
+
const { loop } = props;
|
|
1342
|
+
const isTabbing = key === EVENT_CODE.tab && !altKey && !ctrlKey && !metaKey;
|
|
1343
|
+
const currentFocusingEl = document.activeElement;
|
|
1344
|
+
if (isTabbing && currentFocusingEl) {
|
|
1345
|
+
const container = currentTarget;
|
|
1346
|
+
const [first, last] = getEdges(container);
|
|
1347
|
+
const isTabbable = first && last;
|
|
1348
|
+
if (!isTabbable) {
|
|
1349
|
+
if (currentFocusingEl === container) {
|
|
1350
|
+
const focusoutPreventedEvent = createFocusOutPreventedEvent({
|
|
1351
|
+
focusReason: focusReason.value
|
|
1352
|
+
});
|
|
1353
|
+
emit("focusout-prevented", focusoutPreventedEvent);
|
|
1354
|
+
if (!focusoutPreventedEvent.defaultPrevented) {
|
|
1355
|
+
e.preventDefault();
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
} else {
|
|
1359
|
+
if (!shiftKey && currentFocusingEl === last) {
|
|
1360
|
+
const focusoutPreventedEvent = createFocusOutPreventedEvent({
|
|
1361
|
+
focusReason: focusReason.value
|
|
1362
|
+
});
|
|
1363
|
+
emit("focusout-prevented", focusoutPreventedEvent);
|
|
1364
|
+
if (!focusoutPreventedEvent.defaultPrevented) {
|
|
1365
|
+
e.preventDefault();
|
|
1366
|
+
if (loop)
|
|
1367
|
+
tryFocus(first, true);
|
|
1368
|
+
}
|
|
1369
|
+
} else if (shiftKey && [first, container].includes(currentFocusingEl)) {
|
|
1370
|
+
const focusoutPreventedEvent = createFocusOutPreventedEvent({
|
|
1371
|
+
focusReason: focusReason.value
|
|
1372
|
+
});
|
|
1373
|
+
emit("focusout-prevented", focusoutPreventedEvent);
|
|
1374
|
+
if (!focusoutPreventedEvent.defaultPrevented) {
|
|
1375
|
+
e.preventDefault();
|
|
1376
|
+
if (loop)
|
|
1377
|
+
tryFocus(last, true);
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
};
|
|
1383
|
+
vue.provide(FOCUS_TRAP_INJECTION_KEY, {
|
|
1384
|
+
focusTrapRef: forwardRef,
|
|
1385
|
+
onKeydown
|
|
1386
|
+
});
|
|
1387
|
+
vue.watch(() => props.focusTrapEl, (focusTrapEl) => {
|
|
1388
|
+
if (focusTrapEl) {
|
|
1389
|
+
forwardRef.value = focusTrapEl;
|
|
1390
|
+
}
|
|
1391
|
+
}, { immediate: true });
|
|
1392
|
+
vue.watch([forwardRef], ([forwardRef2], [oldForwardRef]) => {
|
|
1393
|
+
if (forwardRef2) {
|
|
1394
|
+
forwardRef2.addEventListener("keydown", onKeydown);
|
|
1395
|
+
forwardRef2.addEventListener("focusin", onFocusIn);
|
|
1396
|
+
forwardRef2.addEventListener("focusout", onFocusOut);
|
|
1397
|
+
}
|
|
1398
|
+
if (oldForwardRef) {
|
|
1399
|
+
oldForwardRef.removeEventListener("keydown", onKeydown);
|
|
1400
|
+
oldForwardRef.removeEventListener("focusin", onFocusIn);
|
|
1401
|
+
oldForwardRef.removeEventListener("focusout", onFocusOut);
|
|
1402
|
+
}
|
|
1403
|
+
});
|
|
1404
|
+
const trapOnFocus = (e) => {
|
|
1405
|
+
emit(ON_TRAP_FOCUS_EVT, e);
|
|
1406
|
+
};
|
|
1407
|
+
const releaseOnFocus = (e) => emit(ON_RELEASE_FOCUS_EVT, e);
|
|
1408
|
+
const onFocusIn = (e) => {
|
|
1409
|
+
const trapContainer = vue.unref(forwardRef);
|
|
1410
|
+
if (!trapContainer)
|
|
1411
|
+
return;
|
|
1412
|
+
const target = e.target;
|
|
1413
|
+
const relatedTarget = e.relatedTarget;
|
|
1414
|
+
const isFocusedInTrap = target && trapContainer.contains(target);
|
|
1415
|
+
if (!props.trapped) {
|
|
1416
|
+
const isPrevFocusedInTrap = relatedTarget && trapContainer.contains(relatedTarget);
|
|
1417
|
+
if (!isPrevFocusedInTrap) {
|
|
1418
|
+
lastFocusBeforeTrapped = relatedTarget;
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
if (isFocusedInTrap)
|
|
1422
|
+
emit("focusin", e);
|
|
1423
|
+
if (focusLayer.paused)
|
|
1424
|
+
return;
|
|
1425
|
+
if (props.trapped) {
|
|
1426
|
+
if (isFocusedInTrap) {
|
|
1427
|
+
lastFocusAfterTrapped = target;
|
|
1428
|
+
} else {
|
|
1429
|
+
tryFocus(lastFocusAfterTrapped, true);
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
};
|
|
1433
|
+
const onFocusOut = (e) => {
|
|
1434
|
+
const trapContainer = vue.unref(forwardRef);
|
|
1435
|
+
if (focusLayer.paused || !trapContainer)
|
|
1436
|
+
return;
|
|
1437
|
+
if (props.trapped) {
|
|
1438
|
+
const relatedTarget = e.relatedTarget;
|
|
1439
|
+
if (!isNil(relatedTarget) && !trapContainer.contains(relatedTarget)) {
|
|
1440
|
+
setTimeout(() => {
|
|
1441
|
+
if (!focusLayer.paused && props.trapped) {
|
|
1442
|
+
const focusoutPreventedEvent = createFocusOutPreventedEvent({
|
|
1443
|
+
focusReason: focusReason.value
|
|
1444
|
+
});
|
|
1445
|
+
emit("focusout-prevented", focusoutPreventedEvent);
|
|
1446
|
+
if (!focusoutPreventedEvent.defaultPrevented) {
|
|
1447
|
+
tryFocus(lastFocusAfterTrapped, true);
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
}, 0);
|
|
1451
|
+
}
|
|
1452
|
+
} else {
|
|
1453
|
+
const target = e.target;
|
|
1454
|
+
const isFocusedInTrap = target && trapContainer.contains(target);
|
|
1455
|
+
if (!isFocusedInTrap)
|
|
1456
|
+
emit("focusout", e);
|
|
1457
|
+
}
|
|
1458
|
+
};
|
|
1459
|
+
async function startTrap() {
|
|
1460
|
+
await vue.nextTick();
|
|
1461
|
+
const trapContainer = vue.unref(forwardRef);
|
|
1462
|
+
if (trapContainer) {
|
|
1463
|
+
focusableStack.push(focusLayer);
|
|
1464
|
+
const prevFocusedElement = trapContainer.contains(document.activeElement) ? lastFocusBeforeTrapped : document.activeElement;
|
|
1465
|
+
lastFocusBeforeTrapped = prevFocusedElement;
|
|
1466
|
+
const isPrevFocusContained = trapContainer.contains(prevFocusedElement);
|
|
1467
|
+
if (!isPrevFocusContained) {
|
|
1468
|
+
const focusEvent = new Event(FOCUS_AFTER_TRAPPED, FOCUS_AFTER_TRAPPED_OPTS);
|
|
1469
|
+
trapContainer.addEventListener(FOCUS_AFTER_TRAPPED, trapOnFocus);
|
|
1470
|
+
trapContainer.dispatchEvent(focusEvent);
|
|
1471
|
+
if (!focusEvent.defaultPrevented) {
|
|
1472
|
+
vue.nextTick(() => {
|
|
1473
|
+
let focusStartEl = props.focusStartEl;
|
|
1474
|
+
if (!isString(focusStartEl)) {
|
|
1475
|
+
tryFocus(focusStartEl);
|
|
1476
|
+
if (document.activeElement !== focusStartEl) {
|
|
1477
|
+
focusStartEl = "first";
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
if (focusStartEl === "first") {
|
|
1481
|
+
focusFirstDescendant(obtainAllFocusableElements(trapContainer), true);
|
|
1482
|
+
}
|
|
1483
|
+
if (document.activeElement === prevFocusedElement || focusStartEl === "container") {
|
|
1484
|
+
tryFocus(trapContainer);
|
|
1485
|
+
}
|
|
1486
|
+
});
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
function stopTrap() {
|
|
1492
|
+
const trapContainer = vue.unref(forwardRef);
|
|
1493
|
+
if (trapContainer) {
|
|
1494
|
+
trapContainer.removeEventListener(FOCUS_AFTER_TRAPPED, trapOnFocus);
|
|
1495
|
+
const releasedEvent = new CustomEvent(FOCUS_AFTER_RELEASED, {
|
|
1496
|
+
...FOCUS_AFTER_TRAPPED_OPTS,
|
|
1497
|
+
detail: {
|
|
1498
|
+
focusReason: focusReason.value
|
|
1499
|
+
}
|
|
1500
|
+
});
|
|
1501
|
+
trapContainer.addEventListener(FOCUS_AFTER_RELEASED, releaseOnFocus);
|
|
1502
|
+
trapContainer.dispatchEvent(releasedEvent);
|
|
1503
|
+
if (!releasedEvent.defaultPrevented && (focusReason.value == "keyboard" || !isFocusCausedByUserEvent() || trapContainer.contains(document.activeElement))) {
|
|
1504
|
+
tryFocus(lastFocusBeforeTrapped != null ? lastFocusBeforeTrapped : document.body);
|
|
1505
|
+
}
|
|
1506
|
+
trapContainer.removeEventListener(FOCUS_AFTER_RELEASED, trapOnFocus);
|
|
1507
|
+
focusableStack.remove(focusLayer);
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
vue.onMounted(() => {
|
|
1511
|
+
if (props.trapped) {
|
|
1512
|
+
startTrap();
|
|
1513
|
+
}
|
|
1514
|
+
vue.watch(() => props.trapped, (trapped) => {
|
|
1515
|
+
if (trapped) {
|
|
1516
|
+
startTrap();
|
|
1517
|
+
} else {
|
|
1518
|
+
stopTrap();
|
|
1519
|
+
}
|
|
1520
|
+
});
|
|
1521
|
+
});
|
|
1522
|
+
vue.onBeforeUnmount(() => {
|
|
1523
|
+
if (props.trapped) {
|
|
1524
|
+
stopTrap();
|
|
1525
|
+
}
|
|
1526
|
+
});
|
|
1527
|
+
return {
|
|
1528
|
+
onKeydown
|
|
1529
|
+
};
|
|
1530
|
+
}
|
|
1531
|
+
});
|
|
1532
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1533
|
+
return vue.renderSlot(_ctx.$slots, "default", { handleKeydown: _ctx.onKeydown });
|
|
1534
|
+
}
|
|
1535
|
+
var ElFocusTrap = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render], ["__file", "/home/runner/work/element-plus/element-plus/packages/components/focus-trap/src/focus-trap.vue"]]);
|
|
1536
|
+
|
|
1537
|
+
const POSITIONING_STRATEGIES = ["fixed", "absolute"];
|
|
1538
|
+
const popperCoreConfigProps = buildProps({
|
|
1539
|
+
boundariesPadding: {
|
|
1540
|
+
type: Number,
|
|
1541
|
+
default: 0
|
|
1542
|
+
},
|
|
1543
|
+
fallbackPlacements: {
|
|
1544
|
+
type: definePropType(Array),
|
|
1545
|
+
default: void 0
|
|
1546
|
+
},
|
|
1547
|
+
gpuAcceleration: {
|
|
1548
|
+
type: Boolean,
|
|
1549
|
+
default: true
|
|
1550
|
+
},
|
|
1551
|
+
offset: {
|
|
1552
|
+
type: Number,
|
|
1553
|
+
default: 12
|
|
1554
|
+
},
|
|
1555
|
+
placement: {
|
|
1556
|
+
type: String,
|
|
1557
|
+
values: Ee,
|
|
1558
|
+
default: "bottom"
|
|
1559
|
+
},
|
|
1560
|
+
popperOptions: {
|
|
1561
|
+
type: definePropType(Object),
|
|
1562
|
+
default: () => ({})
|
|
1563
|
+
},
|
|
1564
|
+
strategy: {
|
|
1565
|
+
type: String,
|
|
1566
|
+
values: POSITIONING_STRATEGIES,
|
|
1567
|
+
default: "absolute"
|
|
1568
|
+
}
|
|
1569
|
+
});
|
|
1570
|
+
const popperContentProps = buildProps({
|
|
1571
|
+
...popperCoreConfigProps,
|
|
1572
|
+
id: String,
|
|
1573
|
+
style: {
|
|
1574
|
+
type: definePropType([String, Array, Object])
|
|
1575
|
+
},
|
|
1576
|
+
className: {
|
|
1577
|
+
type: definePropType([String, Array, Object])
|
|
1578
|
+
},
|
|
1579
|
+
effect: {
|
|
1580
|
+
type: String,
|
|
1581
|
+
default: "dark"
|
|
1582
|
+
},
|
|
1583
|
+
visible: Boolean,
|
|
1584
|
+
enterable: {
|
|
1585
|
+
type: Boolean,
|
|
1586
|
+
default: true
|
|
1587
|
+
},
|
|
1588
|
+
pure: Boolean,
|
|
1589
|
+
focusOnShow: {
|
|
1590
|
+
type: Boolean,
|
|
1591
|
+
default: false
|
|
1592
|
+
},
|
|
1593
|
+
trapping: {
|
|
1594
|
+
type: Boolean,
|
|
1595
|
+
default: false
|
|
1596
|
+
},
|
|
1597
|
+
popperClass: {
|
|
1598
|
+
type: definePropType([String, Array, Object])
|
|
1599
|
+
},
|
|
1600
|
+
popperStyle: {
|
|
1601
|
+
type: definePropType([String, Array, Object])
|
|
1602
|
+
},
|
|
1603
|
+
referenceEl: {
|
|
1604
|
+
type: definePropType(Object)
|
|
1605
|
+
},
|
|
1606
|
+
triggerTargetEl: {
|
|
1607
|
+
type: definePropType(Object)
|
|
1608
|
+
},
|
|
1609
|
+
stopPopperMouseEvent: {
|
|
1610
|
+
type: Boolean,
|
|
1611
|
+
default: true
|
|
1612
|
+
},
|
|
1613
|
+
ariaLabel: {
|
|
1614
|
+
type: String,
|
|
1615
|
+
default: void 0
|
|
1616
|
+
},
|
|
1617
|
+
virtualTriggering: Boolean,
|
|
1618
|
+
zIndex: Number
|
|
1619
|
+
});
|
|
1620
|
+
const popperContentEmits = {
|
|
1621
|
+
mouseenter: (evt) => evt instanceof MouseEvent,
|
|
1622
|
+
mouseleave: (evt) => evt instanceof MouseEvent,
|
|
1623
|
+
focus: () => true,
|
|
1624
|
+
blur: () => true,
|
|
1625
|
+
close: () => true
|
|
1626
|
+
};
|
|
1627
|
+
|
|
1628
|
+
const buildPopperOptions = (props, modifiers = []) => {
|
|
1629
|
+
const { placement, strategy, popperOptions } = props;
|
|
1630
|
+
const options = {
|
|
1631
|
+
placement,
|
|
1632
|
+
strategy,
|
|
1633
|
+
...popperOptions,
|
|
1634
|
+
modifiers: [...genModifiers(props), ...modifiers]
|
|
1635
|
+
};
|
|
1636
|
+
deriveExtraModifiers(options, popperOptions == null ? void 0 : popperOptions.modifiers);
|
|
1637
|
+
return options;
|
|
1638
|
+
};
|
|
1639
|
+
const unwrapMeasurableEl = ($el) => {
|
|
1640
|
+
if (!isClient)
|
|
1641
|
+
return;
|
|
1642
|
+
return unrefElement($el);
|
|
1643
|
+
};
|
|
1644
|
+
function genModifiers(options) {
|
|
1645
|
+
const { offset, gpuAcceleration, fallbackPlacements } = options;
|
|
1646
|
+
return [
|
|
1647
|
+
{
|
|
1648
|
+
name: "offset",
|
|
1649
|
+
options: {
|
|
1650
|
+
offset: [0, offset != null ? offset : 12]
|
|
1651
|
+
}
|
|
1652
|
+
},
|
|
1653
|
+
{
|
|
1654
|
+
name: "preventOverflow",
|
|
1655
|
+
options: {
|
|
1656
|
+
padding: {
|
|
1657
|
+
top: 2,
|
|
1658
|
+
bottom: 2,
|
|
1659
|
+
left: 5,
|
|
1660
|
+
right: 5
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
},
|
|
1664
|
+
{
|
|
1665
|
+
name: "flip",
|
|
1666
|
+
options: {
|
|
1667
|
+
padding: 5,
|
|
1668
|
+
fallbackPlacements
|
|
1669
|
+
}
|
|
1670
|
+
},
|
|
1671
|
+
{
|
|
1672
|
+
name: "computeStyles",
|
|
1673
|
+
options: {
|
|
1674
|
+
gpuAcceleration
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
];
|
|
1678
|
+
}
|
|
1679
|
+
function deriveExtraModifiers(options, modifiers) {
|
|
1680
|
+
if (modifiers) {
|
|
1681
|
+
options.modifiers = [...options.modifiers, ...modifiers != null ? modifiers : []];
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
const DEFAULT_ARROW_OFFSET = 0;
|
|
1686
|
+
const usePopperContent = (props) => {
|
|
1687
|
+
const { popperInstanceRef, contentRef, triggerRef, role } = vue.inject(POPPER_INJECTION_KEY, void 0);
|
|
1688
|
+
const arrowRef = vue.ref();
|
|
1689
|
+
const arrowOffset = vue.ref();
|
|
1690
|
+
const eventListenerModifier = vue.computed(() => {
|
|
1691
|
+
return {
|
|
1692
|
+
name: "eventListeners",
|
|
1693
|
+
enabled: !!props.visible
|
|
1694
|
+
};
|
|
1695
|
+
});
|
|
1696
|
+
const arrowModifier = vue.computed(() => {
|
|
1697
|
+
var _a;
|
|
1698
|
+
const arrowEl = vue.unref(arrowRef);
|
|
1699
|
+
const offset = (_a = vue.unref(arrowOffset)) != null ? _a : DEFAULT_ARROW_OFFSET;
|
|
1700
|
+
return {
|
|
1701
|
+
name: "arrow",
|
|
1702
|
+
enabled: !isUndefined(arrowEl),
|
|
1703
|
+
options: {
|
|
1704
|
+
element: arrowEl,
|
|
1705
|
+
padding: offset
|
|
1706
|
+
}
|
|
1707
|
+
};
|
|
1708
|
+
});
|
|
1709
|
+
const options = vue.computed(() => {
|
|
1710
|
+
return {
|
|
1711
|
+
onFirstUpdate: () => {
|
|
1712
|
+
update();
|
|
1713
|
+
},
|
|
1714
|
+
...buildPopperOptions(props, [
|
|
1715
|
+
vue.unref(arrowModifier),
|
|
1716
|
+
vue.unref(eventListenerModifier)
|
|
1717
|
+
])
|
|
1718
|
+
};
|
|
1719
|
+
});
|
|
1720
|
+
const computedReference = vue.computed(() => unwrapMeasurableEl(props.referenceEl) || vue.unref(triggerRef));
|
|
1721
|
+
const { attributes, state, styles, update, forceUpdate, instanceRef } = usePopper(computedReference, contentRef, options);
|
|
1722
|
+
vue.watch(instanceRef, (instance) => popperInstanceRef.value = instance);
|
|
1723
|
+
vue.onMounted(() => {
|
|
1724
|
+
vue.watch(() => {
|
|
1725
|
+
var _a;
|
|
1726
|
+
return (_a = vue.unref(computedReference)) == null ? void 0 : _a.getBoundingClientRect();
|
|
1727
|
+
}, () => {
|
|
1728
|
+
update();
|
|
1729
|
+
});
|
|
1730
|
+
});
|
|
1731
|
+
return {
|
|
1732
|
+
attributes,
|
|
1733
|
+
arrowRef,
|
|
1734
|
+
contentRef,
|
|
1735
|
+
instanceRef,
|
|
1736
|
+
state,
|
|
1737
|
+
styles,
|
|
1738
|
+
role,
|
|
1739
|
+
forceUpdate,
|
|
1740
|
+
update
|
|
1741
|
+
};
|
|
1742
|
+
};
|
|
1743
|
+
|
|
1744
|
+
const usePopperContentDOM = (props, {
|
|
1745
|
+
attributes,
|
|
1746
|
+
styles,
|
|
1747
|
+
role
|
|
1748
|
+
}) => {
|
|
1749
|
+
const { nextZIndex } = useZIndex();
|
|
1750
|
+
const ns = useNamespace("popper");
|
|
1751
|
+
const contentAttrs = vue.computed(() => vue.unref(attributes).popper);
|
|
1752
|
+
const contentZIndex = vue.ref(props.zIndex || nextZIndex());
|
|
1753
|
+
const contentClass = vue.computed(() => [
|
|
1754
|
+
ns.b(),
|
|
1755
|
+
ns.is("pure", props.pure),
|
|
1756
|
+
ns.is(props.effect),
|
|
1757
|
+
props.popperClass
|
|
1758
|
+
]);
|
|
1759
|
+
const contentStyle = vue.computed(() => {
|
|
1760
|
+
return [
|
|
1761
|
+
{ zIndex: vue.unref(contentZIndex) },
|
|
1762
|
+
vue.unref(styles).popper,
|
|
1763
|
+
props.popperStyle || {}
|
|
1764
|
+
];
|
|
1765
|
+
});
|
|
1766
|
+
const ariaModal = vue.computed(() => role.value === "dialog" ? "false" : void 0);
|
|
1767
|
+
const arrowStyle = vue.computed(() => vue.unref(styles).arrow || {});
|
|
1768
|
+
const updateZIndex = () => {
|
|
1769
|
+
contentZIndex.value = props.zIndex || nextZIndex();
|
|
1770
|
+
};
|
|
1771
|
+
return {
|
|
1772
|
+
ariaModal,
|
|
1773
|
+
arrowStyle,
|
|
1774
|
+
contentAttrs,
|
|
1775
|
+
contentClass,
|
|
1776
|
+
contentStyle,
|
|
1777
|
+
contentZIndex,
|
|
1778
|
+
updateZIndex
|
|
1779
|
+
};
|
|
1780
|
+
};
|
|
1781
|
+
|
|
1782
|
+
const usePopperContentFocusTrap = (props, emit) => {
|
|
1783
|
+
const trapped = vue.ref(false);
|
|
1784
|
+
const focusStartRef = vue.ref();
|
|
1785
|
+
const onFocusAfterTrapped = () => {
|
|
1786
|
+
emit("focus");
|
|
1787
|
+
};
|
|
1788
|
+
const onFocusAfterReleased = (event) => {
|
|
1789
|
+
var _a;
|
|
1790
|
+
if (((_a = event.detail) == null ? void 0 : _a.focusReason) !== "pointer") {
|
|
1791
|
+
focusStartRef.value = "first";
|
|
1792
|
+
emit("blur");
|
|
1793
|
+
}
|
|
1794
|
+
};
|
|
1795
|
+
const onFocusInTrap = (event) => {
|
|
1796
|
+
if (props.visible && !trapped.value) {
|
|
1797
|
+
if (event.target) {
|
|
1798
|
+
focusStartRef.value = event.target;
|
|
1799
|
+
}
|
|
1800
|
+
trapped.value = true;
|
|
1801
|
+
}
|
|
1802
|
+
};
|
|
1803
|
+
const onFocusoutPrevented = (event) => {
|
|
1804
|
+
if (!props.trapping) {
|
|
1805
|
+
if (event.detail.focusReason === "pointer") {
|
|
1806
|
+
event.preventDefault();
|
|
1807
|
+
}
|
|
1808
|
+
trapped.value = false;
|
|
1809
|
+
}
|
|
1810
|
+
};
|
|
1811
|
+
const onReleaseRequested = () => {
|
|
1812
|
+
trapped.value = false;
|
|
1813
|
+
emit("close");
|
|
1814
|
+
};
|
|
1815
|
+
return {
|
|
1816
|
+
focusStartRef,
|
|
1817
|
+
trapped,
|
|
1818
|
+
onFocusAfterReleased,
|
|
1819
|
+
onFocusAfterTrapped,
|
|
1820
|
+
onFocusInTrap,
|
|
1821
|
+
onFocusoutPrevented,
|
|
1822
|
+
onReleaseRequested
|
|
1823
|
+
};
|
|
1824
|
+
};
|
|
1825
|
+
|
|
1826
|
+
const __default__$3 = vue.defineComponent({
|
|
1827
|
+
name: "ElPopperContent"
|
|
1828
|
+
});
|
|
1829
|
+
const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
|
|
1830
|
+
...__default__$3,
|
|
1831
|
+
props: popperContentProps,
|
|
1832
|
+
emits: popperContentEmits,
|
|
1833
|
+
setup(__props, { expose, emit }) {
|
|
1834
|
+
const props = __props;
|
|
1835
|
+
const {
|
|
1836
|
+
focusStartRef,
|
|
1837
|
+
trapped,
|
|
1838
|
+
onFocusAfterReleased,
|
|
1839
|
+
onFocusAfterTrapped,
|
|
1840
|
+
onFocusInTrap,
|
|
1841
|
+
onFocusoutPrevented,
|
|
1842
|
+
onReleaseRequested
|
|
1843
|
+
} = usePopperContentFocusTrap(props, emit);
|
|
1844
|
+
const { attributes, arrowRef, contentRef, styles, instanceRef, role, update } = usePopperContent(props);
|
|
1845
|
+
const {
|
|
1846
|
+
ariaModal,
|
|
1847
|
+
arrowStyle,
|
|
1848
|
+
contentAttrs,
|
|
1849
|
+
contentClass,
|
|
1850
|
+
contentStyle,
|
|
1851
|
+
updateZIndex
|
|
1852
|
+
} = usePopperContentDOM(props, {
|
|
1853
|
+
styles,
|
|
1854
|
+
attributes,
|
|
1855
|
+
role
|
|
1856
|
+
});
|
|
1857
|
+
const formItemContext = vue.inject(formItemContextKey, void 0);
|
|
1858
|
+
const arrowOffset = vue.ref();
|
|
1859
|
+
vue.provide(POPPER_CONTENT_INJECTION_KEY, {
|
|
1860
|
+
arrowStyle,
|
|
1861
|
+
arrowRef,
|
|
1862
|
+
arrowOffset
|
|
1863
|
+
});
|
|
1864
|
+
if (formItemContext && (formItemContext.addInputId || formItemContext.removeInputId)) {
|
|
1865
|
+
vue.provide(formItemContextKey, {
|
|
1866
|
+
...formItemContext,
|
|
1867
|
+
addInputId: NOOP,
|
|
1868
|
+
removeInputId: NOOP
|
|
1869
|
+
});
|
|
1870
|
+
}
|
|
1871
|
+
let triggerTargetAriaStopWatch = void 0;
|
|
1872
|
+
const updatePopper = (shouldUpdateZIndex = true) => {
|
|
1873
|
+
update();
|
|
1874
|
+
shouldUpdateZIndex && updateZIndex();
|
|
1875
|
+
};
|
|
1876
|
+
const togglePopperAlive = () => {
|
|
1877
|
+
updatePopper(false);
|
|
1878
|
+
if (props.visible && props.focusOnShow) {
|
|
1879
|
+
trapped.value = true;
|
|
1880
|
+
} else if (props.visible === false) {
|
|
1881
|
+
trapped.value = false;
|
|
1882
|
+
}
|
|
1883
|
+
};
|
|
1884
|
+
vue.onMounted(() => {
|
|
1885
|
+
vue.watch(() => props.triggerTargetEl, (triggerTargetEl, prevTriggerTargetEl) => {
|
|
1886
|
+
triggerTargetAriaStopWatch == null ? void 0 : triggerTargetAriaStopWatch();
|
|
1887
|
+
triggerTargetAriaStopWatch = void 0;
|
|
1888
|
+
const el = vue.unref(triggerTargetEl || contentRef.value);
|
|
1889
|
+
const prevEl = vue.unref(prevTriggerTargetEl || contentRef.value);
|
|
1890
|
+
if (isElement(el)) {
|
|
1891
|
+
triggerTargetAriaStopWatch = vue.watch([role, () => props.ariaLabel, ariaModal, () => props.id], (watches) => {
|
|
1892
|
+
["role", "aria-label", "aria-modal", "id"].forEach((key, idx) => {
|
|
1893
|
+
isNil(watches[idx]) ? el.removeAttribute(key) : el.setAttribute(key, watches[idx]);
|
|
1894
|
+
});
|
|
1895
|
+
}, { immediate: true });
|
|
1896
|
+
}
|
|
1897
|
+
if (prevEl !== el && isElement(prevEl)) {
|
|
1898
|
+
["role", "aria-label", "aria-modal", "id"].forEach((key) => {
|
|
1899
|
+
prevEl.removeAttribute(key);
|
|
1900
|
+
});
|
|
1901
|
+
}
|
|
1902
|
+
}, { immediate: true });
|
|
1903
|
+
vue.watch(() => props.visible, togglePopperAlive, { immediate: true });
|
|
1904
|
+
});
|
|
1905
|
+
vue.onBeforeUnmount(() => {
|
|
1906
|
+
triggerTargetAriaStopWatch == null ? void 0 : triggerTargetAriaStopWatch();
|
|
1907
|
+
triggerTargetAriaStopWatch = void 0;
|
|
1908
|
+
});
|
|
1909
|
+
expose({
|
|
1910
|
+
popperContentRef: contentRef,
|
|
1911
|
+
popperInstanceRef: instanceRef,
|
|
1912
|
+
updatePopper,
|
|
1913
|
+
contentStyle
|
|
1914
|
+
});
|
|
1915
|
+
return (_ctx, _cache) => {
|
|
1916
|
+
return vue.openBlock(), vue.createElementBlock("div", vue.mergeProps({
|
|
1917
|
+
ref_key: "contentRef",
|
|
1918
|
+
ref: contentRef
|
|
1919
|
+
}, vue.unref(contentAttrs), {
|
|
1920
|
+
style: vue.unref(contentStyle),
|
|
1921
|
+
class: vue.unref(contentClass),
|
|
1922
|
+
tabindex: "-1",
|
|
1923
|
+
onMouseenter: _cache[0] || (_cache[0] = (e) => _ctx.$emit("mouseenter", e)),
|
|
1924
|
+
onMouseleave: _cache[1] || (_cache[1] = (e) => _ctx.$emit("mouseleave", e))
|
|
1925
|
+
}), [
|
|
1926
|
+
vue.createVNode(vue.unref(ElFocusTrap), {
|
|
1927
|
+
trapped: vue.unref(trapped),
|
|
1928
|
+
"trap-on-focus-in": true,
|
|
1929
|
+
"focus-trap-el": vue.unref(contentRef),
|
|
1930
|
+
"focus-start-el": vue.unref(focusStartRef),
|
|
1931
|
+
onFocusAfterTrapped: vue.unref(onFocusAfterTrapped),
|
|
1932
|
+
onFocusAfterReleased: vue.unref(onFocusAfterReleased),
|
|
1933
|
+
onFocusin: vue.unref(onFocusInTrap),
|
|
1934
|
+
onFocusoutPrevented: vue.unref(onFocusoutPrevented),
|
|
1935
|
+
onReleaseRequested: vue.unref(onReleaseRequested)
|
|
1936
|
+
}, {
|
|
1937
|
+
default: vue.withCtx(() => [
|
|
1938
|
+
vue.renderSlot(_ctx.$slots, "default")
|
|
1939
|
+
]),
|
|
1940
|
+
_: 3
|
|
1941
|
+
}, 8, ["trapped", "focus-trap-el", "focus-start-el", "onFocusAfterTrapped", "onFocusAfterReleased", "onFocusin", "onFocusoutPrevented", "onReleaseRequested"])
|
|
1942
|
+
], 16);
|
|
1943
|
+
};
|
|
1944
|
+
}
|
|
1945
|
+
});
|
|
1946
|
+
var ElPopperContent = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/popper/src/content.vue"]]);
|
|
1947
|
+
|
|
1948
|
+
const ElPopper = withInstall(Popper);
|
|
1949
|
+
|
|
1950
|
+
const TOOLTIP_INJECTION_KEY = Symbol("elTooltip");
|
|
1951
|
+
|
|
1952
|
+
const useTooltipContentProps = buildProps({
|
|
1953
|
+
...useDelayedToggleProps,
|
|
1954
|
+
...popperContentProps,
|
|
1955
|
+
appendTo: {
|
|
1956
|
+
type: definePropType([String, Object])
|
|
1957
|
+
},
|
|
1958
|
+
content: {
|
|
1959
|
+
type: String,
|
|
1960
|
+
default: ""
|
|
1961
|
+
},
|
|
1962
|
+
rawContent: {
|
|
1963
|
+
type: Boolean,
|
|
1964
|
+
default: false
|
|
1965
|
+
},
|
|
1966
|
+
persistent: Boolean,
|
|
1967
|
+
ariaLabel: String,
|
|
1968
|
+
visible: {
|
|
1969
|
+
type: definePropType(Boolean),
|
|
1970
|
+
default: null
|
|
1971
|
+
},
|
|
1972
|
+
transition: String,
|
|
1973
|
+
teleported: {
|
|
1974
|
+
type: Boolean,
|
|
1975
|
+
default: true
|
|
1976
|
+
},
|
|
1977
|
+
disabled: Boolean
|
|
1978
|
+
});
|
|
1979
|
+
|
|
1980
|
+
const useTooltipTriggerProps = buildProps({
|
|
1981
|
+
...popperTriggerProps,
|
|
1982
|
+
disabled: Boolean,
|
|
1983
|
+
trigger: {
|
|
1984
|
+
type: definePropType([String, Array]),
|
|
1985
|
+
default: "hover"
|
|
1986
|
+
},
|
|
1987
|
+
triggerKeys: {
|
|
1988
|
+
type: definePropType(Array),
|
|
1989
|
+
default: () => [EVENT_CODE.enter, EVENT_CODE.space]
|
|
1990
|
+
}
|
|
1991
|
+
});
|
|
1992
|
+
|
|
1993
|
+
const {
|
|
1994
|
+
useModelToggleProps: useTooltipModelToggleProps,
|
|
1995
|
+
useModelToggleEmits: useTooltipModelToggleEmits,
|
|
1996
|
+
useModelToggle: useTooltipModelToggle
|
|
1997
|
+
} = createModelToggleComposable("visible");
|
|
1998
|
+
const useTooltipProps = buildProps({
|
|
1999
|
+
...popperProps,
|
|
2000
|
+
...useTooltipModelToggleProps,
|
|
2001
|
+
...useTooltipContentProps,
|
|
2002
|
+
...useTooltipTriggerProps,
|
|
2003
|
+
...popperArrowProps,
|
|
2004
|
+
showArrow: {
|
|
2005
|
+
type: Boolean,
|
|
2006
|
+
default: true
|
|
2007
|
+
}
|
|
2008
|
+
});
|
|
2009
|
+
const tooltipEmits = [
|
|
2010
|
+
...useTooltipModelToggleEmits,
|
|
2011
|
+
"before-show",
|
|
2012
|
+
"before-hide",
|
|
2013
|
+
"show",
|
|
2014
|
+
"hide",
|
|
2015
|
+
"open",
|
|
2016
|
+
"close"
|
|
2017
|
+
];
|
|
2018
|
+
|
|
2019
|
+
const isTriggerType = (trigger, type) => {
|
|
2020
|
+
if (isArray(trigger)) {
|
|
2021
|
+
return trigger.includes(type);
|
|
2022
|
+
}
|
|
2023
|
+
return trigger === type;
|
|
2024
|
+
};
|
|
2025
|
+
const whenTrigger = (trigger, type, handler) => {
|
|
2026
|
+
return (e) => {
|
|
2027
|
+
isTriggerType(vue.unref(trigger), type) && handler(e);
|
|
2028
|
+
};
|
|
2029
|
+
};
|
|
2030
|
+
|
|
2031
|
+
const __default__$2 = vue.defineComponent({
|
|
2032
|
+
name: "ElTooltipTrigger"
|
|
2033
|
+
});
|
|
2034
|
+
const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
2035
|
+
...__default__$2,
|
|
2036
|
+
props: useTooltipTriggerProps,
|
|
2037
|
+
setup(__props, { expose }) {
|
|
2038
|
+
const props = __props;
|
|
2039
|
+
const ns = useNamespace("tooltip");
|
|
2040
|
+
const { controlled, id, open, onOpen, onClose, onToggle } = vue.inject(TOOLTIP_INJECTION_KEY, void 0);
|
|
2041
|
+
const triggerRef = vue.ref(null);
|
|
2042
|
+
const stopWhenControlledOrDisabled = () => {
|
|
2043
|
+
if (vue.unref(controlled) || props.disabled) {
|
|
2044
|
+
return true;
|
|
2045
|
+
}
|
|
2046
|
+
};
|
|
2047
|
+
const trigger = vue.toRef(props, "trigger");
|
|
2048
|
+
const onMouseenter = composeEventHandlers(stopWhenControlledOrDisabled, whenTrigger(trigger, "hover", onOpen));
|
|
2049
|
+
const onMouseleave = composeEventHandlers(stopWhenControlledOrDisabled, whenTrigger(trigger, "hover", onClose));
|
|
2050
|
+
const onClick = composeEventHandlers(stopWhenControlledOrDisabled, whenTrigger(trigger, "click", (e) => {
|
|
2051
|
+
if (e.button === 0) {
|
|
2052
|
+
onToggle(e);
|
|
2053
|
+
}
|
|
2054
|
+
}));
|
|
2055
|
+
const onFocus = composeEventHandlers(stopWhenControlledOrDisabled, whenTrigger(trigger, "focus", onOpen));
|
|
2056
|
+
const onBlur = composeEventHandlers(stopWhenControlledOrDisabled, whenTrigger(trigger, "focus", onClose));
|
|
2057
|
+
const onContextMenu = composeEventHandlers(stopWhenControlledOrDisabled, whenTrigger(trigger, "contextmenu", (e) => {
|
|
2058
|
+
e.preventDefault();
|
|
2059
|
+
onToggle(e);
|
|
2060
|
+
}));
|
|
2061
|
+
const onKeydown = composeEventHandlers(stopWhenControlledOrDisabled, (e) => {
|
|
2062
|
+
const { code } = e;
|
|
2063
|
+
if (props.triggerKeys.includes(code)) {
|
|
2064
|
+
e.preventDefault();
|
|
2065
|
+
onToggle(e);
|
|
2066
|
+
}
|
|
2067
|
+
});
|
|
2068
|
+
expose({
|
|
2069
|
+
triggerRef
|
|
2070
|
+
});
|
|
2071
|
+
return (_ctx, _cache) => {
|
|
2072
|
+
return vue.openBlock(), vue.createBlock(vue.unref(ElPopperTrigger), {
|
|
2073
|
+
id: vue.unref(id),
|
|
2074
|
+
"virtual-ref": _ctx.virtualRef,
|
|
2075
|
+
open: vue.unref(open),
|
|
2076
|
+
"virtual-triggering": _ctx.virtualTriggering,
|
|
2077
|
+
class: vue.normalizeClass(vue.unref(ns).e("trigger")),
|
|
2078
|
+
onBlur: vue.unref(onBlur),
|
|
2079
|
+
onClick: vue.unref(onClick),
|
|
2080
|
+
onContextmenu: vue.unref(onContextMenu),
|
|
2081
|
+
onFocus: vue.unref(onFocus),
|
|
2082
|
+
onMouseenter: vue.unref(onMouseenter),
|
|
2083
|
+
onMouseleave: vue.unref(onMouseleave),
|
|
2084
|
+
onKeydown: vue.unref(onKeydown)
|
|
2085
|
+
}, {
|
|
2086
|
+
default: vue.withCtx(() => [
|
|
2087
|
+
vue.renderSlot(_ctx.$slots, "default")
|
|
2088
|
+
]),
|
|
2089
|
+
_: 3
|
|
2090
|
+
}, 8, ["id", "virtual-ref", "open", "virtual-triggering", "class", "onBlur", "onClick", "onContextmenu", "onFocus", "onMouseenter", "onMouseleave", "onKeydown"]);
|
|
2091
|
+
};
|
|
2092
|
+
}
|
|
2093
|
+
});
|
|
2094
|
+
var ElTooltipTrigger = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/tooltip/src/trigger.vue"]]);
|
|
2095
|
+
|
|
2096
|
+
const __default__$1 = vue.defineComponent({
|
|
2097
|
+
name: "ElTooltipContent",
|
|
2098
|
+
inheritAttrs: false
|
|
2099
|
+
});
|
|
2100
|
+
const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
2101
|
+
...__default__$1,
|
|
2102
|
+
props: useTooltipContentProps,
|
|
2103
|
+
setup(__props, { expose }) {
|
|
2104
|
+
const props = __props;
|
|
2105
|
+
const { selector } = usePopperContainerId();
|
|
2106
|
+
const ns = useNamespace("tooltip");
|
|
2107
|
+
const contentRef = vue.ref(null);
|
|
2108
|
+
const destroyed = vue.ref(false);
|
|
2109
|
+
const {
|
|
2110
|
+
controlled,
|
|
2111
|
+
id,
|
|
2112
|
+
open,
|
|
2113
|
+
trigger,
|
|
2114
|
+
onClose,
|
|
2115
|
+
onOpen,
|
|
2116
|
+
onShow,
|
|
2117
|
+
onHide,
|
|
2118
|
+
onBeforeShow,
|
|
2119
|
+
onBeforeHide
|
|
2120
|
+
} = vue.inject(TOOLTIP_INJECTION_KEY, void 0);
|
|
2121
|
+
const transitionClass = vue.computed(() => {
|
|
2122
|
+
return props.transition || `${ns.namespace.value}-fade-in-linear`;
|
|
2123
|
+
});
|
|
2124
|
+
const persistentRef = vue.computed(() => {
|
|
2125
|
+
if (process.env.NODE_ENV === "test") {
|
|
2126
|
+
return true;
|
|
2127
|
+
}
|
|
2128
|
+
return props.persistent;
|
|
2129
|
+
});
|
|
2130
|
+
vue.onBeforeUnmount(() => {
|
|
2131
|
+
destroyed.value = true;
|
|
2132
|
+
});
|
|
2133
|
+
const shouldRender = vue.computed(() => {
|
|
2134
|
+
return vue.unref(persistentRef) ? true : vue.unref(open);
|
|
2135
|
+
});
|
|
2136
|
+
const shouldShow = vue.computed(() => {
|
|
2137
|
+
return props.disabled ? false : vue.unref(open);
|
|
2138
|
+
});
|
|
2139
|
+
const appendTo = vue.computed(() => {
|
|
2140
|
+
return props.appendTo || selector.value;
|
|
2141
|
+
});
|
|
2142
|
+
const contentStyle = vue.computed(() => {
|
|
2143
|
+
var _a;
|
|
2144
|
+
return (_a = props.style) != null ? _a : {};
|
|
2145
|
+
});
|
|
2146
|
+
const ariaHidden = vue.computed(() => !vue.unref(open));
|
|
2147
|
+
const onTransitionLeave = () => {
|
|
2148
|
+
onHide();
|
|
2149
|
+
};
|
|
2150
|
+
const stopWhenControlled = () => {
|
|
2151
|
+
if (vue.unref(controlled))
|
|
2152
|
+
return true;
|
|
2153
|
+
};
|
|
2154
|
+
const onContentEnter = composeEventHandlers(stopWhenControlled, () => {
|
|
2155
|
+
if (props.enterable && vue.unref(trigger) === "hover") {
|
|
2156
|
+
onOpen();
|
|
2157
|
+
}
|
|
2158
|
+
});
|
|
2159
|
+
const onContentLeave = composeEventHandlers(stopWhenControlled, () => {
|
|
2160
|
+
if (vue.unref(trigger) === "hover") {
|
|
2161
|
+
onClose();
|
|
2162
|
+
}
|
|
2163
|
+
});
|
|
2164
|
+
const onBeforeEnter = () => {
|
|
2165
|
+
var _a, _b;
|
|
2166
|
+
(_b = (_a = contentRef.value) == null ? void 0 : _a.updatePopper) == null ? void 0 : _b.call(_a);
|
|
2167
|
+
onBeforeShow == null ? void 0 : onBeforeShow();
|
|
2168
|
+
};
|
|
2169
|
+
const onBeforeLeave = () => {
|
|
2170
|
+
onBeforeHide == null ? void 0 : onBeforeHide();
|
|
2171
|
+
};
|
|
2172
|
+
const onAfterShow = () => {
|
|
2173
|
+
onShow();
|
|
2174
|
+
stopHandle = onClickOutside(vue.computed(() => {
|
|
2175
|
+
var _a;
|
|
2176
|
+
return (_a = contentRef.value) == null ? void 0 : _a.popperContentRef;
|
|
2177
|
+
}), () => {
|
|
2178
|
+
if (vue.unref(controlled))
|
|
2179
|
+
return;
|
|
2180
|
+
const $trigger = vue.unref(trigger);
|
|
2181
|
+
if ($trigger !== "hover") {
|
|
2182
|
+
onClose();
|
|
2183
|
+
}
|
|
2184
|
+
});
|
|
2185
|
+
};
|
|
2186
|
+
const onBlur = () => {
|
|
2187
|
+
if (!props.virtualTriggering) {
|
|
2188
|
+
onClose();
|
|
2189
|
+
}
|
|
2190
|
+
};
|
|
2191
|
+
let stopHandle;
|
|
2192
|
+
vue.watch(() => vue.unref(open), (val) => {
|
|
2193
|
+
if (!val) {
|
|
2194
|
+
stopHandle == null ? void 0 : stopHandle();
|
|
2195
|
+
}
|
|
2196
|
+
}, {
|
|
2197
|
+
flush: "post"
|
|
2198
|
+
});
|
|
2199
|
+
vue.watch(() => props.content, () => {
|
|
2200
|
+
var _a, _b;
|
|
2201
|
+
(_b = (_a = contentRef.value) == null ? void 0 : _a.updatePopper) == null ? void 0 : _b.call(_a);
|
|
2202
|
+
});
|
|
2203
|
+
expose({
|
|
2204
|
+
contentRef
|
|
2205
|
+
});
|
|
2206
|
+
return (_ctx, _cache) => {
|
|
2207
|
+
return vue.openBlock(), vue.createBlock(vue.Teleport, {
|
|
2208
|
+
disabled: !_ctx.teleported,
|
|
2209
|
+
to: vue.unref(appendTo)
|
|
2210
|
+
}, [
|
|
2211
|
+
vue.createVNode(vue.Transition, {
|
|
2212
|
+
name: vue.unref(transitionClass),
|
|
2213
|
+
onAfterLeave: onTransitionLeave,
|
|
2214
|
+
onBeforeEnter,
|
|
2215
|
+
onAfterEnter: onAfterShow,
|
|
2216
|
+
onBeforeLeave
|
|
2217
|
+
}, {
|
|
2218
|
+
default: vue.withCtx(() => [
|
|
2219
|
+
vue.unref(shouldRender) ? vue.withDirectives((vue.openBlock(), vue.createBlock(vue.unref(ElPopperContent), vue.mergeProps({
|
|
2220
|
+
key: 0,
|
|
2221
|
+
id: vue.unref(id),
|
|
2222
|
+
ref_key: "contentRef",
|
|
2223
|
+
ref: contentRef
|
|
2224
|
+
}, _ctx.$attrs, {
|
|
2225
|
+
"aria-label": _ctx.ariaLabel,
|
|
2226
|
+
"aria-hidden": vue.unref(ariaHidden),
|
|
2227
|
+
"boundaries-padding": _ctx.boundariesPadding,
|
|
2228
|
+
"fallback-placements": _ctx.fallbackPlacements,
|
|
2229
|
+
"gpu-acceleration": _ctx.gpuAcceleration,
|
|
2230
|
+
offset: _ctx.offset,
|
|
2231
|
+
placement: _ctx.placement,
|
|
2232
|
+
"popper-options": _ctx.popperOptions,
|
|
2233
|
+
strategy: _ctx.strategy,
|
|
2234
|
+
effect: _ctx.effect,
|
|
2235
|
+
enterable: _ctx.enterable,
|
|
2236
|
+
pure: _ctx.pure,
|
|
2237
|
+
"popper-class": _ctx.popperClass,
|
|
2238
|
+
"popper-style": [_ctx.popperStyle, vue.unref(contentStyle)],
|
|
2239
|
+
"reference-el": _ctx.referenceEl,
|
|
2240
|
+
"trigger-target-el": _ctx.triggerTargetEl,
|
|
2241
|
+
visible: vue.unref(shouldShow),
|
|
2242
|
+
"z-index": _ctx.zIndex,
|
|
2243
|
+
onMouseenter: vue.unref(onContentEnter),
|
|
2244
|
+
onMouseleave: vue.unref(onContentLeave),
|
|
2245
|
+
onBlur,
|
|
2246
|
+
onClose: vue.unref(onClose)
|
|
2247
|
+
}), {
|
|
2248
|
+
default: vue.withCtx(() => [
|
|
2249
|
+
!destroyed.value ? vue.renderSlot(_ctx.$slots, "default", { key: 0 }) : vue.createCommentVNode("v-if", true)
|
|
2250
|
+
]),
|
|
2251
|
+
_: 3
|
|
2252
|
+
}, 16, ["id", "aria-label", "aria-hidden", "boundaries-padding", "fallback-placements", "gpu-acceleration", "offset", "placement", "popper-options", "strategy", "effect", "enterable", "pure", "popper-class", "popper-style", "reference-el", "trigger-target-el", "visible", "z-index", "onMouseenter", "onMouseleave", "onClose"])), [
|
|
2253
|
+
[vue.vShow, vue.unref(shouldShow)]
|
|
2254
|
+
]) : vue.createCommentVNode("v-if", true)
|
|
2255
|
+
]),
|
|
2256
|
+
_: 3
|
|
2257
|
+
}, 8, ["name"])
|
|
2258
|
+
], 8, ["disabled", "to"]);
|
|
2259
|
+
};
|
|
2260
|
+
}
|
|
2261
|
+
});
|
|
2262
|
+
var ElTooltipContent = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/tooltip/src/content.vue"]]);
|
|
2263
|
+
|
|
2264
|
+
const _hoisted_1 = ["innerHTML"];
|
|
2265
|
+
const _hoisted_2 = { key: 1 };
|
|
2266
|
+
const __default__ = vue.defineComponent({
|
|
2267
|
+
name: "ElTooltip"
|
|
2268
|
+
});
|
|
2269
|
+
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
2270
|
+
...__default__,
|
|
2271
|
+
props: useTooltipProps,
|
|
2272
|
+
emits: tooltipEmits,
|
|
2273
|
+
setup(__props, { expose, emit }) {
|
|
2274
|
+
const props = __props;
|
|
2275
|
+
usePopperContainer();
|
|
2276
|
+
const id = useId();
|
|
2277
|
+
const popperRef = vue.ref();
|
|
2278
|
+
const contentRef = vue.ref();
|
|
2279
|
+
const updatePopper = () => {
|
|
2280
|
+
var _a;
|
|
2281
|
+
const popperComponent = vue.unref(popperRef);
|
|
2282
|
+
if (popperComponent) {
|
|
2283
|
+
(_a = popperComponent.popperInstanceRef) == null ? void 0 : _a.update();
|
|
2284
|
+
}
|
|
2285
|
+
};
|
|
2286
|
+
const open = vue.ref(false);
|
|
2287
|
+
const toggleReason = vue.ref();
|
|
2288
|
+
const { show, hide, hasUpdateHandler } = useTooltipModelToggle({
|
|
2289
|
+
indicator: open,
|
|
2290
|
+
toggleReason
|
|
2291
|
+
});
|
|
2292
|
+
const { onOpen, onClose } = useDelayedToggle({
|
|
2293
|
+
showAfter: vue.toRef(props, "showAfter"),
|
|
2294
|
+
hideAfter: vue.toRef(props, "hideAfter"),
|
|
2295
|
+
autoClose: vue.toRef(props, "autoClose"),
|
|
2296
|
+
open: show,
|
|
2297
|
+
close: hide
|
|
2298
|
+
});
|
|
2299
|
+
const controlled = vue.computed(() => isBoolean(props.visible) && !hasUpdateHandler.value);
|
|
2300
|
+
vue.provide(TOOLTIP_INJECTION_KEY, {
|
|
2301
|
+
controlled,
|
|
2302
|
+
id,
|
|
2303
|
+
open: vue.readonly(open),
|
|
2304
|
+
trigger: vue.toRef(props, "trigger"),
|
|
2305
|
+
onOpen: (event) => {
|
|
2306
|
+
onOpen(event);
|
|
2307
|
+
},
|
|
2308
|
+
onClose: (event) => {
|
|
2309
|
+
onClose(event);
|
|
2310
|
+
},
|
|
2311
|
+
onToggle: (event) => {
|
|
2312
|
+
if (vue.unref(open)) {
|
|
2313
|
+
onClose(event);
|
|
2314
|
+
} else {
|
|
2315
|
+
onOpen(event);
|
|
2316
|
+
}
|
|
2317
|
+
},
|
|
2318
|
+
onShow: () => {
|
|
2319
|
+
emit("show", toggleReason.value);
|
|
2320
|
+
},
|
|
2321
|
+
onHide: () => {
|
|
2322
|
+
emit("hide", toggleReason.value);
|
|
2323
|
+
},
|
|
2324
|
+
onBeforeShow: () => {
|
|
2325
|
+
emit("before-show", toggleReason.value);
|
|
2326
|
+
},
|
|
2327
|
+
onBeforeHide: () => {
|
|
2328
|
+
emit("before-hide", toggleReason.value);
|
|
2329
|
+
},
|
|
2330
|
+
updatePopper
|
|
2331
|
+
});
|
|
2332
|
+
vue.watch(() => props.disabled, (disabled) => {
|
|
2333
|
+
if (disabled && open.value) {
|
|
2334
|
+
open.value = false;
|
|
2335
|
+
}
|
|
2336
|
+
});
|
|
2337
|
+
const isFocusInsideContent = () => {
|
|
2338
|
+
var _a, _b;
|
|
2339
|
+
const popperContent = (_b = (_a = contentRef.value) == null ? void 0 : _a.contentRef) == null ? void 0 : _b.popperContentRef;
|
|
2340
|
+
return popperContent && popperContent.contains(document.activeElement);
|
|
2341
|
+
};
|
|
2342
|
+
vue.onDeactivated(() => open.value && hide());
|
|
2343
|
+
expose({
|
|
2344
|
+
popperRef,
|
|
2345
|
+
contentRef,
|
|
2346
|
+
isFocusInsideContent,
|
|
2347
|
+
updatePopper,
|
|
2348
|
+
onOpen,
|
|
2349
|
+
onClose,
|
|
2350
|
+
hide
|
|
2351
|
+
});
|
|
2352
|
+
return (_ctx, _cache) => {
|
|
2353
|
+
return vue.openBlock(), vue.createBlock(vue.unref(ElPopper), {
|
|
2354
|
+
ref_key: "popperRef",
|
|
2355
|
+
ref: popperRef,
|
|
2356
|
+
role: _ctx.role
|
|
2357
|
+
}, {
|
|
2358
|
+
default: vue.withCtx(() => [
|
|
2359
|
+
vue.createVNode(ElTooltipTrigger, {
|
|
2360
|
+
disabled: _ctx.disabled,
|
|
2361
|
+
trigger: _ctx.trigger,
|
|
2362
|
+
"trigger-keys": _ctx.triggerKeys,
|
|
2363
|
+
"virtual-ref": _ctx.virtualRef,
|
|
2364
|
+
"virtual-triggering": _ctx.virtualTriggering
|
|
2365
|
+
}, {
|
|
2366
|
+
default: vue.withCtx(() => [
|
|
2367
|
+
_ctx.$slots.default ? vue.renderSlot(_ctx.$slots, "default", { key: 0 }) : vue.createCommentVNode("v-if", true)
|
|
2368
|
+
]),
|
|
2369
|
+
_: 3
|
|
2370
|
+
}, 8, ["disabled", "trigger", "trigger-keys", "virtual-ref", "virtual-triggering"]),
|
|
2371
|
+
vue.createVNode(ElTooltipContent, {
|
|
2372
|
+
ref_key: "contentRef",
|
|
2373
|
+
ref: contentRef,
|
|
2374
|
+
"aria-label": _ctx.ariaLabel,
|
|
2375
|
+
"boundaries-padding": _ctx.boundariesPadding,
|
|
2376
|
+
content: _ctx.content,
|
|
2377
|
+
disabled: _ctx.disabled,
|
|
2378
|
+
effect: _ctx.effect,
|
|
2379
|
+
enterable: _ctx.enterable,
|
|
2380
|
+
"fallback-placements": _ctx.fallbackPlacements,
|
|
2381
|
+
"hide-after": _ctx.hideAfter,
|
|
2382
|
+
"gpu-acceleration": _ctx.gpuAcceleration,
|
|
2383
|
+
offset: _ctx.offset,
|
|
2384
|
+
persistent: _ctx.persistent,
|
|
2385
|
+
"popper-class": _ctx.popperClass,
|
|
2386
|
+
"popper-style": _ctx.popperStyle,
|
|
2387
|
+
placement: _ctx.placement,
|
|
2388
|
+
"popper-options": _ctx.popperOptions,
|
|
2389
|
+
pure: _ctx.pure,
|
|
2390
|
+
"raw-content": _ctx.rawContent,
|
|
2391
|
+
"reference-el": _ctx.referenceEl,
|
|
2392
|
+
"trigger-target-el": _ctx.triggerTargetEl,
|
|
2393
|
+
"show-after": _ctx.showAfter,
|
|
2394
|
+
strategy: _ctx.strategy,
|
|
2395
|
+
teleported: _ctx.teleported,
|
|
2396
|
+
transition: _ctx.transition,
|
|
2397
|
+
"virtual-triggering": _ctx.virtualTriggering,
|
|
2398
|
+
"z-index": _ctx.zIndex,
|
|
2399
|
+
"append-to": _ctx.appendTo
|
|
2400
|
+
}, {
|
|
2401
|
+
default: vue.withCtx(() => [
|
|
2402
|
+
vue.renderSlot(_ctx.$slots, "content", {}, () => [
|
|
2403
|
+
_ctx.rawContent ? (vue.openBlock(), vue.createElementBlock("span", {
|
|
2404
|
+
key: 0,
|
|
2405
|
+
innerHTML: _ctx.content
|
|
2406
|
+
}, null, 8, _hoisted_1)) : (vue.openBlock(), vue.createElementBlock("span", _hoisted_2, vue.toDisplayString(_ctx.content), 1))
|
|
2407
|
+
]),
|
|
2408
|
+
_ctx.showArrow ? (vue.openBlock(), vue.createBlock(vue.unref(ElPopperArrow), {
|
|
2409
|
+
key: 0,
|
|
2410
|
+
"arrow-offset": _ctx.arrowOffset
|
|
2411
|
+
}, null, 8, ["arrow-offset"])) : vue.createCommentVNode("v-if", true)
|
|
2412
|
+
]),
|
|
2413
|
+
_: 3
|
|
2414
|
+
}, 8, ["aria-label", "boundaries-padding", "content", "disabled", "effect", "enterable", "fallback-placements", "hide-after", "gpu-acceleration", "offset", "persistent", "popper-class", "popper-style", "placement", "popper-options", "pure", "raw-content", "reference-el", "trigger-target-el", "show-after", "strategy", "teleported", "transition", "virtual-triggering", "z-index", "append-to"])
|
|
2415
|
+
]),
|
|
2416
|
+
_: 3
|
|
2417
|
+
}, 8, ["role"]);
|
|
2418
|
+
};
|
|
2419
|
+
}
|
|
2420
|
+
});
|
|
2421
|
+
var Tooltip = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/tooltip/src/tooltip.vue"]]);
|
|
2422
|
+
|
|
2423
|
+
const ElTooltip = withInstall(Tooltip);
|
|
2424
|
+
|
|
2425
|
+
function useBase(props, attrs) {
|
|
2426
|
+
const rxToolTipOptions = vue.ref();
|
|
2427
|
+
function init() {
|
|
2428
|
+
const { popperClass } = attrs;
|
|
2429
|
+
console.log(attrs);
|
|
2430
|
+
rxToolTipOptions.value = Object.assign(Object.assign({}, attrs), { popperClass: popperClass ? popperClass : 'rx-tooltip' });
|
|
2431
|
+
}
|
|
2432
|
+
return { rxToolTipOptions, init };
|
|
2433
|
+
}
|
|
2434
|
+
|
|
2435
|
+
function useController(props, attrs, init) {
|
|
2436
|
+
vue.watch(() => attrs, () => {
|
|
2437
|
+
vue.nextTick(() => init());
|
|
2438
|
+
}, { deep: true, immediate: true });
|
|
2439
|
+
return {};
|
|
2440
|
+
}
|
|
2441
|
+
|
|
2442
|
+
var script = vue.defineComponent({
|
|
2443
|
+
name: 'RxTooltip',
|
|
2444
|
+
components: { ElTooltip },
|
|
2445
|
+
props: RxTooltipProps,
|
|
2446
|
+
setup(props, { attrs }) {
|
|
2447
|
+
const { rxToolTipOptions, init } = useBase(props, attrs);
|
|
2448
|
+
vue.onMounted(() => {
|
|
2449
|
+
useController(props, attrs, init);
|
|
2450
|
+
});
|
|
2451
|
+
return { rxToolTipOptions };
|
|
2452
|
+
}
|
|
2453
|
+
});
|
|
2454
|
+
|
|
2455
|
+
function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2456
|
+
const _component_el_tooltip = vue.resolveComponent("el-tooltip");
|
|
2457
|
+
|
|
2458
|
+
return (vue.openBlock(), vue.createBlock(_component_el_tooltip, vue.normalizeProps(vue.guardReactiveProps(_ctx.$attrs)), {
|
|
2459
|
+
default: vue.withCtx(() => [
|
|
2460
|
+
vue.renderSlot(_ctx.$slots, "default")
|
|
2461
|
+
]),
|
|
2462
|
+
content: vue.withCtx(() => [
|
|
2463
|
+
vue.renderSlot(_ctx.$slots, "content")
|
|
2464
|
+
]),
|
|
2465
|
+
_: 3 /* FORWARDED */
|
|
2466
|
+
}, 16 /* FULL_PROPS */))
|
|
2467
|
+
}
|
|
2468
|
+
|
|
2469
|
+
script.render = render;
|
|
2470
|
+
script.__file = "packages/components/RxTooltip/src/index.vue";
|
|
2471
|
+
|
|
2472
|
+
const RxTooltip = withInstall$1.withInstall(script);
|
|
2473
|
+
|
|
2474
|
+
exports.RxTooltip = RxTooltip;
|
|
2475
|
+
exports["default"] = RxTooltip;
|