wuira 0.3.0 → 0.3.2

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.
@@ -1,62 +1,169 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  -- Lua Library inline imports
3
- local function __TS__NumberIsFinite(value)
4
- return type(value) == "number" and value == value and value ~= math.huge and value ~= -math.huge
3
+ local function __TS__StringIncludes(self, searchString, position)
4
+ if not position then
5
+ position = 1
6
+ else
7
+ position = position + 1
8
+ end
9
+ local index = string.find(self, searchString, position, true)
10
+ return index ~= nil
11
+ end
12
+
13
+ local function __TS__ArrayMap(self, callbackfn, thisArg)
14
+ local result = {}
15
+ for i = 1, #self do
16
+ result[i] = callbackfn(thisArg, self[i], i - 1, self)
17
+ end
18
+ return result
5
19
  end
6
20
  -- End of Lua Library inline imports
7
21
  local ____exports = {}
8
- --- Pure layout calculation in top-left UI coordinates.
9
- function ____exports.calculateFlow(self, props, children)
10
- local horizontal = props.direction == "horizontal"
11
- local requestedLimit = horizontal and props.width or props.height
12
- local limit = props.sizing == "content" and requestedLimit == 0 and math.huge or requestedLimit
22
+ local function axisFraction(self, anchor, axis, fallback)
23
+ if anchor == nil or anchor == "" then
24
+ return fallback
25
+ end
26
+ if axis == "x" then
27
+ if __TS__StringIncludes(anchor, "LEFT") then
28
+ return 0
29
+ end
30
+ if __TS__StringIncludes(anchor, "RIGHT") then
31
+ return 1
32
+ end
33
+ return 0.5
34
+ end
35
+ if __TS__StringIncludes(anchor, "TOP") then
36
+ return 0
37
+ end
38
+ if __TS__StringIncludes(anchor, "BOTTOM") then
39
+ return 1
40
+ end
41
+ return 0.5
42
+ end
43
+ --- Horizontal space is columnGap. Vertical space is rowGap. Older gap and lineGap fill whichever axis is unset.
44
+ function ____exports.flowSpacing(self, direction, props)
45
+ local horizontal = direction == "horizontal" or direction == "ltr" or direction == "rtl" or direction == "horizontalReverse"
13
46
  local gap = props.gap or 0
14
47
  local lineGap = props.lineGap or gap
15
- if gap < 0 or lineGap < 0 then
48
+ local column = props.columnGap or (horizontal and gap or lineGap)
49
+ local row = props.rowGap or (horizontal and lineGap or gap)
50
+ if column < 0 or row < 0 then
16
51
  error("FlowLayout gaps must be non-negative")
17
52
  end
