widenarrow-ui 1.0.13 → 1.0.14
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/lib/components/SortableTable/SortableTable.types.d.ts +5 -6
- package/lib/index.css +1 -1
- package/lib/index.d.ts +4 -7
- package/lib/index.esm.css +1 -1
- package/lib/index.esm.js +28 -33
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +28 -33
- package/lib/index.js.map +1 -1
- package/lib/types/styling.types.d.ts +0 -3
- package/lib/utils.d.ts +2 -2
- package/package.json +1 -1
- package/src/components/SortableTable/SortableTable.tsx +14 -16
- package/src/components/SortableTable/SortableTable.types.ts +5 -6
- package/src/components/SwitchButton/SwitchButton.module.scss +19 -18
- package/src/types/styling.types.ts +0 -4
- package/src/utils.ts +1 -1
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { SizeTypes, ColorTypes, IconTypes, HierarchyTypes } from 'src/constants';
|
|
2
|
-
export interface UnknownObjectInterface {
|
|
3
|
-
[key: string]: unknown;
|
|
4
|
-
}
|
|
5
2
|
export interface MarginInterface {
|
|
6
3
|
margin?: '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8';
|
|
7
4
|
marginX?: '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8';
|
package/lib/utils.d.ts
CHANGED
|
@@ -44,10 +44,10 @@ export declare const getSortableTableState: (currentState: Array<{
|
|
|
44
44
|
keyName: string;
|
|
45
45
|
}>, newSortOption: {
|
|
46
46
|
key: string;
|
|
47
|
-
}) =>
|
|
47
|
+
}) => {
|
|
48
48
|
keyName: string;
|
|
49
49
|
ascending: boolean;
|
|
50
|
-
}
|
|
50
|
+
}[];
|
|
51
51
|
/**
|
|
52
52
|
* @function getSortableTableState
|
|
53
53
|
* @param {Array} state [{}]
|
package/package.json
CHANGED
|
@@ -4,7 +4,6 @@ import classNames from 'classnames/bind';
|
|
|
4
4
|
import { useInView } from 'react-intersection-observer';
|
|
5
5
|
|
|
6
6
|
import { SizeTypes, HierarchyTypes, IconTypes } from 'src/constants';
|
|
7
|
-
import { UnknownObjectInterface } from 'src/types/styling.types';
|
|
8
7
|
import {
|
|
9
8
|
isArrayWithContent,
|
|
10
9
|
sortObjectsInArrayByMultipleKeys,
|
|
@@ -15,6 +14,7 @@ import {
|
|
|
15
14
|
|
|
16
15
|
import { InlineButton } from 'src/components/InlineButton';
|
|
17
16
|
import { SolidSpinner } from 'src/components/SolidSpinner';
|
|
17
|
+
import { Heading } from 'src/components/Typography';
|
|
18
18
|
|
|
19
19
|
import { CellInterface, RowProps, SortableTableProps } from './SortableTable.types';
|
|
20
20
|
import styles from './SortableTable.module.scss';
|
|
@@ -73,6 +73,14 @@ const SortableTable: FC<SortableTableProps> = ({
|
|
|
73
73
|
return path([0, 'keyName'], sortByLocalState) === cell.key;
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
+
if (cell.disableSort) {
|
|
77
|
+
return (
|
|
78
|
+
<Heading type={'h6'} marginBottom={'0'} withEllipsis>
|
|
79
|
+
{cell.title}
|
|
80
|
+
</Heading>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
76
84
|
return (
|
|
77
85
|
<InlineButton
|
|
78
86
|
className={s('headerButton')}
|
|
@@ -81,11 +89,7 @@ const SortableTable: FC<SortableTableProps> = ({
|
|
|
81
89
|
type={optionIsPrimaryColor() ? HierarchyTypes.PRIMARY : HierarchyTypes.SECONDARY}
|
|
82
90
|
onClickCallback={() => {
|
|
83
91
|
if (sortByLocalState) {
|
|
84
|
-
// eslint-disable-next-line
|
|
85
|
-
// @ts-ignore
|
|
86
92
|
const newState = getSortableTableState(sortByLocalState, cell);
|
|
87
|
-
// eslint-disable-next-line
|
|
88
|
-
// @ts-ignore
|
|
89
93
|
return setSortByLocalState(newState);
|
|
90
94
|
}
|
|
91
95
|
is(Function, onSortCallback) && onSortCallback(cell.key);
|
|
@@ -94,7 +98,7 @@ const SortableTable: FC<SortableTableProps> = ({
|
|
|
94
98
|
rotateIcon={optionIsActive && arrowIsAscending}
|
|
95
99
|
withIconRight={!cell.alignRight}
|
|
96
100
|
size={SizeTypes.SMALL}
|
|
97
|
-
disabled={noData ||
|
|
101
|
+
disabled={noData || loading}
|
|
98
102
|
withEllipsis
|
|
99
103
|
/>
|
|
100
104
|
);
|
|
@@ -117,21 +121,17 @@ const SortableTable: FC<SortableTableProps> = ({
|
|
|
117
121
|
cellData_withEllipsis: cell.withEllipsis
|
|
118
122
|
});
|
|
119
123
|
|
|
120
|
-
|
|
124
|
+
// eslint-disable-next-line
|
|
125
|
+
const getCellData = (row: any, cell: CellInterface) => {
|
|
121
126
|
if (cell.customCellComponent && is(Function, cell.customCellComponent)) {
|
|
122
|
-
// eslint-disable-next-line
|
|
123
|
-
// @ts-ignore
|
|
124
127
|
return <span className={getCellDataClassName(cell)}>{cell.customCellComponent(row)}</span>;
|
|
125
128
|
}
|
|
126
|
-
// eslint-disable-next-line
|
|
127
|
-
// @ts-ignore
|
|
128
129
|
const cellValue = getCellValue(row[cell.key as keyof unknown]);
|
|
129
|
-
// eslint-disable-next-line
|
|
130
|
-
// @ts-ignore
|
|
131
130
|
return <span className={getCellDataClassName(cell)}>{cellValue}</span>;
|
|
132
131
|
};
|
|
133
132
|
|
|
134
|
-
|
|
133
|
+
// eslint-disable-next-line
|
|
134
|
+
const getRowContent = (row: any) =>
|
|
135
135
|
cells.map((cell, i) => (
|
|
136
136
|
<td
|
|
137
137
|
style={{ width: cell.width }}
|
|
@@ -152,8 +152,6 @@ const SortableTable: FC<SortableTableProps> = ({
|
|
|
152
152
|
return sortedData.map((row, i) => (
|
|
153
153
|
<SortableTableRow
|
|
154
154
|
row={row}
|
|
155
|
-
// eslint-disable-next-line
|
|
156
|
-
// @ts-ignore
|
|
157
155
|
key={`${row.id}${i}`}
|
|
158
156
|
withIntersectionObserver={withIntersectionObserver}
|
|
159
157
|
rowClassName={rowClassName as string}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { IconTypes } from '../../constants';
|
|
3
|
-
import { UnknownObjectInterface } from '../../types/styling.types';
|
|
4
3
|
|
|
5
4
|
export interface RowProps {
|
|
6
|
-
row:
|
|
5
|
+
row: any; // eslint-disable-line
|
|
7
6
|
rowClassName?: string;
|
|
8
7
|
withIntersectionObserver?: boolean | undefined;
|
|
9
|
-
children?: ReactNode;
|
|
8
|
+
children?: ReactNode | JSX.Element;
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
export interface CellInterface {
|
|
@@ -19,13 +18,13 @@ export interface CellInterface {
|
|
|
19
18
|
alignCenter?: boolean;
|
|
20
19
|
withEllipsis?: boolean;
|
|
21
20
|
toolTip?: string;
|
|
22
|
-
customHeaderCellComponent?: (cell: CellInterface) => ReactNode;
|
|
23
|
-
customCellComponent?: (row:
|
|
21
|
+
customHeaderCellComponent?: (cell: CellInterface) => ReactNode | JSX.Element;
|
|
22
|
+
customCellComponent?: (row: any) => ReactNode | JSX.Element; // eslint-disable-line
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
export interface SortableTableProps {
|
|
27
26
|
cells: Array<CellInterface>;
|
|
28
|
-
data: Array<
|
|
27
|
+
data: Array<any>; // eslint-disable-line
|
|
29
28
|
sortBy: Array<{
|
|
30
29
|
keyName: string;
|
|
31
30
|
ascending: boolean;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
@import 'src/styles/mixins.scss';
|
|
2
|
-
// @import '~styles/keyframes';
|
|
3
2
|
|
|
4
3
|
@keyframes fadeInAnimation {
|
|
5
4
|
from {
|
|
@@ -32,8 +31,8 @@
|
|
|
32
31
|
|
|
33
32
|
.button {
|
|
34
33
|
position: relative;
|
|
35
|
-
height:
|
|
36
|
-
width:
|
|
34
|
+
height: 20px;
|
|
35
|
+
width: 48px;
|
|
37
36
|
|
|
38
37
|
&_alignCenter {
|
|
39
38
|
margin: 0 auto;
|
|
@@ -45,6 +44,7 @@
|
|
|
45
44
|
|
|
46
45
|
&:hover {
|
|
47
46
|
.circle:before {
|
|
47
|
+
background: $transparent-grey-3;
|
|
48
48
|
animation-duration: 150ms;
|
|
49
49
|
animation-timing-function: ease;
|
|
50
50
|
animation-name: fadeInAnimation;
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
|
|
55
55
|
&:active {
|
|
56
56
|
.circle:before {
|
|
57
|
-
background: $transparent-grey-
|
|
57
|
+
background: $transparent-grey-4;
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -80,46 +80,47 @@
|
|
|
80
80
|
.line {
|
|
81
81
|
position: absolute;
|
|
82
82
|
transition: background 200ms ease;
|
|
83
|
-
background:
|
|
83
|
+
background: #c2c2c2;
|
|
84
84
|
box-shadow: $box-shadow-card;
|
|
85
|
-
top:
|
|
85
|
+
top: 0;
|
|
86
|
+
left: 0;
|
|
86
87
|
display: block;
|
|
87
|
-
width:
|
|
88
|
-
height:
|
|
88
|
+
width: 100%;
|
|
89
|
+
height: 100%;
|
|
89
90
|
border-radius: 20px;
|
|
90
|
-
opacity: 0.5;
|
|
91
91
|
|
|
92
92
|
&_isActive {
|
|
93
|
-
background: $
|
|
93
|
+
background: $blue;
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
.circle {
|
|
98
|
+
top: 2px;
|
|
99
|
+
left: 2px;
|
|
98
100
|
position: absolute;
|
|
99
101
|
transition: transform 200ms ease;
|
|
100
102
|
background: $grey-4;
|
|
101
103
|
transform: translateX(0px);
|
|
102
104
|
display: block;
|
|
103
|
-
height:
|
|
104
|
-
width:
|
|
105
|
+
height: 16px;
|
|
106
|
+
width: 16px;
|
|
105
107
|
border-radius: 50%;
|
|
108
|
+
background: white;
|
|
106
109
|
|
|
107
110
|
&:before {
|
|
108
111
|
content: '';
|
|
109
112
|
pointer-events: none;
|
|
110
113
|
position: absolute;
|
|
111
114
|
opacity: 0;
|
|
112
|
-
height:
|
|
113
|
-
width:
|
|
114
|
-
top: -
|
|
115
|
-
left: -
|
|
116
|
-
background: $transparent-grey-1;
|
|
115
|
+
height: 120%;
|
|
116
|
+
width: 120%;
|
|
117
|
+
top: -10%;
|
|
118
|
+
left: -10%;
|
|
117
119
|
border-radius: 50%;
|
|
118
120
|
}
|
|
119
121
|
|
|
120
122
|
&_isActive {
|
|
121
123
|
transform: translateX(28px);
|
|
122
|
-
background: $blue;
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
126
|
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { SizeTypes, ColorTypes, IconTypes, HierarchyTypes } from 'src/constants';
|
|
2
2
|
|
|
3
|
-
export interface UnknownObjectInterface {
|
|
4
|
-
[key: string]: unknown;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
3
|
export interface MarginInterface {
|
|
8
4
|
margin?: '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8';
|
|
9
5
|
marginX?: '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8';
|
package/src/utils.ts
CHANGED
|
@@ -81,7 +81,7 @@ export const sortObjectsInArrayByMultipleKeys = <Type>(array: Type[], sortOption
|
|
|
81
81
|
export const getSortableTableState = (
|
|
82
82
|
currentState: Array<{ ascending: boolean; keyName: string }>,
|
|
83
83
|
newSortOption: { key: string }
|
|
84
|
-
):
|
|
84
|
+
): { keyName: string; ascending: boolean }[] => {
|
|
85
85
|
if (!isArrayWithContent(currentState)) {
|
|
86
86
|
return [newSortOption];
|
|
87
87
|
}
|