UNPKG

jadq-x-vue

Version:

Craft AI-driven interfaces effortlessly

106 lines (105 loc) 2.78 kB
import { defineComponent as D, mergeDefaults as L, toRef as X, useSlots as p, computed as l, ref as B, watch as I, createVNode as N } from "vue"; import { q as P, b as w } from "../chunks/module-chunk.mjs"; import "../x-provider/index.mjs"; import T from "../_util/hooks/use-x-component-config.mjs"; import q from "./style/index.mjs"; import x from "../_util/hooks/use-state.mjs"; import { Cascader as z } from "ant-design-vue"; import E from "./useActive.mjs"; import K from "../x-provider/hooks/use-x-provider-context.mjs"; const Z = /* @__PURE__ */ D({ name: "AXSuggestion", __name: "Suggestion", props: L({ prefixCls: null, className: null, rootClassName: null, style: null, children: { type: Function }, open: { type: Boolean }, onOpenChange: { type: Function }, items: { type: Function }, onSelect: { type: Function }, block: { type: Boolean }, styles: null, classNames: null }, { open: !1 }), setup(e) { X(e, "prefixCls"); const a = p(), { direction: b, getPrefixCls: k } = K(), n = l(() => k("suggestion", e.prefixCls)); `${n.value}`; const s = l(() => b.value === "rtl"), i = T("suggestion"), u = B(), [F, c, r] = q(n), { width: f } = P(u), O = l(() => { if (e.block && f.value) return { width: `${f.value}px` }; }), [m, d] = x(e.open); I(() => e.open, (t) => { d(t); }); const [R, V] = x(), o = (t) => { var S; d(t), (S = e.onOpenChange) == null || S.call(e, t); }, g = (t) => { t === !1 ? o(!1) : (V(t), o(!0)); }, v = () => { o(!1); }, C = l(() => typeof e.items == "function" ? e.items(R.value) : e.items), h = (t) => { e.onSelect && e.onSelect(t[t.length - 1]), o(!1); }, [$, y] = E(C, m, s, h, v), A = l(() => { var t; return a.default ? a.default({ onTrigger: g, onKeyDown: y }) : (t = e.children) == null ? void 0 : t.call(e, { onTrigger: g, onKeyDown: y }); }); return () => F(N(z, { options: C.value, open: m.value, value: $.value, placement: s.value ? "topRight" : "topLeft", onDropdownVisibleChange: (t) => { t || v(); }, popupClassName: w(e.rootClassName, n.value, c.value, r, { [`${n.value}-block`]: e.block }), onChange: h, dropdownStyle: O.value }, { default: () => N("div", { ref: u, class: w(n.value, i.value.className, e.rootClassName, e.className, `${n.value}-wrapper`, c.value, r), style: { ...i.value.style, ...e.style } }, [A.value]) })); } }); export { Z as default };