@transferwise/components 0.0.0-experimental-e94d625 → 0.0.0-experimental-8e1de95
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/Snackbar/Snackbar.js +97 -101
- package/build/Snackbar/Snackbar.js.map +1 -1
- package/build/Snackbar/Snackbar.mjs +98 -102
- package/build/Snackbar/Snackbar.mjs.map +1 -1
- package/build/types/Carousel/_stories/constants.d.ts +25 -0
- package/build/types/Carousel/_stories/constants.d.ts.map +1 -1
- package/build/types/ListItem/_stories/variants/helpers.d.ts +38 -1
- package/build/types/ListItem/_stories/variants/helpers.d.ts.map +1 -1
- package/build/types/Snackbar/Snackbar.d.ts +1 -15
- package/build/types/Snackbar/Snackbar.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Accordion/_stories/Accordion.test.story.tsx +74 -48
- package/src/AvatarLayout/_stories/AvatarLayout.test.story.tsx +46 -30
- package/src/Button/LegacyButton/_stories/LegacyButton.test.story.tsx +29 -19
- package/src/Calendar/_stories/Calendar.test.story.tsx +34 -21
- package/src/Carousel/_stories/Carousel.test.story.tsx +18 -8
- package/src/Carousel/_stories/constants.tsx +29 -4
- package/src/Checkbox/_stories/Checkbox.test.story.tsx +22 -13
- package/src/CheckboxButton/_stories/CheckboxButton.test.story.tsx +23 -14
- package/src/Chips/_stories/Chips.test.story.tsx +51 -36
- package/src/DateInput/_stories/DateInput.rtl.test.story.tsx +62 -12
- package/src/Decision/_stories/Decision.test.story.tsx +74 -58
- package/src/DefinitionList/_stories/DefinitionList.test.story.tsx +58 -42
- package/src/Drawer/_stories/Drawer.rtl.test.story.tsx +65 -38
- package/src/ExpressiveMoneyInput/_stories/ExpressiveMoneyInput.rtl.test.story.tsx +107 -74
- package/src/Field/_stories/Field.test.story.tsx +1 -1
- package/src/FlowNavigation/_stories/FlowNavigation.rtl.test.story.tsx +81 -51
- package/src/Header/_stories/Header.test.story.tsx +30 -18
- package/src/Info/_stories/Info.rtl.test.story.tsx +124 -50
- package/src/Inputs/InputGroup/_stories/InputGroup.test.story.tsx +4 -2
- package/src/Inputs/SelectInput/_stories/SelectInput.rtl.test.story.tsx +106 -77
- package/src/InstructionsList/_stories/InstructionsList.test.story.tsx +43 -16
- package/src/Link/_stories/Link.test.story.tsx +27 -13
- package/src/ListItem/_stories/ListItem.rtl.test.story.tsx +126 -6
- package/src/ListItem/_stories/variants/helpers.tsx +174 -126
- package/src/Loader/_stories/Loader.test.story.tsx +17 -10
- package/src/Modal/_stories/Modal.rtl.test.story.tsx +58 -39
- package/src/MoneyInput/_stories/MoneyInput.rtl.test.story.tsx +14 -2
- package/src/Nudge/_stories/Nudge.test.story.tsx +70 -21
- package/src/Popover/_stories/Popover.rtl.test.story.tsx +92 -49
- package/src/PromoCard/_stories/PromoCard.test.story.tsx +53 -29
- package/src/PromoCard/_stories/PromoCardGroup.test.story.tsx +60 -36
- package/src/Prompt/ActionPrompt/_stories/ActionPrompt.test.story.tsx +74 -38
- package/src/Prompt/CriticalBanner/_stories/CriticalBanner.test.story.tsx +68 -31
- package/src/Prompt/InfoPrompt/_stories/InfoPrompt.test.story.tsx +52 -22
- package/src/Prompt/InlinePrompt/_stories/InlinePrompt.test.story.tsx +36 -21
- package/src/Radio/_stories/Radio.test.story.tsx +60 -46
- package/src/RadioGroup/_stories/RadioGroup.test.story.tsx +70 -51
- package/src/Section/_stories/Section.test.story.tsx +30 -14
- package/src/SegmentedControl/_stories/SegmentedControl.test.story.tsx +38 -15
- package/src/SlidingPanel/_stories/SlidingPanel.rtl.test.story.tsx +58 -34
- package/src/Snackbar/Snackbar.tsx +90 -88
- package/src/Snackbar/_stories/Snackbar.rtl.test.story.tsx +24 -12
- package/src/Stepper/_stories/Stepper.test.story.tsx +27 -9
- package/src/Switch/_stories/Switch.test.story.tsx +20 -12
- package/src/Table/_stories/Table.test.story.tsx +107 -86
- package/src/Tabs/_stories/Tabs.test.story.tsx +92 -52
- package/src/Tag/_stories/Tag.test.story.tsx +27 -16
- package/src/Tooltip/_stories/Tooltip.rtl.test.story.tsx +68 -25
- package/src/Typeahead/_stories/Typeahead.rtl.test.story.tsx +3 -3
- package/src/Upload/_stories/Upload.rtl.test.story.tsx +49 -26
- package/src/UploadInput/_stories/UploadInput.test.story.tsx +63 -41
- package/src/_deprecated/Alert/_stories/Alert.test.story.tsx +45 -24
- package/src/_deprecated/Card/_stories/Card.test.story.tsx +47 -23
- package/src/_deprecated/CriticalBanner/_stories/CriticalCommsBanner.test.story.tsx +21 -15
- package/src/_deprecated/InlineAlert/_stories/InlineAlert.test.story.tsx +23 -12
- package/src/_deprecated/Select/_stories/Select.rtl.test.story.tsx +76 -40
- package/src/common/BottomSheet/_stories/BottomSheet.test.story.tsx +38 -20
- package/src/common/Panel/_stories/Panel.rtl.test.story.tsx +135 -51
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { CSSTransition } from 'react-transition-group';
|
|
3
3
|
|
|
4
4
|
import Button from '../Button';
|
|
5
5
|
import Body from '../Body';
|
|
6
6
|
import type { ThemeDark, ThemeLight } from '../common';
|
|
7
|
-
import { DirectionContext } from '../Provider/Direction';
|
|
8
7
|
import withNextPortal from '../WithNextPortal/WithNextPortal';
|
|
9
8
|
|
|
10
9
|
const CSS_TRANSITION_DURATION = 400;
|
|
@@ -25,102 +24,105 @@ interface SnackbarState extends Pick<SnackbarProps, 'action' | 'text' | 'theme'>
|
|
|
25
24
|
visible: boolean;
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
export
|
|
29
|
-
bodyRef =
|
|
30
|
-
|
|
31
|
-
transitionTimeout = 0;
|
|
27
|
+
export const Snackbar = (props: SnackbarProps) => {
|
|
28
|
+
const bodyRef = useRef<HTMLSpanElement>(null);
|
|
29
|
+
const leaveTimeout = useRef(0);
|
|
30
|
+
const transitionTimeout = useRef(0);
|
|
31
|
+
/** The props of the last committed render, as `this.props` was in the class component. */
|
|
32
|
+
const committedProps = useRef(props);
|
|
33
|
+
|
|
34
|
+
const [state, setState] = useState<SnackbarState>({
|
|
35
|
+
visible: false,
|
|
36
|
+
text: '',
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
useEffect(
|
|
40
|
+
() => () => {
|
|
41
|
+
window.clearTimeout(leaveTimeout.current);
|
|
42
|
+
window.clearTimeout(transitionTimeout.current);
|
|
43
|
+
},
|
|
44
|
+
[],
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
// Runs after every render to mirror the componentDidUpdate lifecycle this component previously
|
|
48
|
+
// relied on, including the shouldComponentUpdate guard that ignored every update without text.
|
|
49
|
+
// Both rules below are disabled on purpose: the dependency-less effect and its synchronous state
|
|
50
|
+
// updates are what keep this conversion behaviour-identical to the class component.
|
|
51
|
+
/* eslint-disable react-hooks/exhaustive-deps, react-hooks/set-state-in-effect */
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
const previousProps = committedProps.current;
|
|
54
|
+
committedProps.current = props;
|
|
55
|
+
|
|
56
|
+
const { action, text, timestamp } = props;
|
|
57
|
+
|
|
58
|
+
// shouldComponentUpdate bailed out whenever the incoming text was empty. That also blocked the
|
|
59
|
+
// updates scheduled below, so a Snackbar whose text is cleared stays on screen until it is
|
|
60
|
+
// given text again. Preserved here deliberately to keep this refactor behaviour-identical.
|
|
61
|
+
const updateWhileTextIsPresent = (update: () => void) => {
|
|
62
|
+
if (committedProps.current.text) {
|
|
63
|
+
update();
|
|
64
|
+
}
|
|
65
|
+
};
|
|
32
66
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
text: '',
|
|
67
|
+
const setLeaveTimeout = () => {
|
|
68
|
+
leaveTimeout.current = window.setTimeout(() => {
|
|
69
|
+
updateWhileTextIsPresent(() => setState((current) => ({ ...current, visible: false })));
|
|
70
|
+
}, committedProps.current.timeout);
|
|
38
71
|
};
|
|
39
|
-
}
|
|
40
72
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
73
|
+
const show = () => {
|
|
74
|
+
setState((current) => ({ ...current, visible: true, action, text }));
|
|
75
|
+
setLeaveTimeout();
|
|
76
|
+
};
|
|
45
77
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return false;
|
|
78
|
+
if (!text) {
|
|
79
|
+
return;
|
|
49
80
|
}
|
|
50
|
-
if (
|
|
51
|
-
nextProps.timestamp === this.props.timestamp &&
|
|
52
|
-
nextState.visible === this.state.visible &&
|
|
53
|
-
nextState.text === this.state.text
|
|
54
|
-
) {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
setLeaveTimeout = () => {
|
|
62
|
-
const { timeout } = this.props;
|
|
63
|
-
|
|
64
|
-
this.timeout = window.setTimeout(() => {
|
|
65
|
-
this.setState({ visible: false });
|
|
66
|
-
}, timeout);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
componentDidUpdate(previousProps: SnackbarProps) {
|
|
70
|
-
const { action, text, timestamp } = this.props;
|
|
71
81
|
|
|
72
82
|
if (!previousProps.text) {
|
|
73
|
-
|
|
74
|
-
this.setLeaveTimeout();
|
|
75
|
-
});
|
|
83
|
+
show();
|
|
76
84
|
} else if (previousProps.timestamp !== timestamp) {
|
|
77
|
-
window.clearTimeout(
|
|
78
|
-
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}, CSS_TRANSITION_DURATION);
|
|
85
|
-
});
|
|
85
|
+
window.clearTimeout(leaveTimeout.current);
|
|
86
|
+
|
|
87
|
+
if (state.visible) {
|
|
88
|
+
setState((current) => ({ ...current, visible: false }));
|
|
89
|
+
transitionTimeout.current = window.setTimeout(() => {
|
|
90
|
+
updateWhileTextIsPresent(show);
|
|
91
|
+
}, CSS_TRANSITION_DURATION);
|
|
86
92
|
} else {
|
|
87
|
-
|
|
88
|
-
this.setLeaveTimeout();
|
|
93
|
+
show();
|
|
89
94
|
}
|
|
90
95
|
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
Snackbar.contextType = DirectionContext;
|
|
96
|
+
});
|
|
97
|
+
/* eslint-enable react-hooks/exhaustive-deps, react-hooks/set-state-in-effect */
|
|
98
|
+
|
|
99
|
+
const { action, text, visible } = state;
|
|
100
|
+
const { timeout } = props;
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<div className="snackbar" aria-live="assertive" role="alert">
|
|
104
|
+
<CSSTransition
|
|
105
|
+
nodeRef={bodyRef}
|
|
106
|
+
in={visible}
|
|
107
|
+
classNames="snackbar__text-container"
|
|
108
|
+
timeout={{
|
|
109
|
+
appear: 0,
|
|
110
|
+
enter: timeout,
|
|
111
|
+
exit: CSS_TRANSITION_DURATION,
|
|
112
|
+
}}
|
|
113
|
+
unmountOnExit
|
|
114
|
+
>
|
|
115
|
+
<Body ref={bodyRef} as="span" className="snackbar__text">
|
|
116
|
+
{text}
|
|
117
|
+
{action ? (
|
|
118
|
+
<Button className="snackbar__text__action" v2 size="sm" onClick={action.onClick}>
|
|
119
|
+
{action.label}
|
|
120
|
+
</Button>
|
|
121
|
+
) : null}
|
|
122
|
+
</Body>
|
|
123
|
+
</CSSTransition>
|
|
124
|
+
</div>
|
|
125
|
+
);
|
|
126
|
+
};
|
|
125
127
|
|
|
126
128
|
export default withNextPortal(Snackbar);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
2
|
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
3
3
|
|
|
4
|
-
import { withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
|
|
4
|
+
import { useRtlDiffI18n, withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
|
|
5
5
|
import { Snackbar } from '../Snackbar';
|
|
6
6
|
|
|
7
7
|
export default {
|
|
@@ -14,7 +14,7 @@ type Story = StoryObj<typeof Snackbar>;
|
|
|
14
14
|
|
|
15
15
|
const TIMEOUT = 10_000_000;
|
|
16
16
|
|
|
17
|
-
function SnackbarStory({ action }: { action?: { label: string } }) {
|
|
17
|
+
function SnackbarStory({ text, action }: { text: string; action?: { label: string } }) {
|
|
18
18
|
const [timestamp, setTimestamp] = useState(0);
|
|
19
19
|
|
|
20
20
|
useEffect(() => {
|
|
@@ -23,21 +23,33 @@ function SnackbarStory({ action }: { action?: { label: string } }) {
|
|
|
23
23
|
}, []);
|
|
24
24
|
|
|
25
25
|
return (
|
|
26
|
-
<Snackbar
|
|
27
|
-
text={<span>Transfer completed successfully</span>}
|
|
28
|
-
timestamp={timestamp}
|
|
29
|
-
timeout={TIMEOUT}
|
|
30
|
-
action={action}
|
|
31
|
-
/>
|
|
26
|
+
<Snackbar text={<span>{text}</span>} timestamp={timestamp} timeout={TIMEOUT} action={action} />
|
|
32
27
|
);
|
|
33
28
|
}
|
|
34
29
|
|
|
35
30
|
export const WithAction: Story = {
|
|
36
|
-
render: () =>
|
|
37
|
-
|
|
31
|
+
render: () => {
|
|
32
|
+
const i18n = useRtlDiffI18n();
|
|
33
|
+
return <SnackbarStory text={i18n.text} action={{ label: i18n.actionLabel }} />;
|
|
34
|
+
},
|
|
35
|
+
...withRTLDiff({
|
|
36
|
+
renderAs: 'iframe',
|
|
37
|
+
i18n: {
|
|
38
|
+
text: { en: 'Transfer completed successfully', ar: 'تم إتمام التحويل بنجاح' },
|
|
39
|
+
actionLabel: { en: 'View', ar: 'عرض' },
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
38
42
|
};
|
|
39
43
|
|
|
40
44
|
export const WithoutAction: Story = {
|
|
41
|
-
render: () =>
|
|
42
|
-
|
|
45
|
+
render: () => {
|
|
46
|
+
const i18n = useRtlDiffI18n();
|
|
47
|
+
return <SnackbarStory text={i18n.text} />;
|
|
48
|
+
},
|
|
49
|
+
...withRTLDiff({
|
|
50
|
+
renderAs: 'iframe',
|
|
51
|
+
i18n: {
|
|
52
|
+
text: { en: 'Transfer completed successfully', ar: 'تم إتمام التحويل بنجاح' },
|
|
53
|
+
},
|
|
54
|
+
}),
|
|
43
55
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
2
|
import { fn, within, expect, screen } from 'storybook/test';
|
|
3
3
|
import Stepper from '../Stepper';
|
|
4
|
-
import { withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
|
|
4
|
+
import { useRtlDiffI18n, withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
|
|
5
5
|
|
|
6
6
|
const STEPS = [
|
|
7
7
|
{
|
|
@@ -90,18 +90,36 @@ export const ProgressbarWidth: Story = {
|
|
|
90
90
|
},
|
|
91
91
|
};
|
|
92
92
|
|
|
93
|
+
// `steps` is a required prop, so `args` must supply it even though `render` builds its own
|
|
94
|
+
// translated steps from the i18n map and ignores this value.
|
|
93
95
|
const RTL_STEPS = [{ label: 'Amount' }, { label: 'You' }, { label: 'Review' }, { label: 'Pay' }];
|
|
94
96
|
|
|
95
97
|
export const RTLDiff: Story = {
|
|
96
98
|
args: {
|
|
97
99
|
steps: RTL_STEPS,
|
|
98
100
|
},
|
|
99
|
-
render: () =>
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
101
|
+
render: () => {
|
|
102
|
+
const i18n = useRtlDiffI18n();
|
|
103
|
+
const steps = [
|
|
104
|
+
{ label: i18n.amount },
|
|
105
|
+
{ label: i18n.you },
|
|
106
|
+
{ label: i18n.review },
|
|
107
|
+
{ label: i18n.pay },
|
|
108
|
+
];
|
|
109
|
+
return (
|
|
110
|
+
<div style={{ width: '80%', marginLeft: 'auto', marginRight: 'auto' }}>
|
|
111
|
+
<Stepper steps={steps} activeStep={0} />
|
|
112
|
+
<Stepper steps={steps} activeStep={2} />
|
|
113
|
+
<Stepper steps={steps} activeStep={4} />
|
|
114
|
+
</div>
|
|
115
|
+
);
|
|
116
|
+
},
|
|
117
|
+
...withRTLDiff({
|
|
118
|
+
i18n: {
|
|
119
|
+
amount: { en: 'Amount', ar: 'المبلغ' },
|
|
120
|
+
you: { en: 'You', ar: 'بياناتك' },
|
|
121
|
+
review: { en: 'Review', ar: 'المراجعة' },
|
|
122
|
+
pay: { en: 'Pay', ar: 'الدفع' },
|
|
123
|
+
},
|
|
124
|
+
}),
|
|
107
125
|
};
|
|
@@ -3,7 +3,7 @@ import { expect, userEvent, within } from 'storybook/test';
|
|
|
3
3
|
import { useState } from 'react';
|
|
4
4
|
|
|
5
5
|
import { withVariantConfig } from '../../../.storybook/helpers';
|
|
6
|
-
import { withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
|
|
6
|
+
import { useRtlDiffI18n, withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
|
|
7
7
|
import Field from '../../Field/Field';
|
|
8
8
|
import Switch from '../Switch';
|
|
9
9
|
|
|
@@ -103,15 +103,23 @@ export const Zoom400: Story = {
|
|
|
103
103
|
* the thumb direction flips correctly between writing modes.
|
|
104
104
|
*/
|
|
105
105
|
export const RTLDiff: Story = {
|
|
106
|
-
render: () =>
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
106
|
+
render: () => {
|
|
107
|
+
const i18n = useRtlDiffI18n();
|
|
108
|
+
return (
|
|
109
|
+
<>
|
|
110
|
+
<Field label={i18n.unchecked}>
|
|
111
|
+
<Switch checked={false} onClick={() => {}} />
|
|
112
|
+
</Field>
|
|
113
|
+
<Field label={i18n.checked}>
|
|
114
|
+
<Switch checked onClick={() => {}} />
|
|
115
|
+
</Field>
|
|
116
|
+
</>
|
|
117
|
+
);
|
|
118
|
+
},
|
|
119
|
+
...withRTLDiff({
|
|
120
|
+
i18n: {
|
|
121
|
+
unchecked: { en: 'Unchecked', ar: 'غير محدد' },
|
|
122
|
+
checked: { en: 'Checked', ar: 'محدد' },
|
|
123
|
+
},
|
|
124
|
+
}),
|
|
117
125
|
};
|
|
@@ -1,79 +1,11 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
2
|
import { DirectDebits } from '@transferwise/icons';
|
|
3
3
|
|
|
4
|
-
import { withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
|
|
4
|
+
import { useRtlDiffI18n, withRTLDiff } from '../../../.storybook/decorators/RtlDiffDecorator';
|
|
5
5
|
import Table from '..';
|
|
6
6
|
import { TableHeaderType } from '../Header/TableHeader';
|
|
7
7
|
import { TableRowType, TableRowClickableType } from '../Row/TableRow';
|
|
8
8
|
|
|
9
|
-
const headers: TableHeaderType[] = [
|
|
10
|
-
{ header: 'Employee', width: '200px' },
|
|
11
|
-
{ header: 'Location' },
|
|
12
|
-
{ header: 'Payment', alignment: 'right' },
|
|
13
|
-
{ header: 'Status' },
|
|
14
|
-
];
|
|
15
|
-
|
|
16
|
-
const rows: TableRowType[] = [
|
|
17
|
-
{
|
|
18
|
-
cells: [
|
|
19
|
-
{
|
|
20
|
-
cell: {
|
|
21
|
-
type: 'leading',
|
|
22
|
-
primaryText: 'Bob Brown',
|
|
23
|
-
secondaryText: 'Software Engineer',
|
|
24
|
-
avatar: { profileName: 'Bob Brown', badge: { flagCode: 'GBP' } },
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
{ cell: { type: 'text', text: 'FR, Paris' } },
|
|
28
|
-
{
|
|
29
|
-
cell: {
|
|
30
|
-
type: 'currency',
|
|
31
|
-
primaryCurrency: { amount: 12345.67, currency: 'eur' },
|
|
32
|
-
secondaryCurrency: { amount: 11000.0, currency: 'gbp' },
|
|
33
|
-
},
|
|
34
|
-
alignment: 'right',
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
cell: {
|
|
38
|
-
type: 'status',
|
|
39
|
-
primaryText: 'Cancelled',
|
|
40
|
-
secondaryText: '1 day ago',
|
|
41
|
-
sentiment: 'negative',
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
cells: [
|
|
48
|
-
{
|
|
49
|
-
cell: {
|
|
50
|
-
type: 'leading',
|
|
51
|
-
primaryText: 'Jan Kowalski',
|
|
52
|
-
secondaryText: 'Product Manager',
|
|
53
|
-
avatar: { asset: <DirectDebits />, badge: { status: 'warning' } },
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
{ cell: { type: 'text', text: 'US, New York' } },
|
|
57
|
-
{
|
|
58
|
-
cell: {
|
|
59
|
-
type: 'currency',
|
|
60
|
-
primaryCurrency: { amount: 23456.78, currency: 'usd' },
|
|
61
|
-
secondaryCurrency: { amount: 21000.0, currency: 'gbp' },
|
|
62
|
-
},
|
|
63
|
-
alignment: 'right',
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
cell: {
|
|
67
|
-
type: 'status',
|
|
68
|
-
primaryText: 'Paid',
|
|
69
|
-
secondaryText: 'Yesterday',
|
|
70
|
-
sentiment: 'positive',
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
],
|
|
74
|
-
},
|
|
75
|
-
];
|
|
76
|
-
|
|
77
9
|
export default {
|
|
78
10
|
component: Table,
|
|
79
11
|
title: 'Content/Table/Tests',
|
|
@@ -83,22 +15,111 @@ export default {
|
|
|
83
15
|
type Story = StoryObj<typeof Table>;
|
|
84
16
|
|
|
85
17
|
export const RTLDiff: Story = {
|
|
86
|
-
render: () =>
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
18
|
+
render: () => {
|
|
19
|
+
const i18n = useRtlDiffI18n();
|
|
20
|
+
|
|
21
|
+
const headers: TableHeaderType[] = [
|
|
22
|
+
{ header: i18n.employeeHeader, width: '200px' },
|
|
23
|
+
{ header: i18n.locationHeader },
|
|
24
|
+
{ header: i18n.paymentHeader, alignment: 'right' },
|
|
25
|
+
{ header: i18n.statusHeader },
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
const rows: TableRowType[] = [
|
|
29
|
+
{
|
|
30
|
+
cells: [
|
|
31
|
+
{
|
|
32
|
+
cell: {
|
|
33
|
+
type: 'leading',
|
|
34
|
+
primaryText: i18n.employeeOneName,
|
|
35
|
+
secondaryText: i18n.employeeOneRole,
|
|
36
|
+
avatar: { profileName: i18n.employeeOneName, badge: { flagCode: 'GBP' } },
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{ cell: { type: 'text', text: i18n.employeeOneLocation } },
|
|
40
|
+
{
|
|
41
|
+
cell: {
|
|
42
|
+
type: 'currency',
|
|
43
|
+
primaryCurrency: { amount: 12345.67, currency: 'eur' },
|
|
44
|
+
secondaryCurrency: { amount: 11000.0, currency: 'gbp' },
|
|
45
|
+
},
|
|
46
|
+
alignment: 'right',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
cell: {
|
|
50
|
+
type: 'status',
|
|
51
|
+
primaryText: i18n.employeeOneStatus,
|
|
52
|
+
secondaryText: i18n.employeeOneStatusTime,
|
|
53
|
+
sentiment: 'negative',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
cells: [
|
|
60
|
+
{
|
|
61
|
+
cell: {
|
|
62
|
+
type: 'leading',
|
|
63
|
+
primaryText: i18n.employeeTwoName,
|
|
64
|
+
secondaryText: i18n.employeeTwoRole,
|
|
65
|
+
avatar: { asset: <DirectDebits />, badge: { status: 'warning' } },
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
{ cell: { type: 'text', text: i18n.employeeTwoLocation } },
|
|
69
|
+
{
|
|
70
|
+
cell: {
|
|
71
|
+
type: 'currency',
|
|
72
|
+
primaryCurrency: { amount: 23456.78, currency: 'usd' },
|
|
73
|
+
secondaryCurrency: { amount: 21000.0, currency: 'gbp' },
|
|
74
|
+
},
|
|
75
|
+
alignment: 'right',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
cell: {
|
|
79
|
+
type: 'status',
|
|
80
|
+
primaryText: i18n.employeeTwoStatus,
|
|
81
|
+
secondaryText: i18n.employeeTwoStatusTime,
|
|
82
|
+
sentiment: 'positive',
|
|
83
|
+
},
|
|
95
84
|
},
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<>
|
|
91
|
+
<Table data={{ headers, rows }} />
|
|
92
|
+
<Table
|
|
93
|
+
data={{
|
|
94
|
+
headers,
|
|
95
|
+
rows,
|
|
96
|
+
onRowClick: (rowData: TableRowType | TableRowClickableType) => {
|
|
97
|
+
void rowData;
|
|
98
|
+
},
|
|
99
|
+
}}
|
|
100
|
+
/>
|
|
101
|
+
<Table data={{ headers, rows }} fullWidth={false} />
|
|
102
|
+
<Table data={{ headers, rows: [] }} />
|
|
103
|
+
<Table data={{ headers, rows }} loading />
|
|
104
|
+
</>
|
|
105
|
+
);
|
|
106
|
+
},
|
|
107
|
+
...withRTLDiff({
|
|
108
|
+
i18n: {
|
|
109
|
+
employeeHeader: { en: 'Employee', ar: 'الموظف' },
|
|
110
|
+
locationHeader: { en: 'Location', ar: 'الموقع' },
|
|
111
|
+
paymentHeader: { en: 'Payment', ar: 'الدفعة' },
|
|
112
|
+
statusHeader: { en: 'Status', ar: 'الحالة' },
|
|
113
|
+
employeeOneName: { en: 'Bob Brown', ar: 'بوب براون' },
|
|
114
|
+
employeeOneRole: { en: 'Software Engineer', ar: 'مهندس برمجيات' },
|
|
115
|
+
employeeOneLocation: { en: 'FR, Paris', ar: 'فرنسا، باريس' },
|
|
116
|
+
employeeOneStatus: { en: 'Cancelled', ar: 'ملغى' },
|
|
117
|
+
employeeOneStatusTime: { en: '1 day ago', ar: 'منذ يوم واحد' },
|
|
118
|
+
employeeTwoName: { en: 'Jan Kowalski', ar: 'يان كوفالسكي' },
|
|
119
|
+
employeeTwoRole: { en: 'Product Manager', ar: 'مدير المنتج' },
|
|
120
|
+
employeeTwoLocation: { en: 'US, New York', ar: 'أمريكا، نيويورك' },
|
|
121
|
+
employeeTwoStatus: { en: 'Paid', ar: 'مدفوع' },
|
|
122
|
+
employeeTwoStatusTime: { en: 'Yesterday', ar: 'أمس' },
|
|
123
|
+
},
|
|
124
|
+
}),
|
|
104
125
|
};
|