@transferwise/components 0.0.0-experimental-4533565 → 0.0.0-experimental-feb2ddf
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/flowNavigation/animatedLabel/AnimatedLabel.js +1 -1
- package/build/flowNavigation/animatedLabel/AnimatedLabel.js.map +1 -1
- package/build/flowNavigation/animatedLabel/AnimatedLabel.mjs +1 -1
- package/build/flowNavigation/animatedLabel/AnimatedLabel.mjs.map +1 -1
- package/build/index.js +3 -3
- package/build/index.mjs +2 -2
- package/build/{listItem/ListItem.js → legacylistItem/LegacyListItem.js} +3 -3
- package/build/legacylistItem/LegacyListItem.js.map +1 -0
- package/build/{listItem/ListItem.mjs → legacylistItem/LegacyListItem.mjs} +3 -3
- package/build/legacylistItem/LegacyListItem.mjs.map +1 -0
- package/build/legacylistItem/List.js.map +1 -0
- package/build/legacylistItem/List.mjs.map +1 -0
- package/build/main.css +60 -57
- package/build/phoneNumberInput/PhoneNumberInput.js +1 -1
- package/build/phoneNumberInput/PhoneNumberInput.js.map +1 -1
- package/build/phoneNumberInput/PhoneNumberInput.mjs +1 -1
- package/build/phoneNumberInput/PhoneNumberInput.mjs.map +1 -1
- package/build/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.js +2 -2
- package/build/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.js.map +1 -1
- package/build/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.mjs +2 -2
- package/build/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.mjs.map +1 -1
- package/build/styles/legacylistItem/LegacyListItem.css +6 -0
- package/build/styles/listItem/ListItem.css +185 -3
- package/build/styles/main.css +60 -57
- package/build/styles/switch/Switch.css +3 -0
- package/build/types/index.d.ts +3 -3
- package/build/types/index.d.ts.map +1 -1
- package/build/types/legacylistItem/LegacyListItem.d.ts +13 -0
- package/build/types/legacylistItem/LegacyListItem.d.ts.map +1 -0
- package/build/types/legacylistItem/List.d.ts.map +1 -0
- package/build/types/legacylistItem/index.d.ts +5 -0
- package/build/types/legacylistItem/index.d.ts.map +1 -0
- package/build/types/listItem/ListItem.d.ts +38 -8
- package/build/types/listItem/ListItem.d.ts.map +1 -1
- package/build/types/{item/ItemAdditionalInfo.d.ts → listItem/ListItemAdditionalInfo.d.ts} +1 -1
- package/build/types/listItem/ListItemAdditionalInfo.d.ts.map +1 -0
- package/build/types/{item/ItemButton.d.ts → listItem/ListItemButton.d.ts} +1 -1
- package/build/types/listItem/ListItemButton.d.ts.map +1 -0
- package/build/types/{item/ItemCheckbox.d.ts → listItem/ListItemCheckbox.d.ts} +1 -1
- package/build/types/listItem/ListItemCheckbox.d.ts.map +1 -0
- package/build/types/{item/ItemIconButton.d.ts → listItem/ListItemIconButton.d.ts} +1 -1
- package/build/types/listItem/ListItemIconButton.d.ts.map +1 -0
- package/build/types/{item/ItemMedia.d.ts → listItem/ListItemMedia.d.ts} +1 -1
- package/build/types/listItem/ListItemMedia.d.ts.map +1 -0
- package/build/types/{item/ItemNavigation.d.ts → listItem/ListItemNavigation.d.ts} +1 -1
- package/build/types/listItem/ListItemNavigation.d.ts.map +1 -0
- package/build/types/{item/ItemSwitch.d.ts → listItem/ListItemSwitch.d.ts} +1 -1
- package/build/types/listItem/ListItemSwitch.d.ts.map +1 -0
- package/build/types/listItem/index.d.ts +4 -3
- package/build/types/listItem/index.d.ts.map +1 -1
- package/build/types/listItem/prompt/Prompt.d.ts.map +1 -0
- package/build/types/listItem/useItemControl.d.ts +5 -0
- package/build/types/listItem/useItemControl.d.ts.map +1 -0
- package/build/types/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.d.ts +2 -2
- package/build/types/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/flowNavigation/animatedLabel/AnimatedLabel.tsx +1 -1
- package/src/index.ts +3 -3
- package/src/legacylistItem/LegacyListItem.css +6 -0
- package/src/legacylistItem/LegacyListItem.less +7 -0
- package/src/legacylistItem/LegacyListItem.story.tsx +120 -0
- package/src/{listItem/ListItem.tests.story.tsx → legacylistItem/LegacyListItem.tests.story.tsx} +2 -2
- package/src/legacylistItem/LegacyListItem.tsx +53 -0
- package/src/legacylistItem/index.ts +4 -0
- package/src/listItem/ListItem.css +185 -3
- package/src/listItem/ListItem.less +180 -5
- package/src/listItem/ListItem.story.tsx +250 -97
- package/src/listItem/ListItem.tsx +167 -37
- package/src/{item/ItemAdditionalInfo.tsx → listItem/ListItemAdditionalInfo.tsx} +2 -2
- package/src/{item/ItemButton.spec.tsx → listItem/ListItemButton.spec.tsx} +4 -4
- package/src/listItem/index.ts +5 -3
- package/src/listItem/useItemControl.tsx +12 -0
- package/src/main.css +60 -57
- package/src/main.less +2 -2
- package/src/phoneNumberInput/PhoneNumberInput.spec.tsx +4 -4
- package/src/phoneNumberInput/PhoneNumberInput.story.tsx +22 -0
- package/src/phoneNumberInput/PhoneNumberInput.tsx +1 -1
- package/src/phoneNumberInput/utils/isValidPhoneNumber/isValidPhoneNumber.ts +4 -3
- package/src/switch/Switch.css +3 -0
- package/src/switch/Switch.less +1 -0
- package/build/listItem/List.js.map +0 -1
- package/build/listItem/List.mjs.map +0 -1
- package/build/listItem/ListItem.js.map +0 -1
- package/build/listItem/ListItem.mjs.map +0 -1
- package/build/styles/item/Item.css +0 -188
- package/build/types/item/Item.d.ts +0 -43
- package/build/types/item/Item.d.ts.map +0 -1
- package/build/types/item/ItemAdditionalInfo.d.ts.map +0 -1
- package/build/types/item/ItemButton.d.ts.map +0 -1
- package/build/types/item/ItemCheckbox.d.ts.map +0 -1
- package/build/types/item/ItemIconButton.d.ts.map +0 -1
- package/build/types/item/ItemMedia.d.ts.map +0 -1
- package/build/types/item/ItemNavigation.d.ts.map +0 -1
- package/build/types/item/ItemSwitch.d.ts.map +0 -1
- package/build/types/item/index.d.ts +0 -6
- package/build/types/item/index.d.ts.map +0 -1
- package/build/types/item/prompt/Prompt.d.ts.map +0 -1
- package/build/types/item/useItemControl.d.ts +0 -5
- package/build/types/item/useItemControl.d.ts.map +0 -1
- package/build/types/listItem/List.d.ts.map +0 -1
- package/src/item/Item.css +0 -188
- package/src/item/Item.less +0 -182
- package/src/item/Item.story.tsx +0 -273
- package/src/item/Item.tsx +0 -181
- package/src/item/index.ts +0 -6
- package/src/item/useItemControl.tsx +0 -12
- /package/build/{listItem → legacylistItem}/List.js +0 -0
- /package/build/{listItem → legacylistItem}/List.mjs +0 -0
- /package/build/types/{listItem → legacylistItem}/List.d.ts +0 -0
- /package/build/types/{item → listItem}/prompt/Prompt.d.ts +0 -0
- /package/src/{listItem/ListItem.spec.tsx → legacylistItem/LegacyListItem.spec.tsx} +0 -0
- /package/src/{listItem → legacylistItem}/List.tsx +0 -0
- /package/src/{item/ItemButton.tsx → listItem/ListItemButton.tsx} +0 -0
- /package/src/{item/ItemCheckbox.tsx → listItem/ListItemCheckbox.tsx} +0 -0
- /package/src/{item/ItemIconButton.tsx → listItem/ListItemIconButton.tsx} +0 -0
- /package/src/{item/ItemMedia.tsx → listItem/ListItemMedia.tsx} +0 -0
- /package/src/{item/ItemNavigation.tsx → listItem/ListItemNavigation.tsx} +0 -0
- /package/src/{item/ItemSwitch.tsx → listItem/ListItemSwitch.tsx} +0 -0
- /package/src/{item → listItem}/prompt/Prompt.spec.tsx +0 -0
- /package/src/{item → listItem}/prompt/Prompt.story.tsx +0 -0
- /package/src/{item → listItem}/prompt/Prompt.tsx +0 -0
package/src/item/Item.tsx
DELETED
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import { createContext, ReactNode, useId, useMemo, useState } from 'react';
|
|
2
|
-
import { Typography } from '../common';
|
|
3
|
-
import Body from '../body';
|
|
4
|
-
import { AdditionalInfo } from './ItemAdditionalInfo';
|
|
5
|
-
import { IconButton } from './ItemIconButton';
|
|
6
|
-
import { Checkbox } from './ItemCheckbox';
|
|
7
|
-
import { Navigation } from './ItemNavigation';
|
|
8
|
-
import { clsx } from 'clsx';
|
|
9
|
-
import { Button } from './ItemButton';
|
|
10
|
-
import { Switch } from './ItemSwitch';
|
|
11
|
-
import { AvatarLayout, AvatarView, Image } from './ItemMedia';
|
|
12
|
-
import Prompt from './prompt/Prompt';
|
|
13
|
-
|
|
14
|
-
export type ItemTypes =
|
|
15
|
-
| 'non-interactive'
|
|
16
|
-
| 'navigation'
|
|
17
|
-
| 'radio'
|
|
18
|
-
| 'checkbox'
|
|
19
|
-
| 'switch'
|
|
20
|
-
| 'button'
|
|
21
|
-
| 'icon-button';
|
|
22
|
-
|
|
23
|
-
export type Props = {
|
|
24
|
-
as?: 'li' | 'div' | 'span';
|
|
25
|
-
inverted?: boolean;
|
|
26
|
-
disabled?: boolean;
|
|
27
|
-
spotlight?: 'active' | 'inactive';
|
|
28
|
-
title: ReactNode;
|
|
29
|
-
subtitle?: ReactNode;
|
|
30
|
-
additionalInfo?: ReactNode;
|
|
31
|
-
valueTitle?: ReactNode;
|
|
32
|
-
valueSubtitle?: ReactNode;
|
|
33
|
-
media?: ReactNode;
|
|
34
|
-
control?: ReactNode;
|
|
35
|
-
prompt?: ReactNode;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export type ItemContextData = {
|
|
39
|
-
setControlType: (type: ItemTypes) => void;
|
|
40
|
-
ids: {
|
|
41
|
-
label: string;
|
|
42
|
-
additionalInfo: string;
|
|
43
|
-
value: string;
|
|
44
|
-
control: string;
|
|
45
|
-
prompt: string;
|
|
46
|
-
};
|
|
47
|
-
props: Pick<Props, 'as' | 'disabled' | 'inverted'>;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// @ts-expect-error for now let's mock it with `null` value
|
|
51
|
-
// but actually by default we should specify `setControlType('none')`
|
|
52
|
-
export const ItemContext = createContext<ItemContextData>(null);
|
|
53
|
-
|
|
54
|
-
export const Item = ({
|
|
55
|
-
as: View = 'li',
|
|
56
|
-
title,
|
|
57
|
-
subtitle,
|
|
58
|
-
additionalInfo,
|
|
59
|
-
prompt,
|
|
60
|
-
inverted,
|
|
61
|
-
media,
|
|
62
|
-
spotlight = undefined,
|
|
63
|
-
valueTitle,
|
|
64
|
-
valueSubtitle,
|
|
65
|
-
control = null,
|
|
66
|
-
disabled,
|
|
67
|
-
}: Props) => {
|
|
68
|
-
/*
|
|
69
|
-
const returnType = (): ReactNode => {
|
|
70
|
-
switch (type) {
|
|
71
|
-
case 'Navigation':
|
|
72
|
-
return <Chevron orientation={Position.RIGHT} disabled />;
|
|
73
|
-
case 'Radio':
|
|
74
|
-
return <RadioButton name="Hello" checked />;
|
|
75
|
-
case 'Checkbox':
|
|
76
|
-
return <CheckboxButton name="Hello" checked />;
|
|
77
|
-
case 'Switch':
|
|
78
|
-
return <Switch onClick={() => console.log('clicked')} />;
|
|
79
|
-
case 'Button':
|
|
80
|
-
return <Button v2>Hello</Button>;
|
|
81
|
-
case 'IconButton':
|
|
82
|
-
return (
|
|
83
|
-
<IconButton size={40} priority="minimal">
|
|
84
|
-
<InfoCircle />
|
|
85
|
-
</IconButton>
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
*/
|
|
90
|
-
const idPrefix = useId();
|
|
91
|
-
|
|
92
|
-
const [controlType, setControlType] = useState<ItemTypes>('non-interactive');
|
|
93
|
-
const ids = {
|
|
94
|
-
label: `${idPrefix}_label`,
|
|
95
|
-
value: `${idPrefix}_value`,
|
|
96
|
-
control: `${idPrefix}_control`,
|
|
97
|
-
prompt: `${idPrefix}_prompt`,
|
|
98
|
-
additionalInfo: `${idPrefix}_additional-info`,
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
const itemCtx = useMemo(
|
|
102
|
-
() => ({ setControlType, ids, props: { as: View, disabled, inverted } }),
|
|
103
|
-
[],
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
return (
|
|
107
|
-
<ItemContext.Provider value={itemCtx}>
|
|
108
|
-
<View
|
|
109
|
-
className={clsx(
|
|
110
|
-
'np-item',
|
|
111
|
-
{ 'np-item-interactive': controlType !== 'non-interactive' },
|
|
112
|
-
`np-item-${controlType}`,
|
|
113
|
-
'd-flex flex-row',
|
|
114
|
-
{ 'align-items-center': !subtitle },
|
|
115
|
-
{
|
|
116
|
-
[`np-item-spotlight-${spotlight}`]: !!spotlight,
|
|
117
|
-
},
|
|
118
|
-
)}
|
|
119
|
-
aria-describedby={[ids.additionalInfo].join(' ')}
|
|
120
|
-
>
|
|
121
|
-
{media && <div className="np-item-media">{media}</div>}
|
|
122
|
-
|
|
123
|
-
{/* Title + Subtitle + Values + Additional Info - Group */}
|
|
124
|
-
<div className="np-item-body">
|
|
125
|
-
{/* Title + Subtitle + Values - Group */}
|
|
126
|
-
<div className="d-flex justify-content-between">
|
|
127
|
-
<span>
|
|
128
|
-
{/* @ts-expect-error div can have role and aria-lavel props */}
|
|
129
|
-
<Body
|
|
130
|
-
type={Typography.BODY_LARGE_BOLD}
|
|
131
|
-
className="np-item-title"
|
|
132
|
-
// for a11y this needs to be a header but for SEO it shouldn't be `h*` tag
|
|
133
|
-
// so we enable header semantics via `role` and `aria-level` attrs
|
|
134
|
-
role="heading"
|
|
135
|
-
aria-level="4"
|
|
136
|
-
>
|
|
137
|
-
{title}
|
|
138
|
-
</Body>
|
|
139
|
-
<Body className="np-item-subtitle">{subtitle}</Body>
|
|
140
|
-
</span>
|
|
141
|
-
{(valueTitle || valueSubtitle) && (
|
|
142
|
-
<span
|
|
143
|
-
id={ids.value}
|
|
144
|
-
className={clsx('np-item-value', 'd-flex align-items-center', {
|
|
145
|
-
'flex-column': valueTitle !== undefined && valueSubtitle !== undefined,
|
|
146
|
-
})}
|
|
147
|
-
>
|
|
148
|
-
{valueTitle && (
|
|
149
|
-
<Body type={Typography.BODY_LARGE_BOLD} className="np-item-title-value">
|
|
150
|
-
{valueTitle}
|
|
151
|
-
</Body>
|
|
152
|
-
)}
|
|
153
|
-
{valueSubtitle && <Body className="np-item-subtitle-value">{valueSubtitle}</Body>}
|
|
154
|
-
</span>
|
|
155
|
-
)}
|
|
156
|
-
</div>
|
|
157
|
-
|
|
158
|
-
{/* Additional Info and Prompt here */}
|
|
159
|
-
{Boolean(subtitle) && additionalInfo}
|
|
160
|
-
</div>
|
|
161
|
-
{control === null ? null : <Body className="np-item-control">{control}</Body>}
|
|
162
|
-
{prompt}
|
|
163
|
-
</View>
|
|
164
|
-
</ItemContext.Provider>
|
|
165
|
-
);
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
/* eslint-disable functional/immutable-data */
|
|
169
|
-
Item.Image = Image;
|
|
170
|
-
Item.AvatarView = AvatarView;
|
|
171
|
-
Item.AvatarLayout = AvatarLayout;
|
|
172
|
-
Item.AdditionalInfo = AdditionalInfo;
|
|
173
|
-
Item.Checkbox = Checkbox;
|
|
174
|
-
Item.IconButton = IconButton;
|
|
175
|
-
Item.Navigation = Navigation;
|
|
176
|
-
Item.Button = Button;
|
|
177
|
-
Item.Switch = Switch;
|
|
178
|
-
Item.Prompt = Prompt;
|
|
179
|
-
/* eslint-enable functional/immutable-data */
|
|
180
|
-
|
|
181
|
-
export default Item;
|
package/src/item/index.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export type { Props as ItemProps } from './Item';
|
|
2
|
-
export type { ItemAdditionalInfoProps } from './ItemAdditionalInfo';
|
|
3
|
-
export type { ItemCheckboxProps } from './ItemCheckbox';
|
|
4
|
-
export type { ItemImageProps, ItemAvatarViewProps, ItemAvatarLayoutProps } from './ItemMedia';
|
|
5
|
-
|
|
6
|
-
export { default } from './Item';
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { useContext, useEffect } from 'react';
|
|
2
|
-
import { ItemContext, ItemContextData, ItemTypes } from './Item';
|
|
3
|
-
|
|
4
|
-
export function useItemControl(controlType: ItemTypes) {
|
|
5
|
-
const { setControlType, props: baseItemProps } = useContext<ItemContextData>(ItemContext);
|
|
6
|
-
|
|
7
|
-
useEffect(() => {
|
|
8
|
-
setControlType(controlType);
|
|
9
|
-
}, [controlType, setControlType]);
|
|
10
|
-
|
|
11
|
-
return { baseItemProps };
|
|
12
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|