@transferwise/components 46.19.0 → 46.20.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.
Files changed (67) hide show
  1. package/build/index.esm.js +61 -100
  2. package/build/index.esm.js.map +1 -1
  3. package/build/index.js +60 -99
  4. package/build/index.js.map +1 -1
  5. package/build/types/common/index.d.ts +0 -1
  6. package/build/types/common/panel/Panel.d.ts.map +1 -1
  7. package/build/types/common/textFormat/formatWithPattern/index.d.ts +1 -1
  8. package/build/types/common/textFormat/formatWithPattern/index.d.ts.map +1 -1
  9. package/build/types/common/textFormat/getCountOfSymbolsInSelection/getCountOfSymbolsInSelection.d.ts +1 -1
  10. package/build/types/common/textFormat/getCountOfSymbolsInSelection/getCountOfSymbolsInSelection.d.ts.map +1 -1
  11. package/build/types/common/textFormat/getCountOfSymbolsInSelection/index.d.ts +1 -1
  12. package/build/types/common/textFormat/getCountOfSymbolsInSelection/index.d.ts.map +1 -1
  13. package/build/types/common/textFormat/getCursorPositionAfterKeystroke/index.d.ts +1 -1
  14. package/build/types/common/textFormat/getCursorPositionAfterKeystroke/index.d.ts.map +1 -1
  15. package/build/types/common/textFormat/getDistanceToSymbol/getDistanceToSymbol.d.ts +2 -2
  16. package/build/types/common/textFormat/getDistanceToSymbol/getDistanceToSymbol.d.ts.map +1 -1
  17. package/build/types/common/textFormat/getDistanceToSymbol/index.d.ts +1 -1
  18. package/build/types/common/textFormat/getDistanceToSymbol/index.d.ts.map +1 -1
  19. package/build/types/common/textFormat/getSymbolsInPatternWithPosition/index.d.ts +1 -1
  20. package/build/types/common/textFormat/getSymbolsInPatternWithPosition/index.d.ts.map +1 -1
  21. package/build/types/common/textFormat/index.d.ts +7 -6
  22. package/build/types/common/textFormat/index.d.ts.map +1 -1
  23. package/build/types/common/textFormat/unformatWithPattern/index.d.ts +1 -1
  24. package/build/types/common/textFormat/unformatWithPattern/index.d.ts.map +1 -1
  25. package/build/types/index.d.ts +1 -0
  26. package/build/types/index.d.ts.map +1 -1
  27. package/build/types/info/Info.d.ts +3 -2
  28. package/build/types/info/Info.d.ts.map +1 -1
  29. package/build/types/logo/Logo.d.ts.map +1 -1
  30. package/build/types/popover/Popover.d.ts +16 -21
  31. package/build/types/popover/Popover.d.ts.map +1 -1
  32. package/build/types/popover/index.d.ts +2 -1
  33. package/build/types/popover/index.d.ts.map +1 -1
  34. package/build/types/promoCard/PromoCard.d.ts.map +1 -1
  35. package/package.json +1 -1
  36. package/src/common/index.js +0 -1
  37. package/src/common/panel/Panel.tsx +1 -0
  38. package/src/common/textFormat/getCountOfSymbolsInSelection/{getCountOfSymbolsInSelection.js → getCountOfSymbolsInSelection.ts} +5 -1
  39. package/src/common/textFormat/getCursorPositionAfterKeystroke/{getCursorPositionAfterKeystroke.spec.js → getCursorPositionAfterKeystroke.spec.ts} +15 -18
  40. package/src/common/textFormat/getDistanceToSymbol/{getDistanceToSymbol.spec.js → getDistanceToSymbol.spec.ts} +3 -3
  41. package/src/common/textFormat/getDistanceToSymbol/{getDistanceToSymbol.js → getDistanceToSymbol.ts} +8 -3
  42. package/src/index.ts +1 -0
  43. package/src/info/Info.tsx +2 -2
  44. package/src/logo/Logo.js +1 -0
  45. package/src/logo/__snapshots__/Logo.spec.js.snap +6 -0
  46. package/src/popover/{Popover.spec.js → Popover.spec.tsx} +5 -2
  47. package/src/popover/Popover.tsx +101 -0
  48. package/src/popover/__snapshots__/{Popover.spec.js.snap → Popover.spec.tsx.snap} +2 -3
  49. package/src/popover/index.ts +2 -0
  50. package/src/promoCard/PromoCard.tsx +5 -3
  51. package/build/types/common/randomId.d.ts +0 -13
  52. package/build/types/common/randomId.d.ts.map +0 -1
  53. package/src/common/randomId.ts +0 -14
  54. package/src/popover/Popover.js +0 -101
  55. package/src/popover/index.js +0 -1
  56. /package/src/common/textFormat/formatWithPattern/{formatWithPattern.spec.js → formatWithPattern.spec.ts} +0 -0
  57. /package/src/common/textFormat/formatWithPattern/{index.js → index.ts} +0 -0
  58. /package/src/common/textFormat/getCountOfSymbolsInSelection/{getCountOfSymbolsInSelection.spec.js → getCountOfSymbolsInSelection.spec.ts} +0 -0
  59. /package/src/common/textFormat/getCountOfSymbolsInSelection/{index.js → index.ts} +0 -0
  60. /package/src/common/textFormat/getCursorPositionAfterKeystroke/{index.js → index.ts} +0 -0
  61. /package/src/common/textFormat/getDistanceToSymbol/{index.js → index.ts} +0 -0
  62. /package/src/common/textFormat/getSymbolsInPatternWithPosition/{getSymbolsInPatternWithPosition.spec.js → getSymbolsInPatternWithPosition.spec.ts} +0 -0
  63. /package/src/common/textFormat/getSymbolsInPatternWithPosition/{index.js → index.ts} +0 -0
  64. /package/src/common/textFormat/{index.js → index.ts} +0 -0
  65. /package/src/common/textFormat/unformatWithPattern/{index.js → index.ts} +0 -0
  66. /package/src/common/textFormat/unformatWithPattern/{unformatWithPattern.spec.js → unformatWithPattern.spec.ts} +0 -0
  67. /package/src/popover/{Popover.story.js → Popover.story.tsx} +0 -0
