uikit-react-public 0.26.3 → 0.27.1
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/BaseCheckbox/BaseCheckbox.d.ts +26 -0
- package/dist/components/BaseCheckbox/BaseCheckbox.stories.d.ts +29 -0
- package/dist/components/BaseCheckbox/__tests__/BaseCheckbox.test.d.ts +1 -0
- package/dist/components/BaseCheckbox/index.d.ts +2 -0
- package/dist/components/MenuNew/MenuAccordion/MenuAccordionItem.d.ts +2 -3
- package/dist/components/MenuNew/MenuBaseItem.d.ts +2 -1
- package/dist/components/MenuNew/index.d.ts +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/index.js +2865 -2776
- package/lib/components/BaseCheckbox/BaseCheckbox.stories.tsx +82 -0
- package/lib/components/BaseCheckbox/BaseCheckbox.tsx +168 -0
- package/lib/components/BaseCheckbox/__tests__/BaseCheckbox.test.tsx +98 -0
- package/lib/components/BaseCheckbox/index.ts +2 -0
- package/lib/components/Checkbox/Checkbox.tsx +49 -53
- package/lib/components/Checkbox/__tests__/__snapshots__/Checkbox.test.tsx.snap +66 -43
- package/lib/components/MenuNew/MenuAccordion/MenuAccordion.tsx +2 -1
- package/lib/components/MenuNew/MenuAccordion/MenuAccordionItem.tsx +7 -6
- package/lib/components/MenuNew/MenuBaseItem.tsx +17 -0
- package/lib/components/MenuNew/__tests__/Menu.test.tsx +64 -0
- package/lib/components/MenuNew/index.ts +1 -0
- package/lib/components/Table/subcomponents/Cell/__tests__/__snapshots__/Cell.test.tsx.snap +7 -2
- package/lib/components/Table/subcomponents/HeadCell/__tests__/__snapshots__/HeadCell.test.tsx.snap +7 -2
- package/lib/components/index.ts +3 -0
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ export interface MenuBaseItemProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
8
8
|
endAdornment?: ReactNode;
|
|
9
9
|
hoverMode?: 'background' | 'underline';
|
|
10
10
|
asChild?: boolean;
|
|
11
|
+
active?: boolean;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
const MenuBaseItem = ({
|
|
@@ -22,6 +23,7 @@ const MenuBaseItem = ({
|
|
|
22
23
|
tabIndex,
|
|
23
24
|
hoverMode = 'background',
|
|
24
25
|
asChild = false,
|
|
26
|
+
active = false,
|
|
25
27
|
...props
|
|
26
28
|
}: MenuBaseItemProps) => {
|
|
27
29
|
const [theme] = useTheme();
|
|
@@ -53,6 +55,7 @@ const MenuBaseItem = ({
|
|
|
53
55
|
display: flex;
|
|
54
56
|
align-items: center;
|
|
55
57
|
gap: ${theme.margin.m16};
|
|
58
|
+
position: relative;
|
|
56
59
|
cursor: pointer;
|
|
57
60
|
outline: none;
|
|
58
61
|
|
|
@@ -65,6 +68,19 @@ const MenuBaseItem = ({
|
|
|
65
68
|
}
|
|
66
69
|
`;
|
|
67
70
|
|
|
71
|
+
const activeStyle = css`
|
|
72
|
+
&::before {
|
|
73
|
+
content: '';
|
|
74
|
+
position: absolute;
|
|
75
|
+
left: 0;
|
|
76
|
+
top: calc(50% - 12px);
|
|
77
|
+
width: 6px;
|
|
78
|
+
height: 24px;
|
|
79
|
+
background-color: ${theme.colour.fill.brand};
|
|
80
|
+
pointer-events: none;
|
|
81
|
+
}
|
|
82
|
+
`;
|
|
83
|
+
|
|
68
84
|
const backgroundOnHoverStyle = css`
|
|
69
85
|
&:hover {
|
|
70
86
|
background-color: ${theme.colour.fill.brandSubtleHover};
|
|
@@ -79,6 +95,7 @@ const MenuBaseItem = ({
|
|
|
79
95
|
|
|
80
96
|
const style = cx(
|
|
81
97
|
baseStyle,
|
|
98
|
+
active && activeStyle,
|
|
82
99
|
hoverMode === 'underline' && underlineStyleOnHoverStyle,
|
|
83
100
|
hoverMode === 'background' && backgroundOnHoverStyle,
|
|
84
101
|
className
|
|
@@ -129,6 +129,7 @@ describe('Menu', () => {
|
|
|
129
129
|
.getByText('Library')
|
|
130
130
|
.closest('.ucl-uikit-menu__accordion-item');
|
|
131
131
|
const accordionContentInner = accordionItem?.parentElement;
|
|
132
|
+
const accordionContent = accordionContentInner?.parentElement;
|
|
132
133
|
|
|
133
134
|
expect(accordionItem).toHaveStyle({
|
|
134
135
|
marginTop: '0px',
|
|
@@ -137,6 +138,10 @@ describe('Menu', () => {
|
|
|
137
138
|
marginBottom: '0px',
|
|
138
139
|
width: 'calc(100% - 12px)',
|
|
139
140
|
});
|
|
141
|
+
expect(accordionContent).toHaveStyle({
|
|
142
|
+
marginLeft: '-6px',
|
|
143
|
+
width: 'calc(100% + 12px)',
|
|
144
|
+
});
|
|
140
145
|
expect(accordionContentInner).toHaveStyle({
|
|
141
146
|
paddingTop: '6px',
|
|
142
147
|
paddingBottom: '6px',
|
|
@@ -257,6 +262,65 @@ describe('Menu', () => {
|
|
|
257
262
|
expect(item?.firstChild).toHaveAttribute('data-testid', 'left-icon');
|
|
258
263
|
});
|
|
259
264
|
|
|
265
|
+
test('active items render a non-disruptive marker', () => {
|
|
266
|
+
wrap(
|
|
267
|
+
<Menu>
|
|
268
|
+
<Menu.PrimaryItem active>Home</Menu.PrimaryItem>
|
|
269
|
+
</Menu>
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
const item = screen
|
|
273
|
+
.getByText('Home')
|
|
274
|
+
.closest('.ucl-uikit-menu__primary-item');
|
|
275
|
+
const generatedClass = Array.from(item?.classList ?? []).find((className) =>
|
|
276
|
+
className.startsWith('css-')
|
|
277
|
+
);
|
|
278
|
+
const cssRules = Array.from(document.styleSheets)
|
|
279
|
+
.flatMap((styleSheet) => Array.from(styleSheet.cssRules))
|
|
280
|
+
.map((rule) => rule.cssText)
|
|
281
|
+
.join(' ');
|
|
282
|
+
|
|
283
|
+
expect(item).not.toHaveAttribute('active');
|
|
284
|
+
expect(item).toHaveStyle({ position: 'relative' });
|
|
285
|
+
expect(cssRules).toContain(`.${generatedClass}::before`);
|
|
286
|
+
expect(cssRules).toContain('width: 6px');
|
|
287
|
+
expect(cssRules).toContain('height: 24px');
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
test.each([
|
|
291
|
+
{
|
|
292
|
+
name: 'accordion',
|
|
293
|
+
menu: (
|
|
294
|
+
<Menu.Accordion
|
|
295
|
+
active
|
|
296
|
+
label='Systems'
|
|
297
|
+
/>
|
|
298
|
+
),
|
|
299
|
+
text: 'Systems',
|
|
300
|
+
selector: '.ucl-uikit-menu__accordion',
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
name: 'accordion item',
|
|
304
|
+
menu: <Menu.Accordion.Item active>Library</Menu.Accordion.Item>,
|
|
305
|
+
text: 'Library',
|
|
306
|
+
selector: '.ucl-uikit-menu__accordion-item',
|
|
307
|
+
},
|
|
308
|
+
])('$name supports active state', ({ menu, text, selector }) => {
|
|
309
|
+
wrap(<Menu>{menu}</Menu>);
|
|
310
|
+
|
|
311
|
+
const item = screen.getByText(text).closest(selector);
|
|
312
|
+
const generatedClass = Array.from(item?.classList ?? []).find((className) =>
|
|
313
|
+
className.startsWith('css-')
|
|
314
|
+
);
|
|
315
|
+
const cssRules = Array.from(document.styleSheets)
|
|
316
|
+
.flatMap((styleSheet) => Array.from(styleSheet.cssRules))
|
|
317
|
+
.map((rule) => rule.cssText)
|
|
318
|
+
.join(' ');
|
|
319
|
+
|
|
320
|
+
expect(item).not.toHaveAttribute('active');
|
|
321
|
+
expect(cssRules).toContain(`.${generatedClass}::before`);
|
|
322
|
+
});
|
|
323
|
+
|
|
260
324
|
test('primary items use background hover instead of underline hover', () => {
|
|
261
325
|
wrap(
|
|
262
326
|
<Menu>
|
|
@@ -44,13 +44,18 @@ exports[`Cell > Snapshot: variants 1`] = `
|
|
|
44
44
|
data-testid="ucl-uikit-table__cell-content"
|
|
45
45
|
>
|
|
46
46
|
<span
|
|
47
|
-
class="ucl-uikit-checkbox css-
|
|
47
|
+
class="ucl-uikit-base-checkbox ucl-uikit-checkbox css-tfrbiv"
|
|
48
|
+
data-testid="ucl-uikit-checkbox__root"
|
|
48
49
|
>
|
|
49
50
|
<input
|
|
50
|
-
class="css-
|
|
51
|
+
class="css-1bjd9qx"
|
|
51
52
|
data-testid="ucl-uikit-checkbox"
|
|
52
53
|
type="checkbox"
|
|
53
54
|
/>
|
|
55
|
+
<span
|
|
56
|
+
aria-hidden="true"
|
|
57
|
+
class="css-1quq9cp"
|
|
58
|
+
/>
|
|
54
59
|
</span>
|
|
55
60
|
</div>
|
|
56
61
|
</td>
|
package/lib/components/Table/subcomponents/HeadCell/__tests__/__snapshots__/HeadCell.test.tsx.snap
CHANGED
|
@@ -14,14 +14,19 @@ exports[`HeadCell > Snapshot: checkbox variant 1`] = `
|
|
|
14
14
|
data-testid="ucl-uikit-table__head-cell-content"
|
|
15
15
|
>
|
|
16
16
|
<span
|
|
17
|
-
class="ucl-uikit-checkbox css-
|
|
17
|
+
class="ucl-uikit-base-checkbox ucl-uikit-checkbox css-tfrbiv"
|
|
18
|
+
data-testid="ucl-uikit-checkbox__root"
|
|
18
19
|
>
|
|
19
20
|
<input
|
|
20
21
|
aria-label="Select all rows"
|
|
21
|
-
class="css-
|
|
22
|
+
class="css-1bjd9qx"
|
|
22
23
|
data-testid="ucl-uikit-checkbox"
|
|
23
24
|
type="checkbox"
|
|
24
25
|
/>
|
|
26
|
+
<span
|
|
27
|
+
aria-hidden="true"
|
|
28
|
+
class="css-1quq9cp"
|
|
29
|
+
/>
|
|
25
30
|
</span>
|
|
26
31
|
</div>
|
|
27
32
|
</th>
|
package/lib/components/index.ts
CHANGED
|
@@ -34,6 +34,9 @@ export type { AvatarProps } from './Avatar';
|
|
|
34
34
|
export { default as Badge } from './Badge';
|
|
35
35
|
export type { BadgeProps } from './Badge';
|
|
36
36
|
|
|
37
|
+
export { default as BaseCheckbox } from './BaseCheckbox';
|
|
38
|
+
export type { BaseCheckboxProps, BaseCheckboxState } from './BaseCheckbox';
|
|
39
|
+
|
|
37
40
|
export { default as Spinner } from './Spinner';
|
|
38
41
|
export type { SpinnerProps } from './Spinner';
|
|
39
42
|
|