Col.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. import { g as E, I as T, _ as g, j as F, aK as D, aL as w, m as k, a as C, F as N } from "./index2.js";
  2. import { shallowRef as K, onMounted as L, inject as V, computed as $, provide as X, defineComponent as W, ref as R, onBeforeUnmount as H, createVNode as B } from "vue";
  3. import { d as P } from "./styleChecker.js";
  4. const J = () => {
  5. const e = K(!1);
  6. return L(() => {
  7. e.value = P();
  8. }), e;
  9. }, _ = Symbol("rowContextKey"), U = (e) => {
  10. X(_, e);
  11. }, q = () => V(_, {
  12. gutter: $(() => {
  13. }),
  14. wrap: $(() => {
  15. }),
  16. supportFlexGap: $(() => {
  17. })
  18. }), Q = (e) => {
  19. const {
  20. componentCls: t
  21. } = e;
  22. return {
  23. // Grid system
  24. [t]: {
  25. display: "flex",
  26. flexFlow: "row wrap",
  27. minWidth: 0,
  28. "&::before, &::after": {
  29. display: "flex"
  30. },
  31. "&-no-wrap": {
  32. flexWrap: "nowrap"
  33. },
  34. // The origin of the X-axis
  35. "&-start": {
  36. justifyContent: "flex-start"
  37. },
  38. // The center of the X-axis
  39. "&-center": {
  40. justifyContent: "center"
  41. },
  42. // The opposite of the X-axis
  43. "&-end": {
  44. justifyContent: "flex-end"
  45. },
  46. "&-space-between": {
  47. justifyContent: "space-between"
  48. },
  49. "&-space-around ": {
  50. justifyContent: "space-around"
  51. },
  52. "&-space-evenly ": {
  53. justifyContent: "space-evenly"
  54. },
  55. // Align at the top
  56. "&-top": {
  57. alignItems: "flex-start"
  58. },
  59. // Align at the center
  60. "&-middle": {
  61. alignItems: "center"
  62. },
  63. "&-bottom": {
  64. alignItems: "flex-end"
  65. }
  66. }
  67. };
  68. }, Y = (e) => {
  69. const {
  70. componentCls: t
  71. } = e;
  72. return {
  73. // Grid system
  74. [t]: {
  75. position: "relative",
  76. maxWidth: "100%",
  77. // Prevent columns from collapsing when empty
  78. minHeight: 1
  79. }
  80. };
  81. }, Z = (e, t) => {
  82. const {
  83. componentCls: a,
  84. gridColumns: u
  85. } = e, o = {};
  86. for (let s = u; s >= 0; s--)
  87. s === 0 ? (o[`${a}${t}-${s}`] = {
  88. display: "none"
  89. }, o[`${a}-push-${s}`] = {
  90. insetInlineStart: "auto"
  91. }, o[`${a}-pull-${s}`] = {
  92. insetInlineEnd: "auto"
  93. }, o[`${a}${t}-push-${s}`] = {
  94. insetInlineStart: "auto"
  95. }, o[`${a}${t}-pull-${s}`] = {
  96. insetInlineEnd: "auto"
  97. }, o[`${a}${t}-offset-${s}`] = {
  98. marginInlineEnd: 0
  99. }, o[`${a}${t}-order-${s}`] = {
  100. order: 0
  101. }) : (o[`${a}${t}-${s}`] = {
  102. display: "block",
  103. flex: `0 0 ${s / u * 100}%`,
  104. maxWidth: `${s / u * 100}%`
  105. }, o[`${a}${t}-push-${s}`] = {
  106. insetInlineStart: `${s / u * 100}%`
  107. }, o[`${a}${t}-pull-${s}`] = {
  108. insetInlineEnd: `${s / u * 100}%`
  109. }, o[`${a}${t}-offset-${s}`] = {
  110. marginInlineStart: `${s / u * 100}%`
  111. }, o[`${a}${t}-order-${s}`] = {
  112. order: s
  113. });
  114. return o;
  115. }, O = (e, t) => Z(e, t), z = (e, t, a) => ({
  116. [`@media (min-width: ${t}px)`]: g({}, O(e, a))
  117. }), ee = E("Grid", (e) => [Q(e)]), te = E("Grid", (e) => {
  118. const t = T(e, {
  119. gridColumns: 24
  120. // Row is divided into 24 parts in Grid
  121. }), a = {
  122. "-sm": t.screenSMMin,
  123. "-md": t.screenMDMin,
  124. "-lg": t.screenLGMin,
  125. "-xl": t.screenXLMin,
  126. "-xxl": t.screenXXLMin
  127. };
  128. return [Y(t), O(t, ""), O(t, "-xs"), Object.keys(a).map((u) => z(t, a[u], u)).reduce((u, o) => g(g({}, u), o), {})];
  129. }), ne = () => ({
  130. align: N([String, Object]),
  131. justify: N([String, Object]),
  132. prefixCls: String,
  133. gutter: N([Number, Array, Object], 0),
  134. wrap: {
  135. type: Boolean,
  136. default: void 0
  137. }
  138. }), ie = W({
  139. compatConfig: {
  140. MODE: 3
  141. },
  142. name: "ARow",
  143. inheritAttrs: !1,
  144. props: ne(),
  145. setup(e, t) {
  146. let {
  147. slots: a,
  148. attrs: u
  149. } = t;
  150. const {
  151. prefixCls: o,
  152. direction: s
  153. } = F("row", e), [G, y] = ee(o);
  154. let v;
  155. const x = D(), b = R({
  156. xs: !0,
  157. sm: !0,
  158. md: !0,
  159. lg: !0,
  160. xl: !0,
  161. xxl: !0
  162. }), S = R({
  163. xs: !1,
  164. sm: !1,
  165. md: !1,
  166. lg: !1,
  167. xl: !1,
  168. xxl: !1
  169. }), h = (n) => $(() => {
  170. if (typeof e[n] == "string")
  171. return e[n];
  172. if (typeof e[n] != "object")
  173. return "";
  174. for (let r = 0; r < w.length; r++) {
  175. const l = w[r];
  176. if (!S.value[l]) continue;
  177. const i = e[n][l];
  178. if (i !== void 0)
  179. return i;
  180. }
  181. return "";
  182. }), f = h("align"), p = h("justify"), d = J();
  183. L(() => {
  184. v = x.value.subscribe((n) => {
  185. S.value = n;
  186. const r = e.gutter || 0;
  187. (!Array.isArray(r) && typeof r == "object" || Array.isArray(r) && (typeof r[0] == "object" || typeof r[1] == "object")) && (b.value = n);
  188. });
  189. }), H(() => {
  190. x.value.unsubscribe(v);
  191. });
  192. const m = $(() => {
  193. const n = [void 0, void 0], {
  194. gutter: r = 0
  195. } = e;
  196. return (Array.isArray(r) ? r : [r, void 0]).forEach((i, M) => {
  197. if (typeof i == "object")
  198. for (let I = 0; I < w.length; I++) {
  199. const A = w[I];
  200. if (b.value[A] && i[A] !== void 0) {
  201. n[M] = i[A];
  202. break;
  203. }
  204. }
  205. else
  206. n[M] = i;
  207. }), n;
  208. });
  209. U({
  210. gutter: m,
  211. supportFlexGap: d,
  212. wrap: $(() => e.wrap)
  213. });
  214. const j = $(() => k(o.value, {
  215. [`${o.value}-no-wrap`]: e.wrap === !1,
  216. [`${o.value}-${p.value}`]: p.value,
  217. [`${o.value}-${f.value}`]: f.value,
  218. [`${o.value}-rtl`]: s.value === "rtl"
  219. }, u.class, y.value)), c = $(() => {
  220. const n = m.value, r = {}, l = n[0] != null && n[0] > 0 ? `${n[0] / -2}px` : void 0, i = n[1] != null && n[1] > 0 ? `${n[1] / -2}px` : void 0;
  221. return l && (r.marginLeft = l, r.marginRight = l), d.value ? r.rowGap = `${n[1]}px` : i && (r.marginTop = i, r.marginBottom = i), r;
  222. });
  223. return () => {
  224. var n;
  225. return G(B("div", C(C({}, u), {}, {
  226. class: j.value,
  227. style: g(g({}, c.value), u.style)
  228. }), [(n = a.default) === null || n === void 0 ? void 0 : n.call(a)]));
  229. };
  230. }
  231. });
  232. function re(e) {
  233. return typeof e == "number" ? `${e} ${e} auto` : /^\d+(\.\d+)?(px|em|rem|%)$/.test(e) ? `0 0 ${e}` : e;
  234. }
  235. const se = () => ({
  236. span: [String, Number],
  237. order: [String, Number],
  238. offset: [String, Number],
  239. push: [String, Number],
  240. pull: [String, Number],
  241. xs: {
  242. type: [String, Number, Object],
  243. default: void 0
  244. },
  245. sm: {
  246. type: [String, Number, Object],
  247. default: void 0
  248. },
  249. md: {
  250. type: [String, Number, Object],
  251. default: void 0
  252. },
  253. lg: {
  254. type: [String, Number, Object],
  255. default: void 0
  256. },
  257. xl: {
  258. type: [String, Number, Object],
  259. default: void 0
  260. },
  261. xxl: {
  262. type: [String, Number, Object],
  263. default: void 0
  264. },
  265. prefixCls: String,
  266. flex: [String, Number]
  267. }), oe = ["xs", "sm", "md", "lg", "xl", "xxl"], de = W({
  268. compatConfig: {
  269. MODE: 3
  270. },
  271. name: "ACol",
  272. inheritAttrs: !1,
  273. props: se(),
  274. setup(e, t) {
  275. let {
  276. slots: a,
  277. attrs: u
  278. } = t;
  279. const {
  280. gutter: o,
  281. supportFlexGap: s,
  282. wrap: G
  283. } = q(), {
  284. prefixCls: y,
  285. direction: v
  286. } = F("col", e), [x, b] = te(y), S = $(() => {
  287. const {
  288. span: f,
  289. order: p,
  290. offset: d,
  291. push: m,
  292. pull: j
  293. } = e, c = y.value;
  294. let n = {};
  295. return oe.forEach((r) => {
  296. let l = {};
  297. const i = e[r];
  298. typeof i == "number" ? l.span = i : typeof i == "object" && (l = i || {}), n = g(g({}, n), {
  299. [`${c}-${r}-${l.span}`]: l.span !== void 0,
  300. [`${c}-${r}-order-${l.order}`]: l.order || l.order === 0,
  301. [`${c}-${r}-offset-${l.offset}`]: l.offset || l.offset === 0,
  302. [`${c}-${r}-push-${l.push}`]: l.push || l.push === 0,
  303. [`${c}-${r}-pull-${l.pull}`]: l.pull || l.pull === 0,
  304. [`${c}-rtl`]: v.value === "rtl"
  305. });
  306. }), k(c, {
  307. [`${c}-${f}`]: f !== void 0,
  308. [`${c}-order-${p}`]: p,
  309. [`${c}-offset-${d}`]: d,
  310. [`${c}-push-${m}`]: m,
  311. [`${c}-pull-${j}`]: j
  312. }, n, u.class, b.value);
  313. }), h = $(() => {
  314. const {
  315. flex: f
  316. } = e, p = o.value, d = {};
  317. if (p && p[0] > 0) {
  318. const m = `${p[0] / 2}px`;
  319. d.paddingLeft = m, d.paddingRight = m;
  320. }
  321. if (p && p[1] > 0 && !s.value) {
  322. const m = `${p[1] / 2}px`;
  323. d.paddingTop = m, d.paddingBottom = m;
  324. }
  325. return f && (d.flex = re(f), G.value === !1 && !d.minWidth && (d.minWidth = 0)), d;
  326. });
  327. return () => {
  328. var f;
  329. return x(B("div", C(C({}, u), {}, {
  330. class: S.value,
  331. style: [h.value, u.style]
  332. }), [(f = a.default) === null || f === void 0 ? void 0 : f.call(a)]));
  333. };
  334. }
  335. });
  336. export {
  337. ie as A,
  338. de as C
  339. };