noreflow 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +219 -0
- package/dist/index.cjs +1572 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +161 -0
- package/dist/index.d.ts +161 -0
- package/dist/index.js +1566 -0
- package/dist/index.js.map +1 -0
- package/package.json +70 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1572 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/defaults.ts
|
|
4
|
+
var DEFAULTS = {
|
|
5
|
+
display: "flex",
|
|
6
|
+
position: "static",
|
|
7
|
+
flexDirection: "row",
|
|
8
|
+
flexWrap: "nowrap",
|
|
9
|
+
justifyContent: "flex-start",
|
|
10
|
+
alignItems: "stretch",
|
|
11
|
+
alignSelf: "auto",
|
|
12
|
+
alignContent: "stretch",
|
|
13
|
+
justifyItems: "stretch",
|
|
14
|
+
justifySelf: "auto",
|
|
15
|
+
gridTemplateColumns: [],
|
|
16
|
+
gridTemplateRows: [],
|
|
17
|
+
gridAutoColumns: "auto",
|
|
18
|
+
gridAutoRows: "auto",
|
|
19
|
+
gridAutoFlow: "row",
|
|
20
|
+
gridColumnStart: "auto",
|
|
21
|
+
gridColumnEnd: "auto",
|
|
22
|
+
gridRowStart: "auto",
|
|
23
|
+
gridRowEnd: "auto",
|
|
24
|
+
flexGrow: 0,
|
|
25
|
+
flexShrink: 1,
|
|
26
|
+
flexBasis: "auto",
|
|
27
|
+
width: "auto",
|
|
28
|
+
height: "auto",
|
|
29
|
+
minWidth: 0,
|
|
30
|
+
minHeight: 0,
|
|
31
|
+
maxWidth: Infinity,
|
|
32
|
+
maxHeight: Infinity,
|
|
33
|
+
top: "auto",
|
|
34
|
+
right: "auto",
|
|
35
|
+
bottom: "auto",
|
|
36
|
+
left: "auto",
|
|
37
|
+
zIndex: 0,
|
|
38
|
+
aspectRatio: void 0,
|
|
39
|
+
paddingTop: 0,
|
|
40
|
+
paddingRight: 0,
|
|
41
|
+
paddingBottom: 0,
|
|
42
|
+
paddingLeft: 0,
|
|
43
|
+
marginTop: 0,
|
|
44
|
+
marginRight: 0,
|
|
45
|
+
marginBottom: 0,
|
|
46
|
+
marginLeft: 0,
|
|
47
|
+
borderTop: 0,
|
|
48
|
+
borderRight: 0,
|
|
49
|
+
borderBottom: 0,
|
|
50
|
+
borderLeft: 0,
|
|
51
|
+
rowGap: 0,
|
|
52
|
+
columnGap: 0,
|
|
53
|
+
boxSizing: "content-box"
|
|
54
|
+
};
|
|
55
|
+
function resolveStyle(style) {
|
|
56
|
+
if (!style) return { ...DEFAULTS };
|
|
57
|
+
return {
|
|
58
|
+
display: style.display ?? DEFAULTS.display,
|
|
59
|
+
position: style.position ?? DEFAULTS.position,
|
|
60
|
+
flexDirection: style.flexDirection ?? DEFAULTS.flexDirection,
|
|
61
|
+
flexWrap: style.flexWrap ?? DEFAULTS.flexWrap,
|
|
62
|
+
justifyContent: style.justifyContent ?? DEFAULTS.justifyContent,
|
|
63
|
+
alignItems: style.alignItems ?? DEFAULTS.alignItems,
|
|
64
|
+
alignSelf: style.alignSelf ?? DEFAULTS.alignSelf,
|
|
65
|
+
alignContent: style.alignContent ?? DEFAULTS.alignContent,
|
|
66
|
+
justifyItems: style.justifyItems ?? DEFAULTS.justifyItems,
|
|
67
|
+
justifySelf: style.justifySelf ?? DEFAULTS.justifySelf,
|
|
68
|
+
gridTemplateColumns: style.gridTemplateColumns ?? DEFAULTS.gridTemplateColumns,
|
|
69
|
+
gridTemplateRows: style.gridTemplateRows ?? DEFAULTS.gridTemplateRows,
|
|
70
|
+
gridAutoColumns: style.gridAutoColumns ?? DEFAULTS.gridAutoColumns,
|
|
71
|
+
gridAutoRows: style.gridAutoRows ?? DEFAULTS.gridAutoRows,
|
|
72
|
+
gridAutoFlow: style.gridAutoFlow ?? DEFAULTS.gridAutoFlow,
|
|
73
|
+
gridColumnStart: style.gridColumnStart ?? DEFAULTS.gridColumnStart,
|
|
74
|
+
gridColumnEnd: style.gridColumnEnd ?? DEFAULTS.gridColumnEnd,
|
|
75
|
+
gridRowStart: style.gridRowStart ?? DEFAULTS.gridRowStart,
|
|
76
|
+
gridRowEnd: style.gridRowEnd ?? DEFAULTS.gridRowEnd,
|
|
77
|
+
flexGrow: style.flexGrow ?? DEFAULTS.flexGrow,
|
|
78
|
+
flexShrink: style.flexShrink ?? DEFAULTS.flexShrink,
|
|
79
|
+
flexBasis: style.flexBasis ?? DEFAULTS.flexBasis,
|
|
80
|
+
width: style.width ?? DEFAULTS.width,
|
|
81
|
+
height: style.height ?? DEFAULTS.height,
|
|
82
|
+
minWidth: style.minWidth ?? DEFAULTS.minWidth,
|
|
83
|
+
minHeight: style.minHeight ?? DEFAULTS.minHeight,
|
|
84
|
+
maxWidth: style.maxWidth ?? DEFAULTS.maxWidth,
|
|
85
|
+
maxHeight: style.maxHeight ?? DEFAULTS.maxHeight,
|
|
86
|
+
top: style.top ?? DEFAULTS.top,
|
|
87
|
+
right: style.right ?? DEFAULTS.right,
|
|
88
|
+
bottom: style.bottom ?? DEFAULTS.bottom,
|
|
89
|
+
left: style.left ?? DEFAULTS.left,
|
|
90
|
+
zIndex: style.zIndex ?? DEFAULTS.zIndex,
|
|
91
|
+
aspectRatio: style.aspectRatio ?? DEFAULTS.aspectRatio,
|
|
92
|
+
paddingTop: style.paddingTop ?? style.padding ?? DEFAULTS.paddingTop,
|
|
93
|
+
paddingRight: style.paddingRight ?? style.padding ?? DEFAULTS.paddingRight,
|
|
94
|
+
paddingBottom: style.paddingBottom ?? style.padding ?? DEFAULTS.paddingBottom,
|
|
95
|
+
paddingLeft: style.paddingLeft ?? style.padding ?? DEFAULTS.paddingLeft,
|
|
96
|
+
marginTop: style.marginTop ?? style.margin ?? DEFAULTS.marginTop,
|
|
97
|
+
marginRight: style.marginRight ?? style.margin ?? DEFAULTS.marginRight,
|
|
98
|
+
marginBottom: style.marginBottom ?? style.margin ?? DEFAULTS.marginBottom,
|
|
99
|
+
marginLeft: style.marginLeft ?? style.margin ?? DEFAULTS.marginLeft,
|
|
100
|
+
borderTop: style.borderTop ?? style.border ?? DEFAULTS.borderTop,
|
|
101
|
+
borderRight: style.borderRight ?? style.border ?? DEFAULTS.borderRight,
|
|
102
|
+
borderBottom: style.borderBottom ?? style.border ?? DEFAULTS.borderBottom,
|
|
103
|
+
borderLeft: style.borderLeft ?? style.border ?? DEFAULTS.borderLeft,
|
|
104
|
+
rowGap: style.rowGap ?? style.gap ?? DEFAULTS.rowGap,
|
|
105
|
+
columnGap: style.columnGap ?? style.gap ?? DEFAULTS.columnGap,
|
|
106
|
+
boxSizing: style.boxSizing ?? DEFAULTS.boxSizing
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// src/boxModel.ts
|
|
111
|
+
function parsePercent(value) {
|
|
112
|
+
if (value.endsWith("%")) {
|
|
113
|
+
const n = Number(value.slice(0, -1));
|
|
114
|
+
return Number.isFinite(n) ? n : null;
|
|
115
|
+
}
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
function resolveSize(value, referenceSize) {
|
|
119
|
+
if (value === "auto") return null;
|
|
120
|
+
if (typeof value === "number") return value;
|
|
121
|
+
const pct = parsePercent(value);
|
|
122
|
+
if (pct !== null) {
|
|
123
|
+
if (!isFinite(referenceSize)) return 0;
|
|
124
|
+
return pct / 100 * referenceSize;
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
function resolveDimension(value, referenceSize) {
|
|
129
|
+
if (typeof value === "number") return value;
|
|
130
|
+
const pct = parsePercent(value);
|
|
131
|
+
if (pct !== null) {
|
|
132
|
+
if (!isFinite(referenceSize)) return 0;
|
|
133
|
+
return pct / 100 * referenceSize;
|
|
134
|
+
}
|
|
135
|
+
return 0;
|
|
136
|
+
}
|
|
137
|
+
function resolveMargin(value, referenceSize) {
|
|
138
|
+
if (value === "auto") return null;
|
|
139
|
+
if (typeof value === "number") return value;
|
|
140
|
+
const pct = parsePercent(value);
|
|
141
|
+
if (pct !== null) return pct / 100 * referenceSize;
|
|
142
|
+
return 0;
|
|
143
|
+
}
|
|
144
|
+
function resolveInset(value, referenceSize) {
|
|
145
|
+
if (value === "auto") return null;
|
|
146
|
+
if (typeof value === "number") return value;
|
|
147
|
+
const pct = parsePercent(value);
|
|
148
|
+
if (pct !== null) return pct / 100 * referenceSize;
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
function resolvePadding(style) {
|
|
152
|
+
return {
|
|
153
|
+
top: style.paddingTop,
|
|
154
|
+
right: style.paddingRight,
|
|
155
|
+
bottom: style.paddingBottom,
|
|
156
|
+
left: style.paddingLeft
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
function resolveBorder(style) {
|
|
160
|
+
return {
|
|
161
|
+
top: style.borderTop,
|
|
162
|
+
right: style.borderRight,
|
|
163
|
+
bottom: style.borderBottom,
|
|
164
|
+
left: style.borderLeft
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function clamp(value, min, max) {
|
|
168
|
+
return Math.max(min, Math.min(max, value));
|
|
169
|
+
}
|
|
170
|
+
function horizontalInset(padding, border) {
|
|
171
|
+
return padding.left + padding.right + border.left + border.right;
|
|
172
|
+
}
|
|
173
|
+
function verticalInset(padding, border) {
|
|
174
|
+
return padding.top + padding.bottom + border.top + border.bottom;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// src/gridLayout.ts
|
|
178
|
+
function parseTrackSize(size) {
|
|
179
|
+
if (size === "auto") return { type: "auto", value: 0 };
|
|
180
|
+
if (typeof size === "number") return { type: "px", value: size };
|
|
181
|
+
const str = size;
|
|
182
|
+
if (str.endsWith("fr")) {
|
|
183
|
+
const n = Number(str.slice(0, -2));
|
|
184
|
+
return { type: "fr", value: Number.isFinite(n) ? n : 0 };
|
|
185
|
+
}
|
|
186
|
+
if (str.endsWith("%")) {
|
|
187
|
+
const n = Number(str.slice(0, -1));
|
|
188
|
+
return { type: "percent", value: Number.isFinite(n) ? n : 0 };
|
|
189
|
+
}
|
|
190
|
+
return { type: "auto", value: 0 };
|
|
191
|
+
}
|
|
192
|
+
function resolveGridLine(value) {
|
|
193
|
+
if (value === "auto") return null;
|
|
194
|
+
return value;
|
|
195
|
+
}
|
|
196
|
+
function placeItems(items, explicitCols, explicitRows, autoFlow) {
|
|
197
|
+
let maxCol = explicitCols;
|
|
198
|
+
let maxRow = explicitRows;
|
|
199
|
+
for (const item of items) {
|
|
200
|
+
const cs = resolveGridLine(item.style.gridColumnStart);
|
|
201
|
+
const ce = resolveGridLine(item.style.gridColumnEnd);
|
|
202
|
+
const rs = resolveGridLine(item.style.gridRowStart);
|
|
203
|
+
const re = resolveGridLine(item.style.gridRowEnd);
|
|
204
|
+
if (cs !== null) item.colStart = cs - 1;
|
|
205
|
+
if (ce !== null) item.colEnd = ce - 1;
|
|
206
|
+
if (rs !== null) item.rowStart = rs - 1;
|
|
207
|
+
if (re !== null) item.rowEnd = re - 1;
|
|
208
|
+
if (cs !== null && ce === null) item.colEnd = item.colStart + 1;
|
|
209
|
+
if (rs !== null && re === null) item.rowEnd = item.rowStart + 1;
|
|
210
|
+
if (cs === null && ce !== null) item.colStart = item.colEnd - 1;
|
|
211
|
+
if (rs === null && re !== null) item.rowStart = item.rowEnd - 1;
|
|
212
|
+
if (item.colEnd > maxCol) maxCol = item.colEnd;
|
|
213
|
+
if (item.rowEnd > maxRow) maxRow = item.rowEnd;
|
|
214
|
+
}
|
|
215
|
+
const isOccupied = (grid2, row2, col2) => grid2.has(`${row2},${col2}`);
|
|
216
|
+
const markOccupied = (grid2, item) => {
|
|
217
|
+
for (let r = item.rowStart; r < item.rowEnd; r++) {
|
|
218
|
+
for (let c = item.colStart; c < item.colEnd; c++) {
|
|
219
|
+
grid2.add(`${r},${c}`);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
const occupiedCells = /* @__PURE__ */ new Set();
|
|
224
|
+
for (const item of items) {
|
|
225
|
+
if (item.colStart >= 0 && item.rowStart >= 0) {
|
|
226
|
+
markOccupied(occupiedCells, item);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
let autoRow = 0;
|
|
230
|
+
let autoCol = 0;
|
|
231
|
+
for (const item of items) {
|
|
232
|
+
const needsColPlacement = item.colStart < 0;
|
|
233
|
+
const needsRowPlacement = item.rowStart < 0;
|
|
234
|
+
if (!needsColPlacement && !needsRowPlacement) continue;
|
|
235
|
+
const spanCols = needsColPlacement ? 1 : item.colEnd - item.colStart;
|
|
236
|
+
const spanRows = needsRowPlacement ? 1 : item.rowEnd - item.rowStart;
|
|
237
|
+
if (autoFlow === "row") {
|
|
238
|
+
let placed = false;
|
|
239
|
+
for (let r = needsRowPlacement ? autoRow : item.rowStart; !placed; r++) {
|
|
240
|
+
const startCol = r === autoRow && needsColPlacement ? autoCol : 0;
|
|
241
|
+
for (let c = needsColPlacement ? startCol : item.colStart; c <= maxCol - spanCols; c++) {
|
|
242
|
+
let fits = true;
|
|
243
|
+
for (let dr = 0; dr < spanRows && fits; dr++) {
|
|
244
|
+
for (let dc = 0; dc < spanCols && fits; dc++) {
|
|
245
|
+
if (isOccupied(occupiedCells, r + dr, c + dc)) fits = false;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
if (fits) {
|
|
249
|
+
if (needsColPlacement) {
|
|
250
|
+
item.colStart = c;
|
|
251
|
+
item.colEnd = c + spanCols;
|
|
252
|
+
}
|
|
253
|
+
if (needsRowPlacement) {
|
|
254
|
+
item.rowStart = r;
|
|
255
|
+
item.rowEnd = r + spanRows;
|
|
256
|
+
}
|
|
257
|
+
markOccupied(occupiedCells, item);
|
|
258
|
+
autoRow = r;
|
|
259
|
+
autoCol = item.colEnd;
|
|
260
|
+
if (autoCol >= maxCol) {
|
|
261
|
+
autoRow++;
|
|
262
|
+
autoCol = 0;
|
|
263
|
+
}
|
|
264
|
+
placed = true;
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
if (!placed) {
|
|
269
|
+
if (r >= maxRow) maxRow = r + 1;
|
|
270
|
+
autoCol = 0;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
} else {
|
|
274
|
+
let placed = false;
|
|
275
|
+
for (let c = needsColPlacement ? autoCol : item.colStart; !placed; c++) {
|
|
276
|
+
const startRow = c === autoCol && needsRowPlacement ? autoRow : 0;
|
|
277
|
+
for (let r = needsRowPlacement ? startRow : item.rowStart; r <= maxRow - spanRows; r++) {
|
|
278
|
+
let fits = true;
|
|
279
|
+
for (let dr = 0; dr < spanRows && fits; dr++) {
|
|
280
|
+
for (let dc = 0; dc < spanCols && fits; dc++) {
|
|
281
|
+
if (isOccupied(occupiedCells, r + dr, c + dc)) fits = false;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
if (fits) {
|
|
285
|
+
if (needsRowPlacement) {
|
|
286
|
+
item.rowStart = r;
|
|
287
|
+
item.rowEnd = r + spanRows;
|
|
288
|
+
}
|
|
289
|
+
if (needsColPlacement) {
|
|
290
|
+
item.colStart = c;
|
|
291
|
+
item.colEnd = c + spanCols;
|
|
292
|
+
}
|
|
293
|
+
markOccupied(occupiedCells, item);
|
|
294
|
+
autoCol = c;
|
|
295
|
+
autoRow = item.rowEnd;
|
|
296
|
+
if (autoRow >= maxRow) {
|
|
297
|
+
autoCol++;
|
|
298
|
+
autoRow = 0;
|
|
299
|
+
}
|
|
300
|
+
placed = true;
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
if (!placed) {
|
|
305
|
+
if (c >= maxCol) maxCol = c + 1;
|
|
306
|
+
autoRow = 0;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
if (item.colEnd > maxCol) maxCol = item.colEnd;
|
|
311
|
+
if (item.rowEnd > maxRow) maxRow = item.rowEnd;
|
|
312
|
+
}
|
|
313
|
+
return { totalCols: maxCol, totalRows: maxRow };
|
|
314
|
+
}
|
|
315
|
+
function resolveTrackSizes(tracks, availableSize, gap, items, axis, layoutFn) {
|
|
316
|
+
const sizes = new Array(tracks.length).fill(0);
|
|
317
|
+
const totalGap = gap * Math.max(0, tracks.length - 1);
|
|
318
|
+
let remainingSpace = availableSize - totalGap;
|
|
319
|
+
const frTracks = [];
|
|
320
|
+
let totalFr = 0;
|
|
321
|
+
for (let i = 0; i < tracks.length; i++) {
|
|
322
|
+
const t = tracks[i];
|
|
323
|
+
if (t.type === "px") {
|
|
324
|
+
sizes[i] = t.value;
|
|
325
|
+
remainingSpace -= t.value;
|
|
326
|
+
} else if (t.type === "percent") {
|
|
327
|
+
sizes[i] = t.value / 100 * availableSize;
|
|
328
|
+
remainingSpace -= sizes[i];
|
|
329
|
+
} else if (t.type === "fr") {
|
|
330
|
+
frTracks.push(i);
|
|
331
|
+
totalFr += t.value;
|
|
332
|
+
} else {
|
|
333
|
+
let maxContent = 0;
|
|
334
|
+
for (const item of items) {
|
|
335
|
+
const start = axis === "col" ? item.colStart : item.rowStart;
|
|
336
|
+
const end = axis === "col" ? item.colEnd : item.rowEnd;
|
|
337
|
+
if (start === i && end === i + 1) {
|
|
338
|
+
const childStyle = item.style;
|
|
339
|
+
const childPadding = resolvePadding(childStyle);
|
|
340
|
+
const childBorder = resolveBorder(childStyle);
|
|
341
|
+
if (axis === "col") {
|
|
342
|
+
const resolved = resolveSize(childStyle.width, availableSize);
|
|
343
|
+
if (resolved !== null) {
|
|
344
|
+
let w = resolved;
|
|
345
|
+
if (childStyle.boxSizing === "border-box") {
|
|
346
|
+
w = Math.max(0, w - horizontalInset(childPadding, childBorder));
|
|
347
|
+
}
|
|
348
|
+
maxContent = Math.max(maxContent, w + horizontalInset(childPadding, childBorder));
|
|
349
|
+
} else if (item.node.measure) {
|
|
350
|
+
const measured = item.node.measure(Infinity, Infinity);
|
|
351
|
+
maxContent = Math.max(maxContent, measured.width + horizontalInset(childPadding, childBorder));
|
|
352
|
+
} else if ((item.node.children ?? []).length > 0) {
|
|
353
|
+
const childLayout = layoutFn(item.node, Infinity, Infinity);
|
|
354
|
+
maxContent = Math.max(maxContent, childLayout.width);
|
|
355
|
+
}
|
|
356
|
+
} else {
|
|
357
|
+
const resolved = resolveSize(childStyle.height, availableSize);
|
|
358
|
+
if (resolved !== null) {
|
|
359
|
+
let h2 = resolved;
|
|
360
|
+
if (childStyle.boxSizing === "border-box") {
|
|
361
|
+
h2 = Math.max(0, h2 - verticalInset(childPadding, childBorder));
|
|
362
|
+
}
|
|
363
|
+
maxContent = Math.max(maxContent, h2 + verticalInset(childPadding, childBorder));
|
|
364
|
+
} else if (item.node.measure) {
|
|
365
|
+
const measured = item.node.measure(Infinity, Infinity);
|
|
366
|
+
maxContent = Math.max(maxContent, measured.height + verticalInset(childPadding, childBorder));
|
|
367
|
+
} else if ((item.node.children ?? []).length > 0) {
|
|
368
|
+
const childLayout = layoutFn(item.node, Infinity, Infinity);
|
|
369
|
+
maxContent = Math.max(maxContent, childLayout.height);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
sizes[i] = maxContent;
|
|
375
|
+
remainingSpace -= maxContent;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
if (frTracks.length > 0 && totalFr > 0) {
|
|
379
|
+
const frSpace = Math.max(0, remainingSpace);
|
|
380
|
+
for (const idx of frTracks) {
|
|
381
|
+
sizes[idx] = tracks[idx].value / totalFr * frSpace;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
return sizes;
|
|
385
|
+
}
|
|
386
|
+
function resolveJustifySelf(justifySelf, parentJustifyItems) {
|
|
387
|
+
return justifySelf === "auto" ? parentJustifyItems : justifySelf;
|
|
388
|
+
}
|
|
389
|
+
function resolveAlignSelf(alignSelf, parentAlignItems) {
|
|
390
|
+
return alignSelf === "auto" ? parentAlignItems : alignSelf;
|
|
391
|
+
}
|
|
392
|
+
function layoutGrid(node, availableWidth, availableHeight, layoutNodeFn) {
|
|
393
|
+
const style = resolveStyle(node.style);
|
|
394
|
+
const padding = resolvePadding(style);
|
|
395
|
+
const border = resolveBorder(style);
|
|
396
|
+
const hInset = horizontalInset(padding, border);
|
|
397
|
+
const vInset = verticalInset(padding, border);
|
|
398
|
+
let containerWidth = resolveSize(style.width, availableWidth);
|
|
399
|
+
let containerHeight = resolveSize(style.height, availableHeight);
|
|
400
|
+
if (style.boxSizing === "border-box") {
|
|
401
|
+
if (containerWidth !== null) containerWidth = Math.max(0, containerWidth - hInset);
|
|
402
|
+
if (containerHeight !== null) containerHeight = Math.max(0, containerHeight - vInset);
|
|
403
|
+
}
|
|
404
|
+
const contentWidth = containerWidth ?? Math.max(0, availableWidth - hInset);
|
|
405
|
+
const contentHeight = containerHeight ?? Math.max(0, availableHeight - vInset);
|
|
406
|
+
const containerMinW = resolveDimension(style.minWidth, availableWidth);
|
|
407
|
+
const containerMaxW = resolveDimension(style.maxWidth, availableWidth);
|
|
408
|
+
const containerMinH = resolveDimension(style.minHeight, availableHeight);
|
|
409
|
+
const containerMaxH = resolveDimension(style.maxHeight, availableHeight);
|
|
410
|
+
const children = node.children ?? [];
|
|
411
|
+
const absoluteChildren = [];
|
|
412
|
+
const flowEntries = [];
|
|
413
|
+
for (let i = 0; i < children.length; i++) {
|
|
414
|
+
const child = children[i];
|
|
415
|
+
const childStyle = resolveStyle(child.style);
|
|
416
|
+
const entry = { index: i, child, style: childStyle };
|
|
417
|
+
if (childStyle.position === "absolute") {
|
|
418
|
+
absoluteChildren.push(entry);
|
|
419
|
+
} else if (childStyle.display !== "none") {
|
|
420
|
+
flowEntries.push(entry);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
const gridItems = flowEntries.map((e) => ({
|
|
424
|
+
node: e.child,
|
|
425
|
+
style: e.style,
|
|
426
|
+
originalIndex: e.index,
|
|
427
|
+
colStart: -1,
|
|
428
|
+
colEnd: -1,
|
|
429
|
+
rowStart: -1,
|
|
430
|
+
rowEnd: -1
|
|
431
|
+
}));
|
|
432
|
+
const colTemplates = style.gridTemplateColumns.map(parseTrackSize);
|
|
433
|
+
const rowTemplates = style.gridTemplateRows.map(parseTrackSize);
|
|
434
|
+
const autoColTrack = parseTrackSize(style.gridAutoColumns);
|
|
435
|
+
const autoRowTrack = parseTrackSize(style.gridAutoRows);
|
|
436
|
+
const explicitCols = colTemplates.length;
|
|
437
|
+
const explicitRows = rowTemplates.length;
|
|
438
|
+
const { totalCols, totalRows } = placeItems(
|
|
439
|
+
gridItems,
|
|
440
|
+
Math.max(explicitCols, 1),
|
|
441
|
+
Math.max(explicitRows, 1),
|
|
442
|
+
style.gridAutoFlow
|
|
443
|
+
);
|
|
444
|
+
const allColTracks = [];
|
|
445
|
+
for (let i = 0; i < totalCols; i++) {
|
|
446
|
+
allColTracks.push(i < explicitCols ? colTemplates[i] : autoColTrack);
|
|
447
|
+
}
|
|
448
|
+
const allRowTracks = [];
|
|
449
|
+
for (let i = 0; i < totalRows; i++) {
|
|
450
|
+
allRowTracks.push(i < explicitRows ? rowTemplates[i] : autoRowTrack);
|
|
451
|
+
}
|
|
452
|
+
const colSizes = resolveTrackSizes(
|
|
453
|
+
allColTracks,
|
|
454
|
+
contentWidth,
|
|
455
|
+
style.columnGap,
|
|
456
|
+
gridItems,
|
|
457
|
+
"col",
|
|
458
|
+
layoutNodeFn
|
|
459
|
+
);
|
|
460
|
+
const rowSizes = resolveTrackSizes(
|
|
461
|
+
allRowTracks,
|
|
462
|
+
contentHeight,
|
|
463
|
+
style.rowGap,
|
|
464
|
+
gridItems,
|
|
465
|
+
"row",
|
|
466
|
+
layoutNodeFn
|
|
467
|
+
);
|
|
468
|
+
const colPositions = new Array(totalCols);
|
|
469
|
+
let pos = 0;
|
|
470
|
+
for (let i = 0; i < totalCols; i++) {
|
|
471
|
+
colPositions[i] = pos;
|
|
472
|
+
pos += colSizes[i] + (i < totalCols - 1 ? style.columnGap : 0);
|
|
473
|
+
}
|
|
474
|
+
const rowPositions = new Array(totalRows);
|
|
475
|
+
pos = 0;
|
|
476
|
+
for (let i = 0; i < totalRows; i++) {
|
|
477
|
+
rowPositions[i] = pos;
|
|
478
|
+
pos += rowSizes[i] + (i < totalRows - 1 ? style.rowGap : 0);
|
|
479
|
+
}
|
|
480
|
+
const tracksWidth = totalCols > 0 ? colPositions[totalCols - 1] + colSizes[totalCols - 1] : 0;
|
|
481
|
+
const tracksHeight = totalRows > 0 ? rowPositions[totalRows - 1] + rowSizes[totalRows - 1] : 0;
|
|
482
|
+
let finalWidth;
|
|
483
|
+
if (containerWidth !== null) {
|
|
484
|
+
finalWidth = containerWidth + hInset;
|
|
485
|
+
} else {
|
|
486
|
+
finalWidth = clamp(tracksWidth + hInset, containerMinW, containerMaxW);
|
|
487
|
+
}
|
|
488
|
+
let finalHeight;
|
|
489
|
+
if (containerHeight !== null) {
|
|
490
|
+
finalHeight = containerHeight + vInset;
|
|
491
|
+
} else {
|
|
492
|
+
finalHeight = clamp(tracksHeight + vInset, containerMinH, containerMaxH);
|
|
493
|
+
}
|
|
494
|
+
const usableWidth = finalWidth - hInset;
|
|
495
|
+
const usableHeight = finalHeight - vInset;
|
|
496
|
+
const justifyOffset = computeContentAlignment(
|
|
497
|
+
style.justifyContent,
|
|
498
|
+
tracksWidth,
|
|
499
|
+
usableWidth
|
|
500
|
+
);
|
|
501
|
+
const alignOffset = computeContentAlignment(
|
|
502
|
+
style.alignContent,
|
|
503
|
+
tracksHeight,
|
|
504
|
+
usableHeight
|
|
505
|
+
);
|
|
506
|
+
const childLayoutMap = /* @__PURE__ */ new Map();
|
|
507
|
+
for (const item of gridItems) {
|
|
508
|
+
let areaX = colPositions[item.colStart] + justifyOffset;
|
|
509
|
+
let areaY = rowPositions[item.rowStart] + alignOffset;
|
|
510
|
+
let areaW = 0;
|
|
511
|
+
for (let c = item.colStart; c < item.colEnd; c++) {
|
|
512
|
+
areaW += colSizes[c];
|
|
513
|
+
if (c > item.colStart) areaW += style.columnGap;
|
|
514
|
+
}
|
|
515
|
+
let areaH = 0;
|
|
516
|
+
for (let r = item.rowStart; r < item.rowEnd; r++) {
|
|
517
|
+
areaH += rowSizes[r];
|
|
518
|
+
if (r > item.rowStart) areaH += style.rowGap;
|
|
519
|
+
}
|
|
520
|
+
const childPadding = resolvePadding(item.style);
|
|
521
|
+
const childBorder = resolveBorder(item.style);
|
|
522
|
+
const childHInset = horizontalInset(childPadding, childBorder);
|
|
523
|
+
const childVInset = verticalInset(childPadding, childBorder);
|
|
524
|
+
let itemW = resolveSize(item.style.width, contentWidth);
|
|
525
|
+
let itemH = resolveSize(item.style.height, contentHeight);
|
|
526
|
+
if (item.style.boxSizing === "border-box") {
|
|
527
|
+
if (itemW !== null) itemW = Math.max(0, itemW - childHInset);
|
|
528
|
+
if (itemH !== null) itemH = Math.max(0, itemH - childVInset);
|
|
529
|
+
}
|
|
530
|
+
if (item.style.aspectRatio !== void 0) {
|
|
531
|
+
if (itemW !== null && itemH === null) {
|
|
532
|
+
itemH = itemW / item.style.aspectRatio;
|
|
533
|
+
} else if (itemH !== null && itemW === null) {
|
|
534
|
+
itemW = itemH * item.style.aspectRatio;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
const effectiveJustify = resolveJustifySelf(item.style.justifySelf, style.justifyItems);
|
|
538
|
+
const effectiveAlign = resolveAlignSelf(item.style.alignSelf, style.alignItems);
|
|
539
|
+
if (itemW === null) {
|
|
540
|
+
if (effectiveJustify === "stretch") {
|
|
541
|
+
itemW = Math.max(0, areaW - childHInset);
|
|
542
|
+
} else if (item.node.measure) {
|
|
543
|
+
const measured = item.node.measure(areaW, areaH);
|
|
544
|
+
itemW = measured.width;
|
|
545
|
+
} else if ((item.node.children ?? []).length > 0) {
|
|
546
|
+
const childLayout = layoutNodeFn(item.node, areaW, areaH);
|
|
547
|
+
itemW = Math.max(0, childLayout.width - childHInset);
|
|
548
|
+
} else {
|
|
549
|
+
itemW = Math.max(0, areaW - childHInset);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
if (itemH === null) {
|
|
553
|
+
if (effectiveAlign === "stretch") {
|
|
554
|
+
itemH = Math.max(0, areaH - childVInset);
|
|
555
|
+
} else if (item.node.measure) {
|
|
556
|
+
const measured = item.node.measure(itemW + childHInset, areaH);
|
|
557
|
+
itemH = measured.height;
|
|
558
|
+
} else if ((item.node.children ?? []).length > 0) {
|
|
559
|
+
const childLayout = layoutNodeFn(item.node, itemW + childHInset, areaH);
|
|
560
|
+
itemH = Math.max(0, childLayout.height - childVInset);
|
|
561
|
+
} else {
|
|
562
|
+
itemH = Math.max(0, areaH - childVInset);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
const minW = resolveDimension(item.style.minWidth, contentWidth);
|
|
566
|
+
const maxW = resolveDimension(item.style.maxWidth, contentWidth);
|
|
567
|
+
const minH = resolveDimension(item.style.minHeight, contentHeight);
|
|
568
|
+
const maxH = resolveDimension(item.style.maxHeight, contentHeight);
|
|
569
|
+
itemW = clamp(itemW, minW, maxW);
|
|
570
|
+
itemH = clamp(itemH, minH, maxH);
|
|
571
|
+
const outerW = itemW + childHInset;
|
|
572
|
+
const outerH = itemH + childVInset;
|
|
573
|
+
let itemX = padding.left + border.left + areaX;
|
|
574
|
+
let itemY = padding.top + border.top + areaY;
|
|
575
|
+
switch (effectiveJustify) {
|
|
576
|
+
case "start":
|
|
577
|
+
break;
|
|
578
|
+
case "end":
|
|
579
|
+
itemX += areaW - outerW;
|
|
580
|
+
break;
|
|
581
|
+
case "center":
|
|
582
|
+
itemX += (areaW - outerW) / 2;
|
|
583
|
+
break;
|
|
584
|
+
}
|
|
585
|
+
switch (effectiveAlign) {
|
|
586
|
+
case "flex-start":
|
|
587
|
+
break;
|
|
588
|
+
case "flex-end":
|
|
589
|
+
itemY += areaH - outerH;
|
|
590
|
+
break;
|
|
591
|
+
case "center":
|
|
592
|
+
itemY += (areaH - outerH) / 2;
|
|
593
|
+
break;
|
|
594
|
+
}
|
|
595
|
+
if (item.style.position === "relative") {
|
|
596
|
+
const insetTop = resolveInset(item.style.top, finalHeight);
|
|
597
|
+
const insetLeft = resolveInset(item.style.left, finalWidth);
|
|
598
|
+
const insetBottom = resolveInset(item.style.bottom, finalHeight);
|
|
599
|
+
const insetRight = resolveInset(item.style.right, finalWidth);
|
|
600
|
+
if (insetLeft !== null) itemX += insetLeft;
|
|
601
|
+
else if (insetRight !== null) itemX -= insetRight;
|
|
602
|
+
if (insetTop !== null) itemY += insetTop;
|
|
603
|
+
else if (insetBottom !== null) itemY -= insetBottom;
|
|
604
|
+
}
|
|
605
|
+
let itemChildLayouts = [];
|
|
606
|
+
if ((item.node.children ?? []).length > 0) {
|
|
607
|
+
const sizedNode = {
|
|
608
|
+
...item.node,
|
|
609
|
+
style: {
|
|
610
|
+
...item.node.style,
|
|
611
|
+
width: outerW,
|
|
612
|
+
height: outerH,
|
|
613
|
+
boxSizing: "border-box"
|
|
614
|
+
}
|
|
615
|
+
};
|
|
616
|
+
const innerLayout = layoutNodeFn(sizedNode, outerW, outerH);
|
|
617
|
+
itemChildLayouts = innerLayout.children;
|
|
618
|
+
}
|
|
619
|
+
childLayoutMap.set(item.originalIndex, {
|
|
620
|
+
x: itemX,
|
|
621
|
+
y: itemY,
|
|
622
|
+
width: outerW,
|
|
623
|
+
height: outerH,
|
|
624
|
+
children: itemChildLayouts
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
const cbWidth = finalWidth - border.left - border.right;
|
|
628
|
+
const cbHeight = finalHeight - border.top - border.bottom;
|
|
629
|
+
for (const { index, child, style: absStyle } of absoluteChildren) {
|
|
630
|
+
if (absStyle.display === "none") {
|
|
631
|
+
childLayoutMap.set(index, { x: 0, y: 0, width: 0, height: 0, children: [] });
|
|
632
|
+
continue;
|
|
633
|
+
}
|
|
634
|
+
const absPadding = resolvePadding(absStyle);
|
|
635
|
+
const absBorder = resolveBorder(absStyle);
|
|
636
|
+
const absHInset = horizontalInset(absPadding, absBorder);
|
|
637
|
+
const absVInset = verticalInset(absPadding, absBorder);
|
|
638
|
+
const insetTop = resolveInset(absStyle.top, cbHeight);
|
|
639
|
+
const insetRight = resolveInset(absStyle.right, cbWidth);
|
|
640
|
+
const insetBottom = resolveInset(absStyle.bottom, cbHeight);
|
|
641
|
+
const insetLeft = resolveInset(absStyle.left, cbWidth);
|
|
642
|
+
let absW = resolveSize(absStyle.width, cbWidth);
|
|
643
|
+
let absH = resolveSize(absStyle.height, cbHeight);
|
|
644
|
+
if (absStyle.boxSizing === "border-box") {
|
|
645
|
+
if (absW !== null) absW = Math.max(0, absW - absHInset);
|
|
646
|
+
if (absH !== null) absH = Math.max(0, absH - absVInset);
|
|
647
|
+
}
|
|
648
|
+
if (absW === null && insetLeft !== null && insetRight !== null) {
|
|
649
|
+
absW = Math.max(0, cbWidth - insetLeft - insetRight - absHInset);
|
|
650
|
+
}
|
|
651
|
+
if (absH === null && insetTop !== null && insetBottom !== null) {
|
|
652
|
+
absH = Math.max(0, cbHeight - insetTop - insetBottom - absVInset);
|
|
653
|
+
}
|
|
654
|
+
if (absStyle.aspectRatio !== void 0) {
|
|
655
|
+
if (absW !== null && absH === null) absH = absW / absStyle.aspectRatio;
|
|
656
|
+
else if (absH !== null && absW === null) absW = absH * absStyle.aspectRatio;
|
|
657
|
+
}
|
|
658
|
+
if (absW === null || absH === null) {
|
|
659
|
+
if (child.measure) {
|
|
660
|
+
const measured = child.measure(absW ?? cbWidth, absH ?? cbHeight);
|
|
661
|
+
if (absW === null) absW = measured.width;
|
|
662
|
+
if (absH === null) absH = measured.height;
|
|
663
|
+
} else if ((child.children ?? []).length > 0) {
|
|
664
|
+
const intrinsic = layoutNodeFn(child, absW !== null ? absW + absHInset : cbWidth, absH !== null ? absH + absVInset : cbHeight);
|
|
665
|
+
if (absW === null) absW = Math.max(0, intrinsic.width - absHInset);
|
|
666
|
+
if (absH === null) absH = Math.max(0, intrinsic.height - absVInset);
|
|
667
|
+
} else {
|
|
668
|
+
if (absW === null) absW = 0;
|
|
669
|
+
if (absH === null) absH = 0;
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
const absMinW = resolveDimension(absStyle.minWidth, cbWidth);
|
|
673
|
+
const absMaxW = resolveDimension(absStyle.maxWidth, cbWidth);
|
|
674
|
+
const absMinH = resolveDimension(absStyle.minHeight, cbHeight);
|
|
675
|
+
const absMaxH = resolveDimension(absStyle.maxHeight, cbHeight);
|
|
676
|
+
absW = clamp(absW, absMinW, absMaxW);
|
|
677
|
+
absH = clamp(absH, absMinH, absMaxH);
|
|
678
|
+
const absOuterW = absW + absHInset;
|
|
679
|
+
const absOuterH = absH + absVInset;
|
|
680
|
+
let absX = insetLeft !== null ? border.left + insetLeft : insetRight !== null ? border.left + cbWidth - insetRight - absOuterW : border.left;
|
|
681
|
+
let absY = insetTop !== null ? border.top + insetTop : insetBottom !== null ? border.top + cbHeight - insetBottom - absOuterH : border.top;
|
|
682
|
+
let absChildLayouts = [];
|
|
683
|
+
if ((child.children ?? []).length > 0) {
|
|
684
|
+
const innerLayout = layoutNodeFn(child, absOuterW, absOuterH);
|
|
685
|
+
absChildLayouts = innerLayout.children;
|
|
686
|
+
}
|
|
687
|
+
childLayoutMap.set(index, {
|
|
688
|
+
x: absX,
|
|
689
|
+
y: absY,
|
|
690
|
+
width: absOuterW,
|
|
691
|
+
height: absOuterH,
|
|
692
|
+
children: absChildLayouts
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
for (let i = 0; i < children.length; i++) {
|
|
696
|
+
if (!childLayoutMap.has(i)) {
|
|
697
|
+
const childStyle = resolveStyle(children[i].style);
|
|
698
|
+
if (childStyle.display === "none" && childStyle.position !== "absolute") {
|
|
699
|
+
childLayoutMap.set(i, { x: 0, y: 0, width: 0, height: 0, children: [] });
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
const childLayouts = [];
|
|
704
|
+
for (let i = 0; i < children.length; i++) {
|
|
705
|
+
const layout = childLayoutMap.get(i);
|
|
706
|
+
if (layout) childLayouts.push(layout);
|
|
707
|
+
}
|
|
708
|
+
return {
|
|
709
|
+
x: 0,
|
|
710
|
+
y: 0,
|
|
711
|
+
width: finalWidth,
|
|
712
|
+
height: finalHeight,
|
|
713
|
+
children: childLayouts
|
|
714
|
+
};
|
|
715
|
+
}
|
|
716
|
+
function computeContentAlignment(alignment, tracksSize, containerSize) {
|
|
717
|
+
const freeSpace = Math.max(0, containerSize - tracksSize);
|
|
718
|
+
switch (alignment) {
|
|
719
|
+
case "flex-start":
|
|
720
|
+
case "stretch":
|
|
721
|
+
return 0;
|
|
722
|
+
case "flex-end":
|
|
723
|
+
return freeSpace;
|
|
724
|
+
case "center":
|
|
725
|
+
return freeSpace / 2;
|
|
726
|
+
case "space-between":
|
|
727
|
+
case "space-around":
|
|
728
|
+
case "space-evenly":
|
|
729
|
+
return 0;
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
// src/layout.ts
|
|
734
|
+
function isRow(direction) {
|
|
735
|
+
return direction === "row" || direction === "row-reverse";
|
|
736
|
+
}
|
|
737
|
+
function mainAxisIsHorizontal(direction) {
|
|
738
|
+
return isRow(direction);
|
|
739
|
+
}
|
|
740
|
+
var layoutCache = null;
|
|
741
|
+
function computeLayout(node, availableWidth = Infinity, availableHeight = Infinity) {
|
|
742
|
+
layoutCache = /* @__PURE__ */ new Map();
|
|
743
|
+
const result = layoutNode(node, availableWidth, availableHeight);
|
|
744
|
+
layoutCache = null;
|
|
745
|
+
return result;
|
|
746
|
+
}
|
|
747
|
+
function layoutNode(node, availableWidth, availableHeight, definiteWidth, definiteHeight) {
|
|
748
|
+
if (layoutCache) {
|
|
749
|
+
const nodeCache = layoutCache.get(node);
|
|
750
|
+
if (nodeCache) {
|
|
751
|
+
const key = `${availableWidth},${availableHeight},${definiteWidth ?? ""},${definiteHeight ?? ""}`;
|
|
752
|
+
const cached = nodeCache.get(key);
|
|
753
|
+
if (cached) return cached;
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
const style = resolveStyle(node.style);
|
|
757
|
+
if (style.display === "none") {
|
|
758
|
+
return { x: 0, y: 0, width: 0, height: 0, children: [] };
|
|
759
|
+
}
|
|
760
|
+
if (style.display === "grid") {
|
|
761
|
+
const gridResult = layoutGrid(node, availableWidth, availableHeight, layoutNode);
|
|
762
|
+
if (layoutCache) {
|
|
763
|
+
let nodeCache = layoutCache.get(node);
|
|
764
|
+
if (!nodeCache) {
|
|
765
|
+
nodeCache = /* @__PURE__ */ new Map();
|
|
766
|
+
layoutCache.set(node, nodeCache);
|
|
767
|
+
}
|
|
768
|
+
const key = `${availableWidth},${availableHeight},${definiteWidth ?? ""},${definiteHeight ?? ""}`;
|
|
769
|
+
nodeCache.set(key, gridResult);
|
|
770
|
+
}
|
|
771
|
+
return gridResult;
|
|
772
|
+
}
|
|
773
|
+
const padding = resolvePadding(style);
|
|
774
|
+
const border = resolveBorder(style);
|
|
775
|
+
const hInset = horizontalInset(padding, border);
|
|
776
|
+
const vInset = verticalInset(padding, border);
|
|
777
|
+
let containerWidth = resolveSize(style.width, availableWidth);
|
|
778
|
+
let containerHeight = resolveSize(style.height, availableHeight);
|
|
779
|
+
if (containerWidth === null && definiteWidth !== void 0) {
|
|
780
|
+
containerWidth = Math.max(0, definiteWidth - hInset);
|
|
781
|
+
}
|
|
782
|
+
if (containerHeight === null && definiteHeight !== void 0) {
|
|
783
|
+
containerHeight = Math.max(0, definiteHeight - vInset);
|
|
784
|
+
}
|
|
785
|
+
if (style.boxSizing === "border-box") {
|
|
786
|
+
if (containerWidth !== null) containerWidth = Math.max(0, containerWidth - hInset);
|
|
787
|
+
if (containerHeight !== null) containerHeight = Math.max(0, containerHeight - vInset);
|
|
788
|
+
}
|
|
789
|
+
const horizontal = mainAxisIsHorizontal(style.flexDirection);
|
|
790
|
+
const mainSize = horizontal ? containerWidth : containerHeight;
|
|
791
|
+
const crossSize = horizontal ? containerHeight : containerWidth;
|
|
792
|
+
const availableMainForItems = mainSize ?? (horizontal ? availableWidth - hInset : availableHeight - vInset);
|
|
793
|
+
const availableCrossForItems = crossSize ?? (horizontal ? availableHeight - vInset : availableWidth - hInset);
|
|
794
|
+
const containerMinW = resolveDimension(style.minWidth, availableWidth);
|
|
795
|
+
const containerMaxW = resolveDimension(style.maxWidth, availableWidth);
|
|
796
|
+
const containerMinH = resolveDimension(style.minHeight, availableHeight);
|
|
797
|
+
const containerMaxH = resolveDimension(style.maxHeight, availableHeight);
|
|
798
|
+
const children = node.children ?? [];
|
|
799
|
+
const absoluteChildren = [];
|
|
800
|
+
const flowChildren = [];
|
|
801
|
+
for (let i = 0; i < children.length; i++) {
|
|
802
|
+
const child = children[i];
|
|
803
|
+
const childStyle = resolveStyle(child.style);
|
|
804
|
+
const entry = { index: i, child, style: childStyle };
|
|
805
|
+
if (childStyle.position === "absolute") {
|
|
806
|
+
absoluteChildren.push(entry);
|
|
807
|
+
} else {
|
|
808
|
+
flowChildren.push(entry);
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
const items = flowChildren.map(({ child, style: childStyle }) => {
|
|
812
|
+
const childPadding = resolvePadding(childStyle);
|
|
813
|
+
const childBorder = resolveBorder(childStyle);
|
|
814
|
+
return {
|
|
815
|
+
node: child,
|
|
816
|
+
style: childStyle,
|
|
817
|
+
padding: childPadding,
|
|
818
|
+
border: childBorder,
|
|
819
|
+
marginTop: resolveMargin(childStyle.marginTop, horizontal ? availableCrossForItems : availableMainForItems),
|
|
820
|
+
marginRight: resolveMargin(childStyle.marginRight, horizontal ? availableMainForItems : availableCrossForItems),
|
|
821
|
+
marginBottom: resolveMargin(childStyle.marginBottom, horizontal ? availableCrossForItems : availableMainForItems),
|
|
822
|
+
marginLeft: resolveMargin(childStyle.marginLeft, horizontal ? availableMainForItems : availableCrossForItems),
|
|
823
|
+
flexBaseSize: 0,
|
|
824
|
+
hypotheticalMainSize: 0,
|
|
825
|
+
targetMainSize: 0,
|
|
826
|
+
usedMainSize: 0,
|
|
827
|
+
hypotheticalCrossSize: 0,
|
|
828
|
+
usedCrossSize: 0,
|
|
829
|
+
minMainSize: horizontal ? resolveDimension(childStyle.minWidth, availableMainForItems) : resolveDimension(childStyle.minHeight, availableMainForItems),
|
|
830
|
+
maxMainSize: horizontal ? resolveDimension(childStyle.maxWidth, availableMainForItems) : resolveDimension(childStyle.maxHeight, availableMainForItems),
|
|
831
|
+
minCrossSize: horizontal ? resolveDimension(childStyle.minHeight, availableCrossForItems) : resolveDimension(childStyle.minWidth, availableCrossForItems),
|
|
832
|
+
maxCrossSize: horizontal ? resolveDimension(childStyle.maxHeight, availableCrossForItems) : resolveDimension(childStyle.maxWidth, availableCrossForItems),
|
|
833
|
+
mainPos: 0,
|
|
834
|
+
crossPos: 0,
|
|
835
|
+
frozen: false,
|
|
836
|
+
measure: child.measure,
|
|
837
|
+
children: child.children ?? []
|
|
838
|
+
};
|
|
839
|
+
});
|
|
840
|
+
const hiddenFlowIndices = [];
|
|
841
|
+
const visibleItems = [];
|
|
842
|
+
for (let i = 0; i < items.length; i++) {
|
|
843
|
+
if (items[i].style.display === "none") {
|
|
844
|
+
hiddenFlowIndices.push(flowChildren[i].index);
|
|
845
|
+
} else {
|
|
846
|
+
visibleItems.push(items[i]);
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
for (const item of visibleItems) {
|
|
850
|
+
const childHInset = horizontalInset(item.padding, item.border);
|
|
851
|
+
const childVInset = verticalInset(item.padding, item.border);
|
|
852
|
+
const mainInset = horizontal ? childHInset : childVInset;
|
|
853
|
+
let baseSize;
|
|
854
|
+
if (item.style.flexBasis !== "auto") {
|
|
855
|
+
baseSize = item.style.flexBasis;
|
|
856
|
+
if (item.style.boxSizing === "border-box") {
|
|
857
|
+
baseSize = Math.max(0, baseSize - mainInset);
|
|
858
|
+
}
|
|
859
|
+
} else {
|
|
860
|
+
const mainSizeValue = horizontal ? item.style.width : item.style.height;
|
|
861
|
+
const resolved = resolveSize(mainSizeValue, availableMainForItems);
|
|
862
|
+
if (resolved !== null) {
|
|
863
|
+
baseSize = resolved;
|
|
864
|
+
if (item.style.boxSizing === "border-box") {
|
|
865
|
+
baseSize = Math.max(0, baseSize - mainInset);
|
|
866
|
+
}
|
|
867
|
+
} else if (item.style.aspectRatio !== void 0) {
|
|
868
|
+
const crossSizeValue = horizontal ? item.style.height : item.style.width;
|
|
869
|
+
const crossInset = horizontal ? childVInset : childHInset;
|
|
870
|
+
const resolvedCross = resolveSize(crossSizeValue, availableCrossForItems);
|
|
871
|
+
if (resolvedCross !== null) {
|
|
872
|
+
let cs = resolvedCross;
|
|
873
|
+
if (item.style.boxSizing === "border-box") {
|
|
874
|
+
cs = Math.max(0, cs - crossInset);
|
|
875
|
+
}
|
|
876
|
+
baseSize = horizontal ? cs * item.style.aspectRatio : cs / item.style.aspectRatio;
|
|
877
|
+
} else {
|
|
878
|
+
baseSize = 0;
|
|
879
|
+
}
|
|
880
|
+
} else if (item.measure) {
|
|
881
|
+
const measured = item.measure(
|
|
882
|
+
horizontal ? availableMainForItems : availableCrossForItems,
|
|
883
|
+
horizontal ? availableCrossForItems : availableMainForItems
|
|
884
|
+
);
|
|
885
|
+
baseSize = horizontal ? measured.width : measured.height;
|
|
886
|
+
} else if (item.children.length > 0 && item.style.display === "flex") {
|
|
887
|
+
const childLayout = layoutNode(
|
|
888
|
+
item.node,
|
|
889
|
+
horizontal ? Infinity : availableCrossForItems + childHInset,
|
|
890
|
+
horizontal ? availableCrossForItems + childVInset : Infinity
|
|
891
|
+
);
|
|
892
|
+
baseSize = horizontal ? Math.max(0, childLayout.width - childHInset) : Math.max(0, childLayout.height - childVInset);
|
|
893
|
+
} else {
|
|
894
|
+
baseSize = 0;
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
item.flexBaseSize = baseSize;
|
|
898
|
+
item.hypotheticalMainSize = Math.max(
|
|
899
|
+
0,
|
|
900
|
+
clamp(baseSize, item.minMainSize, item.maxMainSize)
|
|
901
|
+
);
|
|
902
|
+
}
|
|
903
|
+
const lines = [];
|
|
904
|
+
const mainGap = horizontal ? style.columnGap : style.rowGap;
|
|
905
|
+
const crossGap = horizontal ? style.rowGap : style.columnGap;
|
|
906
|
+
if (style.flexWrap === "nowrap" || visibleItems.length === 0) {
|
|
907
|
+
lines.push({ items: visibleItems, crossSize: 0, crossOffset: 0 });
|
|
908
|
+
} else {
|
|
909
|
+
let currentLine = [];
|
|
910
|
+
let lineMainSize = 0;
|
|
911
|
+
for (const item of visibleItems) {
|
|
912
|
+
const outerHypo = item.hypotheticalMainSize + outerMainAll(item, horizontal);
|
|
913
|
+
const gapSize = currentLine.length > 0 ? mainGap : 0;
|
|
914
|
+
if (currentLine.length > 0 && lineMainSize + gapSize + outerHypo > availableMainForItems) {
|
|
915
|
+
lines.push({ items: currentLine, crossSize: 0, crossOffset: 0 });
|
|
916
|
+
currentLine = [item];
|
|
917
|
+
lineMainSize = outerHypo;
|
|
918
|
+
} else {
|
|
919
|
+
currentLine.push(item);
|
|
920
|
+
lineMainSize += gapSize + outerHypo;
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
if (currentLine.length > 0) {
|
|
924
|
+
lines.push({ items: currentLine, crossSize: 0, crossOffset: 0 });
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
if (style.flexWrap === "wrap-reverse") {
|
|
928
|
+
lines.reverse();
|
|
929
|
+
}
|
|
930
|
+
for (const line of lines) {
|
|
931
|
+
resolveFlexibleLengths(line.items, availableMainForItems, mainGap, horizontal);
|
|
932
|
+
}
|
|
933
|
+
for (const line of lines) {
|
|
934
|
+
for (const item of line.items) {
|
|
935
|
+
const childHInset = horizontalInset(item.padding, item.border);
|
|
936
|
+
const childVInset = verticalInset(item.padding, item.border);
|
|
937
|
+
const crossInset = horizontal ? childVInset : childHInset;
|
|
938
|
+
const crossSizeValue = horizontal ? item.style.height : item.style.width;
|
|
939
|
+
const resolvedCross = resolveSize(crossSizeValue, availableCrossForItems);
|
|
940
|
+
if (resolvedCross !== null) {
|
|
941
|
+
let cs = resolvedCross;
|
|
942
|
+
if (item.style.boxSizing === "border-box") {
|
|
943
|
+
cs = Math.max(0, cs - crossInset);
|
|
944
|
+
}
|
|
945
|
+
item.hypotheticalCrossSize = cs;
|
|
946
|
+
} else if (item.style.aspectRatio !== void 0) {
|
|
947
|
+
item.hypotheticalCrossSize = horizontal ? item.usedMainSize / item.style.aspectRatio : item.usedMainSize * item.style.aspectRatio;
|
|
948
|
+
} else if (item.measure) {
|
|
949
|
+
const measured = item.measure(
|
|
950
|
+
horizontal ? item.usedMainSize : availableCrossForItems,
|
|
951
|
+
horizontal ? availableCrossForItems : item.usedMainSize
|
|
952
|
+
);
|
|
953
|
+
item.hypotheticalCrossSize = horizontal ? measured.height : measured.width;
|
|
954
|
+
} else if (item.children.length > 0 && item.style.display === "flex") {
|
|
955
|
+
const childLayout = layoutNode(
|
|
956
|
+
item.node,
|
|
957
|
+
horizontal ? item.usedMainSize + childHInset : availableCrossForItems + childHInset,
|
|
958
|
+
horizontal ? availableCrossForItems + childVInset : item.usedMainSize + childVInset
|
|
959
|
+
);
|
|
960
|
+
item.hypotheticalCrossSize = horizontal ? Math.max(0, childLayout.height - childVInset) : Math.max(0, childLayout.width - childHInset);
|
|
961
|
+
} else {
|
|
962
|
+
item.hypotheticalCrossSize = 0;
|
|
963
|
+
}
|
|
964
|
+
item.hypotheticalCrossSize = Math.max(
|
|
965
|
+
0,
|
|
966
|
+
clamp(item.hypotheticalCrossSize, item.minCrossSize, item.maxCrossSize)
|
|
967
|
+
);
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
const isSingleLine = style.flexWrap === "nowrap";
|
|
971
|
+
if (isSingleLine && crossSize !== null) {
|
|
972
|
+
lines[0].crossSize = crossSize;
|
|
973
|
+
} else {
|
|
974
|
+
for (const line of lines) {
|
|
975
|
+
let maxCross = 0;
|
|
976
|
+
for (const item of line.items) {
|
|
977
|
+
const outerCross = item.hypotheticalCrossSize + outerCrossAll(item, horizontal);
|
|
978
|
+
if (outerCross > maxCross) maxCross = outerCross;
|
|
979
|
+
}
|
|
980
|
+
line.crossSize = maxCross;
|
|
981
|
+
}
|
|
982
|
+
if (isSingleLine && lines[0]) {
|
|
983
|
+
const minCross = horizontal ? Math.max(0, containerMinH - vInset) : Math.max(0, containerMinW - hInset);
|
|
984
|
+
const maxCross = horizontal ? Math.max(0, containerMaxH - vInset) : Math.max(0, containerMaxW - hInset);
|
|
985
|
+
lines[0].crossSize = clamp(lines[0].crossSize, minCross, maxCross);
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
for (const line of lines) {
|
|
989
|
+
for (const item of line.items) {
|
|
990
|
+
const effectiveAlign = resolveAlignSelf2(item.style.alignSelf, style.alignItems);
|
|
991
|
+
if (effectiveAlign === "stretch" && item.style.aspectRatio === void 0 && (horizontal ? item.style.height : item.style.width) === "auto" && item.marginTop !== null && item.marginBottom !== null && (horizontal ? item.marginTop : item.marginLeft) !== null && (horizontal ? item.marginBottom : item.marginRight) !== null) {
|
|
992
|
+
const crossMargin = outerCrossMargin(item, horizontal);
|
|
993
|
+
const crossInset = horizontal ? verticalInset(item.padding, item.border) : horizontalInset(item.padding, item.border);
|
|
994
|
+
item.usedCrossSize = clamp(
|
|
995
|
+
line.crossSize - crossMargin - crossInset,
|
|
996
|
+
item.minCrossSize,
|
|
997
|
+
item.maxCrossSize
|
|
998
|
+
);
|
|
999
|
+
} else {
|
|
1000
|
+
item.usedCrossSize = item.hypotheticalCrossSize;
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
for (const line of lines) {
|
|
1005
|
+
alignMainAxis(line.items, availableMainForItems, style.justifyContent, mainGap, horizontal);
|
|
1006
|
+
}
|
|
1007
|
+
for (const line of lines) {
|
|
1008
|
+
for (const item of line.items) {
|
|
1009
|
+
const effectiveAlign = resolveAlignSelf2(item.style.alignSelf, style.alignItems);
|
|
1010
|
+
const outerCross = item.usedCrossSize + outerCrossAll(item, horizontal);
|
|
1011
|
+
const freeSpace = line.crossSize - outerCross;
|
|
1012
|
+
const crossStartMarginAuto = horizontal ? item.marginTop === null : item.marginLeft === null;
|
|
1013
|
+
const crossEndMarginAuto = horizontal ? item.marginBottom === null : item.marginRight === null;
|
|
1014
|
+
if (crossStartMarginAuto || crossEndMarginAuto) {
|
|
1015
|
+
if (crossStartMarginAuto && crossEndMarginAuto) {
|
|
1016
|
+
const half = Math.max(0, freeSpace) / 2;
|
|
1017
|
+
if (horizontal) {
|
|
1018
|
+
item.marginTop = half;
|
|
1019
|
+
item.marginBottom = half;
|
|
1020
|
+
} else {
|
|
1021
|
+
item.marginLeft = half;
|
|
1022
|
+
item.marginRight = half;
|
|
1023
|
+
}
|
|
1024
|
+
} else if (crossStartMarginAuto) {
|
|
1025
|
+
if (horizontal) item.marginTop = Math.max(0, freeSpace);
|
|
1026
|
+
else item.marginLeft = Math.max(0, freeSpace);
|
|
1027
|
+
} else {
|
|
1028
|
+
if (horizontal) item.marginBottom = Math.max(0, freeSpace);
|
|
1029
|
+
else item.marginRight = Math.max(0, freeSpace);
|
|
1030
|
+
}
|
|
1031
|
+
item.crossPos = crossStartMarginValue(item, horizontal);
|
|
1032
|
+
} else {
|
|
1033
|
+
const crossStartM = crossStartMarginValue(item, horizontal);
|
|
1034
|
+
switch (effectiveAlign) {
|
|
1035
|
+
case "flex-start":
|
|
1036
|
+
item.crossPos = crossStartM;
|
|
1037
|
+
break;
|
|
1038
|
+
case "flex-end": {
|
|
1039
|
+
const ci = horizontal ? verticalInset(item.padding, item.border) : horizontalInset(item.padding, item.border);
|
|
1040
|
+
item.crossPos = line.crossSize - item.usedCrossSize - ci - crossEndMarginValue(item, horizontal);
|
|
1041
|
+
break;
|
|
1042
|
+
}
|
|
1043
|
+
case "center": {
|
|
1044
|
+
item.crossPos = crossStartM + freeSpace / 2;
|
|
1045
|
+
break;
|
|
1046
|
+
}
|
|
1047
|
+
case "stretch":
|
|
1048
|
+
item.crossPos = crossStartM;
|
|
1049
|
+
break;
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
let totalCrossSize;
|
|
1055
|
+
if (crossSize !== null) {
|
|
1056
|
+
totalCrossSize = crossSize;
|
|
1057
|
+
} else {
|
|
1058
|
+
totalCrossSize = 0;
|
|
1059
|
+
for (let i = 0; i < lines.length; i++) {
|
|
1060
|
+
totalCrossSize += lines[i].crossSize;
|
|
1061
|
+
if (i < lines.length - 1) totalCrossSize += crossGap;
|
|
1062
|
+
}
|
|
1063
|
+
const minCross = horizontal ? Math.max(0, containerMinH - vInset) : Math.max(0, containerMinW - hInset);
|
|
1064
|
+
const maxCross = horizontal ? Math.max(0, containerMaxH - vInset) : Math.max(0, containerMaxW - hInset);
|
|
1065
|
+
totalCrossSize = clamp(totalCrossSize, minCross, maxCross);
|
|
1066
|
+
}
|
|
1067
|
+
alignCrossLines(lines, totalCrossSize, style.alignContent, crossGap);
|
|
1068
|
+
let usedMainSize;
|
|
1069
|
+
if (mainSize !== null) {
|
|
1070
|
+
usedMainSize = mainSize;
|
|
1071
|
+
} else {
|
|
1072
|
+
usedMainSize = 0;
|
|
1073
|
+
for (const line of lines) {
|
|
1074
|
+
let lineSize = 0;
|
|
1075
|
+
for (let i = 0; i < line.items.length; i++) {
|
|
1076
|
+
const it = line.items[i];
|
|
1077
|
+
lineSize += it.usedMainSize + outerMainAll(it, horizontal);
|
|
1078
|
+
if (i < line.items.length - 1) lineSize += mainGap;
|
|
1079
|
+
}
|
|
1080
|
+
if (lineSize > usedMainSize) usedMainSize = lineSize;
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
const contentWidth = horizontal ? usedMainSize : totalCrossSize;
|
|
1084
|
+
const contentHeight = horizontal ? totalCrossSize : usedMainSize;
|
|
1085
|
+
let finalWidth;
|
|
1086
|
+
let finalHeight;
|
|
1087
|
+
if (containerWidth !== null) {
|
|
1088
|
+
finalWidth = containerWidth + hInset;
|
|
1089
|
+
} else {
|
|
1090
|
+
finalWidth = clamp(contentWidth + hInset, containerMinW, containerMaxW);
|
|
1091
|
+
}
|
|
1092
|
+
if (containerHeight !== null) {
|
|
1093
|
+
finalHeight = containerHeight + vInset;
|
|
1094
|
+
} else {
|
|
1095
|
+
finalHeight = clamp(contentHeight + vInset, containerMinH, containerMaxH);
|
|
1096
|
+
}
|
|
1097
|
+
const childLayoutMap = /* @__PURE__ */ new Map();
|
|
1098
|
+
const itemToOriginalIndex = /* @__PURE__ */ new Map();
|
|
1099
|
+
for (let i = 0; i < items.length; i++) {
|
|
1100
|
+
itemToOriginalIndex.set(items[i], flowChildren[i].index);
|
|
1101
|
+
}
|
|
1102
|
+
for (const line of lines) {
|
|
1103
|
+
for (const item of line.items) {
|
|
1104
|
+
const mainOffset = horizontal ? padding.left + border.left : padding.top + border.top;
|
|
1105
|
+
const crossOffset = horizontal ? padding.top + border.top : padding.left + border.left;
|
|
1106
|
+
let itemX = horizontal ? mainOffset + item.mainPos : crossOffset + line.crossOffset + item.crossPos;
|
|
1107
|
+
let itemY = horizontal ? crossOffset + line.crossOffset + item.crossPos : mainOffset + item.mainPos;
|
|
1108
|
+
const itemW = horizontal ? item.usedMainSize : item.usedCrossSize;
|
|
1109
|
+
const itemH = horizontal ? item.usedCrossSize : item.usedMainSize;
|
|
1110
|
+
const itemOuterW = itemW + horizontalInset(item.padding, item.border);
|
|
1111
|
+
const itemOuterH = itemH + verticalInset(item.padding, item.border);
|
|
1112
|
+
if (item.style.position === "relative") {
|
|
1113
|
+
const insetTop = resolveInset(item.style.top, finalHeight);
|
|
1114
|
+
const insetLeft = resolveInset(item.style.left, finalWidth);
|
|
1115
|
+
const insetBottom = resolveInset(item.style.bottom, finalHeight);
|
|
1116
|
+
const insetRight = resolveInset(item.style.right, finalWidth);
|
|
1117
|
+
if (insetLeft !== null) {
|
|
1118
|
+
itemX += insetLeft;
|
|
1119
|
+
} else if (insetRight !== null) {
|
|
1120
|
+
itemX -= insetRight;
|
|
1121
|
+
}
|
|
1122
|
+
if (insetTop !== null) {
|
|
1123
|
+
itemY += insetTop;
|
|
1124
|
+
} else if (insetBottom !== null) {
|
|
1125
|
+
itemY -= insetBottom;
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
let itemChildLayouts = [];
|
|
1129
|
+
if (item.children.length > 0 && item.style.display === "flex") {
|
|
1130
|
+
const innerLayout = layoutNode(item.node, itemOuterW, itemOuterH, itemOuterW, itemOuterH);
|
|
1131
|
+
itemChildLayouts = innerLayout.children;
|
|
1132
|
+
}
|
|
1133
|
+
const originalIndex = itemToOriginalIndex.get(item);
|
|
1134
|
+
childLayoutMap.set(originalIndex, {
|
|
1135
|
+
x: itemX,
|
|
1136
|
+
y: itemY,
|
|
1137
|
+
width: itemOuterW,
|
|
1138
|
+
height: itemOuterH,
|
|
1139
|
+
children: itemChildLayouts
|
|
1140
|
+
});
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
const cbWidth = finalWidth - border.left - border.right;
|
|
1144
|
+
const cbHeight = finalHeight - border.top - border.bottom;
|
|
1145
|
+
for (const { index, child, style: absStyle } of absoluteChildren) {
|
|
1146
|
+
if (absStyle.display === "none") {
|
|
1147
|
+
childLayoutMap.set(index, { x: 0, y: 0, width: 0, height: 0, children: [] });
|
|
1148
|
+
continue;
|
|
1149
|
+
}
|
|
1150
|
+
const absPadding = resolvePadding(absStyle);
|
|
1151
|
+
const absBorder = resolveBorder(absStyle);
|
|
1152
|
+
const absHInset = horizontalInset(absPadding, absBorder);
|
|
1153
|
+
const absVInset = verticalInset(absPadding, absBorder);
|
|
1154
|
+
const insetTop = resolveInset(absStyle.top, cbHeight);
|
|
1155
|
+
const insetRight = resolveInset(absStyle.right, cbWidth);
|
|
1156
|
+
const insetBottom = resolveInset(absStyle.bottom, cbHeight);
|
|
1157
|
+
const insetLeft = resolveInset(absStyle.left, cbWidth);
|
|
1158
|
+
let absW = resolveSize(absStyle.width, cbWidth);
|
|
1159
|
+
let absH = resolveSize(absStyle.height, cbHeight);
|
|
1160
|
+
if (absStyle.boxSizing === "border-box") {
|
|
1161
|
+
if (absW !== null) absW = Math.max(0, absW - absHInset);
|
|
1162
|
+
if (absH !== null) absH = Math.max(0, absH - absVInset);
|
|
1163
|
+
}
|
|
1164
|
+
if (absW === null && insetLeft !== null && insetRight !== null) {
|
|
1165
|
+
absW = Math.max(0, cbWidth - insetLeft - insetRight - absHInset);
|
|
1166
|
+
}
|
|
1167
|
+
if (absH === null && insetTop !== null && insetBottom !== null) {
|
|
1168
|
+
absH = Math.max(0, cbHeight - insetTop - insetBottom - absVInset);
|
|
1169
|
+
}
|
|
1170
|
+
if (absStyle.aspectRatio !== void 0) {
|
|
1171
|
+
if (absW !== null && absH === null) {
|
|
1172
|
+
absH = absW / absStyle.aspectRatio;
|
|
1173
|
+
} else if (absH !== null && absW === null) {
|
|
1174
|
+
absW = absH * absStyle.aspectRatio;
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
if (absW === null || absH === null) {
|
|
1178
|
+
if (child.measure) {
|
|
1179
|
+
const measured = child.measure(absW ?? cbWidth, absH ?? cbHeight);
|
|
1180
|
+
if (absW === null) absW = measured.width;
|
|
1181
|
+
if (absH === null) absH = measured.height;
|
|
1182
|
+
} else if ((child.children ?? []).length > 0 && absStyle.display === "flex") {
|
|
1183
|
+
const intrinsic = layoutNode(
|
|
1184
|
+
child,
|
|
1185
|
+
absW !== null ? absW + absHInset : cbWidth,
|
|
1186
|
+
absH !== null ? absH + absVInset : cbHeight
|
|
1187
|
+
);
|
|
1188
|
+
if (absW === null) absW = Math.max(0, intrinsic.width - absHInset);
|
|
1189
|
+
if (absH === null) absH = Math.max(0, intrinsic.height - absVInset);
|
|
1190
|
+
} else {
|
|
1191
|
+
if (absW === null) absW = 0;
|
|
1192
|
+
if (absH === null) absH = 0;
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
const absMinW = resolveDimension(absStyle.minWidth, cbWidth);
|
|
1196
|
+
const absMaxW = resolveDimension(absStyle.maxWidth, cbWidth);
|
|
1197
|
+
const absMinH = resolveDimension(absStyle.minHeight, cbHeight);
|
|
1198
|
+
const absMaxH = resolveDimension(absStyle.maxHeight, cbHeight);
|
|
1199
|
+
absW = clamp(absW, absMinW, absMaxW);
|
|
1200
|
+
absH = clamp(absH, absMinH, absMaxH);
|
|
1201
|
+
const absOuterW = absW + absHInset;
|
|
1202
|
+
const absOuterH = absH + absVInset;
|
|
1203
|
+
let absX;
|
|
1204
|
+
if (insetLeft !== null) {
|
|
1205
|
+
absX = border.left + insetLeft;
|
|
1206
|
+
} else if (insetRight !== null) {
|
|
1207
|
+
absX = border.left + cbWidth - insetRight - absOuterW;
|
|
1208
|
+
} else {
|
|
1209
|
+
absX = border.left;
|
|
1210
|
+
}
|
|
1211
|
+
let absY;
|
|
1212
|
+
if (insetTop !== null) {
|
|
1213
|
+
absY = border.top + insetTop;
|
|
1214
|
+
} else if (insetBottom !== null) {
|
|
1215
|
+
absY = border.top + cbHeight - insetBottom - absOuterH;
|
|
1216
|
+
} else {
|
|
1217
|
+
absY = border.top;
|
|
1218
|
+
}
|
|
1219
|
+
let absChildLayouts = [];
|
|
1220
|
+
if ((child.children ?? []).length > 0 && absStyle.display === "flex") {
|
|
1221
|
+
const innerLayout = layoutNode(child, absOuterW, absOuterH);
|
|
1222
|
+
absChildLayouts = innerLayout.children;
|
|
1223
|
+
}
|
|
1224
|
+
childLayoutMap.set(index, {
|
|
1225
|
+
x: absX,
|
|
1226
|
+
y: absY,
|
|
1227
|
+
width: absOuterW,
|
|
1228
|
+
height: absOuterH,
|
|
1229
|
+
children: absChildLayouts
|
|
1230
|
+
});
|
|
1231
|
+
}
|
|
1232
|
+
for (const hiddenIdx of hiddenFlowIndices) {
|
|
1233
|
+
childLayoutMap.set(hiddenIdx, { x: 0, y: 0, width: 0, height: 0, children: [] });
|
|
1234
|
+
}
|
|
1235
|
+
const childLayouts = [];
|
|
1236
|
+
for (let i = 0; i < children.length; i++) {
|
|
1237
|
+
const layout = childLayoutMap.get(i);
|
|
1238
|
+
if (layout) childLayouts.push(layout);
|
|
1239
|
+
}
|
|
1240
|
+
const result = {
|
|
1241
|
+
x: 0,
|
|
1242
|
+
y: 0,
|
|
1243
|
+
width: finalWidth,
|
|
1244
|
+
height: finalHeight,
|
|
1245
|
+
children: childLayouts
|
|
1246
|
+
};
|
|
1247
|
+
if (layoutCache) {
|
|
1248
|
+
let nodeCache = layoutCache.get(node);
|
|
1249
|
+
if (!nodeCache) {
|
|
1250
|
+
nodeCache = /* @__PURE__ */ new Map();
|
|
1251
|
+
layoutCache.set(node, nodeCache);
|
|
1252
|
+
}
|
|
1253
|
+
nodeCache.set(`${availableWidth},${availableHeight},${definiteWidth ?? ""},${definiteHeight ?? ""}`, result);
|
|
1254
|
+
}
|
|
1255
|
+
return result;
|
|
1256
|
+
}
|
|
1257
|
+
function resolveFlexibleLengths(items, availableMain, gap, horizontal) {
|
|
1258
|
+
if (items.length === 0) return;
|
|
1259
|
+
if (!isFinite(availableMain)) {
|
|
1260
|
+
for (const item of items) {
|
|
1261
|
+
item.usedMainSize = Math.max(0, item.hypotheticalMainSize);
|
|
1262
|
+
}
|
|
1263
|
+
return;
|
|
1264
|
+
}
|
|
1265
|
+
const totalGap = gap * (items.length - 1);
|
|
1266
|
+
for (const item of items) {
|
|
1267
|
+
item.targetMainSize = item.flexBaseSize;
|
|
1268
|
+
item.frozen = false;
|
|
1269
|
+
}
|
|
1270
|
+
let usedByHypothetical = totalGap;
|
|
1271
|
+
for (const item of items) {
|
|
1272
|
+
usedByHypothetical += item.hypotheticalMainSize + outerMainAll(item, horizontal);
|
|
1273
|
+
}
|
|
1274
|
+
const growing = usedByHypothetical < availableMain;
|
|
1275
|
+
for (const item of items) {
|
|
1276
|
+
const factor = growing ? item.style.flexGrow : item.style.flexShrink;
|
|
1277
|
+
if (factor === 0) {
|
|
1278
|
+
item.targetMainSize = item.hypotheticalMainSize;
|
|
1279
|
+
item.frozen = true;
|
|
1280
|
+
} else if (growing && item.flexBaseSize > item.hypotheticalMainSize) {
|
|
1281
|
+
item.targetMainSize = item.hypotheticalMainSize;
|
|
1282
|
+
item.frozen = true;
|
|
1283
|
+
} else if (!growing && item.flexBaseSize < item.hypotheticalMainSize) {
|
|
1284
|
+
item.targetMainSize = item.hypotheticalMainSize;
|
|
1285
|
+
item.frozen = true;
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
let initialFreeSpace = availableMain - totalGap;
|
|
1289
|
+
for (const item of items) {
|
|
1290
|
+
if (item.frozen) {
|
|
1291
|
+
initialFreeSpace -= item.targetMainSize + outerMainAll(item, horizontal);
|
|
1292
|
+
} else {
|
|
1293
|
+
initialFreeSpace -= item.flexBaseSize + outerMainAll(item, horizontal);
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
for (let iteration = 0; iteration < 100; iteration++) {
|
|
1297
|
+
const unfrozen = items.filter((i) => !i.frozen);
|
|
1298
|
+
if (unfrozen.length === 0) break;
|
|
1299
|
+
let remainingFreeSpace = availableMain - totalGap;
|
|
1300
|
+
for (const item of items) {
|
|
1301
|
+
if (item.frozen) {
|
|
1302
|
+
remainingFreeSpace -= item.targetMainSize + outerMainAll(item, horizontal);
|
|
1303
|
+
} else {
|
|
1304
|
+
remainingFreeSpace -= item.flexBaseSize + outerMainAll(item, horizontal);
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
let sumFlexFactors = 0;
|
|
1308
|
+
for (const item of unfrozen) {
|
|
1309
|
+
sumFlexFactors += growing ? item.style.flexGrow : item.style.flexShrink;
|
|
1310
|
+
}
|
|
1311
|
+
if (sumFlexFactors < 1 && sumFlexFactors > 0) {
|
|
1312
|
+
const scaled = initialFreeSpace * sumFlexFactors;
|
|
1313
|
+
if (Math.abs(scaled) < Math.abs(remainingFreeSpace)) {
|
|
1314
|
+
remainingFreeSpace = scaled;
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
if (remainingFreeSpace !== 0) {
|
|
1318
|
+
if (growing) {
|
|
1319
|
+
let totalGrowth = 0;
|
|
1320
|
+
for (const item of unfrozen) totalGrowth += item.style.flexGrow;
|
|
1321
|
+
if (totalGrowth > 0) {
|
|
1322
|
+
for (const item of unfrozen) {
|
|
1323
|
+
const ratio = item.style.flexGrow / totalGrowth;
|
|
1324
|
+
item.targetMainSize = item.flexBaseSize + remainingFreeSpace * ratio;
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
} else {
|
|
1328
|
+
let totalScaledShrink = 0;
|
|
1329
|
+
for (const item of unfrozen) {
|
|
1330
|
+
totalScaledShrink += item.style.flexShrink * item.flexBaseSize;
|
|
1331
|
+
}
|
|
1332
|
+
if (totalScaledShrink > 0) {
|
|
1333
|
+
for (const item of unfrozen) {
|
|
1334
|
+
const scaledFactor = item.style.flexShrink * item.flexBaseSize;
|
|
1335
|
+
const ratio = scaledFactor / totalScaledShrink;
|
|
1336
|
+
item.targetMainSize = item.flexBaseSize - Math.abs(remainingFreeSpace) * ratio;
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
let totalViolation = 0;
|
|
1342
|
+
const violations = [];
|
|
1343
|
+
for (const item of unfrozen) {
|
|
1344
|
+
const clamped = Math.max(0, clamp(item.targetMainSize, item.minMainSize, item.maxMainSize));
|
|
1345
|
+
const violation = clamped - item.targetMainSize;
|
|
1346
|
+
totalViolation += violation;
|
|
1347
|
+
if (violation > 0) {
|
|
1348
|
+
violations.push({ item, type: "min" });
|
|
1349
|
+
} else if (violation < 0) {
|
|
1350
|
+
violations.push({ item, type: "max" });
|
|
1351
|
+
} else {
|
|
1352
|
+
violations.push({ item, type: "none" });
|
|
1353
|
+
}
|
|
1354
|
+
item.targetMainSize = clamped;
|
|
1355
|
+
}
|
|
1356
|
+
if (totalViolation === 0) {
|
|
1357
|
+
for (const item of unfrozen) item.frozen = true;
|
|
1358
|
+
} else if (totalViolation > 0) {
|
|
1359
|
+
for (const { item, type } of violations) {
|
|
1360
|
+
if (type === "min") item.frozen = true;
|
|
1361
|
+
}
|
|
1362
|
+
} else {
|
|
1363
|
+
for (const { item, type } of violations) {
|
|
1364
|
+
if (type === "max") item.frozen = true;
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
for (const item of items) {
|
|
1369
|
+
item.usedMainSize = Math.max(0, item.targetMainSize);
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
function alignMainAxis(items, availableMain, justifyContent, gap, horizontal) {
|
|
1373
|
+
if (items.length === 0) return;
|
|
1374
|
+
const totalGap = gap * (items.length - 1);
|
|
1375
|
+
let autoMarginCount = 0;
|
|
1376
|
+
for (const item of items) {
|
|
1377
|
+
if (horizontal) {
|
|
1378
|
+
if (item.marginLeft === null) autoMarginCount++;
|
|
1379
|
+
if (item.marginRight === null) autoMarginCount++;
|
|
1380
|
+
} else {
|
|
1381
|
+
if (item.marginTop === null) autoMarginCount++;
|
|
1382
|
+
if (item.marginBottom === null) autoMarginCount++;
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
let usedSpace = totalGap;
|
|
1386
|
+
for (const item of items) {
|
|
1387
|
+
usedSpace += item.usedMainSize + outerMainAll(item, horizontal);
|
|
1388
|
+
}
|
|
1389
|
+
const freeSpace = availableMain - usedSpace;
|
|
1390
|
+
if (autoMarginCount > 0 && freeSpace > 0) {
|
|
1391
|
+
const perAutoMargin = freeSpace / autoMarginCount;
|
|
1392
|
+
for (const item of items) {
|
|
1393
|
+
if (horizontal) {
|
|
1394
|
+
if (item.marginLeft === null) item.marginLeft = perAutoMargin;
|
|
1395
|
+
if (item.marginRight === null) item.marginRight = perAutoMargin;
|
|
1396
|
+
} else {
|
|
1397
|
+
if (item.marginTop === null) item.marginTop = perAutoMargin;
|
|
1398
|
+
if (item.marginBottom === null) item.marginBottom = perAutoMargin;
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
let pos2 = 0;
|
|
1402
|
+
for (let i = 0; i < items.length; i++) {
|
|
1403
|
+
const item = items[i];
|
|
1404
|
+
const mainInset = horizontal ? horizontalInset(item.padding, item.border) : verticalInset(item.padding, item.border);
|
|
1405
|
+
pos2 += mainStartMarginValue(item, horizontal);
|
|
1406
|
+
item.mainPos = pos2;
|
|
1407
|
+
pos2 += item.usedMainSize + mainInset + mainEndMarginValue(item, horizontal);
|
|
1408
|
+
if (i < items.length - 1) pos2 += gap;
|
|
1409
|
+
}
|
|
1410
|
+
return;
|
|
1411
|
+
}
|
|
1412
|
+
for (const item of items) {
|
|
1413
|
+
if (horizontal) {
|
|
1414
|
+
if (item.marginLeft === null) item.marginLeft = 0;
|
|
1415
|
+
if (item.marginRight === null) item.marginRight = 0;
|
|
1416
|
+
} else {
|
|
1417
|
+
if (item.marginTop === null) item.marginTop = 0;
|
|
1418
|
+
if (item.marginBottom === null) item.marginBottom = 0;
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
usedSpace = totalGap;
|
|
1422
|
+
for (const item of items) {
|
|
1423
|
+
usedSpace += item.usedMainSize + outerMainAll(item, horizontal);
|
|
1424
|
+
}
|
|
1425
|
+
const actualFreeSpace = Math.max(0, availableMain - usedSpace);
|
|
1426
|
+
let startOffset = 0;
|
|
1427
|
+
let betweenSpace = gap;
|
|
1428
|
+
switch (justifyContent) {
|
|
1429
|
+
case "flex-start":
|
|
1430
|
+
startOffset = 0;
|
|
1431
|
+
betweenSpace = gap;
|
|
1432
|
+
break;
|
|
1433
|
+
case "flex-end":
|
|
1434
|
+
startOffset = actualFreeSpace;
|
|
1435
|
+
betweenSpace = gap;
|
|
1436
|
+
break;
|
|
1437
|
+
case "center":
|
|
1438
|
+
startOffset = actualFreeSpace / 2;
|
|
1439
|
+
betweenSpace = gap;
|
|
1440
|
+
break;
|
|
1441
|
+
case "space-between":
|
|
1442
|
+
startOffset = 0;
|
|
1443
|
+
betweenSpace = items.length > 1 ? gap + actualFreeSpace / (items.length - 1) : gap;
|
|
1444
|
+
break;
|
|
1445
|
+
case "space-around": {
|
|
1446
|
+
const perItem = actualFreeSpace / items.length;
|
|
1447
|
+
startOffset = perItem / 2;
|
|
1448
|
+
betweenSpace = gap + perItem;
|
|
1449
|
+
break;
|
|
1450
|
+
}
|
|
1451
|
+
case "space-evenly": {
|
|
1452
|
+
const perSlot = actualFreeSpace / (items.length + 1);
|
|
1453
|
+
startOffset = perSlot;
|
|
1454
|
+
betweenSpace = gap + perSlot;
|
|
1455
|
+
break;
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
let pos = startOffset;
|
|
1459
|
+
for (let i = 0; i < items.length; i++) {
|
|
1460
|
+
const item = items[i];
|
|
1461
|
+
const mainInset = horizontal ? horizontalInset(item.padding, item.border) : verticalInset(item.padding, item.border);
|
|
1462
|
+
pos += mainStartMarginValue(item, horizontal);
|
|
1463
|
+
item.mainPos = pos;
|
|
1464
|
+
pos += item.usedMainSize + mainInset + mainEndMarginValue(item, horizontal);
|
|
1465
|
+
if (i < items.length - 1) pos += betweenSpace;
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
function alignCrossLines(lines, totalCrossSize, alignContent, crossGap) {
|
|
1469
|
+
if (lines.length === 0) return;
|
|
1470
|
+
const totalLinesCross = lines.reduce((sum, l) => sum + l.crossSize, 0) + crossGap * (lines.length - 1);
|
|
1471
|
+
const freeSpace = Math.max(0, totalCrossSize - totalLinesCross);
|
|
1472
|
+
let offset = 0;
|
|
1473
|
+
let betweenSpace = crossGap;
|
|
1474
|
+
switch (alignContent) {
|
|
1475
|
+
case "flex-start":
|
|
1476
|
+
offset = 0;
|
|
1477
|
+
betweenSpace = crossGap;
|
|
1478
|
+
break;
|
|
1479
|
+
case "flex-end":
|
|
1480
|
+
offset = freeSpace;
|
|
1481
|
+
betweenSpace = crossGap;
|
|
1482
|
+
break;
|
|
1483
|
+
case "center":
|
|
1484
|
+
offset = freeSpace / 2;
|
|
1485
|
+
betweenSpace = crossGap;
|
|
1486
|
+
break;
|
|
1487
|
+
case "stretch":
|
|
1488
|
+
offset = 0;
|
|
1489
|
+
betweenSpace = crossGap;
|
|
1490
|
+
if (lines.length > 0) {
|
|
1491
|
+
const extra = freeSpace / lines.length;
|
|
1492
|
+
for (const line of lines) {
|
|
1493
|
+
line.crossSize += extra;
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
break;
|
|
1497
|
+
case "space-between":
|
|
1498
|
+
offset = 0;
|
|
1499
|
+
betweenSpace = lines.length > 1 ? crossGap + freeSpace / (lines.length - 1) : crossGap;
|
|
1500
|
+
break;
|
|
1501
|
+
case "space-around": {
|
|
1502
|
+
const perLine = freeSpace / lines.length;
|
|
1503
|
+
offset = perLine / 2;
|
|
1504
|
+
betweenSpace = crossGap + perLine;
|
|
1505
|
+
break;
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
let pos = offset;
|
|
1509
|
+
for (const line of lines) {
|
|
1510
|
+
line.crossOffset = pos;
|
|
1511
|
+
pos += line.crossSize + betweenSpace;
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
function resolveAlignSelf2(alignSelf, parentAlignItems) {
|
|
1515
|
+
return alignSelf === "auto" ? parentAlignItems : alignSelf;
|
|
1516
|
+
}
|
|
1517
|
+
function outerMainMargin(item, horizontal) {
|
|
1518
|
+
if (horizontal) {
|
|
1519
|
+
return (item.marginLeft ?? 0) + (item.marginRight ?? 0);
|
|
1520
|
+
}
|
|
1521
|
+
return (item.marginTop ?? 0) + (item.marginBottom ?? 0);
|
|
1522
|
+
}
|
|
1523
|
+
function outerMainAll(item, horizontal) {
|
|
1524
|
+
const margin = outerMainMargin(item, horizontal);
|
|
1525
|
+
const inset = horizontal ? horizontalInset(item.padding, item.border) : verticalInset(item.padding, item.border);
|
|
1526
|
+
return margin + inset;
|
|
1527
|
+
}
|
|
1528
|
+
function outerCrossMargin(item, horizontal) {
|
|
1529
|
+
if (horizontal) {
|
|
1530
|
+
return (item.marginTop ?? 0) + (item.marginBottom ?? 0);
|
|
1531
|
+
}
|
|
1532
|
+
return (item.marginLeft ?? 0) + (item.marginRight ?? 0);
|
|
1533
|
+
}
|
|
1534
|
+
function outerCrossAll(item, horizontal) {
|
|
1535
|
+
const margin = outerCrossMargin(item, horizontal);
|
|
1536
|
+
const inset = horizontal ? verticalInset(item.padding, item.border) : horizontalInset(item.padding, item.border);
|
|
1537
|
+
return margin + inset;
|
|
1538
|
+
}
|
|
1539
|
+
function mainStartMarginValue(item, horizontal) {
|
|
1540
|
+
return (horizontal ? item.marginLeft : item.marginTop) ?? 0;
|
|
1541
|
+
}
|
|
1542
|
+
function mainEndMarginValue(item, horizontal) {
|
|
1543
|
+
return (horizontal ? item.marginRight : item.marginBottom) ?? 0;
|
|
1544
|
+
}
|
|
1545
|
+
function crossStartMarginValue(item, horizontal) {
|
|
1546
|
+
return (horizontal ? item.marginTop : item.marginLeft) ?? 0;
|
|
1547
|
+
}
|
|
1548
|
+
function crossEndMarginValue(item, horizontal) {
|
|
1549
|
+
return (horizontal ? item.marginBottom : item.marginRight) ?? 0;
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
// src/helpers.ts
|
|
1553
|
+
function h(style, ...children) {
|
|
1554
|
+
return children.length > 0 ? { style, children } : { style };
|
|
1555
|
+
}
|
|
1556
|
+
function row(style, ...children) {
|
|
1557
|
+
return h({ flexDirection: "row", ...style }, ...children);
|
|
1558
|
+
}
|
|
1559
|
+
function col(style, ...children) {
|
|
1560
|
+
return h({ flexDirection: "column", ...style }, ...children);
|
|
1561
|
+
}
|
|
1562
|
+
function grid(style, ...children) {
|
|
1563
|
+
return h({ display: "grid", ...style }, ...children);
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
exports.col = col;
|
|
1567
|
+
exports.computeLayout = computeLayout;
|
|
1568
|
+
exports.grid = grid;
|
|
1569
|
+
exports.h = h;
|
|
1570
|
+
exports.row = row;
|
|
1571
|
+
//# sourceMappingURL=index.cjs.map
|
|
1572
|
+
//# sourceMappingURL=index.cjs.map
|