@extclp/vexip-ui
Version:
A Vue 3 UI library, Highly customizability, full TypeScript, performance pretty good
61 lines (60 loc) • 1.87 kB
JavaScript
import { defineComponent as x, getCurrentInstance as f, onMounted as c, watch as v, onBeforeUnmount as z, renderSlot as g } from "vue";
import { useProps as h, emitEvent as S } from "@vexip-ui/config";
import { useResize as E } from "@vexip-ui/hooks";
import { throttle as R } from "@vexip-ui/utils";
import { resizeObserverProps as y } from "./props.mjs";
const B = x({
name: "ResizeObserver",
props: y,
setup(m, { slots: b }) {
const n = h("resizeObserver", m, {
throttle: {
default: !1,
validator: (e) => typeof e == "boolean" || e > 0
},
disabled: !1
}), { observeResize: p, unobserveResize: s } = E();
let r = !1;
function l(e) {
S(n.onResize, e);
}
const u = n.throttle ? R(l, typeof n.throttle == "boolean" ? 16 : n.throttle) : l, o = f();
c(() => {
v(
() => n.disabled,
(e) => {
e ? d() : a();
},
{ immediate: !0, flush: "post" }
);
}), z(() => {
var e, t;
if (r) {
const i = (t = (e = f()) == null ? void 0 : e.proxy) == null ? void 0 : t.$el;
i != null && i.nextElementSibling && s(i.nextElementSibling);
}
});
function a() {
var t;
if (r) return;
const e = (t = o == null ? void 0 : o.proxy) == null ? void 0 : t.$el;
if (e != null && e.nextElementSibling) {
if (e.nextElementSibling !== e.nextSibling && e.nodeType === 3 && e.nodeValue !== "")
return;
p(e.nextElementSibling, u), r = !0;
}
}
function d() {
var e;
if (r) {
const t = (e = o == null ? void 0 : o.proxy) == null ? void 0 : e.$el;
t != null && t.nextElementSibling && s(t.nextElementSibling), r = !1;
}
}
return () => g(b, "default");
}
});
export {
B as default
};
//# sourceMappingURL=resize-observer.mjs.map