@react-spectrum/card 3.0.0-alpha.52 → 3.0.0-alpha.54

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 (240) hide show
  1. package/dist/import.mjs +6 -6
  2. package/dist/main.js +10 -10
  3. package/dist/main.js.map +1 -1
  4. package/dist/module.js +6 -6
  5. package/dist/module.js.map +1 -1
  6. package/dist/types/src/index.d.ts +9 -0
  7. package/package.json +12 -40
  8. package/src/index.ts +9 -9
  9. package/dist/BaseLayout.main.js +0 -213
  10. package/dist/BaseLayout.main.js.map +0 -1
  11. package/dist/BaseLayout.mjs +0 -208
  12. package/dist/BaseLayout.module.js +0 -208
  13. package/dist/BaseLayout.module.js.map +0 -1
  14. package/dist/Card.main.js +0 -52
  15. package/dist/Card.main.js.map +0 -1
  16. package/dist/Card.mjs +0 -43
  17. package/dist/Card.module.js +0 -43
  18. package/dist/Card.module.js.map +0 -1
  19. package/dist/CardBase.main.js +0 -205
  20. package/dist/CardBase.main.js.map +0 -1
  21. package/dist/CardBase.mjs +0 -200
  22. package/dist/CardBase.module.js +0 -200
  23. package/dist/CardBase.module.js.map +0 -1
  24. package/dist/CardView.main.js +0 -238
  25. package/dist/CardView.main.js.map +0 -1
  26. package/dist/CardView.mjs +0 -233
  27. package/dist/CardView.module.js +0 -233
  28. package/dist/CardView.module.js.map +0 -1
  29. package/dist/CardViewContext.main.js +0 -32
  30. package/dist/CardViewContext.main.js.map +0 -1
  31. package/dist/CardViewContext.mjs +0 -22
  32. package/dist/CardViewContext.module.js +0 -22
  33. package/dist/CardViewContext.module.js.map +0 -1
  34. package/dist/GalleryLayout.main.js +0 -230
  35. package/dist/GalleryLayout.main.js.map +0 -1
  36. package/dist/GalleryLayout.mjs +0 -225
  37. package/dist/GalleryLayout.module.js +0 -225
  38. package/dist/GalleryLayout.module.js.map +0 -1
  39. package/dist/GridLayout.main.js +0 -175
  40. package/dist/GridLayout.main.js.map +0 -1
  41. package/dist/GridLayout.mjs +0 -170
  42. package/dist/GridLayout.module.js +0 -170
  43. package/dist/GridLayout.module.js.map +0 -1
  44. package/dist/WaterfallLayout.main.js +0 -182
  45. package/dist/WaterfallLayout.main.js.map +0 -1
  46. package/dist/WaterfallLayout.mjs +0 -177
  47. package/dist/WaterfallLayout.module.js +0 -177
  48. package/dist/WaterfallLayout.module.js.map +0 -1
  49. package/dist/ar-AE.main.js +0 -7
  50. package/dist/ar-AE.main.js.map +0 -1
  51. package/dist/ar-AE.mjs +0 -9
  52. package/dist/ar-AE.module.js +0 -9
  53. package/dist/ar-AE.module.js.map +0 -1
  54. package/dist/bg-BG.main.js +0 -7
  55. package/dist/bg-BG.main.js.map +0 -1
  56. package/dist/bg-BG.mjs +0 -9
  57. package/dist/bg-BG.module.js +0 -9
  58. package/dist/bg-BG.module.js.map +0 -1
  59. package/dist/card.4d5d6544.css +0 -1671
  60. package/dist/card.4d5d6544.css.map +0 -1
  61. package/dist/card_vars_css.main.js +0 -116
  62. package/dist/card_vars_css.main.js.map +0 -1
  63. package/dist/card_vars_css.mjs +0 -118
  64. package/dist/card_vars_css.module.js +0 -118
  65. package/dist/card_vars_css.module.js.map +0 -1
  66. package/dist/cs-CZ.main.js +0 -7
  67. package/dist/cs-CZ.main.js.map +0 -1
  68. package/dist/cs-CZ.mjs +0 -9
  69. package/dist/cs-CZ.module.js +0 -9
  70. package/dist/cs-CZ.module.js.map +0 -1
  71. package/dist/da-DK.main.js +0 -7
  72. package/dist/da-DK.main.js.map +0 -1
  73. package/dist/da-DK.mjs +0 -9
  74. package/dist/da-DK.module.js +0 -9
  75. package/dist/da-DK.module.js.map +0 -1
  76. package/dist/de-DE.main.js +0 -7
  77. package/dist/de-DE.main.js.map +0 -1
  78. package/dist/de-DE.mjs +0 -9
  79. package/dist/de-DE.module.js +0 -9
  80. package/dist/de-DE.module.js.map +0 -1
  81. package/dist/el-GR.main.js +0 -7
  82. package/dist/el-GR.main.js.map +0 -1
  83. package/dist/el-GR.mjs +0 -9
  84. package/dist/el-GR.module.js +0 -9
  85. package/dist/el-GR.module.js.map +0 -1
  86. package/dist/en-US.main.js +0 -7
  87. package/dist/en-US.main.js.map +0 -1
  88. package/dist/en-US.mjs +0 -9
  89. package/dist/en-US.module.js +0 -9
  90. package/dist/en-US.module.js.map +0 -1
  91. package/dist/es-ES.main.js +0 -7
  92. package/dist/es-ES.main.js.map +0 -1
  93. package/dist/es-ES.mjs +0 -9
  94. package/dist/es-ES.module.js +0 -9
  95. package/dist/es-ES.module.js.map +0 -1
  96. package/dist/et-EE.main.js +0 -7
  97. package/dist/et-EE.main.js.map +0 -1
  98. package/dist/et-EE.mjs +0 -9
  99. package/dist/et-EE.module.js +0 -9
  100. package/dist/et-EE.module.js.map +0 -1
  101. package/dist/fi-FI.main.js +0 -7
  102. package/dist/fi-FI.main.js.map +0 -1
  103. package/dist/fi-FI.mjs +0 -9
  104. package/dist/fi-FI.module.js +0 -9
  105. package/dist/fi-FI.module.js.map +0 -1
  106. package/dist/fr-FR.main.js +0 -7
  107. package/dist/fr-FR.main.js.map +0 -1
  108. package/dist/fr-FR.mjs +0 -9
  109. package/dist/fr-FR.module.js +0 -9
  110. package/dist/fr-FR.module.js.map +0 -1
  111. package/dist/he-IL.main.js +0 -7
  112. package/dist/he-IL.main.js.map +0 -1
  113. package/dist/he-IL.mjs +0 -9
  114. package/dist/he-IL.module.js +0 -9
  115. package/dist/he-IL.module.js.map +0 -1
  116. package/dist/hr-HR.main.js +0 -7
  117. package/dist/hr-HR.main.js.map +0 -1
  118. package/dist/hr-HR.mjs +0 -9
  119. package/dist/hr-HR.module.js +0 -9
  120. package/dist/hr-HR.module.js.map +0 -1
  121. package/dist/hu-HU.main.js +0 -7
  122. package/dist/hu-HU.main.js.map +0 -1
  123. package/dist/hu-HU.mjs +0 -9
  124. package/dist/hu-HU.module.js +0 -9
  125. package/dist/hu-HU.module.js.map +0 -1
  126. package/dist/intlStrings.main.js +0 -108
  127. package/dist/intlStrings.main.js.map +0 -1
  128. package/dist/intlStrings.mjs +0 -110
  129. package/dist/intlStrings.module.js +0 -110
  130. package/dist/intlStrings.module.js.map +0 -1
  131. package/dist/it-IT.main.js +0 -7
  132. package/dist/it-IT.main.js.map +0 -1
  133. package/dist/it-IT.mjs +0 -9
  134. package/dist/it-IT.module.js +0 -9
  135. package/dist/it-IT.module.js.map +0 -1
  136. package/dist/ja-JP.main.js +0 -7
  137. package/dist/ja-JP.main.js.map +0 -1
  138. package/dist/ja-JP.mjs +0 -9
  139. package/dist/ja-JP.module.js +0 -9
  140. package/dist/ja-JP.module.js.map +0 -1
  141. package/dist/ko-KR.main.js +0 -7
  142. package/dist/ko-KR.main.js.map +0 -1
  143. package/dist/ko-KR.mjs +0 -9
  144. package/dist/ko-KR.module.js +0 -9
  145. package/dist/ko-KR.module.js.map +0 -1
  146. package/dist/lt-LT.main.js +0 -7
  147. package/dist/lt-LT.main.js.map +0 -1
  148. package/dist/lt-LT.mjs +0 -9
  149. package/dist/lt-LT.module.js +0 -9
  150. package/dist/lt-LT.module.js.map +0 -1
  151. package/dist/lv-LV.main.js +0 -7
  152. package/dist/lv-LV.main.js.map +0 -1
  153. package/dist/lv-LV.mjs +0 -9
  154. package/dist/lv-LV.module.js +0 -9
  155. package/dist/lv-LV.module.js.map +0 -1
  156. package/dist/nb-NO.main.js +0 -7
  157. package/dist/nb-NO.main.js.map +0 -1
  158. package/dist/nb-NO.mjs +0 -9
  159. package/dist/nb-NO.module.js +0 -9
  160. package/dist/nb-NO.module.js.map +0 -1
  161. package/dist/nl-NL.main.js +0 -7
  162. package/dist/nl-NL.main.js.map +0 -1
  163. package/dist/nl-NL.mjs +0 -9
  164. package/dist/nl-NL.module.js +0 -9
  165. package/dist/nl-NL.module.js.map +0 -1
  166. package/dist/pl-PL.main.js +0 -7
  167. package/dist/pl-PL.main.js.map +0 -1
  168. package/dist/pl-PL.mjs +0 -9
  169. package/dist/pl-PL.module.js +0 -9
  170. package/dist/pl-PL.module.js.map +0 -1
  171. package/dist/pt-BR.main.js +0 -7
  172. package/dist/pt-BR.main.js.map +0 -1
  173. package/dist/pt-BR.mjs +0 -9
  174. package/dist/pt-BR.module.js +0 -9
  175. package/dist/pt-BR.module.js.map +0 -1
  176. package/dist/pt-PT.main.js +0 -7
  177. package/dist/pt-PT.main.js.map +0 -1
  178. package/dist/pt-PT.mjs +0 -9
  179. package/dist/pt-PT.module.js +0 -9
  180. package/dist/pt-PT.module.js.map +0 -1
  181. package/dist/ro-RO.main.js +0 -7
  182. package/dist/ro-RO.main.js.map +0 -1
  183. package/dist/ro-RO.mjs +0 -9
  184. package/dist/ro-RO.module.js +0 -9
  185. package/dist/ro-RO.module.js.map +0 -1
  186. package/dist/ru-RU.main.js +0 -7
  187. package/dist/ru-RU.main.js.map +0 -1
  188. package/dist/ru-RU.mjs +0 -9
  189. package/dist/ru-RU.module.js +0 -9
  190. package/dist/ru-RU.module.js.map +0 -1
  191. package/dist/sk-SK.main.js +0 -7
  192. package/dist/sk-SK.main.js.map +0 -1
  193. package/dist/sk-SK.mjs +0 -9
  194. package/dist/sk-SK.module.js +0 -9
  195. package/dist/sk-SK.module.js.map +0 -1
  196. package/dist/sl-SI.main.js +0 -7
  197. package/dist/sl-SI.main.js.map +0 -1
  198. package/dist/sl-SI.mjs +0 -9
  199. package/dist/sl-SI.module.js +0 -9
  200. package/dist/sl-SI.module.js.map +0 -1
  201. package/dist/sr-SP.main.js +0 -7
  202. package/dist/sr-SP.main.js.map +0 -1
  203. package/dist/sr-SP.mjs +0 -9
  204. package/dist/sr-SP.module.js +0 -9
  205. package/dist/sr-SP.module.js.map +0 -1
  206. package/dist/sv-SE.main.js +0 -7
  207. package/dist/sv-SE.main.js.map +0 -1
  208. package/dist/sv-SE.mjs +0 -9
  209. package/dist/sv-SE.module.js +0 -9
  210. package/dist/sv-SE.module.js.map +0 -1
  211. package/dist/tr-TR.main.js +0 -7
  212. package/dist/tr-TR.main.js.map +0 -1
  213. package/dist/tr-TR.mjs +0 -9
  214. package/dist/tr-TR.module.js +0 -9
  215. package/dist/tr-TR.module.js.map +0 -1
  216. package/dist/types.d.ts +0 -194
  217. package/dist/types.d.ts.map +0 -1
  218. package/dist/uk-UA.main.js +0 -7
  219. package/dist/uk-UA.main.js.map +0 -1
  220. package/dist/uk-UA.mjs +0 -9
  221. package/dist/uk-UA.module.js +0 -9
  222. package/dist/uk-UA.module.js.map +0 -1
  223. package/dist/zh-CN.main.js +0 -7
  224. package/dist/zh-CN.main.js.map +0 -1
  225. package/dist/zh-CN.mjs +0 -9
  226. package/dist/zh-CN.module.js +0 -9
  227. package/dist/zh-CN.module.js.map +0 -1
  228. package/dist/zh-TW.main.js +0 -7
  229. package/dist/zh-TW.main.js.map +0 -1
  230. package/dist/zh-TW.mjs +0 -9
  231. package/dist/zh-TW.module.js +0 -9
  232. package/dist/zh-TW.module.js.map +0 -1
  233. package/src/BaseLayout.tsx +0 -290
  234. package/src/Card.tsx +0 -48
  235. package/src/CardBase.tsx +0 -188
  236. package/src/CardView.tsx +0 -250
  237. package/src/CardViewContext.tsx +0 -27
  238. package/src/GalleryLayout.tsx +0 -321
  239. package/src/GridLayout.tsx +0 -242
  240. package/src/WaterfallLayout.tsx +0 -241
