5
5
InfiniteTable ,
6
6
InfiniteTableColumn ,
7
7
InfiniteTablePropColumns ,
8
+ useInfiniteColumnCell ,
8
9
} from '@infinite-table/infinite-react' ;
9
10
import { DataSource } from '@infinite-table/infinite-react' ;
10
11
@@ -45,15 +46,113 @@ const style: InfiniteTableColumn<any>['style'] = (
45
46
46
47
const header : InfiniteTableColumn < Developer > [ 'header' ] = ( {
47
48
horizontalLayoutPageIndex,
49
+
48
50
column,
49
51
} ) => {
50
52
return (
51
53
< b >
52
- { column . field } - { horizontalLayoutPageIndex }
54
+ { column . field } - { horizontalLayoutPageIndex } { ' ' }
55
+ { column . computedSortedAsc
56
+ ? '📈'
57
+ : column . computedSortedDesc
58
+ ? '📉'
59
+ : '👀' }
53
60
</ b >
54
61
) ;
55
62
} ;
56
63
64
+ // const FlashingColumnCell = React.forwardRef(
65
+ // (props: React.HTMLProps<HTMLDivElement>, ref: React.Ref<HTMLDivElement>) => {
66
+ // const { domRef, value, column, rowInfo } =
67
+ // useInfiniteColumnCell<Developer>();
68
+
69
+ // const flashBackground = 'blue';
70
+ // const [flash, setFlash] = React.useState(false);
71
+
72
+ // const rowId = rowInfo.id;
73
+ // const columnId = column.id;
74
+ // const prevValueRef = React.useRef({
75
+ // columnId,
76
+ // rowId,
77
+ // value,
78
+ // });
79
+
80
+ // console.log(
81
+ // 'render',
82
+ // // props.children?.props?.children?[1].props?.children.props.children[3]
83
+ // );
84
+
85
+ // React.useEffect(() => {
86
+ // const prev = prevValueRef.current;
87
+ // if (
88
+ // prev.value !== value &&
89
+ // prev.rowId === rowId &&
90
+ // prev.columnId === columnId
91
+ // ) {
92
+ // console.log('value changed', value, 'prev', prev.value);
93
+ // setFlash(true);
94
+ // setTimeout(() => {
95
+ // setFlash(false);
96
+ // }, 500);
97
+ // }
98
+
99
+ // console.log('value', value);
100
+ // prevValueRef.current = {
101
+ // columnId: column.id,
102
+ // rowId: rowInfo.id,
103
+ // value,
104
+ // };
105
+ // }, [value, columnId, rowId]);
106
+
107
+ // React.useEffect(() => {
108
+ // console.log('mount');
109
+ // }, []);
110
+
111
+ // return (
112
+ // <div
113
+ // ref={domRef}
114
+ // {...props}
115
+ // style={{
116
+ // ...props.style,
117
+ // background: flash ? flashBackground : props.style?.background,
118
+ // }}
119
+ // >
120
+ // {props.children}
121
+ // </div>
122
+ // );
123
+ // },
124
+ // );
125
+
126
+ // const Flashing = (props: { value: any }) => {
127
+ // const value = props.value;
128
+
129
+ // const prevValueRef = React.useRef(value);
130
+ // const { htmlElementRef } = useInfiniteColumnCell();
131
+ // const flash = () => {
132
+ // if (!htmlElementRef.current) {
133
+ // return;
134
+ // }
135
+
136
+ // htmlElementRef.current!.style.backgroundColor = 'red';
137
+ // setTimeout(() => {
138
+ // htmlElementRef.current!.style.backgroundColor = '';
139
+ // }, 500);
140
+ // };
141
+
142
+ // React.useEffect(() => {
143
+ // if (prevValueRef.current !== value) {
144
+ // flash();
145
+ // }
146
+ // prevValueRef.current = value;
147
+ // }, [value]);
148
+
149
+ // React.useEffect(() => {
150
+ // flash();
151
+ // }, []);
152
+
153
+ // return <div>{props.value}</div>;
154
+ // };
155
+
57
156
const columns : InfiniteTablePropColumns < Developer > = {
58
157
id : {
59
158
field : 'id' ,
@@ -75,6 +174,15 @@ const columns: InfiniteTablePropColumns<Developer> = {
75
174
columnGroup : 'colgroup' ,
76
175
style,
77
176
header,
177
+ // renderValue: ({ value }) => {
178
+ // console.log('renderValue', value);
179
+ // return value;
180
+ // // return <Flashing value={value} />;
181
+ // },
182
+ components : {
183
+ // ColumnCell: FlashingColumnCell,
184
+ // ColumnCell: FlashingColumnCell,
185
+ } ,
78
186
} ,
79
187
firstName : {
80
188
field : 'firstName' ,
@@ -149,6 +257,7 @@ export default () => {
149
257
return fetch ( process . env . NEXT_PUBLIC_BASE_URL + '/developers1k' )
150
258
. then ( ( r ) => r . json ( ) )
151
259
. then ( ( data ) => {
260
+ // data.length = 2;
152
261
return data ;
153
262
// return new Promise((resolve) => {
154
263
// setTimeout(() => {
0 commit comments