orc-shared 5.10.0-dev.7 → 5.10.0-dev.9
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/AppFrame/Preferences.js +46 -45
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +15 -3
- package/dist/components/MaterialUI/DataDisplay/Table.js +15 -8
- package/dist/hocs/withScrollBox.js +9 -3
- package/dist/hooks/useInMemoryPaging.js +139 -0
- package/dist/utils/ListHelper.js +271 -0
- package/dist/utils/comparisonHelper.js +176 -0
- package/package.json +1 -1
- package/src/components/AppFrame/Preferences.js +30 -29
- package/src/components/AppFrame/Preferences.test.js +108 -123
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +17 -2
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.test.js +3 -1
- package/src/components/MaterialUI/DataDisplay/Table.js +121 -121
- package/src/components/MaterialUI/DataDisplay/Table.test.js +115 -1
- package/src/hocs/withScrollBox.js +10 -5
- package/src/hocs/withScrollBox.test.js +12 -0
- package/src/hooks/useInMemoryPaging.js +85 -0
- package/src/hooks/useInMemoryPaging.test.js +551 -0
- package/src/utils/ListHelper.js +203 -0
- package/src/utils/ListHelper.test.js +710 -0
- package/src/utils/comparisonHelper.js +124 -0
- package/src/utils/comparisonHelper.test.js +324 -0
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import Immutable from "immutable";
|
|
3
|
-
import { Provider } from "react-redux";
|
|
4
|
-
import { IntlProvider } from "react-intl";
|
|
5
3
|
import { RSAA } from "redux-api-middleware";
|
|
6
4
|
import sinon from "sinon";
|
|
7
5
|
import { Ignore } from "unexpected-reaction";
|
|
@@ -23,14 +21,15 @@ import Preferences, {
|
|
|
23
21
|
PrefForm,
|
|
24
22
|
Footer,
|
|
25
23
|
PrefButton,
|
|
26
|
-
createGetUpdater,
|
|
27
24
|
PREFS_NAME,
|
|
28
25
|
clickOutsideHandler,
|
|
26
|
+
stateEventUpdater,
|
|
29
27
|
} from "./Preferences";
|
|
30
28
|
import { RESET_VERSION_INFO } from "../../actions/versionInfo";
|
|
31
|
-
import { extractMessages } from "./../../utils/testUtils";
|
|
29
|
+
import { extractMessages, TestWrapper } from "./../../utils/testUtils";
|
|
32
30
|
import sharedMessages from "./../../sharedMessages";
|
|
33
31
|
import { stringifyWithoutQuotes } from "./../../utils/parseHelper";
|
|
32
|
+
import InformationItem from "../MaterialUI/DataDisplay/PredefinedElements/InformationItem";
|
|
34
33
|
|
|
35
34
|
const messages = extractMessages(sharedMessages);
|
|
36
35
|
|
|
@@ -148,11 +147,9 @@ describe("Preferences", () => {
|
|
|
148
147
|
|
|
149
148
|
it("renders a form dialog", () => {
|
|
150
149
|
return expect(
|
|
151
|
-
<
|
|
152
|
-
<
|
|
153
|
-
|
|
154
|
-
</IntlProvider>
|
|
155
|
-
</Provider>,
|
|
150
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider>
|
|
151
|
+
<Preferences />
|
|
152
|
+
</TestWrapper>,
|
|
156
153
|
"when mounted",
|
|
157
154
|
"to satisfy",
|
|
158
155
|
null,
|
|
@@ -166,29 +163,29 @@ describe("Preferences", () => {
|
|
|
166
163
|
target: getStyledClassSelector(PrefButton) + ":last-child",
|
|
167
164
|
},
|
|
168
165
|
"to satisfy",
|
|
169
|
-
<
|
|
166
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider>
|
|
170
167
|
<div>
|
|
171
168
|
<div>
|
|
172
|
-
<
|
|
173
|
-
|
|
174
|
-
<
|
|
175
|
-
<label
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
</
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
</
|
|
188
|
-
</
|
|
169
|
+
<div>
|
|
170
|
+
<Header>{stringifyWithoutQuotes(messages["orc-shared.preferences"])}</Header>
|
|
171
|
+
<PrefForm>
|
|
172
|
+
<InformationItem label={sharedMessages.displayLanguage}>
|
|
173
|
+
<Ignore />
|
|
174
|
+
</InformationItem>
|
|
175
|
+
<InformationItem label={sharedMessages.defaultApp}>
|
|
176
|
+
<Ignore />
|
|
177
|
+
</InformationItem>
|
|
178
|
+
</PrefForm>
|
|
179
|
+
<Footer>
|
|
180
|
+
<PrefButton id="cancelPrefs">{stringifyWithoutQuotes(messages["orc-shared.cancel"])}</PrefButton>
|
|
181
|
+
<PrefButton id="savePrefs" primary>
|
|
182
|
+
{stringifyWithoutQuotes(messages["orc-shared.save"])}
|
|
183
|
+
</PrefButton>
|
|
184
|
+
</Footer>
|
|
185
|
+
</div>
|
|
189
186
|
</div>
|
|
190
187
|
</div>
|
|
191
|
-
</
|
|
188
|
+
</TestWrapper>,
|
|
192
189
|
),
|
|
193
190
|
)
|
|
194
191
|
.then(() =>
|
|
@@ -203,11 +200,9 @@ describe("Preferences", () => {
|
|
|
203
200
|
it("shows view state fields, saves language change", () => {
|
|
204
201
|
state = state.setIn(["view", PREFS_NAME], Immutable.fromJS({ show: true, language: "fr-CA" }));
|
|
205
202
|
return expect(
|
|
206
|
-
<
|
|
207
|
-
<
|
|
208
|
-
|
|
209
|
-
</IntlProvider>
|
|
210
|
-
</Provider>,
|
|
203
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider>
|
|
204
|
+
<Preferences />
|
|
205
|
+
</TestWrapper>,
|
|
211
206
|
"when mounted",
|
|
212
207
|
"to satisfy",
|
|
213
208
|
null,
|
|
@@ -221,24 +216,24 @@ describe("Preferences", () => {
|
|
|
221
216
|
target: getStyledClassSelector(PrefButton) + ":last-child",
|
|
222
217
|
},
|
|
223
218
|
"to satisfy",
|
|
224
|
-
<
|
|
219
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider>
|
|
225
220
|
<div>
|
|
226
221
|
<div>
|
|
227
|
-
<
|
|
228
|
-
|
|
229
|
-
<
|
|
230
|
-
<label
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
</
|
|
237
|
-
|
|
238
|
-
|
|
222
|
+
<div>
|
|
223
|
+
<Ignore />
|
|
224
|
+
<PrefForm>
|
|
225
|
+
<InformationItem label={sharedMessages.displayLanguage}>
|
|
226
|
+
<Ignore />
|
|
227
|
+
</InformationItem>
|
|
228
|
+
<InformationItem label={sharedMessages.defaultApp}>
|
|
229
|
+
<Ignore />
|
|
230
|
+
</InformationItem>
|
|
231
|
+
</PrefForm>
|
|
232
|
+
<Ignore />
|
|
233
|
+
</div>
|
|
239
234
|
</div>
|
|
240
235
|
</div>
|
|
241
|
-
</
|
|
236
|
+
</TestWrapper>,
|
|
242
237
|
),
|
|
243
238
|
)
|
|
244
239
|
.then(() =>
|
|
@@ -316,11 +311,9 @@ describe("Preferences", () => {
|
|
|
316
311
|
it("shows view state fields, saves application change", () => {
|
|
317
312
|
state = state.setIn(["view", PREFS_NAME], Immutable.fromJS({ show: true, application: 3 }));
|
|
318
313
|
return expect(
|
|
319
|
-
<
|
|
320
|
-
<
|
|
321
|
-
|
|
322
|
-
</IntlProvider>
|
|
323
|
-
</Provider>,
|
|
314
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider>
|
|
315
|
+
<Preferences />
|
|
316
|
+
</TestWrapper>,
|
|
324
317
|
"when mounted",
|
|
325
318
|
"to satisfy",
|
|
326
319
|
null,
|
|
@@ -334,24 +327,24 @@ describe("Preferences", () => {
|
|
|
334
327
|
target: getStyledClassSelector(PrefButton) + ":last-child",
|
|
335
328
|
},
|
|
336
329
|
"to satisfy",
|
|
337
|
-
<
|
|
330
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider>
|
|
338
331
|
<div>
|
|
339
332
|
<div>
|
|
340
|
-
<
|
|
341
|
-
|
|
342
|
-
<
|
|
343
|
-
<label
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
</
|
|
350
|
-
|
|
351
|
-
|
|
333
|
+
<div>
|
|
334
|
+
<Ignore />
|
|
335
|
+
<PrefForm>
|
|
336
|
+
<InformationItem label={sharedMessages.displayLanguage}>
|
|
337
|
+
<Ignore />
|
|
338
|
+
</InformationItem>
|
|
339
|
+
<InformationItem label={sharedMessages.defaultApp}>
|
|
340
|
+
<Ignore />
|
|
341
|
+
</InformationItem>
|
|
342
|
+
</PrefForm>
|
|
343
|
+
<Ignore />
|
|
344
|
+
</div>
|
|
352
345
|
</div>
|
|
353
346
|
</div>
|
|
354
|
-
</
|
|
347
|
+
</TestWrapper>,
|
|
355
348
|
),
|
|
356
349
|
)
|
|
357
350
|
.then(() =>
|
|
@@ -393,11 +386,9 @@ describe("Preferences", () => {
|
|
|
393
386
|
it("clears and closes", () => {
|
|
394
387
|
state = state.setIn(["view", PREFS_NAME], Immutable.fromJS({ show: true, language: "fr-CA", application: 3 }));
|
|
395
388
|
return expect(
|
|
396
|
-
<
|
|
397
|
-
<
|
|
398
|
-
|
|
399
|
-
</IntlProvider>
|
|
400
|
-
</Provider>,
|
|
389
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider>
|
|
390
|
+
<Preferences />
|
|
391
|
+
</TestWrapper>,
|
|
401
392
|
"when mounted",
|
|
402
393
|
"to satisfy",
|
|
403
394
|
null,
|
|
@@ -411,24 +402,24 @@ describe("Preferences", () => {
|
|
|
411
402
|
target: getStyledClassSelector(PrefButton) + ":first-child",
|
|
412
403
|
},
|
|
413
404
|
"to satisfy",
|
|
414
|
-
<
|
|
405
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider>
|
|
415
406
|
<div>
|
|
416
407
|
<div>
|
|
417
|
-
<
|
|
418
|
-
|
|
419
|
-
<
|
|
420
|
-
<label
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
</
|
|
427
|
-
|
|
428
|
-
|
|
408
|
+
<div>
|
|
409
|
+
<Ignore />
|
|
410
|
+
<PrefForm>
|
|
411
|
+
<InformationItem label={sharedMessages.displayLanguage}>
|
|
412
|
+
<Ignore />
|
|
413
|
+
</InformationItem>
|
|
414
|
+
<InformationItem label={sharedMessages.defaultApp}>
|
|
415
|
+
<Ignore />
|
|
416
|
+
</InformationItem>
|
|
417
|
+
</PrefForm>
|
|
418
|
+
<Ignore />
|
|
419
|
+
</div>
|
|
429
420
|
</div>
|
|
430
421
|
</div>
|
|
431
|
-
</
|
|
422
|
+
</TestWrapper>,
|
|
432
423
|
),
|
|
433
424
|
)
|
|
434
425
|
.then(() =>
|
|
@@ -451,11 +442,9 @@ describe("Preferences", () => {
|
|
|
451
442
|
.deleteIn(["locale", "defaultCulture"])
|
|
452
443
|
.deleteIn(["settings", "defaultApp"]);
|
|
453
444
|
expect(
|
|
454
|
-
<
|
|
455
|
-
<
|
|
456
|
-
|
|
457
|
-
</IntlProvider>
|
|
458
|
-
</Provider>,
|
|
445
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider>
|
|
446
|
+
<Preferences />
|
|
447
|
+
</TestWrapper>,
|
|
459
448
|
"when mounted",
|
|
460
449
|
"to satisfy",
|
|
461
450
|
null,
|
|
@@ -463,50 +452,46 @@ describe("Preferences", () => {
|
|
|
463
452
|
expect(
|
|
464
453
|
modalRoot,
|
|
465
454
|
"to satisfy",
|
|
466
|
-
<
|
|
455
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages }} stylesProvider>
|
|
467
456
|
<div>
|
|
468
457
|
<div>
|
|
469
|
-
<
|
|
470
|
-
|
|
471
|
-
<
|
|
472
|
-
<label
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
</
|
|
479
|
-
|
|
480
|
-
|
|
458
|
+
<div>
|
|
459
|
+
<Ignore />
|
|
460
|
+
<PrefForm>
|
|
461
|
+
<InformationItem label={sharedMessages.displayLanguage}>
|
|
462
|
+
<Ignore />
|
|
463
|
+
</InformationItem>
|
|
464
|
+
<InformationItem label={sharedMessages.defaultApp}>
|
|
465
|
+
<Ignore />
|
|
466
|
+
</InformationItem>
|
|
467
|
+
</PrefForm>
|
|
468
|
+
<Ignore />
|
|
469
|
+
</div>
|
|
481
470
|
</div>
|
|
482
471
|
</div>
|
|
483
|
-
</
|
|
472
|
+
</TestWrapper>,
|
|
484
473
|
),
|
|
485
474
|
);
|
|
486
475
|
});
|
|
487
476
|
|
|
488
|
-
describe("
|
|
489
|
-
let update
|
|
477
|
+
describe("stateEventUpdater", () => {
|
|
478
|
+
let update;
|
|
490
479
|
beforeEach(() => {
|
|
491
480
|
update = sinon.spy().named("update");
|
|
492
|
-
update2 = () => {};
|
|
493
481
|
});
|
|
494
|
-
it("returns an update function", () =>
|
|
495
|
-
expect(createGetUpdater, "when called with", [update], "called with", ["testField"], "called with", [
|
|
496
|
-
"testValue",
|
|
497
|
-
]).then(() => expect(update, "to have calls satisfying", [{ args: ["testField", "testValue"] }])));
|
|
498
482
|
|
|
499
|
-
it("
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
483
|
+
it("creates a handler for an event and calls update with the value of the target", () =>
|
|
484
|
+
expect(stateEventUpdater, "called with", [update, "application"], "called with", ["foo"]).then(() =>
|
|
485
|
+
expect(update, "to have calls satisfying", [{ args: ["application", "foo"] }]),
|
|
486
|
+
));
|
|
487
|
+
|
|
488
|
+
it("is memoized", () =>
|
|
489
|
+
expect(
|
|
490
|
+
stateEventUpdater,
|
|
491
|
+
"called with",
|
|
492
|
+
[update, "application"],
|
|
493
|
+
"to be",
|
|
494
|
+
stateEventUpdater(update, "application"),
|
|
495
|
+
));
|
|
511
496
|
});
|
|
512
497
|
});
|
|
@@ -60,10 +60,20 @@ const useStyles = makeStyles(theme => ({
|
|
|
60
60
|
},
|
|
61
61
|
root: {
|
|
62
62
|
flexGrow: 1,
|
|
63
|
+
display: "flex",
|
|
64
|
+
},
|
|
65
|
+
animatePlaceholderImage: {
|
|
66
|
+
animation: "$rotate 4s linear infinite",
|
|
67
|
+
margin: "auto",
|
|
68
|
+
},
|
|
69
|
+
"@keyframes rotate": {
|
|
70
|
+
to: {
|
|
71
|
+
transform: "rotate(1turn)",
|
|
72
|
+
},
|
|
63
73
|
},
|
|
64
74
|
}));
|
|
65
75
|
|
|
66
|
-
const Placeholder = ({ icon, title, subtitle, cellList = [], error = false }) => {
|
|
76
|
+
const Placeholder = ({ icon, title, subtitle, cellList = [], error = false, animateIcon = false }) => {
|
|
67
77
|
const classes = useStyles();
|
|
68
78
|
return (
|
|
69
79
|
<>
|
|
@@ -101,7 +111,12 @@ const Placeholder = ({ icon, title, subtitle, cellList = [], error = false }) =>
|
|
|
101
111
|
alignItems="center"
|
|
102
112
|
className={`${classes.placeholder} ${error ? classes.placeholderError : ""}`}
|
|
103
113
|
>
|
|
104
|
-
{icon ?
|
|
114
|
+
{icon ? (
|
|
115
|
+
<Icon
|
|
116
|
+
className={`${classes.placeholderImage} ${animateIcon ? classes.animatePlaceholderImage : ""}`}
|
|
117
|
+
id={icon}
|
|
118
|
+
/>
|
|
119
|
+
) : null}
|
|
105
120
|
{title ? <Typography className={classes.placeholderTitle}>{title}</Typography> : null}
|
|
106
121
|
{subtitle ? <Typography className={classes.placeholderSubtitle}>{subtitle}</Typography> : null}
|
|
107
122
|
</Grid>
|
|
@@ -151,7 +151,9 @@ describe("Placeholder", () => {
|
|
|
151
151
|
});
|
|
152
152
|
|
|
153
153
|
it("Renders placeholder with all parametres", () => {
|
|
154
|
-
const component =
|
|
154
|
+
const component = (
|
|
155
|
+
<Placeholder icon={icon} animateIcon title={title} subtitle={subtitle} cellList={cellList} error={true} />
|
|
156
|
+
);
|
|
155
157
|
|
|
156
158
|
const mountedComponent = mount(component);
|
|
157
159
|
const expected = (
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState, useImperativeHandle } from "react";
|
|
2
2
|
import TableMui from "@material-ui/core/Table";
|
|
3
3
|
import TableContainer from "@material-ui/core/TableContainer";
|
|
4
4
|
import TableHead from "@material-ui/core/TableHead";
|
|
@@ -392,136 +392,136 @@ const FullTableWithSavedScrollbar = React.forwardRef((props, ref) => {
|
|
|
392
392
|
return <DefaultFullTable {...props} ref={ref} saveScrollBarPosition={saveScrollBarPosition} />;
|
|
393
393
|
});
|
|
394
394
|
|
|
395
|
-
const Table = (
|
|
396
|
-
tableInfo,
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
latestPage,
|
|
401
|
-
pageLength,
|
|
402
|
-
placeholder,
|
|
403
|
-
tableProps,
|
|
404
|
-
context,
|
|
405
|
-
}) => {
|
|
406
|
-
if (isTableProps(tableProps) === false) {
|
|
407
|
-
throw new TypeError("tableProps property is not of type TableProps");
|
|
408
|
-
}
|
|
395
|
+
const Table = React.forwardRef(
|
|
396
|
+
({ tableInfo, headers, rows, scrollLoader, latestPage, pageLength, placeholder, tableProps, context }, ref) => {
|
|
397
|
+
if (isTableProps(tableProps) === false) {
|
|
398
|
+
throw new TypeError("tableProps property is not of type TableProps");
|
|
399
|
+
}
|
|
409
400
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
401
|
+
const customClasses = tableProps?.get(TableProps.propNames.classes) || {};
|
|
402
|
+
const selectMode = tableProps?.get(TableProps.propNames.selectMode) || false;
|
|
403
|
+
const stickyHeader = tableProps?.get(TableProps.propNames.stickyHeader) || false;
|
|
404
|
+
const withoutTopBorder = tableProps?.get(TableProps.propNames.withoutTopBorder) || false;
|
|
405
|
+
const onRowClick = tableProps?.get(TableProps.propNames.onRowClick) || null;
|
|
406
|
+
const deepPropsComparation = tableProps?.get(TableProps.propNames.deepPropsComparation) || false;
|
|
407
|
+
const isEditingMode = tableProps?.get(TableProps.propNames.isEditingMode) || false;
|
|
408
|
+
const selectedRows = tableProps?.get(TableProps.propNames.selectedRows) || null;
|
|
409
|
+
const selectedRowsChanged = tableProps?.get(TableProps.propNames.selectedRowsChanged) || null;
|
|
410
|
+
const constrained = tableProps?.get(TableProps.propNames.constrained) || false;
|
|
411
|
+
const tableName = tableProps?.get(TableProps.propNames.tableName) || null;
|
|
412
|
+
const saveScrollbarPosition = tableProps?.get(TableProps.propNames.saveScrollbarPosition) || false;
|
|
413
|
+
|
|
414
|
+
customClasses["tableHeader"] = tableProps?.getStyle(TableProps.ruleNames.tableHeader) || null;
|
|
415
|
+
customClasses["tableRow"] = tableProps?.getStyle(TableProps.ruleNames.tableRow) || null;
|
|
416
|
+
customClasses["tableCell"] = tableProps?.getStyle(TableProps.ruleNames.tableCell) || null;
|
|
417
|
+
customClasses["headerCell"] = tableProps?.getStyle(TableProps.ruleNames.headerCell) || null;
|
|
418
|
+
customClasses["tableContainer"] = tableProps?.getStyle(TableProps.ruleNames.tableContainer) || null;
|
|
419
|
+
customClasses["container"] = tableProps?.getStyle(TableProps.ruleNames.container) || null;
|
|
420
|
+
customClasses["table"] = tableProps?.getStyle(TableProps.ruleNames.table) || null;
|
|
421
|
+
|
|
422
|
+
if ((selectedRows && !selectedRowsChanged) || (!selectedRows && selectedRowsChanged))
|
|
423
|
+
throw new Error("Both 'selectedRows' and 'selectedRowsChanged' need to be defined if one of them is.");
|
|
424
|
+
|
|
425
|
+
const refScrolled = useRef();
|
|
426
|
+
|
|
427
|
+
useImperativeHandle(ref, () => ({
|
|
428
|
+
scrollToTop: () => {
|
|
429
|
+
if (refScrolled.current.scrollTop > 0) {
|
|
430
|
+
refScrolled.current.scrollTop = 0;
|
|
431
|
+
}
|
|
432
|
+
},
|
|
433
|
+
}));
|
|
434
|
+
|
|
435
|
+
const [scrolled, setScrolled] = useState(0);
|
|
436
|
+
const [tableSize, setTableSize] = useState({ width: 0, height: 0 });
|
|
437
|
+
|
|
438
|
+
const [selectedNumber, tableSelectionStatus, selectionMethods] = useTableSelection(
|
|
439
|
+
rows,
|
|
440
|
+
selectedRows,
|
|
441
|
+
selectedRowsChanged,
|
|
442
|
+
);
|
|
444
443
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
444
|
+
const classes = useStyles({
|
|
445
|
+
withoutTopBorder,
|
|
446
|
+
selectMode,
|
|
447
|
+
stickyHeader,
|
|
448
|
+
scrolled,
|
|
449
|
+
onRowClick,
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
useEffect(() => {
|
|
453
|
+
const handleResize = () => {
|
|
454
|
+
if (refScrolled.current.offsetHeight < refScrolled.current.scrollHeight)
|
|
455
|
+
setScrolled(refScrolled.current.offsetWidth - refScrolled.current.clientWidth);
|
|
456
|
+
else setScrolled(0);
|
|
457
|
+
};
|
|
452
458
|
|
|
453
|
-
|
|
454
|
-
const handleResize = () => {
|
|
455
|
-
if (refScrolled.current.offsetHeight < refScrolled.current.scrollHeight)
|
|
456
|
-
setScrolled(refScrolled.current.offsetWidth - refScrolled.current.clientWidth);
|
|
457
|
-
else setScrolled(0);
|
|
458
|
-
};
|
|
459
|
+
handleResize();
|
|
459
460
|
|
|
460
|
-
|
|
461
|
+
window.addEventListener("resize", handleResize);
|
|
461
462
|
|
|
462
|
-
|
|
463
|
+
/* istanbul ignore next */
|
|
464
|
+
return () => window.removeEventListener("resize", handleResize);
|
|
465
|
+
}, [refScrolled, tableSize.width, tableSize.height]);
|
|
463
466
|
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
selectMode,
|
|
473
|
-
tableSelectionStatus,
|
|
474
|
-
selectionMethods,
|
|
475
|
-
);
|
|
467
|
+
const tableHeaders = buildTableHeaders(
|
|
468
|
+
headers,
|
|
469
|
+
classes,
|
|
470
|
+
customClasses,
|
|
471
|
+
selectMode,
|
|
472
|
+
tableSelectionStatus,
|
|
473
|
+
selectionMethods,
|
|
474
|
+
);
|
|
476
475
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
476
|
+
const tableRows = buildTableRows(
|
|
477
|
+
rows,
|
|
478
|
+
classes,
|
|
479
|
+
customClasses,
|
|
480
|
+
selectMode,
|
|
481
|
+
onRowClick,
|
|
482
|
+
selectionMethods,
|
|
483
|
+
deepPropsComparation,
|
|
484
|
+
context,
|
|
485
|
+
isEditingMode,
|
|
486
|
+
);
|
|
488
487
|
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
488
|
+
const stickerTableHeader =
|
|
489
|
+
stickyHeader === true ? (
|
|
490
|
+
<StickerTableHeader selectMode={selectMode} classes={classes} tableHeaders={tableHeaders} />
|
|
491
|
+
) : null;
|
|
493
492
|
|
|
494
|
-
|
|
495
|
-
|
|
493
|
+
/* istanbul ignore next */
|
|
494
|
+
const onResize = useCallback((width, height) => setTableSize({ width: width, height: height }), [setTableSize]);
|
|
496
495
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
}
|
|
496
|
+
return (
|
|
497
|
+
<TableContainer className={classNames(classes.container, customClasses.container)}>
|
|
498
|
+
{tableInfo}
|
|
499
|
+
{stickerTableHeader}
|
|
500
|
+
<FullTable
|
|
501
|
+
ref={refScrolled}
|
|
502
|
+
classes={classes}
|
|
503
|
+
customClasses={customClasses}
|
|
504
|
+
constrained={constrained}
|
|
505
|
+
onResize={onResize}
|
|
506
|
+
selectedNumber={selectedNumber}
|
|
507
|
+
scrollLoader={scrollLoader}
|
|
508
|
+
tableHeaders={tableHeaders}
|
|
509
|
+
dataRows={rows}
|
|
510
|
+
tableRows={tableRows}
|
|
511
|
+
stickyHeader={stickyHeader}
|
|
512
|
+
latestPage={latestPage}
|
|
513
|
+
pageLength={pageLength}
|
|
514
|
+
placeholder={placeholder}
|
|
515
|
+
deepPropsComparation={deepPropsComparation}
|
|
516
|
+
isEditingMode={isEditingMode}
|
|
517
|
+
context={context}
|
|
518
|
+
tableName={tableName}
|
|
519
|
+
saveScrollbarPosition={saveScrollbarPosition}
|
|
520
|
+
/>
|
|
521
|
+
</TableContainer>
|
|
522
|
+
);
|
|
523
|
+
},
|
|
524
|
+
);
|
|
525
525
|
|
|
526
526
|
export default React.memo(
|
|
527
527
|
Table,
|