@transferwise/components 0.0.0-experimental-9442a3d → 0.0.0-experimental-fe42ce4

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 (120) hide show
  1. package/build/dateInput/DateInput.js +2 -2
  2. package/build/dateInput/DateInput.js.map +1 -1
  3. package/build/dateInput/DateInput.mjs +2 -2
  4. package/build/dateInput/DateInput.mjs.map +1 -1
  5. package/build/i18n/en.json +2 -0
  6. package/build/i18n/en.json.js +2 -0
  7. package/build/i18n/en.json.js.map +1 -1
  8. package/build/i18n/en.json.mjs +2 -0
  9. package/build/i18n/en.json.mjs.map +1 -1
  10. package/build/index.js +2 -0
  11. package/build/index.js.map +1 -1
  12. package/build/index.mjs +1 -0
  13. package/build/index.mjs.map +1 -1
  14. package/build/main.css +66 -0
  15. package/build/moneyInputField/AmountInput.js +284 -0
  16. package/build/moneyInputField/AmountInput.js.map +1 -0
  17. package/build/moneyInputField/AmountInput.mjs +282 -0
  18. package/build/moneyInputField/AmountInput.mjs.map +1 -0
  19. package/build/moneyInputField/AnimatedNumber.js +50 -0
  20. package/build/moneyInputField/AnimatedNumber.js.map +1 -0
  21. package/build/moneyInputField/AnimatedNumber.mjs +48 -0
  22. package/build/moneyInputField/AnimatedNumber.mjs.map +1 -0
  23. package/build/moneyInputField/Chevron.js +33 -0
  24. package/build/moneyInputField/Chevron.js.map +1 -0
  25. package/build/moneyInputField/Chevron.mjs +31 -0
  26. package/build/moneyInputField/Chevron.mjs.map +1 -0
  27. package/build/moneyInputField/CurrencySelector.js +160 -0
  28. package/build/moneyInputField/CurrencySelector.js.map +1 -0
  29. package/build/moneyInputField/CurrencySelector.mjs +157 -0
  30. package/build/moneyInputField/CurrencySelector.mjs.map +1 -0
  31. package/build/moneyInputField/MoneyInputField.js +112 -0
  32. package/build/moneyInputField/MoneyInputField.js.map +1 -0
  33. package/build/moneyInputField/MoneyInputField.messages.js +17 -0
  34. package/build/moneyInputField/MoneyInputField.messages.js.map +1 -0
  35. package/build/moneyInputField/MoneyInputField.messages.mjs +13 -0
  36. package/build/moneyInputField/MoneyInputField.messages.mjs.map +1 -0
  37. package/build/moneyInputField/MoneyInputField.mjs +108 -0
  38. package/build/moneyInputField/MoneyInputField.mjs.map +1 -0
  39. package/build/moneyInputField/useFocus.js +37 -0
  40. package/build/moneyInputField/useFocus.js.map +1 -0
  41. package/build/moneyInputField/useFocus.mjs +35 -0
  42. package/build/moneyInputField/useFocus.mjs.map +1 -0
  43. package/build/moneyInputField/useInputStyle.js +71 -0
  44. package/build/moneyInputField/useInputStyle.js.map +1 -0
  45. package/build/moneyInputField/useInputStyle.mjs +69 -0
  46. package/build/moneyInputField/useInputStyle.mjs.map +1 -0
  47. package/build/moneyInputField/utils.js +87 -0
  48. package/build/moneyInputField/utils.js.map +1 -0
  49. package/build/moneyInputField/utils.mjs +78 -0
  50. package/build/moneyInputField/utils.mjs.map +1 -0
  51. package/build/phoneNumberInput/PhoneNumberInput.js +1 -1
  52. package/build/phoneNumberInput/PhoneNumberInput.js.map +1 -1
  53. package/build/phoneNumberInput/PhoneNumberInput.mjs +1 -1
  54. package/build/phoneNumberInput/PhoneNumberInput.mjs.map +1 -1
  55. package/build/styles/inputs/Input.css +5 -0
  56. package/build/styles/inputs/TextArea.css +5 -0
  57. package/build/styles/main.css +66 -0
  58. package/build/styles/moneyInputField/AmountInput.css +32 -0
  59. package/build/styles/moneyInputField/Chevron.css +12 -0
  60. package/build/styles/moneyInputField/CurrencySelector.css +6 -0
  61. package/build/styles/moneyInputField/MoneyInputField.css +61 -0
  62. package/build/types/index.d.ts +2 -0
  63. package/build/types/index.d.ts.map +1 -1
  64. package/build/types/moneyInputField/AmountInput.d.ts +13 -0
  65. package/build/types/moneyInputField/AmountInput.d.ts.map +1 -0
  66. package/build/types/moneyInputField/AnimatedNumber.d.ts +9 -0
  67. package/build/types/moneyInputField/AnimatedNumber.d.ts.map +1 -0
  68. package/build/types/moneyInputField/Chevron.d.ts +6 -0
  69. package/build/types/moneyInputField/Chevron.d.ts.map +1 -0
  70. package/build/types/moneyInputField/CurrencySelector.d.ts +30 -0
  71. package/build/types/moneyInputField/CurrencySelector.d.ts.map +1 -0
  72. package/build/types/moneyInputField/MoneyInputField.d.ts +22 -0
  73. package/build/types/moneyInputField/MoneyInputField.d.ts.map +1 -0
  74. package/build/types/moneyInputField/MoneyInputField.messages.d.ts +12 -0
  75. package/build/types/moneyInputField/MoneyInputField.messages.d.ts.map +1 -0
  76. package/build/types/moneyInputField/index.d.ts +3 -0
  77. package/build/types/moneyInputField/index.d.ts.map +1 -0
  78. package/build/types/moneyInputField/useFocus.d.ts +7 -0
  79. package/build/types/moneyInputField/useFocus.d.ts.map +1 -0
  80. package/build/types/moneyInputField/useInputStyle.d.ts +10 -0
  81. package/build/types/moneyInputField/useInputStyle.d.ts.map +1 -0
  82. package/build/types/moneyInputField/useSelectionRange.d.ts +10 -0
  83. package/build/types/moneyInputField/useSelectionRange.d.ts.map +1 -0
  84. package/build/types/moneyInputField/utils.d.ts +22 -0
  85. package/build/types/moneyInputField/utils.d.ts.map +1 -0
  86. package/build/types/test-utils/index.d.ts +4 -0
  87. package/build/types/test-utils/index.d.ts.map +1 -1
  88. package/package.json +3 -2
  89. package/src/DisabledComponents.story.tsx +156 -0
  90. package/src/dateInput/DateInput.tsx +2 -2
  91. package/src/i18n/en.json +2 -0
  92. package/src/index.ts +2 -0
  93. package/src/inputs/Input.css +5 -0
  94. package/src/inputs/TextArea.css +5 -0
  95. package/src/inputs/_common.less +5 -0
  96. package/src/main.css +66 -0
  97. package/src/main.less +1 -0
  98. package/src/moneyInputField/AmountInput.css +32 -0
  99. package/src/moneyInputField/AmountInput.less +43 -0
  100. package/src/moneyInputField/AmountInput.tsx +355 -0
  101. package/src/moneyInputField/AnimatedNumber.tsx +40 -0
  102. package/src/moneyInputField/Chevron.css +12 -0
  103. package/src/moneyInputField/Chevron.less +13 -0
  104. package/src/moneyInputField/Chevron.tsx +35 -0
  105. package/src/moneyInputField/CurrencySelector.css +6 -0
  106. package/src/moneyInputField/CurrencySelector.less +7 -0
  107. package/src/moneyInputField/CurrencySelector.tsx +219 -0
  108. package/src/moneyInputField/MoneyInputField.css +61 -0
  109. package/src/moneyInputField/MoneyInputField.less +16 -0
  110. package/src/moneyInputField/MoneyInputField.messages.ts +13 -0
  111. package/src/moneyInputField/MoneyInputField.story.tsx +193 -0
  112. package/src/moneyInputField/MoneyInputField.tsx +118 -0
  113. package/src/moneyInputField/index.ts +2 -0
  114. package/src/moneyInputField/useFocus.ts +35 -0
  115. package/src/moneyInputField/useInputStyle.ts +85 -0
  116. package/src/moneyInputField/useSelectionRange.ts +23 -0
  117. package/src/moneyInputField/utils.spec.ts +114 -0
  118. package/src/moneyInputField/utils.ts +116 -0
  119. package/src/phoneNumberInput/PhoneNumberInput.tsx +1 -1
  120. package/src/ssr.spec.tsx +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AmountInput.d.ts","sourceRoot":"","sources":["../../../src/moneyInputField/AmountInput.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,IAAI,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAelE,KAAK,KAAK,GAAG;IACX,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC1C,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CAC5C,GAAG,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAAC;AAE1C,eAAO,MAAM,WAAW,GAAI,uFASzB,KAAK,gCA6SP,CAAC"}
