@aurora-ds/components 1.1.3 → 1.1.4
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/dist/cjs/index.js +14 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +14 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +13 -0
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -2346,14 +2346,23 @@ const VARIANT_ICONS = {
|
|
|
2346
2346
|
warning: AlertWarningIcon,
|
|
2347
2347
|
info: AlertInfoIcon,
|
|
2348
2348
|
};
|
|
2349
|
+
/** Returns true if value is a React component type (function/class), false if it is a rendered node. */
|
|
2350
|
+
const isSvgComponent = (value) => typeof value === 'function';
|
|
2349
2351
|
/**
|
|
2350
2352
|
* Alert title row: renders the variant icon alongside the title text.
|
|
2351
2353
|
* Must be used inside an `<Alert>` component.
|
|
2352
2354
|
*/
|
|
2353
|
-
const AlertTitle = ({ children }) => {
|
|
2355
|
+
const AlertTitle = ({ children, icon }) => {
|
|
2354
2356
|
const { variant, accentColor } = useAlertContext();
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
+
// Resolve which icon to render:
|
|
2358
|
+
// - custom icon prop always takes precedence over the built-in variant icon
|
|
2359
|
+
// - for "default" variant there is no built-in icon; custom icon adds one
|
|
2360
|
+
const builtInIcon = VARIANT_ICONS[variant];
|
|
2361
|
+
// Must be capitalised for JSX to treat it as a component (not an HTML tag)
|
|
2362
|
+
const ResolvedIcon = icon && isSvgComponent(icon) ? icon : (icon === undefined ? (builtInIcon ?? null) : null);
|
|
2363
|
+
const customNode = icon && !isSvgComponent(icon) ? icon : null;
|
|
2364
|
+
const hasIcon = ResolvedIcon !== null || customNode !== null;
|
|
2365
|
+
return (jsxs(Stack, { flexDirection: 'row', alignItems: 'center', gap: 'sm', children: [hasIcon && (jsx(Stack, { flexShrink: 0, alignItems: 'center', color: accentColor, width: '1.25rem', height: '1.25rem', "aria-hidden": true, children: ResolvedIcon ? (jsx(ResolvedIcon, { width: 20, height: 20 })) : (customNode) })), jsx(Text, { fontWeight: 'semibold', fontSize: 'sm', color: accentColor, children: children })] }));
|
|
2357
2366
|
};
|
|
2358
2367
|
AlertTitle.displayName = 'Alert.Title';
|
|
2359
2368
|
|
|
@@ -2387,9 +2396,9 @@ const VARIANT_ARIA_LIVE = {
|
|
|
2387
2396
|
* <Alert.Body>Your changes have been saved successfully.</Alert.Body>
|
|
2388
2397
|
* </Alert>
|
|
2389
2398
|
*/
|
|
2390
|
-
const AlertBase = ({ variant = 'default', children, width = '100%' }) => {
|
|
2399
|
+
const AlertBase = ({ variant = 'default', children, width = '100%', outline = false, shadow = 'none', }) => {
|
|
2391
2400
|
const { backgroundColor, borderColor, accentColor } = VARIANT_TOKENS[variant];
|
|
2392
|
-
return (jsx(AlertContext.Provider, { value: { variant, accentColor }, children: jsx(Stack, { role: 'alert', "aria-live": VARIANT_ARIA_LIVE[variant], flexDirection: 'column', gap: 'xs', padding: 'md', borderRadius: 'lg', backgroundColor: backgroundColor, borderColor: borderColor, borderWidth: '1px', borderStyle: 'solid', width: width, children: children }) }));
|
|
2401
|
+
return (jsx(AlertContext.Provider, { value: { variant, accentColor }, children: jsx(Stack, { role: 'alert', "aria-live": VARIANT_ARIA_LIVE[variant], flexDirection: 'column', gap: 'xs', padding: 'md', borderRadius: 'lg', backgroundColor: backgroundColor, borderColor: outline ? borderColor : undefined, borderWidth: outline ? '1px' : undefined, borderStyle: outline ? 'solid' : undefined, boxShadow: shadow, width: width, children: children }) }));
|
|
2393
2402
|
};
|
|
2394
2403
|
AlertBase.displayName = 'Alert';
|
|
2395
2404
|
const Alert = AlertBase;
|