@hh.ru/magritte-ui-table 3.2.9 → 4.0.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 (54) hide show
  1. package/StickyTableHeader.d.ts +2 -2
  2. package/StickyTableHeader.js +6 -10
  3. package/StickyTableHeader.js.map +1 -1
  4. package/Table.js +26 -27
  5. package/Table.js.map +1 -1
  6. package/TableBody.js +8 -8
  7. package/TableBody.js.map +1 -1
  8. package/TableCell.js +2 -2
  9. package/TableHeader.js +7 -11
  10. package/TableHeader.js.map +1 -1
  11. package/TableRow.js +2 -2
  12. package/VirtualizedList/VirtualizedList.d.ts +12 -0
  13. package/VirtualizedList/VirtualizedList.js +49 -0
  14. package/VirtualizedList/VirtualizedList.js.map +1 -0
  15. package/VirtualizedList/VirtualizedListWrapper.d.ts +18 -0
  16. package/VirtualizedList/VirtualizedListWrapper.js +28 -0
  17. package/VirtualizedList/VirtualizedListWrapper.js.map +1 -0
  18. package/VirtualizedList/VirtualizedPanel.d.ts +12 -0
  19. package/VirtualizedList/VirtualizedPanel.js +15 -0
  20. package/VirtualizedList/VirtualizedPanel.js.map +1 -0
  21. package/VirtualizedList/context.d.ts +9 -0
  22. package/VirtualizedList/context.js +10 -0
  23. package/VirtualizedList/context.js.map +1 -0
  24. package/VirtualizedList/index.d.ts +3 -0
  25. package/VirtualizedList/index.js +14 -0
  26. package/VirtualizedList/index.js.map +1 -0
  27. package/VirtualizedList/useVirtualizedList.d.ts +11 -0
  28. package/VirtualizedList/useVirtualizedList.js +43 -0
  29. package/VirtualizedList/useVirtualizedList.js.map +1 -0
  30. package/cell-DJucuY6T.js +5 -0
  31. package/cell-DJucuY6T.js.map +1 -0
  32. package/index.css +651 -683
  33. package/index.d.ts +1 -0
  34. package/index.js +9 -5
  35. package/index.js.map +1 -1
  36. package/index.mock.d.ts +4 -0
  37. package/index.mock.js +5 -1
  38. package/index.mock.js.map +1 -1
  39. package/package.json +2 -2
  40. package/table-h9Fxk8He.js +5 -0
  41. package/table-h9Fxk8He.js.map +1 -0
  42. package/types.d.ts +3 -4
  43. package/virtualized-list-B8kzPHyT.js +5 -0
  44. package/virtualized-list-B8kzPHyT.js.map +1 -0
  45. package/VirtualizedTableBody.d.ts +0 -4
  46. package/VirtualizedTableBody.js +0 -34
  47. package/VirtualizedTableBody.js.map +0 -1
  48. package/cell-CmFhtUuZ.js +0 -5
  49. package/cell-CmFhtUuZ.js.map +0 -1
  50. package/table-DCGiTlL0.js +0 -5
  51. package/table-DCGiTlL0.js.map +0 -1
  52. package/useTableVirtualizer.d.ts +0 -12
  53. package/useTableVirtualizer.js +0 -48
  54. package/useTableVirtualizer.js.map +0 -1
@@ -1,10 +1,10 @@
1
1
  import { FC, PropsWithChildren, RefObject } from 'react';
2
- import { Density } from '@hh.ru/magritte-ui-table/types';
2
+ import { TokenBaseStaticSpace } from '@hh.ru/magritte-design-tokens/types';
3
3
  interface StickyTableHeaderProps extends PropsWithChildren {
4
4
  root: HTMLDivElement;
5
5
  headerRef: RefObject<HTMLTableSectionElement>;
6
6
  divider?: boolean;
7
- density: Density;
7
+ density: TokenBaseStaticSpace;
8
8
  }
9
9
  export declare const StickyTableHeader: FC<StickyTableHeaderProps>;
10
10
  export {};
@@ -4,15 +4,9 @@ import { useRef, useContext, useCallback, useLayoutEffect } from 'react';
4
4
  import { createPortal } from 'react-dom';
5
5
  import classnames from 'classnames';
6
6
  import { TableContext } from './context.js';
7
- import { c as cellStyles } from './cell-CmFhtUuZ.js';
8
- import { s as styles } from './table-DCGiTlL0.js';
7
+ import { c as cellStyles } from './cell-DJucuY6T.js';
8
+ import { s as styles } from './table-h9Fxk8He.js';
9
9
 
10
- const DENSITY_TO_CSS = {
11
- 'extra-small': styles.densityExtraSmall,
12
- small: styles.densitySmall,
13
- medium: styles.densityMedium,
14
- large: styles.densityLarge,
15
- };
16
10
  const StickyTableHeader = ({ root, divider, density, headerRef, children }) => {
17
11
  const ref = useRef(null);
18
12
  const { fontLoaded: renderPortal, subscribeResizeHandler, unsubscribeResizeHandler } = useContext(TableContext);
@@ -40,9 +34,11 @@ const StickyTableHeader = ({ root, divider, density, headerRef, children }) => {
40
34
  return void 0;
41
35
  }, [root, renderPortal, calcWidth, subscribeResizeHandler, unsubscribeResizeHandler]);
42
36
  return (jsx(Fragment, { children: renderPortal &&
43
- createPortal(jsx("table", { ref: ref, className: classnames(styles.table, cellStyles.duplicateTable), children: jsx("thead", { className: classnames(styles.header, DENSITY_TO_CSS[density], {
37
+ createPortal(jsx("table", { ref: ref, className: classnames(styles.table, cellStyles.duplicateTable), children: jsx("thead", { className: classnames(styles.header, {
44
38
  [styles.withDivider]: !!divider,
45
- }), "data-qa": "table-sticky-header", children: children }) }), root) }));
39
+ }), style: {
40
+ '--magritte-table-row-gap': `${density}px 0`,
41
+ }, "data-qa": "table-sticky-header", children: children }) }), root) }));
46
42
  };
47
43
 
48
44
  export { StickyTableHeader };
