@transferwise/components 0.0.0-experimental-a6eccb9 → 0.0.0-experimental-eecc435
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 +73 -60
- package/build/index.esm.js.map +1 -1
- package/build/index.js +72 -59
- package/build/index.js.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 +0 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/info/Info.d.ts +2 -3
- package/build/types/info/Info.d.ts.map +1 -1
- package/build/types/logo/Logo.d.ts.map +1 -1
- package/build/types/popover/Popover.d.ts +21 -16
- package/build/types/popover/Popover.d.ts.map +1 -1
- package/build/types/popover/index.d.ts +1 -2
- package/build/types/popover/index.d.ts.map +1 -1
- package/package.json +1 -1
- 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 +0 -1
- 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/popover/Popover.js +101 -0
- package/src/popover/{Popover.spec.tsx → Popover.spec.js} +2 -5
- package/src/popover/index.js +1 -0
- package/src/popover/Popover.tsx +0 -106
- package/src/popover/index.ts +0 -2
- /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.tsx → Popover.story.js} +0 -0
- /package/src/popover/__snapshots__/{Popover.spec.tsx.snap → Popover.spec.js.snap} +0 -0
package/src/popover/Popover.tsx
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
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
|
-
const { isModern } = useTheme();
|
|
65
|
-
|
|
66
|
-
const handleOnClose = () => {
|
|
67
|
-
setOpen(false);
|
|
68
|
-
onClose?.();
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
return (
|
|
72
|
-
<span className={classnames('np-popover', className)}>
|
|
73
|
-
<span ref={anchorReference} className="d-inline-block">
|
|
74
|
-
{isValidElement<{ onClick?: () => void }>(children)
|
|
75
|
-
? cloneElement(children, {
|
|
76
|
-
onClick: () => {
|
|
77
|
-
children.props.onClick?.();
|
|
78
|
-
setOpen((prevOpen) => !prevOpen);
|
|
79
|
-
},
|
|
80
|
-
})
|
|
81
|
-
: children}
|
|
82
|
-
</span>
|
|
83
|
-
<ResponsivePanel
|
|
84
|
-
open={open}
|
|
85
|
-
anchorRef={anchorReference}
|
|
86
|
-
position={resolvedPlacement}
|
|
87
|
-
arrow
|
|
88
|
-
className="np-popover__container"
|
|
89
|
-
onClose={handleOnClose}
|
|
90
|
-
>
|
|
91
|
-
<div
|
|
92
|
-
className={isModern ? 'np-popover__content np-text-default-body' : 'np-popover__content'}
|
|
93
|
-
aria-hidden={!open}
|
|
94
|
-
role="dialog"
|
|
95
|
-
>
|
|
96
|
-
{title && (
|
|
97
|
-
<Title type={Typography.TITLE_BODY} className="m-b-1">
|
|
98
|
-
{title}
|
|
99
|
-
</Title>
|
|
100
|
-
)}
|
|
101
|
-
{content}
|
|
102
|
-
</div>
|
|
103
|
-
</ResponsivePanel>
|
|
104
|
-
</span>
|
|
105
|
-
);
|
|
106
|
-
}
|
package/src/popover/index.ts
DELETED
|
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
|