@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 CHANGED
@@ -2366,14 +2366,23 @@ const VARIANT_ICONS = {
2366
2366
  warning: AlertWarningIcon,
2367
2367
  info: AlertInfoIcon,
2368
2368
  };
2369
+ /** Returns true if value is a React component type (function/class), false if it is a rendered node. */
2370
+ const isSvgComponent = (value) => typeof value === 'function';
2369
2371
  /**
2370
2372
  * Alert title row: renders the variant icon alongside the title text.
2371
2373
  * Must be used inside an `<Alert>` component.
2372
2374
  */
2373
- const AlertTitle = ({ children }) => {
2375
+ const AlertTitle = ({ children, icon }) => {
2374
2376
  const { variant, accentColor } = useAlertContext();
2375
- const IconComponent = VARIANT_ICONS[variant];
2376
- return (jsxRuntime.jsxs(Stack, { flexDirection: 'row', alignItems: 'center', gap: 'sm', children: [IconComponent && (jsxRuntime.jsx(Stack, { flexShrink: 0, alignItems: 'center', color: accentColor, width: '1.25rem', height: '1.25rem', "aria-hidden": true, children: jsxRuntime.jsx(IconComponent, { width: 20, height: 20 }) })), jsxRuntime.jsx(Text, { fontWeight: 'semibold', fontSize: 'sm', color: accentColor, children: children })] }));
2377
+ // Resolve which icon to render:
2378
+ // - custom icon prop always takes precedence over the built-in variant icon
2379
+ // - for "default" variant there is no built-in icon; custom icon adds one
2380
+ const builtInIcon = VARIANT_ICONS[variant];
2381
+ // Must be capitalised for JSX to treat it as a component (not an HTML tag)
2382
+ const ResolvedIcon = icon && isSvgComponent(icon) ? icon : (icon === undefined ? (builtInIcon ?? null) : null);
2383
+ const customNode = icon && !isSvgComponent(icon) ? icon : null;
2384
+ const hasIcon = ResolvedIcon !== null || customNode !== null;
2385
+ return (jsxRuntime.jsxs(Stack, { flexDirection: 'row', alignItems: 'center', gap: 'sm', children: [hasIcon && (jsxRuntime.jsx(Stack, { flexShrink: 0, alignItems: 'center', color: accentColor, width: '1.25rem', height: '1.25rem', "aria-hidden": true, children: ResolvedIcon ? (jsxRuntime.jsx(ResolvedIcon, { width: 20, height: 20 })) : (customNode) })), jsxRuntime.jsx(Text, { fontWeight: 'semibold', fontSize: 'sm', color: accentColor, children: children })] }));
2377
2386
  };
2378
2387
  AlertTitle.displayName = 'Alert.Title';
2379
2388
 
@@ -2407,9 +2416,9 @@ const VARIANT_ARIA_LIVE = {
2407
2416
  * <Alert.Body>Your changes have been saved successfully.</Alert.Body>
2408
2417
  * </Alert>
2409
2418
  */
2410
- const AlertBase = ({ variant = 'default', children, width = '100%' }) => {
2419
+ const AlertBase = ({ variant = 'default', children, width = '100%', outline = false, shadow = 'none', }) => {
2411
2420
  const { backgroundColor, borderColor, accentColor } = VARIANT_TOKENS[variant];
2412
- return (jsxRuntime.jsx(AlertContext.Provider, { value: { variant, accentColor }, children: jsxRuntime.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 }) }));
2421
+ return (jsxRuntime.jsx(AlertContext.Provider, { value: { variant, accentColor }, children: jsxRuntime.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 }) }));
2413
2422
  };
2414
2423
  AlertBase.displayName = 'Alert';
2415
2424
  const Alert = AlertBase;