@react-spectrum/card 3.0.0-nightly.3074 → 3.0.0-nightly.3077

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/module.js CHANGED
@@ -9,9 +9,8 @@ import {useListState as $k8Xpo$useListState} from "@react-stately/list";
9
9
  import {useProvider as $k8Xpo$useProvider, useProviderProps as $k8Xpo$useProviderProps} from "@react-spectrum/provider";
10
10
  import {VirtualizerItem as $k8Xpo$VirtualizerItem, Virtualizer as $k8Xpo$Virtualizer} from "@react-aria/virtualizer";
11
11
  import {Checkbox as $k8Xpo$Checkbox} from "@react-spectrum/checkbox";
12
- import {Divider as $k8Xpo$Divider} from "@react-spectrum/divider";
13
12
  import {useResizeObserver as $k8Xpo$useResizeObserver, useLayoutEffect as $k8Xpo$useLayoutEffect, mergeProps as $k8Xpo$mergeProps, filterDOMProps as $k8Xpo$filterDOMProps, useSlotId as $k8Xpo$useSlotId} from "@react-aria/utils";
14
- import {FocusRing as $k8Xpo$FocusRing} from "@react-aria/focus";
13
+ import {getFocusableTreeWalker as $k8Xpo$getFocusableTreeWalker, FocusRing as $k8Xpo$FocusRing} from "@react-aria/focus";
15
14
  import {useHover as $k8Xpo$useHover, useFocusWithin as $k8Xpo$useFocusWithin} from "@react-aria/interactions";
16
15
  import {Size as $k8Xpo$Size, Rect as $k8Xpo$Rect, LayoutInfo as $k8Xpo$LayoutInfo, Layout as $k8Xpo$Layout} from "@react-stately/virtualizer";
17
16
 
