@react-spectrum/card 3.0.0-alpha.4 → 3.0.0-alpha.41
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/BaseLayout.main.js +213 -0
- package/dist/BaseLayout.main.js.map +1 -0
- package/dist/BaseLayout.mjs +208 -0
- package/dist/BaseLayout.module.js +208 -0
- package/dist/BaseLayout.module.js.map +1 -0
- package/dist/Card.main.js +52 -0
- package/dist/Card.main.js.map +1 -0
- package/dist/Card.mjs +43 -0
- package/dist/Card.module.js +43 -0
- package/dist/Card.module.js.map +1 -0
- package/dist/CardBase.main.js +203 -0
- package/dist/CardBase.main.js.map +1 -0
- package/dist/CardBase.mjs +198 -0
- package/dist/CardBase.module.js +198 -0
- package/dist/CardBase.module.js.map +1 -0
- package/dist/CardView.main.js +238 -0
- package/dist/CardView.main.js.map +1 -0
- package/dist/CardView.mjs +233 -0
- package/dist/CardView.module.js +233 -0
- package/dist/CardView.module.js.map +1 -0
- package/dist/CardViewContext.main.js +32 -0
- package/dist/CardViewContext.main.js.map +1 -0
- package/dist/CardViewContext.mjs +22 -0
- package/dist/CardViewContext.module.js +22 -0
- package/dist/CardViewContext.module.js.map +1 -0
- package/dist/GalleryLayout.main.js +230 -0
- package/dist/GalleryLayout.main.js.map +1 -0
- package/dist/GalleryLayout.mjs +225 -0
- package/dist/GalleryLayout.module.js +225 -0
- package/dist/GalleryLayout.module.js.map +1 -0
- package/dist/GridLayout.main.js +175 -0
- package/dist/GridLayout.main.js.map +1 -0
- package/dist/GridLayout.mjs +170 -0
- package/dist/GridLayout.module.js +170 -0
- package/dist/GridLayout.module.js.map +1 -0
- package/dist/WaterfallLayout.main.js +182 -0
- package/dist/WaterfallLayout.main.js.map +1 -0
- package/dist/WaterfallLayout.mjs +177 -0
- package/dist/WaterfallLayout.module.js +177 -0
- package/dist/WaterfallLayout.module.js.map +1 -0
- 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/card_vars_css.main.js +116 -0
- package/dist/card_vars_css.main.js.map +1 -0
- package/dist/card_vars_css.mjs +118 -0
- package/dist/card_vars_css.module.js +118 -0
- package/dist/card_vars_css.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 +26 -0
- package/dist/intlStrings.main.js +108 -0
- package/dist/intlStrings.main.js.map +1 -0
- package/dist/intlStrings.mjs +110 -0
- package/dist/intlStrings.module.js +110 -0
- package/dist/intlStrings.module.js.map +1 -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.js +21 -1447
- package/dist/main.js.map +1 -1
- package/dist/module.js +17 -1432
- 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 +38 -36
- 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/vars.02438011.css +1671 -0
- package/dist/vars.02438011.css.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 +36 -32
- package/src/Card.tsx +1 -0
- package/src/CardBase.tsx +9 -11
- package/src/CardView.tsx +71 -51
- package/src/CardViewContext.tsx +1 -0
- package/src/GalleryLayout.tsx +4 -2
- package/src/GridLayout.tsx +7 -39
- package/src/WaterfallLayout.tsx +8 -5
- package/src/index.ts +10 -5
- package/dist/main.css +0 -1
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import "./vars.02438011.css";
|
|
2
|
+
import $8eFIe$card_vars_cssmodulejs from "./card_vars_css.mjs";
|
|
3
|
+
import {useCardViewContext as $8d180a244893de14$export$fea0b38586ec8f13} from "./CardViewContext.mjs";
|
|
4
|
+
import {Checkbox as $8eFIe$Checkbox} from "@react-spectrum/checkbox";
|
|
5
|
+
import {useStyleProps as $8eFIe$useStyleProps, useDOMRef as $8eFIe$useDOMRef, useHasChild as $8eFIe$useHasChild, classNames as $8eFIe$classNames, SlotProvider as $8eFIe$SlotProvider} from "@react-spectrum/utils";
|
|
6
|
+
import {useResizeObserver as $8eFIe$useResizeObserver, useLayoutEffect as $8eFIe$useLayoutEffect, mergeProps as $8eFIe$mergeProps, filterDOMProps as $8eFIe$filterDOMProps, useSlotId as $8eFIe$useSlotId} from "@react-aria/utils";
|
|
7
|
+
import {getFocusableTreeWalker as $8eFIe$getFocusableTreeWalker, FocusRing as $8eFIe$FocusRing} from "@react-aria/focus";
|
|
8
|
+
import $8eFIe$react, {useRef as $8eFIe$useRef, useState as $8eFIe$useState, useCallback as $8eFIe$useCallback, useMemo as $8eFIe$useMemo} from "react";
|
|
9
|
+
import {useHover as $8eFIe$useHover, useFocusWithin as $8eFIe$useFocusWithin} from "@react-aria/interactions";
|
|
10
|
+
import {useProviderProps as $8eFIe$useProviderProps} from "@react-spectrum/provider";
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
function $parcel$interopDefault(a) {
|
|
14
|
+
return a && a.__esModule ? a.default : a;
|
|
15
|
+
}
|
|
16
|
+
// @ts-nocheck
|
|
17
|
+
/*
|
|
18
|
+
* Copyright 2021 Adobe. All rights reserved.
|
|
19
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
20
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
21
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
22
|
+
*
|
|
23
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
24
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
25
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
26
|
+
* governing permissions and limitations under the License.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
const $643dd8fa80926f94$export$7a6ccaf429ad93a8 = /*#__PURE__*/ (0, $8eFIe$react).forwardRef(function CardBase(props, ref) {
|
|
37
|
+
props = (0, $8eFIe$useProviderProps)(props);
|
|
38
|
+
let context = (0, $8d180a244893de14$export$fea0b38586ec8f13)() || {}; // we can call again here, won't change from Card.tsx
|
|
39
|
+
let { state: state } = context;
|
|
40
|
+
let manager = state === null || state === void 0 ? void 0 : state.selectionManager;
|
|
41
|
+
let { isQuiet: isQuiet, orientation: orientation = 'vertical', articleProps: articleProps = {}, item: item, layout: layout, children: children } = props;
|
|
42
|
+
let key = item === null || item === void 0 ? void 0 : item.key;
|
|
43
|
+
let isSelected = manager === null || manager === void 0 ? void 0 : manager.isSelected(key);
|
|
44
|
+
let isDisabled = state === null || state === void 0 ? void 0 : state.disabledKeys.has(key);
|
|
45
|
+
let onChange = ()=>manager === null || manager === void 0 ? void 0 : manager.select(key);
|
|
46
|
+
let { styleProps: styleProps } = (0, $8eFIe$useStyleProps)(props);
|
|
47
|
+
let { cardProps: cardProps, titleProps: titleProps, contentProps: contentProps } = $643dd8fa80926f94$var$useCard(props);
|
|
48
|
+
let domRef = (0, $8eFIe$useDOMRef)(ref);
|
|
49
|
+
let gridRef = (0, $8eFIe$useRef)(undefined);
|
|
50
|
+
let checkboxRef = (0, $8eFIe$useRef)(null);
|
|
51
|
+
// cards are only interactive if there is a selection manager and it allows selection
|
|
52
|
+
let { hoverProps: hoverProps, isHovered: isHovered } = (0, $8eFIe$useHover)({
|
|
53
|
+
isDisabled: manager === undefined || (manager === null || manager === void 0 ? void 0 : manager.selectionMode) === 'none' || isDisabled
|
|
54
|
+
});
|
|
55
|
+
let [isFocused, setIsFocused] = (0, $8eFIe$useState)(false);
|
|
56
|
+
let { focusWithinProps: focusWithinProps } = (0, $8eFIe$useFocusWithin)({
|
|
57
|
+
onFocusWithinChange: setIsFocused,
|
|
58
|
+
isDisabled: isDisabled
|
|
59
|
+
});
|
|
60
|
+
// ToDo: see css for comment about avatar under selector .spectrum-Card--noLayout.spectrum-Card--default
|
|
61
|
+
let hasPreviewImage = (0, $8eFIe$useHasChild)(`.${(0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs)))['spectrum-Card-image']}`, gridRef);
|
|
62
|
+
let hasPreviewIllustration = (0, $8eFIe$useHasChild)(`.${(0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs)))['spectrum-Card-illustration']}`, gridRef);
|
|
63
|
+
let hasPreview = hasPreviewImage || hasPreviewIllustration;
|
|
64
|
+
// this is for horizontal cards
|
|
65
|
+
let [height, setHeight] = (0, $8eFIe$useState)(NaN);
|
|
66
|
+
let updateHeight = (0, $8eFIe$useCallback)(()=>{
|
|
67
|
+
if (orientation !== 'horizontal') return;
|
|
68
|
+
let cardHeight = gridRef.current.getBoundingClientRect().height;
|
|
69
|
+
setHeight(cardHeight);
|
|
70
|
+
}, [
|
|
71
|
+
orientation,
|
|
72
|
+
gridRef,
|
|
73
|
+
setHeight
|
|
74
|
+
]);
|
|
75
|
+
(0, $8eFIe$useResizeObserver)({
|
|
76
|
+
ref: gridRef,
|
|
77
|
+
onResize: updateHeight
|
|
78
|
+
});
|
|
79
|
+
let aspectRatioEnforce = undefined;
|
|
80
|
+
if (orientation === 'horizontal' && !isNaN(height)) aspectRatioEnforce = {
|
|
81
|
+
height: `${height}px`,
|
|
82
|
+
width: `${height}px`
|
|
83
|
+
};
|
|
84
|
+
let slots = (0, $8eFIe$useMemo)(()=>({
|
|
85
|
+
image: {
|
|
86
|
+
UNSAFE_className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), 'spectrum-Card-image'),
|
|
87
|
+
objectFit: orientation === 'horizontal' ? 'cover' : 'contain',
|
|
88
|
+
alt: '',
|
|
89
|
+
...aspectRatioEnforce
|
|
90
|
+
},
|
|
91
|
+
illustration: {
|
|
92
|
+
UNSAFE_className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), 'spectrum-Card-illustration'),
|
|
93
|
+
...aspectRatioEnforce
|
|
94
|
+
},
|
|
95
|
+
avatar: {
|
|
96
|
+
UNSAFE_className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), 'spectrum-Card-avatar'),
|
|
97
|
+
size: 'avatar-size-400'
|
|
98
|
+
},
|
|
99
|
+
heading: {
|
|
100
|
+
UNSAFE_className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), 'spectrum-Card-heading'),
|
|
101
|
+
...titleProps
|
|
102
|
+
},
|
|
103
|
+
content: {
|
|
104
|
+
UNSAFE_className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), 'spectrum-Card-content'),
|
|
105
|
+
...contentProps
|
|
106
|
+
},
|
|
107
|
+
detail: {
|
|
108
|
+
UNSAFE_className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), 'spectrum-Card-detail')
|
|
109
|
+
}
|
|
110
|
+
}), [
|
|
111
|
+
titleProps,
|
|
112
|
+
contentProps,
|
|
113
|
+
height,
|
|
114
|
+
isQuiet,
|
|
115
|
+
orientation
|
|
116
|
+
]);
|
|
117
|
+
(0, $8eFIe$useLayoutEffect)(()=>{
|
|
118
|
+
if (gridRef === null || gridRef === void 0 ? void 0 : gridRef.current) {
|
|
119
|
+
let walker = (0, $8eFIe$getFocusableTreeWalker)(gridRef.current);
|
|
120
|
+
let nextNode = walker.nextNode();
|
|
121
|
+
while(nextNode != null){
|
|
122
|
+
if (checkboxRef.current && !checkboxRef.current.UNSAFE_getDOMNode().contains(nextNode)) {
|
|
123
|
+
console.warn('Card does not support focusable elements, please contact the team regarding your use case.');
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
nextNode = walker.nextNode();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}, [
|
|
130
|
+
children
|
|
131
|
+
]);
|
|
132
|
+
return /*#__PURE__*/ (0, $8eFIe$react).createElement((0, $8eFIe$FocusRing), {
|
|
133
|
+
focusRingClass: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), 'focus-ring')
|
|
134
|
+
}, /*#__PURE__*/ (0, $8eFIe$react).createElement("article", {
|
|
135
|
+
...styleProps,
|
|
136
|
+
...(0, $8eFIe$mergeProps)(cardProps, focusWithinProps, hoverProps, (0, $8eFIe$filterDOMProps)(props), articleProps),
|
|
137
|
+
ref: domRef,
|
|
138
|
+
className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), 'spectrum-Card', {
|
|
139
|
+
'spectrum-Card--default': !isQuiet && orientation !== 'horizontal',
|
|
140
|
+
'spectrum-Card--isQuiet': isQuiet && orientation !== 'horizontal',
|
|
141
|
+
'spectrum-Card--horizontal': orientation === 'horizontal',
|
|
142
|
+
'spectrum-Card--noPreview': !hasPreview,
|
|
143
|
+
'is-hovered': isHovered,
|
|
144
|
+
'is-focused': isFocused,
|
|
145
|
+
'is-selected': isSelected,
|
|
146
|
+
'spectrum-Card--waterfall': layout === 'waterfall',
|
|
147
|
+
'spectrum-Card--gallery': layout === 'gallery',
|
|
148
|
+
'spectrum-Card--grid': layout === 'grid',
|
|
149
|
+
'spectrum-Card--noLayout': layout !== 'waterfall' && layout !== 'gallery' && layout !== 'grid'
|
|
150
|
+
}, styleProps.className)
|
|
151
|
+
}, /*#__PURE__*/ (0, $8eFIe$react).createElement("div", {
|
|
152
|
+
ref: gridRef,
|
|
153
|
+
className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), 'spectrum-Card-grid')
|
|
154
|
+
}, manager && manager.selectionMode !== 'none' && /*#__PURE__*/ (0, $8eFIe$react).createElement("div", {
|
|
155
|
+
className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), 'spectrum-Card-checkboxWrapper')
|
|
156
|
+
}, /*#__PURE__*/ (0, $8eFIe$react).createElement((0, $8eFIe$Checkbox), {
|
|
157
|
+
ref: checkboxRef,
|
|
158
|
+
isDisabled: isDisabled,
|
|
159
|
+
excludeFromTabOrder: true,
|
|
160
|
+
isSelected: isSelected,
|
|
161
|
+
onChange: onChange,
|
|
162
|
+
UNSAFE_className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), 'spectrum-Card-checkbox'),
|
|
163
|
+
isEmphasized: true,
|
|
164
|
+
"aria-label": "select"
|
|
165
|
+
})), /*#__PURE__*/ (0, $8eFIe$react).createElement((0, $8eFIe$SlotProvider), {
|
|
166
|
+
slots: slots
|
|
167
|
+
}, children), /*#__PURE__*/ (0, $8eFIe$react).createElement("div", {
|
|
168
|
+
className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), 'spectrum-Card-decoration')
|
|
169
|
+
}))));
|
|
170
|
+
});
|
|
171
|
+
function $643dd8fa80926f94$var$useCard(props) {
|
|
172
|
+
let titleId = (0, $8eFIe$useSlotId)();
|
|
173
|
+
let descriptionId = (0, $8eFIe$useSlotId)();
|
|
174
|
+
let titleProps = (0, $8eFIe$useMemo)(()=>({
|
|
175
|
+
id: titleId
|
|
176
|
+
}), [
|
|
177
|
+
titleId
|
|
178
|
+
]);
|
|
179
|
+
let contentProps = (0, $8eFIe$useMemo)(()=>({
|
|
180
|
+
id: descriptionId
|
|
181
|
+
}), [
|
|
182
|
+
descriptionId
|
|
183
|
+
]);
|
|
184
|
+
return {
|
|
185
|
+
cardProps: {
|
|
186
|
+
...(0, $8eFIe$filterDOMProps)(props),
|
|
187
|
+
'aria-labelledby': titleId,
|
|
188
|
+
'aria-describedby': descriptionId,
|
|
189
|
+
tabIndex: 0
|
|
190
|
+
},
|
|
191
|
+
titleProps: titleProps,
|
|
192
|
+
contentProps: contentProps
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
export {$643dd8fa80926f94$export$7a6ccaf429ad93a8 as CardBase};
|
|
198
|
+
//# sourceMappingURL=CardBase.module.js.map
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import "./vars.02438011.css";
|
|
2
|
+
import $8eFIe$card_vars_cssmodulejs from "./card_vars_css.module.js";
|
|
3
|
+
import {useCardViewContext as $8d180a244893de14$export$fea0b38586ec8f13} from "./CardViewContext.module.js";
|
|
4
|
+
import {Checkbox as $8eFIe$Checkbox} from "@react-spectrum/checkbox";
|
|
5
|
+
import {useStyleProps as $8eFIe$useStyleProps, useDOMRef as $8eFIe$useDOMRef, useHasChild as $8eFIe$useHasChild, classNames as $8eFIe$classNames, SlotProvider as $8eFIe$SlotProvider} from "@react-spectrum/utils";
|
|
6
|
+
import {useResizeObserver as $8eFIe$useResizeObserver, useLayoutEffect as $8eFIe$useLayoutEffect, mergeProps as $8eFIe$mergeProps, filterDOMProps as $8eFIe$filterDOMProps, useSlotId as $8eFIe$useSlotId} from "@react-aria/utils";
|
|
7
|
+
import {getFocusableTreeWalker as $8eFIe$getFocusableTreeWalker, FocusRing as $8eFIe$FocusRing} from "@react-aria/focus";
|
|
8
|
+
import $8eFIe$react, {useRef as $8eFIe$useRef, useState as $8eFIe$useState, useCallback as $8eFIe$useCallback, useMemo as $8eFIe$useMemo} from "react";
|
|
9
|
+
import {useHover as $8eFIe$useHover, useFocusWithin as $8eFIe$useFocusWithin} from "@react-aria/interactions";
|
|
10
|
+
import {useProviderProps as $8eFIe$useProviderProps} from "@react-spectrum/provider";
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
function $parcel$interopDefault(a) {
|
|
14
|
+
return a && a.__esModule ? a.default : a;
|
|
15
|
+
}
|
|
16
|
+
// @ts-nocheck
|
|
17
|
+
/*
|
|
18
|
+
* Copyright 2021 Adobe. All rights reserved.
|
|
19
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
20
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
21
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
22
|
+
*
|
|
23
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
24
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
25
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
26
|
+
* governing permissions and limitations under the License.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
const $643dd8fa80926f94$export$7a6ccaf429ad93a8 = /*#__PURE__*/ (0, $8eFIe$react).forwardRef(function CardBase(props, ref) {
|
|
37
|
+
props = (0, $8eFIe$useProviderProps)(props);
|
|
38
|
+
let context = (0, $8d180a244893de14$export$fea0b38586ec8f13)() || {}; // we can call again here, won't change from Card.tsx
|
|
39
|
+
let { state: state } = context;
|
|
40
|
+
let manager = state === null || state === void 0 ? void 0 : state.selectionManager;
|
|
41
|
+
let { isQuiet: isQuiet, orientation: orientation = 'vertical', articleProps: articleProps = {}, item: item, layout: layout, children: children } = props;
|
|
42
|
+
let key = item === null || item === void 0 ? void 0 : item.key;
|
|
43
|
+
let isSelected = manager === null || manager === void 0 ? void 0 : manager.isSelected(key);
|
|
44
|
+
let isDisabled = state === null || state === void 0 ? void 0 : state.disabledKeys.has(key);
|
|
45
|
+
let onChange = ()=>manager === null || manager === void 0 ? void 0 : manager.select(key);
|
|
46
|
+
let { styleProps: styleProps } = (0, $8eFIe$useStyleProps)(props);
|
|
47
|
+
let { cardProps: cardProps, titleProps: titleProps, contentProps: contentProps } = $643dd8fa80926f94$var$useCard(props);
|
|
48
|
+
let domRef = (0, $8eFIe$useDOMRef)(ref);
|
|
49
|
+
let gridRef = (0, $8eFIe$useRef)(undefined);
|
|
50
|
+
let checkboxRef = (0, $8eFIe$useRef)(null);
|
|
51
|
+
// cards are only interactive if there is a selection manager and it allows selection
|
|
52
|
+
let { hoverProps: hoverProps, isHovered: isHovered } = (0, $8eFIe$useHover)({
|
|
53
|
+
isDisabled: manager === undefined || (manager === null || manager === void 0 ? void 0 : manager.selectionMode) === 'none' || isDisabled
|
|
54
|
+
});
|
|
55
|
+
let [isFocused, setIsFocused] = (0, $8eFIe$useState)(false);
|
|
56
|
+
let { focusWithinProps: focusWithinProps } = (0, $8eFIe$useFocusWithin)({
|
|
57
|
+
onFocusWithinChange: setIsFocused,
|
|
58
|
+
isDisabled: isDisabled
|
|
59
|
+
});
|
|
60
|
+
// ToDo: see css for comment about avatar under selector .spectrum-Card--noLayout.spectrum-Card--default
|
|
61
|
+
let hasPreviewImage = (0, $8eFIe$useHasChild)(`.${(0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs)))['spectrum-Card-image']}`, gridRef);
|
|
62
|
+
let hasPreviewIllustration = (0, $8eFIe$useHasChild)(`.${(0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs)))['spectrum-Card-illustration']}`, gridRef);
|
|
63
|
+
let hasPreview = hasPreviewImage || hasPreviewIllustration;
|
|
64
|
+
// this is for horizontal cards
|
|
65
|
+
let [height, setHeight] = (0, $8eFIe$useState)(NaN);
|
|
66
|
+
let updateHeight = (0, $8eFIe$useCallback)(()=>{
|
|
67
|
+
if (orientation !== 'horizontal') return;
|
|
68
|
+
let cardHeight = gridRef.current.getBoundingClientRect().height;
|
|
69
|
+
setHeight(cardHeight);
|
|
70
|
+
}, [
|
|
71
|
+
orientation,
|
|
72
|
+
gridRef,
|
|
73
|
+
setHeight
|
|
74
|
+
]);
|
|
75
|
+
(0, $8eFIe$useResizeObserver)({
|
|
76
|
+
ref: gridRef,
|
|
77
|
+
onResize: updateHeight
|
|
78
|
+
});
|
|
79
|
+
let aspectRatioEnforce = undefined;
|
|
80
|
+
if (orientation === 'horizontal' && !isNaN(height)) aspectRatioEnforce = {
|
|
81
|
+
height: `${height}px`,
|
|
82
|
+
width: `${height}px`
|
|
83
|
+
};
|
|
84
|
+
let slots = (0, $8eFIe$useMemo)(()=>({
|
|
85
|
+
image: {
|
|
86
|
+
UNSAFE_className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), 'spectrum-Card-image'),
|
|
87
|
+
objectFit: orientation === 'horizontal' ? 'cover' : 'contain',
|
|
88
|
+
alt: '',
|
|
89
|
+
...aspectRatioEnforce
|
|
90
|
+
},
|
|
91
|
+
illustration: {
|
|
92
|
+
UNSAFE_className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), 'spectrum-Card-illustration'),
|
|
93
|
+
...aspectRatioEnforce
|
|
94
|
+
},
|
|
95
|
+
avatar: {
|
|
96
|
+
UNSAFE_className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), 'spectrum-Card-avatar'),
|
|
97
|
+
size: 'avatar-size-400'
|
|
98
|
+
},
|
|
99
|
+
heading: {
|
|
100
|
+
UNSAFE_className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), 'spectrum-Card-heading'),
|
|
101
|
+
...titleProps
|
|
102
|
+
},
|
|
103
|
+
content: {
|
|
104
|
+
UNSAFE_className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), 'spectrum-Card-content'),
|
|
105
|
+
...contentProps
|
|
106
|
+
},
|
|
107
|
+
detail: {
|
|
108
|
+
UNSAFE_className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), 'spectrum-Card-detail')
|
|
109
|
+
}
|
|
110
|
+
}), [
|
|
111
|
+
titleProps,
|
|
112
|
+
contentProps,
|
|
113
|
+
height,
|
|
114
|
+
isQuiet,
|
|
115
|
+
orientation
|
|
116
|
+
]);
|
|
117
|
+
(0, $8eFIe$useLayoutEffect)(()=>{
|
|
118
|
+
if (gridRef === null || gridRef === void 0 ? void 0 : gridRef.current) {
|
|
119
|
+
let walker = (0, $8eFIe$getFocusableTreeWalker)(gridRef.current);
|
|
120
|
+
let nextNode = walker.nextNode();
|
|
121
|
+
while(nextNode != null){
|
|
122
|
+
if (checkboxRef.current && !checkboxRef.current.UNSAFE_getDOMNode().contains(nextNode)) {
|
|
123
|
+
console.warn('Card does not support focusable elements, please contact the team regarding your use case.');
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
nextNode = walker.nextNode();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}, [
|
|
130
|
+
children
|
|
131
|
+
]);
|
|
132
|
+
return /*#__PURE__*/ (0, $8eFIe$react).createElement((0, $8eFIe$FocusRing), {
|
|
133
|
+
focusRingClass: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), 'focus-ring')
|
|
134
|
+
}, /*#__PURE__*/ (0, $8eFIe$react).createElement("article", {
|
|
135
|
+
...styleProps,
|
|
136
|
+
...(0, $8eFIe$mergeProps)(cardProps, focusWithinProps, hoverProps, (0, $8eFIe$filterDOMProps)(props), articleProps),
|
|
137
|
+
ref: domRef,
|
|
138
|
+
className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), 'spectrum-Card', {
|
|
139
|
+
'spectrum-Card--default': !isQuiet && orientation !== 'horizontal',
|
|
140
|
+
'spectrum-Card--isQuiet': isQuiet && orientation !== 'horizontal',
|
|
141
|
+
'spectrum-Card--horizontal': orientation === 'horizontal',
|
|
142
|
+
'spectrum-Card--noPreview': !hasPreview,
|
|
143
|
+
'is-hovered': isHovered,
|
|
144
|
+
'is-focused': isFocused,
|
|
145
|
+
'is-selected': isSelected,
|
|
146
|
+
'spectrum-Card--waterfall': layout === 'waterfall',
|
|
147
|
+
'spectrum-Card--gallery': layout === 'gallery',
|
|
148
|
+
'spectrum-Card--grid': layout === 'grid',
|
|
149
|
+
'spectrum-Card--noLayout': layout !== 'waterfall' && layout !== 'gallery' && layout !== 'grid'
|
|
150
|
+
}, styleProps.className)
|
|
151
|
+
}, /*#__PURE__*/ (0, $8eFIe$react).createElement("div", {
|
|
152
|
+
ref: gridRef,
|
|
153
|
+
className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), 'spectrum-Card-grid')
|
|
154
|
+
}, manager && manager.selectionMode !== 'none' && /*#__PURE__*/ (0, $8eFIe$react).createElement("div", {
|
|
155
|
+
className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), 'spectrum-Card-checkboxWrapper')
|
|
156
|
+
}, /*#__PURE__*/ (0, $8eFIe$react).createElement((0, $8eFIe$Checkbox), {
|
|
157
|
+
ref: checkboxRef,
|
|
158
|
+
isDisabled: isDisabled,
|
|
159
|
+
excludeFromTabOrder: true,
|
|
160
|
+
isSelected: isSelected,
|
|
161
|
+
onChange: onChange,
|
|
162
|
+
UNSAFE_className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), 'spectrum-Card-checkbox'),
|
|
163
|
+
isEmphasized: true,
|
|
164
|
+
"aria-label": "select"
|
|
165
|
+
})), /*#__PURE__*/ (0, $8eFIe$react).createElement((0, $8eFIe$SlotProvider), {
|
|
166
|
+
slots: slots
|
|
167
|
+
}, children), /*#__PURE__*/ (0, $8eFIe$react).createElement("div", {
|
|
168
|
+
className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), 'spectrum-Card-decoration')
|
|
169
|
+
}))));
|
|
170
|
+
});
|
|
171
|
+
function $643dd8fa80926f94$var$useCard(props) {
|
|
172
|
+
let titleId = (0, $8eFIe$useSlotId)();
|
|
173
|
+
let descriptionId = (0, $8eFIe$useSlotId)();
|
|
174
|
+
let titleProps = (0, $8eFIe$useMemo)(()=>({
|
|
175
|
+
id: titleId
|
|
176
|
+
}), [
|
|
177
|
+
titleId
|
|
178
|
+
]);
|
|
179
|
+
let contentProps = (0, $8eFIe$useMemo)(()=>({
|
|
180
|
+
id: descriptionId
|
|
181
|
+
}), [
|
|
182
|
+
descriptionId
|
|
183
|
+
]);
|
|
184
|
+
return {
|
|
185
|
+
cardProps: {
|
|
186
|
+
...(0, $8eFIe$filterDOMProps)(props),
|
|
187
|
+
'aria-labelledby': titleId,
|
|
188
|
+
'aria-describedby': descriptionId,
|
|
189
|
+
tabIndex: 0
|
|
190
|
+
},
|
|
191
|
+
titleProps: titleProps,
|
|
192
|
+
contentProps: contentProps
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
export {$643dd8fa80926f94$export$7a6ccaf429ad93a8 as CardBase};
|
|
198
|
+
//# sourceMappingURL=CardBase.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"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","sources":["packages/@react-spectrum/card/src/CardBase.tsx"],"sourcesContent":["// @ts-nocheck\n/*\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\n/**\n * TODO: Add description of component here.\n */\nexport const CardBase = React.forwardRef(function 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>(undefined);\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"],"names":[],"version":3,"file":"CardBase.module.js.map"}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
var $7888205ff7de382f$exports = require("./CardBase.main.js");
|
|
2
|
+
var $e57ab98cef2f01a5$exports = require("./CardViewContext.main.js");
|
|
3
|
+
var $85c597beff94758b$exports = require("./intlStrings.main.js");
|
|
4
|
+
require("./vars.02438011.css");
|
|
5
|
+
var $71570f0038472fa2$exports = require("./card_vars_css.main.js");
|
|
6
|
+
var $kFdxB$reactspectrumutils = require("@react-spectrum/utils");
|
|
7
|
+
var $kFdxB$reactstatelygrid = require("@react-stately/grid");
|
|
8
|
+
var $kFdxB$reactariautils = require("@react-aria/utils");
|
|
9
|
+
var $kFdxB$reactspectrumprogress = require("@react-spectrum/progress");
|
|
10
|
+
var $kFdxB$react = require("react");
|
|
11
|
+
var $kFdxB$reactariai18n = require("@react-aria/i18n");
|
|
12
|
+
var $kFdxB$reactariagrid = require("@react-aria/grid");
|
|
13
|
+
var $kFdxB$reactstatelylist = require("@react-stately/list");
|
|
14
|
+
var $kFdxB$reactspectrumprovider = require("@react-spectrum/provider");
|
|
15
|
+
var $kFdxB$reactariavirtualizer = require("@react-aria/virtualizer");
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
function $parcel$interopDefault(a) {
|
|
19
|
+
return a && a.__esModule ? a.default : a;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function $parcel$export(e, n, v, s) {
|
|
23
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
$parcel$export(module.exports, "CardView", () => $514a55f6d91f25ef$export$7e52c821f7b6f422);
|
|
27
|
+
// @ts-nocheck
|
|
28
|
+
/*
|
|
29
|
+
* Copyright 2021 Adobe. All rights reserved.
|
|
30
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
31
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
32
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
33
|
+
*
|
|
34
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
35
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
36
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
37
|
+
* governing permissions and limitations under the License.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
const $514a55f6d91f25ef$export$7e52c821f7b6f422 = /*#__PURE__*/ (0, ($parcel$interopDefault($kFdxB$react))).forwardRef(function CardView(props, ref) {
|
|
53
|
+
let { scale: scale } = (0, $kFdxB$reactspectrumprovider.useProvider)();
|
|
54
|
+
let { styleProps: styleProps } = (0, $kFdxB$reactspectrumutils.useStyleProps)(props);
|
|
55
|
+
let domRef = (0, $kFdxB$reactspectrumutils.useDOMRef)(ref);
|
|
56
|
+
let { isQuiet: isQuiet, renderEmptyState: renderEmptyState, layout: layout, loadingState: loadingState, onLoadMore: onLoadMore, cardOrientation: cardOrientation = 'vertical' } = props;
|
|
57
|
+
let collator = (0, $kFdxB$reactariai18n.useCollator)({
|
|
58
|
+
usage: 'search',
|
|
59
|
+
sensitivity: 'base'
|
|
60
|
+
});
|
|
61
|
+
let isLoading = loadingState === 'loading' || loadingState === 'loadingMore';
|
|
62
|
+
let cardViewLayout = (0, $kFdxB$react.useMemo)(()=>typeof layout === 'function' ? new layout({
|
|
63
|
+
collator: collator,
|
|
64
|
+
cardOrientation: cardOrientation,
|
|
65
|
+
scale: scale
|
|
66
|
+
}) : layout, [
|
|
67
|
+
layout,
|
|
68
|
+
collator,
|
|
69
|
+
cardOrientation,
|
|
70
|
+
scale
|
|
71
|
+
]);
|
|
72
|
+
let layoutType = cardViewLayout.layoutType;
|
|
73
|
+
let { direction: direction } = (0, $kFdxB$reactariai18n.useLocale)();
|
|
74
|
+
let { collection: collection } = (0, $kFdxB$reactstatelylist.useListState)(props);
|
|
75
|
+
let gridCollection = (0, $kFdxB$react.useMemo)(()=>new (0, $kFdxB$reactstatelygrid.GridCollection)({
|
|
76
|
+
columnCount: 1,
|
|
77
|
+
items: [
|
|
78
|
+
...collection
|
|
79
|
+
].map((item)=>({
|
|
80
|
+
// Makes the Grid row use the keys the user provides to the cards so that selection change via interactions returns the card keys
|
|
81
|
+
...item,
|
|
82
|
+
hasChildNodes: true,
|
|
83
|
+
childNodes: [
|
|
84
|
+
{
|
|
85
|
+
key: `cell-${item.key}`,
|
|
86
|
+
type: 'cell',
|
|
87
|
+
value: null,
|
|
88
|
+
level: 0,
|
|
89
|
+
rendered: null,
|
|
90
|
+
textValue: item.textValue,
|
|
91
|
+
hasChildNodes: false,
|
|
92
|
+
childNodes: []
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
}))
|
|
96
|
+
}), [
|
|
97
|
+
collection
|
|
98
|
+
]);
|
|
99
|
+
let state = (0, $kFdxB$reactstatelygrid.useGridState)({
|
|
100
|
+
...props,
|
|
101
|
+
selectionMode: cardOrientation === 'horizontal' && layoutType === 'grid' ? 'none' : props.selectionMode,
|
|
102
|
+
collection: gridCollection,
|
|
103
|
+
focusMode: 'cell'
|
|
104
|
+
});
|
|
105
|
+
cardViewLayout.collection = gridCollection;
|
|
106
|
+
cardViewLayout.disabledKeys = state.disabledKeys;
|
|
107
|
+
let { gridProps: gridProps } = (0, $kFdxB$reactariagrid.useGrid)({
|
|
108
|
+
...props,
|
|
109
|
+
isVirtualized: true,
|
|
110
|
+
keyboardDelegate: cardViewLayout
|
|
111
|
+
}, state, domRef);
|
|
112
|
+
let renderWrapper = (0, $kFdxB$react.useCallback)((parent, reusableView)=>/*#__PURE__*/ (0, ($parcel$interopDefault($kFdxB$react))).createElement((0, $kFdxB$reactariavirtualizer.VirtualizerItem), {
|
|
113
|
+
key: reusableView.key,
|
|
114
|
+
layoutInfo: reusableView.layoutInfo,
|
|
115
|
+
virtualizer: reusableView.virtualizer,
|
|
116
|
+
parent: parent === null || parent === void 0 ? void 0 : parent.layoutInfo
|
|
117
|
+
}, reusableView.rendered), []);
|
|
118
|
+
let focusedKey = state.selectionManager.focusedKey;
|
|
119
|
+
let focusedItem = gridCollection.getItem(state.selectionManager.focusedKey);
|
|
120
|
+
if ((focusedItem === null || focusedItem === void 0 ? void 0 : focusedItem.parentKey) != null) focusedKey = focusedItem.parentKey;
|
|
121
|
+
let persistedKeys = (0, $kFdxB$react.useMemo)(()=>focusedKey != null ? new Set([
|
|
122
|
+
focusedKey
|
|
123
|
+
]) : null, [
|
|
124
|
+
focusedKey
|
|
125
|
+
]);
|
|
126
|
+
// TODO: does aria-row count and aria-col count need to be modified? Perhaps aria-col count needs to be omitted
|
|
127
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($kFdxB$react))).createElement((0, $e57ab98cef2f01a5$exports.CardViewContext).Provider, {
|
|
128
|
+
value: {
|
|
129
|
+
state: state,
|
|
130
|
+
isQuiet: isQuiet,
|
|
131
|
+
layout: cardViewLayout,
|
|
132
|
+
cardOrientation: cardOrientation,
|
|
133
|
+
renderEmptyState: renderEmptyState
|
|
134
|
+
}
|
|
135
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($kFdxB$react))).createElement((0, $kFdxB$reactariavirtualizer.Virtualizer), {
|
|
136
|
+
...gridProps,
|
|
137
|
+
...styleProps,
|
|
138
|
+
className: (0, $kFdxB$reactspectrumutils.classNames)((0, ($parcel$interopDefault($71570f0038472fa2$exports))), 'spectrum-CardView'),
|
|
139
|
+
ref: domRef,
|
|
140
|
+
persistedKeys: persistedKeys,
|
|
141
|
+
scrollDirection: "vertical",
|
|
142
|
+
layout: cardViewLayout,
|
|
143
|
+
collection: gridCollection,
|
|
144
|
+
isLoading: isLoading,
|
|
145
|
+
onLoadMore: onLoadMore,
|
|
146
|
+
layoutOptions: (0, $kFdxB$react.useMemo)(()=>({
|
|
147
|
+
isLoading: isLoading,
|
|
148
|
+
direction: direction
|
|
149
|
+
}), [
|
|
150
|
+
isLoading,
|
|
151
|
+
direction
|
|
152
|
+
]),
|
|
153
|
+
renderWrapper: renderWrapper,
|
|
154
|
+
style: {
|
|
155
|
+
...styleProps.style,
|
|
156
|
+
scrollPaddingTop: cardViewLayout.margin || 0
|
|
157
|
+
}
|
|
158
|
+
}, (0, $kFdxB$react.useCallback)((type, item)=>{
|
|
159
|
+
if (type === 'item') return /*#__PURE__*/ (0, ($parcel$interopDefault($kFdxB$react))).createElement($514a55f6d91f25ef$var$InternalCard, {
|
|
160
|
+
item: item
|
|
161
|
+
});
|
|
162
|
+
else if (type === 'loader') return /*#__PURE__*/ (0, ($parcel$interopDefault($kFdxB$react))).createElement($514a55f6d91f25ef$var$LoadingState, null);
|
|
163
|
+
else if (type === 'placeholder') return /*#__PURE__*/ (0, ($parcel$interopDefault($kFdxB$react))).createElement($514a55f6d91f25ef$var$EmptyState, null);
|
|
164
|
+
}, [])));
|
|
165
|
+
});
|
|
166
|
+
function $514a55f6d91f25ef$var$LoadingState() {
|
|
167
|
+
let { state: state } = (0, $e57ab98cef2f01a5$exports.useCardViewContext)();
|
|
168
|
+
let stringFormatter = (0, $kFdxB$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($85c597beff94758b$exports))), '@react-spectrum/card');
|
|
169
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($kFdxB$react))).createElement($514a55f6d91f25ef$var$CenteredWrapper, null, /*#__PURE__*/ (0, ($parcel$interopDefault($kFdxB$react))).createElement((0, $kFdxB$reactspectrumprogress.ProgressCircle), {
|
|
170
|
+
isIndeterminate: true,
|
|
171
|
+
"aria-label": state.collection.size > 0 ? stringFormatter.format('loadingMore') : stringFormatter.format('loading')
|
|
172
|
+
}));
|
|
173
|
+
}
|
|
174
|
+
function $514a55f6d91f25ef$var$EmptyState() {
|
|
175
|
+
let { renderEmptyState: renderEmptyState } = (0, $e57ab98cef2f01a5$exports.useCardViewContext)();
|
|
176
|
+
let emptyState = renderEmptyState ? renderEmptyState() : null;
|
|
177
|
+
if (emptyState == null) return null;
|
|
178
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($kFdxB$react))).createElement($514a55f6d91f25ef$var$CenteredWrapper, null, emptyState);
|
|
179
|
+
}
|
|
180
|
+
function $514a55f6d91f25ef$var$CenteredWrapper({ children: children }) {
|
|
181
|
+
let { state: state } = (0, $e57ab98cef2f01a5$exports.useCardViewContext)();
|
|
182
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($kFdxB$react))).createElement("div", {
|
|
183
|
+
role: "row",
|
|
184
|
+
"aria-rowindex": state.collection.size + 1,
|
|
185
|
+
className: (0, $kFdxB$reactspectrumutils.classNames)((0, ($parcel$interopDefault($71570f0038472fa2$exports))), 'spectrum-CardView-centeredWrapper')
|
|
186
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($kFdxB$react))).createElement("div", {
|
|
187
|
+
role: "gridcell"
|
|
188
|
+
}, children));
|
|
189
|
+
}
|
|
190
|
+
function $514a55f6d91f25ef$var$InternalCard(props) {
|
|
191
|
+
let { item: item } = props;
|
|
192
|
+
let cellNode = [
|
|
193
|
+
...item.childNodes
|
|
194
|
+
][0];
|
|
195
|
+
let { state: state, cardOrientation: cardOrientation, isQuiet: isQuiet, layout: layout } = (0, $e57ab98cef2f01a5$exports.useCardViewContext)();
|
|
196
|
+
let layoutType = layout.layoutType;
|
|
197
|
+
let rowRef = (0, $kFdxB$react.useRef)(undefined);
|
|
198
|
+
let cellRef = (0, $kFdxB$react.useRef)(undefined);
|
|
199
|
+
let unwrappedRef = (0, $kFdxB$reactspectrumutils.useUnwrapDOMRef)(cellRef);
|
|
200
|
+
let { rowProps: gridRowProps } = (0, $kFdxB$reactariagrid.useGridRow)({
|
|
201
|
+
node: item,
|
|
202
|
+
isVirtualized: true
|
|
203
|
+
}, state, rowRef);
|
|
204
|
+
let { gridCellProps: gridCellProps } = (0, $kFdxB$reactariagrid.useGridCell)({
|
|
205
|
+
node: cellNode,
|
|
206
|
+
focusMode: 'cell'
|
|
207
|
+
}, state, unwrappedRef);
|
|
208
|
+
// Prevent space key from scrolling the CardView if triggered on a disabled item or on a Card in a selectionMode="none" CardView.
|
|
209
|
+
let allowsInteraction = state.selectionManager.selectionMode !== 'none';
|
|
210
|
+
let isDisabled = !allowsInteraction || state.disabledKeys.has(item.key);
|
|
211
|
+
let onKeyDown = (e)=>{
|
|
212
|
+
if (e.key === ' ' && isDisabled) e.preventDefault();
|
|
213
|
+
};
|
|
214
|
+
let rowProps = (0, $kFdxB$reactariautils.mergeProps)(gridRowProps, {
|
|
215
|
+
onKeyDown: onKeyDown
|
|
216
|
+
});
|
|
217
|
+
if (layoutType === 'grid' || layoutType === 'gallery') isQuiet = true;
|
|
218
|
+
if (layoutType !== 'grid') cardOrientation = 'vertical';
|
|
219
|
+
// We don't want to focus the checkbox (or any other focusable elements) within the Card
|
|
220
|
+
// when pressing the arrow keys so we delete the key down handler here. Arrow key navigation between
|
|
221
|
+
// the cards in the CardView is handled by useGrid => useSelectableCollection instead.
|
|
222
|
+
delete gridCellProps.onKeyDownCapture;
|
|
223
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($kFdxB$react))).createElement("div", {
|
|
224
|
+
...rowProps,
|
|
225
|
+
ref: rowRef,
|
|
226
|
+
className: (0, $kFdxB$reactspectrumutils.classNames)((0, ($parcel$interopDefault($71570f0038472fa2$exports))), 'spectrum-CardView-row')
|
|
227
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($kFdxB$react))).createElement((0, $7888205ff7de382f$exports.CardBase), {
|
|
228
|
+
ref: cellRef,
|
|
229
|
+
articleProps: gridCellProps,
|
|
230
|
+
isQuiet: isQuiet,
|
|
231
|
+
orientation: cardOrientation,
|
|
232
|
+
item: item,
|
|
233
|
+
layout: layoutType
|
|
234
|
+
}, item.rendered));
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
//# sourceMappingURL=CardView.main.js.map
|