@react-spectrum/card 3.0.0-nightly.4552 → 3.0.0-nightly.4558

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.
Files changed (94) hide show
  1. package/dist/BaseLayout.main.js +218 -0
  2. package/dist/BaseLayout.main.js.map +1 -0
  3. package/dist/BaseLayout.mjs +213 -0
  4. package/dist/BaseLayout.module.js +213 -0
  5. package/dist/BaseLayout.module.js.map +1 -0
  6. package/dist/Card.main.js +51 -0
  7. package/dist/Card.main.js.map +1 -0
  8. package/dist/Card.mjs +42 -0
  9. package/dist/Card.module.js +42 -0
  10. package/dist/Card.module.js.map +1 -0
  11. package/dist/CardBase.main.js +205 -0
  12. package/dist/CardBase.main.js.map +1 -0
  13. package/dist/CardBase.mjs +200 -0
  14. package/dist/CardBase.module.js +200 -0
  15. package/dist/CardBase.module.js.map +1 -0
  16. package/dist/CardView.main.js +232 -0
  17. package/dist/CardView.main.js.map +1 -0
  18. package/dist/CardView.mjs +227 -0
  19. package/dist/CardView.module.js +227 -0
  20. package/dist/CardView.module.js.map +1 -0
  21. package/dist/CardViewContext.main.js +31 -0
  22. package/dist/CardViewContext.main.js.map +1 -0
  23. package/dist/CardViewContext.mjs +21 -0
  24. package/dist/CardViewContext.module.js +21 -0
  25. package/dist/CardViewContext.module.js.map +1 -0
  26. package/dist/GalleryLayout.main.js +229 -0
  27. package/dist/GalleryLayout.main.js.map +1 -0
  28. package/dist/GalleryLayout.mjs +224 -0
  29. package/dist/GalleryLayout.module.js +224 -0
  30. package/dist/GalleryLayout.module.js.map +1 -0
  31. package/dist/GridLayout.main.js +198 -0
  32. package/dist/GridLayout.main.js.map +1 -0
  33. package/dist/GridLayout.mjs +193 -0
  34. package/dist/GridLayout.module.js +193 -0
  35. package/dist/GridLayout.module.js.map +1 -0
  36. package/dist/WaterfallLayout.main.js +181 -0
  37. package/dist/WaterfallLayout.main.js.map +1 -0
  38. package/dist/WaterfallLayout.mjs +176 -0
  39. package/dist/WaterfallLayout.module.js +176 -0
  40. package/dist/WaterfallLayout.module.js.map +1 -0
  41. package/dist/ar-AE.mjs +1 -1
  42. package/dist/bg-BG.mjs +1 -1
  43. package/dist/card_vars_css.main.js +116 -0
  44. package/dist/card_vars_css.main.js.map +1 -0
  45. package/dist/card_vars_css.mjs +118 -0
  46. package/dist/card_vars_css.module.js +118 -0
  47. package/dist/card_vars_css.module.js.map +1 -0
  48. package/dist/cs-CZ.mjs +1 -1
  49. package/dist/da-DK.mjs +1 -1
  50. package/dist/de-DE.mjs +1 -1
  51. package/dist/el-GR.mjs +1 -1
  52. package/dist/en-US.mjs +1 -1
  53. package/dist/es-ES.mjs +1 -1
  54. package/dist/et-EE.mjs +1 -1
  55. package/dist/fi-FI.mjs +1 -1
  56. package/dist/fr-FR.mjs +1 -1
  57. package/dist/he-IL.mjs +1 -1
  58. package/dist/hr-HR.mjs +1 -1
  59. package/dist/hu-HU.mjs +1 -1
  60. package/dist/import.mjs +5 -1458
  61. package/dist/intlStrings.main.js +108 -0
  62. package/dist/intlStrings.main.js.map +1 -0
  63. package/dist/intlStrings.mjs +110 -0
  64. package/dist/intlStrings.module.js +110 -0
  65. package/dist/intlStrings.module.js.map +1 -0
  66. package/dist/it-IT.mjs +1 -1
  67. package/dist/ja-JP.mjs +1 -1
  68. package/dist/ko-KR.mjs +1 -1
  69. package/dist/lt-LT.mjs +1 -1
  70. package/dist/lv-LV.mjs +1 -1
  71. package/dist/main.js +10 -1459
  72. package/dist/main.js.map +1 -1
  73. package/dist/module.js +5 -1458
  74. package/dist/module.js.map +1 -1
  75. package/dist/nb-NO.mjs +1 -1
  76. package/dist/nl-NL.mjs +1 -1
  77. package/dist/pl-PL.mjs +1 -1
  78. package/dist/pt-BR.mjs +1 -1
  79. package/dist/pt-PT.mjs +1 -1
  80. package/dist/ro-RO.mjs +1 -1
  81. package/dist/ru-RU.mjs +1 -1
  82. package/dist/sk-SK.mjs +1 -1
  83. package/dist/sl-SI.mjs +1 -1
  84. package/dist/sr-SP.mjs +1 -1
  85. package/dist/sv-SE.mjs +1 -1
  86. package/dist/tr-TR.mjs +1 -1
  87. package/dist/uk-UA.mjs +1 -1
  88. package/dist/{main.css → vars.e5a6cd16.css} +1 -1
  89. package/dist/{main.css.map → vars.e5a6cd16.css.map} +1 -1
  90. package/dist/zh-CN.mjs +1 -1
  91. package/dist/zh-TW.mjs +1 -1
  92. package/package.json +19 -19
  93. package/dist/module.css +0 -1671
  94. package/dist/module.css.map +0 -1
