SDrawer.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import { ref as i, watch as y, watchEffect as b, openBlock as S, createBlock as C, withCtx as a, createElementVNode as c, renderSlot as m, createVNode as n, createTextVNode as u, toDisplayString as f } from "vue";
  2. import { n as N, B as $ } from "./index2.js";
  3. import { _ as k } from "./index8.js";
  4. import { S as B } from "./index9.js";
  5. const D = { class: "s-drawer-body" }, x = { class: "s-drawer-footer" }, z = {
  6. __name: "SDrawer",
  7. props: {
  8. // 显隐(v-model:value)
  9. value: {
  10. type: Boolean,
  11. default: !1
  12. },
  13. // 抽屉标题
  14. title: {
  15. type: String,
  16. default: ""
  17. },
  18. // 弹出方向:right / left / top / bottom
  19. mode: {
  20. type: String,
  21. default: "right"
  22. },
  23. // 左右方向时的宽度,单位 px
  24. width: {
  25. type: Number,
  26. default: 500
  27. },
  28. // 上下方向时的高度,单位 px
  29. height: {
  30. type: Number,
  31. default: 378
  32. }
  33. },
  34. emits: ["update:value", "confirm"],
  35. setup(t, { emit: p }) {
  36. const l = p, o = t, s = i(o.value);
  37. y(
  38. () => o.value,
  39. (e) => {
  40. s.value = e;
  41. },
  42. { immediate: !0 }
  43. );
  44. const h = i(o.mode), _ = i(8);
  45. b(() => {
  46. const e = {
  47. left: "",
  48. right: "",
  49. top: "",
  50. bottom: ""
  51. };
  52. Object.keys(e).includes(o.mode) || (console.warn(`当前设置mode【${o.mode}】不在【${e}】中,已默认为【right】`), h.value = "right");
  53. });
  54. const r = () => {
  55. l("update:value", !1);
  56. }, v = () => {
  57. l("update:value", !1), l("confirm");
  58. };
  59. return (e, V) => {
  60. const d = $, w = B, g = k;
  61. return S(), C(g, {
  62. rootClassName: "s-drawer-wrap",
  63. title: t.title,
  64. placement: t.mode,
  65. width: t.width,
  66. height: t.height,
  67. visible: s.value,
  68. onClose: r,
  69. bodyStyle: {
  70. padding: 0,
  71. display: "flex",
  72. flexDirection: "column"
  73. }
  74. }, {
  75. default: a(() => [
  76. c("div", D, [
  77. m(e.$slots, "default", {}, void 0, !0)
  78. ]),
  79. c("div", x, [
  80. n(w, { size: _.value }, {
  81. default: a(() => [
  82. m(e.$slots, "footer", {}, () => [
  83. n(d, { onClick: r }, {
  84. default: a(() => [
  85. u(f(e.$l("取消")), 1)
  86. ]),
  87. _: 1
  88. }),
  89. n(d, {
  90. type: "primary",
  91. onClick: v
  92. }, {
  93. default: a(() => [
  94. u(f(e.$l("确定")), 1)
  95. ]),
  96. _: 1
  97. })
  98. ], !0)
  99. ]),
  100. _: 3
  101. }, 8, ["size"])
  102. ])
  103. ]),
  104. _: 3
  105. }, 8, ["title", "placement", "width", "height", "visible"]);
  106. };
  107. }
  108. }, T = /* @__PURE__ */ N(z, [["__scopeId", "data-v-db140b8a"]]);
  109. export {
  110. T as default
  111. };