@transferwise/components 0.0.0-experimental-d7e8cfa → 0.0.0-experimental-c6fb370
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/CurrencySelector/CurrencySelector.js +3 -5
- package/build/ExpressiveMoneyInput/CurrencySelector/CurrencySelector.js.map +1 -1
- package/build/ExpressiveMoneyInput/CurrencySelector/CurrencySelector.mjs +3 -5
- package/build/ExpressiveMoneyInput/CurrencySelector/CurrencySelector.mjs.map +1 -1
- package/build/Inputs/SelectInput/TriggerButton/SelectInputTriggerButton.js.map +1 -1
- package/build/Inputs/SelectInput/TriggerButton/SelectInputTriggerButton.mjs.map +1 -1
- package/build/Typeahead/Typeahead.js +27 -53
- package/build/Typeahead/Typeahead.js.map +1 -1
- package/build/Typeahead/Typeahead.messages.js +0 -3
- package/build/Typeahead/Typeahead.messages.js.map +1 -1
- package/build/Typeahead/Typeahead.messages.mjs +0 -3
- package/build/Typeahead/Typeahead.messages.mjs.map +1 -1
- package/build/Typeahead/Typeahead.mjs +27 -53
- package/build/Typeahead/Typeahead.mjs.map +1 -1
- package/build/Typeahead/TypeaheadInput/TypeaheadInput.js +2 -2
- package/build/Typeahead/TypeaheadInput/TypeaheadInput.js.map +1 -1
- package/build/Typeahead/TypeaheadInput/TypeaheadInput.mjs +2 -2
- package/build/Typeahead/TypeaheadInput/TypeaheadInput.mjs.map +1 -1
- package/build/Typeahead/TypeaheadOption/TypeaheadOption.js +1 -3
- package/build/Typeahead/TypeaheadOption/TypeaheadOption.js.map +1 -1
- package/build/Typeahead/TypeaheadOption/TypeaheadOption.mjs +1 -3
- package/build/Typeahead/TypeaheadOption/TypeaheadOption.mjs.map +1 -1
- package/build/i18n/en.json +0 -1
- package/build/i18n/en.json.js +0 -1
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +0 -1
- package/build/i18n/en.json.mjs.map +1 -1
- package/build/main.css +0 -10
- package/build/styles/Typeahead/Typeahead.css +0 -4
- package/build/styles/Typeahead/TypeaheadOption/TypeaheadOption.css +0 -5
- package/build/styles/main.css +0 -10
- package/build/types/ExpressiveMoneyInput/CurrencySelector/CurrencySelector.d.ts +6 -4
- package/build/types/ExpressiveMoneyInput/CurrencySelector/CurrencySelector.d.ts.map +1 -1
- package/build/types/Inputs/SelectInput/TriggerButton/SelectInputTriggerButton.d.ts +1 -1
- package/build/types/Inputs/SelectInput/TriggerButton/SelectInputTriggerButton.d.ts.map +1 -1
- package/build/types/Typeahead/Typeahead.d.ts.map +1 -1
- package/build/types/Typeahead/Typeahead.messages.d.ts +0 -5
- package/build/types/Typeahead/Typeahead.messages.d.ts.map +1 -1
- package/build/types/Typeahead/TypeaheadInput/TypeaheadInput.d.ts.map +1 -1
- package/build/types/Typeahead/TypeaheadOption/TypeaheadOption.d.ts +0 -1
- package/build/types/Typeahead/TypeaheadOption/TypeaheadOption.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts +0 -2
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ExpressiveMoneyInput/CurrencySelector/CurrencySelector.tsx +12 -13
- package/src/Inputs/SelectInput/SelectInput.test.tsx +37 -0
- package/src/Inputs/SelectInput/TriggerButton/SelectInputTriggerButton.tsx +1 -1
- package/src/Typeahead/Typeahead.css +0 -4
- package/src/Typeahead/Typeahead.less +0 -2
- package/src/Typeahead/Typeahead.messages.ts +0 -5
- package/src/Typeahead/Typeahead.test.tsx +3 -80
- package/src/Typeahead/Typeahead.tsx +27 -50
- package/src/Typeahead/TypeaheadInput/TypeaheadInput.tsx +6 -2
- package/src/Typeahead/TypeaheadOption/TypeaheadOption.css +0 -5
- package/src/Typeahead/TypeaheadOption/TypeaheadOption.less +0 -9
- package/src/Typeahead/TypeaheadOption/TypeaheadOption.tsx +2 -4
- package/src/main.css +0 -10
package/build/styles/main.css
CHANGED
|
@@ -34122,10 +34122,6 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
34122
34122
|
.typeahead .dropdown-menu {
|
|
34123
34123
|
max-width: 100%;
|
|
34124
34124
|
width: 100%;
|
|
34125
|
-
scroll-padding-top: 8px;
|
|
34126
|
-
scroll-padding-top: var(--size-8);
|
|
34127
|
-
scroll-padding-bottom: 8px;
|
|
34128
|
-
scroll-padding-bottom: var(--size-8);
|
|
34129
34125
|
}
|
|
34130
34126
|
|
|
34131
34127
|
.np-theme-personal--forest-green .typeahead .dropdown-menu,
|
|
@@ -34352,12 +34348,6 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
34352
34348
|
border-radius: var(--radius-small);
|
|
34353
34349
|
}
|
|
34354
34350
|
|
|
34355
|
-
.dropdown-menu > li.typeahead__option:not(.active):not(.selected) > .dropdown-item:not([disabled]):not(.disabled):hover,
|
|
34356
|
-
.dropdown-menu > li.typeahead__option:not(.active):not(.selected) > .dropdown-item:not([disabled]):not(.disabled):focus,
|
|
34357
|
-
.dropdown-menu > li.typeahead__option:not(.active):not(.selected) > .dropdown-item:not([disabled]):not(.disabled):active {
|
|
34358
|
-
box-shadow: none;
|
|
34359
|
-
}
|
|
34360
|
-
|
|
34361
34351
|
.tw-droppable-lg {
|
|
34362
34352
|
min-height: 346px;
|
|
34363
34353
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AvatarLayoutProps } from '../../AvatarLayout';
|
|
2
|
+
import type { NewButtonProps } from '../../Button';
|
|
2
3
|
import type { CurrencyType, ExpressiveMoneyInputProps } from '../ExpressiveMoneyInput';
|
|
3
|
-
import { type ButtonHTMLAttributes } from 'react';
|
|
4
4
|
export interface CurrencyOption {
|
|
5
5
|
label?: string;
|
|
6
6
|
code: string;
|
|
@@ -23,8 +23,10 @@ export type CurrencySelectorProps = {
|
|
|
23
23
|
resultCount: number;
|
|
24
24
|
}) => void;
|
|
25
25
|
} & Pick<ExpressiveMoneyInputProps, 'currency'>;
|
|
26
|
+
type ButtonInputProps = Omit<Extract<NewButtonProps, {
|
|
27
|
+
as?: 'button';
|
|
28
|
+
}>, 'v2' | 'size' | 'priority' | 'className' | 'href' | 'target'>;
|
|
26
29
|
export declare const CurrencySelector: ({ id, currency, options, labelId, onChange, addons, onOpen, onSearchChange, }: CurrencySelectorProps) => import("react").JSX.Element;
|
|
27
|
-
export declare const ButtonInput: import("react").ForwardRefExoticComponent<
|
|
28
|
-
|
|
29
|
-
} & import("react").RefAttributes<HTMLButtonElement | null>>;
|
|
30
|
+
export declare const ButtonInput: import("react").ForwardRefExoticComponent<ButtonInputProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
31
|
+
export {};
|
|
30
32
|
//# sourceMappingURL=CurrencySelector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAE5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAMnD,OAAO,KAAK,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAUvF,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,qBAAqB,GAAG;IAClC,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,KAAK,gBAAgB,GAAG,IAAI,CAC1B,OAAO,CAAC,cAAc,EAAE;IAAE,EAAE,CAAC,EAAE,QAAQ,CAAA;CAAE,CAAC,EAC1C,IAAI,GAAG,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,MAAM,GAAG,QAAQ,CAC7D,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,+EAS9B,qBAAqB,gCA+FvB,CAAC;AAEF,eAAO,MAAM,WAAW,gHAgBtB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Merge } from '../../../utils';
|
|
2
|
-
export type SelectInputTriggerButtonElementType =
|
|
2
|
+
export type SelectInputTriggerButtonElementType = React.ElementType;
|
|
3
3
|
export type SelectInputTriggerButtonProps<T extends SelectInputTriggerButtonElementType = 'button'> = Merge<React.ComponentPropsWithoutRef<T>, {
|
|
4
4
|
as?: T;
|
|
5
5
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectInputTriggerButton.d.ts","sourceRoot":"","sources":["../../../../../src/Inputs/SelectInput/TriggerButton/SelectInputTriggerButton.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,MAAM,MAAM,mCAAmC,GAAG,
|
|
1
|
+
{"version":3,"file":"SelectInputTriggerButton.d.ts","sourceRoot":"","sources":["../../../../../src/Inputs/SelectInput/TriggerButton/SelectInputTriggerButton.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,MAAM,MAAM,mCAAmC,GAAG,KAAK,CAAC,WAAW,CAAC;AAEpE,MAAM,MAAM,6BAA6B,CACvC,CAAC,SAAS,mCAAmC,GAAG,QAAQ,IACtD,KAAK,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE;IAAE,EAAE,CAAC,EAAE,CAAC,CAAA;CAAE,CAAC,CAAC;AAEzD;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,mCAAmC,GAAG,QAAQ,EAAE,EACjG,EAAkB,EAClB,GAAG,SAAS,EACb,EAAE,6BAA6B,CAAC,CAAC,CAAC,+BAclC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Typeahead.d.ts","sourceRoot":"","sources":["../../../src/Typeahead/Typeahead.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,EAAa,SAAS,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAc,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAG9E,OAAO,EAEL,SAAS,EACT,UAAU,EACV,SAAS,EAIV,MAAM,WAAW,CAAC;AACnB,OAAO,EAAgB,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAU5D,MAAM,MAAM,eAAe,CAAC,CAAC,GAAG,MAAM,IAAI;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,CAAC,CAAC;IACV,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,iBAAiB,CAAC,EAAE,OAAO,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AAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC;IAClD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC;CACtD;wBAsfoF,CAAC,CAAC,EACrF,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,KACrB,KAAK,CAAC,YAAY;AAFvB,wBAEwB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Typeahead.messages.d.ts","sourceRoot":"","sources":["../../../src/Typeahead/Typeahead.messages.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Typeahead.messages.d.ts","sourceRoot":"","sources":["../../../src/Typeahead/Typeahead.messages.ts"],"names":[],"mappings":";;;;;;;AAEA,wBAMG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeaheadInput.d.ts","sourceRoot":"","sources":["../../../../src/Typeahead/TypeaheadInput/TypeaheadInput.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAa,SAAS,EAAE,MAAM,OAAO,CAAC;AAGxD,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAI/D,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;IACxC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,KA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aheadOption.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/C,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI;IACpC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAClC,
|
|
1
|
+
{"version":3,"file":"TypeaheadOption.d.ts","sourceRoot":"","sources":["../../../../src/Typeahead/TypeaheadOption/TypeaheadOption.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/C,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI;IACpC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,QAAA,MAAM,MAAM,qHA2BV,CAAC;AAEH,eAAe,MAAM,CAAC"}
|
|
@@ -56,7 +56,6 @@ declare function customRender(ui: ReactElement, { locale, messages, ...renderOpt
|
|
|
56
56
|
"neptune.Table.loaded": string;
|
|
57
57
|
"neptune.Table.loading": string;
|
|
58
58
|
"neptune.Table.refreshPage": string;
|
|
59
|
-
"neptune.Typeahead.suggestionsLabel": string;
|
|
60
59
|
"neptune.Upload.csButtonText": string;
|
|
61
60
|
"neptune.Upload.csFailureText": string;
|
|
62
61
|
"neptune.Upload.csSuccessText": string;
|
|
@@ -145,7 +144,6 @@ declare function customRenderHook(callback: () => unknown, { locale, messages }?
|
|
|
145
144
|
"neptune.Table.loaded": string;
|
|
146
145
|
"neptune.Table.loading": string;
|
|
147
146
|
"neptune.Table.refreshPage": string;
|
|
148
|
-
"neptune.Typeahead.suggestionsLabel": string;
|
|
149
147
|
"neptune.Upload.csButtonText": string;
|
|
150
148
|
"neptune.Upload.csFailureText": string;
|
|
151
149
|
"neptune.Upload.csSuccessText": 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;AAC5D,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
|
|
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;AAC5D,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,eAAe,CAAC;AAC9B,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,gBAAgB,IAAI,UAAU,EAAE,SAAS,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AvatarLayoutProps } from '../../AvatarLayout';
|
|
2
2
|
import Button from '../../Button';
|
|
3
|
+
import type { NewButtonProps } from '../../Button';
|
|
3
4
|
import {
|
|
4
5
|
SelectInput,
|
|
5
6
|
SelectInputOptionContent,
|
|
@@ -8,13 +9,7 @@ import {
|
|
|
8
9
|
import type { CurrencyType, ExpressiveMoneyInputProps } from '../ExpressiveMoneyInput';
|
|
9
10
|
import { ChevronDown } from '@transferwise/icons';
|
|
10
11
|
import { Flag } from '@wise/art';
|
|
11
|
-
import {
|
|
12
|
-
type ButtonHTMLAttributes,
|
|
13
|
-
forwardRef,
|
|
14
|
-
type MouseEventHandler,
|
|
15
|
-
useMemo,
|
|
16
|
-
useState,
|
|
17
|
-
} from 'react';
|
|
12
|
+
import { forwardRef, type MouseEventHandler, useMemo, useState } from 'react';
|
|
18
13
|
import { useIntl } from 'react-intl';
|
|
19
14
|
|
|
20
15
|
import messages from '../ExpressiveMoneyInput.messages';
|
|
@@ -44,6 +39,11 @@ export type CurrencySelectorProps = {
|
|
|
44
39
|
onSearchChange?: (payload: { query: string; resultCount: number }) => void;
|
|
45
40
|
} & Pick<ExpressiveMoneyInputProps, 'currency'>;
|
|
46
41
|
|
|
42
|
+
type ButtonInputProps = Omit<
|
|
43
|
+
Extract<NewButtonProps, { as?: 'button' }>,
|
|
44
|
+
'v2' | 'size' | 'priority' | 'className' | 'href' | 'target'
|
|
45
|
+
>;
|
|
46
|
+
|
|
47
47
|
export const CurrencySelector = ({
|
|
48
48
|
id,
|
|
49
49
|
currency,
|
|
@@ -109,7 +109,6 @@ export const CurrencySelector = ({
|
|
|
109
109
|
renderTrigger={() => (
|
|
110
110
|
<SelectInputTriggerButton
|
|
111
111
|
as={ButtonInput}
|
|
112
|
-
// @ts-expect-error new (v2) ButtonProps
|
|
113
112
|
addonStart={{
|
|
114
113
|
type: 'avatar',
|
|
115
114
|
value: [
|
|
@@ -122,11 +121,11 @@ export const CurrencySelector = ({
|
|
|
122
121
|
}),
|
|
123
122
|
},
|
|
124
123
|
]
|
|
125
|
-
.filter(
|
|
124
|
+
.filter((avatar): avatar is NonNullable<typeof avatar> => avatar != null)
|
|
126
125
|
.filter((avatar) => !(avatar && Object.keys(avatar).length === 0)),
|
|
127
126
|
}}
|
|
128
127
|
addonEnd={disabled ? undefined : { type: 'icon', value: <ChevronDown /> }}
|
|
129
|
-
onClick={
|
|
128
|
+
onClick={handleTriggerClick}
|
|
130
129
|
>
|
|
131
130
|
<>
|
|
132
131
|
<span aria-hidden>{formatCurrencyCode(currency)}</span>
|
|
@@ -151,9 +150,9 @@ export const CurrencySelector = ({
|
|
|
151
150
|
);
|
|
152
151
|
};
|
|
153
152
|
|
|
154
|
-
export const ButtonInput = forwardRef(function ButtonInput(
|
|
155
|
-
{ children, ...rest }
|
|
156
|
-
ref
|
|
153
|
+
export const ButtonInput = forwardRef<HTMLButtonElement, ButtonInputProps>(function ButtonInput(
|
|
154
|
+
{ children, ...rest },
|
|
155
|
+
ref,
|
|
157
156
|
) {
|
|
158
157
|
return (
|
|
159
158
|
<Button
|
|
@@ -7,9 +7,12 @@ import { render, mockMatchMedia, mockResizeObserver } from '../../test-utils';
|
|
|
7
7
|
import {
|
|
8
8
|
SelectInput,
|
|
9
9
|
SelectInputOptionContent,
|
|
10
|
+
SelectInputTriggerButton,
|
|
10
11
|
type SelectInputOptionItem,
|
|
11
12
|
type SelectInputProps,
|
|
12
13
|
} from '.';
|
|
14
|
+
import Button from '../../Button';
|
|
15
|
+
import type { ButtonProps as ResolverButtonProps } from '../../Button/Button.resolver';
|
|
13
16
|
import Field from '../../Field';
|
|
14
17
|
|
|
15
18
|
mockMatchMedia();
|
|
@@ -337,6 +340,40 @@ describe('SelectInput', () => {
|
|
|
337
340
|
expect(screen.getByLabelText(/Currency/)).toHaveAttribute('aria-haspopup');
|
|
338
341
|
});
|
|
339
342
|
|
|
343
|
+
it('renders addonStart and addonEnd when using trigger as Button', () => {
|
|
344
|
+
type V2ButtonProps = Extract<ResolverButtonProps, { v2: true }>;
|
|
345
|
+
|
|
346
|
+
render(
|
|
347
|
+
<SelectInput
|
|
348
|
+
items={[{ type: 'option', value: 'USD' }]}
|
|
349
|
+
renderTrigger={({ content, className, size }) => {
|
|
350
|
+
const triggerButtonProps: V2ButtonProps = {
|
|
351
|
+
v2: true,
|
|
352
|
+
size,
|
|
353
|
+
className,
|
|
354
|
+
addonStart: {
|
|
355
|
+
type: 'icon',
|
|
356
|
+
value: <span data-testid="select-trigger-addon-start">Start</span>,
|
|
357
|
+
},
|
|
358
|
+
addonEnd: {
|
|
359
|
+
type: 'icon',
|
|
360
|
+
value: <span data-testid="select-trigger-addon-end">End</span>,
|
|
361
|
+
},
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
return (
|
|
365
|
+
<SelectInputTriggerButton as={Button} {...triggerButtonProps}>
|
|
366
|
+
{content}
|
|
367
|
+
</SelectInputTriggerButton>
|
|
368
|
+
);
|
|
369
|
+
}}
|
|
370
|
+
/>,
|
|
371
|
+
);
|
|
372
|
+
|
|
373
|
+
expect(screen.getByTestId('select-trigger-addon-start')).toBeInTheDocument();
|
|
374
|
+
expect(screen.getByTestId('select-trigger-addon-end')).toBeInTheDocument();
|
|
375
|
+
});
|
|
376
|
+
|
|
340
377
|
it('deduplicates search results across groups using compareValues as key', async () => {
|
|
341
378
|
interface Currency {
|
|
342
379
|
code: string;
|
|
@@ -5,7 +5,7 @@ import { PolymorphicWithOverrides } from '../../../common/PolymorphicWithOverrid
|
|
|
5
5
|
import { Merge } from '../../../utils';
|
|
6
6
|
import { SelectInputTriggerButtonPropsContext } from '../SelectInput.contexts';
|
|
7
7
|
|
|
8
|
-
export type SelectInputTriggerButtonElementType =
|
|
8
|
+
export type SelectInputTriggerButtonElementType = React.ElementType;
|
|
9
9
|
|
|
10
10
|
export type SelectInputTriggerButtonProps<
|
|
11
11
|
T extends SelectInputTriggerButtonElementType = 'button',
|
|
@@ -7,10 +7,6 @@
|
|
|
7
7
|
.typeahead .dropdown-menu {
|
|
8
8
|
max-width: 100%;
|
|
9
9
|
width: 100%;
|
|
10
|
-
scroll-padding-top: 8px;
|
|
11
|
-
scroll-padding-top: var(--size-8);
|
|
12
|
-
scroll-padding-bottom: 8px;
|
|
13
|
-
scroll-padding-bottom: var(--size-8);
|
|
14
10
|
}
|
|
15
11
|
.np-theme-personal--forest-green .typeahead .dropdown-menu,
|
|
16
12
|
.np-theme-personal--bright-green .typeahead .dropdown-menu,
|
|
@@ -6,9 +6,4 @@ export default defineMessages({
|
|
|
6
6
|
defaultMessage: 'Clear',
|
|
7
7
|
description: 'Description of clear button',
|
|
8
8
|
},
|
|
9
|
-
suggestionsLabel: {
|
|
10
|
-
id: 'neptune.Typeahead.suggestionsLabel',
|
|
11
|
-
defaultMessage: 'Suggestions',
|
|
12
|
-
description: 'Accessible label for the list of typeahead suggestions',
|
|
13
|
-
},
|
|
14
9
|
});
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
import Field from '../Field';
|
|
2
|
-
import { mockMatchMedia, render, screen, fireEvent
|
|
2
|
+
import { mockMatchMedia, render, screen, fireEvent } from '../test-utils';
|
|
3
3
|
import { wait } from '../test-utils/wait';
|
|
4
4
|
import Typeahead from './Typeahead';
|
|
5
5
|
|
|
6
6
|
mockMatchMedia();
|
|
7
7
|
|
|
8
|
-
const scrollIntoView = jest.fn();
|
|
9
|
-
|
|
10
8
|
describe('Typeahead', () => {
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
HTMLElement.prototype.scrollIntoView = scrollIntoView;
|
|
13
|
-
scrollIntoView.mockClear();
|
|
14
|
-
});
|
|
15
|
-
|
|
16
9
|
it('supports `Field` for labeling', () => {
|
|
17
10
|
render(
|
|
18
11
|
<Field id="test" label="Tags">
|
|
@@ -29,7 +22,7 @@ describe('Typeahead', () => {
|
|
|
29
22
|
<Typeahead id="test" name="test" options={[]} onChange={() => {}} />
|
|
30
23
|
</Field>,
|
|
31
24
|
);
|
|
32
|
-
expect(screen.queryByRole('
|
|
25
|
+
expect(screen.queryByRole('menu')).not.toBeInTheDocument();
|
|
33
26
|
});
|
|
34
27
|
it('does render a dropdown when only a footer is provided', () => {
|
|
35
28
|
render(
|
|
@@ -37,7 +30,7 @@ describe('Typeahead', () => {
|
|
|
37
30
|
<Typeahead id="test" name="test" options={[]} footer={<p>hello</p>} onChange={() => {}} />
|
|
38
31
|
</Field>,
|
|
39
32
|
);
|
|
40
|
-
expect(screen.getByRole('
|
|
33
|
+
expect(screen.getByRole('menu')).toBeInTheDocument();
|
|
41
34
|
});
|
|
42
35
|
});
|
|
43
36
|
|
|
@@ -81,76 +74,6 @@ describe('Typeahead', () => {
|
|
|
81
74
|
expect(onChange).toHaveBeenCalled();
|
|
82
75
|
});
|
|
83
76
|
|
|
84
|
-
it('scrolls options into view when navigating with arrow keys', async () => {
|
|
85
|
-
render(
|
|
86
|
-
<Typeahead
|
|
87
|
-
id="test"
|
|
88
|
-
name="test"
|
|
89
|
-
options={[{ label: 'Option 1' }, { label: 'Option 2' }]}
|
|
90
|
-
minQueryLength={0}
|
|
91
|
-
onChange={() => {}}
|
|
92
|
-
/>,
|
|
93
|
-
);
|
|
94
|
-
const input = screen.getByRole('combobox');
|
|
95
|
-
|
|
96
|
-
await userEvent.click(input);
|
|
97
|
-
await userEvent.keyboard('{ArrowDown}{ArrowDown}');
|
|
98
|
-
|
|
99
|
-
expect(input).toHaveFocus();
|
|
100
|
-
expect(scrollIntoView).toHaveBeenCalledTimes(2);
|
|
101
|
-
expect(scrollIntoView).toHaveBeenNthCalledWith(1, { block: 'nearest' });
|
|
102
|
-
expect(scrollIntoView).toHaveBeenNthCalledWith(2, { block: 'nearest' });
|
|
103
|
-
expect(scrollIntoView.mock.contexts[0]).toBe(screen.getByText('Option 1').closest('li'));
|
|
104
|
-
expect(scrollIntoView.mock.contexts[1]).toBe(screen.getByText('Option 2').closest('li'));
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it('uses one Tab stop for the suggestions', async () => {
|
|
108
|
-
render(
|
|
109
|
-
<>
|
|
110
|
-
<Typeahead
|
|
111
|
-
id="test"
|
|
112
|
-
name="test"
|
|
113
|
-
options={[{ label: 'Option 1' }, { label: 'Option 2' }]}
|
|
114
|
-
minQueryLength={0}
|
|
115
|
-
onChange={() => {}}
|
|
116
|
-
/>
|
|
117
|
-
<button type="button">Next control</button>
|
|
118
|
-
</>,
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
const input = screen.getByRole('combobox');
|
|
122
|
-
await userEvent.click(input);
|
|
123
|
-
await userEvent.tab();
|
|
124
|
-
|
|
125
|
-
expect(screen.getByRole('listbox')).toHaveFocus();
|
|
126
|
-
await userEvent.keyboard('{ArrowDown}');
|
|
127
|
-
expect(screen.getByRole('option', { name: 'Option 1' })).toHaveClass(
|
|
128
|
-
'tw-dropdown-item--focused',
|
|
129
|
-
);
|
|
130
|
-
expect(screen.getByRole('listbox')).toHaveFocus();
|
|
131
|
-
await userEvent.tab();
|
|
132
|
-
expect(screen.getByRole('button', { name: 'Next control' })).toHaveFocus();
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it('uses the active option style when hovering a suggestion', async () => {
|
|
136
|
-
render(
|
|
137
|
-
<Typeahead
|
|
138
|
-
id="test"
|
|
139
|
-
name="test"
|
|
140
|
-
options={[{ label: 'Option 1' }, { label: 'Option 2' }]}
|
|
141
|
-
minQueryLength={0}
|
|
142
|
-
onChange={() => {}}
|
|
143
|
-
/>,
|
|
144
|
-
);
|
|
145
|
-
|
|
146
|
-
await userEvent.click(screen.getByRole('combobox'));
|
|
147
|
-
await userEvent.hover(screen.getByRole('option', { name: 'Option 2' }));
|
|
148
|
-
|
|
149
|
-
expect(screen.getByRole('option', { name: 'Option 2' })).toHaveClass(
|
|
150
|
-
'tw-dropdown-item--focused',
|
|
151
|
-
);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
77
|
it('shows clear button when there is a value', () => {
|
|
155
78
|
render(
|
|
156
79
|
<Typeahead
|
|
@@ -216,15 +216,31 @@ class Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, Typea
|
|
|
216
216
|
};
|
|
217
217
|
|
|
218
218
|
handleOnKeyDown: React.KeyboardEventHandler<HTMLInputElement> = (event) => {
|
|
219
|
-
const { showSuggestions, allowNew, multiple, chipSeparators } = this.props;
|
|
220
|
-
const { query, selected } = this.state;
|
|
219
|
+
const { showSuggestions, allowNew, multiple, chipSeparators, options } = this.props;
|
|
220
|
+
const { keyboardFocusedOptionIndex, query, selected } = this.state;
|
|
221
221
|
const chipsMode = !showSuggestions && allowNew && multiple;
|
|
222
222
|
|
|
223
223
|
if (chipsMode && ['Enter', 'Tab', ...chipSeparators].includes(event.key) && query.trim()) {
|
|
224
224
|
event.preventDefault();
|
|
225
225
|
this.selectItem({ label: query });
|
|
226
|
-
} else
|
|
226
|
+
} else {
|
|
227
227
|
switch (event.key) {
|
|
228
|
+
case 'ArrowDown':
|
|
229
|
+
event.preventDefault();
|
|
230
|
+
this.moveFocusedOption(1);
|
|
231
|
+
break;
|
|
232
|
+
case 'ArrowUp':
|
|
233
|
+
event.preventDefault();
|
|
234
|
+
this.moveFocusedOption(-1);
|
|
235
|
+
break;
|
|
236
|
+
case 'Enter':
|
|
237
|
+
event.preventDefault();
|
|
238
|
+
if (keyboardFocusedOptionIndex != null && options[keyboardFocusedOptionIndex]) {
|
|
239
|
+
this.selectItem(options[keyboardFocusedOptionIndex]);
|
|
240
|
+
} else if (allowNew && query.trim()) {
|
|
241
|
+
this.selectItem({ label: query });
|
|
242
|
+
}
|
|
243
|
+
break;
|
|
228
244
|
case 'Backspace':
|
|
229
245
|
if (multiple && !query && selected.length > 0) {
|
|
230
246
|
this.updateSelectedValue(selected.slice(0, -1));
|
|
@@ -235,36 +251,6 @@ class Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, Typea
|
|
|
235
251
|
}
|
|
236
252
|
}
|
|
237
253
|
};
|
|
238
|
-
|
|
239
|
-
handleOptionListKeyDown: React.KeyboardEventHandler<HTMLUListElement> = (event) => {
|
|
240
|
-
this.handleOptionNavigation(event);
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
handleOptionNavigation(event: React.KeyboardEvent<HTMLElement>) {
|
|
244
|
-
const { allowNew, options } = this.props;
|
|
245
|
-
const { keyboardFocusedOptionIndex, query } = this.state;
|
|
246
|
-
|
|
247
|
-
switch (event.key) {
|
|
248
|
-
case 'ArrowDown':
|
|
249
|
-
event.preventDefault();
|
|
250
|
-
this.moveFocusedOption(1);
|
|
251
|
-
return true;
|
|
252
|
-
case 'ArrowUp':
|
|
253
|
-
event.preventDefault();
|
|
254
|
-
this.moveFocusedOption(-1);
|
|
255
|
-
return true;
|
|
256
|
-
case 'Enter':
|
|
257
|
-
event.preventDefault();
|
|
258
|
-
if (keyboardFocusedOptionIndex != null && options[keyboardFocusedOptionIndex]) {
|
|
259
|
-
this.selectItem(options[keyboardFocusedOptionIndex]);
|
|
260
|
-
} else if (allowNew && query.trim()) {
|
|
261
|
-
this.selectItem({ label: query });
|
|
262
|
-
}
|
|
263
|
-
return true;
|
|
264
|
-
default:
|
|
265
|
-
return false;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
254
|
moveFocusedOption(offset: number) {
|
|
269
255
|
this.setState((previousState) => {
|
|
270
256
|
const { keyboardFocusedOptionIndex } = previousState;
|
|
@@ -275,7 +261,7 @@ class Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, Typea
|
|
|
275
261
|
}
|
|
276
262
|
const optionRef = this.optionRefs[index];
|
|
277
263
|
if (optionRef?.current) {
|
|
278
|
-
optionRef.current.
|
|
264
|
+
optionRef.current.focus(); // Set focus on the option element
|
|
279
265
|
}
|
|
280
266
|
return {
|
|
281
267
|
keyboardFocusedOptionIndex: index,
|
|
@@ -283,10 +269,6 @@ class Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, Typea
|
|
|
283
269
|
});
|
|
284
270
|
}
|
|
285
271
|
|
|
286
|
-
setFocusedOption = (index: number) => {
|
|
287
|
-
this.setState({ keyboardFocusedOptionIndex: index });
|
|
288
|
-
};
|
|
289
|
-
|
|
290
272
|
selectItem = (item: TypeaheadOption<T>) => {
|
|
291
273
|
const { multiple } = this.props;
|
|
292
274
|
let selected = [...this.state.selected];
|
|
@@ -441,16 +423,12 @@ class Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, Typea
|
|
|
441
423
|
});
|
|
442
424
|
}
|
|
443
425
|
return (
|
|
444
|
-
<div
|
|
426
|
+
<div
|
|
427
|
+
className={clsx('dropdown btn-group btn-block', { open: dropdownOpen })}
|
|
428
|
+
id={`menu-${id}`}
|
|
429
|
+
>
|
|
445
430
|
{(!!optionsToRender.length || footer) && (
|
|
446
|
-
<ul
|
|
447
|
-
className="dropdown-menu"
|
|
448
|
-
id={`menu-${id}`}
|
|
449
|
-
role="listbox"
|
|
450
|
-
aria-label={this.props?.intl?.formatMessage(messages.suggestionsLabel)}
|
|
451
|
-
tabIndex={0}
|
|
452
|
-
onKeyDown={this.handleOptionListKeyDown}
|
|
453
|
-
>
|
|
431
|
+
<ul className="dropdown-menu" role="menu">
|
|
454
432
|
{optionsToRender.map((option, idx) => {
|
|
455
433
|
const ref = React.createRef<HTMLLIElement>();
|
|
456
434
|
this.optionRefs[idx] = ref;
|
|
@@ -461,8 +439,7 @@ class Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, Typea
|
|
|
461
439
|
query={query}
|
|
462
440
|
option={option}
|
|
463
441
|
selected={keyboardFocusedOptionIndex === idx}
|
|
464
|
-
id={
|
|
465
|
-
onMouseEnter={() => this.setFocusedOption(idx)}
|
|
442
|
+
id={String(option.label.replace(/\s+/g, '-'))}
|
|
466
443
|
onClick={(event) => {
|
|
467
444
|
this.onOptionSelected(event, option);
|
|
468
445
|
}}
|
|
@@ -577,7 +554,7 @@ class Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, Typea
|
|
|
577
554
|
autoComplete={inputAutoComplete}
|
|
578
555
|
ariaActivedescendant={
|
|
579
556
|
keyboardFocusedOptionIndex !== null && options[keyboardFocusedOptionIndex]
|
|
580
|
-
? `option-${
|
|
557
|
+
? `option-${options[keyboardFocusedOptionIndex].label.replace(/\s+/g, '-')}`
|
|
581
558
|
: undefined
|
|
582
559
|
}
|
|
583
560
|
onChange={this.handleOnChange}
|
|
@@ -82,7 +82,7 @@ export default class TypeaheadInput<T> extends Component<
|
|
|
82
82
|
onFocus,
|
|
83
83
|
onPaste,
|
|
84
84
|
autoComplete,
|
|
85
|
-
ariaActivedescendant,
|
|
85
|
+
ariaActivedescendant, // Declare the ariaActivedescendant variable
|
|
86
86
|
} = this.props;
|
|
87
87
|
const { inputWidth } = this.state;
|
|
88
88
|
|
|
@@ -93,7 +93,11 @@ export default class TypeaheadInput<T> extends Component<
|
|
|
93
93
|
className={clsx(multiple && 'typeahead__input')}
|
|
94
94
|
name={name}
|
|
95
95
|
id={`input-${typeaheadId}`}
|
|
96
|
-
aria-activedescendant={
|
|
96
|
+
aria-activedescendant={
|
|
97
|
+
ariaActivedescendant
|
|
98
|
+
? `menu-${typeaheadId} ${ariaActivedescendant}`
|
|
99
|
+
: `menu-${typeaheadId}`
|
|
100
|
+
}
|
|
97
101
|
autoFocus={autoFocus}
|
|
98
102
|
placeholder={hasPlaceholder ? placeholder : ''}
|
|
99
103
|
aria-autocomplete="list"
|
|
@@ -7,8 +7,3 @@
|
|
|
7
7
|
border-radius: 10px;
|
|
8
8
|
border-radius: var(--radius-small);
|
|
9
9
|
}
|
|
10
|
-
.dropdown-menu > li.typeahead__option:not(.active):not(.selected) > .dropdown-item:not([disabled]):not(.disabled):hover,
|
|
11
|
-
.dropdown-menu > li.typeahead__option:not(.active):not(.selected) > .dropdown-item:not([disabled]):not(.disabled):focus,
|
|
12
|
-
.dropdown-menu > li.typeahead__option:not(.active):not(.selected) > .dropdown-item:not([disabled]):not(.disabled):active {
|
|
13
|
-
box-shadow: none;
|
|
14
|
-
}
|
|
@@ -8,13 +8,12 @@ export type TypeaheadOptionProps<T> = {
|
|
|
8
8
|
option: TypeaheadOption<T>;
|
|
9
9
|
selected?: boolean;
|
|
10
10
|
onClick?: React.MouseEventHandler;
|
|
11
|
-
onMouseEnter?: React.MouseEventHandler;
|
|
12
11
|
query?: string;
|
|
13
12
|
id?: string;
|
|
14
13
|
};
|
|
15
14
|
|
|
16
15
|
const Option = forwardRef<HTMLLIElement, TypeaheadOptionProps<any>>((props, ref) => {
|
|
17
|
-
const { option, selected = false, onClick = () => {},
|
|
16
|
+
const { option, selected = false, onClick = () => {}, query = '', id } = props;
|
|
18
17
|
const { label, note, secondary } = option;
|
|
19
18
|
|
|
20
19
|
return (
|
|
@@ -26,9 +25,8 @@ const Option = forwardRef<HTMLLIElement, TypeaheadOptionProps<any>>((props, ref)
|
|
|
26
25
|
className={clsx('typeahead__option tw-dropdown-item clickable', {
|
|
27
26
|
'tw-dropdown-item--focused': selected,
|
|
28
27
|
})}
|
|
29
|
-
onMouseEnter={onMouseEnter}
|
|
30
28
|
>
|
|
31
|
-
<a className="dropdown-item" href="#" tabIndex={
|
|
29
|
+
<a className="dropdown-item" href="#" tabIndex={0} onClick={onClick}>
|
|
32
30
|
<Highlight value={label} query={query} />
|
|
33
31
|
{note && <span className="np-text-body-default m-l-1">{note}</span>}
|
|
34
32
|
{secondary && (
|