@transferwise/components 0.0.0-experimental-83f1188 → 0.0.0-experimental-128143a

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 (116) hide show
  1. package/build/i18n/en.json +0 -2
  2. package/build/i18n/en.json.js +0 -2
  3. package/build/i18n/en.json.js.map +1 -1
  4. package/build/i18n/en.json.mjs +0 -2
  5. package/build/i18n/en.json.mjs.map +1 -1
  6. package/build/index.js +0 -2
  7. package/build/index.js.map +1 -1
  8. package/build/index.mjs +0 -1
  9. package/build/index.mjs.map +1 -1
  10. package/build/main.css +7 -65
  11. package/build/prompt/InlinePrompt/InlinePrompt.js +0 -7
  12. package/build/prompt/InlinePrompt/InlinePrompt.js.map +1 -1
  13. package/build/prompt/InlinePrompt/InlinePrompt.mjs +1 -8
  14. package/build/prompt/InlinePrompt/InlinePrompt.mjs.map +1 -1
  15. package/build/styles/main.css +7 -65
  16. package/build/styles/prompt/InlinePrompt/InlinePrompt.css +7 -7
  17. package/build/types/index.d.ts +0 -2
  18. package/build/types/index.d.ts.map +1 -1
  19. package/build/types/prompt/InlinePrompt/InlinePrompt.d.ts +2 -3
  20. package/build/types/prompt/InlinePrompt/InlinePrompt.d.ts.map +1 -1
  21. package/build/types/test-utils/index.d.ts +0 -4
  22. package/build/types/test-utils/index.d.ts.map +1 -1
  23. package/package.json +5 -5
  24. package/src/i18n/en.json +0 -2
  25. package/src/index.ts +0 -2
  26. package/src/main.css +7 -65
  27. package/src/main.less +0 -1
  28. package/src/prompt/InlinePrompt/InlinePrompt.css +7 -7
  29. package/src/prompt/InlinePrompt/InlinePrompt.less +7 -7
  30. package/src/prompt/InlinePrompt/InlinePrompt.spec.tsx +0 -6
  31. package/src/prompt/InlinePrompt/InlinePrompt.tsx +2 -12
  32. package/src/ssr.spec.tsx +0 -1
  33. package/build/expressiveMoneyInput/ExpressiveMoneyInput.js +0 -113
  34. package/build/expressiveMoneyInput/ExpressiveMoneyInput.js.map +0 -1
  35. package/build/expressiveMoneyInput/ExpressiveMoneyInput.messages.js +0 -17
  36. package/build/expressiveMoneyInput/ExpressiveMoneyInput.messages.js.map +0 -1
  37. package/build/expressiveMoneyInput/ExpressiveMoneyInput.messages.mjs +0 -13
  38. package/build/expressiveMoneyInput/ExpressiveMoneyInput.messages.mjs.map +0 -1
  39. package/build/expressiveMoneyInput/ExpressiveMoneyInput.mjs +0 -109
  40. package/build/expressiveMoneyInput/ExpressiveMoneyInput.mjs.map +0 -1
  41. package/build/expressiveMoneyInput/amountInput/AmountInput.js +0 -281
  42. package/build/expressiveMoneyInput/amountInput/AmountInput.js.map +0 -1
  43. package/build/expressiveMoneyInput/amountInput/AmountInput.mjs +0 -279
  44. package/build/expressiveMoneyInput/amountInput/AmountInput.mjs.map +0 -1
  45. package/build/expressiveMoneyInput/amountInput/utils.js +0 -87
  46. package/build/expressiveMoneyInput/amountInput/utils.js.map +0 -1
  47. package/build/expressiveMoneyInput/amountInput/utils.mjs +0 -78
  48. package/build/expressiveMoneyInput/amountInput/utils.mjs.map +0 -1
  49. package/build/expressiveMoneyInput/animatedNumber/AnimatedNumber.js +0 -50
  50. package/build/expressiveMoneyInput/animatedNumber/AnimatedNumber.js.map +0 -1
  51. package/build/expressiveMoneyInput/animatedNumber/AnimatedNumber.mjs +0 -48
  52. package/build/expressiveMoneyInput/animatedNumber/AnimatedNumber.mjs.map +0 -1
  53. package/build/expressiveMoneyInput/chevron/Chevron.js +0 -31
  54. package/build/expressiveMoneyInput/chevron/Chevron.js.map +0 -1
  55. package/build/expressiveMoneyInput/chevron/Chevron.mjs +0 -29
  56. package/build/expressiveMoneyInput/chevron/Chevron.mjs.map +0 -1
  57. package/build/expressiveMoneyInput/currencySelector/CurrencySelector.js +0 -160
  58. package/build/expressiveMoneyInput/currencySelector/CurrencySelector.js.map +0 -1
  59. package/build/expressiveMoneyInput/currencySelector/CurrencySelector.mjs +0 -157
  60. package/build/expressiveMoneyInput/currencySelector/CurrencySelector.mjs.map +0 -1
  61. package/build/expressiveMoneyInput/hooks/useFocus.js +0 -37
  62. package/build/expressiveMoneyInput/hooks/useFocus.js.map +0 -1
  63. package/build/expressiveMoneyInput/hooks/useFocus.mjs +0 -35
  64. package/build/expressiveMoneyInput/hooks/useFocus.mjs.map +0 -1
  65. package/build/expressiveMoneyInput/hooks/useInputStyle.js +0 -71
  66. package/build/expressiveMoneyInput/hooks/useInputStyle.js.map +0 -1
  67. package/build/expressiveMoneyInput/hooks/useInputStyle.mjs +0 -69
  68. package/build/expressiveMoneyInput/hooks/useInputStyle.mjs.map +0 -1
  69. package/build/styles/expressiveMoneyInput/ExpressiveMoneyInput.css +0 -58
  70. package/build/styles/expressiveMoneyInput/amountInput/AmountInput.css +0 -32
  71. package/build/styles/expressiveMoneyInput/chevron/Chevron.css +0 -12
  72. package/build/styles/expressiveMoneyInput/currencySelector/CurrencySelector.css +0 -6
  73. package/build/types/expressiveMoneyInput/ExpressiveMoneyInput.d.ts +0 -33
  74. package/build/types/expressiveMoneyInput/ExpressiveMoneyInput.d.ts.map +0 -1
  75. package/build/types/expressiveMoneyInput/ExpressiveMoneyInput.messages.d.ts +0 -12
  76. package/build/types/expressiveMoneyInput/ExpressiveMoneyInput.messages.d.ts.map +0 -1
  77. package/build/types/expressiveMoneyInput/amountInput/AmountInput.d.ts +0 -13
  78. package/build/types/expressiveMoneyInput/amountInput/AmountInput.d.ts.map +0 -1
  79. package/build/types/expressiveMoneyInput/amountInput/utils.d.ts +0 -22
  80. package/build/types/expressiveMoneyInput/amountInput/utils.d.ts.map +0 -1
  81. package/build/types/expressiveMoneyInput/animatedNumber/AnimatedNumber.d.ts +0 -9
  82. package/build/types/expressiveMoneyInput/animatedNumber/AnimatedNumber.d.ts.map +0 -1
  83. package/build/types/expressiveMoneyInput/chevron/Chevron.d.ts +0 -6
  84. package/build/types/expressiveMoneyInput/chevron/Chevron.d.ts.map +0 -1
  85. package/build/types/expressiveMoneyInput/currencySelector/CurrencySelector.d.ts +0 -30
  86. package/build/types/expressiveMoneyInput/currencySelector/CurrencySelector.d.ts.map +0 -1
  87. package/build/types/expressiveMoneyInput/hooks/useFocus.d.ts +0 -7
  88. package/build/types/expressiveMoneyInput/hooks/useFocus.d.ts.map +0 -1
  89. package/build/types/expressiveMoneyInput/hooks/useInputStyle.d.ts +0 -10
  90. package/build/types/expressiveMoneyInput/hooks/useInputStyle.d.ts.map +0 -1
  91. package/build/types/expressiveMoneyInput/hooks/useSelectionRange.d.ts +0 -10
  92. package/build/types/expressiveMoneyInput/hooks/useSelectionRange.d.ts.map +0 -1
  93. package/build/types/expressiveMoneyInput/index.d.ts +0 -3
  94. package/build/types/expressiveMoneyInput/index.d.ts.map +0 -1
  95. package/src/expressiveMoneyInput/ExpressiveMoneyInput.css +0 -58
  96. package/src/expressiveMoneyInput/ExpressiveMoneyInput.less +0 -13
  97. package/src/expressiveMoneyInput/ExpressiveMoneyInput.messages.ts +0 -13
  98. package/src/expressiveMoneyInput/ExpressiveMoneyInput.story.tsx +0 -287
  99. package/src/expressiveMoneyInput/ExpressiveMoneyInput.tsx +0 -130
  100. package/src/expressiveMoneyInput/amountInput/AmountInput.css +0 -32
  101. package/src/expressiveMoneyInput/amountInput/AmountInput.less +0 -43
  102. package/src/expressiveMoneyInput/amountInput/AmountInput.tsx +0 -353
  103. package/src/expressiveMoneyInput/amountInput/utils.spec.ts +0 -114
  104. package/src/expressiveMoneyInput/amountInput/utils.ts +0 -116
  105. package/src/expressiveMoneyInput/animatedNumber/AnimatedNumber.tsx +0 -40
  106. package/src/expressiveMoneyInput/chevron/Chevron.css +0 -12
  107. package/src/expressiveMoneyInput/chevron/Chevron.less +0 -13
  108. package/src/expressiveMoneyInput/chevron/Chevron.tsx +0 -35
  109. package/src/expressiveMoneyInput/currencySelector/CurrencySelector.css +0 -6
  110. package/src/expressiveMoneyInput/currencySelector/CurrencySelector.less +0 -7
  111. package/src/expressiveMoneyInput/currencySelector/CurrencySelector.tsx +0 -218
  112. package/src/expressiveMoneyInput/hooks/useFocus.ts +0 -35
  113. package/src/expressiveMoneyInput/hooks/useInputStyle.ts +0 -85
  114. package/src/expressiveMoneyInput/hooks/useSelectionRange.ts +0 -23
  115. package/src/expressiveMoneyInput/index.ts +0 -2
  116. package/src/prompt/InlinePrompt/InlinePrompt.story.tsx +0 -39
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/expressiveMoneyInput/amountInput/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,eAAO,MAAM,mBAAmB,GAAI,UAAU,MAAM,EAAE,QAAQ,MAAM,KAAG,MAAM,GAAG,IAE/E,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,UAAU,MAAM,EAAE,QAAQ,MAAM,KAAG,MAAM,GAAG,IAE7E,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,EAAE,QAAQ,MAAM,KAAG,MAOlE,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,OAAO,MAAM,EAAE,kBAAkB,MAAM,WAE9E,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,8CAIlC;IACD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,KAAG,MAAM,GAAG,IAmBZ,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,oEAKhC;IACD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,KAAG,MAiBH,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,iBAGxC;IACD,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IACvC,KAAK,EAAE,MAAM,CAAC;CACf,wBASA,CAAC;AAaF,eAAO,MAAM,iBAAiB,GAAI,GAAG,aAAa,CAAC,gBAAgB,CAAC,YAKnE,CAAC"}
@@ -1,9 +0,0 @@
1
- import type { ReactNode } from 'react';
2
- interface Props {
3
- children: ReactNode;
4
- onClick?: () => void;
5
- className?: string;
6
- }
7
- export declare const AnimatedNumber: ({ children, onClick, className }: Props) => import("react").JSX.Element;
8
- export {};
9
- //# sourceMappingURL=AnimatedNumber.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AnimatedNumber.d.ts","sourceRoot":"","sources":["../../../../src/expressiveMoneyInput/animatedNumber/AnimatedNumber.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,UAAU,KAAK;IACb,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,cAAc,GAAI,kCAAkC,KAAK,gCA8BrE,CAAC"}
@@ -1,6 +0,0 @@
1
- interface Props {
2
- shouldShow: boolean;
3
- }
4
- export declare const Chevron: ({ shouldShow }: Props) => import("react").JSX.Element;
5
- export {};
6
- //# sourceMappingURL=Chevron.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Chevron.d.ts","sourceRoot":"","sources":["../../../../src/expressiveMoneyInput/chevron/Chevron.tsx"],"names":[],"mappings":"AAIA,UAAU,KAAK;IACb,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,OAAO,GAAI,gBAAuB,KAAK,gCA0BnD,CAAC"}
@@ -1,30 +0,0 @@
1
- import type { AvatarLayoutProps } from '../../avatarLayout';
2
- import { CurrencyType, Props as ExpressiveMoneyInputProps } from '../ExpressiveMoneyInput';
3
- import { type ButtonHTMLAttributes } from 'react';
4
- export interface CurrencyOption {
5
- label?: string;
6
- code: string;
7
- keywords: string[] | undefined;
8
- }
9
- export interface CurrencySection {
10
- title: string;
11
- currencies: CurrencyOption[];
12
- }
13
- export type CurrencyOptions = CurrencySection[];
14
- export type Props = {
15
- id: string;
16
- labelId: string;
17
- options?: CurrencyOptions;
18
- onChange?: (currency: CurrencyType) => void;
19
- onOpen?: () => void;
20
- addons?: AvatarLayoutProps['avatars'];
21
- onSearchChange?: (payload: {
22
- query: string;
23
- resultCount: number;
24
- }) => void;
25
- } & Pick<ExpressiveMoneyInputProps, 'currency'>;
26
- export declare const CurrencySelector: ({ id, currency, options, labelId, onChange, addons, onOpen, onSearchChange, }: Props) => import("react").JSX.Element;
27
- export declare const ButtonInput: import("react").ForwardRefExoticComponent<ButtonHTMLAttributes<HTMLButtonElement> & {
28
- children?: import("react").ReactNode | undefined;
29
- } & import("react").RefAttributes<HTMLButtonElement | null>>;
30
- //# sourceMappingURL=CurrencySelector.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CurrencySelector.d.ts","sourceRoot":"","sources":["../../../../src/expressiveMoneyInput/currencySelector/CurrencySelector.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAO5D,OAAO,EAAE,YAAY,EAAE,KAAK,IAAI,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAG3F,OAAO,EACL,KAAK,oBAAoB,EAK1B,MAAM,OAAO,CAAC;AAKf,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CAChC;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,cAAc,EAAE,CAAC;CAC9B;AAED,MAAM,MAAM,eAAe,GAAG,eAAe,EAAE,CAAC;AAEhD,MAAM,MAAM,KAAK,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,YAAY,KAAK,IAAI,CAAC;IAC5C,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAC;IACtC,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CAC5E,GAAG,IAAI,CAAC,yBAAyB,EAAE,UAAU,CAAC,CAAC;AAEhD,eAAO,MAAM,gBAAgB,GAAI,+EAS9B,KAAK,gCA2FP,CAAC;AAEF,eAAO,MAAM,WAAW;;4DAgBtB,CAAC"}
@@ -1,7 +0,0 @@
1
- export declare const useFocus: () => {
2
- focus: boolean;
3
- setFocus: (value: boolean) => void;
4
- visualFocus: boolean;
5
- setVisualFocus: (value: boolean) => void;
6
- };
7
- //# sourceMappingURL=useFocus.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useFocus.d.ts","sourceRoot":"","sources":["../../../../src/expressiveMoneyInput/hooks/useFocus.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,QAAQ;;sBAgBC,OAAO;;4BAUD,OAAO;CAIlC,CAAC"}
@@ -1,10 +0,0 @@
1
- import { type CSSProperties } from 'react';
2
- import { Props as ExpressiveMoneyInputProps } from '../ExpressiveMoneyInput';
3
- type InputStyleObject = {
4
- value: string;
5
- focus: boolean;
6
- inputElement: HTMLInputElement | null;
7
- } & Pick<ExpressiveMoneyInputProps, 'loading'>;
8
- export declare const useInputStyle: ({ value, focus, inputElement, loading }: InputStyleObject) => CSSProperties;
9
- export {};
10
- //# sourceMappingURL=useInputStyle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useInputStyle.d.ts","sourceRoot":"","sources":["../../../../src/expressiveMoneyInput/hooks/useInputStyle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAwC,MAAM,OAAO,CAAC;AACjF,OAAO,EAAE,KAAK,IAAI,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAE7E,KAAK,gBAAgB,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,YAAY,EAAE,gBAAgB,GAAG,IAAI,CAAC;CACvC,GAAG,IAAI,CAAC,yBAAyB,EAAE,SAAS,CAAC,CAAC;AAE/C,eAAO,MAAM,aAAa,GAAI,yCAAyC,gBAAgB,kBAyBtF,CAAC"}
@@ -1,10 +0,0 @@
1
- import { type SyntheticEvent } from 'react';
2
- export declare const useSelectionRange: () => {
3
- selection: {
4
- selectionStart: number | null;
5
- selectionEnd: number | null;
6
- } | undefined;
7
- handleSelect: (e: SyntheticEvent<HTMLInputElement>) => void;
8
- handleSelectionBlur: () => void;
9
- };
10
- //# sourceMappingURL=useSelectionRange.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSelectionRange.d.ts","sourceRoot":"","sources":["../../../../src/expressiveMoneyInput/hooks/useSelectionRange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAU,MAAM,OAAO,CAAC;AAEpD,eAAO,MAAM,iBAAiB;;wBAEV,MAAM,GAAG,IAAI;sBACf,MAAM,GAAG,IAAI;;sBAGJ,cAAc,CAAC,gBAAgB,CAAC;;CAc1D,CAAC"}
@@ -1,3 +0,0 @@
1
- export type { Props as ExpressiveMoneyInputProps } from './ExpressiveMoneyInput';
2
- export { default } from './ExpressiveMoneyInput';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/expressiveMoneyInput/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,KAAK,IAAI,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACjF,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC"}
@@ -1,58 +0,0 @@
1
- .wds-amount-input-container {
2
- width: 100%;
3
- }
4
- .wds-amount-input-input-container {
5
- display: flex;
6
- justify-content: right;
7
- width: 100%;
8
- transition: font-size 0.4s cubic-bezier(0.3, 0, 0.1, 1), height 0.4s cubic-bezier(0.3, 0, 0.1, 1), margin-top 0.4s cubic-bezier(0.3, 0, 0.1, 1), color 0.4s ease;
9
- color: var(--color-interactive-primary);
10
- overflow: hidden;
11
- margin-bottom: 0 !important;
12
- }
13
- @media (prefers-reduced-motion: reduce) {
14
- .wds-amount-input-input-container {
15
- transition: none;
16
- }
17
- }
18
- .wds-amount-input-input {
19
- border: none;
20
- outline: none;
21
- flex-grow: 1;
22
- text-align: right;
23
- background-color: transparent;
24
- }
25
- .wds-amount-input-input:focus-visible {
26
- outline: none;
27
- }
28
- .wds-amount-input-placeholder {
29
- flex-grow: 0;
30
- display: flex;
31
- align-items: center;
32
- }
33
- .wds-currency-selector:disabled {
34
- opacity: 1 !important;
35
- cursor: auto !important;
36
- cursor: initial !important;
37
- mix-blend-mode: initial !important;
38
- }
39
- .wds-chevron-container {
40
- width: 32px;
41
- width: var(--size-32);
42
- overflow: hidden;
43
- color: var(--color-interactive-primary);
44
- margin-left: 8px;
45
- margin-left: var(--size-8);
46
- transition: width 0.3s ease;
47
- }
48
- .wds-chevron-hidden {
49
- width: 0;
50
- }
51
- .wds-expressive-money-input-currency-selector {
52
- flex-shrink: 0;
53
- margin-right: 24px;
54
- margin-right: var(--size-24);
55
- }
56
- .wds-expressive-money-input-chevron {
57
- transform: translateY(-5%);
58
- }
@@ -1,13 +0,0 @@
1
- @import "./amountInput/AmountInput.less";
2
- @import "./currencySelector/CurrencySelector.less";
3
- @import "./chevron/Chevron.less";
4
-
5
- .wds-expressive-money-input {
6
- &-currency-selector {
7
- flex-shrink: 0;
8
- margin-right: var(--size-24);
9
- }
10
- &-chevron {
11
- transform: translateY(-5%);
12
- }
13
- }
@@ -1,13 +0,0 @@
1
- import { defineMessages } from 'react-intl';
2
-
3
- export default defineMessages({
4
- currencySelectorSearchPlaceholder: {
5
- id: 'neptune.ExpressiveMoneyInput.currency.search.placeholder',
6
- defaultMessage: 'Type a currency / country',
7
- },
8
-
9
- currencySelectorSelectCurrency: {
10
- id: 'neptune.ExpressiveMoneyInput.currency.select.currency',
11
- defaultMessage: 'Select currency',
12
- },
13
- });
@@ -1,287 +0,0 @@
1
- /* eslint-disable jsx-a11y/anchor-is-valid, no-console, jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */
2
- import { Meta } from '@storybook/react-webpack5';
3
- import ExpressiveMoneyInput, { Props as ExpressiveMoneyInputProps } from './ExpressiveMoneyInput';
4
- import { lorem10, lorem5 } from '../test-utils';
5
- import { Sentiment } from '../common';
6
- import Image from '../image';
7
- import Link from '../link';
8
- import Money from '../money';
9
- import React from 'react';
10
- import Button from '../button';
11
- import Modal from '../modal';
12
- import ListItem from '../listItem';
13
- import List from '../list';
14
- import { Flag } from '@wise/art';
15
- import { Rewards, Tags } from '@transferwise/icons';
16
-
17
- export default {
18
- title: 'Forms/ExpressiveMoneyInput',
19
- component: ExpressiveMoneyInput,
20
- tags: ['contribution'],
21
- } as Meta;
22
-
23
- const props: ExpressiveMoneyInputProps = {
24
- label: 'You send',
25
- currency: 'GBP',
26
- amount: 1234.56,
27
- onAmountChange: (amount) => {
28
- console.log('Amount changed', amount);
29
- },
30
- currencySelector: {
31
- addons: [
32
- { asset: <Image src="../avatar-square-dude.webp" alt="" /> },
33
- { profileName: 'Test Test' },
34
- ],
35
- options: [
36
- {
37
- title: 'Popular',
38
- currencies: [
39
- { code: 'USD', label: 'US Dollar', keywords: ['dollar', 'us'] },
40
- { code: 'AUD', label: 'Australia Dollar', keywords: ['dollar', 'us'] },
41
- ],
42
- },
43
- {
44
- title: 'Others',
45
- currencies: [
46
- { code: 'GBP', label: 'Pound', keywords: ['british'] },
47
- { code: 'EUR', label: 'Euro', keywords: ['euro'] },
48
- ],
49
- },
50
- ],
51
- onOpen: () => {
52
- console.log('Currency selector opened');
53
- },
54
- onSearchChange: (payload) => {
55
- console.log('Search changed', payload);
56
- },
57
- onChange: (currency) => {
58
- console.log('Currency changed', currency);
59
- },
60
- },
61
- loading: false,
62
- inlinePrompt: { message: lorem10, sentiment: Sentiment.POSITIVE },
63
- showChevron: true,
64
- autoFocus: true,
65
- };
66
-
67
- export const NullAmount = {
68
- args: props,
69
- render: (args: ExpressiveMoneyInputProps) => (
70
- <ExpressiveMoneyInput
71
- label={args.label}
72
- amount={null}
73
- currency="EUR"
74
- onAmountChange={args.onAmountChange}
75
- />
76
- ),
77
- };
78
-
79
- export const WithInitAmount = {
80
- args: props,
81
- render: (args: ExpressiveMoneyInputProps) => {
82
- const availableBalance = 1500;
83
- return (
84
- <ExpressiveMoneyInput
85
- label={args.label}
86
- amount={availableBalance}
87
- currency="EUR"
88
- onAmountChange={args.onAmountChange}
89
- />
90
- );
91
- },
92
- };
93
-
94
- export const WithLoading = {
95
- args: props,
96
- render: (args: ExpressiveMoneyInputProps) => {
97
- const availableBalance = 1500;
98
- return (
99
- <ExpressiveMoneyInput
100
- label={args.label}
101
- amount={availableBalance}
102
- currency="EUR"
103
- loading
104
- onAmountChange={args.onAmountChange}
105
- />
106
- );
107
- },
108
- };
109
-
110
- export const WithoutChevron = {
111
- args: props,
112
- render: (args: ExpressiveMoneyInputProps) => {
113
- const availableBalance = 1500;
114
- return (
115
- <ExpressiveMoneyInput
116
- label={args.label}
117
- amount={availableBalance}
118
- currency="EUR"
119
- showChevron={false}
120
- onAmountChange={args.onAmountChange}
121
- />
122
- );
123
- },
124
- };
125
-
126
- export const WithCurrencySelector = {
127
- args: props,
128
- render: (args: ExpressiveMoneyInputProps) => {
129
- const availableBalance = 1500;
130
- return (
131
- <ExpressiveMoneyInput
132
- label={args.label}
133
- amount={availableBalance}
134
- currency="EUR"
135
- currencySelector={args.currencySelector}
136
- onAmountChange={args.onAmountChange}
137
- />
138
- );
139
- },
140
- };
141
-
142
- export const WithInlinePromptNoSentiment = {
143
- args: props,
144
- render: (args: ExpressiveMoneyInputProps) => {
145
- const availableBalance = 1500;
146
- const [sourceAmount, setSourceAmount] = React.useState(args.amount);
147
- return (
148
- <ExpressiveMoneyInput
149
- label={args.label}
150
- amount={sourceAmount}
151
- currency="EUR"
152
- currencySelector={args.currencySelector}
153
- inlinePrompt={{
154
- message: (
155
- <>
156
- {`Available balance `}
157
- <Link
158
- onClick={() => {
159
- setSourceAmount(availableBalance);
160
- }}
161
- >
162
- <Money amount={availableBalance} currency={args.currency} />
163
- </Link>
164
- </>
165
- ),
166
- }}
167
- onAmountChange={args.onAmountChange}
168
- />
169
- );
170
- },
171
- };
172
-
173
- export const WithInlinePromptSentiment = {
174
- args: props,
175
- render: (args: ExpressiveMoneyInputProps) => {
176
- return (
177
- <>
178
- <ExpressiveMoneyInput
179
- label={args.label}
180
- currency="EUR"
181
- currencySelector={args.currencySelector}
182
- inlinePrompt={{ message: lorem5, sentiment: 'negative' }}
183
- onAmountChange={args.onAmountChange}
184
- />
185
- <ExpressiveMoneyInput
186
- label={args.label}
187
- currency="EUR"
188
- currencySelector={args.currencySelector}
189
- inlinePrompt={{ message: lorem5, sentiment: 'warning' }}
190
- onAmountChange={args.onAmountChange}
191
- />
192
- <ExpressiveMoneyInput
193
- label={args.label}
194
- currency="EUR"
195
- currencySelector={args.currencySelector}
196
- inlinePrompt={{ message: lorem5, sentiment: 'neutral' }}
197
- onAmountChange={args.onAmountChange}
198
- />
199
- <ExpressiveMoneyInput
200
- label={args.label}
201
- currency="EUR"
202
- currencySelector={args.currencySelector}
203
- inlinePrompt={{ message: lorem5, sentiment: 'positive' }}
204
- onAmountChange={args.onAmountChange}
205
- />
206
- <ExpressiveMoneyInput
207
- label={args.label}
208
- currency="EUR"
209
- currencySelector={args.currencySelector}
210
- inlinePrompt={{ message: lorem5, sentiment: 'positive', media: <Tags /> }}
211
- onAmountChange={args.onAmountChange}
212
- />
213
- <ExpressiveMoneyInput
214
- label={args.label}
215
- currency="EUR"
216
- currencySelector={args.currencySelector}
217
- inlinePrompt={{ message: lorem5, sentiment: 'proposition' }}
218
- onAmountChange={args.onAmountChange}
219
- />
220
- <ExpressiveMoneyInput
221
- label={args.label}
222
- currency="EUR"
223
- currencySelector={args.currencySelector}
224
- inlinePrompt={{ message: lorem5, sentiment: 'proposition', media: <Rewards /> }}
225
- onAmountChange={args.onAmountChange}
226
- />
227
- </>
228
- );
229
- },
230
- };
231
-
232
- export const Autofocus = {
233
- args: props,
234
- render: (args: ExpressiveMoneyInputProps) => (
235
- <ExpressiveMoneyInput {...args} currency="MXN" inlinePrompt={undefined} />
236
- ),
237
- };
238
-
239
- export const WithCustomRender = {
240
- args: props,
241
- render: (args: ExpressiveMoneyInputProps) => {
242
- const [open, setOpen] = React.useState(false);
243
- return (
244
- <>
245
- <ExpressiveMoneyInput
246
- label="Instance with Custom Currency Selector"
247
- currency="AUD"
248
- currencySelector={{
249
- customRender: ({ id, labelId }) => (
250
- <Button v2 size="sm" priority="primary" onClick={() => setOpen(true)}>
251
- Custom Render
252
- </Button>
253
- ),
254
- }}
255
- onAmountChange={(amount) => console.log(amount)}
256
- />
257
- <Modal
258
- open={open}
259
- title="Custom UX for currency selectors"
260
- body={
261
- <List>
262
- <ListItem
263
- media={
264
- <ListItem.AvatarView>
265
- <Flag code="gb" />
266
- </ListItem.AvatarView>
267
- }
268
- title="GBP"
269
- control={<ListItem.Radio name="currency-key" checked={false} />}
270
- />
271
- <ListItem
272
- media={
273
- <ListItem.AvatarView>
274
- <Flag code="au" />
275
- </ListItem.AvatarView>
276
- }
277
- title="AUD"
278
- control={<ListItem.Radio name="currency-key" checked />}
279
- />
280
- </List>
281
- }
282
- onClose={() => setOpen(false)}
283
- />
284
- </>
285
- );
286
- },
287
- };
@@ -1,130 +0,0 @@
1
- import Body from '../body';
2
- import { Label } from '../label/Label';
3
- import { clsx } from 'clsx';
4
- import { AnimatePresence, motion } from 'framer-motion';
5
- import { useId, type ReactNode } from 'react';
6
-
7
- import {
8
- type Props as CurrencySelectorProps,
9
- CurrencySelector,
10
- } from './currencySelector/CurrencySelector';
11
- import { CommonProps } from '../common';
12
- import { AmountInput } from './amountInput/AmountInput';
13
- import { Chevron } from './chevron/Chevron';
14
- import { InlinePrompt, type InlinePromptProps } from '../prompt/InlinePrompt';
15
-
16
- type AmountType = number | null;
17
- export type CurrencyType = string;
18
-
19
- type DefaultCurrencySelectorInstanceType = Pick<
20
- CurrencySelectorProps,
21
- 'addons' | 'options' | 'onChange' | 'onOpen' | 'onSearchChange'
22
- >;
23
- type CustomCurrencySelectorInstanceType = {
24
- customRender?: (props: { id: string; labelId: string }) => ReactNode;
25
- };
26
- type CurrencySelectorType = DefaultCurrencySelectorInstanceType &
27
- CustomCurrencySelectorInstanceType;
28
-
29
- export type Props = {
30
- label?: ReactNode;
31
- currencySelector?: CurrencySelectorType;
32
- amount?: AmountType;
33
- currency: CurrencyType;
34
- inlinePrompt?: {
35
- sentiment?: InlinePromptProps['sentiment'];
36
- message: InlinePromptProps['children'];
37
- media?: InlinePromptProps['media'];
38
- };
39
- showChevron?: boolean;
40
- autoFocus?: boolean;
41
- loading?: boolean;
42
- onAmountChange: (amount: AmountType) => void;
43
- onFocusChange?: (focused: boolean) => void;
44
- } & CommonProps;
45
-
46
- export default function ExpressiveMoneyInput({
47
- label,
48
- currency,
49
- currencySelector = { options: [] } as DefaultCurrencySelectorInstanceType,
50
- amount,
51
- onAmountChange,
52
- className,
53
- inlinePrompt,
54
- showChevron,
55
- autoFocus,
56
- loading,
57
- onFocusChange,
58
- }: Props) {
59
- const inputId = useId();
60
- const labelId = useId();
61
- const customAlertId = useId();
62
- const currencyId = useId();
63
-
64
- return (
65
- <div className={clsx('wds-expressive-money-input', className)}>
66
- <Label id={labelId} htmlFor={inputId} className={clsx('m-b-1', 'font-weight-normal')}>
67
- {label}
68
- </Label>
69
- <div
70
- className={clsx('d-flex')}
71
- role="group"
72
- aria-labelledby={labelId}
73
- {...(inlinePrompt ? { 'aria-describedby': customAlertId } : {})}
74
- >
75
- <div className="wds-expressive-money-input-currency-selector">
76
- {currencySelector.customRender?.({ id: currencyId, labelId }) ?? (
77
- <CurrencySelector
78
- id={currencyId}
79
- labelId={labelId}
80
- currency={currency}
81
- {...currencySelector}
82
- />
83
- )}
84
- </div>
85
- <AmountInput
86
- id={inputId}
87
- describedById={currencyId}
88
- amount={amount}
89
- currency={currency}
90
- // eslint-disable-next-line jsx-a11y/no-autofocus
91
- autoFocus={autoFocus}
92
- loading={loading}
93
- onChange={onAmountChange}
94
- onFocusChange={onFocusChange}
95
- />
96
- <div className={clsx('d-flex align-items-center', 'wds-expressive-money-input-chevron')}>
97
- <Chevron shouldShow={Boolean(showChevron)} />
98
- </div>
99
- </div>
100
- <AnimatePresence initial={false}>
101
- {inlinePrompt && (
102
- <div className={clsx('d-flex justify-content-end', inlinePrompt && 'm-t-1')}>
103
- <motion.div
104
- key={customAlertId}
105
- initial={{ opacity: 0, height: 0 }}
106
- animate={{
107
- opacity: 1,
108
- height: 'auto',
109
- transition: { delay: 0.75, duration: 0.3 },
110
- }}
111
- exit={{ opacity: 0, height: 0 }}
112
- >
113
- {inlinePrompt.sentiment ? (
114
- <InlinePrompt
115
- id={customAlertId}
116
- media={inlinePrompt.media}
117
- sentiment={inlinePrompt.sentiment}
118
- >
119
- {inlinePrompt.message}
120
- </InlinePrompt>
121
- ) : (
122
- <Body>{inlinePrompt.message}</Body>
123
- )}
124
- </motion.div>
125
- </div>
126
- )}
127
- </AnimatePresence>
128
- </div>
129
- );
130
- }
@@ -1,32 +0,0 @@
1
- .wds-amount-input-container {
2
- width: 100%;
3
- }
4
- .wds-amount-input-input-container {
5
- display: flex;
6
- justify-content: right;
7
- width: 100%;
8
- transition: font-size 0.4s cubic-bezier(0.3, 0, 0.1, 1), height 0.4s cubic-bezier(0.3, 0, 0.1, 1), margin-top 0.4s cubic-bezier(0.3, 0, 0.1, 1), color 0.4s ease;
9
- color: var(--color-interactive-primary);
10
- overflow: hidden;
11
- margin-bottom: 0 !important;
12
- }
13
- @media (prefers-reduced-motion: reduce) {
14
- .wds-amount-input-input-container {
15
- transition: none;
16
- }
17
- }
18
- .wds-amount-input-input {
19
- border: none;
20
- outline: none;
21
- flex-grow: 1;
22
- text-align: right;
23
- background-color: transparent;
24
- }
25
- .wds-amount-input-input:focus-visible {
26
- outline: none;
27
- }
28
- .wds-amount-input-placeholder {
29
- flex-grow: 0;
30
- display: flex;
31
- align-items: center;
32
- }