1 | var __defProp = Object.defineProperty;
|
2 | var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3 | var __getOwnPropNames = Object.getOwnPropertyNames;
|
4 | var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5 | var __export = (target, all) => {
|
6 | for (var name2 in all)
|
7 | __defProp(target, name2, { get: all[name2], enumerable: true });
|
8 | };
|
9 | var __copyProps = (to, from, except, desc) => {
|
10 | if (from && typeof from === "object" || typeof from === "function") {
|
11 | for (let key of __getOwnPropNames(from))
|
12 | if (!__hasOwnProp.call(to, key) && key !== except)
|
13 | __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
14 | }
|
15 | return to;
|
16 | };
|
17 | var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18 | var stdin_exports = {};
|
19 | __export(stdin_exports, {
|
20 | ROW_KEY: () => ROW_KEY,
|
21 | default: () => stdin_default,
|
22 | rowProps: () => rowProps
|
23 | });
|
24 | module.exports = __toCommonJS(stdin_exports);
|
25 | var import_vue = require("vue");
|
26 | var import_utils = require("../utils");
|
27 | var import_use = require("@vant/use");
|
28 | const [name, bem] = (0, import_utils.createNamespace)("row");
|
29 | const ROW_KEY = Symbol(name);
|
30 | const rowProps = {
|
31 | tag: (0, import_utils.makeStringProp)("div"),
|
32 | wrap: import_utils.truthProp,
|
33 | align: String,
|
34 | gutter: {
|
35 | type: [String, Number, Array],
|
36 | default: 0
|
37 | },
|
38 | justify: String
|
39 | };
|
40 | var stdin_default = (0, import_vue.defineComponent)({
|
41 | name,
|
42 | props: rowProps,
|
43 | setup(props, {
|
44 | slots
|
45 | }) {
|
46 | const {
|
47 | children,
|
48 | linkChildren
|
49 | } = (0, import_use.useChildren)(ROW_KEY);
|
50 | const groups = (0, import_vue.computed)(() => {
|
51 | const groups2 = [[]];
|
52 | let totalSpan = 0;
|
53 | children.forEach((child, index) => {
|
54 | totalSpan += Number(child.span);
|
55 | if (totalSpan > 24) {
|
56 | groups2.push([index]);
|
57 | totalSpan -= 24;
|
58 | } else {
|
59 | groups2[groups2.length - 1].push(index);
|
60 | }
|
61 | });
|
62 | return groups2;
|
63 | });
|
64 | const spaces = (0, import_vue.computed)(() => {
|
65 | let gutter = 0;
|
66 | if (Array.isArray(props.gutter)) {
|
67 | gutter = Number(props.gutter[0]) || 0;
|
68 | } else {
|
69 | gutter = Number(props.gutter);
|
70 | }
|
71 | const spaces2 = [];
|
72 | if (!gutter) {
|
73 | return spaces2;
|
74 | }
|
75 | groups.value.forEach((group) => {
|
76 | const averagePadding = gutter * (group.length - 1) / group.length;
|
77 | group.forEach((item, index) => {
|
78 | if (index === 0) {
|
79 | spaces2.push({
|
80 | right: averagePadding
|
81 | });
|
82 | } else {
|
83 | const left = gutter - spaces2[item - 1].right;
|
84 | const right = averagePadding - left;
|
85 | spaces2.push({
|
86 | left,
|
87 | right
|
88 | });
|
89 | }
|
90 | });
|
91 | });
|
92 | return spaces2;
|
93 | });
|
94 | const verticalSpaces = (0, import_vue.computed)(() => {
|
95 | const {
|
96 | gutter
|
97 | } = props;
|
98 | const spaces2 = [];
|
99 | if (Array.isArray(gutter) && gutter.length > 1) {
|
100 | const bottom = Number(gutter[1]) || 0;
|
101 | if (bottom <= 0) {
|
102 | return spaces2;
|
103 | }
|
104 | groups.value.forEach((group, index) => {
|
105 | if (index === groups.value.length - 1) return;
|
106 | group.forEach(() => {
|
107 | spaces2.push({
|
108 | bottom
|
109 | });
|
110 | });
|
111 | });
|
112 | }
|
113 | return spaces2;
|
114 | });
|
115 | linkChildren({
|
116 | spaces,
|
117 | verticalSpaces
|
118 | });
|
119 | return () => {
|
120 | const {
|
121 | tag,
|
122 | wrap,
|
123 | align,
|
124 | justify
|
125 | } = props;
|
126 | return (0, import_vue.createVNode)(tag, {
|
127 | "class": bem({
|
128 | [`align-${align}`]: align,
|
129 | [`justify-${justify}`]: justify,
|
130 | nowrap: !wrap
|
131 | })
|
132 | }, {
|
133 | default: () => {
|
134 | var _a;
|
135 | return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
|
136 | }
|
137 | });
|
138 | };
|
139 | }
|
140 | });
|