UNPKG

birdpaper-ui

Version:

一个通用的 vue3 UI组件库。A common vue3 UI component library.

31 lines (30 loc) 972 B
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const vue = require("vue"); const type = require("./type.js"); const dom = require("../../utils/dom.js"); const useSelect = (slots) => { const currentSelect = vue.reactive(new type.SelectOption()); const isFocus = vue.ref(false); const valueMap = vue.computed(() => { var _a, _b, _c; try { let obj = {}; const children = dom.getAllElements((_a = slots.default) == null ? void 0 : _a.call(slots), true).filter((item) => item.type !== vue.Comment) ?? []; for (const item of children) { if (item.type["name"] === "BpOption") { obj[item.props.value] = item.props.label || ((_c = (_b = item.children)["default"]) == null ? void 0 : _c.call(_b)[0].children); } } return obj; } catch (error) { return {}; } }); return { isFocus, currentSelect, valueMap }; }; exports.useSelect = useSelect;