UNPKG

vue-box-overflow

Version:

Headless UI for automatically collapsing boxes when overflow in Vue.

42 lines (41 loc) 959 B
import { BoxOverflow } from "box-overflow-core"; import { unref, shallowRef, watch, triggerRef, onScopeDispose } from "vue"; function useOverflow(options) { const overflow = new BoxOverflow(unref(options)); const state = shallowRef(overflow); const cleanup = overflow.onMount(); watch( () => unref(options).getContainer(), (el) => { if (el) overflow.onUpdate(); }, { immediate: true } ); watch( () => unref(options), (options2) => { overflow.setOptions({ ...options2, onDisplayChange: (overflowItems) => { var _a; triggerRef(state); (_a = options2.onDisplayChange) == null ? void 0 : _a.call(options2, overflowItems); } }); overflow.onUpdate(); triggerRef(state); }, { immediate: true } ); onScopeDispose(cleanup); return state; } export { useOverflow }; //# sourceMappingURL=useOverflow.js.map