dce-reactkit 3.5.9 → 3.5.10

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.
@@ -12,6 +12,8 @@ type Props = {
12
12
  itemsName?: string;
13
13
  items: AutoScrollItem[];
14
14
  jumpToBottomButtonVariant?: Variant;
15
+ messageBeforeItems?: React.ReactNode;
16
+ messageAfterItems?: React.ReactNode;
15
17
  };
16
18
  type AutoScrollItem = {
17
19
  id: string | number;
package/dist/index.d.ts CHANGED
@@ -619,6 +619,8 @@ type Props = {
619
619
  itemsName?: string;
620
620
  items: AutoScrollItem[];
621
621
  jumpToBottomButtonVariant?: Variant;
622
+ messageBeforeItems?: React.ReactNode;
623
+ messageAfterItems?: React.ReactNode;
622
624
  };
623
625
  type AutoScrollItem = {
624
626
  id: string | number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dce-reactkit",
3
- "version": "3.5.9",
3
+ "version": "3.5.10",
4
4
  "description": "Shared components for Harvard DCE apps",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -35,6 +35,10 @@ type Props = {
35
35
  items: AutoScrollItem[],
36
36
  // Custom variant for the "Jump to Bottom" button
37
37
  jumpToBottomButtonVariant?: Variant,
38
+ // Optional element to display before last item (but within the scrollpane)
39
+ messageBeforeItems?: React.ReactNode,
40
+ // Optional element to display after the last item (but within the scrollpane)
41
+ messageAfterItems?: React.ReactNode,
38
42
  };
39
43
 
40
44
  // AutoScrollItem definition
@@ -187,6 +191,8 @@ const AutoscrollToBottomContainer: React.FC<Props> = (props) => {
187
191
  itemsName,
188
192
  items,
189
193
  jumpToBottomButtonVariant = Variant.Danger,
194
+ messageBeforeItems,
195
+ messageAfterItems,
190
196
  } = props;
191
197
 
192
198
  /* -------------- State ------------- */
@@ -319,6 +325,8 @@ const AutoscrollToBottomContainer: React.FC<Props> = (props) => {
319
325
  // Check if new content appeared at bottom
320
326
  const newContentAppeared = (
321
327
  currentItemIds.length > 0
328
+ && lastItemIds.current
329
+ && lastItemIds.current.length > 0
322
330
  && (
323
331
  currentItemIds[currentItemIds.length - 1]
324
332
  !== lastItemIds.current[lastItemIds.current.length - 1]
@@ -400,6 +408,9 @@ const AutoscrollToBottomContainer: React.FC<Props> = (props) => {
400
408
  onScroll={handleScroll}
401
409
  ref={container}
402
410
  >
411
+ {/* Message before items */}
412
+ {messageBeforeItems}
413
+
403
414
  {/* Items */}
404
415
  {
405
416
  items
@@ -415,6 +426,9 @@ const AutoscrollToBottomContainer: React.FC<Props> = (props) => {
415
426
  );
416
427
  })
417
428
  }
429
+
430
+ {/* Message after items */}
431
+ {messageAfterItems}
418
432
  </div>
419
433
  </div>
420
434
  );