vue-box-overflow
Version:
Headless UI for automatically collapsing boxes when overflow in Vue.
42 lines (41 loc) • 1.06 kB
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const boxOverflowCore = require("box-overflow-core");
const vue = require("vue");
function useOverflow(options) {
const overflow = new boxOverflowCore.BoxOverflow(vue.unref(options));
const state = vue.shallowRef(overflow);
const cleanup = overflow.onMount();
vue.watch(
() => vue.unref(options).getContainer(),
(el) => {
if (el)
overflow.onUpdate();
},
{
immediate: true
}
);
vue.watch(
() => vue.unref(options),
(options2) => {
overflow.setOptions({
...options2,
onDisplayChange: (overflowItems) => {
var _a;
vue.triggerRef(state);
(_a = options2.onDisplayChange) == null ? void 0 : _a.call(options2, overflowItems);
}
});
overflow.onUpdate();
vue.triggerRef(state);
},
{
immediate: true
}
);
vue.onScopeDispose(cleanup);
return state;
}
exports.useOverflow = useOverflow;
//# sourceMappingURL=useOverflow.cjs.map