UNPKG

@aplus-frontend/ui

Version:

61 lines (60 loc) 1.89 kB
import { computed as R, unref as u } from "vue"; function w(l, o) { return l.collapsible && o.collapsible ? l.showCollapsibleIcon === !0 || o.showCollapsibleIcon === !0 ? !0 : l.showCollapsibleIcon === "auto" || o.showCollapsibleIcon === "auto" ? "auto" : !1 : l.collapsible ? l.showCollapsibleIcon : o.collapsible ? o.showCollapsibleIcon : !1; } const k = (l, o, i) => R(() => { const b = [], c = u(l), p = u(o); for (let e = 0; e < c.length - 1; e += 1) { const d = c[e], f = c[e + 1], s = p[e], n = p[e + 1], { resizable: z = !0, min: m, collapsible: t } = d, { resizable: S = !0, min: x, collapsible: a } = f, E = ( // Both need to be resizable z && S && // Prev is not collapsed and limit min size (s !== 0 || !m) && // Next is not collapsed and limit min size (n !== 0 || !x) ), g = !!t.end && s > 0, v = !!a.start && n === 0 && s > 0, r = ( // Self is collapsible t.end && s > 0 || // Collapsed and can be collapsed a.start && n === 0 && s > 0 ), M = !!a.start && n > 0, _ = !!t.end && s === 0 && n > 0, C = ( // Self is collapsible a.start && n > 0 || // Collapsed and can be collapsed t.end && s === 0 && n > 0 ), I = w( { collapsible: g, showCollapsibleIcon: t.showCollapsibleIcon }, { collapsible: v, showCollapsibleIcon: a.showCollapsibleIcon } ), h = w( { collapsible: M, showCollapsibleIcon: a.showCollapsibleIcon }, { collapsible: _, showCollapsibleIcon: t.showCollapsibleIcon } ); b[e] = { resizable: E, startCollapsible: !!(i ? C : r), endCollapsible: !!(i ? r : C), showStartCollapsibleIcon: i ? h : I, showEndCollapsibleIcon: i ? I : h }; } return b; }); export { k as useResizable };