@react-spectrum/card 3.0.0-alpha.30 → 3.0.0-alpha.32

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 (229) 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.main.js +7 -0
  42. package/dist/ar-AE.main.js.map +1 -0
  43. package/dist/ar-AE.mjs +9 -0
  44. package/dist/ar-AE.module.js +9 -0
  45. package/dist/ar-AE.module.js.map +1 -0
  46. package/dist/bg-BG.main.js +7 -0
  47. package/dist/bg-BG.main.js.map +1 -0
  48. package/dist/bg-BG.mjs +9 -0
  49. package/dist/bg-BG.module.js +9 -0
  50. package/dist/bg-BG.module.js.map +1 -0
  51. package/dist/card_vars_css.main.js +116 -0
  52. package/dist/card_vars_css.main.js.map +1 -0
  53. package/dist/card_vars_css.mjs +118 -0
  54. package/dist/card_vars_css.module.js +118 -0
  55. package/dist/card_vars_css.module.js.map +1 -0
  56. package/dist/cs-CZ.main.js +7 -0
  57. package/dist/cs-CZ.main.js.map +1 -0
  58. package/dist/cs-CZ.mjs +9 -0
  59. package/dist/cs-CZ.module.js +9 -0
  60. package/dist/cs-CZ.module.js.map +1 -0
  61. package/dist/da-DK.main.js +7 -0
  62. package/dist/da-DK.main.js.map +1 -0
  63. package/dist/da-DK.mjs +9 -0
  64. package/dist/da-DK.module.js +9 -0
  65. package/dist/da-DK.module.js.map +1 -0
  66. package/dist/de-DE.main.js +7 -0
  67. package/dist/de-DE.main.js.map +1 -0
  68. package/dist/de-DE.mjs +9 -0
  69. package/dist/de-DE.module.js +9 -0
  70. package/dist/de-DE.module.js.map +1 -0
  71. package/dist/el-GR.main.js +7 -0
  72. package/dist/el-GR.main.js.map +1 -0
  73. package/dist/el-GR.mjs +9 -0
  74. package/dist/el-GR.module.js +9 -0
  75. package/dist/el-GR.module.js.map +1 -0
  76. package/dist/en-US.main.js +7 -0
  77. package/dist/en-US.main.js.map +1 -0
  78. package/dist/en-US.mjs +9 -0
  79. package/dist/en-US.module.js +9 -0
  80. package/dist/en-US.module.js.map +1 -0
  81. package/dist/es-ES.main.js +7 -0
  82. package/dist/es-ES.main.js.map +1 -0
  83. package/dist/es-ES.mjs +9 -0
  84. package/dist/es-ES.module.js +9 -0
  85. package/dist/es-ES.module.js.map +1 -0
  86. package/dist/et-EE.main.js +7 -0
  87. package/dist/et-EE.main.js.map +1 -0
  88. package/dist/et-EE.mjs +9 -0
  89. package/dist/et-EE.module.js +9 -0
  90. package/dist/et-EE.module.js.map +1 -0
  91. package/dist/fi-FI.main.js +7 -0
  92. package/dist/fi-FI.main.js.map +1 -0
  93. package/dist/fi-FI.mjs +9 -0
  94. package/dist/fi-FI.module.js +9 -0
  95. package/dist/fi-FI.module.js.map +1 -0
  96. package/dist/fr-FR.main.js +7 -0
  97. package/dist/fr-FR.main.js.map +1 -0
  98. package/dist/fr-FR.mjs +9 -0
  99. package/dist/fr-FR.module.js +9 -0
  100. package/dist/fr-FR.module.js.map +1 -0
  101. package/dist/he-IL.main.js +7 -0
  102. package/dist/he-IL.main.js.map +1 -0
  103. package/dist/he-IL.mjs +9 -0
  104. package/dist/he-IL.module.js +9 -0
  105. package/dist/he-IL.module.js.map +1 -0
  106. package/dist/hr-HR.main.js +7 -0
  107. package/dist/hr-HR.main.js.map +1 -0
  108. package/dist/hr-HR.mjs +9 -0
  109. package/dist/hr-HR.module.js +9 -0
  110. package/dist/hr-HR.module.js.map +1 -0
  111. package/dist/hu-HU.main.js +7 -0
  112. package/dist/hu-HU.main.js.map +1 -0
  113. package/dist/hu-HU.mjs +9 -0
  114. package/dist/hu-HU.module.js +9 -0
  115. package/dist/hu-HU.module.js.map +1 -0
  116. package/dist/import.mjs +5 -1628
  117. package/dist/intlStrings.main.js +108 -0
  118. package/dist/intlStrings.main.js.map +1 -0
  119. package/dist/intlStrings.mjs +110 -0
  120. package/dist/intlStrings.module.js +110 -0
  121. package/dist/intlStrings.module.js.map +1 -0
  122. package/dist/it-IT.main.js +7 -0
  123. package/dist/it-IT.main.js.map +1 -0
  124. package/dist/it-IT.mjs +9 -0
  125. package/dist/it-IT.module.js +9 -0
  126. package/dist/it-IT.module.js.map +1 -0
  127. package/dist/ja-JP.main.js +7 -0
  128. package/dist/ja-JP.main.js.map +1 -0
  129. package/dist/ja-JP.mjs +9 -0
  130. package/dist/ja-JP.module.js +9 -0
  131. package/dist/ja-JP.module.js.map +1 -0
  132. package/dist/ko-KR.main.js +7 -0
  133. package/dist/ko-KR.main.js.map +1 -0
  134. package/dist/ko-KR.mjs +9 -0
  135. package/dist/ko-KR.module.js +9 -0
  136. package/dist/ko-KR.module.js.map +1 -0
  137. package/dist/lt-LT.main.js +7 -0
  138. package/dist/lt-LT.main.js.map +1 -0
  139. package/dist/lt-LT.mjs +9 -0
  140. package/dist/lt-LT.module.js +9 -0
  141. package/dist/lt-LT.module.js.map +1 -0
  142. package/dist/lv-LV.main.js +7 -0
  143. package/dist/lv-LV.main.js.map +1 -0
  144. package/dist/lv-LV.mjs +9 -0
  145. package/dist/lv-LV.module.js +9 -0
  146. package/dist/lv-LV.module.js.map +1 -0
  147. package/dist/main.js +10 -1629
  148. package/dist/main.js.map +1 -1
  149. package/dist/module.js +5 -1628
  150. package/dist/module.js.map +1 -1
  151. package/dist/nb-NO.main.js +7 -0
  152. package/dist/nb-NO.main.js.map +1 -0
  153. package/dist/nb-NO.mjs +9 -0
  154. package/dist/nb-NO.module.js +9 -0
  155. package/dist/nb-NO.module.js.map +1 -0
  156. package/dist/nl-NL.main.js +7 -0
  157. package/dist/nl-NL.main.js.map +1 -0
  158. package/dist/nl-NL.mjs +9 -0
  159. package/dist/nl-NL.module.js +9 -0
  160. package/dist/nl-NL.module.js.map +1 -0
  161. package/dist/pl-PL.main.js +7 -0
  162. package/dist/pl-PL.main.js.map +1 -0
  163. package/dist/pl-PL.mjs +9 -0
  164. package/dist/pl-PL.module.js +9 -0
  165. package/dist/pl-PL.module.js.map +1 -0
  166. package/dist/pt-BR.main.js +7 -0
  167. package/dist/pt-BR.main.js.map +1 -0
  168. package/dist/pt-BR.mjs +9 -0
  169. package/dist/pt-BR.module.js +9 -0
  170. package/dist/pt-BR.module.js.map +1 -0
  171. package/dist/pt-PT.main.js +7 -0
  172. package/dist/pt-PT.main.js.map +1 -0
  173. package/dist/pt-PT.mjs +9 -0
  174. package/dist/pt-PT.module.js +9 -0
  175. package/dist/pt-PT.module.js.map +1 -0
  176. package/dist/ro-RO.main.js +7 -0
  177. package/dist/ro-RO.main.js.map +1 -0
  178. package/dist/ro-RO.mjs +9 -0
  179. package/dist/ro-RO.module.js +9 -0
  180. package/dist/ro-RO.module.js.map +1 -0
  181. package/dist/ru-RU.main.js +7 -0
  182. package/dist/ru-RU.main.js.map +1 -0
  183. package/dist/ru-RU.mjs +9 -0
  184. package/dist/ru-RU.module.js +9 -0
  185. package/dist/ru-RU.module.js.map +1 -0
  186. package/dist/sk-SK.main.js +7 -0
  187. package/dist/sk-SK.main.js.map +1 -0
  188. package/dist/sk-SK.mjs +9 -0
  189. package/dist/sk-SK.module.js +9 -0
  190. package/dist/sk-SK.module.js.map +1 -0
  191. package/dist/sl-SI.main.js +7 -0
  192. package/dist/sl-SI.main.js.map +1 -0
  193. package/dist/sl-SI.mjs +9 -0
  194. package/dist/sl-SI.module.js +9 -0
  195. package/dist/sl-SI.module.js.map +1 -0
  196. package/dist/sr-SP.main.js +7 -0
  197. package/dist/sr-SP.main.js.map +1 -0
  198. package/dist/sr-SP.mjs +9 -0
  199. package/dist/sr-SP.module.js +9 -0
  200. package/dist/sr-SP.module.js.map +1 -0
  201. package/dist/sv-SE.main.js +7 -0
  202. package/dist/sv-SE.main.js.map +1 -0
  203. package/dist/sv-SE.mjs +9 -0
  204. package/dist/sv-SE.module.js +9 -0
  205. package/dist/sv-SE.module.js.map +1 -0
  206. package/dist/tr-TR.main.js +7 -0
  207. package/dist/tr-TR.main.js.map +1 -0
  208. package/dist/tr-TR.mjs +9 -0
  209. package/dist/tr-TR.module.js +9 -0
  210. package/dist/tr-TR.module.js.map +1 -0
  211. package/dist/uk-UA.main.js +7 -0
  212. package/dist/uk-UA.main.js.map +1 -0
  213. package/dist/uk-UA.mjs +9 -0
  214. package/dist/uk-UA.module.js +9 -0
  215. package/dist/uk-UA.module.js.map +1 -0
  216. package/dist/vars.e5a6cd16.css +1671 -0
  217. package/dist/vars.e5a6cd16.css.map +1 -0
  218. package/dist/zh-CN.main.js +7 -0
  219. package/dist/zh-CN.main.js.map +1 -0
  220. package/dist/zh-CN.mjs +9 -0
  221. package/dist/zh-CN.module.js +9 -0
  222. package/dist/zh-CN.module.js.map +1 -0
  223. package/dist/zh-TW.main.js +7 -0
  224. package/dist/zh-TW.main.js.map +1 -0
  225. package/dist/zh-TW.mjs +9 -0
  226. package/dist/zh-TW.module.js +9 -0
  227. package/dist/zh-TW.module.js.map +1 -0
  228. package/package.json +18 -18
  229. package/dist/main.css +0 -1