package/dist/types.d.ts DELETED
@@ -1,194 +0,0 @@
1
- import { Direction, Key, KeyboardDelegate, Node, Orientation, DOMRef, DOMRefValue, ItemProps } from "@react-types/shared";
2
- import { GridCollection } from "@react-stately/grid";
3
- import { InvalidationContext, Layout, LayoutInfo, Rect, Size } from "@react-stately/virtualizer";
4
- import { Scale } from "@react-types/provider";
5
- import { ReactElement, ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from "react";
6
- import { SpectrumCardViewProps, SpectrumCardProps } from "@react-types/card";
7
- interface BaseLayoutOptions {
8
- collator?: Intl.Collator;
9
- scale?: Scale;
10
- /**
11
- * The margin around the grid view between the edges and the items.
12
- * @default 24
13
- */
14
- margin?: number;
15
- }
16
- interface CardViewLayoutOptions {
17
- isLoading: boolean;
18
- direction: Direction;
19
- }
20
- declare class BaseLayout<T> extends Layout<Node<T>, CardViewLayoutOptions> implements KeyboardDelegate {
21
- protected contentSize: Size;
22
- protected layoutInfos: Map<Key, LayoutInfo>;
23
- protected collator: Intl.Collator;
24
- protected lastCollection: GridCollection<T>;
25
- collection: GridCollection<T>;
26
- isLoading: boolean;
27
- disabledKeys: Set<Key>;
28
- direction: Direction;
29
- scale: Scale;
30
- margin: number;
31
- constructor(options?: BaseLayoutOptions);
32
- update(invalidationContext: InvalidationContext<CardViewLayoutOptions>): void;
33
- buildCollection(invalidationContext?: InvalidationContext): void;
34
- getContentSize(): number;
35
- getLayoutInfo(key: Key): LayoutInfo;
36
- getVisibleLayoutInfos(rect: Rect, excludePersistedKeys?: boolean): LayoutInfo[];
37
- isVisible(layoutInfo: LayoutInfo, rect: Rect, excludePersistedKeys: boolean): boolean;
38
- _findClosestLayoutInfo(target: Rect, rect: Rect): LayoutInfo | null;
39
- _findClosest(target: Rect, rect: Rect): LayoutInfo | null;
40
- getKeyBelow(key: Key): Node<T> | undefined;
41
- getKeyAbove(key: Key): Node<T> | undefined;
42
- getKeyRightOf(key: Key): Node<T> | undefined;
43
- getKeyLeftOf(key: Key): Node<T> | undefined;
44
- getFirstKey(): Node<T> | undefined;
45
- getLastKey(): Node<T> | undefined;
46
- getKeyPageAbove(key: Key): Node<T> | undefined;
47
- getKeyPageBelow(key: Key): Node<T> | undefined;
48
- getKeyForSearch(search: string, fromKey?: Key): Node<T> | undefined | null;
49
- }
50
- export interface GalleryLayoutOptions extends BaseLayoutOptions {
51
- /**
52
- * The the default row height. Note this must be larger than the min item height.
53
- * @default 208
54
- */
55
- idealRowHeight?: number;
56
- /**
57
- * The spacing between items.
58
- * @default 18 x 18
59
- */
60
- itemSpacing?: Size;
61
- /**
62
- * The vertical padding for an item.
63
- * @default 78
64
- */
65
- itemPadding?: number;
66
- /**
67
- * Minimum size for a item in the grid.
68
- * @default 136 x 136
69
- */
70
- minItemSize?: Size;
71
- /**
72
- * Target for adding extra weight to elements during linear partitioning. Anything with an aspect ratio smaler than this value
73
- * will be targeted.
74
- * @type {number}
75
- */
76
- threshold?: number;
77
- }
78
- export class GalleryLayout<T> extends BaseLayout<T> {
79
- protected idealRowHeight: number;
80
- protected itemSpacing: Size;
81
- itemPadding: number;
82
- protected minItemSize: Size;
83
- protected threshold: number;
84
- constructor(options?: GalleryLayoutOptions);
85
- get layoutType(): string;
86
- /**
87
- * Takes a row of widths and if there are any widths smaller than the min-width, leech width starting from
88
- * the widest in the row until it can't give anymore, then move to the second widest and so forth.
89
- * Do this until all assets meet the min-width.
90
- * */
91
- _distributeWidths(widths: number[]): boolean;
92
- buildCollection(): void;
93
- }
94
- export interface GridLayoutOptions extends BaseLayoutOptions {
95
- /**
96
- * The minimum item size.
97
- * @default 208 x 208 for horizontal card orientation. 102 x 102 for vertical card orientation.
98
- */
99
- minItemSize?: Size;
100
- /**
101
- * The maximum item size.
102
- * @default Infinity
103
- */
104
- maxItemSize?: Size;
105
- /**
106
- * The minimum space required between items.
107
- * @default 18 x 18
108
- */
109
- minSpace?: Size;
110
- /**
111
- * The maximum number of columns.
112
- * @default Infinity
113
- */
114
- maxColumns?: number;
115
- /**
116
- * The additional padding along the card's main axis. Affects the sizing of the content area following the card image.
117
- * @default 95
118
- */
119
- itemPadding?: number;
120
- /**
121
- * The orientation of the cards withn the grid.
122
- * @default vertical
123
- */
124
- cardOrientation?: Orientation;
125
- }
126
- export class GridLayout<T> extends BaseLayout<T> {
127
- protected minItemSize: Size;
128
- protected maxItemSize: Size;
129
- protected minSpace: Size;
130
- protected maxColumns: number;
131
- itemPadding: number;
132
- cardOrientation: Orientation;
133
- protected itemSize: Size;
134
- protected numColumns: number;
135
- protected numRows: number;
136
- protected horizontalSpacing: number;
137
- constructor(options?: GridLayoutOptions);
138
- get layoutType(): string;
139
- getIndexAtPoint(x: number, y: number, allowInsertingAtEnd?: boolean): number;
140
- buildCollection(): void;
141
- buildChild(node: Node<T>, y: number, index: number): LayoutInfo;
142
- getKeyBelow(key: Key): Node<T> | undefined | null;
143
- getKeyAbove(key: Key): Node<T> | undefined | null;
144
- }
145
- export interface WaterfallLayoutOptions extends BaseLayoutOptions {
146
- /**
147
- * The minimum item size.
148
- * @default 240 x 136
149
- */
150
- minItemSize?: Size;
151
- /**
152
- * The maximum item size.
153
- * @default Infinity
154
- */
155
- maxItemSize?: Size;
156
- /**
157
- * The minimum space required between items.
158
- * @default 18 x 18
159
- */
160
- minSpace?: Size;
161
- /**
162
- * The maximum number of columns.
163
- * @default Infinity
164
- */
165
- maxColumns?: number;
166
- }
167
- export class WaterfallLayout<T> extends BaseLayout<T> implements KeyboardDelegate {
168
- protected minItemSize: Size;
169
- protected maxItemSize: Size;
170
- protected minSpace: Size;
171
- protected maxColumns: number;
172
- protected numColumns: number;
173
- protected itemWidth: number;
174
- protected horizontalSpacing: number;
175
- constructor(options?: WaterfallLayoutOptions);
176
- get layoutType(): string;
177
- buildCollection(invalidationContext: InvalidationContext): void;
178
- updateItemSize(key: Key, size: Size): number;
179
- getNextColumnIndex(columnHeights: number[]): number;
180
- getClosestRight(key: Key): Node<T> | undefined;
181
- getClosestLeft(key: Key): Node<T> | undefined;
182
- getKeyRightOf(key: Key): Node<T> | undefined;
183
- getKeyLeftOf(key: Key): Node<T> | undefined;
184
- }
185
- /**
186
- * TODO: Add description of component here.
187
- */
188
- export const CardView: <T>(props: SpectrumCardViewProps<T> & {
189
- ref?: DOMRef<HTMLDivElement>;
190
- }) => ReactElement;
191
- export let Card: ForwardRefExoticComponent<ItemProps<SpectrumCardProps> & PropsWithoutRef<SpectrumCardProps> & RefAttributes<DOMRefValue<HTMLDivElement>>>;
192
- export type { SpectrumCardViewProps } from '@react-types/card';
193
-
194
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;AAmBA;IACE,QAAQ,CAAC,EAAE,KAAK,QAAQ,CAAC;IAEzB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd;;;OAGG;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,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,SAAS;IAM5C,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,SAAS;CAK5C;AGhND;;GAEG;AACH,OAAO,MAAM,UA8GP,CAAC,CAAC,EAAE,KAAK,EAAE,sBAAsB,CAAC,CAAC,GAAG;IAAC,GAAG,CAAC,EAAE,OAAO,cAAc,CAAC,CAAA;CAAC,KAAK,YAAY,CAAC;ACnG5F,OAAA,IAAI,MAAgB,0BAA0B,UAAU,iBAAiB,CAAC,GAAG,gBAAgB,iBAAiB,CAAC,GAAG,cAAc,YAAY,cAAc,CAAC,CAAC,CAAC,CAAC;ACvB9J,YAAY,EAAC,qBAAqB,EAAC,MAAM,mBAAmB,CAAC","sources":["packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/BaseLayout.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/GalleryLayout.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/GridLayout.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/WaterfallLayout.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/CardViewContext.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/CardBase.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/CardView.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/Card.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/index.ts","packages/@react-spectrum/card/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,"/*\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\n/// <reference types=\"css-module-types\" />\n\nexport type {GalleryLayoutOptions} from './GalleryLayout';\nexport type {GridLayoutOptions} from './GridLayout';\nexport type {WaterfallLayoutOptions} from './WaterfallLayout';\n\nexport {CardView} from './CardView';\nexport {GalleryLayout} from './GalleryLayout';\nexport {GridLayout} from './GridLayout';\nexport {WaterfallLayout} from './WaterfallLayout';\nexport {Card} from './Card';\nexport type {SpectrumCardViewProps} from '@react-types/card';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
@@ -1,7 +0,0 @@
1
- module.exports = {
2
- "loading": `\u{417}\u{430}\u{432}\u{430}\u{43D}\u{442}\u{430}\u{436}\u{435}\u{43D}\u{43D}\u{44F}\u{2026}`,
3
- "loadingMore": `\u{417}\u{430}\u{432}\u{430}\u{43D}\u{442}\u{430}\u{436}\u{435}\u{43D}\u{43D}\u{44F} \u{456}\u{43D}\u{448}\u{438}\u{445} \u{43E}\u{431}\u{2019}\u{454}\u{43A}\u{442}\u{456}\u{432}...`
4
- };
5
-
6
-
7
- //# sourceMappingURL=uk-UA.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":"AAAA,iBAAiB;IAAG,WAAW,CAAC,4FAAa,CAAC;IAC5C,eAAe,CAAC,qLAA8B,CAAC;AACjD","sources":["packages/@react-spectrum/card/intl/uk-UA.json"],"sourcesContent":["{\n \"loading\": \"Завантаження…\",\n \"loadingMore\": \"Завантаження інших об’єктів...\"\n}\n"],"names":[],"version":3,"file":"uk-UA.main.js.map"}
package/dist/uk-UA.mjs DELETED
@@ -1,9 +0,0 @@
1
- var $1b8fd2890c177825$exports = {};
2
- $1b8fd2890c177825$exports = {
3
- "loading": `\u{417}\u{430}\u{432}\u{430}\u{43D}\u{442}\u{430}\u{436}\u{435}\u{43D}\u{43D}\u{44F}\u{2026}`,
4
- "loadingMore": `\u{417}\u{430}\u{432}\u{430}\u{43D}\u{442}\u{430}\u{436}\u{435}\u{43D}\u{43D}\u{44F} \u{456}\u{43D}\u{448}\u{438}\u{445} \u{43E}\u{431}\u{2019}\u{454}\u{43A}\u{442}\u{456}\u{432}...`
5
- };
6
-
7
-
8
- export {$1b8fd2890c177825$exports as default};
9
- //# sourceMappingURL=uk-UA.module.js.map
@@ -1,9 +0,0 @@
1
- var $1b8fd2890c177825$exports = {};
2
- $1b8fd2890c177825$exports = {
3
- "loading": `\u{417}\u{430}\u{432}\u{430}\u{43D}\u{442}\u{430}\u{436}\u{435}\u{43D}\u{43D}\u{44F}\u{2026}`,
4
- "loadingMore": `\u{417}\u{430}\u{432}\u{430}\u{43D}\u{442}\u{430}\u{436}\u{435}\u{43D}\u{43D}\u{44F} \u{456}\u{43D}\u{448}\u{438}\u{445} \u{43E}\u{431}\u{2019}\u{454}\u{43A}\u{442}\u{456}\u{432}...`
5
- };
6
-
7
-
8
- export {$1b8fd2890c177825$exports as default};
9
- //# sourceMappingURL=uk-UA.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";AAAA,4BAAiB;IAAG,WAAW,CAAC,4FAAa,CAAC;IAC5C,eAAe,CAAC,qLAA8B,CAAC;AACjD","sources":["packages/@react-spectrum/card/intl/uk-UA.json"],"sourcesContent":["{\n \"loading\": \"Завантаження…\",\n \"loadingMore\": \"Завантаження інших об’єктів...\"\n}\n"],"names":[],"version":3,"file":"uk-UA.module.js.map"}
@@ -1,7 +0,0 @@
1
- module.exports = {
2
- "loading": `\u{6B63}\u{5728}\u{52A0}\u{8F7D}...`,
3
- "loadingMore": `\u{6B63}\u{5728}\u{52A0}\u{8F7D}\u{66F4}\u{591A}...`
4
- };
5
-
6
-
7
- //# sourceMappingURL=zh-CN.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":"AAAA,iBAAiB;IAAG,WAAW,CAAC,mCAAO,CAAC;IACtC,eAAe,CAAC,mDAAS,CAAC;AAC5B","sources":["packages/@react-spectrum/card/intl/zh-CN.json"],"sourcesContent":["{\n \"loading\": \"正在加载...\",\n \"loadingMore\": \"正在加载更多...\"\n}\n"],"names":[],"version":3,"file":"zh-CN.main.js.map"}
package/dist/zh-CN.mjs DELETED
@@ -1,9 +0,0 @@
1
- var $88c83d794a7a062b$exports = {};
2
- $88c83d794a7a062b$exports = {
3
- "loading": `\u{6B63}\u{5728}\u{52A0}\u{8F7D}...`,
4
- "loadingMore": `\u{6B63}\u{5728}\u{52A0}\u{8F7D}\u{66F4}\u{591A}...`
5
- };
6
-
7
-
8
- export {$88c83d794a7a062b$exports as default};
9
- //# sourceMappingURL=zh-CN.module.js.map
@@ -1,9 +0,0 @@
1
- var $88c83d794a7a062b$exports = {};
2
- $88c83d794a7a062b$exports = {
3
- "loading": `\u{6B63}\u{5728}\u{52A0}\u{8F7D}...`,
4
- "loadingMore": `\u{6B63}\u{5728}\u{52A0}\u{8F7D}\u{66F4}\u{591A}...`
5
- };
6
-
7
-
8
- export {$88c83d794a7a062b$exports as default};
9
- //# sourceMappingURL=zh-CN.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";AAAA,4BAAiB;IAAG,WAAW,CAAC,mCAAO,CAAC;IACtC,eAAe,CAAC,mDAAS,CAAC;AAC5B","sources":["packages/@react-spectrum/card/intl/zh-CN.json"],"sourcesContent":["{\n \"loading\": \"正在加载...\",\n \"loadingMore\": \"正在加载更多...\"\n}\n"],"names":[],"version":3,"file":"zh-CN.module.js.map"}
@@ -1,7 +0,0 @@
1
- module.exports = {
2
- "loading": `\u{8F09}\u{5165}\u{4E2D}\u{2026}`,
3
- "loadingMore": `\u{6B63}\u{5728}\u{8F09}\u{5165}\u{66F4}\u{591A}\u{2026}`
4
- };
5
-
6
-
7
- //# sourceMappingURL=zh-TW.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":"AAAA,iBAAiB;IAAG,WAAW,CAAC,gCAAI,CAAC;IACnC,eAAe,CAAC,wDAAO,CAAC;AAC1B","sources":["packages/@react-spectrum/card/intl/zh-TW.json"],"sourcesContent":["{\n \"loading\": \"載入中…\",\n \"loadingMore\": \"正在載入更多…\"\n}\n"],"names":[],"version":3,"file":"zh-TW.main.js.map"}
package/dist/zh-TW.mjs DELETED
@@ -1,9 +0,0 @@
1
- var $b7e2865acb74a940$exports = {};
2
- $b7e2865acb74a940$exports = {
3
- "loading": `\u{8F09}\u{5165}\u{4E2D}\u{2026}`,
4
- "loadingMore": `\u{6B63}\u{5728}\u{8F09}\u{5165}\u{66F4}\u{591A}\u{2026}`
5
- };
6
-
7
-
8
- export {$b7e2865acb74a940$exports as default};
9
- //# sourceMappingURL=zh-TW.module.js.map
@@ -1,9 +0,0 @@
1
- var $b7e2865acb74a940$exports = {};
2
- $b7e2865acb74a940$exports = {
3
- "loading": `\u{8F09}\u{5165}\u{4E2D}\u{2026}`,
4
- "loadingMore": `\u{6B63}\u{5728}\u{8F09}\u{5165}\u{66F4}\u{591A}\u{2026}`
5
- };
6
-
7
-
8
- export {$b7e2865acb74a940$exports as default};
9
- //# sourceMappingURL=zh-TW.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";AAAA,4BAAiB;IAAG,WAAW,CAAC,gCAAI,CAAC;IACnC,eAAe,CAAC,wDAAO,CAAC;AAC1B","sources":["packages/@react-spectrum/card/intl/zh-TW.json"],"sourcesContent":["{\n \"loading\": \"載入中…\",\n \"loadingMore\": \"正在載入更多…\"\n}\n"],"names":[],"version":3,"file":"zh-TW.module.js.map"}
@@ -1,290 +0,0 @@
1
- // @ts-nocheck
2
- /*
3
- * Copyright 2021 Adobe. All rights reserved.
4
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License. You may obtain a copy
6
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
7
- *
8
- * Unless required by applicable law or agreed to in writing, software distributed under
9
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
10
- * OF ANY KIND, either express or implied. See the License for the specific language
11
- * governing permissions and limitations under the License.
12
- */
13
-
14
- import {Direction, Key, KeyboardDelegate, Node} from '@react-types/shared';
15
- import {getChildNodes, getFirstItem} from '@react-stately/collections';
16
- import {GridCollection} from '@react-stately/grid';
17
- import {InvalidationContext, Layout, LayoutInfo, Rect, Size} from '@react-stately/virtualizer';
18
- import {Scale} from '@react-types/provider';
19
-
20
- export interface BaseLayoutOptions {
21
- collator?: Intl.Collator,
22
- // TODO: is this valid or is scale a spectrum specific thing that should be left out of the layouts?
23
- scale?: Scale,
24
- /**
25
- * The margin around the grid view between the edges and the items.
26
- * @default 24
27
- */
28
- margin?: number
29
- }
30
-
31
- interface CardViewLayoutOptions {
32
- isLoading: boolean,
33
- direction: Direction
34
- }
35
-
36
- export class BaseLayout<T> extends Layout<Node<T>, CardViewLayoutOptions> implements KeyboardDelegate {
37
- protected contentSize: Size;
38
- protected layoutInfos: Map<Key, LayoutInfo>;
39
- protected collator: Intl.Collator;
40
- protected lastCollection: GridCollection<T>;
41
- collection: GridCollection<T>;
42
- isLoading: boolean;
43
- disabledKeys: Set<Key> = new Set();
44
- direction: Direction;
45
- scale: Scale;
46
- margin: number;
47
-
48
- constructor(options: BaseLayoutOptions = {}) {
49
- super();
50
- this.layoutInfos = new Map();
51
- this.collator = options.collator;
52
- this.lastCollection = null;
53
- this.scale = options.scale || 'medium';
54
- this.margin = options.margin || 24;
55
- }
56
-
57
- update(invalidationContext: InvalidationContext<CardViewLayoutOptions>): void {
58
- this.collection = this.virtualizer.collection as GridCollection<T>;
59
- this.isLoading = invalidationContext.layoutOptions?.isLoading || false;
60
- this.direction = invalidationContext.layoutOptions?.direction || 'ltr';
61
- this.buildCollection(invalidationContext);
62
-
63
- // Remove layout info that doesn't exist in new collection
64
- if (this.lastCollection) {
65
- for (let key of this.lastCollection.getKeys()) {
66
- if (!this.collection.getItem(key)) {
67
- this.layoutInfos.delete(key);
68
- }
69
- }
70
-
71
- if (!this.isLoading) {
72
- this.layoutInfos.delete('loader');
73
- }
74
-
75
- if (this.collection.size > 0) {
76
- this.layoutInfos.delete('placeholder');
77
- }
78
- }
79
-
80
- this.lastCollection = this.collection;
81
- }
82
-
83
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
84
- buildCollection(invalidationContext?: InvalidationContext): void {}
85
-
86
- getContentSize(): number {
87
- return this.contentSize;
88
- }
89
-
90
- getLayoutInfo(key: Key): LayoutInfo {
91
- return this.layoutInfos.get(key)!;
92
- }
93
-
94
- getVisibleLayoutInfos(rect: Rect, excludePersistedKeys = false): LayoutInfo[] {
95
- let res: LayoutInfo[] = [];
96
-
97
- for (let layoutInfo of this.layoutInfos.values()) {
98
- if (this.isVisible(layoutInfo, rect, excludePersistedKeys)) {
99
- res.push(layoutInfo);
100
- }
101
- }
102
-
103
- return res;
104
- }
105
-
106
- isVisible(layoutInfo: LayoutInfo, rect: Rect, excludePersistedKeys: boolean): boolean {
107
- if (layoutInfo.rect.intersects(rect)) {
108
- return true;
109
- }
110
-
111
- if (!excludePersistedKeys) {
112
- return this.virtualizer.isPersistedKey(layoutInfo.key);
113
- }
114
-
115
- return false;
116
- }
117
-
118
- _findClosestLayoutInfo(target: Rect, rect: Rect): LayoutInfo | null {
119
- let layoutInfos = this.getVisibleLayoutInfos(rect, true);
120
- let best = null;
121
- let bestDistance = Infinity;
122
-
123
- // Calculates distance as the distance between the center of 2 rects.
124
- for (let cur of layoutInfos) {
125
- if (cur.type === 'item') {
126
- let curRect = cur.rect;
127
- let targetMidX = (target.x + target.maxX) / 2;
128
- let targetMidY = (target.y + target.maxY) / 2;
129
- let curMidX = (curRect.x + curRect.maxX) / 2;
130
- let curMidY = (curRect.y + curRect.maxY) / 2;
131
- let dist = Math.pow(targetMidX - curMidX, 2) + Math.pow(targetMidY - curMidY, 2);
132
- if (dist < bestDistance) {
133
- best = cur;
134
- bestDistance = dist;
135
- }
136
- }
137
- }
138
-
139
- return best;
140
- }
141
-
142
- _findClosest(target: Rect, rect: Rect): LayoutInfo | null {
143
- let best = this._findClosestLayoutInfo(target, rect);
144
- return best || null;
145
- }
146
-
147
- getKeyBelow(key: Key): Node<T> | undefined {
148
- // Expected key is the currently focused cell so we need the parent row key
149
- let parentRowKey = this.collection.getItem(key).parentKey;
150
- let layoutInfo = this.getLayoutInfo(parentRowKey);
151
- let rect = new Rect(layoutInfo.rect.x, layoutInfo.rect.maxY + 1, layoutInfo.rect.width, this.virtualizer.visibleRect.height);
152
- let closestRow = this.collection.getItem(this._findClosest(layoutInfo.rect, rect)?.key);
153
- return getFirstItem(getChildNodes(closestRow, this.collection))?.key;
154
- }
155
-
156
- getKeyAbove(key: Key): Node<T> | undefined {
157
- // Expected key is the currently focused cell so we need the parent row key
158
- let parentRowKey = this.collection.getItem(key).parentKey;
159
- let layoutInfo = this.getLayoutInfo(parentRowKey);
160
- let rect = new Rect(layoutInfo.rect.x, 0, layoutInfo.rect.width, layoutInfo.rect.y - 1);
161
- let closestRow = this.collection.getItem(this._findClosest(layoutInfo.rect, rect)?.key);
162
- return getFirstItem(getChildNodes(closestRow, this.collection))?.key;
163
- }
164
-
165
- getKeyRightOf(key: Key): Node<T> | undefined {
166
- // Expected key is the currently focused cell so we need the parent row key
167
- let parentRowKey = this.collection.getItem(key).parentKey;
168
- key = this.direction === 'rtl' ? this.collection.getKeyBefore(parentRowKey) : this.collection.getKeyAfter(parentRowKey);
169
-
170
- while (key != null) {
171
- let item = this.collection.getItem(key);
172
- // Don't check if item is disabled because we want to be able to focus disabled items in a grid (double check this)
173
- if (item.type === 'item') {
174
- return getFirstItem(getChildNodes(item, this.collection))?.key;
175
- }
176
- key = this.direction === 'rtl' ? this.collection.getKeyBefore(key) : this.collection.getKeyAfter(key);
177
- }
178
- }
179
-
180
- getKeyLeftOf(key: Key): Node<T> | undefined {
181
- // Expected key is the currently focused cell so we need the parent row key
182
- let parentRowKey = this.collection.getItem(key).parentKey;
183
- key = this.direction === 'rtl' ? this.collection.getKeyAfter(parentRowKey) : this.collection.getKeyBefore(parentRowKey);
184
- while (key != null) {
185
- let item = this.collection.getItem(key);
186
- // Don't check if item is disabled because we want to be able to focus disabled items in a grid (double check this)
187
- if (item.type === 'item') {
188
- return getFirstItem(getChildNodes(item, this.collection))?.key;
189
- }
190
-
191
- key = this.direction === 'rtl' ? this.collection.getKeyAfter(key) : this.collection.getKeyBefore(key);
192
- }
193
- }
194
-
195
- getFirstKey(): Node<T> | undefined {
196
- let firstRow = this.collection.getItem(this.collection.getFirstKey());
197
- return getFirstItem(getChildNodes(firstRow, this.collection))?.key;
198
- }
199
-
200
- getLastKey(): Node<T> | undefined {
201
- let lastRow = this.collection.getItem(this.collection.getLastKey());
202
- return getFirstItem(getChildNodes(lastRow, this.collection))?.key;
203
- }
204
-
205
- // TODO: pretty unwieldy because it needs to bounce back and forth between the parent key and the child key
206
- // Perhaps have layoutInfo store childKey as well so we don't need to do this? Or maybe make the layoutInfos be the cells instead of the rows?
207
- getKeyPageAbove(key: Key): Node<T> | undefined {
208
- // Expected key is the currently focused cell so we need the parent row key
209
- let parentRowKey = this.collection.getItem(key).parentKey;
210
- let layoutInfo = this.getLayoutInfo(parentRowKey);
211
-
212
- if (layoutInfo) {
213
- let pageY = Math.max(0, layoutInfo.rect.y + layoutInfo.rect.height - this.virtualizer.visibleRect.height);
214
- // If the node is so large that it spans multiple page heights, return the key of the item immediately above
215
- // Otherwise keep going up until we exceed a single page height worth of nodes
216
- let keyAbove = this.collection.getItem(this.getKeyAbove(key))?.parentKey;
217
- layoutInfo = this.getLayoutInfo(keyAbove);
218
-
219
- if (layoutInfo && layoutInfo.rect.y > pageY) {
220
- while (layoutInfo && layoutInfo.rect.y > pageY) {
221
- let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;
222
- let keyAbove = this.collection.getItem(this.getKeyAbove(childKey))?.parentKey;
223
- layoutInfo = this.getLayoutInfo(keyAbove);
224
- }
225
- }
226
-
227
- if (layoutInfo) {
228
- let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;
229
- return childKey;
230
- }
231
- }
232
-
233
- return this.getFirstKey();
234
- }
235
-
236
- // TODO: pretty unwieldy because it needs to bounce back and forth between the parent key and the child key
237
- // Perhaps have layoutInfo store childKey as well so we don't need to do this?
238
- getKeyPageBelow(key: Key): Node<T> | undefined {
239
- // Expected key is the currently focused cell so we need the parent row key
240
- let parentRowKey = this.collection.getItem(key).parentKey;
241
- let layoutInfo = this.getLayoutInfo(parentRowKey);
242
- if (layoutInfo) {
243
- let pageY = Math.min(this.virtualizer.contentSize.height, layoutInfo.rect.y - layoutInfo.rect.height + this.virtualizer.visibleRect.height);
244
- // If the node is so large that it spans multiple page heights, return the key of the item immediately below
245
- // Otherwise keep going up until we exceed a single page height worth of nodes
246
- let keyBelow = this.collection.getItem(this.getKeyBelow(key))?.parentKey;
247
- layoutInfo = this.getLayoutInfo(keyBelow);
248
- if (layoutInfo && layoutInfo.rect.y < pageY) {
249
- while (layoutInfo && layoutInfo.rect.y < pageY) {
250
- let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;
251
- let keyBelow = this.collection.getItem(this.getKeyBelow(childKey))?.parentKey;
252
- layoutInfo = this.getLayoutInfo(keyBelow);
253
- }
254
- }
255
-
256
- if (layoutInfo) {
257
- let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;
258
- return childKey;
259
- }
260
- }
261
-
262
- return this.getLastKey();
263
- }
264
-
265
- getKeyForSearch(search: string, fromKey?: Key): Node<T> | undefined | null {
266
- if (!this.collator) {
267
- return null;
268
- }
269
-
270
- let collection = this.collection;
271
- let key = fromKey ?? this.getFirstKey();
272
-
273
- let startItem = collection.getItem(key);
274
- key = startItem.parentKey;
275
-
276
- while (key != null) {
277
- let item = collection.getItem(key);
278
- if (item.textValue) {
279
- let substring = item.textValue.slice(0, search.length);
280
- if (this.collator.compare(substring, search) === 0) {
281
- return getFirstItem(getChildNodes(item, this.collection))?.key;
282
- }
283
- }
284
-
285
- key = this.collection.getKeyAfter(key);
286
- }
287
-
288
- return null;
289
- }
290
- }
package/src/Card.tsx DELETED
@@ -1,48 +0,0 @@
1
- // @ts-nocheck
2
- /*
3
- * Copyright 2021 Adobe. All rights reserved.
4
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License. You may obtain a copy
6
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
7
- *
8
- * Unless required by applicable law or agreed to in writing, software distributed under
9
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
10
- * OF ANY KIND, either express or implied. See the License for the specific language
11
- * governing permissions and limitations under the License.
12
- */
13
-
14
- import {CardBase} from './CardBase';
15
- import {DOMRef, DOMRefValue, ItemProps} from '@react-types/shared';
16
- import {PartialNode} from '@react-stately/collections';
17
- import React, {forwardRef, ForwardRefExoticComponent, PropsWithoutRef, RefAttributes} from 'react';
18
- import {SpectrumCardProps} from '@react-types/card';
19
- import {useCardViewContext} from './CardViewContext';
20
-
21
-
22
- let Card = forwardRef((props: SpectrumCardProps, ref: DOMRef<HTMLDivElement>) => {
23
- let context = useCardViewContext();
24
- if (context !== null) {
25
- return null;
26
- } else {
27
- return (
28
- <CardBase {...props} ref={ref} />
29
- );
30
- }
31
- });
32
-
33
- // @ts-ignore
34
- Card.getCollectionNode = function* getCollectionNode<T>(props: any): Generator<PartialNode<T>> {
35
- let {children, textValue} = props;
36
-
37
- yield {
38
- type: 'item',
39
- props: props,
40
- rendered: children,
41
- 'aria-label': props['aria-label'],
42
- hasChildNodes: false,
43
- textValue
44
- };
45
- };
46
-
47
- let _Card = Card as ForwardRefExoticComponent<ItemProps<SpectrumCardProps> & PropsWithoutRef<SpectrumCardProps> & RefAttributes<DOMRefValue<HTMLDivElement>>>;
48
- export {_Card as Card};