@@ -0,0 +1,2 @@
1
+ export { default } from './Popover';
2
+ export type { PopoverProps, PopoverPreferredPlacement } from './Popover';
@@ -1,9 +1,10 @@
1
+ import { useId } from '@radix-ui/react-id';
1
2
  import { Check } from '@transferwise/icons';
2
3
  import classNames from 'classnames';
3
- import React, { forwardRef, FunctionComponent, ReactElement, useEffect, useState } from 'react';
4
+ import React, { forwardRef, FunctionComponent, useEffect, useState } from 'react';
4
5
 
5
6
  import Body from '../body';
6
- import { Typography, generateRandomId } from '../common';
7
+ import { Typography } from '../common';
7
8
  import Card, { CardProps } from '../common/card';
8
9
  import Display from '../display';
9
10
  import Image from '../image/Image';
@@ -230,7 +231,8 @@ const PromoCard: FunctionComponent<PromoCardProps> = forwardRef(
230
231
  }
231
232
  };
232
233
 
233
- const componentId = `${id || generateRandomId()}`;
234
+ const fallbackId = useId();
235
+ const componentId = id || fallbackId;
234
236
 
235
237
  // Set the icon to `'arrow'` if `href` is truthy and `type` is falsy, or
236
238
  // `'download'` if `download` is truthy. If neither condition is true, set
@@ -1,13 +0,0 @@
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
@@ -1 +0,0 @@
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,14 +0,0 @@
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
- };
@@ -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;
@@ -1 +0,0 @@
1
- export { default } from './Popover';
File without changes