@ringcentral/juno 2.40.0 → 2.41.0

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 (183) hide show
  1. package/components/Downshift/SuggestionList/SuggestionList.d.ts +3 -3
  2. package/components/Downshift/utils/useDownshift.d.ts +1 -1
  3. package/components/Tooltip/Tooltip.js +20 -2
  4. package/components/Virtuoso/index.d.ts +1 -1
  5. package/components/Virtuoso/index.js +1 -1
  6. package/components/Virtuoso/react-virtuoso/AATree.d.ts +1 -1
  7. package/components/Virtuoso/react-virtuoso/AATree.js +60 -48
  8. package/components/Virtuoso/react-virtuoso/TableVirtuoso.d.ts +5 -0
  9. package/components/Virtuoso/react-virtuoso/TableVirtuoso.js +217 -0
  10. package/components/Virtuoso/react-virtuoso/Virtuoso.d.ts +7696 -0
  11. package/components/Virtuoso/react-virtuoso/Virtuoso.js +317 -0
  12. package/components/Virtuoso/react-virtuoso/{Grid.d.ts → VirtuosoGrid.d.ts} +170 -72
  13. package/components/Virtuoso/react-virtuoso/VirtuosoGrid.js +199 -0
  14. package/components/Virtuoso/react-virtuoso/alignToBottomSystem.d.ts +119 -65
  15. package/components/Virtuoso/react-virtuoso/alignToBottomSystem.js +3 -3
  16. package/components/Virtuoso/react-virtuoso/comparators.d.ts +1 -1
  17. package/components/Virtuoso/react-virtuoso/comparators.js +1 -3
  18. package/components/Virtuoso/react-virtuoso/component-interfaces/TableVirtuoso.d.ts +194 -0
  19. package/components/Virtuoso/react-virtuoso/component-interfaces/TableVirtuoso.js +2 -0
  20. package/components/Virtuoso/react-virtuoso/component-interfaces/Virtuoso.d.ts +274 -0
  21. package/components/Virtuoso/react-virtuoso/component-interfaces/Virtuoso.js +2 -0
  22. package/components/Virtuoso/react-virtuoso/component-interfaces/VirtuosoGrid.d.ts +125 -0
  23. package/components/Virtuoso/react-virtuoso/component-interfaces/VirtuosoGrid.js +2 -0
  24. package/components/Virtuoso/react-virtuoso/domIOSystem.d.ts +3 -2
  25. package/components/Virtuoso/react-virtuoso/domIOSystem.js +5 -3
  26. package/components/Virtuoso/react-virtuoso/followOutputSystem.d.ts +80 -43
  27. package/components/Virtuoso/react-virtuoso/followOutputSystem.js +21 -19
  28. package/components/Virtuoso/react-virtuoso/gridSystem.d.ts +57 -31
  29. package/components/Virtuoso/react-virtuoso/gridSystem.js +173 -86
  30. package/components/Virtuoso/react-virtuoso/groupedListSystem.d.ts +76 -67
  31. package/components/Virtuoso/react-virtuoso/groupedListSystem.js +12 -12
  32. package/components/Virtuoso/react-virtuoso/hooks/useChangedChildSizes.d.ts +6 -3
  33. package/components/Virtuoso/react-virtuoso/hooks/useChangedChildSizes.js +36 -17
  34. package/components/Virtuoso/react-virtuoso/hooks/useIsomorphicLayoutEffect.d.ts +2 -2
  35. package/components/Virtuoso/react-virtuoso/hooks/useIsomorphicLayoutEffect.js +3 -2
  36. package/components/Virtuoso/react-virtuoso/hooks/useRcPortalWindowContext.d.ts +2 -0
  37. package/components/Virtuoso/react-virtuoso/hooks/useRcPortalWindowContext.js +5 -0
  38. package/components/Virtuoso/react-virtuoso/hooks/useScrollTop.d.ts +2 -3
  39. package/components/Virtuoso/react-virtuoso/hooks/useScrollTop.js +36 -51
  40. package/components/Virtuoso/react-virtuoso/hooks/useSize.d.ts +2 -3
  41. package/components/Virtuoso/react-virtuoso/hooks/useSize.js +13 -13
  42. package/components/Virtuoso/react-virtuoso/hooks/useWindowViewportRect.js +17 -15
  43. package/components/Virtuoso/react-virtuoso/index.d.ts +7 -1
  44. package/components/Virtuoso/react-virtuoso/index.js +8 -1
  45. package/components/Virtuoso/react-virtuoso/initialItemCountSystem.d.ts +304 -68
  46. package/components/Virtuoso/react-virtuoso/initialItemCountSystem.js +9 -31
  47. package/components/Virtuoso/react-virtuoso/initialScrollTopSystem.d.ts +127 -109
  48. package/components/Virtuoso/react-virtuoso/initialScrollTopSystem.js +7 -7
  49. package/components/Virtuoso/react-virtuoso/initialTopMostItemIndexSystem.d.ts +38 -22
  50. package/components/Virtuoso/react-virtuoso/initialTopMostItemIndexSystem.js +13 -20
  51. package/components/Virtuoso/react-virtuoso/interfaces.d.ts +150 -51
  52. package/components/Virtuoso/react-virtuoso/listStateSystem.d.ts +109 -59
  53. package/components/Virtuoso/react-virtuoso/listStateSystem.js +100 -52
  54. package/components/Virtuoso/react-virtuoso/listSystem.d.ts +1691 -693
  55. package/components/Virtuoso/react-virtuoso/listSystem.js +15 -16
  56. package/components/Virtuoso/react-virtuoso/loggerSystem.d.ts +1 -1
  57. package/components/Virtuoso/react-virtuoso/loggerSystem.js +2 -4
  58. package/components/Virtuoso/react-virtuoso/propsReadySystem.d.ts +1 -1
  59. package/components/Virtuoso/react-virtuoso/propsReadySystem.js +3 -4
  60. package/components/Virtuoso/react-virtuoso/react-urx/index.d.ts +110 -0
  61. package/components/Virtuoso/react-virtuoso/react-urx/index.js +200 -0
  62. package/components/Virtuoso/react-virtuoso/react-urx/package.json +5 -0
  63. package/components/Virtuoso/react-virtuoso/recalcSystem.d.ts +4 -0
  64. package/components/Virtuoso/react-virtuoso/recalcSystem.js +8 -0
  65. package/components/Virtuoso/react-virtuoso/scrollIntoViewSystem.d.ts +144 -78
  66. package/components/Virtuoso/react-virtuoso/scrollIntoViewSystem.js +33 -21
  67. package/components/Virtuoso/react-virtuoso/scrollSeekSystem.d.ts +12 -7
  68. package/components/Virtuoso/react-virtuoso/scrollSeekSystem.js +7 -10
  69. package/components/Virtuoso/react-virtuoso/scrollToIndexSystem.d.ts +19 -11
  70. package/components/Virtuoso/react-virtuoso/scrollToIndexSystem.js +11 -23
  71. package/components/Virtuoso/react-virtuoso/sizeRangeSystem.d.ts +7 -6
  72. package/components/Virtuoso/react-virtuoso/sizeRangeSystem.js +15 -27
  73. package/components/Virtuoso/react-virtuoso/sizeSystem.d.ts +20 -11
  74. package/components/Virtuoso/react-virtuoso/sizeSystem.js +182 -52
  75. package/components/Virtuoso/react-virtuoso/stateFlagsSystem.d.ts +8 -5
  76. package/components/Virtuoso/react-virtuoso/stateFlagsSystem.js +32 -23
  77. package/components/Virtuoso/react-virtuoso/stateLoadSystem.d.ts +318 -0
  78. package/components/Virtuoso/react-virtuoso/stateLoadSystem.js +41 -0
  79. package/components/Virtuoso/react-virtuoso/topItemCountSystem.d.ts +518 -467
  80. package/components/Virtuoso/react-virtuoso/topItemCountSystem.js +5 -5
  81. package/components/Virtuoso/react-virtuoso/totalListHeightSystem.d.ts +115 -63
  82. package/components/Virtuoso/react-virtuoso/totalListHeightSystem.js +6 -13
  83. package/components/Virtuoso/react-virtuoso/upwardScrollFixSystem.d.ts +139 -73
  84. package/components/Virtuoso/react-virtuoso/upwardScrollFixSystem.js +74 -31
  85. package/components/Virtuoso/react-virtuoso/urx/actions.d.ts +127 -0
  86. package/components/Virtuoso/react-virtuoso/urx/actions.js +98 -0
  87. package/components/Virtuoso/react-virtuoso/urx/constants.d.ts +8 -0
  88. package/components/Virtuoso/react-virtuoso/urx/constants.js +6 -0
  89. package/components/Virtuoso/react-virtuoso/urx/index.d.ts +6 -0
  90. package/components/Virtuoso/react-virtuoso/urx/index.js +9 -0
  91. package/components/Virtuoso/react-virtuoso/urx/package.json +5 -0
  92. package/components/Virtuoso/react-virtuoso/urx/pipe.d.ts +220 -0
  93. package/components/Virtuoso/react-virtuoso/urx/pipe.js +279 -0
  94. package/components/Virtuoso/react-virtuoso/urx/streams.d.ts +143 -0
  95. package/components/Virtuoso/react-virtuoso/urx/streams.js +227 -0
  96. package/components/Virtuoso/react-virtuoso/urx/system.d.ts +148 -0
  97. package/components/Virtuoso/react-virtuoso/urx/system.js +106 -0
  98. package/components/Virtuoso/react-virtuoso/urx/transformers.d.ts +71 -0
  99. package/components/Virtuoso/react-virtuoso/urx/transformers.js +106 -0
  100. package/components/Virtuoso/react-virtuoso/urx/utils.d.ts +57 -0
  101. package/components/Virtuoso/react-virtuoso/urx/utils.js +102 -0
  102. package/components/Virtuoso/react-virtuoso/utils/approximatelyEqual.d.ts +1 -0
  103. package/components/Virtuoso/react-virtuoso/utils/approximatelyEqual.js +6 -0
  104. package/components/Virtuoso/react-virtuoso/utils/context.d.ts +13 -0
  105. package/components/Virtuoso/react-virtuoso/utils/context.js +6 -0
  106. package/components/Virtuoso/react-virtuoso/utils/skipFrames.d.ts +1 -0
  107. package/components/Virtuoso/react-virtuoso/utils/skipFrames.js +11 -0
  108. package/components/Virtuoso/react-virtuoso/windowScrollerSystem.d.ts +6 -4
  109. package/components/Virtuoso/react-virtuoso/windowScrollerSystem.js +1 -1
  110. package/components/Virtuoso/utils/isOutOfRange.d.ts +1 -1
  111. package/components/Virtuoso/utils/useHighlightScroll.d.ts +2 -2
  112. package/es6/components/Tooltip/Tooltip.js +21 -3
  113. package/es6/components/Virtuoso/index.js +1 -1
  114. package/es6/components/Virtuoso/react-virtuoso/AATree.js +60 -48
  115. package/es6/components/Virtuoso/react-virtuoso/{Table.js → TableVirtuoso.js} +73 -52
  116. package/es6/components/Virtuoso/react-virtuoso/{List.js → Virtuoso.js} +85 -161
  117. package/es6/components/Virtuoso/react-virtuoso/VirtuosoGrid.js +198 -0
  118. package/es6/components/Virtuoso/react-virtuoso/alignToBottomSystem.js +3 -3
  119. package/es6/components/Virtuoso/react-virtuoso/comparators.js +1 -3
  120. package/es6/components/Virtuoso/react-virtuoso/component-interfaces/TableVirtuoso.js +0 -0
  121. package/es6/components/Virtuoso/react-virtuoso/component-interfaces/Virtuoso.js +0 -0
  122. package/es6/components/Virtuoso/react-virtuoso/component-interfaces/VirtuosoGrid.js +0 -0
  123. package/es6/components/Virtuoso/react-virtuoso/domIOSystem.js +5 -3
  124. package/es6/components/Virtuoso/react-virtuoso/followOutputSystem.js +21 -19
  125. package/es6/components/Virtuoso/react-virtuoso/gridSystem.js +173 -87
  126. package/es6/components/Virtuoso/react-virtuoso/groupedListSystem.js +13 -13
  127. package/es6/components/Virtuoso/react-virtuoso/hooks/useChangedChildSizes.js +35 -16
  128. package/es6/components/Virtuoso/react-virtuoso/hooks/useIsomorphicLayoutEffect.js +2 -2
  129. package/es6/components/Virtuoso/react-virtuoso/hooks/useRcPortalWindowContext.js +2 -0
  130. package/es6/components/Virtuoso/react-virtuoso/hooks/useScrollTop.js +35 -50
  131. package/es6/components/Virtuoso/react-virtuoso/hooks/useSize.js +11 -12
  132. package/es6/components/Virtuoso/react-virtuoso/hooks/useWindowViewportRect.js +15 -14
  133. package/es6/components/Virtuoso/react-virtuoso/index.js +4 -1
  134. package/es6/components/Virtuoso/react-virtuoso/initialItemCountSystem.js +11 -33
  135. package/es6/components/Virtuoso/react-virtuoso/initialScrollTopSystem.js +7 -7
  136. package/es6/components/Virtuoso/react-virtuoso/initialTopMostItemIndexSystem.js +13 -20
  137. package/es6/components/Virtuoso/react-virtuoso/listStateSystem.js +101 -54
  138. package/es6/components/Virtuoso/react-virtuoso/listSystem.js +15 -16
  139. package/es6/components/Virtuoso/react-virtuoso/loggerSystem.js +2 -4
  140. package/es6/components/Virtuoso/react-virtuoso/propsReadySystem.js +3 -4
  141. package/es6/components/Virtuoso/react-virtuoso/react-urx/index.js +197 -0
  142. package/es6/components/Virtuoso/react-virtuoso/recalcSystem.js +5 -0
  143. package/es6/components/Virtuoso/react-virtuoso/scrollIntoViewSystem.js +34 -22
  144. package/es6/components/Virtuoso/react-virtuoso/scrollSeekSystem.js +7 -10
  145. package/es6/components/Virtuoso/react-virtuoso/scrollToIndexSystem.js +11 -23
  146. package/es6/components/Virtuoso/react-virtuoso/sizeRangeSystem.js +16 -28
  147. package/es6/components/Virtuoso/react-virtuoso/sizeSystem.js +180 -53
  148. package/es6/components/Virtuoso/react-virtuoso/stateFlagsSystem.js +32 -23
  149. package/es6/components/Virtuoso/react-virtuoso/stateLoadSystem.js +39 -0
  150. package/es6/components/Virtuoso/react-virtuoso/topItemCountSystem.js +5 -5
  151. package/es6/components/Virtuoso/react-virtuoso/totalListHeightSystem.js +6 -13
  152. package/es6/components/Virtuoso/react-virtuoso/upwardScrollFixSystem.js +75 -32
  153. package/es6/components/Virtuoso/react-virtuoso/urx/actions.js +90 -0
  154. package/es6/components/Virtuoso/react-virtuoso/urx/constants.js +4 -0
  155. package/es6/components/Virtuoso/react-virtuoso/urx/index.js +6 -0
  156. package/es6/components/Virtuoso/react-virtuoso/urx/pipe.js +266 -0
  157. package/es6/components/Virtuoso/react-virtuoso/urx/streams.js +220 -0
  158. package/es6/components/Virtuoso/react-virtuoso/urx/system.js +102 -0
  159. package/es6/components/Virtuoso/react-virtuoso/urx/transformers.js +101 -0
  160. package/es6/components/Virtuoso/react-virtuoso/urx/utils.js +88 -0
  161. package/es6/components/Virtuoso/react-virtuoso/utils/approximatelyEqual.js +3 -0
  162. package/es6/components/Virtuoso/react-virtuoso/utils/context.js +3 -0
  163. package/es6/components/Virtuoso/react-virtuoso/utils/skipFrames.js +8 -0
  164. package/es6/components/Virtuoso/react-virtuoso/windowScrollerSystem.js +1 -1
  165. package/es6/foundation/hooks/useForkRef/useForkRef.js +2 -1
  166. package/foundation/hooks/useForkRef/useForkRef.d.ts +2 -1
  167. package/foundation/hooks/useForkRef/useForkRef.js +1 -0
  168. package/package.json +2 -2
  169. package/components/Virtuoso/Virtuoso.d.ts +0 -1
  170. package/components/Virtuoso/Virtuoso.js +0 -4
  171. package/components/Virtuoso/react-virtuoso/Grid.js +0 -168
  172. package/components/Virtuoso/react-virtuoso/List.d.ts +0 -6749
  173. package/components/Virtuoso/react-virtuoso/List.js +0 -393
  174. package/components/Virtuoso/react-virtuoso/Table.d.ts +0 -6515
  175. package/components/Virtuoso/react-virtuoso/Table.js +0 -196
  176. package/components/Virtuoso/react-virtuoso/components.d.ts +0 -505
  177. package/components/Virtuoso/react-virtuoso/components.js +0 -9
  178. package/components/Virtuoso/react-virtuoso/utils/conditionalFlushSync.d.ts +0 -1
  179. package/components/Virtuoso/react-virtuoso/utils/conditionalFlushSync.js +0 -11
  180. package/es6/components/Virtuoso/Virtuoso.js +0 -1
  181. package/es6/components/Virtuoso/react-virtuoso/Grid.js +0 -166
  182. package/es6/components/Virtuoso/react-virtuoso/components.js +0 -7
  183. package/es6/components/Virtuoso/react-virtuoso/utils/conditionalFlushSync.js +0 -8
