SIconSelect.js 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import { ref as m, computed as x, resolveComponent as N, openBlock as a, createElementBlock as c, createVNode as i, normalizeStyle as $, withCtx as p, createBlock as f, resolveDynamicComponent as w, createCommentVNode as T, createElementVNode as r, Fragment as b, renderList as B, normalizeClass as L, toDisplayString as V } from "vue";
  2. import { n as z, ap as D, I as E, aq as F } from "./index2.js";
  3. const U = { class: "s-icon-select-common" }, j = { class: "icon-search" }, q = { class: "icon-list" }, H = ["onClick"], O = { class: "name" }, A = {
  4. __name: "SIconSelect",
  5. props: {
  6. // 选中图标名,支持 v-model:value
  7. value: {
  8. type: String,
  9. default: ""
  10. },
  11. width: {
  12. type: [Number, String],
  13. default: 300
  14. },
  15. placeholder: {
  16. type: String,
  17. default() {
  18. return window.$l("请选择图标");
  19. }
  20. },
  21. title: {
  22. type: String,
  23. default() {
  24. return window.$l("图标选择");
  25. }
  26. }
  27. },
  28. emits: ["update:value", "change"],
  29. setup(e, { expose: h, emit: y }) {
  30. const u = y, C = ["createFromIconfontCN", "default", "getTwoToneColor", "setTwoToneColor"], d = Object.keys(D).filter((l) => !C.includes(l)), o = m(!1), s = m(""), k = x(() => {
  31. const l = s.value.trim().toLowerCase();
  32. return l ? d.filter((n) => n.toLowerCase().includes(l)) : d;
  33. }), v = () => {
  34. o.value = !0;
  35. }, _ = (l) => {
  36. u("update:value", l), u("change", l), o.value = !1;
  37. };
  38. return h({ open: v }), (l, n) => {
  39. const g = E, S = F, I = N("s-modal");
  40. return a(), c("div", U, [
  41. i(g, {
  42. readonly: !0,
  43. value: e.value,
  44. placeholder: e.placeholder,
  45. style: $({ width: e.width.includes("px") || e.width.includes("%") ? e.width : e.width + "px" }),
  46. onClick: v
  47. }, {
  48. prefix: p(() => [
  49. e.value ? (a(), f(w(e.value), {
  50. key: 0,
  51. class: "prefix-icon"
  52. })) : T("", !0)
  53. ]),
  54. _: 1
  55. }, 8, ["value", "placeholder", "style"]),
  56. i(I, {
  57. value: o.value,
  58. "onUpdate:value": n[1] || (n[1] = (t) => o.value = t),
  59. title: e.title,
  60. width: 900,
  61. onHandCancel: n[2] || (n[2] = (t) => o.value = !1)
  62. }, {
  63. default: p(() => [
  64. r("div", j, [
  65. i(S, {
  66. value: s.value,
  67. "onUpdate:value": n[0] || (n[0] = (t) => s.value = t),
  68. placeholder: l.$l("搜索图标"),
  69. "allow-clear": ""
  70. }, null, 8, ["value", "placeholder"])
  71. ]),
  72. r("div", q, [
  73. (a(!0), c(b, null, B(k.value, (t) => (a(), c("div", {
  74. key: t,
  75. class: L(["item-icon", { active: t === e.value }]),
  76. onClick: (G) => _(t)
  77. }, [
  78. (a(), f(w(t), { class: "icon" })),
  79. r("div", O, V(t), 1)
  80. ], 10, H))), 128))
  81. ])
  82. ]),
  83. _: 1
  84. }, 8, ["value", "title"])
  85. ]);
  86. };
  87. }
  88. }, M = /* @__PURE__ */ z(A, [["__scopeId", "data-v-39f10f6c"]]);
  89. export {
  90. M as default
  91. };