index9.js 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import { u as W, bV as k, c as L, d as m, bb as M, _ as G, bn as q, P as I, bg as j, bW as b } from "./index2.js";
  2. import { defineComponent as H, computed as o, ref as B, watch as J, createVNode as p, Fragment as K } from "vue";
  3. import { u as Q } from "./useFlexGapSupport.js";
  4. const U = {
  5. small: 8,
  6. middle: 16,
  7. large: 24
  8. }, X = () => ({
  9. prefixCls: String,
  10. size: {
  11. type: [String, Number, Array]
  12. },
  13. direction: I.oneOf(j("horizontal", "vertical")).def("horizontal"),
  14. align: I.oneOf(j("start", "end", "center", "baseline")),
  15. wrap: q()
  16. });
  17. function Y(e) {
  18. return typeof e == "string" ? U[e] : e || 0;
  19. }
  20. const d = H({
  21. compatConfig: {
  22. MODE: 3
  23. },
  24. name: "ASpace",
  25. inheritAttrs: !1,
  26. props: X(),
  27. slots: Object,
  28. setup(e, F) {
  29. let {
  30. slots: r,
  31. attrs: f
  32. } = F;
  33. const {
  34. prefixCls: l,
  35. space: g,
  36. direction: x
  37. } = W("space", e), [P, V] = k(l), z = Q(), n = o(() => {
  38. var t, a, i;
  39. return (i = (t = e.size) !== null && t !== void 0 ? t : (a = g == null ? void 0 : g.value) === null || a === void 0 ? void 0 : a.size) !== null && i !== void 0 ? i : "small";
  40. }), y = B(), s = B();
  41. J(n, () => {
  42. [y.value, s.value] = (Array.isArray(n.value) ? n.value : [n.value, n.value]).map((t) => Y(t));
  43. }, {
  44. immediate: !0
  45. });
  46. const h = o(() => e.align === void 0 && e.direction === "horizontal" ? "center" : e.align), D = o(() => L(l.value, V.value, `${l.value}-${e.direction}`, {
  47. [`${l.value}-rtl`]: x.value === "rtl",
  48. [`${l.value}-align-${h.value}`]: h.value
  49. })), E = o(() => x.value === "rtl" ? "marginLeft" : "marginRight"), R = o(() => {
  50. const t = {};
  51. return z.value && (t.columnGap = `${y.value}px`, t.rowGap = `${s.value}px`), m(m({}, t), e.wrap && {
  52. flexWrap: "wrap",
  53. marginBottom: `${-s.value}px`
  54. });
  55. });
  56. return () => {
  57. var t, a;
  58. const {
  59. wrap: i,
  60. direction: T = "horizontal"
  61. } = e, C = (t = r.default) === null || t === void 0 ? void 0 : t.call(r), _ = M(C), w = _.length;
  62. if (w === 0)
  63. return null;
  64. const c = (a = r.split) === null || a === void 0 ? void 0 : a.call(r), A = `${l.value}-item`, N = y.value, S = w - 1;
  65. return p("div", G(G({}, f), {}, {
  66. class: [D.value, f.class],
  67. style: [R.value, f.style]
  68. }), [_.map((O, u) => {
  69. let $ = C.indexOf(O);
  70. $ === -1 && ($ = `$$space-${u}`);
  71. let v = {};
  72. return z.value || (T === "vertical" ? u < S && (v = {
  73. marginBottom: `${N / (c ? 2 : 1)}px`
  74. }) : v = m(m({}, u < S && {
  75. [E.value]: `${N / (c ? 2 : 1)}px`
  76. }), i && {
  77. paddingBottom: `${s.value}px`
  78. })), P(p(K, {
  79. key: $
  80. }, [p("div", {
  81. class: A,
  82. style: v
  83. }, [O]), u < S && c && p("span", {
  84. class: `${A}-split`,
  85. style: v
  86. }, [c])]));
  87. })]);
  88. };
  89. }
  90. });
  91. d.Compact = b;
  92. d.install = function(e) {
  93. return e.component(d.name, d), e.component(b.name, b), e;
  94. };
  95. export {
  96. d as S
  97. };