@fluentui/react-alert 9.0.0-beta.4 → 9.0.0-beta.40
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/CHANGELOG.json +1189 -1
- package/CHANGELOG.md +424 -2
- package/README.md +1 -1
- package/dist/index.d.ts +11 -1
- package/lib/Alert.js.map +1 -1
- package/lib/components/Alert/Alert.js +0 -1
- package/lib/components/Alert/Alert.js.map +1 -1
- package/lib/components/Alert/Alert.types.js.map +1 -1
- package/lib/components/Alert/index.js.map +1 -1
- package/lib/components/Alert/renderAlert.js +8 -3
- package/lib/components/Alert/renderAlert.js.map +1 -1
- package/lib/components/Alert/useAlert.js +29 -17
- package/lib/components/Alert/useAlert.js.map +1 -1
- package/lib/components/Alert/useAlertStyles.js +106 -57
- package/lib/components/Alert/useAlertStyles.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib-commonjs/Alert.js +0 -2
- package/lib-commonjs/Alert.js.map +1 -1
- package/lib-commonjs/components/Alert/Alert.js +0 -6
- package/lib-commonjs/components/Alert/Alert.js.map +1 -1
- package/lib-commonjs/components/Alert/Alert.types.js.map +1 -1
- package/lib-commonjs/components/Alert/index.js +0 -6
- package/lib-commonjs/components/Alert/index.js.map +1 -1
- package/lib-commonjs/components/Alert/renderAlert.js +8 -7
- package/lib-commonjs/components/Alert/renderAlert.js.map +1 -1
- package/lib-commonjs/components/Alert/useAlert.js +29 -23
- package/lib-commonjs/components/Alert/useAlert.js.map +1 -1
- package/lib-commonjs/components/Alert/useAlertStyles.js +106 -61
- package/lib-commonjs/components/Alert/useAlertStyles.js.map +1 -1
- package/lib-commonjs/index.js +0 -2
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +28 -17
- package/Migration.md +0 -0
- package/Spec.md +0 -95
- package/dist/tsdoc-metadata.json +0 -11
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { Avatar } from '@fluentui/react-avatar';
|
|
2
3
|
import { Button } from '@fluentui/react-button';
|
|
3
4
|
import { CheckmarkCircleFilled, DismissCircleFilled, InfoFilled, WarningFilled } from '@fluentui/react-icons';
|
|
4
5
|
import { getNativeElementProps, resolveShorthand } from '@fluentui/react-utilities';
|
|
@@ -11,53 +12,64 @@ import { getNativeElementProps, resolveShorthand } from '@fluentui/react-utiliti
|
|
|
11
12
|
* @param props - props from this instance of Alert
|
|
12
13
|
* @param ref - reference to root HTMLElement of Alert
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
15
|
export const useAlert_unstable = (props, ref) => {
|
|
16
16
|
const {
|
|
17
|
+
appearance = 'primary',
|
|
17
18
|
intent
|
|
18
19
|
} = props;
|
|
19
|
-
/** Determine the icon to render based on the intent */
|
|
20
|
-
|
|
20
|
+
/** Determine the role and icon to render based on the intent */
|
|
21
21
|
let defaultIcon;
|
|
22
|
-
|
|
22
|
+
let defaultRole = 'status';
|
|
23
23
|
switch (intent) {
|
|
24
24
|
case 'success':
|
|
25
25
|
defaultIcon = /*#__PURE__*/React.createElement(CheckmarkCircleFilled, null);
|
|
26
26
|
break;
|
|
27
|
-
|
|
28
27
|
case 'error':
|
|
29
28
|
defaultIcon = /*#__PURE__*/React.createElement(DismissCircleFilled, null);
|
|
29
|
+
defaultRole = 'alert';
|
|
30
30
|
break;
|
|
31
|
-
|
|
32
31
|
case 'warning':
|
|
33
32
|
defaultIcon = /*#__PURE__*/React.createElement(WarningFilled, null);
|
|
33
|
+
defaultRole = 'alert';
|
|
34
34
|
break;
|
|
35
|
-
|
|
36
35
|
case 'info':
|
|
37
36
|
defaultIcon = /*#__PURE__*/React.createElement(InfoFilled, null);
|
|
38
37
|
break;
|
|
39
38
|
}
|
|
40
|
-
|
|
41
|
-
const icon = resolveShorthand(props.icon, {
|
|
39
|
+
const action = resolveShorthand(props.action, {
|
|
42
40
|
defaultProps: {
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
required: !!props.intent
|
|
41
|
+
appearance: 'transparent'
|
|
42
|
+
}
|
|
46
43
|
});
|
|
44
|
+
const avatar = resolveShorthand(props.avatar);
|
|
45
|
+
let icon;
|
|
46
|
+
/** Avatar prop takes precedence over the icon or intent prop */
|
|
47
|
+
if (!avatar) {
|
|
48
|
+
icon = resolveShorthand(props.icon, {
|
|
49
|
+
defaultProps: {
|
|
50
|
+
children: defaultIcon
|
|
51
|
+
},
|
|
52
|
+
required: !!props.intent
|
|
53
|
+
});
|
|
54
|
+
}
|
|
47
55
|
return {
|
|
56
|
+
action,
|
|
57
|
+
appearance,
|
|
58
|
+
avatar,
|
|
48
59
|
components: {
|
|
49
60
|
root: 'div',
|
|
50
61
|
icon: 'span',
|
|
51
|
-
action: Button
|
|
62
|
+
action: Button,
|
|
63
|
+
avatar: Avatar
|
|
52
64
|
},
|
|
65
|
+
icon,
|
|
66
|
+
intent,
|
|
53
67
|
root: getNativeElementProps('div', {
|
|
54
68
|
ref,
|
|
69
|
+
role: defaultRole,
|
|
55
70
|
children: props.children,
|
|
56
71
|
...props
|
|
57
|
-
})
|
|
58
|
-
icon,
|
|
59
|
-
action: resolveShorthand(props.action),
|
|
60
|
-
intent
|
|
72
|
+
})
|
|
61
73
|
};
|
|
62
74
|
};
|
|
63
75
|
//# sourceMappingURL=useAlert.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["React","Avatar","Button","CheckmarkCircleFilled","DismissCircleFilled","InfoFilled","WarningFilled","getNativeElementProps","resolveShorthand","useAlert_unstable","props","ref","appearance","intent","defaultIcon","defaultRole","createElement","action","defaultProps","avatar","icon","children","required","components","root","role"],"sources":["../src/packages/react-components/react-alert/src/components/Alert/useAlert.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Avatar } from '@fluentui/react-avatar';\nimport { Button } from '@fluentui/react-button';\nimport { CheckmarkCircleFilled, DismissCircleFilled, InfoFilled, WarningFilled } from '@fluentui/react-icons';\nimport { getNativeElementProps, resolveShorthand } from '@fluentui/react-utilities';\n\nimport type { AlertProps, AlertState } from './Alert.types';\n\n/**\n * Create the state required to render Alert.\n *\n * The returned state can be modified with hooks such as useAlertStyles_unstable,\n * before being passed to renderAlert_unstable.\n *\n * @param props - props from this instance of Alert\n * @param ref - reference to root HTMLElement of Alert\n */\nexport const useAlert_unstable = (props: AlertProps, ref: React.Ref<HTMLElement>): AlertState => {\n const { appearance = 'primary', intent } = props;\n\n /** Determine the role and icon to render based on the intent */\n let defaultIcon;\n let defaultRole = 'status';\n switch (intent) {\n case 'success':\n defaultIcon = <CheckmarkCircleFilled />;\n break;\n case 'error':\n defaultIcon = <DismissCircleFilled />;\n defaultRole = 'alert';\n break;\n case 'warning':\n defaultIcon = <WarningFilled />;\n defaultRole = 'alert';\n break;\n case 'info':\n defaultIcon = <InfoFilled />;\n break;\n }\n\n const action = resolveShorthand(props.action, { defaultProps: { appearance: 'transparent' } });\n const avatar = resolveShorthand(props.avatar);\n let icon;\n /** Avatar prop takes precedence over the icon or intent prop */\n if (!avatar) {\n icon = resolveShorthand(props.icon, {\n defaultProps: {\n children: defaultIcon,\n },\n required: !!props.intent,\n });\n }\n\n return {\n action,\n appearance,\n avatar,\n components: {\n root: 'div',\n icon: 'span',\n action: Button,\n avatar: Avatar,\n },\n icon,\n intent,\n root: getNativeElementProps('div', {\n ref,\n role: defaultRole,\n children: props.children,\n ...props,\n }),\n };\n};\n"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAE9B,SAASC,MAAM,QAAQ,wBAAwB;AAC/C,SAASC,MAAM,QAAQ,wBAAwB;AAC/C,SAASC,qBAAqB,EAAEC,mBAAmB,EAAEC,UAAU,EAAEC,aAAa,QAAQ,uBAAuB;AAC7G,SAASC,qBAAqB,EAAEC,gBAAgB,QAAQ,2BAA2B;AAInF;;;;;;;;;AASA,OAAO,MAAMC,iBAAiB,GAAGA,CAACC,KAAiB,EAAEC,GAA2B,KAAgB;EAC9F,MAAM;IAAEC,UAAU,GAAG,SAAS;IAAE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GAAGX;KACJ;GACF;AACH,CAAC"}
|
|
@@ -1,88 +1,137 @@
|
|
|
1
1
|
import { tokens } from '@fluentui/react-theme';
|
|
2
2
|
import { __styles, mergeClasses, shorthands } from '@griffel/react';
|
|
3
|
+
import { createCustomFocusIndicatorStyle } from '@fluentui/react-tabster';
|
|
3
4
|
export const alertClassNames = {
|
|
4
5
|
root: 'fui-Alert',
|
|
5
6
|
icon: 'fui-Alert__icon',
|
|
6
|
-
action: 'fui-Alert__action'
|
|
7
|
+
action: 'fui-Alert__action',
|
|
8
|
+
avatar: 'fui-Alert__avatar'
|
|
7
9
|
};
|
|
8
|
-
|
|
9
10
|
const useStyles = /*#__PURE__*/__styles({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
"
|
|
11
|
+
root: {
|
|
12
|
+
mc9l5x: "f22iagw",
|
|
13
|
+
Bt984gj: "f122n59",
|
|
14
|
+
sshi5w: "f5pgtk9",
|
|
15
|
+
z8tnut: "f1g0x7ka",
|
|
16
|
+
z189sj: ["f11qrl6u", "fjlbh76"],
|
|
17
|
+
Byoj8tv: "f1qch9an",
|
|
18
|
+
uwmqm3: ["fjlbh76", "f11qrl6u"],
|
|
19
|
+
Bbmb7ep: ["fff7au0", "f1bjk9e1"],
|
|
20
|
+
Beyfa6y: ["f1bjk9e1", "fff7au0"],
|
|
21
|
+
B7oj6ja: ["fwsfkhu", "f8wkphi"],
|
|
22
|
+
Btl43ni: ["f8wkphi", "fwsfkhu"],
|
|
23
|
+
B4j52fo: "f5ogflp",
|
|
24
|
+
Bekrc4i: ["f1hqa2wf", "finvdd3"],
|
|
25
|
+
Bn0qgzm: "f1f09k3d",
|
|
26
|
+
ibv6hh: ["finvdd3", "f1hqa2wf"],
|
|
27
|
+
icvyot: "fzkkow9",
|
|
28
|
+
vrafjx: ["fcdblym", "fjik90z"],
|
|
29
|
+
oivjwe: "fg706s2",
|
|
30
|
+
wvpqe5: ["fjik90z", "fcdblym"],
|
|
31
|
+
g2u3we: "fghlq4f",
|
|
32
|
+
h3c5rm: ["f1gn591s", "fjscplz"],
|
|
33
|
+
B9xav0g: "fb073pr",
|
|
34
|
+
zhjwy3: ["fjscplz", "f1gn591s"],
|
|
35
|
+
E5pizo: "fz58gqq",
|
|
36
|
+
Be2twd7: "fkhj508",
|
|
37
|
+
Bhrd7zp: "fl43uef",
|
|
38
|
+
sj55zd: "f19n0e5",
|
|
39
|
+
De3pzq: "fxugw4r"
|
|
30
40
|
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"z8tnut": "f1g0x7ka",
|
|
35
|
-
"z189sj": ["f19lj068", "f177v4lu"],
|
|
36
|
-
"Byoj8tv": "f1qch9an",
|
|
37
|
-
"uwmqm3": ["f1cnd47f", "fhxju0i"]
|
|
41
|
+
inverted: {
|
|
42
|
+
sj55zd: "f1w7i9ko",
|
|
43
|
+
De3pzq: "f5pduvr"
|
|
38
44
|
},
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
icon: {
|
|
46
|
+
Bqenvij: "fd461yt",
|
|
47
|
+
Be2twd7: "f4ybsrx",
|
|
48
|
+
z8tnut: "f1g0x7ka",
|
|
49
|
+
z189sj: ["f19lj068", "f177v4lu"],
|
|
50
|
+
Byoj8tv: "f1qch9an",
|
|
51
|
+
uwmqm3: ["f1cnd47f", "fhxju0i"]
|
|
52
|
+
},
|
|
53
|
+
avatar: {
|
|
54
|
+
B6of3ja: "f1hu3pq6",
|
|
55
|
+
t21cq0: ["f1phki43", "ff9s3yw"],
|
|
56
|
+
jrapky: "f19f4twv",
|
|
57
|
+
Frg6f3: ["f1tyq0we", "f11qmguv"]
|
|
58
|
+
},
|
|
59
|
+
action: {
|
|
60
|
+
z8tnut: "f1sbtcvk",
|
|
61
|
+
z189sj: ["f81rol6", "frdkuqy"],
|
|
62
|
+
Byoj8tv: "fdghr9",
|
|
63
|
+
uwmqm3: ["frdkuqy", "f81rol6"],
|
|
64
|
+
Bf4jedk: "fy77jfu",
|
|
65
|
+
Frg6f3: ["fcgxt0o", "f1ujusj6"],
|
|
66
|
+
sj55zd: "f16muhyy"
|
|
47
67
|
}
|
|
48
68
|
}, {
|
|
49
|
-
|
|
69
|
+
d: [".f22iagw{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}", ".f122n59{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}", ".f5pgtk9{min-height:44px;}", ".f1g0x7ka{padding-top:0;}", ".f11qrl6u{padding-right:12px;}", ".fjlbh76{padding-left:12px;}", ".f1qch9an{padding-bottom:0;}", ".fff7au0{border-bottom-right-radius:4px;}", ".f1bjk9e1{border-bottom-left-radius:4px;}", ".fwsfkhu{border-top-right-radius:4px;}", ".f8wkphi{border-top-left-radius:4px;}", ".f5ogflp{border-top-width:1px;}", ".f1hqa2wf{border-right-width:1px;}", ".finvdd3{border-left-width:1px;}", ".f1f09k3d{border-bottom-width:1px;}", ".fzkkow9{border-top-style:solid;}", ".fcdblym{border-right-style:solid;}", ".fjik90z{border-left-style:solid;}", ".fg706s2{border-bottom-style:solid;}", ".fghlq4f{border-top-color:var(--colorTransparentStroke);}", ".f1gn591s{border-right-color:var(--colorTransparentStroke);}", ".fjscplz{border-left-color:var(--colorTransparentStroke);}", ".fb073pr{border-bottom-color:var(--colorTransparentStroke);}", ".fz58gqq{box-shadow:var(--shadow8);}", ".fkhj508{font-size:var(--fontSizeBase300);}", ".fl43uef{font-weight:var(--fontWeightSemibold);}", ".f19n0e5{color:var(--colorNeutralForeground1);}", ".fxugw4r{background-color:var(--colorNeutralBackground1);}", ".f1w7i9ko{color:var(--colorNeutralForegroundInverted2);}", ".f5pduvr{background-color:var(--colorNeutralBackgroundInverted);}", ".fd461yt{height:16px;}", ".f4ybsrx{font-size:16px;}", ".f19lj068{padding-right:8px;}", ".f177v4lu{padding-left:8px;}", ".f1cnd47f{padding-left:0;}", ".fhxju0i{padding-right:0;}", ".f1hu3pq6{margin-top:0;}", ".f1phki43{margin-right:8px;}", ".ff9s3yw{margin-left:8px;}", ".f19f4twv{margin-bottom:0;}", ".f1tyq0we{margin-left:0;}", ".f11qmguv{margin-right:0;}", ".f1sbtcvk{padding-top:5px;}", ".f81rol6{padding-right:10px;}", ".frdkuqy{padding-left:10px;}", ".fdghr9{padding-bottom:5px;}", ".fy77jfu{min-width:0;}", ".fcgxt0o{margin-left:auto;}", ".f1ujusj6{margin-right:auto;}", ".f16muhyy{color:var(--colorBrandForeground1);}"]
|
|
50
70
|
});
|
|
51
|
-
|
|
52
71
|
const useIntentIconStyles = /*#__PURE__*/__styles({
|
|
53
|
-
|
|
54
|
-
|
|
72
|
+
success: {
|
|
73
|
+
sj55zd: "f1m7fhi8"
|
|
74
|
+
},
|
|
75
|
+
error: {
|
|
76
|
+
sj55zd: "f1whyuy6"
|
|
77
|
+
},
|
|
78
|
+
warning: {
|
|
79
|
+
sj55zd: "fpti2h4"
|
|
80
|
+
},
|
|
81
|
+
info: {
|
|
82
|
+
sj55zd: "fkfq4zb"
|
|
83
|
+
}
|
|
84
|
+
}, {
|
|
85
|
+
d: [".f1m7fhi8{color:var(--colorPaletteGreenForeground3);}", ".f1whyuy6{color:var(--colorPaletteRedForeground3);}", ".fpti2h4{color:var(--colorPaletteYellowForeground2);}", ".fkfq4zb{color:var(--colorNeutralForeground2);}"]
|
|
86
|
+
});
|
|
87
|
+
const useIntentIconStylesInverted = /*#__PURE__*/__styles({
|
|
88
|
+
success: {
|
|
89
|
+
sj55zd: "f1pvjcpr"
|
|
55
90
|
},
|
|
56
|
-
|
|
57
|
-
|
|
91
|
+
error: {
|
|
92
|
+
sj55zd: "fcrp5ll"
|
|
58
93
|
},
|
|
59
|
-
|
|
60
|
-
|
|
94
|
+
warning: {
|
|
95
|
+
sj55zd: "f1r8f1cl"
|
|
61
96
|
},
|
|
62
|
-
|
|
63
|
-
|
|
97
|
+
info: {
|
|
98
|
+
sj55zd: "f1w7i9ko"
|
|
99
|
+
}
|
|
100
|
+
}, {
|
|
101
|
+
d: [".f1pvjcpr{color:var(--colorPaletteGreenForegroundInverted);}", ".fcrp5ll{color:var(--colorPaletteRedForegroundInverted);}", ".f1r8f1cl{color:var(--colorPaletteYellowForegroundInverted);}", ".f1w7i9ko{color:var(--colorNeutralForegroundInverted2);}"]
|
|
102
|
+
});
|
|
103
|
+
const useActionButtonColorInverted = /*#__PURE__*/__styles({
|
|
104
|
+
action: {
|
|
105
|
+
sj55zd: "f1qz2gb0",
|
|
106
|
+
B8q5s1w: "fa5e339",
|
|
107
|
+
Bci5o5g: ["fk4svks", "fqzoz0o"],
|
|
108
|
+
n8qw10: "fw8q0i0",
|
|
109
|
+
Bdrgwmp: ["fqzoz0o", "fk4svks"],
|
|
110
|
+
Bfpq7zp: "f1dlk4fq"
|
|
64
111
|
}
|
|
65
112
|
}, {
|
|
66
|
-
|
|
113
|
+
d: [".f1qz2gb0{color:var(--colorBrandForegroundInverted);}", ".fa5e339[data-fui-focus-visible]{border-top-color:var(--colorTransparentStrokeInteractive);}", ".fk4svks[data-fui-focus-visible]{border-right-color:var(--colorTransparentStrokeInteractive);}", ".fqzoz0o[data-fui-focus-visible]{border-left-color:var(--colorTransparentStrokeInteractive);}", ".fw8q0i0[data-fui-focus-visible]{border-bottom-color:var(--colorTransparentStrokeInteractive);}", ".f1dlk4fq[data-fui-focus-visible]{outline-color:var(--colorNeutralBackground5Pressed);}"]
|
|
67
114
|
});
|
|
68
115
|
/**
|
|
69
116
|
* Apply styling to the Alert slots based on the state
|
|
70
117
|
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
118
|
export const useAlertStyles_unstable = state => {
|
|
119
|
+
const inverted = state.appearance === 'inverted';
|
|
74
120
|
const styles = useStyles();
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
121
|
+
const intentIconStylesPrimary = useIntentIconStyles();
|
|
122
|
+
const intentIconStylesInverted = useIntentIconStylesInverted();
|
|
123
|
+
const actionStylesInverted = useActionButtonColorInverted();
|
|
124
|
+
state.root.className = mergeClasses(alertClassNames.root, styles.root, inverted && styles.inverted, state.root.className);
|
|
78
125
|
if (state.icon) {
|
|
79
|
-
state.icon.className = mergeClasses(alertClassNames.icon, styles.icon, state.intent &&
|
|
126
|
+
state.icon.className = mergeClasses(alertClassNames.icon, styles.icon, state.intent && (inverted ? intentIconStylesInverted[state.intent] : intentIconStylesPrimary[state.intent]), state.icon.className);
|
|
127
|
+
}
|
|
128
|
+
if (state.avatar) {
|
|
129
|
+
state.avatar.className = mergeClasses(alertClassNames.avatar, styles.avatar, state.avatar.className);
|
|
80
130
|
}
|
|
81
|
-
|
|
82
131
|
if (state.action) {
|
|
83
|
-
|
|
132
|
+
// Note: inverted && actionStylesInverted.action has the highest piority and must be merged last
|
|
133
|
+
state.action.className = mergeClasses(alertClassNames.action, styles.action, inverted && actionStylesInverted.action, state.action.className);
|
|
84
134
|
}
|
|
85
|
-
|
|
86
135
|
return state;
|
|
87
136
|
};
|
|
88
137
|
//# sourceMappingURL=useAlertStyles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["tokens","__styles","mergeClasses","shorthands","createCustomFocusIndicatorStyle","alertClassNames","root","icon","action","avatar","useStyles","mc9l5x","Bt984gj","sshi5w","z8tnut","z189sj","Byoj8tv","uwmqm3","Bbmb7ep","Beyfa6y","B7oj6ja","Btl43ni","B4j52fo","Bekrc4i","Bn0qgzm","ibv6hh","icvyot","vrafjx","oivjwe","wvpqe5","g2u3we","h3c5rm","B9xav0g","zhjwy3","E5pizo","Be2twd7","Bhrd7zp","sj55zd","De3pzq","inverted","Bqenvij","B6of3ja","t21cq0","jrapky","Frg6f3","Bf4jedk","d","useIntentIconStyles","success","error","warning","info","useIntentIconStylesInverted","useActionButtonColorInverted","B8q5s1w","Bci5o5g","n8qw10","Bdrgwmp","Bfpq7zp","useAlertStyles_unstable","state","appearance","styles","intentIconStylesPrimary","intentIconStylesInverted","actionStylesInverted","className","intent"],"sources":["../src/packages/react-components/react-alert/src/components/Alert/useAlertStyles.ts"],"sourcesContent":["import { tokens } from '@fluentui/react-theme';\nimport { makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport { createCustomFocusIndicatorStyle } from '@fluentui/react-tabster';\nimport type { AlertSlots, AlertState } from './Alert.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\nexport const alertClassNames: SlotClassNames<AlertSlots> = {\n root: 'fui-Alert',\n icon: 'fui-Alert__icon',\n action: 'fui-Alert__action',\n avatar: 'fui-Alert__avatar',\n};\n\nconst useStyles = makeStyles({\n root: {\n display: 'flex',\n alignItems: 'center',\n minHeight: '44px',\n ...shorthands.padding('0', '12px'),\n ...shorthands.borderRadius('4px'),\n ...shorthands.border('1px', 'solid', tokens.colorTransparentStroke),\n boxShadow: tokens.shadow8,\n fontSize: tokens.fontSizeBase300,\n fontWeight: tokens.fontWeightSemibold,\n color: tokens.colorNeutralForeground1,\n backgroundColor: tokens.colorNeutralBackground1,\n },\n inverted: {\n color: tokens.colorNeutralForegroundInverted2,\n backgroundColor: tokens.colorNeutralBackgroundInverted,\n },\n icon: {\n height: '16px',\n fontSize: '16px',\n ...shorthands.padding('0', '8px', '0', '0'),\n },\n avatar: {\n ...shorthands.margin('0', '8px', '0', '0'),\n },\n action: {\n ...shorthands.padding('5px', '10px'),\n minWidth: 0,\n marginLeft: 'auto',\n color: tokens.colorBrandForeground1,\n },\n});\n\nconst useIntentIconStyles = makeStyles({\n success: {\n color: tokens.colorPaletteGreenForeground3,\n },\n error: {\n color: tokens.colorPaletteRedForeground3,\n },\n warning: {\n color: tokens.colorPaletteYellowForeground2,\n },\n info: {\n color: tokens.colorNeutralForeground2,\n },\n});\n\nconst useIntentIconStylesInverted = makeStyles({\n success: {\n color: tokens.colorPaletteGreenForegroundInverted,\n },\n error: {\n color: tokens.colorPaletteRedForegroundInverted,\n },\n warning: {\n color: tokens.colorPaletteYellowForegroundInverted,\n },\n info: {\n color: tokens.colorNeutralForegroundInverted2,\n },\n});\n\nconst useActionButtonColorInverted = makeStyles({\n action: {\n color: tokens.colorBrandForegroundInverted,\n ...createCustomFocusIndicatorStyle(\n {\n ...shorthands.borderColor(tokens.colorTransparentStrokeInteractive),\n outlineColor: tokens.colorNeutralBackground5Pressed,\n },\n { enableOutline: true },\n ),\n },\n});\n\n/**\n * Apply styling to the Alert slots based on the state\n */\nexport const useAlertStyles_unstable = (state: AlertState): AlertState => {\n const inverted = state.appearance === 'inverted';\n const styles = useStyles();\n const intentIconStylesPrimary = useIntentIconStyles();\n const intentIconStylesInverted = useIntentIconStylesInverted();\n const actionStylesInverted = useActionButtonColorInverted();\n\n state.root.className = mergeClasses(\n alertClassNames.root,\n styles.root,\n inverted && styles.inverted,\n state.root.className,\n );\n\n if (state.icon) {\n state.icon.className = mergeClasses(\n alertClassNames.icon,\n styles.icon,\n state.intent && (inverted ? intentIconStylesInverted[state.intent] : intentIconStylesPrimary[state.intent]),\n state.icon.className,\n );\n }\n\n if (state.avatar) {\n state.avatar.className = mergeClasses(alertClassNames.avatar, styles.avatar, state.avatar.className);\n }\n\n if (state.action) {\n // Note: inverted && actionStylesInverted.action has the highest piority and must be merged last\n state.action.className = mergeClasses(\n alertClassNames.action,\n styles.action,\n inverted && actionStylesInverted.action,\n state.action.className,\n );\n }\n\n return state;\n};\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,uBAAuB;AAC9C,SAAAC,QAAA,EAAqBC,YAAY,EAAEC,UAAU,QAAQ,gBAAgB;AACrE,SAASC,+BAA+B,QAAQ,yBAAyB;AAIzE,OAA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D,MAAM,EAAEmD,KAAK,CAACnD,MAAM,CAACyD,SAAS,CAAC;;EAGtG,IAAIN,KAAK,CAACpD,MAAM,EAAE;IAChB;IACAoD,KAAK,CAACpD,MAAM,CAAC0D,SAAS,GAAGhE,YAAY,CACnCG,eAAe,CAACG,MAAM,EACtBsD,MAAM,CAACtD,MAAM,EACb+B,QAAQ,IAAI0B,oBAAoB,CAACzD,MAAM,EACvCoD,KAAK,CAACpD,MAAM,CAAC0D,SAAS,CACvB;;EAGH,OAAON,KAAK;AACd,CAAC"}
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC","sourcesContent":["export { Alert, alertClassNames, renderAlert_unstable, useAlertStyles_unstable, useAlert_unstable } from './Alert';\nexport type { AlertProps, AlertSlots, AlertState } from './Alert';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["packages/react-components/react-alert/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC","sourcesContent":["export { Alert, alertClassNames, renderAlert_unstable, useAlertStyles_unstable, useAlert_unstable } from './Alert';\nexport type { AlertProps, AlertSlots, AlertState } from './Alert';\n"]}
|
package/lib-commonjs/Alert.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["tslib_1","__exportStar","require","exports"],"sources":["../src/packages/react-components/react-alert/src/Alert.ts"],"sourcesContent":["export * from './components/Alert/index';\n"],"mappings":";;;;;;AAAAA,OAAA,CAAAC,YAAA,CAAAC,OAAA,8BAAAC,OAAA"}
|
|
@@ -4,20 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Alert = void 0;
|
|
7
|
-
|
|
8
7
|
const React = /*#__PURE__*/require("react");
|
|
9
|
-
|
|
10
8
|
const renderAlert_1 = /*#__PURE__*/require("./renderAlert");
|
|
11
|
-
|
|
12
9
|
const useAlert_1 = /*#__PURE__*/require("./useAlert");
|
|
13
|
-
|
|
14
10
|
const useAlertStyles_1 = /*#__PURE__*/require("./useAlertStyles");
|
|
15
11
|
/**
|
|
16
12
|
* An Alert component displays a brief, important message to attract a user's attention
|
|
17
13
|
* without interrupting their current task.
|
|
18
14
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
15
|
exports.Alert = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
22
16
|
const state = useAlert_1.useAlert_unstable(props, ref);
|
|
23
17
|
useAlertStyles_1.useAlertStyles_unstable(state);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["React","require","renderAlert_1","useAlert_1","useAlertStyles_1","exports","Alert","forwardRef","props","ref","state","useAlert_unstable","useAlertStyles_unstable","renderAlert_unstable","displayName"],"sources":["../src/packages/react-components/react-alert/src/components/Alert/Alert.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { renderAlert_unstable } from './renderAlert';\nimport { useAlert_unstable } from './useAlert';\nimport { useAlertStyles_unstable } from './useAlertStyles';\n\nimport type { AlertProps } from './Alert.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\n\n/**\n * An Alert component displays a brief, important message to attract a user's attention\n * without interrupting their current task.\n */\nexport const Alert: ForwardRefComponent<AlertProps> = React.forwardRef((props, ref) => {\n const state = useAlert_unstable(props, ref);\n\n useAlertStyles_unstable(state);\n return renderAlert_unstable(state);\n}) as ForwardRefComponent<AlertProps>;\n\nAlert.displayName = 'Alert';\n"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AAEA,MAAAC,aAAA,gBAAAD,OAAA;AACA,MAAAE,UAAA,gBAAAF,OAAA;AACA,MAAAG,gBAAA,gBAAAH,OAAA;AAKA;;;;AAIaI,OAAA,CAAAC,KAAK,gBAAoCN,KAAK,CAACO,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAI;EACpF,MAAMC,KAAK,GAAGP,UAAA,CAAAQ,iBAAiB,CAACH,KAAK,EAAEC,GAAG,CAAC;EAE3CL,gBAAA,CAAAQ,uBAAuB,CAACF,KAAK,CAAC;EAC9B,OAAOR,aAAA,CAAAW,oBAAoB,CAACH,KAAK,CAAC;AACpC,CAAC,CAAoC;AAErCL,OAAA,CAAAC,KAAK,CAACQ,WAAW,GAAG,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":[],"sources":["../src/packages/react-components/react-alert/src/components/Alert/Alert.types.ts"],"sourcesContent":["import { Avatar } from '@fluentui/react-avatar';\nimport { Button } from '@fluentui/react-button';\n\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\nexport type AlertSlots = {\n /**\n * The root slot is the top level container for the alert component\n */\n root: NonNullable<Slot<'div'>>;\n /**\n * The icon slot renders the icon determined by the `icon` or `intent` prop\n */\n icon?: Slot<'span'>;\n /**\n * The action slot renders a button that prompts the user to take action on the alert\n */\n action?: Slot<typeof Button>;\n /**\n * The avatar slot renders an avatar before the contents of the alert\n */\n avatar?: Slot<typeof Avatar>;\n};\n\n/**\n * Alert Props\n */\nexport type AlertProps = ComponentProps<AlertSlots> & {\n /**\n * The intent prop, if present, determines the icon to be rendered in the icon slot. The icon prop\n * overrides the intent prop\n */\n intent?: 'info' | 'success' | 'error' | 'warning';\n /**\n * The appearance of the Alert.\n * @default 'primary'\n */\n appearance?: 'primary' | 'inverted';\n};\n\n/**\n * State used in rendering Alert\n */\nexport type AlertState = ComponentState<AlertSlots> &\n Pick<AlertProps, 'intent'> &\n Required<Pick<AlertProps, 'appearance'>>;\n"],"mappings":""}
|
|
@@ -3,16 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
6
|
const tslib_1 = /*#__PURE__*/require("tslib");
|
|
8
|
-
|
|
9
7
|
tslib_1.__exportStar(require("./Alert"), exports);
|
|
10
|
-
|
|
11
8
|
tslib_1.__exportStar(require("./Alert.types"), exports);
|
|
12
|
-
|
|
13
9
|
tslib_1.__exportStar(require("./renderAlert"), exports);
|
|
14
|
-
|
|
15
10
|
tslib_1.__exportStar(require("./useAlert"), exports);
|
|
16
|
-
|
|
17
11
|
tslib_1.__exportStar(require("./useAlertStyles"), exports);
|
|
18
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["tslib_1","__exportStar","require","exports"],"sources":["../src/packages/react-components/react-alert/src/components/Alert/index.ts"],"sourcesContent":["export * from './Alert';\nexport * from './Alert.types';\nexport * from './renderAlert';\nexport * from './useAlert';\nexport * from './useAlertStyles';\n"],"mappings":";;;;;;AAAAA,OAAA,CAAAC,YAAA,CAAAC,OAAA,aAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,mBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,mBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,gBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,sBAAAC,OAAA"}
|
|
@@ -4,21 +4,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.renderAlert_unstable = void 0;
|
|
7
|
-
|
|
8
7
|
const React = /*#__PURE__*/require("react");
|
|
9
|
-
|
|
10
8
|
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
|
11
|
-
|
|
12
9
|
const renderAlert_unstable = state => {
|
|
13
10
|
const {
|
|
14
11
|
slots,
|
|
15
12
|
slotProps
|
|
16
13
|
} = react_utilities_1.getSlots(state);
|
|
17
|
-
return React.createElement(slots.root, {
|
|
18
|
-
|
|
19
|
-
}
|
|
14
|
+
return React.createElement(slots.root, {
|
|
15
|
+
...slotProps.root
|
|
16
|
+
}, slots.icon && React.createElement(slots.icon, {
|
|
17
|
+
...slotProps.icon
|
|
18
|
+
}), slots.avatar && React.createElement(slots.avatar, {
|
|
19
|
+
...slotProps.avatar
|
|
20
|
+
}), slotProps.root.children, slots.action && React.createElement(slots.action, {
|
|
21
|
+
...slotProps.action
|
|
20
22
|
}));
|
|
21
23
|
};
|
|
22
|
-
|
|
23
24
|
exports.renderAlert_unstable = renderAlert_unstable;
|
|
24
25
|
//# sourceMappingURL=renderAlert.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["React","require","react_utilities_1","renderAlert_unstable","state","slots","slotProps","getSlots","createElement","root","icon","avatar","children","action","exports"],"sources":["../src/packages/react-components/react-alert/src/components/Alert/renderAlert.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { getSlots } from '@fluentui/react-utilities';\n\nimport type { AlertState, AlertSlots } from './Alert.types';\n\nexport const renderAlert_unstable = (state: AlertState) => {\n const { slots, slotProps } = getSlots<AlertSlots>(state);\n\n return (\n <slots.root {...slotProps.root}>\n {slots.icon && <slots.icon {...slotProps.icon} />}\n {slots.avatar && <slots.avatar {...slotProps.avatar} />}\n {slotProps.root.children}\n {slots.action && <slots.action {...slotProps.action} />}\n </slots.root>\n );\n};\n"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AAEA,MAAAC,iBAAA,gBAAAD,OAAA;AAIO,MAAME,oBAAoB,GAAIC,KAAiB,IAAI;EACxD,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAE,GAAGJ,iBAAA,CAAAK,QAAQ,CAAaH,KAAK,CAAC;EAExD,OACEJ,KAAA,CAAAQ,aAAA,CAACH,KAAK,CAACI,IAAI;IAAA,GAAKH,SAAS,CAACG;EAAI,GAC3BJ,KAAK,CAACK,IAAI,IAAIV,KAAA,CAAAQ,aAAA,CAACH,KAAK,CAACK,IAAI;IAAA,GAAKJ,SAAS,CAACI;EAAI,EAAI,EAChDL,KAAK,CAACM,MAAM,IAAIX,KAAA,CAAAQ,aAAA,CAACH,KAAK,CAACM,MAAM;IAAA,GAAKL,SAAS,CAACK;EAAM,EAAI,EACtDL,SAAS,CAACG,IAAI,CAACG,QAAQ,EACvBP,KAAK,CAACQ,MAAM,IAAIb,KAAA,CAAAQ,aAAA,CAACH,KAAK,CAACQ,MAAM;IAAA,GAAKP,SAAS,CAACO;EAAM,EAAI,CAC5C;AAEjB,CAAC;AAXYC,OAAA,CAAAX,oBAAoB,GAAAA,oBAAA"}
|
|
@@ -4,13 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useAlert_unstable = void 0;
|
|
7
|
-
|
|
8
7
|
const React = /*#__PURE__*/require("react");
|
|
9
|
-
|
|
8
|
+
const react_avatar_1 = /*#__PURE__*/require("@fluentui/react-avatar");
|
|
10
9
|
const react_button_1 = /*#__PURE__*/require("@fluentui/react-button");
|
|
11
|
-
|
|
12
10
|
const react_icons_1 = /*#__PURE__*/require("@fluentui/react-icons");
|
|
13
|
-
|
|
14
11
|
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
|
15
12
|
/**
|
|
16
13
|
* Create the state required to render Alert.
|
|
@@ -21,56 +18,65 @@ const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
|
|
21
18
|
* @param props - props from this instance of Alert
|
|
22
19
|
* @param ref - reference to root HTMLElement of Alert
|
|
23
20
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
21
|
const useAlert_unstable = (props, ref) => {
|
|
27
22
|
const {
|
|
23
|
+
appearance = 'primary',
|
|
28
24
|
intent
|
|
29
25
|
} = props;
|
|
30
|
-
/** Determine the icon to render based on the intent */
|
|
31
|
-
|
|
26
|
+
/** Determine the role and icon to render based on the intent */
|
|
32
27
|
let defaultIcon;
|
|
33
|
-
|
|
28
|
+
let defaultRole = 'status';
|
|
34
29
|
switch (intent) {
|
|
35
30
|
case 'success':
|
|
36
31
|
defaultIcon = React.createElement(react_icons_1.CheckmarkCircleFilled, null);
|
|
37
32
|
break;
|
|
38
|
-
|
|
39
33
|
case 'error':
|
|
40
34
|
defaultIcon = React.createElement(react_icons_1.DismissCircleFilled, null);
|
|
35
|
+
defaultRole = 'alert';
|
|
41
36
|
break;
|
|
42
|
-
|
|
43
37
|
case 'warning':
|
|
44
38
|
defaultIcon = React.createElement(react_icons_1.WarningFilled, null);
|
|
39
|
+
defaultRole = 'alert';
|
|
45
40
|
break;
|
|
46
|
-
|
|
47
41
|
case 'info':
|
|
48
42
|
defaultIcon = React.createElement(react_icons_1.InfoFilled, null);
|
|
49
43
|
break;
|
|
50
44
|
}
|
|
51
|
-
|
|
52
|
-
const icon = react_utilities_1.resolveShorthand(props.icon, {
|
|
45
|
+
const action = react_utilities_1.resolveShorthand(props.action, {
|
|
53
46
|
defaultProps: {
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
required: !!props.intent
|
|
47
|
+
appearance: 'transparent'
|
|
48
|
+
}
|
|
57
49
|
});
|
|
50
|
+
const avatar = react_utilities_1.resolveShorthand(props.avatar);
|
|
51
|
+
let icon;
|
|
52
|
+
/** Avatar prop takes precedence over the icon or intent prop */
|
|
53
|
+
if (!avatar) {
|
|
54
|
+
icon = react_utilities_1.resolveShorthand(props.icon, {
|
|
55
|
+
defaultProps: {
|
|
56
|
+
children: defaultIcon
|
|
57
|
+
},
|
|
58
|
+
required: !!props.intent
|
|
59
|
+
});
|
|
60
|
+
}
|
|
58
61
|
return {
|
|
62
|
+
action,
|
|
63
|
+
appearance,
|
|
64
|
+
avatar,
|
|
59
65
|
components: {
|
|
60
66
|
root: 'div',
|
|
61
67
|
icon: 'span',
|
|
62
|
-
action: react_button_1.Button
|
|
68
|
+
action: react_button_1.Button,
|
|
69
|
+
avatar: react_avatar_1.Avatar
|
|
63
70
|
},
|
|
71
|
+
icon,
|
|
72
|
+
intent,
|
|
64
73
|
root: react_utilities_1.getNativeElementProps('div', {
|
|
65
74
|
ref,
|
|
75
|
+
role: defaultRole,
|
|
66
76
|
children: props.children,
|
|
67
77
|
...props
|
|
68
|
-
})
|
|
69
|
-
icon,
|
|
70
|
-
action: react_utilities_1.resolveShorthand(props.action),
|
|
71
|
-
intent
|
|
78
|
+
})
|
|
72
79
|
};
|
|
73
80
|
};
|
|
74
|
-
|
|
75
81
|
exports.useAlert_unstable = useAlert_unstable;
|
|
76
82
|
//# sourceMappingURL=useAlert.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["React","require","react_avatar_1","react_button_1","react_icons_1","react_utilities_1","useAlert_unstable","props","ref","appearance","intent","defaultIcon","defaultRole","createElement","CheckmarkCircleFilled","DismissCircleFilled","WarningFilled","InfoFilled","action","resolveShorthand","defaultProps","avatar","icon","children","required","components","root","Button","Avatar","getNativeElementProps","role","exports"],"sources":["../src/packages/react-components/react-alert/src/components/Alert/useAlert.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Avatar } from '@fluentui/react-avatar';\nimport { Button } from '@fluentui/react-button';\nimport { CheckmarkCircleFilled, DismissCircleFilled, InfoFilled, WarningFilled } from '@fluentui/react-icons';\nimport { getNativeElementProps, resolveShorthand } from '@fluentui/react-utilities';\n\nimport type { AlertProps, AlertState } from './Alert.types';\n\n/**\n * Create the state required to render Alert.\n *\n * The returned state can be modified with hooks such as useAlertStyles_unstable,\n * before being passed to renderAlert_unstable.\n *\n * @param props - props from this instance of Alert\n * @param ref - reference to root HTMLElement of Alert\n */\nexport const useAlert_unstable = (props: AlertProps, ref: React.Ref<HTMLElement>): AlertState => {\n const { appearance = 'primary', intent } = props;\n\n /** Determine the role and icon to render based on the intent */\n let defaultIcon;\n let defaultRole = 'status';\n switch (intent) {\n case 'success':\n defaultIcon = <CheckmarkCircleFilled />;\n break;\n case 'error':\n defaultIcon = <DismissCircleFilled />;\n defaultRole = 'alert';\n break;\n case 'warning':\n defaultIcon = <WarningFilled />;\n defaultRole = 'alert';\n break;\n case 'info':\n defaultIcon = <InfoFilled />;\n break;\n }\n\n const action = resolveShorthand(props.action, { defaultProps: { appearance: 'transparent' } });\n const avatar = resolveShorthand(props.avatar);\n let icon;\n /** Avatar prop takes precedence over the icon or intent prop */\n if (!avatar) {\n icon = resolveShorthand(props.icon, {\n defaultProps: {\n children: defaultIcon,\n },\n required: !!props.intent,\n });\n }\n\n return {\n action,\n appearance,\n avatar,\n components: {\n root: 'div',\n icon: 'span',\n action: Button,\n avatar: Avatar,\n },\n icon,\n intent,\n root: getNativeElementProps('div', {\n ref,\n role: defaultRole,\n children: props.children,\n ...props,\n }),\n };\n};\n"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AAEA,MAAAC,cAAA,gBAAAD,OAAA;AACA,MAAAE,cAAA,gBAAAF,OAAA;AACA,MAAAG,aAAA,gBAAAH,OAAA;AACA,MAAAI,iBAAA,gBAAAJ,OAAA;AAIA;;;;;;;;;AASO,MAAMK,iBAAiB,GAAGA,CAACC,KAAiB,EAAEC,GAA2B,KAAgB;EAC9F,MAAM;IAAEC,UAAU,GAAG,SAAS;IAAEC;EAAM,CAAE,GAAGH,KAAK;EAEhD;EACA,IAAII,WAAW;EACf,IAAIC,WAAW,GAAG,QAAQ;EAC1B,QAAQF,MAAM;IACZ,KAAK,SAAS;MACZC,WAAW,GAAGX,KAAA,CAAAa,aAAA,CAACT,aAAA,CAAAU,qBAAqB,OAAG;MACvC;IACF,KAAK,OAAO;MACVH,WAAW,GAAGX,KAAA,CAAAa,aAAA,CAACT,aAAA,CAAAW,mBAAmB,OAAG;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