@moderneinc/neo-styled-components 4.1.2-next.d146c6 → 4.1.2-next.f98de9

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.
@@ -1,7 +1,8 @@
1
- import { type IconButtonProps } from '@mui/material/IconButton';
1
+ import type { ButtonBaseProps } from '@mui/material/ButtonBase';
2
+ import type { ReactNode } from 'react';
2
3
  type IconButtonSize = 'small' | 'medium';
3
- type IconButtonVariant = 'default' | 'nav';
4
- export interface NeoIconButtonProps extends Omit<IconButtonProps, 'color' | 'size'> {
4
+ type IconButtonVariant = 'primary' | 'secondary' | 'destructive' | 'tertiary' | 'nav';
5
+ export interface NeoIconButtonProps extends Omit<ButtonBaseProps, 'children' | 'size'> {
5
6
  /**
6
7
  * The size of the icon button
7
8
  * @default "medium"
@@ -10,10 +11,10 @@ export interface NeoIconButtonProps extends Omit<IconButtonProps, 'color' | 'siz
10
11
  */
11
12
  size?: IconButtonSize;
12
13
  /**
13
- * The visual variant of the icon button
14
- * - `default`: Transparent neutral style
14
+ * The visual variant of the icon button.
15
+ * - `primary`, `secondary`, `destructive`, `tertiary`: Uses NeoButton's hierarchy styling
15
16
  * - `nav`: White background with border, used in global navigation
16
- * @default "default"
17
+ * @default "tertiary"
17
18
  */
18
19
  variant?: IconButtonVariant;
19
20
  /**
@@ -22,25 +23,34 @@ export interface NeoIconButtonProps extends Omit<IconButtonProps, 'color' | 'siz
22
23
  * @default false
23
24
  */
24
25
  active?: boolean;
26
+ /**
27
+ * Show loading spinner instead of icon.
28
+ * Only applies to hierarchy variants (not `nav`).
29
+ * @default false
30
+ */
31
+ loading?: boolean;
32
+ children?: ReactNode;
25
33
  }
26
34
  /**
27
- * NeoIconButton - Icon-only button component based on MUI IconButton
35
+ * NeoIconButton - Icon-only button component
28
36
  *
29
- * Simple, neutral icon button with transparent background and icon color states.
30
- * Use `variant="nav"` for the global navigation pill-shaped button style.
37
+ * For hierarchy variants (primary/secondary/destructive/tertiary), wraps NeoButton with
38
+ * icon-only sizing. For the `nav` variant, uses a standalone MUI IconButton with custom styling.
31
39
  *
32
- * @figma https://www.figma.com/design/fQTkGSFbYyE7LiHuQJsENC?node-id=11126-21344
40
+ * @figma https://www.figma.com/design/fQTkGSFbYyE7LiHuQJsENC?node-id=4086-7590
33
41
  *
34
42
  * Figma Props Mapping:
43
+ * - Hierarchy (Primary|Secondary|Destructive|Tertiary) → variant prop
35
44
  * - Size (Small|Medium) → size prop
45
+ * - Show text = false → always (this is the icon-only variant of NeoButton)
36
46
  * - State=Disabled → disabled prop
47
+ * - State=Loading → loading prop
37
48
  * - State=Hover → CSS :hover
38
- * - State=Active → CSS :active
49
+ * - State=Pressed → CSS :active
39
50
  * - State=Focus → CSS :focus-visible
40
- * - State=Loading → not yet implemented
41
51
  */
42
52
  export declare const NeoIconButton: {
43
- ({ size, variant, active, ...props }: NeoIconButtonProps): import("react/jsx-runtime").JSX.Element;
53
+ ({ size, variant, active, loading, children, ...props }: NeoIconButtonProps): import("react/jsx-runtime").JSX.Element;
44
54
  displayName: string;
45
55
  };
46
56
  export {};
package/dist/index.d.ts CHANGED
@@ -18,7 +18,6 @@ import { DividerProps } from '@mui/material/Divider';
18
18
  import { PaperProps } from '@mui/material/Paper';
19
19
  import { BadgeProps } from '@mui/material/Badge';
20
20
  import { AvatarProps } from '@mui/material/Avatar';
21
- import { IconButtonProps } from '@mui/material/IconButton';
22
21
  import { InputBaseProps } from '@mui/material/InputBase';
23
22
  import { MenuProps } from '@mui/material/Menu';
24
23
  import { MenuItemProps } from '@mui/material/MenuItem';
@@ -1421,8 +1420,8 @@ declare const NeoGeneralAvatar: {
1421
1420
  };
1422
1421
 
1423
1422
  type IconButtonSize = 'small' | 'medium';
1424
- type IconButtonVariant = 'default' | 'nav';
1425
- interface NeoIconButtonProps extends Omit<IconButtonProps, 'color' | 'size'> {
1423
+ type IconButtonVariant = 'primary' | 'secondary' | 'destructive' | 'tertiary' | 'nav';
1424
+ interface NeoIconButtonProps extends Omit<ButtonBaseProps, 'children' | 'size'> {
1426
1425
  /**
1427
1426
  * The size of the icon button
1428
1427
  * @default "medium"
@@ -1431,10 +1430,10 @@ interface NeoIconButtonProps extends Omit<IconButtonProps, 'color' | 'size'> {
1431
1430
  */
1432
1431
  size?: IconButtonSize;
1433
1432
  /**
1434
- * The visual variant of the icon button
1435
- * - `default`: Transparent neutral style
1433
+ * The visual variant of the icon button.
1434
+ * - `primary`, `secondary`, `destructive`, `tertiary`: Uses NeoButton's hierarchy styling
1436
1435
  * - `nav`: White background with border, used in global navigation
1437
- * @default "default"
1436
+ * @default "tertiary"
1438
1437
  */
1439
1438
  variant?: IconButtonVariant;
1440
1439
  /**
@@ -1443,25 +1442,34 @@ interface NeoIconButtonProps extends Omit<IconButtonProps, 'color' | 'size'> {
1443
1442
  * @default false
1444
1443
  */
1445
1444
  active?: boolean;
1445
+ /**
1446
+ * Show loading spinner instead of icon.
1447
+ * Only applies to hierarchy variants (not `nav`).
1448
+ * @default false
1449
+ */
1450
+ loading?: boolean;
1451
+ children?: ReactNode;
1446
1452
  }
1447
1453
  /**
1448
- * NeoIconButton - Icon-only button component based on MUI IconButton
1454
+ * NeoIconButton - Icon-only button component
1449
1455
  *
1450
- * Simple, neutral icon button with transparent background and icon color states.
1451
- * Use `variant="nav"` for the global navigation pill-shaped button style.
1456
+ * For hierarchy variants (primary/secondary/destructive/tertiary), wraps NeoButton with
1457
+ * icon-only sizing. For the `nav` variant, uses a standalone MUI IconButton with custom styling.
1452
1458
  *
1453
- * @figma https://www.figma.com/design/fQTkGSFbYyE7LiHuQJsENC?node-id=11126-21344
1459
+ * @figma https://www.figma.com/design/fQTkGSFbYyE7LiHuQJsENC?node-id=4086-7590
1454
1460
  *
1455
1461
  * Figma Props Mapping:
1462
+ * - Hierarchy (Primary|Secondary|Destructive|Tertiary) → variant prop
1456
1463
  * - Size (Small|Medium) → size prop
1464
+ * - Show text = false → always (this is the icon-only variant of NeoButton)
1457
1465
  * - State=Disabled → disabled prop
1466
+ * - State=Loading → loading prop
1458
1467
  * - State=Hover → CSS :hover
1459
- * - State=Active → CSS :active
1468
+ * - State=Pressed → CSS :active
1460
1469
  * - State=Focus → CSS :focus-visible
1461
- * - State=Loading → not yet implemented
1462
1470
  */
1463
1471
  declare const NeoIconButton: {
1464
- ({ size, variant, active, ...props }: NeoIconButtonProps): react_jsx_runtime.JSX.Element;
1472
+ ({ size, variant, active, loading, children, ...props }: NeoIconButtonProps): react_jsx_runtime.JSX.Element;
1465
1473
  displayName: string;
1466
1474
  };
1467
1475
 
package/dist/index.esm.js CHANGED
@@ -1084,7 +1084,7 @@ const LinkText = styled('span')(({ bannerType = 'outlined' }) => ({
1084
1084
  textDecoration: 'underline',
1085
1085
  },
1086
1086
  }));
1087
- const StyledIconButton$1 = styled(IconButton)(({ closeIconColor }) => ({
1087
+ const StyledIconButton = styled(IconButton)(({ closeIconColor }) => ({
1088
1088
  padding: 0,
1089
1089
  color: closeIconColor,
1090
1090
  '&:hover': {
@@ -1101,7 +1101,7 @@ const NeoBanner = ({ intent = 'info', type = 'outlined', message, messagePositio
1101
1101
  return null;
1102
1102
  }
1103
1103
  const closeIconColor = type === 'filled' ? semanticColors.surfaces.white : intentColors$1[intent].default;
1104
- return (jsx(StyledAlert$1, { ...props, intent: intent, bannerType: type, messagePosition: messagePosition, icon: messagePosition === 'left' ? icon || false : false, action: showClose ? (jsx(StyledIconButton$1, { size: "small", onClick: handleClose, closeIconColor: closeIconColor, children: jsx(X, { size: 24 }) })) : undefined, children: messagePosition === 'center' ? (jsxs(Fragment, { children: [icon, jsx("span", { children: message }), linkText && (jsx(LinkText, { bannerType: type, onClick: onLinkClick, children: linkText }))] })) : (jsxs(Fragment, { children: [jsx("span", { children: message }), linkText && (jsx(LinkText, { bannerType: type, onClick: onLinkClick, children: linkText }))] })) }));
1104
+ return (jsx(StyledAlert$1, { ...props, intent: intent, bannerType: type, messagePosition: messagePosition, icon: messagePosition === 'left' ? icon || false : false, action: showClose ? (jsx(StyledIconButton, { size: "small", onClick: handleClose, closeIconColor: closeIconColor, children: jsx(X, { size: 24 }) })) : undefined, children: messagePosition === 'center' ? (jsxs(Fragment, { children: [icon, jsx("span", { children: message }), linkText && (jsx(LinkText, { bannerType: type, onClick: onLinkClick, children: linkText }))] })) : (jsxs(Fragment, { children: [jsx("span", { children: message }), linkText && (jsx(LinkText, { bannerType: type, onClick: onLinkClick, children: linkText }))] })) }));
1105
1105
  };
1106
1106
  NeoBanner.displayName = 'NeoBanner';
1107
1107
 
@@ -1171,7 +1171,7 @@ function NeoBreadcrumbs({ children, className }) {
1171
1171
  }
1172
1172
 
1173
1173
  // Props that should not be forwarded to ButtonBase (Button-specific props that ButtonBase doesn't support)
1174
- const buttonOnlyProps$1 = [
1174
+ const buttonOnlyProps = [
1175
1175
  'variant',
1176
1176
  'size',
1177
1177
  'loading',
@@ -1181,7 +1181,7 @@ const buttonOnlyProps$1 = [
1181
1181
  'disableElevation',
1182
1182
  ];
1183
1183
  const StyledButtonBase$1 = styled(ButtonBase, {
1184
- shouldForwardProp: prop => !buttonOnlyProps$1.includes(prop),
1184
+ shouldForwardProp: prop => !buttonOnlyProps.includes(prop),
1185
1185
  })(({ theme, variant = 'primary', size = 'medium', loading = false }) => {
1186
1186
  // Size configurations using theme.spacing()
1187
1187
  const sizeConfig = {
@@ -3414,20 +3414,24 @@ function subMonths(date, amount, options) {
3414
3414
  return addMonths(date, -1);
3415
3415
  }
3416
3416
 
3417
- // Props that should not be forwarded to IconButton (Button-specific props that IconButton doesn't support)
3418
- const buttonOnlyProps = [
3419
- 'size',
3420
- 'startIcon',
3421
- 'endIcon',
3422
- 'fullWidth',
3423
- 'disableElevation',
3424
- 'variant',
3425
- 'active',
3426
- ];
3427
- const StyledIconButton = styled(IconButton, {
3428
- shouldForwardProp: prop => !buttonOnlyProps.includes(prop),
3429
- })(({ theme, size = 'medium', variant = 'default', active = false }) => {
3430
- // Size configurations using theme.spacing()
3417
+ // Cast NeoButton to a simpler type for styled() compatibility (avoids generic inference issues)
3418
+ const NeoButtonBase = NeoButton;
3419
+ // Icon-only wrapper around NeoButton for hierarchy variants
3420
+ const StyledIconOnlyButton = styled(NeoButtonBase)(({ size = 'medium' }) => {
3421
+ const dimension = size === 'small' ? 32 : spacing.spacing_5;
3422
+ return {
3423
+ '&&': {
3424
+ minWidth: 'unset',
3425
+ padding: 0,
3426
+ width: dimension,
3427
+ },
3428
+ };
3429
+ });
3430
+ // Nav variant - standalone styled MUI IconButton (not backed by Figma)
3431
+ const navOnlyProps = ['size', 'variant', 'active'];
3432
+ const StyledNavButton = styled(IconButton, {
3433
+ shouldForwardProp: prop => !navOnlyProps.includes(prop),
3434
+ })(({ theme, size = 'medium', active = false }) => {
3431
3435
  const sizeConfig = {
3432
3436
  small: {
3433
3437
  width: 32,
@@ -3441,50 +3445,24 @@ const StyledIconButton = styled(IconButton, {
3441
3445
  },
3442
3446
  };
3443
3447
  const sizeStyles = sizeConfig[size];
3444
- // Base styles shared by all variants
3445
- const baseStyles = {
3448
+ const activeNavStyles = {
3449
+ backgroundColor: semanticColors.icons.pressedBackground,
3450
+ borderColor: 'transparent',
3451
+ color: semanticColors.buttons.primary.pressed,
3452
+ };
3453
+ return {
3446
3454
  width: sizeStyles.width,
3447
3455
  height: sizeStyles.height,
3448
3456
  padding: sizeStyles.padding,
3449
- borderRadius: borderRadius.button, // Fully rounded/circular
3457
+ borderRadius: borderRadius.button,
3450
3458
  transition: theme.transitions.create(['background-color', 'border-color', 'color'], {
3451
3459
  duration: theme.transitions.duration.short,
3452
3460
  }),
3453
- // Disabled state
3454
- [`&.${iconButtonClasses.disabled}`]: {
3455
- cursor: 'not-allowed',
3456
- pointerEvents: 'auto',
3457
- },
3458
- // Focus visible for keyboard navigation
3459
3461
  '&:focus-visible': {
3460
3462
  outline: `2px solid ${semanticColors.border.focus}`,
3461
3463
  outlineOffset: 2,
3462
3464
  },
3463
- };
3464
- // Default variant - transparent neutral style
3465
- const defaultStyles = {
3466
- backgroundColor: 'transparent',
3467
- color: semanticColors.icons.default,
3468
- border: 'none',
3469
- '&:hover': {
3470
- backgroundColor: semanticColors.icons.hoverBackground,
3471
- color: semanticColors.icons.hover,
3472
- },
3473
- '&:active': {
3474
- color: semanticColors.icons.pressed,
3475
- },
3476
- [`&.${iconButtonClasses.disabled}`]: {
3477
- backgroundColor: 'transparent',
3478
- color: semanticColors.icons.disabled,
3479
- },
3480
- };
3481
- // Nav variant - 44px pill with border, used in global navigation
3482
- const activeNavStyles = {
3483
- backgroundColor: semanticColors.icons.pressedBackground,
3484
- borderColor: 'transparent',
3485
- color: semanticColors.buttons.primary.pressed,
3486
- };
3487
- const navStyles = {
3465
+ // Nav styles
3488
3466
  backgroundColor: semanticColors.surfaces.white,
3489
3467
  color: semanticColors.icons.default,
3490
3468
  border: `1px solid ${semanticColors.border.secondary}`,
@@ -3495,6 +3473,8 @@ const StyledIconButton = styled(IconButton, {
3495
3473
  },
3496
3474
  '&:active': activeNavStyles,
3497
3475
  [`&.${iconButtonClasses.disabled}`]: {
3476
+ cursor: 'not-allowed',
3477
+ pointerEvents: 'auto',
3498
3478
  backgroundColor: semanticColors.surfaces.white,
3499
3479
  borderColor: semanticColors.border.secondary,
3500
3480
  color: semanticColors.icons.disabled,
@@ -3502,33 +3482,30 @@ const StyledIconButton = styled(IconButton, {
3502
3482
  },
3503
3483
  ...(active ? activeNavStyles : {}),
3504
3484
  };
3505
- const variantStyles = {
3506
- default: defaultStyles,
3507
- nav: navStyles,
3508
- };
3509
- return {
3510
- ...baseStyles,
3511
- ...variantStyles[variant],
3512
- };
3513
3485
  });
3514
3486
  /**
3515
- * NeoIconButton - Icon-only button component based on MUI IconButton
3487
+ * NeoIconButton - Icon-only button component
3516
3488
  *
3517
- * Simple, neutral icon button with transparent background and icon color states.
3518
- * Use `variant="nav"` for the global navigation pill-shaped button style.
3489
+ * For hierarchy variants (primary/secondary/destructive/tertiary), wraps NeoButton with
3490
+ * icon-only sizing. For the `nav` variant, uses a standalone MUI IconButton with custom styling.
3519
3491
  *
3520
- * @figma https://www.figma.com/design/fQTkGSFbYyE7LiHuQJsENC?node-id=11126-21344
3492
+ * @figma https://www.figma.com/design/fQTkGSFbYyE7LiHuQJsENC?node-id=4086-7590
3521
3493
  *
3522
3494
  * Figma Props Mapping:
3495
+ * - Hierarchy (Primary|Secondary|Destructive|Tertiary) → variant prop
3523
3496
  * - Size (Small|Medium) → size prop
3497
+ * - Show text = false → always (this is the icon-only variant of NeoButton)
3524
3498
  * - State=Disabled → disabled prop
3499
+ * - State=Loading → loading prop
3525
3500
  * - State=Hover → CSS :hover
3526
- * - State=Active → CSS :active
3501
+ * - State=Pressed → CSS :active
3527
3502
  * - State=Focus → CSS :focus-visible
3528
- * - State=Loading → not yet implemented
3529
3503
  */
3530
- const NeoIconButton = ({ size = 'medium', variant = 'default', active = false, ...props }) => {
3531
- return (jsx(StyledIconButton, { size: size, variant: variant, active: active, disableRipple: variant === 'nav', ...props }));
3504
+ const NeoIconButton = ({ size = 'medium', variant = 'tertiary', active = false, loading, children, ...props }) => {
3505
+ if (variant === 'nav') {
3506
+ return (jsx(StyledNavButton, { size: size, active: active, disableRipple: true, ...props, children: children }));
3507
+ }
3508
+ return (jsx(StyledIconOnlyButton, { variant: variant, size: size, loading: loading, ...props, children: children }));
3532
3509
  };
3533
3510
  NeoIconButton.displayName = 'NeoIconButton';
3534
3511