This commit is contained in:
2025-09-19 14:25:20 +08:00
parent 269893a435
commit fbf3f77229
24949 changed files with 2839404 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
import type { ObjectDirective } from 'vue';
declare const ClickOutside: ObjectDirective;
export default ClickOutside;

View File

@@ -0,0 +1,79 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var core = require('@vueuse/core');
var types = require('../../utils/types.js');
var shared = require('@vue/shared');
const nodeList = /* @__PURE__ */ new Map();
if (core.isClient) {
let startClick;
document.addEventListener("mousedown", (e) => startClick = e);
document.addEventListener("mouseup", (e) => {
if (startClick) {
for (const handlers of nodeList.values()) {
for (const { documentHandler } of handlers) {
documentHandler(e, startClick);
}
}
startClick = void 0;
}
});
}
function createDocumentHandler(el, binding) {
let excludes = [];
if (shared.isArray(binding.arg)) {
excludes = binding.arg;
} else if (types.isElement(binding.arg)) {
excludes.push(binding.arg);
}
return function(mouseup, mousedown) {
const popperRef = binding.instance.popperRef;
const mouseUpTarget = mouseup.target;
const mouseDownTarget = mousedown == null ? void 0 : mousedown.target;
const isBound = !binding || !binding.instance;
const isTargetExists = !mouseUpTarget || !mouseDownTarget;
const isContainedByEl = el.contains(mouseUpTarget) || el.contains(mouseDownTarget);
const isSelf = el === mouseUpTarget;
const isTargetExcluded = excludes.length && excludes.some((item) => item == null ? void 0 : item.contains(mouseUpTarget)) || excludes.length && excludes.includes(mouseDownTarget);
const isContainedByPopper = popperRef && (popperRef.contains(mouseUpTarget) || popperRef.contains(mouseDownTarget));
if (isBound || isTargetExists || isContainedByEl || isSelf || isTargetExcluded || isContainedByPopper) {
return;
}
binding.value(mouseup, mousedown);
};
}
const ClickOutside = {
beforeMount(el, binding) {
if (!nodeList.has(el)) {
nodeList.set(el, []);
}
nodeList.get(el).push({
documentHandler: createDocumentHandler(el, binding),
bindingFn: binding.value
});
},
updated(el, binding) {
if (!nodeList.has(el)) {
nodeList.set(el, []);
}
const handlers = nodeList.get(el);
const oldHandlerIndex = handlers.findIndex((item) => item.bindingFn === binding.oldValue);
const newHandler = {
documentHandler: createDocumentHandler(el, binding),
bindingFn: binding.value
};
if (oldHandlerIndex >= 0) {
handlers.splice(oldHandlerIndex, 1, newHandler);
} else {
handlers.push(newHandler);
}
},
unmounted(el) {
nodeList.delete(el);
}
};
exports["default"] = ClickOutside;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

4
node_modules/element-plus/lib/directives/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
export { default as ClickOutside } from './click-outside';
export { vRepeatClick } from './repeat-click';
export { default as TrapFocus } from './trap-focus';
export { default as Mousewheel } from './mousewheel';

16
node_modules/element-plus/lib/directives/index.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var index = require('./click-outside/index.js');
var index$1 = require('./repeat-click/index.js');
var index$2 = require('./trap-focus/index.js');
var index$3 = require('./mousewheel/index.js');
exports.ClickOutside = index["default"];
exports.vRepeatClick = index$1.vRepeatClick;
exports.TrapFocus = index$2["default"];
exports.Mousewheel = index$3["default"];
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"}

View File

@@ -0,0 +1,3 @@
import type { ObjectDirective } from 'vue';
declare const Mousewheel: ObjectDirective;
export default Mousewheel;

View File

