first-commit
Some checks failed
CI Pipeline / build (push) Failing after 3m23s

This commit is contained in:
2025-08-27 14:05:33 +08:00
commit 9e1b8bdc9d
5159 changed files with 1081326 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
import { unrefElement } from '@vueuse/core';
import { createFocusTrap } from 'focus-trap';
import { defineComponent, ref, watch, onScopeDispose, h } from 'vue';
const UseFocusTrap = /* @__PURE__ */ /*@__PURE__*/ defineComponent({
name: "UseFocusTrap",
props: ["as", "options"],
setup(props, { slots }) {
let trap;
const target = ref();
const activate = () => trap && trap.activate();
const deactivate = () => trap && trap.deactivate();
watch(
() => unrefElement(target),
(el) => {
if (!el)
return;
trap = createFocusTrap(el, props.options || {});
activate();
},
{ flush: "post" }
);
onScopeDispose(() => deactivate());
return () => {
if (slots.default)
return h(props.as || "div", { ref: target }, slots.default());
};
}
});
export { UseFocusTrap };