@skyscanner/backpack-web 9.2.0-beta.3 → 10.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 (118) hide show
  1. package/bpk-animate-height/package.json +3 -3
  2. package/bpk-component-accordion/package.json +7 -7
  3. package/bpk-component-aria-live/README.md +2 -2
  4. package/bpk-component-aria-live/{index.js → index.ts} +0 -1
  5. package/bpk-component-aria-live/package.json +9 -10
  6. package/bpk-component-aria-live/src/BpkAriaLive-test.tsx +60 -0
  7. package/bpk-component-aria-live/src/{BpkAriaLive.js → BpkAriaLive.tsx} +20 -26
  8. package/bpk-component-aria-live/src/accessibility-test.tsx +31 -0
  9. package/bpk-component-autosuggest/package.json +4 -4
  10. package/bpk-component-badge/package.json +5 -5
  11. package/bpk-component-banner-alert/package.json +9 -9
  12. package/bpk-component-barchart/package.json +8 -8
  13. package/bpk-component-blockquote/package.json +2 -2
  14. package/bpk-component-breadcrumb/package.json +5 -5
  15. package/bpk-component-breadcrumb/src/BpkBreadcrumbItem.module.scss +2 -2
  16. package/bpk-component-breakpoint/package.json +3 -3
  17. package/bpk-component-button/package.json +3 -3
  18. package/bpk-component-calendar/DOCS.md +1 -7
  19. package/bpk-component-calendar/README.md +0 -10
  20. package/bpk-component-calendar/index.js +0 -2
  21. package/bpk-component-calendar/package.json +9 -9
  22. package/bpk-component-calendar/src/BpkCalendarDate.js +0 -15
  23. package/bpk-component-calendar/src/BpkCalendarDate.module.scss +17 -50
  24. package/bpk-component-calendar/src/BpkCalendarGrid.js +3 -2
  25. package/bpk-component-calendar/src/BpkCalendarGrid.module.scss +5 -5
  26. package/bpk-component-calendar/src/_variables.scss +1 -3
  27. package/bpk-component-card/package.json +4 -4
  28. package/bpk-component-checkbox/package.json +5 -5
  29. package/bpk-component-chip/package.json +5 -5
  30. package/bpk-component-close-button/package.json +4 -4
  31. package/bpk-component-code/package.json +2 -2
  32. package/bpk-component-content-cards/README.md +43 -0
  33. package/bpk-component-content-cards/index.ts +21 -0
  34. package/bpk-component-content-cards/package.json +23 -0
  35. package/bpk-component-content-cards/src/BpkContentCard-test.tsx +88 -0
  36. package/bpk-component-content-cards/src/BpkContentCard.module.scss +87 -0
  37. package/bpk-component-content-cards/src/BpkContentCard.tsx +84 -0
  38. package/bpk-component-content-cards/src/BpkContentCards-test.tsx +126 -0
  39. package/bpk-component-content-cards/src/BpkContentCards.module.css +18 -0
  40. package/bpk-component-content-cards/src/BpkContentCards.module.scss +51 -0
  41. package/bpk-component-content-cards/src/BpkContentCards.tsx +72 -0
  42. package/bpk-component-content-cards/src/accessibility-test.tsx +64 -0
  43. package/bpk-component-content-container/package.json +2 -2
  44. package/bpk-component-datatable/README.md +78 -21
  45. package/bpk-component-datatable/package.json +5 -6
  46. package/bpk-component-datatable/src/BpkDataTable.js +176 -143
  47. package/bpk-component-datatable/src/BpkDataTable.module.scss +10 -14
  48. package/bpk-component-datatable/src/BpkDataTableColumn.js +37 -40
  49. package/bpk-component-datatable/src/BpkDataTableHeader.js +143 -0
  50. package/bpk-component-datatable/src/{BpkDataTableColumn.module.scss → BpkDataTableHeader.module.scss} +12 -11
  51. package/bpk-component-datatable/src/common-types.js +33 -11
  52. package/bpk-component-datatable/src/sort-types.js +6 -0
  53. package/bpk-component-datatable/src/utils.js +66 -9
  54. package/bpk-component-datepicker/package.json +9 -9
  55. package/bpk-component-description-list/package.json +2 -2
  56. package/bpk-component-dialog/package.json +8 -8
  57. package/bpk-component-drawer/package.json +9 -9
  58. package/bpk-component-fieldset/package.json +12 -12
  59. package/bpk-component-flare/package.json +4 -4
  60. package/bpk-component-floating-notification/package.json +5 -5
  61. package/bpk-component-form-validation/package.json +10 -10
  62. package/bpk-component-graphic-promotion/package.json +6 -5
  63. package/bpk-component-graphic-promotion/src/BpkGraphicPromo-test.tsx +3 -2
  64. package/bpk-component-graphic-promotion/src/BpkGraphicPromo.tsx +24 -24
  65. package/bpk-component-grid/package.json +2 -2
  66. package/bpk-component-grid-toggle/package.json +3 -3
  67. package/bpk-component-horizontal-nav/package.json +6 -6
  68. package/bpk-component-icon/package.json +7 -7
  69. package/bpk-component-image/package.json +6 -6
  70. package/bpk-component-infinite-scroll/package.json +6 -6
  71. package/bpk-component-input/package.json +6 -6
  72. package/bpk-component-label/package.json +2 -2
  73. package/bpk-component-link/package.json +4 -4
  74. package/bpk-component-list/README.md +8 -5
  75. package/bpk-component-list/package.json +2 -2
  76. package/bpk-component-list/src/BpkList.js +18 -2
  77. package/bpk-component-loading-button/package.json +6 -6
  78. package/bpk-component-map/package.json +6 -6
  79. package/bpk-component-map/src/BpkIconMarker.module.scss +3 -3
  80. package/bpk-component-map/src/BpkIconMarkerBackground.module.scss +4 -4
  81. package/bpk-component-map/src/BpkPriceMarker.module.scss +17 -17
  82. package/bpk-component-map/src/DefaultLoadingElement.module.scss +1 -1
  83. package/bpk-component-mobile-scroll-container/package.json +3 -3
  84. package/bpk-component-modal/package.json +9 -9
  85. package/bpk-component-navigation-bar/package.json +8 -8
  86. package/bpk-component-nudger/package.json +7 -7
  87. package/bpk-component-overlay/package.json +4 -4
  88. package/bpk-component-pagination/package.json +4 -4
  89. package/bpk-component-panel/package.json +2 -2
  90. package/bpk-component-phone-input/package.json +9 -9
  91. package/bpk-component-popover/package.json +8 -8
  92. package/bpk-component-price/package.json +3 -3
  93. package/bpk-component-progress/package.json +5 -5
  94. package/bpk-component-radio/package.json +4 -4
  95. package/bpk-component-rating/package.json +4 -4
  96. package/bpk-component-rtl-toggle/package.json +2 -2
  97. package/bpk-component-scrollable-calendar/package.json +7 -7
  98. package/bpk-component-scrollable-calendar/src/BpkScrollableCalendarGridList.js +100 -69
  99. package/bpk-component-scrollable-calendar/src/utils.js +24 -1
  100. package/bpk-component-section-list/package.json +6 -6
  101. package/bpk-component-select/package.json +3 -3
  102. package/bpk-component-skip-link/package.json +2 -2
  103. package/bpk-component-slider/package.json +4 -4
  104. package/bpk-component-spinner/package.json +3 -3
  105. package/bpk-component-split-input/package.json +3 -3
  106. package/bpk-component-star-rating/package.json +5 -5
  107. package/bpk-component-switch/package.json +2 -2
  108. package/bpk-component-table/package.json +2 -2
  109. package/bpk-component-text/package.json +2 -2
  110. package/bpk-component-textarea/package.json +4 -4
  111. package/bpk-component-theme-toggle/package.json +5 -5
  112. package/bpk-component-ticket/package.json +4 -4
  113. package/bpk-component-tooltip/package.json +4 -4
  114. package/bpk-scrim-utils/package.json +2 -2
  115. package/bpk-theming/package.json +2 -2
  116. package/package.json +6 -5
  117. package/bpk-component-datatable/src/bpkHeaderRenderer.js +0 -110
  118. package/bpk-component-datatable/src/sorter.js +0 -166
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpk-component-table",
3
- "version": "4.0.1",
3
+ "version": "4.0.3",
4
4
  "description": "Backpack table component.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "gitHead": "5c156b97cb0ba5e75851d3c763334578714c895e",