@@ -46,10 +45,7 @@ $parcel$export($2ebe8b6b61a3e4e2$exports, "spectrum-Card-image", () => $2ebe8b6b
46
45
  $parcel$export($2ebe8b6b61a3e4e2$exports, "spectrum-Card-illustration", () => $2ebe8b6b61a3e4e2$export$13dd3510ae7a8399, (v) => $2ebe8b6b61a3e4e2$export$13dd3510ae7a8399 = v);
47
46
  $parcel$export($2ebe8b6b61a3e4e2$exports, "spectrum-Card-avatar", () => $2ebe8b6b61a3e4e2$export$159930c59efb6273, (v) => $2ebe8b6b61a3e4e2$export$159930c59efb6273 = v);
48
47
  $parcel$export($2ebe8b6b61a3e4e2$exports, "spectrum-Card-detail", () => $2ebe8b6b61a3e4e2$export$16715af38fbd9819, (v) => $2ebe8b6b61a3e4e2$export$16715af38fbd9819 = v);
49
- $parcel$export($2ebe8b6b61a3e4e2$exports, "spectrum-Card-actions", () => $2ebe8b6b61a3e4e2$export$8a136ca0c815e3d4, (v) => $2ebe8b6b61a3e4e2$export$8a136ca0c815e3d4 = v);
50
48
  $parcel$export($2ebe8b6b61a3e4e2$exports, "spectrum-Card-content", () => $2ebe8b6b61a3e4e2$export$d946625b97e8aa17, (v) => $2ebe8b6b61a3e4e2$export$d946625b97e8aa17 = v);
51
- $parcel$export($2ebe8b6b61a3e4e2$exports, "spectrum-Card-divider", () => $2ebe8b6b61a3e4e2$export$f41a14ec81fc166a, (v) => $2ebe8b6b61a3e4e2$export$f41a14ec81fc166a = v);
52
- $parcel$export($2ebe8b6b61a3e4e2$exports, "spectrum-Card-footer", () => $2ebe8b6b61a3e4e2$export$6d6eb6737fc59a18, (v) => $2ebe8b6b61a3e4e2$export$6d6eb6737fc59a18 = v);
53
49
  $parcel$export($2ebe8b6b61a3e4e2$exports, "spectrum-Card--waterfall", () => $2ebe8b6b61a3e4e2$export$d9c7209e0e4f7e4d, (v) => $2ebe8b6b61a3e4e2$export$d9c7209e0e4f7e4d = v);
54
50
  $parcel$export($2ebe8b6b61a3e4e2$exports, "spectrum-Card--default", () => $2ebe8b6b61a3e4e2$export$c7a022df9e10a238, (v) => $2ebe8b6b61a3e4e2$export$c7a022df9e10a238 = v);
55
51
  $parcel$export($2ebe8b6b61a3e4e2$exports, "spectrum-Card--noPreview", () => $2ebe8b6b61a3e4e2$export$b77922bc0320c9e4, (v) => $2ebe8b6b61a3e4e2$export$b77922bc0320c9e4 = v);
@@ -57,7 +53,6 @@ $parcel$export($2ebe8b6b61a3e4e2$exports, "spectrum-Card--grid", () => $2ebe8b6b
57
53
  $parcel$export($2ebe8b6b61a3e4e2$exports, "spectrum-Card--noLayout", () => $2ebe8b6b61a3e4e2$export$a03d836e6ef3e749, (v) => $2ebe8b6b61a3e4e2$export$a03d836e6ef3e749 = v);
58
54
  $parcel$export($2ebe8b6b61a3e4e2$exports, "spectrum-Card--isQuiet", () => $2ebe8b6b61a3e4e2$export$92ad04b5ac9296ea, (v) => $2ebe8b6b61a3e4e2$export$92ad04b5ac9296ea = v);
59
55
  $parcel$export($2ebe8b6b61a3e4e2$exports, "spectrum-Card--gallery", () => $2ebe8b6b61a3e4e2$export$ccd8ffc36bd10cc, (v) => $2ebe8b6b61a3e4e2$export$ccd8ffc36bd10cc = v);
60
- $parcel$export($2ebe8b6b61a3e4e2$exports, "spectrum-Card--closeToSquare", () => $2ebe8b6b61a3e4e2$export$20899a36767527c0, (v) => $2ebe8b6b61a3e4e2$export$20899a36767527c0 = v);
61
56
  $parcel$export($2ebe8b6b61a3e4e2$exports, "spectrum-Card--horizontal", () => $2ebe8b6b61a3e4e2$export$1c52334407225704, (v) => $2ebe8b6b61a3e4e2$export$1c52334407225704 = v);
62
57
  $parcel$export($2ebe8b6b61a3e4e2$exports, "spectrum-CardView", () => $2ebe8b6b61a3e4e2$export$2f34e9e3e0b89d95, (v) => $2ebe8b6b61a3e4e2$export$2f34e9e3e0b89d95 = v);
63
58
  $parcel$export($2ebe8b6b61a3e4e2$exports, "spectrum-CardView-centeredWrapper", () => $2ebe8b6b61a3e4e2$export$7fc89689fcfab196, (v) => $2ebe8b6b61a3e4e2$export$7fc89689fcfab196 = v);
@@ -77,10 +72,7 @@ var $2ebe8b6b61a3e4e2$export$8d5fea71dc66db80;
77
72
  var $2ebe8b6b61a3e4e2$export$13dd3510ae7a8399;
78
73
  var $2ebe8b6b61a3e4e2$export$159930c59efb6273;
79
74
  var $2ebe8b6b61a3e4e2$export$16715af38fbd9819;
80
- var $2ebe8b6b61a3e4e2$export$8a136ca0c815e3d4;
81
75
  var $2ebe8b6b61a3e4e2$export$d946625b97e8aa17;
82
- var $2ebe8b6b61a3e4e2$export$f41a14ec81fc166a;
83
- var $2ebe8b6b61a3e4e2$export$6d6eb6737fc59a18;
84
76
  var $2ebe8b6b61a3e4e2$export$d9c7209e0e4f7e4d;
85
77
  var $2ebe8b6b61a3e4e2$export$c7a022df9e10a238;
86
78
  var $2ebe8b6b61a3e4e2$export$b77922bc0320c9e4;
@@ -88,7 +80,6 @@ var $2ebe8b6b61a3e4e2$export$59739ab951d2dcc7;
88
80
  var $2ebe8b6b61a3e4e2$export$a03d836e6ef3e749;
89
81
  var $2ebe8b6b61a3e4e2$export$92ad04b5ac9296ea;
90
82
  var $2ebe8b6b61a3e4e2$export$ccd8ffc36bd10cc;
91
- var $2ebe8b6b61a3e4e2$export$20899a36767527c0;
92
83
  var $2ebe8b6b61a3e4e2$export$1c52334407225704;
93
84
  var $2ebe8b6b61a3e4e2$export$2f34e9e3e0b89d95;
94
85
  var $2ebe8b6b61a3e4e2$export$7fc89689fcfab196;
@@ -108,10 +99,7 @@ $2ebe8b6b61a3e4e2$export$8d5fea71dc66db80 = "_spectrum-Card-image_6fdf9f";
108
99
  $2ebe8b6b61a3e4e2$export$13dd3510ae7a8399 = "_spectrum-Card-illustration_6fdf9f";
109
100
  $2ebe8b6b61a3e4e2$export$159930c59efb6273 = "_spectrum-Card-avatar_6fdf9f";
110
101
  $2ebe8b6b61a3e4e2$export$16715af38fbd9819 = "_spectrum-Card-detail_6fdf9f";
111
- $2ebe8b6b61a3e4e2$export$8a136ca0c815e3d4 = "_spectrum-Card-actions_6fdf9f";
112
102
  $2ebe8b6b61a3e4e2$export$d946625b97e8aa17 = "_spectrum-Card-content_6fdf9f";
113
- $2ebe8b6b61a3e4e2$export$f41a14ec81fc166a = "_spectrum-Card-divider_6fdf9f";
114
- $2ebe8b6b61a3e4e2$export$6d6eb6737fc59a18 = "_spectrum-Card-footer_6fdf9f";
115
103
  $2ebe8b6b61a3e4e2$export$d9c7209e0e4f7e4d = "_spectrum-Card--waterfall_6fdf9f";
116
104
  $2ebe8b6b61a3e4e2$export$c7a022df9e10a238 = "_spectrum-Card--default_6fdf9f";
117
105
  $2ebe8b6b61a3e4e2$export$b77922bc0320c9e4 = "_spectrum-Card--noPreview_6fdf9f";
@@ -119,7 +107,6 @@ $2ebe8b6b61a3e4e2$export$59739ab951d2dcc7 = "_spectrum-Card--grid_6fdf9f";
119
107
  $2ebe8b6b61a3e4e2$export$a03d836e6ef3e749 = "_spectrum-Card--noLayout_6fdf9f";
120
108
  $2ebe8b6b61a3e4e2$export$92ad04b5ac9296ea = "_spectrum-Card--isQuiet_6fdf9f";
121
109
  $2ebe8b6b61a3e4e2$export$ccd8ffc36bd10cc = "_spectrum-Card--gallery_6fdf9f";
122
- $2ebe8b6b61a3e4e2$export$20899a36767527c0 = "_spectrum-Card--closeToSquare_6fdf9f";
123
110
  $2ebe8b6b61a3e4e2$export$1c52334407225704 = "_spectrum-Card--horizontal_6fdf9f";
124
111
  $2ebe8b6b61a3e4e2$export$2f34e9e3e0b89d95 = "_spectrum-CardView_6fdf9f";
125
112
  $2ebe8b6b61a3e4e2$export$7fc89689fcfab196 = "_spectrum-CardView-centeredWrapper_6fdf9f";
@@ -143,7 +130,7 @@ function $6b5e97142b400aef$var$CardBase(props, ref) {
143
130
  let { state: state } = context;
144
131
  let manager = state?.selectionManager;
145
132
  let { isQuiet: isQuiet , orientation: orientation = 'vertical' , articleProps: articleProps = {
146
- } , item: item , layout: layout } = props;
133
+ } , item: item , layout: layout , children: children } = props;
147
134
  let key = item?.key;
148
135
  let isSelected = manager?.isSelected(key);
149
136
  let isDisabled = state?.disabledKeys.has(key);
@@ -153,6 +140,7 @@ function $6b5e97142b400aef$var$CardBase(props, ref) {
153
140
  let { cardProps: cardProps , titleProps: titleProps , contentProps: contentProps } = $6b5e97142b400aef$var$useCard(props);
154
141
  let domRef = $k8Xpo$useDOMRef(ref);
155
142
  let gridRef = $k8Xpo$useRef();
143
+ let checkboxRef = $k8Xpo$useRef(null);
156
144
  // cards are only interactive if there is a selection manager and it allows selection
157
145
  let { hoverProps: hoverProps , isHovered: isHovered } = $k8Xpo$useHover({
158
146
  isDisabled: manager === undefined || manager?.selectionMode === 'none' || isDisabled
@@ -162,13 +150,12 @@ function $6b5e97142b400aef$var$CardBase(props, ref) {
162
150
  onFocusWithinChange: setIsFocused,
163
151
  isDisabled: isDisabled
164
152
  });
165
- let hasFooter = $k8Xpo$useHasChild(`.${(/*@__PURE__*/$parcel$interopDefault($2ebe8b6b61a3e4e2$exports))['spectrum-Card-footer']}`, gridRef);
166
153
  // ToDo: see css for comment about avatar under selector .spectrum-Card--noLayout.spectrum-Card--default
167
154
  let hasPreviewImage = $k8Xpo$useHasChild(`.${(/*@__PURE__*/$parcel$interopDefault($2ebe8b6b61a3e4e2$exports))['spectrum-Card-image']}`, gridRef);
168
155
  let hasPreviewIllustration = $k8Xpo$useHasChild(`.${(/*@__PURE__*/$parcel$interopDefault($2ebe8b6b61a3e4e2$exports))['spectrum-Card-illustration']}`, gridRef);
169
156
  let hasPreview = hasPreviewImage || hasPreviewIllustration;
170
157
  // this is for horizontal cards
171
- let [height1, setHeight] = $k8Xpo$useState(NaN);
158
+ let [height, setHeight] = $k8Xpo$useState(NaN);
172
159
  let updateHeight = $k8Xpo$useCallback(()=>{
173
160
  if (orientation !== 'horizontal') return;
174
161
  let cardHeight = gridRef.current.getBoundingClientRect().height;
@@ -183,9 +170,9 @@ function $6b5e97142b400aef$var$CardBase(props, ref) {
183
170
  onResize: updateHeight
184
171
  });
185
172
  let aspectRatioEnforce = undefined;
186
- if (orientation === 'horizontal' && !isNaN(height1)) aspectRatioEnforce = {
187
- height: `${height1}px`,
188
- width: `${height1}px`
173
+ if (orientation === 'horizontal' && !isNaN(height)) aspectRatioEnforce = {
174
+ height: `${height}px`,
175
+ width: `${height}px`
189
176
  };
190
177
  let slots = $k8Xpo$useMemo(()=>({
191
178
  image: {
@@ -212,72 +199,29 @@ function $6b5e97142b400aef$var$CardBase(props, ref) {
212
199
  },
213
200
  detail: {
214
201
  UNSAFE_className: $k8Xpo$classNames((/*@__PURE__*/$parcel$interopDefault($2ebe8b6b61a3e4e2$exports)), 'spectrum-Card-detail')
215
- },
216
- actionmenu: {
217
- UNSAFE_className: $k8Xpo$classNames((/*@__PURE__*/$parcel$interopDefault($2ebe8b6b61a3e4e2$exports)), 'spectrum-Card-actions'),
218
- align: 'end',
219
- isQuiet: true
220
- },
221
- footer: {
222
- UNSAFE_className: $k8Xpo$classNames((/*@__PURE__*/$parcel$interopDefault($2ebe8b6b61a3e4e2$exports)), 'spectrum-Card-footer'),
223
- isHidden: isQuiet
224
- },
225
- divider: {
226
- UNSAFE_className: $k8Xpo$classNames((/*@__PURE__*/$parcel$interopDefault($2ebe8b6b61a3e4e2$exports)), 'spectrum-Card-divider'),
227
- size: 'S'
228
202
  }
229
203
  })
230
204
  , [
231
205
  titleProps,
232
206
  contentProps,
233
- height1,
207
+ height,
234
208
  isQuiet,
235
209
  orientation
236
210
  ]);
237
- // This is only for quiet grid cards
238
- let [isCloseToSquare, setIsCloseToSquare] = $k8Xpo$useState(false);
239
211
  $k8Xpo$useLayoutEffect(()=>{
240
- if (!(layout === 'grid' && isQuiet)) return;
241
- // ToDo: how to handle illustrations? what if the illustration looks like an image? What about swatches/fonts https://spectrum-contributions.corp.adobe.com/page/asset-card-beta/#File-type
242
- let image = gridRef.current.querySelector(`.${(/*@__PURE__*/$parcel$interopDefault($2ebe8b6b61a3e4e2$exports))['spectrum-Card-image']} img`);
243
- if (!image) return;
244
- let measure = ()=>{
245
- let height = image.naturalHeight;
246
- let width = image.naturalWidth;
247
- /*
248
- * ToDo: Choose between min-padding and plain ratio
249
- * Do we want to just do a ratio measurement when it's close to being a square?
250
- * or do we want to actually figure out min-padding?
251
- * Min Padding would require us to check that the padding is not less than the min in both Vertical and Horizontal
252
- * Unfortunately img contain doesn't actually create padding, which is what this math below can figure out
253
- * Vs the commented out straight ratio check
254
- * */ let imgTagHeight = image.clientHeight;
255
- let imgTagWidth = image.clientWidth;
256
- let ratio = Math.min(imgTagWidth / width, imgTagHeight / height);
257
- let trueHeight = ratio * height;
258
- let trueWidth = ratio * width;
259
- let paddingVertical = imgTagHeight - trueHeight;
260
- let paddingHorizontal = imgTagWidth - trueWidth;
261
- if (paddingVertical < 16 && paddingHorizontal < 16) setIsCloseToSquare(true);
262
- else setIsCloseToSquare(false);
263
- // let ratio = height / width;
264
- // if (ratio > 0.9 && ratio < 1.1) {
265
- // setIsCloseToSquare(true);
266
- // }
267
- };
268
- if (image.complete) measure();
269
- else {
270
- image.addEventListener('load', measure);
271
- return ()=>{
272
- image.removeEventListener('load', measure);
273
- };
212
+ if (gridRef?.current) {
213
+ let walker = $k8Xpo$getFocusableTreeWalker(gridRef.current);
214
+ let nextNode = walker.nextNode();
215
+ while(nextNode != null){
216
+ if (checkboxRef.current && !checkboxRef.current.UNSAFE_getDOMNode().contains(nextNode)) {
217
+ console.warn('Card does not support focusable elements, please contact the team regarding your use case.');
218
+ break;
219
+ }
220
+ nextNode = walker.nextNode();
221
+ }
274
222
  }
275
- // ToDo: how to re-run if image src changes?
276
223
  }, [
277
- props.children,
278
- setIsCloseToSquare,
279
- isQuiet,
280
- layout
224
+ children
281
225
  ]);
282
226
  return(/*#__PURE__*/ $k8Xpo$react.createElement($k8Xpo$FocusRing, {
283
227
  focusRingClass: $k8Xpo$classNames((/*@__PURE__*/$parcel$interopDefault($2ebe8b6b61a3e4e2$exports)), 'focus-ring')
@@ -289,7 +233,6 @@ function $6b5e97142b400aef$var$CardBase(props, ref) {
289
233
  'spectrum-Card--default': !isQuiet && orientation !== 'horizontal',
290
234
  'spectrum-Card--isQuiet': isQuiet && orientation !== 'horizontal',
291
235
  'spectrum-Card--horizontal': orientation === 'horizontal',
292
- 'spectrum-Card--closeToSquare': isCloseToSquare,
293
236
  'spectrum-Card--noPreview': !hasPreview,
294
237
  'is-hovered': isHovered,
295
238
  'is-focused': isFocused,
@@ -305,6 +248,7 @@ function $6b5e97142b400aef$var$CardBase(props, ref) {
305
248
  }, manager && manager.selectionMode !== 'none' && /*#__PURE__*/ $k8Xpo$react.createElement("div", {
306
249
  className: $k8Xpo$classNames((/*@__PURE__*/$parcel$interopDefault($2ebe8b6b61a3e4e2$exports)), 'spectrum-Card-checkboxWrapper')
307
250
  }, /*#__PURE__*/ $k8Xpo$react.createElement($k8Xpo$Checkbox, {
251
+ ref: checkboxRef,
308
252
  isDisabled: isDisabled,
309
253
  excludeFromTabOrder: true,
310
254
  isSelected: isSelected,
@@ -314,7 +258,7 @@ function $6b5e97142b400aef$var$CardBase(props, ref) {
314
258
  "aria-label": "select"
315
259
  })), /*#__PURE__*/ $k8Xpo$react.createElement($k8Xpo$SlotProvider, {
316
260
  slots: slots
317
- }, props.children, hasFooter && /*#__PURE__*/ $k8Xpo$react.createElement($k8Xpo$Divider, null)), /*#__PURE__*/ $k8Xpo$react.createElement("div", {
261
+ }, children), /*#__PURE__*/ $k8Xpo$react.createElement("div", {
318
262
  className: $k8Xpo$classNames((/*@__PURE__*/$parcel$interopDefault($2ebe8b6b61a3e4e2$exports)), 'spectrum-Card-decoration')
319
263
  })))));
320
264
  }
@@ -688,6 +632,10 @@ function $49e01256efa8773b$var$InternalCard(props) {
688
632
  }, state, unwrappedRef);
689
633
  if (layoutType === 'grid' || layoutType === 'gallery') isQuiet = true;
690
634
  if (layoutType !== 'grid') cardOrientation = 'vertical';
635
+ // We don't want to focus the checkbox (or any other focusable elements) within the Card
636
+ // when pressing the arrow keys so we delete the key down handler here. Arrow key navigation between
637
+ // the cards in the CardView is handled by useGrid => useSelectableCollection instead.
638
+ delete gridCellProps.onKeyDownCapture;
691
639
  return(/*#__PURE__*/ $k8Xpo$react.createElement("div", {
692
640
  ...rowProps,
693
641
  ref: rowRef,
@@ -912,8 +860,8 @@ const $22fcfd471bc7ee86$var$DEFAULT_OPTIONS = {
912
860
  minItemSize: new $k8Xpo$Size(136, 136),
913
861
  itemSpacing: new $k8Xpo$Size(18, 18),
914
862
  itemPadding: {
915
- 'medium': 114,
916
- 'large': 143
863
+ 'medium': 78,
864
+ 'large': 99
917
865
  },
918
866
  dropSpacing: 100,
919
867
  margin: 24
@@ -1304,8 +1252,6 @@ class $e7acb160b0e0df88$export$e9f7cda058ba8df8 extends $ce95ffe2429f6396$export
1304
1252
  this.margin = options.margin != null ? options.margin : 24;
1305
1253
  this.minSpace = options.minSpace || new $k8Xpo$Size(18, 18);
1306
1254
  this.maxColumns = options.maxColumns || Infinity;
1307
- // TODO: not entirely sure what this is for since the layout will automatically shift itself to the correct vertical space for the card
1308
- this.itemPadding = options.itemPadding != null ? options.itemPadding : 56;
1309
1255
  this.itemWidth = 0;
1310
1256
  this.numColumns = 0;
1311
1257
  this.lastCollection = null;
@@ -1345,8 +1291,8 @@ class $e7acb160b0e0df88$export$e9f7cda058ba8df8 extends $ce95ffe2429f6396$export
1345
1291
  } else if (node.props.width && node.props.height) {
1346
1292
  let nodeWidth = node.props.width;
1347
1293
  let nodeHeight = node.props.height;
1348
- let scaledHeight = Math.round(nodeWidth * (itemWidth / nodeHeight));
1349
- height = Math.max(this.minItemSize.height, Math.min(this.maxItemSize.height, scaledHeight)) + this.itemPadding;
1294
+ let scaledHeight = Math.round(nodeHeight * (itemWidth / nodeWidth));
1295
+ height = Math.max(this.minItemSize.height, Math.min(this.maxItemSize.height, scaledHeight));
1350
1296
  } else height = itemWidth;
1351
1297
  // Figure out which column to place the item in, and compute its position.
1352
1298
  let column = this.getNextColumnIndex(columnHeights);