@transferwise/components 0.0.0-experimental-daa78e3 → 0.0.0-experimental-b18fbc4
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/build/alert/Alert.js +2 -11
- package/build/alert/Alert.js.map +1 -1
- package/build/alert/Alert.mjs +2 -11
- package/build/alert/Alert.mjs.map +1 -1
- package/build/avatar/Avatar.js +5 -0
- package/build/avatar/Avatar.js.map +1 -1
- package/build/avatar/Avatar.mjs +5 -0
- package/build/avatar/Avatar.mjs.map +1 -1
- package/build/circularButton/CircularButton.js +1 -1
- package/build/circularButton/CircularButton.js.map +1 -1
- package/build/circularButton/CircularButton.mjs +1 -1
- package/build/circularButton/CircularButton.mjs.map +1 -1
- package/build/common/circle/Circle.js +15 -2
- package/build/common/circle/Circle.js.map +1 -1
- package/build/common/circle/Circle.mjs +15 -2
- package/build/common/circle/Circle.mjs.map +1 -1
- package/build/main.css +6 -22
- package/build/statusIcon/StatusIcon.js +4 -4
- package/build/statusIcon/StatusIcon.js.map +1 -1
- package/build/statusIcon/StatusIcon.mjs +4 -4
- package/build/statusIcon/StatusIcon.mjs.map +1 -1
- package/build/styles/circularButton/CircularButton.css +2 -2
- package/build/styles/common/circle/Circle.css +4 -0
- package/build/styles/main.css +6 -22
- package/build/styles/statusIcon/StatusIcon.css +0 -20
- package/build/types/alert/Alert.d.ts.map +1 -1
- package/build/types/avatar/Avatar.d.ts.map +1 -1
- package/build/types/common/circle/Circle.d.ts +1 -1
- package/build/types/common/circle/Circle.d.ts.map +1 -1
- package/build/types/statusIcon/StatusIcon.d.ts +6 -2
- package/build/types/statusIcon/StatusIcon.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/alert/Alert.story.tsx +6 -36
- package/src/alert/Alert.tsx +2 -12
- package/src/avatar/Avatar.spec.tsx +3 -1
- package/src/avatar/Avatar.tsx +5 -2
- package/src/avatarWrapper/__snapshots__/AvatarWrapper.spec.tsx.snap +11 -11
- package/src/badge/Badge.spec.tsx +3 -1
- package/src/circularButton/CircularButton.css +2 -2
- package/src/circularButton/CircularButton.less +1 -1
- package/src/circularButton/CircularButton.tsx +1 -1
- package/src/circularButton/__snapshots__/CircularButton.spec.tsx.snap +10 -10
- package/src/common/circle/Circle.css +4 -0
- package/src/common/circle/Circle.less +6 -0
- package/src/common/circle/Circle.tsx +25 -2
- package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +4 -4
- package/src/main.css +6 -22
- package/src/overlayHeader/OverlayHeader.spec.tsx +3 -1
- package/src/overlayHeader/__snapshots__/OverlayHeader.spec.tsx.snap +2 -2
- package/src/promoCard/PromoCard.spec.tsx +3 -1
- package/src/radio/Radio.rtl.spec.tsx +2 -1
- package/src/radio/__snapshots__/Radio.rtl.spec.tsx.snap +2 -2
- package/src/statusIcon/StatusIcon.css +0 -20
- package/src/statusIcon/StatusIcon.less +0 -17
- package/src/statusIcon/StatusIcon.spec.tsx +3 -21
- package/src/statusIcon/StatusIcon.story.tsx +31 -8
- package/src/statusIcon/StatusIcon.tsx +12 -6
- package/build/constants.js +0 -15
- package/build/constants.js.map +0 -1
- package/build/constants.mjs +0 -13
- package/build/constants.mjs.map +0 -1
- package/build/types/constants.d.ts +0 -11
- package/build/types/constants.d.ts.map +0 -1
- package/src/alert/Alert.spec.story.tsx +0 -87
- package/src/constants.ts +0 -11
|
@@ -22,11 +22,11 @@ exports[`FlowNavigation on mobile renders as expected 1`] = `
|
|
|
22
22
|
>
|
|
23
23
|
<div
|
|
24
24
|
class="np-circle d-flex align-items-center justify-content-center tw-avatar tw-avatar--48 tw-avatar--initials np-text-title-body"
|
|
25
|
-
style="--circle-size: 48px;"
|
|
25
|
+
style="--circle-size: 48px; --circle-icon-size: 24px;"
|
|
26
26
|
>
|
|
27
27
|
<div
|
|
28
28
|
class="np-circle d-flex align-items-center justify-content-center tw-avatar__content"
|
|
29
|
-
style="--circle-size: 48px;"
|
|
29
|
+
style="--circle-size: 48px; --circle-icon-size: 16px;"
|
|
30
30
|
>
|
|
31
31
|
TM
|
|
32
32
|
</div>
|
|
@@ -139,11 +139,11 @@ exports[`FlowNavigation renders as expected 1`] = `
|
|
|
139
139
|
>
|
|
140
140
|
<div
|
|
141
141
|
class="np-circle d-flex align-items-center justify-content-center tw-avatar tw-avatar--48 tw-avatar--initials np-text-title-body"
|
|
142
|
-
style="--circle-size: 48px;"
|
|
142
|
+
style="--circle-size: 48px; --circle-icon-size: 24px;"
|
|
143
143
|
>
|
|
144
144
|
<div
|
|
145
145
|
class="np-circle d-flex align-items-center justify-content-center tw-avatar__content"
|
|
146
|
-
style="--circle-size: 48px;"
|
|
146
|
+
style="--circle-size: 48px; --circle-icon-size: 16px;"
|
|
147
147
|
>
|
|
148
148
|
TM
|
|
149
149
|
</div>
|
package/src/main.css
CHANGED
|
@@ -1013,8 +1013,8 @@ div.critical-comms .critical-comms-body {
|
|
|
1013
1013
|
}
|
|
1014
1014
|
@media (max-width: 320px) {
|
|
1015
1015
|
.np-circular-btn .tw-icon {
|
|
1016
|
-
top:
|
|
1017
|
-
top: var(--size-
|
|
1016
|
+
top: 12px;
|
|
1017
|
+
top: var(--size-12);
|
|
1018
1018
|
}
|
|
1019
1019
|
}
|
|
1020
1020
|
.np-circular-btn .tw-icon > svg {
|
|
@@ -1169,6 +1169,10 @@ div.critical-comms .critical-comms-body {
|
|
|
1169
1169
|
height: var(--circle-size);
|
|
1170
1170
|
flex-shrink: 0;
|
|
1171
1171
|
}
|
|
1172
|
+
.np-circle .tw-icon > svg {
|
|
1173
|
+
height: var(--circle-icon-size);
|
|
1174
|
+
width: var(--circle-icon-size);
|
|
1175
|
+
}
|
|
1172
1176
|
.np-bottom-sheet {
|
|
1173
1177
|
border-radius: 10px 10px 0 0;
|
|
1174
1178
|
}
|
|
@@ -4155,12 +4159,6 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
4155
4159
|
transform: translateY(-24px);
|
|
4156
4160
|
}
|
|
4157
4161
|
}
|
|
4158
|
-
.status-icon > svg {
|
|
4159
|
-
height: 32px;
|
|
4160
|
-
height: var(--size-32);
|
|
4161
|
-
width: 32px;
|
|
4162
|
-
width: var(--size-32);
|
|
4163
|
-
}
|
|
4164
4162
|
.status-circle .light {
|
|
4165
4163
|
color: var(--color-contrast);
|
|
4166
4164
|
}
|
|
@@ -4176,20 +4174,6 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
4176
4174
|
.np-theme-personal .status-circle.pending .status-icon {
|
|
4177
4175
|
color: var(--color-dark);
|
|
4178
4176
|
}
|
|
4179
|
-
.status-circle-sm .status-icon > svg {
|
|
4180
|
-
height: 14px;
|
|
4181
|
-
height: var(--size-14);
|
|
4182
|
-
width: 14px;
|
|
4183
|
-
width: var(--size-14);
|
|
4184
|
-
}
|
|
4185
|
-
@media (max-width: 320px) {
|
|
4186
|
-
.status-circle-sm .status-icon > svg {
|
|
4187
|
-
width: 24px;
|
|
4188
|
-
width: var(--size-24);
|
|
4189
|
-
height: 24px;
|
|
4190
|
-
height: var(--size-24);
|
|
4191
|
-
}
|
|
4192
|
-
}
|
|
4193
4177
|
.status-circle.negative,
|
|
4194
4178
|
.status-circle.error {
|
|
4195
4179
|
background-color: var(--color-sentiment-negative);
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import Avatar, { AvatarType } from '../avatar';
|
|
2
2
|
import { Size } from '../common';
|
|
3
|
-
import { render } from '../test-utils';
|
|
3
|
+
import { render, mockMatchMedia } from '../test-utils';
|
|
4
4
|
|
|
5
5
|
import OverlayHeader from '.';
|
|
6
6
|
|
|
7
|
+
mockMatchMedia();
|
|
8
|
+
|
|
7
9
|
describe('OverlayHeader', () => {
|
|
8
10
|
const props = {
|
|
9
11
|
avatar: (
|
|
@@ -19,11 +19,11 @@ exports[`OverlayHeader renders as expected 1`] = `
|
|
|
19
19
|
>
|
|
20
20
|
<div
|
|
21
21
|
class="np-circle d-flex align-items-center justify-content-center tw-avatar tw-avatar--48 tw-avatar--initials np-text-title-body"
|
|
22
|
-
style="--circle-size: 48px;"
|
|
22
|
+
style="--circle-size: 48px; --circle-icon-size: 24px;"
|
|
23
23
|
>
|
|
24
24
|
<div
|
|
25
25
|
class="np-circle d-flex align-items-center justify-content-center tw-avatar__content"
|
|
26
|
-
style="--circle-size: 48px;"
|
|
26
|
+
style="--circle-size: 48px; --circle-icon-size: 16px;"
|
|
27
27
|
>
|
|
28
28
|
TM
|
|
29
29
|
</div>
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { render, fireEvent, screen } from '
|
|
1
|
+
import { render, fireEvent, screen, mockMatchMedia } from '../test-utils';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
4
|
import PromoCard, { PromoCardProps, PromoCardCheckedProps, PromoCardLinkProps } from './PromoCard';
|
|
5
5
|
|
|
6
|
+
mockMatchMedia();
|
|
7
|
+
|
|
6
8
|
describe('PromoCard', () => {
|
|
7
9
|
const defaultProps = {
|
|
8
10
|
title: 'Test Title',
|
|
@@ -35,11 +35,11 @@ exports[`Radio shows the avatar when supplied 1`] = `
|
|
|
35
35
|
>
|
|
36
36
|
<div
|
|
37
37
|
class="np-circle d-flex align-items-center justify-content-center tw-avatar tw-avatar--48 tw-avatar--initials np-text-title-body"
|
|
38
|
-
style="--circle-size: 48px;"
|
|
38
|
+
style="--circle-size: 48px; --circle-icon-size: 24px;"
|
|
39
39
|
>
|
|
40
40
|
<div
|
|
41
41
|
class="np-circle d-flex align-items-center justify-content-center tw-avatar__content"
|
|
42
|
-
style="--circle-size: 48px;"
|
|
42
|
+
style="--circle-size: 48px; --circle-icon-size: 16px;"
|
|
43
43
|
>
|
|
44
44
|
HD
|
|
45
45
|
</div>
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
.status-icon > svg {
|
|
2
|
-
height: 32px;
|
|
3
|
-
height: var(--size-32);
|
|
4
|
-
width: 32px;
|
|
5
|
-
width: var(--size-32);
|
|
6
|
-
}
|
|
7
1
|
.status-circle .light {
|
|
8
2
|
color: var(--color-contrast);
|
|
9
3
|
}
|
|
@@ -19,20 +13,6 @@
|
|
|
19
13
|
.np-theme-personal .status-circle.pending .status-icon {
|
|
20
14
|
color: var(--color-dark);
|
|
21
15
|
}
|
|
22
|
-
.status-circle-sm .status-icon > svg {
|
|
23
|
-
height: 14px;
|
|
24
|
-
height: var(--size-14);
|
|
25
|
-
width: 14px;
|
|
26
|
-
width: var(--size-14);
|
|
27
|
-
}
|
|
28
|
-
@media (max-width: 320px) {
|
|
29
|
-
.status-circle-sm .status-icon > svg {
|
|
30
|
-
width: 24px;
|
|
31
|
-
width: var(--size-24);
|
|
32
|
-
height: 24px;
|
|
33
|
-
height: var(--size-24);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
16
|
.status-circle.negative,
|
|
37
17
|
.status-circle.error {
|
|
38
18
|
background-color: var(--color-sentiment-negative);
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
.status-icon > svg {
|
|
2
|
-
height: var(--size-32);
|
|
3
|
-
width: var(--size-32);
|
|
4
|
-
}
|
|
5
|
-
|
|
6
1
|
.status-circle {
|
|
7
2
|
.light {
|
|
8
3
|
color: var(--color-contrast);
|
|
@@ -22,18 +17,6 @@
|
|
|
22
17
|
}
|
|
23
18
|
}
|
|
24
19
|
}
|
|
25
|
-
|
|
26
|
-
&-sm {
|
|
27
|
-
.status-icon > svg {
|
|
28
|
-
height: var(--size-14);
|
|
29
|
-
width: var(--size-14);
|
|
30
|
-
|
|
31
|
-
@media (--screen-400-zoom) {
|
|
32
|
-
width: var(--size-24);
|
|
33
|
-
height: var(--size-24);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
20
|
}
|
|
38
21
|
|
|
39
22
|
.status-circle.negative,
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import { Sentiment, Size
|
|
1
|
+
import { Sentiment, Size } from '../common';
|
|
2
2
|
import { render, cleanup, screen, mockMatchMedia } from '../test-utils';
|
|
3
3
|
|
|
4
|
-
import StatusIcon from '.';
|
|
4
|
+
import StatusIcon, { type StatusIconProps } from '.';
|
|
5
5
|
|
|
6
6
|
mockMatchMedia();
|
|
7
7
|
|
|
8
8
|
describe('StatusIcon', () => {
|
|
9
|
-
const renderStatusIcon = (props?: {
|
|
10
|
-
sentiment?: Sentiment;
|
|
11
|
-
size?: SizeLarge | SizeMedium | SizeSmall;
|
|
12
|
-
}) => {
|
|
9
|
+
const renderStatusIcon = (props?: StatusIconProps) => {
|
|
13
10
|
return render(
|
|
14
11
|
<StatusIcon
|
|
15
12
|
sentiment={props?.sentiment || Sentiment.NEUTRAL}
|
|
@@ -25,23 +22,8 @@ describe('StatusIcon', () => {
|
|
|
25
22
|
|
|
26
23
|
expect(screen.getByTestId('status-icon')).toHaveClass('neutral');
|
|
27
24
|
expect(screen.getByTestId('status-icon')).toHaveClass('status-circle');
|
|
28
|
-
expect(screen.getByTestId('status-icon')).toHaveClass('status-circle-md');
|
|
29
25
|
});
|
|
30
26
|
|
|
31
|
-
it.each([
|
|
32
|
-
[Size.SMALL as const, 'status-circle-sm'],
|
|
33
|
-
[Size.MEDIUM as const, 'status-circle-md'],
|
|
34
|
-
[Size.LARGE as const, 'status-circle-lg'],
|
|
35
|
-
])(
|
|
36
|
-
"if prop 'size' equals '%s' is passed, renders the status icon with class '%s'",
|
|
37
|
-
(size, expectedClass) => {
|
|
38
|
-
renderStatusIcon({ size });
|
|
39
|
-
|
|
40
|
-
expect(screen.getByTestId('status-icon')).toHaveClass(expectedClass);
|
|
41
|
-
cleanup();
|
|
42
|
-
},
|
|
43
|
-
);
|
|
44
|
-
|
|
45
27
|
it.each([
|
|
46
28
|
[Sentiment.NEGATIVE, Sentiment.NEGATIVE],
|
|
47
29
|
[Sentiment.NEUTRAL, Sentiment.NEUTRAL],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Meta, StoryObj } from '@storybook/react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { Sentiment, Size } from '../common';
|
|
4
4
|
|
|
5
5
|
import StatusIcon from './StatusIcon';
|
|
6
6
|
|
|
@@ -11,22 +11,45 @@ export default {
|
|
|
11
11
|
|
|
12
12
|
type Story = StoryObj<typeof StatusIcon>;
|
|
13
13
|
|
|
14
|
-
export const
|
|
15
|
-
render: (
|
|
16
|
-
<span style={{ display: 'flex' }}>
|
|
17
|
-
|
|
14
|
+
export const Variants: Story = {
|
|
15
|
+
render: () => (
|
|
16
|
+
<span style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '400px' }}>
|
|
17
|
+
{[
|
|
18
|
+
Sentiment.POSITIVE,
|
|
19
|
+
Sentiment.NEGATIVE,
|
|
20
|
+
Sentiment.WARNING,
|
|
21
|
+
Sentiment.NEUTRAL,
|
|
22
|
+
Sentiment.PENDING,
|
|
23
|
+
].map((sentiment) => {
|
|
24
|
+
return (
|
|
25
|
+
<span
|
|
26
|
+
key={sentiment}
|
|
27
|
+
style={{
|
|
28
|
+
display: 'flex',
|
|
29
|
+
justifyContent: 'space-between',
|
|
30
|
+
flexDirection: 'column',
|
|
31
|
+
minHeight: '150px',
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
}}
|
|
34
|
+
>
|
|
35
|
+
{([16, 24, 32, 40, 48, 56, 72] as const).map((size) => {
|
|
36
|
+
return <StatusIcon key={size} size={size} sentiment={sentiment} />;
|
|
37
|
+
})}
|
|
38
|
+
</span>
|
|
39
|
+
);
|
|
40
|
+
})}
|
|
18
41
|
</span>
|
|
19
42
|
),
|
|
20
43
|
};
|
|
21
44
|
|
|
22
|
-
export const
|
|
23
|
-
render: () => (
|
|
45
|
+
export const LegacySizes: Story = {
|
|
46
|
+
render: (args) => (
|
|
24
47
|
<span style={{ display: 'flex', justifyContent: 'space-between', maxWidth: '400px' }}>
|
|
25
48
|
{[
|
|
26
49
|
Sentiment.POSITIVE,
|
|
27
50
|
Sentiment.NEGATIVE,
|
|
28
|
-
Sentiment.NEUTRAL,
|
|
29
51
|
Sentiment.WARNING,
|
|
52
|
+
Sentiment.NEUTRAL,
|
|
30
53
|
Sentiment.PENDING,
|
|
31
54
|
].map((sentiment) => {
|
|
32
55
|
return (
|
|
@@ -5,9 +5,14 @@ import { SizeSmall, SizeMedium, SizeLarge, Sentiment, Size, Breakpoint } from '.
|
|
|
5
5
|
import Circle, { CircleProps } from '../common/circle';
|
|
6
6
|
import { useMedia } from '../common/hooks/useMedia';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated use `16 | 24 | 32 | 40 | 48 | 56 | 72` component instead
|
|
10
|
+
*/
|
|
11
|
+
type LegacySizes = SizeSmall | SizeMedium | SizeLarge;
|
|
12
|
+
|
|
8
13
|
export type StatusIconProps = {
|
|
9
|
-
sentiment
|
|
10
|
-
size
|
|
14
|
+
sentiment?: `${Sentiment}`;
|
|
15
|
+
size?: LegacySizes | 16 | 24 | 32 | 40 | 48 | 56 | 72;
|
|
11
16
|
};
|
|
12
17
|
|
|
13
18
|
const iconTypeMap = {
|
|
@@ -27,17 +32,18 @@ const mapLegacySize = {
|
|
|
27
32
|
[String(Size.LARGE)]: 48,
|
|
28
33
|
} satisfies Record<string, CircleProps['size']>;
|
|
29
34
|
|
|
30
|
-
const StatusIcon = ({ sentiment = 'neutral', size: sizeProp =
|
|
35
|
+
const StatusIcon = ({ sentiment = 'neutral', size: sizeProp = 40 }: StatusIconProps) => {
|
|
31
36
|
const Icon = iconTypeMap[sentiment];
|
|
32
37
|
const iconColor = sentiment === 'warning' || sentiment === 'pending' ? 'dark' : 'light';
|
|
33
38
|
const isTinyViewport = useMedia(`(max-width: ${Breakpoint.ZOOM_400}px)`);
|
|
34
|
-
const size
|
|
39
|
+
const size: CircleProps['size'] =
|
|
40
|
+
typeof sizeProp === 'string' ? mapLegacySize[sizeProp] : sizeProp;
|
|
35
41
|
return (
|
|
36
42
|
<Circle
|
|
37
43
|
as="span"
|
|
38
|
-
size={size}
|
|
44
|
+
size={isTinyViewport && size < 40 ? 32 : size}
|
|
39
45
|
data-testid="status-icon"
|
|
40
|
-
className={clsx('status-circle',
|
|
46
|
+
className={clsx('status-circle', sentiment)}
|
|
41
47
|
>
|
|
42
48
|
<Icon className={clsx('status-icon', iconColor)} />
|
|
43
49
|
</Circle>
|
package/build/constants.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This file holds repository-wide constants that are reusable by more than 1 component.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* A delay [ms] after which it's OK to update a live region content,
|
|
8
|
-
* taking under consideration delayed programmatic refocusing
|
|
9
|
-
* of triggering components (e.g., SelectInput) and Accessibility
|
|
10
|
-
* Tree updates that prevent the screen reader announcements.
|
|
11
|
-
*/
|
|
12
|
-
const WDS_LIVE_REGION_DELAY_MS = 175;
|
|
13
|
-
|
|
14
|
-
exports.WDS_LIVE_REGION_DELAY_MS = WDS_LIVE_REGION_DELAY_MS;
|
|
15
|
-
//# sourceMappingURL=constants.js.map
|
package/build/constants.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../src/constants.ts"],"sourcesContent":["/**\n * This file holds repository-wide constants that are reusable by more than 1 component.\n */\n\n/**\n * A delay [ms] after which it's OK to update a live region content,\n * taking under consideration delayed programmatic refocusing\n * of triggering components (e.g., SelectInput) and Accessibility\n * Tree updates that prevent the screen reader announcements.\n */\nexport const WDS_LIVE_REGION_DELAY_MS = 175;\n"],"names":["WDS_LIVE_REGION_DELAY_MS"],"mappings":";;AAAA;;AAEG;AAEH;;;;;AAKG;AACI,MAAMA,wBAAwB,GAAG;;;;"}
|
package/build/constants.mjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file holds repository-wide constants that are reusable by more than 1 component.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* A delay [ms] after which it's OK to update a live region content,
|
|
6
|
-
* taking under consideration delayed programmatic refocusing
|
|
7
|
-
* of triggering components (e.g., SelectInput) and Accessibility
|
|
8
|
-
* Tree updates that prevent the screen reader announcements.
|
|
9
|
-
*/
|
|
10
|
-
const WDS_LIVE_REGION_DELAY_MS = 175;
|
|
11
|
-
|
|
12
|
-
export { WDS_LIVE_REGION_DELAY_MS };
|
|
13
|
-
//# sourceMappingURL=constants.mjs.map
|
package/build/constants.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.mjs","sources":["../src/constants.ts"],"sourcesContent":["/**\n * This file holds repository-wide constants that are reusable by more than 1 component.\n */\n\n/**\n * A delay [ms] after which it's OK to update a live region content,\n * taking under consideration delayed programmatic refocusing\n * of triggering components (e.g., SelectInput) and Accessibility\n * Tree updates that prevent the screen reader announcements.\n */\nexport const WDS_LIVE_REGION_DELAY_MS = 175;\n"],"names":["WDS_LIVE_REGION_DELAY_MS"],"mappings":"AAAA;;AAEG;AAEH;;;;;AAKG;AACI,MAAMA,wBAAwB,GAAG;;;;"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file holds repository-wide constants that are reusable by more than 1 component.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* A delay [ms] after which it's OK to update a live region content,
|
|
6
|
-
* taking under consideration delayed programmatic refocusing
|
|
7
|
-
* of triggering components (e.g., SelectInput) and Accessibility
|
|
8
|
-
* Tree updates that prevent the screen reader announcements.
|
|
9
|
-
*/
|
|
10
|
-
export declare const WDS_LIVE_REGION_DELAY_MS = 175;
|
|
11
|
-
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,MAAM,CAAC"}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import { userEvent, within, expect, waitFor } from '@storybook/test';
|
|
3
|
-
import { Button, Field, SelectInput, Sentiment } from '..';
|
|
4
|
-
import Alert from './Alert';
|
|
5
|
-
|
|
6
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
7
|
-
|
|
8
|
-
const meta = {
|
|
9
|
-
title: 'Feedback/Alert/tests',
|
|
10
|
-
component: Alert,
|
|
11
|
-
argTypes: {},
|
|
12
|
-
args: {
|
|
13
|
-
type: Sentiment.POSITIVE,
|
|
14
|
-
active: true,
|
|
15
|
-
message: 'Payments sent to your bank details today might not arrive in time for the holidays.',
|
|
16
|
-
},
|
|
17
|
-
} satisfies Meta<typeof Alert>;
|
|
18
|
-
export default meta;
|
|
19
|
-
|
|
20
|
-
type Story = StoryObj<typeof meta>;
|
|
21
|
-
|
|
22
|
-
const wait = async (duration = 500) =>
|
|
23
|
-
new Promise<void>((resolve) => {
|
|
24
|
-
setTimeout(resolve, duration);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
export const SimpleTrigger: Story = {
|
|
28
|
-
play: async ({ args, canvasElement }) => {
|
|
29
|
-
const canvas = within(canvasElement);
|
|
30
|
-
await wait();
|
|
31
|
-
await userEvent.tab();
|
|
32
|
-
await wait();
|
|
33
|
-
await userEvent.keyboard('{Enter}');
|
|
34
|
-
|
|
35
|
-
await waitFor(async () => expect(canvas.getByText(args.message || '')).toBeInTheDocument());
|
|
36
|
-
},
|
|
37
|
-
render: function Render(args) {
|
|
38
|
-
const [isActive, setIsActive] = useState(false);
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<>
|
|
42
|
-
<Button htmlType="button" onClick={() => setIsActive(true)}>
|
|
43
|
-
Trigger Alert
|
|
44
|
-
</Button>
|
|
45
|
-
|
|
46
|
-
<Alert {...args} active={isActive} className="m-t-4" />
|
|
47
|
-
</>
|
|
48
|
-
);
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export const ComplexTrigger: Story = {
|
|
53
|
-
play: async ({ args, canvasElement }) => {
|
|
54
|
-
const canvas = within(canvasElement);
|
|
55
|
-
await wait();
|
|
56
|
-
await userEvent.tab();
|
|
57
|
-
await wait();
|
|
58
|
-
await userEvent.keyboard('{ArrowDown}');
|
|
59
|
-
await wait();
|
|
60
|
-
await userEvent.keyboard('{ArrowDown}');
|
|
61
|
-
await wait();
|
|
62
|
-
await userEvent.keyboard('{Enter}');
|
|
63
|
-
|
|
64
|
-
await waitFor(async () => expect(canvas.getByText(args.message || '')).toBeInTheDocument());
|
|
65
|
-
},
|
|
66
|
-
render: function Render(args) {
|
|
67
|
-
const [isActive, setIsActive] = useState(false);
|
|
68
|
-
const [value, setValue] = useState<string>();
|
|
69
|
-
|
|
70
|
-
return (
|
|
71
|
-
<>
|
|
72
|
-
<Field label="Select option to triger Alert">
|
|
73
|
-
<SelectInput
|
|
74
|
-
items={[
|
|
75
|
-
{ type: 'option', value: 'one' },
|
|
76
|
-
{ type: 'option', value: 'two' },
|
|
77
|
-
]}
|
|
78
|
-
onChange={setValue}
|
|
79
|
-
onClose={() => setIsActive(Boolean(value))}
|
|
80
|
-
/>
|
|
81
|
-
</Field>
|
|
82
|
-
|
|
83
|
-
<Alert {...args} active={isActive} className="m-t-2" />
|
|
84
|
-
</>
|
|
85
|
-
);
|
|
86
|
-
},
|
|
87
|
-
};
|
package/src/constants.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file holds repository-wide constants that are reusable by more than 1 component.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* A delay [ms] after which it's OK to update a live region content,
|
|
7
|
-
* taking under consideration delayed programmatic refocusing
|
|
8
|
-
* of triggering components (e.g., SelectInput) and Accessibility
|
|
9
|
-
* Tree updates that prevent the screen reader announcements.
|
|
10
|
-
*/
|
|
11
|
-
export const WDS_LIVE_REGION_DELAY_MS = 175;
|