@transferwise/components 0.0.0-experimental-bd2aa28 → 0.0.0-experimental-17d9e6b
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/i18n/cs.json +0 -2
- package/build/i18n/cs.json.js +0 -2
- package/build/i18n/cs.json.js.map +1 -1
- package/build/i18n/cs.json.mjs +0 -2
- package/build/i18n/cs.json.mjs.map +1 -1
- package/build/i18n/de.json +0 -2
- package/build/i18n/de.json.js +0 -2
- package/build/i18n/de.json.js.map +1 -1
- package/build/i18n/de.json.mjs +0 -2
- package/build/i18n/de.json.mjs.map +1 -1
- package/build/i18n/en.json +0 -2
- package/build/i18n/en.json.js +0 -2
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +0 -2
- package/build/i18n/en.json.mjs.map +1 -1
- package/build/i18n/es.json +0 -2
- package/build/i18n/es.json.js +0 -2
- package/build/i18n/es.json.js.map +1 -1
- package/build/i18n/es.json.mjs +0 -2
- package/build/i18n/es.json.mjs.map +1 -1
- package/build/i18n/fr.json +0 -2
- package/build/i18n/fr.json.js +0 -2
- package/build/i18n/fr.json.js.map +1 -1
- package/build/i18n/fr.json.mjs +0 -2
- package/build/i18n/fr.json.mjs.map +1 -1
- package/build/i18n/hu.json +0 -2
- package/build/i18n/hu.json.js +0 -2
- package/build/i18n/hu.json.js.map +1 -1
- package/build/i18n/hu.json.mjs +0 -2
- package/build/i18n/hu.json.mjs.map +1 -1
- package/build/i18n/id.json +0 -2
- package/build/i18n/id.json.js +0 -2
- package/build/i18n/id.json.js.map +1 -1
- package/build/i18n/id.json.mjs +0 -2
- package/build/i18n/id.json.mjs.map +1 -1
- package/build/i18n/it.json +0 -2
- package/build/i18n/it.json.js +0 -2
- package/build/i18n/it.json.js.map +1 -1
- package/build/i18n/it.json.mjs +0 -2
- package/build/i18n/it.json.mjs.map +1 -1
- package/build/i18n/ja.json +0 -2
- package/build/i18n/ja.json.js +0 -2
- package/build/i18n/ja.json.js.map +1 -1
- package/build/i18n/ja.json.mjs +0 -2
- package/build/i18n/ja.json.mjs.map +1 -1
- package/build/i18n/nl.json +0 -2
- package/build/i18n/pl.json +0 -2
- package/build/i18n/pl.json.js +0 -2
- package/build/i18n/pl.json.js.map +1 -1
- package/build/i18n/pl.json.mjs +0 -2
- package/build/i18n/pl.json.mjs.map +1 -1
- package/build/i18n/pt.json +0 -2
- package/build/i18n/pt.json.js +0 -2
- package/build/i18n/pt.json.js.map +1 -1
- package/build/i18n/pt.json.mjs +0 -2
- package/build/i18n/pt.json.mjs.map +1 -1
- package/build/i18n/ro.json +0 -2
- package/build/i18n/ro.json.js +0 -2
- package/build/i18n/ro.json.js.map +1 -1
- package/build/i18n/ro.json.mjs +0 -2
- package/build/i18n/ro.json.mjs.map +1 -1
- package/build/i18n/ru.json +0 -2
- package/build/i18n/ru.json.js +0 -2
- package/build/i18n/ru.json.js.map +1 -1
- package/build/i18n/ru.json.mjs +0 -2
- package/build/i18n/ru.json.mjs.map +1 -1
- package/build/i18n/th.json +0 -2
- package/build/i18n/th.json.js +0 -2
- package/build/i18n/th.json.js.map +1 -1
- package/build/i18n/th.json.mjs +0 -2
- package/build/i18n/th.json.mjs.map +1 -1
- package/build/i18n/tr.json +0 -2
- package/build/i18n/tr.json.js +0 -2
- package/build/i18n/tr.json.js.map +1 -1
- package/build/i18n/tr.json.mjs +0 -2
- package/build/i18n/tr.json.mjs.map +1 -1
- package/build/i18n/zh-CN.json +0 -2
- package/build/i18n/zh-CN.json.js +0 -2
- package/build/i18n/zh-CN.json.js.map +1 -1
- package/build/i18n/zh-CN.json.mjs +0 -2
- package/build/i18n/zh-CN.json.mjs.map +1 -1
- package/build/i18n/zh-HK.json +0 -2
- package/build/i18n/zh-HK.json.js +0 -2
- package/build/i18n/zh-HK.json.js.map +1 -1
- package/build/i18n/zh-HK.json.mjs +0 -2
- package/build/i18n/zh-HK.json.mjs.map +1 -1
- package/build/index.js +0 -3
- package/build/index.js.map +1 -1
- package/build/index.mjs +1 -2
- package/build/index.mjs.map +1 -1
- package/build/main.css +0 -256
- package/build/styles/main.css +0 -256
- package/build/types/index.d.ts +0 -4
- package/build/types/index.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts +0 -4
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/i18n/cs.json +0 -2
- package/src/i18n/de.json +0 -2
- package/src/i18n/en.json +0 -2
- package/src/i18n/es.json +0 -2
- package/src/i18n/fr.json +0 -2
- package/src/i18n/hu.json +0 -2
- package/src/i18n/id.json +0 -2
- package/src/i18n/it.json +0 -2
- package/src/i18n/ja.json +0 -2
- package/src/i18n/nl.json +0 -2
- package/src/i18n/pl.json +0 -2
- package/src/i18n/pt.json +0 -2
- package/src/i18n/ro.json +0 -2
- package/src/i18n/ru.json +0 -2
- package/src/i18n/th.json +0 -2
- package/src/i18n/tr.json +0 -2
- package/src/i18n/zh-CN.json +0 -2
- package/src/i18n/zh-HK.json +0 -2
- package/src/index.ts +0 -4
- package/src/main.css +0 -256
- package/src/main.less +0 -2
- package/src/ssr.spec.tsx +0 -1
- package/build/selectOption/SelectOption.js +0 -131
- package/build/selectOption/SelectOption.js.map +0 -1
- package/build/selectOption/SelectOption.messages.js +0 -17
- package/build/selectOption/SelectOption.messages.js.map +0 -1
- package/build/selectOption/SelectOption.messages.mjs +0 -13
- package/build/selectOption/SelectOption.messages.mjs.map +0 -1
- package/build/selectOption/SelectOption.mjs +0 -127
- package/build/selectOption/SelectOption.mjs.map +0 -1
- package/build/styles/listItem/ListItem.css +0 -212
- package/build/styles/selectOption/SelectOption.css +0 -44
- package/build/types/listItem/ListItem.d.ts +0 -50
- package/build/types/listItem/ListItem.d.ts.map +0 -1
- package/build/types/listItem/ListItemAdditionalInfo.d.ts +0 -9
- package/build/types/listItem/ListItemAdditionalInfo.d.ts.map +0 -1
- package/build/types/listItem/ListItemButton.d.ts +0 -6
- package/build/types/listItem/ListItemButton.d.ts.map +0 -1
- package/build/types/listItem/ListItemCheckbox.d.ts +0 -4
- package/build/types/listItem/ListItemCheckbox.d.ts.map +0 -1
- package/build/types/listItem/ListItemIconButton.d.ts +0 -8
- package/build/types/listItem/ListItemIconButton.d.ts.map +0 -1
- package/build/types/listItem/ListItemMedia.d.ts +0 -19
- package/build/types/listItem/ListItemMedia.d.ts.map +0 -1
- package/build/types/listItem/ListItemNavigation.d.ts +0 -4
- package/build/types/listItem/ListItemNavigation.d.ts.map +0 -1
- package/build/types/listItem/ListItemSwitch.d.ts +0 -3
- package/build/types/listItem/ListItemSwitch.d.ts.map +0 -1
- package/build/types/listItem/index.d.ts +0 -6
- package/build/types/listItem/index.d.ts.map +0 -1
- package/build/types/listItem/prompt/Prompt.d.ts +0 -12
- package/build/types/listItem/prompt/Prompt.d.ts.map +0 -1
- package/build/types/listItem/useItemControl.d.ts +0 -5
- package/build/types/listItem/useItemControl.d.ts.map +0 -1
- package/build/types/selectOption/SelectOption.d.ts +0 -21
- package/build/types/selectOption/SelectOption.d.ts.map +0 -1
- package/build/types/selectOption/SelectOption.messages.d.ts +0 -12
- package/build/types/selectOption/SelectOption.messages.d.ts.map +0 -1
- package/build/types/selectOption/index.d.ts +0 -3
- package/build/types/selectOption/index.d.ts.map +0 -1
- package/src/listItem/ListItem.css +0 -212
- package/src/listItem/ListItem.less +0 -210
- package/src/listItem/ListItem.spec.tsx +0 -35
- package/src/listItem/ListItem.story.tsx +0 -461
- package/src/listItem/ListItem.tsx +0 -282
- package/src/listItem/ListItemAdditionalInfo.tsx +0 -31
- package/src/listItem/ListItemButton.spec.tsx +0 -92
- package/src/listItem/ListItemButton.tsx +0 -24
- package/src/listItem/ListItemCheckbox.tsx +0 -14
- package/src/listItem/ListItemIconButton.tsx +0 -16
- package/src/listItem/ListItemMedia.tsx +0 -52
- package/src/listItem/ListItemNavigation.tsx +0 -23
- package/src/listItem/ListItemSwitch.tsx +0 -8
- package/src/listItem/index.ts +0 -10
- package/src/listItem/prompt/Prompt.spec.tsx +0 -77
- package/src/listItem/prompt/Prompt.story.tsx +0 -170
- package/src/listItem/prompt/Prompt.tsx +0 -44
- package/src/listItem/useItemControl.tsx +0 -23
- package/src/selectOption/SelectOption.css +0 -44
- package/src/selectOption/SelectOption.less +0 -40
- package/src/selectOption/SelectOption.messages.ts +0 -12
- package/src/selectOption/SelectOption.spec.tsx +0 -83
- package/src/selectOption/SelectOption.story.tsx +0 -277
- package/src/selectOption/SelectOption.tsx +0 -151
- package/src/selectOption/index.ts +0 -2
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { useRef, useState } from 'react';
|
|
2
|
-
import { ActionButtonProps } from '../actionButton';
|
|
3
|
-
import { clsx } from 'clsx';
|
|
4
|
-
import Option from '../common/Option';
|
|
5
|
-
import type { OptionProps } from '../common/Option/Option';
|
|
6
|
-
import { Breakpoint, Position } from '../common';
|
|
7
|
-
import Section from '../section';
|
|
8
|
-
import Header from '../header';
|
|
9
|
-
import { HeaderProps } from '../header/Header';
|
|
10
|
-
import NavigationOption from '../navigationOption';
|
|
11
|
-
import NavigationOptionsList from '../navigationOptionsList';
|
|
12
|
-
import { useInputAttributes } from '../inputs/contexts';
|
|
13
|
-
import messages from './SelectOption.messages';
|
|
14
|
-
import { useIntl } from 'react-intl';
|
|
15
|
-
import ResponsivePanel from '../common/responsivePanel';
|
|
16
|
-
import { useScreenSize } from '../common/hooks/useScreenSize';
|
|
17
|
-
import { ChevronDown, Plus } from '@transferwise/icons';
|
|
18
|
-
|
|
19
|
-
export type SelectOptiopsSection<T = unknown> = {
|
|
20
|
-
title?: HeaderProps['title'];
|
|
21
|
-
options: SelectOptionValue<T>[];
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export type SelectOptionValue<T = unknown> = Pick<
|
|
25
|
-
OptionProps,
|
|
26
|
-
'media' | 'title' | 'content' | 'disabled'
|
|
27
|
-
> & {
|
|
28
|
-
value?: T;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export type SelectOptionPlaceholder = Pick<OptionProps, 'media' | 'title' | 'content'> & {
|
|
32
|
-
actionLabel?: ActionButtonProps['children'];
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export type SelectOptionProps<T = unknown> = {
|
|
36
|
-
onChange: (selected: SelectOptionValue<T>) => void;
|
|
37
|
-
selected?: SelectOptionValue<T>;
|
|
38
|
-
options: SelectOptiopsSection<T>[];
|
|
39
|
-
placeholder: SelectOptionPlaceholder;
|
|
40
|
-
} & Omit<
|
|
41
|
-
OptionProps,
|
|
42
|
-
'as' | 'title' | 'media' | 'content' | 'onClick' | 'onChange' | 'showMediaAtAllSizes' | 'decision'
|
|
43
|
-
>;
|
|
44
|
-
|
|
45
|
-
export default function SelectOption<T>({
|
|
46
|
-
selected = undefined,
|
|
47
|
-
options,
|
|
48
|
-
onChange,
|
|
49
|
-
placeholder,
|
|
50
|
-
disabled,
|
|
51
|
-
...props
|
|
52
|
-
}: SelectOptionProps<T>) {
|
|
53
|
-
const intl = useIntl();
|
|
54
|
-
const rootRef = useRef(null);
|
|
55
|
-
const [showOptions, setShowOptions] = useState(false);
|
|
56
|
-
|
|
57
|
-
const hasSelected = selected !== undefined;
|
|
58
|
-
const isLargeScreen = useScreenSize(Breakpoint.SMALL);
|
|
59
|
-
|
|
60
|
-
const inputAttributes = useInputAttributes();
|
|
61
|
-
const ariaLabelledBy = props['aria-labelledby'] ?? inputAttributes?.['aria-labelledby'];
|
|
62
|
-
|
|
63
|
-
function handleOnClick(showOptionsStatus: boolean) {
|
|
64
|
-
return () => {
|
|
65
|
-
setShowOptions(showOptionsStatus);
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function handleOnChange(data: SelectOptionValue<T>) {
|
|
70
|
-
return () => {
|
|
71
|
-
setShowOptions(false);
|
|
72
|
-
onChange(data);
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function getOptions(isLargeScreen = false) {
|
|
77
|
-
return (
|
|
78
|
-
<div className={clsx({ 'np-select-option-list': isLargeScreen })}>
|
|
79
|
-
{options.map((optionsSection, index) => (
|
|
80
|
-
<Section key={index} className={clsx({ 'p-x-2 p-y-1': isLargeScreen })}>
|
|
81
|
-
{optionsSection.title && <Header title={optionsSection.title} />}
|
|
82
|
-
<NavigationOptionsList>
|
|
83
|
-
{optionsSection.options.map((option, index) => {
|
|
84
|
-
return (
|
|
85
|
-
<NavigationOption
|
|
86
|
-
key={index}
|
|
87
|
-
isContainerAligned={!isLargeScreen}
|
|
88
|
-
showMediaCircle
|
|
89
|
-
showMediaAtAllSizes
|
|
90
|
-
onClick={handleOnChange(option)}
|
|
91
|
-
{...option}
|
|
92
|
-
/>
|
|
93
|
-
);
|
|
94
|
-
})}
|
|
95
|
-
</NavigationOptionsList>
|
|
96
|
-
</Section>
|
|
97
|
-
))}
|
|
98
|
-
</div>
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return (
|
|
103
|
-
<>
|
|
104
|
-
<Option
|
|
105
|
-
ref={rootRef}
|
|
106
|
-
as="div"
|
|
107
|
-
showMediaAtAllSizes
|
|
108
|
-
disabled={disabled}
|
|
109
|
-
decision={false}
|
|
110
|
-
media={hasSelected ? selected.media : (placeholder.media ?? <Plus size={24} />)}
|
|
111
|
-
title={(hasSelected ? selected : placeholder).title}
|
|
112
|
-
content={(hasSelected ? selected : placeholder).content}
|
|
113
|
-
className={clsx(
|
|
114
|
-
'np-select-option',
|
|
115
|
-
'clickable',
|
|
116
|
-
hasSelected ? 'np-select-option-selected' : 'np-select-option-placeholder',
|
|
117
|
-
props.className,
|
|
118
|
-
)}
|
|
119
|
-
button={
|
|
120
|
-
<button
|
|
121
|
-
{...inputAttributes}
|
|
122
|
-
type="button"
|
|
123
|
-
disabled={disabled}
|
|
124
|
-
aria-labelledby={ariaLabelledBy}
|
|
125
|
-
aria-haspopup="dialog"
|
|
126
|
-
aria-expanded={showOptions}
|
|
127
|
-
className={hasSelected ? 'btn-unstyled' : 'np-action-btn'}
|
|
128
|
-
aria-label={hasSelected ? undefined : props['aria-label']}
|
|
129
|
-
onClick={handleOnClick(true)}
|
|
130
|
-
>
|
|
131
|
-
{hasSelected ? (
|
|
132
|
-
<ChevronDown title={intl.formatMessage(messages.selectedActionLabel)} />
|
|
133
|
-
) : (
|
|
134
|
-
placeholder.actionLabel || intl.formatMessage(messages.actionLabel)
|
|
135
|
-
)}
|
|
136
|
-
</button>
|
|
137
|
-
}
|
|
138
|
-
/>
|
|
139
|
-
<ResponsivePanel
|
|
140
|
-
anchorWidth
|
|
141
|
-
altAxis
|
|
142
|
-
anchorRef={rootRef}
|
|
143
|
-
open={showOptions}
|
|
144
|
-
position={Position.BOTTOM}
|
|
145
|
-
onClose={handleOnClick(false)}
|
|
146
|
-
>
|
|
147
|
-
{getOptions(isLargeScreen)}
|
|
148
|
-
</ResponsivePanel>
|
|
149
|
-
</>
|
|
150
|
-
);
|
|
151
|
-
}
|