UNPKG

@aplus-frontend/ui

Version:

109 lines (108 loc) 3.77 kB
import { defineComponent as E, ref as p, computed as v, createElementBlock as O, openBlock as F, normalizeClass as i, unref as n, createVNode as m, withCtx as d, createElementVNode as L } from "vue"; import { Popover as z, Textarea as G } from "@aplus-frontend/antdv"; import { IconApAdLineScreen as S } from "@aplus-frontend/icon"; import { isNumber as W } from "lodash-unified"; import "../../../config-provider/index.mjs"; import "../../../hooks/index.mjs"; import { splitValue as j } from "../utils.mjs"; import { useControllableValue as T } from "../../../hooks/useControllableValue.mjs"; import { useLocale as U } from "../../../config-provider/hooks/use-locale.mjs"; import { useNamespace as g } from "../../../config-provider/hooks/use-namespace.mjs"; const ee = /* @__PURE__ */ E({ name: "BatchInputGroupPopoverInput", inheritAttrs: !1, __name: "index", props: { _parent: {}, onClose: { type: Function }, disabled: { type: Boolean }, maxNum: {}, getPopupContainer: { type: Function }, placement: {}, value: {}, "onUpdate:value": { type: Function } }, emits: ["update:value"], setup(h, { emit: C }) { const o = h, b = C, { value: y, updateValue: x } = T(o, b), u = p(!1), s = p(), c = p(), r = p({ left: 0, right: 0 }), P = (e) => o._parent || e, { t: V } = U(); function I(e) { const a = e.target.value || ""; let t = j(a, ` ,`, ` `, o.maxNum); if (t = t.replace(/\\n/g, ` `), t !== a) { const l = s.value?.$el || s.value; l && (l.value = t); } x(t); } const N = () => { if (o.getPopupContainer) { const e = o._parent, a = o.getPopupContainer(), t = e?.getBoundingClientRect(), l = a?.getBoundingClientRect(); c.value = e?.offsetWidth, r.value.left = (t?.left || 0) - (l.left || 0), r.value.right = (t?.right || 0) - (l.right || 0); } }; function $(e) { N(), o.disabled ? u.value = !1 : u.value = e, !e && o.onClose?.(); } const { b: f, e: R, em: _, bm: B } = g("batch-input-group-popover-input"), { cssVar: A } = g("batch-input-group-popover"), k = v(() => { const e = o.placement, a = W(e) ? `${e}px` : e === "left" ? `${r.value.left}px` : "unset", t = e === "right" ? `${-r.value.right}px` : "unset"; return { left: a, right: t }; }), w = v(() => A({ ...k.value, width: c.value ? `${c.value}px` : "100%" })); return (e, a) => (F(), O("div", { class: i(n(f)()) }, [ m(n(z), { "overlay-class-name": `${n(R)("popover")} ${e.$attrs.class}`, "get-popup-container": e.getPopupContainer ?? P, trigger: "click", placement: "bottomLeft", open: u.value, "overlay-style": w.value, onOpenChange: $ }, { content: d(() => [ L("div", { class: i(n(_)("popover", "content")) }, [ m(n(G), { ref_key: "textAreaRef", ref: s, placeholder: n(V)("ap.batchInputGroup.popoverInputPlaceholder", { maxNum: e.maxNum + "" }), bordered: !1, rows: 10, value: n(y), "allow-clear": !1, "auto-size": !1, onInput: I }, null, 8, ["placeholder", "value"]) ], 2) ]), default: d(() => [ m(n(S), { class: i([ n(f)("trigger-icon"), e.disabled ? n(B)("trigger-icon", "disabled") : null ]) }, null, 8, ["class"]) ]), _: 1 }, 8, ["overlay-class-name", "get-popup-container", "open", "overlay-style"]) ], 2)); } }); export { ee as default };