@@ -0,0 +1,9 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnimatedNumber.d.ts","sourceRoot":"","sources":["../../../src/moneyInputField/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"}
@@ -0,0 +1,6 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Chevron.d.ts","sourceRoot":"","sources":["../../../src/moneyInputField/Chevron.tsx"],"names":[],"mappings":"AAIA,UAAU,KAAK;IACb,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,OAAO,GAAI,gBAAuB,KAAK,gCA0BnD,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { AvatarLayoutProps } from '..';
2
+ import { CurrencyType, Props as MoneyInputFieldProps } from './MoneyInputField';
3
+ import { type ButtonHTMLAttributes, type ReactNode } 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<MoneyInputFieldProps, '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?: ReactNode | undefined;
29
+ } & import("react").RefAttributes<HTMLButtonElement | null>>;
30
+ //# sourceMappingURL=CurrencySelector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CurrencySelector.d.ts","sourceRoot":"","sources":["../../../src/moneyInputField/CurrencySelector.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAKlB,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,YAAY,EAAE,KAAK,IAAI,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAGhF,OAAO,EACL,KAAK,oBAAoB,EAGzB,KAAK,SAAS,EAGf,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,oBAAoB,EAAE,UAAU,CAAC,CAAC;AAE3C,eAAO,MAAM,gBAAgB,GAAI,+EAS9B,KAAK,gCA2FP,CAAC;AAEF,eAAO,MAAM,WAAW;;4DAgBtB,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { type Props as CurrencySelectorProps } from './CurrencySelector';
2
+ import { CommonProps } from '../common';
3
+ import { type InlinePromptProps } from '../prompt/InlinePrompt';
4
+ type AmountType = number | null;
5
+ export type CurrencyType = string;
6
+ export type Props = {
7
+ currencySelector?: Pick<CurrencySelectorProps, 'addons' | 'options' | 'onChange' | 'onOpen' | 'onSearchChange'>;
8
+ amount?: AmountType;
9
+ currency: CurrencyType;
10
+ inlinePrompt?: {
11
+ sentiment?: InlinePromptProps['sentiment'];
12
+ message: InlinePromptProps['children'];
13
+ };
14
+ showChevron?: boolean;
15
+ autoFocus?: boolean;
16
+ loading?: boolean;
17
+ onAmountChange: (amount: AmountType) => void;
18
+ onFocusChange?: (focused: boolean) => void;
19
+ } & CommonProps;
20
+ export default function MoneyInputField({ currency, currencySelector, amount, onAmountChange, className, inlinePrompt, showChevron, autoFocus, loading, onFocusChange, }: Props): import("react").JSX.Element;
21
+ export {};
22
+ //# sourceMappingURL=MoneyInputField.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MoneyInputField.d.ts","sourceRoot":"","sources":["../../../src/moneyInputField/MoneyInputField.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,KAAK,IAAI,qBAAqB,EAAoB,MAAM,oBAAoB,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAIxC,OAAO,EAAgB,KAAK,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE9E,KAAK,UAAU,GAAG,MAAM,GAAG,IAAI,CAAC;AAChC,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAElC,MAAM,MAAM,KAAK,GAAG;IAClB,gBAAgB,CAAC,EAAE,IAAI,CACrB,qBAAqB,EACrB,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,GAAG,gBAAgB,CAChE,CAAC;IACF,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,QAAQ,EAAE,YAAY,CAAC;IACvB,YAAY,CAAC,EAAE;QACb,SAAS,CAAC,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAC;QAC3C,OAAO,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAC;KACxC,CAAC;IACF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IAC7C,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CAC5C,GAAG,WAAW,CAAC;AAEhB,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EACtC,QAAQ,EACR,gBAAqB,EACrB,MAAM,EACN,cAAc,EACd,SAAS,EACT,YAAY,EACZ,WAAW,EACX,SAAS,EACT,OAAO,EACP,aAAa,GACd,EAAE,KAAK,+BAyEP"}
@@ -0,0 +1,12 @@
1
+ declare const _default: {
2
+ currencySelectorSearchPlaceholder: {
3
+ id: string;
4
+ defaultMessage: string;
5
+ };
6
+ currencySelectorSelectCurrency: {
7
+ id: string;
8
+ defaultMessage: string;
9
+ };
10
+ };
11
+ export default _default;
12
+ //# sourceMappingURL=MoneyInputField.messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MoneyInputField.messages.d.ts","sourceRoot":"","sources":["../../../src/moneyInputField/MoneyInputField.messages.ts"],"names":[],"mappings":";;;;;;;;;;AAEA,wBAUG"}
@@ -0,0 +1,3 @@
1
+ export type { Props as MoneyInputFieldProps } from './MoneyInputField';
2
+ export { default } from './MoneyInputField';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/moneyInputField/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,KAAK,IAAI,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,7 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFocus.d.ts","sourceRoot":"","sources":["../../../src/moneyInputField/useFocus.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,QAAQ;;sBAgBC,OAAO;;4BAUD,OAAO;CAIlC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type CSSProperties } from 'react';
2
+ import { Props as MoneyInputFieldProps } from './MoneyInputField';
3
+ type InputStyleObject = {
4
+ value: string;
5
+ focus: boolean;
6
+ inputElement: HTMLInputElement | null;
7
+ } & Pick<MoneyInputFieldProps, 'loading'>;
8
+ export declare const useInputStyle: ({ value, focus, inputElement, loading }: InputStyleObject) => CSSProperties;
9
+ export {};
10
+ //# sourceMappingURL=useInputStyle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useInputStyle.d.ts","sourceRoot":"","sources":["../../../src/moneyInputField/useInputStyle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAwC,MAAM,OAAO,CAAC;AACjF,OAAO,EAAE,KAAK,IAAI,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAElE,KAAK,gBAAgB,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,YAAY,EAAE,gBAAgB,GAAG,IAAI,CAAC;CACvC,GAAG,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAAC;AAE1C,eAAO,MAAM,aAAa,GAAI,yCAAyC,gBAAgB,kBAyBtF,CAAC"}
@@ -0,0 +1,10 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSelectionRange.d.ts","sourceRoot":"","sources":["../../../src/moneyInputField/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"}
@@ -0,0 +1,22 @@
1
+ import type { KeyboardEvent } from 'react';
2
+ export declare const getDecimalSeparator: (currency: string, locale: string) => string | null;
3
+ export declare const getGroupSeparator: (currency: string, locale: string) => string | null;
4
+ export declare const getDecimalCount: (currency: string, locale: string) => number;
5
+ export declare const getEnteredDecimalsCount: (value: string, decimalSeparator: string) => number;
6
+ export declare const getUnformattedNumber: ({ value: formattedValue, currency, locale, }: {
7
+ value: string;
8
+ currency: string;
9
+ locale: string;
10
+ }) => number | null;
11
+ export declare const getFormattedString: ({ value: unformattedValue, currency, locale, alwaysShowDecimals, }: {
12
+ value: number;
13
+ currency: string;
14
+ locale: string;
15
+ alwaysShowDecimals?: boolean;
16
+ }) => string;
17
+ export declare const isInputPossiblyOverflowing: ({ ref, value, }: {
18
+ ref: React.RefObject<HTMLInputElement>;
19
+ value: string;
20
+ }) => boolean | undefined;
21
+ export declare const isAllowedInputKey: (e: KeyboardEvent<HTMLInputElement>) => boolean;
22
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/moneyInputField/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"}
@@ -33,6 +33,8 @@ declare function customRender(ui: ReactElement, { locale, messages, ...renderOpt
33
33
  "neptune.MoneyInput.Select.placeholder": string;
34
34
  "neptune.MoneyInput.Select.searchPlaceholder": string;
35
35
  "neptune.MoneyInput.Select.selectCurrencyLabel": string;
36
+ "neptune.MoneyInputField.currency.search.placeholder": string;
37
+ "neptune.MoneyInputField.currency.select.currency": string;
36
38
  "neptune.PhoneNumberInput.SelectInput.placeholder": string;
37
39
  "neptune.PhoneNumberInput.countryCodeLabel": string;
38
40
  "neptune.PhoneNumberInput.phoneNumberLabel": string;
@@ -116,6 +118,8 @@ declare function customRenderHook(callback: () => unknown, { locale, messages }?
116
118
  "neptune.MoneyInput.Select.placeholder": string;
117
119
  "neptune.MoneyInput.Select.searchPlaceholder": string;
118
120
  "neptune.MoneyInput.Select.selectCurrencyLabel": string;
121
+ "neptune.MoneyInputField.currency.search.placeholder": string;
122
+ "neptune.MoneyInputField.currency.select.currency": string;
119
123
  "neptune.PhoneNumberInput.SelectInput.placeholder": string;
120
124
  "neptune.PhoneNumberInput.countryCodeLabel": string;
121
125
  "neptune.PhoneNumberInput.phoneNumberLabel": string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/test-utils/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAM,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,MAAM,EAAc,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAMxD;;;;GAIG;AACH,iBAAS,YAAY,CACnB,EAAE,EAAE,YAAY,EAChB,EAAE,MAAuB,EAAE,QAAa,EAAE,GAAG,aAAa,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAK,GAChE,UAAU,CAAC,OAAO,MAAM,CAAC,CAK3B;AAED;;;GAGG;AACH,iBAAS,gBAAgB,CACvB,QAAQ,EAAE,MAAM,OAAO,EACvB,EAAE,MAAuB,EAAE,QAAa,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAK,uEAKhD;AAED,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,gBAAgB,IAAI,UAAU,EAAE,SAAS,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/test-utils/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAM,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,MAAM,EAAc,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAMxD;;;;GAIG;AACH,iBAAS,YAAY,CACnB,EAAE,EAAE,YAAY,EAChB,EAAE,MAAuB,EAAE,QAAa,EAAE,GAAG,aAAa,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAK,GAChE,UAAU,CAAC,OAAO,MAAM,CAAC,CAK3B;AAED;;;GAGG;AACH,iBAAS,gBAAgB,CACvB,QAAQ,EAAE,MAAM,OAAO,EACvB,EAAE,MAAuB,EAAE,QAAa,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAK,uEAKhD;AAED,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,gBAAgB,IAAI,UAAU,EAAE,SAAS,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "0.0.0-experimental-9442a3d",
3
+ "version": "0.0.0-experimental-fe42ce4",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -101,6 +101,7 @@
101
101
  "@babel/runtime": "^7.28.3",
102
102
  "@floating-ui/react": "^0.27.16",
103
103
  "@headlessui/react": "^1.7.19",
104
+ "framer-motion": "^12.15.0",
104
105
  "@popperjs/core": "^2.11.8",
105
106
  "@react-aria/focus": "^3.21.0",
106
107
  "@react-aria/overlays": "^3.28.0",
@@ -115,7 +116,7 @@
115
116
  "merge-props": "^6.0.0",
116
117
  "react-popper": "^2.3.0",
117
118
  "react-transition-group": "^4.4.5",
118
- "virtua": "^0.44.2"
119
+ "virtua": "^0.41.5"
119
120
  },
120
121
  "publishConfig": {
121
122
  "access": "public"
@@ -0,0 +1,156 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-webpack5';
2
+ import { Cross } from '@transferwise/icons';
3
+ import { useState } from 'react';
4
+
5
+ import Button from './button';
6
+ import { Input } from './inputs/Input';
7
+ import { SelectInput, SelectInputOptionContent } from './inputs/SelectInput';
8
+ import DateInput from './dateInput';
9
+ import PhoneNumberInput from './phoneNumberInput';
10
+ import { Field } from './field/Field';
11
+ import Checkbox from './checkbox';
12
+ import Body from './body';
13
+ import Header from './header';
14
+
15
+ export default {
16
+ title: 'Forms/Disabled Forms',
17
+ parameters: {
18
+ layout: 'centered',
19
+ },
20
+ } satisfies Meta;
21
+
22
+ type Story = StoryObj;
23
+
24
+ export const Disabled: Story = {
25
+ render: () => <DisabledFormShowcaseComponent />,
26
+ tags: ['!autodocs'],
27
+ };
28
+
29
+ function DisabledFormShowcaseComponent() {
30
+ const [selectValue, setSelectValue] = useState<string | undefined>('United Kingdom');
31
+ const [dateValue, setDateValue] = useState<string | null>('11/09/1990');
32
+ const [checkboxValue, setCheckboxValue] = useState(false);
33
+
34
+ const countryOptions = [{ value: 'United Kingdom', label: 'United Kingdom' }];
35
+
36
+ return (
37
+ <div>
38
+ {/* Country of residence */}
39
+ <div style={{ marginBottom: '32px' }}>
40
+ <Field label="Country of residence">
41
+ <SelectInput
42
+ disabled
43
+ value={selectValue}
44
+ placeholder="Select country"
45
+ items={countryOptions.map((option) => ({
46
+ type: 'option' as const,
47
+ value: option.value,
48
+ }))}
49
+ renderValue={(value) => <SelectInputOptionContent title={value} />}
50
+ onChange={setSelectValue}
51
+ />
52
+ </Field>
53
+ </div>
54
+
55
+ {/* Personal details section */}
56
+ <Body style={{ marginBottom: '16px', fontWeight: '600', fontSize: '18px' }}>
57
+ Personal details
58
+ </Body>
59
+
60
+ {/* Full legal first and middle name(s) */}
61
+ <div style={{ marginBottom: '24px' }}>
62
+ <Field label="Full legal first and middle name(s)">
63
+ <Input disabled defaultValue="Mickey" placeholder="Enter your first and middle names" />
64
+ </Field>
65
+ </div>
66
+
67
+ {/* Full legal last name(s) */}
68
+ <div style={{ marginBottom: '24px' }}>
69
+ <Field label="Full legal last name(s)">
70
+ <Input disabled defaultValue="Mantle" placeholder="Enter your last name" />
71
+ </Field>
72
+ </div>
73
+
74
+ {/* Preferred name (optional) */}
75
+ <div style={{ marginBottom: '24px' }}>
76
+ <Field
77
+ label="Preferred name (optional)"
78
+ description="This is how we'll address you in emails and notifications"
79
+ >
80
+ <Input disabled placeholder="Enter your preferred name" />
81
+ </Field>
82
+ </div>
83
+
84
+ {/* Date of birth */}
85
+ <div style={{ marginBottom: '24px' }}>
86
+ <Field label="Date of birth">
87
+ <DateInput
88
+ disabled
89
+ value={dateValue || undefined}
90
+ placeholders={{
91
+ day: '11',
92
+ // month: 'September',
93
+ // year: '1990',
94
+ }}
95
+ onChange={setDateValue}
96
+ />
97
+ </Field>
98
+ </div>
99
+
100
+ {/* Dynamic flow input */}
101
+ <div className="np-field-control" style={{ marginBottom: '32px' }}>
102
+ <fieldset className="np-input-group">
103
+ <Input disabled value="Fercus" />
104
+ </fieldset>
105
+ </div>
106
+
107
+ {/* Phone number */}
108
+ <div style={{ marginBottom: '32px' }}>
109
+ <Field label="Phone number">
110
+ <PhoneNumberInput
111
+ disabled
112
+ initialValue="+4407891300098"
113
+ countryCode="GB"
114
+ onChange={() => {}}
115
+ />
116
+ </Field>
117
+ </div>
118
+
119
+ {/* Additional components */}
120
+ <div
121
+ style={{
122
+ borderTop: '1px solid #e5e7eb',
123
+ paddingTop: '32px',
124
+ marginTop: '32px',
125
+ }}
126
+ >
127
+ <Body style={{ marginBottom: '16px', fontWeight: '600', fontSize: '18px' }}>
128
+ Additional Components
129
+ </Body>
130
+
131
+ {/* Naked Inputs (without Field wrapper) */}
132
+ <div style={{ marginBottom: '24px' }}>
133
+ <Body style={{ marginBottom: '12px', fontWeight: '500', fontSize: '16px' }}>
134
+ Naked Inputs (without Field wrapper)
135
+ </Body>
136
+ <div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>
137
+ <Input disabled placeholder="Disabled input with placeholder" />
138
+ <Input disabled defaultValue="Disabled input with default value" />
139
+ <Input disabled type="email" placeholder="email@example.com" />
140
+ <Input disabled type="password" placeholder="Password input" />
141
+ </div>
142
+ </div>
143
+
144
+ {/* Checkbox */}
145
+ <div style={{ marginBottom: '24px' }}>
146
+ <Checkbox
147
+ disabled
148
+ checked={checkboxValue}
149
+ label="I agree to the terms and conditions"
150
+ onChange={(checked) => setCheckboxValue(checked)}
151
+ />
152
+ </div>
153
+ </div>
154
+ </div>
155
+ );
156
+ }
@@ -291,7 +291,7 @@ const DateInput = ({
291
291
  <div className="col-sm-3 tw-date--day">
292
292
  <label>
293
293
  <Body type={Typography.BODY_DEFAULT}>{dayLabel}</Body>
294
- <div className={`input-group input-group-${size}`}>
294
+ <div className={`input-group input-group-${size} ${disabled ? 'disabled' : ''}`}>
295
295
  <Input
296
296
  ref={dayRef}
297
297
  id={`${id}:day`}
@@ -319,7 +319,7 @@ const DateInput = ({
319
319
  <div className="col-sm-4 tw-date--year">
320
320
  <label>
321
321
  <Body type={Typography.BODY_DEFAULT}>{yearLabel}</Body>
322
- <div className={`input-group input-group-${size}`}>
322
+ <div className={`input-group input-group-${size} ${disabled ? 'disabled' : ''}`}>
323
323
  <Input
324
324
  ref={yearRef}
325
325
  id={`${id}:year`}
package/src/i18n/en.json CHANGED
@@ -23,6 +23,8 @@
23
23
  "neptune.MoneyInput.Select.placeholder": "Select an option...",
24
24
  "neptune.MoneyInput.Select.searchPlaceholder": "Type a currency or country",
25
25
  "neptune.MoneyInput.Select.selectCurrencyLabel": "Select currency",
26
+ "neptune.MoneyInputField.currency.search.placeholder": "Type a currency / country",
27
+ "neptune.MoneyInputField.currency.select.currency": "Select currency",
26
28
  "neptune.PhoneNumberInput.SelectInput.placeholder": "Select an option...",
27
29
  "neptune.PhoneNumberInput.countryCodeLabel": "Country code",
28
30
  "neptune.PhoneNumberInput.phoneNumberLabel": "Phone number",
package/src/index.ts CHANGED
@@ -62,6 +62,7 @@ export type {
62
62
  CurrencyOptionItem,
63
63
  MoneyInputProps,
64
64
  } from './moneyInput';
65
+ export type { MoneyInputFieldProps } from './moneyInputField';
65
66
  export type { NavigationOptionListProps } from './navigationOptionsList';
66
67
  export type { NavigationOptionProps } from './navigationOption/NavigationOption';
67
68
  export type { OverlayHeaderProps } from './overlayHeader';
@@ -188,6 +189,7 @@ export { default as Markdown } from './markdown';
188
189
  export { default as Modal } from './modal';
189
190
  export { default as Money } from './money';
190
191
  export { default as MoneyInput } from './moneyInput';
192
+ export { default as MoneyInputField } from './moneyInputField';
191
193
  export { default as NavigationOption } from './navigationOption';
192
194
  export { default as NavigationOptionsList } from './navigationOptionsList';
193
195
  export { default as Nudge } from './nudge';
@@ -18,6 +18,11 @@
18
18
  transition-duration: 300ms;
19
19
  /* TODO: Remove these overrides once `.form-control` isn’t used anymore */
20
20
  }
21
+ .disabled .np-form-control,
22
+ :disabled .np-form-control {
23
+ opacity: 1;
24
+ opacity: initial;
25
+ }
21
26
  .np-form-control:focus-visible {
22
27
  outline: none;
23
28
  }
@@ -18,6 +18,11 @@
18
18
  transition-duration: 300ms;
19
19
  /* TODO: Remove these overrides once `.form-control` isn’t used anymore */
20
20
  }
21
+ .disabled .np-form-control,
22
+ :disabled .np-form-control {
23
+ opacity: 1;
24
+ opacity: initial;
25
+ }
21
26
  .np-form-control:focus-visible {
22
27
  outline: none;
23
28
  }
@@ -15,6 +15,11 @@
15
15
  transition-timing-function: ease-in-out;
16
16
  transition-duration: 300ms;
17
17
 
18
+ .disabled &,
19
+ :disabled & {
20
+ opacity: unset;
21
+ }
22
+
18
23
  &:focus-visible {
19
24
  outline: none;
20
25
  }
package/src/main.css CHANGED
@@ -2660,6 +2660,11 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
2660
2660
  transition-duration: 300ms;
2661
2661
  /* TODO: Remove these overrides once `.form-control` isn’t used anymore */
2662
2662
  }
2663
+ .disabled .np-form-control,
2664
+ :disabled .np-form-control {
2665
+ opacity: 1;
2666
+ opacity: initial;
2667
+ }
2663
2668
  .np-form-control:focus-visible {
2664
2669
  outline: none;
2665
2670
  }
@@ -4436,6 +4441,67 @@ button.np-link {
4436
4441
  box-shadow: inset 0 0 0 1px #c9cbce !important;
4437
4442
  box-shadow: inset 0 0 0 1px var(--color-interactive-secondary) !important;
4438
4443
  }
4444
+ .wds-amount-input-container {
4445
+ width: 100%;
4446
+ }
4447
+ .wds-amount-input-input-container {
4448
+ display: flex;
4449
+ justify-content: right;
4450
+ width: 100%;
4451
+ 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;
4452
+ color: var(--color-interactive-primary);
4453
+ overflow: hidden;
4454
+ margin-bottom: 0 !important;
4455
+ }
4456
+ @media (prefers-reduced-motion: reduce) {
4457
+ .wds-amount-input-input-container {
4458
+ transition: none;
4459
+ }
4460
+ }
4461
+ .wds-amount-input-input {
4462
+ border: none;
4463
+ outline: none;
4464
+ flex-grow: 1;
4465
+ text-align: right;
4466
+ background-color: transparent;
4467
+ }
4468
+ .wds-amount-input-input:focus-visible {
4469
+ outline: none;
4470
+ }
4471
+ .wds-amount-input-placeholder {
4472
+ flex-grow: 0;
4473
+ display: flex;
4474
+ align-items: center;
4475
+ }
4476
+ .wds-currency-selector:disabled {
4477
+ opacity: 1 !important;
4478
+ cursor: auto !important;
4479
+ cursor: initial !important;
4480
+ mix-blend-mode: initial !important;
4481
+ }
4482
+ .wds-chevron-container {
4483
+ width: 32px;
4484
+ width: var(--size-32);
4485
+ overflow: hidden;
4486
+ color: var(--color-interactive-primary);
4487
+ margin-left: 8px;
4488
+ margin-left: var(--size-8);
4489
+ transition: width 0.3s ease;
4490
+ }
4491
+ .wds-chevron-hidden {
4492
+ width: 0;
4493
+ }
4494
+ .wds-money-input-field {
4495
+ display: flex;
4496
+ }
4497
+ .wds-money-input-field-currency-selector {
4498
+ flex-shrink: 0;
4499
+ margin-right: 24px;
4500
+ margin-right: var(--size-24);
4501
+ }
4502
+ .wds-money-input-field-chevron {
4503
+ transform: translateY(-5%);
4504
+ }
4439
4505
  .np-navigation-option {
4440
4506
  -webkit-text-decoration: none;
4441
4507
  text-decoration: none;
package/src/main.less CHANGED
@@ -51,6 +51,7 @@
51
51
  @import "./logo/Logo.less";
52
52
  @import "./modal/Modal.less";
53
53
  @import "./moneyInput/MoneyInput.less";
54
+ @import "./moneyInputField/MoneyInputField.less";
54
55
  @import "./navigationOption/NavigationOption.less";
55
56
  @import "./navigationOptionsList/NavigationOptionsList.less";
56
57
  @import "./nudge/Nudge.less";
@@ -0,0 +1,32 @@
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
+ }
@@ -0,0 +1,43 @@
1
+ .wds-amount-input {
2
+ &-container {
3
+ width: 100%;
4
+ }
5
+
6
+ &-input-container {
7
+ display: flex;
8
+ justify-content: right;
9
+ width: 100%;
10
+ transition:
11
+ font-size 0.4s cubic-bezier(0.3, 0, 0.1, 1),
12
+ height 0.4s cubic-bezier(0.3, 0, 0.1, 1),
13
+ margin-top 0.4s cubic-bezier(0.3, 0, 0.1, 1),
14
+ color 0.4s ease;
15
+ color: var(--color-interactive-primary);
16
+ overflow: hidden;
17
+ margin-bottom: 0 !important;
18
+ }
19
+
20
+ @media (prefers-reduced-motion: reduce) {
21
+ &-input-container {
22
+ transition: none;
23
+ }
24
+ }
25
+
26
+ &-input {
27
+ border: none;
28
+ outline: none;
29
+ flex-grow: 1;
30
+ text-align: right;
31
+ background-color: transparent;
32
+
33
+ &:focus-visible {
34
+ outline: none;
35
+ }
36
+ }
37
+
38
+ &-placeholder {
39
+ flex-grow: 0;
40
+ display: flex;
41
+ align-items: center;
42
+ }
43
+ }