@@ -0,0 +1,213 @@
1
+ import {getFirstItem as $1JdnP$getFirstItem, getChildNodes as $1JdnP$getChildNodes} from "@react-stately/collections";
2
+ import {Rect as $1JdnP$Rect, Layout as $1JdnP$Layout} from "@react-stately/virtualizer";
3
+
4
+ /*
5
+ * Copyright 2021 Adobe. All rights reserved.
6
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License. You may obtain a copy
8
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software distributed under
11
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ * OF ANY KIND, either express or implied. See the License for the specific language
13
+ * governing permissions and limitations under the License.
14
+ */
15
+
16
+ class $3d424c147206bac9$export$64943d2e59d72a29 extends (0, $1JdnP$Layout) {
17
+ validate(invalidationContext) {
18
+ this.collection = this.virtualizer.collection;
19
+ this.buildCollection(invalidationContext);
20
+ // Remove layout info that doesn't exist in new collection
21
+ if (this.lastCollection) {
22
+ for (let key of this.lastCollection.getKeys())if (!this.collection.getItem(key)) this.layoutInfos.delete(key);
23
+ if (!this.isLoading) this.layoutInfos.delete("loader");
24
+ if (this.collection.size > 0) this.layoutInfos.delete("placeholder");
25
+ }
26
+ this.lastCollection = this.collection;
27
+ }
28
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
29
+ buildCollection(invalidationContext) {}
30
+ getContentSize() {
31
+ return this.contentSize;
32
+ }
33
+ getLayoutInfo(key) {
34
+ return this.layoutInfos.get(key);
35
+ }
36
+ getVisibleLayoutInfos(rect) {
37
+ let res = [];
38
+ for (let layoutInfo of this.layoutInfos.values())if (this.isVisible(layoutInfo, rect)) res.push(layoutInfo);
39
+ return res;
40
+ }
41
+ isVisible(layoutInfo, rect) {
42
+ return layoutInfo.rect.intersects(rect);
43
+ }
44
+ getInitialLayoutInfo(layoutInfo) {
45
+ layoutInfo.opacity = 0;
46
+ layoutInfo.transform = "scale3d(0.8, 0.8, 0.8)";
47
+ return layoutInfo;
48
+ }
49
+ getFinalLayoutInfo(layoutInfo) {
50
+ layoutInfo.opacity = 0;
51
+ layoutInfo.transform = "scale3d(0.8, 0.8, 0.8)";
52
+ return layoutInfo;
53
+ }
54
+ _findClosestLayoutInfo(target, rect) {
55
+ let layoutInfos = this.getVisibleLayoutInfos(rect);
56
+ let best = null;
57
+ let bestDistance = Infinity;
58
+ // Calculates distance as the distance between the center of 2 rects.
59
+ for (let cur of layoutInfos)if (cur.type === "item") {
60
+ let curRect = cur.rect;
61
+ let targetMidX = (target.x + target.maxX) / 2;
62
+ let targetMidY = (target.y + target.maxY) / 2;
63
+ let curMidX = (curRect.x + curRect.maxX) / 2;
64
+ let curMidY = (curRect.y + curRect.maxY) / 2;
65
+ let dist = Math.pow(targetMidX - curMidX, 2) + Math.pow(targetMidY - curMidY, 2);
66
+ if (dist < bestDistance) {
67
+ best = cur;
68
+ bestDistance = dist;
69
+ }
70
+ }
71
+ return best;
72
+ }
73
+ _findClosest(target, rect) {
74
+ let best = this._findClosestLayoutInfo(target, rect);
75
+ return best || null;
76
+ }
77
+ getKeyBelow(key) {
78
+ var _this__findClosest, _getFirstItem;
79
+ // Expected key is the currently focused cell so we need the parent row key
80
+ let parentRowKey = this.collection.getItem(key).parentKey;
81
+ let layoutInfo = this.getLayoutInfo(parentRowKey);
82
+ let rect = new (0, $1JdnP$Rect)(layoutInfo.rect.x, layoutInfo.rect.maxY + 1, layoutInfo.rect.width, this.virtualizer.visibleRect.height);
83
+ let closestRow = this.collection.getItem((_this__findClosest = this._findClosest(layoutInfo.rect, rect)) === null || _this__findClosest === void 0 ? void 0 : _this__findClosest.key);
84
+ return (_getFirstItem = (0, $1JdnP$getFirstItem)((0, $1JdnP$getChildNodes)(closestRow, this.collection))) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key;
85
+ }
86
+ getKeyAbove(key) {
87
+ var _this__findClosest, _getFirstItem;
88
+ // Expected key is the currently focused cell so we need the parent row key
89
+ let parentRowKey = this.collection.getItem(key).parentKey;
90
+ let layoutInfo = this.getLayoutInfo(parentRowKey);
91
+ let rect = new (0, $1JdnP$Rect)(layoutInfo.rect.x, 0, layoutInfo.rect.width, layoutInfo.rect.y - 1);
92
+ let closestRow = this.collection.getItem((_this__findClosest = this._findClosest(layoutInfo.rect, rect)) === null || _this__findClosest === void 0 ? void 0 : _this__findClosest.key);
93
+ return (_getFirstItem = (0, $1JdnP$getFirstItem)((0, $1JdnP$getChildNodes)(closestRow, this.collection))) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key;
94
+ }
95
+ getKeyRightOf(key) {
96
+ // Expected key is the currently focused cell so we need the parent row key
97
+ let parentRowKey = this.collection.getItem(key).parentKey;
98
+ key = this.direction === "rtl" ? this.collection.getKeyBefore(parentRowKey) : this.collection.getKeyAfter(parentRowKey);
99
+ while(key != null){
100
+ var _getFirstItem;
101
+ let item = this.collection.getItem(key);
102
+ // Don't check if item is disabled because we want to be able to focus disabled items in a grid (double check this)
103
+ if (item.type === "item") return (_getFirstItem = (0, $1JdnP$getFirstItem)((0, $1JdnP$getChildNodes)(item, this.collection))) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key;
104
+ key = this.direction === "rtl" ? this.collection.getKeyBefore(key) : this.collection.getKeyAfter(key);
105
+ }
106
+ }
107
+ getKeyLeftOf(key) {
108
+ // Expected key is the currently focused cell so we need the parent row key
109
+ let parentRowKey = this.collection.getItem(key).parentKey;
110
+ key = this.direction === "rtl" ? this.collection.getKeyAfter(parentRowKey) : this.collection.getKeyBefore(parentRowKey);
111
+ while(key != null){
112
+ var _getFirstItem;
113
+ let item = this.collection.getItem(key);
114
+ // Don't check if item is disabled because we want to be able to focus disabled items in a grid (double check this)
115
+ if (item.type === "item") return (_getFirstItem = (0, $1JdnP$getFirstItem)((0, $1JdnP$getChildNodes)(item, this.collection))) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key;
116
+ key = this.direction === "rtl" ? this.collection.getKeyAfter(key) : this.collection.getKeyBefore(key);
117
+ }
118
+ }
119
+ getFirstKey() {
120
+ var _getFirstItem;
121
+ let firstRow = this.collection.getItem(this.collection.getFirstKey());
122
+ return (_getFirstItem = (0, $1JdnP$getFirstItem)((0, $1JdnP$getChildNodes)(firstRow, this.collection))) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key;
123
+ }
124
+ getLastKey() {
125
+ var _getFirstItem;
126
+ let lastRow = this.collection.getItem(this.collection.getLastKey());
127
+ return (_getFirstItem = (0, $1JdnP$getFirstItem)((0, $1JdnP$getChildNodes)(lastRow, this.collection))) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key;
128
+ }
129
+ // TODO: pretty unwieldy because it needs to bounce back and forth between the parent key and the child key
130
+ // 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?
131
+ getKeyPageAbove(key) {
132
+ // Expected key is the currently focused cell so we need the parent row key
133
+ let parentRowKey = this.collection.getItem(key).parentKey;
134
+ let layoutInfo = this.getLayoutInfo(parentRowKey);
135
+ if (layoutInfo) {
136
+ var _this_collection_getItem;
137
+ let pageY = Math.max(0, layoutInfo.rect.y + layoutInfo.rect.height - this.virtualizer.visibleRect.height);
138
+ // If the node is so large that it spans multiple page heights, return the key of the item immediately above
139
+ // Otherwise keep going up until we exceed a single page height worth of nodes
140
+ let keyAbove = (_this_collection_getItem = this.collection.getItem(this.getKeyAbove(key))) === null || _this_collection_getItem === void 0 ? void 0 : _this_collection_getItem.parentKey;
141
+ layoutInfo = this.getLayoutInfo(keyAbove);
142
+ if (layoutInfo && layoutInfo.rect.y > pageY) while(layoutInfo && layoutInfo.rect.y > pageY){
143
+ var _getFirstItem, _this_collection_getItem1;
144
+ let childKey = (_getFirstItem = (0, $1JdnP$getFirstItem)((0, $1JdnP$getChildNodes)(this.collection.getItem(layoutInfo.key), this.collection))) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key;
145
+ let keyAbove = (_this_collection_getItem1 = this.collection.getItem(this.getKeyAbove(childKey))) === null || _this_collection_getItem1 === void 0 ? void 0 : _this_collection_getItem1.parentKey;
146
+ layoutInfo = this.getLayoutInfo(keyAbove);
147
+ }
148
+ if (layoutInfo) {
149
+ var _getFirstItem1;
150
+ let childKey = (_getFirstItem1 = (0, $1JdnP$getFirstItem)((0, $1JdnP$getChildNodes)(this.collection.getItem(layoutInfo.key), this.collection))) === null || _getFirstItem1 === void 0 ? void 0 : _getFirstItem1.key;
151
+ return childKey;
152
+ }
153
+ }
154
+ return this.getFirstKey();
155
+ }
156
+ // TODO: pretty unwieldy because it needs to bounce back and forth between the parent key and the child key
157
+ // Perhaps have layoutInfo store childKey as well so we don't need to do this?
158
+ getKeyPageBelow(key) {
159
+ // Expected key is the currently focused cell so we need the parent row key
160
+ let parentRowKey = this.collection.getItem(key).parentKey;
161
+ let layoutInfo = this.getLayoutInfo(parentRowKey);
162
+ if (layoutInfo) {
163
+ var _this_collection_getItem;
164
+ let pageY = Math.min(this.virtualizer.contentSize.height, layoutInfo.rect.y - layoutInfo.rect.height + this.virtualizer.visibleRect.height);
165
+ // If the node is so large that it spans multiple page heights, return the key of the item immediately below
166
+ // Otherwise keep going up until we exceed a single page height worth of nodes
167
+ let keyBelow = (_this_collection_getItem = this.collection.getItem(this.getKeyBelow(key))) === null || _this_collection_getItem === void 0 ? void 0 : _this_collection_getItem.parentKey;
168
+ layoutInfo = this.getLayoutInfo(keyBelow);
169
+ if (layoutInfo && layoutInfo.rect.y < pageY) while(layoutInfo && layoutInfo.rect.y < pageY){
170
+ var _getFirstItem, _this_collection_getItem1;
171
+ let childKey = (_getFirstItem = (0, $1JdnP$getFirstItem)((0, $1JdnP$getChildNodes)(this.collection.getItem(layoutInfo.key), this.collection))) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key;
172
+ let keyBelow = (_this_collection_getItem1 = this.collection.getItem(this.getKeyBelow(childKey))) === null || _this_collection_getItem1 === void 0 ? void 0 : _this_collection_getItem1.parentKey;
173
+ layoutInfo = this.getLayoutInfo(keyBelow);
174
+ }
175
+ if (layoutInfo) {
176
+ var _getFirstItem1;
177
+ let childKey = (_getFirstItem1 = (0, $1JdnP$getFirstItem)((0, $1JdnP$getChildNodes)(this.collection.getItem(layoutInfo.key), this.collection))) === null || _getFirstItem1 === void 0 ? void 0 : _getFirstItem1.key;
178
+ return childKey;
179
+ }
180
+ }
181
+ return this.getLastKey();
182
+ }
183
+ getKeyForSearch(search, fromKey) {
184
+ if (!this.collator) return null;
185
+ let collection = this.collection;
186
+ let key = fromKey !== null && fromKey !== void 0 ? fromKey : this.getFirstKey();
187
+ let startItem = collection.getItem(key);
188
+ key = startItem.parentKey;
189
+ while(key != null){
190
+ let item = collection.getItem(key);
191
+ if (item.textValue) {
192
+ var _getFirstItem;
193
+ let substring = item.textValue.slice(0, search.length);
194
+ if (this.collator.compare(substring, search) === 0) return (_getFirstItem = (0, $1JdnP$getFirstItem)((0, $1JdnP$getChildNodes)(item, this.collection))) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key;
195
+ }
196
+ key = this.collection.getKeyAfter(key);
197
+ }
198
+ return null;
199
+ }
200
+ constructor(options = {}){
201
+ super();
202
+ this.disabledKeys = new Set();
203
+ this.layoutInfos = new Map();
204
+ this.collator = options.collator;
205
+ this.lastCollection = null;
206
+ this.scale = options.scale || "medium";
207
+ this.margin = options.margin || 24;
208
+ }
209
+ }
210
+
211
+
212
+ export {$3d424c147206bac9$export$64943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ved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Direction, Key, KeyboardDelegate, Node} from '@react-types/shared';\nimport {getChildNodes, getFirstItem} from '@react-stately/collections';\nimport {GridCollection} from '@react-stately/grid';\nimport {InvalidationContext, Layout, LayoutInfo, Rect, Size} from '@react-stately/virtualizer';\nimport {Scale} from '@react-types/provider';\n\nexport interface BaseLayoutOptions {\n collator?: Intl.Collator,\n // TODO: is this valid or is scale a spectrum specific thing that should be left out of the layouts?\n scale?: Scale,\n /**\n * The margin around the grid view between the edges and the items.\n * @default 24\n */\n margin?: number\n}\n\nexport class BaseLayout<T> extends Layout<Node<T>> implements KeyboardDelegate {\n protected contentSize: Size;\n protected layoutInfos: Map<Key, LayoutInfo>;\n protected collator: Intl.Collator;\n protected lastCollection: GridCollection<T>;\n collection: GridCollection<T>;\n isLoading: boolean;\n disabledKeys: Set<Key> = new Set();\n direction: Direction;\n scale: Scale;\n margin: number;\n\n constructor(options: BaseLayoutOptions = {}) {\n super();\n this.layoutInfos = new Map();\n this.collator = options.collator;\n this.lastCollection = null;\n this.scale = options.scale || 'medium';\n this.margin = options.margin || 24;\n }\n\n validate(invalidationContext: InvalidationContext<Node<T>, unknown>) {\n this.collection = this.virtualizer.collection as GridCollection<T>;\n this.buildCollection(invalidationContext);\n\n // Remove layout info that doesn't exist in new collection\n if (this.lastCollection) {\n for (let key of this.lastCollection.getKeys()) {\n if (!this.collection.getItem(key)) {\n this.layoutInfos.delete(key);\n }\n }\n\n if (!this.isLoading) {\n this.layoutInfos.delete('loader');\n }\n\n if (this.collection.size > 0) {\n this.layoutInfos.delete('placeholder');\n }\n }\n\n this.lastCollection = this.collection;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n buildCollection(invalidationContext?: InvalidationContext<Node<T>, unknown>) {}\n\n getContentSize() {\n return this.contentSize;\n }\n\n getLayoutInfo(key: Key) {\n return this.layoutInfos.get(key);\n }\n\n getVisibleLayoutInfos(rect) {\n let res: LayoutInfo[] = [];\n\n for (let layoutInfo of this.layoutInfos.values()) {\n if (this.isVisible(layoutInfo, rect)) {\n res.push(layoutInfo);\n }\n }\n\n return res;\n }\n\n isVisible(layoutInfo: LayoutInfo, rect: Rect) {\n return layoutInfo.rect.intersects(rect);\n }\n\n getInitialLayoutInfo(layoutInfo: LayoutInfo) {\n layoutInfo.opacity = 0;\n layoutInfo.transform = 'scale3d(0.8, 0.8, 0.8)';\n return layoutInfo;\n }\n\n getFinalLayoutInfo(layoutInfo: LayoutInfo) {\n layoutInfo.opacity = 0;\n layoutInfo.transform = 'scale3d(0.8, 0.8, 0.8)';\n return layoutInfo;\n }\n\n _findClosestLayoutInfo(target: Rect, rect: Rect) {\n let layoutInfos = this.getVisibleLayoutInfos(rect);\n let best = null;\n let bestDistance = Infinity;\n\n // Calculates distance as the distance between the center of 2 rects.\n for (let cur of layoutInfos) {\n if (cur.type === 'item') {\n let curRect = cur.rect;\n let targetMidX = (target.x + target.maxX) / 2;\n let targetMidY = (target.y + target.maxY) / 2;\n let curMidX = (curRect.x + curRect.maxX) / 2;\n let curMidY = (curRect.y + curRect.maxY) / 2;\n let dist = Math.pow(targetMidX - curMidX, 2) + Math.pow(targetMidY - curMidY, 2);\n if (dist < bestDistance) {\n best = cur;\n bestDistance = dist;\n }\n }\n }\n\n return best;\n }\n\n _findClosest(target: Rect, rect: Rect) {\n let best = this._findClosestLayoutInfo(target, rect);\n return best || null;\n }\n\n getKeyBelow(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n let layoutInfo = this.getLayoutInfo(parentRowKey);\n let rect = new Rect(layoutInfo.rect.x, layoutInfo.rect.maxY + 1, layoutInfo.rect.width, this.virtualizer.visibleRect.height);\n let closestRow = this.collection.getItem(this._findClosest(layoutInfo.rect, rect)?.key);\n return getFirstItem(getChildNodes(closestRow, this.collection))?.key;\n }\n\n getKeyAbove(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n let layoutInfo = this.getLayoutInfo(parentRowKey);\n let rect = new Rect(layoutInfo.rect.x, 0, layoutInfo.rect.width, layoutInfo.rect.y - 1);\n let closestRow = this.collection.getItem(this._findClosest(layoutInfo.rect, rect)?.key);\n return getFirstItem(getChildNodes(closestRow, this.collection))?.key;\n }\n\n getKeyRightOf(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n key = this.direction === 'rtl' ? this.collection.getKeyBefore(parentRowKey) : this.collection.getKeyAfter(parentRowKey);\n\n while (key != null) {\n let item = this.collection.getItem(key);\n // Don't check if item is disabled because we want to be able to focus disabled items in a grid (double check this)\n if (item.type === 'item') {\n return getFirstItem(getChildNodes(item, this.collection))?.key;\n }\n key = this.direction === 'rtl' ? this.collection.getKeyBefore(key) : this.collection.getKeyAfter(key);\n }\n }\n\n getKeyLeftOf(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n key = this.direction === 'rtl' ? this.collection.getKeyAfter(parentRowKey) : this.collection.getKeyBefore(parentRowKey);\n while (key != null) {\n let item = this.collection.getItem(key);\n // Don't check if item is disabled because we want to be able to focus disabled items in a grid (double check this)\n if (item.type === 'item') {\n return getFirstItem(getChildNodes(item, this.collection))?.key;\n }\n\n key = this.direction === 'rtl' ? this.collection.getKeyAfter(key) : this.collection.getKeyBefore(key);\n }\n }\n\n getFirstKey() {\n let firstRow = this.collection.getItem(this.collection.getFirstKey());\n return getFirstItem(getChildNodes(firstRow, this.collection))?.key;\n }\n\n getLastKey() {\n let lastRow = this.collection.getItem(this.collection.getLastKey());\n return getFirstItem(getChildNodes(lastRow, this.collection))?.key;\n }\n\n // TODO: pretty unwieldy because it needs to bounce back and forth between the parent key and the child key\n // 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?\n getKeyPageAbove(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n let layoutInfo = this.getLayoutInfo(parentRowKey);\n\n if (layoutInfo) {\n let pageY = Math.max(0, layoutInfo.rect.y + layoutInfo.rect.height - this.virtualizer.visibleRect.height);\n // If the node is so large that it spans multiple page heights, return the key of the item immediately above\n // Otherwise keep going up until we exceed a single page height worth of nodes\n let keyAbove = this.collection.getItem(this.getKeyAbove(key))?.parentKey;\n layoutInfo = this.getLayoutInfo(keyAbove);\n\n if (layoutInfo && layoutInfo.rect.y > pageY) {\n while (layoutInfo && layoutInfo.rect.y > pageY) {\n let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;\n let keyAbove = this.collection.getItem(this.getKeyAbove(childKey))?.parentKey;\n layoutInfo = this.getLayoutInfo(keyAbove);\n }\n }\n\n if (layoutInfo) {\n let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;\n return childKey;\n }\n }\n\n return this.getFirstKey();\n }\n\n // TODO: pretty unwieldy because it needs to bounce back and forth between the parent key and the child key\n // Perhaps have layoutInfo store childKey as well so we don't need to do this?\n getKeyPageBelow(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n let layoutInfo = this.getLayoutInfo(parentRowKey);\n if (layoutInfo) {\n let pageY = Math.min(this.virtualizer.contentSize.height, layoutInfo.rect.y - layoutInfo.rect.height + this.virtualizer.visibleRect.height);\n // If the node is so large that it spans multiple page heights, return the key of the item immediately below\n // Otherwise keep going up until we exceed a single page height worth of nodes\n let keyBelow = this.collection.getItem(this.getKeyBelow(key))?.parentKey;\n layoutInfo = this.getLayoutInfo(keyBelow);\n if (layoutInfo && layoutInfo.rect.y < pageY) {\n while (layoutInfo && layoutInfo.rect.y < pageY) {\n let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;\n let keyBelow = this.collection.getItem(this.getKeyBelow(childKey))?.parentKey;\n layoutInfo = this.getLayoutInfo(keyBelow);\n }\n }\n\n if (layoutInfo) {\n let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;\n return childKey;\n }\n }\n\n return this.getLastKey();\n }\n\n getKeyForSearch(search: string, fromKey?: Key) {\n if (!this.collator) {\n return null;\n }\n\n let collection = this.collection;\n let key = fromKey ?? this.getFirstKey();\n\n let startItem = collection.getItem(key);\n key = startItem.parentKey;\n\n while (key != null) {\n let item = collection.getItem(key);\n if (item.textValue) {\n let substring = item.textValue.slice(0, search.length);\n if (this.collator.compare(substring, search) === 0) {\n return getFirstItem(getChildNodes(item, this.collection))?.key;\n }\n }\n\n key = this.collection.getKeyAfter(key);\n }\n\n return null;\n }\n}\n"],"names":[],"version":3,"file":"BaseLayout.module.js.map"}
@@ -0,0 +1,51 @@
1
+ var $7888205ff7de382f$exports = require("./CardBase.main.js");
2
+ var $e57ab98cef2f01a5$exports = require("./CardViewContext.main.js");
3
+ var $495a5$react = require("react");
4
+
5
+
6
+ function $parcel$interopDefault(a) {
7
+ return a && a.__esModule ? a.default : a;
8
+ }
9
+
10
+ function $parcel$export(e, n, v, s) {
11
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
12
+ }
13
+
14
+ $parcel$export(module.exports, "Card", () => $6b630ac4b78ba7f3$export$60332b2344f7fe41);
15
+ /*
16
+ * Copyright 2021 Adobe. All rights reserved.
17
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
18
+ * you may not use this file except in compliance with the License. You may obtain a copy
19
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
20
+ *
21
+ * Unless required by applicable law or agreed to in writing, software distributed under
22
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
23
+ * OF ANY KIND, either express or implied. See the License for the specific language
24
+ * governing permissions and limitations under the License.
25
+ */
26
+
27
+
28
+ let $6b630ac4b78ba7f3$var$Card = /*#__PURE__*/ (0, $495a5$react.forwardRef)((props, ref)=>{
29
+ let context = (0, $e57ab98cef2f01a5$exports.useCardViewContext)();
30
+ if (context !== null) return null;
31
+ else return /*#__PURE__*/ (0, ($parcel$interopDefault($495a5$react))).createElement((0, $7888205ff7de382f$exports.CardBase), {
32
+ ...props,
33
+ ref: ref
34
+ });
35
+ });
36
+ // @ts-ignore
37
+ $6b630ac4b78ba7f3$var$Card.getCollectionNode = function* getCollectionNode(props) {
38
+ let { children: children, textValue: textValue } = props;
39
+ yield {
40
+ type: "item",
41
+ props: props,
42
+ rendered: children,
43
+ "aria-label": props["aria-label"],
44
+ hasChildNodes: false,
45
+ textValue: textValue
46
+ };
47
+ };
48
+ let $6b630ac4b78ba7f3$export$60332b2344f7fe41 = $6b630ac4b78ba7f3$var$Card;
49
+
50
+
51
+ //# sourceMappingURL=Card.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAUD,IAAI,2CAAO,CAAA,GAAA,uBAAS,EAAE,CAAC,OAA0B;IAC/C,IAAI,UAAU,CAAA,GAAA,4CAAiB;IAC/B,IAAI,YAAY,MACd,OAAO;SAEP,qBACE,0DAAC,CAAA,GAAA,kCAAO;QAAG,GAAG,KAAK;QAAE,KAAK;;AAGhC;AAEA,aAAa;AACb,2BAAK,iBAAiB,GAAG,UAAU,kBAAqB,KAAU;IAChE,IAAI,YAAC,QAAQ,aAAE,SAAS,EAAC,GAAG;IAE5B,MAAM;QACJ,MAAM;QACN,OAAO;QACP,UAAU;QACV,cAAc,KAAK,CAAC,aAAa;QACjC,eAAe;mBACf;IACF;AACF;AAEA,IAAI,4CAAQ","sources":["packages/@react-spectrum/card/src/Card.tsx"],"sourcesContent":["/*\n * Copyright 2021 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CardBase} from './CardBase';\nimport {DOMRef, DOMRefValue, ItemProps} from '@react-types/shared';\nimport {PartialNode} from '@react-stately/collections';\nimport React, {forwardRef, ForwardRefExoticComponent, PropsWithoutRef, RefAttributes} from 'react';\nimport {SpectrumCardProps} from '@react-types/card';\nimport {useCardViewContext} from './CardViewContext';\n\n\nlet Card = forwardRef((props: SpectrumCardProps, ref: DOMRef<HTMLDivElement>) => {\n let context = useCardViewContext();\n if (context !== null) {\n return null;\n } else {\n return (\n <CardBase {...props} ref={ref} />\n );\n }\n});\n\n// @ts-ignore\nCard.getCollectionNode = function* getCollectionNode<T>(props: any): Generator<PartialNode<T>> {\n let {children, textValue} = props;\n\n yield {\n type: 'item',\n props: props,\n rendered: children,\n 'aria-label': props['aria-label'],\n hasChildNodes: false,\n textValue\n };\n};\n\nlet _Card = Card as ForwardRefExoticComponent<ItemProps<SpectrumCardProps> & PropsWithoutRef<SpectrumCardProps> & RefAttributes<DOMRefValue<HTMLDivElement>>>;\nexport {_Card as Card};\n"],"names":[],"version":3,"file":"Card.main.js.map"}
package/dist/Card.mjs ADDED
@@ -0,0 +1,42 @@
1
+ import {CardBase as $643dd8fa80926f94$export$7a6ccaf429ad93a8} from "./CardBase.mjs";
2
+ import {useCardViewContext as $8d180a244893de14$export$fea0b38586ec8f13} from "./CardViewContext.mjs";
3
+ import $kaPls$react, {forwardRef as $kaPls$forwardRef} from "react";
4
+
5
+ /*
6
+ * Copyright 2021 Adobe. All rights reserved.
7
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License. You may obtain a copy
9
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software distributed under
12
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
+ * OF ANY KIND, either express or implied. See the License for the specific language
14
+ * governing permissions and limitations under the License.
15
+ */
16
+
17
+
18
+ let $d2d1c099b89e366a$var$Card = /*#__PURE__*/ (0, $kaPls$forwardRef)((props, ref)=>{
19
+ let context = (0, $8d180a244893de14$export$fea0b38586ec8f13)();
20
+ if (context !== null) return null;
21
+ else return /*#__PURE__*/ (0, $kaPls$react).createElement((0, $643dd8fa80926f94$export$7a6ccaf429ad93a8), {
22
+ ...props,
23
+ ref: ref
24
+ });
25
+ });
26
+ // @ts-ignore
27
+ $d2d1c099b89e366a$var$Card.getCollectionNode = function* getCollectionNode(props) {
28
+ let { children: children, textValue: textValue } = props;
29
+ yield {
30
+ type: "item",
31
+ props: props,
32
+ rendered: children,
33
+ "aria-label": props["aria-label"],
34
+ hasChildNodes: false,
35
+ textValue: textValue
36
+ };
37
+ };
38
+ let $d2d1c099b89e366a$export$60332b2344f7fe41 = $d2d1c099b89e366a$var$Card;
39
+
40
+
41
+ export {$d2d1c099b89e366a$export$60332b2344f7fe41 as Card};
42
+ //# sourceMappingURL=Card.mjs.map
@@ -0,0 +1,42 @@
1
+ import {CardBase as $643dd8fa80926f94$export$7a6ccaf429ad93a8} from "./CardBase.module.js";
2
+ import {useCardViewContext as $8d180a244893de14$export$fea0b38586ec8f13} from "./CardViewContext.module.js";
3
+ import $kaPls$react, {forwardRef as $kaPls$forwardRef} from "react";
4
+
5
+ /*
6
+ * Copyright 2021 Adobe. All rights reserved.
7
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License. You may obtain a copy
9
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software distributed under
12
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
+ * OF ANY KIND, either express or implied. See the License for the specific language
14
+ * governing permissions and limitations under the License.
15
+ */
16
+
17
+
18
+ let $d2d1c099b89e366a$var$Card = /*#__PURE__*/ (0, $kaPls$forwardRef)((props, ref)=>{
19
+ let context = (0, $8d180a244893de14$export$fea0b38586ec8f13)();
20
+ if (context !== null) return null;
21
+ else return /*#__PURE__*/ (0, $kaPls$react).createElement((0, $643dd8fa80926f94$export$7a6ccaf429ad93a8), {
22
+ ...props,
23
+ ref: ref
24
+ });
25
+ });
26
+ // @ts-ignore
27
+ $d2d1c099b89e366a$var$Card.getCollectionNode = function* getCollectionNode(props) {
28
+ let { children: children, textValue: textValue } = props;
29
+ yield {
30
+ type: "item",
31
+ props: props,
32
+ rendered: children,
33
+ "aria-label": props["aria-label"],
34
+ hasChildNodes: false,
35
+ textValue: textValue
36
+ };
37
+ };
38
+ let $d2d1c099b89e366a$export$60332b2344f7fe41 = $d2d1c099b89e366a$var$Card;
39
+
40
+
41
+ export {$d2d1c099b89e366a$export$60332b2344f7fe41 as Card};
42
+ //# sourceMappingURL=Card.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAUD,IAAI,2CAAO,CAAA,GAAA,iBAAS,EAAE,CAAC,OAA0B;IAC/C,IAAI,UAAU,CAAA,GAAA,yCAAiB;IAC/B,IAAI,YAAY,MACd,OAAO;SAEP,qBACE,gCAAC,CAAA,GAAA,yCAAO;QAAG,GAAG,KAAK;QAAE,KAAK;;AAGhC;AAEA,aAAa;AACb,2BAAK,iBAAiB,GAAG,UAAU,kBAAqB,KAAU;IAChE,IAAI,YAAC,QAAQ,aAAE,SAAS,EAAC,GAAG;IAE5B,MAAM;QACJ,MAAM;QACN,OAAO;QACP,UAAU;QACV,cAAc,KAAK,CAAC,aAAa;QACjC,eAAe;mBACf;IACF;AACF;AAEA,IAAI,4CAAQ","sources":["packages/@react-spectrum/card/src/Card.tsx"],"sourcesContent":["/*\n * Copyright 2021 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CardBase} from './CardBase';\nimport {DOMRef, DOMRefValue, ItemProps} from '@react-types/shared';\nimport {PartialNode} from '@react-stately/collections';\nimport React, {forwardRef, ForwardRefExoticComponent, PropsWithoutRef, RefAttributes} from 'react';\nimport {SpectrumCardProps} from '@react-types/card';\nimport {useCardViewContext} from './CardViewContext';\n\n\nlet Card = forwardRef((props: SpectrumCardProps, ref: DOMRef<HTMLDivElement>) => {\n let context = useCardViewContext();\n if (context !== null) {\n return null;\n } else {\n return (\n <CardBase {...props} ref={ref} />\n );\n }\n});\n\n// @ts-ignore\nCard.getCollectionNode = function* getCollectionNode<T>(props: any): Generator<PartialNode<T>> {\n let {children, textValue} = props;\n\n yield {\n type: 'item',\n props: props,\n rendered: children,\n 'aria-label': props['aria-label'],\n hasChildNodes: false,\n textValue\n };\n};\n\nlet _Card = Card as ForwardRefExoticComponent<ItemProps<SpectrumCardProps> & PropsWithoutRef<SpectrumCardProps> & RefAttributes<DOMRefValue<HTMLDivElement>>>;\nexport {_Card as Card};\n"],"names":[],"version":3,"file":"Card.module.js.map"}
@@ -0,0 +1,205 @@
1
+ require("./vars.e5a6cd16.css");
2
+ var $71570f0038472fa2$exports = require("./card_vars_css.main.js");
3
+ var $e57ab98cef2f01a5$exports = require("./CardViewContext.main.js");
4
+ var $1rjnI$reactspectrumcheckbox = require("@react-spectrum/checkbox");
5
+ var $1rjnI$reactspectrumutils = require("@react-spectrum/utils");
6
+ var $1rjnI$reactariautils = require("@react-aria/utils");
7
+ var $1rjnI$reactariafocus = require("@react-aria/focus");
8
+ var $1rjnI$react = require("react");
9
+ var $1rjnI$reactariainteractions = require("@react-aria/interactions");
10
+ var $1rjnI$reactspectrumprovider = require("@react-spectrum/provider");
11
+
12
+
13
+ function $parcel$interopDefault(a) {
14
+ return a && a.__esModule ? a.default : a;
15
+ }
16
+
17
+ function $parcel$export(e, n, v, s) {
18
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
19
+ }
20
+
21
+ $parcel$export(module.exports, "CardBase", () => $7888205ff7de382f$export$7a6ccaf429ad93a8);
22
+ /*
23
+ * Copyright 2021 Adobe. All rights reserved.
24
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
25
+ * you may not use this file except in compliance with the License. You may obtain a copy
26
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
27
+ *
28
+ * Unless required by applicable law or agreed to in writing, software distributed under
29
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
30
+ * OF ANY KIND, either express or implied. See the License for the specific language
31
+ * governing permissions and limitations under the License.
32
+ */
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+ function $7888205ff7de382f$var$CardBase(props, ref) {
42
+ props = (0, $1rjnI$reactspectrumprovider.useProviderProps)(props);
43
+ let context = (0, $e57ab98cef2f01a5$exports.useCardViewContext)() || {}; // we can call again here, won't change from Card.tsx
44
+ let { state: state } = context;
45
+ let manager = state === null || state === void 0 ? void 0 : state.selectionManager;
46
+ let { isQuiet: isQuiet, orientation: orientation = "vertical", articleProps: articleProps = {}, item: item, layout: layout, children: children } = props;
47
+ let key = item === null || item === void 0 ? void 0 : item.key;
48
+ let isSelected = manager === null || manager === void 0 ? void 0 : manager.isSelected(key);
49
+ let isDisabled = state === null || state === void 0 ? void 0 : state.disabledKeys.has(key);
50
+ let onChange = ()=>manager === null || manager === void 0 ? void 0 : manager.select(key);
51
+ let { styleProps: styleProps } = (0, $1rjnI$reactspectrumutils.useStyleProps)(props);
52
+ let { cardProps: cardProps, titleProps: titleProps, contentProps: contentProps } = $7888205ff7de382f$var$useCard(props);
53
+ let domRef = (0, $1rjnI$reactspectrumutils.useDOMRef)(ref);
54
+ let gridRef = (0, $1rjnI$react.useRef)();
55
+ let checkboxRef = (0, $1rjnI$react.useRef)(null);
56
+ // cards are only interactive if there is a selection manager and it allows selection
57
+ let { hoverProps: hoverProps, isHovered: isHovered } = (0, $1rjnI$reactariainteractions.useHover)({
58
+ isDisabled: manager === undefined || (manager === null || manager === void 0 ? void 0 : manager.selectionMode) === "none" || isDisabled
59
+ });
60
+ let [isFocused, setIsFocused] = (0, $1rjnI$react.useState)(false);
61
+ let { focusWithinProps: focusWithinProps } = (0, $1rjnI$reactariainteractions.useFocusWithin)({
62
+ onFocusWithinChange: setIsFocused,
63
+ isDisabled: isDisabled
64
+ });
65
+ // ToDo: see css for comment about avatar under selector .spectrum-Card--noLayout.spectrum-Card--default
66
+ let hasPreviewImage = (0, $1rjnI$reactspectrumutils.useHasChild)(`.${(0, ($parcel$interopDefault($71570f0038472fa2$exports)))["spectrum-Card-image"]}`, gridRef);
67
+ let hasPreviewIllustration = (0, $1rjnI$reactspectrumutils.useHasChild)(`.${(0, ($parcel$interopDefault($71570f0038472fa2$exports)))["spectrum-Card-illustration"]}`, gridRef);
68
+ let hasPreview = hasPreviewImage || hasPreviewIllustration;
69
+ // this is for horizontal cards
70
+ let [height, setHeight] = (0, $1rjnI$react.useState)(NaN);
71
+ let updateHeight = (0, $1rjnI$react.useCallback)(()=>{
72
+ if (orientation !== "horizontal") return;
73
+ let cardHeight = gridRef.current.getBoundingClientRect().height;
74
+ setHeight(cardHeight);
75
+ }, [
76
+ orientation,
77
+ gridRef,
78
+ setHeight
79
+ ]);
80
+ (0, $1rjnI$reactariautils.useResizeObserver)({
81
+ ref: gridRef,
82
+ onResize: updateHeight
83
+ });
84
+ let aspectRatioEnforce = undefined;
85
+ if (orientation === "horizontal" && !isNaN(height)) aspectRatioEnforce = {
86
+ height: `${height}px`,
87
+ width: `${height}px`
88
+ };
89
+ let slots = (0, $1rjnI$react.useMemo)(()=>({
90
+ image: {
91
+ UNSAFE_className: (0, $1rjnI$reactspectrumutils.classNames)((0, ($parcel$interopDefault($71570f0038472fa2$exports))), "spectrum-Card-image"),
92
+ objectFit: orientation === "horizontal" ? "cover" : "contain",
93
+ alt: "",
94
+ ...aspectRatioEnforce
95
+ },
96
+ illustration: {
97
+ UNSAFE_className: (0, $1rjnI$reactspectrumutils.classNames)((0, ($parcel$interopDefault($71570f0038472fa2$exports))), "spectrum-Card-illustration"),
98
+ ...aspectRatioEnforce
99
+ },
100
+ avatar: {
101
+ UNSAFE_className: (0, $1rjnI$reactspectrumutils.classNames)((0, ($parcel$interopDefault($71570f0038472fa2$exports))), "spectrum-Card-avatar"),
102
+ size: "avatar-size-400"
103
+ },
104
+ heading: {
105
+ UNSAFE_className: (0, $1rjnI$reactspectrumutils.classNames)((0, ($parcel$interopDefault($71570f0038472fa2$exports))), "spectrum-Card-heading"),
106
+ ...titleProps
107
+ },
108
+ content: {
109
+ UNSAFE_className: (0, $1rjnI$reactspectrumutils.classNames)((0, ($parcel$interopDefault($71570f0038472fa2$exports))), "spectrum-Card-content"),
110
+ ...contentProps
111
+ },
112
+ detail: {
113
+ UNSAFE_className: (0, $1rjnI$reactspectrumutils.classNames)((0, ($parcel$interopDefault($71570f0038472fa2$exports))), "spectrum-Card-detail")
114
+ }
115
+ }), [
116
+ titleProps,
117
+ contentProps,
118
+ height,
119
+ isQuiet,
120
+ orientation
121
+ ]);
122
+ (0, $1rjnI$reactariautils.useLayoutEffect)(()=>{
123
+ if (gridRef === null || gridRef === void 0 ? void 0 : gridRef.current) {
124
+ let walker = (0, $1rjnI$reactariafocus.getFocusableTreeWalker)(gridRef.current);
125
+ let nextNode = walker.nextNode();
126
+ while(nextNode != null){
127
+ if (checkboxRef.current && !checkboxRef.current.UNSAFE_getDOMNode().contains(nextNode)) {
128
+ console.warn("Card does not support focusable elements, please contact the team regarding your use case.");
129
+ break;
130
+ }
131
+ nextNode = walker.nextNode();
132
+ }
133
+ }
134
+ }, [
135
+ children
136
+ ]);
137
+ return /*#__PURE__*/ (0, ($parcel$interopDefault($1rjnI$react))).createElement((0, $1rjnI$reactariafocus.FocusRing), {
138
+ focusRingClass: (0, $1rjnI$reactspectrumutils.classNames)((0, ($parcel$interopDefault($71570f0038472fa2$exports))), "focus-ring")
139
+ }, /*#__PURE__*/ (0, ($parcel$interopDefault($1rjnI$react))).createElement("article", {
140
+ ...styleProps,
141
+ ...(0, $1rjnI$reactariautils.mergeProps)(cardProps, focusWithinProps, hoverProps, (0, $1rjnI$reactariautils.filterDOMProps)(props), articleProps),
142
+ ref: domRef,
143
+ className: (0, $1rjnI$reactspectrumutils.classNames)((0, ($parcel$interopDefault($71570f0038472fa2$exports))), "spectrum-Card", {
144
+ "spectrum-Card--default": !isQuiet && orientation !== "horizontal",
145
+ "spectrum-Card--isQuiet": isQuiet && orientation !== "horizontal",
146
+ "spectrum-Card--horizontal": orientation === "horizontal",
147
+ "spectrum-Card--noPreview": !hasPreview,
148
+ "is-hovered": isHovered,
149
+ "is-focused": isFocused,
150
+ "is-selected": isSelected,
151
+ "spectrum-Card--waterfall": layout === "waterfall",
152
+ "spectrum-Card--gallery": layout === "gallery",
153
+ "spectrum-Card--grid": layout === "grid",
154
+ "spectrum-Card--noLayout": layout !== "waterfall" && layout !== "gallery" && layout !== "grid"
155
+ }, styleProps.className)
156
+ }, /*#__PURE__*/ (0, ($parcel$interopDefault($1rjnI$react))).createElement("div", {
157
+ ref: gridRef,
158
+ className: (0, $1rjnI$reactspectrumutils.classNames)((0, ($parcel$interopDefault($71570f0038472fa2$exports))), "spectrum-Card-grid")
159
+ }, manager && manager.selectionMode !== "none" && /*#__PURE__*/ (0, ($parcel$interopDefault($1rjnI$react))).createElement("div", {
160
+ className: (0, $1rjnI$reactspectrumutils.classNames)((0, ($parcel$interopDefault($71570f0038472fa2$exports))), "spectrum-Card-checkboxWrapper")
161
+ }, /*#__PURE__*/ (0, ($parcel$interopDefault($1rjnI$react))).createElement((0, $1rjnI$reactspectrumcheckbox.Checkbox), {
162
+ ref: checkboxRef,
163
+ isDisabled: isDisabled,
164
+ excludeFromTabOrder: true,
165
+ isSelected: isSelected,
166
+ onChange: onChange,
167
+ UNSAFE_className: (0, $1rjnI$reactspectrumutils.classNames)((0, ($parcel$interopDefault($71570f0038472fa2$exports))), "spectrum-Card-checkbox"),
168
+ isEmphasized: true,
169
+ "aria-label": "select"
170
+ })), /*#__PURE__*/ (0, ($parcel$interopDefault($1rjnI$react))).createElement((0, $1rjnI$reactspectrumutils.SlotProvider), {
171
+ slots: slots
172
+ }, children), /*#__PURE__*/ (0, ($parcel$interopDefault($1rjnI$react))).createElement("div", {
173
+ className: (0, $1rjnI$reactspectrumutils.classNames)((0, ($parcel$interopDefault($71570f0038472fa2$exports))), "spectrum-Card-decoration")
174
+ }))));
175
+ }
176
+ function $7888205ff7de382f$var$useCard(props) {
177
+ let titleId = (0, $1rjnI$reactariautils.useSlotId)();
178
+ let descriptionId = (0, $1rjnI$reactariautils.useSlotId)();
179
+ let titleProps = (0, $1rjnI$react.useMemo)(()=>({
180
+ id: titleId
181
+ }), [
182
+ titleId
183
+ ]);
184
+ let contentProps = (0, $1rjnI$react.useMemo)(()=>({
185
+ id: descriptionId
186
+ }), [
187
+ descriptionId
188
+ ]);
189
+ return {
190
+ cardProps: {
191
+ ...(0, $1rjnI$reactariautils.filterDOMProps)(props),
192
+ "aria-labelledby": titleId,
193
+ "aria-describedby": descriptionId,
194
+ tabIndex: 0
195
+ },
196
+ titleProps: titleProps,
197
+ contentProps: contentProps
198
+ };
199
+ }
200
+ /**
201
+ * TODO: Add description of component here.
202
+ */ const $7888205ff7de382f$export$7a6ccaf429ad93a8 = /*#__PURE__*/ (0, ($parcel$interop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0BAA0B,WAAW;YACrC,uBAAuB,WAAW;YAClC,2BAA2B,WAAW,eAAe,WAAW,aAAa,WAAW;QAC1F,GAAG,WAAW,SAAS;qBACvB,0DAAC;QAAI,KAAK;QAAS,WAAW,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;OAC9C,WAAW,QAAQ,aAAa,KAAK,wBACpC,0DAAC;QAAI,WAAW,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;qBACjC,0DAAC,CAAA,GAAA,qCAAO;QACN,KAAK;QACL,YAAY;QACZ,qBAAA;QACA,YAAY;QACZ,UAAU;QACV,kBAAkB,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;QACrC,cAAA;QACA,cAAW;uBAGjB,0DAAC,CAAA,GAAA,sCAAW;QAAE,OAAO;OAClB,yBAEH,0DAAC;QAAI,WAAW,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;;AAK7C;AAWA,SAAS,8BAAQ,KAAsB;IACrC,IAAI,UAAU,CAAA,GAAA,+BAAQ;IACtB,IAAI,gBAAgB,CAAA,GAAA,+BAAQ;IAC5B,IAAI,aAAa,CAAA,GAAA,oBAAM,EAAE,IAAO,CAAA;YAC9B,IAAI;QACN,CAAA,GAAI;QAAC;KAAQ;IACb,IAAI,eAAe,CAAA,GAAA,oBAAM,EAAE,IAAO,CAAA;YAChC,IAAI;QACN,CAAA,GAAI;QAAC;KAAc;IAEnB,OAAO;QACL,WAAW;YACT,GAAG,CAAA,GAAA,oCAAa,EAAE,MAAM;YACxB,mBAAmB;YACnB,oBAAoB;YACpB,UAAU;QACZ;oBACA;sBACA;IACF;AACF;AAEA;;CAEC,GACD,MAAM,0DAAY,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC","sources":["packages/@react-spectrum/card/src/CardBase.tsx"],"sourcesContent":["/*\n * Copyright 2021 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaCardProps, SpectrumCardProps} from '@react-types/card';\nimport {Checkbox} from '@react-spectrum/checkbox';\nimport {classNames, SlotProvider, useDOMRef, useHasChild, useStyleProps} from '@react-spectrum/utils';\nimport {DOMRef, Node} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useLayoutEffect, useResizeObserver, useSlotId} from '@react-aria/utils';\nimport {FocusRing, getFocusableTreeWalker} from '@react-aria/focus';\nimport React, {HTMLAttributes, useCallback, useMemo, useRef, useState} from 'react';\nimport styles from '@adobe/spectrum-css-temp/components/card/vars.css';\nimport {useCardViewContext} from './CardViewContext';\nimport {useFocusWithin, useHover} from '@react-aria/interactions';\nimport {useProviderProps} from '@react-spectrum/provider';\n\ninterface CardBaseProps<T> extends SpectrumCardProps {\n articleProps?: HTMLAttributes<HTMLElement>,\n item?: Node<T>\n}\n\nfunction CardBase<T extends object>(props: CardBaseProps<T>, ref: DOMRef<HTMLDivElement>) {\n props = useProviderProps(props);\n let context = useCardViewContext() || {}; // we can call again here, won't change from Card.tsx\n let {state} = context;\n let manager = state?.selectionManager;\n let {\n isQuiet,\n orientation = 'vertical',\n articleProps = {},\n item,\n layout,\n children\n } = props;\n\n let key = item?.key;\n let isSelected = manager?.isSelected(key);\n let isDisabled = state?.disabledKeys.has(key);\n let onChange = () => manager?.select(key);\n\n let {styleProps} = useStyleProps(props);\n let {cardProps, titleProps, contentProps} = useCard(props);\n let domRef = useDOMRef(ref);\n let gridRef = useRef<HTMLDivElement>();\n let checkboxRef = useRef(null);\n\n // cards are only interactive if there is a selection manager and it allows selection\n let {hoverProps, isHovered} = useHover({isDisabled: manager === undefined || manager?.selectionMode === 'none' || isDisabled});\n let [isFocused, setIsFocused] = useState(false);\n let {focusWithinProps} = useFocusWithin({\n onFocusWithinChange: setIsFocused,\n isDisabled\n });\n\n // ToDo: see css for comment about avatar under selector .spectrum-Card--noLayout.spectrum-Card--default\n let hasPreviewImage = useHasChild(`.${styles['spectrum-Card-image']}`, gridRef);\n let hasPreviewIllustration = useHasChild(`.${styles['spectrum-Card-illustration']}`, gridRef);\n let hasPreview = hasPreviewImage || hasPreviewIllustration;\n\n // this is for horizontal cards\n let [height, setHeight] = useState(NaN);\n let updateHeight = useCallback(() => {\n if (orientation !== 'horizontal') {\n return;\n }\n\n let cardHeight = gridRef.current.getBoundingClientRect().height;\n setHeight(cardHeight);\n }, [orientation, gridRef, setHeight]);\n useResizeObserver({ref: gridRef, onResize: updateHeight});\n\n let aspectRatioEnforce = undefined;\n if (orientation === 'horizontal' && !isNaN(height)) {\n aspectRatioEnforce = {\n height: `${height}px`,\n width: `${height}px`\n };\n }\n\n let slots = useMemo(() => ({\n image: {UNSAFE_className: classNames(styles, 'spectrum-Card-image'), objectFit: orientation === 'horizontal' ? 'cover' : 'contain', alt: '', ...aspectRatioEnforce},\n illustration: {UNSAFE_className: classNames(styles, 'spectrum-Card-illustration'), ...aspectRatioEnforce},\n avatar: {UNSAFE_className: classNames(styles, 'spectrum-Card-avatar'), size: 'avatar-size-400'},\n heading: {UNSAFE_className: classNames(styles, 'spectrum-Card-heading'), ...titleProps},\n content: {UNSAFE_className: classNames(styles, 'spectrum-Card-content'), ...contentProps},\n detail: {UNSAFE_className: classNames(styles, 'spectrum-Card-detail')}\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }), [titleProps, contentProps, height, isQuiet, orientation]);\n\n useLayoutEffect(() => {\n if (gridRef?.current) {\n let walker = getFocusableTreeWalker(gridRef.current);\n let nextNode = walker.nextNode();\n while (nextNode != null) {\n if (checkboxRef.current && !checkboxRef.current.UNSAFE_getDOMNode().contains(nextNode)) {\n console.warn('Card does not support focusable elements, please contact the team regarding your use case.');\n break;\n }\n nextNode = walker.nextNode();\n }\n }\n }, [children]);\n\n return (\n <FocusRing focusRingClass={classNames(styles, 'focus-ring')}>\n <article\n {...styleProps}\n {...mergeProps(cardProps, focusWithinProps, hoverProps, filterDOMProps(props), articleProps)}\n ref={domRef}\n className={classNames(styles, 'spectrum-Card', {\n 'spectrum-Card--default': !isQuiet && orientation !== 'horizontal',\n 'spectrum-Card--isQuiet': isQuiet && orientation !== 'horizontal',\n 'spectrum-Card--horizontal': orientation === 'horizontal',\n 'spectrum-Card--noPreview': !hasPreview,\n 'is-hovered': isHovered,\n 'is-focused': isFocused,\n 'is-selected': isSelected,\n 'spectrum-Card--waterfall': layout === 'waterfall',\n 'spectrum-Card--gallery': layout === 'gallery',\n 'spectrum-Card--grid': layout === 'grid',\n 'spectrum-Card--noLayout': layout !== 'waterfall' && layout !== 'gallery' && layout !== 'grid'\n }, styleProps.className)}>\n <div ref={gridRef} className={classNames(styles, 'spectrum-Card-grid')}>\n {manager && manager.selectionMode !== 'none' && (\n <div className={classNames(styles, 'spectrum-Card-checkboxWrapper')}>\n <Checkbox\n ref={checkboxRef}\n isDisabled={isDisabled}\n excludeFromTabOrder\n isSelected={isSelected}\n onChange={onChange}\n UNSAFE_className={classNames(styles, 'spectrum-Card-checkbox')}\n isEmphasized\n aria-label=\"select\" />\n </div>\n )}\n <SlotProvider slots={slots}>\n {children}\n </SlotProvider>\n <div className={classNames(styles, 'spectrum-Card-decoration')} />\n </div>\n </article>\n </FocusRing>\n );\n}\n\ninterface AriaCardOptions extends AriaCardProps {\n}\n\ninterface CardAria {\n cardProps: HTMLAttributes<HTMLDivElement>,\n titleProps: HTMLAttributes<HTMLDivElement>,\n contentProps: HTMLAttributes<HTMLDivElement>\n}\n\nfunction useCard(props: AriaCardOptions): CardAria {\n let titleId = useSlotId();\n let descriptionId = useSlotId();\n let titleProps = useMemo(() => ({\n id: titleId\n }), [titleId]);\n let contentProps = useMemo(() => ({\n id: descriptionId\n }), [descriptionId]);\n\n return {\n cardProps: {\n ...filterDOMProps(props),\n 'aria-labelledby': titleId,\n 'aria-describedby': descriptionId,\n tabIndex: 0\n },\n titleProps,\n contentProps\n };\n}\n\n/**\n * TODO: Add description of component here.\n */\nconst _CardBase = React.forwardRef(CardBase);\nexport {_CardBase as CardBase};\n"],"names":[],"version":3,"file":"CardBase.main.js.map"}