UNPKG

vuux

Version:

Vue3 Nuxt3 Nuxt4 组件库

99 lines (98 loc) 3.49 kB
import { defineComponent as E, createElementBlock as a, openBlock as t, normalizeClass as o, createElementVNode as n, createVNode as u, unref as e, Fragment as f, renderList as y, createBlock as _, createCommentVNode as c, toDisplayString as p, withModifiers as z, Transition as N, withCtx as C } from "vue"; import { ScrollBar as A } from "../../ScrollBar/index.mjs"; import { useSelect as O } from "./hook/useSelect.mjs"; import { Icon as m } from "@vuux/icons"; const $ = { key: 0, class: "select-data" }, D = { key: 1, class: "select-data" }, F = { class: "select-item" }, G = ["onClick"], L = { key: 0 }, H = /* @__PURE__ */ E({ name: "Select", __name: "index", props: { label: { default: "label" }, value: { default: "value" }, data: {}, modelValue: {}, multiple: { type: Boolean }, shadow: { type: Boolean }, placeholder: { default: "请选择" }, disabled: { type: Boolean } }, emits: ["update:modelValue", "change"], setup(B, { emit: b }) { const l = B, w = b, { items: r, isOpen: h, selectEl: I, handleOpen: k, handleClick: V, handleIsSelected: v, handleRemoveItem: g, handleGetValue: S } = O(l, w); return (M, i) => (t(), a("div", { ref_key: "selectEl", ref: I, class: o(["app-select", { "is-disabled": l.disabled }]) }, [ n("div", { class: "select-content", onClick: i[0] || (i[0] = //@ts-ignore (...s) => e(k) && e(k)(...s)) }, [ u(e(m), { name: "Icon1336922", class: o({ "is-active": e(h) }) }, null, 8, ["class"]), Array.isArray(e(r)) && e(r).length > 0 ? (t(), a("div", $, [ (t(!0), a(f, null, y(e(r), (s, d) => (t(), a("div", { key: d, class: o(["select-item", { "is-multiple": l.multiple }]) }, [ n("span", null, p(e(S)(s)), 1), l.multiple ? (t(), _(e(m), { key: 0, name: "Icon9176904", size: 12, onClick: z((x) => e(g)(d), ["stop"]) }, null, 8, ["onClick"])) : c("", !0) ], 2))), 128)) ])) : (t(), a("div", D, [ n("div", F, [ n("span", null, p(l.placeholder), 1) ]) ])) ]), u(N, { name: "ease-drop" }, { default: C(() => [ e(h) ? (t(), a("div", { key: 0, class: o(["select-dropdown", { "is-shadow": l.shadow }]) }, [ u(e(A), null, { default: C(() => [ n("ul", null, [ (t(!0), a(f, null, y(l.data, (s, d) => (t(), a("li", { key: d, class: o({ "is-active": e(v)(s[l.value]) }), onClick: (x) => e(V)(s[l.value]) }, [ n("span", null, p(s[l.label]), 1), e(v)(s[l.value]) ? (t(), _(e(m), { key: 0, name: "Icon1722501", size: 12, color: "var(--app-theme)" })) : c("", !0) ], 10, G))), 128)), !l.data || l.data.length == 0 ? (t(), a("li", L, [...i[1] || (i[1] = [ n("span", null, "暂无数据", -1) ])])) : c("", !0) ]) ]), _: 1 }) ], 2)) : c("", !0) ]), _: 1 }) ], 2)); } }); export { H as default };