@@ -0,0 +1,200 @@
1
+ import "./vars.e5a6cd16.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
+ /*
17
+ * Copyright 2021 Adobe. All rights reserved.
18
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
19
+ * you may not use this file except in compliance with the License. You may obtain a copy
20
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
21
+ *
22
+ * Unless required by applicable law or agreed to in writing, software distributed under
23
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
24
+ * OF ANY KIND, either express or implied. See the License for the specific language
25
+ * governing permissions and limitations under the License.
26
+ */
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+ function $643dd8fa80926f94$var$CardBase(props, ref) {
36
+ props = (0, $8eFIe$useProviderProps)(props);
37
+ let context = (0, $8d180a244893de14$export$fea0b38586ec8f13)() || {}; // we can call again here, won't change from Card.tsx
38
+ let { state: state } = context;
39
+ let manager = state === null || state === void 0 ? void 0 : state.selectionManager;
40
+ let { isQuiet: isQuiet, orientation: orientation = "vertical", articleProps: articleProps = {}, item: item, layout: layout, children: children } = props;
41
+ let key = item === null || item === void 0 ? void 0 : item.key;
42
+ let isSelected = manager === null || manager === void 0 ? void 0 : manager.isSelected(key);
43
+ let isDisabled = state === null || state === void 0 ? void 0 : state.disabledKeys.has(key);
44
+ let onChange = ()=>manager === null || manager === void 0 ? void 0 : manager.select(key);
45
+ let { styleProps: styleProps } = (0, $8eFIe$useStyleProps)(props);
46
+ let { cardProps: cardProps, titleProps: titleProps, contentProps: contentProps } = $643dd8fa80926f94$var$useCard(props);
47
+ let domRef = (0, $8eFIe$useDOMRef)(ref);
48
+ let gridRef = (0, $8eFIe$useRef)();
49
+ let checkboxRef = (0, $8eFIe$useRef)(null);
50
+ // cards are only interactive if there is a selection manager and it allows selection
51
+ let { hoverProps: hoverProps, isHovered: isHovered } = (0, $8eFIe$useHover)({
52
+ isDisabled: manager === undefined || (manager === null || manager === void 0 ? void 0 : manager.selectionMode) === "none" || isDisabled
53
+ });
54
+ let [isFocused, setIsFocused] = (0, $8eFIe$useState)(false);
55
+ let { focusWithinProps: focusWithinProps } = (0, $8eFIe$useFocusWithin)({
56
+ onFocusWithinChange: setIsFocused,
57
+ isDisabled: isDisabled
58
+ });
59
+ // ToDo: see css for comment about avatar under selector .spectrum-Card--noLayout.spectrum-Card--default
60
+ let hasPreviewImage = (0, $8eFIe$useHasChild)(`.${(0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs)))["spectrum-Card-image"]}`, gridRef);
61
+ let hasPreviewIllustration = (0, $8eFIe$useHasChild)(`.${(0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs)))["spectrum-Card-illustration"]}`, gridRef);
62
+ let hasPreview = hasPreviewImage || hasPreviewIllustration;
63
+ // this is for horizontal cards
64
+ let [height, setHeight] = (0, $8eFIe$useState)(NaN);
65
+ let updateHeight = (0, $8eFIe$useCallback)(()=>{
66
+ if (orientation !== "horizontal") return;
67
+ let cardHeight = gridRef.current.getBoundingClientRect().height;
68
+ setHeight(cardHeight);
69
+ }, [
70
+ orientation,
71
+ gridRef,
72
+ setHeight
73
+ ]);
74
+ (0, $8eFIe$useResizeObserver)({
75
+ ref: gridRef,
76
+ onResize: updateHeight
77
+ });
78
+ let aspectRatioEnforce = undefined;
79
+ if (orientation === "horizontal" && !isNaN(height)) aspectRatioEnforce = {
80
+ height: `${height}px`,
81
+ width: `${height}px`
82
+ };
83
+ let slots = (0, $8eFIe$useMemo)(()=>({
84
+ image: {
85
+ UNSAFE_className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), "spectrum-Card-image"),
86
+ objectFit: orientation === "horizontal" ? "cover" : "contain",
87
+ alt: "",
88
+ ...aspectRatioEnforce
89
+ },
90
+ illustration: {
91
+ UNSAFE_className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), "spectrum-Card-illustration"),
92
+ ...aspectRatioEnforce
93
+ },
94
+ avatar: {
95
+ UNSAFE_className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), "spectrum-Card-avatar"),
96
+ size: "avatar-size-400"
97
+ },
98
+ heading: {
99
+ UNSAFE_className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), "spectrum-Card-heading"),
100
+ ...titleProps
101
+ },
102
+ content: {
103
+ UNSAFE_className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), "spectrum-Card-content"),
104
+ ...contentProps
105
+ },
106
+ detail: {
107
+ UNSAFE_className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), "spectrum-Card-detail")
108
+ }
109
+ }), [
110
+ titleProps,
111
+ contentProps,
112
+ height,
113
+ isQuiet,
114
+ orientation
115
+ ]);
116
+ (0, $8eFIe$useLayoutEffect)(()=>{
117
+ if (gridRef === null || gridRef === void 0 ? void 0 : gridRef.current) {
118
+ let walker = (0, $8eFIe$getFocusableTreeWalker)(gridRef.current);
119
+ let nextNode = walker.nextNode();
120
+ while(nextNode != null){
121
+ if (checkboxRef.current && !checkboxRef.current.UNSAFE_getDOMNode().contains(nextNode)) {
122
+ console.warn("Card does not support focusable elements, please contact the team regarding your use case.");
123
+ break;
124
+ }
125
+ nextNode = walker.nextNode();
126
+ }
127
+ }
128
+ }, [
129
+ children
130
+ ]);
131
+ return /*#__PURE__*/ (0, $8eFIe$react).createElement((0, $8eFIe$FocusRing), {
132
+ focusRingClass: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), "focus-ring")
133
+ }, /*#__PURE__*/ (0, $8eFIe$react).createElement("article", {
134
+ ...styleProps,
135
+ ...(0, $8eFIe$mergeProps)(cardProps, focusWithinProps, hoverProps, (0, $8eFIe$filterDOMProps)(props), articleProps),
136
+ ref: domRef,
137
+ className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), "spectrum-Card", {
138
+ "spectrum-Card--default": !isQuiet && orientation !== "horizontal",
139
+ "spectrum-Card--isQuiet": isQuiet && orientation !== "horizontal",
140
+ "spectrum-Card--horizontal": orientation === "horizontal",
141
+ "spectrum-Card--noPreview": !hasPreview,
142
+ "is-hovered": isHovered,
143
+ "is-focused": isFocused,
144
+ "is-selected": isSelected,
145
+ "spectrum-Card--waterfall": layout === "waterfall",
146
+ "spectrum-Card--gallery": layout === "gallery",
147
+ "spectrum-Card--grid": layout === "grid",
148
+ "spectrum-Card--noLayout": layout !== "waterfall" && layout !== "gallery" && layout !== "grid"
149
+ }, styleProps.className)
150
+ }, /*#__PURE__*/ (0, $8eFIe$react).createElement("div", {
151
+ ref: gridRef,
152
+ className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), "spectrum-Card-grid")
153
+ }, manager && manager.selectionMode !== "none" && /*#__PURE__*/ (0, $8eFIe$react).createElement("div", {
154
+ className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), "spectrum-Card-checkboxWrapper")
155
+ }, /*#__PURE__*/ (0, $8eFIe$react).createElement((0, $8eFIe$Checkbox), {
156
+ ref: checkboxRef,
157
+ isDisabled: isDisabled,
158
+ excludeFromTabOrder: true,
159
+ isSelected: isSelected,
160
+ onChange: onChange,
161
+ UNSAFE_className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), "spectrum-Card-checkbox"),
162
+ isEmphasized: true,
163
+ "aria-label": "select"
164
+ })), /*#__PURE__*/ (0, $8eFIe$react).createElement((0, $8eFIe$SlotProvider), {
165
+ slots: slots
166
+ }, children), /*#__PURE__*/ (0, $8eFIe$react).createElement("div", {
167
+ className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), "spectrum-Card-decoration")
168
+ }))));
169
+ }
170
+ function $643dd8fa80926f94$var$useCard(props) {
171
+ let titleId = (0, $8eFIe$useSlotId)();
172
+ let descriptionId = (0, $8eFIe$useSlotId)();
173
+ let titleProps = (0, $8eFIe$useMemo)(()=>({
174
+ id: titleId
175
+ }), [
176
+ titleId
177
+ ]);
178
+ let contentProps = (0, $8eFIe$useMemo)(()=>({
179
+ id: descriptionId
180
+ }), [
181
+ descriptionId
182
+ ]);
183
+ return {
184
+ cardProps: {
185
+ ...(0, $8eFIe$filterDOMProps)(props),
186
+ "aria-labelledby": titleId,
187
+ "aria-describedby": descriptionId,
188
+ tabIndex: 0
189
+ },
190
+ titleProps: titleProps,
191
+ contentProps: contentProps
192
+ };
193
+ }
194
+ /**
195
+ * TODO: Add description of component here.
196
+ */ const $643dd8fa80926f94$export$7a6ccaf429ad93a8 = /*#__PURE__*/ (0, $8eFIe$react).forwardRef($643dd8fa80926f94$var$CardBase);
197
+
198
+
199
+ export {$643dd8fa80926f94$export$7a6ccaf429ad93a8 as CardBase};
200
+ //# sourceMappingURL=CardBase.mjs.map
@@ -0,0 +1,200 @@
1
+ import "./vars.e5a6cd16.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
+ /*
17
+ * Copyright 2021 Adobe. All rights reserved.
18
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
19
+ * you may not use this file except in compliance with the License. You may obtain a copy
20
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
21
+ *
22
+ * Unless required by applicable law or agreed to in writing, software distributed under
23
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
24
+ * OF ANY KIND, either express or implied. See the License for the specific language
25
+ * governing permissions and limitations under the License.
26
+ */
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+ function $643dd8fa80926f94$var$CardBase(props, ref) {
36
+ props = (0, $8eFIe$useProviderProps)(props);
37
+ let context = (0, $8d180a244893de14$export$fea0b38586ec8f13)() || {}; // we can call again here, won't change from Card.tsx
38
+ let { state: state } = context;
39
+ let manager = state === null || state === void 0 ? void 0 : state.selectionManager;
40
+ let { isQuiet: isQuiet, orientation: orientation = "vertical", articleProps: articleProps = {}, item: item, layout: layout, children: children } = props;
41
+ let key = item === null || item === void 0 ? void 0 : item.key;
42
+ let isSelected = manager === null || manager === void 0 ? void 0 : manager.isSelected(key);
43
+ let isDisabled = state === null || state === void 0 ? void 0 : state.disabledKeys.has(key);
44
+ let onChange = ()=>manager === null || manager === void 0 ? void 0 : manager.select(key);
45
+ let { styleProps: styleProps } = (0, $8eFIe$useStyleProps)(props);
46
+ let { cardProps: cardProps, titleProps: titleProps, contentProps: contentProps } = $643dd8fa80926f94$var$useCard(props);
47
+ let domRef = (0, $8eFIe$useDOMRef)(ref);
48
+ let gridRef = (0, $8eFIe$useRef)();
49
+ let checkboxRef = (0, $8eFIe$useRef)(null);
50
+ // cards are only interactive if there is a selection manager and it allows selection
51
+ let { hoverProps: hoverProps, isHovered: isHovered } = (0, $8eFIe$useHover)({
52
+ isDisabled: manager === undefined || (manager === null || manager === void 0 ? void 0 : manager.selectionMode) === "none" || isDisabled
53
+ });
54
+ let [isFocused, setIsFocused] = (0, $8eFIe$useState)(false);
55
+ let { focusWithinProps: focusWithinProps } = (0, $8eFIe$useFocusWithin)({
56
+ onFocusWithinChange: setIsFocused,
57
+ isDisabled: isDisabled
58
+ });
59
+ // ToDo: see css for comment about avatar under selector .spectrum-Card--noLayout.spectrum-Card--default
60
+ let hasPreviewImage = (0, $8eFIe$useHasChild)(`.${(0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs)))["spectrum-Card-image"]}`, gridRef);
61
+ let hasPreviewIllustration = (0, $8eFIe$useHasChild)(`.${(0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs)))["spectrum-Card-illustration"]}`, gridRef);
62
+ let hasPreview = hasPreviewImage || hasPreviewIllustration;
63
+ // this is for horizontal cards
64
+ let [height, setHeight] = (0, $8eFIe$useState)(NaN);
65
+ let updateHeight = (0, $8eFIe$useCallback)(()=>{
66
+ if (orientation !== "horizontal") return;
67
+ let cardHeight = gridRef.current.getBoundingClientRect().height;
68
+ setHeight(cardHeight);
69
+ }, [
70
+ orientation,
71
+ gridRef,
72
+ setHeight
73
+ ]);
74
+ (0, $8eFIe$useResizeObserver)({
75
+ ref: gridRef,
76
+ onResize: updateHeight
77
+ });
78
+ let aspectRatioEnforce = undefined;
79
+ if (orientation === "horizontal" && !isNaN(height)) aspectRatioEnforce = {
80
+ height: `${height}px`,
81
+ width: `${height}px`
82
+ };
83
+ let slots = (0, $8eFIe$useMemo)(()=>({
84
+ image: {
85
+ UNSAFE_className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), "spectrum-Card-image"),
86
+ objectFit: orientation === "horizontal" ? "cover" : "contain",
87
+ alt: "",
88
+ ...aspectRatioEnforce
89
+ },
90
+ illustration: {
91
+ UNSAFE_className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), "spectrum-Card-illustration"),
92
+ ...aspectRatioEnforce
93
+ },
94
+ avatar: {
95
+ UNSAFE_className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), "spectrum-Card-avatar"),
96
+ size: "avatar-size-400"
97
+ },
98
+ heading: {
99
+ UNSAFE_className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), "spectrum-Card-heading"),
100
+ ...titleProps
101
+ },
102
+ content: {
103
+ UNSAFE_className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), "spectrum-Card-content"),
104
+ ...contentProps
105
+ },
106
+ detail: {
107
+ UNSAFE_className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), "spectrum-Card-detail")
108
+ }
109
+ }), [
110
+ titleProps,
111
+ contentProps,
112
+ height,
113
+ isQuiet,
114
+ orientation
115
+ ]);
116
+ (0, $8eFIe$useLayoutEffect)(()=>{
117
+ if (gridRef === null || gridRef === void 0 ? void 0 : gridRef.current) {
118
+ let walker = (0, $8eFIe$getFocusableTreeWalker)(gridRef.current);
119
+ let nextNode = walker.nextNode();
120
+ while(nextNode != null){
121
+ if (checkboxRef.current && !checkboxRef.current.UNSAFE_getDOMNode().contains(nextNode)) {
122
+ console.warn("Card does not support focusable elements, please contact the team regarding your use case.");
123
+ break;
124
+ }
125
+ nextNode = walker.nextNode();
126
+ }
127
+ }
128
+ }, [
129
+ children
130
+ ]);
131
+ return /*#__PURE__*/ (0, $8eFIe$react).createElement((0, $8eFIe$FocusRing), {
132
+ focusRingClass: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), "focus-ring")
133
+ }, /*#__PURE__*/ (0, $8eFIe$react).createElement("article", {
134
+ ...styleProps,
135
+ ...(0, $8eFIe$mergeProps)(cardProps, focusWithinProps, hoverProps, (0, $8eFIe$filterDOMProps)(props), articleProps),
136
+ ref: domRef,
137
+ className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), "spectrum-Card", {
138
+ "spectrum-Card--default": !isQuiet && orientation !== "horizontal",
139
+ "spectrum-Card--isQuiet": isQuiet && orientation !== "horizontal",
140
+ "spectrum-Card--horizontal": orientation === "horizontal",
141
+ "spectrum-Card--noPreview": !hasPreview,
142
+ "is-hovered": isHovered,
143
+ "is-focused": isFocused,
144
+ "is-selected": isSelected,
145
+ "spectrum-Card--waterfall": layout === "waterfall",
146
+ "spectrum-Card--gallery": layout === "gallery",
147
+ "spectrum-Card--grid": layout === "grid",
148
+ "spectrum-Card--noLayout": layout !== "waterfall" && layout !== "gallery" && layout !== "grid"
149
+ }, styleProps.className)
150
+ }, /*#__PURE__*/ (0, $8eFIe$react).createElement("div", {
151
+ ref: gridRef,
152
+ className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), "spectrum-Card-grid")
153
+ }, manager && manager.selectionMode !== "none" && /*#__PURE__*/ (0, $8eFIe$react).createElement("div", {
154
+ className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), "spectrum-Card-checkboxWrapper")
155
+ }, /*#__PURE__*/ (0, $8eFIe$react).createElement((0, $8eFIe$Checkbox), {
156
+ ref: checkboxRef,
157
+ isDisabled: isDisabled,
158
+ excludeFromTabOrder: true,
159
+ isSelected: isSelected,
160
+ onChange: onChange,
161
+ UNSAFE_className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), "spectrum-Card-checkbox"),
162
+ isEmphasized: true,
163
+ "aria-label": "select"
164
+ })), /*#__PURE__*/ (0, $8eFIe$react).createElement((0, $8eFIe$SlotProvider), {
165
+ slots: slots
166
+ }, children), /*#__PURE__*/ (0, $8eFIe$react).createElement("div", {
167
+ className: (0, $8eFIe$classNames)((0, ($parcel$interopDefault($8eFIe$card_vars_cssmodulejs))), "spectrum-Card-decoration")
168
+ }))));
169
+ }
170
+ function $643dd8fa80926f94$var$useCard(props) {
171
+ let titleId = (0, $8eFIe$useSlotId)();
172
+ let descriptionId = (0, $8eFIe$useSlotId)();
173
+ let titleProps = (0, $8eFIe$useMemo)(()=>({
174
+ id: titleId
175
+ }), [
176
+ titleId
177
+ ]);
178
+ let contentProps = (0, $8eFIe$useMemo)(()=>({
179
+ id: descriptionId
180
+ }), [
181
+ descriptionId
182
+ ]);
183
+ return {
184
+ cardProps: {
185
+ ...(0, $8eFIe$filterDOMProps)(props),
186
+ "aria-labelledby": titleId,
187
+ "aria-describedby": descriptionId,
188
+ tabIndex: 0
189
+ },
190
+ titleProps: titleProps,
191
+ contentProps: contentProps
192
+ };
193
+ }
194
+ /**
195
+ * TODO: Add description of component here.
196
+ */ const $643dd8fa80926f94$export$7a6ccaf429ad93a8 = /*#__PURE__*/ (0, $8eFIe$react).forwardRef($643dd8fa80926f94$var$CardBase);
197
+
198
+
199
+ export {$643dd8fa80926f94$export$7a6ccaf429ad93a8 as CardBase};
200
+ //# sourceMappingURL=CardBase.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AAmBD,SAAS,+BAA2B,KAAuB,EAAE,GAA2B;IACtF,QAAQ,CAAA,GAAA,uBAAe,EAAE;IACzB,IAAI,UAAU,CAAA,GAAA,yCAAiB,OAAO,CAAC,GAAG,qDAAqD;IAC/F,IAAI,SAAC,KAAK,EAAC,GAAG;IACd,IAAI,UAAU,kBAAA,4BAAA,MAAO,gBAAgB;IACrC,IAAI,WAC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AS,EAAE,CAAA,GAAA,sDAAK,GAAG;QACrC,cAAA;QACA,cAAW;uBAGjB,gCAAC,CAAA,GAAA,mBAAW;QAAE,OAAO;OAClB,yBAEH,gCAAC;QAAI,WAAW,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,sDAAK,GAAG;;AAK7C;AAWA,SAAS,8BAAQ,KAAsB;IACrC,IAAI,UAAU,CAAA,GAAA,gBAAQ;IACtB,IAAI,gBAAgB,CAAA,GAAA,gBAAQ;IAC5B,IAAI,aAAa,CAAA,GAAA,cAAM,EAAE,IAAO,CAAA;YAC9B,IAAI;QACN,CAAA,GAAI;QAAC;KAAQ;IACb,IAAI,eAAe,CAAA,GAAA,cAAM,EAAE,IAAO,CAAA;YAChC,IAAI;QACN,CAAA,GAAI;QAAC;KAAc;IAEnB,OAAO;QACL,WAAW;YACT,GAAG,CAAA,GAAA,qBAAa,EAAE,MAAM;YACxB,mBAAmB;YACnB,oBAAoB;YACpB,UAAU;QACZ;oBACA;sBACA;IACF;AACF;AAEA;;CAEC,GACD,MAAM,0DAAY,CAAA,GAAA,YAAI,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.module.js.map"}
@@ -0,0 +1,232 @@
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.e5a6cd16.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
+ /*
28
+ * Copyright 2021 Adobe. All rights reserved.
29
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
30
+ * you may not use this file except in compliance with the License. You may obtain a copy
31
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
32
+ *
33
+ * Unless required by applicable law or agreed to in writing, software distributed under
34
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
35
+ * OF ANY KIND, either express or implied. See the License for the specific language
36
+ * governing permissions and limitations under the License.
37
+ */
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+ function $514a55f6d91f25ef$var$CardView(props, ref) {
52
+ let { scale: scale } = (0, $kFdxB$reactspectrumprovider.useProvider)();
53
+ let { styleProps: styleProps } = (0, $kFdxB$reactspectrumutils.useStyleProps)(props);
54
+ let domRef = (0, $kFdxB$reactspectrumutils.useDOMRef)(ref);
55
+ let { isQuiet: isQuiet, renderEmptyState: renderEmptyState, layout: layout, loadingState: loadingState, onLoadMore: onLoadMore, cardOrientation: cardOrientation = "vertical" } = props;
56
+ let collator = (0, $kFdxB$reactariai18n.useCollator)({
57
+ usage: "search",
58
+ sensitivity: "base"
59
+ });
60
+ let isLoading = loadingState === "loading" || loadingState === "loadingMore";
61
+ let cardViewLayout = (0, $kFdxB$react.useMemo)(()=>typeof layout === "function" ? new layout({
62
+ collator: collator,
63
+ cardOrientation: cardOrientation,
64
+ scale: scale
65
+ }) : layout, [
66
+ layout,
67
+ collator,
68
+ cardOrientation,
69
+ scale
70
+ ]);
71
+ let layoutType = cardViewLayout.layoutType;
72
+ let stringFormatter = (0, $kFdxB$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($85c597beff94758b$exports))), "@react-spectrum/card");
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
+ cardViewLayout.isLoading = isLoading;
108
+ cardViewLayout.direction = direction;
109
+ let { gridProps: gridProps } = (0, $kFdxB$reactariagrid.useGrid)({
110
+ ...props,
111
+ isVirtualized: true,
112
+ keyboardDelegate: cardViewLayout
113
+ }, state, domRef);
114
+ let renderWrapper = (parent, reusableView)=>/*#__PURE__*/ (0, ($parcel$interopDefault($kFdxB$react))).createElement((0, $kFdxB$reactariavirtualizer.VirtualizerItem), {
115
+ key: reusableView.key,
116
+ layoutInfo: reusableView.layoutInfo,
117
+ virtualizer: reusableView.virtualizer,
118
+ parent: parent === null || parent === void 0 ? void 0 : parent.layoutInfo
119
+ }, reusableView.rendered);
120
+ let focusedKey = state.selectionManager.focusedKey;
121
+ let focusedItem = gridCollection.getItem(state.selectionManager.focusedKey);
122
+ if ((focusedItem === null || focusedItem === void 0 ? void 0 : focusedItem.parentKey) != null) focusedKey = focusedItem.parentKey;
123
+ let margin = cardViewLayout.margin || 0;
124
+ let virtualizer = cardViewLayout.virtualizer;
125
+ let scrollToItem = (0, $kFdxB$react.useCallback)((key)=>{
126
+ virtualizer && virtualizer.scrollToItem(key, {
127
+ duration: 0,
128
+ offsetY: margin
129
+ });
130
+ }, [
131
+ margin,
132
+ virtualizer
133
+ ]);
134
+ // TODO: does aria-row count and aria-col count need to be modified? Perhaps aria-col count needs to be omitted
135
+ return /*#__PURE__*/ (0, ($parcel$interopDefault($kFdxB$react))).createElement((0, $e57ab98cef2f01a5$exports.CardViewContext).Provider, {
136
+ value: {
137
+ state: state,
138
+ isQuiet: isQuiet,
139
+ layout: cardViewLayout,
140
+ cardOrientation: cardOrientation
141
+ }
142
+ }, /*#__PURE__*/ (0, ($parcel$interopDefault($kFdxB$react))).createElement((0, $kFdxB$reactariavirtualizer.Virtualizer), {
143
+ ...gridProps,
144
+ ...styleProps,
145
+ className: (0, $kFdxB$reactspectrumutils.classNames)((0, ($parcel$interopDefault($71570f0038472fa2$exports))), "spectrum-CardView"),
146
+ ref: domRef,
147
+ focusedKey: focusedKey,
148
+ scrollDirection: "vertical",
149
+ layout: cardViewLayout,
150
+ collection: gridCollection,
151
+ isLoading: isLoading,
152
+ onLoadMore: onLoadMore,
153
+ renderWrapper: renderWrapper,
154
+ transitionDuration: isLoading ? 160 : 220,
155
+ scrollToItem: scrollToItem
156
+ }, (type, item)=>{
157
+ if (type === "item") return /*#__PURE__*/ (0, ($parcel$interopDefault($kFdxB$react))).createElement($514a55f6d91f25ef$var$InternalCard, {
158
+ item: item
159
+ });
160
+ else if (type === "loader") return /*#__PURE__*/ (0, ($parcel$interopDefault($kFdxB$react))).createElement($514a55f6d91f25ef$var$CenteredWrapper, null, /*#__PURE__*/ (0, ($parcel$interopDefault($kFdxB$react))).createElement((0, $kFdxB$reactspectrumprogress.ProgressCircle), {
161
+ isIndeterminate: true,
162
+ "aria-label": state.collection.size > 0 ? stringFormatter.format("loadingMore") : stringFormatter.format("loading")
163
+ }));
164
+ else if (type === "placeholder") {
165
+ let emptyState = renderEmptyState ? renderEmptyState() : null;
166
+ if (emptyState == null) return null;
167
+ return /*#__PURE__*/ (0, ($parcel$interopDefault($kFdxB$react))).createElement($514a55f6d91f25ef$var$CenteredWrapper, null, emptyState);
168
+ }
169
+ }));
170
+ }
171
+ function $514a55f6d91f25ef$var$CenteredWrapper({ children: children }) {
172
+ let { state: state } = (0, $e57ab98cef2f01a5$exports.useCardViewContext)();
173
+ return /*#__PURE__*/ (0, ($parcel$interopDefault($kFdxB$react))).createElement("div", {
174
+ role: "row",
175
+ "aria-rowindex": state.collection.size + 1,
176
+ className: (0, $kFdxB$reactspectrumutils.classNames)((0, ($parcel$interopDefault($71570f0038472fa2$exports))), "spectrum-CardView-centeredWrapper")
177
+ }, /*#__PURE__*/ (0, ($parcel$interopDefault($kFdxB$react))).createElement("div", {
178
+ role: "gridcell"
179
+ }, children));
180
+ }
181
+ function $514a55f6d91f25ef$var$InternalCard(props) {
182
+ let { item: item } = props;
183
+ let cellNode = [
184
+ ...item.childNodes
185
+ ][0];
186
+ let { state: state, cardOrientation: cardOrientation, isQuiet: isQuiet, layout: layout } = (0, $e57ab98cef2f01a5$exports.useCardViewContext)();
187
+ let layoutType = layout.layoutType;
188
+ let rowRef = (0, $kFdxB$react.useRef)();
189
+ let cellRef = (0, $kFdxB$react.useRef)();
190
+ let unwrappedRef = (0, $kFdxB$reactspectrumutils.useUnwrapDOMRef)(cellRef);
191
+ let { rowProps: gridRowProps } = (0, $kFdxB$reactariagrid.useGridRow)({
192
+ node: item,
193
+ isVirtualized: true
194
+ }, state, rowRef);
195
+ let { gridCellProps: gridCellProps } = (0, $kFdxB$reactariagrid.useGridCell)({
196
+ node: cellNode,
197
+ focusMode: "cell"
198
+ }, state, unwrappedRef);
199
+ // Prevent space key from scrolling the CardView if triggered on a disabled item or on a Card in a selectionMode="none" CardView.
200
+ let allowsInteraction = state.selectionManager.selectionMode !== "none";
201
+ let isDisabled = !allowsInteraction || state.disabledKeys.has(item.key);
202
+ let onKeyDown = (e)=>{
203
+ if (e.key === " " && isDisabled) e.preventDefault();
204
+ };
205
+ let rowProps = (0, $kFdxB$reactariautils.mergeProps)(gridRowProps, {
206
+ onKeyDown: onKeyDown
207
+ });
208
+ if (layoutType === "grid" || layoutType === "gallery") isQuiet = true;
209
+ if (layoutType !== "grid") cardOrientation = "vertical";
210
+ // We don't want to focus the checkbox (or any other focusable elements) within the Card
211
+ // when pressing the arrow keys so we delete the key down handler here. Arrow key navigation between
212
+ // the cards in the CardView is handled by useGrid => useSelectableCollection instead.
213
+ delete gridCellProps.onKeyDownCapture;
214
+ return /*#__PURE__*/ (0, ($parcel$interopDefault($kFdxB$react))).createElement("div", {
215
+ ...rowProps,
216
+ ref: rowRef,
217
+ className: (0, $kFdxB$reactspectrumutils.classNames)((0, ($parcel$interopDefault($71570f0038472fa2$exports))), "spectrum-CardView-row")
218
+ }, /*#__PURE__*/ (0, ($parcel$interopDefault($kFdxB$react))).createElement((0, $7888205ff7de382f$exports.CardBase), {
219
+ ref: cellRef,
220
+ articleProps: gridCellProps,
221
+ isQuiet: isQuiet,
222
+ orientation: cardOrientation,
223
+ item: item,
224
+ layout: layoutType
225
+ }, item.rendered));
226
+ }
227
+ /**
228
+ * TODO: Add description of component here.
229
+ */ const $514a55f6d91f25ef$export$7e52c821f7b6f422 = /*#__PURE__*/ (0, ($parcel$interopDefault($kFdxB$react))).forwardRef($514a55f6d91f25ef$var$CardView);
230
+
231
+
232
+ //# sourceMappingURL=CardView.main.js.map