pne-ui 5.0.0-rc.13 → 5.0.0-rc.14
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/README.md +11 -0
- package/cjs/component/PneModal.js +4 -29
- package/cjs/component/iconActionLook.js +42 -0
- package/cjs/component/overlay/OverlayHost.js +17 -55
- package/cjs/component/overlay/OverlayToast.js +124 -0
- package/cjs/component/overlay/overlayStore.js +8 -6
- package/cjs/createTheme.js +2 -0
- package/cjs/toastPalette.js +30 -0
- package/esm/component/PneModal.js +4 -29
- package/esm/component/iconActionLook.d.ts +8 -0
- package/esm/component/iconActionLook.js +38 -0
- package/esm/component/overlay/OverlayHost.js +18 -56
- package/esm/component/overlay/OverlayToast.d.ts +31 -0
- package/esm/component/overlay/OverlayToast.js +121 -0
- package/esm/component/overlay/overlayStore.js +8 -6
- package/esm/component/overlay/types.d.ts +3 -0
- package/esm/createTheme.d.ts +3 -0
- package/esm/createTheme.js +2 -0
- package/esm/exports/theme.d.ts +1 -0
- package/esm/toastPalette.d.ts +22 -0
- package/esm/toastPalette.js +26 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2578,6 +2578,17 @@ const OwnChip = ({children}: {children: React.ReactNode}) => {
|
|
|
2578
2578
|
|
|
2579
2579
|
## OverlayHost и уведомления
|
|
2580
2580
|
|
|
2581
|
+
Вид уведомлений (UI Kit Toast и Banner). Каждое уведомление шириной 448 px (на телефоне — по ширине экрана),
|
|
2582
|
+
между уведомлениями 8 px; нижние рисуются поверх теней верхних. Тост залит цветом своего тона (успех — зелёный,
|
|
2583
|
+
информация — синий, предупреждение — янтарный, ошибка — красный), скругление 8, отступы 8/16, тень тоста; значка
|
|
2584
|
+
тона нет. `message` — заголовок 18/26 SemiBold, необязательное `description` — вторая строка 12/16 цветом текста
|
|
2585
|
+
тона. Справа, в 64 px от текста, стоят действие потребителя (`action`) и крестик — значок 16 px в кнопке 32 px
|
|
2586
|
+
без заливки, цветом текста тона; крестик есть и рядом с действием. Полоса таймера 3 px идёт по нижнему краю и
|
|
2587
|
+
убывает влево. Кнопка «Undo» из `showUndoSnackbar` — мягкая `small` с подписью цвета основного текста, без значка.
|
|
2588
|
+
Ошибка Paynet с идентификатором и деталями (`showError({error})`) — баннер: бледная заливка тона в кольце его
|
|
2589
|
+
цвета, отступы 12/16, знак тона 20 px слева, крестик 24 px. Цвета — `theme.palette.pne.toast`, одинаковые для
|
|
2590
|
+
всех скинов.
|
|
2591
|
+
|
|
2581
2592
|
`OverlayHost` рендерит snackbars из `overlayActions` и принимает декларативные постоянные оверлеи через `PermanentOverlay`
|
|
2582
2593
|
(по одному на слот: `top-left/top-right/bottom-left/bottom-right`).
|
|
2583
2594
|
```tsx
|
|
@@ -9,6 +9,7 @@ const styles_1 = require("@mui/material/styles");
|
|
|
9
9
|
const React = tslib_1.__importStar(require("react"));
|
|
10
10
|
const createTheme_1 = require("../createTheme");
|
|
11
11
|
const dropdownLook_1 = require("./dropdown/dropdownLook");
|
|
12
|
+
const iconActionLook_1 = require("./iconActionLook");
|
|
12
13
|
const PneSurface_1 = require("./internal/PneSurface");
|
|
13
14
|
const PneModal = React.forwardRef(function PneModal(props, ref) {
|
|
14
15
|
const { actions, ariaDescribedBy, ariaLabel, blockingOverlay, children, className, closeButtonProps, closeLabel = 'Close', containerProps, containerSx, hideCloseButton = false, modalProps, onClose, open, overlay, slotProps, subtitle, title, ...directContainerDataAttributes } = props;
|
|
@@ -103,7 +104,7 @@ const PneModal = React.forwardRef(function PneModal(props, ref) {
|
|
|
103
104
|
modalSubtitleSx,
|
|
104
105
|
...(Array.isArray(subtitleSx) ? subtitleSx : [subtitleSx]),
|
|
105
106
|
] }, subtitle)),
|
|
106
|
-
!hideCloseButton && React.createElement(IconButton_1.default, { ...forwardedCloseButtonProps, "aria-label": resolvedCloseLabel, inert: isBlocked ? true : undefined, sx: modalCloseButtonSx, onClick: handleCloseButtonClick, type: 'button' },
|
|
107
|
+
!hideCloseButton && React.createElement(IconButton_1.default, { ...forwardedCloseButtonProps, "aria-label": resolvedCloseLabel, inert: isBlocked ? true : undefined, disableRipple: true, sx: modalCloseButtonSx, onClick: handleCloseButtonClick, type: 'button' },
|
|
107
108
|
React.createElement(dropdownLook_1.PneCloseIcon, null))),
|
|
108
109
|
children != null && React.createElement(Body, { ...forwardedBodyProps, "data-pne-modal-body": 'true', "data-pne-modal-last": actions == null ? 'true' : undefined, inert: isBlocked ? true : forwardedBodyProps.inert }, children),
|
|
109
110
|
actions != null && React.createElement(Footer, { ...forwardedFooterProps, "data-pne-modal-footer": 'true', inert: isBlocked ? true : forwardedFooterProps.inert }, actions),
|
|
@@ -372,34 +373,8 @@ const modalSubtitleSx = theme => ({
|
|
|
372
373
|
lineHeight: '16px',
|
|
373
374
|
color: (0, createTheme_1.resolvePneSemanticPalette)(theme).modal.subtitle,
|
|
374
375
|
});
|
|
375
|
-
// UI Kit Icon action: a 32px
|
|
376
|
-
const modalCloseButtonSx =
|
|
377
|
-
const pne = (0, createTheme_1.resolvePneSemanticPalette)(theme);
|
|
378
|
-
const colors = pne.button.text;
|
|
379
|
-
return {
|
|
380
|
-
flex: '0 0 auto',
|
|
381
|
-
width: '32px',
|
|
382
|
-
height: '32px',
|
|
383
|
-
padding: 0,
|
|
384
|
-
borderRadius: '4px',
|
|
385
|
-
backgroundColor: 'transparent',
|
|
386
|
-
color: colors.default.text,
|
|
387
|
-
'& .MuiSvgIcon-root': {
|
|
388
|
-
fontSize: '16px',
|
|
389
|
-
},
|
|
390
|
-
'&:hover': {
|
|
391
|
-
backgroundColor: colors.hover.fill,
|
|
392
|
-
color: colors.hover.text,
|
|
393
|
-
},
|
|
394
|
-
'&:active': {
|
|
395
|
-
backgroundColor: colors.pressed.fill,
|
|
396
|
-
color: colors.pressed.text,
|
|
397
|
-
},
|
|
398
|
-
'&.Mui-focusVisible': {
|
|
399
|
-
boxShadow: `0 0 0 2px ${pne.modal.fill}, 0 0 0 4px ${pne.focusRing}`,
|
|
400
|
-
},
|
|
401
|
-
};
|
|
402
|
-
};
|
|
376
|
+
// UI Kit Icon action md: a 32px box with the 16px thin cross; hover and press colour only the icon.
|
|
377
|
+
const modalCloseButtonSx = (0, iconActionLook_1.pneIconActionSx)('medium');
|
|
403
378
|
const BlockingOverlaySlot = (0, styles_1.styled)(Box_1.default) `
|
|
404
379
|
position: absolute;
|
|
405
380
|
inset: 0;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pneIconActionSx = void 0;
|
|
4
|
+
const createTheme_1 = require("../createTheme");
|
|
5
|
+
const themeColors_1 = require("../themeColors");
|
|
6
|
+
/**
|
|
7
|
+
* UI Kit Icon action on a MUI IconButton: an icon button with no background, where hover and press
|
|
8
|
+
* colour only the icon. `medium` is a 32px box with a 16px glyph (the close cross of a modal and of
|
|
9
|
+
* a toast), `small` a 24px box with a 14px glyph. The icon rests in the tertiary text colour, or in
|
|
10
|
+
* `restColor` (the tone of a toast), and takes the brand text colour under the pointer.
|
|
11
|
+
*/
|
|
12
|
+
const pneIconActionSx = (size, restColor) => theme => {
|
|
13
|
+
const pne = (0, createTheme_1.resolvePneSemanticPalette)(theme);
|
|
14
|
+
const dark = theme.palette.mode === 'dark';
|
|
15
|
+
const box = size === 'small' ? '24px' : '32px';
|
|
16
|
+
return {
|
|
17
|
+
flex: '0 0 auto',
|
|
18
|
+
width: box,
|
|
19
|
+
height: box,
|
|
20
|
+
padding: 0,
|
|
21
|
+
borderRadius: '4px',
|
|
22
|
+
backgroundColor: 'transparent',
|
|
23
|
+
color: restColor ?? (dark ? themeColors_1.PNE_DARK_COLORS.textMuted : themeColors_1.PNE_NEUTRAL_RAMP[600]),
|
|
24
|
+
'& .MuiSvgIcon-root': {
|
|
25
|
+
fontSize: size === 'small' ? '14px' : '16px',
|
|
26
|
+
},
|
|
27
|
+
'&:hover': {
|
|
28
|
+
backgroundColor: 'transparent',
|
|
29
|
+
color: pne.button.text.hover.text,
|
|
30
|
+
},
|
|
31
|
+
'&:active': {
|
|
32
|
+
color: pne.button.text.pressed.text,
|
|
33
|
+
},
|
|
34
|
+
'&.Mui-focusVisible': {
|
|
35
|
+
boxShadow: `0 0 0 2px ${theme.palette.background.paper}, 0 0 0 4px ${pne.focusRing}`,
|
|
36
|
+
},
|
|
37
|
+
'&.Mui-disabled': {
|
|
38
|
+
color: dark ? themeColors_1.PNE_DARK_COLORS.textDisabled : themeColors_1.PNE_NEUTRAL_RAMP[400],
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
exports.pneIconActionSx = pneIconActionSx;
|
|
@@ -11,6 +11,8 @@ const PermanentOverlayContext_1 = require("./PermanentOverlayContext");
|
|
|
11
11
|
const OverlayPortalContainerContext_1 = require("./OverlayPortalContainerContext");
|
|
12
12
|
const PaynetErrorPresentationContext_1 = require("./PaynetErrorPresentationContext");
|
|
13
13
|
const overlayRuntime_1 = require("./overlayRuntime");
|
|
14
|
+
const OverlayToast_1 = tslib_1.__importDefault(require("./OverlayToast"));
|
|
15
|
+
const PaynetErrorContent_1 = tslib_1.__importDefault(require("./PaynetErrorContent"));
|
|
14
16
|
/**
|
|
15
17
|
* Final left coordinates matching the adaptive Paynet menu shell:
|
|
16
18
|
* no reserved menu below 1080px, a collapsed rail below 1600px,
|
|
@@ -25,6 +27,8 @@ exports.PAYNET_LEFT_MENU_OVERLAY_OFFSET = {
|
|
|
25
27
|
],
|
|
26
28
|
};
|
|
27
29
|
const STACK_GAP = 12;
|
|
30
|
+
// UI Kit OverlayHost: 8px between notifications.
|
|
31
|
+
const NOTIFICATION_GAP = 8;
|
|
28
32
|
const STACK_OFFSET = 24;
|
|
29
33
|
const OPERATION_CENTER_OFFSET = 16;
|
|
30
34
|
const STACK_REFLOW_DURATION_MS = 200;
|
|
@@ -65,6 +69,9 @@ const clearTimer = (timer) => {
|
|
|
65
69
|
clearTimeout(timer);
|
|
66
70
|
}
|
|
67
71
|
};
|
|
72
|
+
const NOTIFICATION_WIDTH = 448;
|
|
73
|
+
// An error with an identifier and details is a banner, not a toast (UI Kit OverlayHost).
|
|
74
|
+
const isPaynetErrorMessage = (message) => react_1.default.isValidElement(message) && message.type === PaynetErrorContent_1.default;
|
|
68
75
|
const ManagedSnackbar = ({ anchor, onExited, open, onRemove, prefersReducedMotion, snack, }) => {
|
|
69
76
|
const autoHideMs = typeof snack.autoHideMs === 'number' && snack.autoHideMs > 0 ? snack.autoHideMs : null;
|
|
70
77
|
const [remainingMs, setRemainingMs] = (0, react_1.useState)(autoHideMs);
|
|
@@ -168,59 +175,11 @@ const ManagedSnackbar = ({ anchor, onExited, open, onRemove, prefersReducedMotio
|
|
|
168
175
|
position: 'static',
|
|
169
176
|
transform: 'none',
|
|
170
177
|
pointerEvents: open ? 'auto' : 'none',
|
|
171
|
-
|
|
178
|
+
// UI Kit OverlayHost: every notification is 448px wide, or as wide as a phone lets it be.
|
|
172
179
|
maxWidth: 'calc(100vw - 32px)',
|
|
173
|
-
width:
|
|
180
|
+
width: `${NOTIFICATION_WIDTH}px`,
|
|
174
181
|
} },
|
|
175
|
-
react_1.default.createElement(
|
|
176
|
-
boxSizing: 'border-box',
|
|
177
|
-
position: 'relative',
|
|
178
|
-
overflow: 'hidden',
|
|
179
|
-
alignItems: 'flex-start',
|
|
180
|
-
maxWidth: '100%',
|
|
181
|
-
width: '100%',
|
|
182
|
-
'& .MuiAlert-message': {
|
|
183
|
-
minWidth: 0,
|
|
184
|
-
},
|
|
185
|
-
...(snack.action != null ? {
|
|
186
|
-
'& .MuiAlert-action': {
|
|
187
|
-
alignItems: 'flex-start',
|
|
188
|
-
},
|
|
189
|
-
} : {
|
|
190
|
-
'& .MuiAlert-action': {
|
|
191
|
-
alignItems: 'stretch',
|
|
192
|
-
alignSelf: 'stretch',
|
|
193
|
-
mb: '-6px',
|
|
194
|
-
mr: '-16px',
|
|
195
|
-
mt: '-6px',
|
|
196
|
-
pb: 0,
|
|
197
|
-
pl: '8px',
|
|
198
|
-
pt: 0,
|
|
199
|
-
},
|
|
200
|
-
'& .MuiAlert-action .MuiIconButton-root': {
|
|
201
|
-
alignItems: 'flex-start',
|
|
202
|
-
alignSelf: 'stretch',
|
|
203
|
-
borderRadius: 0,
|
|
204
|
-
pb: 0,
|
|
205
|
-
pl: '13px',
|
|
206
|
-
pr: '13px',
|
|
207
|
-
pt: '15px',
|
|
208
|
-
},
|
|
209
|
-
}),
|
|
210
|
-
} },
|
|
211
|
-
progressScale != null && !prefersReducedMotion ? (react_1.default.createElement(material_1.Box, { "data-testid": 'overlay-snackbar-progress', sx: {
|
|
212
|
-
position: 'absolute',
|
|
213
|
-
top: 0,
|
|
214
|
-
left: 0,
|
|
215
|
-
right: 0,
|
|
216
|
-
height: '3px',
|
|
217
|
-
backgroundColor: 'currentColor',
|
|
218
|
-
opacity: 0.24,
|
|
219
|
-
transformOrigin: 'left',
|
|
220
|
-
transform: `scaleX(${progressScale})`,
|
|
221
|
-
pointerEvents: 'none',
|
|
222
|
-
} })) : null,
|
|
223
|
-
snack.message)));
|
|
182
|
+
react_1.default.createElement(OverlayToast_1.default, { action: snack.action, description: snack.description, onClose: remove, presentation: isPaynetErrorMessage(snack.message) ? 'banner' : 'toast', progress: prefersReducedMotion ? null : progressScale, tone: snack.variant ?? 'info' }, snack.message)));
|
|
224
183
|
};
|
|
225
184
|
const MeasuredSnackbarStack = ({ anchor, breakpoint, completeExitPart, items, leftOffset, operationCenterElement, operationCenterHeight, prefersReducedMotion, removeSnackbar, }) => {
|
|
226
185
|
const [stackElement, setStackElement] = (0, react_1.useState)(null);
|
|
@@ -243,13 +202,13 @@ const MeasuredSnackbarStack = ({ anchor, breakpoint, completeExitPart, items, le
|
|
|
243
202
|
: {
|
|
244
203
|
bottom: sharesOperationBottom
|
|
245
204
|
? operationCenterHeight + OPERATION_CENTER_OFFSET
|
|
246
|
-
: STACK_OFFSET -
|
|
205
|
+
: STACK_OFFSET - NOTIFICATION_GAP,
|
|
247
206
|
top: 'auto',
|
|
248
207
|
flexDirection: 'column-reverse',
|
|
249
208
|
'@supports (bottom: env(safe-area-inset-bottom))': {
|
|
250
209
|
bottom: sharesOperationBottom
|
|
251
210
|
? `calc(${operationCenterHeight + OPERATION_CENTER_OFFSET}px + env(safe-area-inset-bottom, 0px))`
|
|
252
|
-
: `calc(${STACK_OFFSET -
|
|
211
|
+
: `calc(${STACK_OFFSET - NOTIFICATION_GAP}px + env(safe-area-inset-bottom, 0px))`,
|
|
253
212
|
},
|
|
254
213
|
};
|
|
255
214
|
return (react_1.default.createElement(material_1.Box, { "data-pne-overlay-stack": `${anchor.vertical}-${anchor.horizontal}`, ref: setStackElement, sx: {
|
|
@@ -260,8 +219,11 @@ const MeasuredSnackbarStack = ({ anchor, breakpoint, completeExitPart, items, le
|
|
|
260
219
|
pointerEvents: 'none',
|
|
261
220
|
...horizontalStyles,
|
|
262
221
|
...verticalStyles,
|
|
263
|
-
} }, items.map(({ open, presentationKey, snack }) => (react_1.default.createElement(material_1.Collapse, { key: presentationKey, appear: false, enter: false, in: open, onExited: () => completeExitPart(presentationKey, 'collapse'),
|
|
264
|
-
|
|
222
|
+
} }, items.map(({ open, presentationKey, snack }, index) => (react_1.default.createElement(material_1.Collapse, { key: presentationKey, appear: false, enter: false, in: open, onExited: () => completeExitPart(presentationKey, 'collapse'),
|
|
223
|
+
// The first item stands lowest. A toast casts a long shadow downwards, so each item is
|
|
224
|
+
// drawn over the ones above it and no shadow falls on a neighbour's face.
|
|
225
|
+
sx: { position: 'relative', zIndex: items.length - index }, timeout: prefersReducedMotion ? 0 : STACK_REFLOW_DURATION_MS },
|
|
226
|
+
react_1.default.createElement(material_1.Box, { "data-pne-overlay-stack-item": true, sx: { pb: `${NOTIFICATION_GAP}px` } },
|
|
265
227
|
react_1.default.createElement(ManagedSnackbar, { anchor: anchor, onExited: () => completeExitPart(presentationKey, 'grow'), open: open, onRemove: removeSnackbar, prefersReducedMotion: prefersReducedMotion, snack: snack })))))));
|
|
266
228
|
};
|
|
267
229
|
const MeasuredPermanentOverlay = ({ breakpoint, content, entry, operationCenterElement, operationCenterHeight, }) => {
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const material_1 = require("@mui/material");
|
|
5
|
+
const React = tslib_1.__importStar(require("react"));
|
|
6
|
+
const createTheme_1 = require("../../createTheme");
|
|
7
|
+
const dropdownLook_1 = require("../dropdown/dropdownLook");
|
|
8
|
+
const iconActionLook_1 = require("../iconActionLook");
|
|
9
|
+
/**
|
|
10
|
+
* One notification of OverlayHost by the UI Kit.
|
|
11
|
+
* Toast: a card filled with the colour of its tone, radius 8, 8/16 inside, the toast shadow; the
|
|
12
|
+
* message as the title (18/26 SemiBold) over an optional description (12/16 in the text colour of
|
|
13
|
+
* the tone); the consumer's action and a 32px close cross on the right, 64px from the text; a 3px
|
|
14
|
+
* timer bar along the bottom that shrinks to the left. No sign of the tone.
|
|
15
|
+
* Banner (an error with details): the pale fill of the tone inside a ring of its colour, 12/16
|
|
16
|
+
* inside, the 20px sign of the tone on the left, a 24px close cross.
|
|
17
|
+
*/
|
|
18
|
+
// The snackbar's transition holds the card by its ref and style, so both go to the root.
|
|
19
|
+
const OverlayToast = React.forwardRef(function OverlayToast({ action, children, closeLabel = 'Close', description, onClose, presentation = 'toast', progress, style, tone = 'info', }, ref) {
|
|
20
|
+
const isBanner = presentation === 'banner';
|
|
21
|
+
return React.createElement(material_1.Alert, { ref: ref, style: style, action: React.createElement(React.Fragment, null,
|
|
22
|
+
action,
|
|
23
|
+
onClose ? React.createElement(material_1.IconButton, { "aria-label": closeLabel, "data-pne-toast-close": 'true', disableRipple: true, onClick: onClose, sx: (0, iconActionLook_1.pneIconActionSx)(isBanner ? 'small' : 'medium', 'var(--pne-toast-text)'), title: closeLabel, type: 'button' },
|
|
24
|
+
React.createElement(dropdownLook_1.PneCloseIcon, null)) : null), "data-pne-toast": presentation, "data-pne-tone": tone, elevation: 0, icon: isBanner ? undefined : false, severity: tone, sx: overlayToastSx },
|
|
25
|
+
progress != null ? React.createElement("span", { "aria-hidden": 'true', "data-pne-toast-timer": 'true', "data-testid": 'overlay-snackbar-progress', style: { transform: `scaleX(${progress})` } }) : null,
|
|
26
|
+
isBanner ? children : React.createElement(React.Fragment, null,
|
|
27
|
+
React.createElement("span", { "data-pne-toast-title": 'true' }, children),
|
|
28
|
+
description != null && description !== ''
|
|
29
|
+
? React.createElement("span", { "data-pne-toast-description": 'true' }, description)
|
|
30
|
+
: null));
|
|
31
|
+
});
|
|
32
|
+
exports.default = OverlayToast;
|
|
33
|
+
const TONES = ['info', 'success', 'warning', 'error'];
|
|
34
|
+
const overlayToastSx = theme => {
|
|
35
|
+
const toast = (0, createTheme_1.resolvePneSemanticPalette)(theme).toast;
|
|
36
|
+
const rules = {
|
|
37
|
+
'&': {
|
|
38
|
+
alignItems: 'center',
|
|
39
|
+
borderRadius: '8px',
|
|
40
|
+
boxShadow: toast.shadow,
|
|
41
|
+
boxSizing: 'border-box',
|
|
42
|
+
color: toast.title,
|
|
43
|
+
maxWidth: '100%',
|
|
44
|
+
overflow: 'hidden',
|
|
45
|
+
padding: '8px 16px',
|
|
46
|
+
position: 'relative',
|
|
47
|
+
width: '100%',
|
|
48
|
+
},
|
|
49
|
+
'& .MuiAlert-message': {
|
|
50
|
+
display: 'flex',
|
|
51
|
+
flex: '1 1 auto',
|
|
52
|
+
flexDirection: 'column',
|
|
53
|
+
minWidth: 0,
|
|
54
|
+
overflow: 'visible',
|
|
55
|
+
padding: 0,
|
|
56
|
+
},
|
|
57
|
+
// The actions keep 64px from the text; on a phone the text needs that room itself.
|
|
58
|
+
'& .MuiAlert-action': {
|
|
59
|
+
alignItems: 'center',
|
|
60
|
+
display: 'flex',
|
|
61
|
+
flex: '0 0 auto',
|
|
62
|
+
gap: '8px',
|
|
63
|
+
margin: 0,
|
|
64
|
+
padding: '0 0 0 64px',
|
|
65
|
+
'@media (max-width: 480px)': {
|
|
66
|
+
paddingLeft: '16px',
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
'& [data-pne-toast-title]': {
|
|
70
|
+
fontSize: '18px',
|
|
71
|
+
fontWeight: 600,
|
|
72
|
+
lineHeight: '26px',
|
|
73
|
+
overflowWrap: 'anywhere',
|
|
74
|
+
},
|
|
75
|
+
'& [data-pne-toast-description]': {
|
|
76
|
+
color: 'var(--pne-toast-text)',
|
|
77
|
+
fontSize: '12px',
|
|
78
|
+
lineHeight: '16px',
|
|
79
|
+
overflowWrap: 'anywhere',
|
|
80
|
+
},
|
|
81
|
+
'& [data-pne-toast-timer]': {
|
|
82
|
+
backgroundColor: 'var(--pne-toast-text)',
|
|
83
|
+
bottom: 0,
|
|
84
|
+
height: '3px',
|
|
85
|
+
left: 0,
|
|
86
|
+
pointerEvents: 'none',
|
|
87
|
+
position: 'absolute',
|
|
88
|
+
right: 0,
|
|
89
|
+
transformOrigin: 'left',
|
|
90
|
+
},
|
|
91
|
+
// Banner: an error with an identifier and details.
|
|
92
|
+
'&[data-pne-toast="banner"]': {
|
|
93
|
+
alignItems: 'flex-start',
|
|
94
|
+
padding: '12px 16px',
|
|
95
|
+
},
|
|
96
|
+
'&[data-pne-toast="banner"] .MuiAlert-icon': {
|
|
97
|
+
color: 'var(--pne-toast-text)',
|
|
98
|
+
fontSize: '20px',
|
|
99
|
+
marginRight: '12px',
|
|
100
|
+
opacity: 1,
|
|
101
|
+
padding: 0,
|
|
102
|
+
},
|
|
103
|
+
'&[data-pne-toast="banner"] .MuiAlert-message': {
|
|
104
|
+
fontSize: '14px',
|
|
105
|
+
lineHeight: '20px',
|
|
106
|
+
},
|
|
107
|
+
'&[data-pne-toast="banner"] .MuiAlert-action': {
|
|
108
|
+
alignItems: 'flex-start',
|
|
109
|
+
paddingLeft: '12px',
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
for (const tone of TONES) {
|
|
113
|
+
const colors = toast[tone];
|
|
114
|
+
rules[`&[data-pne-tone="${tone}"]`] = {
|
|
115
|
+
'--pne-toast-text': colors.text,
|
|
116
|
+
backgroundColor: colors.fill,
|
|
117
|
+
};
|
|
118
|
+
rules[`&[data-pne-toast="banner"][data-pne-tone="${tone}"]`] = {
|
|
119
|
+
backgroundColor: colors.bannerFill,
|
|
120
|
+
boxShadow: `inset 0 0 0 1px ${colors.fill}, ${toast.shadow}`,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
return rules;
|
|
124
|
+
};
|
|
@@ -3,13 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.overlayActions = exports.useOverlayStore = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
-
const
|
|
6
|
+
const createTheme_1 = require("../../createTheme");
|
|
7
7
|
const PneButton_1 = tslib_1.__importDefault(require("../PneButton"));
|
|
8
8
|
const zustand_1 = require("zustand");
|
|
9
9
|
const overlayRuntime_1 = require("./overlayRuntime");
|
|
10
10
|
const paynetError_1 = require("./paynetError");
|
|
11
11
|
const PaynetErrorContent_1 = require("./PaynetErrorContent");
|
|
12
12
|
const defaultAutoHideMs = 5000;
|
|
13
|
+
// The label of a toast's action reads as the primary text on the soft fill, whatever the skin.
|
|
14
|
+
const toastActionSx = theme => ({
|
|
15
|
+
color: (0, createTheme_1.resolvePneSemanticPalette)(theme).toast.title,
|
|
16
|
+
});
|
|
13
17
|
const makeId = () => {
|
|
14
18
|
if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
|
|
15
19
|
return crypto.randomUUID();
|
|
@@ -96,16 +100,14 @@ exports.overlayActions = {
|
|
|
96
100
|
...snackbar,
|
|
97
101
|
id,
|
|
98
102
|
action: react_1.default.createElement(PneButton_1.default, {
|
|
99
|
-
|
|
103
|
+
// UI Kit Toast: a soft small button whose label reads as the primary text.
|
|
104
|
+
pneStyle: 'neutral',
|
|
100
105
|
size: 'small',
|
|
101
|
-
startIcon: react_1.default.createElement(Undo_1.default, { fontSize: 'inherit' }),
|
|
102
106
|
onClick: () => {
|
|
103
107
|
exports.useOverlayStore.getState().removeSnackbar(id);
|
|
104
108
|
onUndo();
|
|
105
109
|
},
|
|
106
|
-
sx:
|
|
107
|
-
fontWeight: 600,
|
|
108
|
-
},
|
|
110
|
+
sx: toastActionSx,
|
|
109
111
|
}, undoLabel),
|
|
110
112
|
});
|
|
111
113
|
return id;
|
package/cjs/createTheme.js
CHANGED
|
@@ -8,6 +8,7 @@ const buttonPalette_1 = require("./buttonPalette");
|
|
|
8
8
|
const checkboxPalette_1 = require("./checkboxPalette");
|
|
9
9
|
const dropdownPalette_1 = require("./dropdownPalette");
|
|
10
10
|
const modalPalette_1 = require("./modalPalette");
|
|
11
|
+
const toastPalette_1 = require("./toastPalette");
|
|
11
12
|
const fieldPalette_1 = require("./fieldPalette");
|
|
12
13
|
const switchPalette_1 = require("./switchPalette");
|
|
13
14
|
const themeColors_1 = require("./themeColors");
|
|
@@ -104,6 +105,7 @@ const createSemanticPalette = (seed, mode) => {
|
|
|
104
105
|
field: (0, fieldPalette_1.createPneFieldPalette)(ramp, mode),
|
|
105
106
|
dropdown: (0, dropdownPalette_1.createPneDropdownPalette)(ramp, mode),
|
|
106
107
|
modal: (0, modalPalette_1.createPneModalPalette)(mode),
|
|
108
|
+
toast: (0, toastPalette_1.createPneToastPalette)(mode),
|
|
107
109
|
focusRing: (0, buttonPalette_1.createPneFocusRing)(ramp, mode),
|
|
108
110
|
link: (0, buttonPalette_1.createPneLinkColor)(ramp, mode),
|
|
109
111
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createPneToastPalette = void 0;
|
|
4
|
+
const themeColors_1 = require("./themeColors");
|
|
5
|
+
// The UI Kit blue of the Info tone: a fixed ramp, not the brand ramp of the skin.
|
|
6
|
+
const INFO = { 100: '#EBF3FF', 300: '#B3D4FF', 700: '#005EB9', 900: '#003670' };
|
|
7
|
+
// UI Kit `--elevation-toast` (Figma effect style NW).
|
|
8
|
+
const TOAST_SHADOW = '0 -1px 12px rgba(0,0,0,0.03), 0 3px 3px rgba(2,0,107,0.02), 0 7px 6px rgba(0,11,70,0.03), '
|
|
9
|
+
+ '0 12px 10px rgba(0,0,98,0.03), 0 22px 18px rgba(0,15,44,0.04), 0 40px 33px rgba(0,10,255,0.05), '
|
|
10
|
+
+ '0 100px 80px rgba(0,0,0,0.07)';
|
|
11
|
+
const RAMPS = {
|
|
12
|
+
info: INFO,
|
|
13
|
+
success: themeColors_1.PNE_STATUS_COLORS.success,
|
|
14
|
+
warning: themeColors_1.PNE_STATUS_COLORS.warning,
|
|
15
|
+
error: themeColors_1.PNE_STATUS_COLORS.error,
|
|
16
|
+
};
|
|
17
|
+
const TONES = Object.keys(RAMPS);
|
|
18
|
+
const tones = (pick) => Object.fromEntries(TONES.map(tone => [tone, pick(RAMPS[tone])]));
|
|
19
|
+
const createPneToastPalette = (mode) => mode === 'dark'
|
|
20
|
+
? {
|
|
21
|
+
...tones(ramp => ({ fill: ramp[700], text: ramp[300], bannerFill: ramp[900] })),
|
|
22
|
+
title: themeColors_1.PNE_DARK_COLORS.textPrimary,
|
|
23
|
+
shadow: TOAST_SHADOW,
|
|
24
|
+
}
|
|
25
|
+
: {
|
|
26
|
+
...tones(ramp => ({ fill: ramp[300], text: ramp[700], bannerFill: ramp[100] })),
|
|
27
|
+
title: themeColors_1.PNE_NEUTRAL_RAMP[900],
|
|
28
|
+
shadow: TOAST_SHADOW,
|
|
29
|
+
};
|
|
30
|
+
exports.createPneToastPalette = createPneToastPalette;
|
|
@@ -6,6 +6,7 @@ import { styled } from '@mui/material/styles';
|
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import { resolvePneSemanticPalette } from '../createTheme';
|
|
8
8
|
import { PneCloseIcon } from './dropdown/dropdownLook';
|
|
9
|
+
import { pneIconActionSx } from './iconActionLook';
|
|
9
10
|
import { PneSurface, PneSurfaceBody, PneSurfaceFooter, PneSurfaceHeader, } from './internal/PneSurface';
|
|
10
11
|
const PneModal = React.forwardRef(function PneModal(props, ref) {
|
|
11
12
|
const { actions, ariaDescribedBy, ariaLabel, blockingOverlay, children, className, closeButtonProps, closeLabel = 'Close', containerProps, containerSx, hideCloseButton = false, modalProps, onClose, open, overlay, slotProps, subtitle, title, ...directContainerDataAttributes } = props;
|
|
@@ -100,7 +101,7 @@ const PneModal = React.forwardRef(function PneModal(props, ref) {
|
|
|
100
101
|
modalSubtitleSx,
|
|
101
102
|
...(Array.isArray(subtitleSx) ? subtitleSx : [subtitleSx]),
|
|
102
103
|
] }, subtitle)),
|
|
103
|
-
!hideCloseButton && React.createElement(IconButton, { ...forwardedCloseButtonProps, "aria-label": resolvedCloseLabel, inert: isBlocked ? true : undefined, sx: modalCloseButtonSx, onClick: handleCloseButtonClick, type: 'button' },
|
|
104
|
+
!hideCloseButton && React.createElement(IconButton, { ...forwardedCloseButtonProps, "aria-label": resolvedCloseLabel, inert: isBlocked ? true : undefined, disableRipple: true, sx: modalCloseButtonSx, onClick: handleCloseButtonClick, type: 'button' },
|
|
104
105
|
React.createElement(PneCloseIcon, null))),
|
|
105
106
|
children != null && React.createElement(Body, { ...forwardedBodyProps, "data-pne-modal-body": 'true', "data-pne-modal-last": actions == null ? 'true' : undefined, inert: isBlocked ? true : forwardedBodyProps.inert }, children),
|
|
106
107
|
actions != null && React.createElement(Footer, { ...forwardedFooterProps, "data-pne-modal-footer": 'true', inert: isBlocked ? true : forwardedFooterProps.inert }, actions),
|
|
@@ -369,34 +370,8 @@ const modalSubtitleSx = theme => ({
|
|
|
369
370
|
lineHeight: '16px',
|
|
370
371
|
color: resolvePneSemanticPalette(theme).modal.subtitle,
|
|
371
372
|
});
|
|
372
|
-
// UI Kit Icon action: a 32px
|
|
373
|
-
const modalCloseButtonSx =
|
|
374
|
-
const pne = resolvePneSemanticPalette(theme);
|
|
375
|
-
const colors = pne.button.text;
|
|
376
|
-
return {
|
|
377
|
-
flex: '0 0 auto',
|
|
378
|
-
width: '32px',
|
|
379
|
-
height: '32px',
|
|
380
|
-
padding: 0,
|
|
381
|
-
borderRadius: '4px',
|
|
382
|
-
backgroundColor: 'transparent',
|
|
383
|
-
color: colors.default.text,
|
|
384
|
-
'& .MuiSvgIcon-root': {
|
|
385
|
-
fontSize: '16px',
|
|
386
|
-
},
|
|
387
|
-
'&:hover': {
|
|
388
|
-
backgroundColor: colors.hover.fill,
|
|
389
|
-
color: colors.hover.text,
|
|
390
|
-
},
|
|
391
|
-
'&:active': {
|
|
392
|
-
backgroundColor: colors.pressed.fill,
|
|
393
|
-
color: colors.pressed.text,
|
|
394
|
-
},
|
|
395
|
-
'&.Mui-focusVisible': {
|
|
396
|
-
boxShadow: `0 0 0 2px ${pne.modal.fill}, 0 0 0 4px ${pne.focusRing}`,
|
|
397
|
-
},
|
|
398
|
-
};
|
|
399
|
-
};
|
|
373
|
+
// UI Kit Icon action md: a 32px box with the 16px thin cross; hover and press colour only the icon.
|
|
374
|
+
const modalCloseButtonSx = pneIconActionSx('medium');
|
|
400
375
|
const BlockingOverlaySlot = styled(Box) `
|
|
401
376
|
position: absolute;
|
|
402
377
|
inset: 0;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SxProps, Theme } from '@mui/material/styles';
|
|
2
|
+
/**
|
|
3
|
+
* UI Kit Icon action on a MUI IconButton: an icon button with no background, where hover and press
|
|
4
|
+
* colour only the icon. `medium` is a 32px box with a 16px glyph (the close cross of a modal and of
|
|
5
|
+
* a toast), `small` a 24px box with a 14px glyph. The icon rests in the tertiary text colour, or in
|
|
6
|
+
* `restColor` (the tone of a toast), and takes the brand text colour under the pointer.
|
|
7
|
+
*/
|
|
8
|
+
export declare const pneIconActionSx: (size: "small" | "medium", restColor?: string) => SxProps<Theme>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { resolvePneSemanticPalette } from '../createTheme';
|
|
2
|
+
import { PNE_DARK_COLORS, PNE_NEUTRAL_RAMP } from '../themeColors';
|
|
3
|
+
/**
|
|
4
|
+
* UI Kit Icon action on a MUI IconButton: an icon button with no background, where hover and press
|
|
5
|
+
* colour only the icon. `medium` is a 32px box with a 16px glyph (the close cross of a modal and of
|
|
6
|
+
* a toast), `small` a 24px box with a 14px glyph. The icon rests in the tertiary text colour, or in
|
|
7
|
+
* `restColor` (the tone of a toast), and takes the brand text colour under the pointer.
|
|
8
|
+
*/
|
|
9
|
+
export const pneIconActionSx = (size, restColor) => theme => {
|
|
10
|
+
const pne = resolvePneSemanticPalette(theme);
|
|
11
|
+
const dark = theme.palette.mode === 'dark';
|
|
12
|
+
const box = size === 'small' ? '24px' : '32px';
|
|
13
|
+
return {
|
|
14
|
+
flex: '0 0 auto',
|
|
15
|
+
width: box,
|
|
16
|
+
height: box,
|
|
17
|
+
padding: 0,
|
|
18
|
+
borderRadius: '4px',
|
|
19
|
+
backgroundColor: 'transparent',
|
|
20
|
+
color: restColor ?? (dark ? PNE_DARK_COLORS.textMuted : PNE_NEUTRAL_RAMP[600]),
|
|
21
|
+
'& .MuiSvgIcon-root': {
|
|
22
|
+
fontSize: size === 'small' ? '14px' : '16px',
|
|
23
|
+
},
|
|
24
|
+
'&:hover': {
|
|
25
|
+
backgroundColor: 'transparent',
|
|
26
|
+
color: pne.button.text.hover.text,
|
|
27
|
+
},
|
|
28
|
+
'&:active': {
|
|
29
|
+
color: pne.button.text.pressed.text,
|
|
30
|
+
},
|
|
31
|
+
'&.Mui-focusVisible': {
|
|
32
|
+
boxShadow: `0 0 0 2px ${theme.palette.background.paper}, 0 0 0 4px ${pne.focusRing}`,
|
|
33
|
+
},
|
|
34
|
+
'&.Mui-disabled': {
|
|
35
|
+
color: dark ? PNE_DARK_COLORS.textDisabled : PNE_NEUTRAL_RAMP[400],
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React, { useCallback, useMemo, useState } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Box, Collapse, Portal, Snackbar, useMediaQuery } from '@mui/material';
|
|
3
3
|
import { useBreakpoint } from '../responsive/useBreakpoint';
|
|
4
4
|
import { useOverlayStore } from './overlayStore';
|
|
5
5
|
import { PermanentOverlayContext } from './PermanentOverlayContext';
|
|
6
6
|
import { OverlayPortalContainerContext } from './OverlayPortalContainerContext';
|
|
7
7
|
import { PaynetErrorPresentationContext } from './PaynetErrorPresentationContext';
|
|
8
8
|
import { registerOverlayHost } from './overlayRuntime';
|
|
9
|
+
import OverlayToast from './OverlayToast';
|
|
10
|
+
import PaynetErrorContent from './PaynetErrorContent';
|
|
9
11
|
/**
|
|
10
12
|
* Final left coordinates matching the adaptive Paynet menu shell:
|
|
11
13
|
* no reserved menu below 1080px, a collapsed rail below 1600px,
|
|
@@ -20,6 +22,8 @@ export const PAYNET_LEFT_MENU_OVERLAY_OFFSET = {
|
|
|
20
22
|
],
|
|
21
23
|
};
|
|
22
24
|
const STACK_GAP = 12;
|
|
25
|
+
// UI Kit OverlayHost: 8px between notifications.
|
|
26
|
+
const NOTIFICATION_GAP = 8;
|
|
23
27
|
const STACK_OFFSET = 24;
|
|
24
28
|
const OPERATION_CENTER_OFFSET = 16;
|
|
25
29
|
const STACK_REFLOW_DURATION_MS = 200;
|
|
@@ -60,6 +64,9 @@ const clearTimer = (timer) => {
|
|
|
60
64
|
clearTimeout(timer);
|
|
61
65
|
}
|
|
62
66
|
};
|
|
67
|
+
const NOTIFICATION_WIDTH = 448;
|
|
68
|
+
// An error with an identifier and details is a banner, not a toast (UI Kit OverlayHost).
|
|
69
|
+
const isPaynetErrorMessage = (message) => React.isValidElement(message) && message.type === PaynetErrorContent;
|
|
63
70
|
const ManagedSnackbar = ({ anchor, onExited, open, onRemove, prefersReducedMotion, snack, }) => {
|
|
64
71
|
const autoHideMs = typeof snack.autoHideMs === 'number' && snack.autoHideMs > 0 ? snack.autoHideMs : null;
|
|
65
72
|
const [remainingMs, setRemainingMs] = useState(autoHideMs);
|
|
@@ -163,59 +170,11 @@ const ManagedSnackbar = ({ anchor, onExited, open, onRemove, prefersReducedMotio
|
|
|
163
170
|
position: 'static',
|
|
164
171
|
transform: 'none',
|
|
165
172
|
pointerEvents: open ? 'auto' : 'none',
|
|
166
|
-
|
|
173
|
+
// UI Kit OverlayHost: every notification is 448px wide, or as wide as a phone lets it be.
|
|
167
174
|
maxWidth: 'calc(100vw - 32px)',
|
|
168
|
-
width:
|
|
175
|
+
width: `${NOTIFICATION_WIDTH}px`,
|
|
169
176
|
} },
|
|
170
|
-
React.createElement(
|
|
171
|
-
boxSizing: 'border-box',
|
|
172
|
-
position: 'relative',
|
|
173
|
-
overflow: 'hidden',
|
|
174
|
-
alignItems: 'flex-start',
|
|
175
|
-
maxWidth: '100%',
|
|
176
|
-
width: '100%',
|
|
177
|
-
'& .MuiAlert-message': {
|
|
178
|
-
minWidth: 0,
|
|
179
|
-
},
|
|
180
|
-
...(snack.action != null ? {
|
|
181
|
-
'& .MuiAlert-action': {
|
|
182
|
-
alignItems: 'flex-start',
|
|
183
|
-
},
|
|
184
|
-
} : {
|
|
185
|
-
'& .MuiAlert-action': {
|
|
186
|
-
alignItems: 'stretch',
|
|
187
|
-
alignSelf: 'stretch',
|
|
188
|
-
mb: '-6px',
|
|
189
|
-
mr: '-16px',
|
|
190
|
-
mt: '-6px',
|
|
191
|
-
pb: 0,
|
|
192
|
-
pl: '8px',
|
|
193
|
-
pt: 0,
|
|
194
|
-
},
|
|
195
|
-
'& .MuiAlert-action .MuiIconButton-root': {
|
|
196
|
-
alignItems: 'flex-start',
|
|
197
|
-
alignSelf: 'stretch',
|
|
198
|
-
borderRadius: 0,
|
|
199
|
-
pb: 0,
|
|
200
|
-
pl: '13px',
|
|
201
|
-
pr: '13px',
|
|
202
|
-
pt: '15px',
|
|
203
|
-
},
|
|
204
|
-
}),
|
|
205
|
-
} },
|
|
206
|
-
progressScale != null && !prefersReducedMotion ? (React.createElement(Box, { "data-testid": 'overlay-snackbar-progress', sx: {
|
|
207
|
-
position: 'absolute',
|
|
208
|
-
top: 0,
|
|
209
|
-
left: 0,
|
|
210
|
-
right: 0,
|
|
211
|
-
height: '3px',
|
|
212
|
-
backgroundColor: 'currentColor',
|
|
213
|
-
opacity: 0.24,
|
|
214
|
-
transformOrigin: 'left',
|
|
215
|
-
transform: `scaleX(${progressScale})`,
|
|
216
|
-
pointerEvents: 'none',
|
|
217
|
-
} })) : null,
|
|
218
|
-
snack.message)));
|
|
177
|
+
React.createElement(OverlayToast, { action: snack.action, description: snack.description, onClose: remove, presentation: isPaynetErrorMessage(snack.message) ? 'banner' : 'toast', progress: prefersReducedMotion ? null : progressScale, tone: snack.variant ?? 'info' }, snack.message)));
|
|
219
178
|
};
|
|
220
179
|
const MeasuredSnackbarStack = ({ anchor, breakpoint, completeExitPart, items, leftOffset, operationCenterElement, operationCenterHeight, prefersReducedMotion, removeSnackbar, }) => {
|
|
221
180
|
const [stackElement, setStackElement] = useState(null);
|
|
@@ -238,13 +197,13 @@ const MeasuredSnackbarStack = ({ anchor, breakpoint, completeExitPart, items, le
|
|
|
238
197
|
: {
|
|
239
198
|
bottom: sharesOperationBottom
|
|
240
199
|
? operationCenterHeight + OPERATION_CENTER_OFFSET
|
|
241
|
-
: STACK_OFFSET -
|
|
200
|
+
: STACK_OFFSET - NOTIFICATION_GAP,
|
|
242
201
|
top: 'auto',
|
|
243
202
|
flexDirection: 'column-reverse',
|
|
244
203
|
'@supports (bottom: env(safe-area-inset-bottom))': {
|
|
245
204
|
bottom: sharesOperationBottom
|
|
246
205
|
? `calc(${operationCenterHeight + OPERATION_CENTER_OFFSET}px + env(safe-area-inset-bottom, 0px))`
|
|
247
|
-
: `calc(${STACK_OFFSET -
|
|
206
|
+
: `calc(${STACK_OFFSET - NOTIFICATION_GAP}px + env(safe-area-inset-bottom, 0px))`,
|
|
248
207
|
},
|
|
249
208
|
};
|
|
250
209
|
return (React.createElement(Box, { "data-pne-overlay-stack": `${anchor.vertical}-${anchor.horizontal}`, ref: setStackElement, sx: {
|
|
@@ -255,8 +214,11 @@ const MeasuredSnackbarStack = ({ anchor, breakpoint, completeExitPart, items, le
|
|
|
255
214
|
pointerEvents: 'none',
|
|
256
215
|
...horizontalStyles,
|
|
257
216
|
...verticalStyles,
|
|
258
|
-
} }, items.map(({ open, presentationKey, snack }) => (React.createElement(Collapse, { key: presentationKey, appear: false, enter: false, in: open, onExited: () => completeExitPart(presentationKey, 'collapse'),
|
|
259
|
-
|
|
217
|
+
} }, items.map(({ open, presentationKey, snack }, index) => (React.createElement(Collapse, { key: presentationKey, appear: false, enter: false, in: open, onExited: () => completeExitPart(presentationKey, 'collapse'),
|
|
218
|
+
// The first item stands lowest. A toast casts a long shadow downwards, so each item is
|
|
219
|
+
// drawn over the ones above it and no shadow falls on a neighbour's face.
|
|
220
|
+
sx: { position: 'relative', zIndex: items.length - index }, timeout: prefersReducedMotion ? 0 : STACK_REFLOW_DURATION_MS },
|
|
221
|
+
React.createElement(Box, { "data-pne-overlay-stack-item": true, sx: { pb: `${NOTIFICATION_GAP}px` } },
|
|
260
222
|
React.createElement(ManagedSnackbar, { anchor: anchor, onExited: () => completeExitPart(presentationKey, 'grow'), open: open, onRemove: removeSnackbar, prefersReducedMotion: prefersReducedMotion, snack: snack })))))));
|
|
261
223
|
};
|
|
262
224
|
const MeasuredPermanentOverlay = ({ breakpoint, content, entry, operationCenterElement, operationCenterHeight, }) => {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { PneToastTone } from '../../toastPalette';
|
|
3
|
+
export type OverlayToastPresentation = 'toast' | 'banner';
|
|
4
|
+
export type OverlayToastProps = {
|
|
5
|
+
/** The consumer's action, for example an undo button; it stands before the close cross. */
|
|
6
|
+
action?: React.ReactNode;
|
|
7
|
+
/** The message: the title of a toast, the whole content of a banner. */
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
closeLabel?: string;
|
|
10
|
+
/** The second line of a toast, in the text colour of its tone. */
|
|
11
|
+
description?: React.ReactNode;
|
|
12
|
+
onClose?: () => void;
|
|
13
|
+
/** A toast is a short message; a banner is an error with an identifier and details. */
|
|
14
|
+
presentation?: OverlayToastPresentation;
|
|
15
|
+
/** How much of the time to live is left, 1…0; without it there is no timer bar. */
|
|
16
|
+
progress?: number | null;
|
|
17
|
+
tone?: PneToastTone;
|
|
18
|
+
/** The transition of the snackbar animates the card through its style. */
|
|
19
|
+
style?: React.CSSProperties;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* One notification of OverlayHost by the UI Kit.
|
|
23
|
+
* Toast: a card filled with the colour of its tone, radius 8, 8/16 inside, the toast shadow; the
|
|
24
|
+
* message as the title (18/26 SemiBold) over an optional description (12/16 in the text colour of
|
|
25
|
+
* the tone); the consumer's action and a 32px close cross on the right, 64px from the text; a 3px
|
|
26
|
+
* timer bar along the bottom that shrinks to the left. No sign of the tone.
|
|
27
|
+
* Banner (an error with details): the pale fill of the tone inside a ring of its colour, 12/16
|
|
28
|
+
* inside, the 20px sign of the tone on the left, a 24px close cross.
|
|
29
|
+
*/
|
|
30
|
+
declare const OverlayToast: React.ForwardRefExoticComponent<OverlayToastProps & React.RefAttributes<HTMLDivElement>>;
|
|
31
|
+
export default OverlayToast;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { Alert, IconButton } from '@mui/material';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { resolvePneSemanticPalette } from '../../createTheme';
|
|
4
|
+
import { PneCloseIcon } from '../dropdown/dropdownLook';
|
|
5
|
+
import { pneIconActionSx } from '../iconActionLook';
|
|
6
|
+
/**
|
|
7
|
+
* One notification of OverlayHost by the UI Kit.
|
|
8
|
+
* Toast: a card filled with the colour of its tone, radius 8, 8/16 inside, the toast shadow; the
|
|
9
|
+
* message as the title (18/26 SemiBold) over an optional description (12/16 in the text colour of
|
|
10
|
+
* the tone); the consumer's action and a 32px close cross on the right, 64px from the text; a 3px
|
|
11
|
+
* timer bar along the bottom that shrinks to the left. No sign of the tone.
|
|
12
|
+
* Banner (an error with details): the pale fill of the tone inside a ring of its colour, 12/16
|
|
13
|
+
* inside, the 20px sign of the tone on the left, a 24px close cross.
|
|
14
|
+
*/
|
|
15
|
+
// The snackbar's transition holds the card by its ref and style, so both go to the root.
|
|
16
|
+
const OverlayToast = React.forwardRef(function OverlayToast({ action, children, closeLabel = 'Close', description, onClose, presentation = 'toast', progress, style, tone = 'info', }, ref) {
|
|
17
|
+
const isBanner = presentation === 'banner';
|
|
18
|
+
return React.createElement(Alert, { ref: ref, style: style, action: React.createElement(React.Fragment, null,
|
|
19
|
+
action,
|
|
20
|
+
onClose ? React.createElement(IconButton, { "aria-label": closeLabel, "data-pne-toast-close": 'true', disableRipple: true, onClick: onClose, sx: pneIconActionSx(isBanner ? 'small' : 'medium', 'var(--pne-toast-text)'), title: closeLabel, type: 'button' },
|
|
21
|
+
React.createElement(PneCloseIcon, null)) : null), "data-pne-toast": presentation, "data-pne-tone": tone, elevation: 0, icon: isBanner ? undefined : false, severity: tone, sx: overlayToastSx },
|
|
22
|
+
progress != null ? React.createElement("span", { "aria-hidden": 'true', "data-pne-toast-timer": 'true', "data-testid": 'overlay-snackbar-progress', style: { transform: `scaleX(${progress})` } }) : null,
|
|
23
|
+
isBanner ? children : React.createElement(React.Fragment, null,
|
|
24
|
+
React.createElement("span", { "data-pne-toast-title": 'true' }, children),
|
|
25
|
+
description != null && description !== ''
|
|
26
|
+
? React.createElement("span", { "data-pne-toast-description": 'true' }, description)
|
|
27
|
+
: null));
|
|
28
|
+
});
|
|
29
|
+
export default OverlayToast;
|
|
30
|
+
const TONES = ['info', 'success', 'warning', 'error'];
|
|
31
|
+
const overlayToastSx = theme => {
|
|
32
|
+
const toast = resolvePneSemanticPalette(theme).toast;
|
|
33
|
+
const rules = {
|
|
34
|
+
'&': {
|
|
35
|
+
alignItems: 'center',
|
|
36
|
+
borderRadius: '8px',
|
|
37
|
+
boxShadow: toast.shadow,
|
|
38
|
+
boxSizing: 'border-box',
|
|
39
|
+
color: toast.title,
|
|
40
|
+
maxWidth: '100%',
|
|
41
|
+
overflow: 'hidden',
|
|
42
|
+
padding: '8px 16px',
|
|
43
|
+
position: 'relative',
|
|
44
|
+
width: '100%',
|
|
45
|
+
},
|
|
46
|
+
'& .MuiAlert-message': {
|
|
47
|
+
display: 'flex',
|
|
48
|
+
flex: '1 1 auto',
|
|
49
|
+
flexDirection: 'column',
|
|
50
|
+
minWidth: 0,
|
|
51
|
+
overflow: 'visible',
|
|
52
|
+
padding: 0,
|
|
53
|
+
},
|
|
54
|
+
// The actions keep 64px from the text; on a phone the text needs that room itself.
|
|
55
|
+
'& .MuiAlert-action': {
|
|
56
|
+
alignItems: 'center',
|
|
57
|
+
display: 'flex',
|
|
58
|
+
flex: '0 0 auto',
|
|
59
|
+
gap: '8px',
|
|
60
|
+
margin: 0,
|
|
61
|
+
padding: '0 0 0 64px',
|
|
62
|
+
'@media (max-width: 480px)': {
|
|
63
|
+
paddingLeft: '16px',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
'& [data-pne-toast-title]': {
|
|
67
|
+
fontSize: '18px',
|
|
68
|
+
fontWeight: 600,
|
|
69
|
+
lineHeight: '26px',
|
|
70
|
+
overflowWrap: 'anywhere',
|
|
71
|
+
},
|
|
72
|
+
'& [data-pne-toast-description]': {
|
|
73
|
+
color: 'var(--pne-toast-text)',
|
|
74
|
+
fontSize: '12px',
|
|
75
|
+
lineHeight: '16px',
|
|
76
|
+
overflowWrap: 'anywhere',
|
|
77
|
+
},
|
|
78
|
+
'& [data-pne-toast-timer]': {
|
|
79
|
+
backgroundColor: 'var(--pne-toast-text)',
|
|
80
|
+
bottom: 0,
|
|
81
|
+
height: '3px',
|
|
82
|
+
left: 0,
|
|
83
|
+
pointerEvents: 'none',
|
|
84
|
+
position: 'absolute',
|
|
85
|
+
right: 0,
|
|
86
|
+
transformOrigin: 'left',
|
|
87
|
+
},
|
|
88
|
+
// Banner: an error with an identifier and details.
|
|
89
|
+
'&[data-pne-toast="banner"]': {
|
|
90
|
+
alignItems: 'flex-start',
|
|
91
|
+
padding: '12px 16px',
|
|
92
|
+
},
|
|
93
|
+
'&[data-pne-toast="banner"] .MuiAlert-icon': {
|
|
94
|
+
color: 'var(--pne-toast-text)',
|
|
95
|
+
fontSize: '20px',
|
|
96
|
+
marginRight: '12px',
|
|
97
|
+
opacity: 1,
|
|
98
|
+
padding: 0,
|
|
99
|
+
},
|
|
100
|
+
'&[data-pne-toast="banner"] .MuiAlert-message': {
|
|
101
|
+
fontSize: '14px',
|
|
102
|
+
lineHeight: '20px',
|
|
103
|
+
},
|
|
104
|
+
'&[data-pne-toast="banner"] .MuiAlert-action': {
|
|
105
|
+
alignItems: 'flex-start',
|
|
106
|
+
paddingLeft: '12px',
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
for (const tone of TONES) {
|
|
110
|
+
const colors = toast[tone];
|
|
111
|
+
rules[`&[data-pne-tone="${tone}"]`] = {
|
|
112
|
+
'--pne-toast-text': colors.text,
|
|
113
|
+
backgroundColor: colors.fill,
|
|
114
|
+
};
|
|
115
|
+
rules[`&[data-pne-toast="banner"][data-pne-tone="${tone}"]`] = {
|
|
116
|
+
backgroundColor: colors.bannerFill,
|
|
117
|
+
boxShadow: `inset 0 0 0 1px ${colors.fill}, ${toast.shadow}`,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
return rules;
|
|
121
|
+
};
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { resolvePneSemanticPalette } from '../../createTheme';
|
|
3
3
|
import PneButton from '../PneButton';
|
|
4
4
|
import { create } from 'zustand';
|
|
5
5
|
import { reportMissingOverlayHost } from './overlayRuntime';
|
|
6
6
|
import { normalizePaynetError } from './paynetError';
|
|
7
7
|
import { PaynetErrorContent } from './PaynetErrorContent';
|
|
8
8
|
const defaultAutoHideMs = 5000;
|
|
9
|
+
// The label of a toast's action reads as the primary text on the soft fill, whatever the skin.
|
|
10
|
+
const toastActionSx = theme => ({
|
|
11
|
+
color: resolvePneSemanticPalette(theme).toast.title,
|
|
12
|
+
});
|
|
9
13
|
const makeId = () => {
|
|
10
14
|
if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
|
|
11
15
|
return crypto.randomUUID();
|
|
@@ -92,16 +96,14 @@ export const overlayActions = {
|
|
|
92
96
|
...snackbar,
|
|
93
97
|
id,
|
|
94
98
|
action: React.createElement(PneButton, {
|
|
95
|
-
|
|
99
|
+
// UI Kit Toast: a soft small button whose label reads as the primary text.
|
|
100
|
+
pneStyle: 'neutral',
|
|
96
101
|
size: 'small',
|
|
97
|
-
startIcon: React.createElement(UndoIcon, { fontSize: 'inherit' }),
|
|
98
102
|
onClick: () => {
|
|
99
103
|
useOverlayStore.getState().removeSnackbar(id);
|
|
100
104
|
onUndo();
|
|
101
105
|
},
|
|
102
|
-
sx:
|
|
103
|
-
fontWeight: 600,
|
|
104
|
-
},
|
|
106
|
+
sx: toastActionSx,
|
|
105
107
|
}, undoLabel),
|
|
106
108
|
});
|
|
107
109
|
return id;
|
|
@@ -3,7 +3,10 @@ import type React from 'react';
|
|
|
3
3
|
export type SnackbarVariant = 'info' | 'success' | 'warning' | 'error';
|
|
4
4
|
export type SnackbarOptions = {
|
|
5
5
|
id?: string;
|
|
6
|
+
/** The text of the notification; a toast shows it as its title. */
|
|
6
7
|
message: React.ReactNode;
|
|
8
|
+
/** The second line of a toast under the message, in the text colour of the tone. */
|
|
9
|
+
description?: React.ReactNode;
|
|
7
10
|
variant?: SnackbarVariant;
|
|
8
11
|
/**
|
|
9
12
|
* Auto-close timeout in milliseconds. `undefined` keeps the snackbar open until closed explicitly.
|
package/esm/createTheme.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { type PneButtonPalette } from './buttonPalette';
|
|
|
5
5
|
import { type PneCheckboxPalette } from './checkboxPalette';
|
|
6
6
|
import { type PneDropdownPalette } from './dropdownPalette';
|
|
7
7
|
import { type PneModalPalette } from './modalPalette';
|
|
8
|
+
import { type PneToastPalette } from './toastPalette';
|
|
8
9
|
import { type PneFieldPalette } from './fieldPalette';
|
|
9
10
|
import { type PneSwitchPalette } from './switchPalette';
|
|
10
11
|
import { type PneColorMode } from './themeColors';
|
|
@@ -66,6 +67,8 @@ export type PneSemanticPalette = {
|
|
|
66
67
|
dropdown: PneDropdownPalette;
|
|
67
68
|
/** Modal colours by UI Kit role. */
|
|
68
69
|
modal: PneModalPalette;
|
|
70
|
+
/** Notification colours by UI Kit role: toasts and error banners of OverlayHost. */
|
|
71
|
+
toast: PneToastPalette;
|
|
69
72
|
/** The outer 2px of the keyboard focus ring; the 2px gap inside takes the page colour. */
|
|
70
73
|
focusRing: string;
|
|
71
74
|
/** Link text on the page. */
|
package/esm/createTheme.js
CHANGED
|
@@ -5,6 +5,7 @@ import { createPneButtonPalette, createPneFocusRing, createPneLinkColor, } from
|
|
|
5
5
|
import { createPneCheckboxPalette } from './checkboxPalette';
|
|
6
6
|
import { createPneDropdownPalette } from './dropdownPalette';
|
|
7
7
|
import { createPneModalPalette } from './modalPalette';
|
|
8
|
+
import { createPneToastPalette } from './toastPalette';
|
|
8
9
|
import { createPneFieldPalette } from './fieldPalette';
|
|
9
10
|
import { createPneSwitchPalette } from './switchPalette';
|
|
10
11
|
import { PNE_DARK_COLORS, PNE_LIGHT_COLORS } from './themeColors';
|
|
@@ -100,6 +101,7 @@ const createSemanticPalette = (seed, mode) => {
|
|
|
100
101
|
field: createPneFieldPalette(ramp, mode),
|
|
101
102
|
dropdown: createPneDropdownPalette(ramp, mode),
|
|
102
103
|
modal: createPneModalPalette(mode),
|
|
104
|
+
toast: createPneToastPalette(mode),
|
|
103
105
|
focusRing: createPneFocusRing(ramp, mode),
|
|
104
106
|
link: createPneLinkColor(ramp, mode),
|
|
105
107
|
};
|
package/esm/exports/theme.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export type { PneButtonPalette, PneButtonState, PneButtonStateColors, PneButtonV
|
|
|
3
3
|
export type { PneCheckboxPalette, PneCheckboxState, PneCheckboxStateColors, PneCheckboxValueColors, } from '../checkboxPalette';
|
|
4
4
|
export type { PneDropdownPalette } from '../dropdownPalette';
|
|
5
5
|
export type { PneModalPalette } from '../modalPalette';
|
|
6
|
+
export type { PneToastPalette, PneToastTone, PneToastToneColors } from '../toastPalette';
|
|
6
7
|
export type { PneFieldPalette, PneFieldState, PneFieldStateColors, PneFieldVariantColors, } from '../fieldPalette';
|
|
7
8
|
export type { PneSwitchPalette, PneSwitchState, PneSwitchStateColors, PneSwitchValueColors, } from '../switchPalette';
|
|
8
9
|
export { PNE_NEUTRAL_RAMP, PNE_STATUS_COLORS } from '../themeColors';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type PneColorMode } from './themeColors';
|
|
2
|
+
/**
|
|
3
|
+
* Notification colours by UI Kit (Claude) role (Toast, and Banner for an error with details). A toast
|
|
4
|
+
* is filled with the colour of its tone (`Tags/Status/<tone>/Border`) and writes its description,
|
|
5
|
+
* its timer and its close cross in the text colour of the tone; the title reads as a value. A banner
|
|
6
|
+
* is the pale fill of the tone inside a ring of the toast fill. The tones are the same for every skin.
|
|
7
|
+
*/
|
|
8
|
+
export type PneToastTone = 'info' | 'success' | 'warning' | 'error';
|
|
9
|
+
export type PneToastToneColors = {
|
|
10
|
+
/** The fill of a toast and the ring of a banner. */
|
|
11
|
+
fill: string;
|
|
12
|
+
/** The description, the timer bar, the close cross and the sign of a banner. */
|
|
13
|
+
text: string;
|
|
14
|
+
/** The fill of a banner. */
|
|
15
|
+
bannerFill: string;
|
|
16
|
+
};
|
|
17
|
+
export type PneToastPalette = Record<PneToastTone, PneToastToneColors> & {
|
|
18
|
+
/** The title of a toast and the text of a banner. */
|
|
19
|
+
title: string;
|
|
20
|
+
shadow: string;
|
|
21
|
+
};
|
|
22
|
+
export declare const createPneToastPalette: (mode: PneColorMode) => PneToastPalette;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { PNE_DARK_COLORS, PNE_NEUTRAL_RAMP, PNE_STATUS_COLORS } from './themeColors';
|
|
2
|
+
// The UI Kit blue of the Info tone: a fixed ramp, not the brand ramp of the skin.
|
|
3
|
+
const INFO = { 100: '#EBF3FF', 300: '#B3D4FF', 700: '#005EB9', 900: '#003670' };
|
|
4
|
+
// UI Kit `--elevation-toast` (Figma effect style NW).
|
|
5
|
+
const TOAST_SHADOW = '0 -1px 12px rgba(0,0,0,0.03), 0 3px 3px rgba(2,0,107,0.02), 0 7px 6px rgba(0,11,70,0.03), '
|
|
6
|
+
+ '0 12px 10px rgba(0,0,98,0.03), 0 22px 18px rgba(0,15,44,0.04), 0 40px 33px rgba(0,10,255,0.05), '
|
|
7
|
+
+ '0 100px 80px rgba(0,0,0,0.07)';
|
|
8
|
+
const RAMPS = {
|
|
9
|
+
info: INFO,
|
|
10
|
+
success: PNE_STATUS_COLORS.success,
|
|
11
|
+
warning: PNE_STATUS_COLORS.warning,
|
|
12
|
+
error: PNE_STATUS_COLORS.error,
|
|
13
|
+
};
|
|
14
|
+
const TONES = Object.keys(RAMPS);
|
|
15
|
+
const tones = (pick) => Object.fromEntries(TONES.map(tone => [tone, pick(RAMPS[tone])]));
|
|
16
|
+
export const createPneToastPalette = (mode) => mode === 'dark'
|
|
17
|
+
? {
|
|
18
|
+
...tones(ramp => ({ fill: ramp[700], text: ramp[300], bannerFill: ramp[900] })),
|
|
19
|
+
title: PNE_DARK_COLORS.textPrimary,
|
|
20
|
+
shadow: TOAST_SHADOW,
|
|
21
|
+
}
|
|
22
|
+
: {
|
|
23
|
+
...tones(ramp => ({ fill: ramp[300], text: ramp[700], bannerFill: ramp[100] })),
|
|
24
|
+
title: PNE_NEUTRAL_RAMP[900],
|
|
25
|
+
shadow: TOAST_SHADOW,
|
|
26
|
+
};
|