@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
|
@@ -6,124 +6,120 @@ var React = require('react');
|
|
|
6
6
|
var reactTransitionGroup = require('react-transition-group');
|
|
7
7
|
var Button_resolver = require('../Button/Button.resolver.js');
|
|
8
8
|
var Body = require('../Body/Body.js');
|
|
9
|
-
var DirectionProvider = require('../Provider/Direction/DirectionProvider.js');
|
|
10
9
|
var WithNextPortal = require('../WithNextPortal/WithNextPortal.js');
|
|
11
10
|
var jsxRuntime = require('react/jsx-runtime');
|
|
12
11
|
|
|
13
12
|
const CSS_TRANSITION_DURATION = 400;
|
|
14
|
-
|
|
15
|
-
bodyRef =
|
|
16
|
-
|
|
17
|
-
transitionTimeout = 0;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
window.clearTimeout(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
setLeaveTimeout = () => {
|
|
39
|
-
const {
|
|
40
|
-
timeout
|
|
41
|
-
} = this.props;
|
|
42
|
-
this.timeout = window.setTimeout(() => {
|
|
43
|
-
this.setState({
|
|
44
|
-
visible: false
|
|
45
|
-
});
|
|
46
|
-
}, timeout);
|
|
47
|
-
};
|
|
48
|
-
componentDidUpdate(previousProps) {
|
|
13
|
+
const Snackbar = props => {
|
|
14
|
+
const bodyRef = React.useRef(null);
|
|
15
|
+
const leaveTimeout = React.useRef(0);
|
|
16
|
+
const transitionTimeout = React.useRef(0);
|
|
17
|
+
/** The props of the last committed render, as `this.props` was in the class component. */
|
|
18
|
+
const committedProps = React.useRef(props);
|
|
19
|
+
const [state, setState] = React.useState({
|
|
20
|
+
visible: false,
|
|
21
|
+
text: ''
|
|
22
|
+
});
|
|
23
|
+
React.useEffect(() => () => {
|
|
24
|
+
window.clearTimeout(leaveTimeout.current);
|
|
25
|
+
window.clearTimeout(transitionTimeout.current);
|
|
26
|
+
}, []);
|
|
27
|
+
// Runs after every render to mirror the componentDidUpdate lifecycle this component previously
|
|
28
|
+
// relied on, including the shouldComponentUpdate guard that ignored every update without text.
|
|
29
|
+
// Both rules below are disabled on purpose: the dependency-less effect and its synchronous state
|
|
30
|
+
// updates are what keep this conversion behaviour-identical to the class component.
|
|
31
|
+
/* eslint-disable react-hooks/exhaustive-deps, react-hooks/set-state-in-effect */
|
|
32
|
+
React.useEffect(() => {
|
|
33
|
+
const previousProps = committedProps.current;
|
|
34
|
+
committedProps.current = props;
|
|
49
35
|
const {
|
|
50
36
|
action,
|
|
51
37
|
text,
|
|
52
38
|
timestamp
|
|
53
|
-
} =
|
|
54
|
-
|
|
55
|
-
|
|
39
|
+
} = props;
|
|
40
|
+
// shouldComponentUpdate bailed out whenever the incoming text was empty. That also blocked the
|
|
41
|
+
// updates scheduled below, so a Snackbar whose text is cleared stays on screen until it is
|
|
42
|
+
// given text again. Preserved here deliberately to keep this refactor behaviour-identical.
|
|
43
|
+
const updateWhileTextIsPresent = update => {
|
|
44
|
+
if (committedProps.current.text) {
|
|
45
|
+
update();
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const setLeaveTimeout = () => {
|
|
49
|
+
leaveTimeout.current = window.setTimeout(() => {
|
|
50
|
+
updateWhileTextIsPresent(() => setState(current => ({
|
|
51
|
+
...current,
|
|
52
|
+
visible: false
|
|
53
|
+
})));
|
|
54
|
+
}, committedProps.current.timeout);
|
|
55
|
+
};
|
|
56
|
+
const show = () => {
|
|
57
|
+
setState(current => ({
|
|
58
|
+
...current,
|
|
56
59
|
visible: true,
|
|
57
60
|
action,
|
|
58
61
|
text
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
}));
|
|
63
|
+
setLeaveTimeout();
|
|
64
|
+
};
|
|
65
|
+
if (!text) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (!previousProps.text) {
|
|
69
|
+
show();
|
|
62
70
|
} else if (previousProps.timestamp !== timestamp) {
|
|
63
|
-
window.clearTimeout(
|
|
64
|
-
if (
|
|
65
|
-
|
|
71
|
+
window.clearTimeout(leaveTimeout.current);
|
|
72
|
+
if (state.visible) {
|
|
73
|
+
setState(current => ({
|
|
74
|
+
...current,
|
|
66
75
|
visible: false
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
action,
|
|
72
|
-
text
|
|
73
|
-
});
|
|
74
|
-
this.setLeaveTimeout();
|
|
75
|
-
}, CSS_TRANSITION_DURATION);
|
|
76
|
-
});
|
|
76
|
+
}));
|
|
77
|
+
transitionTimeout.current = window.setTimeout(() => {
|
|
78
|
+
updateWhileTextIsPresent(show);
|
|
79
|
+
}, CSS_TRANSITION_DURATION);
|
|
77
80
|
} else {
|
|
78
|
-
|
|
79
|
-
visible: true,
|
|
80
|
-
action,
|
|
81
|
-
text
|
|
82
|
-
});
|
|
83
|
-
this.setLeaveTimeout();
|
|
81
|
+
show();
|
|
84
82
|
}
|
|
85
83
|
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
})
|
|
84
|
+
});
|
|
85
|
+
/* eslint-enable react-hooks/exhaustive-deps, react-hooks/set-state-in-effect */
|
|
86
|
+
const {
|
|
87
|
+
action,
|
|
88
|
+
text,
|
|
89
|
+
visible
|
|
90
|
+
} = state;
|
|
91
|
+
const {
|
|
92
|
+
timeout
|
|
93
|
+
} = props;
|
|
94
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
95
|
+
className: "snackbar",
|
|
96
|
+
"aria-live": "assertive",
|
|
97
|
+
role: "alert",
|
|
98
|
+
children: /*#__PURE__*/jsxRuntime.jsx(reactTransitionGroup.CSSTransition, {
|
|
99
|
+
nodeRef: bodyRef,
|
|
100
|
+
in: visible,
|
|
101
|
+
classNames: "snackbar__text-container",
|
|
102
|
+
timeout: {
|
|
103
|
+
appear: 0,
|
|
104
|
+
enter: timeout,
|
|
105
|
+
exit: CSS_TRANSITION_DURATION
|
|
106
|
+
},
|
|
107
|
+
unmountOnExit: true,
|
|
108
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(Body.default, {
|
|
109
|
+
ref: bodyRef,
|
|
110
|
+
as: "span",
|
|
111
|
+
className: "snackbar__text",
|
|
112
|
+
children: [text, action ? /*#__PURE__*/jsxRuntime.jsx(Button_resolver.default, {
|
|
113
|
+
className: "snackbar__text__action",
|
|
114
|
+
v2: true,
|
|
115
|
+
size: "sm",
|
|
116
|
+
onClick: action.onClick,
|
|
117
|
+
children: action.label
|
|
118
|
+
}) : null]
|
|
122
119
|
})
|
|
123
|
-
})
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
Snackbar.contextType = DirectionProvider.DirectionContext;
|
|
120
|
+
})
|
|
121
|
+
});
|
|
122
|
+
};
|
|
127
123
|
var SnackbarPortal = WithNextPortal.default(Snackbar);
|
|
128
124
|
|
|
129
125
|
exports.Snackbar = Snackbar;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Snackbar.js","sources":["../../src/Snackbar/Snackbar.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"Snackbar.js","sources":["../../src/Snackbar/Snackbar.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport { CSSTransition } from 'react-transition-group';\n\nimport Button from '../Button';\nimport Body from '../Body';\nimport type { ThemeDark, ThemeLight } from '../common';\nimport withNextPortal from '../WithNextPortal/WithNextPortal';\n\nconst CSS_TRANSITION_DURATION = 400;\n\nexport interface SnackbarProps {\n action?: {\n label: string;\n onClick?: React.MouseEventHandler<HTMLButtonElement>;\n };\n text: React.ReactNode;\n /** @deprecated */\n theme?: ThemeLight | ThemeDark;\n timeout: number;\n timestamp: number;\n}\n\ninterface SnackbarState extends Pick<SnackbarProps, 'action' | 'text' | 'theme'> {\n visible: boolean;\n}\n\nexport const Snackbar = (props: SnackbarProps) => {\n const bodyRef = useRef<HTMLSpanElement>(null);\n const leaveTimeout = useRef(0);\n const transitionTimeout = useRef(0);\n /** The props of the last committed render, as `this.props` was in the class component. */\n const committedProps = useRef(props);\n\n const [state, setState] = useState<SnackbarState>({\n visible: false,\n text: '',\n });\n\n useEffect(\n () => () => {\n window.clearTimeout(leaveTimeout.current);\n window.clearTimeout(transitionTimeout.current);\n },\n [],\n );\n\n // Runs after every render to mirror the componentDidUpdate lifecycle this component previously\n // relied on, including the shouldComponentUpdate guard that ignored every update without text.\n // Both rules below are disabled on purpose: the dependency-less effect and its synchronous state\n // updates are what keep this conversion behaviour-identical to the class component.\n /* eslint-disable react-hooks/exhaustive-deps, react-hooks/set-state-in-effect */\n useEffect(() => {\n const previousProps = committedProps.current;\n committedProps.current = props;\n\n const { action, text, timestamp } = props;\n\n // shouldComponentUpdate bailed out whenever the incoming text was empty. That also blocked the\n // updates scheduled below, so a Snackbar whose text is cleared stays on screen until it is\n // given text again. Preserved here deliberately to keep this refactor behaviour-identical.\n const updateWhileTextIsPresent = (update: () => void) => {\n if (committedProps.current.text) {\n update();\n }\n };\n\n const setLeaveTimeout = () => {\n leaveTimeout.current = window.setTimeout(() => {\n updateWhileTextIsPresent(() => setState((current) => ({ ...current, visible: false })));\n }, committedProps.current.timeout);\n };\n\n const show = () => {\n setState((current) => ({ ...current, visible: true, action, text }));\n setLeaveTimeout();\n };\n\n if (!text) {\n return;\n }\n\n if (!previousProps.text) {\n show();\n } else if (previousProps.timestamp !== timestamp) {\n window.clearTimeout(leaveTimeout.current);\n\n if (state.visible) {\n setState((current) => ({ ...current, visible: false }));\n transitionTimeout.current = window.setTimeout(() => {\n updateWhileTextIsPresent(show);\n }, CSS_TRANSITION_DURATION);\n } else {\n show();\n }\n }\n });\n /* eslint-enable react-hooks/exhaustive-deps, react-hooks/set-state-in-effect */\n\n const { action, text, visible } = state;\n const { timeout } = props;\n\n return (\n <div className=\"snackbar\" aria-live=\"assertive\" role=\"alert\">\n <CSSTransition\n nodeRef={bodyRef}\n in={visible}\n classNames=\"snackbar__text-container\"\n timeout={{\n appear: 0,\n enter: timeout,\n exit: CSS_TRANSITION_DURATION,\n }}\n unmountOnExit\n >\n <Body ref={bodyRef} as=\"span\" className=\"snackbar__text\">\n {text}\n {action ? (\n <Button className=\"snackbar__text__action\" v2 size=\"sm\" onClick={action.onClick}>\n {action.label}\n </Button>\n ) : null}\n </Body>\n </CSSTransition>\n </div>\n );\n};\n\nexport default withNextPortal(Snackbar);\n"],"names":["CSS_TRANSITION_DURATION","Snackbar","props","bodyRef","useRef","leaveTimeout","transitionTimeout","committedProps","state","setState","useState","visible","text","useEffect","window","clearTimeout","current","previousProps","action","timestamp","updateWhileTextIsPresent","update","setLeaveTimeout","setTimeout","timeout","show","_jsx","className","role","children","CSSTransition","nodeRef","in","classNames","appear","enter","exit","unmountOnExit","_jsxs","Body","ref","as","Button","v2","size","onClick","label","withNextPortal"],"mappings":";;;;;;;;;;;AAQA,MAAMA,uBAAuB,GAAG,GAAG;AAkB5B,MAAMC,QAAQ,GAAIC,KAAoB,IAAI;AAC/C,EAAA,MAAMC,OAAO,GAAGC,YAAM,CAAkB,IAAI,CAAC;AAC7C,EAAA,MAAMC,YAAY,GAAGD,YAAM,CAAC,CAAC,CAAC;AAC9B,EAAA,MAAME,iBAAiB,GAAGF,YAAM,CAAC,CAAC,CAAC;AACnC;AACA,EAAA,MAAMG,cAAc,GAAGH,YAAM,CAACF,KAAK,CAAC;AAEpC,EAAA,MAAM,CAACM,KAAK,EAAEC,QAAQ,CAAC,GAAGC,cAAQ,CAAgB;AAChDC,IAAAA,OAAO,EAAE,KAAK;AACdC,IAAAA,IAAI,EAAE;AACP,GAAA,CAAC;EAEFC,eAAS,CACP,MAAM,MAAK;AACTC,IAAAA,MAAM,CAACC,YAAY,CAACV,YAAY,CAACW,OAAO,CAAC;AACzCF,IAAAA,MAAM,CAACC,YAAY,CAACT,iBAAiB,CAACU,OAAO,CAAC;EAChD,CAAC,EACD,EAAE,CACH;AAED;AACA;AACA;AACA;AACA;AACAH,EAAAA,eAAS,CAAC,MAAK;AACb,IAAA,MAAMI,aAAa,GAAGV,cAAc,CAACS,OAAO;IAC5CT,cAAc,CAACS,OAAO,GAAGd,KAAK;IAE9B,MAAM;MAAEgB,MAAM;MAAEN,IAAI;AAAEO,MAAAA;AAAS,KAAE,GAAGjB,KAAK;AAEzC;AACA;AACA;IACA,MAAMkB,wBAAwB,GAAIC,MAAkB,IAAI;AACtD,MAAA,IAAId,cAAc,CAACS,OAAO,CAACJ,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C;AACF;EAEA,MAAM;IAAEP,MAAM;IAAEN,IAAI;AAAED,IAAAA;AAAO,GAAE,GAAGH,KAAK;EACvC,MAAM;AAAEgB,IAAAA;AAAO,GAAE,GAAGtB,KAAK;AAEzB,EAAA,oBACEwB,cAAA,CAAA,KAAA,EAAA;AAAKC,IAAAA,SAAS,EAAC,UAAU;AAAC,IAAA,WAAA,EAAU,WAAW;AAACC,IAAAA,IAAI,EAAC,OAAO;IAAAC,QAAA,eAC1DH,cAAA,CAACI,kCAAa,EAAA;AACZC,MAAAA,OAAO,EAAE5B,OAAQ;AACjB6B,MAAAA,EAAE,EAAErB,OAAQ;AACZsB,MAAAA,UAAU,EAAC,0BAA0B;AACrCT,MAAAA,OAAO,EAAE;AACPU,QAAAA,MAAM,EAAE,CAAC;AACTC,QAAAA,KAAK,EAAEX,OAAO;AACdY,QAAAA,IAAI,EAAEpC;OACN;MACFqC,aAAa,EAAA,IAAA;MAAAR,QAAA,eAEbS,eAAA,CAACC,YAAI,EAAA;AAACC,QAAAA,GAAG,EAAErC,OAAQ;AAACsC,QAAAA,EAAE,EAAC,MAAM;AAACd,QAAAA,SAAS,EAAC,gBAAgB;AAAAE,QAAAA,QAAA,GACrDjB,IAAI,EACJM,MAAM,gBACLQ,cAAA,CAACgB,uBAAM,EAAA;AAACf,UAAAA,SAAS,EAAC,wBAAwB;UAACgB,EAAE,EAAA,IAAA;AAACC,UAAAA,IAAI,EAAC,IAAI;UAACC,OAAO,EAAE3B,MAAM,CAAC2B,OAAQ;UAAAhB,QAAA,EAC7EX,MAAM,CAAC4B;SACF,CAAC,GACP,IAAI;OACJ;KACO;AACjB,GAAK,CAAC;AAEV;AAEA,qBAAeC,sBAAc,CAAC9C,QAAQ,CAAC;;;"}
|
|
@@ -1,125 +1,121 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useRef, useState, useEffect } from 'react';
|
|
2
2
|
import { CSSTransition } from 'react-transition-group';
|
|
3
3
|
import Button from '../Button/Button.resolver.mjs';
|
|
4
4
|
import Body from '../Body/Body.mjs';
|
|
5
|
-
import { DirectionContext } from '../Provider/Direction/DirectionProvider.mjs';
|
|
6
5
|
import withNextPortalWrapper from '../WithNextPortal/WithNextPortal.mjs';
|
|
7
6
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
8
7
|
|
|
9
8
|
const CSS_TRANSITION_DURATION = 400;
|
|
10
|
-
|
|
11
|
-
bodyRef =
|
|
12
|
-
|
|
13
|
-
transitionTimeout = 0;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
window.clearTimeout(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
setLeaveTimeout = () => {
|
|
35
|
-
const {
|
|
36
|
-
timeout
|
|
37
|
-
} = this.props;
|
|
38
|
-
this.timeout = window.setTimeout(() => {
|
|
39
|
-
this.setState({
|
|
40
|
-
visible: false
|
|
41
|
-
});
|
|
42
|
-
}, timeout);
|
|
43
|
-
};
|
|
44
|
-
componentDidUpdate(previousProps) {
|
|
9
|
+
const Snackbar = props => {
|
|
10
|
+
const bodyRef = useRef(null);
|
|
11
|
+
const leaveTimeout = useRef(0);
|
|
12
|
+
const transitionTimeout = useRef(0);
|
|
13
|
+
/** The props of the last committed render, as `this.props` was in the class component. */
|
|
14
|
+
const committedProps = useRef(props);
|
|
15
|
+
const [state, setState] = useState({
|
|
16
|
+
visible: false,
|
|
17
|
+
text: ''
|
|
18
|
+
});
|
|
19
|
+
useEffect(() => () => {
|
|
20
|
+
window.clearTimeout(leaveTimeout.current);
|
|
21
|
+
window.clearTimeout(transitionTimeout.current);
|
|
22
|
+
}, []);
|
|
23
|
+
// Runs after every render to mirror the componentDidUpdate lifecycle this component previously
|
|
24
|
+
// relied on, including the shouldComponentUpdate guard that ignored every update without text.
|
|
25
|
+
// Both rules below are disabled on purpose: the dependency-less effect and its synchronous state
|
|
26
|
+
// updates are what keep this conversion behaviour-identical to the class component.
|
|
27
|
+
/* eslint-disable react-hooks/exhaustive-deps, react-hooks/set-state-in-effect */
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
const previousProps = committedProps.current;
|
|
30
|
+
committedProps.current = props;
|
|
45
31
|
const {
|
|
46
32
|
action,
|
|
47
33
|
text,
|
|
48
34
|
timestamp
|
|
49
|
-
} =
|
|
50
|
-
|
|
51
|
-
|
|
35
|
+
} = props;
|
|
36
|
+
// shouldComponentUpdate bailed out whenever the incoming text was empty. That also blocked the
|
|
37
|
+
// updates scheduled below, so a Snackbar whose text is cleared stays on screen until it is
|
|
38
|
+
// given text again. Preserved here deliberately to keep this refactor behaviour-identical.
|
|
39
|
+
const updateWhileTextIsPresent = update => {
|
|
40
|
+
if (committedProps.current.text) {
|
|
41
|
+
update();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const setLeaveTimeout = () => {
|
|
45
|
+
leaveTimeout.current = window.setTimeout(() => {
|
|
46
|
+
updateWhileTextIsPresent(() => setState(current => ({
|
|
47
|
+
...current,
|
|
48
|
+
visible: false
|
|
49
|
+
})));
|
|
50
|
+
}, committedProps.current.timeout);
|
|
51
|
+
};
|
|
52
|
+
const show = () => {
|
|
53
|
+
setState(current => ({
|
|
54
|
+
...current,
|
|
52
55
|
visible: true,
|
|
53
56
|
action,
|
|
54
57
|
text
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
}));
|
|
59
|
+
setLeaveTimeout();
|
|
60
|
+
};
|
|
61
|
+
if (!text) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (!previousProps.text) {
|
|
65
|
+
show();
|
|
58
66
|
} else if (previousProps.timestamp !== timestamp) {
|
|
59
|
-
window.clearTimeout(
|
|
60
|
-
if (
|
|
61
|
-
|
|
67
|
+
window.clearTimeout(leaveTimeout.current);
|
|
68
|
+
if (state.visible) {
|
|
69
|
+
setState(current => ({
|
|
70
|
+
...current,
|
|
62
71
|
visible: false
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
action,
|
|
68
|
-
text
|
|
69
|
-
});
|
|
70
|
-
this.setLeaveTimeout();
|
|
71
|
-
}, CSS_TRANSITION_DURATION);
|
|
72
|
-
});
|
|
72
|
+
}));
|
|
73
|
+
transitionTimeout.current = window.setTimeout(() => {
|
|
74
|
+
updateWhileTextIsPresent(show);
|
|
75
|
+
}, CSS_TRANSITION_DURATION);
|
|
73
76
|
} else {
|
|
74
|
-
|
|
75
|
-
visible: true,
|
|
76
|
-
action,
|
|
77
|
-
text
|
|
78
|
-
});
|
|
79
|
-
this.setLeaveTimeout();
|
|
77
|
+
show();
|
|
80
78
|
}
|
|
81
79
|
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
})
|
|
80
|
+
});
|
|
81
|
+
/* eslint-enable react-hooks/exhaustive-deps, react-hooks/set-state-in-effect */
|
|
82
|
+
const {
|
|
83
|
+
action,
|
|
84
|
+
text,
|
|
85
|
+
visible
|
|
86
|
+
} = state;
|
|
87
|
+
const {
|
|
88
|
+
timeout
|
|
89
|
+
} = props;
|
|
90
|
+
return /*#__PURE__*/jsx("div", {
|
|
91
|
+
className: "snackbar",
|
|
92
|
+
"aria-live": "assertive",
|
|
93
|
+
role: "alert",
|
|
94
|
+
children: /*#__PURE__*/jsx(CSSTransition, {
|
|
95
|
+
nodeRef: bodyRef,
|
|
96
|
+
in: visible,
|
|
97
|
+
classNames: "snackbar__text-container",
|
|
98
|
+
timeout: {
|
|
99
|
+
appear: 0,
|
|
100
|
+
enter: timeout,
|
|
101
|
+
exit: CSS_TRANSITION_DURATION
|
|
102
|
+
},
|
|
103
|
+
unmountOnExit: true,
|
|
104
|
+
children: /*#__PURE__*/jsxs(Body, {
|
|
105
|
+
ref: bodyRef,
|
|
106
|
+
as: "span",
|
|
107
|
+
className: "snackbar__text",
|
|
108
|
+
children: [text, action ? /*#__PURE__*/jsx(Button, {
|
|
109
|
+
className: "snackbar__text__action",
|
|
110
|
+
v2: true,
|
|
111
|
+
size: "sm",
|
|
112
|
+
onClick: action.onClick,
|
|
113
|
+
children: action.label
|
|
114
|
+
}) : null]
|
|
118
115
|
})
|
|
119
|
-
})
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
Snackbar.contextType = DirectionContext;
|
|
116
|
+
})
|
|
117
|
+
});
|
|
118
|
+
};
|
|
123
119
|
var SnackbarPortal = withNextPortalWrapper(Snackbar);
|
|
124
120
|
|
|
125
121
|
export { Snackbar, SnackbarPortal as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Snackbar.mjs","sources":["../../src/Snackbar/Snackbar.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"Snackbar.mjs","sources":["../../src/Snackbar/Snackbar.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport { CSSTransition } from 'react-transition-group';\n\nimport Button from '../Button';\nimport Body from '../Body';\nimport type { ThemeDark, ThemeLight } from '../common';\nimport withNextPortal from '../WithNextPortal/WithNextPortal';\n\nconst CSS_TRANSITION_DURATION = 400;\n\nexport interface SnackbarProps {\n action?: {\n label: string;\n onClick?: React.MouseEventHandler<HTMLButtonElement>;\n };\n text: React.ReactNode;\n /** @deprecated */\n theme?: ThemeLight | ThemeDark;\n timeout: number;\n timestamp: number;\n}\n\ninterface SnackbarState extends Pick<SnackbarProps, 'action' | 'text' | 'theme'> {\n visible: boolean;\n}\n\nexport const Snackbar = (props: SnackbarProps) => {\n const bodyRef = useRef<HTMLSpanElement>(null);\n const leaveTimeout = useRef(0);\n const transitionTimeout = useRef(0);\n /** The props of the last committed render, as `this.props` was in the class component. */\n const committedProps = useRef(props);\n\n const [state, setState] = useState<SnackbarState>({\n visible: false,\n text: '',\n });\n\n useEffect(\n () => () => {\n window.clearTimeout(leaveTimeout.current);\n window.clearTimeout(transitionTimeout.current);\n },\n [],\n );\n\n // Runs after every render to mirror the componentDidUpdate lifecycle this component previously\n // relied on, including the shouldComponentUpdate guard that ignored every update without text.\n // Both rules below are disabled on purpose: the dependency-less effect and its synchronous state\n // updates are what keep this conversion behaviour-identical to the class component.\n /* eslint-disable react-hooks/exhaustive-deps, react-hooks/set-state-in-effect */\n useEffect(() => {\n const previousProps = committedProps.current;\n committedProps.current = props;\n\n const { action, text, timestamp } = props;\n\n // shouldComponentUpdate bailed out whenever the incoming text was empty. That also blocked the\n // updates scheduled below, so a Snackbar whose text is cleared stays on screen until it is\n // given text again. Preserved here deliberately to keep this refactor behaviour-identical.\n const updateWhileTextIsPresent = (update: () => void) => {\n if (committedProps.current.text) {\n update();\n }\n };\n\n const setLeaveTimeout = () => {\n leaveTimeout.current = window.setTimeout(() => {\n updateWhileTextIsPresent(() => setState((current) => ({ ...current, visible: false })));\n }, committedProps.current.timeout);\n };\n\n const show = () => {\n setState((current) => ({ ...current, visible: true, action, text }));\n setLeaveTimeout();\n };\n\n if (!text) {\n return;\n }\n\n if (!previousProps.text) {\n show();\n } else if (previousProps.timestamp !== timestamp) {\n window.clearTimeout(leaveTimeout.current);\n\n if (state.visible) {\n setState((current) => ({ ...current, visible: false }));\n transitionTimeout.current = window.setTimeout(() => {\n updateWhileTextIsPresent(show);\n }, CSS_TRANSITION_DURATION);\n } else {\n show();\n }\n }\n });\n /* eslint-enable react-hooks/exhaustive-deps, react-hooks/set-state-in-effect */\n\n const { action, text, visible } = state;\n const { timeout } = props;\n\n return (\n <div className=\"snackbar\" aria-live=\"assertive\" role=\"alert\">\n <CSSTransition\n nodeRef={bodyRef}\n in={visible}\n classNames=\"snackbar__text-container\"\n timeout={{\n appear: 0,\n enter: timeout,\n exit: CSS_TRANSITION_DURATION,\n }}\n unmountOnExit\n >\n <Body ref={bodyRef} as=\"span\" className=\"snackbar__text\">\n {text}\n {action ? (\n <Button className=\"snackbar__text__action\" v2 size=\"sm\" onClick={action.onClick}>\n {action.label}\n </Button>\n ) : null}\n </Body>\n </CSSTransition>\n </div>\n );\n};\n\nexport default withNextPortal(Snackbar);\n"],"names":["CSS_TRANSITION_DURATION","Snackbar","props","bodyRef","useRef","leaveTimeout","transitionTimeout","committedProps","state","setState","useState","visible","text","useEffect","window","clearTimeout","current","previousProps","action","timestamp","updateWhileTextIsPresent","update","setLeaveTimeout","setTimeout","timeout","show","_jsx","className","role","children","CSSTransition","nodeRef","in","classNames","appear","enter","exit","unmountOnExit","_jsxs","Body","ref","as","Button","v2","size","onClick","label","withNextPortal"],"mappings":";;;;;;;AAQA,MAAMA,uBAAuB,GAAG,GAAG;AAkB5B,MAAMC,QAAQ,GAAIC,KAAoB,IAAI;AAC/C,EAAA,MAAMC,OAAO,GAAGC,MAAM,CAAkB,IAAI,CAAC;AAC7C,EAAA,MAAMC,YAAY,GAAGD,MAAM,CAAC,CAAC,CAAC;AAC9B,EAAA,MAAME,iBAAiB,GAAGF,MAAM,CAAC,CAAC,CAAC;AACnC;AACA,EAAA,MAAMG,cAAc,GAAGH,MAAM,CAACF,KAAK,CAAC;AAEpC,EAAA,MAAM,CAACM,KAAK,EAAEC,QAAQ,CAAC,GAAGC,QAAQ,CAAgB;AAChDC,IAAAA,OAAO,EAAE,KAAK;AACdC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MAAM;AAACd,QAAAA,SAAS,EAAC,gBAAgB;AAAAE,QAAAA,QAAA,GACrDjB,IAAI,EACJM,MAAM,gBACLQ,GAAA,CAACgB,MAAM,EAAA;AAACf,UAAAA,SAAS,EAAC,wBAAwB;UAACgB,EAAE,EAAA,IAAA;AAACC,UAAAA,IAAI,EAAC,IAAI;UAACC,OAAO,EAAE3B,MAAM,CAAC2B,OAAQ;UAAAhB,QAAA,EAC7EX,MAAM,CAAC4B;SACF,CAAC,GACP,IAAI;OACJ;KACO;AACjB,GAAK,CAAC;AAEV;AAEA,qBAAeC,qBAAc,CAAC9C,QAAQ,CAAC;;"}
|
|
@@ -1,3 +1,28 @@
|
|
|
1
1
|
import type { CarouselCard } from '../Carousel';
|
|
2
|
+
/**
|
|
3
|
+
* Every string the stubbed cards render, shaped as a `withRTLDiff({ i18n })` map so the RTL diff
|
|
4
|
+
* can spread it — that call site is what type-checks the shape against `I18nMap`. The type is not
|
|
5
|
+
* imported here: this file is part of the Rollup build, which cannot emit declarations that
|
|
6
|
+
* reference `.storybook/`. The promo card's `Wise` title is a brand name and stays in Latin script.
|
|
7
|
+
*/
|
|
8
|
+
export declare const carouselCardsI18n: {
|
|
9
|
+
globeCardTitle: {
|
|
10
|
+
en: string;
|
|
11
|
+
ar: string;
|
|
12
|
+
};
|
|
13
|
+
promoDescription: {
|
|
14
|
+
en: string;
|
|
15
|
+
ar: string;
|
|
16
|
+
};
|
|
17
|
+
quickPayCardTitle: {
|
|
18
|
+
en: string;
|
|
19
|
+
ar: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Takes copy already resolved for one language — exactly what `useRtlDiffI18n()` returns — so the
|
|
24
|
+
* same fixture serves the single-direction stories and the RTL diff.
|
|
25
|
+
*/
|
|
26
|
+
export declare const getStubbedCarouselCards: (i18n: Record<string, string>) => CarouselCard[];
|
|
2
27
|
export declare const stubbedCarouselCards: CarouselCard[];
|
|
3
28
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/Carousel/_stories/constants.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/Carousel/_stories/constants.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;CAO7B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAAI,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAG,YAAY,EAyClF,CAAC;AAMF,eAAO,MAAM,oBAAoB,gBAAuC,CAAC"}
|
|
@@ -1,10 +1,47 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
1
2
|
import { StoryObj } from '@storybook/react-webpack5';
|
|
3
|
+
import { type ListItemProps } from '../../ListItem';
|
|
2
4
|
import { SB_ListItem_ControlType as ControlType } from '../subcomponents';
|
|
5
|
+
type VariantPartial = {
|
|
6
|
+
title: string;
|
|
7
|
+
} & Partial<ListItemProps>;
|
|
3
8
|
type Variant = 'default' | 'dark' | 'rtl' | 'forest-green' | 'bright-green' | 'mobile' | '400%';
|
|
4
|
-
type
|
|
9
|
+
export type VariantText = {
|
|
10
|
+
title: string;
|
|
11
|
+
subtitle: string;
|
|
12
|
+
valueTitle: string;
|
|
13
|
+
valueSubtitle: string;
|
|
14
|
+
longTitle: string;
|
|
15
|
+
longSubtitle: string;
|
|
16
|
+
longValueTitle: ReactNode;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Every piece of copy and every slot the instance matrix is built from. Extracted so a story can
|
|
20
|
+
* render the same matrix with different content — the RTL diff swaps in localised versions.
|
|
21
|
+
*/
|
|
22
|
+
export type VariantContent = {
|
|
23
|
+
text: VariantText;
|
|
24
|
+
media: ReactNode;
|
|
25
|
+
additionalInfo: {
|
|
26
|
+
interactive: ReactNode;
|
|
27
|
+
nonInteractive: ReactNode;
|
|
28
|
+
};
|
|
29
|
+
prompt: {
|
|
30
|
+
interactive: ReactNode;
|
|
31
|
+
nonInteractive: ReactNode;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export declare const DEFAULT_VARIANT_CONTENT: VariantContent;
|
|
35
|
+
export declare const getVariantInstances: (controlType: ControlType, { text, media, additionalInfo: info, prompt: prompts }: VariantContent) => VariantPartial[];
|
|
36
|
+
export type VariantStoryProps = {
|
|
5
37
|
controlType: ControlType;
|
|
6
38
|
variant?: Variant;
|
|
7
39
|
};
|
|
40
|
+
type VariantListProps = VariantStoryProps & {
|
|
41
|
+
content?: VariantContent;
|
|
42
|
+
controls?: Record<ControlType, ReactNode>;
|
|
43
|
+
};
|
|
44
|
+
export declare const VariantList: ({ controlType, variant, content, controls, }: VariantListProps) => import("react").JSX.Element;
|
|
8
45
|
type VariantStory = StoryObj<VariantStoryProps>;
|
|
9
46
|
export declare const VariantStory: VariantStory;
|
|
10
47
|
export {};
|