SIconSelect.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import { useAttrs as y, resolveComponent as S, openBlock as o, createBlock as c, mergeProps as _, unref as s, withCtx as d, createElementBlock as v, Fragment as w, renderList as B, createVNode as b, createElementVNode as x, toDisplayString as C } from "vue";
  2. import { f as k } from "./icon-groups.js";
  3. import { a7 as L, a8 as N } from "./index2.js";
  4. const W = { style: { "margin-left": "8px" } }, O = {
  5. __name: "SIconSelect",
  6. props: {
  7. // 选中图标名,支持 v-model:value
  8. value: {
  9. type: String,
  10. default: ""
  11. },
  12. // 占位文案
  13. placeholder: {
  14. type: String,
  15. default() {
  16. return window.$l("请选择图标");
  17. }
  18. },
  19. // 是否多选
  20. multiple: {
  21. type: Boolean,
  22. default: !1
  23. },
  24. // 是否禁用
  25. disabled: {
  26. type: Boolean,
  27. default: !1
  28. },
  29. // 是否必填(表单校验用)
  30. required: {
  31. type: Boolean,
  32. default: !1
  33. },
  34. // 下拉面板最小宽度,单位 px
  35. minWidth: {
  36. type: Number,
  37. default: 240
  38. }
  39. },
  40. emits: ["update:value", "change"],
  41. setup(t, { emit: i }) {
  42. const u = y(), r = i, m = (e) => {
  43. r("update:value", e), r("change", e);
  44. }, f = k("all", ""), p = (e, l) => {
  45. var a;
  46. return String((a = l == null ? void 0 : l.value) != null ? a : "").toLowerCase().includes(String(e != null ? e : "").trim().toLowerCase());
  47. };
  48. return (e, l) => {
  49. const a = S("s-icon"), h = N, g = L;
  50. return o(), c(g, _({
  51. value: t.value,
  52. disabled: t.disabled,
  53. mode: t.multiple ? "multiple" : void 0,
  54. "allow-clear": !t.required,
  55. placeholder: t.placeholder,
  56. "show-search": "",
  57. "filter-option": p,
  58. onChange: m
  59. }, s(u), {
  60. style: { minWidth: t.minWidth + "px" }
  61. }), {
  62. default: d(() => [
  63. (o(!0), v(w, null, B(s(f), (n) => (o(), c(h, {
  64. value: n,
  65. key: n
  66. }, {
  67. default: d(() => [
  68. b(a, {
  69. name: n,
  70. color: ""
  71. }, null, 8, ["name"]),
  72. x("span", W, C(n), 1)
  73. ]),
  74. _: 2
  75. }, 1032, ["value"]))), 128))
  76. ]),
  77. _: 1
  78. }, 16, ["value", "disabled", "mode", "allow-clear", "placeholder", "style"]);
  79. };
  80. }
  81. };
  82. export {
  83. O as default
  84. };