UNPKG

various-ui

Version:

This is a test version of the Vue 3 component library

154 lines (151 loc) 5.84 kB
import { defineComponent, onBeforeUnmount, openBlock, createElementBlock, mergeProps, unref, createCommentVNode, createElementVNode, createVNode, createBlock, Transition, toHandlers, withCtx, withDirectives, Fragment, renderList, renderSlot, createTextVNode, toDisplayString, vShow } from 'vue'; import { UiIcon } from '../../icon/index.mjs'; import { UiSelectPropsOption, UiSelectEmits } from './index.mjs'; import { useComposable } from './src/composable.mjs'; import '../../../utils/index.mjs'; import { remove } from '../../../utils/src/node/index.mjs'; const _hoisted_1 = { class: "ui-form-candidate-container" }; const _hoisted_2 = { key: 0, class: "ui-mask ui-loading" }; const __default__ = defineComponent({ name: "UiSelect" }); var _sfc_main = /* @__PURE__ */ defineComponent({ ...__default__, props: UiSelectPropsOption, emits: UiSelectEmits, setup(__props, { expose: __expose, emit: __emit }) { const define = __props; const emits = __emit; const { ons, vars, refs, binds, nodes, methods } = useComposable(define, emits); const { visible } = refs; const { container, body } = nodes; const { show, clear, hidden } = methods; onBeforeUnmount(() => { var _a; body.value && remove(document.body, body.value); (_a = vars.observer) == null ? void 0 : _a.disconnect(); }); ; __expose({ show, clear, hidden }); return (_ctx, _cache) => { return openBlock(), createElementBlock( "div", mergeProps({ class: "ui-select", ref_key: "container", ref: container }, unref(binds).container), [ createCommentVNode(" * \u4E3B\u4F53 "), createElementVNode( "input", mergeProps({ class: "ui-form-control", type: "text" }, unref(binds).main, { onClick: _cache[0] || (_cache[0] = //@ts-ignore (...args) => unref(show) && unref(show)(...args)), readonly: "" }), null, 16 /* FULL_PROPS */ ), createCommentVNode(" * \u7BAD\u5934 "), createVNode(unref(UiIcon), { name: _ctx.icon, class: "ui-select-arrow", onClick: unref(show) }, null, 8, ["name", "onClick"]), createCommentVNode(" * \u6E05\u7A7A "), _ctx.clearable && _ctx.modelValue ? (openBlock(), createBlock(unref(UiIcon), { key: 0, name: _ctx.closeIcon, class: "ui-form-clearable", onClick: unref(clear) }, null, 8, ["name", "onClick"])) : createCommentVNode("v-if", true), createCommentVNode(" * \u5019\u9009\u9879 "), createVNode( Transition, toHandlers(unref(ons).animation), { default: withCtx(() => [ unref(visible) ? withDirectives((openBlock(), createElementBlock( "div", mergeProps({ key: 0, ref_key: "body", ref: body }, unref(binds).body), [ createElementVNode("div", _hoisted_1, [ createElementVNode( "div", mergeProps({ class: "ui-form-candidate-content" }, unref(binds).candidates), [ (openBlock(true), createElementBlock( Fragment, null, renderList(_ctx.candidates, (value) => { return openBlock(), createElementBlock( "div", mergeProps({ class: ["ui-form-candidate", { "ui-active": _ctx.modelValue == value.value }] }, toHandlers(unref(ons).candidate(value), true)), [ renderSlot(_ctx.$slots, "candidate", { data: value }, () => [ createTextVNode( toDisplayString(value.label), 1 /* TEXT */ ) ]) ], 16 /* FULL_PROPS */ ); }), 256 /* UNKEYED_FRAGMENT */ )) ], 16 /* FULL_PROPS */ ) ]) ], 16 /* FULL_PROPS */ )), [ [vShow, _ctx.candidates.length] ]) : createCommentVNode("v-if", true) ]), _: 3 /* FORWARDED */ }, 16 /* FULL_PROPS */ ), createCommentVNode(" * \u906E\u7F69\u5C42 "), createVNode(Transition, null, { default: withCtx(() => [ _ctx.loading ? (openBlock(), createElementBlock("div", _hoisted_2, [ createVNode(unref(UiIcon), { class: "ui-mask-icon", name: _ctx.loadingIcon }, null, 8, ["name"]) ])) : createCommentVNode("v-if", true) ]), _: 1 /* STABLE */ }) ], 16 /* FULL_PROPS */ ); }; } }); export { _sfc_main as default }; //# sourceMappingURL=index.vue2.mjs.map