@@ -0,0 +1,27 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var normalizeWheel = require('normalize-wheel-es');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var normalizeWheel__default = /*#__PURE__*/_interopDefaultLegacy(normalizeWheel);
const mousewheel = function(element, callback) {
if (element && element.addEventListener) {
const fn = function(event) {
const normalized = normalizeWheel__default["default"](event);
callback && Reflect.apply(callback, this, [event, normalized]);
};
element.addEventListener("wheel", fn, { passive: true });
}
};
const Mousewheel = {
beforeMount(el, binding) {
mousewheel(el, binding.value);
}
};
exports["default"] = Mousewheel;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../../../../../packages/directives/mousewheel/index.ts"],"sourcesContent":["import normalizeWheel from 'normalize-wheel-es'\n\nimport type { DirectiveBinding, ObjectDirective } from 'vue'\nimport type { NormalizedWheelEvent } from 'normalize-wheel-es'\n\nconst mousewheel = function (\n element: HTMLElement,\n callback: (e: WheelEvent, normalized: NormalizedWheelEvent) => void\n) {\n if (element && element.addEventListener) {\n const fn = function (this: HTMLElement, event: WheelEvent) {\n const normalized = normalizeWheel(event)\n callback && Reflect.apply(callback, this, [event, normalized])\n }\n element.addEventListener('wheel', fn, { passive: true })\n }\n}\n\nconst Mousewheel: ObjectDirective = {\n beforeMount(el: HTMLElement, binding: DirectiveBinding) {\n mousewheel(el, binding.value)\n },\n}\n\nexport default Mousewheel\n"],"names":["normalizeWheel"],"mappings":";;;;;;;;;;AACA,MAAM,UAAU,GAAG,SAAS,OAAO,EAAE,QAAQ,EAAE;AAC/C,EAAE,IAAI,OAAO,IAAI,OAAO,CAAC,gBAAgB,EAAE;AAC3C,IAAI,MAAM,EAAE,GAAG,SAAS,KAAK,EAAE;AAC/B,MAAM,MAAM,UAAU,GAAGA,kCAAc,CAAC,KAAK,CAAC,CAAC;AAC/C,MAAM,QAAQ,IAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;AACrE,KAAK,CAAC;AACN,IAAI,OAAO,CAAC,gBAAgB,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;AAC7D,GAAG;AACH,CAAC,CAAC;AACG,MAAC,UAAU,GAAG;AACnB,EAAE,WAAW,CAAC,EAAE,EAAE,OAAO,EAAE;AAC3B,IAAI,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;AAClC,GAAG;AACH;;;;"}

View File

@@ -0,0 +1,9 @@
import type { ObjectDirective } from 'vue';
export declare const REPEAT_INTERVAL = 100;
export declare const REPEAT_DELAY = 600;
export interface RepeatClickOptions {
interval?: number;
delay?: number;
handler: (...args: unknown[]) => unknown;
}
export declare const vRepeatClick: ObjectDirective<HTMLElement, RepeatClickOptions | RepeatClickOptions['handler']>;

View File

