@transferwise/components 46.18.0 → 46.20.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/build/index.esm.js +70 -107
- package/build/index.esm.js.map +1 -1
- package/build/index.js +70 -107
- package/build/index.js.map +1 -1
- package/build/types/actionButton/ActionButton.d.ts +1 -1
- package/build/types/circularButton/CircularButton.d.ts +16 -20
- package/build/types/circularButton/CircularButton.d.ts.map +1 -1
- package/build/types/circularButton/index.d.ts +2 -1
- package/build/types/circularButton/index.d.ts.map +1 -1
- package/build/types/common/panel/Panel.d.ts.map +1 -1
- package/build/types/common/textFormat/formatWithPattern/index.d.ts +1 -1
- package/build/types/common/textFormat/formatWithPattern/index.d.ts.map +1 -1
- package/build/types/common/textFormat/getCountOfSymbolsInSelection/getCountOfSymbolsInSelection.d.ts +1 -1
- package/build/types/common/textFormat/getCountOfSymbolsInSelection/getCountOfSymbolsInSelection.d.ts.map +1 -1
- package/build/types/common/textFormat/getCountOfSymbolsInSelection/index.d.ts +1 -1
- package/build/types/common/textFormat/getCountOfSymbolsInSelection/index.d.ts.map +1 -1
- package/build/types/common/textFormat/getCursorPositionAfterKeystroke/index.d.ts +1 -1
- package/build/types/common/textFormat/getCursorPositionAfterKeystroke/index.d.ts.map +1 -1
- package/build/types/common/textFormat/getDistanceToSymbol/getDistanceToSymbol.d.ts +2 -2
- package/build/types/common/textFormat/getDistanceToSymbol/getDistanceToSymbol.d.ts.map +1 -1
- package/build/types/common/textFormat/getDistanceToSymbol/index.d.ts +1 -1
- package/build/types/common/textFormat/getDistanceToSymbol/index.d.ts.map +1 -1
- package/build/types/common/textFormat/getSymbolsInPatternWithPosition/index.d.ts +1 -1
- package/build/types/common/textFormat/getSymbolsInPatternWithPosition/index.d.ts.map +1 -1
- package/build/types/common/textFormat/index.d.ts +7 -6
- package/build/types/common/textFormat/index.d.ts.map +1 -1
- package/build/types/common/textFormat/unformatWithPattern/index.d.ts +1 -1
- package/build/types/common/textFormat/unformatWithPattern/index.d.ts.map +1 -1
- package/build/types/index.d.ts +2 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/info/Info.d.ts +3 -2
- package/build/types/info/Info.d.ts.map +1 -1
- package/build/types/logo/Logo.d.ts.map +1 -1
- package/build/types/phoneNumberInput/PhoneNumberInput.d.ts +2 -1
- package/build/types/phoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
- package/build/types/popover/Popover.d.ts +16 -21
- package/build/types/popover/Popover.d.ts.map +1 -1
- package/build/types/popover/index.d.ts +2 -1
- package/build/types/popover/index.d.ts.map +1 -1
- package/build/types/summary/Summary.d.ts.map +1 -1
- package/build/types/typeahead/typeaheadInput/TypeaheadInput.d.ts +1 -1
- package/package.json +1 -1
- package/src/circularButton/{CircularButton.story.js → CircularButton.story.tsx} +2 -2
- package/src/circularButton/CircularButton.tsx +51 -0
- package/src/circularButton/index.ts +2 -0
- package/src/common/panel/Panel.tsx +1 -0
- package/src/common/textFormat/getCountOfSymbolsInSelection/{getCountOfSymbolsInSelection.js → getCountOfSymbolsInSelection.ts} +5 -1
- package/src/common/textFormat/getCursorPositionAfterKeystroke/{getCursorPositionAfterKeystroke.spec.js → getCursorPositionAfterKeystroke.spec.ts} +15 -18
- package/src/common/textFormat/getDistanceToSymbol/{getDistanceToSymbol.spec.js → getDistanceToSymbol.spec.ts} +3 -3
- package/src/common/textFormat/getDistanceToSymbol/{getDistanceToSymbol.js → getDistanceToSymbol.ts} +8 -3
- package/src/index.ts +2 -0
- package/src/info/Info.tsx +2 -2
- package/src/logo/Logo.js +1 -0
- package/src/logo/__snapshots__/Logo.spec.js.snap +6 -0
- package/src/phoneNumberInput/PhoneNumberInput.rtl.spec.tsx +22 -0
- package/src/phoneNumberInput/PhoneNumberInput.tsx +3 -1
- package/src/popover/{Popover.spec.js → Popover.spec.tsx} +5 -2
- package/src/popover/Popover.tsx +101 -0
- package/src/popover/__snapshots__/{Popover.spec.js.snap → Popover.spec.tsx.snap} +2 -3
- package/src/popover/index.ts +2 -0
- package/src/summary/Summary.tsx +7 -1
- package/src/typeahead/Typeahead.spec.js +9 -0
- package/src/typeahead/Typeahead.tsx +1 -1
- package/src/typeahead/typeaheadInput/TypeaheadInput.tsx +3 -3
- package/src/circularButton/CircularButton.js +0 -57
- package/src/circularButton/index.js +0 -1
- package/src/popover/Popover.js +0 -101
- package/src/popover/index.js +0 -1
- /package/src/circularButton/{CircularButton.spec.js → CircularButton.spec.tsx} +0 -0
- /package/src/circularButton/__snapshots__/{CircularButton.spec.js.snap → CircularButton.spec.tsx.snap} +0 -0
- /package/src/common/textFormat/formatWithPattern/{formatWithPattern.spec.js → formatWithPattern.spec.ts} +0 -0
- /package/src/common/textFormat/formatWithPattern/{index.js → index.ts} +0 -0
- /package/src/common/textFormat/getCountOfSymbolsInSelection/{getCountOfSymbolsInSelection.spec.js → getCountOfSymbolsInSelection.spec.ts} +0 -0
- /package/src/common/textFormat/getCountOfSymbolsInSelection/{index.js → index.ts} +0 -0
- /package/src/common/textFormat/getCursorPositionAfterKeystroke/{index.js → index.ts} +0 -0
- /package/src/common/textFormat/getDistanceToSymbol/{index.js → index.ts} +0 -0
- /package/src/common/textFormat/getSymbolsInPatternWithPosition/{getSymbolsInPatternWithPosition.spec.js → getSymbolsInPatternWithPosition.spec.ts} +0 -0
- /package/src/common/textFormat/getSymbolsInPatternWithPosition/{index.js → index.ts} +0 -0
- /package/src/common/textFormat/{index.js → index.ts} +0 -0
- /package/src/common/textFormat/unformatWithPattern/{index.js → index.ts} +0 -0
- /package/src/common/textFormat/unformatWithPattern/{unformatWithPattern.spec.js → unformatWithPattern.spec.ts} +0 -0
- /package/src/popover/{Popover.story.js → Popover.story.tsx} +0 -0
|
@@ -5,6 +5,7 @@ exports[`Logo on mobile renders only fast flag 1`] = `
|
|
|
5
5
|
<span
|
|
6
6
|
aria-label="Wise"
|
|
7
7
|
class="class np-logo"
|
|
8
|
+
role="img"
|
|
8
9
|
>
|
|
9
10
|
<svg
|
|
10
11
|
class="np-logo-svg np-logo-svg--size-sm"
|
|
@@ -39,6 +40,7 @@ exports[`Logo renders wise business logo 1`] = `
|
|
|
39
40
|
<span
|
|
40
41
|
aria-label="Wise business"
|
|
41
42
|
class="class np-logo"
|
|
43
|
+
role="img"
|
|
42
44
|
>
|
|
43
45
|
<svg
|
|
44
46
|
class="np-logo-svg np-logo-svg--size-sm"
|
|
@@ -73,6 +75,7 @@ exports[`Logo renders wise business logo inversed 1`] = `
|
|
|
73
75
|
<span
|
|
74
76
|
aria-label="Wise business"
|
|
75
77
|
class="class np-logo"
|
|
78
|
+
role="img"
|
|
76
79
|
>
|
|
77
80
|
<svg
|
|
78
81
|
class="np-logo-svg np-logo-svg--size-sm"
|
|
@@ -107,6 +110,7 @@ exports[`Logo renders wise logo 1`] = `
|
|
|
107
110
|
<span
|
|
108
111
|
aria-label="Wise"
|
|
109
112
|
class="class np-logo"
|
|
113
|
+
role="img"
|
|
110
114
|
>
|
|
111
115
|
<svg
|
|
112
116
|
class="np-logo-svg np-logo-svg--size-sm"
|
|
@@ -141,6 +145,7 @@ exports[`Logo renders wise logo by default 1`] = `
|
|
|
141
145
|
<span
|
|
142
146
|
aria-label="Wise"
|
|
143
147
|
class="class np-logo"
|
|
148
|
+
role="img"
|
|
144
149
|
>
|
|
145
150
|
<svg
|
|
146
151
|
class="np-logo-svg np-logo-svg--size-sm"
|
|
@@ -175,6 +180,7 @@ exports[`Logo renders wise logo inversed 1`] = `
|
|
|
175
180
|
<span
|
|
176
181
|
aria-label="Wise"
|
|
177
182
|
class="class np-logo"
|
|
183
|
+
role="img"
|
|
178
184
|
>
|
|
179
185
|
<svg
|
|
180
186
|
class="np-logo-svg np-logo-svg--size-sm"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { mockMatchMedia, mockResizeObserver, render, screen, within } from '../test-utils';
|
|
2
|
+
|
|
3
|
+
import PhoneNumberInput from './PhoneNumberInput';
|
|
4
|
+
|
|
5
|
+
mockMatchMedia();
|
|
6
|
+
mockResizeObserver();
|
|
7
|
+
|
|
8
|
+
describe('PhoneNumberInput', () => {
|
|
9
|
+
it('supports custom `aria-labelledby` attribute', () => {
|
|
10
|
+
render(
|
|
11
|
+
<>
|
|
12
|
+
{/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}
|
|
13
|
+
<label id="prioritized-label">Prioritized label</label>
|
|
14
|
+
<PhoneNumberInput aria-labelledby="prioritized-label" onChange={() => {}} />
|
|
15
|
+
</>,
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
expect(
|
|
19
|
+
within(screen.getByLabelText('Prioritized label')).getByRole('textbox'),
|
|
20
|
+
).toBeInTheDocument();
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -22,6 +22,7 @@ const ALLOWED_PHONE_CHARS = /^$|^[\d-\s]+$/;
|
|
|
22
22
|
|
|
23
23
|
export interface PhoneNumberInputProps {
|
|
24
24
|
id?: string;
|
|
25
|
+
'aria-labelledby'?: string;
|
|
25
26
|
required?: boolean;
|
|
26
27
|
disabled?: boolean;
|
|
27
28
|
initialValue?: string;
|
|
@@ -42,6 +43,7 @@ const defaultDisabledCountries = [] satisfies PhoneNumberInputProps['disabledCou
|
|
|
42
43
|
|
|
43
44
|
const PhoneNumberInput = ({
|
|
44
45
|
id,
|
|
46
|
+
'aria-labelledby': ariaLabelledBy,
|
|
45
47
|
required,
|
|
46
48
|
disabled,
|
|
47
49
|
initialValue,
|
|
@@ -130,7 +132,7 @@ const PhoneNumberInput = ({
|
|
|
130
132
|
}, [onChange, broadcastedValue, internalValue]);
|
|
131
133
|
|
|
132
134
|
return (
|
|
133
|
-
<div className="tw-telephone">
|
|
135
|
+
<div aria-labelledby={ariaLabelledBy} className="tw-telephone">
|
|
134
136
|
<div className="tw-telephone__country-select">
|
|
135
137
|
<SelectInput
|
|
136
138
|
placeholder={formatMessage(messages.selectInputPlaceholder)}
|
|
@@ -7,7 +7,7 @@ mockMatchMedia();
|
|
|
7
7
|
|
|
8
8
|
jest.mock('react-transition-group', () => ({
|
|
9
9
|
__esModule: true,
|
|
10
|
-
CSSTransition: (props) => (props.in ? props.children : null),
|
|
10
|
+
CSSTransition: (props: Record<string, unknown>) => (props.in ? props.children : null),
|
|
11
11
|
}));
|
|
12
12
|
|
|
13
13
|
describe('Popover', () => {
|
|
@@ -117,7 +117,10 @@ describe('Popover', () => {
|
|
|
117
117
|
expect(handleOnClose).not.toHaveBeenCalled();
|
|
118
118
|
userEvent.click(screen.getByText('Open'));
|
|
119
119
|
await waitForPanel();
|
|
120
|
-
|
|
120
|
+
const dimmer = getDimmer();
|
|
121
|
+
if (dimmer != null) {
|
|
122
|
+
userEvent.click(dimmer);
|
|
123
|
+
}
|
|
121
124
|
expect(handleOnClose).toHaveBeenCalledTimes(1);
|
|
122
125
|
});
|
|
123
126
|
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { useTheme } from '@wise/components-theming';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import { useRef, useState, cloneElement, useEffect, isValidElement } from 'react';
|
|
4
|
+
|
|
5
|
+
import { Position, Typography } from '../common';
|
|
6
|
+
import ResponsivePanel from '../common/responsivePanel';
|
|
7
|
+
import Title from '../title';
|
|
8
|
+
import { logActionRequired } from '../utilities';
|
|
9
|
+
|
|
10
|
+
/** @deprecated Use `"top" | "bottom"` instead. */
|
|
11
|
+
type PopoverPreferredPlacementDeprecated =
|
|
12
|
+
| `${Position.LEFT_TOP}`
|
|
13
|
+
| `${Position.RIGHT_TOP}`
|
|
14
|
+
| `${Position.BOTTOM_RIGHT}`
|
|
15
|
+
| `${Position.BOTTOM_LEFT}`;
|
|
16
|
+
|
|
17
|
+
export type PopoverPreferredPlacement =
|
|
18
|
+
| `${Position.TOP}`
|
|
19
|
+
| `${Position.RIGHT}`
|
|
20
|
+
| `${Position.BOTTOM}`
|
|
21
|
+
| `${Position.LEFT}`
|
|
22
|
+
| PopoverPreferredPlacementDeprecated;
|
|
23
|
+
|
|
24
|
+
export interface PopoverProps {
|
|
25
|
+
children?: React.ReactNode;
|
|
26
|
+
className?: string;
|
|
27
|
+
content: React.ReactNode;
|
|
28
|
+
preferredPlacement?: PopoverPreferredPlacement;
|
|
29
|
+
onClose?: () => void;
|
|
30
|
+
title?: React.ReactNode;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function resolvePlacement(preferredPlacement: PopoverPreferredPlacement) {
|
|
34
|
+
switch (preferredPlacement) {
|
|
35
|
+
case 'left-top':
|
|
36
|
+
case 'right-top':
|
|
37
|
+
return 'top';
|
|
38
|
+
case 'bottom-left':
|
|
39
|
+
case 'bottom-right':
|
|
40
|
+
return 'bottom';
|
|
41
|
+
}
|
|
42
|
+
return preferredPlacement;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default function Popover({
|
|
46
|
+
children,
|
|
47
|
+
className,
|
|
48
|
+
content,
|
|
49
|
+
preferredPlacement = Position.RIGHT,
|
|
50
|
+
title,
|
|
51
|
+
onClose,
|
|
52
|
+
}: PopoverProps) {
|
|
53
|
+
const resolvedPlacement = resolvePlacement(preferredPlacement);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (resolvedPlacement !== preferredPlacement) {
|
|
56
|
+
logActionRequired(
|
|
57
|
+
`Popover has deprecated ${preferredPlacement} value for the 'preferredPlacement' prop. Please use ${resolvedPlacement} instead.`,
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
}, [preferredPlacement, resolvedPlacement]);
|
|
61
|
+
|
|
62
|
+
const anchorReference = useRef(null);
|
|
63
|
+
const [open, setOpen] = useState(false);
|
|
64
|
+
|
|
65
|
+
const handleOnClose = () => {
|
|
66
|
+
setOpen(false);
|
|
67
|
+
onClose?.();
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<span className={classnames('np-popover', className)}>
|
|
72
|
+
<span ref={anchorReference} className="d-inline-block">
|
|
73
|
+
{isValidElement<{ onClick?: () => void }>(children)
|
|
74
|
+
? cloneElement(children, {
|
|
75
|
+
onClick: () => {
|
|
76
|
+
children.props.onClick?.();
|
|
77
|
+
setOpen((prevOpen) => !prevOpen);
|
|
78
|
+
},
|
|
79
|
+
})
|
|
80
|
+
: children}
|
|
81
|
+
</span>
|
|
82
|
+
<ResponsivePanel
|
|
83
|
+
open={open}
|
|
84
|
+
anchorRef={anchorReference}
|
|
85
|
+
position={resolvedPlacement}
|
|
86
|
+
arrow
|
|
87
|
+
className="np-popover__container"
|
|
88
|
+
onClose={handleOnClose}
|
|
89
|
+
>
|
|
90
|
+
<div className="np-popover__content np-text-default-body">
|
|
91
|
+
{title && (
|
|
92
|
+
<Title type={Typography.TITLE_BODY} className="m-b-1">
|
|
93
|
+
{title}
|
|
94
|
+
</Title>
|
|
95
|
+
)}
|
|
96
|
+
{content}
|
|
97
|
+
</div>
|
|
98
|
+
</ResponsivePanel>
|
|
99
|
+
</span>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
@@ -6,15 +6,14 @@ exports[`Popover on desktop renders when is open 1`] = `
|
|
|
6
6
|
data-popper-escaped="true"
|
|
7
7
|
data-popper-placement="right"
|
|
8
8
|
data-popper-reference-hidden="true"
|
|
9
|
+
role="dialog"
|
|
9
10
|
style="position: absolute; left: 0px; top: 0px; transform: translate(16px, 0px);"
|
|
10
11
|
>
|
|
11
12
|
<div
|
|
12
13
|
class="np-panel__content"
|
|
13
14
|
>
|
|
14
15
|
<div
|
|
15
|
-
|
|
16
|
-
class="np-popover__content"
|
|
17
|
-
role="dialog"
|
|
16
|
+
class="np-popover__content np-text-default-body"
|
|
18
17
|
>
|
|
19
18
|
<h4
|
|
20
19
|
class="np-text-title-body m-b-1"
|
package/src/summary/Summary.tsx
CHANGED
|
@@ -137,7 +137,13 @@ const Summary = ({
|
|
|
137
137
|
</div>
|
|
138
138
|
<div className="np-summary__body m-l-2">
|
|
139
139
|
<div className="np-summary__title d-flex">
|
|
140
|
-
<Body
|
|
140
|
+
<Body
|
|
141
|
+
as="span"
|
|
142
|
+
role="heading"
|
|
143
|
+
aria-level={4}
|
|
144
|
+
type={Typography.BODY_LARGE_BOLD}
|
|
145
|
+
className="text-primary m-b-1"
|
|
146
|
+
>
|
|
141
147
|
{title}
|
|
142
148
|
</Body>
|
|
143
149
|
{info && (
|
|
@@ -370,5 +370,14 @@ describe('Typeahead', () => {
|
|
|
370
370
|
input().simulate('change', { target: { value: 'test' } });
|
|
371
371
|
expect(menu().is('.open')).toBe(true);
|
|
372
372
|
});
|
|
373
|
+
|
|
374
|
+
it('sets aria-expanded to true when options are shown', () => {
|
|
375
|
+
expect(input().prop('aria-expanded')).toBe(false);
|
|
376
|
+
// we don't want aria-expanded to be true on focus or before 3 characters are entered (that's when the menu is shown)
|
|
377
|
+
input().simulate('change', { target: { value: 'aa' } });
|
|
378
|
+
expect(input().prop('aria-expanded')).toBe(false);
|
|
379
|
+
input().simulate('change', { target: { value: 'aaa' } });
|
|
380
|
+
expect(input().prop('aria-expanded')).toBe(true);
|
|
381
|
+
});
|
|
373
382
|
});
|
|
374
383
|
});
|
|
@@ -13,7 +13,7 @@ export type TypeaheadInputProps<T> = {
|
|
|
13
13
|
typeaheadId: string;
|
|
14
14
|
value: string;
|
|
15
15
|
selected: readonly TypeaheadOption<T>[];
|
|
16
|
-
|
|
16
|
+
dropdownOpen?: boolean;
|
|
17
17
|
autoComplete: string;
|
|
18
18
|
onChange: React.ChangeEventHandler<HTMLInputElement>;
|
|
19
19
|
onKeyDown: React.KeyboardEventHandler<HTMLInputElement>;
|
|
@@ -67,7 +67,7 @@ export default class TypeaheadInput<T> extends Component<
|
|
|
67
67
|
autoFocus,
|
|
68
68
|
multiple,
|
|
69
69
|
name,
|
|
70
|
-
|
|
70
|
+
dropdownOpen,
|
|
71
71
|
placeholder,
|
|
72
72
|
selected,
|
|
73
73
|
value,
|
|
@@ -89,7 +89,7 @@ export default class TypeaheadInput<T> extends Component<
|
|
|
89
89
|
autoFocus={autoFocus}
|
|
90
90
|
placeholder={hasPlaceholder ? placeholder : ''}
|
|
91
91
|
aria-autocomplete="list"
|
|
92
|
-
aria-expanded={
|
|
92
|
+
aria-expanded={dropdownOpen}
|
|
93
93
|
aria-haspopup="listbox"
|
|
94
94
|
aria-controls={`menu-${typeaheadId}`}
|
|
95
95
|
autoComplete={autoComplete}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import classNames from 'classnames';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { cloneElement } from 'react';
|
|
4
|
-
|
|
5
|
-
import Body from '../body/Body';
|
|
6
|
-
import { typeClassMap, priorityClassMap } from '../button/classMap';
|
|
7
|
-
import { ControlType, Priority } from '../common';
|
|
8
|
-
import { Typography } from '../common';
|
|
9
|
-
|
|
10
|
-
const CircularButton = ({ className, children, disabled, icon, priority, type, ...rest }) => {
|
|
11
|
-
const classes = classNames('btn np-btn', typeClassMap[type], priorityClassMap[priority]);
|
|
12
|
-
|
|
13
|
-
const iconElement = icon.props.size !== 24 ? cloneElement(icon, { size: 24 }) : icon;
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<label
|
|
17
|
-
className={classNames(
|
|
18
|
-
'np-circular-btn',
|
|
19
|
-
priority,
|
|
20
|
-
type,
|
|
21
|
-
disabled ? 'disabled' : '',
|
|
22
|
-
className,
|
|
23
|
-
)}
|
|
24
|
-
>
|
|
25
|
-
<input
|
|
26
|
-
type="button"
|
|
27
|
-
aria-label={children}
|
|
28
|
-
className={classes}
|
|
29
|
-
disabled={disabled}
|
|
30
|
-
{...rest}
|
|
31
|
-
/>
|
|
32
|
-
{iconElement}
|
|
33
|
-
<Body as="span" className="np-circular-btn__label" type={Typography.BODY_DEFAULT_BOLD}>
|
|
34
|
-
{children}
|
|
35
|
-
</Body>
|
|
36
|
-
</label>
|
|
37
|
-
);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
CircularButton.propTypes = {
|
|
41
|
-
className: PropTypes.string,
|
|
42
|
-
children: PropTypes.string.isRequired,
|
|
43
|
-
disabled: PropTypes.bool,
|
|
44
|
-
icon: PropTypes.element.isRequired,
|
|
45
|
-
onClick: PropTypes.func,
|
|
46
|
-
priority: PropTypes.oneOf(['primary', 'secondary']),
|
|
47
|
-
type: PropTypes.oneOf(['accent', 'positive', 'negative']),
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
CircularButton.defaultProps = {
|
|
51
|
-
className: undefined,
|
|
52
|
-
disabled: false,
|
|
53
|
-
priority: Priority.PRIMARY,
|
|
54
|
-
type: ControlType.ACCENT,
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export default CircularButton;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './CircularButton';
|
package/src/popover/Popover.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { useTheme } from '@wise/components-theming';
|
|
2
|
-
import classnames from 'classnames';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import { useRef, useState, cloneElement } from 'react';
|
|
5
|
-
|
|
6
|
-
import { Position, Typography } from '../common';
|
|
7
|
-
import ResponsivePanel from '../common/responsivePanel';
|
|
8
|
-
import Title from '../title';
|
|
9
|
-
import { logActionRequiredIf } from '../utilities';
|
|
10
|
-
|
|
11
|
-
const Popover = ({ children, className, content, preferredPlacement, title, onClose }) => {
|
|
12
|
-
logActionRequired({ preferredPlacement });
|
|
13
|
-
const anchorReference = useRef(null);
|
|
14
|
-
const [open, setOpen] = useState(false);
|
|
15
|
-
const { isModern } = useTheme();
|
|
16
|
-
|
|
17
|
-
const handleOnClose = () => {
|
|
18
|
-
setOpen(false);
|
|
19
|
-
onClose?.();
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<span className={classnames('np-popover', className)}>
|
|
24
|
-
<span ref={anchorReference} className="d-inline-block">
|
|
25
|
-
{cloneElement(children, {
|
|
26
|
-
onClick: () => {
|
|
27
|
-
if (children?.props?.onClick) {
|
|
28
|
-
children.props.onClick();
|
|
29
|
-
}
|
|
30
|
-
setOpen(!open);
|
|
31
|
-
},
|
|
32
|
-
})}
|
|
33
|
-
</span>
|
|
34
|
-
<ResponsivePanel
|
|
35
|
-
open={open}
|
|
36
|
-
anchorRef={anchorReference}
|
|
37
|
-
position={deprecatedPlacements[preferredPlacement] || preferredPlacement}
|
|
38
|
-
arrow
|
|
39
|
-
className="np-popover__container"
|
|
40
|
-
onClose={handleOnClose}
|
|
41
|
-
>
|
|
42
|
-
<div
|
|
43
|
-
className={isModern ? 'np-popover__content np-text-default-body' : 'np-popover__content'}
|
|
44
|
-
aria-hidden={!open}
|
|
45
|
-
role="dialog"
|
|
46
|
-
>
|
|
47
|
-
{title && (
|
|
48
|
-
<Title type={Typography.TITLE_BODY} className="m-b-1">
|
|
49
|
-
{title}
|
|
50
|
-
</Title>
|
|
51
|
-
)}
|
|
52
|
-
{content}
|
|
53
|
-
</div>
|
|
54
|
-
</ResponsivePanel>
|
|
55
|
-
</span>
|
|
56
|
-
);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const logActionRequired = ({ preferredPlacement }) => {
|
|
60
|
-
logActionRequiredIf(
|
|
61
|
-
`Popover has deprecated ${preferredPlacement} value for the 'preferredPlacement' prop. Please use ${deprecatedPlacements[preferredPlacement]} instead.`,
|
|
62
|
-
deprecatedPlacements[preferredPlacement],
|
|
63
|
-
);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
Popover.defaultProps = {
|
|
67
|
-
className: undefined,
|
|
68
|
-
preferredPlacement: Position.RIGHT,
|
|
69
|
-
title: undefined,
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
Popover.propTypes = {
|
|
73
|
-
children: PropTypes.node.isRequired,
|
|
74
|
-
className: PropTypes.string,
|
|
75
|
-
content: PropTypes.node.isRequired,
|
|
76
|
-
/**
|
|
77
|
-
* `'left-top'` / `'right-top'` are deprecated use `Position.TOP` / `'top'` instead,
|
|
78
|
-
* `'bottom-right'` / `'bottom-left'` are deprecated use `Position.BOTTOM` / `'bottom'` instead
|
|
79
|
-
*/
|
|
80
|
-
preferredPlacement: PropTypes.oneOf([
|
|
81
|
-
'top',
|
|
82
|
-
'right',
|
|
83
|
-
'bottom',
|
|
84
|
-
'left',
|
|
85
|
-
'left-top',
|
|
86
|
-
'right-top',
|
|
87
|
-
'bottom-right',
|
|
88
|
-
'bottom-left',
|
|
89
|
-
]),
|
|
90
|
-
onClose: PropTypes.func,
|
|
91
|
-
title: PropTypes.node,
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const deprecatedPlacements = {
|
|
95
|
-
[Position.BOTTOM_LEFT]: Position.BOTTOM,
|
|
96
|
-
[Position.BOTTOM_RIGHT]: Position.BOTTOM,
|
|
97
|
-
[Position.LEFT_TOP]: Position.TOP,
|
|
98
|
-
[Position.RIGHT_TOP]: Position.TOP,
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
export default Popover;
|
package/src/popover/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './Popover';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|