16
16
  "dependencies": {
17
- "bpk-mixins": "^31.4.0",
17
+ "bpk-mixins": "^31.6.1",
18
18
  "bpk-react-utils": "^7.0.0",
19
19
  "prop-types": "^15.7.2"
20
20
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpk-component-text",
3
- "version": "8.0.1",
3
+ "version": "8.0.3",
4
4
  "description": "Backpack text component.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "gitHead": "f9f94f86d7cfc75e43bc6ad5eb01b23e62a89cc8",
16
16
  "dependencies": {
17
- "bpk-mixins": "^31.4.0",
17
+ "bpk-mixins": "^31.6.1",
18
18
  "bpk-react-utils": "^7.0.0",
19
19
  "prop-types": "^15.7.2"
20
20
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpk-component-textarea",
3
- "version": "5.0.1",
3
+ "version": "5.0.3",
4
4
  "description": "Backpack textarea component.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -14,13 +14,13 @@
14
14
  },
15
15
  "gitHead": "5c156b97cb0ba5e75851d3c763334578714c895e",
16
16
  "dependencies": {
17
- "bpk-mixins": "^31.4.0",
17
+ "bpk-mixins": "^31.6.1",
18
18
  "bpk-react-utils": "^7.0.0",
19
19
  "prop-types": "^15.7.2"
20
20
  },
21
21
  "devDependencies": {
22
- "bpk-component-label": "^6.0.1",
23
- "bpk-storybook-utils": "^2.0.1"
22
+ "bpk-component-label": "^6.0.3",
23
+ "bpk-storybook-utils": "^2.0.3"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "react": "^17.0.2"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpk-component-theme-toggle",
3
- "version": "4.0.1",
3
+ "version": "4.0.3",
4
4
  "description": "Backpack theme toggle component.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -14,10 +14,10 @@
14
14
  },
15
15
  "gitHead": "5c156b97cb0ba5e75851d3c763334578714c895e",
16
16
  "dependencies": {
17
- "@skyscanner/bpk-foundations-web": "^8.5.0",
18
- "bpk-component-label": "^6.0.1",
19
- "bpk-component-select": "^6.0.1",
20
- "bpk-mixins": "^31.4.0",
17
+ "@skyscanner/bpk-foundations-web": "^9.2.0",
18
+ "bpk-component-label": "^6.0.3",
19
+ "bpk-component-select": "^6.0.3",
20
+ "bpk-mixins": "^31.6.1",
21
21
  "bpk-react-utils": "^7.0.0",
22
22
  "prop-types": "^15.7.2"
23
23
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpk-component-ticket",
3
- "version": "6.0.1",
3
+ "version": "6.0.3",
4
4
  "description": "Backpack ticket component.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "gitHead": "f9f94f86d7cfc75e43bc6ad5eb01b23e62a89cc8",
16
16
  "dependencies": {
17
- "bpk-mixins": "^31.4.0",
17
+ "bpk-mixins": "^31.6.1",
18
18
  "bpk-react-utils": "^7.0.0",
19
19
  "prop-types": "^15.7.2"
20
20
  },
@@ -22,7 +22,7 @@
22
22
  "react": "^17.0.2"
23
23
  },
24
24
  "devDependencies": {
25
- "bpk-component-button": "^7.0.1",
26
- "bpk-component-icon": "^10.0.1"
25
+ "bpk-component-button": "^7.0.3",
26
+ "bpk-component-icon": "^10.0.3"
27
27
  }
28
28
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpk-component-tooltip",
3
- "version": "9.0.1",
3
+ "version": "9.0.3",
4
4
  "description": "Backpack tooltip component.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -15,7 +15,7 @@
15
15
  "gitHead": "f9f94f86d7cfc75e43bc6ad5eb01b23e62a89cc8",
16
16
  "dependencies": {
17
17
  "@popperjs/core": "^2.11.5",
18
- "bpk-mixins": "^31.4.0",
18
+ "bpk-mixins": "^31.6.1",
19
19
  "bpk-react-utils": "^7.0.0",
20
20
  "prop-types": "^15.7.2"
21
21
  },
@@ -23,7 +23,7 @@
23
23
  "react": "^17.0.2"
24
24
  },
