uikit-react-public 0.36.0 → 0.37.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.
- package/dist/components/Table/Table.context.d.ts +6 -0
- package/dist/components/Table/Table.d.ts +4 -3
- package/dist/components/Table/Table.stories.d.ts +3 -3
- package/dist/components/Table/Table.types.d.ts +6 -0
- package/dist/components/Table/index.d.ts +1 -1
- package/dist/components/Table/subcomponents/Cell/Cell.d.ts +8 -1
- package/dist/components/Table/subcomponents/Cell/Cell.stories.d.ts +5 -1
- package/dist/components/Table/subcomponents/Cell/CellContent.d.ts +3 -2
- package/dist/components/Table/subcomponents/HeadCell/HeadCell.d.ts +4 -2
- package/dist/components/Table/subcomponents/HeadCell/HeadCell.stories.d.ts +3 -1
- package/dist/components/Table/subcomponents/Row.d.ts +8 -1
- package/dist/index.js +6564 -6194
- package/lib/components/Snackbar/Snackbar.tsx +2 -3
- package/lib/components/Snackbar/__tests__/__snapshots__/Snackbar.test.tsx.snap +2 -2
- package/lib/components/Table/Table.context.ts +12 -0
- package/lib/components/Table/Table.tsx +91 -12
- package/lib/components/Table/Table.types.ts +21 -0
- package/lib/components/Table/__tests__/Table.test.tsx +95 -1
- package/lib/components/Table/__tests__/__snapshots__/Table.test.tsx.snap +54 -13
- package/lib/components/Table/index.ts +6 -1
- package/lib/components/Table/subcomponents/Body.tsx +16 -3
- package/lib/components/Table/subcomponents/Cell/Cell.tsx +193 -4
- package/lib/components/Table/subcomponents/Cell/CellContent.tsx +63 -3
- package/lib/components/Table/subcomponents/Cell/__tests__/__snapshots__/Cell.test.tsx.snap +15 -10
- package/lib/components/Table/subcomponents/Head.tsx +14 -3
- package/lib/components/Table/subcomponents/HeadCell/HeadCell.tsx +17 -4
- package/lib/components/Table/subcomponents/HeadCell/__tests__/__snapshots__/HeadCell.test.tsx.snap +3 -3
- package/lib/components/Table/subcomponents/Row.tsx +195 -6
- package/lib/components/Table/subcomponents/SortIcon.tsx +4 -4
- package/lib/theme/__tests__/useTheme.test.tsx +2 -2
- package/lib/theme/useTheme.tsx +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { css, cx } from '@emotion/css';
|
|
2
2
|
import CellContent from './CellContent';
|
|
3
3
|
import { useTheme } from '../../../../theme';
|
|
4
|
-
import
|
|
4
|
+
import { useTableContext } from '../../Table.context';
|
|
5
|
+
import type {
|
|
6
|
+
ColumnVariant,
|
|
7
|
+
NormalizedTableMobileRole,
|
|
8
|
+
} from '../../Table.types';
|
|
5
9
|
import type { CheckboxProps } from '../../../Checkbox/Checkbox';
|
|
6
10
|
import type { ButtonProps } from '../../../Button';
|
|
7
11
|
|
|
@@ -21,10 +25,25 @@ export interface TableCellProps extends React.HTMLAttributes<HTMLTableCellElemen
|
|
|
21
25
|
ButtonProps<'button'>,
|
|
22
26
|
'variant' | 'onClick' | 'className'
|
|
23
27
|
>;
|
|
28
|
+
/** @internal */
|
|
29
|
+
__mobileColumnIndex?: number;
|
|
30
|
+
__mobileHasSelection?: boolean;
|
|
31
|
+
/** @internal */
|
|
32
|
+
__mobileHasPrimaryMeta?: boolean;
|
|
33
|
+
/** @internal */
|
|
34
|
+
__mobileIsFirstBodyField?: boolean;
|
|
24
35
|
}
|
|
25
36
|
|
|
26
37
|
const NAME = 'ucl-uikit-table__cell';
|
|
27
38
|
|
|
39
|
+
const getDefaultMobileRole = (
|
|
40
|
+
variant: ColumnVariant
|
|
41
|
+
): NormalizedTableMobileRole => {
|
|
42
|
+
if (variant === 'checkbox') return 'selection';
|
|
43
|
+
if (variant === 'button') return 'primaryAction';
|
|
44
|
+
return 'field';
|
|
45
|
+
};
|
|
46
|
+
|
|
28
47
|
const Cell = ({
|
|
29
48
|
variant = 'default',
|
|
30
49
|
icon,
|
|
@@ -36,9 +55,17 @@ const Cell = ({
|
|
|
36
55
|
children,
|
|
37
56
|
checkboxProps,
|
|
38
57
|
buttonProps,
|
|
58
|
+
__mobileColumnIndex,
|
|
59
|
+
__mobileHasSelection = false,
|
|
60
|
+
__mobileHasPrimaryMeta = false,
|
|
61
|
+
__mobileIsFirstBodyField = false,
|
|
39
62
|
...props
|
|
40
63
|
}: TableCellProps) => {
|
|
41
64
|
const [theme] = useTheme();
|
|
65
|
+
const { columns } = useTableContext();
|
|
66
|
+
const mobileColumn = columns[__mobileColumnIndex ?? -1];
|
|
67
|
+
const mobileRole = mobileColumn?.mobileRole ?? getDefaultMobileRole(variant);
|
|
68
|
+
const mobileLabel = mobileColumn?.mobileLabel;
|
|
42
69
|
|
|
43
70
|
if (
|
|
44
71
|
variant === 'checkbox' &&
|
|
@@ -63,20 +90,182 @@ const Cell = ({
|
|
|
63
90
|
box-sizing: border-box;
|
|
64
91
|
padding: 0 ${theme.padding.p16};
|
|
65
92
|
height: 40px;
|
|
66
|
-
font-family: ${theme.
|
|
67
|
-
font-
|
|
93
|
+
font-family: ${theme.typography.body.sm.fontFamily};
|
|
94
|
+
font-feature-settings: ${theme.typography.body.sm.fontSettings};
|
|
95
|
+
font-size: ${theme.typography.body.sm.fontSize}px;
|
|
96
|
+
font-weight: ${theme.typography.body.sm.fontWeight};
|
|
97
|
+
line-height: ${theme.typography.body.sm.lineHeight}%;
|
|
98
|
+
|
|
99
|
+
@media screen and (max-width: ${theme.breakpoints.tablet - 1}px) {
|
|
100
|
+
min-width: 0;
|
|
101
|
+
height: auto;
|
|
102
|
+
padding: 0;
|
|
103
|
+
}
|
|
104
|
+
`;
|
|
105
|
+
|
|
106
|
+
const mobileSelectionStyle = css`
|
|
107
|
+
@media screen and (max-width: ${theme.breakpoints.tablet - 1}px) {
|
|
108
|
+
grid-column: 1;
|
|
109
|
+
grid-row: 1 / span 2;
|
|
110
|
+
order: 0;
|
|
111
|
+
align-self: center;
|
|
112
|
+
padding-top: ${theme.padding.p2};
|
|
113
|
+
}
|
|
114
|
+
`;
|
|
115
|
+
|
|
116
|
+
const mobilePrimaryStyle = css`
|
|
117
|
+
@media screen and (max-width: ${theme.breakpoints.tablet - 1}px) {
|
|
118
|
+
display: grid;
|
|
119
|
+
grid-template-columns: minmax(0, 1fr) auto;
|
|
120
|
+
align-items: start;
|
|
121
|
+
gap: ${theme.padding.p8};
|
|
122
|
+
min-height: 20px;
|
|
123
|
+
}
|
|
124
|
+
`;
|
|
125
|
+
|
|
126
|
+
const mobilePrimaryAfterSelectionStyle = css`
|
|
127
|
+
@media screen and (max-width: ${theme.breakpoints.tablet - 1}px) {
|
|
128
|
+
grid-column: 2;
|
|
129
|
+
}
|
|
130
|
+
`;
|
|
131
|
+
|
|
132
|
+
const mobilePrimaryWithoutSelectionStyle = css`
|
|
133
|
+
@media screen and (max-width: ${theme.breakpoints.tablet - 1}px) {
|
|
134
|
+
grid-column: 1 / 3;
|
|
135
|
+
}
|
|
136
|
+
`;
|
|
137
|
+
|
|
138
|
+
const mobilePrimaryWithPrimaryMetaStyle = css`
|
|
139
|
+
@media screen and (max-width: ${theme.breakpoints.tablet - 1}px) {
|
|
140
|
+
grid-row: 2;
|
|
141
|
+
order: 2;
|
|
142
|
+
}
|
|
143
|
+
`;
|
|
144
|
+
|
|
145
|
+
const mobilePrimaryWithoutPrimaryMetaStyle = css`
|
|
146
|
+
@media screen and (max-width: ${theme.breakpoints.tablet - 1}px) {
|
|
147
|
+
grid-row: 1 / span 2;
|
|
148
|
+
order: 1;
|
|
149
|
+
align-self: center;
|
|
150
|
+
}
|
|
151
|
+
`;
|
|
152
|
+
|
|
153
|
+
const mobilePrimaryMetaStyle = css`
|
|
154
|
+
@media screen and (max-width: ${theme.breakpoints.tablet - 1}px) {
|
|
155
|
+
grid-row: 1;
|
|
156
|
+
order: 1;
|
|
157
|
+
min-height: 18px;
|
|
158
|
+
}
|
|
159
|
+
`;
|
|
160
|
+
|
|
161
|
+
const mobilePrimaryMetaAfterSelectionStyle = css`
|
|
162
|
+
@media screen and (max-width: ${theme.breakpoints.tablet - 1}px) {
|
|
163
|
+
grid-column: 2;
|
|
164
|
+
}
|
|
165
|
+
`;
|
|
166
|
+
|
|
167
|
+
const mobilePrimaryMetaWithoutSelectionStyle = css`
|
|
168
|
+
@media screen and (max-width: ${theme.breakpoints.tablet - 1}px) {
|
|
169
|
+
grid-column: 1 / 3;
|
|
170
|
+
}
|
|
171
|
+
`;
|
|
172
|
+
|
|
173
|
+
const mobileStatusStyle = css`
|
|
174
|
+
@media screen and (max-width: ${theme.breakpoints.tablet - 1}px) {
|
|
175
|
+
grid-column: 3;
|
|
176
|
+
grid-row: 1 / span 2;
|
|
177
|
+
order: 2;
|
|
178
|
+
align-self: center;
|
|
179
|
+
}
|
|
180
|
+
`;
|
|
181
|
+
|
|
182
|
+
const mobileContextMenuStyle = css`
|
|
183
|
+
@media screen and (max-width: ${theme.breakpoints.tablet - 1}px) {
|
|
184
|
+
grid-column: 4;
|
|
185
|
+
grid-row: 1 / span 2;
|
|
186
|
+
order: 3;
|
|
187
|
+
align-self: center;
|
|
188
|
+
}
|
|
189
|
+
`;
|
|
190
|
+
|
|
191
|
+
const mobileFieldStyle = css`
|
|
192
|
+
@media screen and (max-width: ${theme.breakpoints.tablet - 1}px) {
|
|
193
|
+
display: grid;
|
|
194
|
+
grid-template-columns: minmax(90px, 32%) minmax(0, 1fr);
|
|
195
|
+
grid-column: 1 / -1;
|
|
196
|
+
order: 20;
|
|
197
|
+
align-items: start;
|
|
198
|
+
column-gap: ${theme.padding.p16};
|
|
199
|
+
padding: ${theme.padding.p6} 0;
|
|
200
|
+
|
|
201
|
+
&::before {
|
|
202
|
+
content: attr(data-mobile-label);
|
|
203
|
+
color: ${theme.colour.text.secondary};
|
|
204
|
+
font-weight: ${theme.typography.body.sm.fontWeight};
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
`;
|
|
208
|
+
|
|
209
|
+
const mobileFirstFieldStyle = css`
|
|
210
|
+
@media screen and (max-width: ${theme.breakpoints.tablet - 1}px) {
|
|
211
|
+
margin-top: ${theme.margin.m16};
|
|
212
|
+
padding-top: ${theme.padding.p12};
|
|
213
|
+
border-top: ${theme.border.b1} solid ${theme.colour.border.default};
|
|
214
|
+
}
|
|
215
|
+
`;
|
|
216
|
+
|
|
217
|
+
const mobilePrimaryActionStyle = css`
|
|
218
|
+
@media screen and (max-width: ${theme.breakpoints.tablet - 1}px) {
|
|
219
|
+
grid-column: 1 / -1;
|
|
220
|
+
order: 30;
|
|
221
|
+
margin-top: ${theme.margin.m8};
|
|
222
|
+
padding-top: ${theme.padding.p12};
|
|
223
|
+
border-top: ${theme.border.b1} solid ${theme.colour.border.default};
|
|
224
|
+
}
|
|
225
|
+
`;
|
|
226
|
+
|
|
227
|
+
const mobileHiddenStyle = css`
|
|
228
|
+
@media screen and (max-width: ${theme.breakpoints.tablet - 1}px) {
|
|
229
|
+
display: none;
|
|
230
|
+
}
|
|
68
231
|
`;
|
|
69
232
|
|
|
70
233
|
const style = cx(baseStyle, className, NAME);
|
|
234
|
+
const mobileStyle = cx({
|
|
235
|
+
[mobileSelectionStyle]: mobileRole === 'selection',
|
|
236
|
+
[mobilePrimaryStyle]: mobileRole === 'primary',
|
|
237
|
+
[mobilePrimaryAfterSelectionStyle]:
|
|
238
|
+
mobileRole === 'primary' && __mobileHasSelection,
|
|
239
|
+
[mobilePrimaryWithoutSelectionStyle]:
|
|
240
|
+
mobileRole === 'primary' && !__mobileHasSelection,
|
|
241
|
+
[mobilePrimaryWithPrimaryMetaStyle]:
|
|
242
|
+
mobileRole === 'primary' && __mobileHasPrimaryMeta,
|
|
243
|
+
[mobilePrimaryWithoutPrimaryMetaStyle]:
|
|
244
|
+
mobileRole === 'primary' && !__mobileHasPrimaryMeta,
|
|
245
|
+
[mobilePrimaryMetaStyle]: mobileRole === 'primaryMeta',
|
|
246
|
+
[mobilePrimaryMetaAfterSelectionStyle]:
|
|
247
|
+
mobileRole === 'primaryMeta' && __mobileHasSelection,
|
|
248
|
+
[mobilePrimaryMetaWithoutSelectionStyle]:
|
|
249
|
+
mobileRole === 'primaryMeta' && !__mobileHasSelection,
|
|
250
|
+
[mobileStatusStyle]: mobileRole === 'status',
|
|
251
|
+
[mobileContextMenuStyle]: mobileRole === 'contextMenu',
|
|
252
|
+
[mobileFieldStyle]: mobileRole === 'field',
|
|
253
|
+
[mobileFirstFieldStyle]: mobileRole === 'field' && __mobileIsFirstBodyField,
|
|
254
|
+
[mobilePrimaryActionStyle]: mobileRole === 'primaryAction',
|
|
255
|
+
[mobileHiddenStyle]: mobileRole === 'hidden',
|
|
256
|
+
});
|
|
71
257
|
|
|
72
258
|
return (
|
|
73
259
|
<td
|
|
74
|
-
className={style}
|
|
260
|
+
className={cx(style, mobileStyle)}
|
|
75
261
|
data-testid={testId}
|
|
262
|
+
data-mobile-role={mobileRole}
|
|
263
|
+
data-mobile-label={mobileLabel}
|
|
76
264
|
{...props}
|
|
77
265
|
>
|
|
78
266
|
<CellContent
|
|
79
267
|
variant={variant}
|
|
268
|
+
mobileRole={mobileRole}
|
|
80
269
|
icon={icon}
|
|
81
270
|
checked={checked}
|
|
82
271
|
handleCheckboxChange={handleCheckboxChange}
|
|
@@ -4,10 +4,14 @@ import type { CheckboxProps } from '../../../Checkbox/Checkbox';
|
|
|
4
4
|
import Button from '../../../Button';
|
|
5
5
|
import type { ButtonProps } from '../../../Button';
|
|
6
6
|
import { useTheme } from '../../../../theme';
|
|
7
|
-
import type {
|
|
7
|
+
import type {
|
|
8
|
+
ColumnVariant,
|
|
9
|
+
NormalizedTableMobileRole,
|
|
10
|
+
} from '../../Table.types';
|
|
8
11
|
|
|
9
12
|
interface CellContentProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
10
13
|
variant: ColumnVariant;
|
|
14
|
+
mobileRole: NormalizedTableMobileRole;
|
|
11
15
|
icon?: React.ReactNode;
|
|
12
16
|
checked?: boolean;
|
|
13
17
|
checkboxProps?: Omit<CheckboxProps, 'checked' | 'onChange'>;
|
|
@@ -23,6 +27,7 @@ const NAME = 'ucl-uikit-table__cell-content';
|
|
|
23
27
|
|
|
24
28
|
const CellContent = ({
|
|
25
29
|
variant,
|
|
30
|
+
mobileRole,
|
|
26
31
|
icon,
|
|
27
32
|
checked,
|
|
28
33
|
checkboxProps,
|
|
@@ -44,11 +49,11 @@ const CellContent = ({
|
|
|
44
49
|
|
|
45
50
|
const variantStyles = {
|
|
46
51
|
default: css`
|
|
47
|
-
font-weight: ${theme.
|
|
52
|
+
font-weight: ${theme.typography.body.sm.fontWeight};
|
|
48
53
|
`,
|
|
49
54
|
numeric: css`
|
|
50
55
|
justify-content: flex-end;
|
|
51
|
-
font-weight: ${theme.
|
|
56
|
+
font-weight: ${theme.typography.body.sm.fontWeight};
|
|
52
57
|
`,
|
|
53
58
|
checkbox: css`
|
|
54
59
|
justify-content: flex-end;
|
|
@@ -61,13 +66,68 @@ const CellContent = ({
|
|
|
61
66
|
height: auto;
|
|
62
67
|
`;
|
|
63
68
|
|
|
69
|
+
const mobileStyle = css`
|
|
70
|
+
@media screen and (max-width: ${theme.breakpoints.tablet - 1}px) {
|
|
71
|
+
align-items: flex-start;
|
|
72
|
+
justify-content: flex-start;
|
|
73
|
+
min-width: 0;
|
|
74
|
+
height: auto;
|
|
75
|
+
padding-right: 0;
|
|
76
|
+
}
|
|
77
|
+
`;
|
|
78
|
+
|
|
79
|
+
const mobilePrimaryStyle = css`
|
|
80
|
+
@media screen and (max-width: ${theme.breakpoints.tablet - 1}px) {
|
|
81
|
+
display: -webkit-box;
|
|
82
|
+
overflow: hidden;
|
|
83
|
+
color: ${theme.colour.text.default};
|
|
84
|
+
font-family: ${theme.typography.body.md.fontFamily};
|
|
85
|
+
font-feature-settings: ${theme.typography.body.md.fontSettings};
|
|
86
|
+
font-size: ${theme.typography.body.md.fontSize}px;
|
|
87
|
+
line-height: ${theme.typography.body.md.lineHeight}%;
|
|
88
|
+
font-weight: ${theme.typography.body.md.fontWeight};
|
|
89
|
+
-webkit-box-orient: vertical;
|
|
90
|
+
-webkit-line-clamp: 2;
|
|
91
|
+
}
|
|
92
|
+
`;
|
|
93
|
+
|
|
94
|
+
const mobilePrimaryMetaStyle = css`
|
|
95
|
+
@media screen and (max-width: ${theme.breakpoints.tablet - 1}px) {
|
|
96
|
+
color: ${theme.colour.text.secondary};
|
|
97
|
+
font-family: ${theme.typography.body.xs.fontFamily};
|
|
98
|
+
font-feature-settings: ${theme.typography.body.xs.fontSettings};
|
|
99
|
+
font-size: ${theme.typography.body.xs.fontSize}px;
|
|
100
|
+
font-weight: ${theme.typography.body.xs.fontWeight};
|
|
101
|
+
line-height: ${theme.typography.body.xs.lineHeight}%;
|
|
102
|
+
}
|
|
103
|
+
`;
|
|
104
|
+
|
|
105
|
+
const mobilePrimaryActionStyle = css`
|
|
106
|
+
@media screen and (max-width: ${theme.breakpoints.tablet - 1}px) {
|
|
107
|
+
color: ${theme.colour.link.visited};
|
|
108
|
+
font-weight: ${theme.typography.body.sm.fontWeight};
|
|
109
|
+
}
|
|
110
|
+
`;
|
|
111
|
+
|
|
112
|
+
const mobileHeaderTrailingStyle = css`
|
|
113
|
+
@media screen and (max-width: ${theme.breakpoints.tablet - 1}px) {
|
|
114
|
+
justify-content: flex-end;
|
|
115
|
+
}
|
|
116
|
+
`;
|
|
117
|
+
|
|
64
118
|
const style = cx(
|
|
65
119
|
baseStyle,
|
|
66
120
|
{
|
|
67
121
|
[variantStyles.default]: variant === 'default',
|
|
68
122
|
[variantStyles.numeric]: variant === 'numeric',
|
|
69
123
|
[variantStyles.checkbox]: variant === 'checkbox',
|
|
124
|
+
[mobilePrimaryStyle]: mobileRole === 'primary',
|
|
125
|
+
[mobilePrimaryMetaStyle]: mobileRole === 'primaryMeta',
|
|
126
|
+
[mobilePrimaryActionStyle]: mobileRole === 'primaryAction',
|
|
127
|
+
[mobileHeaderTrailingStyle]:
|
|
128
|
+
mobileRole === 'status' || mobileRole === 'contextMenu',
|
|
70
129
|
},
|
|
130
|
+
mobileStyle,
|
|
71
131
|
NAME
|
|
72
132
|
);
|
|
73
133
|
|
|
@@ -5,11 +5,12 @@ exports[`Cell > Snapshot: default 1`] = `
|
|
|
5
5
|
<tbody>
|
|
6
6
|
<tr>
|
|
7
7
|
<td
|
|
8
|
-
class="
|
|
8
|
+
class="ucl-uikit-table__cell css-501n1z"
|
|
9
|
+
data-mobile-role="field"
|
|
9
10
|
data-testid="ucl-uikit-table__cell"
|
|
10
11
|
>
|
|
11
12
|
<div
|
|
12
|
-
class="ucl-uikit-table__cell-content css-
|
|
13
|
+
class="ucl-uikit-table__cell-content css-qn93h1"
|
|
13
14
|
data-testid="ucl-uikit-table__cell-content"
|
|
14
15
|
>
|
|
15
16
|
Default cell
|
|
@@ -25,22 +26,24 @@ exports[`Cell > Snapshot: variants 1`] = `
|
|
|
25
26
|
<tbody>
|
|
26
27
|
<tr>
|
|
27
28
|
<td
|
|
28
|
-
class="
|
|
29
|
+
class="ucl-uikit-table__cell css-501n1z"
|
|
30
|
+
data-mobile-role="field"
|
|
29
31
|
data-testid="ucl-uikit-table__cell"
|
|
30
32
|
>
|
|
31
33
|
<div
|
|
32
|
-
class="ucl-uikit-table__cell-content css-
|
|
34
|
+
class="ucl-uikit-table__cell-content css-1tff2yh"
|
|
33
35
|
data-testid="ucl-uikit-table__cell-content"
|
|
34
36
|
>
|
|
35
37
|
123
|
|
36
38
|
</div>
|
|
37
39
|
</td>
|
|
38
40
|
<td
|
|
39
|
-
class="
|
|
41
|
+
class="ucl-uikit-table__cell css-11iy32t"
|
|
42
|
+
data-mobile-role="selection"
|
|
40
43
|
data-testid="ucl-uikit-table__cell"
|
|
41
44
|
>
|
|
42
45
|
<div
|
|
43
|
-
class="ucl-uikit-table__cell-content css-
|
|
46
|
+
class="ucl-uikit-table__cell-content css-e77rql"
|
|
44
47
|
data-testid="ucl-uikit-table__cell-content"
|
|
45
48
|
>
|
|
46
49
|
<span
|
|
@@ -60,11 +63,12 @@ exports[`Cell > Snapshot: variants 1`] = `
|
|
|
60
63
|
</div>
|
|
61
64
|
</td>
|
|
62
65
|
<td
|
|
63
|
-
class="
|
|
66
|
+
class="ucl-uikit-table__cell css-501n1z"
|
|
67
|
+
data-mobile-role="field"
|
|
64
68
|
data-testid="ucl-uikit-table__cell"
|
|
65
69
|
>
|
|
66
70
|
<div
|
|
67
|
-
class="ucl-uikit-table__cell-content css-
|
|
71
|
+
class="ucl-uikit-table__cell-content css-qn93h1"
|
|
68
72
|
data-testid="ucl-uikit-table__cell-content"
|
|
69
73
|
>
|
|
70
74
|
<svg
|
|
@@ -91,11 +95,12 @@ exports[`Cell > Snapshot: variants 1`] = `
|
|
|
91
95
|
</div>
|
|
92
96
|
</td>
|
|
93
97
|
<td
|
|
94
|
-
class="
|
|
98
|
+
class="ucl-uikit-table__cell css-x1o1q5"
|
|
99
|
+
data-mobile-role="primaryAction"
|
|
95
100
|
data-testid="ucl-uikit-table__cell"
|
|
96
101
|
>
|
|
97
102
|
<div
|
|
98
|
-
class="
|
|
103
|
+
class="ucl-uikit-table__cell-content css-1d5ok6z"
|
|
99
104
|
data-testid="ucl-uikit-table__cell-content"
|
|
100
105
|
>
|
|
101
106
|
<button
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { css, cx } from '@emotion/css';
|
|
2
2
|
import { useTheme } from '../../../theme';
|
|
3
3
|
|
|
4
|
-
export interface TableHeadProps
|
|
5
|
-
extends React.HTMLAttributes<HTMLTableSectionElement> {}
|
|
4
|
+
export interface TableHeadProps extends React.HTMLAttributes<HTMLTableSectionElement> {}
|
|
6
5
|
|
|
7
6
|
const NAME = 'ucl-uikit-table__head';
|
|
8
7
|
|
|
@@ -12,10 +11,22 @@ const Head = ({ className, children, ...props }: TableHeadProps) => {
|
|
|
12
11
|
const baseStyle = css`
|
|
13
12
|
height: 40px;
|
|
14
13
|
background-color: #f8f8f8; // TODO: Add a design token
|
|
14
|
+
|
|
15
|
+
@media screen and (max-width: ${theme.breakpoints.tablet - 1}px) {
|
|
16
|
+
position: absolute;
|
|
17
|
+
width: 1px;
|
|
18
|
+
height: 1px;
|
|
19
|
+
padding: 0;
|
|
20
|
+
margin: -1px;
|
|
21
|
+
overflow: hidden;
|
|
22
|
+
clip: rect(0, 0, 0, 0);
|
|
23
|
+
white-space: nowrap;
|
|
24
|
+
border: 0;
|
|
25
|
+
}
|
|
15
26
|
`;
|
|
16
27
|
|
|
17
28
|
const rowStyle = css`
|
|
18
|
-
border-bottom: 1px solid ${theme.
|
|
29
|
+
border-bottom: 1px solid ${theme.colour.border.default};
|
|
19
30
|
`;
|
|
20
31
|
|
|
21
32
|
const style = cx(baseStyle, className, NAME);
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { css, cx } from '@emotion/css';
|
|
2
2
|
import { useTheme } from '../../../../theme';
|
|
3
3
|
import HeadCellContent from './HeadCellContent';
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
ColumnVariant,
|
|
6
|
+
SortOrder,
|
|
7
|
+
TableMobileRole,
|
|
8
|
+
} from '../../Table.types';
|
|
5
9
|
|
|
6
10
|
export interface TableHeadCellProps extends React.HTMLAttributes<HTMLTableCellElement> {
|
|
7
11
|
variant?: ColumnVariant;
|
|
8
12
|
accessor?: string;
|
|
13
|
+
mobileRole?: TableMobileRole;
|
|
14
|
+
mobileLabel?: string;
|
|
9
15
|
sort?: SortOrder;
|
|
10
16
|
onSortChange?: (
|
|
11
17
|
accessor: string,
|
|
@@ -27,6 +33,8 @@ const NAME = 'ucl-uikit-table__head-cell';
|
|
|
27
33
|
const HeadCell = ({
|
|
28
34
|
variant = 'default',
|
|
29
35
|
accessor,
|
|
36
|
+
mobileRole,
|
|
37
|
+
mobileLabel,
|
|
30
38
|
sort = null,
|
|
31
39
|
onSortChange,
|
|
32
40
|
showSortIcon = true,
|
|
@@ -73,9 +81,12 @@ const HeadCell = ({
|
|
|
73
81
|
|
|
74
82
|
const baseStyle = css`
|
|
75
83
|
padding: ${theme.padding.p8} ${theme.padding.p16};
|
|
76
|
-
color: ${theme.
|
|
77
|
-
font-family: ${theme.
|
|
78
|
-
font-
|
|
84
|
+
color: ${theme.colour.text.secondary};
|
|
85
|
+
font-family: ${theme.typography.body.sm.fontFamily};
|
|
86
|
+
font-feature-settings: ${theme.typography.body.sm.fontSettings};
|
|
87
|
+
font-size: ${theme.typography.body.sm.fontSize}px;
|
|
88
|
+
font-weight: ${theme.typography.body.sm.fontWeight};
|
|
89
|
+
line-height: ${theme.typography.body.sm.lineHeight}%;
|
|
79
90
|
text-align: left;
|
|
80
91
|
cursor: ${isSortable ? 'pointer' : 'default'};
|
|
81
92
|
user-select: none;
|
|
@@ -91,6 +102,8 @@ const HeadCell = ({
|
|
|
91
102
|
className={style}
|
|
92
103
|
data-testid={testId}
|
|
93
104
|
data-accessor={accessor}
|
|
105
|
+
data-mobile-role={mobileRole}
|
|
106
|
+
data-mobile-label={mobileLabel}
|
|
94
107
|
data-sort={sort}
|
|
95
108
|
tabIndex={isSortable ? 0 : undefined}
|
|
96
109
|
aria-sort={
|
package/lib/components/Table/subcomponents/HeadCell/__tests__/__snapshots__/HeadCell.test.tsx.snap
CHANGED
|
@@ -5,7 +5,7 @@ exports[`HeadCell > Snapshot: checkbox variant 1`] = `
|
|
|
5
5
|
<thead>
|
|
6
6
|
<tr>
|
|
7
7
|
<th
|
|
8
|
-
class="css-
|
|
8
|
+
class="css-x1n4gt ucl-uikit-table__head-cell"
|
|
9
9
|
data-testid="ucl-uikit-table__head-cell"
|
|
10
10
|
scope="col"
|
|
11
11
|
>
|
|
@@ -40,7 +40,7 @@ exports[`HeadCell > Snapshot: default 1`] = `
|
|
|
40
40
|
<thead>
|
|
41
41
|
<tr>
|
|
42
42
|
<th
|
|
43
|
-
class="css-
|
|
43
|
+
class="css-x1n4gt ucl-uikit-table__head-cell"
|
|
44
44
|
data-testid="ucl-uikit-table__head-cell"
|
|
45
45
|
scope="col"
|
|
46
46
|
>
|
|
@@ -100,7 +100,7 @@ exports[`HeadCell > no sorting icon 1`] = `
|
|
|
100
100
|
<thead>
|
|
101
101
|
<tr>
|
|
102
102
|
<th
|
|
103
|
-
class="css-
|
|
103
|
+
class="css-x1n4gt ucl-uikit-table__head-cell"
|
|
104
104
|
data-testid="ucl-uikit-table__head-cell"
|
|
105
105
|
scope="col"
|
|
106
106
|
>
|