@pallasoft/ps-table-components 1.28.0 → 1.28.2

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.
@@ -99,7 +99,7 @@ const PsDataTable = ({ caption, className, clearSelectionKey, columns, cursorPag
99
99
  const [seenClearKey, setSeenClearKey] = (0, react_1.useState)(clearSelectionKey);
100
100
  const stickyRegionRef = (0, react_1.useRef)(null);
101
101
  const stickySentinelRef = (0, react_1.useRef)(null);
102
- const stickyBackdropRef = (0, react_1.useRef)(null);
102
+ const stickyCardRef = (0, react_1.useRef)(null);
103
103
  const stickyHeadRef = (0, react_1.useRef)(null);
104
104
  const currentQuery = query ? query : uncontrolledQuery;
105
105
  if (seenClearKey !== clearSelectionKey) {
@@ -129,7 +129,7 @@ const PsDataTable = ({ caption, className, clearSelectionKey, columns, cursorPag
129
129
  const placementOf = (column, columnIndex) => ps_design_system_1.PallasoftClassNameService.merge(column.hideBelow === undefined ? '' : table_breakpoint_1.PsTableHideBelowClasses[column.hideBelow], columnIndex === 0 ? pins.first : '', ps_table_pin_service_1.PsTablePinService.end(column.pinEnd === true));
130
130
  const overflow = (0, use_ps_table_overflow_1.usePsTableOverflow)(`${visibleColumns.map((column) => column.id).join(',')}:${rows.length}`);
131
131
  const isStuck = (0, use_ps_sticky_head_1.usePsStickyHead)({
132
- backdropRef: stickyBackdropRef,
132
+ cardRef: stickyCardRef,
133
133
  headRef: stickyHeadRef,
134
134
  layoutKey: `${visibleColumns.map((column) => column.id).join(',')}:${rows.length}:${isLoading}`,
135
135
  regionRef: stickyRegionRef,
@@ -396,7 +396,7 @@ const PsDataTable = ({ caption, className, clearSelectionKey, columns, cursorPag
396
396
  updateQuery({ search: next });
397
397
  resetPage();
398
398
  }, rows: rows, search: search, searchPlaceholder: searchPlaceholder })) : null, banner] }));
399
- return ((0, jsx_runtime_1.jsxs)("div", { ref: containerRef, className: ps_design_system_1.PallasoftClassNameService.merge('flex min-w-0 flex-col gap-3', className), children: [stickyTop === undefined ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [stickyLeading, topContent] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { "aria-hidden": 'true', className: '-mb-3 h-0', ref: stickySentinelRef }), (0, jsx_runtime_1.jsxs)("div", { className: ps_design_system_1.PallasoftClassNameService.merge('sticky z-sticky flex flex-col gap-3', stickyClassName), "data-stuck": isStuck, ref: stickyRegionRef, style: { top: stickyTop }, children: [(0, jsx_runtime_1.jsx)("div", { "aria-hidden": 'true', className: ps_design_system_1.PallasoftClassNameService.merge('ps-glass-strong pointer-events-none absolute -inset-x-3 -bottom-3 rounded-b-ps-card border-t-0 transition-opacity duration-150', isStuck ? 'opacity-100' : 'opacity-0'), ref: stickyBackdropRef, style: { top: `calc(-1 * ${stickyTop})` } }), (0, jsx_runtime_1.jsxs)("div", { className: 'relative flex flex-col gap-3', children: [stickyLeading, topContent] })] })] })), (0, jsx_runtime_1.jsxs)("div", { "aria-busy": isRefreshing, className: 'min-w-0 overflow-hidden rounded-[1.25rem] border border-line bg-surface', children: [showsPagination &&
399
+ return ((0, jsx_runtime_1.jsxs)("div", { ref: containerRef, className: ps_design_system_1.PallasoftClassNameService.merge('flex min-w-0 flex-col gap-3', className), children: [stickyTop === undefined ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [stickyLeading, topContent] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { "aria-hidden": 'true', className: '-mb-3 h-0', ref: stickySentinelRef }), (0, jsx_runtime_1.jsxs)("div", { className: ps_design_system_1.PallasoftClassNameService.merge('sticky z-sticky flex flex-col gap-3', stickyClassName), "data-stuck": isStuck, ref: stickyRegionRef, style: { top: stickyTop }, children: [stickyLeading, topContent] })] })), (0, jsx_runtime_1.jsxs)("div", { "aria-busy": isRefreshing, className: 'min-w-0 overflow-hidden rounded-[1.25rem] border border-line bg-surface', ref: stickyCardRef, children: [showsPagination &&
400
400
  paginationPosition !== ps_table_pagination_position_1.PsTablePaginationPosition.bottom &&
401
401
  rowCount > ps_table_pagination_config_1.PsTablePaginationConfig.topMinRows
402
402
  ? renderPagination('border-b border-t-0')
@@ -0,0 +1,4 @@
1
+ export declare const PsTableStickyConfig: {
2
+ readonly cardGapPx: 12;
3
+ readonly cardRadius: "1.25rem";
4
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PsTableStickyConfig = void 0;
4
+ exports.PsTableStickyConfig = {
5
+ cardGapPx: 12,
6
+ cardRadius: '1.25rem',
7
+ };
@@ -63,7 +63,7 @@ export const PsDataTable = ({ caption, className, clearSelectionKey, columns, cu
63
63
  const [seenClearKey, setSeenClearKey] = useState(clearSelectionKey);
64
64
  const stickyRegionRef = useRef(null);
65
65
  const stickySentinelRef = useRef(null);
66
- const stickyBackdropRef = useRef(null);
66
+ const stickyCardRef = useRef(null);
67
67
  const stickyHeadRef = useRef(null);
68
68
  const currentQuery = query ? query : uncontrolledQuery;
69
69
  if (seenClearKey !== clearSelectionKey) {
@@ -93,7 +93,7 @@ export const PsDataTable = ({ caption, className, clearSelectionKey, columns, cu
93
93
  const placementOf = (column, columnIndex) => PallasoftClassNameService.merge(column.hideBelow === undefined ? '' : PsTableHideBelowClasses[column.hideBelow], columnIndex === 0 ? pins.first : '', PsTablePinService.end(column.pinEnd === true));
94
94
  const overflow = usePsTableOverflow(`${visibleColumns.map((column) => column.id).join(',')}:${rows.length}`);
95
95
  const isStuck = usePsStickyHead({
96
- backdropRef: stickyBackdropRef,
96
+ cardRef: stickyCardRef,
97
97
  headRef: stickyHeadRef,
98
98
  layoutKey: `${visibleColumns.map((column) => column.id).join(',')}:${rows.length}:${isLoading}`,
99
99
  regionRef: stickyRegionRef,
@@ -360,7 +360,7 @@ export const PsDataTable = ({ caption, className, clearSelectionKey, columns, cu
360
360
  updateQuery({ search: next });
361
361
  resetPage();
362
362
  }, rows: rows, search: search, searchPlaceholder: searchPlaceholder })) : null, banner] }));
363
- return (_jsxs("div", { ref: containerRef, className: PallasoftClassNameService.merge('flex min-w-0 flex-col gap-3', className), children: [stickyTop === undefined ? (_jsxs(_Fragment, { children: [stickyLeading, topContent] })) : (_jsxs(_Fragment, { children: [_jsx("div", { "aria-hidden": 'true', className: '-mb-3 h-0', ref: stickySentinelRef }), _jsxs("div", { className: PallasoftClassNameService.merge('sticky z-sticky flex flex-col gap-3', stickyClassName), "data-stuck": isStuck, ref: stickyRegionRef, style: { top: stickyTop }, children: [_jsx("div", { "aria-hidden": 'true', className: PallasoftClassNameService.merge('ps-glass-strong pointer-events-none absolute -inset-x-3 -bottom-3 rounded-b-ps-card border-t-0 transition-opacity duration-150', isStuck ? 'opacity-100' : 'opacity-0'), ref: stickyBackdropRef, style: { top: `calc(-1 * ${stickyTop})` } }), _jsxs("div", { className: 'relative flex flex-col gap-3', children: [stickyLeading, topContent] })] })] })), _jsxs("div", { "aria-busy": isRefreshing, className: 'min-w-0 overflow-hidden rounded-[1.25rem] border border-line bg-surface', children: [showsPagination &&
363
+ return (_jsxs("div", { ref: containerRef, className: PallasoftClassNameService.merge('flex min-w-0 flex-col gap-3', className), children: [stickyTop === undefined ? (_jsxs(_Fragment, { children: [stickyLeading, topContent] })) : (_jsxs(_Fragment, { children: [_jsx("div", { "aria-hidden": 'true', className: '-mb-3 h-0', ref: stickySentinelRef }), _jsxs("div", { className: PallasoftClassNameService.merge('sticky z-sticky flex flex-col gap-3', stickyClassName), "data-stuck": isStuck, ref: stickyRegionRef, style: { top: stickyTop }, children: [stickyLeading, topContent] })] })), _jsxs("div", { "aria-busy": isRefreshing, className: 'min-w-0 overflow-hidden rounded-[1.25rem] border border-line bg-surface', ref: stickyCardRef, children: [showsPagination &&
364
364
  paginationPosition !== PsTablePaginationPosition.bottom &&
365
365
  rowCount > PsTablePaginationConfig.topMinRows
366
366
  ? renderPagination('border-b border-t-0')
@@ -0,0 +1,4 @@
1
+ export const PsTableStickyConfig = {
2
+ cardGapPx: 12,
3
+ cardRadius: '1.25rem',
4
+ };
@@ -1,49 +1,56 @@
1
1
  import { useLayoutEffect, useState } from 'react';
2
+ import { PsTableStickyConfig } from '../constants/ps-table-sticky-config';
2
3
  import { PsTableScrollService } from '../services/ps-table-scroll-service';
3
4
  import { PsTableStickyHeadService } from '../services/ps-table-sticky-head-service';
4
- export const usePsStickyHead = ({ backdropRef, headRef, layoutKey, regionRef, sentinelRef, stickyTop, }) => {
5
+ export const usePsStickyHead = ({ cardRef, headRef, layoutKey, regionRef, sentinelRef, stickyTop, }) => {
5
6
  const [isStuck, setIsStuck] = useState(false);
6
7
  useLayoutEffect(() => {
7
8
  const region = regionRef.current;
8
9
  const sentinel = sentinelRef.current;
9
- const backdrop = backdropRef.current;
10
+ const card = cardRef.current;
10
11
  const head = headRef.current;
11
12
  const table = head === null ? null : head.parentElement;
12
13
  if (stickyTop === undefined ||
13
14
  region === null ||
14
15
  sentinel === null ||
15
- backdrop === null ||
16
+ card === null ||
16
17
  head === null ||
17
18
  table === null)
18
19
  return;
19
20
  const scroller = PsTableScrollService.parent(region);
20
21
  const Timeline = window.ScrollTimeline;
21
22
  const isDriven = scroller !== null && Timeline !== undefined;
22
- let animation = null;
23
+ let animations = [];
23
24
  let frame = 0;
24
- const maxShift = () => Math.max(table.offsetHeight - head.offsetHeight, 0);
25
+ const headTravel = () => Math.max(table.offsetHeight - head.offsetHeight, 0);
25
26
  const drive = () => {
26
27
  if (scroller === null || Timeline === undefined)
27
28
  return;
28
- const scrollerTop = scroller.getBoundingClientRect().top;
29
- const regionTop = region.getBoundingClientRect().top;
30
- const pinnedBottom = scrollerTop +
29
+ const pinnedLine = scroller.getBoundingClientRect().top +
31
30
  Number.parseFloat(getComputedStyle(region).top) +
32
- backdrop.getBoundingClientRect().bottom -
33
- regionTop;
34
- const pinScroll = table.getBoundingClientRect().top + scroller.scrollTop - pinnedBottom;
35
- const keyframes = PsTableStickyHeadService.keyframes(pinScroll, maxShift(), scroller.scrollHeight - scroller.clientHeight);
36
- if (animation !== null)
37
- animation.cancel();
38
- animation =
39
- keyframes.length === 0
40
- ? null
41
- : head.animate(keyframes.map((keyframe) => ({
42
- offset: keyframe.offset,
43
- transform: `translateY(${keyframe.shift}px)`,
44
- })), { fill: 'both', timeline: new Timeline({ axis: 'block', source: scroller }) });
31
+ region.offsetHeight +
32
+ PsTableStickyConfig.cardGapPx;
33
+ const scrollRange = scroller.scrollHeight - scroller.clientHeight;
34
+ const timeline = new Timeline({ axis: 'block', source: scroller });
35
+ const headFrames = PsTableStickyHeadService.keyframes(table.getBoundingClientRect().top + scroller.scrollTop - pinnedLine, headTravel(), scrollRange);
36
+ const cardFrames = PsTableStickyHeadService.keyframes(card.getBoundingClientRect().top + scroller.scrollTop - pinnedLine, card.offsetHeight, scrollRange);
37
+ animations.forEach((animation) => animation.cancel());
38
+ animations = [
39
+ head.animate(headFrames.map((keyframe) => ({
40
+ offset: keyframe.offset,
41
+ transform: `translateY(${keyframe.shift}px)`,
42
+ })), { fill: 'both', timeline }),
43
+ card.animate(cardFrames.map((keyframe) => ({
44
+ clipPath: PsTableStickyHeadService.clip(keyframe.shift),
45
+ offset: keyframe.offset,
46
+ })), { fill: 'both', timeline }),
47
+ ];
48
+ };
49
+ const follow = () => {
50
+ const pinnedLine = region.getBoundingClientRect().bottom + PsTableStickyConfig.cardGapPx;
51
+ head.style.transform = `translateY(${PsTableStickyHeadService.offset(pinnedLine, table.getBoundingClientRect().top, table.offsetHeight, head.offsetHeight)}px)`;
52
+ card.style.clipPath = PsTableStickyHeadService.clip(PsTableStickyHeadService.offset(pinnedLine, card.getBoundingClientRect().top, card.offsetHeight, 0));
45
53
  };
46
- const follow = () => (head.style.transform = `translateY(${PsTableStickyHeadService.offset(backdrop.getBoundingClientRect().bottom, table.getBoundingClientRect().top, table.offsetHeight, head.offsetHeight)}px)`);
47
54
  const check = () => {
48
55
  frame = 0;
49
56
  setIsStuck(sentinel.getBoundingClientRect().top < region.getBoundingClientRect().top - 1);
@@ -62,21 +69,21 @@ export const usePsStickyHead = ({ backdropRef, headRef, layoutKey, regionRef, se
62
69
  const observer = new ResizeObserver(measure);
63
70
  measure();
64
71
  observer.observe(region);
65
- observer.observe(table);
72
+ observer.observe(card);
66
73
  if (scroller !== null)
67
74
  Array.from(scroller.children).forEach((child) => observer.observe(child));
68
75
  window.addEventListener('scroll', schedule, { capture: true, passive: true });
69
76
  window.addEventListener('resize', measure);
70
77
  return () => {
71
78
  observer.disconnect();
72
- if (animation !== null)
73
- animation.cancel();
79
+ animations.forEach((animation) => animation.cancel());
74
80
  head.style.transform = '';
81
+ card.style.clipPath = '';
75
82
  window.removeEventListener('scroll', schedule, { capture: true });
76
83
  window.removeEventListener('resize', measure);
77
84
  if (frame !== 0)
78
85
  window.cancelAnimationFrame(frame);
79
86
  };
80
- }, [backdropRef, headRef, layoutKey, regionRef, sentinelRef, stickyTop]);
87
+ }, [cardRef, headRef, layoutKey, regionRef, sentinelRef, stickyTop]);
81
88
  return isStuck;
82
89
  };
@@ -1,3 +1,4 @@
1
+ import { PsTableStickyConfig } from '../constants/ps-table-sticky-config';
1
2
  export class PsTableStickyHeadService {
2
3
  static offset(pinnedBottom, tableTop, tableHeight, headHeight) {
3
4
  return Math.min(Math.max(pinnedBottom - tableTop, 0), Math.max(tableHeight - headHeight, 0));
@@ -6,12 +7,17 @@ export class PsTableStickyHeadService {
6
7
  if (scrollRange <= 0)
7
8
  return [];
8
9
  const shiftAt = (scroll) => Math.min(Math.max(scroll - pinScroll, 0), maxShift);
9
- const stops = [0, pinScroll, pinScroll + maxShift, scrollRange].filter((scroll) => scroll >= 0 && scroll <= scrollRange);
10
- return stops
11
- .filter((scroll, index) => stops.indexOf(scroll) === index)
12
- .map((scroll) => ({
10
+ return PsTableStickyHeadService.stops([0, pinScroll, pinScroll + maxShift, scrollRange], scrollRange).map((scroll) => ({
13
11
  offset: scroll / scrollRange,
14
12
  shift: shiftAt(scroll),
15
13
  }));
16
14
  }
15
+ static clip(shift) {
16
+ const radius = PsTableStickyConfig.cardRadius;
17
+ return `inset(${shift}px 0 0 0 round ${radius} ${radius} 0 0)`;
18
+ }
19
+ static stops(scrolls, scrollRange) {
20
+ const inside = scrolls.filter((scroll) => scroll >= 0 && scroll <= scrollRange);
21
+ return inside.filter((scroll, index) => inside.indexOf(scroll) === index);
22
+ }
17
23
  }
@@ -1,2 +1,2 @@
1
1
  import type { PsStickyHeadRefs } from '../interfaces/ps-sticky-head-refs';
2
- export declare const usePsStickyHead: ({ backdropRef, headRef, layoutKey, regionRef, sentinelRef, stickyTop, }: PsStickyHeadRefs) => boolean;
2
+ export declare const usePsStickyHead: ({ cardRef, headRef, layoutKey, regionRef, sentinelRef, stickyTop, }: PsStickyHeadRefs) => boolean;
@@ -2,51 +2,58 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.usePsStickyHead = void 0;
4
4
  const react_1 = require("react");
5
+ const ps_table_sticky_config_1 = require("../constants/ps-table-sticky-config");
5
6
  const ps_table_scroll_service_1 = require("../services/ps-table-scroll-service");
6
7
  const ps_table_sticky_head_service_1 = require("../services/ps-table-sticky-head-service");
7
- const usePsStickyHead = ({ backdropRef, headRef, layoutKey, regionRef, sentinelRef, stickyTop, }) => {
8
+ const usePsStickyHead = ({ cardRef, headRef, layoutKey, regionRef, sentinelRef, stickyTop, }) => {
8
9
  const [isStuck, setIsStuck] = (0, react_1.useState)(false);
9
10
  (0, react_1.useLayoutEffect)(() => {
10
11
  const region = regionRef.current;
11
12
  const sentinel = sentinelRef.current;
12
- const backdrop = backdropRef.current;
13
+ const card = cardRef.current;
13
14
  const head = headRef.current;
14
15
  const table = head === null ? null : head.parentElement;
15
16
  if (stickyTop === undefined ||
16
17
  region === null ||
17
18
  sentinel === null ||
18
- backdrop === null ||
19
+ card === null ||
19
20
  head === null ||
20
21
  table === null)
21
22
  return;
22
23
  const scroller = ps_table_scroll_service_1.PsTableScrollService.parent(region);
23
24
  const Timeline = window.ScrollTimeline;
24
25
  const isDriven = scroller !== null && Timeline !== undefined;
25
- let animation = null;
26
+ let animations = [];
26
27
  let frame = 0;
27
- const maxShift = () => Math.max(table.offsetHeight - head.offsetHeight, 0);
28
+ const headTravel = () => Math.max(table.offsetHeight - head.offsetHeight, 0);
28
29
  const drive = () => {
29
30
  if (scroller === null || Timeline === undefined)
30
31
  return;
31
- const scrollerTop = scroller.getBoundingClientRect().top;
32
- const regionTop = region.getBoundingClientRect().top;
33
- const pinnedBottom = scrollerTop +
32
+ const pinnedLine = scroller.getBoundingClientRect().top +
34
33
  Number.parseFloat(getComputedStyle(region).top) +
35
- backdrop.getBoundingClientRect().bottom -
36
- regionTop;
37
- const pinScroll = table.getBoundingClientRect().top + scroller.scrollTop - pinnedBottom;
38
- const keyframes = ps_table_sticky_head_service_1.PsTableStickyHeadService.keyframes(pinScroll, maxShift(), scroller.scrollHeight - scroller.clientHeight);
39
- if (animation !== null)
40
- animation.cancel();
41
- animation =
42
- keyframes.length === 0
43
- ? null
44
- : head.animate(keyframes.map((keyframe) => ({
45
- offset: keyframe.offset,
46
- transform: `translateY(${keyframe.shift}px)`,
47
- })), { fill: 'both', timeline: new Timeline({ axis: 'block', source: scroller }) });
34
+ region.offsetHeight +
35
+ ps_table_sticky_config_1.PsTableStickyConfig.cardGapPx;
36
+ const scrollRange = scroller.scrollHeight - scroller.clientHeight;
37
+ const timeline = new Timeline({ axis: 'block', source: scroller });
38
+ const headFrames = ps_table_sticky_head_service_1.PsTableStickyHeadService.keyframes(table.getBoundingClientRect().top + scroller.scrollTop - pinnedLine, headTravel(), scrollRange);
39
+ const cardFrames = ps_table_sticky_head_service_1.PsTableStickyHeadService.keyframes(card.getBoundingClientRect().top + scroller.scrollTop - pinnedLine, card.offsetHeight, scrollRange);
40
+ animations.forEach((animation) => animation.cancel());
41
+ animations = [
42
+ head.animate(headFrames.map((keyframe) => ({
43
+ offset: keyframe.offset,
44
+ transform: `translateY(${keyframe.shift}px)`,
45
+ })), { fill: 'both', timeline }),
46
+ card.animate(cardFrames.map((keyframe) => ({
47
+ clipPath: ps_table_sticky_head_service_1.PsTableStickyHeadService.clip(keyframe.shift),
48
+ offset: keyframe.offset,
49
+ })), { fill: 'both', timeline }),
50
+ ];
51
+ };
52
+ const follow = () => {
53
+ const pinnedLine = region.getBoundingClientRect().bottom + ps_table_sticky_config_1.PsTableStickyConfig.cardGapPx;
54
+ head.style.transform = `translateY(${ps_table_sticky_head_service_1.PsTableStickyHeadService.offset(pinnedLine, table.getBoundingClientRect().top, table.offsetHeight, head.offsetHeight)}px)`;
55
+ card.style.clipPath = ps_table_sticky_head_service_1.PsTableStickyHeadService.clip(ps_table_sticky_head_service_1.PsTableStickyHeadService.offset(pinnedLine, card.getBoundingClientRect().top, card.offsetHeight, 0));
48
56
  };
49
- const follow = () => (head.style.transform = `translateY(${ps_table_sticky_head_service_1.PsTableStickyHeadService.offset(backdrop.getBoundingClientRect().bottom, table.getBoundingClientRect().top, table.offsetHeight, head.offsetHeight)}px)`);
50
57
  const check = () => {
51
58
  frame = 0;
52
59
  setIsStuck(sentinel.getBoundingClientRect().top < region.getBoundingClientRect().top - 1);
@@ -65,22 +72,22 @@ const usePsStickyHead = ({ backdropRef, headRef, layoutKey, regionRef, sentinelR
65
72
  const observer = new ResizeObserver(measure);
66
73
  measure();
67
74
  observer.observe(region);
68
- observer.observe(table);
75
+ observer.observe(card);
69
76
  if (scroller !== null)
70
77
  Array.from(scroller.children).forEach((child) => observer.observe(child));
71
78
  window.addEventListener('scroll', schedule, { capture: true, passive: true });
72
79
  window.addEventListener('resize', measure);
73
80
  return () => {
74
81
  observer.disconnect();
75
- if (animation !== null)
76
- animation.cancel();
82
+ animations.forEach((animation) => animation.cancel());
77
83
  head.style.transform = '';
84
+ card.style.clipPath = '';
78
85
  window.removeEventListener('scroll', schedule, { capture: true });
79
86
  window.removeEventListener('resize', measure);
80
87
  if (frame !== 0)
81
88
  window.cancelAnimationFrame(frame);
82
89
  };
83
- }, [backdropRef, headRef, layoutKey, regionRef, sentinelRef, stickyTop]);
90
+ }, [cardRef, headRef, layoutKey, regionRef, sentinelRef, stickyTop]);
84
91
  return isStuck;
85
92
  };
86
93
  exports.usePsStickyHead = usePsStickyHead;
@@ -1,6 +1,6 @@
1
1
  import type { RefObject } from 'react';
2
2
  export interface PsStickyHeadRefs {
3
- backdropRef: RefObject<HTMLDivElement | null>;
3
+ cardRef: RefObject<HTMLDivElement | null>;
4
4
  headRef: RefObject<HTMLTableSectionElement | null>;
5
5
  layoutKey: string;
6
6
  regionRef: RefObject<HTMLDivElement | null>;
@@ -2,4 +2,6 @@ import type { PsTableStickyHeadKeyframe } from '../interfaces/ps-table-sticky-he
2
2
  export declare class PsTableStickyHeadService {
3
3
  static offset(pinnedBottom: number, tableTop: number, tableHeight: number, headHeight: number): number;
4
4
  static keyframes(pinScroll: number, maxShift: number, scrollRange: number): PsTableStickyHeadKeyframe[];
5
+ static clip(shift: number): string;
6
+ private static stops;
5
7
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PsTableStickyHeadService = void 0;
4
+ const ps_table_sticky_config_1 = require("../constants/ps-table-sticky-config");
4
5
  class PsTableStickyHeadService {
5
6
  static offset(pinnedBottom, tableTop, tableHeight, headHeight) {
6
7
  return Math.min(Math.max(pinnedBottom - tableTop, 0), Math.max(tableHeight - headHeight, 0));
@@ -9,13 +10,18 @@ class PsTableStickyHeadService {
9
10
  if (scrollRange <= 0)
10
11
  return [];
11
12
  const shiftAt = (scroll) => Math.min(Math.max(scroll - pinScroll, 0), maxShift);
12
- const stops = [0, pinScroll, pinScroll + maxShift, scrollRange].filter((scroll) => scroll >= 0 && scroll <= scrollRange);
13
- return stops
14
- .filter((scroll, index) => stops.indexOf(scroll) === index)
15
- .map((scroll) => ({
13
+ return PsTableStickyHeadService.stops([0, pinScroll, pinScroll + maxShift, scrollRange], scrollRange).map((scroll) => ({
16
14
  offset: scroll / scrollRange,
17
15
  shift: shiftAt(scroll),
18
16
  }));
19
17
  }
18
+ static clip(shift) {
19
+ const radius = ps_table_sticky_config_1.PsTableStickyConfig.cardRadius;
20
+ return `inset(${shift}px 0 0 0 round ${radius} ${radius} 0 0)`;
21
+ }
22
+ static stops(scrolls, scrollRange) {
23
+ const inside = scrolls.filter((scroll) => scroll >= 0 && scroll <= scrollRange);
24
+ return inside.filter((scroll, index) => inside.indexOf(scroll) === index);
25
+ }
20
26
  }
21
27
  exports.PsTableStickyHeadService = PsTableStickyHeadService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pallasoft/ps-table-components",
3
- "version": "1.28.0",
3
+ "version": "1.28.2",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/esm/index.js",