@transferwise/components 0.0.0-experimental-77845f6 → 0.0.0-experimental-e556371

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 (119) 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 +15 -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 +15 -65
  16. package/build/styles/moneyInput/MoneyInput.css +8 -0
  17. package/build/styles/prompt/InlinePrompt/InlinePrompt.css +7 -7
  18. package/build/types/index.d.ts +0 -2
  19. package/build/types/index.d.ts.map +1 -1
  20. package/build/types/prompt/InlinePrompt/InlinePrompt.d.ts +2 -3
  21. package/build/types/prompt/InlinePrompt/InlinePrompt.d.ts.map +1 -1
  22. package/build/types/test-utils/index.d.ts +0 -4
  23. package/build/types/test-utils/index.d.ts.map +1 -1
  24. package/package.json +4 -4
  25. package/src/i18n/en.json +0 -2
  26. package/src/index.ts +0 -2
  27. package/src/main.css +15 -65
  28. package/src/main.less +0 -1
  29. package/src/moneyInput/MoneyInput.css +8 -0
  30. package/src/moneyInput/MoneyInput.less +5 -0
  31. package/src/prompt/InlinePrompt/InlinePrompt.css +7 -7
  32. package/src/prompt/InlinePrompt/InlinePrompt.less +7 -7
  33. package/src/prompt/InlinePrompt/InlinePrompt.spec.tsx +0 -6
  34. package/src/prompt/InlinePrompt/InlinePrompt.tsx +2 -12
  35. package/src/ssr.spec.tsx +0 -1
  36. package/build/expressiveMoneyInput/ExpressiveMoneyInput.js +0 -114
  37. package/build/expressiveMoneyInput/ExpressiveMoneyInput.js.map +0 -1
  38. package/build/expressiveMoneyInput/ExpressiveMoneyInput.messages.js +0 -17
  39. package/build/expressiveMoneyInput/ExpressiveMoneyInput.messages.js.map +0 -1
  40. package/build/expressiveMoneyInput/ExpressiveMoneyInput.messages.mjs +0 -13
  41. package/build/expressiveMoneyInput/ExpressiveMoneyInput.messages.mjs.map +0 -1
  42. package/build/expressiveMoneyInput/ExpressiveMoneyInput.mjs +0 -110
  43. package/build/expressiveMoneyInput/ExpressiveMoneyInput.mjs.map +0 -1
  44. package/build/expressiveMoneyInput/amountInput/AmountInput.js +0 -281
  45. package/build/expressiveMoneyInput/amountInput/AmountInput.js.map +0 -1
  46. package/build/expressiveMoneyInput/amountInput/AmountInput.mjs +0 -279
  47. package/build/expressiveMoneyInput/amountInput/AmountInput.mjs.map +0 -1
  48. package/build/expressiveMoneyInput/amountInput/utils.js +0 -87
  49. package/build/expressiveMoneyInput/amountInput/utils.js.map +0 -1
  50. package/build/expressiveMoneyInput/amountInput/utils.mjs +0 -78
  51. package/build/expressiveMoneyInput/amountInput/utils.mjs.map +0 -1
  52. package/build/expressiveMoneyInput/animatedNumber/AnimatedNumber.js +0 -50
  53. package/build/expressiveMoneyInput/animatedNumber/AnimatedNumber.js.map +0 -1
  54. package/build/expressiveMoneyInput/animatedNumber/AnimatedNumber.mjs +0 -48
  55. package/build/expressiveMoneyInput/animatedNumber/AnimatedNumber.mjs.map +0 -1
  56. package/build/expressiveMoneyInput/chevron/Chevron.js +0 -31
  57. package/build/expressiveMoneyInput/chevron/Chevron.js.map +0 -1
  58. package/build/expressiveMoneyInput/chevron/Chevron.mjs +0 -29
  59. package/build/expressiveMoneyInput/chevron/Chevron.mjs.map +0 -1
  60. package/build/expressiveMoneyInput/currencySelector/CurrencySelector.js +0 -160
  61. package/build/expressiveMoneyInput/currencySelector/CurrencySelector.js.map +0 -1
  62. package/build/expressiveMoneyInput/currencySelector/CurrencySelector.mjs +0 -157
  63. package/build/expressiveMoneyInput/currencySelector/CurrencySelector.mjs.map +0 -1
  64. package/build/expressiveMoneyInput/hooks/useFocus.js +0 -37
  65. package/build/expressiveMoneyInput/hooks/useFocus.js.map +0 -1
  66. package/build/expressiveMoneyInput/hooks/useFocus.mjs +0 -35
  67. package/build/expressiveMoneyInput/hooks/useFocus.mjs.map +0 -1
  68. package/build/expressiveMoneyInput/hooks/useInputStyle.js +0 -71
  69. package/build/expressiveMoneyInput/hooks/useInputStyle.js.map +0 -1
  70. package/build/expressiveMoneyInput/hooks/useInputStyle.mjs +0 -69
  71. package/build/expressiveMoneyInput/hooks/useInputStyle.mjs.map +0 -1
  72. package/build/styles/expressiveMoneyInput/ExpressiveMoneyInput.css +0 -58
  73. package/build/styles/expressiveMoneyInput/amountInput/AmountInput.css +0 -32
  74. package/build/styles/expressiveMoneyInput/chevron/Chevron.css +0 -12
  75. package/build/styles/expressiveMoneyInput/currencySelector/CurrencySelector.css +0 -6
  76. package/build/types/expressiveMoneyInput/ExpressiveMoneyInput.d.ts +0 -33
  77. package/build/types/expressiveMoneyInput/ExpressiveMoneyInput.d.ts.map +0 -1
  78. package/build/types/expressiveMoneyInput/ExpressiveMoneyInput.messages.d.ts +0 -12
  79. package/build/types/expressiveMoneyInput/ExpressiveMoneyInput.messages.d.ts.map +0 -1
  80. package/build/types/expressiveMoneyInput/amountInput/AmountInput.d.ts +0 -13
  81. package/build/types/expressiveMoneyInput/amountInput/AmountInput.d.ts.map +0 -1
  82. package/build/types/expressiveMoneyInput/amountInput/utils.d.ts +0 -22
  83. package/build/types/expressiveMoneyInput/amountInput/utils.d.ts.map +0 -1
  84. package/build/types/expressiveMoneyInput/animatedNumber/AnimatedNumber.d.ts +0 -9
  85. package/build/types/expressiveMoneyInput/animatedNumber/AnimatedNumber.d.ts.map +0 -1
  86. package/build/types/expressiveMoneyInput/chevron/Chevron.d.ts +0 -6
  87. package/build/types/expressiveMoneyInput/chevron/Chevron.d.ts.map +0 -1
  88. package/build/types/expressiveMoneyInput/currencySelector/CurrencySelector.d.ts +0 -30
  89. package/build/types/expressiveMoneyInput/currencySelector/CurrencySelector.d.ts.map +0 -1
  90. package/build/types/expressiveMoneyInput/hooks/useFocus.d.ts +0 -7
  91. package/build/types/expressiveMoneyInput/hooks/useFocus.d.ts.map +0 -1
  92. package/build/types/expressiveMoneyInput/hooks/useInputStyle.d.ts +0 -10
  93. package/build/types/expressiveMoneyInput/hooks/useInputStyle.d.ts.map +0 -1
  94. package/build/types/expressiveMoneyInput/hooks/useSelectionRange.d.ts +0 -10
  95. package/build/types/expressiveMoneyInput/hooks/useSelectionRange.d.ts.map +0 -1
  96. package/build/types/expressiveMoneyInput/index.d.ts +0 -3
  97. package/build/types/expressiveMoneyInput/index.d.ts.map +0 -1
  98. package/src/expressiveMoneyInput/ExpressiveMoneyInput.css +0 -58
  99. package/src/expressiveMoneyInput/ExpressiveMoneyInput.less +0 -13
  100. package/src/expressiveMoneyInput/ExpressiveMoneyInput.messages.ts +0 -13
  101. package/src/expressiveMoneyInput/ExpressiveMoneyInput.story.tsx +0 -290
  102. package/src/expressiveMoneyInput/ExpressiveMoneyInput.tsx +0 -125
  103. package/src/expressiveMoneyInput/amountInput/AmountInput.css +0 -32
  104. package/src/expressiveMoneyInput/amountInput/AmountInput.less +0 -43
  105. package/src/expressiveMoneyInput/amountInput/AmountInput.tsx +0 -353
  106. package/src/expressiveMoneyInput/amountInput/utils.spec.ts +0 -114
  107. package/src/expressiveMoneyInput/amountInput/utils.ts +0 -116
  108. package/src/expressiveMoneyInput/animatedNumber/AnimatedNumber.tsx +0 -40
  109. package/src/expressiveMoneyInput/chevron/Chevron.css +0 -12
  110. package/src/expressiveMoneyInput/chevron/Chevron.less +0 -13
  111. package/src/expressiveMoneyInput/chevron/Chevron.tsx +0 -35
  112. package/src/expressiveMoneyInput/currencySelector/CurrencySelector.css +0 -6
  113. package/src/expressiveMoneyInput/currencySelector/CurrencySelector.less +0 -7
  114. package/src/expressiveMoneyInput/currencySelector/CurrencySelector.tsx +0 -218
  115. package/src/expressiveMoneyInput/hooks/useFocus.ts +0 -35
  116. package/src/expressiveMoneyInput/hooks/useInputStyle.ts +0 -85
  117. package/src/expressiveMoneyInput/hooks/useSelectionRange.ts +0 -23
  118. package/src/expressiveMoneyInput/index.ts +0 -2
  119. package/src/prompt/InlinePrompt/InlinePrompt.story.tsx +0 -57
