@transferwise/components 46.112.0 → 46.113.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/expressiveMoneyInput/ExpressiveMoneyInput.js +113 -0
- package/build/expressiveMoneyInput/ExpressiveMoneyInput.js.map +1 -0
- package/build/expressiveMoneyInput/ExpressiveMoneyInput.messages.js +17 -0
- package/build/expressiveMoneyInput/ExpressiveMoneyInput.messages.js.map +1 -0
- package/build/expressiveMoneyInput/ExpressiveMoneyInput.messages.mjs +13 -0
- package/build/expressiveMoneyInput/ExpressiveMoneyInput.messages.mjs.map +1 -0
- package/build/expressiveMoneyInput/ExpressiveMoneyInput.mjs +109 -0
- package/build/expressiveMoneyInput/ExpressiveMoneyInput.mjs.map +1 -0
- package/build/expressiveMoneyInput/amountInput/AmountInput.js +281 -0
- package/build/expressiveMoneyInput/amountInput/AmountInput.js.map +1 -0
- package/build/expressiveMoneyInput/amountInput/AmountInput.mjs +279 -0
- package/build/expressiveMoneyInput/amountInput/AmountInput.mjs.map +1 -0
- package/build/expressiveMoneyInput/amountInput/utils.js +87 -0
- package/build/expressiveMoneyInput/amountInput/utils.js.map +1 -0
- package/build/expressiveMoneyInput/amountInput/utils.mjs +78 -0
- package/build/expressiveMoneyInput/amountInput/utils.mjs.map +1 -0
- package/build/expressiveMoneyInput/animatedNumber/AnimatedNumber.js +50 -0
- package/build/expressiveMoneyInput/animatedNumber/AnimatedNumber.js.map +1 -0
- package/build/expressiveMoneyInput/animatedNumber/AnimatedNumber.mjs +48 -0
- package/build/expressiveMoneyInput/animatedNumber/AnimatedNumber.mjs.map +1 -0
- package/build/expressiveMoneyInput/chevron/Chevron.js +31 -0
- package/build/expressiveMoneyInput/chevron/Chevron.js.map +1 -0
- package/build/expressiveMoneyInput/chevron/Chevron.mjs +29 -0
- package/build/expressiveMoneyInput/chevron/Chevron.mjs.map +1 -0
- package/build/expressiveMoneyInput/currencySelector/CurrencySelector.js +160 -0
- package/build/expressiveMoneyInput/currencySelector/CurrencySelector.js.map +1 -0
- package/build/expressiveMoneyInput/currencySelector/CurrencySelector.mjs +157 -0
- package/build/expressiveMoneyInput/currencySelector/CurrencySelector.mjs.map +1 -0
- package/build/expressiveMoneyInput/hooks/useFocus.js +37 -0
- package/build/expressiveMoneyInput/hooks/useFocus.js.map +1 -0
- package/build/expressiveMoneyInput/hooks/useFocus.mjs +35 -0
- package/build/expressiveMoneyInput/hooks/useFocus.mjs.map +1 -0
- package/build/expressiveMoneyInput/hooks/useInputStyle.js +71 -0
- package/build/expressiveMoneyInput/hooks/useInputStyle.js.map +1 -0
- package/build/expressiveMoneyInput/hooks/useInputStyle.mjs +69 -0
- package/build/expressiveMoneyInput/hooks/useInputStyle.mjs.map +1 -0
- package/build/i18n/en.json +2 -0
- package/build/i18n/en.json.js +2 -0
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +2 -0
- package/build/i18n/en.json.mjs.map +1 -1
- package/build/index.js +2 -0
- package/build/index.js.map +1 -1
- package/build/index.mjs +1 -0
- package/build/index.mjs.map +1 -1
- package/build/listItem/useListItemControl.js +1 -1
- package/build/listItem/useListItemControl.js.map +1 -1
- package/build/listItem/useListItemControl.mjs +2 -2
- package/build/listItem/useListItemControl.mjs.map +1 -1
- package/build/listItem/useListItemMedia.js +1 -1
- package/build/listItem/useListItemMedia.js.map +1 -1
- package/build/listItem/useListItemMedia.mjs +2 -2
- package/build/listItem/useListItemMedia.mjs.map +1 -1
- package/build/main.css +73 -7
- package/build/prompt/InlinePrompt/InlinePrompt.js +7 -0
- package/build/prompt/InlinePrompt/InlinePrompt.js.map +1 -1
- package/build/prompt/InlinePrompt/InlinePrompt.mjs +8 -1
- package/build/prompt/InlinePrompt/InlinePrompt.mjs.map +1 -1
- package/build/styles/expressiveMoneyInput/ExpressiveMoneyInput.css +58 -0
- package/build/styles/expressiveMoneyInput/amountInput/AmountInput.css +32 -0
- package/build/styles/expressiveMoneyInput/chevron/Chevron.css +12 -0
- package/build/styles/expressiveMoneyInput/currencySelector/CurrencySelector.css +6 -0
- package/build/styles/main.css +73 -7
- package/build/styles/moneyInput/MoneyInput.css +8 -0
- package/build/styles/prompt/InlinePrompt/InlinePrompt.css +7 -7
- package/build/types/expressiveMoneyInput/ExpressiveMoneyInput.d.ts +59 -0
- package/build/types/expressiveMoneyInput/ExpressiveMoneyInput.d.ts.map +1 -0
- package/build/types/expressiveMoneyInput/ExpressiveMoneyInput.messages.d.ts +12 -0
- package/build/types/expressiveMoneyInput/ExpressiveMoneyInput.messages.d.ts.map +1 -0
- package/build/types/expressiveMoneyInput/amountInput/AmountInput.d.ts +13 -0
- package/build/types/expressiveMoneyInput/amountInput/AmountInput.d.ts.map +1 -0
- package/build/types/expressiveMoneyInput/amountInput/utils.d.ts +22 -0
- package/build/types/expressiveMoneyInput/amountInput/utils.d.ts.map +1 -0
- package/build/types/expressiveMoneyInput/animatedNumber/AnimatedNumber.d.ts +9 -0
- package/build/types/expressiveMoneyInput/animatedNumber/AnimatedNumber.d.ts.map +1 -0
- package/build/types/expressiveMoneyInput/chevron/Chevron.d.ts +6 -0
- package/build/types/expressiveMoneyInput/chevron/Chevron.d.ts.map +1 -0
- package/build/types/expressiveMoneyInput/currencySelector/CurrencySelector.d.ts +30 -0
- package/build/types/expressiveMoneyInput/currencySelector/CurrencySelector.d.ts.map +1 -0
- package/build/types/expressiveMoneyInput/hooks/useFocus.d.ts +7 -0
- package/build/types/expressiveMoneyInput/hooks/useFocus.d.ts.map +1 -0
- package/build/types/expressiveMoneyInput/hooks/useInputStyle.d.ts +10 -0
- package/build/types/expressiveMoneyInput/hooks/useInputStyle.d.ts.map +1 -0
- package/build/types/expressiveMoneyInput/hooks/useSelectionRange.d.ts +10 -0
- package/build/types/expressiveMoneyInput/hooks/useSelectionRange.d.ts.map +1 -0
- package/build/types/expressiveMoneyInput/index.d.ts +3 -0
- package/build/types/expressiveMoneyInput/index.d.ts.map +1 -0
- package/build/types/index.d.ts +2 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/prompt/InlinePrompt/InlinePrompt.d.ts +3 -2
- package/build/types/prompt/InlinePrompt/InlinePrompt.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts +4 -0
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/build/types/withDisplayFormat/WithDisplayFormat.d.ts.map +1 -1
- package/build/withDisplayFormat/WithDisplayFormat.js +0 -1
- package/build/withDisplayFormat/WithDisplayFormat.js.map +1 -1
- package/build/withDisplayFormat/WithDisplayFormat.mjs +0 -1
- package/build/withDisplayFormat/WithDisplayFormat.mjs.map +1 -1
- package/package.json +11 -4
- package/src/expressiveMoneyInput/ExpressiveMoneyInput.autofocus.docs.mdx +12 -0
- package/src/expressiveMoneyInput/ExpressiveMoneyInput.css +58 -0
- package/src/expressiveMoneyInput/ExpressiveMoneyInput.less +13 -0
- package/src/expressiveMoneyInput/ExpressiveMoneyInput.messages.ts +13 -0
- package/src/expressiveMoneyInput/ExpressiveMoneyInput.story.tsx +232 -0
- package/src/expressiveMoneyInput/ExpressiveMoneyInput.tsx +156 -0
- package/src/expressiveMoneyInput/amountInput/AmountInput.css +32 -0
- package/src/expressiveMoneyInput/amountInput/AmountInput.less +43 -0
- package/src/expressiveMoneyInput/amountInput/AmountInput.tsx +353 -0
- package/src/expressiveMoneyInput/amountInput/utils.spec.ts +114 -0
- package/src/expressiveMoneyInput/amountInput/utils.ts +116 -0
- package/src/expressiveMoneyInput/animatedNumber/AnimatedNumber.tsx +40 -0
- package/src/expressiveMoneyInput/chevron/Chevron.css +12 -0
- package/src/expressiveMoneyInput/chevron/Chevron.less +13 -0
- package/src/expressiveMoneyInput/chevron/Chevron.tsx +35 -0
- package/src/expressiveMoneyInput/currencySelector/CurrencySelector.css +6 -0
- package/src/expressiveMoneyInput/currencySelector/CurrencySelector.less +7 -0
- package/src/expressiveMoneyInput/currencySelector/CurrencySelector.tsx +220 -0
- package/src/expressiveMoneyInput/hooks/useFocus.ts +35 -0
- package/src/expressiveMoneyInput/hooks/useInputStyle.ts +85 -0
- package/src/expressiveMoneyInput/hooks/useSelectionRange.ts +23 -0
- package/src/expressiveMoneyInput/index.ts +2 -0
- package/src/i18n/en.json +2 -0
- package/src/index.ts +2 -0
- package/src/listItem/useListItemControl.tsx +2 -2
- package/src/listItem/useListItemMedia.tsx +2 -2
- package/src/main.css +73 -7
- package/src/main.less +1 -0
- package/src/moneyInput/MoneyInput.css +8 -0
- package/src/moneyInput/MoneyInput.less +5 -0
- package/src/prompt/InlinePrompt/InlinePrompt.css +7 -7
- package/src/prompt/InlinePrompt/InlinePrompt.less +7 -7
- package/src/prompt/InlinePrompt/InlinePrompt.spec.tsx +6 -0
- package/src/prompt/InlinePrompt/InlinePrompt.story.tsx +39 -0
- package/src/prompt/InlinePrompt/InlinePrompt.tsx +12 -2
- package/src/ssr.spec.tsx +1 -0
- package/src/withDisplayFormat/WithDisplayFormat.spec.js +28 -1
- package/src/withDisplayFormat/WithDisplayFormat.tsx +0 -1
package/src/main.css
CHANGED
|
@@ -526,26 +526,26 @@
|
|
|
526
526
|
background-color: var(--color-sentiment-positive-secondary-active);
|
|
527
527
|
}
|
|
528
528
|
.wds-inline-prompt--proposition {
|
|
529
|
-
background-color:
|
|
530
|
-
color: var(--color-
|
|
529
|
+
background-color: #D2F9F7;
|
|
530
|
+
color: var(--color-interactive-primary);
|
|
531
531
|
}
|
|
532
532
|
.wds-inline-prompt--proposition a,
|
|
533
533
|
.wds-inline-prompt--proposition button {
|
|
534
|
-
color: var(--color-
|
|
534
|
+
color: var(--color-interactive-primary);
|
|
535
535
|
}
|
|
536
536
|
.wds-inline-prompt--proposition a:hover,
|
|
537
537
|
.wds-inline-prompt--proposition button:hover {
|
|
538
|
-
color: var(--color-
|
|
538
|
+
color: var(--color-interactive-primary-hover);
|
|
539
539
|
}
|
|
540
540
|
.wds-inline-prompt--proposition a:active,
|
|
541
541
|
.wds-inline-prompt--proposition button:active {
|
|
542
|
-
color: var(--color-
|
|
542
|
+
color: var(--color-interactive-primary-active);
|
|
543
543
|
}
|
|
544
544
|
.wds-inline-prompt.wds-inline-prompt--proposition:has(a, button):hover {
|
|
545
|
-
background-color:
|
|
545
|
+
background-color: #B2F4F3;
|
|
546
546
|
}
|
|
547
547
|
.wds-inline-prompt.wds-inline-prompt--proposition:has(a, button):active {
|
|
548
|
-
background-color:
|
|
548
|
+
background-color: #91F0EE;
|
|
549
549
|
}
|
|
550
550
|
.wds-inline-prompt--neutral {
|
|
551
551
|
background-color: rgba(134,167,189,0.10196);
|
|
@@ -4421,6 +4421,14 @@ button.np-link {
|
|
|
4421
4421
|
flex-shrink: 0;
|
|
4422
4422
|
width: auto;
|
|
4423
4423
|
}
|
|
4424
|
+
.tw-money-input .input-group-addon:not(.amount-currency-select-btn):not(.tw-money-input__fixed-currency):not(:has(~ .tw-money-input__fixed-currency)) {
|
|
4425
|
+
padding-right: 0 !important;
|
|
4426
|
+
}
|
|
4427
|
+
[dir="rtl"] .tw-money-input .input-group-addon:not(.amount-currency-select-btn):not(.tw-money-input__fixed-currency):not(:has(~ .tw-money-input__fixed-currency)) {
|
|
4428
|
+
padding-left: 0 !important;
|
|
4429
|
+
padding-right: 0 !important;
|
|
4430
|
+
padding-right: initial !important;
|
|
4431
|
+
}
|
|
4424
4432
|
.tw-money-input .amount-currency-select-btn {
|
|
4425
4433
|
flex-shrink: 0;
|
|
4426
4434
|
width: auto;
|
|
@@ -4447,6 +4455,64 @@ button.np-link {
|
|
|
4447
4455
|
box-shadow: inset 0 0 0 1px #c9cbce !important;
|
|
4448
4456
|
box-shadow: inset 0 0 0 1px var(--color-interactive-secondary) !important;
|
|
4449
4457
|
}
|
|
4458
|
+
.wds-amount-input-container {
|
|
4459
|
+
width: 100%;
|
|
4460
|
+
}
|
|
4461
|
+
.wds-amount-input-input-container {
|
|
4462
|
+
display: flex;
|
|
4463
|
+
justify-content: right;
|
|
4464
|
+
width: 100%;
|
|
4465
|
+
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;
|
|
4466
|
+
color: var(--color-interactive-primary);
|
|
4467
|
+
overflow: hidden;
|
|
4468
|
+
margin-bottom: 0 !important;
|
|
4469
|
+
}
|
|
4470
|
+
@media (prefers-reduced-motion: reduce) {
|
|
4471
|
+
.wds-amount-input-input-container {
|
|
4472
|
+
transition: none;
|
|
4473
|
+
}
|
|
4474
|
+
}
|
|
4475
|
+
.wds-amount-input-input {
|
|
4476
|
+
border: none;
|
|
4477
|
+
outline: none;
|
|
4478
|
+
flex-grow: 1;
|
|
4479
|
+
text-align: right;
|
|
4480
|
+
background-color: transparent;
|
|
4481
|
+
}
|
|
4482
|
+
.wds-amount-input-input:focus-visible {
|
|
4483
|
+
outline: none;
|
|
4484
|
+
}
|
|
4485
|
+
.wds-amount-input-placeholder {
|
|
4486
|
+
flex-grow: 0;
|
|
4487
|
+
display: flex;
|
|
4488
|
+
align-items: center;
|
|
4489
|
+
}
|
|
4490
|
+
.wds-currency-selector:disabled {
|
|
4491
|
+
opacity: 1 !important;
|
|
4492
|
+
cursor: auto !important;
|
|
4493
|
+
cursor: initial !important;
|
|
4494
|
+
mix-blend-mode: initial !important;
|
|
4495
|
+
}
|
|
4496
|
+
.wds-chevron-container {
|
|
4497
|
+
width: 32px;
|
|
4498
|
+
width: var(--size-32);
|
|
4499
|
+
overflow: hidden;
|
|
4500
|
+
color: var(--color-interactive-primary);
|
|
4501
|
+
margin-left: 8px;
|
|
4502
|
+
margin-left: var(--size-8);
|
|
4503
|
+
transition: width 0.3s ease;
|
|
4504
|
+
}
|
|
4505
|
+
.wds-chevron-hidden {
|
|
4506
|
+
width: 0;
|
|
4507
|
+
}
|
|
4508
|
+
.wds-expressive-money-input-currency-selector {
|
|
4509
|
+
flex-shrink: 0;
|
|
4510
|
+
margin-right: 24px;
|
|
4511
|
+
margin-right: var(--size-24);
|
|
4512
|
+
}
|
|
4513
|
+
.wds-expressive-money-input-chevron {
|
|
4514
|
+
transform: translateY(-5%);
|
|
4515
|
+
}
|
|
4450
4516
|
.np-navigation-option {
|
|
4451
4517
|
-webkit-text-decoration: none;
|
|
4452
4518
|
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 "./expressiveMoneyInput/ExpressiveMoneyInput.less";
|
|
54
55
|
@import "./navigationOption/NavigationOption.less";
|
|
55
56
|
@import "./navigationOptionsList/NavigationOptionsList.less";
|
|
56
57
|
@import "./nudge/Nudge.less";
|
|
@@ -38,6 +38,14 @@
|
|
|
38
38
|
flex-shrink: 0;
|
|
39
39
|
width: auto;
|
|
40
40
|
}
|
|
41
|
+
.tw-money-input .input-group-addon:not(.amount-currency-select-btn):not(.tw-money-input__fixed-currency):not(:has(~ .tw-money-input__fixed-currency)) {
|
|
42
|
+
padding-right: 0 !important;
|
|
43
|
+
}
|
|
44
|
+
[dir="rtl"] .tw-money-input .input-group-addon:not(.amount-currency-select-btn):not(.tw-money-input__fixed-currency):not(:has(~ .tw-money-input__fixed-currency)) {
|
|
45
|
+
padding-left: 0 !important;
|
|
46
|
+
padding-right: 0 !important;
|
|
47
|
+
padding-right: initial !important;
|
|
48
|
+
}
|
|
41
49
|
.tw-money-input .amount-currency-select-btn {
|
|
42
50
|
flex-shrink: 0;
|
|
43
51
|
width: auto;
|
|
@@ -32,11 +32,16 @@
|
|
|
32
32
|
|
|
33
33
|
.input-group-addon {
|
|
34
34
|
flex-shrink: 0;
|
|
35
|
+
|
|
35
36
|
&:not(.amount-currency-select-btn) {
|
|
36
37
|
display: flex;
|
|
37
38
|
align-items: center;
|
|
38
39
|
flex-shrink: 0;
|
|
39
40
|
width: auto;
|
|
41
|
+
|
|
42
|
+
&:not(.tw-money-input__fixed-currency):not(:has(~ .tw-money-input__fixed-currency)) {
|
|
43
|
+
.padding(right, 0) !important;
|
|
44
|
+
}
|
|
40
45
|
}
|
|
41
46
|
}
|
|
42
47
|
|
|
@@ -91,26 +91,26 @@
|
|
|
91
91
|
background-color: var(--color-sentiment-positive-secondary-active);
|
|
92
92
|
}
|
|
93
93
|
.wds-inline-prompt--proposition {
|
|
94
|
-
background-color:
|
|
95
|
-
color: var(--color-
|
|
94
|
+
background-color: #D2F9F7;
|
|
95
|
+
color: var(--color-interactive-primary);
|
|
96
96
|
}
|
|
97
97
|
.wds-inline-prompt--proposition a,
|
|
98
98
|
.wds-inline-prompt--proposition button {
|
|
99
|
-
color: var(--color-
|
|
99
|
+
color: var(--color-interactive-primary);
|
|
100
100
|
}
|
|
101
101
|
.wds-inline-prompt--proposition a:hover,
|
|
102
102
|
.wds-inline-prompt--proposition button:hover {
|
|
103
|
-
color: var(--color-
|
|
103
|
+
color: var(--color-interactive-primary-hover);
|
|
104
104
|
}
|
|
105
105
|
.wds-inline-prompt--proposition a:active,
|
|
106
106
|
.wds-inline-prompt--proposition button:active {
|
|
107
|
-
color: var(--color-
|
|
107
|
+
color: var(--color-interactive-primary-active);
|
|
108
108
|
}
|
|
109
109
|
.wds-inline-prompt.wds-inline-prompt--proposition:has(a, button):hover {
|
|
110
|
-
background-color:
|
|
110
|
+
background-color: #B2F4F3;
|
|
111
111
|
}
|
|
112
112
|
.wds-inline-prompt.wds-inline-prompt--proposition:has(a, button):active {
|
|
113
|
-
background-color:
|
|
113
|
+
background-color: #91F0EE;
|
|
114
114
|
}
|
|
115
115
|
.wds-inline-prompt--neutral {
|
|
116
116
|
background-color: rgba(134,167,189,0.10196);
|
|
@@ -94,26 +94,26 @@
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
&--proposition {
|
|
97
|
-
background-color:
|
|
97
|
+
background-color: #D2F9F7;
|
|
98
98
|
|
|
99
|
-
color: var(--color-
|
|
99
|
+
color: var(--color-interactive-primary);
|
|
100
100
|
|
|
101
101
|
a, button {
|
|
102
|
-
color: var(--color-
|
|
102
|
+
color: var(--color-interactive-primary);
|
|
103
103
|
&:hover {
|
|
104
|
-
color: var(--color-
|
|
104
|
+
color: var(--color-interactive-primary-hover);
|
|
105
105
|
}
|
|
106
106
|
&:active {
|
|
107
|
-
color: var(--color-
|
|
107
|
+
color: var(--color-interactive-primary-active);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
.wds-inline-prompt&:has(a, button) {
|
|
112
112
|
&:hover {
|
|
113
|
-
background-color:
|
|
113
|
+
background-color: #B2F4F3;
|
|
114
114
|
}
|
|
115
115
|
&:active {
|
|
116
|
-
background-color:
|
|
116
|
+
background-color: #91F0EE;
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
}
|
|
@@ -15,6 +15,12 @@ describe('InlinePrompt', () => {
|
|
|
15
15
|
expect(screen.getByText('Hello world')).toBeInTheDocument();
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
+
it('renders with GiftBox icon as default for `proposition` sentiment', () => {
|
|
19
|
+
render(<InlinePrompt {...defaultProps} sentiment="proposition" />);
|
|
20
|
+
expect(screen.getByText('Prompt message')).toBeInTheDocument();
|
|
21
|
+
expect(screen.getByTestId('gift-box-icon')).toBeInTheDocument();
|
|
22
|
+
});
|
|
23
|
+
|
|
18
24
|
describe('renders with each sentiment', () => {
|
|
19
25
|
it.each([Sentiment.POSITIVE, Sentiment.NEUTRAL, Sentiment.NEGATIVE, Sentiment.WARNING])(
|
|
20
26
|
'renders with sentiment %s',
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { lorem10, lorem5 } from '../../test-utils';
|
|
2
|
+
import { InlinePrompt } from './InlinePrompt';
|
|
3
|
+
import { CardWise, Rewards } from '@transferwise/icons';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Internal/InlinePrompt',
|
|
7
|
+
component: InlinePrompt,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const AllVariants = () => {
|
|
11
|
+
return (
|
|
12
|
+
<div
|
|
13
|
+
style={{
|
|
14
|
+
display: 'grid',
|
|
15
|
+
gridAutoFlow: 'row',
|
|
16
|
+
rowGap: 'var(--size-12)',
|
|
17
|
+
justifyItems: 'start',
|
|
18
|
+
width: 'fit-content',
|
|
19
|
+
}}
|
|
20
|
+
>
|
|
21
|
+
<InlinePrompt sentiment="positive">{lorem5}</InlinePrompt>
|
|
22
|
+
<InlinePrompt media={<Rewards />} sentiment="positive">
|
|
23
|
+
{lorem10}
|
|
24
|
+
</InlinePrompt>
|
|
25
|
+
<InlinePrompt sentiment="negative">{lorem5}</InlinePrompt>
|
|
26
|
+
<InlinePrompt sentiment="negative">{lorem10}</InlinePrompt>
|
|
27
|
+
<InlinePrompt sentiment="neutral">{lorem5}</InlinePrompt>
|
|
28
|
+
<InlinePrompt sentiment="neutral">{lorem10}</InlinePrompt>
|
|
29
|
+
<InlinePrompt sentiment="warning">{lorem5}</InlinePrompt>
|
|
30
|
+
<InlinePrompt sentiment="warning">{lorem10}</InlinePrompt>
|
|
31
|
+
<InlinePrompt sentiment="proposition">{lorem5}</InlinePrompt>
|
|
32
|
+
<InlinePrompt sentiment="proposition">{lorem10}</InlinePrompt>
|
|
33
|
+
<InlinePrompt sentiment="proposition" media={<CardWise />}>
|
|
34
|
+
{lorem10}
|
|
35
|
+
</InlinePrompt>
|
|
36
|
+
<InlinePrompt>{lorem5}</InlinePrompt>
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Sentiment } from '../../common';
|
|
2
|
-
import { BackslashCircle } from '@transferwise/icons';
|
|
2
|
+
import { BackslashCircle, GiftBox } from '@transferwise/icons';
|
|
3
3
|
import ProcessIndicator from '../../processIndicator';
|
|
4
4
|
import StatusIcon from '../../statusIcon';
|
|
5
5
|
import { clsx } from 'clsx';
|
|
6
6
|
import Body from '../../body';
|
|
7
7
|
|
|
8
8
|
export type InlinePromptProps = {
|
|
9
|
-
sentiment?:
|
|
9
|
+
sentiment?:
|
|
10
|
+
| `${Sentiment.POSITIVE | Sentiment.NEGATIVE | Sentiment.NEUTRAL | Sentiment.WARNING}`
|
|
11
|
+
| 'proposition';
|
|
10
12
|
loading?: boolean;
|
|
11
13
|
/**
|
|
12
14
|
* Use for short-lived inline prompts to avoid swap of the icon (which is bad UX for short-lived prompts, e.g. when submit form)
|
|
@@ -16,6 +18,7 @@ export type InlinePromptProps = {
|
|
|
16
18
|
className?: string;
|
|
17
19
|
'data-testid'?: string;
|
|
18
20
|
children: React.ReactNode;
|
|
21
|
+
media?: React.ReactNode;
|
|
19
22
|
};
|
|
20
23
|
|
|
21
24
|
export const InlinePrompt = ({
|
|
@@ -24,9 +27,16 @@ export const InlinePrompt = ({
|
|
|
24
27
|
loading = false,
|
|
25
28
|
className,
|
|
26
29
|
children,
|
|
30
|
+
media = null,
|
|
27
31
|
...rest
|
|
28
32
|
}: InlinePromptProps) => {
|
|
29
33
|
const renderMedia = () => {
|
|
34
|
+
if (media && ['proposition', 'positive'].includes(sentiment)) {
|
|
35
|
+
return media;
|
|
36
|
+
}
|
|
37
|
+
if (sentiment === 'proposition') {
|
|
38
|
+
return <GiftBox />;
|
|
39
|
+
}
|
|
30
40
|
if (muted) {
|
|
31
41
|
return <BackslashCircle size={16} data-testid="InlinePrompt_Muted" />;
|
|
32
42
|
}
|
package/src/ssr.spec.tsx
CHANGED
|
@@ -92,6 +92,7 @@ describe('Server side rendering', () => {
|
|
|
92
92
|
// stick all possible properties we might need to render all components in here
|
|
93
93
|
const allProps: Record<string, unknown> = {
|
|
94
94
|
currencies: [],
|
|
95
|
+
currencySelector: { options: [] },
|
|
95
96
|
steps: [],
|
|
96
97
|
stepper: {
|
|
97
98
|
steps: [],
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { userEvent, render, screen, waitFor } from '../test-utils';
|
|
2
|
+
import { userEvent, render, screen, waitFor, fireEvent } from '../test-utils';
|
|
3
3
|
import { Input } from '../inputs/Input';
|
|
4
4
|
import WithDisplayFormat from '.';
|
|
5
5
|
|
|
@@ -22,6 +22,10 @@ describe('InputWithTextFormat (React Testing Library)', () => {
|
|
|
22
22
|
onBlur: jest.fn(),
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
+
beforeEach(() => {
|
|
26
|
+
jest.clearAllMocks();
|
|
27
|
+
});
|
|
28
|
+
|
|
25
29
|
[
|
|
26
30
|
{ value: '123', expectedValue: '12-3', displayPattern: '**-**-**' },
|
|
27
31
|
{ value: '1234', expectedValue: '12-34', displayPattern: '**-**-**' },
|
|
@@ -170,4 +174,27 @@ describe('InputWithTextFormat (React Testing Library)', () => {
|
|
|
170
174
|
|
|
171
175
|
expect(input).toHaveValue('14-5');
|
|
172
176
|
});
|
|
177
|
+
|
|
178
|
+
it('calls onFocus when input is focused', () => {
|
|
179
|
+
const onFocus = jest.fn();
|
|
180
|
+
setup({ ...initialProps, onFocus });
|
|
181
|
+
|
|
182
|
+
const input = screen.getByRole('textbox');
|
|
183
|
+
fireEvent.focus(input);
|
|
184
|
+
|
|
185
|
+
expect(initialProps.onBlur).not.toHaveBeenCalled();
|
|
186
|
+
expect(initialProps.onChange).not.toHaveBeenCalled();
|
|
187
|
+
expect(onFocus).toHaveBeenCalled();
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it('calls onBlur when input is blurred', () => {
|
|
191
|
+
setup(initialProps);
|
|
192
|
+
|
|
193
|
+
const input = screen.getByRole('textbox');
|
|
194
|
+
fireEvent.blur(input);
|
|
195
|
+
|
|
196
|
+
expect(initialProps.onFocus).not.toHaveBeenCalled();
|
|
197
|
+
expect(initialProps.onChange).not.toHaveBeenCalled();
|
|
198
|
+
expect(initialProps.onBlur).toHaveBeenCalled();
|
|
199
|
+
});
|
|
173
200
|
});
|
|
@@ -237,7 +237,6 @@ class WithDisplayFormat<T extends TextElementProps> extends React.Component<
|
|
|
237
237
|
handleOnFocus: React.FocusEventHandler<HTMLTextElement> = (event) => {
|
|
238
238
|
const { displayPattern, onFocus } = this.props;
|
|
239
239
|
if (onFocus) {
|
|
240
|
-
this.handleOnChange(event);
|
|
241
240
|
onFocus(unformatWithPattern(event.target.value, displayPattern));
|
|
242
241
|
}
|
|
243
242
|
};
|