@react-spectrum/card 3.0.0-alpha.16 → 3.0.0-alpha.18
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/import.mjs +38 -25
- package/dist/main.css +1 -1
- package/dist/main.js +38 -25
- package/dist/main.js.map +1 -1
- package/dist/module.js +38 -25
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +14 -14
- package/dist/types.d.ts.map +1 -1
- package/package.json +20 -20
- package/src/BaseLayout.tsx +12 -11
- package/src/GridLayout.tsx +5 -2
- package/src/WaterfallLayout.tsx +5 -2
package/dist/main.js
CHANGED
|
@@ -14,6 +14,7 @@ var $jpY3B$reactariafocus = require("@react-aria/focus");
|
|
|
14
14
|
var $jpY3B$reactariainteractions = require("@react-aria/interactions");
|
|
15
15
|
var $jpY3B$reactstatelyvirtualizer = require("@react-stately/virtualizer");
|
|
16
16
|
var $jpY3B$swchelperslib_define_propertyjs = require("@swc/helpers/lib/_define_property.js");
|
|
17
|
+
var $jpY3B$reactstatelycollections = require("@react-stately/collections");
|
|
17
18
|
|
|
18
19
|
function $parcel$export(e, n, v, s) {
|
|
19
20
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
@@ -825,6 +826,7 @@ function $514a55f6d91f25ef$var$InternalCard(props) {
|
|
|
825
826
|
* governing permissions and limitations under the License.
|
|
826
827
|
*/
|
|
827
828
|
|
|
829
|
+
|
|
828
830
|
class $5ee605f09afaa4de$export$64943d2e59d72a29 extends (0, $jpY3B$reactstatelyvirtualizer.Layout) {
|
|
829
831
|
validate(invalidationContext) {
|
|
830
832
|
this.collection = this.virtualizer.collection;
|
|
@@ -887,31 +889,32 @@ class $5ee605f09afaa4de$export$64943d2e59d72a29 extends (0, $jpY3B$reactstatelyv
|
|
|
887
889
|
return best || null;
|
|
888
890
|
}
|
|
889
891
|
getKeyBelow(key) {
|
|
890
|
-
var _this__findClosest,
|
|
892
|
+
var _this__findClosest, _getFirstItem;
|
|
891
893
|
// Expected key is the currently focused cell so we need the parent row key
|
|
892
894
|
let parentRowKey = this.collection.getItem(key).parentKey;
|
|
893
895
|
let layoutInfo = this.getLayoutInfo(parentRowKey);
|
|
894
896
|
let rect = new (0, $jpY3B$reactstatelyvirtualizer.Rect)(layoutInfo.rect.x, layoutInfo.rect.maxY + 1, layoutInfo.rect.width, this.virtualizer.visibleRect.height);
|
|
895
897
|
let closestRow = this.collection.getItem((_this__findClosest = this._findClosest(layoutInfo.rect, rect)) === null || _this__findClosest === void 0 ? void 0 : _this__findClosest.key);
|
|
896
|
-
return (
|
|
898
|
+
return (_getFirstItem = (0, $jpY3B$reactstatelycollections.getFirstItem)((0, $jpY3B$reactstatelycollections.getChildNodes)(closestRow, this.collection))) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key;
|
|
897
899
|
}
|
|
898
900
|
getKeyAbove(key) {
|
|
899
|
-
var _this__findClosest,
|
|
901
|
+
var _this__findClosest, _getFirstItem;
|
|
900
902
|
// Expected key is the currently focused cell so we need the parent row key
|
|
901
903
|
let parentRowKey = this.collection.getItem(key).parentKey;
|
|
902
904
|
let layoutInfo = this.getLayoutInfo(parentRowKey);
|
|
903
905
|
let rect = new (0, $jpY3B$reactstatelyvirtualizer.Rect)(layoutInfo.rect.x, 0, layoutInfo.rect.width, layoutInfo.rect.y - 1);
|
|
904
906
|
let closestRow = this.collection.getItem((_this__findClosest = this._findClosest(layoutInfo.rect, rect)) === null || _this__findClosest === void 0 ? void 0 : _this__findClosest.key);
|
|
905
|
-
return (
|
|
907
|
+
return (_getFirstItem = (0, $jpY3B$reactstatelycollections.getFirstItem)((0, $jpY3B$reactstatelycollections.getChildNodes)(closestRow, this.collection))) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key;
|
|
906
908
|
}
|
|
907
909
|
getKeyRightOf(key) {
|
|
908
910
|
// Expected key is the currently focused cell so we need the parent row key
|
|
909
911
|
let parentRowKey = this.collection.getItem(key).parentKey;
|
|
910
912
|
key = this.direction === "rtl" ? this.collection.getKeyBefore(parentRowKey) : this.collection.getKeyAfter(parentRowKey);
|
|
911
913
|
while(key != null){
|
|
914
|
+
var _getFirstItem;
|
|
912
915
|
let item = this.collection.getItem(key);
|
|
913
916
|
// Don't check if item is disabled because we want to be able to focus disabled items in a grid (double check this)
|
|
914
|
-
if (item.type === "item") return item.
|
|
917
|
+
if (item.type === "item") return (_getFirstItem = (0, $jpY3B$reactstatelycollections.getFirstItem)((0, $jpY3B$reactstatelycollections.getChildNodes)(item, this.collection))) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key;
|
|
915
918
|
key = this.direction === "rtl" ? this.collection.getKeyBefore(key) : this.collection.getKeyAfter(key);
|
|
916
919
|
}
|
|
917
920
|
}
|
|
@@ -920,19 +923,22 @@ class $5ee605f09afaa4de$export$64943d2e59d72a29 extends (0, $jpY3B$reactstatelyv
|
|
|
920
923
|
let parentRowKey = this.collection.getItem(key).parentKey;
|
|
921
924
|
key = this.direction === "rtl" ? this.collection.getKeyAfter(parentRowKey) : this.collection.getKeyBefore(parentRowKey);
|
|
922
925
|
while(key != null){
|
|
926
|
+
var _getFirstItem;
|
|
923
927
|
let item = this.collection.getItem(key);
|
|
924
928
|
// Don't check if item is disabled because we want to be able to focus disabled items in a grid (double check this)
|
|
925
|
-
if (item.type === "item") return item.
|
|
929
|
+
if (item.type === "item") return (_getFirstItem = (0, $jpY3B$reactstatelycollections.getFirstItem)((0, $jpY3B$reactstatelycollections.getChildNodes)(item, this.collection))) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key;
|
|
926
930
|
key = this.direction === "rtl" ? this.collection.getKeyAfter(key) : this.collection.getKeyBefore(key);
|
|
927
931
|
}
|
|
928
932
|
}
|
|
929
933
|
getFirstKey() {
|
|
934
|
+
var _getFirstItem;
|
|
930
935
|
let firstRow = this.collection.getItem(this.collection.getFirstKey());
|
|
931
|
-
return firstRow.
|
|
936
|
+
return (_getFirstItem = (0, $jpY3B$reactstatelycollections.getFirstItem)((0, $jpY3B$reactstatelycollections.getChildNodes)(firstRow, this.collection))) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key;
|
|
932
937
|
}
|
|
933
938
|
getLastKey() {
|
|
939
|
+
var _getFirstItem;
|
|
934
940
|
let lastRow = this.collection.getItem(this.collection.getLastKey());
|
|
935
|
-
return lastRow.
|
|
941
|
+
return (_getFirstItem = (0, $jpY3B$reactstatelycollections.getFirstItem)((0, $jpY3B$reactstatelycollections.getChildNodes)(lastRow, this.collection))) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key;
|
|
936
942
|
}
|
|
937
943
|
// TODO: pretty unwieldy because it needs to bounce back and forth between the parent key and the child key
|
|
938
944
|
// Perhaps have layoutInfo store childKey as well so we don't need to do this? Or maybe make the layoutInfos be the cells instead of the rows?
|
|
@@ -948,13 +954,14 @@ class $5ee605f09afaa4de$export$64943d2e59d72a29 extends (0, $jpY3B$reactstatelyv
|
|
|
948
954
|
let keyAbove = (_this_collection_getItem = this.collection.getItem(this.getKeyAbove(key))) === null || _this_collection_getItem === void 0 ? void 0 : _this_collection_getItem.parentKey;
|
|
949
955
|
layoutInfo = this.getLayoutInfo(keyAbove);
|
|
950
956
|
if (layoutInfo && layoutInfo.rect.y > pageY) while(layoutInfo && layoutInfo.rect.y > pageY){
|
|
951
|
-
var _this_collection_getItem1;
|
|
952
|
-
let childKey = this.collection.getItem(layoutInfo.key).
|
|
957
|
+
var _getFirstItem, _this_collection_getItem1;
|
|
958
|
+
let childKey = (_getFirstItem = (0, $jpY3B$reactstatelycollections.getFirstItem)((0, $jpY3B$reactstatelycollections.getChildNodes)(this.collection.getItem(layoutInfo.key), this.collection))) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key;
|
|
953
959
|
let keyAbove1 = (_this_collection_getItem1 = this.collection.getItem(this.getKeyAbove(childKey))) === null || _this_collection_getItem1 === void 0 ? void 0 : _this_collection_getItem1.parentKey;
|
|
954
960
|
layoutInfo = this.getLayoutInfo(keyAbove1);
|
|
955
961
|
}
|
|
956
962
|
if (layoutInfo) {
|
|
957
|
-
|
|
963
|
+
var _getFirstItem1;
|
|
964
|
+
let childKey1 = (_getFirstItem1 = (0, $jpY3B$reactstatelycollections.getFirstItem)((0, $jpY3B$reactstatelycollections.getChildNodes)(this.collection.getItem(layoutInfo.key), this.collection))) === null || _getFirstItem1 === void 0 ? void 0 : _getFirstItem1.key;
|
|
958
965
|
return childKey1;
|
|
959
966
|
}
|
|
960
967
|
}
|
|
@@ -974,13 +981,14 @@ class $5ee605f09afaa4de$export$64943d2e59d72a29 extends (0, $jpY3B$reactstatelyv
|
|
|
974
981
|
let keyBelow = (_this_collection_getItem = this.collection.getItem(this.getKeyBelow(key))) === null || _this_collection_getItem === void 0 ? void 0 : _this_collection_getItem.parentKey;
|
|
975
982
|
layoutInfo = this.getLayoutInfo(keyBelow);
|
|
976
983
|
if (layoutInfo && layoutInfo.rect.y < pageY) while(layoutInfo && layoutInfo.rect.y < pageY){
|
|
977
|
-
var _this_collection_getItem1;
|
|
978
|
-
let childKey = this.collection.getItem(layoutInfo.key).
|
|
984
|
+
var _getFirstItem, _this_collection_getItem1;
|
|
985
|
+
let childKey = (_getFirstItem = (0, $jpY3B$reactstatelycollections.getFirstItem)((0, $jpY3B$reactstatelycollections.getChildNodes)(this.collection.getItem(layoutInfo.key), this.collection))) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key;
|
|
979
986
|
let keyBelow1 = (_this_collection_getItem1 = this.collection.getItem(this.getKeyBelow(childKey))) === null || _this_collection_getItem1 === void 0 ? void 0 : _this_collection_getItem1.parentKey;
|
|
980
987
|
layoutInfo = this.getLayoutInfo(keyBelow1);
|
|
981
988
|
}
|
|
982
989
|
if (layoutInfo) {
|
|
983
|
-
|
|
990
|
+
var _getFirstItem1;
|
|
991
|
+
let childKey1 = (_getFirstItem1 = (0, $jpY3B$reactstatelycollections.getFirstItem)((0, $jpY3B$reactstatelycollections.getChildNodes)(this.collection.getItem(layoutInfo.key), this.collection))) === null || _getFirstItem1 === void 0 ? void 0 : _getFirstItem1.key;
|
|
984
992
|
return childKey1;
|
|
985
993
|
}
|
|
986
994
|
}
|
|
@@ -995,10 +1003,9 @@ class $5ee605f09afaa4de$export$64943d2e59d72a29 extends (0, $jpY3B$reactstatelyv
|
|
|
995
1003
|
while(key != null){
|
|
996
1004
|
let item = collection.getItem(key);
|
|
997
1005
|
if (item.textValue) {
|
|
1006
|
+
var _getFirstItem;
|
|
998
1007
|
let substring = item.textValue.slice(0, search.length);
|
|
999
|
-
if (this.collator.compare(substring, search) === 0) return
|
|
1000
|
-
...item.childNodes
|
|
1001
|
-
][0].key;
|
|
1008
|
+
if (this.collator.compare(substring, search) === 0) return (_getFirstItem = (0, $jpY3B$reactstatelycollections.getFirstItem)((0, $jpY3B$reactstatelycollections.getChildNodes)(item, this.collection))) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key;
|
|
1002
1009
|
}
|
|
1003
1010
|
key = this.collection.getKeyAfter(key);
|
|
1004
1011
|
}
|
|
@@ -1236,6 +1243,7 @@ function $8019a3d2c7d098ea$var$linearPartition(seq, k) {
|
|
|
1236
1243
|
* governing permissions and limitations under the License.
|
|
1237
1244
|
*/
|
|
1238
1245
|
|
|
1246
|
+
|
|
1239
1247
|
const $71b727f94b595b1a$var$DEFAULT_OPTIONS = {
|
|
1240
1248
|
S: {
|
|
1241
1249
|
itemPadding: 20,
|
|
@@ -1371,24 +1379,26 @@ class $71b727f94b595b1a$export$7d2b12578154a735 extends (0, $5ee605f09afaa4de$ex
|
|
|
1371
1379
|
// then return the key that occupies the row + column below. This can be done by figuring out how many cards exist per column then dividing the
|
|
1372
1380
|
// collection contents by that number (which will give us the row distribution)
|
|
1373
1381
|
getKeyBelow(key) {
|
|
1374
|
-
var
|
|
1382
|
+
var _getFirstItem;
|
|
1375
1383
|
// Expected key is the currently focused cell so we need the parent row key
|
|
1376
1384
|
let parentRowKey = this.collection.getItem(key).parentKey;
|
|
1377
1385
|
let indexRowBelow;
|
|
1378
1386
|
let index = this.collection.rows.findIndex((card)=>card.key === parentRowKey);
|
|
1379
1387
|
if (index !== -1) indexRowBelow = index + this.numColumns;
|
|
1380
1388
|
else return null;
|
|
1381
|
-
|
|
1389
|
+
let row = this.collection.rows[indexRowBelow];
|
|
1390
|
+
return (_getFirstItem = (0, $jpY3B$reactstatelycollections.getFirstItem)((0, $jpY3B$reactstatelycollections.getChildNodes)(row, this.collection))) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key;
|
|
1382
1391
|
}
|
|
1383
1392
|
getKeyAbove(key) {
|
|
1384
|
-
var
|
|
1393
|
+
var _getFirstItem;
|
|
1385
1394
|
// Expected key is the currently focused cell so we need the parent row key
|
|
1386
1395
|
let parentRowKey = this.collection.getItem(key).parentKey;
|
|
1387
1396
|
let indexRowAbove;
|
|
1388
1397
|
let index = this.collection.rows.findIndex((card)=>card.key === parentRowKey);
|
|
1389
1398
|
if (index !== -1) indexRowAbove = index - this.numColumns;
|
|
1390
1399
|
else return null;
|
|
1391
|
-
|
|
1400
|
+
let row = this.collection.rows[indexRowAbove];
|
|
1401
|
+
return (_getFirstItem = (0, $jpY3B$reactstatelycollections.getFirstItem)((0, $jpY3B$reactstatelycollections.getChildNodes)(row, this.collection))) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key;
|
|
1392
1402
|
}
|
|
1393
1403
|
constructor(options = {}){
|
|
1394
1404
|
super(options);
|
|
@@ -1420,6 +1430,7 @@ class $71b727f94b595b1a$export$7d2b12578154a735 extends (0, $5ee605f09afaa4de$ex
|
|
|
1420
1430
|
* governing permissions and limitations under the License.
|
|
1421
1431
|
*/
|
|
1422
1432
|
|
|
1433
|
+
|
|
1423
1434
|
class $632abf8fbf0ad57b$export$e9f7cda058ba8df8 extends (0, $5ee605f09afaa4de$export$64943d2e59d72a29) {
|
|
1424
1435
|
get layoutType() {
|
|
1425
1436
|
return "waterfall";
|
|
@@ -1520,7 +1531,7 @@ class $632abf8fbf0ad57b$export$e9f7cda058ba8df8 extends (0, $5ee605f09afaa4de$ex
|
|
|
1520
1531
|
return minIndex;
|
|
1521
1532
|
}
|
|
1522
1533
|
getClosestRight(key) {
|
|
1523
|
-
var _this__findClosest,
|
|
1534
|
+
var _this__findClosest, _getFirstItem;
|
|
1524
1535
|
let layoutInfo = this.getLayoutInfo(key);
|
|
1525
1536
|
// Refactored from v2. Current strategy is to find the closest card in the adjacent column.
|
|
1526
1537
|
// This prevent the issue where it was possible that the closest layoutInfo would be two columns over due to the middle card being exceptionally tall
|
|
@@ -1533,10 +1544,11 @@ class $632abf8fbf0ad57b$export$e9f7cda058ba8df8 extends (0, $5ee605f09afaa4de$ex
|
|
|
1533
1544
|
rect = new (0, $jpY3B$reactstatelyvirtualizer.Rect)(layoutInfo.rect.maxX + 1, 0, layoutInfo.rect.width + this.horizontalSpacing, this.virtualizer.contentSize.height);
|
|
1534
1545
|
key = (_this__findClosest1 = this._findClosest(layoutInfo.rect, rect)) === null || _this__findClosest1 === void 0 ? void 0 : _this__findClosest1.key;
|
|
1535
1546
|
}
|
|
1536
|
-
|
|
1547
|
+
let item = this.collection.getItem(key);
|
|
1548
|
+
return (_getFirstItem = (0, $jpY3B$reactstatelycollections.getFirstItem)((0, $jpY3B$reactstatelycollections.getChildNodes)(item, this.collection))) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key;
|
|
1537
1549
|
}
|
|
1538
1550
|
getClosestLeft(key) {
|
|
1539
|
-
var _this__findClosest,
|
|
1551
|
+
var _this__findClosest, _getFirstItem;
|
|
1540
1552
|
let layoutInfo = this.getLayoutInfo(key);
|
|
1541
1553
|
// First look for a card to the immediate left of the current card. If we can't find any, look for the nearest card in the entire column to the left of the card
|
|
1542
1554
|
let rect = new (0, $jpY3B$reactstatelyvirtualizer.Rect)(layoutInfo.rect.x - layoutInfo.rect.width - this.horizontalSpacing - 1, layoutInfo.rect.y, layoutInfo.rect.width + this.horizontalSpacing, layoutInfo.rect.height);
|
|
@@ -1546,7 +1558,8 @@ class $632abf8fbf0ad57b$export$e9f7cda058ba8df8 extends (0, $5ee605f09afaa4de$ex
|
|
|
1546
1558
|
rect = new (0, $jpY3B$reactstatelyvirtualizer.Rect)(layoutInfo.rect.x - layoutInfo.rect.width - this.horizontalSpacing - 1, 0, layoutInfo.rect.width + this.horizontalSpacing, this.virtualizer.contentSize.height);
|
|
1547
1559
|
key = (_this__findClosest1 = this._findClosest(layoutInfo.rect, rect)) === null || _this__findClosest1 === void 0 ? void 0 : _this__findClosest1.key;
|
|
1548
1560
|
}
|
|
1549
|
-
|
|
1561
|
+
let item = this.collection.getItem(key);
|
|
1562
|
+
return (_getFirstItem = (0, $jpY3B$reactstatelycollections.getFirstItem)((0, $jpY3B$reactstatelycollections.getChildNodes)(item, this.collection))) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key;
|
|
1550
1563
|
}
|
|
1551
1564
|
getKeyRightOf(key) {
|
|
1552
1565
|
// Expected key is the currently focused cell so we need the parent row key
|