完全跑通1.0版本
This commit is contained in:
4
frontend/node_modules/element-plus/lib/components/focus-trap/index.d.ts
generated
vendored
Normal file
4
frontend/node_modules/element-plus/lib/components/focus-trap/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import _default from "./src/focus-trap.vue.js";
|
||||
import { FOCUSOUT_PREVENTED, FOCUSOUT_PREVENTED_OPTS, FOCUS_AFTER_RELEASED, FOCUS_AFTER_TRAPPED, FOCUS_AFTER_TRAPPED_OPTS, FOCUS_TRAP_INJECTION_KEY, FocusTrapInjectionContext, ON_RELEASE_FOCUS_EVT, ON_TRAP_FOCUS_EVT } from "./src/tokens.js";
|
||||
import { FocusLayer, FocusStack, createFocusOutPreventedEvent, focusFirstDescendant, focusableStack, getEdges, getVisibleElement, isFocusCausedByUserEvent, isHidden, obtainAllFocusableElements, tryFocus, useFocusReason } from "./src/utils.js";
|
||||
export { _default as ElFocusTrap, _default as default, FOCUSOUT_PREVENTED, FOCUSOUT_PREVENTED_OPTS, FOCUS_AFTER_RELEASED, FOCUS_AFTER_TRAPPED, FOCUS_AFTER_TRAPPED_OPTS, FOCUS_TRAP_INJECTION_KEY, FocusLayer, FocusStack, FocusTrapInjectionContext, ON_RELEASE_FOCUS_EVT, ON_TRAP_FOCUS_EVT, createFocusOutPreventedEvent, focusFirstDescendant, focusableStack, getEdges, getVisibleElement, isFocusCausedByUserEvent, isHidden, obtainAllFocusableElements, tryFocus, useFocusReason };
|
||||
32
frontend/node_modules/element-plus/lib/components/focus-trap/index.js
generated
vendored
Normal file
32
frontend/node_modules/element-plus/lib/components/focus-trap/index.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
Object.defineProperties(exports, {
|
||||
__esModule: { value: true },
|
||||
[Symbol.toStringTag]: { value: "Module" }
|
||||
});
|
||||
const require_tokens = require("./src/tokens.js");
|
||||
const require_utils = require("./src/utils.js");
|
||||
const require_focus_trap = require("./src/focus-trap.js");
|
||||
//#region ../../packages/components/focus-trap/index.ts
|
||||
var focus_trap_default$1 = require_focus_trap.default;
|
||||
//#endregion
|
||||
exports.ElFocusTrap = require_focus_trap.default;
|
||||
exports.FOCUSOUT_PREVENTED = require_tokens.FOCUSOUT_PREVENTED;
|
||||
exports.FOCUSOUT_PREVENTED_OPTS = require_tokens.FOCUSOUT_PREVENTED_OPTS;
|
||||
exports.FOCUS_AFTER_RELEASED = require_tokens.FOCUS_AFTER_RELEASED;
|
||||
exports.FOCUS_AFTER_TRAPPED = require_tokens.FOCUS_AFTER_TRAPPED;
|
||||
exports.FOCUS_AFTER_TRAPPED_OPTS = require_tokens.FOCUS_AFTER_TRAPPED_OPTS;
|
||||
exports.FOCUS_TRAP_INJECTION_KEY = require_tokens.FOCUS_TRAP_INJECTION_KEY;
|
||||
exports.ON_RELEASE_FOCUS_EVT = require_tokens.ON_RELEASE_FOCUS_EVT;
|
||||
exports.ON_TRAP_FOCUS_EVT = require_tokens.ON_TRAP_FOCUS_EVT;
|
||||
exports.createFocusOutPreventedEvent = require_utils.createFocusOutPreventedEvent;
|
||||
exports.default = focus_trap_default$1;
|
||||
exports.focusFirstDescendant = require_utils.focusFirstDescendant;
|
||||
exports.focusableStack = require_utils.focusableStack;
|
||||
exports.getEdges = require_utils.getEdges;
|
||||
exports.getVisibleElement = require_utils.getVisibleElement;
|
||||
exports.isFocusCausedByUserEvent = require_utils.isFocusCausedByUserEvent;
|
||||
exports.isHidden = require_utils.isHidden;
|
||||
exports.obtainAllFocusableElements = require_utils.obtainAllFocusableElements;
|
||||
exports.tryFocus = require_utils.tryFocus;
|
||||
exports.useFocusReason = require_utils.useFocusReason;
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
frontend/node_modules/element-plus/lib/components/focus-trap/index.js.map
generated
vendored
Normal file
1
frontend/node_modules/element-plus/lib/components/focus-trap/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","names":["ElFocusTrap"],"sources":["../../../../../packages/components/focus-trap/index.ts"],"sourcesContent":["import ElFocusTrap from './src/focus-trap.vue'\n\nexport { ElFocusTrap }\n\nexport default ElFocusTrap\nexport * from './src/tokens'\nexport * from './src/utils'\n"],"mappings":";;;;;;;;AAIA,IAAA,uBAAeA,mBAAAA"}
|
||||
17
frontend/node_modules/element-plus/lib/components/focus-trap/src/focus-trap.js
generated
vendored
Normal file
17
frontend/node_modules/element-plus/lib/components/focus-trap/src/focus-trap.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
Object.defineProperties(exports, {
|
||||
__esModule: { value: true },
|
||||
[Symbol.toStringTag]: { value: "Module" }
|
||||
});
|
||||
require("../../../_virtual/_rolldown/runtime.js");
|
||||
const require_focus_trap_vue_vue_type_script_lang = require("./focus-trap.vue_vue_type_script_lang.js");
|
||||
const require__plugin_vue_export_helper = require("../../../_virtual/_plugin-vue_export-helper.js");
|
||||
let vue = require("vue");
|
||||
//#region ../../packages/components/focus-trap/src/focus-trap.vue
|
||||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
return (0, vue.renderSlot)(_ctx.$slots, "default", { handleKeydown: _ctx.onKeydown });
|
||||
}
|
||||
var focus_trap_default = /* @__PURE__ */ require__plugin_vue_export_helper.default(require_focus_trap_vue_vue_type_script_lang.default, [["render", _sfc_render]]);
|
||||
//#endregion
|
||||
exports.default = focus_trap_default;
|
||||
|
||||
//# sourceMappingURL=focus-trap.js.map
|
||||
1
frontend/node_modules/element-plus/lib/components/focus-trap/src/focus-trap.js.map
generated
vendored
Normal file
1
frontend/node_modules/element-plus/lib/components/focus-trap/src/focus-trap.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
37
frontend/node_modules/element-plus/lib/components/focus-trap/src/focus-trap.vue.d.ts
generated
vendored
Normal file
37
frontend/node_modules/element-plus/lib/components/focus-trap/src/focus-trap.vue.d.ts
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
import * as _$vue from "vue";
|
||||
import { PropType } from "vue";
|
||||
|
||||
//#region ../../packages/components/focus-trap/src/focus-trap.vue.d.ts
|
||||
declare const _default: typeof __VLS_export;
|
||||
declare const __VLS_export: _$vue.DefineComponent<_$vue.ExtractPropTypes<{
|
||||
loop: BooleanConstructor;
|
||||
trapped: BooleanConstructor;
|
||||
focusTrapEl: PropType<HTMLElement>;
|
||||
focusStartEl: {
|
||||
type: PropType<"container" | "first" | HTMLElement>;
|
||||
default: string;
|
||||
};
|
||||
}>, {
|
||||
onKeydown: (e: KeyboardEvent) => void;
|
||||
}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, ("focusin" | "focusout" | "focusAfterTrapped" | "focusAfterReleased" | "focusout-prevented" | "release-requested")[], "focusin" | "focusout" | "focusAfterTrapped" | "focusAfterReleased" | "focusout-prevented" | "release-requested", _$vue.PublicProps, Readonly<_$vue.ExtractPropTypes<{
|
||||
loop: BooleanConstructor;
|
||||
trapped: BooleanConstructor;
|
||||
focusTrapEl: PropType<HTMLElement>;
|
||||
focusStartEl: {
|
||||
type: PropType<"container" | "first" | HTMLElement>;
|
||||
default: string;
|
||||
};
|
||||
}>> & Readonly<{
|
||||
onFocusin?: ((...args: any[]) => any) | undefined;
|
||||
onFocusout?: ((...args: any[]) => any) | undefined;
|
||||
onFocusAfterTrapped?: ((...args: any[]) => any) | undefined;
|
||||
onFocusAfterReleased?: ((...args: any[]) => any) | undefined;
|
||||
"onFocusout-prevented"?: ((...args: any[]) => any) | undefined;
|
||||
"onRelease-requested"?: ((...args: any[]) => any) | undefined;
|
||||
}>, {
|
||||
loop: boolean;
|
||||
trapped: boolean;
|
||||
focusStartEl: HTMLElement | "container" | "first";
|
||||
}, {}, {}, {}, string, _$vue.ComponentProvideOptions, true, {}, any>;
|
||||
//#endregion
|
||||
export { _default as default };
|
||||
199
frontend/node_modules/element-plus/lib/components/focus-trap/src/focus-trap.vue_vue_type_script_lang.js
generated
vendored
Normal file
199
frontend/node_modules/element-plus/lib/components/focus-trap/src/focus-trap.vue_vue_type_script_lang.js
generated
vendored
Normal file
@@ -0,0 +1,199 @@
|
||||
require("../../../_virtual/_rolldown/runtime.js");
|
||||
const require_aria = require("../../../constants/aria.js");
|
||||
const require_event = require("../../../utils/dom/event.js");
|
||||
const require_index = require("../../../hooks/use-escape-keydown/index.js");
|
||||
const require_tokens = require("./tokens.js");
|
||||
const require_utils = require("./utils.js");
|
||||
let lodash_unified = require("lodash-unified");
|
||||
let vue = require("vue");
|
||||
let _vue_shared = require("@vue/shared");
|
||||
//#region ../../packages/components/focus-trap/src/focus-trap.vue?vue&type=script&lang.ts
|
||||
var focus_trap_vue_vue_type_script_lang_default = (0, vue.defineComponent)({
|
||||
name: "ElFocusTrap",
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
loop: Boolean,
|
||||
trapped: Boolean,
|
||||
focusTrapEl: Object,
|
||||
focusStartEl: {
|
||||
type: [Object, String],
|
||||
default: "first"
|
||||
}
|
||||
},
|
||||
emits: [
|
||||
require_tokens.ON_TRAP_FOCUS_EVT,
|
||||
require_tokens.ON_RELEASE_FOCUS_EVT,
|
||||
"focusin",
|
||||
"focusout",
|
||||
"focusout-prevented",
|
||||
"release-requested"
|
||||
],
|
||||
setup(props, { emit }) {
|
||||
const forwardRef = (0, vue.ref)();
|
||||
let lastFocusBeforeTrapped;
|
||||
let lastFocusAfterTrapped;
|
||||
const { focusReason } = require_utils.useFocusReason();
|
||||
require_index.useEscapeKeydown((event) => {
|
||||
if (props.trapped && !focusLayer.paused) emit("release-requested", event);
|
||||
});
|
||||
const focusLayer = {
|
||||
paused: false,
|
||||
pause() {
|
||||
this.paused = true;
|
||||
},
|
||||
resume() {
|
||||
this.paused = false;
|
||||
}
|
||||
};
|
||||
const onKeydown = (e) => {
|
||||
if (!props.loop && !props.trapped) return;
|
||||
if (focusLayer.paused) return;
|
||||
const { altKey, ctrlKey, metaKey, currentTarget, shiftKey } = e;
|
||||
const { loop } = props;
|
||||
const isTabbing = require_event.getEventCode(e) === require_aria.EVENT_CODE.tab && !altKey && !ctrlKey && !metaKey;
|
||||
const currentFocusingEl = document.activeElement;
|
||||
if (isTabbing && currentFocusingEl) {
|
||||
const container = currentTarget;
|
||||
const [first, last] = require_utils.getEdges(container);
|
||||
if (!(first && last)) {
|
||||
if (currentFocusingEl === container) {
|
||||
const focusoutPreventedEvent = require_utils.createFocusOutPreventedEvent({ focusReason: focusReason.value });
|
||||
emit("focusout-prevented", focusoutPreventedEvent);
|
||||
if (!focusoutPreventedEvent.defaultPrevented) e.preventDefault();
|
||||
}
|
||||
} else if (!shiftKey && currentFocusingEl === last) {
|
||||
const focusoutPreventedEvent = require_utils.createFocusOutPreventedEvent({ focusReason: focusReason.value });
|
||||
emit("focusout-prevented", focusoutPreventedEvent);
|
||||
if (!focusoutPreventedEvent.defaultPrevented) {
|
||||
e.preventDefault();
|
||||
if (loop) require_utils.tryFocus(first, true);
|
||||
}
|
||||
} else if (shiftKey && [first, container].includes(currentFocusingEl)) {
|
||||
const focusoutPreventedEvent = require_utils.createFocusOutPreventedEvent({ focusReason: focusReason.value });
|
||||
emit("focusout-prevented", focusoutPreventedEvent);
|
||||
if (!focusoutPreventedEvent.defaultPrevented) {
|
||||
e.preventDefault();
|
||||
if (loop) require_utils.tryFocus(last, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
(0, vue.provide)(require_tokens.FOCUS_TRAP_INJECTION_KEY, {
|
||||
focusTrapRef: forwardRef,
|
||||
onKeydown
|
||||
});
|
||||
(0, vue.watch)(() => props.focusTrapEl, (focusTrapEl) => {
|
||||
if (focusTrapEl) forwardRef.value = focusTrapEl;
|
||||
}, { immediate: true });
|
||||
(0, vue.watch)([forwardRef], ([forwardRef], [oldForwardRef]) => {
|
||||
if (forwardRef) {
|
||||
forwardRef.addEventListener("keydown", onKeydown);
|
||||
forwardRef.addEventListener("focusin", onFocusIn);
|
||||
forwardRef.addEventListener("focusout", onFocusOut);
|
||||
}
|
||||
if (oldForwardRef) {
|
||||
oldForwardRef.removeEventListener("keydown", onKeydown);
|
||||
oldForwardRef.removeEventListener("focusin", onFocusIn);
|
||||
oldForwardRef.removeEventListener("focusout", onFocusOut);
|
||||
}
|
||||
});
|
||||
const trapOnFocus = (e) => {
|
||||
emit(require_tokens.ON_TRAP_FOCUS_EVT, e);
|
||||
};
|
||||
const releaseOnFocus = (e) => emit(require_tokens.ON_RELEASE_FOCUS_EVT, e);
|
||||
const onFocusIn = (e) => {
|
||||
const trapContainer = (0, vue.unref)(forwardRef);
|
||||
if (!trapContainer) return;
|
||||
const target = e.target;
|
||||
const relatedTarget = e.relatedTarget;
|
||||
const isFocusedInTrap = target && trapContainer.contains(target);
|
||||
if (!props.trapped) {
|
||||
if (!(relatedTarget && trapContainer.contains(relatedTarget))) lastFocusBeforeTrapped = relatedTarget;
|
||||
}
|
||||
if (isFocusedInTrap) emit("focusin", e);
|
||||
if (focusLayer.paused) return;
|
||||
if (props.trapped) if (isFocusedInTrap) lastFocusAfterTrapped = target;
|
||||
else require_utils.tryFocus(lastFocusAfterTrapped, true);
|
||||
};
|
||||
const onFocusOut = (e) => {
|
||||
const trapContainer = (0, vue.unref)(forwardRef);
|
||||
if (focusLayer.paused || !trapContainer) return;
|
||||
if (props.trapped) {
|
||||
const relatedTarget = e.relatedTarget;
|
||||
if (!(0, lodash_unified.isNil)(relatedTarget) && !trapContainer.contains(relatedTarget)) setTimeout(() => {
|
||||
if (!focusLayer.paused && props.trapped) {
|
||||
const focusoutPreventedEvent = require_utils.createFocusOutPreventedEvent({ focusReason: focusReason.value });
|
||||
emit("focusout-prevented", focusoutPreventedEvent);
|
||||
if (!focusoutPreventedEvent.defaultPrevented) require_utils.tryFocus(lastFocusAfterTrapped, true);
|
||||
}
|
||||
}, 0);
|
||||
} else {
|
||||
const target = e.target;
|
||||
if (!(target && trapContainer.contains(target))) emit("focusout", e);
|
||||
}
|
||||
};
|
||||
async function startTrap() {
|
||||
await (0, vue.nextTick)();
|
||||
const trapContainer = (0, vue.unref)(forwardRef);
|
||||
if (trapContainer) {
|
||||
require_utils.focusableStack.push(focusLayer);
|
||||
const prevFocusedElement = trapContainer.contains(document.activeElement) ? lastFocusBeforeTrapped : document.activeElement;
|
||||
lastFocusBeforeTrapped = prevFocusedElement;
|
||||
if (!trapContainer.contains(prevFocusedElement)) {
|
||||
const focusEvent = new Event(require_tokens.FOCUS_AFTER_TRAPPED, require_tokens.FOCUS_AFTER_TRAPPED_OPTS);
|
||||
trapContainer.addEventListener(require_tokens.FOCUS_AFTER_TRAPPED, trapOnFocus);
|
||||
trapContainer.dispatchEvent(focusEvent);
|
||||
if (!focusEvent.defaultPrevented) (0, vue.nextTick)(() => {
|
||||
let focusStartEl = props.focusStartEl;
|
||||
if (!(0, _vue_shared.isString)(focusStartEl)) {
|
||||
require_utils.tryFocus(focusStartEl);
|
||||
if (document.activeElement !== focusStartEl) focusStartEl = "first";
|
||||
}
|
||||
if (focusStartEl === "first") require_utils.focusFirstDescendant(require_utils.obtainAllFocusableElements(trapContainer), true);
|
||||
if (document.activeElement === prevFocusedElement || focusStartEl === "container") require_utils.tryFocus(trapContainer);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
function stopTrap() {
|
||||
const trapContainer = (0, vue.unref)(forwardRef);
|
||||
if (trapContainer) {
|
||||
trapContainer.removeEventListener(require_tokens.FOCUS_AFTER_TRAPPED, trapOnFocus);
|
||||
const releasedEvent = new CustomEvent(require_tokens.FOCUS_AFTER_RELEASED, {
|
||||
...require_tokens.FOCUS_AFTER_TRAPPED_OPTS,
|
||||
detail: { focusReason: focusReason.value }
|
||||
});
|
||||
trapContainer.addEventListener(require_tokens.FOCUS_AFTER_RELEASED, releaseOnFocus);
|
||||
trapContainer.dispatchEvent(releasedEvent);
|
||||
if (!releasedEvent.defaultPrevented && (focusReason.value == "keyboard" || !require_utils.isFocusCausedByUserEvent() || trapContainer.contains(document.activeElement))) require_utils.tryFocus(lastFocusBeforeTrapped ?? document.body);
|
||||
trapContainer.removeEventListener(require_tokens.FOCUS_AFTER_RELEASED, releaseOnFocus);
|
||||
require_utils.focusableStack.remove(focusLayer);
|
||||
lastFocusBeforeTrapped = null;
|
||||
lastFocusAfterTrapped = null;
|
||||
}
|
||||
}
|
||||
(0, vue.onMounted)(() => {
|
||||
if (props.trapped) startTrap();
|
||||
(0, vue.watch)(() => props.trapped, (trapped) => {
|
||||
if (trapped) startTrap();
|
||||
else stopTrap();
|
||||
});
|
||||
});
|
||||
(0, vue.onBeforeUnmount)(() => {
|
||||
if (props.trapped) stopTrap();
|
||||
if (forwardRef.value) {
|
||||
forwardRef.value.removeEventListener("keydown", onKeydown);
|
||||
forwardRef.value.removeEventListener("focusin", onFocusIn);
|
||||
forwardRef.value.removeEventListener("focusout", onFocusOut);
|
||||
forwardRef.value = void 0;
|
||||
}
|
||||
lastFocusBeforeTrapped = null;
|
||||
lastFocusAfterTrapped = null;
|
||||
});
|
||||
return { onKeydown };
|
||||
}
|
||||
});
|
||||
//#endregion
|
||||
exports.default = focus_trap_vue_vue_type_script_lang_default;
|
||||
|
||||
//# sourceMappingURL=focus-trap.vue_vue_type_script_lang.js.map
|
||||
1
frontend/node_modules/element-plus/lib/components/focus-trap/src/focus-trap.vue_vue_type_script_lang.js.map
generated
vendored
Normal file
1
frontend/node_modules/element-plus/lib/components/focus-trap/src/focus-trap.vue_vue_type_script_lang.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
17
frontend/node_modules/element-plus/lib/components/focus-trap/src/tokens.d.ts
generated
vendored
Normal file
17
frontend/node_modules/element-plus/lib/components/focus-trap/src/tokens.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { InjectionKey, Ref } from "vue";
|
||||
|
||||
//#region ../../packages/components/focus-trap/src/tokens.d.ts
|
||||
declare const FOCUS_AFTER_TRAPPED = "focus-trap.focus-after-trapped";
|
||||
declare const FOCUS_AFTER_RELEASED = "focus-trap.focus-after-released";
|
||||
declare const FOCUSOUT_PREVENTED = "focus-trap.focusout-prevented";
|
||||
declare const FOCUS_AFTER_TRAPPED_OPTS: EventInit;
|
||||
declare const FOCUSOUT_PREVENTED_OPTS: EventInit;
|
||||
declare const ON_TRAP_FOCUS_EVT = "focusAfterTrapped";
|
||||
declare const ON_RELEASE_FOCUS_EVT = "focusAfterReleased";
|
||||
type FocusTrapInjectionContext = {
|
||||
focusTrapRef: Ref<HTMLElement | undefined>;
|
||||
onKeydown: (e: KeyboardEvent) => void;
|
||||
};
|
||||
declare const FOCUS_TRAP_INJECTION_KEY: InjectionKey<FocusTrapInjectionContext>;
|
||||
//#endregion
|
||||
export { FOCUSOUT_PREVENTED, FOCUSOUT_PREVENTED_OPTS, FOCUS_AFTER_RELEASED, FOCUS_AFTER_TRAPPED, FOCUS_AFTER_TRAPPED_OPTS, FOCUS_TRAP_INJECTION_KEY, FocusTrapInjectionContext, ON_RELEASE_FOCUS_EVT, ON_TRAP_FOCUS_EVT };
|
||||
27
frontend/node_modules/element-plus/lib/components/focus-trap/src/tokens.js
generated
vendored
Normal file
27
frontend/node_modules/element-plus/lib/components/focus-trap/src/tokens.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
//#region ../../packages/components/focus-trap/src/tokens.ts
|
||||
const FOCUS_AFTER_TRAPPED = "focus-trap.focus-after-trapped";
|
||||
const FOCUS_AFTER_RELEASED = "focus-trap.focus-after-released";
|
||||
const FOCUSOUT_PREVENTED = "focus-trap.focusout-prevented";
|
||||
const FOCUS_AFTER_TRAPPED_OPTS = {
|
||||
cancelable: true,
|
||||
bubbles: false
|
||||
};
|
||||
const FOCUSOUT_PREVENTED_OPTS = {
|
||||
cancelable: true,
|
||||
bubbles: false
|
||||
};
|
||||
const ON_TRAP_FOCUS_EVT = "focusAfterTrapped";
|
||||
const ON_RELEASE_FOCUS_EVT = "focusAfterReleased";
|
||||
const FOCUS_TRAP_INJECTION_KEY = Symbol("elFocusTrap");
|
||||
//#endregion
|
||||
exports.FOCUSOUT_PREVENTED = FOCUSOUT_PREVENTED;
|
||||
exports.FOCUSOUT_PREVENTED_OPTS = FOCUSOUT_PREVENTED_OPTS;
|
||||
exports.FOCUS_AFTER_RELEASED = FOCUS_AFTER_RELEASED;
|
||||
exports.FOCUS_AFTER_TRAPPED = FOCUS_AFTER_TRAPPED;
|
||||
exports.FOCUS_AFTER_TRAPPED_OPTS = FOCUS_AFTER_TRAPPED_OPTS;
|
||||
exports.FOCUS_TRAP_INJECTION_KEY = FOCUS_TRAP_INJECTION_KEY;
|
||||
exports.ON_RELEASE_FOCUS_EVT = ON_RELEASE_FOCUS_EVT;
|
||||
exports.ON_TRAP_FOCUS_EVT = ON_TRAP_FOCUS_EVT;
|
||||
|
||||
//# sourceMappingURL=tokens.js.map
|
||||
1
frontend/node_modules/element-plus/lib/components/focus-trap/src/tokens.js.map
generated
vendored
Normal file
1
frontend/node_modules/element-plus/lib/components/focus-trap/src/tokens.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"tokens.js","names":[],"sources":["../../../../../../packages/components/focus-trap/src/tokens.ts"],"sourcesContent":["import type { InjectionKey, Ref } from 'vue'\n\nexport const FOCUS_AFTER_TRAPPED = 'focus-trap.focus-after-trapped'\nexport const FOCUS_AFTER_RELEASED = 'focus-trap.focus-after-released'\nexport const FOCUSOUT_PREVENTED = 'focus-trap.focusout-prevented'\nexport const FOCUS_AFTER_TRAPPED_OPTS: EventInit = {\n cancelable: true,\n bubbles: false,\n}\nexport const FOCUSOUT_PREVENTED_OPTS: EventInit = {\n cancelable: true,\n bubbles: false,\n}\n\nexport const ON_TRAP_FOCUS_EVT = 'focusAfterTrapped'\nexport const ON_RELEASE_FOCUS_EVT = 'focusAfterReleased'\n\nexport type FocusTrapInjectionContext = {\n focusTrapRef: Ref<HTMLElement | undefined>\n onKeydown: (e: KeyboardEvent) => void\n}\n\nexport const FOCUS_TRAP_INJECTION_KEY: InjectionKey<FocusTrapInjectionContext> =\n Symbol('elFocusTrap')\n"],"mappings":";;AAEA,MAAa,sBAAsB;AACnC,MAAa,uBAAuB;AACpC,MAAa,qBAAqB;AAClC,MAAa,2BAAsC;CACjD,YAAY;CACZ,SAAS;CACV;AACD,MAAa,0BAAqC;CAChD,YAAY;CACZ,SAAS;CACV;AAED,MAAa,oBAAoB;AACjC,MAAa,uBAAuB;AAOpC,MAAa,2BACX,OAAO,cAAc"}
|
||||
33
frontend/node_modules/element-plus/lib/components/focus-trap/src/utils.d.ts
generated
vendored
Normal file
33
frontend/node_modules/element-plus/lib/components/focus-trap/src/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
import * as _$vue from "vue";
|
||||
|
||||
//#region ../../packages/components/focus-trap/src/utils.d.ts
|
||||
declare const focusReason: _$vue.Ref<"pointer" | "keyboard" | undefined, "pointer" | "keyboard" | undefined>;
|
||||
declare const lastUserFocusTimestamp: _$vue.Ref<number, number>;
|
||||
declare const lastAutomatedFocusTimestamp: _$vue.Ref<number, number>;
|
||||
type FocusLayer = {
|
||||
paused: boolean;
|
||||
pause: () => void;
|
||||
resume: () => void;
|
||||
};
|
||||
type FocusStack = FocusLayer[];
|
||||
declare const obtainAllFocusableElements: (element: HTMLElement) => HTMLElement[];
|
||||
declare const getVisibleElement: (elements: HTMLElement[], container: HTMLElement) => HTMLElement | undefined;
|
||||
declare const isHidden: (element: HTMLElement, container: HTMLElement) => boolean;
|
||||
declare const getEdges: (container: HTMLElement) => (HTMLElement | undefined)[];
|
||||
declare const tryFocus: (element?: HTMLElement | {
|
||||
focus: () => void;
|
||||
} | null, shouldSelect?: boolean) => void;
|
||||
declare const focusFirstDescendant: (elements: HTMLElement[], shouldSelect?: boolean) => void;
|
||||
declare const focusableStack: {
|
||||
push: (layer: FocusLayer) => void;
|
||||
remove: (layer: FocusLayer) => void;
|
||||
};
|
||||
declare const isFocusCausedByUserEvent: () => boolean;
|
||||
declare const useFocusReason: () => {
|
||||
focusReason: typeof focusReason;
|
||||
lastUserFocusTimestamp: typeof lastUserFocusTimestamp;
|
||||
lastAutomatedFocusTimestamp: typeof lastAutomatedFocusTimestamp;
|
||||
};
|
||||
declare const createFocusOutPreventedEvent: (detail: CustomEventInit["detail"]) => CustomEvent<any>;
|
||||
//#endregion
|
||||
export { FocusLayer, FocusStack, createFocusOutPreventedEvent, focusFirstDescendant, focusableStack, getEdges, getVisibleElement, isFocusCausedByUserEvent, isHidden, obtainAllFocusableElements, tryFocus, useFocusReason };
|
||||
132
frontend/node_modules/element-plus/lib/components/focus-trap/src/utils.js
generated
vendored
Normal file
132
frontend/node_modules/element-plus/lib/components/focus-trap/src/utils.js
generated
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
require("../../../_virtual/_rolldown/runtime.js");
|
||||
const require_aria = require("../../../utils/dom/aria.js");
|
||||
const require_tokens = require("./tokens.js");
|
||||
let vue = require("vue");
|
||||
//#region ../../packages/components/focus-trap/src/utils.ts
|
||||
const focusReason = (0, vue.ref)();
|
||||
const lastUserFocusTimestamp = (0, vue.ref)(0);
|
||||
const lastAutomatedFocusTimestamp = (0, vue.ref)(0);
|
||||
let focusReasonUserCount = 0;
|
||||
const obtainAllFocusableElements = (element) => {
|
||||
const nodes = [];
|
||||
const walker = document.createTreeWalker(element, NodeFilter.SHOW_ELEMENT, { acceptNode: (node) => {
|
||||
const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
|
||||
if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP;
|
||||
return node.tabIndex >= 0 || node === document.activeElement ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
||||
} });
|
||||
while (walker.nextNode()) nodes.push(walker.currentNode);
|
||||
return nodes;
|
||||
};
|
||||
const getVisibleElement = (elements, container) => {
|
||||
for (const element of elements) if (!isHidden(element, container)) return element;
|
||||
};
|
||||
const isHidden = (element, container) => {
|
||||
if (process.env.NODE_ENV === "test") return false;
|
||||
if (getComputedStyle(element).visibility === "hidden") return true;
|
||||
while (element) {
|
||||
if (container && element === container) return false;
|
||||
if (getComputedStyle(element).display === "none") return true;
|
||||
element = element.parentElement;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
const getEdges = (container) => {
|
||||
const focusable = obtainAllFocusableElements(container);
|
||||
return [getVisibleElement(focusable, container), getVisibleElement(focusable.reverse(), container)];
|
||||
};
|
||||
const isSelectable = (element) => {
|
||||
return element instanceof HTMLInputElement && "select" in element;
|
||||
};
|
||||
const tryFocus = (element, shouldSelect) => {
|
||||
if (element) {
|
||||
const prevFocusedElement = document.activeElement;
|
||||
require_aria.focusElement(element, { preventScroll: true });
|
||||
lastAutomatedFocusTimestamp.value = window.performance.now();
|
||||
if (element !== prevFocusedElement && isSelectable(element) && shouldSelect) element.select();
|
||||
}
|
||||
};
|
||||
function removeFromStack(list, item) {
|
||||
const copy = [...list];
|
||||
const idx = list.indexOf(item);
|
||||
if (idx !== -1) copy.splice(idx, 1);
|
||||
return copy;
|
||||
}
|
||||
const createFocusableStack = () => {
|
||||
let stack = [];
|
||||
const push = (layer) => {
|
||||
const currentLayer = stack[0];
|
||||
if (currentLayer && layer !== currentLayer) currentLayer.pause();
|
||||
stack = removeFromStack(stack, layer);
|
||||
stack.unshift(layer);
|
||||
};
|
||||
const remove = (layer) => {
|
||||
stack = removeFromStack(stack, layer);
|
||||
stack[0]?.resume?.();
|
||||
};
|
||||
return {
|
||||
push,
|
||||
remove
|
||||
};
|
||||
};
|
||||
const focusFirstDescendant = (elements, shouldSelect = false) => {
|
||||
const prevFocusedElement = document.activeElement;
|
||||
for (const element of elements) {
|
||||
tryFocus(element, shouldSelect);
|
||||
if (document.activeElement !== prevFocusedElement) return;
|
||||
}
|
||||
};
|
||||
const focusableStack = createFocusableStack();
|
||||
const isFocusCausedByUserEvent = () => {
|
||||
return lastUserFocusTimestamp.value > lastAutomatedFocusTimestamp.value;
|
||||
};
|
||||
const notifyFocusReasonPointer = () => {
|
||||
focusReason.value = "pointer";
|
||||
lastUserFocusTimestamp.value = window.performance.now();
|
||||
};
|
||||
const notifyFocusReasonKeydown = () => {
|
||||
focusReason.value = "keyboard";
|
||||
lastUserFocusTimestamp.value = window.performance.now();
|
||||
};
|
||||
const useFocusReason = () => {
|
||||
(0, vue.onMounted)(() => {
|
||||
if (focusReasonUserCount === 0) {
|
||||
document.addEventListener("mousedown", notifyFocusReasonPointer);
|
||||
document.addEventListener("touchstart", notifyFocusReasonPointer);
|
||||
document.addEventListener("keydown", notifyFocusReasonKeydown);
|
||||
}
|
||||
focusReasonUserCount++;
|
||||
});
|
||||
(0, vue.onBeforeUnmount)(() => {
|
||||
focusReasonUserCount--;
|
||||
if (focusReasonUserCount <= 0) {
|
||||
document.removeEventListener("mousedown", notifyFocusReasonPointer);
|
||||
document.removeEventListener("touchstart", notifyFocusReasonPointer);
|
||||
document.removeEventListener("keydown", notifyFocusReasonKeydown);
|
||||
}
|
||||
});
|
||||
return {
|
||||
focusReason,
|
||||
lastUserFocusTimestamp,
|
||||
lastAutomatedFocusTimestamp
|
||||
};
|
||||
};
|
||||
const createFocusOutPreventedEvent = (detail) => {
|
||||
return new CustomEvent(require_tokens.FOCUSOUT_PREVENTED, {
|
||||
...require_tokens.FOCUSOUT_PREVENTED_OPTS,
|
||||
detail
|
||||
});
|
||||
};
|
||||
//#endregion
|
||||
exports.createFocusOutPreventedEvent = createFocusOutPreventedEvent;
|
||||
exports.focusFirstDescendant = focusFirstDescendant;
|
||||
exports.focusableStack = focusableStack;
|
||||
exports.getEdges = getEdges;
|
||||
exports.getVisibleElement = getVisibleElement;
|
||||
exports.isFocusCausedByUserEvent = isFocusCausedByUserEvent;
|
||||
exports.isHidden = isHidden;
|
||||
exports.obtainAllFocusableElements = obtainAllFocusableElements;
|
||||
exports.tryFocus = tryFocus;
|
||||
exports.useFocusReason = useFocusReason;
|
||||
|
||||
//# sourceMappingURL=utils.js.map
|
||||
1
frontend/node_modules/element-plus/lib/components/focus-trap/src/utils.js.map
generated
vendored
Normal file
1
frontend/node_modules/element-plus/lib/components/focus-trap/src/utils.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user