@react-spectrum/card 3.0.0-alpha.3 → 3.0.0-alpha.31
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/ar-AE.main.js +7 -0
- package/dist/ar-AE.main.js.map +1 -0
- package/dist/ar-AE.mjs +9 -0
- package/dist/ar-AE.module.js +9 -0
- package/dist/ar-AE.module.js.map +1 -0
- package/dist/bg-BG.main.js +7 -0
- package/dist/bg-BG.main.js.map +1 -0
- package/dist/bg-BG.mjs +9 -0
- package/dist/bg-BG.module.js +9 -0
- package/dist/bg-BG.module.js.map +1 -0
- package/dist/cs-CZ.main.js +7 -0
- package/dist/cs-CZ.main.js.map +1 -0
- package/dist/cs-CZ.mjs +9 -0
- package/dist/cs-CZ.module.js +9 -0
- package/dist/cs-CZ.module.js.map +1 -0
- package/dist/da-DK.main.js +7 -0
- package/dist/da-DK.main.js.map +1 -0
- package/dist/da-DK.mjs +9 -0
- package/dist/da-DK.module.js +9 -0
- package/dist/da-DK.module.js.map +1 -0
- package/dist/de-DE.main.js +7 -0
- package/dist/de-DE.main.js.map +1 -0
- package/dist/de-DE.mjs +9 -0
- package/dist/de-DE.module.js +9 -0
- package/dist/de-DE.module.js.map +1 -0
- package/dist/el-GR.main.js +7 -0
- package/dist/el-GR.main.js.map +1 -0
- package/dist/el-GR.mjs +9 -0
- package/dist/el-GR.module.js +9 -0
- package/dist/el-GR.module.js.map +1 -0
- package/dist/en-US.main.js +7 -0
- package/dist/en-US.main.js.map +1 -0
- package/dist/en-US.mjs +9 -0
- package/dist/en-US.module.js +9 -0
- package/dist/en-US.module.js.map +1 -0
- package/dist/es-ES.main.js +7 -0
- package/dist/es-ES.main.js.map +1 -0
- package/dist/es-ES.mjs +9 -0
- package/dist/es-ES.module.js +9 -0
- package/dist/es-ES.module.js.map +1 -0
- package/dist/et-EE.main.js +7 -0
- package/dist/et-EE.main.js.map +1 -0
- package/dist/et-EE.mjs +9 -0
- package/dist/et-EE.module.js +9 -0
- package/dist/et-EE.module.js.map +1 -0
- package/dist/fi-FI.main.js +7 -0
- package/dist/fi-FI.main.js.map +1 -0
- package/dist/fi-FI.mjs +9 -0
- package/dist/fi-FI.module.js +9 -0
- package/dist/fi-FI.module.js.map +1 -0
- package/dist/fr-FR.main.js +7 -0
- package/dist/fr-FR.main.js.map +1 -0
- package/dist/fr-FR.mjs +9 -0
- package/dist/fr-FR.module.js +9 -0
- package/dist/fr-FR.module.js.map +1 -0
- package/dist/he-IL.main.js +7 -0
- package/dist/he-IL.main.js.map +1 -0
- package/dist/he-IL.mjs +9 -0
- package/dist/he-IL.module.js +9 -0
- package/dist/he-IL.module.js.map +1 -0
- package/dist/hr-HR.main.js +7 -0
- package/dist/hr-HR.main.js.map +1 -0
- package/dist/hr-HR.mjs +9 -0
- package/dist/hr-HR.module.js +9 -0
- package/dist/hr-HR.module.js.map +1 -0
- package/dist/hu-HU.main.js +7 -0
- package/dist/hu-HU.main.js.map +1 -0
- package/dist/hu-HU.mjs +9 -0
- package/dist/hu-HU.module.js +9 -0
- package/dist/hu-HU.module.js.map +1 -0
- package/dist/import.mjs +1479 -0
- package/dist/it-IT.main.js +7 -0
- package/dist/it-IT.main.js.map +1 -0
- package/dist/it-IT.mjs +9 -0
- package/dist/it-IT.module.js +9 -0
- package/dist/it-IT.module.js.map +1 -0
- package/dist/ja-JP.main.js +7 -0
- package/dist/ja-JP.main.js.map +1 -0
- package/dist/ja-JP.mjs +9 -0
- package/dist/ja-JP.module.js +9 -0
- package/dist/ja-JP.module.js.map +1 -0
- package/dist/ko-KR.main.js +7 -0
- package/dist/ko-KR.main.js.map +1 -0
- package/dist/ko-KR.mjs +9 -0
- package/dist/ko-KR.module.js +9 -0
- package/dist/ko-KR.module.js.map +1 -0
- package/dist/lt-LT.main.js +7 -0
- package/dist/lt-LT.main.js.map +1 -0
- package/dist/lt-LT.mjs +9 -0
- package/dist/lt-LT.module.js +9 -0
- package/dist/lt-LT.module.js.map +1 -0
- package/dist/lv-LV.main.js +7 -0
- package/dist/lv-LV.main.js.map +1 -0
- package/dist/lv-LV.mjs +9 -0
- package/dist/lv-LV.module.js +9 -0
- package/dist/lv-LV.module.js.map +1 -0
- package/dist/main.css +1802 -1
- package/dist/main.css.map +1 -0
- package/dist/main.js +636 -613
- package/dist/main.js.map +1 -1
- package/dist/module.js +630 -592
- package/dist/module.js.map +1 -1
- package/dist/nb-NO.main.js +7 -0
- package/dist/nb-NO.main.js.map +1 -0
- package/dist/nb-NO.mjs +9 -0
- package/dist/nb-NO.module.js +9 -0
- package/dist/nb-NO.module.js.map +1 -0
- package/dist/nl-NL.main.js +7 -0
- package/dist/nl-NL.main.js.map +1 -0
- package/dist/nl-NL.mjs +9 -0
- package/dist/nl-NL.module.js +9 -0
- package/dist/nl-NL.module.js.map +1 -0
- package/dist/pl-PL.main.js +7 -0
- package/dist/pl-PL.main.js.map +1 -0
- package/dist/pl-PL.mjs +9 -0
- package/dist/pl-PL.module.js +9 -0
- package/dist/pl-PL.module.js.map +1 -0
- package/dist/pt-BR.main.js +7 -0
- package/dist/pt-BR.main.js.map +1 -0
- package/dist/pt-BR.mjs +9 -0
- package/dist/pt-BR.module.js +9 -0
- package/dist/pt-BR.module.js.map +1 -0
- package/dist/pt-PT.main.js +7 -0
- package/dist/pt-PT.main.js.map +1 -0
- package/dist/pt-PT.mjs +9 -0
- package/dist/pt-PT.module.js +9 -0
- package/dist/pt-PT.module.js.map +1 -0
- package/dist/ro-RO.main.js +7 -0
- package/dist/ro-RO.main.js.map +1 -0
- package/dist/ro-RO.mjs +9 -0
- package/dist/ro-RO.module.js +9 -0
- package/dist/ro-RO.module.js.map +1 -0
- package/dist/ru-RU.main.js +7 -0
- package/dist/ru-RU.main.js.map +1 -0
- package/dist/ru-RU.mjs +9 -0
- package/dist/ru-RU.module.js +9 -0
- package/dist/ru-RU.module.js.map +1 -0
- package/dist/sk-SK.main.js +7 -0
- package/dist/sk-SK.main.js.map +1 -0
- package/dist/sk-SK.mjs +9 -0
- package/dist/sk-SK.module.js +9 -0
- package/dist/sk-SK.module.js.map +1 -0
- package/dist/sl-SI.main.js +7 -0
- package/dist/sl-SI.main.js.map +1 -0
- package/dist/sl-SI.mjs +9 -0
- package/dist/sl-SI.module.js +9 -0
- package/dist/sl-SI.module.js.map +1 -0
- package/dist/sr-SP.main.js +7 -0
- package/dist/sr-SP.main.js.map +1 -0
- package/dist/sr-SP.mjs +9 -0
- package/dist/sr-SP.module.js +9 -0
- package/dist/sr-SP.module.js.map +1 -0
- package/dist/sv-SE.main.js +7 -0
- package/dist/sv-SE.main.js.map +1 -0
- package/dist/sv-SE.mjs +9 -0
- package/dist/sv-SE.module.js +9 -0
- package/dist/sv-SE.module.js.map +1 -0
- package/dist/tr-TR.main.js +7 -0
- package/dist/tr-TR.main.js.map +1 -0
- package/dist/tr-TR.mjs +9 -0
- package/dist/tr-TR.module.js +9 -0
- package/dist/tr-TR.module.js.map +1 -0
- package/dist/types.d.ts +24 -23
- package/dist/types.d.ts.map +1 -1
- package/dist/uk-UA.main.js +7 -0
- package/dist/uk-UA.main.js.map +1 -0
- package/dist/uk-UA.mjs +9 -0
- package/dist/uk-UA.module.js +9 -0
- package/dist/uk-UA.module.js.map +1 -0
- package/dist/zh-CN.main.js +7 -0
- package/dist/zh-CN.main.js.map +1 -0
- package/dist/zh-CN.mjs +9 -0
- package/dist/zh-CN.module.js +9 -0
- package/dist/zh-CN.module.js.map +1 -0
- package/dist/zh-TW.main.js +7 -0
- package/dist/zh-TW.main.js.map +1 -0
- package/dist/zh-TW.mjs +9 -0
- package/dist/zh-TW.module.js +9 -0
- package/dist/zh-TW.module.js.map +1 -0
- package/package.json +26 -23
- package/src/BaseLayout.tsx +13 -13
- package/src/CardBase.tsx +2 -2
- package/src/CardView.tsx +26 -8
- package/src/GalleryLayout.tsx +1 -0
- package/src/GridLayout.tsx +6 -4
- package/src/WaterfallLayout.tsx +6 -4
- package/src/index.ts +10 -5
package/dist/zh-TW.mjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var $b7e2865acb74a940$exports = {};
|
|
2
|
+
$b7e2865acb74a940$exports = {
|
|
3
|
+
"loading": `\u{6B63}\u{5728}\u{8F09}\u{5165}\u{2026}`,
|
|
4
|
+
"loadingMore": `\u{6B63}\u{5728}\u{8F09}\u{5165}\u{66F4}\u{591A}\u{2026}`
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export {$b7e2865acb74a940$exports as default};
|
|
9
|
+
//# sourceMappingURL=zh-TW.module.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var $b7e2865acb74a940$exports = {};
|
|
2
|
+
$b7e2865acb74a940$exports = {
|
|
3
|
+
"loading": `\u{6B63}\u{5728}\u{8F09}\u{5165}\u{2026}`,
|
|
4
|
+
"loadingMore": `\u{6B63}\u{5728}\u{8F09}\u{5165}\u{66F4}\u{591A}\u{2026}`
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export {$b7e2865acb74a940$exports as default};
|
|
9
|
+
//# sourceMappingURL=zh-TW.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";AAAA,4BAAiB;IAAG,WAAW,CAAC,wCAAK,CAAC;IACpC,eAAe,CAAC,wDAAO,CAAC;AAC1B","sources":["packages/@react-spectrum/card/intl/zh-TW.json"],"sourcesContent":["{\n \"loading\": \"正在載入…\",\n \"loadingMore\": \"正在載入更多…\"\n}\n"],"names":[],"version":3,"file":"zh-TW.module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-spectrum/card",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.31",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
7
7
|
"module": "dist/module.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
"types": "./dist/types.d.ts",
|
|
10
|
+
"import": "./dist/import.mjs",
|
|
11
|
+
"require": "./dist/main.js"
|
|
12
|
+
},
|
|
8
13
|
"types": "dist/types.d.ts",
|
|
9
14
|
"source": "src/index.ts",
|
|
10
15
|
"files": [
|
|
@@ -31,36 +36,34 @@
|
|
|
31
36
|
"url": "https://github.com/adobe/react-spectrum"
|
|
32
37
|
},
|
|
33
38
|
"dependencies": {
|
|
34
|
-
"@
|
|
35
|
-
"@react-aria/
|
|
36
|
-
"@react-aria/
|
|
37
|
-
"@react-aria/
|
|
38
|
-
"@react-aria/
|
|
39
|
-
"@react-aria/
|
|
40
|
-
"@react-
|
|
41
|
-
"@react-spectrum/
|
|
42
|
-
"@react-spectrum/
|
|
43
|
-
"@react-
|
|
44
|
-
"@react-
|
|
45
|
-
"@react-
|
|
46
|
-
"@react-stately/
|
|
47
|
-
"@react-
|
|
48
|
-
"@react-
|
|
49
|
-
"@react-
|
|
50
|
-
"@
|
|
51
|
-
"@react-types/card": "3.0.0-alpha.3",
|
|
52
|
-
"@react-types/provider": "^3.4.1",
|
|
53
|
-
"@react-types/shared": "^3.11.1"
|
|
39
|
+
"@react-aria/focus": "^3.16.2",
|
|
40
|
+
"@react-aria/grid": "^3.8.8",
|
|
41
|
+
"@react-aria/i18n": "^3.10.2",
|
|
42
|
+
"@react-aria/interactions": "^3.21.1",
|
|
43
|
+
"@react-aria/utils": "^3.23.2",
|
|
44
|
+
"@react-aria/virtualizer": "^3.9.10",
|
|
45
|
+
"@react-spectrum/checkbox": "^3.9.4",
|
|
46
|
+
"@react-spectrum/progress": "^3.7.5",
|
|
47
|
+
"@react-spectrum/utils": "^3.11.5",
|
|
48
|
+
"@react-stately/collections": "^3.10.5",
|
|
49
|
+
"@react-stately/grid": "^3.8.5",
|
|
50
|
+
"@react-stately/list": "^3.10.3",
|
|
51
|
+
"@react-stately/virtualizer": "^3.6.8",
|
|
52
|
+
"@react-types/card": "3.0.0-alpha.24",
|
|
53
|
+
"@react-types/provider": "^3.7.2",
|
|
54
|
+
"@react-types/shared": "^3.22.1",
|
|
55
|
+
"@swc/helpers": "^0.5.0"
|
|
54
56
|
},
|
|
55
57
|
"devDependencies": {
|
|
56
58
|
"@adobe/spectrum-css-temp": "3.0.0-alpha.1"
|
|
57
59
|
},
|
|
58
60
|
"peerDependencies": {
|
|
59
61
|
"@react-spectrum/provider": "^3.0.0",
|
|
60
|
-
"react": "^16.8.0 || ^17.0.0-rc.1"
|
|
62
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0",
|
|
63
|
+
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
|
61
64
|
},
|
|
62
65
|
"publishConfig": {
|
|
63
66
|
"access": "public"
|
|
64
67
|
},
|
|
65
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "de9f84a22583fc741c29b341d14cd35ef4cca161"
|
|
66
69
|
}
|
package/src/BaseLayout.tsx
CHANGED
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {Direction, KeyboardDelegate, Node} from '@react-types/shared';
|
|
13
|
+
import {Direction, Key, KeyboardDelegate, Node} from '@react-types/shared';
|
|
14
|
+
import {getChildNodes, getFirstItem} from '@react-stately/collections';
|
|
14
15
|
import {GridCollection} from '@react-stately/grid';
|
|
15
16
|
import {InvalidationContext, Layout, LayoutInfo, Rect, Size} from '@react-stately/virtualizer';
|
|
16
|
-
import {Key} from 'react';
|
|
17
17
|
import {Scale} from '@react-types/provider';
|
|
18
18
|
|
|
19
19
|
export interface BaseLayoutOptions {
|
|
@@ -146,7 +146,7 @@ export class BaseLayout<T> extends Layout<Node<T>> implements KeyboardDelegate {
|
|
|
146
146
|
let layoutInfo = this.getLayoutInfo(parentRowKey);
|
|
147
147
|
let rect = new Rect(layoutInfo.rect.x, layoutInfo.rect.maxY + 1, layoutInfo.rect.width, this.virtualizer.visibleRect.height);
|
|
148
148
|
let closestRow = this.collection.getItem(this._findClosest(layoutInfo.rect, rect)?.key);
|
|
149
|
-
return closestRow?.
|
|
149
|
+
return getFirstItem(getChildNodes(closestRow, this.collection))?.key;
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
getKeyAbove(key: Key) {
|
|
@@ -155,7 +155,7 @@ export class BaseLayout<T> extends Layout<Node<T>> implements KeyboardDelegate {
|
|
|
155
155
|
let layoutInfo = this.getLayoutInfo(parentRowKey);
|
|
156
156
|
let rect = new Rect(layoutInfo.rect.x, 0, layoutInfo.rect.width, layoutInfo.rect.y - 1);
|
|
157
157
|
let closestRow = this.collection.getItem(this._findClosest(layoutInfo.rect, rect)?.key);
|
|
158
|
-
return closestRow?.
|
|
158
|
+
return getFirstItem(getChildNodes(closestRow, this.collection))?.key;
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
getKeyRightOf(key: Key) {
|
|
@@ -167,7 +167,7 @@ export class BaseLayout<T> extends Layout<Node<T>> implements KeyboardDelegate {
|
|
|
167
167
|
let item = this.collection.getItem(key);
|
|
168
168
|
// Don't check if item is disabled because we want to be able to focus disabled items in a grid (double check this)
|
|
169
169
|
if (item.type === 'item') {
|
|
170
|
-
return item.
|
|
170
|
+
return getFirstItem(getChildNodes(item, this.collection))?.key;
|
|
171
171
|
}
|
|
172
172
|
key = this.direction === 'rtl' ? this.collection.getKeyBefore(key) : this.collection.getKeyAfter(key);
|
|
173
173
|
}
|
|
@@ -181,7 +181,7 @@ export class BaseLayout<T> extends Layout<Node<T>> implements KeyboardDelegate {
|
|
|
181
181
|
let item = this.collection.getItem(key);
|
|
182
182
|
// Don't check if item is disabled because we want to be able to focus disabled items in a grid (double check this)
|
|
183
183
|
if (item.type === 'item') {
|
|
184
|
-
return item.
|
|
184
|
+
return getFirstItem(getChildNodes(item, this.collection))?.key;
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
key = this.direction === 'rtl' ? this.collection.getKeyAfter(key) : this.collection.getKeyBefore(key);
|
|
@@ -190,12 +190,12 @@ export class BaseLayout<T> extends Layout<Node<T>> implements KeyboardDelegate {
|
|
|
190
190
|
|
|
191
191
|
getFirstKey() {
|
|
192
192
|
let firstRow = this.collection.getItem(this.collection.getFirstKey());
|
|
193
|
-
return firstRow.
|
|
193
|
+
return getFirstItem(getChildNodes(firstRow, this.collection))?.key;
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
getLastKey() {
|
|
197
197
|
let lastRow = this.collection.getItem(this.collection.getLastKey());
|
|
198
|
-
return lastRow.
|
|
198
|
+
return getFirstItem(getChildNodes(lastRow, this.collection))?.key;
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
// TODO: pretty unwieldy because it needs to bounce back and forth between the parent key and the child key
|
|
@@ -214,14 +214,14 @@ export class BaseLayout<T> extends Layout<Node<T>> implements KeyboardDelegate {
|
|
|
214
214
|
|
|
215
215
|
if (layoutInfo && layoutInfo.rect.y > pageY) {
|
|
216
216
|
while (layoutInfo && layoutInfo.rect.y > pageY) {
|
|
217
|
-
let childKey = this.collection.getItem(layoutInfo.key).
|
|
217
|
+
let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;
|
|
218
218
|
let keyAbove = this.collection.getItem(this.getKeyAbove(childKey))?.parentKey;
|
|
219
219
|
layoutInfo = this.getLayoutInfo(keyAbove);
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
if (layoutInfo) {
|
|
224
|
-
let childKey = this.collection.getItem(layoutInfo.key).
|
|
224
|
+
let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;
|
|
225
225
|
return childKey;
|
|
226
226
|
}
|
|
227
227
|
}
|
|
@@ -243,14 +243,14 @@ export class BaseLayout<T> extends Layout<Node<T>> implements KeyboardDelegate {
|
|
|
243
243
|
layoutInfo = this.getLayoutInfo(keyBelow);
|
|
244
244
|
if (layoutInfo && layoutInfo.rect.y < pageY) {
|
|
245
245
|
while (layoutInfo && layoutInfo.rect.y < pageY) {
|
|
246
|
-
let childKey = this.collection.getItem(layoutInfo.key).
|
|
246
|
+
let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;
|
|
247
247
|
let keyBelow = this.collection.getItem(this.getKeyBelow(childKey))?.parentKey;
|
|
248
248
|
layoutInfo = this.getLayoutInfo(keyBelow);
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
if (layoutInfo) {
|
|
253
|
-
let childKey = this.collection.getItem(layoutInfo.key).
|
|
253
|
+
let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;
|
|
254
254
|
return childKey;
|
|
255
255
|
}
|
|
256
256
|
}
|
|
@@ -274,7 +274,7 @@ export class BaseLayout<T> extends Layout<Node<T>> implements KeyboardDelegate {
|
|
|
274
274
|
if (item.textValue) {
|
|
275
275
|
let substring = item.textValue.slice(0, search.length);
|
|
276
276
|
if (this.collator.compare(substring, search) === 0) {
|
|
277
|
-
return
|
|
277
|
+
return getFirstItem(getChildNodes(item, this.collection))?.key;
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
280
|
|
package/src/CardBase.tsx
CHANGED
|
@@ -15,8 +15,7 @@ import {Checkbox} from '@react-spectrum/checkbox';
|
|
|
15
15
|
import {classNames, SlotProvider, useDOMRef, useHasChild, useStyleProps} from '@react-spectrum/utils';
|
|
16
16
|
import {DOMRef, Node} from '@react-types/shared';
|
|
17
17
|
import {filterDOMProps, mergeProps, useLayoutEffect, useResizeObserver, useSlotId} from '@react-aria/utils';
|
|
18
|
-
import {FocusRing} from '@react-aria/focus';
|
|
19
|
-
import {getFocusableTreeWalker} from '@react-aria/focus';
|
|
18
|
+
import {FocusRing, getFocusableTreeWalker} from '@react-aria/focus';
|
|
20
19
|
import React, {HTMLAttributes, useCallback, useMemo, useRef, useState} from 'react';
|
|
21
20
|
import styles from '@adobe/spectrum-css-temp/components/card/vars.css';
|
|
22
21
|
import {useCardViewContext} from './CardViewContext';
|
|
@@ -93,6 +92,7 @@ function CardBase<T extends object>(props: CardBaseProps<T>, ref: DOMRef<HTMLDiv
|
|
|
93
92
|
heading: {UNSAFE_className: classNames(styles, 'spectrum-Card-heading'), ...titleProps},
|
|
94
93
|
content: {UNSAFE_className: classNames(styles, 'spectrum-Card-content'), ...contentProps},
|
|
95
94
|
detail: {UNSAFE_className: classNames(styles, 'spectrum-Card-detail')}
|
|
95
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
96
96
|
}), [titleProps, contentProps, height, isQuiet, orientation]);
|
|
97
97
|
|
|
98
98
|
useLayoutEffect(() => {
|
package/src/CardView.tsx
CHANGED
|
@@ -17,12 +17,13 @@ import {DOMRef, DOMRefValue, Node} from '@react-types/shared';
|
|
|
17
17
|
import {GridCollection, useGridState} from '@react-stately/grid';
|
|
18
18
|
// @ts-ignore
|
|
19
19
|
import intlMessages from '../intl/*.json';
|
|
20
|
+
import {mergeProps} from '@react-aria/utils';
|
|
20
21
|
import {ProgressCircle} from '@react-spectrum/progress';
|
|
21
|
-
import React, {ReactElement, useCallback, useMemo, useRef} from 'react';
|
|
22
|
+
import React, {ReactElement, ReactNode, useCallback, useMemo, useRef} from 'react';
|
|
22
23
|
import {ReusableView} from '@react-stately/virtualizer';
|
|
23
24
|
import {SpectrumCardViewProps} from '@react-types/card';
|
|
24
25
|
import styles from '@adobe/spectrum-css-temp/components/card/vars.css';
|
|
25
|
-
import {useCollator, useLocale,
|
|
26
|
+
import {useCollator, useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';
|
|
26
27
|
import {useGrid, useGridCell, useGridRow} from '@react-aria/grid';
|
|
27
28
|
import {useListState} from '@react-stately/list';
|
|
28
29
|
import {useProvider} from '@react-spectrum/provider';
|
|
@@ -46,7 +47,7 @@ function CardView<T extends object>(props: SpectrumCardViewProps<T>, ref: DOMRef
|
|
|
46
47
|
let cardViewLayout = useMemo(() => typeof layout === 'function' ? new layout({collator, cardOrientation, scale}) : layout, [layout, collator, cardOrientation, scale]);
|
|
47
48
|
let layoutType = cardViewLayout.layoutType;
|
|
48
49
|
|
|
49
|
-
let
|
|
50
|
+
let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/card');
|
|
50
51
|
let {direction} = useLocale();
|
|
51
52
|
let {collection} = useListState(props);
|
|
52
53
|
|
|
@@ -87,12 +88,15 @@ function CardView<T extends object>(props: SpectrumCardViewProps<T>, ref: DOMRef
|
|
|
87
88
|
keyboardDelegate: cardViewLayout
|
|
88
89
|
}, state, domRef);
|
|
89
90
|
|
|
90
|
-
type View = ReusableView<Node<T>,
|
|
91
|
+
type View = ReusableView<Node<T>, ReactNode>;
|
|
91
92
|
let renderWrapper = (parent: View, reusableView: View) => (
|
|
92
93
|
<VirtualizerItem
|
|
93
94
|
key={reusableView.key}
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
layoutInfo={reusableView.layoutInfo}
|
|
96
|
+
virtualizer={reusableView.virtualizer}
|
|
97
|
+
parent={parent?.layoutInfo}>
|
|
98
|
+
{reusableView.rendered}
|
|
99
|
+
</VirtualizerItem>
|
|
96
100
|
);
|
|
97
101
|
|
|
98
102
|
let focusedKey = state.selectionManager.focusedKey;
|
|
@@ -137,7 +141,7 @@ function CardView<T extends object>(props: SpectrumCardViewProps<T>, ref: DOMRef
|
|
|
137
141
|
<CenteredWrapper>
|
|
138
142
|
<ProgressCircle
|
|
139
143
|
isIndeterminate
|
|
140
|
-
aria-label={state.collection.size > 0 ?
|
|
144
|
+
aria-label={state.collection.size > 0 ? stringFormatter.format('loadingMore') : stringFormatter.format('loading')} />
|
|
141
145
|
</CenteredWrapper>
|
|
142
146
|
);
|
|
143
147
|
} else if (type === 'placeholder') {
|
|
@@ -185,7 +189,7 @@ function InternalCard(props) {
|
|
|
185
189
|
let cellRef = useRef<DOMRefValue<HTMLDivElement>>();
|
|
186
190
|
let unwrappedRef = useUnwrapDOMRef(cellRef);
|
|
187
191
|
|
|
188
|
-
let {rowProps} = useGridRow({
|
|
192
|
+
let {rowProps: gridRowProps} = useGridRow({
|
|
189
193
|
node: item,
|
|
190
194
|
isVirtualized: true
|
|
191
195
|
}, state, rowRef);
|
|
@@ -195,6 +199,20 @@ function InternalCard(props) {
|
|
|
195
199
|
focusMode: 'cell'
|
|
196
200
|
}, state, unwrappedRef);
|
|
197
201
|
|
|
202
|
+
// Prevent space key from scrolling the CardView if triggered on a disabled item or on a Card in a selectionMode="none" CardView.
|
|
203
|
+
let allowsInteraction = state.selectionManager.selectionMode !== 'none';
|
|
204
|
+
let isDisabled = !allowsInteraction || state.disabledKeys.has(item.key);
|
|
205
|
+
|
|
206
|
+
let onKeyDown = (e) => {
|
|
207
|
+
if (e.key === ' ' && isDisabled) {
|
|
208
|
+
e.preventDefault();
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
let rowProps = mergeProps(
|
|
213
|
+
gridRowProps,
|
|
214
|
+
{onKeyDown}
|
|
215
|
+
);
|
|
198
216
|
|
|
199
217
|
if (layoutType === 'grid' || layoutType === 'gallery') {
|
|
200
218
|
isQuiet = true;
|
package/src/GalleryLayout.tsx
CHANGED
|
@@ -109,6 +109,7 @@ export class GalleryLayout<T> extends BaseLayout<T> {
|
|
|
109
109
|
if (widths[item[0]][1] > this.minItemSize.width) {
|
|
110
110
|
// subtract the delta from the width, if it's still greater than the min width
|
|
111
111
|
// then we have finished, subtract the delta permanently from that width
|
|
112
|
+
// eslint-disable-next-line max-depth
|
|
112
113
|
if (widths[item[0]][1] - delta > this.minItemSize.width) {
|
|
113
114
|
widths[item[0]][1] -= delta;
|
|
114
115
|
delta = 0;
|
package/src/GridLayout.tsx
CHANGED
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import {BaseLayout, BaseLayoutOptions} from './BaseLayout';
|
|
14
|
-
import {
|
|
14
|
+
import {getChildNodes, getFirstItem} from '@react-stately/collections';
|
|
15
|
+
import {Key, Node, Orientation} from '@react-types/shared';
|
|
15
16
|
import {LayoutInfo, Rect, Size} from '@react-stately/virtualizer';
|
|
16
|
-
import {Node, Orientation} from '@react-types/shared';
|
|
17
17
|
|
|
18
18
|
export interface GridLayoutOptions extends BaseLayoutOptions {
|
|
19
19
|
// /**
|
|
@@ -255,7 +255,8 @@ export class GridLayout<T> extends BaseLayout<T> {
|
|
|
255
255
|
return null;
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
-
|
|
258
|
+
let row = this.collection.rows[indexRowBelow];
|
|
259
|
+
return row ? getFirstItem(getChildNodes(row, this.collection))?.key : null;
|
|
259
260
|
}
|
|
260
261
|
|
|
261
262
|
getKeyAbove(key: Key) {
|
|
@@ -269,6 +270,7 @@ export class GridLayout<T> extends BaseLayout<T> {
|
|
|
269
270
|
return null;
|
|
270
271
|
}
|
|
271
272
|
|
|
272
|
-
|
|
273
|
+
let row = this.collection.rows[indexRowAbove];
|
|
274
|
+
return row ? getFirstItem(getChildNodes(row, this.collection))?.key : null;
|
|
273
275
|
}
|
|
274
276
|
}
|
package/src/WaterfallLayout.tsx
CHANGED
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import {BaseLayout, BaseLayoutOptions} from './BaseLayout';
|
|
14
|
+
import {getChildNodes, getFirstItem} from '@react-stately/collections';
|
|
14
15
|
import {InvalidationContext, LayoutInfo, Rect, Size} from '@react-stately/virtualizer';
|
|
15
|
-
import {Key} from 'react';
|
|
16
|
-
import {KeyboardDelegate, Node} from '@react-types/shared';
|
|
16
|
+
import {Key, KeyboardDelegate, Node} from '@react-types/shared';
|
|
17
17
|
|
|
18
18
|
export interface WaterfallLayoutOptions extends BaseLayoutOptions {
|
|
19
19
|
/**
|
|
@@ -207,7 +207,8 @@ export class WaterfallLayout<T> extends BaseLayout<T> implements KeyboardDelegat
|
|
|
207
207
|
key = this._findClosest(layoutInfo.rect, rect)?.key;
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
|
|
210
|
+
let item = this.collection.getItem(key);
|
|
211
|
+
return getFirstItem(getChildNodes(item, this.collection))?.key;
|
|
211
212
|
}
|
|
212
213
|
|
|
213
214
|
getClosestLeft(key: Key) {
|
|
@@ -221,7 +222,8 @@ export class WaterfallLayout<T> extends BaseLayout<T> implements KeyboardDelegat
|
|
|
221
222
|
key = this._findClosest(layoutInfo.rect, rect)?.key;
|
|
222
223
|
}
|
|
223
224
|
|
|
224
|
-
|
|
225
|
+
let item = this.collection.getItem(key);
|
|
226
|
+
return getFirstItem(getChildNodes(item, this.collection))?.key;
|
|
225
227
|
}
|
|
226
228
|
|
|
227
229
|
getKeyRightOf(key: Key) {
|
package/src/index.ts
CHANGED
|
@@ -12,8 +12,13 @@
|
|
|
12
12
|
|
|
13
13
|
/// <reference types="css-module-types" />
|
|
14
14
|
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
export
|
|
15
|
+
export type {GalleryLayoutOptions} from './GalleryLayout';
|
|
16
|
+
export type {GridLayoutOptions} from './GridLayout';
|
|
17
|
+
export type {WaterfallLayoutOptions} from './WaterfallLayout';
|
|
18
|
+
|
|
19
|
+
export {CardView} from './CardView';
|
|
20
|
+
export {GalleryLayout} from './GalleryLayout';
|
|
21
|
+
export {GridLayout} from './GridLayout';
|
|
22
|
+
export {WaterfallLayout} from './WaterfallLayout';
|
|
23
|
+
export {Card} from './Card';
|
|
24
|
+
export type {SpectrumCardViewProps} from '@react-types/card';
|