@react-spectrum/card 3.0.0-alpha.0 → 3.0.0-alpha.1
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/dist/main.css +1 -1
- package/dist/main.css.map +1 -1
- package/dist/main.js +89 -67
- package/dist/main.js.map +1 -1
- package/dist/module.js +89 -69
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +18 -21
- package/dist/types.d.ts.map +1 -1
- package/package.json +15 -14
- package/src/BaseLayout.tsx +13 -1
- package/src/CardBase.tsx +7 -5
- package/src/CardView.tsx +29 -19
- package/src/GalleryLayout.tsx +7 -14
- package/src/GridLayout.tsx +40 -29
- package/src/WaterfallLayout.tsx +1 -6
- package/src/cardview.css +0 -16
package/dist/main.js
CHANGED
|
@@ -50,6 +50,7 @@ var _react2 = require("react");
|
|
|
50
50
|
var _react = $parcel$interopDefault(_react2);
|
|
51
51
|
|
|
52
52
|
var {
|
|
53
|
+
useCallback,
|
|
53
54
|
useMemo,
|
|
54
55
|
useRef,
|
|
55
56
|
useState,
|
|
@@ -65,6 +66,7 @@ var {
|
|
|
65
66
|
filterDOMProps,
|
|
66
67
|
mergeProps,
|
|
67
68
|
useLayoutEffect,
|
|
69
|
+
useResizeObserver,
|
|
68
70
|
useSlotId
|
|
69
71
|
} = require("@react-aria/utils");
|
|
70
72
|
|
|
@@ -125,6 +127,9 @@ $e80f3e549a26f7869571c50d85a$exports = {
|
|
|
125
127
|
"spectrum-Card--gallery": "_spectrum-Card--gallery_dd040",
|
|
126
128
|
"spectrum-Card--closeToSquare": "_spectrum-Card--closeToSquare_dd040",
|
|
127
129
|
"spectrum-Card--horizontal": "_spectrum-Card--horizontal_dd040",
|
|
130
|
+
"spectrum-CardView": "_spectrum-CardView_dd040",
|
|
131
|
+
"spectrum-CardView-centeredWrapper": "_spectrum-CardView-centeredWrapper_dd040",
|
|
132
|
+
"spectrum-CardView-row": "_spectrum-CardView-row_dd040",
|
|
128
133
|
"is-drop-target": "_is-drop-target_dd040"
|
|
129
134
|
};
|
|
130
135
|
|
|
@@ -137,8 +142,7 @@ function $d2268ebff01b30dc8701260db9de8b73$export$useCardViewContext() {
|
|
|
137
142
|
var $e80f3e549a26f7869571c50d85a$$interop$default = $parcel$interopDefault($e80f3e549a26f7869571c50d85a$exports);
|
|
138
143
|
|
|
139
144
|
function $c05a01cf76428c47b3d1dc747d32$var$CardBase(props, ref) {
|
|
140
|
-
props = useProviderProps(props);
|
|
141
|
-
|
|
145
|
+
props = useProviderProps(props);
|
|
142
146
|
let context = $d2268ebff01b30dc8701260db9de8b73$export$useCardViewContext() || {}; // we can call again here, won't change from Card.tsx
|
|
143
147
|
|
|
144
148
|
let {
|
|
@@ -189,14 +193,18 @@ function $c05a01cf76428c47b3d1dc747d32$var$CardBase(props, ref) {
|
|
|
189
193
|
let hasPreview = hasPreviewImage || hasPreviewIllustration; // this is for horizontal cards
|
|
190
194
|
|
|
191
195
|
let [height, setHeight] = useState(NaN);
|
|
192
|
-
|
|
196
|
+
let updateHeight = useCallback(() => {
|
|
193
197
|
if (orientation !== 'horizontal') {
|
|
194
198
|
return;
|
|
195
199
|
}
|
|
196
200
|
|
|
197
201
|
let cardHeight = gridRef.current.getBoundingClientRect().height;
|
|
198
202
|
setHeight(cardHeight);
|
|
199
|
-
}, [gridRef, setHeight
|
|
203
|
+
}, [orientation, gridRef, setHeight]);
|
|
204
|
+
useResizeObserver({
|
|
205
|
+
ref: gridRef,
|
|
206
|
+
onResize: updateHeight
|
|
207
|
+
});
|
|
200
208
|
let aspectRatioEnforce = undefined;
|
|
201
209
|
|
|
202
210
|
if (orientation === 'horizontal' && !isNaN(height)) {
|
|
@@ -362,13 +370,6 @@ function $c05a01cf76428c47b3d1dc747d32$var$useCard(props) {
|
|
|
362
370
|
|
|
363
371
|
const $c05a01cf76428c47b3d1dc747d32$export$CardBase = /*#__PURE__*/_react.forwardRef($c05a01cf76428c47b3d1dc747d32$var$CardBase);
|
|
364
372
|
|
|
365
|
-
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-spectrum/card/src/cardview.css
|
|
366
|
-
var $ebdef199d5449cee6008bd291a26a$exports = {};
|
|
367
|
-
$ebdef199d5449cee6008bd291a26a$exports = {
|
|
368
|
-
"react-spectrum-CardView-centeredWrapper": "_react-spectrum-CardView-centeredWrapper_0cd7c",
|
|
369
|
-
"react-spectrum-CardView-CardWrapper": "_react-spectrum-CardView-CardWrapper_0cd7c",
|
|
370
|
-
"react-spectrum-CardView": "_react-spectrum-CardView_0cd7c"
|
|
371
|
-
};
|
|
372
373
|
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-spectrum/card/intl/ar-AE.json
|
|
373
374
|
var $a73c2251b3d85c65b5e95b28f93c8042$exports = {};
|
|
374
375
|
$a73c2251b3d85c65b5e95b28f93c8042$exports = JSON.parse("{\"loading\":\"جارٍ التحميل...\",\"loadingMore\":\"جارٍ تحميل المزيد...\"}");
|
|
@@ -508,7 +509,6 @@ const $e13c04c0c86a4119edea9d2f83b$var$intlMessages = {
|
|
|
508
509
|
"zh-CN": _babelRuntimeHelpersInteropRequireDefault($b9216cdc8ad21d0c1b8e94822b8d13a3$exports).default,
|
|
509
510
|
"zh-TW": _babelRuntimeHelpersInteropRequireDefault($f9135827d71b7bceae5eb74e24cd6$exports).default
|
|
510
511
|
};
|
|
511
|
-
var $ebdef199d5449cee6008bd291a26a$$interop$default = $parcel$interopDefault($ebdef199d5449cee6008bd291a26a$exports);
|
|
512
512
|
|
|
513
513
|
function $e13c04c0c86a4119edea9d2f83b$var$CardView(props, ref) {
|
|
514
514
|
let {
|
|
@@ -523,7 +523,8 @@ function $e13c04c0c86a4119edea9d2f83b$var$CardView(props, ref) {
|
|
|
523
523
|
renderEmptyState,
|
|
524
524
|
layout,
|
|
525
525
|
loadingState,
|
|
526
|
-
onLoadMore
|
|
526
|
+
onLoadMore,
|
|
527
|
+
cardOrientation = 'vertical'
|
|
527
528
|
} = props;
|
|
528
529
|
let collator = useCollator({
|
|
529
530
|
usage: 'search',
|
|
@@ -531,18 +532,11 @@ function $e13c04c0c86a4119edea9d2f83b$var$CardView(props, ref) {
|
|
|
531
532
|
});
|
|
532
533
|
let isLoading = loadingState === 'loading' || loadingState === 'loadingMore';
|
|
533
534
|
let cardViewLayout = useMemo(() => typeof layout === 'function' ? new layout({
|
|
534
|
-
collator
|
|
535
|
-
|
|
535
|
+
collator,
|
|
536
|
+
cardOrientation,
|
|
537
|
+
scale
|
|
538
|
+
}) : layout, [layout, collator, cardOrientation, scale]);
|
|
536
539
|
let layoutType = cardViewLayout.layoutType;
|
|
537
|
-
|
|
538
|
-
if (typeof layout === 'function') {
|
|
539
|
-
if (layoutType === 'grid') {
|
|
540
|
-
cardViewLayout.itemPadding = scale === 'large' ? 116 : 95;
|
|
541
|
-
} else if (layoutType === 'gallery') {
|
|
542
|
-
cardViewLayout.itemPadding = scale === 'large' ? 143 : 114;
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
|
|
546
540
|
let formatMessage = useMessageFormatter($e13c04c0c86a4119edea9d2f83b$var$intlMessages);
|
|
547
541
|
let {
|
|
548
542
|
direction
|
|
@@ -567,7 +561,9 @@ function $e13c04c0c86a4119edea9d2f83b$var$CardView(props, ref) {
|
|
|
567
561
|
}))
|
|
568
562
|
}), [collection]);
|
|
569
563
|
let state = useGridState(_babelRuntimeHelpersExtends({}, props, {
|
|
570
|
-
|
|
564
|
+
selectionMode: cardOrientation === 'horizontal' && layoutType === 'grid' ? 'none' : props.selectionMode,
|
|
565
|
+
collection: gridCollection,
|
|
566
|
+
focusMode: 'cell'
|
|
571
567
|
}));
|
|
572
568
|
cardViewLayout.collection = gridCollection;
|
|
573
569
|
cardViewLayout.disabledKeys = state.disabledKeys;
|
|
@@ -581,7 +577,6 @@ function $e13c04c0c86a4119edea9d2f83b$var$CardView(props, ref) {
|
|
|
581
577
|
}), state, domRef);
|
|
582
578
|
|
|
583
579
|
let renderWrapper = (parent, reusableView) => /*#__PURE__*/_react.createElement(VirtualizerItem, {
|
|
584
|
-
className: classNames($ebdef199d5449cee6008bd291a26a$$interop$default, 'react-spectrum-CardView-CardWrapper'),
|
|
585
580
|
key: reusableView.key,
|
|
586
581
|
reusableView: reusableView,
|
|
587
582
|
parent: parent
|
|
@@ -592,17 +587,26 @@ function $e13c04c0c86a4119edea9d2f83b$var$CardView(props, ref) {
|
|
|
592
587
|
|
|
593
588
|
if ((focusedItem == null ? void 0 : focusedItem.parentKey) != null) {
|
|
594
589
|
focusedKey = focusedItem.parentKey;
|
|
595
|
-
}
|
|
590
|
+
}
|
|
596
591
|
|
|
592
|
+
let margin = cardViewLayout.margin || 0;
|
|
593
|
+
let virtualizer = cardViewLayout.virtualizer;
|
|
594
|
+
let scrollToItem = useCallback(key => {
|
|
595
|
+
virtualizer && virtualizer.scrollToItem(key, {
|
|
596
|
+
duration: 0,
|
|
597
|
+
offsetY: margin
|
|
598
|
+
});
|
|
599
|
+
}, [margin, virtualizer]); // TODO: does aria-row count and aria-col count need to be modified? Perhaps aria-col count needs to be omitted
|
|
597
600
|
|
|
598
601
|
return /*#__PURE__*/_react.createElement($d2268ebff01b30dc8701260db9de8b73$export$CardViewContext.Provider, {
|
|
599
602
|
value: {
|
|
600
603
|
state,
|
|
601
604
|
isQuiet,
|
|
602
|
-
layout: cardViewLayout
|
|
605
|
+
layout: cardViewLayout,
|
|
606
|
+
cardOrientation
|
|
603
607
|
}
|
|
604
608
|
}, /*#__PURE__*/_react.createElement(Virtualizer, _babelRuntimeHelpersExtends({}, gridProps, styleProps, {
|
|
605
|
-
className: classNames($
|
|
609
|
+
className: classNames($e80f3e549a26f7869571c50d85a$$interop$default, 'spectrum-CardView'),
|
|
606
610
|
ref: domRef,
|
|
607
611
|
focusedKey: focusedKey,
|
|
608
612
|
scrollDirection: "vertical",
|
|
@@ -610,7 +614,9 @@ function $e13c04c0c86a4119edea9d2f83b$var$CardView(props, ref) {
|
|
|
610
614
|
collection: gridCollection,
|
|
611
615
|
isLoading: isLoading,
|
|
612
616
|
onLoadMore: onLoadMore,
|
|
613
|
-
renderWrapper: renderWrapper
|
|
617
|
+
renderWrapper: renderWrapper,
|
|
618
|
+
transitionDuration: isLoading ? 160 : 220,
|
|
619
|
+
scrollToItem: scrollToItem
|
|
614
620
|
}), (type, item) => {
|
|
615
621
|
if (type === 'item') {
|
|
616
622
|
return /*#__PURE__*/_react.createElement($e13c04c0c86a4119edea9d2f83b$var$InternalCard, {
|
|
@@ -643,7 +649,7 @@ function $e13c04c0c86a4119edea9d2f83b$var$CenteredWrapper(_ref) {
|
|
|
643
649
|
return /*#__PURE__*/_react.createElement("div", {
|
|
644
650
|
role: "row",
|
|
645
651
|
"aria-rowindex": state.collection.size + 1,
|
|
646
|
-
className: classNames($
|
|
652
|
+
className: classNames($e80f3e549a26f7869571c50d85a$$interop$default, 'spectrum-CardView-centeredWrapper')
|
|
647
653
|
}, /*#__PURE__*/_react.createElement("div", {
|
|
648
654
|
role: "gridcell"
|
|
649
655
|
}, children));
|
|
@@ -681,11 +687,13 @@ function $e13c04c0c86a4119edea9d2f83b$var$InternalCard(props) {
|
|
|
681
687
|
isQuiet = true;
|
|
682
688
|
}
|
|
683
689
|
|
|
690
|
+
if (layoutType !== 'grid') {
|
|
691
|
+
cardOrientation = 'vertical';
|
|
692
|
+
}
|
|
693
|
+
|
|
684
694
|
return /*#__PURE__*/_react.createElement("div", _babelRuntimeHelpersExtends({}, rowProps, {
|
|
685
695
|
ref: rowRef,
|
|
686
|
-
|
|
687
|
-
height: '100%'
|
|
688
|
-
}
|
|
696
|
+
className: classNames($e80f3e549a26f7869571c50d85a$$interop$default, 'spectrum-CardView-row')
|
|
689
697
|
}), /*#__PURE__*/_react.createElement($c05a01cf76428c47b3d1dc747d32$export$CardBase, {
|
|
690
698
|
ref: cellRef,
|
|
691
699
|
articleProps: gridCellProps,
|
|
@@ -719,9 +727,13 @@ class $ae626509048548c15655cbbeb258411$export$BaseLayout extends Layout {
|
|
|
719
727
|
this.isLoading = void 0;
|
|
720
728
|
this.disabledKeys = new Set();
|
|
721
729
|
this.direction = void 0;
|
|
730
|
+
this.scale = void 0;
|
|
731
|
+
this.margin = void 0;
|
|
722
732
|
this.layoutInfos = new Map();
|
|
723
733
|
this.collator = options.collator;
|
|
724
734
|
this.lastCollection = null;
|
|
735
|
+
this.scale = options.scale || 'medium';
|
|
736
|
+
this.margin = options.margin || 24;
|
|
725
737
|
}
|
|
726
738
|
|
|
727
739
|
validate(invalidationContext) {
|
|
@@ -979,14 +991,11 @@ class $ae626509048548c15655cbbeb258411$export$BaseLayout extends Layout {
|
|
|
979
991
|
|
|
980
992
|
}
|
|
981
993
|
|
|
982
|
-
// TODO: copied from V2, update this with the proper spectrum values
|
|
983
|
-
// Should these be affected by Scale as well?
|
|
984
994
|
const $a23e32931be921d018d1ae1efeda8$var$DEFAULT_OPTIONS = {
|
|
985
995
|
S: {
|
|
986
996
|
idealRowHeight: 112,
|
|
987
997
|
minItemSize: new Size(96, 96),
|
|
988
998
|
itemSpacing: new Size(8, 16),
|
|
989
|
-
// TODO: will need to update as well
|
|
990
999
|
itemPadding: 24,
|
|
991
1000
|
dropSpacing: 50,
|
|
992
1001
|
margin: 8
|
|
@@ -995,8 +1004,10 @@ const $a23e32931be921d018d1ae1efeda8$var$DEFAULT_OPTIONS = {
|
|
|
995
1004
|
idealRowHeight: 208,
|
|
996
1005
|
minItemSize: new Size(136, 136),
|
|
997
1006
|
itemSpacing: new Size(18, 18),
|
|
998
|
-
|
|
999
|
-
|
|
1007
|
+
itemPadding: {
|
|
1008
|
+
'medium': 114,
|
|
1009
|
+
'large': 143
|
|
1010
|
+
},
|
|
1000
1011
|
dropSpacing: 100,
|
|
1001
1012
|
margin: 24
|
|
1002
1013
|
}
|
|
@@ -1008,10 +1019,8 @@ class GalleryLayout extends $ae626509048548c15655cbbeb258411$export$BaseLayout {
|
|
|
1008
1019
|
options = {};
|
|
1009
1020
|
}
|
|
1010
1021
|
|
|
1011
|
-
super(options);
|
|
1012
|
-
|
|
1022
|
+
super(options);
|
|
1013
1023
|
this.idealRowHeight = void 0;
|
|
1014
|
-
this.margin = void 0;
|
|
1015
1024
|
this.itemSpacing = void 0;
|
|
1016
1025
|
this.itemPadding = void 0;
|
|
1017
1026
|
this.minItemSize = void 0;
|
|
@@ -1019,7 +1028,7 @@ class GalleryLayout extends $ae626509048548c15655cbbeb258411$export$BaseLayout {
|
|
|
1019
1028
|
let cardSize = 'L';
|
|
1020
1029
|
this.idealRowHeight = options.idealRowHeight || $a23e32931be921d018d1ae1efeda8$var$DEFAULT_OPTIONS[cardSize].idealRowHeight;
|
|
1021
1030
|
this.itemSpacing = options.itemSpacing || $a23e32931be921d018d1ae1efeda8$var$DEFAULT_OPTIONS[cardSize].itemSpacing;
|
|
1022
|
-
this.itemPadding = options.itemPadding != null ? options.itemPadding : $a23e32931be921d018d1ae1efeda8$var$DEFAULT_OPTIONS[cardSize].itemPadding;
|
|
1031
|
+
this.itemPadding = options.itemPadding != null ? options.itemPadding : $a23e32931be921d018d1ae1efeda8$var$DEFAULT_OPTIONS[cardSize].itemPadding[this.scale];
|
|
1023
1032
|
this.minItemSize = options.minItemSize || $a23e32931be921d018d1ae1efeda8$var$DEFAULT_OPTIONS[cardSize].minItemSize;
|
|
1024
1033
|
this.threshold = options.threshold || 1;
|
|
1025
1034
|
this.margin = options.margin != null ? options.margin : $a23e32931be921d018d1ae1efeda8$var$DEFAULT_OPTIONS[cardSize].margin;
|
|
@@ -1151,6 +1160,7 @@ class GalleryLayout extends $ae626509048548c15655cbbeb258411$export$BaseLayout {
|
|
|
1151
1160
|
let itemWidth = Math.max(widths[j - index][1], this.minItemSize.width);
|
|
1152
1161
|
let rect = new Rect(x, y, itemWidth, itemHeight);
|
|
1153
1162
|
let layoutInfo = new LayoutInfo(node.type, node.key, rect);
|
|
1163
|
+
layoutInfo.allowOverflow = true;
|
|
1154
1164
|
this.layoutInfos.set(node.key, layoutInfo);
|
|
1155
1165
|
x += itemWidth + this.itemSpacing.width;
|
|
1156
1166
|
}
|
|
@@ -1266,12 +1276,12 @@ function $a23e32931be921d018d1ae1efeda8$var$linearPartition(seq, k) {
|
|
|
1266
1276
|
return result;
|
|
1267
1277
|
}
|
|
1268
1278
|
|
|
1269
|
-
// TODO: copied from V2, update this with the proper spectrum values
|
|
1270
|
-
// Should these be affected by Scale as well?
|
|
1271
1279
|
const $e0c00724bec6201efad9430accf8c3b1$var$DEFAULT_OPTIONS = {
|
|
1272
1280
|
S: {
|
|
1273
1281
|
itemPadding: 20,
|
|
1274
|
-
minItemSize:
|
|
1282
|
+
minItemSize: {
|
|
1283
|
+
'vertical': new Size(96, 96)
|
|
1284
|
+
},
|
|
1275
1285
|
maxItemSize: new Size(Infinity, Infinity),
|
|
1276
1286
|
margin: 8,
|
|
1277
1287
|
minSpace: new Size(6, 6),
|
|
@@ -1279,10 +1289,20 @@ const $e0c00724bec6201efad9430accf8c3b1$var$DEFAULT_OPTIONS = {
|
|
|
1279
1289
|
dropSpacing: 50
|
|
1280
1290
|
},
|
|
1281
1291
|
L: {
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1292
|
+
itemPadding: {
|
|
1293
|
+
'vertical': {
|
|
1294
|
+
'medium': 78,
|
|
1295
|
+
'large': 98
|
|
1296
|
+
},
|
|
1297
|
+
'horizontal': {
|
|
1298
|
+
'medium': 150,
|
|
1299
|
+
'large': 170
|
|
1300
|
+
}
|
|
1301
|
+
},
|
|
1302
|
+
minItemSize: {
|
|
1303
|
+
'vertical': new Size(208, 208),
|
|
1304
|
+
'horizontal': new Size(102, 102)
|
|
1305
|
+
},
|
|
1286
1306
|
maxItemSize: new Size(Infinity, Infinity),
|
|
1287
1307
|
margin: 24,
|
|
1288
1308
|
minSpace: new Size(18, 18),
|
|
@@ -1297,25 +1317,25 @@ class GridLayout extends $ae626509048548c15655cbbeb258411$export$BaseLayout {
|
|
|
1297
1317
|
options = {};
|
|
1298
1318
|
}
|
|
1299
1319
|
|
|
1300
|
-
super(options);
|
|
1301
|
-
|
|
1320
|
+
super(options);
|
|
1302
1321
|
this.minItemSize = void 0;
|
|
1303
1322
|
this.maxItemSize = void 0;
|
|
1304
|
-
this.margin = void 0;
|
|
1305
1323
|
this.minSpace = void 0;
|
|
1306
1324
|
this.maxColumns = void 0;
|
|
1307
1325
|
this.itemPadding = void 0;
|
|
1326
|
+
this.cardOrientation = void 0;
|
|
1308
1327
|
this.itemSize = void 0;
|
|
1309
1328
|
this.numColumns = void 0;
|
|
1310
1329
|
this.numRows = void 0;
|
|
1311
1330
|
this.horizontalSpacing = void 0;
|
|
1312
1331
|
let cardSize = 'L';
|
|
1313
|
-
this.
|
|
1332
|
+
this.cardOrientation = options.cardOrientation || 'vertical';
|
|
1333
|
+
this.minItemSize = options.minItemSize || $e0c00724bec6201efad9430accf8c3b1$var$DEFAULT_OPTIONS[cardSize].minItemSize[this.cardOrientation];
|
|
1314
1334
|
this.maxItemSize = options.maxItemSize || $e0c00724bec6201efad9430accf8c3b1$var$DEFAULT_OPTIONS[cardSize].maxItemSize;
|
|
1315
1335
|
this.margin = options.margin != null ? options.margin : $e0c00724bec6201efad9430accf8c3b1$var$DEFAULT_OPTIONS[cardSize].margin;
|
|
1316
1336
|
this.minSpace = options.minSpace || $e0c00724bec6201efad9430accf8c3b1$var$DEFAULT_OPTIONS[cardSize].minSpace;
|
|
1317
1337
|
this.maxColumns = options.maxColumns || $e0c00724bec6201efad9430accf8c3b1$var$DEFAULT_OPTIONS[cardSize].maxColumns;
|
|
1318
|
-
this.itemPadding = options.itemPadding != null ? options.itemPadding : $e0c00724bec6201efad9430accf8c3b1$var$DEFAULT_OPTIONS[cardSize].itemPadding;
|
|
1338
|
+
this.itemPadding = options.itemPadding != null ? options.itemPadding : $e0c00724bec6201efad9430accf8c3b1$var$DEFAULT_OPTIONS[cardSize].itemPadding[this.cardOrientation][this.scale];
|
|
1319
1339
|
this.itemSize = null;
|
|
1320
1340
|
this.numColumns = 0;
|
|
1321
1341
|
this.numRows = 0;
|
|
@@ -1324,8 +1344,7 @@ class GridLayout extends $ae626509048548c15655cbbeb258411$export$BaseLayout {
|
|
|
1324
1344
|
|
|
1325
1345
|
get layoutType() {
|
|
1326
1346
|
return 'grid';
|
|
1327
|
-
}
|
|
1328
|
-
|
|
1347
|
+
}
|
|
1329
1348
|
|
|
1330
1349
|
getIndexAtPoint(x, y, allowInsertingAtEnd) {
|
|
1331
1350
|
if (allowInsertingAtEnd === void 0) {
|
|
@@ -1360,7 +1379,7 @@ class GridLayout extends $ae626509048548c15655cbbeb258411$export$BaseLayout {
|
|
|
1360
1379
|
let keyFromIndex = this.collection.rows[index].key;
|
|
1361
1380
|
let layoutInfo = this.layoutInfos.get(keyFromIndex);
|
|
1362
1381
|
|
|
1363
|
-
if (this.isVisible(layoutInfo, rect)) {
|
|
1382
|
+
if (layoutInfo && this.isVisible(layoutInfo, rect)) {
|
|
1364
1383
|
res.push(layoutInfo);
|
|
1365
1384
|
}
|
|
1366
1385
|
} // Check if loader is in view and add to res if so
|
|
@@ -1378,21 +1397,24 @@ class GridLayout extends $ae626509048548c15655cbbeb258411$export$BaseLayout {
|
|
|
1378
1397
|
|
|
1379
1398
|
buildCollection() {
|
|
1380
1399
|
let visibleWidth = this.virtualizer.visibleRect.width;
|
|
1381
|
-
let visibleHeight = this.virtualizer.visibleRect.height;
|
|
1400
|
+
let visibleHeight = this.virtualizer.visibleRect.height;
|
|
1401
|
+
let horizontalItemPadding = this.cardOrientation === 'horizontal' ? this.itemPadding : 0;
|
|
1402
|
+
let verticalItemPadding = this.cardOrientation === 'vertical' ? this.itemPadding : 0;
|
|
1403
|
+
let minCardWidth = this.minItemSize.width + horizontalItemPadding; // Compute the number of rows and columns needed to display the content
|
|
1382
1404
|
|
|
1383
1405
|
let availableWidth = visibleWidth - this.margin * 2;
|
|
1384
|
-
let columns = Math.floor((availableWidth + this.minSpace.width) / (
|
|
1406
|
+
let columns = Math.floor((availableWidth + this.minSpace.width) / (minCardWidth + this.minSpace.width));
|
|
1385
1407
|
this.numColumns = Math.max(1, Math.min(this.maxColumns, columns));
|
|
1386
1408
|
this.numRows = Math.ceil(this.collection.size / this.numColumns); // Compute the available width (minus the space between items)
|
|
1387
1409
|
|
|
1388
1410
|
let width = availableWidth - this.minSpace.width * Math.max(0, this.numColumns - 1); // Compute the item width based on the space available
|
|
1389
1411
|
|
|
1390
1412
|
let itemWidth = Math.floor(width / this.numColumns);
|
|
1391
|
-
itemWidth = Math.max(
|
|
1413
|
+
itemWidth = Math.max(minCardWidth, Math.min(this.maxItemSize.width, itemWidth)); // Compute the item height, which is proportional to the item width
|
|
1392
1414
|
|
|
1393
|
-
let t = (itemWidth -
|
|
1394
|
-
let itemHeight = this.minItemSize.height + this.minItemSize.height * t;
|
|
1395
|
-
itemHeight = Math.max(this.minItemSize.height, Math.min(this.maxItemSize.height, itemHeight)) +
|
|
1415
|
+
let t = (itemWidth - minCardWidth) / minCardWidth;
|
|
1416
|
+
let itemHeight = Math.floor(this.minItemSize.height + this.minItemSize.height * t);
|
|
1417
|
+
itemHeight = Math.max(this.minItemSize.height, Math.min(this.maxItemSize.height, itemHeight)) + verticalItemPadding;
|
|
1396
1418
|
this.itemSize = new Size(itemWidth, itemHeight); // Compute the horizontal spacing and content height
|
|
1397
1419
|
|
|
1398
1420
|
this.horizontalSpacing = this.numColumns < 2 ? 0 : Math.floor((availableWidth - this.numColumns * this.itemSize.width) / (this.numColumns - 1));
|
|
@@ -1439,6 +1461,7 @@ class GridLayout extends $ae626509048548c15655cbbeb258411$export$BaseLayout {
|
|
|
1439
1461
|
let rect = new Rect(x, y, this.itemSize.width, this.itemSize.height); // TODO: Perhaps have it so that the child key for each row is stored with the layoutInfo?
|
|
1440
1462
|
|
|
1441
1463
|
let layoutInfo = new LayoutInfo(node.type, node.key, rect);
|
|
1464
|
+
layoutInfo.allowOverflow = true;
|
|
1442
1465
|
this.layoutInfos.set(node.key, layoutInfo);
|
|
1443
1466
|
return layoutInfo;
|
|
1444
1467
|
} // Since the collection doesn't represent the visual layout, need to calculate what row and column the current key is in,
|
|
@@ -1496,7 +1519,6 @@ class WaterfallLayout extends $ae626509048548c15655cbbeb258411$export$BaseLayout
|
|
|
1496
1519
|
super(options);
|
|
1497
1520
|
this.minItemSize = void 0;
|
|
1498
1521
|
this.maxItemSize = void 0;
|
|
1499
|
-
this.margin = void 0;
|
|
1500
1522
|
this.minSpace = void 0;
|
|
1501
1523
|
this.maxColumns = void 0;
|
|
1502
1524
|
this.itemPadding = void 0;
|
|
@@ -1566,6 +1588,7 @@ class WaterfallLayout extends $ae626509048548c15655cbbeb258411$export$BaseLayout
|
|
|
1566
1588
|
let rect = new Rect(x, y, itemWidth, height);
|
|
1567
1589
|
let layoutInfo = new LayoutInfo(node.type, key, rect);
|
|
1568
1590
|
layoutInfo.estimatedSize = estimatedSize;
|
|
1591
|
+
layoutInfo.allowOverflow = true;
|
|
1569
1592
|
this.layoutInfos.set(key, layoutInfo); // TODO: From v2 figure out this bit, when does this get called and what to replace this.collectionView._transaction with?
|
|
1570
1593
|
// Removing it from v2 doesn't seem to do anything?
|
|
1571
1594
|
// if (layoutInfo.estimatedSize && !invalidationContext.contentChanged && !this.collectionView._transaction) {
|
|
@@ -1573,8 +1596,7 @@ class WaterfallLayout extends $ae626509048548c15655cbbeb258411$export$BaseLayout
|
|
|
1573
1596
|
// }
|
|
1574
1597
|
|
|
1575
1598
|
columnHeights[column] += layoutInfo.rect.height + this.minSpace.height;
|
|
1576
|
-
}
|
|
1577
|
-
|
|
1599
|
+
}
|
|
1578
1600
|
|
|
1579
1601
|
let maxHeight = Math.max.apply(Math, columnHeights) - this.minSpace.height + this.margin;
|
|
1580
1602
|
columnHeights.fill(maxHeight);
|