@hh.ru/magritte-ui-table 4.0.4 → 4.1.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.
package/BaseTable.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { FC } from 'react';
2
+ import { TableProps } from '@hh.ru/magritte-ui-table/types';
3
+ export declare const BaseTable: FC<TableProps>;
package/BaseTable.js ADDED
@@ -0,0 +1,165 @@
1
+ import './index.css';
2
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
3
+ import { useRef, useState, useMemo, useCallback, useLayoutEffect } from 'react';
4
+ import classnames from 'classnames';
5
+ import { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';
6
+ import { useWhenFontLoaded } from '@hh.ru/magritte-common-use-when-font-loaded';
7
+ import { useScrollbar, Scrollbar } from '@hh.ru/magritte-ui-scrollbar';
8
+ import { VirtualizedListWrapper } from './VirtualizedList/VirtualizedListWrapper.js';
9
+ import { VirtualizedPanel } from './VirtualizedList/VirtualizedPanel.js';
10
+ import { TableContext } from './context.js';
11
+ import { useTableResize } from './useTableResize.js';
12
+ import { c as cellStyles } from './cell-YFy-_qG_.js';
13
+ import { s as styles } from './table-CqVQVOzK.js';
14
+ import './VirtualizedList/context.js';
15
+ import './virtualized-list-VL55s-Jm.js';
16
+
17
+ const measureElement = (element) => {
18
+ let rowHeight = element?.getBoundingClientRect().height;
19
+ const siblingElement = element.nextElementSibling;
20
+ if (siblingElement && siblingElement.hasAttribute('data-magritte-table-row-panel')) {
21
+ rowHeight += siblingElement.getBoundingClientRect().height;
22
+ }
23
+ return rowHeight;
24
+ };
25
+ const BaseTable = ({ 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, stretched, 'data-qa': dataQa = 'table-wrapper', children, }) => {
26
+ const wrapperRef = useRef(null);
27
+ const contentRef = useRef(null);
28
+ const tableRef = useRef(null);
29
+ const headerRef = useRef(null);
30
+ const scrollbarContainerRef = useRef(null);
31
+ const scrollbarRef = useRef(null);
32
+ const [headerNode, setHeaderNode] = useState(null);
33
+ const topWithDivider = dividerTop ?? !!divider;
34
+ const bottomWithDivider = dividerBottom ?? !!divider;
35
+ const paddingLeft = _paddingLeft ?? padding;
36
+ const paddingRight = _paddingRight ?? padding;
37
+ const highlightedColor = styleHighlighted || style;
38
+ const tintedHighlightedColor = tintedStyleHighlighted || tintedStyle;
39
+ const topColor = topStyle || style;
40
+ const bottomColor = bottomStyle || style;
41
+ const [fontLoaded, setFontLoaded] = useState(false);
42
+ useWhenFontLoaded(() => setFontLoaded(true));
43
+ const { subscribeResizeHandler, unsubscribeResizeHandler } = useTableResize({
44
+ tableRef,
45
+ wrapperRef,
46
+ fontLoaded,
47
+ });
48
+ const value = useMemo(() => ({
49
+ headerNode,
50
+ stickyHeader,
51
+ paddingLeft,
52
+ paddingRight,
53
+ fixedSize,
54
+ fontLoaded,
55
+ virtualized,
56
+ divider: !!divider,
57
+ subscribeResizeHandler,
58
+ unsubscribeResizeHandler,
59
+ }), [
60
+ headerNode,
61
+ stickyHeader,
62
+ paddingLeft,
63
+ paddingRight,
64
+ fixedSize,
65
+ fontLoaded,
66
+ divider,
67
+ virtualized,
68
+ subscribeResizeHandler,
69
+ unsubscribeResizeHandler,
70
+ ]);
71
+ const setScrollStyles = useCallback(() => {
72
+ if (wrapperRef.current && contentRef.current) {
73
+ wrapperRef.current.classList.toggle(cellStyles.hasScrollLeft, contentRef.current.scrollLeft > 0);
74
+ wrapperRef.current.classList.toggle(cellStyles.hasScrollRight, Math.round(contentRef.current.scrollLeft) + contentRef.current.offsetWidth + (paddingRight ?? 0) <
75
+ contentRef.current.scrollWidth);
76
+ }
77
+ }, [paddingRight]);
78
+ const setFakeScrollbar = useCallback(() => {
79
+ if (scrollbarRef.current && tableRef.current && contentRef.current && scrollbarContainerRef.current) {
80
+ if (contentRef.current.scrollWidth > contentRef.current.offsetWidth) {
81
+ scrollbarRef.current.style.setProperty('width', `${tableRef.current.getBoundingClientRect().width}px`);
82
+ scrollbarContainerRef.current.style.setProperty('display', 'block');
83
+ }
84
+ else {
85
+ scrollbarRef.current.style.setProperty('width', 'auto');
86
+ scrollbarContainerRef.current.style.setProperty('display', 'none');
87
+ }
88
+ }
89
+ }, []);
90
+ const calcDividersAndScrollbar = useCallback(() => {
91
+ setScrollStyles();
92
+ setFakeScrollbar();
93
+ }, [setScrollStyles, setFakeScrollbar]);
94
+ const handleScrollContent = useCallback(() => {
95
+ if (headerRef.current) {
96
+ headerRef.current.scrollLeft = contentRef.current?.scrollLeft || 0;
97
+ }
98
+ if (scrollbarContainerRef.current) {
99
+ scrollbarContainerRef.current.scrollLeft = contentRef.current?.scrollLeft || 0;
100
+ }
101
+ setScrollStyles();
102
+ onScrollHorizontal?.();
103
+ }, [setScrollStyles, onScrollHorizontal]);
104
+ const handleHeaderScroll = useCallback(() => {
105
+ if (contentRef.current) {
106
+ contentRef.current.scrollLeft = headerRef.current?.scrollLeft || 0;
107
+ }
108
+ if (scrollbarContainerRef.current) {
109
+ scrollbarContainerRef.current.scrollLeft = headerRef.current?.scrollLeft || 0;
110
+ }
111
+ }, []);
112
+ const handleScrollContainerScroll = useCallback(() => {
113
+ if (contentRef.current) {
114
+ contentRef.current.scrollLeft = scrollbarContainerRef.current?.scrollLeft || 0;
115
+ }
116
+ if (headerRef.current) {
117
+ headerRef.current.scrollLeft = scrollbarContainerRef.current?.scrollLeft || 0;
118
+ }
119
+ }, []);
120
+ const headerRefCallback = useCallback((node) => {
121
+ if (node) {
122
+ setHeaderNode(node);
123
+ headerRef.current = node;
124
+ }
125
+ else {
126
+ headerRef.current = null;
127
+ }
128
+ }, []);
129
+ useLayoutEffect(() => {
130
+ calcDividersAndScrollbar();
131
+ subscribeResizeHandler?.(calcDividersAndScrollbar);
132
+ return () => unsubscribeResizeHandler?.(calcDividersAndScrollbar);
133
+ }, [calcDividersAndScrollbar, subscribeResizeHandler, unsubscribeResizeHandler]);
134
+ const { hasHorizontalScroll, horizontalScrollbarProps, ...hScrollbar } = useScrollbar({
135
+ axis: 'horizontal',
136
+ offsetRight: fixedSize ? 8 : undefined,
137
+ });
138
+ const scrollContainerRefCallback = useMultipleRefs(scrollbarContainerRef, hScrollbar.scrollContainerRef);
139
+ const scrollContentRefCallback = useMultipleRefs(scrollbarRef, hScrollbar.contentWrapperRef);
140
+ const topPanel = _topPanel || stickyHeader ? (jsxs(VirtualizedPanel, { stickyTop: stickyHeader, style: topColor, children: [_topPanel && (jsx("div", { className: classnames(styles.topPanel, {
141
+ [styles.withDivider]: topWithDivider,
142
+ }), "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;
143
+ 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, {
144
+ [styles.withDivider]: bottomWithDivider,
145
+ }), "data-qa": "table-bottom-panel", style: { paddingLeft, paddingRight }, children: _bottomPanel })] }))] }));
146
+ return (jsx("div", { className: classnames(styles.wrapper, {
147
+ [styles.stretched]: stretched,
148
+ [styles[`style-${style}`]]: style,
149
+ [styles[`style-highlighted-${highlightedColor}`]]: highlightedColor,
150
+ [styles[`tinted-style-${tintedStyle}`]]: tinted && tintedStyle,
151
+ [styles[`tinted-style-highlighted-${tintedHighlightedColor}`]]: tinted && tintedHighlightedColor,
152
+ }), "data-qa": dataQa, style: {
153
+ '--magritte-table-padding-left': `${paddingLeft ?? 0}px`,
154
+ '--magritte-table-padding-right': `${paddingRight ?? 0}px`,
155
+ '--magritte-table-row-gap': `${density}px 0`,
156
+ '--magritte-table-row-panel-gap': `0 0 ${density}px`,
157
+ ...(typeof cellsGap === 'number' ? { '--magritte-table-cell-padding': `${cellsGap / 2}px` } : {}),
158
+ }, 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, {
159
+ [styles.stretched]: stretched,
160
+ [styles.divider]: !!divider,
161
+ }), "data-qa": "table", ref: tableRef, children: children }) }) }) }) }));
162
+ };
163
+
164
+ export { BaseTable };
165
+ //# sourceMappingURL=BaseTable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseTable.js","sources":["src/BaseTable.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 { 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 BaseTable: 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 stretched,\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\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 calcDividersAndScrollbar();\n subscribeResizeHandler?.(calcDividersAndScrollbar);\n\n return () => unsubscribeResizeHandler?.(calcDividersAndScrollbar);\n }, [calcDividersAndScrollbar, 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 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.stretched]: stretched,\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 ...(typeof cellsGap === 'number' ? { '--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.stretched]: stretched,\n [styles.divider]: !!divider,\n })}\n data-qa=\"table\"\n ref={tableRef}\n >\n {children}\n </table>\n </div>\n </TableContext.Provider>\n </VirtualizedListWrapper>\n </div>\n );\n};\n"],"names":["_jsxs","_jsx","_Fragment"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAM,cAAc,GAAG,CAAC,OAAgB,KAAI;IACxC,IAAI,SAAS,GAAG,OAAO,EAAE,qBAAqB,EAAE,CAAC,MAAM,CAAC;AACxD,IAAA,MAAM,cAAc,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAClD,IAAI,cAAc,IAAI,cAAc,CAAC,YAAY,CAAC,+BAA+B,CAAC,EAAE;AAChF,QAAA,SAAS,IAAI,cAAc,CAAC,qBAAqB,EAAE,CAAC,MAAM,CAAC;KAC9D;AACD,IAAA,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AAEW,MAAA,SAAS,GAAmB,CAAC,EACtC,OAAO,GAAG,EAAE,EACZ,QAAQ,EAAE,SAAS,EACnB,WAAW,EAAE,YAAY,EACzB,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,EACT,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,CA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C,OAAO;AAC9B,yBAAA,CAAC,EACM,SAAA,EAAA,OAAO,EACf,GAAG,EAAE,QAAQ,EAAA,QAAA,EAEZ,QAAQ,EAAA,CACL,EACN,CAAA,EAAA,CACc,EACH,CAAA,EAAA,CACvB,EACR;AACN;;;;"}
@@ -0,0 +1,3 @@
1
+ import { FC } from 'react';
2
+ import { SimpleTableProps } from '@hh.ru/magritte-ui-table/types';
3
+ export declare const SimpleTable: FC<SimpleTableProps>;
package/SimpleTable.js ADDED
@@ -0,0 +1,23 @@
1
+ import './index.css';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { BaseTable } from './BaseTable.js';
4
+ import 'react';
5
+ import 'classnames';
6
+ import '@hh.ru/magritte-common-use-multiple-refs';
7
+ import '@hh.ru/magritte-common-use-when-font-loaded';
8
+ import '@hh.ru/magritte-ui-scrollbar';
9
+ import './VirtualizedList/VirtualizedListWrapper.js';
10
+ import './VirtualizedList/context.js';
11
+ import './virtualized-list-VL55s-Jm.js';
12
+ import './VirtualizedList/VirtualizedPanel.js';
13
+ import './context.js';
14
+ import './useTableResize.js';
15
+ import './cell-YFy-_qG_.js';
16
+ import './table-CqVQVOzK.js';
17
+
18
+ const SimpleTable = (props) => {
19
+ return jsx(BaseTable, { ...props, virtualized: false });
20
+ };
21
+
22
+ export { SimpleTable };
23
+ //# sourceMappingURL=SimpleTable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SimpleTable.js","sources":["src/SimpleTable.tsx"],"sourcesContent":["import { FC } from 'react';\n\nimport { BaseTable } from '@hh.ru/magritte-ui-table/BaseTable';\nimport { SimpleTableProps } from '@hh.ru/magritte-ui-table/types';\n\nexport const SimpleTable: FC<SimpleTableProps> = (props) => {\n return <BaseTable {...props} virtualized={false}></BaseTable>;\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;;AAKa,MAAA,WAAW,GAAyB,CAAC,KAAK,KAAI;IACvD,OAAOA,GAAA,CAAC,SAAS,EAAK,EAAA,GAAA,KAAK,EAAE,WAAW,EAAE,KAAK,EAAA,CAAc,CAAC;AAClE;;;;"}
@@ -4,8 +4,8 @@ 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-7oIL_F5q.js';
8
- import { s as styles } from './table-QMqzXL_B.js';
7
+ import { c as cellStyles } from './cell-YFy-_qG_.js';
8
+ import { s as styles } from './table-CqVQVOzK.js';
9
9
 
