@transferwise/components 46.17.3 → 46.18.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/index.esm.js +12 -5
- package/build/index.esm.js.map +1 -1
- package/build/index.js +12 -5
- package/build/index.js.map +1 -1
- package/build/main.css +4 -0
- package/build/styles/instructionsList/InstructionsList.css +4 -0
- package/build/styles/main.css +4 -0
- package/build/types/accordion/Accordion.d.ts +3 -7
- package/build/types/accordion/Accordion.d.ts.map +1 -1
- package/build/types/accordion/index.d.ts +1 -0
- package/build/types/accordion/index.d.ts.map +1 -1
- package/build/types/body/Body.d.ts +1 -1
- package/build/types/dateLookup/DateLookup.d.ts +1 -0
- package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
- package/build/types/index.d.ts +2 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/radioGroup/RadioGroup.d.ts +2 -1
- package/build/types/radioGroup/RadioGroup.d.ts.map +1 -1
- package/build/types/radioGroup/index.d.ts +1 -1
- package/build/types/radioGroup/index.d.ts.map +1 -1
- package/build/types/typeahead/Typeahead.d.ts +3 -1
- package/build/types/typeahead/Typeahead.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/accordion/Accordion.tsx +6 -7
- package/src/accordion/index.ts +1 -0
- package/src/dateLookup/DateLookup.js +2 -0
- package/src/dateLookup/DateLookup.story.js +3 -0
- package/src/dateLookup/DateLookup.view.spec.js +5 -0
- package/src/index.ts +2 -1
- package/src/instructionsList/InstructionsList.css +4 -0
- package/src/instructionsList/InstructionsList.less +5 -0
- package/src/instructionsList/InstructionsList.tsx +3 -3
- package/src/main.css +4 -0
- package/src/radioGroup/RadioGroup.tsx +6 -1
- package/src/radioGroup/index.ts +1 -1
- package/src/typeahead/Typeahead.story.tsx +109 -0
- package/src/typeahead/Typeahead.tsx +12 -3
package/build/main.css
CHANGED
|
@@ -2665,6 +2665,10 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
|
|
|
2665
2665
|
color: var(--color-content-tertiary);
|
|
2666
2666
|
}
|
|
2667
2667
|
.tw-instructions {
|
|
2668
|
+
/* Reset */
|
|
2669
|
+
margin: 0;
|
|
2670
|
+
padding: 0;
|
|
2671
|
+
list-style: none;
|
|
2668
2672
|
display: flex;
|
|
2669
2673
|
flex-direction: column;
|
|
2670
2674
|
}
|
package/build/styles/main.css
CHANGED
|
@@ -2665,6 +2665,10 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
|
|
|
2665
2665
|
color: var(--color-content-tertiary);
|
|
2666
2666
|
}
|
|
2667
2667
|
.tw-instructions {
|
|
2668
|
+
/* Reset */
|
|
2669
|
+
margin: 0;
|
|
2670
|
+
padding: 0;
|
|
2671
|
+
list-style: none;
|
|
2668
2672
|
display: flex;
|
|
2669
2673
|
flex-direction: column;
|
|
2670
2674
|
}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
+
import { AccordionItemProps } from './AccordionItem';
|
|
3
|
+
export type AccordionItem = Pick<AccordionItemProps, 'id' | 'title' | 'subtitle' | 'content' | 'icon'>;
|
|
2
4
|
export interface AccordionProps {
|
|
3
5
|
/** The index of the item that should be open by default. */
|
|
4
6
|
indexOpen?: number;
|
|
5
7
|
/** An array of items to display in the accordion. */
|
|
6
|
-
items: readonly
|
|
7
|
-
id?: string;
|
|
8
|
-
title: React.ReactNode;
|
|
9
|
-
subtitle?: React.ReactNode;
|
|
10
|
-
content: React.ReactNode;
|
|
11
|
-
icon?: React.ReactNode;
|
|
12
|
-
}[];
|
|
8
|
+
items: readonly AccordionItem[];
|
|
13
9
|
/** A callback function that is called when an item is clicked. */
|
|
14
10
|
onClick?: (index: number) => void;
|
|
15
11
|
/** @deprecated */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Accordion.d.ts","sourceRoot":"","sources":["../../../src/accordion/Accordion.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,EAAE,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Accordion.d.ts","sourceRoot":"","sources":["../../../src/accordion/Accordion.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,EAAE,EAAE,MAAM,OAAO,CAAC;AAErC,OAAsB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAEpE,MAAM,MAAM,aAAa,GAAG,IAAI,CAC9B,kBAAkB,EAClB,IAAI,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,GAAG,MAAM,CACjD,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qDAAqD;IACrD,KAAK,EAAE,SAAS,aAAa,EAAE,CAAC;IAChC,kEAAkE;IAClE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,kBAAkB;IAClB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,QAAA,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAkCjC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/accordion/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/accordion/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -8,7 +8,7 @@ declare const Body: import("react").ForwardRefExoticComponent<HTMLAttributes<HTM
|
|
|
8
8
|
/**
|
|
9
9
|
* Default value: `div`
|
|
10
10
|
*/
|
|
11
|
-
as?: "
|
|
11
|
+
as?: "span" | "p" | "div" | undefined;
|
|
12
12
|
} & import("react").RefAttributes<HTMLSpanElement | HTMLParagraphElement | HTMLDivElement>>;
|
|
13
13
|
export default Body;
|
|
14
14
|
//# sourceMappingURL=Body.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateLookup.d.ts","sourceRoot":"","sources":["../../../src/dateLookup/DateLookup.js"],"names":[],"mappings":";AAoBA;IAoBE;;;;;;aAqBC;IApCD,wBAaC;IAjBD,wCAAsB;IAEtB,yCAAuB;IAIrB;;;;;;;;;;MAUC;IA0BH,6CAMC;IAFC,uCAAyE;IAI3E,6BAGC;IAED,iBAOE;IAEF,oBAME;IAEF,kBAME;IAEF,oCA6CE;IAEF,wEAmBE;IAEF,+DAOE;IAEF,gCAIE;IAEF,yBAA+C;IAE/C,2BAAmD;IAEnD,0BAAiD;IAEjD,sDAME;IAEF;;;eAEE;IAEF,+CA8BE;IAEF,wBAGE;IAEF,
|
|
1
|
+
{"version":3,"file":"DateLookup.d.ts","sourceRoot":"","sources":["../../../src/dateLookup/DateLookup.js"],"names":[],"mappings":";AAoBA;IAoBE;;;;;;aAqBC;IApCD,wBAaC;IAjBD,wCAAsB;IAEtB,yCAAuB;IAIrB;;;;;;;;;;MAUC;IA0BH,6CAMC;IAFC,uCAAyE;IAI3E,6BAGC;IAED,iBAOE;IAEF,oBAME;IAEF,kBAME;IAEF,oCA6CE;IAEF,wEAmBE;IAEF,+DAOE;IAEF,gCAIE;IAEF,yBAA+C;IAE/C,2BAAmD;IAEnD,0BAAiD;IAEjD,sDAME;IAEF;;;eAEE;IAEF,+CA8BE;IAEF,wBAGE;IAEF,sCAqCC;CACF"}
|
package/build/types/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Types
|
|
3
3
|
*/
|
|
4
|
+
export type { AccordionProps, AccordionItem } from './accordion';
|
|
4
5
|
export type { DecisionProps } from './decision/Decision';
|
|
5
6
|
export type { InfoProps } from './info';
|
|
6
7
|
export type { SummaryProps } from './summary';
|
|
@@ -13,7 +14,7 @@ export type { SelectInputGroupItem, SelectInputItem, SelectInputOptionContentPro
|
|
|
13
14
|
export type { TextAreaProps } from './inputs/TextArea';
|
|
14
15
|
export type { PhoneNumberInputProps } from './phoneNumberInput/PhoneNumberInput';
|
|
15
16
|
export type { RadioProps } from './radio';
|
|
16
|
-
export type { RadioGroupProps } from './radioGroup';
|
|
17
|
+
export type { RadioGroupProps, RadioGroupRadio } from './radioGroup';
|
|
17
18
|
export type { RadioOptionProps } from './radioOption';
|
|
18
19
|
export type { SnackbarProps } from './snackbar/Snackbar';
|
|
19
20
|
export type { SnackbarContextType } from './snackbar/SnackbarContext';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,YAAY,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACxC,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,YAAY,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAC5E,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,YAAY,EACV,oBAAoB,EACpB,eAAe,EACf,6BAA6B,EAC7B,qBAAqB,EACrB,gBAAgB,EAChB,wBAAwB,EACxB,6BAA6B,GAC9B,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,YAAY,EAAE,qBAAqB,EAAE,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ACX,QAAQ,EACR,MAAM,EACN,WAAW,EACX,UAAU,EACV,MAAM,EACN,MAAM,EACN,gBAAgB,EAChB,UAAU,EACV,OAAO,GACR,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC;;GAEG;AACH,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,SAAS,EACT,YAAY,EACZ,aAAa,EACb,mBAAmB,GACpB,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,QAAQ,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { RadioProps } from '../radio/Radio';
|
|
3
|
+
export type RadioGroupRadio<T extends string | number = string> = Omit<RadioProps<T>, 'name' | 'checked' | 'onChange' | 'className'>;
|
|
3
4
|
export interface RadioGroupProps<T extends string | number = string> {
|
|
4
5
|
name: string;
|
|
5
|
-
radios: readonly
|
|
6
|
+
radios: readonly RadioGroupRadio<T>[];
|
|
6
7
|
selectedValue?: T;
|
|
7
8
|
onChange: NonNullable<RadioProps<T>['onChange']>;
|
|
8
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.d.ts","sourceRoot":"","sources":["../../../src/radioGroup/RadioGroup.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,
|
|
1
|
+
{"version":3,"file":"RadioGroup.d.ts","sourceRoot":"","sources":["../../../src/radioGroup/RadioGroup.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,IAAI,IAAI,CACpE,UAAU,CAAC,CAAC,CAAC,EACb,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,WAAW,CAC9C,CAAC;AAEF,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM;IACjE,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;IACtC,aAAa,CAAC,EAAE,CAAC,CAAC;IAClB,QAAQ,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;CAClD;AAED,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,KAAK,EAAE,EACpE,IAAI,EACJ,MAAM,EACN,aAAa,EAAE,eAAe,EAC9B,QAAQ,GACT,EAAE,eAAe,CAAC,CAAC,CAAC,sCAqBpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/radioGroup/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/radioGroup/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -8,6 +8,8 @@ export type TypeaheadOption<T = string> = {
|
|
|
8
8
|
note?: string;
|
|
9
9
|
secondary?: string;
|
|
10
10
|
value?: T;
|
|
11
|
+
clearQueryOnSelect?: boolean;
|
|
12
|
+
keepFocusOnSelect?: boolean;
|
|
11
13
|
};
|
|
12
14
|
export interface TypeaheadProps<T> {
|
|
13
15
|
id: string;
|
|
@@ -86,7 +88,7 @@ export default class Typeahead<T> extends Component<TypeaheadProps<T>, Typeahead
|
|
|
86
88
|
clear: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
87
89
|
removeChip: (option: TypeaheadOption<T>) => void;
|
|
88
90
|
renderChip: (option: TypeaheadOption<T>, idx: number) => ReactNode;
|
|
89
|
-
renderMenu: ({ footer, options, id, keyboardFocusedOptionIndex, query, allowNew, showNewEntry, dropdownOpen, }: Pick<TypeaheadProps<T>, "
|
|
91
|
+
renderMenu: ({ footer, options, id, keyboardFocusedOptionIndex, query, allowNew, showNewEntry, dropdownOpen, }: Pick<TypeaheadProps<T>, "footer" | "id" | "options" | "allowNew" | "showNewEntry"> & Pick<TypeaheadState<T>, "query" | "keyboardFocusedOptionIndex"> & {
|
|
90
92
|
dropdownOpen: boolean;
|
|
91
93
|
}) => import("react").JSX.Element;
|
|
92
94
|
render(): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Typeahead.d.ts","sourceRoot":"","sources":["../../../src/typeahead/Typeahead.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAGvC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAG7C,OAAO,EAAE,IAAI,EAAa,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAOnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAG9D,OAAO,eAAe,MAAM,mCAAmC,CAAC;A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,KAAG,SAAS,CAc/D;IAEF,UAAU;sBAWQ,OAAO;sCAkCvB;IAEF,MAAM;CAsGP"}
|
package/package.json
CHANGED
|
@@ -2,17 +2,16 @@ import { useState, FC } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import AccordionItem, { AccordionItemProps } from './AccordionItem';
|
|
4
4
|
|
|
5
|
+
export type AccordionItem = Pick<
|
|
6
|
+
AccordionItemProps,
|
|
7
|
+
'id' | 'title' | 'subtitle' | 'content' | 'icon'
|
|
8
|
+
>;
|
|
9
|
+
|
|
5
10
|
export interface AccordionProps {
|
|
6
11
|
/** The index of the item that should be open by default. */
|
|
7
12
|
indexOpen?: number;
|
|
8
13
|
/** An array of items to display in the accordion. */
|
|
9
|
-
items: readonly
|
|
10
|
-
id?: string;
|
|
11
|
-
title: React.ReactNode;
|
|
12
|
-
subtitle?: React.ReactNode;
|
|
13
|
-
content: React.ReactNode;
|
|
14
|
-
icon?: React.ReactNode;
|
|
15
|
-
}[];
|
|
14
|
+
items: readonly AccordionItem[];
|
|
16
15
|
/** A callback function that is called when an item is clicked. */
|
|
17
16
|
onClick?: (index: number) => void;
|
|
18
17
|
/** @deprecated */
|
package/src/accordion/index.ts
CHANGED
|
@@ -253,6 +253,7 @@ class DateLookup extends PureComponent {
|
|
|
253
253
|
return (
|
|
254
254
|
<div // eslint-disable-line jsx-a11y/no-static-element-interactions
|
|
255
255
|
ref={this.element}
|
|
256
|
+
id={this.props.id}
|
|
256
257
|
aria-labelledby={ariaLabelledBy}
|
|
257
258
|
className="input-group"
|
|
258
259
|
onKeyDown={this.handleKeyDown}
|
|
@@ -277,6 +278,7 @@ class DateLookup extends PureComponent {
|
|
|
277
278
|
}
|
|
278
279
|
|
|
279
280
|
DateLookup.propTypes = {
|
|
281
|
+
id: PropTypes.string,
|
|
280
282
|
value: PropTypes.instanceOf(Date),
|
|
281
283
|
min: PropTypes.instanceOf(Date),
|
|
282
284
|
max: PropTypes.instanceOf(Date),
|
|
@@ -25,12 +25,14 @@ export const Basic = () => {
|
|
|
25
25
|
const monthFormat = select('monthFormat', ['long', 'short']);
|
|
26
26
|
const placeholder = text('placeholder', 'placeholder');
|
|
27
27
|
const size = select('size', Object.values(Size), Size.MEDIUM);
|
|
28
|
+
const id = text('id', 'date-lookup');
|
|
28
29
|
|
|
29
30
|
const clearable = boolean('clearable', false);
|
|
30
31
|
|
|
31
32
|
return (
|
|
32
33
|
<DateLookup
|
|
33
34
|
disabled={disabled}
|
|
35
|
+
id={id}
|
|
34
36
|
label={label}
|
|
35
37
|
min={thePast}
|
|
36
38
|
monthFormat={monthFormat}
|
|
@@ -81,6 +83,7 @@ export const RightAligned = () => {
|
|
|
81
83
|
</div>
|
|
82
84
|
<div className="col-xs-6">
|
|
83
85
|
<DateLookup
|
|
86
|
+
id="right-aligned"
|
|
84
87
|
disabled={disabled}
|
|
85
88
|
label={label}
|
|
86
89
|
min={new Date(minvalue)}
|
|
@@ -37,6 +37,7 @@ describe('DateLookup view', () => {
|
|
|
37
37
|
placeholder: 'Asd..',
|
|
38
38
|
label: 'Date..',
|
|
39
39
|
onChange: jest.fn(),
|
|
40
|
+
id: '123456',
|
|
40
41
|
};
|
|
41
42
|
component = shallow(<DateLookup {...props} />);
|
|
42
43
|
});
|
|
@@ -45,6 +46,10 @@ describe('DateLookup view', () => {
|
|
|
45
46
|
expect(dateTrigger()).toHaveLength(1);
|
|
46
47
|
});
|
|
47
48
|
|
|
49
|
+
it('passes id to the component', () => {
|
|
50
|
+
expect(component.prop('id')).toBe('123456');
|
|
51
|
+
});
|
|
52
|
+
|
|
48
53
|
it('passes props forward to open button', () => {
|
|
49
54
|
expect(+dateTrigger().prop('selectedDate')).toBe(+date);
|
|
50
55
|
expect(dateTrigger().prop('size')).toBe('lg');
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Types
|
|
3
3
|
*/
|
|
4
|
+
export type { AccordionProps, AccordionItem } from './accordion';
|
|
4
5
|
export type { DecisionProps } from './decision/Decision';
|
|
5
6
|
export type { InfoProps } from './info';
|
|
6
7
|
export type { SummaryProps } from './summary';
|
|
@@ -21,7 +22,7 @@ export type {
|
|
|
21
22
|
export type { TextAreaProps } from './inputs/TextArea';
|
|
22
23
|
export type { PhoneNumberInputProps } from './phoneNumberInput/PhoneNumberInput';
|
|
23
24
|
export type { RadioProps } from './radio';
|
|
24
|
-
export type { RadioGroupProps } from './radioGroup';
|
|
25
|
+
export type { RadioGroupProps, RadioGroupRadio } from './radioGroup';
|
|
25
26
|
export type { RadioOptionProps } from './radioOption';
|
|
26
27
|
export type { SnackbarProps } from './snackbar/Snackbar';
|
|
27
28
|
export type { SnackbarContextType } from './snackbar/SnackbarContext';
|
|
@@ -49,14 +49,14 @@ const InstructionsList = ({ dos, donts, sort = 'dosFirst' }: InstructionsListPro
|
|
|
49
49
|
</>
|
|
50
50
|
);
|
|
51
51
|
|
|
52
|
-
return <
|
|
52
|
+
return <ul className="tw-instructions">{orderedInstructions}</ul>;
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
function Instruction({ item, type }: { item: ReactNode | InstructionNode; type: 'do' | 'dont' }) {
|
|
56
56
|
const isInstructionNode =
|
|
57
57
|
typeof item === 'object' && item !== null && 'content' in item && 'aria-label' in item;
|
|
58
58
|
return (
|
|
59
|
-
<
|
|
59
|
+
<li
|
|
60
60
|
className="instruction"
|
|
61
61
|
aria-label={isInstructionNode ? (item['aria-label'] as string) : undefined}
|
|
62
62
|
>
|
|
@@ -68,7 +68,7 @@ function Instruction({ item, type }: { item: ReactNode | InstructionNode; type:
|
|
|
68
68
|
<Body className="text-primary" type={Typography.BODY_LARGE}>
|
|
69
69
|
{isInstructionNode ? item.content : item}
|
|
70
70
|
</Body>
|
|
71
|
-
</
|
|
71
|
+
</li>
|
|
72
72
|
);
|
|
73
73
|
}
|
|
74
74
|
|
package/src/main.css
CHANGED
|
@@ -2665,6 +2665,10 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
|
|
|
2665
2665
|
color: var(--color-content-tertiary);
|
|
2666
2666
|
}
|
|
2667
2667
|
.tw-instructions {
|
|
2668
|
+
/* Reset */
|
|
2669
|
+
margin: 0;
|
|
2670
|
+
padding: 0;
|
|
2671
|
+
list-style: none;
|
|
2668
2672
|
display: flex;
|
|
2669
2673
|
flex-direction: column;
|
|
2670
2674
|
}
|
|
@@ -3,9 +3,14 @@ import { useState } from 'react';
|
|
|
3
3
|
import Radio from '../radio';
|
|
4
4
|
import { RadioProps } from '../radio/Radio';
|
|
5
5
|
|
|
6
|
+
export type RadioGroupRadio<T extends string | number = string> = Omit<
|
|
7
|
+
RadioProps<T>,
|
|
8
|
+
'name' | 'checked' | 'onChange' | 'className'
|
|
9
|
+
>;
|
|
10
|
+
|
|
6
11
|
export interface RadioGroupProps<T extends string | number = string> {
|
|
7
12
|
name: string;
|
|
8
|
-
radios: readonly
|
|
13
|
+
radios: readonly RadioGroupRadio<T>[];
|
|
9
14
|
selectedValue?: T; // TODO: `NoInfer<T>` from TypeScript 5.4
|
|
10
15
|
onChange: NonNullable<RadioProps<T>['onChange']>;
|
|
11
16
|
}
|
package/src/radioGroup/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default } from './RadioGroup';
|
|
2
|
-
export type { RadioGroupProps } from './RadioGroup';
|
|
2
|
+
export type { RadioGroupProps, RadioGroupRadio } from './RadioGroup';
|
|
@@ -5,6 +5,7 @@ import { Search as SearchIcon } from '@transferwise/icons';
|
|
|
5
5
|
import { useState } from 'react';
|
|
6
6
|
|
|
7
7
|
import { Sentiment } from '../common';
|
|
8
|
+
import { Input } from '../inputs/Input';
|
|
8
9
|
|
|
9
10
|
import Typeahead, { type TypeaheadOption } from './Typeahead';
|
|
10
11
|
|
|
@@ -120,3 +121,111 @@ Basic.play = async ({ canvasElement }: StoryContext) => {
|
|
|
120
121
|
const canvas = within(canvasElement);
|
|
121
122
|
await userEvent.type(canvas.getByRole('combobox'), 'abc{ArrowDown}');
|
|
122
123
|
};
|
|
124
|
+
|
|
125
|
+
type Result =
|
|
126
|
+
| {
|
|
127
|
+
type: 'action';
|
|
128
|
+
value: string;
|
|
129
|
+
}
|
|
130
|
+
| {
|
|
131
|
+
type: 'search';
|
|
132
|
+
value: string;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
type SearchState = 'success' | 'idle' | 'error' | 'loading';
|
|
136
|
+
|
|
137
|
+
export const Search = () => {
|
|
138
|
+
const [results, setResults] = useState<Result[]>([]);
|
|
139
|
+
const [state, setState] = useState<SearchState>('idle');
|
|
140
|
+
const [filledValue, setFilledValue] = useState<string | null>(null);
|
|
141
|
+
|
|
142
|
+
const onChange = (query: string) => {
|
|
143
|
+
if (query === 'loading') {
|
|
144
|
+
setState('loading');
|
|
145
|
+
setResults([]);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (query === 'error') {
|
|
149
|
+
setState('error');
|
|
150
|
+
setResults([]);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (query === 'nothing') {
|
|
154
|
+
setState('success');
|
|
155
|
+
setResults([]);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
setState('success');
|
|
160
|
+
setResults(getResults(query));
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const onResultSelected = (option: Result) => {
|
|
164
|
+
if (option.type === 'search') {
|
|
165
|
+
setResults([
|
|
166
|
+
{ type: 'action', value: `${option.value} Result #1` },
|
|
167
|
+
{ type: 'action', value: `${option.value} Result #2` },
|
|
168
|
+
{ type: 'action', value: `${option.value} Result #3` },
|
|
169
|
+
]);
|
|
170
|
+
}
|
|
171
|
+
if (option.type === 'action') {
|
|
172
|
+
setFilledValue(option.value);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const getResults = (query: string): Result[] => {
|
|
177
|
+
return [
|
|
178
|
+
{ type: 'action', value: `${query} Result #1` },
|
|
179
|
+
{ type: 'action', value: `${query} Result #2` },
|
|
180
|
+
{ type: 'action', value: `${query} Result #3` },
|
|
181
|
+
{ type: 'search', value: `Search for more: '${query}'` },
|
|
182
|
+
];
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
return (
|
|
186
|
+
<>
|
|
187
|
+
<Typeahead<Result>
|
|
188
|
+
id="typeahead-input-id"
|
|
189
|
+
name="typeahead-input-name"
|
|
190
|
+
size="md"
|
|
191
|
+
maxHeight={100}
|
|
192
|
+
footer={<SearchFooter options={results} state={state} />}
|
|
193
|
+
multiple={false}
|
|
194
|
+
clearable={false}
|
|
195
|
+
addon={<SearchIcon />}
|
|
196
|
+
options={results.map((option) => ({
|
|
197
|
+
value: option,
|
|
198
|
+
label: option.value,
|
|
199
|
+
keepFocusOnSelect: option.type === 'search',
|
|
200
|
+
clearQueryOnSelect: option.type === 'action',
|
|
201
|
+
}))}
|
|
202
|
+
onChange={(values) => {
|
|
203
|
+
if (values.length > 0) {
|
|
204
|
+
const [updatedValue] = values;
|
|
205
|
+
if (updatedValue.value) {
|
|
206
|
+
onResultSelected(updatedValue.value);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}}
|
|
210
|
+
onInputChange={onChange}
|
|
211
|
+
/>
|
|
212
|
+
{filledValue != null ? <Input value={filledValue} /> : null}
|
|
213
|
+
</>
|
|
214
|
+
);
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
function SearchFooter({ options, state }: { options: Result[]; state: SearchState }) {
|
|
218
|
+
if (state === 'loading') {
|
|
219
|
+
return <p className="m-y-2 m-x-2">Loading...</p>;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (state === 'success' && options.length === 0) {
|
|
223
|
+
return <p className="m-y-2 m-x-2">No results found</p>;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (state === 'error' && options.length === 0) {
|
|
227
|
+
return <div className="m-y-2 m-x-2">Something went wrong</div>;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
@@ -30,6 +30,8 @@ export type TypeaheadOption<T = string> = {
|
|
|
30
30
|
note?: string;
|
|
31
31
|
secondary?: string;
|
|
32
32
|
value?: T;
|
|
33
|
+
clearQueryOnSelect?: boolean;
|
|
34
|
+
keepFocusOnSelect?: boolean;
|
|
33
35
|
};
|
|
34
36
|
|
|
35
37
|
export interface TypeaheadProps<T> {
|
|
@@ -250,7 +252,15 @@ export default class Typeahead<T> extends Component<TypeaheadProps<T>, Typeahead
|
|
|
250
252
|
}
|
|
251
253
|
|
|
252
254
|
this.updateSelectedValue(selected);
|
|
253
|
-
|
|
255
|
+
|
|
256
|
+
if (!item.keepFocusOnSelect) {
|
|
257
|
+
this.hideMenu();
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (item.clearQueryOnSelect) {
|
|
261
|
+
query = '';
|
|
262
|
+
}
|
|
263
|
+
|
|
254
264
|
this.setState({
|
|
255
265
|
query,
|
|
256
266
|
});
|
|
@@ -499,8 +509,7 @@ export default class Typeahead<T> extends Component<TypeaheadProps<T>, Typeahead
|
|
|
499
509
|
</div>
|
|
500
510
|
)}
|
|
501
511
|
</div>
|
|
502
|
-
{displayAlert
|
|
503
|
-
{menu}
|
|
512
|
+
{displayAlert ? <InlineAlert type={alert.type}>{alert.message}</InlineAlert> : menu}
|
|
504
513
|
</div>
|
|
505
514
|
</div>
|
|
506
515
|
);
|