SDrawer.js 2.7 KB

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