25
25
  "devDependencies": {
26
- "@skyscanner/bpk-foundations-web": "^8.5.0",
27
- "bpk-component-text": "^8.0.1"
26
+ "@skyscanner/bpk-foundations-web": "^9.2.0",
27
+ "bpk-component-text": "^8.0.3"
28
28
  }
29
29
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpk-scrim-utils",
3
- "version": "6.0.1",
3
+ "version": "6.0.3",
4
4
  "description": "Higher order component that adds an overlay behind components and manages scroll states.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -16,7 +16,7 @@
16
16
  "dependencies": {
17
17
  "a11y-focus-scope": "^1.1.3",
18
18
  "a11y-focus-store": "^1.0.0",
19
- "bpk-mixins": "^31.4.0",
19
+ "bpk-mixins": "^31.6.1",
20
20
  "bpk-react-utils": "^7.0.0"
21
21
  },
22
22
  "peerDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpk-theming",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "description": "Backpack theming utlities.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "gitHead": "c2217d61875a1f3aa2bb9ed9583c50e3f1523501",
16
16
  "dependencies": {
17
- "@skyscanner/bpk-foundations-web": "^8.5.0",
17
+ "@skyscanner/bpk-foundations-web": "^9.2.0",
18
18
  "prop-types": "^15.7.2"
19
19
  },
