@12-apps/ui 6.76.1 → 6.77.0
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/NATIVE.md +1 -1
- package/dist/_internal/components/data-display/Alert/Alert.content.js +20 -0
- package/dist/_internal/components/data-display/Alert/Alert.content.js.map +1 -0
- package/dist/_internal/components/data-display/Alert/Alert.js +5 -3
- package/dist/_internal/components/data-display/Alert/Alert.metrics.js +3 -1
- package/dist/_internal/components/data-display/Alert/Alert.placement.js +8 -0
- package/dist/_internal/components/data-display/Alert/Alert.placement.js.map +1 -0
- package/dist/_internal/components/data-display/Alert/Alert.styles.js +2 -2
- package/dist/_internal/components/data-display/Banner/Banner.js +3 -3
- package/dist/_internal/components/data-display/Banner/Banner.styles.js +2 -2
- package/dist/_internal/components/data-display/CardKit/card-actions-context.js +6 -4
- package/dist/_internal/components/data-display/CardKit/use-remove-confirm.js +7 -5
- package/dist/_internal/components/data-display/DataViews/DataViewsTableBase.js +7 -5
- package/dist/_internal/components/data-display/DataViews/data-views-table-parts.js +6 -4
- package/dist/_internal/components/data-display/index.js +7 -5
- package/dist/_internal/components/feedback/NotificationStatusNotice/NotificationStatusNotice.js +6 -4
- package/dist/_internal/components/feedback/index.js +6 -4
- package/dist/_internal/components/index.js +8 -6
- package/dist/{chunk-3VLVLZ6W.js → chunk-B34WHRKH.js} +2 -2
- package/dist/{chunk-JYAXTRNH.js → chunk-CCJJTLF7.js} +2 -2
- package/dist/{chunk-52CLMR47.js → chunk-ENXGWNCX.js} +2 -2
- package/dist/chunk-IVI574Y5.js +73 -0
- package/dist/chunk-IVI574Y5.js.map +1 -0
- package/dist/{chunk-3LHZCVGM.js → chunk-JNVUB2D4.js} +3 -1
- package/dist/chunk-JNVUB2D4.js.map +1 -0
- package/dist/{chunk-REEV7CLC.js → chunk-QDG6V7OC.js} +2 -2
- package/dist/chunk-QXUXO22M.js +9 -0
- package/dist/chunk-QXUXO22M.js.map +1 -0
- package/dist/{chunk-44AXT2SN.js → chunk-QZX43FIC.js} +2 -2
- package/dist/{chunk-ZBOGZLX3.js → chunk-T2KONJ45.js} +3 -3
- package/dist/{chunk-LY7PBZ3Z.js → chunk-UFNXYOHZ.js} +2 -2
- package/dist/{chunk-ERI6JC4M.js → chunk-X2SJJZFH.js} +2 -2
- package/dist/{chunk-DQJFCVXW.js → chunk-ZSCKXOKE.js} +32 -47
- package/dist/chunk-ZSCKXOKE.js.map +1 -0
- package/dist/data-display/Alert.js +5 -3
- package/dist/data-display/Banner.js +3 -3
- package/dist/data-display/CardKit.js +7 -5
- package/dist/data-display/DataViews.js +7 -5
- package/dist/feedback/NotificationStatusNotice.js +6 -4
- package/dist/native/data-display/Alert.js.map +1 -1
- package/dist/types/components/data-display/Alert/Alert.content.d.ts +18 -0
- package/dist/types/components/data-display/Alert/Alert.content.d.ts.map +1 -0
- package/dist/types/components/data-display/Alert/Alert.d.ts.map +1 -1
- package/dist/types/components/data-display/Alert/Alert.metrics.d.ts +4 -0
- package/dist/types/components/data-display/Alert/Alert.metrics.d.ts.map +1 -1
- package/dist/types/components/data-display/Alert/Alert.placement.d.ts +37 -0
- package/dist/types/components/data-display/Alert/Alert.placement.d.ts.map +1 -0
- package/dist/types/components/data-display/Alert/Alert.types.d.ts +8 -0
- package/dist/types/components/data-display/Alert/Alert.types.d.ts.map +1 -1
- package/dist/types/components/data-display/Alert/index.d.ts +1 -1
- package/dist/types/components/data-display/Alert/index.d.ts.map +1 -1
- package/dist/types-native/components/data-display/Alert/Alert.metrics.d.ts +4 -0
- package/dist/types-native/components/data-display/Alert/Alert.metrics.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/data-display/Alert/Alert.content.tsx +79 -0
- package/src/components/data-display/Alert/Alert.md +19 -0
- package/src/components/data-display/Alert/Alert.metrics.ts +2 -0
- package/src/components/data-display/Alert/Alert.placement.ts +45 -0
- package/src/components/data-display/Alert/Alert.tsx +41 -61
- package/src/components/data-display/Alert/Alert.types.ts +10 -1
- package/src/components/data-display/Alert/index.ts +7 -1
- package/dist/chunk-3LHZCVGM.js.map +0 -1
- package/dist/chunk-DQJFCVXW.js.map +0 -1
- /package/dist/{chunk-3VLVLZ6W.js.map → chunk-B34WHRKH.js.map} +0 -0
- /package/dist/{chunk-JYAXTRNH.js.map → chunk-CCJJTLF7.js.map} +0 -0
- /package/dist/{chunk-52CLMR47.js.map → chunk-ENXGWNCX.js.map} +0 -0
- /package/dist/{chunk-REEV7CLC.js.map → chunk-QDG6V7OC.js.map} +0 -0
- /package/dist/{chunk-44AXT2SN.js.map → chunk-QZX43FIC.js.map} +0 -0
- /package/dist/{chunk-ZBOGZLX3.js.map → chunk-T2KONJ45.js.map} +0 -0
- /package/dist/{chunk-LY7PBZ3Z.js.map → chunk-UFNXYOHZ.js.map} +0 -0
- /package/dist/{chunk-ERI6JC4M.js.map → chunk-X2SJJZFH.js.map} +0 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Theme } from '@mui/material/styles/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* WHERE THE ICON SITS — a choice the HOST makes once, in its theme.
|
|
4
|
+
*
|
|
5
|
+
* - `'gutter'` (the default, and what every alert did before this existed):
|
|
6
|
+
* the icon has a column of its own, and the title and the description both
|
|
7
|
+
* start to its right. A two-line description wraps inside that narrower
|
|
8
|
+
* column and leaves an empty strip under the icon.
|
|
9
|
+
* - `'title'`: the icon sits on the TITLE's line, and the description below
|
|
10
|
+
* starts at the alert's own edge and uses the whole line.
|
|
11
|
+
*
|
|
12
|
+
* It is a theme value, like `uiSurfaces`, because it is a house style rather
|
|
13
|
+
* than a per-call decision: a host that wants it wants it on every alert, and a
|
|
14
|
+
* per-call prop would have to be spelled at each of them. The `iconPlacement`
|
|
15
|
+
* prop still exists for the one call site that must differ, and wins.
|
|
16
|
+
*
|
|
17
|
+
* An alert with no title, or no icon, has no title line to put the icon on;
|
|
18
|
+
* `'title'` then renders exactly as `'gutter'` does.
|
|
19
|
+
*/
|
|
20
|
+
export type AlertIconPlacement = 'gutter' | 'title';
|
|
21
|
+
/** What a host may state about alerts, on its theme. */
|
|
22
|
+
export interface UiAlertTheme {
|
|
23
|
+
iconPlacement?: AlertIconPlacement;
|
|
24
|
+
}
|
|
25
|
+
declare module '@mui/material/styles' {
|
|
26
|
+
interface Theme {
|
|
27
|
+
/** Alert layout the host states. See `Alert.placement.ts`. */
|
|
28
|
+
uiAlert?: UiAlertTheme;
|
|
29
|
+
}
|
|
30
|
+
interface ThemeOptions {
|
|
31
|
+
/** Alert layout, for every alert under this theme. See `Alert.placement.ts`. */
|
|
32
|
+
uiAlert?: UiAlertTheme;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** The placement in force: the call site's, else the theme's, else `'gutter'`. */
|
|
36
|
+
export declare function resolveIconPlacement(theme: Theme, stated: AlertIconPlacement | undefined): AlertIconPlacement;
|
|
37
|
+
//# sourceMappingURL=Alert.placement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Alert.placement.d.ts","sourceRoot":"","sources":["../../../../../src/components/data-display/Alert/Alert.placement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAE3D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEpD,wDAAwD;AACxD,MAAM,WAAW,YAAY;IAC3B,aAAa,CAAC,EAAE,kBAAkB,CAAC;CACpC;AAED,OAAO,QAAQ,sBAAsB,CAAC;IACpC,UAAU,KAAK;QACb,8DAA8D;QAC9D,OAAO,CAAC,EAAE,YAAY,CAAC;KACxB;IACD,UAAU,YAAY;QACpB,gFAAgF;QAChF,OAAO,CAAC,EAAE,YAAY,CAAC;KACxB;CACF;AAED,kFAAkF;AAClF,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,kBAAkB,GAAG,SAAS,GACrC,kBAAkB,CAEpB"}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import type { AlertProps as MuiAlertProps } from '@mui/material/Alert/index.js';
|
|
2
2
|
import type { AlertBaseFields, AlertDismiss } from './Alert.base';
|
|
3
|
+
import type { AlertIconPlacement } from './Alert.placement';
|
|
3
4
|
export type { AlertBaseFields, AlertBaseProps, AlertDismiss, AlertVariant } from './Alert.base';
|
|
5
|
+
export type { AlertIconPlacement, UiAlertTheme } from './Alert.placement';
|
|
4
6
|
/** The web `Alert`'s non-dismiss half: the shared fields, plus MUI's `Alert` props where they do not overlap. */
|
|
5
7
|
export interface AlertBase extends AlertBaseFields, Omit<MuiAlertProps, 'variant' | 'color' | 'role' | keyof AlertBaseFields> {
|
|
8
|
+
/**
|
|
9
|
+
* Where the icon sits: its own column (`'gutter'`) or on the title's line
|
|
10
|
+
* (`'title'`). Unset, the theme's `uiAlert.iconPlacement` decides, else
|
|
11
|
+
* `'gutter'`. Web only. See `Alert.placement.ts`.
|
|
12
|
+
*/
|
|
13
|
+
iconPlacement?: AlertIconPlacement;
|
|
6
14
|
}
|
|
7
15
|
export type AlertProps = AlertBase & AlertDismiss;
|
|
8
16
|
//# sourceMappingURL=Alert.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Alert.types.d.ts","sourceRoot":"","sources":["../../../../../src/components/data-display/Alert/Alert.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAEhF,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"Alert.types.d.ts","sourceRoot":"","sources":["../../../../../src/components/data-display/Alert/Alert.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAEhF,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAChG,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE1E,iHAAiH;AACjH,MAAM,WAAW,SACf,SAAQ,eAAe,EACrB,IAAI,CAAC,aAAa,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,eAAe,CAAC;IAC3E;;;;OAIG;IACH,aAAa,CAAC,EAAE,kBAAkB,CAAC;CACpC;AAED,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/data-display/Alert/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/data-display/Alert/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,YAAY,EACV,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,YAAY,GACb,MAAM,eAAe,CAAC"}
|
|
@@ -54,6 +54,10 @@ export declare const DESCRIPTION: {
|
|
|
54
54
|
readonly fontSize: 14.8;
|
|
55
55
|
readonly opacity: 0.9;
|
|
56
56
|
};
|
|
57
|
+
/** The icon on the title's line (`iconPlacement: 'title'`): 10px from the title. */
|
|
58
|
+
export declare const TITLE_ICON: {
|
|
59
|
+
readonly gapUnits: 1.25;
|
|
60
|
+
};
|
|
57
61
|
/** The icon slot: MUI's 22px glyph at 0.9, 14px from the words, 2px down (MUI's 7px stays below). */
|
|
58
62
|
export declare const ICON_SLOT: {
|
|
59
63
|
readonly size: 22;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Alert.metrics.d.ts","sourceRoot":"","sources":["../../../../../src/components/data-display/Alert/Alert.metrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGjD,OAAO,EAAgB,KAAK,UAAU,EAAE,KAAK,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEpF;;;;;;;;;;GAUG;AAEH,oFAAoF;AACpF,eAAO,MAAM,kBAAkB,MAAM,CAAC;AACtC,eAAO,MAAM,mBAAmB;;;CAA6C,CAAC;AAC9E,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,eAAO,MAAM,YAAY,iCAAiC,CAAC;AAE3D,4EAA4E;AAC5E,eAAO,MAAM,OAAO;;;;CAA8C,CAAC;AACnE,eAAO,MAAM,SAAS;;;;CAA4C,CAAC;AACnE,oEAAoE;AACpE,eAAO,MAAM,WAAW,MAAM,CAAC;AAC/B,eAAO,MAAM,cAAc,MAAM,CAAC;AAElC,4FAA4F;AAC5F,eAAO,MAAM,iBAAiB,IAAI,CAAC;AACnC,eAAO,MAAM,iBAAiB,OAAO,CAAC;AACtC,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,2FAA2F;AAC3F,eAAO,MAAM,cAAc;;;CAAsD,CAAC;AAElF,2GAA2G;AAC3G,eAAO,MAAM,KAAK;;;;;CAAsF,CAAC;AACzG,iDAAiD;AACjD,eAAO,MAAM,WAAW;;;CAA4C,CAAC;AAErE,qGAAqG;AACrG,eAAO,MAAM,SAAS;;;;;;CAAuG,CAAC;AAC9H,oGAAoG;AACpG,eAAO,MAAM,WAAW;;;;CAAmE,CAAC;AAC5F,mFAAmF;AACnF,eAAO,MAAM,YAAY;;;;;CAAsE,CAAC;AAEhG;;;;GAIG;AACH,eAAO,MAAM,gBAAgB;;;;;;;CAA4E,CAAC;AAC1G,oEAAoE;AACpE,eAAO,MAAM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AAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,YAAY,CAAqD,CAAC;AAE9G,8FAA8F;AAC9F,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,GAAG,YAAY,CAUnF;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,CAOzD;AAED,gFAAgF;AAChF,wBAAgB,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAKjF;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,YAAY,CAGnE;AAED,kEAAkE;AAClE,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,GAAG,YAAY,CAIvG"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import AlertTitle from '@mui/material/AlertTitle/index.js';
|
|
2
|
+
import Box from '@mui/material/Box/index.js';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
import { sxRem } from '../../../tokens/relative';
|
|
6
|
+
|
|
7
|
+
import { testIdFor } from './Alert.helpers';
|
|
8
|
+
import { DESCRIPTION, ICON_SLOT, TITLE, TITLE_ICON } from './Alert.metrics';
|
|
9
|
+
import type { AlertProps } from './Alert.types';
|
|
10
|
+
|
|
11
|
+
const BREAK_WORDS = {
|
|
12
|
+
wordWrap: 'break-word',
|
|
13
|
+
overflowWrap: 'break-word',
|
|
14
|
+
wordBreak: 'break-word',
|
|
15
|
+
} as const;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The message column: title, description, then whatever the caller put inside.
|
|
19
|
+
*
|
|
20
|
+
* `titleIcon` is the icon when it sits on the title's line
|
|
21
|
+
* (`iconPlacement: 'title'`, see `Alert.placement.ts`). The title then shares
|
|
22
|
+
* a row with it, and the description below is a sibling of that row — so it
|
|
23
|
+
* starts at the column's own edge rather than under the title's first letter.
|
|
24
|
+
*/
|
|
25
|
+
export const AlertContent: React.FC<{
|
|
26
|
+
title?: AlertProps['title'];
|
|
27
|
+
description?: AlertProps['description'];
|
|
28
|
+
titleIcon?: React.ReactNode;
|
|
29
|
+
dataTestId?: string;
|
|
30
|
+
children?: React.ReactNode;
|
|
31
|
+
}> = ({ title, description, titleIcon, dataTestId, children }) => {
|
|
32
|
+
const heading = title ? (
|
|
33
|
+
<AlertTitle
|
|
34
|
+
data-testid={testIdFor(dataTestId, 'title')}
|
|
35
|
+
sx={{
|
|
36
|
+
fontWeight: TITLE.fontWeight,
|
|
37
|
+
fontSize: sxRem(TITLE.fontSize),
|
|
38
|
+
// On the icon's row the title is centred against the glyph, so MUI's
|
|
39
|
+
// 2px lift would only push it off that centre.
|
|
40
|
+
...(titleIcon ? { margin: 0 } : { marginBottom: description ? TITLE.marginBottomUnits : 0 }),
|
|
41
|
+
...BREAK_WORDS,
|
|
42
|
+
}}
|
|
43
|
+
>
|
|
44
|
+
{title}
|
|
45
|
+
</AlertTitle>
|
|
46
|
+
) : null;
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<>
|
|
50
|
+
{titleIcon && heading ? (
|
|
51
|
+
<Box
|
|
52
|
+
data-testid={testIdFor(dataTestId, 'title-row')}
|
|
53
|
+
sx={{
|
|
54
|
+
display: 'flex',
|
|
55
|
+
alignItems: 'center',
|
|
56
|
+
gap: TITLE_ICON.gapUnits,
|
|
57
|
+
marginBottom: description ? TITLE.marginBottomUnits : 0,
|
|
58
|
+
'& > span': { display: 'flex', flex: 'none', fontSize: sxRem(ICON_SLOT.size) },
|
|
59
|
+
}}
|
|
60
|
+
>
|
|
61
|
+
{titleIcon}
|
|
62
|
+
{heading}
|
|
63
|
+
</Box>
|
|
64
|
+
) : (
|
|
65
|
+
heading
|
|
66
|
+
)}
|
|
67
|
+
{description && (
|
|
68
|
+
<Box
|
|
69
|
+
component="div"
|
|
70
|
+
data-testid={testIdFor(dataTestId, 'message')}
|
|
71
|
+
sx={{ opacity: DESCRIPTION.opacity, fontSize: sxRem(DESCRIPTION.fontSize), ...BREAK_WORDS }}
|
|
72
|
+
>
|
|
73
|
+
{description}
|
|
74
|
+
</Box>
|
|
75
|
+
)}
|
|
76
|
+
{children}
|
|
77
|
+
</>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
@@ -34,6 +34,7 @@ A beautiful and versatile Alert component with multiple variants, animations, an
|
|
|
34
34
|
| `pulse` | `boolean` | `false` | Add a pulsing animation effect |
|
|
35
35
|
| `animate` | `boolean` | `true` | Whether to animate the alert on mount |
|
|
36
36
|
| `announce` | `'polite' \| 'assertive'` | - | Sets `role` and `aria-live` together — see [Accessibility](#accessibility) |
|
|
37
|
+
| `iconPlacement` | `'gutter' \| 'title'` | theme's `uiAlert.iconPlacement`, else `'gutter'` | Icon in its own column, or on the title's line — see [Theming](#theming) |
|
|
37
38
|
| `className` | `string` | - | Additional CSS classes |
|
|
38
39
|
|
|
39
40
|
## Usage Examples
|
|
@@ -188,6 +189,23 @@ The Alert component integrates with the MUI theme system and responds to:
|
|
|
188
189
|
- Border radius settings
|
|
189
190
|
- Shadow/elevation tokens
|
|
190
191
|
|
|
192
|
+
### Where the icon sits — `uiAlert.iconPlacement`
|
|
193
|
+
|
|
194
|
+
A house style, so the host states it ONCE on its theme rather than at each call:
|
|
195
|
+
|
|
196
|
+
```ts
|
|
197
|
+
createTheme({ uiAlert: { iconPlacement: 'title' } });
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
| value | layout |
|
|
201
|
+
|---|---|
|
|
202
|
+
| `'gutter'` (default) | the icon has a column of its own; title and description start to its right |
|
|
203
|
+
| `'title'` | the icon sits on the title's line; the description starts at the alert's edge and uses the whole line |
|
|
204
|
+
|
|
205
|
+
An alert with no title, or with `showIcon={false}`, has no title line for the
|
|
206
|
+
icon, so `'title'` renders as `'gutter'`. A call site that must differ passes
|
|
207
|
+
`iconPlacement`, which wins over the theme. Web only.
|
|
208
|
+
|
|
191
209
|
## Testing
|
|
192
210
|
|
|
193
211
|
### Test IDs
|
|
@@ -198,6 +216,7 @@ The Alert component integrates with the MUI theme system and responds to:
|
|
|
198
216
|
| `alert-icon` | Icon | Alert severity icon |
|
|
199
217
|
| `alert-title` | Title | Alert title text |
|
|
200
218
|
| `alert-message` | Message | Alert message content |
|
|
219
|
+
| `alert-title-row` | Row | Icon and title together (`iconPlacement: 'title'` only) |
|
|
201
220
|
| `alert-close` | Button | Close button (when closable) |
|
|
202
221
|
|
|
203
222
|
Custom test IDs can be provided via the `dataTestId` prop:
|
|
@@ -40,6 +40,8 @@ export const TITLE = { fontSize: 16.8, fontWeight: 600, marginTop: -2, marginBot
|
|
|
40
40
|
/** The description: 0.925rem, slightly faded. */
|
|
41
41
|
export const DESCRIPTION = { fontSize: 14.8, opacity: 0.9 } as const;
|
|
42
42
|
|
|
43
|
+
/** The icon on the title's line (`iconPlacement: 'title'`): 10px from the title. */
|
|
44
|
+
export const TITLE_ICON = { gapUnits: 1.25 } as const;
|
|
43
45
|
/** The icon slot: MUI's 22px glyph at 0.9, 14px from the words, 2px down (MUI's 7px stays below). */
|
|
44
46
|
export const ICON_SLOT = { size: 22, opacity: 0.9, marginRightUnits: 1.75, paddingTopUnits: 0.25, paddingBottom: 7 } as const;
|
|
45
47
|
/** The action slot: MUI's `4px 0 0 16px` with the 16px ours, pushed right, 8px into the padding. */
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Theme } from '@mui/material/styles/index.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WHERE THE ICON SITS — a choice the HOST makes once, in its theme.
|
|
5
|
+
*
|
|
6
|
+
* - `'gutter'` (the default, and what every alert did before this existed):
|
|
7
|
+
* the icon has a column of its own, and the title and the description both
|
|
8
|
+
* start to its right. A two-line description wraps inside that narrower
|
|
9
|
+
* column and leaves an empty strip under the icon.
|
|
10
|
+
* - `'title'`: the icon sits on the TITLE's line, and the description below
|
|
11
|
+
* starts at the alert's own edge and uses the whole line.
|
|
12
|
+
*
|
|
13
|
+
* It is a theme value, like `uiSurfaces`, because it is a house style rather
|
|
14
|
+
* than a per-call decision: a host that wants it wants it on every alert, and a
|
|
15
|
+
* per-call prop would have to be spelled at each of them. The `iconPlacement`
|
|
16
|
+
* prop still exists for the one call site that must differ, and wins.
|
|
17
|
+
*
|
|
18
|
+
* An alert with no title, or no icon, has no title line to put the icon on;
|
|
19
|
+
* `'title'` then renders exactly as `'gutter'` does.
|
|
20
|
+
*/
|
|
21
|
+
export type AlertIconPlacement = 'gutter' | 'title';
|
|
22
|
+
|
|
23
|
+
/** What a host may state about alerts, on its theme. */
|
|
24
|
+
export interface UiAlertTheme {
|
|
25
|
+
iconPlacement?: AlertIconPlacement;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declare module '@mui/material/styles' {
|
|
29
|
+
interface Theme {
|
|
30
|
+
/** Alert layout the host states. See `Alert.placement.ts`. */
|
|
31
|
+
uiAlert?: UiAlertTheme;
|
|
32
|
+
}
|
|
33
|
+
interface ThemeOptions {
|
|
34
|
+
/** Alert layout, for every alert under this theme. See `Alert.placement.ts`. */
|
|
35
|
+
uiAlert?: UiAlertTheme;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The placement in force: the call site's, else the theme's, else `'gutter'`. */
|
|
40
|
+
export function resolveIconPlacement(
|
|
41
|
+
theme: Theme,
|
|
42
|
+
stated: AlertIconPlacement | undefined,
|
|
43
|
+
): AlertIconPlacement {
|
|
44
|
+
return stated ?? theme.uiAlert?.iconPlacement ?? 'gutter';
|
|
45
|
+
}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import Close from '@mui/icons-material/Close';
|
|
2
2
|
import MuiAlert from '@mui/material/Alert/index.js';
|
|
3
|
-
import AlertTitle from '@mui/material/AlertTitle/index.js';
|
|
4
3
|
import Box from '@mui/material/Box/index.js';
|
|
5
4
|
import Collapse from '@mui/material/Collapse/index.js';
|
|
6
5
|
import IconButton from '@mui/material/IconButton/index.js';
|
|
7
|
-
import { alpha, styled } from '@mui/material/styles/index.js';
|
|
6
|
+
import { alpha, styled, useTheme } from '@mui/material/styles/index.js';
|
|
8
7
|
import type { Theme } from '@mui/material/styles/index.js';
|
|
9
8
|
import React from 'react';
|
|
10
9
|
|
|
11
10
|
import { absoluteInk, modeInk } from '../../../tokens/ink';
|
|
12
11
|
|
|
12
|
+
import { AlertContent } from './Alert.content';
|
|
13
13
|
import { resolveAlertProps, resolveAnnouncement, testIdFor } from './Alert.helpers';
|
|
14
|
+
import { resolveIconPlacement, type AlertIconPlacement } from './Alert.placement';
|
|
14
15
|
import type { AlertPalette } from './Alert.metrics';
|
|
15
16
|
import {
|
|
16
17
|
ACTIVE,
|
|
@@ -21,12 +22,10 @@ import {
|
|
|
21
22
|
CLOSE_BUTTON,
|
|
22
23
|
CLOSE_DELAY_MS,
|
|
23
24
|
COLLAPSE_MS,
|
|
24
|
-
DESCRIPTION,
|
|
25
25
|
FADE_IN,
|
|
26
26
|
FOCUS,
|
|
27
27
|
HOVER,
|
|
28
28
|
seconds,
|
|
29
|
-
TITLE,
|
|
30
29
|
} from './Alert.metrics';
|
|
31
30
|
import {
|
|
32
31
|
alertEmphasisStyles,
|
|
@@ -39,7 +38,7 @@ import {
|
|
|
39
38
|
import type { AlertColor } from '@mui/material/Alert/index.js';
|
|
40
39
|
import type { AlertProps } from './Alert.types';
|
|
41
40
|
import { resolveTestId, withoutTestIdProps } from '../../../platform/test-id';
|
|
42
|
-
import { rem, rems
|
|
41
|
+
import { rem, rems } from '../../../tokens/relative';
|
|
43
42
|
|
|
44
43
|
const transition = `all ${seconds(ALERT_TRANSITION_MS)} ${ALERT_EASING}`;
|
|
45
44
|
|
|
@@ -176,47 +175,6 @@ const MUI_SEVERITY: Record<string, AlertColor> = {
|
|
|
176
175
|
const toMuiSeverity = (variant: string): AlertColor =>
|
|
177
176
|
MUI_SEVERITY[variant] ?? (variant as AlertColor);
|
|
178
177
|
|
|
179
|
-
const AlertContent: React.FC<{
|
|
180
|
-
title?: AlertProps['title'];
|
|
181
|
-
description?: AlertProps['description'];
|
|
182
|
-
dataTestId?: string;
|
|
183
|
-
children?: React.ReactNode;
|
|
184
|
-
}> = ({ title, description, dataTestId, children }) => (
|
|
185
|
-
<>
|
|
186
|
-
{title && (
|
|
187
|
-
<AlertTitle
|
|
188
|
-
data-testid={testIdFor(dataTestId, 'title')}
|
|
189
|
-
sx={{
|
|
190
|
-
fontWeight: TITLE.fontWeight,
|
|
191
|
-
fontSize: sxRem(TITLE.fontSize),
|
|
192
|
-
marginBottom: description ? TITLE.marginBottomUnits : 0,
|
|
193
|
-
wordWrap: 'break-word',
|
|
194
|
-
overflowWrap: 'break-word',
|
|
195
|
-
wordBreak: 'break-word',
|
|
196
|
-
}}
|
|
197
|
-
>
|
|
198
|
-
{title}
|
|
199
|
-
</AlertTitle>
|
|
200
|
-
)}
|
|
201
|
-
{description && (
|
|
202
|
-
<Box
|
|
203
|
-
component="div"
|
|
204
|
-
data-testid={testIdFor(dataTestId, 'message')}
|
|
205
|
-
sx={{
|
|
206
|
-
opacity: DESCRIPTION.opacity,
|
|
207
|
-
fontSize: sxRem(DESCRIPTION.fontSize),
|
|
208
|
-
wordWrap: 'break-word',
|
|
209
|
-
overflowWrap: 'break-word',
|
|
210
|
-
wordBreak: 'break-word',
|
|
211
|
-
}}
|
|
212
|
-
>
|
|
213
|
-
{description}
|
|
214
|
-
</Box>
|
|
215
|
-
)}
|
|
216
|
-
{children}
|
|
217
|
-
</>
|
|
218
|
-
);
|
|
219
|
-
|
|
220
178
|
const AlertCloseButton: React.FC<{ dataTestId?: string; label: string; onClose: () => void }> = ({
|
|
221
179
|
dataTestId,
|
|
222
180
|
label,
|
|
@@ -290,6 +248,31 @@ function dismissButton(
|
|
|
290
248
|
return <AlertCloseButton dataTestId={dataTestId} label={props.closeLabel} onClose={onClose} />;
|
|
291
249
|
}
|
|
292
250
|
|
|
251
|
+
/**
|
|
252
|
+
* Where the icon goes: MUI's own slot (`slot`), or the title's row
|
|
253
|
+
* (`titleIcon`) — never both. On the title's row only when there IS a title
|
|
254
|
+
* and an icon to put on it (`Alert.placement.ts`).
|
|
255
|
+
*/
|
|
256
|
+
function placeIcon({
|
|
257
|
+
icon,
|
|
258
|
+
dataTestId,
|
|
259
|
+
hasTitle,
|
|
260
|
+
placement,
|
|
261
|
+
}: {
|
|
262
|
+
icon: React.ReactNode;
|
|
263
|
+
dataTestId: string | undefined;
|
|
264
|
+
hasTitle: boolean;
|
|
265
|
+
placement: AlertIconPlacement;
|
|
266
|
+
}): { slot: React.ReactNode; titleIcon?: React.ReactNode } {
|
|
267
|
+
if (icon === null) return { slot: false };
|
|
268
|
+
const glyph = (
|
|
269
|
+
<Box component="span" data-testid={testIdFor(dataTestId, 'icon')}>
|
|
270
|
+
{icon}
|
|
271
|
+
</Box>
|
|
272
|
+
);
|
|
273
|
+
return placement === 'title' && hasTitle ? { slot: false, titleIcon: glyph } : { slot: glyph };
|
|
274
|
+
}
|
|
275
|
+
|
|
293
276
|
export const Alert = React.forwardRef<HTMLDivElement, AlertProps>((alertProps, ref) => {
|
|
294
277
|
const {
|
|
295
278
|
variant,
|
|
@@ -303,6 +286,7 @@ export const Alert = React.forwardRef<HTMLDivElement, AlertProps>((alertProps, r
|
|
|
303
286
|
description,
|
|
304
287
|
children,
|
|
305
288
|
animate,
|
|
289
|
+
iconPlacement,
|
|
306
290
|
role: _role, announce: _announce, // resolved from `alertProps` — see `resolveAnnouncement`
|
|
307
291
|
'aria-atomic': ariaAtomic,
|
|
308
292
|
...others
|
|
@@ -319,6 +303,7 @@ export const Alert = React.forwardRef<HTMLDivElement, AlertProps>((alertProps, r
|
|
|
319
303
|
|
|
320
304
|
// Depends on `variant`, so it cannot live in the static defaults above.
|
|
321
305
|
const announcement = resolveAnnouncement(alertProps, variant);
|
|
306
|
+
const theme = useTheme();
|
|
322
307
|
const [open, setOpen] = React.useState(true);
|
|
323
308
|
const [isClosing, setIsClosing] = React.useState(false);
|
|
324
309
|
|
|
@@ -332,19 +317,12 @@ export const Alert = React.forwardRef<HTMLDivElement, AlertProps>((alertProps, r
|
|
|
332
317
|
|
|
333
318
|
const severity = toMuiSeverity(variant);
|
|
334
319
|
|
|
335
|
-
const
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
);
|
|
342
|
-
|
|
343
|
-
const content = (
|
|
344
|
-
<AlertContent title={title} description={description} dataTestId={dataTestId}>
|
|
345
|
-
{children}
|
|
346
|
-
</AlertContent>
|
|
347
|
-
);
|
|
320
|
+
const { slot, titleIcon } = placeIcon({
|
|
321
|
+
icon: showIcon ? (icon ?? getVariantIcon(variant)) : null,
|
|
322
|
+
dataTestId,
|
|
323
|
+
hasTitle: Boolean(title),
|
|
324
|
+
placement: resolveIconPlacement(theme, iconPlacement),
|
|
325
|
+
});
|
|
348
326
|
|
|
349
327
|
return (
|
|
350
328
|
<Collapse in={open && !isClosing} timeout={COLLAPSE_MS}>
|
|
@@ -357,7 +335,7 @@ export const Alert = React.forwardRef<HTMLDivElement, AlertProps>((alertProps, r
|
|
|
357
335
|
glow={glow}
|
|
358
336
|
pulse={pulse}
|
|
359
337
|
animate={animate}
|
|
360
|
-
icon={
|
|
338
|
+
icon={slot}
|
|
361
339
|
role={announcement.role}
|
|
362
340
|
aria-live={announcement['aria-live']}
|
|
363
341
|
aria-atomic={ariaAtomic}
|
|
@@ -365,7 +343,9 @@ export const Alert = React.forwardRef<HTMLDivElement, AlertProps>((alertProps, r
|
|
|
365
343
|
action={dismissButton(alertProps, dataTestId, handleClose)}
|
|
366
344
|
{...props}
|
|
367
345
|
>
|
|
368
|
-
{
|
|
346
|
+
<AlertContent title={title} description={description} titleIcon={titleIcon} dataTestId={dataTestId}>
|
|
347
|
+
{children}
|
|
348
|
+
</AlertContent>
|
|
369
349
|
</StyledAlert>
|
|
370
350
|
</Collapse>
|
|
371
351
|
);
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import type { AlertProps as MuiAlertProps } from '@mui/material/Alert/index.js';
|
|
2
2
|
|
|
3
3
|
import type { AlertBaseFields, AlertDismiss } from './Alert.base';
|
|
4
|
+
import type { AlertIconPlacement } from './Alert.placement';
|
|
4
5
|
|
|
5
6
|
export type { AlertBaseFields, AlertBaseProps, AlertDismiss, AlertVariant } from './Alert.base';
|
|
7
|
+
export type { AlertIconPlacement, UiAlertTheme } from './Alert.placement';
|
|
6
8
|
|
|
7
9
|
/** The web `Alert`'s non-dismiss half: the shared fields, plus MUI's `Alert` props where they do not overlap. */
|
|
8
10
|
export interface AlertBase
|
|
9
11
|
extends AlertBaseFields,
|
|
10
|
-
Omit<MuiAlertProps, 'variant' | 'color' | 'role' | keyof AlertBaseFields> {
|
|
12
|
+
Omit<MuiAlertProps, 'variant' | 'color' | 'role' | keyof AlertBaseFields> {
|
|
13
|
+
/**
|
|
14
|
+
* Where the icon sits: its own column (`'gutter'`) or on the title's line
|
|
15
|
+
* (`'title'`). Unset, the theme's `uiAlert.iconPlacement` decides, else
|
|
16
|
+
* `'gutter'`. Web only. See `Alert.placement.ts`.
|
|
17
|
+
*/
|
|
18
|
+
iconPlacement?: AlertIconPlacement;
|
|
19
|
+
}
|
|
11
20
|
|
|
12
21
|
export type AlertProps = AlertBase & AlertDismiss;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/data-display/Alert/Alert.metrics.ts"],"sourcesContent":["import type { AlertVariant } from './Alert.base';\nimport { alpha, darken, lighten } from '../../../tokens/color';\nimport { NEUTRAL_RAMP } from '../../../tokens/ink.core';\nimport { contrastText, type UiGreyStep, type UiTheme } from '../../../tokens/theme';\n\n/**\n * THE NUMBERS BOTH `Alert` RENDERERS DRAW WITH.\n *\n * `Alert.styles.tsx` / `Alert.tsx` (MUI) and `Alert.native.tsx` (React\n * Native) read this one table. Spacing is in SPACING UNITS where the web\n * writes `theme.spacing(n)`; durations are ms (the web turns them into `s`\n * through {@link seconds} so its emitted CSS is byte-for-byte what it was);\n * everything else is px, a ratio or an alpha. The hover, active and focus\n * numbers are here too although only the DOM can honour them — a number the\n * web draws with belongs in the table whether or not native can reach it.\n */\n\n/** The root: 12px corners, 14px 16px of padding, one 300ms curve for everything. */\nexport const ALERT_RADIUS_UNITS = 1.5;\nexport const ALERT_PADDING_UNITS = { vertical: 1.75, horizontal: 2 } as const;\nexport const ALERT_TRANSITION_MS = 300;\nexport const ALERT_EASING = 'cubic-bezier(0.4, 0, 0.2, 1)';\n\n/** Mount: the web's `fadeInScale` keyframes and the icon's `iconRotate`. */\nexport const FADE_IN = { ms: 300, scale: 0.95, lift: 10 } as const;\nexport const ICON_SPIN = { ms: 600, from: 0.8, mid: 1.1 } as const;\n/** Dismiss: MUI `Collapse` runs 300ms; `onClose` fires 200ms in. */\nexport const COLLAPSE_MS = 300;\nexport const CLOSE_DELAY_MS = 200;\n\n/** The message column: 8px between title, description and children; 0.95rem body on 1.5. */\nexport const MESSAGE_GAP_UNITS = 1;\nexport const MESSAGE_FONT_SIZE = 15.2;\nexport const MESSAGE_LINE_HEIGHT = 1.5;\n/** A control inside the message gets an edge: 4px above, a hairline at 0.45 of the hue. */\nexport const MESSAGE_BUTTON = { marginTopUnits: 0.5, borderAlpha: 0.45 } as const;\n\n/** The title: 1.05rem at 600; MUI's `AlertTitle` lifts it 2px; 4px below it when a description follows. */\nexport const TITLE = { fontSize: 16.8, fontWeight: 600, marginTop: -2, marginBottomUnits: 0.5 } as const;\n/** The description: 0.925rem, slightly faded. */\nexport const DESCRIPTION = { fontSize: 14.8, opacity: 0.9 } as const;\n\n/** The icon slot: MUI's 22px glyph at 0.9, 14px from the words, 2px down (MUI's 7px stays below). */\nexport const ICON_SLOT = { size: 22, opacity: 0.9, marginRightUnits: 1.75, paddingTopUnits: 0.25, paddingBottom: 7 } as const;\n/** The action slot: MUI's `4px 0 0 16px` with the 16px ours, pushed right, 8px into the padding. */\nexport const ACTION_SLOT = { paddingLeftUnits: 2, paddingTop: 4, marginRight: -8 } as const;\n/** The close button: MUI's small `IconButton` (5px padding, 18px glyph) at 0.7. */\nexport const CLOSE_BUTTON = { padding: 5, iconSize: 18, opacity: 0.7, washAlpha: 0.1 } as const;\n\n/**\n * A semantic Alert's surface and ink: an OPAQUE tint of the hue with a dark\n * ink of the same hue — MUI's own `standard` recipe, at its ratios. See\n * `semanticSurface` in `Alert.styles.tsx` for why not `alpha(main, 0.1)`.\n */\nexport const SEMANTIC_SURFACE = { tint: { light: 0.9, dark: 0.8 }, ink: 0.6, borderAlpha: 0.35 } as const;\n/** `glass`: 85% paper under a 20px blur, a 0.4 divider hairline. */\nexport const GLASS = { backgroundAlpha: 0.85, borderAlpha: 0.4, blur: 20, saturatePercent: 180 } as const;\n/**\n * `gradient`: light→dark at 0.9 along 135°, a 0.2 white shimmer sweeping 1000px every 3s.\n *\n * It carries no hover of its own, and that is load-bearing rather than an\n * omission. `alertVariantStyles` is spread AFTER the root's `'&:hover'` in the\n * same object literal, so a second `'&:hover'` key does not merge with it — it\n * REPLACES it. While this variant had one, `gradient` was the only alert that\n * brightened on hover while every other variant darkened, and the only one to\n * lose the shimmer reveal the root's hover performs.\n */\nexport const GRADIENT = {\n angleDeg: 135,\n stopAlpha: 0.9,\n shimmerAlpha: 0.2,\n shimmerMs: 3000,\n shimmerTravel: 1000,\n} as const;\n\n/** Emphasis: the glow's shadow and brightness, the pulse's wash. */\nexport const GLOW = { blur: 20, spread: 5, alpha: 0.3, brightness: 1.05 } as const;\nexport const PULSE = { alpha: 0.2, ms: 2000, spread: 10 } as const;\n\n/**\n * Pointer states — DOM only, kept so the web derives them.\n *\n * HOVER and ACTIVE carry NO geometry, and that is the point rather than an\n * omission. They used to lift the card 3px, scale it 1.01, grow a 20px shadow\n * and spin the icon 10deg at 1.15 — four things moving at once on a surface\n * that is not a control, which made a page of alerts twitch under the pointer.\n *\n * Both are a TINT now: a flat inset layer over the surface. Two mechanisms\n * came before it and each failed on a case the next had to fix. Dropping the\n * element's `opacity` composites toward the PAGE, so it inverted the hover on\n * a light tint (L* 95.0 idle, 89.1 hovered, 91.1 pressed) and vanished on a\n * dark one. A `filter: brightness()` fixed the direction but is MULTIPLICATIVE,\n * so it moved a near-black `glass` by four counts (ΔE76 1.71, under the JND)\n * and Banner's 10%-alpha wash by ΔE76 0.44. A layer is additive: it reads the\n * same on an opaque tint, a translucent wash and a gradient, and because it\n * paints above the background and below the content the ink keeps its own\n * contrast.\n */\nexport const HOVER = { tintAlpha: 0.06 } as const;\n\n/**\n * The press: a 20% tint LAYER, eased back fast.\n *\n * The layer is the point. The first attempt dropped the whole element's\n * opacity, which composites toward the PAGE and so behaves differently on\n * every surface it is asked about. Measured: over a light page it made a light\n * tint LIGHTER (L* 95.0 idle, 89.1 hovered, 91.1 pressed), so pushing the\n * surface looked like the pointer leaving; over a dark page it landed back on\n * the idle surface (ΔE76 0.82 on `glass`); on `gradient` it washed white body\n * copy to 2.31:1, under AA; and it diluted the ink during a text-selection\n * drag. A `brightness()` step instead of it fixed the direction but not the\n * reach — a multiplier does nothing to a near-black `glass` in dark mode\n * (ΔE76 1.71) and nothing to Banner's 10%-alpha wash (ΔE76 0.44), because it\n * scales only what the element already paints.\n *\n * An inset shadow at 100vmax is a flat tint over the whole surface: ADDITIVE,\n * so it reads the same on an opaque tint, a translucent wash and a gradient;\n * painted above the background and below the content, so the ink keeps its\n * own contrast; and animatable, which `background-image` is not.\n *\n * `ms` is 250 and not the 1000 first asked for, and the reason is that ONE\n * property carries both states. CSS runs a transition from the DESTINATION\n * state's declaration, and entering hover and releasing a press share that\n * destination — so they cannot have different durations without a second\n * animatable property, and both free pseudo-elements are already spent on the\n * `gradient` shimmer and the `pulse` wash. At 1000ms the hover inherited the\n * second: crossing an alert in 300ms peaked at a ≈ 0.024, under the JND, and\n * for ~360ms the alert you had just LEFT was darker than the one under the\n * pointer. A fast press-return is the smaller loss, and it is the call the\n * product owner made when shown both.\n */\nexport const ACTIVE = { tintAlpha: 0.2, ms: 250 } as const;\n\nexport const FOCUS = { ringWidth: 2, ringAlpha: 1, offset: 2 } as const;\n\n/** `neutral` has no palette slot; the web has always drawn it from three greys. */\nexport const NEUTRAL_GREY: Record<'main' | 'light' | 'dark', UiGreyStep> = { main: 500, light: 300, dark: 700 };\n\n/** A duration as the CSS the web has always emitted: `2000` → `2s`, `300` → `0.3s`. */\nexport const seconds = (ms: number): string => `${ms / 1000}s`;\n\n/** The palette shape the web's `getColorFromTheme` returns — a main plus optional shades. */\nexport interface AlertPalette {\n main: string;\n light?: string;\n dark?: string;\n}\n\n/**\n * The renderer-free twin of the web's `getColorFromTheme`: a variant or\n * colour name to its palette, `neutral` from the greys, anything unknown\n * (`glass`, `gradient`) to `info`.\n */\nexport function alertPalette(theme: UiTheme, key: string | undefined): AlertPalette {\n switch (key) {\n case 'info':\n case 'success':\n case 'warning':\n case 'danger':\n case 'primary':\n case 'secondary':\n return theme.palette[key];\n case 'neutral':\n return {\n main: NEUTRAL_RAMP[NEUTRAL_GREY.main],\n light: NEUTRAL_RAMP[NEUTRAL_GREY.light],\n dark: NEUTRAL_RAMP[NEUTRAL_GREY.dark],\n };\n default:\n return theme.palette.info;\n }\n}\n\n/** What a variant paints: its fill, its ink, its hairline if any, and the colour of its glyph. */\nexport interface AlertSurface {\n backgroundColor: string;\n color: string;\n borderColor?: string;\n iconColor: string;\n}\n\nexport const SEMANTIC_VARIANTS: ReadonlySet<AlertVariant> = new Set(['info', 'success', 'warning', 'danger']);\n\n/** The opaque tint and same-hue ink, inverted for dark mode; the hairline keeps its alpha. */\nexport function semanticSurface(theme: UiTheme, palette: AlertPalette): AlertSurface {\n const dark = theme.mode === 'dark';\n return {\n backgroundColor: dark\n ? darken(palette.main, SEMANTIC_SURFACE.tint.dark)\n : lighten(palette.main, SEMANTIC_SURFACE.tint.light),\n color: dark ? lighten(palette.main, SEMANTIC_SURFACE.ink) : darken(palette.main, SEMANTIC_SURFACE.ink),\n borderColor: alpha(palette.main, SEMANTIC_SURFACE.borderAlpha),\n iconColor: palette.main,\n };\n}\n\nexport function glassSurface(theme: UiTheme): AlertSurface {\n return {\n backgroundColor: alpha(theme.palette.background.paper, GLASS.backgroundAlpha),\n color: theme.palette.text.primary,\n borderColor: alpha(theme.palette.divider, GLASS.borderAlpha),\n iconColor: theme.palette.primary.main,\n };\n}\n\n/** The gradient's two stops; a renderer with no gradient fill paints `from`. */\nexport function gradientStops(palette: AlertPalette): { from: string; to: string } {\n return {\n from: alpha(palette.light || palette.main, GRADIENT.stopAlpha),\n to: alpha(palette.dark || palette.main, GRADIENT.stopAlpha),\n };\n}\n\nexport function gradientSurface(palette: AlertPalette): AlertSurface {\n const ink = contrastText(palette.main);\n return { backgroundColor: gradientStops(palette).from, color: ink, iconColor: ink };\n}\n\n/** The surface for a variant, `glass` and `gradient` included. */\nexport function alertSurface(theme: UiTheme, variant: AlertVariant, palette: AlertPalette): AlertSurface {\n if (variant === 'glass') return glassSurface(theme);\n if (variant === 'gradient') return gradientSurface(palette);\n return semanticSurface(theme, palette);\n}\n"],"mappings":";;;;;;;;;;;;;AAkBO,IAAM,qBAAqB;AAC3B,IAAM,sBAAsB,EAAE,UAAU,MAAM,YAAY,EAAE;AAC5D,IAAM,sBAAsB;AAC5B,IAAM,eAAe;AAGrB,IAAM,UAAU,EAAE,IAAI,KAAK,OAAO,MAAM,MAAM,GAAG;AACjD,IAAM,YAAY,EAAE,IAAI,KAAK,MAAM,KAAK,KAAK,IAAI;AAEjD,IAAM,cAAc;AACpB,IAAM,iBAAiB;AAGvB,IAAM,oBAAoB;AAC1B,IAAM,oBAAoB;AAC1B,IAAM,sBAAsB;AAE5B,IAAM,iBAAiB,EAAE,gBAAgB,KAAK,aAAa,KAAK;AAGhE,IA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Aa,OAAgB,SAAuB,SAAqC;AACvG,MAAI,YAAY,QAAS,QAAO,aAAa,KAAK;AAClD,MAAI,YAAY,WAAY,QAAO,gBAAgB,OAAO;AAC1D,SAAO,gBAAgB,OAAO,OAAO;AACvC;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/data-display/Alert/Alert.tsx"],"sourcesContent":["import Close from '@mui/icons-material/Close';\nimport MuiAlert from '@mui/material/Alert/index.js';\nimport AlertTitle from '@mui/material/AlertTitle/index.js';\nimport Box from '@mui/material/Box/index.js';\nimport Collapse from '@mui/material/Collapse/index.js';\nimport IconButton from '@mui/material/IconButton/index.js';\nimport { alpha, styled } from '@mui/material/styles/index.js';\nimport type { Theme } from '@mui/material/styles/index.js';\nimport React from 'react';\n\nimport { absoluteInk, modeInk } from '../../../tokens/ink';\n\nimport { resolveAlertProps, resolveAnnouncement, testIdFor } from './Alert.helpers';\nimport type { AlertPalette } from './Alert.metrics';\nimport {\n ACTIVE,\n GLOW,\n ALERT_EASING,\n ALERT_RADIUS_UNITS,\n ALERT_TRANSITION_MS,\n CLOSE_BUTTON,\n CLOSE_DELAY_MS,\n COLLAPSE_MS,\n DESCRIPTION,\n FADE_IN,\n FOCUS,\n HOVER,\n seconds,\n TITLE,\n} from './Alert.metrics';\nimport {\n alertEmphasisStyles,\n alertLayoutStyles,\n alertVariantStyles,\n fadeInScale,\n getColorFromTheme,\n getVariantIcon,\n} from './Alert.styles';\nimport type { AlertColor } from '@mui/material/Alert/index.js';\nimport type { AlertProps } from './Alert.types';\nimport { resolveTestId, withoutTestIdProps } from '../../../platform/test-id';\nimport { rem, rems, sxRem } from '../../../tokens/relative';\n\nconst transition = `all ${seconds(ALERT_TRANSITION_MS)} ${ALERT_EASING}`;\n\n// Define animations\n/**\n * The pointer states' shadow: a flat tint, plus the glow when the alert has one.\n *\n * The tint is an inset spread at 100vmax, which always exceeds the element, so\n * it covers the surface edge to edge. It paints ABOVE the background and BELOW\n * the content, which is what keeps the ink's own contrast out of these states\n * entirely — see `ACTIVE` in `Alert.metrics.ts` for why a layer replaced the\n * opacity dip and the brightness multiplier that each preceded it.\n *\n * The glow is COMPOSED rather than replaced, so hovering a glowing alert keeps\n * its glow; `glowStyles` gave up its `!important` for this.\n */\nfunction pointerShadow(\n theme: Theme,\n colorPalette: AlertPalette,\n glow: boolean,\n variant: string | undefined,\n): (alpha_: number) => string {\n // The tint moves the surface AWAY from its own ink, which is why this reads\n // the variant and not only the mode.\n //\n // `gradient` is the one variant where the two disagree: it paints a\n // mid-lightness sweep (L* 42–61) under WHITE ink in BOTH modes, so the\n // mode-keyed answer tinted it white in dark mode — toward the text. Measured:\n // white-on-gradient fell to 2.90:1 on hover and 2.41:1 pressed, under the 3:1\n // floor and below its own idle. Every other variant's surface tracks the mode,\n // so for them the two rules agree.\n const ink = variant === 'gradient' ? absoluteInk(theme).black : modeInk(theme);\n const glowShadow = glow\n ? `0 0 ${rems(theme, GLOW.blur, GLOW.spread)} ${alpha(colorPalette.main, GLOW.alpha)}`\n : null;\n return (alpha_) =>\n [`inset 0 0 0 100vmax ${alpha(ink, alpha_)}`, glowShadow].filter(Boolean).join(', ');\n}\n\nconst StyledAlert = styled(MuiAlert, {\n shouldForwardProp: (prop) =>\n !['customVariant', 'customColor', 'glow', 'pulse', 'animate'].includes(prop as string),\n})<{\n customVariant?: string;\n customColor?: string;\n glow?: boolean;\n pulse?: boolean;\n animate?: boolean;\n}>(({ theme, customVariant, customColor, glow, pulse, animate }) => {\n const colorPalette = getColorFromTheme(theme, customColor || customVariant || 'info');\n\n const withTint = pointerShadow(theme, colorPalette, Boolean(glow), customVariant);\n\n return {\n borderRadius: theme.spacing(ALERT_RADIUS_UNITS),\n transition: `${transition}, box-shadow ${seconds(ACTIVE.ms)} ${ALERT_EASING}`,\n position: 'relative',\n overflow: 'hidden',\n animation: animate ? `${fadeInScale(theme)} ${seconds(FADE_IN.ms)} ease-out` : 'none',\n willChange: 'transform, opacity',\n\n ...alertLayoutStyles(theme, colorPalette, animate),\n\n // Hover: one tint step, and nothing that moves. An alert is a surface\n // rather than a control, so the pointer only needs telling it is here. The\n // icon keeps its own place for the same reason — it is the variant's\n // meaning, not an affordance to animate.\n '&:hover': {\n boxShadow: withTint(HOVER.tintAlpha),\n\n '&::before': {\n opacity: 1,\n },\n },\n\n // Press: a 20% tint, landing at once and easing back. Still no geometry.\n //\n // `transition: none` here is what makes the dip INSTANT: a click's\n // `:active` lasts about as long as the finger is down, so easing into it\n // would be cut off in its first tenth and read as a flicker. The ease is on\n // the way back, governed by the root.\n //\n // Neither `:hover` nor `:focus-visible` may declare `transition`, and that\n // is not a style preference. `:active` under a mouse ALWAYS implies\n // `:hover`, so a bare shorthand in the hover block outranks the root's\n // (0,2,0 beats 0,1,0) and silently resets the timing this state rests on.\n //\n // The `:not(:has(…))` names CONTROLS, not any descendant. `:active`\n // matches an ancestor of whatever is pressed, so dismissing an alert\n // dimmed the alert being dismissed and pressing a call to action dimmed\n // the message explaining it. Excluding `:has(:active)` wholesale does not\n // work and was the first attempt: pressing the TEXT makes that text\n // `:active` too, so the guard matched on every press and the state never\n // fired at all.\n '&:active:not(:has(button:active, a:active, [role=\"button\"]:active))': {\n boxShadow: withTint(ACTIVE.tintAlpha),\n transition: 'none',\n },\n\n // Focus: `:focus-visible`, not `:focus-within`.\n //\n // The alert carries `tabIndex={0}`, so a MOUSE CLICK focused it and painted\n // the ring — a keyboard affordance answering a pointer, which is what made\n // clicking one look like an error state. `:focus-visible` is the browser's\n // own answer to \"did this focus come from the keyboard\": the ring stays for\n // whoever tabs here and never fires on a click.\n //\n // One ring, not three. It was a 3px outline at 3px offset UNDER a 6px halo,\n // and stacking two rings on one edge is what read as unfinished rather than\n // as emphasis.\n // It declares no `transition`: `outline-style` is discrete, so the ring\n // arrives at full width with only its COLOUR easing — from `currentcolor`,\n // the near-black alert ink, to the blue. That is a visible dark flash on\n // every keyboard focus, and it would also outrank the root's opacity\n // transition the way the hover block did.\n '&:focus-visible': {\n outline: `${rem(theme, FOCUS.ringWidth)} solid ${alpha(colorPalette.main, FOCUS.ringAlpha)}`,\n outlineOffset: rem(theme, FOCUS.offset),\n },\n\n ...alertVariantStyles(theme, customVariant, colorPalette),\n ...alertEmphasisStyles(theme, colorPalette, Boolean(glow), Boolean(pulse)),\n };\n});\n\n// glass and gradient are our own looks with no MUI severity of their own; both\n// borrow info's. danger is MUI's error.\nconst MUI_SEVERITY: Record<string, AlertColor> = {\n danger: 'error',\n glass: 'info',\n gradient: 'info',\n};\n\nconst toMuiSeverity = (variant: string): AlertColor =>\n MUI_SEVERITY[variant] ?? (variant as AlertColor);\n\nconst AlertContent: React.FC<{\n title?: AlertProps['title'];\n description?: AlertProps['description'];\n dataTestId?: string;\n children?: React.ReactNode;\n}> = ({ title, description, dataTestId, children }) => (\n <>\n {title && (\n <AlertTitle\n data-testid={testIdFor(dataTestId, 'title')}\n sx={{\n fontWeight: TITLE.fontWeight,\n fontSize: sxRem(TITLE.fontSize),\n marginBottom: description ? TITLE.marginBottomUnits : 0,\n wordWrap: 'break-word',\n overflowWrap: 'break-word',\n wordBreak: 'break-word',\n }}\n >\n {title}\n </AlertTitle>\n )}\n {description && (\n <Box\n component=\"div\"\n data-testid={testIdFor(dataTestId, 'message')}\n sx={{\n opacity: DESCRIPTION.opacity,\n fontSize: sxRem(DESCRIPTION.fontSize),\n wordWrap: 'break-word',\n overflowWrap: 'break-word',\n wordBreak: 'break-word',\n }}\n >\n {description}\n </Box>\n )}\n {children}\n </>\n);\n\nconst AlertCloseButton: React.FC<{ dataTestId?: string; label: string; onClose: () => void }> = ({\n dataTestId,\n label,\n onClose,\n}) => (\n <IconButton\n data-testid={testIdFor(dataTestId, 'close')}\n aria-label={label}\n color=\"inherit\"\n size=\"small\"\n onClick={onClose}\n sx={(theme) => ({\n transition,\n opacity: CLOSE_BUTTON.opacity,\n // Opacity and a wash only: the button used to spin 90deg and grow 1.1,\n // which drew the eye to the dismiss rather than to the message.\n '&:hover': {\n opacity: 1,\n backgroundColor: alpha(theme.palette.action.hover, CLOSE_BUTTON.washAlpha),\n },\n // A REAL ring, on the keyboard-only selector.\n //\n // This used to be `&:focus` setting `outline: 'none'` over a\n // `rgba(0,0,0,0.1)` wash — 1.25:1 against the info surface, and MUI's\n // ButtonBase already sets `outline: 0`, so there was no UA fallback\n // either. It went unnoticed while the ROOT still matched `:focus-within`\n // and drew a ring around the whole alert; moving the root to\n // `:focus-visible` took that away and left this button with no visible\n // focus at all. `Banner`'s dismiss already draws its own outline, so\n // this is also what keeps the two surfaces telling a keyboard user the\n // same thing.\n '&:focus-visible': {\n opacity: 1,\n // `currentColor` is the alert's own ink, inherited through\n // `color=\"inherit\"`, so the ring is drawn in whatever colour was\n // already chosen to be READ on this surface. Measured 11.2:1 on the\n // semantic variants and 5.7:1 on `gradient`.\n //\n // That is a reasoned choice, not a test-backed one, and the difference\n // matters: `alert-contrast.test.tsx` covers the ink of the four\n // semantic variants only — its `glass` case asserts the pane's alpha\n // rather than its ink, and `gradient` it does not render at all. A\n // translucent surface's contrast depends on what sits behind it, which\n // is why that test stops where it does and why this comment does not\n // borrow a guarantee it never made.\n outline: `${rem(theme, FOCUS.ringWidth)} solid currentColor`,\n outlineOffset: rem(theme, FOCUS.offset),\n backgroundColor: alpha(theme.palette.action.focus, CLOSE_BUTTON.washAlpha),\n },\n })}\n >\n <Close fontSize=\"inherit\" />\n </IconButton>\n);\n\n/**\n * The dismiss button, or nothing.\n *\n * Reads `closeLabel` straight off the props rather than through the\n * `definedProps` merge, which would widen it to `string | undefined` and hand\n * the button an empty name. The UNION in `AlertProps` guarantees the label\n * wherever `closable` is true — that narrowing is gone inside the component,\n * which is why the fallback below exists and why it is unreachable.\n */\nfunction dismissButton(\n props: AlertProps,\n dataTestId: string | undefined,\n onClose: () => void,\n): React.JSX.Element | null {\n if (!props.closable) return null;\n return <AlertCloseButton dataTestId={dataTestId} label={props.closeLabel} onClose={onClose} />;\n}\n\nexport const Alert = React.forwardRef<HTMLDivElement, AlertProps>((alertProps, ref) => {\n const {\n variant,\n color,\n glow,\n pulse,\n icon,\n showIcon,\n onClose,\n title,\n description,\n children,\n animate,\n role: _role, announce: _announce, // resolved from `alertProps` — see `resolveAnnouncement`\n 'aria-atomic': ariaAtomic,\n ...others\n } = resolveAlertProps(alertProps);\n\n // Every spelling of the test id the shared contract allows, mapped to the\n // one the DOM reads and defaulted to `alert`; the native Alert does the same.\n const dataTestId = resolveTestId(others, 'alert');\n // Then the dismiss union, which `dismissButton` reads off `alertProps` rather\n // than through this destructure — so without this strip it rides `...props`\n // onto the DOM. `ALERT_DEFAULTS` supplies `closable: false`, so that happened\n // on EVERY alert, not only the closable ones.\n const props = withoutAlertOnlyProps(withoutTestIdProps(others));\n\n // Depends on `variant`, so it cannot live in the static defaults above.\n const announcement = resolveAnnouncement(alertProps, variant);\n const [open, setOpen] = React.useState(true);\n const [isClosing, setIsClosing] = React.useState(false);\n\n const handleClose = () => {\n setIsClosing(true);\n window.setTimeout(() => {\n setOpen(false);\n onClose?.();\n }, CLOSE_DELAY_MS);\n };\n\n const severity = toMuiSeverity(variant);\n\n const displayIcon = showIcon ? (\n <Box component=\"span\" data-testid={testIdFor(dataTestId, 'icon')}>\n {icon || getVariantIcon(variant)}\n </Box>\n ) : (\n false\n );\n\n const content = (\n <AlertContent title={title} description={description} dataTestId={dataTestId}>\n {children}\n </AlertContent>\n );\n\n return (\n <Collapse in={open && !isClosing} timeout={COLLAPSE_MS}>\n <StyledAlert\n ref={ref}\n data-testid={dataTestId}\n severity={severity}\n customVariant={variant}\n customColor={color}\n glow={glow}\n pulse={pulse}\n animate={animate}\n icon={displayIcon}\n role={announcement.role}\n aria-live={announcement['aria-live']}\n aria-atomic={ariaAtomic}\n tabIndex={0}\n action={dismissButton(alertProps, dataTestId, handleClose)}\n {...props}\n >\n {content}\n </StyledAlert>\n </Collapse>\n );\n});\n\n/**\n * The props `Alert` OWNS, which must never reach the DOM.\n *\n * `AlertProps` extends MUI's, whose rest-spread is how a host's real HTML\n * attributes get onto the root — so the same spread carries the alert's own\n * configuration unless it is named here. Everything else the component consumes\n * leaves through the destructure above; these two do not, because\n * `dismissButton` reads them off the original props to keep the dismiss union's\n * narrowing intact.\n *\n * Exported so a test can render an alert carrying every name on it and assert\n * none reaches the DOM — the check that would have caught `closable`.\n */\nexport const ALERT_ONLY_PROPS = ['closable', 'closeLabel'] as const;\n\nfunction withoutAlertOnlyProps<P extends object>(rest: P): P {\n const html = { ...rest } as Record<string, unknown>;\n for (const key of ALERT_ONLY_PROPS) delete html[key];\n return html as P;\n}\n\nAlert.displayName = 'Alert';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,WAAW;AAClB,OAAO,cAAc;AACrB,OAAO,gBAAgB;AACvB,OAAO,SAAS;AAChB,OAAO,cAAc;AACrB,OAAO,gBAAgB;AACvB,SAAS,OAAO,cAAc;AAE9B,OAAO,WAAW;AAgLhB,mBAEI,KAFJ;AA7IF,IAAM,aAAa,OAAO,QAAQ,mBAAmB,CAAC,IAAI,YAAY;AAetE,SAAS,cACP,OACA,cACA,MACA,SAC4B;AAU5B,QAAM,MAAM,YAAY,aAAa,YAAY,KAAK,EAAE,QAAQ,QAAQ,KAAK;AAC7E,QAAM,aAAa,OACf,OAAO,KAAK,OAAO,KAAK,MAAM,KAAK,MAAM,CAAC,IAAI,MAAM,aAAa,MAAM,KAAK,KAAK,CAAC,KAClF;AACJ,SAAO,CAAC,WACN,CAAC,uBAAuB,MAAM,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,OAAO,OAAO,EAAE,KAAK,IAAI;AACvF;AAEA,IAAM,cAAc,OAAO,UAAU;AAAA,EACnC,mBAAmB,CAAC,SAClB,CAAC,CAAC,iBAAiB,eAAe,QAAQ,SAAS,SAAS,EAAE,SAAS,IAAc;AACzF,CAAC,EAME,CAAC,EAAE,OAAO,eAAe,aAAa,MAAM,OAAO,QAAQ,MAAM;AACl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gBAAa,OAAc,aAA0B,YACnD,UACH;AAGF,SACE,oBAAC,YAAS,IAAI,QAAQ,CAAC,WAAW,SAAS,aACzC;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,eAAa;AAAA,MACb;AAAA,MACA,eAAe;AAAA,MACf,aAAa;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM;AAAA,MACN,MAAM,aAAa;AAAA,MACnB,aAAW,aAAa,WAAW;AAAA,MACnC,eAAa;AAAA,MACb,UAAU;AAAA,MACV,QAAQ,cAAc,YAAY,YAAY,WAAW;AAAA,MACxD,GAAG;AAAA,MAEH;AAAA;AAAA,EACH,GACF;AAEJ,CAAC;AAeM,IAAM,mBAAmB,CAAC,YAAY,YAAY;AAEzD,SAAS,sBAAwC,MAAY;AAC3D,QAAM,OAAO,EAAE,GAAG,KAAK;AACvB,aAAW,OAAO,iBAAkB,QAAO,KAAK,GAAG;AACnD,SAAO;AACT;AAEA,MAAM,cAAc;","names":[]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|