@@ -1,51 +1,55 @@
1
- import { ComponentPropsWithRef, ComponentType, Key, ReactNode } from 'react';
1
+ import React from 'react';
2
2
  export interface ListRange {
3
3
  startIndex: number;
4
4
  endIndex: number;
5
5
  }
6
6
  export interface ItemContent<D, C> {
7
- (index: number, data: D, context: C): ReactNode;
7
+ (index: number, data: D, context: C): React.ReactNode;
8
8
  }
9
9
  export declare type FixedHeaderContent = (() => React.ReactNode) | null;
10
+ export declare type FixedFooterContent = (() => React.ReactNode) | null;
10
11
  export interface GroupItemContent<D, C> {
11
- (index: number, groupIndex: number, data: D, context: C): ReactNode;
12
+ (index: number, groupIndex: number, data: D, context: C): React.ReactNode;
12
13
  }
13
- export interface GroupContent {
14
- (index: number): ReactNode;
14
+ export interface GroupContent<C> {
15
+ (index: number, context: C): React.ReactNode;
15
16
  }
16
- export declare type ItemProps = Pick<ComponentPropsWithRef<'div'>, 'style' | 'children'> & {
17
+ export declare type ItemProps<D> = Pick<React.ComponentPropsWithRef<'div'>, 'style' | 'children'> & {
17
18
  'data-index': number;
18
19
  'data-item-index': number;
19
20
  'data-item-group-index'?: number;
20
21
  'data-known-size': number;
22
+ item: D;
21
23
  };
22
- export declare type GroupProps = Pick<ComponentPropsWithRef<'div'>, 'style' | 'children'> & {
24
+ export declare type GroupProps = Pick<React.ComponentPropsWithRef<'div'>, 'style' | 'children'> & {
23
25
  'data-index': number;
24
26
  'data-item-index': number;
25
27
  'data-known-size': number;
26
28
  };
27
- export declare type TopItemListProps = Pick<ComponentPropsWithRef<'div'>, 'style' | 'children'>;
28
- export declare type TableProps = Pick<ComponentPropsWithRef<'table'>, 'style'>;
29
+ export declare type TopItemListProps = Pick<React.ComponentPropsWithRef<'div'>, 'style' | 'children'>;
30
+ export declare type TableProps = Pick<React.ComponentPropsWithRef<'table'>, 'style' | 'children'>;
29
31
  /**
30
32
  * Passed to the Components.TableBody custom component
31
33
  */
32
- export declare type TableBodyProps = Pick<ComponentPropsWithRef<'tbody'>, 'style' | 'children' | 'ref' | 'className'> & {
34
+ export declare type TableBodyProps = Pick<React.ComponentPropsWithRef<'tbody'>, 'style' | 'children' | 'ref' | 'className'> & {
33
35
  'data-test-id': string;
34
36
  };
35
37
  /**
36
38
  * Passed to the Components.List custom component
37
39
  */
38
- export declare type ListProps = Pick<ComponentPropsWithRef<'div'>, 'style' | 'children' | 'ref'> & {
40
+ export declare type ListProps = Pick<React.ComponentPropsWithRef<'div'>, 'style' | 'children' | 'ref'> & {
39
41
  'data-test-id': string;
40
42
  };
41
43
  /**
42
44
  * Passed to the Components.List custom component
43
45
  */
44
- export declare type GridListProps = Pick<ComponentPropsWithRef<'div'>, 'style' | 'children' | 'ref' | 'className'>;
46
+ export declare type GridListProps = Pick<React.ComponentPropsWithRef<'div'>, 'style' | 'children' | 'ref' | 'className'> & {
47
+ 'data-test-id': string;
48
+ };
45
49
  /**
46
50
  * Passed to the Components.Scroller custom component
47
51
  */
48
- export declare type ScrollerProps = Pick<ComponentPropsWithRef<'div'>, 'style' | 'children' | 'tabIndex' | 'ref'> & {
52
+ export declare type ScrollerProps = Pick<React.ComponentPropsWithRef<'div'>, 'style' | 'children' | 'tabIndex' | 'ref'> & {
49
53
  'data-test-id'?: string;
50
54
  'data-virtuoso-scroller'?: boolean;
51
55
  };
@@ -75,124 +79,130 @@ export interface GridScrollSeekPlaceholderProps {
75
79
  /**
76
80
  * Customize the Virtuoso rendering by passing a set of custom components.
77
81
  */
78
- export interface Components<Context = unknown> {
82
+ export interface Components<Data = unknown, Context = unknown> {
79
83
  /**
80
84
  * Set to render a component at the top of the list.
81
85
  *
82
86
  * The header remains above the top items and does not remain sticky.
83
87
  */
84
- Header?: ComponentType<{
88
+ Header?: React.ComponentType<{
85
89
  context?: Context;
86
90
  }>;
87
91
  /**
88
92
  * Set to render a component at the bottom of the list.
89
93
  */
90
- Footer?: ComponentType<{
94
+ Footer?: React.ComponentType<{
91
95
  context?: Context;
92
96
  }>;
93
97
  /**
94
98
  * Set to customize the item wrapping element. Use only if you would like to render list from elements different than a `div`.
95
99
  */
96
- Item?: ComponentType<ItemProps & {
100
+ Item?: React.ComponentType<ItemProps<Data> & {
97
101
  context?: Context;
98
102
  }>;
99
103
  /**
100
104
  * Set to customize the group item wrapping element. Use only if you would like to render list from elements different than a `div`.
101
105
  */
102
- Group?: ComponentType<GroupProps & {
106
+ Group?: React.ComponentType<GroupProps & {
103
107
  context?: Context;
104
108
  }>;
105
109
  /**
106
110
  * Set to customize the top list item wrapping element. Use if you would like to render list from elements different than a `div`
107
111
  * or you want to set a custom z-index for the sticky position.
108
112
  */
109
- TopItemList?: ComponentType<TopItemListProps & {
113
+ TopItemList?: React.ComponentType<TopItemListProps & {
110
114
  context?: Context;
111
115
  }>;
112
116
  /**
113
117
  * Set to customize the outermost scrollable element. This should not be necessary in general,
114
118
  * as the component passes its HTML attribute props to it.
115
119
  */
116
- Scroller?: ComponentType<ScrollerProps & {
120
+ Scroller?: React.ComponentType<ScrollerProps & {
117
121
  context?: Context;
118
122
  }>;
119
123
  /**
120
124
  * Set to customize the items wrapper. Use only if you would like to render list from elements different than a `div`.
121
125
  */
122
- List?: ComponentType<ListProps & {
126
+ List?: React.ComponentType<ListProps & {
123
127
  context?: Context;
124
128
  }>;
125
129
  /**
126
130
  * Set to render a custom UI when the list is empty.
127
131
  */
128
- EmptyPlaceholder?: ComponentType<{
132
+ EmptyPlaceholder?: React.ComponentType<{
129
133
  context?: Context;
130
134
  }>;
131
135
  /**
132
136
  * Set to render an item placeholder when the user scrolls fast. See the `scrollSeek` property for more details.
133
137
  */
134
- ScrollSeekPlaceholder?: ComponentType<ScrollSeekPlaceholderProps & {
138
+ ScrollSeekPlaceholder?: React.ComponentType<ScrollSeekPlaceholderProps & {
135
139
  context?: Context;
136
140
  }>;
137
141
  }
138
142
  /**
139
143
  * Customize the TableVirtuoso rendering by passing a set of custom components.
140
144
  */
141
- export interface TableComponents<Context = unknown> {
145
+ export interface TableComponents<Data = unknown, Context = unknown> {
142
146
  /**
143
147
  * Set to customize the wrapping `table` element.
144
148
  *
145
149
  */
146
- Table?: ComponentType<TableProps & {
150
+ Table?: React.ComponentType<TableProps & {
147
151
  context?: Context;
148
152
  }>;
149
153
  /**
150
- * Set to render a fixed header at the top of the table (`thead`). use [[fixedHeaderHeight]] to set the contents
154
+ * Set to render a fixed header at the top of the table (`thead`). use [[fixedHeaderContent]] to set the contents
151
155
  *
152
156
  */
153
- TableHead?: ComponentType<{
157
+ TableHead?: React.ComponentType<Pick<React.ComponentPropsWithRef<'thead'>, 'style' | 'children' | 'ref'> & {
158
+ context?: Context;
159
+ }>;
160
+ /**
161
+ * Set to render a fixed footer at the bottom of the table (`tfoot`). use [[fixedFooterContent]] to set the contents
162
+ */
163
+ TableFoot?: React.ComponentType<Pick<React.ComponentPropsWithRef<'tfoot'>, 'style' | 'children' | 'ref'> & {
154
164
  context?: Context;
155
165
  }>;
156
166
  /**
157
167
  * Set to customize the item wrapping element. Default is `tr`.
158
168
  */
159
- TableRow?: ComponentType<ItemProps & {
169
+ TableRow?: React.ComponentType<ItemProps<Data> & {
160
170
  context?: Context;
161
171
  }>;
162
172
  /**
163
173
  * Set to customize the outermost scrollable element. This should not be necessary in general,
164
174
  * as the component passes its HTML attribute props to it.
165
175
  */
166
- Scroller?: ComponentType<ScrollerProps & {
176
+ Scroller?: React.ComponentType<ScrollerProps & {
167
177
  context?: Context;
168
178
  }>;
169
179
  /**
170
180
  * Set to customize the items wrapper. Default is `tbody`.
171
181
  */
172
- TableBody?: ComponentType<TableBodyProps & {
182
+ TableBody?: React.ComponentType<TableBodyProps & {
173
183
  context?: Context;
174
184
  }>;
175
185
  /**
176
186
  * Set to render a custom UI when the list is empty.
177
187
  */
178
- EmptyPlaceholder?: ComponentType<{
188
+ EmptyPlaceholder?: React.ComponentType<{
179
189
  context?: Context;
180
190
  }>;
181
191
  /**
182
192
  * Set to render an item placeholder when the user scrolls fast. See the `scrollSeek` property for more details.
183
193
  */
184
- ScrollSeekPlaceholder?: ComponentType<ScrollSeekPlaceholderProps & {
194
+ ScrollSeekPlaceholder?: React.ComponentType<ScrollSeekPlaceholderProps & {
185
195
  context?: Context;
186
196
  }>;
187
197
  /**
188
198
  * Set to render an empty item placeholder.
189
199
  */
190
- FillerRow?: ComponentType<FillerRowProps & {
200
+ FillerRow?: React.ComponentType<FillerRowProps & {
191
201
  context?: Context;
192
202
  }>;
193
203
  }
194
204
  export interface ComputeItemKey<D, C> {
195
- (index: number, item: D, context: C): Key;
205
+ (index: number, item: D, context: C): React.Key;
196
206
  }
197
207
  export interface ScrollSeekToggle {
198
208
  (velocity: number, range: ListRange): boolean;
@@ -207,7 +217,7 @@ export interface ScrollSeekConfiguration {
207
217
  */
208
218
  change?: (velocity: number, range: ListRange) => void;
209
219
  /**
210
- * Callback to determine if the list should enter "scroll seek" mode.
220
+ * Callback to determine if the list should exit "scroll seek" mode.
211
221
  */
212
222
  exit: ScrollSeekToggle;
213
223
  }
@@ -231,11 +241,7 @@ export interface GroupItem<D> extends Item<D> {
231
241
  originalIndex?: number;
232
242
  }
233
243
  export declare type ListItem<D> = RecordItem<D> | GroupItem<D>;
234
- export interface IndexLocationWithAlign {
235
- /**
236
- * The index of the item to scroll to.
237
- */
238
- index: number | 'LAST';
244
+ export interface LocationOptions {
239
245
  /**
240
246
  * How to position the item in the viewport.
241
247
  */
@@ -249,10 +255,28 @@ export interface IndexLocationWithAlign {
249
255
  */
250
256
  offset?: number;
251
257
  }
258
+ export interface FlatIndexLocationWithAlign extends LocationOptions {
259
+ /**
260
+ * The index of the item to scroll to.
261
+ */
262
+ index: number | 'LAST';
263
+ }
264
+ export interface GroupIndexLocationWithAlign extends LocationOptions {
265
+ /**
266
+ * The group index of the item to scroll to.
267
+ */
268
+ groupIndex: number;
269
+ }
270
+ export declare type IndexLocationWithAlign = FlatIndexLocationWithAlign | GroupIndexLocationWithAlign;
271
+ export declare type GridIndexLocation = FlatIndexLocationWithAlign | number;
252
272
  export declare type ListRootProps = Omit<React.HTMLProps<HTMLDivElement>, 'ref' | 'data'>;
253
273
  export declare type TableRootProps = Omit<React.HTMLProps<HTMLTableElement>, 'ref' | 'data'>;
254
274
  export declare type GridRootProps = Omit<React.HTMLProps<HTMLDivElement>, 'ref' | 'data'>;
255
- export interface GridItem {
275
+ export interface GridItem<D> {
276
+ index: number;
277
+ data?: D;
278
+ }
279
+ export interface GridItemProps {
256
280
  'data-index': number;
257
281
  className?: string;
258
282
  }
@@ -260,48 +284,123 @@ export interface GridComponents<Context = any> {
260
284
  /**
261
285
  * Set to customize the item wrapping element. Use only if you would like to render list from elements different than a `div`.
262
286
  */
263
- Item?: ComponentType<GridItem & {
287
+ Item?: React.ComponentType<GridItemProps & {
264
288
  context?: Context;
265
289
  }>;
266
290
  /**
267
291
  * Set to customize the outermost scrollable element. This should not be necessary in general,
268
292
  * as the component passes its HTML attribute props to it.
269
293
  */
270
- Scroller?: ComponentType<ScrollerProps & {
294
+ Scroller?: React.ComponentType<ScrollerProps & {
271
295
  context?: Context;
272
296
  }>;
273
297
  /**
274
298
  * Set to customize the items wrapper. Use only if you would like to render list from elements different than a `div`.
275
299
  */
276
- List?: ComponentType<GridListProps & {
300
+ List?: React.ComponentType<GridListProps & {
301
+ context?: Context;
302
+ }>;
303
+ /**
304
+ * Set to render a component at the top of the list.
305
+ *
306
+ * The header remains above the top items and does not remain sticky.
307
+ */
308
+ Header?: React.ComponentType<{
309
+ context?: Context;
310
+ }>;
311
+ /**
312
+ * Set to render a component at the bottom of the list.
313
+ */
314
+ Footer?: React.ComponentType<{
277
315
  context?: Context;
278
316
  }>;
279
317
  /**
280
318
  * Set to render an item placeholder when the user scrolls fast.
281
319
  * See the `scrollSeekConfiguration` property for more details.
282
320
  */
283
- ScrollSeekPlaceholder?: ComponentType<GridScrollSeekPlaceholderProps & {
321
+ ScrollSeekPlaceholder?: React.ComponentType<GridScrollSeekPlaceholderProps & {
284
322
  context?: Context;
285
323
  }>;
286
324
  }
287
- export interface GridComputeItemKey {
288
- (index: number): Key;
325
+ export interface GridComputeItemKey<D, C> {
326
+ (index: number, item: D, context: C): React.Key;
289
327
  }
290
- export interface GridItemContent<C> {
291
- (index: number, context: C): ReactNode;
328
+ export interface GridItemContent<D, C> {
329
+ (index: number, data: D, context: C): React.ReactNode;
292
330
  }
293
331
  export interface WindowViewportInfo {
294
332
  offsetTop: number;
295
333
  visibleHeight: number;
296
334
  visibleWidth: number;
297
335
  }
298
- export interface ScrollIntoViewLocation {
299
- index: number;
336
+ export interface CalculateViewLocationParams {
337
+ itemTop: number;
338
+ itemBottom: number;
339
+ viewportTop: number;
340
+ viewportBottom: number;
341
+ locationParams: {
342
+ align?: 'start' | 'center' | 'end';
343
+ behavior?: 'auto' | 'smooth';
344
+ } & ({
345
+ index: number;
346
+ } | {
347
+ groupIndex: number;
348
+ });
349
+ }
350
+ export declare type CalculateViewLocation = (params: CalculateViewLocationParams) => IndexLocationWithAlign | number | null;
351
+ export interface ScrollIntoViewLocationOptions {
352
+ align?: 'start' | 'center' | 'end';
300
353
  behavior?: 'auto' | 'smooth';
354
+ /**
355
+ * Will be called when the scroll is done, or immediately if no scroll is needed.
356
+ */
301
357
  done?: () => void;
358
+ /**
359
+ * Use this function to fine-tune the scrollIntoView behavior.
360
+ * The function receives the item's top and bottom position in the viewport, and the viewport top/bottom.
361
+ * Return an location object to scroll, or null to prevent scrolling.
362
+ * Here's the default implementation:
363
+ * ```ts
364
+ const defaultCalculateViewLocation: CalculateViewLocation = ({
365
+ itemTop,
366
+ itemBottom,
367
+ viewportTop,
368
+ viewportBottom,
369
+ locationParams: { behavior, align, ...rest },
370
+ }) => {
371
+ if (itemTop < viewportTop) {
372
+ return { ...rest, behavior, align: align ?? 'start' }
373
+ }
374
+ if (itemBottom > viewportBottom) {
375
+ return { ...rest, behavior, align: align ?? 'end' }
376
+ }
377
+ return null
378
+ }
379
+ *```
380
+ */
381
+ calculateViewLocation?: CalculateViewLocation;
382
+ }
383
+ export interface FlatScrollIntoViewLocation extends ScrollIntoViewLocationOptions {
384
+ index: number;
385
+ }
386
+ export interface GroupedScrollIntoViewLocation extends ScrollIntoViewLocationOptions {
387
+ groupIndex: number;
302
388
  }
389
+ export declare type ScrollIntoViewLocation = FlatScrollIntoViewLocation | GroupedScrollIntoViewLocation;
303
390
  export interface ScrollContainerState {
304
391
  scrollHeight: number;
305
392
  scrollTop: number;
306
393
  viewportHeight: number;
307
394
  }
395
+ /** Calculates the height of `el`, which will be the `Item` element in the DOM. */
396
+ export declare type SizeFunction = (el: HTMLElement, field: 'offsetHeight' | 'offsetWidth') => number;
397
+ export interface SizeRange {
398
+ startIndex: number;
399
+ endIndex: number;
400
+ size: number;
401
+ }
402
+ export interface StateSnapshot {
403
+ ranges: SizeRange[];
404
+ scrollTop: number;
405
+ }
406
+ export declare type StateCallback = (state: StateSnapshot) => void;