20
20
  "peerDependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyscanner/backpack-web",
3
- "version": "9.2.0-beta.3",
3
+ "version": "10.0.0",
4
4
  "description": "Backpack Design System web library",
5
5
  "repository": {
6
6
  "type": "git",
@@ -24,11 +24,11 @@
24
24
  "dependencies": {
25
25
  "@popperjs/core": "^2.11.5",
26
26
  "@react-google-maps/api": "^2.12.0",
27
- "@skyscanner/bpk-foundations-web": "^8.5.0",
28
- "@skyscanner/bpk-svgs": "^14.3.6",
27
+ "@skyscanner/bpk-foundations-web": "^9.2.0",
28
+ "@skyscanner/bpk-svgs": "^14.4.1",
29
29
  "a11y-focus-scope": "^1.1.3",
30
30
  "a11y-focus-store": "^1.0.0",
31
- "bpk-mixins": "^31.4.0",
31
+ "bpk-mixins": "^31.6.1",
32
32
  "d3-path": "^2.0.0",
33
33
  "d3-scale": "^4.0.2",
34
34
  "date-fns": "^2.21.1",
@@ -42,7 +42,8 @@
42
42
  "react-responsive": "^6.1.2",
43
43
  "react-slider": "^1.3.1",
44
44
  "react-transition-group": "^2.5.3",
45
- "react-virtualized": "^9.22.3"
45
+ "react-virtualized": "^9.22.3",
46
+ "react-window": "^1.8.7"
46
47
  },
47
48
  "peerDependencies": {
48
49
  "react": "^17.0.2"
@@ -1,110 +0,0 @@
1
- /*
2
- * Backpack - Skyscanner's Design System
3
- *
4
- * Copyright 2016 Skyscanner Ltd
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
- /* @flow strict */
19
-
20
- import React from 'react';
21
- import { SortDirection } from 'react-virtualized';
22
-
23
- import { cssModules } from '../../bpk-react-utils';
24
- import BpkSmallArrowDownIcon from '../../bpk-component-icon/sm/arrow-down';
25
- import BpkSmallArrowUpIcon from '../../bpk-component-icon/sm/arrow-up';
26
- import { withRtlSupport } from '../../bpk-component-icon';
27
-
28
- import { hasClassName } from './utils';
29
- import STYLES from './BpkDataTableColumn.module.scss';
30
- import { type SortDirectionType, type SortProps } from './sort-types';
31
-
32
- const DownIcon = withRtlSupport(BpkSmallArrowDownIcon);
33
- const UpIcon = withRtlSupport(BpkSmallArrowUpIcon);
34
-
35
- const getClassName = cssModules(STYLES);
36
- const upIconClassName = getClassName('bpk-data-table-column__sort-icon--up');
37
- const downIconClassName = getClassName(
38
- 'bpk-data-table-column__sort-icon--down',
39
- );
40
-
41
- export const getSortIconDirection = (element: Element): ?SortDirectionType => {
42
- if (
43
- hasClassName(element, upIconClassName) ||
44
- hasClassName(element.parentElement, upIconClassName)
45
- ) {
46
- return SortDirection.ASC;
47
- }
48
- if (
49
- hasClassName(element, downIconClassName) ||
50
- hasClassName(element.parentElement, downIconClassName)
51
- ) {
52
- return SortDirection.DESC;
53
- }
54
- return null;
55
- };
56
-
57
- type Props = {
58
- dataKey: string,
59
- label: string,
60
- disableSort: boolean,
61
- ...$Exact<SortProps>,
62
- };
63
- export default ({
64
- dataKey,
65
- disableSort,
66
- label,
67
- sortBy,
68
- sortDirection,
69
- }: Props) => {
70
- const children = [
71
- <span
72
- className={getClassName('bpk-data-table-column__header')}
73
- key="label"
74
- title={label}
75
- >
76
- {label}
77
- </span>,
78
- ];
79
-
80
- if (!disableSort) {
81
- const upIconClassNames = [
82
- getClassName('bpk-data-table-column__sort-icon'),
83
- upIconClassName,
84
- ];
85
-
86
- const downIconClassNames = [
87
- getClassName('bpk-data-table-column__sort-icon'),
88
- downIconClassName,
89
- ];
90
-
91
- if (sortBy === dataKey) {
92
- (sortDirection === SortDirection.ASC
93
- ? upIconClassNames
94
- : downIconClassNames
95
- ).push(getClassName('bpk-data-table-column__sort-icon--selected'));
96
- }
97
-
98
- children.push(
99
- <div
100
- className={getClassName('bpk-data-table-column__sort-icons')}
101
- key="sort"
102
- >
103
- <UpIcon className={upIconClassNames.join(' ')} />
104
- <DownIcon className={downIconClassNames.join(' ')} />
105
- </div>,
106
- );
107
- }
108
-
109
- return children;
110
- };
@@ -1,166 +0,0 @@
1
- /*
2
- * Backpack - Skyscanner's Design System
3
- *
4
- * Copyright 2016 Skyscanner Ltd
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
-
19
- /* @flow strict */
20
- import React from 'react';
21
- import _sortBy from 'lodash/sortBy';
22
- import { SortDirection } from 'react-virtualized';
23
-
24
- import { getSortIconDirection } from './bpkHeaderRenderer';
25
- import type { Props, SortProps, SortDirectionType } from './common-types';
26
-
27
- export type Sorter<Row> = {
28
- rowCount: number,
29
- getRow(indext: number): Row,
30
- propsChange(props: Props<Row>): void,
31
- onHeaderClick(sortBy: string, eventTarget: Element, column: any): Sorter<Row>,
32
- sortProps: SortProps,
33
- };
34
-
35
- const getSortDirection = (
36
- sortProps: SortProps,
37
- newSortBy: ?string,
38
- newSortDirection: ?SortDirectionType,
39
- defaultSortDirection: SortDirectionType,
40
- ): SortDirectionType => {
41
- const { sortBy, sortDirection } = sortProps;
42
- if (newSortDirection != null) {
43
- return newSortDirection;
44
- }
45
- if (sortBy === newSortBy) {
46
- return sortDirection === SortDirection.ASC
47
- ? SortDirection.DESC
48
- : SortDirection.ASC;
49
- }
50
- return defaultSortDirection;
51
- };
52
-
53
- class NaiveSorter<Row> {
54
- sortProps: SortProps;
55
-
56
- list: Array<Row>;
57
-
58
- sortedList: Array<Row>;
59
-
60
- rowCount: number;
61
-
62
- constructor(props: Props<Row>) {
63
- const children = React.Children.toArray(props.children);
64
-
65
- const sortBy =
66
- React.Children.count(props.children) > 0
67
- ? children[props.defaultColumnSortIndex].props.dataKey
68
- : undefined;
69
- const sortDirection =
70
- children[props.defaultColumnSortIndex].props.defaultSortDirection ||
71
- SortDirection.ASC;
72
-
73
- this.sortProps = {
74
- sortBy,
75
- sortDirection,
76
- sort: null,
77
- };
78
- this.list = props.rows;
79
- this.sort();
80
- }
81
-
82
- getRow(index: number): Row {
83
- return this.sortedList[index];
84
- }
85
-
86
- sort() {
87
- const sorted = _sortBy(this.list, this.sortProps.sortBy);
88
- if (this.sortProps.sortDirection === 'DESC') {
89
- sorted.reverse();
90
- }
91
- this.sortedList = sorted;
92
- this.rowCount = this.sortedList.length;
93
- }
94
-
95
- propsChange(nextProps: Props<Row>) {
96
- this.list = nextProps.rows;
97
- this.sort();
98
- }
99
-
100
- onHeaderClick(sortBy: string, eventTarget: Element, column): Sorter<Row> {
101
- const sortDirection = getSortDirection(
102
- this.sortProps,
103
- sortBy,
104
- getSortIconDirection(eventTarget),
105
- column.props.defaultSortDirection || SortDirection.ASC,
106
- );
107
-
108
- this.sortProps = {
109
- sortBy,
110
- sortDirection,
111
- sort: null,
112
- };
113
-
114
- this.sort();
115
- return this;
116
- }
117
- }
118
-
119
- class PropSorter<Row> {
120
- sortProps: SortProps;
121
-
122
- list: Array<Row>;
123
-
124
- rowCount: number;
125
-
126
- constructor(props: Props<Row>) {
127
- this.sortProps = {
128
- sortBy: props.sortBy,
129
- sortDirection: props.sortDirection,
130
- sort: props.sort,
131
- };
132
- this.list = props.rows;
133
- this.rowCount = props.rows.length;
134
- }
135
-
136
- getRow(index: number): Row {
137
- return this.list[index];
138
- }
139
-
140
- propsChange(nextProps: Props<Row>) {
141
- this.sortProps = {
142
- sortBy: nextProps.sortBy,
143
- sortDirection: nextProps.sortDirection,
144
- sort: nextProps.sort,
145
- };
146
- this.list = nextProps.rows;
147
- this.rowCount = nextProps.rows.length;
148
- }
149
-
150
- onHeaderClick(): Sorter<Row> {
151
- return this;
152
- }
153
- }
154
-
155
- const makeSorter = <Row>(props: Props<Row>): Sorter<Row> => {
156
- if (
157
- props.sort !== null &&
158
- props.sortBy !== null &&
159
- props.sortDirection !== null
160
- ) {
161
- return new PropSorter(props);
162
- }
163
- return new NaiveSorter(props);
164
- };
165
-
166
- export default makeSorter;