Col.js 8.5 KB

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