SIconSelectPopover.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import { ref as f, computed as u, watch as z, resolveComponent as D, openBlock as a, createElementBlock as c, createVNode as r, withCtx as i, normalizeStyle as _, normalizeClass as h, createBlock as y, resolveDynamicComponent as g, createCommentVNode as w, createElementVNode as p, Fragment as E, renderList as L, toDisplayString as k } from "vue";
  2. import { f as P } from "./icon-groups.js";
  3. import { n as U, I as W, ap as M } from "./index2.js";
  4. import { _ as j } from "./index6.js";
  5. const q = { class: "s-icon-select-common" }, A = { class: "icon-list" }, G = ["onClick"], H = ["title"], J = {
  6. key: 0,
  7. class: "icon-empty"
  8. }, K = {
  9. __name: "SIconSelectPopover",
  10. props: {
  11. // 选中图标名,支持 v-model:value
  12. value: {
  13. type: String,
  14. default: ""
  15. },
  16. width: {
  17. type: [Number, String],
  18. default: 280
  19. },
  20. placeholder: {
  21. type: String,
  22. default() {
  23. return window.$l("请选择图标");
  24. }
  25. },
  26. // 保留:下拉版不再需要弹窗标题,兼容旧调用方传参
  27. title: {
  28. type: String,
  29. default() {
  30. return window.$l("图标选择");
  31. }
  32. }
  33. },
  34. emits: ["update:value", "change"],
  35. setup(l, { expose: x, emit: S }) {
  36. const $ = l, d = S, o = f(!1), s = f(""), m = u(() => {
  37. const e = $.width;
  38. if (typeof e == "number") return `${e}px`;
  39. const n = String(e != null ? e : "").trim();
  40. return n ? /^-?\d+(\.\d+)?$/.test(n) ? `${n}px` : n : "280px";
  41. }), C = u(() => {
  42. const e = parseFloat(m.value);
  43. return `${Math.max(280, Number.isFinite(e) ? e : 0)}px`;
  44. }), v = u(() => P("all", s.value));
  45. z(o, (e) => {
  46. e || (s.value = "");
  47. });
  48. const I = () => {
  49. o.value = !0;
  50. }, b = (e) => {
  51. d("update:value", e), d("change", e), o.value = !1;
  52. };
  53. return x({ open: I }), (e, n) => {
  54. const N = M, B = D("down-outlined"), F = W, V = j;
  55. return a(), c("div", q, [
  56. r(V, {
  57. trigger: "click",
  58. placement: "bottomLeft",
  59. open: o.value,
  60. "onUpdate:open": n[1] || (n[1] = (t) => o.value = t)
  61. }, {
  62. content: i(() => [
  63. p("div", {
  64. class: "picker-panel",
  65. style: _({ width: C.value })
  66. }, [
  67. r(N, {
  68. value: s.value,
  69. "onUpdate:value": n[0] || (n[0] = (t) => s.value = t),
  70. class: "icon-search",
  71. placeholder: e.$l("搜索图标"),
  72. "allow-clear": ""
  73. }, null, 8, ["value", "placeholder"]),
  74. p("div", A, [
  75. (a(!0), c(E, null, L(v.value, (t) => (a(), c("div", {
  76. key: t,
  77. class: h(["item-icon", { active: t === l.value }]),
  78. onClick: (O) => b(t)
  79. }, [
  80. (a(), y(g(t), { class: "icon" })),
  81. p("div", {
  82. class: "name",
  83. title: t
  84. }, k(t), 9, H)
  85. ], 10, G))), 128)),
  86. v.value.length ? w("", !0) : (a(), c("div", J, k(e.$l("暂无数据")), 1))
  87. ])
  88. ], 4)
  89. ]),
  90. default: i(() => [
  91. r(F, {
  92. class: "icon-input",
  93. readonly: !0,
  94. value: l.value,
  95. placeholder: l.placeholder,
  96. style: _({ width: m.value })
  97. }, {
  98. prefix: i(() => [
  99. l.value ? (a(), y(g(l.value), {
  100. key: 0,
  101. class: "prefix-icon"
  102. })) : w("", !0)
  103. ]),
  104. suffix: i(() => [
  105. r(B, {
  106. class: h(["select-arrow", { open: o.value }])
  107. }, null, 8, ["class"])
  108. ]),
  109. _: 1
  110. }, 8, ["value", "placeholder", "style"])
  111. ]),
  112. _: 1
  113. }, 8, ["open"])
  114. ]);
  115. };
  116. }
  117. }, Y = /* @__PURE__ */ U(K, [["__scopeId", "data-v-854f2576"]]);
  118. export {
  119. Y as default
  120. };