10
10
  const StickyTableHeader = ({ root, divider, density, headerRef, children }) => {
11
11
  const ref = useRef(null);
@@ -24,7 +24,11 @@ const StickyTableHeader = ({ root, divider, density, headerRef, children }) => {
24
24
  });
25
25
  root.style.setProperty('margin-bottom', `-${headerRef.current.getBoundingClientRect().height}px`);
26
26
  }
27
- }, [headerRef, root]);
27
+ // *
28
+ // children стоит в зависимостях, тк есть кейсы, когда контент в ячейке может поменяться, а
29
+ // ячейка была по контенту и ее ширина изменилась - надо чтобы соответствующая колонка в стики шапке на это отреагировала и тоже поменяла свою ширину
30
+ // eslint-disable-next-line disable-autofix/react-hooks/exhaustive-deps
31
+ }, [headerRef, root, children]);
28
32
  useLayoutEffect(() => {
29
33
  if (root && renderPortal) {
30
34
  calcWidth();
@@ -1 +1 @@
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,wB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AAC;AACZ,YAAA,sBAAsB,GAAG,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;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;;;;"}
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 // *\n // children стоит в зависимостях, тк есть кейсы, когда контент в ячейке может поменяться, а\n // ячейка была по контенту и ее ширина изменилась - надо чтобы соответствующая колонка в стики шапке на это отреагировала и тоже поменяла свою ширину\n // eslint-disable-next-line disable-autofix/react-hooks/exhaustive-deps\n }, [headerRef, root, children]);\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,QAA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KJ,EAAE,CAAC,SAAS,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEhC,eAAe,CAAC,MAAK;AACjB,QAAA,IAAI,IAAI,IAAI,YAAY,EAAE;AACtB,YAAA,SAAS,EAAE,CAAC;AACZ,YAAA,sBAAsB,GAAG,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;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
@@ -1,170 +1,27 @@
1
1
  import './index.css';
2
- import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
3
- import { useRef, useState, useMemo, useCallback, useLayoutEffect } from 'react';
4
- import classnames from 'classnames';
5
- import { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';
6
- import { useWhenFontLoaded } from '@hh.ru/magritte-common-use-when-font-loaded';
2
+ import { jsx } from 'react/jsx-runtime';
7
3
  import { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';
8
- import { useScrollbar, Scrollbar } from '@hh.ru/magritte-ui-scrollbar';
9
- import { VirtualizedListWrapper } from './VirtualizedList/VirtualizedListWrapper.js';
10
- import { VirtualizedPanel } from './VirtualizedList/VirtualizedPanel.js';
11
- import { TableContext } from './context.js';
12
- import { useTableResize } from './useTableResize.js';
13
- import { c as cellStyles } from './cell-7oIL_F5q.js';
14
- import { s as styles } from './table-QMqzXL_B.js';
4
+ import { BaseTable } from './BaseTable.js';
5
+ import 'react';
6
+ import 'classnames';
7
+ import '@hh.ru/magritte-common-use-multiple-refs';
8
+ import '@hh.ru/magritte-common-use-when-font-loaded';
9
+ import '@hh.ru/magritte-ui-scrollbar';
10
+ import './VirtualizedList/VirtualizedListWrapper.js';
15
11
  import './VirtualizedList/context.js';
16
- import './virtualized-list-BYDoC__0.js';
12
+ import './virtualized-list-VL55s-Jm.js';
13
+ import './VirtualizedList/VirtualizedPanel.js';
14
+ import './context.js';
15
+ import './useTableResize.js';
16
+ import './cell-YFy-_qG_.js';
17
+ import './table-CqVQVOzK.js';
17
18
 
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;
25
- };
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, }) => {
27
- const wrapperRef = useRef(null);
28
- const contentRef = useRef(null);
29
- const tableRef = useRef(null);
30
- const headerRef = useRef(null);
31
- const scrollbarContainerRef = useRef(null);
32
- const scrollbarRef = useRef(null);
33
- const [headerNode, setHeaderNode] = useState(null);
34
- const topWithDivider = dividerTop ?? !!divider;
35
- const bottomWithDivider = dividerBottom ?? !!divider;
36
- const paddingLeft = _paddingLeft ?? padding;
37
- const paddingRight = _paddingRight ?? padding;
38
- const highlightedColor = styleHighlighted || style;
39
- const tintedHighlightedColor = tintedStyleHighlighted || tintedStyle;
40
- const topColor = topStyle || style;
41
- const bottomColor = bottomStyle || style;
42
- const [fontLoaded, setFontLoaded] = useState(false);
19
+ const Table = (props) => {
43
20
  const { isMobile } = useBreakpoint();
44
- useWhenFontLoaded(() => setFontLoaded(true));
45
- const { subscribeResizeHandler, unsubscribeResizeHandler } = useTableResize({
46
- tableRef,
47
- wrapperRef,
48
- fontLoaded,
49
- });
50
- const value = useMemo(() => ({
51
- headerNode,
52
- stickyHeader,
53
- paddingLeft,
54
- paddingRight,
55
- fixedSize,
56
- fontLoaded,
57
- virtualized,
58
- divider: !!divider,
59
- subscribeResizeHandler,
60
- unsubscribeResizeHandler,
61
- }), [
62
- headerNode,
63
- stickyHeader,
64
- paddingLeft,
65
- paddingRight,
66
- fixedSize,
67
- fontLoaded,
68
- divider,
69
- virtualized,
70
- subscribeResizeHandler,
71
- unsubscribeResizeHandler,
72
- ]);
73
- const setScrollStyles = useCallback(() => {
74
- if (wrapperRef.current && contentRef.current) {
75
- wrapperRef.current.classList.toggle(cellStyles.hasScrollLeft, contentRef.current.scrollLeft > 0);
76
- wrapperRef.current.classList.toggle(cellStyles.hasScrollRight, Math.round(contentRef.current.scrollLeft) + contentRef.current.offsetWidth + (paddingRight ?? 0) <
77
- contentRef.current.scrollWidth);
78
- }
79
- }, [paddingRight]);
80
- const setFakeScrollbar = useCallback(() => {
81
- if (scrollbarRef.current && tableRef.current && contentRef.current && scrollbarContainerRef.current) {
82
- if (contentRef.current.scrollWidth > contentRef.current.offsetWidth) {
83
- scrollbarRef.current.style.setProperty('width', `${tableRef.current.getBoundingClientRect().width}px`);
84
- scrollbarContainerRef.current.style.setProperty('display', 'block');
85
- }
86
- else {
87
- scrollbarRef.current.style.setProperty('width', 'auto');
88
- scrollbarContainerRef.current.style.setProperty('display', 'none');
89
- }
90
- }
91
- }, []);
92
- const calcDividersAndScrollbar = useCallback(() => {
93
- setScrollStyles();
94
- setFakeScrollbar();
95
- }, [setScrollStyles, setFakeScrollbar]);
96
- const handleScrollContent = useCallback(() => {
97
- if (headerRef.current) {
98
- headerRef.current.scrollLeft = contentRef.current?.scrollLeft || 0;
99
- }
100
- if (scrollbarContainerRef.current) {
101
- scrollbarContainerRef.current.scrollLeft = contentRef.current?.scrollLeft || 0;
102
- }
103
- setScrollStyles();
104
- onScrollHorizontal?.();
105
- }, [setScrollStyles, onScrollHorizontal]);
106
- const handleHeaderScroll = useCallback(() => {
107
- if (contentRef.current) {
108
- contentRef.current.scrollLeft = headerRef.current?.scrollLeft || 0;
109
- }
110
- if (scrollbarContainerRef.current) {
111
- scrollbarContainerRef.current.scrollLeft = headerRef.current?.scrollLeft || 0;
112
- }
113
- }, []);
114
- const handleScrollContainerScroll = useCallback(() => {
115
- if (contentRef.current) {
116
- contentRef.current.scrollLeft = scrollbarContainerRef.current?.scrollLeft || 0;
117
- }
118
- if (headerRef.current) {
119
- headerRef.current.scrollLeft = scrollbarContainerRef.current?.scrollLeft || 0;
120
- }
121
- }, []);
122
- const headerRefCallback = useCallback((node) => {
123
- if (node) {
124
- setHeaderNode(node);
125
- headerRef.current = node;
126
- }
127
- else {
128
- headerRef.current = null;
129
- }
130
- }, []);
131
- useLayoutEffect(() => {
132
- if (!isMobile) {
133
- calcDividersAndScrollbar();
134
- subscribeResizeHandler?.(calcDividersAndScrollbar);
135
- return () => unsubscribeResizeHandler?.(calcDividersAndScrollbar);
136
- }
137
- return void 0;
138
- }, [calcDividersAndScrollbar, isMobile, subscribeResizeHandler, unsubscribeResizeHandler]);
139
- const { hasHorizontalScroll, horizontalScrollbarProps, ...hScrollbar } = useScrollbar({
140
- axis: 'horizontal',
141
- offsetRight: fixedSize ? 8 : undefined,
142
- });
143
- const scrollContainerRefCallback = useMultipleRefs(scrollbarContainerRef, hScrollbar.scrollContainerRef);
144
- const scrollContentRefCallback = useMultipleRefs(scrollbarRef, hScrollbar.contentWrapperRef);
145
21
  if (isMobile) {
146
22
  return null;
147
23
  }
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, {
155
- [styles[`style-${style}`]]: style,
156
- [styles[`style-highlighted-${highlightedColor}`]]: highlightedColor,
157
- [styles[`tinted-style-${tintedStyle}`]]: tinted && tintedStyle,
158
- [styles[`tinted-style-highlighted-${tintedHighlightedColor}`]]: tinted && tintedHighlightedColor,
159
- }), "data-qa": dataQa, style: {
160
- '--magritte-table-padding-left': `${paddingLeft ?? 0}px`,
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`,
164
- ...(cellsGap ? { '--magritte-table-cell-padding': `${cellsGap / 2}px` } : {}),
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 }) }) }) }) }));
24
+ return jsx(BaseTable, { ...props });
168
25
  };
169
26
 
170
27
  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 { 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 </VirtualizedListWrapper>\n </div>\n );\n};\n"],"names":["_jsxs","_jsx","_Fragment"],"mappings":";;;;;;;;;;;;;;;;AAgBA,MAAM,cAAc,GAAG,CAAC,OAAgB,KAAI;IACxC,IAAI,SAAS,GAAG,OAAO,EAAE,qBAAqB,EAAE,CAAC,MAAM,CAAC;AACxD,IAAA,MAAM,cAAc,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAClD,IAAI,cAAc,IAAI,cAAc,CAAC,YAAY,CAAC,+BAA+B,CAAC,EAAE;AAChF,QAAA,SAAS,IAAI,cAAc,CAAC,qBAAqB,EAAE,CAAC,MAAM,CAAC;KAC9D;AACD,IAAA,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AAEK,MAAM,KAAK,GAAmB,CAAC,EAClC,OAAO,GAAG,EAAE,EACZ,QAAQ,EAAE,SAAS,EACnB,WAAW,EAAE,YAAY,EACzB,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,MAAM,CAAwB,I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ACL,EACN,CAAA,EAAA,CACc,EACH,CAAA,EAAA,CACvB,EACR;AACN;;;;"}
1
+ {"version":3,"file":"Table.js","sources":["src/Table.tsx"],"sourcesContent":["import { FC } from 'react';\n\nimport { useBreakpoint } from '@hh.ru/magritte-ui-breakpoint';\nimport { BaseTable } from '@hh.ru/magritte-ui-table/BaseTable';\nimport { TableProps } from '@hh.ru/magritte-ui-table/types';\n\nexport const Table: FC<TableProps> = (props) => {\n const { isMobile } = useBreakpoint();\n if (isMobile) {\n return null;\n }\n\n return <BaseTable {...props} />;\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;;;AAMa,MAAA,KAAK,GAAmB,CAAC,KAAK,KAAI;AAC3C,IAAA,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAa,EAAE,CAAC;IACrC,IAAI,QAAQ,EAAE;AACV,QAAA,OAAO,IAAI,CAAC;KACf;AAED,IAAA,OAAOA,GAAC,CAAA,SAAS,EAAK,EAAA,GAAA,KAAK,GAAI,CAAC;AACpC;;;;"}
package/TableBody.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import './index.css';
2
2
  import { jsx } from 'react/jsx-runtime';
3
3
  import { VirtualizedList } from './VirtualizedList/VirtualizedList.js';
4
- import { s as styles } from './table-QMqzXL_B.js';
4
+ import { s as styles } from './table-CqVQVOzK.js';
5
5
  import 'react';
6
6
  import 'classnames';
7
7
  import './VirtualizedList/context.js';
8
8
  import './VirtualizedList/useVirtualizedList.js';
9
9
  import '@tanstack/react-virtual';
10
- import './virtualized-list-BYDoC__0.js';
10
+ import './virtualized-list-VL55s-Jm.js';
11
11
 
12
12
  const TableBody = ({ 'data-qa': dataQa = 'table-body', children, }) => {
13
13
  return (jsx(VirtualizedList, { className: styles.body, "data-qa": dataQa, Element: 'tbody', ElementItem: 'tr', children: children }));
package/TableCell.js CHANGED
@@ -4,11 +4,16 @@ import { forwardRef, useRef, useContext, useCallback, useLayoutEffect } from 're
4
4
  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
+ import { generateCssVarsFromMap } from '@hh.ru/magritte-ui-layout';
7
8
  import { TableContext } from './context.js';
8
- import { c as cellStyles } from './cell-7oIL_F5q.js';
9
- import { s as styles } from './table-QMqzXL_B.js';
9
+ import { c as cellStyles } from './cell-YFy-_qG_.js';
10
+ import { s as styles } from './table-CqVQVOzK.js';
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
+ const TableCellComponent = ({ Element = 'td', m, l, xl, xxl, width: _widthValue, children, stickyLeft, stickyRight, align, verticalAlign, stretched = true, 'data-qa': dataQa = 'table-cell', ...rest }, ref) => {
13
+ const isWidthObject = typeof _widthValue === 'object' && _widthValue !== null && !Array.isArray(_widthValue);
14
+ const cssVars = isWidthObject
15
+ ? generateCssVarsFromMap({ width: _widthValue }, { width: '--table-cell-w' })
16
+ : { width: _widthValue, maxWidth: _widthValue };
12
17
  const cellRef = useRef(null);
13
18
  const multiRef = useMultipleRefs(ref, cellRef);
14
19
  const extendsL = l ?? m;
@@ -47,6 +52,8 @@ const TableCellComponent = ({ Element = 'td', m, l, xl, xxl, width, children, st
47
52
  unsubscribeResizeHandler,
48
53
  ]);
49
54
  return (jsx(Element, { ...rest, "data-qa": dataQa, "data-magritte-table-cell": true, className: classnames(cellStyles.cell, styles.td, {
55
+ [cellStyles.noStretched]: !stretched,
56
+ [cellStyles.withWidth]: !!isWidthObject,
50
57
  [cellStyles[`cell_m-${m}`]]: m,
51
58
  [cellStyles[`cell_l-${extendsL}`]]: extendsL,
52
59
  [cellStyles[`cell_xl-${extendsXL}`]]: extendsXL,
@@ -58,8 +65,7 @@ const TableCellComponent = ({ Element = 'td', m, l, xl, xxl, width, children, st
58
65
  }), ref: multiRef, style: {
59
66
  textAlign: align,
60
67
  verticalAlign,
61
- width,
62
- maxWidth: width,
68
+ ...cssVars,
63
69
  }, children: children }));
64
70
  };
65
71
  const TableCell = forwardRef(TableCellComponent);