@@ -1 +1 @@
1
- {"version":3,"file":"StickyTableHeader.js","sources":["src/StickyTableHeader.tsx"],"sourcesContent":["import { FC, PropsWithChildren, RefObject, useCallback, useContext, useLayoutEffect, useRef } from 'react';\nimport { createPortal } from 'react-dom';\nimport classnames from 'classnames';\n\nimport { TableContext } from '@hh.ru/magritte-ui-table/context';\nimport { Density } from '@hh.ru/magritte-ui-table/types';\n\nimport cellStyles from './cell.less';\nimport styles from './table.less';\n\ninterface StickyTableHeaderProps extends PropsWithChildren {\n root: HTMLDivElement;\n headerRef: RefObject<HTMLTableSectionElement>;\n divider?: boolean;\n density: Density;\n}\n\nconst DENSITY_TO_CSS = {\n 'extra-small': styles.densityExtraSmall,\n small: styles.densitySmall,\n medium: styles.densityMedium,\n large: styles.densityLarge,\n};\n\nexport const StickyTableHeader: FC<StickyTableHeaderProps> = ({ root, divider, density, headerRef, children }) => {\n const ref = useRef<HTMLTableElement>(null);\n const { fontLoaded: renderPortal, subscribeResizeHandler, unsubscribeResizeHandler } = useContext(TableContext);\n\n const calcWidth = useCallback(() => {\n if (ref.current && root && headerRef.current) {\n const columnsHeader =\n headerRef.current.querySelectorAll<HTMLTableCellElement>('[data-magritte-table-cell]');\n const widths: number[] = [];\n [...columnsHeader].forEach((column, index) => {\n widths[index] = column.getBoundingClientRect().width;\n });\n const columns = ref.current.querySelectorAll<HTMLElement>('[data-magritte-table-cell]');\n [...columns].forEach((column, index) => {\n column.style.setProperty('width', `${widths[index]}px`);\n column.style.setProperty('max-width', `${widths[index]}px`);\n });\n root.style.setProperty('margin-bottom', `-${headerRef.current.getBoundingClientRect().height}px`);\n }\n }, [headerRef, root]);\n\n useLayoutEffect(() => {\n if (root && renderPortal) {\n calcWidth();\n subscribeResizeHandler?.(calcWidth, 1);\n\n return () => unsubscribeResizeHandler?.(calcWidth);\n }\n\n return void 0;\n }, [root, renderPortal, calcWidth, subscribeResizeHandler, unsubscribeResizeHandler]);\n\n return (\n <>\n {renderPortal &&\n createPortal(\n <table ref={ref} className={classnames(styles.table, cellStyles.duplicateTable)}>\n <thead\n className={classnames(styles.header, DENSITY_TO_CSS[density], {\n [styles.withDivider]: !!divider,\n })}\n data-qa=\"table-sticky-header\"\n >\n {children}\n </thead>\n </table>,\n root\n )}\n </>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;AAiBA,MAAM,cAAc,GAAG;IACnB,aAAa,EAAE,MAAM,CAAC,iBAAiB;IACvC,KAAK,EAAE,MAAM,CAAC,YAAY;IAC1B,MAAM,EAAE,MAAM,CAAC,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC,YAAY;CAC7B,CAAC;AAEW,MAAA,iBAAiB,GAA+B,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAI;AAC7G,IAAA,MAAM,GAAG,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;AAC3C,IAAA,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,GAAG,UAAU,CA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AAG,SAAS,EAAE,CAAC,CAAC,CAAC;YAEvC,OAAO,MAAM,wBAAwB,GAAG,SAAS,CAAC,CAAC;SACtD;QAED,OAAO,KAAK,CAAC,CAAC;AAClB,KAAC,EAAE,CAAC,IAAI,EAAE,YAAY,EAAE,SAAS,EAAE,sBAAsB,EAAE,wBAAwB,CAAC,CAAC,CAAC;IAEtF,QACIA,0BACK,YAAY;AACT,YAAA,YAAY,CACRA,GAAA,CAAA,OAAA,EAAA,EAAO,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC,cAAc,CAAC,EAC3E,QAAA,EAAAA,GAAA,CAAA,OAAA,EAAA,EACI,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,OAAO,CAAC,EAAE;AAC1D,wBAAA,CAAC,MAAM,CAAC,WAAW,GAAG,CAAC,CAAC,OAAO;qBAClC,CAAC,EAAA,SAAA,EACM,qBAAqB,EAAA,QAAA,EAE5B,QAAQ,EAAA,CACL,EACJ,CAAA,EACR,IAAI,CACP,EACN,CAAA,EACL;AACN;;;;"}
1
+ {"version":3,"file":"StickyTableHeader.js","sources":["src/StickyTableHeader.tsx"],"sourcesContent":["import {\n CSSProperties,\n FC,\n PropsWithChildren,\n RefObject,\n useCallback,\n useContext,\n useLayoutEffect,\n useRef,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport classnames from 'classnames';\n\nimport { TokenBaseStaticSpace } from '@hh.ru/magritte-design-tokens/types';\nimport { TableContext } from '@hh.ru/magritte-ui-table/context';\n\nimport cellStyles from './cell.less';\nimport styles from './table.less';\n\ninterface StickyTableHeaderProps extends PropsWithChildren {\n root: HTMLDivElement;\n headerRef: RefObject<HTMLTableSectionElement>;\n divider?: boolean;\n density: TokenBaseStaticSpace;\n}\n\nexport const StickyTableHeader: FC<StickyTableHeaderProps> = ({ root, divider, density, headerRef, children }) => {\n const ref = useRef<HTMLTableElement>(null);\n const { fontLoaded: renderPortal, subscribeResizeHandler, unsubscribeResizeHandler } = useContext(TableContext);\n\n const calcWidth = useCallback(() => {\n if (ref.current && root && headerRef.current) {\n const columnsHeader =\n headerRef.current.querySelectorAll<HTMLTableCellElement>('[data-magritte-table-cell]');\n const widths: number[] = [];\n [...columnsHeader].forEach((column, index) => {\n widths[index] = column.getBoundingClientRect().width;\n });\n const columns = ref.current.querySelectorAll<HTMLElement>('[data-magritte-table-cell]');\n [...columns].forEach((column, index) => {\n column.style.setProperty('width', `${widths[index]}px`);\n column.style.setProperty('max-width', `${widths[index]}px`);\n });\n root.style.setProperty('margin-bottom', `-${headerRef.current.getBoundingClientRect().height}px`);\n }\n }, [headerRef, root]);\n\n useLayoutEffect(() => {\n if (root && renderPortal) {\n calcWidth();\n subscribeResizeHandler?.(calcWidth, 1);\n\n return () => unsubscribeResizeHandler?.(calcWidth);\n }\n\n return void 0;\n }, [root, renderPortal, calcWidth, subscribeResizeHandler, unsubscribeResizeHandler]);\n\n return (\n <>\n {renderPortal &&\n createPortal(\n <table ref={ref} className={classnames(styles.table, cellStyles.duplicateTable)}>\n <thead\n className={classnames(styles.header, {\n [styles.withDivider]: !!divider,\n })}\n style={\n {\n '--magritte-table-row-gap': `${density}px 0`,\n } as CSSProperties\n }\n data-qa=\"table-sticky-header\"\n >\n {children}\n </thead>\n </table>,\n root\n )}\n </>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;AA0Ba,MAAA,iBAAiB,GAA+B,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAI;AAC7G,IAAA,MAAM,GAAG,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;AAC3C,IAAA,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;AAEhH,IAAA,MAAM,SAAS,GAAG,WAAW,CAAC,MAAK;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AS,CAAC,CAAC;SACtD;QAED,OAAO,KAAK,CAAC,CAAC;AAClB,KAAC,EAAE,CAAC,IAAI,EAAE,YAAY,EAAE,SAAS,EAAE,sBAAsB,EAAE,wBAAwB,CAAC,CAAC,CAAC;IAEtF,QACIA,0BACK,YAAY;YACT,YAAY,CACRA,GAAO,CAAA,OAAA,EAAA,EAAA,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC,cAAc,CAAC,EAAA,QAAA,EAC3EA,GACI,CAAA,OAAA,EAAA,EAAA,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE;AACjC,wBAAA,CAAC,MAAM,CAAC,WAAW,GAAG,CAAC,CAAC,OAAO;qBAClC,CAAC,EACF,KAAK,EACD;wBACI,0BAA0B,EAAE,CAAG,EAAA,OAAO,CAAM,IAAA,CAAA;qBAC9B,EAEd,SAAA,EAAA,qBAAqB,EAE5B,QAAA,EAAA,QAAQ,EACL,CAAA,EAAA,CACJ,EACR,IAAI,CACP,EACN,CAAA,EACL;AACN;;;;"}
package/Table.js CHANGED
@@ -6,18 +6,24 @@ import { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';
6
6
  import { useWhenFontLoaded } from '@hh.ru/magritte-common-use-when-font-loaded';
7
7
  import { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';
8
8
  import { useScrollbar, Scrollbar } from '@hh.ru/magritte-ui-scrollbar';
9
+ import { VirtualizedListWrapper } from './VirtualizedList/VirtualizedListWrapper.js';
10
+ import { VirtualizedPanel } from './VirtualizedList/VirtualizedPanel.js';
9
11
  import { TableContext } from './context.js';
10
12
  import { useTableResize } from './useTableResize.js';
11
- import { c as cellStyles } from './cell-CmFhtUuZ.js';
12
- import { s as styles } from './table-DCGiTlL0.js';
13
+ import { c as cellStyles } from './cell-DJucuY6T.js';
14
+ import { s as styles } from './table-h9Fxk8He.js';
15
+ import './VirtualizedList/context.js';
16
+ import './virtualized-list-B8kzPHyT.js';
13
17
 
14
- const DENSITY_TO_CSS = {
15
- 'extra-small': styles.densityExtraSmall,
16
- small: styles.densitySmall,
17
- medium: styles.densityMedium,
18
- large: styles.densityLarge,
18
+ const measureElement = (element) => {
19
+ let rowHeight = element?.getBoundingClientRect().height;
20
+ const siblingElement = element.nextElementSibling;
21
+ if (siblingElement && siblingElement.hasAttribute('data-magritte-table-row-panel')) {
22
+ rowHeight += siblingElement.getBoundingClientRect().height;
23
+ }
24
+ return rowHeight;
19
25
  };
20
- const Table = ({ density = 'small', topPanel, bottomPanel, fixedSize, stickyBottom, stickyHeader, divider, dividerTop, dividerBottom, tinted, style = 'primary', styleHighlighted, tintedStyle = 'secondary', tintedStyleHighlighted, topStyle, bottomStyle, padding, paddingLeft: _paddingLeft, paddingRight: _paddingRight, cellsGap, onScrollHorizontal, virtualized = true, 'data-qa': dataQa = 'table-wrapper', children, }) => {
26
+ const Table = ({ density = 16, topPanel: _topPanel, bottomPanel: _bottomPanel, fixedSize, stickyBottom, stickyHeader, divider, dividerTop, dividerBottom, tinted, style = 'primary', styleHighlighted, tintedStyle = 'secondary', tintedStyleHighlighted, topStyle, bottomStyle, padding, paddingLeft: _paddingLeft, paddingRight: _paddingRight, cellsGap, onScrollHorizontal, virtualized = true, 'data-qa': dataQa = 'table-wrapper', children, }) => {
21
27
  const wrapperRef = useRef(null);
22
28
  const contentRef = useRef(null);
23
29
  const tableRef = useRef(null);
@@ -130,11 +136,6 @@ const Table = ({ density = 'small', topPanel, bottomPanel, fixedSize, stickyBott
130
136
  }
131
137
  return void 0;
132
138
  }, [calcDividersAndScrollbar, isMobile, subscribeResizeHandler, unsubscribeResizeHandler]);
133
- const { hasVerticalScroll, verticalScrollbarProps, ...vScrollbar } = useScrollbar({
134
- axis: fixedSize ? 'vertical' : 'none',
135
- });
136
- const wrapperRefCallback = useMultipleRefs(wrapperRef, vScrollbar.scrollContainerRef);
137
- const contentRefCallback = useMultipleRefs(contentRef, vScrollbar.contentWrapperRef);
138
139
  const { hasHorizontalScroll, horizontalScrollbarProps, ...hScrollbar } = useScrollbar({
139
140
  axis: 'horizontal',
140
141
  offsetRight: fixedSize ? 8 : undefined,
@@ -144,28 +145,26 @@ const Table = ({ density = 'small', topPanel, bottomPanel, fixedSize, stickyBott
144
145
  if (isMobile) {
145
146
  return null;
146
147
  }
147
- return (jsxs("div", { className: classnames(styles.wrapper, DENSITY_TO_CSS[density], vScrollbar.hoverContainerCssClass, {
148
+ const topPanel = _topPanel || stickyHeader ? (jsxs(VirtualizedPanel, { stickyTop: stickyHeader, style: topColor, children: [_topPanel && (jsx("div", { className: classnames(styles.topPanel, {
149
+ [styles.withDivider]: topWithDivider,
150
+ }), "data-qa": "table-top-panel", style: { paddingLeft, paddingRight }, children: _topPanel })), stickyHeader && (jsx("div", { ref: headerRefCallback, onScroll: handleHeaderScroll, "data-qa": "table-sticky-header-root", className: classnames(styles.headerContainer) }))] })) : null;
151
+ const bottomPanel = (jsxs(Fragment, { children: [(!_bottomPanel || !stickyBottom) && (jsxs(VirtualizedPanel, { stickyBottom: true, children: [jsx("div", { className: styles.scrollContainer, onScroll: handleScrollContainerScroll, ref: scrollContainerRefCallback, children: jsx("div", { className: styles.scrollContent, ref: scrollContentRefCallback }) }), hasHorizontalScroll && (jsx(Scrollbar, { className: styles.horizontalScrollbar, ...horizontalScrollbarProps }))] })), _bottomPanel && (jsxs(VirtualizedPanel, { stickyBottom: stickyBottom, style: bottomColor, children: [stickyBottom && (jsxs(Fragment, { children: [jsx("div", { className: styles.scrollContainer, onScroll: handleScrollContainerScroll, ref: scrollContainerRefCallback, children: jsx("div", { className: styles.scrollContent, ref: scrollContentRefCallback }) }), hasHorizontalScroll && (jsx(Scrollbar, { className: styles.horizontalScrollbar, ...horizontalScrollbarProps }))] })), jsx("div", { className: classnames(styles.bottomPanel, {
152
+ [styles.withDivider]: bottomWithDivider,
153
+ }), "data-qa": "table-bottom-panel", style: { paddingLeft, paddingRight }, children: _bottomPanel })] }))] }));
154
+ return (jsx("div", { className: classnames(styles.wrapper, {
148
155
  [styles[`style-${style}`]]: style,
149
156
  [styles[`style-highlighted-${highlightedColor}`]]: highlightedColor,
150
157
  [styles[`tinted-style-${tintedStyle}`]]: tinted && tintedStyle,
151
158
  [styles[`tinted-style-highlighted-${tintedHighlightedColor}`]]: tinted && tintedHighlightedColor,
152
- [styles[`top-style-${topColor}`]]: topColor,
153
- [styles[`bottom-style-${bottomColor}`]]: bottomColor,
154
159
  }), "data-qa": dataQa, style: {
155
160
  '--magritte-table-padding-left': `${paddingLeft ?? 0}px`,
156
161
  '--magritte-table-padding-right': `${paddingRight ?? 0}px`,
162
+ '--magritte-table-row-gap': `${density}px 0`,
163
+ '--magritte-table-row-panel-gap': `0 0 ${density}px`,
157
164
  ...(cellsGap ? { '--magritte-table-cell-padding': `${cellsGap / 2}px` } : {}),
158
- }, children: [jsxs("div", { className: classnames({ [styles.scrollWrapper]: fixedSize }), "data-magritte-table-wrapper": true, ref: wrapperRefCallback, children: [(topPanel || stickyHeader) && (jsxs("div", { className: classnames(styles.topContainer, {
159
- [styles.sticky]: stickyHeader,
160
- }), children: [topPanel && (jsx("div", { className: classnames(styles.topPanel, {
161
- [styles.withDivider]: topWithDivider,
162
- }), "data-qa": "table-top-panel", style: { paddingLeft, paddingRight }, children: topPanel })), stickyHeader && (jsx("div", { ref: headerRefCallback, onScroll: handleHeaderScroll, "data-qa": "table-sticky-header-root", className: classnames(styles.headerContainer) }))] })), jsx(TableContext.Provider, { value: value, children: jsx("div", { className: classnames(styles.container), ref: contentRefCallback, onScroll: handleScrollContent, "data-qa": 'table-container', children: jsx("table", { className: classnames(styles.table, {
163
- [styles.divider]: !!divider,
164
- }), "data-qa": "table", ref: tableRef, children: children }) }) }), (!bottomPanel || !stickyBottom) && (jsxs("div", { className: classnames(styles.bottomContainer, styles.sticky), children: [jsx("div", { className: styles.scrollContainer, onScroll: handleScrollContainerScroll, ref: scrollContainerRefCallback, children: jsx("div", { className: styles.scrollContent, ref: scrollContentRefCallback }) }), hasHorizontalScroll && (jsx(Scrollbar, { className: styles.horizontalScrollbar, ...horizontalScrollbarProps }))] })), bottomPanel && (jsxs("div", { className: classnames(styles.bottomContainer, {
165
- [styles.sticky]: stickyBottom,
166
- }), children: [stickyBottom && (jsxs(Fragment, { children: [jsx("div", { className: styles.scrollContainer, onScroll: handleScrollContainerScroll, ref: scrollContainerRefCallback, children: jsx("div", { className: styles.scrollContent, ref: scrollContentRefCallback }) }), hasHorizontalScroll && (jsx(Scrollbar, { className: styles.horizontalScrollbar, ...horizontalScrollbarProps }))] })), bottomPanel && (jsx("div", { className: classnames(styles.bottomPanel, {
167
- [styles.withDivider]: bottomWithDivider,
168
- }), "data-qa": "table-bottom-panel", style: { paddingLeft, paddingRight }, children: bottomPanel }))] }))] }), hasVerticalScroll && jsx(Scrollbar, { className: styles.verticalScrollbar, ...verticalScrollbarProps })] }));
165
+ }, children: jsx(VirtualizedListWrapper, { fixedSize: fixedSize, virtualized: virtualized, topPanel: topPanel, bottomPanel: bottomPanel, ref: wrapperRef, measureElement: measureElement, children: jsx(TableContext.Provider, { value: value, children: jsx("div", { ref: contentRef, className: classnames(styles.container), onScroll: handleScrollContent, "data-qa": 'table-container', children: jsx("table", { className: classnames(styles.table, {
166
+ [styles.divider]: !!divider,
167
+ }), "data-qa": "table", ref: tableRef, children: children }) }) }) }) }));
169
168
  };
170
169
 
171
170
  export { Table };
package/Table.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Table.js","sources":["src/Table.tsx"],"sourcesContent":["import { FC, RefCallback, useCallback, useLayoutEffect, useMemo, useRef, useState, CSSProperties } from 'react';\nimport classnames from 'classnames';\n\nimport { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';\nimport { useWhenFontLoaded } from '@hh.ru/magritte-common-use-when-font-loaded';\nimport { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';\nimport { Scrollbar, useScrollbar } from '@hh.ru/magritte-ui-scrollbar';\nimport { TableContext } from '@hh.ru/magritte-ui-table/context';\nimport { TableProps } from '@hh.ru/magritte-ui-table/types';\nimport { useTableResize } from '@hh.ru/magritte-ui-table/useTableResize';\n\nimport cellStyles from './cell.less';\nimport styles from './table.less';\n\nconst DENSITY_TO_CSS = {\n 'extra-small': styles.densityExtraSmall,\n small: styles.densitySmall,\n medium: styles.densityMedium,\n large: styles.densityLarge,\n};\n\nexport const Table: FC<TableProps> = ({\n density = 'small',\n topPanel,\n bottomPanel,\n fixedSize,\n stickyBottom,\n stickyHeader,\n divider,\n dividerTop,\n dividerBottom,\n tinted,\n style = 'primary',\n styleHighlighted,\n tintedStyle = 'secondary',\n tintedStyleHighlighted,\n topStyle,\n bottomStyle,\n padding,\n paddingLeft: _paddingLeft,\n paddingRight: _paddingRight,\n cellsGap,\n onScrollHorizontal,\n virtualized = true,\n 'data-qa': dataQa = 'table-wrapper',\n children,\n}) => {\n const wrapperRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const tableRef = useRef<HTMLTableElement>(null);\n const headerRef = useRef<HTMLDivElement | null>(null);\n const scrollbarContainerRef = useRef<HTMLDivElement | null>(null);\n const scrollbarRef = useRef<HTMLDivElement | null>(null);\n const [headerNode, setHeaderNode] = useState<HTMLDivElement | null>(null);\n const topWithDivider = dividerTop ?? !!divider;\n const bottomWithDivider = dividerBottom ?? !!divider;\n const paddingLeft = _paddingLeft ?? padding;\n const paddingRight = _paddingRight ?? padding;\n const highlightedColor = styleHighlighted || style;\n const tintedHighlightedColor = tintedStyleHighlighted || tintedStyle;\n const topColor = topStyle || style;\n const bottomColor = bottomStyle || style;\n const [fontLoaded, setFontLoaded] = useState(false);\n const { isMobile } = useBreakpoint();\n useWhenFontLoaded(() => setFontLoaded(true));\n const { subscribeResizeHandler, unsubscribeResizeHandler } = useTableResize({\n tableRef,\n wrapperRef,\n fontLoaded,\n });\n\n const value = useMemo(\n () => ({\n headerNode,\n stickyHeader,\n paddingLeft,\n paddingRight,\n fixedSize,\n fontLoaded,\n virtualized,\n divider: !!divider,\n subscribeResizeHandler,\n unsubscribeResizeHandler,\n }),\n [\n headerNode,\n stickyHeader,\n paddingLeft,\n paddingRight,\n fixedSize,\n fontLoaded,\n divider,\n virtualized,\n subscribeResizeHandler,\n unsubscribeResizeHandler,\n ]\n );\n\n const setScrollStyles = useCallback(() => {\n if (wrapperRef.current && contentRef.current) {\n wrapperRef.current.classList.toggle(cellStyles.hasScrollLeft, contentRef.current.scrollLeft > 0);\n wrapperRef.current.classList.toggle(\n cellStyles.hasScrollRight,\n Math.round(contentRef.current.scrollLeft) + contentRef.current.offsetWidth + (paddingRight ?? 0) <\n contentRef.current.scrollWidth\n );\n }\n }, [paddingRight]);\n\n const setFakeScrollbar = useCallback(() => {\n if (scrollbarRef.current && tableRef.current && contentRef.current && scrollbarContainerRef.current) {\n if (contentRef.current.scrollWidth > contentRef.current.offsetWidth) {\n scrollbarRef.current.style.setProperty('width', `${tableRef.current.getBoundingClientRect().width}px`);\n scrollbarContainerRef.current.style.setProperty('display', 'block');\n } else {\n scrollbarRef.current.style.setProperty('width', 'auto');\n scrollbarContainerRef.current.style.setProperty('display', 'none');\n }\n }\n }, []);\n\n const calcDividersAndScrollbar = useCallback(() => {\n setScrollStyles();\n setFakeScrollbar();\n }, [setScrollStyles, setFakeScrollbar]);\n\n const handleScrollContent = useCallback(() => {\n if (headerRef.current) {\n headerRef.current.scrollLeft = contentRef.current?.scrollLeft || 0;\n }\n if (scrollbarContainerRef.current) {\n scrollbarContainerRef.current.scrollLeft = contentRef.current?.scrollLeft || 0;\n }\n setScrollStyles();\n onScrollHorizontal?.();\n }, [setScrollStyles, onScrollHorizontal]);\n\n const handleHeaderScroll = useCallback(() => {\n if (contentRef.current) {\n contentRef.current.scrollLeft = headerRef.current?.scrollLeft || 0;\n }\n if (scrollbarContainerRef.current) {\n scrollbarContainerRef.current.scrollLeft = headerRef.current?.scrollLeft || 0;\n }\n }, []);\n\n const handleScrollContainerScroll = useCallback(() => {\n if (contentRef.current) {\n contentRef.current.scrollLeft = scrollbarContainerRef.current?.scrollLeft || 0;\n }\n\n if (headerRef.current) {\n headerRef.current.scrollLeft = scrollbarContainerRef.current?.scrollLeft || 0;\n }\n }, []);\n\n const headerRefCallback: RefCallback<HTMLDivElement> = useCallback((node) => {\n if (node) {\n setHeaderNode(node);\n headerRef.current = node;\n } else {\n headerRef.current = null;\n }\n }, []);\n\n useLayoutEffect(() => {\n if (!isMobile) {\n calcDividersAndScrollbar();\n subscribeResizeHandler?.(calcDividersAndScrollbar);\n\n return () => unsubscribeResizeHandler?.(calcDividersAndScrollbar);\n }\n return void 0;\n }, [calcDividersAndScrollbar, isMobile, subscribeResizeHandler, unsubscribeResizeHandler]);\n\n const { hasVerticalScroll, verticalScrollbarProps, ...vScrollbar } = useScrollbar({\n axis: fixedSize ? 'vertical' : 'none',\n });\n const wrapperRefCallback = useMultipleRefs(wrapperRef, vScrollbar.scrollContainerRef);\n const contentRefCallback = useMultipleRefs(contentRef, vScrollbar.contentWrapperRef);\n\n const { hasHorizontalScroll, horizontalScrollbarProps, ...hScrollbar } = useScrollbar({\n axis: 'horizontal',\n offsetRight: fixedSize ? 8 : undefined,\n });\n const scrollContainerRefCallback = useMultipleRefs(scrollbarContainerRef, hScrollbar.scrollContainerRef);\n const scrollContentRefCallback = useMultipleRefs(scrollbarRef, hScrollbar.contentWrapperRef);\n\n if (isMobile) {\n return null;\n }\n\n return (\n <div\n className={classnames(styles.wrapper, DENSITY_TO_CSS[density], vScrollbar.hoverContainerCssClass, {\n [styles[`style-${style}`]]: style,\n [styles[`style-highlighted-${highlightedColor}`]]: highlightedColor,\n [styles[`tinted-style-${tintedStyle}`]]: tinted && tintedStyle,\n [styles[`tinted-style-highlighted-${tintedHighlightedColor}`]]: tinted && tintedHighlightedColor,\n [styles[`top-style-${topColor}`]]: topColor,\n [styles[`bottom-style-${bottomColor}`]]: bottomColor,\n })}\n data-qa={dataQa}\n style={\n {\n '--magritte-table-padding-left': `${paddingLeft ?? 0}px`,\n '--magritte-table-padding-right': `${paddingRight ?? 0}px`,\n ...(cellsGap ? { '--magritte-table-cell-padding': `${cellsGap / 2}px` } : {}),\n } as CSSProperties\n }\n >\n <div\n className={classnames({ [styles.scrollWrapper]: fixedSize })}\n data-magritte-table-wrapper\n ref={wrapperRefCallback}\n >\n {(topPanel || stickyHeader) && (\n <div\n className={classnames(styles.topContainer, {\n [styles.sticky]: stickyHeader,\n })}\n >\n {topPanel && (\n <div\n className={classnames(styles.topPanel, {\n [styles.withDivider]: topWithDivider,\n })}\n data-qa=\"table-top-panel\"\n style={{ paddingLeft, paddingRight }}\n >\n {topPanel}\n </div>\n )}\n {stickyHeader && (\n <div\n ref={headerRefCallback}\n onScroll={handleHeaderScroll}\n data-qa=\"table-sticky-header-root\"\n className={classnames(styles.headerContainer)}\n />\n )}\n </div>\n )}\n <TableContext.Provider value={value}>\n <div\n className={classnames(styles.container)}\n ref={contentRefCallback}\n onScroll={handleScrollContent}\n data-qa={'table-container'}\n >\n <table\n className={classnames(styles.table, {\n [styles.divider]: !!divider,\n })}\n data-qa=\"table\"\n ref={tableRef}\n >\n {children}\n </table>\n </div>\n </TableContext.Provider>\n {(!bottomPanel || !stickyBottom) && (\n <div className={classnames(styles.bottomContainer, styles.sticky)}>\n <div\n className={styles.scrollContainer}\n onScroll={handleScrollContainerScroll}\n ref={scrollContainerRefCallback}\n >\n <div className={styles.scrollContent} ref={scrollContentRefCallback}></div>\n </div>\n {hasHorizontalScroll && (\n <Scrollbar className={styles.horizontalScrollbar} {...horizontalScrollbarProps} />\n )}\n </div>\n )}\n {bottomPanel && (\n <div\n className={classnames(styles.bottomContainer, {\n [styles.sticky]: stickyBottom,\n })}\n >\n {stickyBottom && (\n <>\n <div\n className={styles.scrollContainer}\n onScroll={handleScrollContainerScroll}\n ref={scrollContainerRefCallback}\n >\n <div className={styles.scrollContent} ref={scrollContentRefCallback}></div>\n </div>\n {hasHorizontalScroll && (\n <Scrollbar className={styles.horizontalScrollbar} {...horizontalScrollbarProps} />\n )}\n </>\n )}\n {bottomPanel && (\n <div\n className={classnames(styles.bottomPanel, {\n [styles.withDivider]: bottomWithDivider,\n })}\n data-qa=\"table-bottom-panel\"\n style={{ paddingLeft, paddingRight }}\n >\n {bottomPanel}\n </div>\n )}\n </div>\n )}\n </div>\n {hasVerticalScroll && <Scrollbar className={styles.verticalScrollbar} {...verticalScrollbarProps} />}\n </div>\n );\n};\n"],"names":["_jsxs","_jsx","_Fragment"],"mappings":";;;;;;;;;;;;AAcA,MAAM,cAAc,GAAG;IACnB,aAAa,EAAE,MAAM,CAAC,iBAAiB;IACvC,KAAK,EAAE,MAAM,CAAC,YAAY;IAC1B,MAAM,EAAE,MAAM,CAAC,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC,YAAY;CAC7B,CAAC;AAEK,MAAM,KAAK,GAAmB,CAAC,EAClC,OAAO,GAAG,OAAO,EACjB,QAAQ,EACR,WAAW,EACX,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,UAAU,EACV,aAAa,EACb,MAAM,EACN,KAAK,GAAG,SAAS,EACjB,gBAAgB,EAChB,WAAW,GAAG,WAAW,EACzB,sBAAsB,EACtB,QAAQ,EACR,WAAW,EACX,OAAO,EACP,WAAW,EAAE,YAAY,EACzB,YAAY,EAAE,aAAa,EAC3B,QAAQ,EACR,kBAAkB,EAClB,WAAW,GAAG,IAAI,EAClB,SAAS,EAAE,MAAM,GAAG,eAAe,EACnC,QAAQ,GACX,KAAI;AACD,IAAA,MAAM,UAAU,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;AAChD,IAAA,MAAM,UAAU,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;AAChD,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;AAChD,IAAA,MAAM,SAAS,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;AACtD,IAAA,MAAM,qBAAqB,GAAG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,MAAM,CAAC,aAAa,EAAE,GAAG,EAAE,wBAAwB,EAAA,CAAQ,EACzE,CAAA,EACL,mBAAmB,KAChBA,GAAA,CAAC,SAAS,EAAA,EAAC,SAAS,EAAE,MAAM,CAAC,mBAAmB,EAAA,GAAM,wBAAwB,EAAA,CAAI,CACrF,CAAA,EAAA,CACF,CACN,EACA,WAAW,KACRA,GAAA,CAAA,KAAA,EAAA,EACI,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,WAAW,EAAE;AACtC,oCAAA,CAAC,MAAM,CAAC,WAAW,GAAG,iBAAiB;AAC1C,iCAAA,CAAC,EACM,SAAA,EAAA,oBAAoB,EAC5B,KAAK,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,EAAA,QAAA,EAEnC,WAAW,EAAA,CACV,CACT,CACC,EAAA,CAAA,CACT,CACC,EAAA,CAAA,EACL,iBAAiB,IAAIA,GAAC,CAAA,SAAS,IAAC,SAAS,EAAE,MAAM,CAAC,iBAAiB,EAAM,GAAA,sBAAsB,EAAI,CAAA,CAAA,EAAA,CAClG,EACR;AACN;;;;"}
1
+ {"version":3,"file":"Table.js","sources":["src/Table.tsx"],"sourcesContent":["import { FC, RefCallback, useCallback, useLayoutEffect, useMemo, useRef, useState, CSSProperties } from 'react';\nimport classnames from 'classnames';\n\nimport { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';\nimport { useWhenFontLoaded } from '@hh.ru/magritte-common-use-when-font-loaded';\nimport { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';\nimport { Scrollbar, useScrollbar } from '@hh.ru/magritte-ui-scrollbar';\nimport { VirtualizedListWrapper } from '@hh.ru/magritte-ui-table/VirtualizedList/VirtualizedListWrapper';\nimport { VirtualizedPanel } from '@hh.ru/magritte-ui-table/VirtualizedList/VirtualizedPanel';\nimport { TableContext } from '@hh.ru/magritte-ui-table/context';\nimport { TableProps } from '@hh.ru/magritte-ui-table/types';\nimport { useTableResize } from '@hh.ru/magritte-ui-table/useTableResize';\n\nimport cellStyles from './cell.less';\nimport styles from './table.less';\n\nconst measureElement = (element: Element) => {\n let rowHeight = element?.getBoundingClientRect().height;\n const siblingElement = element.nextElementSibling;\n if (siblingElement && siblingElement.hasAttribute('data-magritte-table-row-panel')) {\n rowHeight += siblingElement.getBoundingClientRect().height;\n }\n return rowHeight;\n};\n\nexport const Table: FC<TableProps> = ({\n density = 16,\n topPanel: _topPanel,\n bottomPanel: _bottomPanel,\n fixedSize,\n stickyBottom,\n stickyHeader,\n divider,\n dividerTop,\n dividerBottom,\n tinted,\n style = 'primary',\n styleHighlighted,\n tintedStyle = 'secondary',\n tintedStyleHighlighted,\n topStyle,\n bottomStyle,\n padding,\n paddingLeft: _paddingLeft,\n paddingRight: _paddingRight,\n cellsGap,\n onScrollHorizontal,\n virtualized = true,\n 'data-qa': dataQa = 'table-wrapper',\n children,\n}) => {\n const wrapperRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const tableRef = useRef<HTMLTableElement>(null);\n const headerRef = useRef<HTMLDivElement | null>(null);\n const scrollbarContainerRef = useRef<HTMLDivElement | null>(null);\n const scrollbarRef = useRef<HTMLDivElement | null>(null);\n const [headerNode, setHeaderNode] = useState<HTMLDivElement | null>(null);\n const topWithDivider = dividerTop ?? !!divider;\n const bottomWithDivider = dividerBottom ?? !!divider;\n const paddingLeft = _paddingLeft ?? padding;\n const paddingRight = _paddingRight ?? padding;\n const highlightedColor = styleHighlighted || style;\n const tintedHighlightedColor = tintedStyleHighlighted || tintedStyle;\n const topColor = topStyle || style;\n const bottomColor = bottomStyle || style;\n const [fontLoaded, setFontLoaded] = useState(false);\n const { isMobile } = useBreakpoint();\n useWhenFontLoaded(() => setFontLoaded(true));\n const { subscribeResizeHandler, unsubscribeResizeHandler } = useTableResize({\n tableRef,\n wrapperRef,\n fontLoaded,\n });\n\n const value = useMemo(\n () => ({\n headerNode,\n stickyHeader,\n paddingLeft,\n paddingRight,\n fixedSize,\n fontLoaded,\n virtualized,\n divider: !!divider,\n subscribeResizeHandler,\n unsubscribeResizeHandler,\n }),\n [\n headerNode,\n stickyHeader,\n paddingLeft,\n paddingRight,\n fixedSize,\n fontLoaded,\n divider,\n virtualized,\n subscribeResizeHandler,\n unsubscribeResizeHandler,\n ]\n );\n\n const setScrollStyles = useCallback(() => {\n if (wrapperRef.current && contentRef.current) {\n wrapperRef.current.classList.toggle(cellStyles.hasScrollLeft, contentRef.current.scrollLeft > 0);\n wrapperRef.current.classList.toggle(\n cellStyles.hasScrollRight,\n Math.round(contentRef.current.scrollLeft) + contentRef.current.offsetWidth + (paddingRight ?? 0) <\n contentRef.current.scrollWidth\n );\n }\n }, [paddingRight]);\n\n const setFakeScrollbar = useCallback(() => {\n if (scrollbarRef.current && tableRef.current && contentRef.current && scrollbarContainerRef.current) {\n if (contentRef.current.scrollWidth > contentRef.current.offsetWidth) {\n scrollbarRef.current.style.setProperty('width', `${tableRef.current.getBoundingClientRect().width}px`);\n scrollbarContainerRef.current.style.setProperty('display', 'block');\n } else {\n scrollbarRef.current.style.setProperty('width', 'auto');\n scrollbarContainerRef.current.style.setProperty('display', 'none');\n }\n }\n }, []);\n\n const calcDividersAndScrollbar = useCallback(() => {\n setScrollStyles();\n setFakeScrollbar();\n }, [setScrollStyles, setFakeScrollbar]);\n\n const handleScrollContent = useCallback(() => {\n if (headerRef.current) {\n headerRef.current.scrollLeft = contentRef.current?.scrollLeft || 0;\n }\n if (scrollbarContainerRef.current) {\n scrollbarContainerRef.current.scrollLeft = contentRef.current?.scrollLeft || 0;\n }\n setScrollStyles();\n onScrollHorizontal?.();\n }, [setScrollStyles, onScrollHorizontal]);\n\n const handleHeaderScroll = useCallback(() => {\n if (contentRef.current) {\n contentRef.current.scrollLeft = headerRef.current?.scrollLeft || 0;\n }\n if (scrollbarContainerRef.current) {\n scrollbarContainerRef.current.scrollLeft = headerRef.current?.scrollLeft || 0;\n }\n }, []);\n\n const handleScrollContainerScroll = useCallback(() => {\n if (contentRef.current) {\n contentRef.current.scrollLeft = scrollbarContainerRef.current?.scrollLeft || 0;\n }\n\n if (headerRef.current) {\n headerRef.current.scrollLeft = scrollbarContainerRef.current?.scrollLeft || 0;\n }\n }, []);\n\n const headerRefCallback: RefCallback<HTMLDivElement> = useCallback((node) => {\n if (node) {\n setHeaderNode(node);\n headerRef.current = node;\n } else {\n headerRef.current = null;\n }\n }, []);\n\n useLayoutEffect(() => {\n if (!isMobile) {\n calcDividersAndScrollbar();\n subscribeResizeHandler?.(calcDividersAndScrollbar);\n\n return () => unsubscribeResizeHandler?.(calcDividersAndScrollbar);\n }\n return void 0;\n }, [calcDividersAndScrollbar, isMobile, subscribeResizeHandler, unsubscribeResizeHandler]);\n\n const { hasHorizontalScroll, horizontalScrollbarProps, ...hScrollbar } = useScrollbar({\n axis: 'horizontal',\n offsetRight: fixedSize ? 8 : undefined,\n });\n const scrollContainerRefCallback = useMultipleRefs(scrollbarContainerRef, hScrollbar.scrollContainerRef);\n const scrollContentRefCallback = useMultipleRefs(scrollbarRef, hScrollbar.contentWrapperRef);\n\n if (isMobile) {\n return null;\n }\n\n const topPanel =\n _topPanel || stickyHeader ? (\n <VirtualizedPanel stickyTop={stickyHeader} style={topColor}>\n {_topPanel && (\n <div\n className={classnames(styles.topPanel, {\n [styles.withDivider]: topWithDivider,\n })}\n data-qa=\"table-top-panel\"\n style={{ paddingLeft, paddingRight }}\n >\n {_topPanel}\n </div>\n )}\n {stickyHeader && (\n <div\n ref={headerRefCallback}\n onScroll={handleHeaderScroll}\n data-qa=\"table-sticky-header-root\"\n className={classnames(styles.headerContainer)}\n />\n )}\n </VirtualizedPanel>\n ) : null;\n\n const bottomPanel = (\n <>\n {(!_bottomPanel || !stickyBottom) && (\n <VirtualizedPanel stickyBottom>\n <div\n className={styles.scrollContainer}\n onScroll={handleScrollContainerScroll}\n ref={scrollContainerRefCallback}\n >\n <div className={styles.scrollContent} ref={scrollContentRefCallback}></div>\n </div>\n {hasHorizontalScroll && (\n <Scrollbar className={styles.horizontalScrollbar} {...horizontalScrollbarProps} />\n )}\n </VirtualizedPanel>\n )}\n {_bottomPanel && (\n <VirtualizedPanel stickyBottom={stickyBottom} style={bottomColor}>\n {stickyBottom && (\n <>\n <div\n className={styles.scrollContainer}\n onScroll={handleScrollContainerScroll}\n ref={scrollContainerRefCallback}\n >\n <div className={styles.scrollContent} ref={scrollContentRefCallback}></div>\n </div>\n {hasHorizontalScroll && (\n <Scrollbar className={styles.horizontalScrollbar} {...horizontalScrollbarProps} />\n )}\n </>\n )}\n <div\n className={classnames(styles.bottomPanel, {\n [styles.withDivider]: bottomWithDivider,\n })}\n data-qa=\"table-bottom-panel\"\n style={{ paddingLeft, paddingRight }}\n >\n {_bottomPanel}\n </div>\n </VirtualizedPanel>\n )}\n </>\n );\n return (\n <div\n className={classnames(styles.wrapper, {\n [styles[`style-${style}`]]: style,\n [styles[`style-highlighted-${highlightedColor}`]]: highlightedColor,\n [styles[`tinted-style-${tintedStyle}`]]: tinted && tintedStyle,\n [styles[`tinted-style-highlighted-${tintedHighlightedColor}`]]: tinted && tintedHighlightedColor,\n })}\n data-qa={dataQa}\n style={\n {\n '--magritte-table-padding-left': `${paddingLeft ?? 0}px`,\n '--magritte-table-padding-right': `${paddingRight ?? 0}px`,\n '--magritte-table-row-gap': `${density}px 0`,\n '--magritte-table-row-panel-gap': `0 0 ${density}px`,\n ...(cellsGap ? { '--magritte-table-cell-padding': `${cellsGap / 2}px` } : {}),\n } as CSSProperties\n }\n >\n <VirtualizedListWrapper\n fixedSize={fixedSize}\n virtualized={virtualized}\n topPanel={topPanel}\n bottomPanel={bottomPanel}\n ref={wrapperRef}\n measureElement={measureElement}\n >\n <TableContext.Provider value={value}>\n <div\n ref={contentRef}\n className={classnames(styles.container)}\n onScroll={handleScrollContent}\n data-qa={'table-container'}\n >\n <table\n className={classnames(styles.table, {\n [styles.divider]: !!divider,\n })}\n data-qa=\"table\"\n ref={tableRef}\n >\n {children}\n </table>\n </div>\n </TableContext.Provider>\n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A,CACvB,EACR;AACN;;;;"}
package/TableBody.js CHANGED
@@ -1,16 +1,16 @@
1
1
  import './index.css';
2
2
  import { jsx } from 'react/jsx-runtime';
3
- import { useRef, useContext } from 'react';
4
- import { VirtualizedTableBody } from './VirtualizedTableBody.js';
5
- import { TableContext } from './context.js';
6
- import { s as styles } from './table-DCGiTlL0.js';
7
- import './useTableVirtualizer.js';
3
+ import { VirtualizedList } from './VirtualizedList/VirtualizedList.js';
4
+ import { s as styles } from './table-h9Fxk8He.js';
5
+ import 'react';
6
+ import 'classnames';
7
+ import './VirtualizedList/context.js';
8
+ import './VirtualizedList/useVirtualizedList.js';
8
9
  import '@tanstack/react-virtual';
10
+ import './virtualized-list-B8kzPHyT.js';
9
11
 
10
12
  const TableBody = ({ 'data-qa': dataQa = 'table-body', children, }) => {
11
- const ref = useRef(null);
12
- const { virtualized } = useContext(TableContext);
13
- return (jsx("tbody", { ref: ref, className: styles.body, "data-qa": dataQa, children: virtualized ? jsx(VirtualizedTableBody, { tableRef: ref, children: children }) : children }));
13
+ return (jsx(VirtualizedList, { className: styles.body, "data-qa": dataQa, Element: 'tbody', ElementItem: 'tr', children: children }));
14
14
  };
15
15
 
16
16
  export { TableBody };
package/TableBody.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"TableBody.js","sources":["src/TableBody.tsx"],"sourcesContent":["import { FC, PropsWithChildren, useRef, useContext } from 'react';\n\nimport { VirtualizedTableBody } from '@hh.ru/magritte-ui-table/VirtualizedTableBody';\nimport { TableContext } from '@hh.ru/magritte-ui-table/context';\n\nimport styles from './table.less';\n\nexport const TableBody: FC<PropsWithChildren<{ 'data-qa'?: string }>> = ({\n 'data-qa': dataQa = 'table-body',\n children,\n}) => {\n const ref = useRef(null);\n const { virtualized } = useContext(TableContext);\n\n return (\n <tbody ref={ref} className={styles.body} data-qa={dataQa}>\n {virtualized ? <VirtualizedTableBody tableRef={ref}>{children}</VirtualizedTableBody> : children}\n </tbody>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;AAOO,MAAM,SAAS,GAAkD,CAAC,EACrE,SAAS,EAAE,MAAM,GAAG,YAAY,EAChC,QAAQ,GACX,KAAI;AACD,IAAA,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IACzB,MAAM,EAAE,WAAW,EAAE,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;AAEjD,IAAA,QACIA,GAAA,CAAA,OAAA,EAAA,EAAO,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,IAAI,EAAW,SAAA,EAAA,MAAM,YACnD,WAAW,GAAGA,GAAC,CAAA,oBAAoB,EAAC,EAAA,QAAQ,EAAE,GAAG,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAwB,GAAG,QAAQ,EAAA,CAC5F,EACV;AACN;;;;"}
1
+ {"version":3,"file":"TableBody.js","sources":["src/TableBody.tsx"],"sourcesContent":["import { FC, PropsWithChildren } from 'react';\n\nimport { VirtualizedList } from '@hh.ru/magritte-ui-table/VirtualizedList/VirtualizedList';\n\nimport styles from './table.less';\n\nexport const TableBody: FC<PropsWithChildren<{ 'data-qa'?: string }>> = ({\n 'data-qa': dataQa = 'table-body',\n children,\n}) => {\n return (\n <VirtualizedList className={styles.body} data-qa={dataQa} Element={'tbody'} ElementItem={'tr'}>\n {children}\n </VirtualizedList>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;;;AAMO,MAAM,SAAS,GAAkD,CAAC,EACrE,SAAS,EAAE,MAAM,GAAG,YAAY,EAChC,QAAQ,GACX,KAAI;IACD,QACIA,IAAC,eAAe,EAAA,EAAC,SAAS,EAAE,MAAM,CAAC,IAAI,EAAW,SAAA,EAAA,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EACxF,QAAA,EAAA,QAAQ,EACK,CAAA,EACpB;AACN;;;;"}
package/TableCell.js CHANGED
@@ -5,8 +5,8 @@ import classnames from 'classnames';
5
5
  import { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';
6
6
  import { useLayoutContext } from '@hh.ru/magritte-ui-grid/layoutContext';
7
7
  import { TableContext } from './context.js';
8
- import { c as cellStyles } from './cell-CmFhtUuZ.js';
9
- import { s as styles } from './table-DCGiTlL0.js';
8
+ import { c as cellStyles } from './cell-DJucuY6T.js';
9
+ import { s as styles } from './table-h9Fxk8He.js';
10
10
 
11
11
  const TableCellComponent = ({ Element = 'td', m, l, xl, xxl, width, children, stickyLeft, stickyRight, align, verticalAlign, 'data-qa': dataQa = 'table-cell', ...rest }, ref) => {
12
12
  const cellRef = useRef(null);
package/TableHeader.js CHANGED
@@ -4,23 +4,19 @@ import { useRef, useContext } from 'react';
4
4
  import classnames from 'classnames';
5
5
  import { StickyTableHeader } from './StickyTableHeader.js';
6
6
  import { TableContext } from './context.js';
7
- import { s as styles } from './table-DCGiTlL0.js';
7
+ import { s as styles } from './table-h9Fxk8He.js';
8
8
  import 'react-dom';
9
- import './cell-CmFhtUuZ.js';
9
+ import './cell-DJucuY6T.js';
10
10
 
11
- const DENSITY_TO_CSS = {
12
- 'extra-small': styles.densityExtraSmall,
13
- small: styles.densitySmall,
14
- medium: styles.densityMedium,
15
- large: styles.densityLarge,
16
- };
17
- const TableHeader = ({ divider, density = 'small', 'data-qa': dataQa = 'table-header', children, }) => {
11
+ const TableHeader = ({ divider, density = 16, 'data-qa': dataQa = 'table-header', children, }) => {
18
12
  const theadRef = useRef(null);
19
13
  const tableContext = useContext(TableContext);
20
14
  const withDivider = divider ?? tableContext.divider;
21
- return (jsxs(Fragment, { children: [jsx("thead", { ref: theadRef, className: classnames(styles.header, DENSITY_TO_CSS[density], {
15
+ return (jsxs(Fragment, { children: [jsx("thead", { ref: theadRef, className: classnames(styles.header, {
22
16
  [styles.withDivider]: !!withDivider,
23
- }), "data-qa": dataQa, children: children }), tableContext.stickyHeader && tableContext.headerNode && (jsx(StickyTableHeader, { root: tableContext.headerNode, headerRef: theadRef, divider: withDivider, density: density, children: children }))] }));
17
+ }), "data-qa": dataQa, style: {
18
+ '--magritte-table-row-gap': `${density}px 0`,
19
+ }, children: children }), tableContext.stickyHeader && tableContext.headerNode && (jsx(StickyTableHeader, { root: tableContext.headerNode, headerRef: theadRef, divider: withDivider, density: density, children: children }))] }));
24
20
  };
25
21
 
26
22
  export { TableHeader };
@@ -1 +1 @@
1
- {"version":3,"file":"TableHeader.js","sources":["src/TableHeader.tsx"],"sourcesContent":["import { FC, useContext, useRef } from 'react';\nimport classnames from 'classnames';\n\nimport { StickyTableHeader } from '@hh.ru/magritte-ui-table/StickyTableHeader';\nimport { TableContext } from '@hh.ru/magritte-ui-table/context';\nimport { TableHeaderProps } from '@hh.ru/magritte-ui-table/types';\n\nimport styles from './table.less';\n\nconst DENSITY_TO_CSS = {\n 'extra-small': styles.densityExtraSmall,\n small: styles.densitySmall,\n medium: styles.densityMedium,\n large: styles.densityLarge,\n};\n\nexport const TableHeader: FC<TableHeaderProps> = ({\n divider,\n density = 'small',\n 'data-qa': dataQa = 'table-header',\n children,\n}) => {\n const theadRef = useRef<HTMLTableSectionElement>(null);\n const tableContext = useContext(TableContext);\n const withDivider = divider ?? tableContext.divider;\n\n return (\n <>\n <thead\n ref={theadRef}\n className={classnames(styles.header, DENSITY_TO_CSS[density], {\n [styles.withDivider]: !!withDivider,\n })}\n data-qa={dataQa}\n >\n {children}\n </thead>\n {tableContext.stickyHeader && tableContext.headerNode && (\n <StickyTableHeader\n root={tableContext.headerNode}\n headerRef={theadRef}\n divider={withDivider}\n density={density}\n >\n {children}\n </StickyTableHeader>\n )}\n </>\n );\n};\n"],"names":["_jsxs","_Fragment","_jsx"],"mappings":";;;;;;;;;AASA,MAAM,cAAc,GAAG;IACnB,aAAa,EAAE,MAAM,CAAC,iBAAiB;IACvC,KAAK,EAAE,MAAM,CAAC,YAAY;IAC1B,MAAM,EAAE,MAAM,CAAC,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC,YAAY;CAC7B,CAAC;MAEW,WAAW,GAAyB,CAAC,EAC9C,OAAO,EACP,OAAO,GAAG,OAAO,EACjB,SAAS,EAAE,MAAM,GAAG,cAAc,EAClC,QAAQ,GACX,KAAI;AACD,IAAA,MAAM,QAAQ,GAAG,MAAM,CAA0B,IAAI,CAAC,CAAC;AACvD,IAAA,MAAM,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;AAC9C,IAAA,MAAM,WAAW,GAAG,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC;AAEpD,IAAA,QACIA,IACI,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAA,CAAAC,GAAA,CAAA,OAAA,EAAA,EACI,GAAG,EAAE,QAAQ,EACb,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,OAAO,CAAC,EAAE;AAC1D,oBAAA,CAAC,MAAM,CAAC,WAAW,GAAG,CAAC,CAAC,WAAW;AACtC,iBAAA,CAAC,aACO,MAAM,EAAA,QAAA,EAEd,QAAQ,EACL,CAAA,EACP,YAAY,CAAC,YAAY,IAAI,YAAY,CAAC,UAAU,KACjDA,GAAC,CAAA,iBAAiB,IACd,IAAI,EAAE,YAAY,CAAC,UAAU,EAC7B,SAAS,EAAE,QAAQ,EACnB,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,OAAO,EAEf,QAAA,EAAA,QAAQ,GACO,CACvB,CAAA,EAAA,CACF,EACL;AACN;;;;"}
1
+ {"version":3,"file":"TableHeader.js","sources":["src/TableHeader.tsx"],"sourcesContent":["import { CSSProperties, FC, useContext, useRef } from 'react';\nimport classnames from 'classnames';\n\nimport { StickyTableHeader } from '@hh.ru/magritte-ui-table/StickyTableHeader';\nimport { TableContext } from '@hh.ru/magritte-ui-table/context';\nimport { TableHeaderProps } from '@hh.ru/magritte-ui-table/types';\n\nimport styles from './table.less';\n\nexport const TableHeader: FC<TableHeaderProps> = ({\n divider,\n density = 16,\n 'data-qa': dataQa = 'table-header',\n children,\n}) => {\n const theadRef = useRef<HTMLTableSectionElement>(null);\n const tableContext = useContext(TableContext);\n const withDivider = divider ?? tableContext.divider;\n\n return (\n <>\n <thead\n ref={theadRef}\n className={classnames(styles.header, {\n [styles.withDivider]: !!withDivider,\n })}\n data-qa={dataQa}\n style={\n {\n '--magritte-table-row-gap': `${density}px 0`,\n } as CSSProperties\n }\n >\n {children}\n </thead>\n {tableContext.stickyHeader && tableContext.headerNode && (\n <StickyTableHeader\n root={tableContext.headerNode}\n headerRef={theadRef}\n divider={withDivider}\n density={density}\n >\n {children}\n </StickyTableHeader>\n )}\n </>\n );\n};\n"],"names":["_jsxs","_Fragment","_jsx"],"mappings":";;;;;;;;;MASa,WAAW,GAAyB,CAAC,EAC9C,OAAO,EACP,OAAO,GAAG,EAAE,EACZ,SAAS,EAAE,MAAM,GAAG,cAAc,EAClC,QAAQ,GACX,KAAI;AACD,IAAA,MAAM,QAAQ,GAAG,MAAM,CAA0B,IAAI,CAAC,CAAC;AACvD,IAAA,MAAM,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;AAC9C,IAAA,MAAM,WAAW,GAAG,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC;AAEpD,IAAA,QACIA,IAAA,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAA,CACIC,GACI,CAAA,OAAA,EAAA,EAAA,GAAG,EAAE,QAAQ,EACb,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE;AACjC,oBAAA,CAAC,MAAM,CAAC,WAAW,GAAG,CAAC,CAAC,WAAW;AACtC,iBAAA,CAAC,EACO,SAAA,EAAA,MAAM,EACf,KAAK,EACD;oBACI,0BAA0B,EAAE,CAAG,EAAA,OAAO,CAAM,IAAA,CAAA;AAC9B,iBAAA,EAAA,QAAA,EAGrB,QAAQ,EACL,CAAA,EACP,YAAY,CAAC,YAAY,IAAI,YAAY,CAAC,UAAU,KACjDA,GAAA,CAAC,iBAAiB,EACd,EAAA,IAAI,EAAE,YAAY,CAAC,UAAU,EAC7B,SAAS,EAAE,QAAQ,EACnB,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,OAAO,EAEf,QAAA,EAAA,QAAQ,GACO,CACvB,CAAA,EAAA,CACF,EACL;AACN;;;;"}
package/TableRow.js CHANGED
@@ -4,8 +4,8 @@ import { forwardRef, useContext, useRef, useEffect } from 'react';
4
4
  import classnames from 'classnames';
5
5
  import { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';
6
6
  import { TableContext } from './context.js';
7
- import { c as cellStyles } from './cell-CmFhtUuZ.js';
8
- import { s as styles } from './table-DCGiTlL0.js';
7
+ import { c as cellStyles } from './cell-DJucuY6T.js';
8
+ import { s as styles } from './table-h9Fxk8He.js';
9
9
 
10
10
  const TableRowComponent = ({ style, styleHighlighted, action, showAction, animated, onClick, panel, showPanel, children, measure, align, verticalAlign = 'top', 'data-qa': dataQa = 'table-row', ...rest }, ref) => {
11
11
  const { paddingLeft, paddingRight } = useContext(TableContext);
@@ -0,0 +1,12 @@
1
+ import { FC, HTMLAttributes, PropsWithChildren } from 'react';
2
+ import { VirtualItem } from '@tanstack/virtual-core';
3
+ interface VirtualizedListProps extends PropsWithChildren<HTMLAttributes<HTMLElement>> {
4
+ ElementItem?: keyof JSX.IntrinsicElements & keyof HTMLElementTagNameMap;
5
+ Element?: keyof JSX.IntrinsicElements & keyof HTMLElementTagNameMap;
6
+ }
7
+ export declare const VirtualizedList: FC<VirtualizedListProps>;
8
+ interface VirtualizedItemProps extends PropsWithChildren<HTMLAttributes<HTMLElement>> {
9
+ measure?: VirtualItem<Element>['measureElement'];
10
+ }
11
+ export declare const VirtualizedItem: import("react").ForwardRefExoticComponent<VirtualizedItemProps & import("react").RefAttributes<HTMLDivElement>>;
12
+ export {};
@@ -0,0 +1,49 @@
1
+ import './../index.css';
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import { forwardRef, useContext, Children, isValidElement, useRef, cloneElement } from 'react';
4
+ import classnames from 'classnames';
5
+ import { VirtualizedListContext } from './context.js';
6
+ import { useVirtualizedList } from './useVirtualizedList.js';
7
+ import { s as styles } from '../virtualized-list-B8kzPHyT.js';
8
+ import '@tanstack/react-virtual';
9
+
10
+ const ActivatedVirtualizedList = ({ ElementItem = 'div', Element = 'div', className, children, ...rest }) => {
11
+ const childArray = Children.toArray(children).filter((e) => isValidElement(e));
12
+ const contentRef = useRef(null);
13
+ const virtualizer = useVirtualizedList({
14
+ count: childArray.length,
15
+ contentRef,
16
+ });
17
+ const additionalProps = { ...rest };
18
+ additionalProps.ref = contentRef;
19
+ const items = virtualizer.getVirtualItems();
20
+ const [paddingTop, paddingBottom] = items.length > 0
21
+ ? [
22
+ Math.max(0, items[0].start - virtualizer.options.scrollMargin),
23
+ Math.max(0, virtualizer.getTotalSize() - (items[items.length - 1].end - virtualizer.options.scrollMargin)),
24
+ ]
25
+ : [0, 0];
26
+ return (jsxs(Element, { ...additionalProps, className: classnames(styles.virtualizedList, className), children: [paddingTop > 0 && jsx(ElementItem, { style: { height: paddingTop } }), virtualizer.getVirtualItems().map((virtualItem) => {
27
+ return cloneElement(childArray[virtualItem.index], {
28
+ key: virtualItem.key,
29
+ 'data-index': virtualItem.index,
30
+ ref: virtualItem.measureElement,
31
+ measure: virtualItem.measureElement,
32
+ });
33
+ }), paddingBottom > 0 && jsx(ElementItem, { style: { height: paddingBottom } })] }));
34
+ };
35
+ const VirtualizedList = (props) => {
36
+ const { Element = 'div', className, children, ...rest } = props;
37
+ const { virtualized } = useContext(VirtualizedListContext);
38
+ if (!virtualized) {
39
+ return (jsx(Element, { ...rest, className: classnames(styles.virtualizedList, className), children: children }));
40
+ }
41
+ return jsx(ActivatedVirtualizedList, { ...props });
42
+ };
43
+ const VirtualizedItemComponent = ({ measure, ...rest }, ref) => {
44
+ return jsx("div", { ...rest, ref: ref });
45
+ };
46
+ const VirtualizedItem = forwardRef(VirtualizedItemComponent);
47
+
48
+ export { VirtualizedItem, VirtualizedList };
49
+ //# sourceMappingURL=VirtualizedList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VirtualizedList.js","sources":["src/VirtualizedList/VirtualizedList.tsx"],"sourcesContent":["import {\n Children,\n cloneElement,\n FC,\n type ForwardedRef,\n forwardRef,\n HTMLAttributes,\n isValidElement,\n PropsWithChildren,\n ReactElement,\n useContext,\n useRef,\n} from 'react';\nimport { VirtualItem } from '@tanstack/virtual-core';\nimport classnames from 'classnames';\n\nimport { VirtualizedListContext } from '@hh.ru/magritte-ui-table/VirtualizedList/context';\nimport { useVirtualizedList } from '@hh.ru/magritte-ui-table/VirtualizedList/useVirtualizedList';\n\nimport styles from './virtualized-list.less';\n\ninterface VirtualizedListProps extends PropsWithChildren<HTMLAttributes<HTMLElement>> {\n ElementItem?: keyof JSX.IntrinsicElements & keyof HTMLElementTagNameMap;\n Element?: keyof JSX.IntrinsicElements & keyof HTMLElementTagNameMap;\n}\n\nconst ActivatedVirtualizedList: FC<VirtualizedListProps> = ({\n ElementItem = 'div',\n Element = 'div',\n className,\n children,\n ...rest\n}) => {\n const childArray = Children.toArray(children).filter<ReactElement>((e): e is ReactElement => isValidElement(e));\n const contentRef = useRef<HTMLElement>(null);\n\n const virtualizer = useVirtualizedList({\n count: childArray.length,\n contentRef,\n });\n\n const additionalProps: Record<string, unknown> = { ...rest };\n\n additionalProps.ref = contentRef;\n\n const items = virtualizer.getVirtualItems();\n const [paddingTop, paddingBottom] =\n items.length > 0\n ? [\n Math.max(0, items[0].start - virtualizer.options.scrollMargin),\n Math.max(\n 0,\n virtualizer.getTotalSize() - (items[items.length - 1].end - virtualizer.options.scrollMargin)\n ),\n ]\n : [0, 0];\n\n return (\n <Element {...additionalProps} className={classnames(styles.virtualizedList, className)}>\n {paddingTop > 0 && <ElementItem style={{ height: paddingTop }}></ElementItem>}\n {virtualizer.getVirtualItems().map((virtualItem) => {\n return cloneElement(childArray[virtualItem.index], {\n key: virtualItem.key,\n 'data-index': virtualItem.index,\n ref: virtualItem.measureElement,\n measure: virtualItem.measureElement,\n });\n })}\n {paddingBottom > 0 && <ElementItem style={{ height: paddingBottom }}></ElementItem>}\n </Element>\n );\n};\n\nexport const VirtualizedList: FC<VirtualizedListProps> = (props) => {\n const { Element = 'div', className, children, ...rest } = props;\n\n const { virtualized } = useContext(VirtualizedListContext);\n\n if (!virtualized) {\n return (\n <Element {...rest} className={classnames(styles.virtualizedList, className)}>\n {children}\n </Element>\n );\n }\n\n return <ActivatedVirtualizedList {...props} />;\n};\n\ninterface VirtualizedItemProps extends PropsWithChildren<HTMLAttributes<HTMLElement>> {\n measure?: VirtualItem<Element>['measureElement'];\n}\n\nconst VirtualizedItemComponent = ({ measure, ...rest }: VirtualizedItemProps, ref: ForwardedRef<HTMLDivElement>) => {\n return <div {...rest} ref={ref} />;\n};\n\nexport const VirtualizedItem = forwardRef(VirtualizedItemComponent);\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;AA0BA,MAAM,wBAAwB,GAA6B,CAAC,EACxD,WAAW,GAAG,KAAK,EACnB,OAAO,GAAG,KAAK,EACf,SAAS,EACT,QAAQ,EACR,GAAG,IAAI,EACV,KAAI;IACD,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAe,CAAC,CAAC,KAAwB,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AAChH,IAAA,MAAM,UAAU,GAAG,MAAM,CAAc,IAAI,CAAC,CAAC;IAE7C,MAAM,WAAW,GAAG,kBAAkB,CAAC;QACnC,KAAK,EAAE,UAAU,CAAC,MAAM;QACxB,UAAU;AACb,KAAA,CAAC,CAAC;AAEH,IAAA,MAAM,eAAe,GAA4B,EAAE,GAAG,IAAI,EAAE,CAAC;AAE7D,IAAA,eAAe,CAAC,GAAG,GAAG,UAAU,CAAC;AAEjC,IAAA,MAAM,KAAK,GAAG,WAAW,CAAC,eAAe,EAAE,CAAC;IAC5C,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAC7B,KAAK,CAAC,MAAM,GAAG,C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GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IAEhE,MAAM,EAAE,WAAW,EAAE,GAAG,UAAU,CAAC,sBAAsB,CAAC,CAAC;IAE3D,IAAI,CAAC,WAAW,EAAE;QACd,QACIA,IAAC,OAAO,EAAA,EAAA,GAAK,IAAI,EAAE,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,eAAe,EAAE,SAAS,CAAC,YACtE,QAAQ,EAAA,CACH,EACZ;KACL;AAED,IAAA,OAAOA,GAAC,CAAA,wBAAwB,EAAK,EAAA,GAAA,KAAK,GAAI,CAAC;AACnD,EAAE;AAMF,MAAM,wBAAwB,GAAG,CAAC,EAAE,OAAO,EAAE,GAAG,IAAI,EAAwB,EAAE,GAAiC,KAAI;AAC/G,IAAA,OAAOA,gBAAS,IAAI,EAAE,GAAG,EAAE,GAAG,GAAI,CAAC;AACvC,CAAC,CAAC;MAEW,eAAe,GAAG,UAAU,CAAC,wBAAwB;;;;"}
@@ -0,0 +1,18 @@
1
+ import { PropsWithChildren, ReactNode } from 'react';
2
+ import { VirtualizerOptions } from '@tanstack/virtual-core';
3
+ interface VirtualizedListWrapperProps extends PropsWithChildren {
4
+ /** Находится ли список в блоке ограниченной высоты */
5
+ fixedSize?: boolean;
6
+ /** Верхняя панель */
7
+ topPanel?: ReactNode;
8
+ /** Нижняя панель */
9
+ bottomPanel?: ReactNode;
10
+ /** Включена ли виртуализация */
11
+ virtualized?: boolean;
12
+ /** Функция для замера размеров айтема списка (по умолчанию используется getBoundingClientRect.height) */
13
+ measureElement?: VirtualizerOptions<HTMLElement, Element>['measureElement'];
14
+ /** Предполагаемая высота айтема (по умолчанию 80px) */
15
+ estimateSize?: number;
16
+ }
17
+ export declare const VirtualizedListWrapper: import("react").ForwardRefExoticComponent<VirtualizedListWrapperProps & import("react").RefAttributes<HTMLDivElement>>;
18
+ export {};
@@ -0,0 +1,28 @@
1
+ import './../index.css';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { forwardRef, useRef, useMemo } from 'react';
4
+ import classnames from 'classnames';
5
+ import { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';
6
+ import { useScrollbar, Scrollbar } from '@hh.ru/magritte-ui-scrollbar';
7
+ import { VirtualizedListContext, DEFAULT_ITEM_HEIGHT } from './context.js';
8
+ import { s as styles } from '../virtualized-list-B8kzPHyT.js';
9
+
10
+ const VirtualizedListWrapperComponent = ({ fixedSize, topPanel, bottomPanel, virtualized = true, measureElement, estimateSize = DEFAULT_ITEM_HEIGHT, children, }, ref) => {
11
+ const { hasVerticalScroll, verticalScrollbarProps, ...vScrollbar } = useScrollbar({
12
+ axis: fixedSize ? 'vertical' : 'none',
13
+ });
14
+ const contentRef = useRef(null);
15
+ const wrapperRefCallback = useMultipleRefs(ref, vScrollbar.scrollContainerRef);
16
+ const contentRefCallback = useMultipleRefs(contentRef, vScrollbar.contentWrapperRef);
17
+ const value = useMemo(() => ({
18
+ fixedSize,
19
+ virtualized,
20
+ measureElement,
21
+ estimateSize,
22
+ }), [fixedSize, virtualized, measureElement, estimateSize]);
23
+ return (jsxs("div", { className: classnames(styles.virtualizedWrapper, vScrollbar.hoverContainerCssClass), children: [jsx("div", { className: classnames({ [styles.scrollWrapper]: fixedSize }), "data-virtualized-list-wrapper": true, ref: wrapperRefCallback, children: jsxs(VirtualizedListContext.Provider, { value: value, children: [topPanel, jsx("div", { ref: contentRefCallback, "data-virtualized-list-content": true, children: children }), bottomPanel] }) }), hasVerticalScroll && jsx(Scrollbar, { className: styles.verticalScrollbar, ...verticalScrollbarProps })] }));
24
+ };
25
+ const VirtualizedListWrapper = forwardRef(VirtualizedListWrapperComponent);
26
+
27
+ export { VirtualizedListWrapper };
28
+ //# sourceMappingURL=VirtualizedListWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VirtualizedListWrapper.js","sources":["src/VirtualizedList/VirtualizedListWrapper.tsx"],"sourcesContent":["import { ForwardedRef, forwardRef, PropsWithChildren, ReactNode, useMemo, useRef } from 'react';\nimport { VirtualizerOptions } from '@tanstack/virtual-core';\nimport classnames from 'classnames';\n\nimport { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';\nimport { Scrollbar, useScrollbar } from '@hh.ru/magritte-ui-scrollbar';\nimport { VirtualizedListContext, DEFAULT_ITEM_HEIGHT } from '@hh.ru/magritte-ui-table/VirtualizedList/context';\n\nimport styles from './virtualized-list.less';\n\ninterface VirtualizedListWrapperProps extends PropsWithChildren {\n /** Находится ли список в блоке ограниченной высоты */\n fixedSize?: boolean;\n /** Верхняя панель */\n topPanel?: ReactNode;\n /** Нижняя панель */\n bottomPanel?: ReactNode;\n /** Включена ли виртуализация */\n virtualized?: boolean;\n /** Функция для замера размеров айтема списка (по умолчанию используется getBoundingClientRect.height) */\n measureElement?: VirtualizerOptions<HTMLElement, Element>['measureElement'];\n /** Предполагаемая высота айтема (по умолчанию 80px) */\n estimateSize?: number;\n}\n\nconst VirtualizedListWrapperComponent = (\n {\n fixedSize,\n topPanel,\n bottomPanel,\n virtualized = true,\n measureElement,\n estimateSize = DEFAULT_ITEM_HEIGHT,\n children,\n }: VirtualizedListWrapperProps,\n ref: ForwardedRef<HTMLDivElement>\n) => {\n const { hasVerticalScroll, verticalScrollbarProps, ...vScrollbar } = useScrollbar({\n axis: fixedSize ? 'vertical' : 'none',\n });\n const contentRef = useRef<HTMLDivElement>(null);\n const wrapperRefCallback = useMultipleRefs(ref, vScrollbar.scrollContainerRef);\n const contentRefCallback = useMultipleRefs(contentRef, vScrollbar.contentWrapperRef);\n\n const value = useMemo(\n () => ({\n fixedSize,\n virtualized,\n measureElement,\n estimateSize,\n }),\n [fixedSize, virtualized, measureElement, estimateSize]\n );\n\n return (\n <div className={classnames(styles.virtualizedWrapper, vScrollbar.hoverContainerCssClass)}>\n <div\n className={classnames({ [styles.scrollWrapper]: fixedSize })}\n data-virtualized-list-wrapper\n ref={wrapperRefCallback}\n >\n <VirtualizedListContext.Provider value={value}>\n {topPanel}\n <div ref={contentRefCallback} data-virtualized-list-content>\n {children}\n </div>\n {bottomPanel}\n </VirtualizedListContext.Provider>\n </div>\n {hasVerticalScroll && <Scrollbar className={styles.verticalScrollbar} {...verticalScrollbarProps} />}\n </div>\n );\n};\n\nexport const VirtualizedListWrapper = forwardRef(VirtualizedListWrapperComponent);\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;AAyBA,MAAM,+BAA+B,GAAG,CACpC,EACI,SAAS,EACT,QAAQ,EACR,WAAW,EACX,WAAW,GAAG,IAAI,EAClB,cAAc,EACd,YAAY,GAAG,mBAAmB,EAClC,QAAQ,GACkB,EAC9B,GAAiC,KACjC;IACA,MAAM,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,GAAG,UAAU,EAAE,GAAG,YAAY,CAAC;QAC9E,IAAI,EAAE,SAAS,GAAG,UAAU,GAAG,MAAM;AACxC,KAAA,CAAC,CAAC;AACH,IAAA,MAAM,UAAU,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAChD,MAAM,kBAAkB,GAAG,eAAe,CAAC,GAAG,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAC;IAC/E,MAAM,kBAAkB,GAAG,eAAe,CAAC,UAAU,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC;AAErF,IAAA,MAAM,KAAK,GAAG,OAAO,CACjB,OAAO;QACH,SAAS;QACT,WAAW;QACX,cAAc;QACd,YAAY;KACf,CAAC,EACF,CAAC,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,CAAC,CACzD,CAAC;AAEF,IAAA,QACIA,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,kBAAkB,EAAE,UAAU,CAAC,sBAAsB,CAAC,aACpFC,GACI,CAAA,KAAA,EAAA,EAAA,SAAS,EAAE,UAAU,CAAC,EAAE,CAAC,MAAM,CAAC,aAAa,GAAG,SAAS,EAAE,CAAC,EAAA,+BAAA,EAAA,IAAA,EAE5D,GAAG,EAAE,kBAAkB,EAEvB,QAAA,EAAAD,IAAA,CAAC,sBAAsB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,KAAK,EACxC,QAAA,EAAA,CAAA,QAAQ,EACTC,GAAA,CAAA,KAAA,EAAA,EAAK,GAAG,EAAE,kBAAkB,EACvB,+BAAA,EAAA,IAAA,EAAA,QAAA,EAAA,QAAQ,GACP,EACL,WAAW,CACkB,EAAA,CAAA,EAAA,CAChC,EACL,iBAAiB,IAAIA,GAAC,CAAA,SAAS,IAAC,SAAS,EAAE,MAAM,CAAC,iBAAiB,EAAM,GAAA,sBAAsB,EAAI,CAAA,CAAA,EAAA,CAClG,EACR;AACN,CAAC,CAAC;MAEW,sBAAsB,GAAG,UAAU,CAAC,+BAA+B;;;;"}
@@ -0,0 +1,12 @@
1
+ import { FC, PropsWithChildren } from 'react';
2
+ import { TokenColorBackground } from '@hh.ru/magritte-design-tokens/types';
3
+ interface PanelProps extends PropsWithChildren {
4
+ /** Прилипает ли панель сверху */
5
+ stickyTop?: boolean;
6
+ /** Прилипает ли панель снизу */
7
+ stickyBottom?: boolean;
8
+ /** Цвет фона */
9
+ style?: TokenColorBackground;
10
+ }
11
+ export declare const VirtualizedPanel: FC<PanelProps>;
12
+ export {};
@@ -0,0 +1,15 @@
1
+ import './../index.css';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import classnames from 'classnames';
4
+ import { s as styles } from '../virtualized-list-B8kzPHyT.js';
5
+
6
+ const VirtualizedPanel = ({ stickyTop, stickyBottom, style = 'primary', children }) => {
7
+ return (jsx("div", { className: classnames(styles.panelContainer, styles.topPanel, {
8
+ [styles[`panel-style-${style}`]]: style,
9
+ [styles.stickyTop]: stickyTop,
10
+ [styles.stickyBottom]: stickyBottom,
11
+ }), children: jsx("div", { className: classnames(styles.panel), children: children }) }));
12
+ };
13
+
14
+ export { VirtualizedPanel };
15
+ //# sourceMappingURL=VirtualizedPanel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VirtualizedPanel.js","sources":["src/VirtualizedList/VirtualizedPanel.tsx"],"sourcesContent":["import { FC, PropsWithChildren } from 'react';\nimport classnames from 'classnames';\n\nimport { TokenColorBackground } from '@hh.ru/magritte-design-tokens/types';\n\nimport styles from './virtualized-list.less';\n\ninterface PanelProps extends PropsWithChildren {\n /** Прилипает ли панель сверху */\n stickyTop?: boolean;\n /** Прилипает ли панель снизу */\n stickyBottom?: boolean;\n /** Цвет фона */\n style?: TokenColorBackground;\n}\n\nexport const VirtualizedPanel: FC<PanelProps> = ({ stickyTop, stickyBottom, style = 'primary', children }) => {\n return (\n <div\n className={classnames(styles.panelContainer, styles.topPanel, {\n [styles[`panel-style-${style}`]]: style,\n [styles.stickyTop]: stickyTop,\n [styles.stickyBottom]: stickyBottom,\n })}\n >\n <div className={classnames(styles.panel)}>{children}</div>\n </div>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;AAgBa,MAAA,gBAAgB,GAAmB,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,GAAG,SAAS,EAAE,QAAQ,EAAE,KAAI;AACzG,IAAA,QACIA,GAAA,CAAA,KAAA,EAAA,EACI,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,QAAQ,EAAE;YAC1D,CAAC,MAAM,CAAC,CAAe,YAAA,EAAA,KAAK,EAAE,CAAC,GAAG,KAAK;AACvC,YAAA,CAAC,MAAM,CAAC,SAAS,GAAG,SAAS;AAC7B,YAAA,CAAC,MAAM,CAAC,YAAY,GAAG,YAAY;AACtC,SAAA,CAAC,EAEF,QAAA,EAAAA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,EAAG,QAAA,EAAA,QAAQ,EAAO,CAAA,EAAA,CACxD,EACR;AACN;;;;"}
@@ -0,0 +1,9 @@
1
+ import { VirtualizerOptions } from '@tanstack/virtual-core';
2
+ export declare const DEFAULT_ITEM_HEIGHT = 80;
3
+ export interface VirtualizedListContextProps {
4
+ fixedSize?: boolean;
5
+ virtualized?: boolean;
6
+ measureElement?: VirtualizerOptions<HTMLElement, Element>['measureElement'];
7
+ estimateSize: number;
8
+ }
9
+ export declare const VirtualizedListContext: import("react").Context<VirtualizedListContextProps>;
@@ -0,0 +1,10 @@
1
+ import './../index.css';
2
+ import { createContext } from 'react';
3
+
4
+ const DEFAULT_ITEM_HEIGHT = 80;
5
+ const VirtualizedListContext = createContext({
6
+ estimateSize: DEFAULT_ITEM_HEIGHT,
7
+ });
8
+
9
+ export { DEFAULT_ITEM_HEIGHT, VirtualizedListContext };
10
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sources":["src/VirtualizedList/context.tsx"],"sourcesContent":["import { createContext } from 'react';\nimport { VirtualizerOptions } from '@tanstack/virtual-core';\n\nexport const DEFAULT_ITEM_HEIGHT = 80;\n\nexport interface VirtualizedListContextProps {\n fixedSize?: boolean;\n virtualized?: boolean;\n measureElement?: VirtualizerOptions<HTMLElement, Element>['measureElement'];\n estimateSize: number;\n}\n\nexport const VirtualizedListContext = createContext<VirtualizedListContextProps>({\n estimateSize: DEFAULT_ITEM_HEIGHT,\n});\n"],"names":[],"mappings":";;AAGO,MAAM,mBAAmB,GAAG,GAAG;AAS/B,MAAM,sBAAsB,GAAG,aAAa,CAA8B;AAC7E,IAAA,YAAY,EAAE,mBAAmB;AACpC,CAAA;;;;"}
@@ -0,0 +1,3 @@
1
+ export * from '@hh.ru/magritte-ui-table/VirtualizedList/VirtualizedListWrapper';
2
+ export * from '@hh.ru/magritte-ui-table/VirtualizedList/VirtualizedList';
3
+ export * from '@hh.ru/magritte-ui-table/VirtualizedList/VirtualizedPanel';