@true-engineering/true-react-common-ui-kit 3.0.0-alpha.2 → 3.0.0-alpha.3
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/dist/components/FlexibleTable/FlexibleTable.styles.d.ts +1 -1
- package/dist/true-react-common-ui-kit.js +170 -146
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +170 -146
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/package.json +1 -1
- package/src/components/FlexibleTable/FlexibleTable.stories.tsx +14 -12
- package/src/components/FlexibleTable/FlexibleTable.styles.ts +4 -10
- package/src/components/FlexibleTable/FlexibleTable.tsx +12 -14
- package/src/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.styles.ts +4 -0
package/package.json
CHANGED
|
@@ -315,18 +315,20 @@ const tweak: IFlexibleTableStyles = {
|
|
|
315
315
|
};
|
|
316
316
|
|
|
317
317
|
const Template: ComponentStory<typeof FlexibleTable<ITableContent>> = (args) => (
|
|
318
|
-
<
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
item
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
318
|
+
<div style={{ width: 500, overflow: 'auto' }}>
|
|
319
|
+
<FlexibleTable<ITableContent>
|
|
320
|
+
{...args}
|
|
321
|
+
uniqueField="contractCode"
|
|
322
|
+
expandableRowComponent={(item, _, close) =>
|
|
323
|
+
item.contractCode === 'OB_UT_M119' ? (
|
|
324
|
+
<div onClick={close}>всем привет :) {item.contractCode}</div>
|
|
325
|
+
) : null
|
|
326
|
+
}
|
|
327
|
+
tweakStyles={tweak}
|
|
328
|
+
content={content}
|
|
329
|
+
config={config}
|
|
330
|
+
/>
|
|
331
|
+
</div>
|
|
330
332
|
);
|
|
331
333
|
|
|
332
334
|
export const Default = Template.bind({});
|
|
@@ -22,16 +22,6 @@ export const useStyles = createThemedStyles('FlexibleTable', {
|
|
|
22
22
|
maxHeight: '100%',
|
|
23
23
|
},
|
|
24
24
|
|
|
25
|
-
horizontallyScrolled: {
|
|
26
|
-
'& $cellSticky': {
|
|
27
|
-
boxShadow: '4px 0 4px rgba(0, 0, 0, 0.05)',
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
'& $headerSticky::before': {
|
|
31
|
-
boxShadow: '4px 0 4px rgba(0, 0, 0, 0.05)',
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
|
|
35
25
|
loader: {
|
|
36
26
|
position: 'sticky',
|
|
37
27
|
left: 0,
|
|
@@ -75,6 +65,10 @@ export const useStyles = createThemedStyles('FlexibleTable', {
|
|
|
75
65
|
pointerEvents: 'none',
|
|
76
66
|
zIndex: 1,
|
|
77
67
|
transition: ['box-shadow', '0.25s', 'ease-in-out'],
|
|
68
|
+
|
|
69
|
+
'[data-scrolled] &': {
|
|
70
|
+
boxShadow: '4px 0 4px rgba(0, 0, 0, 0.05)',
|
|
71
|
+
},
|
|
78
72
|
},
|
|
79
73
|
|
|
80
74
|
'&::after': {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReactNode, RefObject, useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
+
import { addDataTestId } from '@true-engineering/true-react-platform-helpers';
|
|
3
4
|
import { addDataAttributes } from '../../helpers';
|
|
4
5
|
import { useTweakStyles } from '../../hooks';
|
|
5
6
|
import { ICommonProps } from '../../types';
|
|
@@ -41,7 +42,7 @@ export function FlexibleTable<Values extends Record<string, any>>({
|
|
|
41
42
|
isHorizontallyScrollable,
|
|
42
43
|
isFirstColumnSticky,
|
|
43
44
|
infinityScrollConfig,
|
|
44
|
-
uniqueField,
|
|
45
|
+
uniqueField = 'id',
|
|
45
46
|
onHeadClick,
|
|
46
47
|
onRowHover,
|
|
47
48
|
onRowClick,
|
|
@@ -111,12 +112,10 @@ export function FlexibleTable<Values extends Record<string, any>>({
|
|
|
111
112
|
return (
|
|
112
113
|
<div
|
|
113
114
|
ref={refForScroll ?? scrollRef}
|
|
114
|
-
className={clsx(
|
|
115
|
-
|
|
116
|
-
isHorizontallyScrolled && classes.horizontallyScrolled,
|
|
117
|
-
)}
|
|
115
|
+
className={clsx({ [classes.scroll]: isHorizontallyScrollable })}
|
|
116
|
+
data-scrolled={isHorizontallyScrolled ? true : undefined}
|
|
118
117
|
>
|
|
119
|
-
<table className={classes.root}
|
|
118
|
+
<table className={classes.root} {...addDataTestId(testId)} {...addDataAttributes(data)}>
|
|
120
119
|
<thead>
|
|
121
120
|
<tr className={classes.headerRow}>
|
|
122
121
|
{(enabledColumns || Object.keys(content[0])).map((key, idx) => {
|
|
@@ -131,11 +130,10 @@ export function FlexibleTable<Values extends Record<string, any>>({
|
|
|
131
130
|
|
|
132
131
|
return (
|
|
133
132
|
<th
|
|
134
|
-
className={clsx(
|
|
135
|
-
classes.
|
|
136
|
-
isFirstColumnSticky && idx ===
|
|
137
|
-
|
|
138
|
-
)}
|
|
133
|
+
className={clsx(classes.header, {
|
|
134
|
+
[classes.headerSticky]: isFirstColumnSticky && idx === 0,
|
|
135
|
+
[classes.headerSecond]: isFirstColumnSticky && idx === 1,
|
|
136
|
+
})}
|
|
139
137
|
style={{
|
|
140
138
|
minWidth: itemConfig?.minWidth,
|
|
141
139
|
width: itemConfig?.width,
|
|
@@ -163,17 +161,17 @@ export function FlexibleTable<Values extends Record<string, any>>({
|
|
|
163
161
|
</tr>
|
|
164
162
|
)}
|
|
165
163
|
|
|
166
|
-
{content.map((item,
|
|
164
|
+
{content.map((item, i) => (
|
|
167
165
|
<FlexibleTableRow
|
|
168
166
|
item={item}
|
|
169
167
|
uniqueField={uniqueField}
|
|
170
|
-
isActive={activeRows?.includes(
|
|
168
|
+
isActive={activeRows?.includes(i) ?? false}
|
|
171
169
|
isFirstColumnSticky={isFirstColumnSticky}
|
|
172
170
|
onRowClick={onRowClick}
|
|
173
171
|
onRowHover={onRowHover}
|
|
174
172
|
enabledColumns={enabledColumns}
|
|
175
173
|
config={config}
|
|
176
|
-
key={
|
|
174
|
+
key={item[uniqueField] ?? i}
|
|
177
175
|
rowAttributes={rowAttributes}
|
|
178
176
|
tweakStyles={tweakTableRowStyles}
|
|
179
177
|
expandableRowComponent={expandableRowComponent}
|