UNPKG

uv-ui

Version:

基于vue3的移动端组件库

50 lines (49 loc) 1.1 kB
import { isDef as d } from "../../utils/type.js"; import { clamp as o } from "../../utils/common.js"; function g(t, n) { const e = t[0]; if (e) { if (Array.isArray(e)) return "multiple"; if (n in e) return "cascade"; } return "default"; } const m = (t) => t.find((n) => !n.disabled) || t[0]; function s(t, n) { n = o(n, 0, t.length); for (let e = n; e < t.length; e++) if (!t[e].disabled) return e; for (let e = n - 1; e >= 0; e--) if (!t[e].disabled) return e; return 0; } function c(t, n, e) { const l = t.findIndex((i) => i[e.value] === n), r = s(t, l); return t[r]; } function p(t, n, e) { const l = []; let r = { [n.children]: t }, i = 0; for (; r && r[n.children]; ) { const u = r[n.children], a = e.value[i]; if (r = d(a) ? c(u, a, n) : void 0, !r && u.length) { const f = m(u)[n.value]; r = c(u, f, n); } i++, l.push(u); } return l; } export { s as findIndexOfEnabledOption, c as findOptionByValue, p as formatCascadeColumns, g as getColumnsType, m as getFirstEnabledOption };