@@ -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,290 +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 Alert from '../alert';
16
- import Divider from '../divider';
17
- import { Rewards, Tags } from '@transferwise/icons';
18
-
19
- export default {
20
- title: 'Forms/ExpressiveMoneyInput',
21
- component: ExpressiveMoneyInput,
22
- } as Meta;
23
-
24
- const props: ExpressiveMoneyInputProps = {
25
- label: 'You send',
26
- currency: 'GBP',
27
- amount: 1234.56,
28
- onAmountChange: (amount) => {
29
- console.log('Amount changed', amount);
30
- },
31
- currencySelector: {
32
- addons: [
33
- { asset: <Image src="../avatar-square-dude.webp" alt="" /> },
34
- { profileName: 'Test Test' },
35
- ],
36
- options: [
37
- {
38
- title: 'Popular',
39
- currencies: [
40
- { code: 'USD', label: 'US Dollar', keywords: ['dollar', 'us'] },
41
- { code: 'AUD', label: 'Australia Dollar', keywords: ['dollar', 'us'] },
42
- ],
43
- },
44
- {
45
- title: 'Others',
46
- currencies: [
47
- { code: 'GBP', label: 'Pound', keywords: ['british'] },
48
- { code: 'EUR', label: 'Euro', keywords: ['euro'] },
49
- ],
50
- },
51
- ],
52
- onOpen: () => {
53
- console.log('Currency selector opened');
54
- },
55
- onSearchChange: (payload) => {
56
- console.log('Search changed', payload);
57
- },
58
- onChange: (currency) => {
59
- console.log('Currency changed', currency);
60
- },
61
- },
62
- loading: false,
63
- inlinePrompt: { message: lorem10, sentiment: Sentiment.POSITIVE },
64
- showChevron: true,
65
- autoFocus: true,
66
- };
67
-
68
- export const NullAmount = {
69
- args: props,
70
- render: (args: ExpressiveMoneyInputProps) => (
71
- <ExpressiveMoneyInput
72
- label={args.label}
73
- amount={null}
74
- currency="EUR"
75
- onAmountChange={args.onAmountChange}
76
- />
77
- ),
78
- };
79
-
80
- export const WithInitAmount = {
81
- args: props,
82
- render: (args: ExpressiveMoneyInputProps) => {
83
- const availableBalance = 1500;
84
- return (
85
- <ExpressiveMoneyInput
86
- label={args.label}
87
- amount={availableBalance}
88
- currency="EUR"
89
- onAmountChange={args.onAmountChange}
90
- />
91
- );
92
- },
93
- };
94
-
95
- export const WithLoading = {
96
- args: props,
97
- render: (args: ExpressiveMoneyInputProps) => {
98
- const availableBalance = 1500;
99
- return (
100
- <ExpressiveMoneyInput
101
- label={args.label}
102
- amount={availableBalance}
103
- currency="EUR"
104
- loading
105
- onAmountChange={args.onAmountChange}
106
- />
107
- );
108
- },
109
- };
110
-
111
- export const WithoutChevron = {
112
- args: props,
113
- render: (args: ExpressiveMoneyInputProps) => {
114
- const availableBalance = 1500;
115
- return (
116
- <ExpressiveMoneyInput
117
- label={args.label}
118
- amount={availableBalance}
119
- currency="EUR"
120
- showChevron={false}
121
- onAmountChange={args.onAmountChange}
122
- />
123
- );
124
- },
125
- };
126
-
127
- export const WithCurrencySelector = {
128
- args: props,
129
- render: (args: ExpressiveMoneyInputProps) => {
130
- const availableBalance = 1500;
131
- return (
132
- <ExpressiveMoneyInput
133
- label={args.label}
134
- amount={availableBalance}
135
- currency="EUR"
136
- currencySelector={args.currencySelector}
137
- onAmountChange={args.onAmountChange}
138
- />
139
- );
140
- },
141
- };
142
-
143
- export const WithInlinePromptNoSentiment = {
144
- args: props,
145
- render: (args: ExpressiveMoneyInputProps) => {
146
- const availableBalance = 1500;
147
- const [sourceAmount, setSourceAmount] = React.useState(args.amount);
148
- return (
149
- <ExpressiveMoneyInput
150
- label={args.label}
151
- amount={sourceAmount}
152
- currency="EUR"
153
- currencySelector={args.currencySelector}
154
- inlinePrompt={{
155
- message: (
156
- <>
157
- {`Available balance `}
158
- <Link
159
- onClick={() => {
160
- setSourceAmount(availableBalance);
161
- }}
162
- >
163
- <Money amount={availableBalance} currency={args.currency} />
164
- </Link>
165
- </>
166
- ),
167
- }}
168
- onAmountChange={args.onAmountChange}
169
- />
170
- );
171
- },
172
- };
173
-
174
- export const WithInlinePromptSentiment = {
175
- args: props,
176
- render: (args: ExpressiveMoneyInputProps) => {
177
- return (
178
- <>
179
- <ExpressiveMoneyInput
180
- label={args.label}
181
- currency="EUR"
182
- currencySelector={args.currencySelector}
183
- inlinePrompt={{ message: lorem5, sentiment: 'negative' }}
184
- onAmountChange={args.onAmountChange}
185
- />
186
- <ExpressiveMoneyInput
187
- label={args.label}
188
- currency="EUR"
189
- currencySelector={args.currencySelector}
190
- inlinePrompt={{ message: lorem5, sentiment: 'warning' }}
191
- onAmountChange={args.onAmountChange}
192
- />
193
- <ExpressiveMoneyInput
194
- label={args.label}
195
- currency="EUR"
196
- currencySelector={args.currencySelector}
197
- inlinePrompt={{ message: lorem5, sentiment: 'neutral' }}
198
- onAmountChange={args.onAmountChange}
199
- />
200
- <ExpressiveMoneyInput
201
- label={args.label}
202
- currency="EUR"
203
- currencySelector={args.currencySelector}
204
- inlinePrompt={{ message: lorem5, sentiment: 'positive' }}
205
- onAmountChange={args.onAmountChange}
206
- />
207
- <ExpressiveMoneyInput
208
- label={args.label}
209
- currency="EUR"
210
- currencySelector={args.currencySelector}
211
- inlinePrompt={{ message: lorem5, sentiment: 'positive', media: <Tags /> }}
212
- onAmountChange={args.onAmountChange}
213
- />
214
- <ExpressiveMoneyInput
215
- label={args.label}
216
- currency="EUR"
217
- currencySelector={args.currencySelector}
218
- inlinePrompt={{ message: lorem5, sentiment: 'proposition' }}
219
- onAmountChange={args.onAmountChange}
220
- />
221
- <ExpressiveMoneyInput
222
- label={args.label}
223
- currency="EUR"
224
- currencySelector={args.currencySelector}
225
- inlinePrompt={{ message: lorem5, sentiment: 'proposition', media: <Rewards /> }}
226
- onAmountChange={args.onAmountChange}
227
- />
228
- </>
229
- );
230
- },
231
- };
232
-
233
- export const Autofocus = {
234
- args: props,
235
- render: (args: ExpressiveMoneyInputProps) => (
236
- <ExpressiveMoneyInput {...args} currency="MXN" inlinePrompt={undefined} />
237
- ),
238
- };
239
-
240
- export const WithCustomRender = {
241
- args: props,
242
- render: (args: ExpressiveMoneyInputProps) => {
243
- const [open, setOpen] = React.useState(false);
244
- return (
245
- <>
246
- <ExpressiveMoneyInput
247
- label="Instance with Custom Currency Selector"
248
- currency="AUD"
249
- currencySelector={{
250
- customRender: ({ id, labelId }) => (
251
- <Button v2 size="sm" priority="primary" onClick={() => setOpen(true)}>
252
- Custom Render
253
- </Button>
254
- ),
255
- }}
256
- onAmountChange={(amount) => console.log(amount)}
257
- />
258
- <Modal
259
- open={open}
260
- title="Custom UX for currency selectors"
261
- body={
262
- <List>
263
- <ListItem
264
- media={
265
- <ListItem.AvatarView>
266
- <Flag code="gb" />
267
- </ListItem.AvatarView>
268
- }
269
- title="GBP"
270
- control={<ListItem.Radio name="currency-key" checked={false} />}
271
- />
272
- <ListItem
273
- media={
274
- <ListItem.AvatarView>
275
- <Flag code="au" />
276
- </ListItem.AvatarView>
277
- }
278
- title="AUD"
279
- control={<ListItem.Radio name="currency-key" checked />}
280
- />
281
- </List>
282
- }
283
- onClose={() => setOpen(false)}
284
- />
285
- <Divider className="m-y-2" />
286
- <Alert type="info" message="TODO: add proper message here" />
287
- </>
288
- );
289
- },
290
- };
@@ -1,125 +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
- const selector = currencySelector.customRender?.({ id: currencyId, labelId }) ?? (
65
- <CurrencySelector id={currencyId} labelId={labelId} currency={currency} {...currencySelector} />
66
- );
67
-
68
- return (
69
- <div className={clsx('wds-expressive-money-input', className)}>
70
- <Label id={labelId} htmlFor={inputId} className={clsx('m-b-1', 'font-weight-normal')}>
71
- {label}
72
- </Label>
73
- <div
74
- className={clsx('d-flex')}
75
- role="group"
76
- aria-labelledby={labelId}
77
- {...(inlinePrompt ? { 'aria-describedby': customAlertId } : {})}
78
- >
79
- <div className="wds-expressive-money-input-currency-selector">{selector}</div>
80
- <AmountInput
81
- id={inputId}
82
- describedById={currencyId}
83
- amount={amount}
84
- currency={currency}
85
- // eslint-disable-next-line jsx-a11y/no-autofocus
86
- autoFocus={autoFocus}
87
- loading={loading}
88
- onChange={onAmountChange}
89
- onFocusChange={onFocusChange}
90
- />
91
- <div className={clsx('d-flex align-items-center', 'wds-expressive-money-input-chevron')}>
92
- <Chevron shouldShow={Boolean(showChevron)} />
93
- </div>
94
- </div>
95
- <AnimatePresence initial={false}>
96
- {inlinePrompt && (
97
- <div className={clsx('d-flex justify-content-end', inlinePrompt && 'm-t-1')}>
98
- <motion.div
99
- key={customAlertId}
100
- initial={{ opacity: 0, height: 0 }}
101
- animate={{
102
- opacity: 1,
103
- height: 'auto',
104
- transition: { delay: 0.75, duration: 0.3 },
105
- }}
106
- exit={{ opacity: 0, height: 0 }}
107
- >
108
- {inlinePrompt.sentiment ? (
109
- <InlinePrompt
110
- id={customAlertId}
111
- media={inlinePrompt.media}
112
- sentiment={inlinePrompt.sentiment}
113
- >
114
- {inlinePrompt.message}
115
- </InlinePrompt>
116
- ) : (
117
- <Body>{inlinePrompt.message}</Body>
118
- )}
119
- </motion.div>
120
- </div>
121
- )}
122
- </AnimatePresence>
123
- </div>
124
- );
125
- }
@@ -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
- }