@solidtv/solid 1.1.3 → 1.3.0-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/README.md +2 -2
- package/dist/src/core/config.d.ts +13 -1
- package/dist/src/core/config.js +13 -1
- package/dist/src/core/config.js.map +1 -1
- package/dist/src/core/dom-renderer/domRenderer.js +1 -0
- package/dist/src/core/dom-renderer/domRenderer.js.map +1 -1
- package/dist/src/core/dom-renderer/domRendererUtils.js +2 -2
- package/dist/src/core/dom-renderer/domRendererUtils.js.map +1 -1
- package/dist/src/core/elementNode.d.ts +10 -4
- package/dist/src/core/elementNode.js +60 -49
- package/dist/src/core/elementNode.js.map +1 -1
- package/dist/src/core/flex.js +124 -52
- package/dist/src/core/flex.js.map +1 -1
- package/dist/src/core/focusKeyTypes.d.ts +14 -0
- package/dist/src/core/focusManager.d.ts +19 -9
- package/dist/src/core/focusManager.js +125 -101
- package/dist/src/core/focusManager.js.map +1 -1
- package/dist/src/core/lightningInit.js +3 -0
- package/dist/src/core/lightningInit.js.map +1 -1
- package/dist/src/core/shaders.js +10 -10
- package/dist/src/core/shaders.js.map +1 -1
- package/dist/src/core/utils.d.ts +0 -1
- package/dist/src/core/utils.js +0 -1
- package/dist/src/core/utils.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/primitives/FadeInOut.jsx +1 -2
- package/dist/src/primitives/FadeInOut.jsx.map +1 -1
- package/dist/src/primitives/useFocusManager.d.ts +1 -5
- package/dist/src/primitives/useFocusManager.js +1 -20
- package/dist/src/primitives/useFocusManager.js.map +1 -1
- package/dist/src/primitives/useHold.d.ts +1 -1
- package/dist/src/primitives/useHold.js +1 -1
- package/dist/src/primitives/useMouse.js +4 -4
- package/dist/src/primitives/useMouse.js.map +1 -1
- package/dist/src/render.d.ts +6 -0
- package/dist/src/render.js +7 -3
- package/dist/src/render.js.map +1 -1
- package/dist/src/solidOpts.d.ts +1 -1
- package/dist/src/solidOpts.js +4 -23
- package/dist/src/solidOpts.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docs/AI_CODING_GUIDELINES.md +7 -7
- package/package.json +2 -2
- package/src/core/config.ts +15 -2
- package/src/core/dom-renderer/domRenderer.ts +1 -0
- package/src/core/dom-renderer/domRendererUtils.ts +2 -2
- package/src/core/elementNode.ts +66 -46
- package/src/core/flex.ts +135 -56
- package/src/core/focusKeyTypes.ts +14 -0
- package/src/core/focusManager.ts +183 -139
- package/src/core/lightningInit.ts +3 -0
- package/src/core/shaders.ts +10 -10
- package/src/core/utils.ts +0 -3
- package/src/index.ts +1 -1
- package/src/primitives/FadeInOut.tsx +2 -2
- package/src/primitives/useFocusManager.ts +5 -44
- package/src/primitives/useHold.ts +1 -1
- package/src/primitives/useMouse.ts +4 -4
- package/src/render.ts +7 -3
- package/src/solidOpts.ts +4 -25
- package/dist/src/activeElement.d.ts +0 -2
- package/dist/src/activeElement.js +0 -3
- package/dist/src/activeElement.js.map +0 -1
- package/dist/src/core/flexLayout.d.ts +0 -2
- package/dist/src/core/flexLayout.js +0 -356
- package/dist/src/core/flexLayout.js.map +0 -1
- package/src/activeElement.ts +0 -5
- package/src/core/flexLayout.ts +0 -410
package/src/core/flex.ts
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
import { type ElementNode } from './elementNode.js';
|
|
2
2
|
import { isTextNode, isElementText } from './utils.js';
|
|
3
3
|
|
|
4
|
+
function getArrayValue(
|
|
5
|
+
val: number | number[] | undefined,
|
|
6
|
+
index: number,
|
|
7
|
+
defaultValue: number = 0,
|
|
8
|
+
): number {
|
|
9
|
+
if (val === undefined) return defaultValue;
|
|
10
|
+
if (typeof val === 'number') return val;
|
|
11
|
+
|
|
12
|
+
const len = val.length;
|
|
13
|
+
let result;
|
|
14
|
+
if (len === 2) {
|
|
15
|
+
result = index % 2 === 0 ? val[0] : val[1];
|
|
16
|
+
} else if (len === 3) {
|
|
17
|
+
result = index === 0 ? val[0] : index === 2 ? val[2] : val[1];
|
|
18
|
+
} else {
|
|
19
|
+
result = val[index];
|
|
20
|
+
}
|
|
21
|
+
return result ?? defaultValue;
|
|
22
|
+
}
|
|
23
|
+
|
|
4
24
|
export default function (node: ElementNode): boolean {
|
|
5
25
|
const direction = node.flexDirection || 'row';
|
|
6
26
|
const isRow = direction === 'row' || direction === 'row-reverse';
|
|
@@ -8,10 +28,20 @@ export default function (node: ElementNode): boolean {
|
|
|
8
28
|
direction === 'row-reverse' || direction === 'column-reverse';
|
|
9
29
|
const dimension = isRow ? 'width' : 'height';
|
|
10
30
|
const crossDimension = isRow ? 'height' : 'width';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
const
|
|
31
|
+
|
|
32
|
+
// padding order: Top, Right, Bottom, Left
|
|
33
|
+
const nodePadding = node.padding;
|
|
34
|
+
const paddingTop = node.paddingTop ?? getArrayValue(nodePadding, 0);
|
|
35
|
+
const paddingRight = node.paddingRight ?? getArrayValue(nodePadding, 1);
|
|
36
|
+
const paddingBottom = node.paddingBottom ?? getArrayValue(nodePadding, 2);
|
|
37
|
+
const paddingLeft = node.paddingLeft ?? getArrayValue(nodePadding, 3);
|
|
38
|
+
|
|
39
|
+
const paddingStart = isRow ? paddingLeft : paddingTop;
|
|
40
|
+
const paddingEnd = isRow ? paddingRight : paddingBottom;
|
|
41
|
+
const paddingCrossStart = isRow ? paddingTop : paddingLeft;
|
|
42
|
+
const paddingCrossEnd = isRow ? paddingBottom : paddingRight;
|
|
43
|
+
const nodePaddingTotal = paddingStart + paddingEnd;
|
|
44
|
+
|
|
15
45
|
const minDimension = isRow ? 'minWidth' : 'minHeight';
|
|
16
46
|
const crossMinDimension = isRow ? 'minHeight' : 'minWidth';
|
|
17
47
|
|
|
@@ -22,15 +52,17 @@ export default function (node: ElementNode): boolean {
|
|
|
22
52
|
return false;
|
|
23
53
|
}
|
|
24
54
|
|
|
55
|
+
// Optimize arrays caching
|
|
25
56
|
const processableChildrenIndices: number[] = [];
|
|
26
57
|
let hasOrder = false;
|
|
27
58
|
let totalFlexGrow = 0;
|
|
59
|
+
let totalFlexShrink = 0;
|
|
28
60
|
|
|
29
61
|
for (let i = 0; i < numChildren; i++) {
|
|
30
62
|
const c = children[i]!;
|
|
31
63
|
|
|
32
64
|
if (isElementText(c) && c.text && !(c.width || c.height)) {
|
|
33
|
-
return false;
|
|
65
|
+
return false; // specific text layout constraint
|
|
34
66
|
}
|
|
35
67
|
|
|
36
68
|
if (isTextNode(c) || c.flexItem === false) {
|
|
@@ -42,10 +74,15 @@ export default function (node: ElementNode): boolean {
|
|
|
42
74
|
}
|
|
43
75
|
|
|
44
76
|
const flexGrow = c.flexGrow;
|
|
45
|
-
if (flexGrow !== undefined && flexGrow
|
|
77
|
+
if (flexGrow !== undefined && flexGrow > 0) {
|
|
46
78
|
totalFlexGrow += flexGrow;
|
|
47
79
|
}
|
|
48
80
|
|
|
81
|
+
const flexShrink = c.flexShrink;
|
|
82
|
+
if (flexShrink !== undefined && flexShrink > 0) {
|
|
83
|
+
totalFlexShrink += flexShrink;
|
|
84
|
+
}
|
|
85
|
+
|
|
49
86
|
if (c[minDimension] && (c[dimension] || 0) < c[minDimension]) {
|
|
50
87
|
c[dimension] = c[minDimension]!;
|
|
51
88
|
}
|
|
@@ -68,13 +105,14 @@ export default function (node: ElementNode): boolean {
|
|
|
68
105
|
});
|
|
69
106
|
}
|
|
70
107
|
|
|
108
|
+
// Apply reverse layout ordering
|
|
71
109
|
if (isReverse || node.direction === 'rtl') {
|
|
72
110
|
processableChildrenIndices.reverse();
|
|
73
111
|
}
|
|
74
112
|
|
|
75
113
|
const numProcessedChildren = processableChildrenIndices.length;
|
|
76
114
|
if (numProcessedChildren === 0) {
|
|
77
|
-
return false;
|
|
115
|
+
return false;
|
|
78
116
|
}
|
|
79
117
|
|
|
80
118
|
const prop = isRow ? 'x' : 'y';
|
|
@@ -92,9 +130,10 @@ export default function (node: ElementNode): boolean {
|
|
|
92
130
|
const isWrapReverse = node.flexWrap === 'wrap-reverse';
|
|
93
131
|
const gap = node.gap || 0;
|
|
94
132
|
const justify = node.justifyContent || 'flexStart';
|
|
95
|
-
const
|
|
133
|
+
const align = node.alignItems || (node.flexWrap ? 'flexStart' : undefined);
|
|
96
134
|
let containerUpdated = false;
|
|
97
135
|
|
|
136
|
+
// Resolve sizes matching old processed calculation
|
|
98
137
|
const childMainSizes = new Float32Array(numProcessedChildren);
|
|
99
138
|
const childMarginStarts = new Float32Array(numProcessedChildren);
|
|
100
139
|
const childMarginEnds = new Float32Array(numProcessedChildren);
|
|
@@ -107,41 +146,55 @@ export default function (node: ElementNode): boolean {
|
|
|
107
146
|
|
|
108
147
|
for (let idx = 0; idx < numProcessedChildren; idx++) {
|
|
109
148
|
const c = children[processableChildrenIndices[idx]!] as ElementNode;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const
|
|
149
|
+
const marginArray = c.margin;
|
|
150
|
+
// index mappings for margins: Top: 0, Right: 1, Bottom: 2, Left: 3
|
|
151
|
+
// if row: main = left/right (3/1),
|
|
152
|
+
const flexBasis = c.flexBasis;
|
|
153
|
+
const isBasisAuto = flexBasis === undefined || flexBasis === 'auto';
|
|
154
|
+
const computedBasis = isBasisAuto
|
|
155
|
+
? c[dimension] || 0
|
|
156
|
+
: (flexBasis as number);
|
|
157
|
+
const baseMainSize = isBasisAuto
|
|
158
|
+
? computedBasis
|
|
159
|
+
: Math.max(computedBasis, c[minDimension] || 0);
|
|
160
|
+
|
|
161
|
+
const marginStart = isRow
|
|
162
|
+
? c.marginLeft || getArrayValue(marginArray, 3)
|
|
163
|
+
: c.marginTop || getArrayValue(marginArray, 0);
|
|
164
|
+
const marginEnd = isRow
|
|
165
|
+
? c.marginRight || getArrayValue(marginArray, 1)
|
|
166
|
+
: c.marginBottom || getArrayValue(marginArray, 2);
|
|
167
|
+
const marginCrossStart = isRow
|
|
168
|
+
? c.marginTop || getArrayValue(marginArray, 0)
|
|
169
|
+
: c.marginLeft || getArrayValue(marginArray, 3);
|
|
170
|
+
const marginCrossEnd = isRow
|
|
171
|
+
? c.marginBottom || getArrayValue(marginArray, 2)
|
|
172
|
+
: c.marginRight || getArrayValue(marginArray, 1);
|
|
114
173
|
|
|
115
174
|
childMainSizes[idx] = baseMainSize;
|
|
116
175
|
childMarginStarts[idx] = marginStart;
|
|
117
176
|
childMarginEnds[idx] = marginEnd;
|
|
118
177
|
childTotalMainSizes[idx] = baseMainSize + marginStart + marginEnd;
|
|
119
|
-
|
|
120
178
|
childCrossSizes[idx] = c[crossDimension] || 0;
|
|
121
|
-
childMarginCrossStarts[idx] =
|
|
122
|
-
childMarginCrossEnds[idx] =
|
|
179
|
+
childMarginCrossStarts[idx] = marginCrossStart;
|
|
180
|
+
childMarginCrossEnds[idx] = marginCrossEnd;
|
|
123
181
|
|
|
124
182
|
sumOfFlexBaseSizesWithMargins += childTotalMainSizes[idx]!;
|
|
125
183
|
}
|
|
126
184
|
|
|
127
|
-
if (totalFlexGrow > 0 && numProcessedChildren > 1) {
|
|
128
|
-
// When flex-grow is used, the container's size is considered fixed for this calculation pass,
|
|
129
|
-
// unless flexBoundary is explicitly set to allow container resizing based on content.
|
|
185
|
+
if ((totalFlexGrow > 0 || totalFlexShrink > 0) && numProcessedChildren > 1) {
|
|
130
186
|
node.flexBoundary = node.flexBoundary || 'fixed';
|
|
131
187
|
|
|
132
|
-
// Calculate the total space occupied by gaps between items.
|
|
133
188
|
const totalGapSpace =
|
|
134
189
|
numProcessedChildren > 0 ? gap * (numProcessedChildren - 1) : 0;
|
|
135
|
-
|
|
136
|
-
// Calculate the available space for flex items to grow into.
|
|
137
190
|
const availableSpace =
|
|
138
191
|
containerSize - sumOfFlexBaseSizesWithMargins - totalGapSpace;
|
|
139
192
|
|
|
140
|
-
if (availableSpace > 0) {
|
|
193
|
+
if (availableSpace > 0 && totalFlexGrow > 0) {
|
|
141
194
|
for (let idx = 0; idx < numProcessedChildren; idx++) {
|
|
142
195
|
const c = children[processableChildrenIndices[idx]!] as ElementNode;
|
|
143
|
-
const flexGrowValue = c.flexGrow;
|
|
144
|
-
if (flexGrowValue
|
|
196
|
+
const flexGrowValue = c.flexGrow || 0;
|
|
197
|
+
if (flexGrowValue > 0) {
|
|
145
198
|
const shareOfSpace = (flexGrowValue / totalFlexGrow) * availableSpace;
|
|
146
199
|
const newMainSize = childMainSizes[idx]! + shareOfSpace;
|
|
147
200
|
c[dimension] = newMainSize;
|
|
@@ -150,16 +203,43 @@ export default function (node: ElementNode): boolean {
|
|
|
150
203
|
newMainSize + childMarginStarts[idx]! + childMarginEnds[idx]!;
|
|
151
204
|
}
|
|
152
205
|
}
|
|
153
|
-
|
|
206
|
+
node._containsFlexGrow = node._containsFlexGrow ? null : true;
|
|
207
|
+
} else if (availableSpace < 0 && totalFlexShrink > 0) {
|
|
208
|
+
// Flex Shrink Phase
|
|
209
|
+
let totalScaledShrinkFactor = 0;
|
|
210
|
+
for (let idx = 0; idx < numProcessedChildren; idx++) {
|
|
211
|
+
const c = children[processableChildrenIndices[idx]!] as ElementNode;
|
|
212
|
+
const flexShrinkValue = c.flexShrink || 0;
|
|
213
|
+
totalScaledShrinkFactor += flexShrinkValue * childMainSizes[idx]!;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (totalScaledShrinkFactor > 0) {
|
|
217
|
+
for (let idx = 0; idx < numProcessedChildren; idx++) {
|
|
218
|
+
const c = children[processableChildrenIndices[idx]!] as ElementNode;
|
|
219
|
+
const flexShrinkValue = c.flexShrink || 0;
|
|
220
|
+
if (flexShrinkValue > 0) {
|
|
221
|
+
const shrinkRatio =
|
|
222
|
+
(flexShrinkValue * childMainSizes[idx]!) /
|
|
223
|
+
totalScaledShrinkFactor;
|
|
224
|
+
const sizeReduction = shrinkRatio * Math.abs(availableSpace);
|
|
225
|
+
let newMainSize = childMainSizes[idx]! - sizeReduction;
|
|
226
|
+
|
|
227
|
+
// Constrain by min width/height
|
|
228
|
+
const minBound = c[minDimension] || 0;
|
|
229
|
+
if (newMainSize < minBound) {
|
|
230
|
+
newMainSize = minBound;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
c[dimension] = newMainSize;
|
|
234
|
+
childMainSizes[idx] = newMainSize;
|
|
235
|
+
childTotalMainSizes[idx] =
|
|
236
|
+
newMainSize + childMarginStarts[idx]! + childMarginEnds[idx]!;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
154
240
|
node._containsFlexGrow = node._containsFlexGrow ? null : true;
|
|
155
241
|
} else if (node._containsFlexGrow) {
|
|
156
242
|
node._containsFlexGrow = null;
|
|
157
|
-
} else {
|
|
158
|
-
// No positive space available for items to grow, or items overflow.
|
|
159
|
-
// flex-grow has no effect in this case.
|
|
160
|
-
console.warn(
|
|
161
|
-
'No available space for flex-grow items to expand, or items overflow.',
|
|
162
|
-
);
|
|
163
243
|
}
|
|
164
244
|
}
|
|
165
245
|
|
|
@@ -175,7 +255,6 @@ export default function (node: ElementNode): boolean {
|
|
|
175
255
|
}
|
|
176
256
|
}
|
|
177
257
|
|
|
178
|
-
const align = node.alignItems || (node.flexWrap ? 'flexStart' : undefined);
|
|
179
258
|
const doCrossAlign = containerCrossSize
|
|
180
259
|
? (c: ElementNode, idx: number, crossCurrentPos: number = 0) => {
|
|
181
260
|
const alignSelf = c.alignSelf || align;
|
|
@@ -213,23 +292,23 @@ export default function (node: ElementNode): boolean {
|
|
|
213
292
|
}
|
|
214
293
|
}
|
|
215
294
|
|
|
216
|
-
let currentPos =
|
|
295
|
+
let currentPos = paddingStart;
|
|
217
296
|
if (justify === 'flexStart') {
|
|
218
|
-
if (node.flexWrap === 'wrap'
|
|
297
|
+
if (node.flexWrap === 'wrap') {
|
|
219
298
|
const childCrossSizeVar =
|
|
220
299
|
numProcessedChildren > 0 ? childCrossSizes[0]! : containerCrossSize;
|
|
221
300
|
let crossCurrentPos = isWrapReverse
|
|
222
|
-
? containerCrossSize - childCrossSizeVar
|
|
223
|
-
:
|
|
301
|
+
? containerCrossSize - paddingCrossEnd - childCrossSizeVar
|
|
302
|
+
: paddingCrossStart;
|
|
224
303
|
const crossGap = isRow ? (node.columnGap ?? gap) : (node.rowGap ?? gap);
|
|
225
304
|
|
|
226
305
|
for (let idx = 0; idx < numProcessedChildren; idx++) {
|
|
227
306
|
const c = children[processableChildrenIndices[idx]!] as ElementNode;
|
|
228
307
|
if (
|
|
229
308
|
currentPos + childTotalMainSizes[idx]! > containerSize &&
|
|
230
|
-
currentPos >
|
|
309
|
+
currentPos > paddingStart
|
|
231
310
|
) {
|
|
232
|
-
currentPos =
|
|
311
|
+
currentPos = paddingStart;
|
|
233
312
|
crossCurrentPos += isWrapReverse
|
|
234
313
|
? -(childCrossSizeVar + crossGap)
|
|
235
314
|
: childCrossSizeVar + crossGap;
|
|
@@ -240,8 +319,8 @@ export default function (node: ElementNode): boolean {
|
|
|
240
319
|
}
|
|
241
320
|
|
|
242
321
|
const finalCrossSize = isWrapReverse
|
|
243
|
-
? containerCrossSize - crossCurrentPos
|
|
244
|
-
: crossCurrentPos + childCrossSizeVar;
|
|
322
|
+
? containerCrossSize - crossCurrentPos + paddingCrossStart
|
|
323
|
+
: crossCurrentPos + childCrossSizeVar + paddingCrossEnd;
|
|
245
324
|
|
|
246
325
|
if (node[crossDimension] !== finalCrossSize) {
|
|
247
326
|
node[`preFlex${crossDimension}`] = node[crossDimension];
|
|
@@ -253,77 +332,77 @@ export default function (node: ElementNode): boolean {
|
|
|
253
332
|
const c = children[processableChildrenIndices[idx]!] as ElementNode;
|
|
254
333
|
c[prop] = currentPos + childMarginStarts[idx]!;
|
|
255
334
|
currentPos += childTotalMainSizes[idx]! + gap;
|
|
256
|
-
doCrossAlign(c, idx);
|
|
335
|
+
doCrossAlign(c, idx, paddingCrossStart);
|
|
257
336
|
}
|
|
258
337
|
}
|
|
338
|
+
|
|
259
339
|
// Update container size
|
|
260
340
|
if (node.flexBoundary !== 'fixed' && node.flexWrap !== 'wrap') {
|
|
261
|
-
let calculatedSize = currentPos - gap +
|
|
341
|
+
let calculatedSize = currentPos - gap + paddingEnd;
|
|
262
342
|
const minSize = node[minDimension] || 0;
|
|
263
343
|
if (calculatedSize < minSize) {
|
|
264
344
|
calculatedSize = minSize;
|
|
265
345
|
}
|
|
266
346
|
if (calculatedSize !== (node[dimension] || 0)) {
|
|
267
|
-
// store the original size for Row & Column
|
|
268
347
|
node[`preFlex${dimension}`] = containerSize;
|
|
269
348
|
node[dimension] = calculatedSize;
|
|
270
349
|
return true;
|
|
271
350
|
}
|
|
272
351
|
}
|
|
273
352
|
} else if (justify === 'flexEnd') {
|
|
274
|
-
currentPos = containerSize -
|
|
353
|
+
currentPos = containerSize - paddingEnd;
|
|
275
354
|
for (let idx = numProcessedChildren - 1; idx >= 0; idx--) {
|
|
276
355
|
const c = children[processableChildrenIndices[idx]!] as ElementNode;
|
|
277
356
|
c[prop] = currentPos - childMainSizes[idx]! - childMarginEnds[idx]!;
|
|
278
357
|
currentPos -= childTotalMainSizes[idx]! + gap;
|
|
279
|
-
doCrossAlign(c, idx);
|
|
358
|
+
doCrossAlign(c, idx, paddingCrossStart);
|
|
280
359
|
}
|
|
281
360
|
} else if (justify === 'center') {
|
|
282
361
|
currentPos =
|
|
283
362
|
(containerSize - (totalItemSize + gap * (numProcessedChildren - 1))) / 2 +
|
|
284
|
-
|
|
363
|
+
paddingStart;
|
|
285
364
|
for (let idx = 0; idx < numProcessedChildren; idx++) {
|
|
286
365
|
const c = children[processableChildrenIndices[idx]!] as ElementNode;
|
|
287
366
|
c[prop] = currentPos + childMarginStarts[idx]!;
|
|
288
367
|
currentPos += childTotalMainSizes[idx]! + gap;
|
|
289
|
-
doCrossAlign(c, idx);
|
|
368
|
+
doCrossAlign(c, idx, paddingCrossStart);
|
|
290
369
|
}
|
|
291
370
|
} else if (justify === 'spaceBetween') {
|
|
292
371
|
const spaceBetween =
|
|
293
372
|
numProcessedChildren > 1
|
|
294
|
-
? (containerSize - totalItemSize -
|
|
373
|
+
? (containerSize - totalItemSize - nodePaddingTotal) /
|
|
295
374
|
(numProcessedChildren - 1)
|
|
296
375
|
: 0;
|
|
297
|
-
currentPos =
|
|
376
|
+
currentPos = paddingStart;
|
|
298
377
|
for (let idx = 0; idx < numProcessedChildren; idx++) {
|
|
299
378
|
const c = children[processableChildrenIndices[idx]!] as ElementNode;
|
|
300
379
|
c[prop] = currentPos + childMarginStarts[idx]!;
|
|
301
380
|
currentPos += childTotalMainSizes[idx]! + spaceBetween;
|
|
302
|
-
doCrossAlign(c, idx);
|
|
381
|
+
doCrossAlign(c, idx, paddingCrossStart);
|
|
303
382
|
}
|
|
304
383
|
} else if (justify === 'spaceAround') {
|
|
305
384
|
const spaceAround =
|
|
306
385
|
numProcessedChildren > 0
|
|
307
|
-
? (containerSize - totalItemSize -
|
|
386
|
+
? (containerSize - totalItemSize - nodePaddingTotal) /
|
|
308
387
|
numProcessedChildren
|
|
309
388
|
: 0;
|
|
310
|
-
currentPos =
|
|
389
|
+
currentPos = paddingStart + spaceAround / 2;
|
|
311
390
|
for (let idx = 0; idx < numProcessedChildren; idx++) {
|
|
312
391
|
const c = children[processableChildrenIndices[idx]!] as ElementNode;
|
|
313
392
|
c[prop] = currentPos + childMarginStarts[idx]!;
|
|
314
393
|
currentPos += childTotalMainSizes[idx]! + spaceAround;
|
|
315
|
-
doCrossAlign(c, idx);
|
|
394
|
+
doCrossAlign(c, idx, paddingCrossStart);
|
|
316
395
|
}
|
|
317
396
|
} else if (justify === 'spaceEvenly') {
|
|
318
397
|
const spaceEvenly =
|
|
319
|
-
(containerSize - totalItemSize -
|
|
398
|
+
(containerSize - totalItemSize - nodePaddingTotal) /
|
|
320
399
|
(numProcessedChildren + 1);
|
|
321
|
-
currentPos = spaceEvenly +
|
|
400
|
+
currentPos = spaceEvenly + paddingStart;
|
|
322
401
|
for (let idx = 0; idx < numProcessedChildren; idx++) {
|
|
323
402
|
const c = children[processableChildrenIndices[idx]!] as ElementNode;
|
|
324
403
|
c[prop] = currentPos + childMarginStarts[idx]!;
|
|
325
404
|
currentPos += childTotalMainSizes[idx]! + spaceEvenly;
|
|
326
|
-
doCrossAlign(c, idx);
|
|
405
|
+
doCrossAlign(c, idx, paddingCrossStart);
|
|
327
406
|
}
|
|
328
407
|
}
|
|
329
408
|
|
|
@@ -69,6 +69,20 @@ export type EventHandlers<Map> = {
|
|
|
69
69
|
|
|
70
70
|
export interface KeyHoldMap extends DefaultKeyHoldMap {}
|
|
71
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Return type of key handlers (onEnter, onUp, onKeyPress, onCapture*, etc.).
|
|
74
|
+
*
|
|
75
|
+
* **1.3 contract:** a handler that runs is considered to have consumed the
|
|
76
|
+
* event by default — traversal up the focus path stops at that element. To
|
|
77
|
+
* let the event continue bubbling (for observation-only handlers like
|
|
78
|
+
* logging, analytics, instrumentation), explicitly `return false`.
|
|
79
|
+
*
|
|
80
|
+
* - `return false` → not consumed; bubble to the next ancestor.
|
|
81
|
+
* - any other return → consumed (default).
|
|
82
|
+
*
|
|
83
|
+
* This is a behavior flip from 1.2, where `return true` was required to
|
|
84
|
+
* consume. See `roadmap.md` for migration notes.
|
|
85
|
+
*/
|
|
72
86
|
export type KeyHandlerReturn = boolean | void;
|
|
73
87
|
|
|
74
88
|
export type KeyHandler = (
|