@aurora-ds/components 1.1.3 → 1.1.5

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/esm/index.js CHANGED
@@ -2272,13 +2272,13 @@ const CARD_VARIANTS = createVariants((theme) => ({
2272
2272
  defaultVariants: { variant: 'elevated' },
2273
2273
  }), { id: 'card' });
2274
2274
 
2275
- const CardHeader = ({ label, icon, actions }) => {
2276
- return (jsxs(Stack, { alignItems: 'center', justifyContent: 'space-between', gap: 'sm', py: 'sm', px: 'md', children: [jsxs(Stack, { alignItems: 'center', gap: 'sm', flex: 1, minWidth: '0', children: [icon !== undefined && (jsx(Icon, { icon: icon, size: 'md', strokeColor: 'textSecondary' })), jsx(Text, { variant: 'span', fontSize: 'sm', fontWeight: 'semibold', color: 'textPrimary', children: label })] }), actions !== undefined && (jsx(Stack, { alignItems: 'center', gap: 'xs', flexShrink: 0, children: actions }))] }));
2275
+ const CardHeader = ({ label, icon, actions, flexDirection = 'row', gap = 'sm', alignItems = 'center', justifyContent = 'space-between', py = 'sm', px = 'md', ...rest }) => {
2276
+ return (jsxs(Stack, { flexDirection: flexDirection, alignItems: alignItems, justifyContent: justifyContent, gap: gap, py: py, px: px, ...rest, children: [jsxs(Stack, { alignItems: 'center', gap: 'sm', flex: 1, minWidth: '0', children: [icon !== undefined && (jsx(Icon, { icon: icon, size: 'md', strokeColor: 'textSecondary' })), jsx(Text, { variant: 'span', fontSize: 'sm', fontWeight: 'semibold', color: 'textPrimary', children: label })] }), actions !== undefined && (jsx(Stack, { alignItems: 'center', gap: 'xs', flexShrink: 0, children: actions }))] }));
2277
2277
  };
2278
2278
  CardHeader.displayName = 'Card.Header';
2279
2279
 
2280
- const CardBody = ({ children, py = 'md', px = 'md', }) => {
2281
- return (jsx(Box, { py: py, px: px, children: children }));
2280
+ const CardBody = ({ children, py = 'md', px = 'md', flexDirection = 'column', gap = 'sm', ...rest }) => {
2281
+ return (jsx(Stack, { flexDirection: flexDirection, gap: gap, py: py, px: px, ...rest, children: children }));
2282
2282
  };
2283
2283
  CardBody.displayName = 'Card.Body';
2284
2284
 
@@ -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
- const IconComponent = VARIANT_ICONS[variant];
2356
- return (jsxs(Stack, { flexDirection: 'row', alignItems: 'center', gap: 'sm', children: [IconComponent && (jsx(Stack, { flexShrink: 0, alignItems: 'center', color: accentColor, width: '1.25rem', height: '1.25rem', "aria-hidden": true, children: jsx(IconComponent, { width: 20, height: 20 }) })), jsx(Text, { fontWeight: 'semibold', fontSize: 'sm', color: accentColor, children: children })] }));
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;