18
- local result = {}
19
- local cursor = 0
20
- local cross = 0
21
- local lineSize = 0
22
- local count = 0
23
- local lineStart = 0
24
- local function alignLine()
25
- local free = __TS__NumberIsFinite(limit) and math.max(0, limit - cursor) or 0
26
- local offset = props.justify == "center" and free / 2 or (props.justify == "end" and free or 0)
27
- do
28
- local index = lineStart
29
- while index < #result do
30
- if horizontal then
31
- local ____result_index_0, ____x_1 = result[index + 1], "x"
32
- ____result_index_0[____x_1] = ____result_index_0[____x_1] + offset
33
- else
34
- local ____result_index_2, ____y_3 = result[index + 1], "y"
35
- ____result_index_2[____y_3] = ____result_index_2[____y_3] + offset
36
- end
37
- index = index + 1
53
+ return horizontal and ({main = column, cross = row}) or ({main = row, cross = column})
54
+ end
55
+ local function flowAxis(self, direction)
56
+ local horizontal = direction == "horizontal" or direction == "ltr" or direction == "rtl" or direction == "horizontalReverse"
57
+ local reverse = direction == "rtl" or direction == "btt" or direction == "horizontalReverse" or direction == "verticalReverse"
58
+ return {horizontal = horizontal, reverse = reverse}
59
+ end
60
+ local function fraction(self, value, center, ____end)
61
+ if value == center then
62
+ return 0.5
63
+ end
64
+ if value == ____end then
65
+ return 1
66
+ end
67
+ return 0
68
+ end
69
+ --- Pack children along one direction, then place the group and each child separately.
70
+ function ____exports.calculateFlow(self, props, children)
71
+ local ____flowAxis_result_0 = flowAxis(nil, props.direction)
72
+ local horizontal = ____flowAxis_result_0.horizontal
73
+ local reverse = ____flowAxis_result_0.reverse
74
+ local requestedLimit = horizontal and props.width or props.height
75
+ local limit = props.sizing == "content" and requestedLimit == 0 and math.huge or requestedLimit
76
+ local spacing = ____exports.flowSpacing(nil, props.direction, props)
77
+ local gap = spacing.main
78
+ local lineGap = spacing.cross
79
+ local justifyFallback = horizontal and props.alignX == nil or not horizontal and props.alignY == nil
80
+ local ____justifyFallback_1
81
+ if justifyFallback then
82
+ ____justifyFallback_1 = props.justify
83
+ else
84
+ ____justifyFallback_1 = nil
85
+ end
86
+ local mainJustify = ____justifyFallback_1
87
+ local alignX = fraction(nil, props.alignX or (horizontal and mainJustify == "center" and "center" or (horizontal and mainJustify == "end" and "right" or nil)), "center", "right")
88
+ local alignY = fraction(nil, props.alignY or (not horizontal and mainJustify == "center" and "center" or (not horizontal and mainJustify == "end" and "bottom" or nil)), "center", "bottom")
89
+ local lines = {}
90
+ local line = {items = {}, mainSize = 0, crossSize = 0}
91
+ do
92
+ local index = 0
93
+ while index < #children do
94
+ local child = children[index + 1]
95
+ local mainSize = horizontal and child.width or child.height
96
+ local crossSize = horizontal and child.height or child.width
97
+ local next = #line.items == 0 and 0 or line.mainSize + gap
98
+ if props.grow and #line.items > 0 and next + mainSize > limit then
99
+ lines[#lines + 1] = line
100
+ line = {items = {}, mainSize = 0, crossSize = 0}
101
+ end
102
+ local main = #line.items == 0 and 0 or line.mainSize + gap
103
+ local ____line_items_2 = line.items
104
+ ____line_items_2[#____line_items_2 + 1] = {
105
+ index = index,
106
+ main = main,
107
+ mainSize = mainSize,
108
+ crossSize = crossSize,
109
+ width = child.width,
110
+ height = child.height,
111
+ anchor = child.anchor
112
+ }
113
+ line.mainSize = main + mainSize
114
+ line.crossSize = math.max(line.crossSize, crossSize)
115
+ index = index + 1
116
+ end
117
+ end
118
+ if #line.items > 0 then
119
+ lines[#lines + 1] = line
120
+ end
121
+ local packCross = 0
122
+ local packMain = 0
123
+ do
124
+ local index = 0
125
+ while index < #lines do
126
+ packMain = math.max(packMain, lines[index + 1].mainSize)
127
+ packCross = packCross + lines[index + 1].crossSize
128
+ if index < #lines - 1 then
129
+ packCross = packCross + lineGap
38
130
  end
131
+ index = index + 1
39
132
  end
40
- lineStart = #result
41
- end
42
- for ____, child in ipairs(children) do
43
- local size = horizontal and child.width or child.height
44
- local crossSize = horizontal and child.height or child.width
45
- local next = count == 0 and 0 or cursor + gap
46
- if props.grow and count > 0 and next + size > limit then
47
- alignLine(nil)
48
- cross = cross + (lineSize + lineGap)
49
- cursor = 0
50
- lineSize = 0
51
- count = 0
133
+ end
134
+ local mainBox = horizontal and (props.sizing == "content" and props.width == 0 and packMain or props.width) or (props.sizing == "content" and props.height == 0 and packMain or props.height)
135
+ local crossBox = horizontal and (props.sizing == "content" and props.height == 0 and packCross or props.height) or (props.sizing == "content" and props.width == 0 and packCross or props.width)
136
+ local mainFraction = horizontal and alignX or alignY
137
+ local crossFraction = horizontal and alignY or alignX
138
+ local result = __TS__ArrayMap(
139
+ children,
140
+ function() return {x = 0, y = 0} end
141
+ )
142
+ local cross = (crossBox - packCross) * crossFraction
143
+ do
144
+ local index = 0
145
+ while index < #lines do
146
+ local packed = lines[index + 1]
147
+ local mainFree = mainBox - packed.mainSize
148
+ local mainShift = (justifyFallback and math.max(0, mainFree) or mainFree) * mainFraction
149
+ for ____, item in ipairs(packed.items) do
150
+ local main = (reverse and packed.mainSize - item.main - item.mainSize or item.main) + mainShift
151
+ local slotX = horizontal and main or cross
152
+ local slotY = horizontal and cross or main
153
+ local slotW = horizontal and item.mainSize or packed.crossSize
154
+ local slotH = horizontal and packed.crossSize or item.mainSize
155
+ result[item.index + 1] = {
156
+ x = slotX + (slotW - item.width) * axisFraction(nil, item.anchor, "x", 0),
157
+ y = slotY + (slotH - item.height) * axisFraction(nil, item.anchor, "y", 0)
158
+ }
159
+ end
160
+ cross = cross + packed.crossSize
161
+ if index < #lines - 1 then
162
+ cross = cross + lineGap
163
+ end
164
+ index = index + 1
52
165
  end
53
- local position = count == 0 and 0 or cursor + gap
54
- result[#result + 1] = horizontal and ({x = position, y = cross}) or ({x = cross, y = position})
55
- cursor = position + size
56
- lineSize = math.max(lineSize, crossSize)
57
- count = count + 1
58
166
  end
59
- alignLine(nil)
60
167
  return result
61
168
  end
62
169
  return ____exports
@@ -1,9 +1,10 @@
1
1
  import type { GridLayoutProps } from "../GridLayout";
2
- /** Row-major placement into uniform slots; children keep their own sizes. */
3
- export declare function calculateGrid(props: GridLayoutProps, children: readonly {
4
- width: number;
5
- height: number;
6
- }[]): {
2
+ import type { FlowChild } from "./calculateFlow";
3
+ /** Place children in slots. Direction chooses the order; each child anchors inside its slot. */
4
+ export declare function calculateGrid(props: GridLayoutProps & {
5
+ width?: number;
6
+ height?: number;
7
+ }, children: readonly FlowChild[]): {
7
8
  x: number;
8
9
  y: number;
9
10
  }[];
@@ -1,5 +1,15 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  -- Lua Library inline imports
3
+ local function __TS__StringIncludes(self, searchString, position)
4
+ if not position then
5
+ position = 1
6
+ else
7
+ position = position + 1
8
+ end
9
+ local index = string.find(self, searchString, position, true)
10
+ return index ~= nil
11
+ end
12
+
3
13
  local function __TS__NumberIsFinite(value)
4
14
  return type(value) == "number" and value == value and value ~= math.huge and value ~= -math.huge
5
15
  end
@@ -13,7 +23,37 @@ local function __TS__ArrayMap(self, callbackfn, thisArg)
13
23
  end
14
24
  -- End of Lua Library inline imports
15
25
  local ____exports = {}
16
- --- Row-major placement into uniform slots; children keep their own sizes.
26
+ local function axisFraction(self, anchor, axis, fallback)
27
+ if anchor == nil or anchor == "" then
28
+ return fallback
29
+ end
30
+ if axis == "x" then
31
+ if __TS__StringIncludes(anchor, "LEFT") then
32
+ return 0
33
+ end
34
+ if __TS__StringIncludes(anchor, "RIGHT") then
35
+ return 1
36
+ end
37
+ return 0.5
38
+ end
39
+ if __TS__StringIncludes(anchor, "TOP") then
40
+ return 0
41
+ end
42
+ if __TS__StringIncludes(anchor, "BOTTOM") then
43
+ return 1
44
+ end
45
+ return 0.5
46
+ end
47
+ local function fraction(self, value, ____end)
48
+ if value == "center" then
49
+ return 0.5
50
+ end
51
+ if value == ____end then
52
+ return 1
53
+ end
54
+ return 0
55
+ end
56
+ --- Place children in slots. Direction chooses the order; each child anchors inside its slot.
17
57
  function ____exports.calculateGrid(self, props, children)
18
58
  if not __TS__NumberIsFinite(props.columns) or props.columns < 1 or math.floor(props.columns) ~= props.columns then
19
59
  error("GridLayout columns must be a positive integer")
@@ -36,12 +76,46 @@ function ____exports.calculateGrid(self, props, children)
36
76
  if width < 0 or height < 0 then
37
77
  error("GridLayout cell sizes must be non-negative")
38
78
  end
39
- return __TS__ArrayMap(
79
+ local columns = props.columns
80
+ local rows = #children == 0 and 0 or math.ceil(#children / columns)
81
+ local vertical = props.direction == "ttb" or props.direction == "btt" or props.direction == "vertical" or props.direction == "verticalReverse"
82
+ local reverse = props.direction == "rtl" or props.direction == "btt" or props.direction == "horizontalReverse" or props.direction == "verticalReverse"
83
+ local alignX = fraction(nil, props.alignX, "right")
84
+ local alignY = fraction(nil, props.alignY, "bottom")
85
+ local points = __TS__ArrayMap(
40
86
  children,
41
- function(____, _, index) return {
42
- x = index % props.columns * (width + columnGap),
43
- y = math.floor(index / props.columns) * (height + rowGap)
44
- } end
87
+ function(____, child, index)
88
+ local column = index % columns
89
+ local row = math.floor(index / columns)
90
+ if vertical then
91
+ column = math.floor(index / math.max(1, rows))
92
+ row = index % math.max(1, rows)
93
+ end
94
+ if reverse then
95
+ if vertical then
96
+ row = rows - 1 - row
97
+ else
98
+ column = columns - 1 - column
99
+ end
100
+ end
101
+ local slotX = column * (width + columnGap)
102
+ local slotY = row * (height + rowGap)
103
+ return {
104
+ x = slotX + (width - child.width) * axisFraction(nil, child.anchor, "x", 0),
105
+ y = slotY + (height - child.height) * axisFraction(nil, child.anchor, "y", 0)
106
+ }
107
+ end
45
108
  )
109
+ local packW = (columns == 0 or rows == 0) and 0 or columns * width + math.max(0, columns - 1) * columnGap
110
+ local packH = (columns == 0 or rows == 0) and 0 or rows * height + math.max(0, rows - 1) * rowGap
111
+ local boxW = props.sizing == "content" and (props.width or 0) == 0 and packW or (props.width or packW)
112
+ local boxH = props.sizing == "content" and (props.height or 0) == 0 and packH or (props.height or packH)
113
+ local shiftX = (boxW - packW) * alignX
114
+ local shiftY = (boxH - packH) * alignY
115
+ for ____, point in ipairs(points) do
116
+ point.x = point.x + shiftX
117
+ point.y = point.y + shiftY
118
+ end
119
+ return points
46
120
  end
47
121
  return ____exports
@@ -4,6 +4,14 @@ local function __TS__NumberIsFinite(value)
4
4
  return type(value) == "number" and value == value and value ~= math.huge and value ~= -math.huge
5
5
  end
6
6
 
7
+ local function __TS__ArrayMap(self, callbackfn, thisArg)
8
+ local result = {}
9
+ for i = 1, #self do
10
+ result[i] = callbackfn(thisArg, self[i], i - 1, self)
11
+ end
12
+ return result
13
+ end
14
+
7
15
  local function __TS__ArrayIncludes(self, searchElement, fromIndex)
8
16
  if fromIndex == nil then
9
17
  fromIndex = 0
@@ -51,14 +59,6 @@ local function __TS__SparseArraySpread(sparseArray)
51
59
  return _unpack(sparseArray, 1, sparseArray.sparseLength)
52
60
  end
53
61
 
54
- local function __TS__ArrayMap(self, callbackfn, thisArg)
55
- local result = {}
56
- for i = 1, #self do
57
- result[i] = callbackfn(thisArg, self[i], i - 1, self)
58
- end
59
- return result
60
- end
61
-
62
62
  local function __TS__ObjectAssign(target, ...)
63
63
  local sources = {...}
64
64
  for i = 1, #sources do
@@ -73,15 +73,20 @@ local function __TS__ObjectAssign(target, ...)
73
73
  end
74
74
  -- End of Lua Library inline imports
75
75
  local ____exports = {}
76
+ local resolveSize, flowMainHorizontal, measureChildren
76
77
  local ____Spacing = require("types.Spacing")
77
78
  local resolveSpacing = ____Spacing.resolveSpacing
78
79
  local ____calculateFlow = require("ui.layout.calculateFlow")
79
80
  local calculateFlow = ____calculateFlow.calculateFlow
81
+ local flowSpacing = ____calculateFlow.flowSpacing
80
82
  local ____calculateGrid = require("ui.layout.calculateGrid")
81
83
  local calculateGrid = ____calculateGrid.calculateGrid
82
- local function resolveSize(self, value, available, margin)
83
- if value == "inherit" then
84
+ function resolveSize(self, value, available, margin)
85
+ if value == "inherit" or value == "fill" then
84
86
  if available == nil then
87
+ if value == "fill" then
88
+ return 0
89
+ end
85
90
  error("Cannot inherit a size from an unconstrained content-sized parent")
86
91
  end
87
92
  return math.max(0, available - margin)
@@ -91,6 +96,72 @@ local function resolveSize(self, value, available, margin)
91
96
  end
92
97
  return value
93
98
  end
99
+ function flowMainHorizontal(self, direction)
100
+ return direction == "horizontal" or direction == "ltr" or direction == "rtl" or direction == "horizontalReverse"
101
+ end
102
+ function measureChildren(self, layout, sourceChildren, contentWidth, contentHeight, path)
103
+ local box = {width = contentWidth, height = contentHeight}
104
+ if layout == nil or layout.kind ~= "flow" then
105
+ return __TS__ArrayMap(
106
+ sourceChildren,
107
+ function(____, child) return ____exports.measureLayout(nil, child, box, path) end
108
+ )
109
+ end
110
+ local horizontal = flowMainHorizontal(nil, layout.props.direction)
111
+ local gap = flowSpacing(nil, layout.props.direction, layout.props).main
112
+ local measured = {}
113
+ local fillIndexes = {}
114
+ do
115
+ local index = 0
116
+ while index < #sourceChildren do
117
+ local child = sourceChildren[index + 1]
118
+ if (horizontal and child.props.width or child.props.height) == "fill" then
119
+ fillIndexes[#fillIndexes + 1] = index
120
+ else
121
+ measured[index + 1] = ____exports.measureLayout(nil, child, box, path)
122
+ end
123
+ index = index + 1
124
+ end
125
+ end
126
+ local used = 0
127
+ do
128
+ local index = 0
129
+ while index < #measured do
130
+ do
131
+ local __continue16
132
+ repeat
133
+ local child = measured[index + 1]
134
+ if child == nil then
135
+ __continue16 = true
136
+ break
137
+ end
138
+ used = used + (horizontal and child.width + child.margin.left + child.margin.right or child.height + child.margin.top + child.margin.bottom)
139
+ __continue16 = true
140
+ until true
141
+ if not __continue16 then
142
+ break
143
+ end
144
+ end
145
+ index = index + 1
146
+ end
147
+ end
148
+ local ____horizontal_0
149
+ if horizontal then
150
+ ____horizontal_0 = contentWidth
151
+ else
152
+ ____horizontal_0 = contentHeight
153
+ end
154
+ local contentMain = ____horizontal_0
155
+ local leftover = contentMain == nil and 0 or math.max(
156
+ 0,
157
+ contentMain - used - math.max(0, #sourceChildren - 1) * gap
158
+ )
159
+ local share = #fillIndexes == 0 and 0 or leftover / #fillIndexes
160
+ for ____, index in ipairs(fillIndexes) do
161
+ measured[index + 1] = ____exports.measureLayout(nil, sourceChildren[index + 1], horizontal and ({width = share, height = contentHeight}) or ({width = contentWidth, height = share}), path)
162
+ end
163
+ return measured
164
+ end
94
165
  --- Resolve available space top-down and content bounds bottom-up.
95
166
  function ____exports.measureLayout(self, element, available, ancestors)
96
167
  if available == nil then
@@ -123,20 +194,20 @@ function ____exports.measureLayout(self, element, available, ancestors)
123
194
  local isLayout = element.kind == "flow" or element.kind == "grid"
124
195
  local layout = isLayout and element or nil
125
196
  local contentSizing = (layout and layout.props.sizing) == "content"
126
- local ____temp_2
197
+ local ____temp_3
127
198
  if contentSizing and props.width == 0 then
128
- ____temp_2 = nil
199
+ ____temp_3 = nil
129
200
  else
130
- ____temp_2 = math.max(0, width - padding.left - padding.right)
201
+ ____temp_3 = math.max(0, width - padding.left - padding.right)
131
202
  end
132
- local contentWidth = ____temp_2
133
- local ____temp_3
203
+ local contentWidth = ____temp_3
204
+ local ____temp_4
134
205
  if contentSizing and props.height == 0 then
135
- ____temp_3 = nil
206
+ ____temp_4 = nil
136
207
  else
137
- ____temp_3 = math.max(0, height - padding.top - padding.bottom)
208
+ ____temp_4 = math.max(0, height - padding.top - padding.bottom)
138
209
  end
139
- local contentHeight = ____temp_3
210
+ local contentHeight = ____temp_4
140
211
  local sourceChildren = layout ~= nil and layout.children or (cell.child == nil and ({}) or ({cell.child}))
141
212
  local childWidth = contentWidth
142
213
  local childHeight = contentHeight
@@ -149,47 +220,55 @@ function ____exports.measureLayout(self, element, available, ancestors)
149
220
  1,
150
221
  math.ceil(#sourceChildren / grid.columns)
151
222
  )
152
- local ____grid_cellWidth_7 = grid.cellWidth
153
- if ____grid_cellWidth_7 == nil then
154
- local ____temp_6
223
+ local ____grid_cellWidth_8 = grid.cellWidth
224
+ if ____grid_cellWidth_8 == nil then
225
+ local ____temp_7
155
226
  if contentWidth == nil then
156
- ____temp_6 = nil
227
+ ____temp_7 = nil
157
228
  else
158
- ____temp_6 = math.max(0, (contentWidth - (grid.columnGap or grid.gap or 0) * (grid.columns - 1)) / grid.columns)
229
+ ____temp_7 = math.max(0, (contentWidth - (grid.columnGap or grid.gap or 0) * (grid.columns - 1)) / grid.columns)
159
230
  end
160
- ____grid_cellWidth_7 = ____temp_6
231
+ ____grid_cellWidth_8 = ____temp_7
161
232
  end
162
- childWidth = ____grid_cellWidth_7
163
- local ____grid_cellHeight_9 = grid.cellHeight
164
- if ____grid_cellHeight_9 == nil then
165
- local ____temp_8
233
+ childWidth = ____grid_cellWidth_8
234
+ local ____grid_cellHeight_10 = grid.cellHeight
235
+ if ____grid_cellHeight_10 == nil then
236
+ local ____temp_9
166
237
  if contentHeight == nil then
167
- ____temp_8 = nil
238
+ ____temp_9 = nil
168
239
  else
169
- ____temp_8 = math.max(0, (contentHeight - (grid.rowGap or grid.gap or 0) * (rows - 1)) / rows)
240
+ ____temp_9 = math.max(0, (contentHeight - (grid.rowGap or grid.gap or 0) * (rows - 1)) / rows)
170
241
  end
171
- ____grid_cellHeight_9 = ____temp_8
242
+ ____grid_cellHeight_10 = ____temp_9
172
243
  end
173
- childHeight = ____grid_cellHeight_9
244
+ childHeight = ____grid_cellHeight_10
174
245
  end
175
- local ____array_10 = __TS__SparseArrayNew(__TS__Unpack(ancestors))
176
- __TS__SparseArrayPush(____array_10, element)
177
- local path = {__TS__SparseArraySpread(____array_10)}
178
- local children = __TS__ArrayMap(
246
+ local ____array_11 = __TS__SparseArrayNew(__TS__Unpack(ancestors))
247
+ __TS__SparseArrayPush(____array_11, element)
248
+ local path = {__TS__SparseArraySpread(____array_11)}
249
+ local children = measureChildren(
250
+ nil,
251
+ layout,
179
252
  sourceChildren,
180
- function(____, child) return ____exports.measureLayout(nil, child, {width = childWidth, height = childHeight}, path) end
253
+ childWidth,
254
+ childHeight,
255
+ path
181
256
  )
182
257
  local placements
183
258
  if layout ~= nil then
184
259
  local sizes = __TS__ArrayMap(
185
260
  children,
186
- function(____, child) return {width = child.width + child.margin.left + child.margin.right, height = child.height + child.margin.top + child.margin.bottom} end
261
+ function(____, child) return {width = child.width + child.margin.left + child.margin.right, height = child.height + child.margin.top + child.margin.bottom, anchor = child.cell.props.anchor} end
187
262
  )
188
263
  local positions = layout.kind == "flow" and calculateFlow(
189
264
  nil,
190
265
  __TS__ObjectAssign({}, layout.props, {width = contentWidth or 0, height = contentHeight or 0}),
191
266
  sizes
192
- ) or calculateGrid(nil, layout.props, sizes)
267
+ ) or calculateGrid(
268
+ nil,
269
+ __TS__ObjectAssign({}, layout.props, {width = contentWidth or 0, height = contentHeight or 0}),
270
+ sizes
271
+ )
193
272
  placements = __TS__ArrayMap(
194
273
  positions,
195
274
  function(____, point) return {x = point.x + padding.left, y = point.y + padding.top} end