@@ -0,0 +1,46 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var shared = require('@vue/shared');
const REPEAT_INTERVAL = 100;
const REPEAT_DELAY = 600;
const vRepeatClick = {
beforeMount(el, binding) {
const value = binding.value;
const { interval = REPEAT_INTERVAL, delay = REPEAT_DELAY } = shared.isFunction(value) ? {} : value;
let intervalId;
let delayId;
const handler = () => shared.isFunction(value) ? value() : value.handler();
const clear = () => {
if (delayId) {
clearTimeout(delayId);
delayId = void 0;
}
if (intervalId) {
clearInterval(intervalId);
intervalId = void 0;
}
};
el.addEventListener("mousedown", (evt) => {
if (evt.button !== 0)
return;
clear();
handler();
document.addEventListener("mouseup", () => clear(), {
once: true
});
delayId = setTimeout(() => {
intervalId = setInterval(() => {
handler();
}, interval);
}, delay);
});
}
};
exports.REPEAT_DELAY = REPEAT_DELAY;
exports.REPEAT_INTERVAL = REPEAT_INTERVAL;
exports.vRepeatClick = vRepeatClick;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../../../../../packages/directives/repeat-click/index.ts"],"sourcesContent":["import { isFunction } from '@element-plus/utils'\n\nimport type { ObjectDirective } from 'vue'\n\nexport const REPEAT_INTERVAL = 100\nexport const REPEAT_DELAY = 600\n\nexport interface RepeatClickOptions {\n interval?: number\n delay?: number\n handler: (...args: unknown[]) => unknown\n}\n\nexport const vRepeatClick: ObjectDirective<\n HTMLElement,\n RepeatClickOptions | RepeatClickOptions['handler']\n> = {\n beforeMount(el, binding) {\n const value = binding.value\n const { interval = REPEAT_INTERVAL, delay = REPEAT_DELAY } = isFunction(\n value\n )\n ? {}\n : value\n\n let intervalId: ReturnType<typeof setInterval> | undefined\n let delayId: ReturnType<typeof setTimeout> | undefined\n\n const handler = () => (isFunction(value) ? value() : value.handler())\n\n const clear = () => {\n if (delayId) {\n clearTimeout(delayId)\n delayId = undefined\n }\n if (intervalId) {\n clearInterval(intervalId)\n intervalId = undefined\n }\n }\n\n el.addEventListener('mousedown', (evt: MouseEvent) => {\n if (evt.button !== 0) return\n clear()\n handler()\n\n document.addEventListener('mouseup', () => clear(), {\n once: true,\n })\n\n delayId = setTimeout(() => {\n intervalId = setInterval(() => {\n handler()\n }, interval)\n }, delay)\n })\n },\n}\n"],"names":["isFunction"],"mappings":";;;;;;AACY,MAAC,eAAe,GAAG,IAAI;AACvB,MAAC,YAAY,GAAG,IAAI;AACpB,MAAC,YAAY,GAAG;AAC5B,EAAE,WAAW,CAAC,EAAE,EAAE,OAAO,EAAE;AAC3B,IAAI,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;AAChC,IAAI,MAAM,EAAE,QAAQ,GAAG,eAAe,EAAE,KAAK,GAAG,YAAY,EAAE,GAAGA,iBAAU,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;AAChG,IAAI,IAAI,UAAU,CAAC;AACnB,IAAI,IAAI,OAAO,CAAC;AAChB,IAAI,MAAM,OAAO,GAAG,MAAMA,iBAAU,CAAC,KAAK,CAAC,GAAG,KAAK,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;AACxE,IAAI,MAAM,KAAK,GAAG,MAAM;AACxB,MAAM,IAAI,OAAO,EAAE;AACnB,QAAQ,YAAY,CAAC,OAAO,CAAC,CAAC;AAC9B,QAAQ,OAAO,GAAG,KAAK,CAAC,CAAC;AACzB,OAAO;AACP,MAAM,IAAI,UAAU,EAAE;AACtB,QAAQ,aAAa,CAAC,UAAU,CAAC,CAAC;AAClC,QAAQ,UAAU,GAAG,KAAK,CAAC,CAAC;AAC5B,OAAO;AACP,KAAK,CAAC;AACN,IAAI,EAAE,CAAC,gBAAgB,CAAC,WAAW,EAAE,CAAC,GAAG,KAAK;AAC9C,MAAM,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;AAC1B,QAAQ,OAAO;AACf,MAAM,KAAK,EAAE,CAAC;AACd,MAAM,OAAO,EAAE,CAAC;AAChB,MAAM,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,MAAM,KAAK,EAAE,EAAE;AAC1D,QAAQ,IAAI,EAAE,IAAI;AAClB,OAAO,CAAC,CAAC;AACT,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM;AACjC,QAAQ,UAAU,GAAG,WAAW,CAAC,MAAM;AACvC,UAAU,OAAO,EAAE,CAAC;AACpB,SAAS,EAAE,QAAQ,CAAC,CAAC;AACrB,OAAO,EAAE,KAAK,CAAC,CAAC;AAChB,KAAK,CAAC,CAAC;AACP,GAAG;AACH;;;;;;"}

View File

@@ -0,0 +1,9 @@
import type { ObjectDirective } from 'vue';
export declare const FOCUSABLE_CHILDREN = "_trap-focus-children";
export declare const TRAP_FOCUS_HANDLER = "_trap-focus-handler";
export interface TrapFocusElement extends HTMLElement {
[FOCUSABLE_CHILDREN]: HTMLElement[];
[TRAP_FOCUS_HANDLER]: (e: KeyboardEvent) => void;
}
declare const TrapFocus: ObjectDirective;
export default TrapFocus;

View File

