@transferwise/components 45.17.0 → 45.17.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/build/i18n/en.json +1 -0
- package/build/index.esm.js +52 -57
- package/build/index.esm.js.map +1 -1
- package/build/index.js +52 -57
- package/build/index.js.map +1 -1
- package/build/main.css +1 -1
- package/build/styles/common/Option/Option.css +1 -1
- package/build/styles/main.css +1 -1
- package/build/types/accordion/AccordionItem/AccordionItem.d.ts.map +1 -1
- package/build/types/button/Button.d.ts.map +1 -1
- package/build/types/button/Button.messages.d.ts +9 -0
- package/build/types/button/Button.messages.d.ts.map +1 -0
- package/build/types/common/index.d.ts +1 -0
- package/build/types/common/randomId.d.ts +13 -0
- package/build/types/common/randomId.d.ts.map +1 -0
- package/build/types/promoCard/PromoCard.d.ts.map +1 -1
- package/build/types/select/Select.d.ts.map +1 -1
- package/build/types/select/searchBox/SearchBox.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/accordion/AccordionItem/AccordionItem.spec.js +1 -0
- package/src/accordion/AccordionItem/AccordionItem.tsx +19 -11
- package/src/accordion/AccordionItem/__snapshots__/AccordionItem.spec.js.snap +18 -4
- package/src/button/Button.messages.js +9 -0
- package/src/button/Button.spec.js +1 -2
- package/src/button/Button.tsx +11 -1
- package/src/button/__snapshots__/Button.spec.js.snap +22 -15
- package/src/common/Option/Option.css +1 -1
- package/src/common/Option/Option.less +0 -5
- package/src/common/index.js +1 -0
- package/src/common/randomId.ts +14 -0
- package/src/dateInput/DateInput.story.tsx +0 -3
- package/src/i18n/en.json +1 -0
- package/src/main.css +1 -1
- package/src/moneyInput/MoneyInput.story.tsx +0 -3
- package/src/phoneNumberInput/PhoneNumberInput.story.js +0 -3
- package/src/promoCard/PromoCard.tsx +1 -16
- package/src/select/Select.js +2 -0
- package/src/select/Select.story.js +0 -6
- package/src/select/searchBox/SearchBox.spec.js +3 -7
- package/src/select/searchBox/SearchBox.tsx +2 -0
- package/src/upload/Upload.spec.js +2 -0
- package/src/select/searchBox/__snapshots__/SearchBox.spec.js.snap +0 -46
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccordionItem.d.ts","sourceRoot":"","sources":["../../../../src/accordion/AccordionItem/AccordionItem.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AccordionItem.d.ts","sourceRoot":"","sources":["../../../../src/accordion/AccordionItem/AccordionItem.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAgB,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAOpD,MAAM,WAAW,kBAAkB;IACjC,uEAAuE;IACvE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qEAAqE;IACrE,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,uCAAuC;IACvC,KAAK,EAAE,SAAS,CAAC;IACjB,yCAAyC;IACzC,OAAO,EAAE,SAAS,CAAC;IACnB,6EAA6E;IAC7E,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,8DAA8D;IAC9D,IAAI,EAAE,OAAO,CAAC;IACd,oEAAoE;IACpE,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,sBAAsB;IACtB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,QAAA,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CAoDzC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/button/Button.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,WAAW,EAAc,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/button/Button.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,W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AW,CAAC;AAE9C,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,GAAG,iBAAiB,CAAC;AAExE,QAAA,MAAM,MAAM,uGAwEX,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.messages.d.ts","sourceRoot":"","sources":["../../../src/button/Button.messages.js"],"names":[],"mappings":""}
|
|
@@ -12,6 +12,7 @@ export * from "./propsValues/profileType";
|
|
|
12
12
|
export * from "./propsValues/scroll";
|
|
13
13
|
export * from "./locale";
|
|
14
14
|
export * from "./commonProps";
|
|
15
|
+
export * from "./randomId";
|
|
15
16
|
export { Breakpoint } from "./propsValues/breakpoint";
|
|
16
17
|
export { Type } from "./propsValues/type";
|
|
17
18
|
export { DateMode } from "./propsValues/dateMode";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* generateRandomId() function
|
|
3
|
+
*
|
|
4
|
+
* This function generates a random string of characters that can be used as
|
|
5
|
+
* an ID.
|
|
6
|
+
*
|
|
7
|
+
* @returns {string} A random string of characters.
|
|
8
|
+
* @example
|
|
9
|
+
* const id = generateRandomId();
|
|
10
|
+
* // id will be a random string of characters, such as "id-4711".
|
|
11
|
+
*/
|
|
12
|
+
export declare const generateRandomId: () => string;
|
|
13
|
+
//# sourceMappingURL=randomId.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"randomId.d.ts","sourceRoot":"","sources":["../../../src/common/randomId.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,QAAO,MAEnC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromoCard.d.ts","sourceRoot":"","sources":["../../../src/promoCard/PromoCard.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA2E,MAAM,OAAO,CAAC;AAIhG,OAAa,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAMjD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6B;IAC7B,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,GAAG,CAAC,EAAE,KAAK,CAAC;IACZ,MAAM,CAAC,EAAE,KAAK,CAAC;CAChB;AAED,MAAM,MAAM,cAAc,GAAG,kBAAkB,GAAG,qBAAqB,CAAC;AAExE,MAAM,MAAM,oBAAoB,GAAG,CACjC,KAAK,EAAE,kBAAkB,GAAG,qBAAqB,KAC9C,GAAG,CAAC,OAAO,CAAC;;AAmOjB,wBAAqC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../src/select/Select.js"],"names":[],"mappings":"AA8EA;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../src/select/Select.js"],"names":[],"mappings":"AA8EA;;;;;;;;;;;;;;;;;;;;;;gCAmeC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchBox.d.ts","sourceRoot":"","sources":["../../../../src/select/searchBox/SearchBox.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAc,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAUxD,QAAA,MAAM,SAAS;;;;
|
|
1
|
+
{"version":3,"file":"SearchBox.d.ts","sourceRoot":"","sources":["../../../../src/select/searchBox/SearchBox.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAc,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAUxD,QAAA,MAAM,SAAS;;;;oJA0Cd,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useId } from '@radix-ui/react-id';
|
|
1
2
|
import { useTheme } from '@wise/components-theming';
|
|
2
3
|
import classNames from 'classnames';
|
|
3
4
|
import { cloneElement, FC, ReactNode } from 'react';
|
|
@@ -70,11 +71,13 @@ const AccordionItem: FC<AccordionItemProps> = ({
|
|
|
70
71
|
icon,
|
|
71
72
|
theme = 'light',
|
|
72
73
|
}) => {
|
|
73
|
-
const iconElement = icon ? cloneElement(icon as
|
|
74
|
+
const iconElement = icon ? cloneElement(icon as React.ReactElement<any>, { size: 24 }) : null;
|
|
75
|
+
const fallbackId = useId();
|
|
76
|
+
const accordionId = id ?? fallbackId;
|
|
74
77
|
|
|
75
78
|
return (
|
|
76
79
|
<div
|
|
77
|
-
id={
|
|
80
|
+
id={accordionId}
|
|
78
81
|
className={classNames(
|
|
79
82
|
'np-accordion-item',
|
|
80
83
|
iconElement ? 'np-accordion-item--with-icon' : null,
|
|
@@ -90,18 +93,23 @@ const AccordionItem: FC<AccordionItemProps> = ({
|
|
|
90
93
|
title={title}
|
|
91
94
|
button={<Chevron orientation={open ? Position.TOP : Position.BOTTOM} size={Size.MEDIUM} />}
|
|
92
95
|
inverseMediaCircle={false}
|
|
96
|
+
aria-expanded={open}
|
|
97
|
+
aria-controls={`${accordionId}-section`}
|
|
98
|
+
id={`${accordionId}-control`}
|
|
93
99
|
onClick={onClick}
|
|
94
100
|
/>
|
|
95
101
|
{open && (
|
|
96
|
-
<
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
'
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
<div id={`${accordionId}-section`} role="region" aria-labelledby={`${accordionId}-control`}>
|
|
103
|
+
<Body
|
|
104
|
+
as="span"
|
|
105
|
+
type={Typography.BODY_LARGE}
|
|
106
|
+
className={classNames('np-accordion-item__content', 'd-block', {
|
|
107
|
+
'has-icon': icon,
|
|
108
|
+
})}
|
|
109
|
+
>
|
|
110
|
+
{content}
|
|
111
|
+
</Body>
|
|
112
|
+
</div>
|
|
105
113
|
)}
|
|
106
114
|
</div>
|
|
107
115
|
);
|
|
@@ -4,9 +4,13 @@ exports[`AccordionItem open / close renders an item closed 1`] = `
|
|
|
4
4
|
<div>
|
|
5
5
|
<div
|
|
6
6
|
class="np-accordion-item"
|
|
7
|
+
id="test-accordion"
|
|
7
8
|
>
|
|
8
9
|
<button
|
|
10
|
+
aria-controls="test-accordion-section"
|
|
11
|
+
aria-expanded="false"
|
|
9
12
|
class="np-option decision"
|
|
13
|
+
id="test-accordion-control"
|
|
10
14
|
>
|
|
11
15
|
<div
|
|
12
16
|
class="media"
|
|
@@ -52,9 +56,13 @@ exports[`AccordionItem open / close renders an item open 1`] = `
|
|
|
52
56
|
<div>
|
|
53
57
|
<div
|
|
54
58
|
class="np-accordion-item np-accordion-item--open"
|
|
59
|
+
id="test-accordion"
|
|
55
60
|
>
|
|
56
61
|
<button
|
|
62
|
+
aria-controls="test-accordion-section"
|
|
63
|
+
aria-expanded="true"
|
|
57
64
|
class="np-option decision"
|
|
65
|
+
id="test-accordion-control"
|
|
58
66
|
>
|
|
59
67
|
<div
|
|
60
68
|
class="media"
|
|
@@ -92,11 +100,17 @@ exports[`AccordionItem open / close renders an item open 1`] = `
|
|
|
92
100
|
</div>
|
|
93
101
|
</div>
|
|
94
102
|
</button>
|
|
95
|
-
<
|
|
96
|
-
|
|
103
|
+
<div
|
|
104
|
+
aria-labelledby="test-accordion-control"
|
|
105
|
+
id="test-accordion-section"
|
|
106
|
+
role="region"
|
|
97
107
|
>
|
|
98
|
-
|
|
99
|
-
|
|
108
|
+
<span
|
|
109
|
+
class="np-text-body-large np-accordion-item__content d-block"
|
|
110
|
+
>
|
|
111
|
+
Lauri Ipsum has been the industry standard dummy text ever since the 1500s.
|
|
112
|
+
</span>
|
|
113
|
+
</div>
|
|
100
114
|
</div>
|
|
101
115
|
</div>
|
|
102
116
|
`;
|
|
@@ -166,9 +166,8 @@ describe('Button', () => {
|
|
|
166
166
|
describe('alternative states', () => {
|
|
167
167
|
it('renders as loading if loading is true', () => {
|
|
168
168
|
const { container } = render(<Button {...props} loading />);
|
|
169
|
-
expect(container).toMatchSnapshot();
|
|
170
|
-
|
|
171
169
|
expect(container.querySelector('.btn-loader')).toBeInTheDocument();
|
|
170
|
+
expect(screen.getByRole('button', { name: 'loading' })).toBeInTheDocument();
|
|
172
171
|
});
|
|
173
172
|
|
|
174
173
|
it('renders as block if block is true', () => {
|
package/src/button/Button.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
2
|
import { AnchorHTMLAttributes, ButtonHTMLAttributes, ElementType, forwardRef } from 'react';
|
|
3
|
+
import { useIntl } from 'react-intl';
|
|
3
4
|
|
|
4
5
|
import {
|
|
5
6
|
Size,
|
|
@@ -18,6 +19,7 @@ import {
|
|
|
18
19
|
LinkProps,
|
|
19
20
|
} from '../common';
|
|
20
21
|
|
|
22
|
+
import messages from './Button.messages';
|
|
21
23
|
import { typeClassMap, priorityClassMap } from './classMap';
|
|
22
24
|
import { establishNewPriority, establishNewType, logDeprecationNotices } from './legacyUtils';
|
|
23
25
|
|
|
@@ -70,6 +72,8 @@ const Button = forwardRef<ButtonReferenceType, Props>(
|
|
|
70
72
|
}: Props,
|
|
71
73
|
reference,
|
|
72
74
|
) => {
|
|
75
|
+
const intl = useIntl();
|
|
76
|
+
|
|
73
77
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
74
78
|
logDeprecationNotices({ size, type });
|
|
75
79
|
|
|
@@ -112,7 +116,13 @@ const Button = forwardRef<ButtonReferenceType, Props>(
|
|
|
112
116
|
}
|
|
113
117
|
|
|
114
118
|
return (
|
|
115
|
-
<Element
|
|
119
|
+
<Element
|
|
120
|
+
ref={reference}
|
|
121
|
+
className={classes}
|
|
122
|
+
{...props}
|
|
123
|
+
aria-live={loading ? 'polite' : 'off'}
|
|
124
|
+
aria-label={loading ? intl.formatMessage(messages.loadingAriaLabel) : undefined}
|
|
125
|
+
>
|
|
116
126
|
{children}
|
|
117
127
|
{loading && <span className={classNames('btn-loader', { 'm-l-2': !block })} />}
|
|
118
128
|
</Element>
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
exports[`Button alternative states renders as block if block is true 1`] = `
|
|
4
4
|
<div>
|
|
5
5
|
<button
|
|
6
|
+
aria-live="off"
|
|
6
7
|
class="btn btn-md np-btn np-btn-md btn-block np-btn-block btn-accent btn-priority-1"
|
|
7
8
|
type="button"
|
|
8
9
|
>
|
|
@@ -11,24 +12,10 @@ exports[`Button alternative states renders as block if block is true 1`] = `
|
|
|
11
12
|
</div>
|
|
12
13
|
`;
|
|
13
14
|
|
|
14
|
-
exports[`Button alternative states renders as loading if loading is true 1`] = `
|
|
15
|
-
<div>
|
|
16
|
-
<button
|
|
17
|
-
class="btn btn-md np-btn np-btn-md btn-loading disabled btn-accent btn-priority-1"
|
|
18
|
-
disabled=""
|
|
19
|
-
type="button"
|
|
20
|
-
>
|
|
21
|
-
Send money
|
|
22
|
-
<span
|
|
23
|
-
class="btn-loader m-l-2"
|
|
24
|
-
/>
|
|
25
|
-
</button>
|
|
26
|
-
</div>
|
|
27
|
-
`;
|
|
28
|
-
|
|
29
15
|
exports[`Button by default renders a medium button of type accent and priority primary 1`] = `
|
|
30
16
|
<div>
|
|
31
17
|
<button
|
|
18
|
+
aria-live="off"
|
|
32
19
|
class="btn btn-md np-btn np-btn-md btn-accent btn-priority-1"
|
|
33
20
|
type="button"
|
|
34
21
|
>
|
|
@@ -40,6 +27,7 @@ exports[`Button by default renders a medium button of type accent and priority p
|
|
|
40
27
|
exports[`Button by default renders an anchor tag with button styles of type accent and priority primary 1`] = `
|
|
41
28
|
<div>
|
|
42
29
|
<a
|
|
30
|
+
aria-live="off"
|
|
43
31
|
class="btn btn-md np-btn np-btn-md btn-accent btn-priority-1"
|
|
44
32
|
href="#"
|
|
45
33
|
>
|
|
@@ -51,6 +39,7 @@ exports[`Button by default renders an anchor tag with button styles of type acce
|
|
|
51
39
|
exports[`Button deprecated types renders danger as negative buttons with priority secondary and logs a warning 1`] = `
|
|
52
40
|
<div>
|
|
53
41
|
<button
|
|
42
|
+
aria-live="off"
|
|
54
43
|
class="btn btn-md np-btn np-btn-md btn-negative btn-priority-2"
|
|
55
44
|
type="button"
|
|
56
45
|
>
|
|
@@ -62,6 +51,7 @@ exports[`Button deprecated types renders danger as negative buttons with priorit
|
|
|
62
51
|
exports[`Button deprecated types renders link as accent buttons with priority tertiary and logs a warning 1`] = `
|
|
63
52
|
<div>
|
|
64
53
|
<button
|
|
54
|
+
aria-live="off"
|
|
65
55
|
class="btn btn-md np-btn np-btn-md btn-accent btn-priority-3"
|
|
66
56
|
type="button"
|
|
67
57
|
>
|
|
@@ -73,6 +63,7 @@ exports[`Button deprecated types renders link as accent buttons with priority te
|
|
|
73
63
|
exports[`Button deprecated types renders pay as positive buttons and logs a warning 1`] = `
|
|
74
64
|
<div>
|
|
75
65
|
<button
|
|
66
|
+
aria-live="off"
|
|
76
67
|
class="btn btn-md np-btn np-btn-md btn-positive btn-priority-1"
|
|
77
68
|
type="button"
|
|
78
69
|
>
|
|
@@ -84,6 +75,7 @@ exports[`Button deprecated types renders pay as positive buttons and logs a warn
|
|
|
84
75
|
exports[`Button deprecated types renders primary as accent buttons and logs a warning 1`] = `
|
|
85
76
|
<div>
|
|
86
77
|
<button
|
|
78
|
+
aria-live="off"
|
|
87
79
|
class="btn btn-md np-btn np-btn-md btn-accent btn-priority-1"
|
|
88
80
|
type="button"
|
|
89
81
|
>
|
|
@@ -95,6 +87,7 @@ exports[`Button deprecated types renders primary as accent buttons and logs a wa
|
|
|
95
87
|
exports[`Button priorities defaults tertiary buttons to secondary for positive buttons 1`] = `
|
|
96
88
|
<div>
|
|
97
89
|
<button
|
|
90
|
+
aria-live="off"
|
|
98
91
|
class="btn btn-md np-btn np-btn-md btn-positive btn-priority-2"
|
|
99
92
|
type="button"
|
|
100
93
|
>
|
|
@@ -106,6 +99,7 @@ exports[`Button priorities defaults tertiary buttons to secondary for positive b
|
|
|
106
99
|
exports[`Button priorities defaults tertiary buttons to secondary for positive buttons 2`] = `
|
|
107
100
|
<div>
|
|
108
101
|
<button
|
|
102
|
+
aria-live="off"
|
|
109
103
|
class="btn btn-md np-btn np-btn-md btn-negative btn-priority-2"
|
|
110
104
|
type="button"
|
|
111
105
|
>
|
|
@@ -117,6 +111,7 @@ exports[`Button priorities defaults tertiary buttons to secondary for positive b
|
|
|
117
111
|
exports[`Button priorities renders primary buttons 1`] = `
|
|
118
112
|
<div>
|
|
119
113
|
<button
|
|
114
|
+
aria-live="off"
|
|
120
115
|
class="btn btn-md np-btn np-btn-md btn-accent btn-priority-1"
|
|
121
116
|
type="button"
|
|
122
117
|
>
|
|
@@ -128,6 +123,7 @@ exports[`Button priorities renders primary buttons 1`] = `
|
|
|
128
123
|
exports[`Button priorities renders primary buttons 2`] = `
|
|
129
124
|
<div>
|
|
130
125
|
<button
|
|
126
|
+
aria-live="off"
|
|
131
127
|
class="btn btn-md np-btn np-btn-md btn-positive btn-priority-1"
|
|
132
128
|
type="button"
|
|
133
129
|
>
|
|
@@ -139,6 +135,7 @@ exports[`Button priorities renders primary buttons 2`] = `
|
|
|
139
135
|
exports[`Button priorities renders primary buttons 3`] = `
|
|
140
136
|
<div>
|
|
141
137
|
<button
|
|
138
|
+
aria-live="off"
|
|
142
139
|
class="btn btn-md np-btn np-btn-md btn-negative btn-priority-1"
|
|
143
140
|
type="button"
|
|
144
141
|
>
|
|
@@ -150,6 +147,7 @@ exports[`Button priorities renders primary buttons 3`] = `
|
|
|
150
147
|
exports[`Button priorities renders secondary buttons 1`] = `
|
|
151
148
|
<div>
|
|
152
149
|
<button
|
|
150
|
+
aria-live="off"
|
|
153
151
|
class="btn btn-md np-btn np-btn-md btn-accent btn-priority-2"
|
|
154
152
|
type="button"
|
|
155
153
|
>
|
|
@@ -161,6 +159,7 @@ exports[`Button priorities renders secondary buttons 1`] = `
|
|
|
161
159
|
exports[`Button priorities renders secondary buttons 2`] = `
|
|
162
160
|
<div>
|
|
163
161
|
<button
|
|
162
|
+
aria-live="off"
|
|
164
163
|
class="btn btn-md np-btn np-btn-md btn-positive btn-priority-2"
|
|
165
164
|
type="button"
|
|
166
165
|
>
|
|
@@ -172,6 +171,7 @@ exports[`Button priorities renders secondary buttons 2`] = `
|
|
|
172
171
|
exports[`Button priorities renders secondary buttons 3`] = `
|
|
173
172
|
<div>
|
|
174
173
|
<button
|
|
174
|
+
aria-live="off"
|
|
175
175
|
class="btn btn-md np-btn np-btn-md btn-negative btn-priority-2"
|
|
176
176
|
type="button"
|
|
177
177
|
>
|
|
@@ -183,6 +183,7 @@ exports[`Button priorities renders secondary buttons 3`] = `
|
|
|
183
183
|
exports[`Button priorities renders tertiary buttons 1`] = `
|
|
184
184
|
<div>
|
|
185
185
|
<button
|
|
186
|
+
aria-live="off"
|
|
186
187
|
class="btn btn-md np-btn np-btn-md btn-accent btn-priority-3"
|
|
187
188
|
type="button"
|
|
188
189
|
>
|
|
@@ -194,6 +195,7 @@ exports[`Button priorities renders tertiary buttons 1`] = `
|
|
|
194
195
|
exports[`Button sizes renders large buttons 1`] = `
|
|
195
196
|
<div>
|
|
196
197
|
<button
|
|
198
|
+
aria-live="off"
|
|
197
199
|
class="btn btn-lg np-btn np-btn-lg btn-accent btn-priority-1"
|
|
198
200
|
type="button"
|
|
199
201
|
>
|
|
@@ -205,6 +207,7 @@ exports[`Button sizes renders large buttons 1`] = `
|
|
|
205
207
|
exports[`Button sizes renders medium buttons 1`] = `
|
|
206
208
|
<div>
|
|
207
209
|
<button
|
|
210
|
+
aria-live="off"
|
|
208
211
|
class="btn btn-md np-btn np-btn-md btn-accent btn-priority-1"
|
|
209
212
|
type="button"
|
|
210
213
|
>
|
|
@@ -216,6 +219,7 @@ exports[`Button sizes renders medium buttons 1`] = `
|
|
|
216
219
|
exports[`Button sizes renders small buttons 1`] = `
|
|
217
220
|
<div>
|
|
218
221
|
<button
|
|
222
|
+
aria-live="off"
|
|
219
223
|
class="btn btn-sm np-btn np-btn-sm btn-accent btn-priority-1"
|
|
220
224
|
type="button"
|
|
221
225
|
>
|
|
@@ -227,6 +231,7 @@ exports[`Button sizes renders small buttons 1`] = `
|
|
|
227
231
|
exports[`Button types renders accent buttons 1`] = `
|
|
228
232
|
<div>
|
|
229
233
|
<button
|
|
234
|
+
aria-live="off"
|
|
230
235
|
class="btn btn-md np-btn np-btn-md btn-accent btn-priority-1"
|
|
231
236
|
type="button"
|
|
232
237
|
>
|
|
@@ -238,6 +243,7 @@ exports[`Button types renders accent buttons 1`] = `
|
|
|
238
243
|
exports[`Button types renders negative buttons 1`] = `
|
|
239
244
|
<div>
|
|
240
245
|
<button
|
|
246
|
+
aria-live="off"
|
|
241
247
|
class="btn btn-md np-btn np-btn-md btn-negative btn-priority-1"
|
|
242
248
|
type="button"
|
|
243
249
|
>
|
|
@@ -249,6 +255,7 @@ exports[`Button types renders negative buttons 1`] = `
|
|
|
249
255
|
exports[`Button types renders positive buttons 1`] = `
|
|
250
256
|
<div>
|
|
251
257
|
<button
|
|
258
|
+
aria-live="off"
|
|
252
259
|
class="btn btn-md np-btn np-btn-md btn-positive btn-priority-1"
|
|
253
260
|
type="button"
|
|
254
261
|
>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.np-option:has(:focus-visible){--ring-outline-offset:0;outline:var(--ring-outline-color) solid var(--ring-outline-width);outline-offset:var(--ring-outline-offset)}.np-option:has(:focus-visible) :focus-visible{outline:none}.np-option .circle-sm{height:40px;height:var(--size-40);width:40px;width:var(--size-40)}.np-option__title{color:#37517e;color:var(--color-content-primary);
|
|
1
|
+
.np-option:has(:focus-visible){--ring-outline-offset:0;outline:var(--ring-outline-color) solid var(--ring-outline-width);outline-offset:var(--ring-outline-offset)}.np-option:has(:focus-visible) :focus-visible{outline:none}.np-option .circle-sm{height:40px;height:var(--size-40);width:40px;width:var(--size-40)}.np-option__title{color:#37517e;color:var(--color-content-primary);font-size:1rem;font-weight:600;font-weight:var(--font-weight-semi-bold);letter-spacing:0;line-height:1.5;line-height:var(--line-height-body);margin:0}.np-option__body{color:#5d7079;color:var(--color-content-secondary);font-size:.875rem;font-size:var(--font-size-14);font-weight:400;font-weight:var(--font-weight-regular);line-height:1.42857;margin-top:4px;margin-top:var(--size-4)}.np-option__sm-media.decision .media-left{display:block}.np-option__no-media-circle{display:flex;justify-content:center;max-width:64px;max-width:var(--size-64);min-width:48px;min-width:var(--size-48)}.np-option__no-media-circle>*{max-height:76px}button.np-option{background-color:transparent;text-align:left;width:100%}[dir=rtl] button.np-option{text-align:right}.np-theme-personal .np-option .circle{overflow:visible}.np-theme-personal .np-option .circle-sm{height:48px;height:var(--size-48);line-height:48px;line-height:var(--size-48);width:48px;width:var(--size-48)}.np-theme-personal .np-option__body{margin:4px 0 0;margin:var(--size-4) 0 0;text-decoration:none}.np-theme-personal .np-option__container-aligned{margin-left:-16px;margin-left:calc(var(--space-content-horizontal)*-1);margin-right:-16px;margin-right:calc(var(--space-content-horizontal)*-1);max-width:none;width:auto}@media (min-width:576px){.np-theme-personal .np-option{border-radius:10px;border-radius:var(--radius-small)}}
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
letter-spacing: 0;
|
|
24
24
|
line-height: var(--line-height-body);
|
|
25
25
|
margin: 0;
|
|
26
|
-
display: inline-block;
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
&__body {
|
|
@@ -72,10 +71,6 @@ button.np-option {
|
|
|
72
71
|
line-height: var(--size-48);
|
|
73
72
|
}
|
|
74
73
|
|
|
75
|
-
&__title {
|
|
76
|
-
display: inline-block;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
74
|
&__body {
|
|
80
75
|
margin: var(--size-4) 0 0;
|
|
81
76
|
text-decoration: none;
|
package/src/common/index.js
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* generateRandomId() function
|
|
3
|
+
*
|
|
4
|
+
* This function generates a random string of characters that can be used as
|
|
5
|
+
* an ID.
|
|
6
|
+
*
|
|
7
|
+
* @returns {string} A random string of characters.
|
|
8
|
+
* @example
|
|
9
|
+
* const id = generateRandomId();
|
|
10
|
+
* // id will be a random string of characters, such as "id-4711".
|
|
11
|
+
*/
|
|
12
|
+
export const generateRandomId = (): string => {
|
|
13
|
+
return `id-${Math.random().toString(36).slice(7)}`;
|
|
14
|
+
};
|