UNPKG

various-ui

Version:

This is a test version of the Vue 3 component library

173 lines (170 loc) 6.71 kB
import { defineComponent, onBeforeUnmount, openBlock, createElementBlock, mergeProps, unref, createElementVNode, createCommentVNode, Fragment, renderList, normalizeClass, withModifiers, createTextVNode, toDisplayString, createVNode, Transition, toHandlers, withCtx, renderSlot } from 'vue'; import { UiIcon } from '../icon/index.mjs'; import { UiRegionSelectorPropsOption, UiRegionSelectorEmits } from './src/index.mjs'; import { useComposable } from './src/composable.mjs'; import '../../utils/index.mjs'; import { remove } from '../../utils/src/node/index.mjs'; const _hoisted_1 = ["disabled"]; const _hoisted_2 = { class: "ui-region-selector-content" }; const _hoisted_3 = ["onClick"]; const _hoisted_4 = { class: "ui-form-candidate-container" }; const _hoisted_5 = ["onClick"]; const _hoisted_6 = { key: 0, class: "ui-mask ui-loading" }; const __default__ = defineComponent({ name: "UiRegionSelector" }); var _sfc_main = /* @__PURE__ */ defineComponent({ ...__default__, props: UiRegionSelectorPropsOption, emits: UiRegionSelectorEmits, setup(__props, { expose: __expose, emit: __emit }) { const emits = __emit; const define = __props; const { ons, vars, refs, nodes, binds, methods, computeds } = useComposable(define, emits); const { regions, disabled } = computeds; const { show, hidden } = methods; const { container, body } = nodes; const { visible, data } = refs; onBeforeUnmount(() => { var _a; body.value && remove(document.body, body.value); (_a = vars.observer) == null ? void 0 : _a.disconnect(); }); ; __expose({ show, hidden }); return (_ctx, _cache) => { return openBlock(), createElementBlock( "div", mergeProps({ class: "ui-region-selector", ref_key: "container", ref: container }, unref(binds).container), [ createElementVNode("div", { class: "ui-form-control", onClick: _cache[0] || (_cache[0] = ($event) => unref(show)()) }, [ createCommentVNode(" * \u4E3B\u4F53 "), createElementVNode("input", { type: "text", autocomplete: "off", disabled: unref(disabled), readonly: "" }, null, 8, _hoisted_1), createCommentVNode(" * \u5185\u5BB9 "), createElementVNode("div", _hoisted_2, [ (openBlock(true), createElementBlock( Fragment, null, renderList(unref(regions), (value, key) => { return openBlock(), createElementBlock("span", { class: normalizeClass(["ui-region-selector-context", { "ui-active": value.children }]), onClick: withModifiers(($event) => unref(show)(value.name), ["stop"]) }, [ key != 0 ? (openBlock(), createElementBlock( Fragment, { key: 0 }, [ createTextVNode(" -") ], 64 /* STABLE_FRAGMENT */ )) : createCommentVNode("v-if", true), createTextVNode( " " + toDisplayString(value.name), 1 /* TEXT */ ) ], 10, _hoisted_3); }), 256 /* UNKEYED_FRAGMENT */ )) ]) ]), createCommentVNode(" * \u7BAD\u5934 "), createVNode(unref(UiIcon), { name: "arrow", class: "ui-region-selector-arrow", onClick: _cache[1] || (_cache[1] = ($event) => unref(show)()) }), createCommentVNode(" * \u5019\u9009\u9879 "), createVNode( Transition, toHandlers(unref(ons).animation), { default: withCtx(() => [ unref(visible) ? (openBlock(), createElementBlock( "div", mergeProps({ key: 0, class: "ui-form-candidates", ref_key: "body", ref: body }, unref(binds).body), [ createElementVNode("div", _hoisted_4, [ createElementVNode( "div", mergeProps({ class: "ui-form-candidate-content" }, unref(binds).candidates), [ (openBlock(true), createElementBlock( Fragment, null, renderList(unref(data), (value) => { return openBlock(), createElementBlock("div", { class: normalizeClass(["ui-form-candidate", { "ui-active": _ctx.modelValue.includes(value.name) }]), onClick: ($event) => unref(methods).select(value) }, [ renderSlot(_ctx.$slots, "candidate", { data: value }, () => [ createTextVNode( toDisplayString(value.name), 1 /* TEXT */ ) ]) ], 10, _hoisted_5); }), 256 /* UNKEYED_FRAGMENT */ )) ], 16 /* FULL_PROPS */ ) ]) ], 16 /* FULL_PROPS */ )) : createCommentVNode("v-if", true) ]), _: 3 /* FORWARDED */ }, 16 /* FULL_PROPS */ ), createCommentVNode(" * \u906E\u7F69\u5C42 "), createVNode(Transition, null, { default: withCtx(() => [ _ctx.loading ? (openBlock(), createElementBlock("div", _hoisted_6, [ createVNode(unref(UiIcon), { class: "ui-mask-icon", name: "loading" }) ])) : createCommentVNode("v-if", true) ]), _: 1 /* STABLE */ }) ], 16 /* FULL_PROPS */ ); }; } }); export { _sfc_main as default }; //# sourceMappingURL=index.vue2.mjs.map