@@ -0,0 +1,61 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var aria = require('../../utils/dom/aria.js');
var aria$1 = require('../../constants/aria.js');
const FOCUSABLE_CHILDREN = "_trap-focus-children";
const TRAP_FOCUS_HANDLER = "_trap-focus-handler";
const FOCUS_STACK = [];
const FOCUS_HANDLER = (e) => {
if (FOCUS_STACK.length === 0)
return;
const focusableElement = FOCUS_STACK[FOCUS_STACK.length - 1][FOCUSABLE_CHILDREN];
if (focusableElement.length > 0 && e.code === aria$1.EVENT_CODE.tab) {
if (focusableElement.length === 1) {
e.preventDefault();
if (document.activeElement !== focusableElement[0]) {
focusableElement[0].focus();
}
return;
}
const goingBackward = e.shiftKey;
const isFirst = e.target === focusableElement[0];
const isLast = e.target === focusableElement[focusableElement.length - 1];
if (isFirst && goingBackward) {
e.preventDefault();
focusableElement[focusableElement.length - 1].focus();
}
if (isLast && !goingBackward) {
e.preventDefault();
focusableElement[0].focus();
}
}
};
const TrapFocus = {
beforeMount(el) {
el[FOCUSABLE_CHILDREN] = aria.obtainAllFocusableElements(el);
FOCUS_STACK.push(el);
if (FOCUS_STACK.length <= 1) {
document.addEventListener("keydown", FOCUS_HANDLER);
}
},
updated(el) {
vue.nextTick(() => {
el[FOCUSABLE_CHILDREN] = aria.obtainAllFocusableElements(el);
});
},
unmounted() {
FOCUS_STACK.shift();
if (FOCUS_STACK.length === 0) {
document.removeEventListener("keydown", FOCUS_HANDLER);
}
}
};
exports.FOCUSABLE_CHILDREN = FOCUSABLE_CHILDREN;
exports.TRAP_FOCUS_HANDLER = TRAP_FOCUS_HANDLER;
exports["default"] = TrapFocus;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../../../../../packages/directives/trap-focus/index.ts"],"sourcesContent":["import { nextTick } from 'vue'\nimport { obtainAllFocusableElements } from '@element-plus/utils'\nimport { EVENT_CODE } from '@element-plus/constants'\n\nimport type { ObjectDirective } from 'vue'\n\nexport const FOCUSABLE_CHILDREN = '_trap-focus-children'\nexport const TRAP_FOCUS_HANDLER = '_trap-focus-handler'\n\nexport interface TrapFocusElement extends HTMLElement {\n [FOCUSABLE_CHILDREN]: HTMLElement[]\n [TRAP_FOCUS_HANDLER]: (e: KeyboardEvent) => void\n}\n\nconst FOCUS_STACK: TrapFocusElement[] = []\n\nconst FOCUS_HANDLER = (e: KeyboardEvent) => {\n // Getting the top layer.\n if (FOCUS_STACK.length === 0) return\n const focusableElement =\n FOCUS_STACK[FOCUS_STACK.length - 1][FOCUSABLE_CHILDREN]\n if (focusableElement.length > 0 && e.code === EVENT_CODE.tab) {\n if (focusableElement.length === 1) {\n e.preventDefault()\n if (document.activeElement !== focusableElement[0]) {\n focusableElement[0].focus()\n }\n return\n }\n const goingBackward = e.shiftKey\n const isFirst = e.target === focusableElement[0]\n const isLast = e.target === focusableElement[focusableElement.length - 1]\n if (isFirst && goingBackward) {\n e.preventDefault()\n focusableElement[focusableElement.length - 1].focus()\n }\n if (isLast && !goingBackward) {\n e.preventDefault()\n focusableElement[0].focus()\n }\n\n // the is critical since jsdom did not implement user actions, you can only mock it\n // DELETE ME: when testing env switches to puppeteer\n if (process.env.NODE_ENV === 'test') {\n const index = focusableElement.indexOf(e.target as HTMLElement)\n if (index !== -1) {\n focusableElement[goingBackward ? index - 1 : index + 1]?.focus()\n }\n }\n }\n}\n\nconst TrapFocus: ObjectDirective = {\n beforeMount(el: TrapFocusElement) {\n el[FOCUSABLE_CHILDREN] = obtainAllFocusableElements(el)\n FOCUS_STACK.push(el)\n if (FOCUS_STACK.length <= 1) {\n document.addEventListener('keydown', FOCUS_HANDLER)\n }\n },\n updated(el: TrapFocusElement) {\n nextTick(() => {\n el[FOCUSABLE_CHILDREN] = obtainAllFocusableElements(el)\n })\n },\n unmounted() {\n FOCUS_STACK.shift()\n if (FOCUS_STACK.length === 0) {\n document.removeEventListener('keydown', FOCUS_HANDLER)\n }\n },\n}\n\nexport default TrapFocus\n"],"names":["EVENT_CODE","obtainAllFocusableElements","nextTick"],"mappings":";;;;;;;;AAGY,MAAC,kBAAkB,GAAG,uBAAuB;AAC7C,MAAC,kBAAkB,GAAG,sBAAsB;AACxD,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK;AAC7B,EAAE,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;AAC9B,IAAI,OAAO;AACX,EAAE,MAAM,gBAAgB,GAAG,WAAW,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC;AACnF,EAAE,IAAI,gBAAgB,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