@udixio/ui-react 2.10.1 → 2.10.3

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.
@@ -12,5 +12,5 @@ import { ReactProps } from '../utils/component';
12
12
  * @a11y
13
13
  * - `role="listbox"` with `aria-selected` management.
14
14
  */
15
- export declare const Menu: ({ children, selected, onItemSelect, className, variant, ...restProps }: ReactProps<MenuInterface>) => import("react/jsx-runtime").JSX.Element;
15
+ export declare const Menu: ({ children, className, variant, ...restProps }: ReactProps<MenuInterface>) => import("react/jsx-runtime").JSX.Element;
16
16
  //# sourceMappingURL=Menu.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Menu.d.ts","sourceRoot":"","sources":["../../../src/lib/components/Menu.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAG7D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAMhD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,IAAI,GAAI,wEAOlB,UAAU,CAAC,aAAa,CAAC,4CAmF3B,CAAC"}
1
+ {"version":3,"file":"Menu.d.ts","sourceRoot":"","sources":["../../../src/lib/components/Menu.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAG7D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAMhD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,IAAI,GAAI,gDAKlB,UAAU,CAAC,aAAa,CAAC,4CA4D3B,CAAC"}
@@ -5,5 +5,5 @@ import { MenuItemInterface } from '../interfaces/menu-item.interface';
5
5
  * @status beta
6
6
  * @category Selection
7
7
  */
8
- export declare const MenuItem: ({ label, children, value, leadingIcon, trailingIcon, disabled, selected, variant, onClick, onItemSelect, className, ...restProps }: ReactProps<MenuItemInterface>) => import("react/jsx-runtime").JSX.Element;
8
+ export declare const MenuItem: ({ label, children, value, leadingIcon, trailingIcon, disabled, variant, href, onClick, onToggle, activated, className, ...restProps }: ReactProps<MenuItemInterface>) => import("react/jsx-runtime").JSX.Element;
9
9
  //# sourceMappingURL=MenuItem.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MenuItem.d.ts","sourceRoot":"","sources":["../../../src/lib/components/MenuItem.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAc,UAAU,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAMtE;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAI,oIAatB,UAAU,CAAC,iBAAiB,CAAC,4CAyK/B,CAAC"}
1
+ {"version":3,"file":"MenuItem.d.ts","sourceRoot":"","sources":["../../../src/lib/components/MenuItem.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAc,UAAU,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAMtE;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAI,uIActB,UAAU,CAAC,iBAAiB,CAAC,4CA0L/B,CAAC"}
@@ -1,34 +1,29 @@
1
- import { ComponentInterface } from '../utils/component';
2
- export interface MenuItemInterface extends ComponentInterface {
3
- value: string | number;
1
+ import { ActionOrLink } from '../utils/component';
2
+ type Props = {
3
+ value?: string | number;
4
4
  label?: string;
5
5
  children?: React.ReactNode;
6
6
  leadingIcon?: any;
7
7
  trailingIcon?: any;
8
8
  disabled?: boolean;
9
- selected?: boolean;
10
9
  variant?: 'standard' | 'vibrant';
11
10
  onClick?: (e?: React.MouseEvent) => void;
12
- type: 'div';
13
- props: {
14
- label?: string;
15
- value: string | number;
16
- leadingIcon?: any;
17
- trailingIcon?: any;
18
- disabled?: boolean;
19
- selected?: boolean;
20
- variant?: 'standard' | 'vibrant';
21
- onItemSelect?: (value: string | number) => void;
22
- children?: React.ReactNode;
11
+ onToggle?: (activated: boolean) => void;
12
+ activated?: boolean;
13
+ };
14
+ type Elements = [
15
+ 'menuItem',
16
+ 'selectedItem',
17
+ 'itemLabel',
18
+ 'itemIcon',
19
+ 'leadingIcon',
20
+ 'trailingIcon'
21
+ ];
22
+ export type MenuItemInterface = ActionOrLink<Props> & {
23
+ states: {
24
+ isActive: boolean;
23
25
  };
24
- states: Record<string, any>;
25
- elements: [
26
- 'menuItem',
27
- 'selectedItem',
28
- 'itemLabel',
29
- 'itemIcon',
30
- 'leadingIcon',
31
- 'trailingIcon'
32
- ];
33
- }
26
+ elements: Elements;
27
+ };
28
+ export {};
34
29
  //# sourceMappingURL=menu-item.interface.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"menu-item.interface.d.ts","sourceRoot":"","sources":["../../../src/lib/interfaces/menu-item.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,MAAM,WAAW,iBAAkB,SAAQ,kBAAkB;IAC3D,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IACjC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IAEzC,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,EAAE;QACL,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;QACvB,WAAW,CAAC,EAAE,GAAG,CAAC;QAClB,YAAY,CAAC,EAAE,GAAG,CAAC;QACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,OAAO,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;QACjC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,CAAC;QAChD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;KAC5B,CAAC;IACF,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,QAAQ,EAAE;QACR,UAAU;QACV,cAAc;QACd,WAAW;QACX,UAAU;QACV,aAAa;QACb,cAAc;KACf,CAAC;CACH"}
1
+ {"version":3,"file":"menu-item.interface.d.ts","sourceRoot":"","sources":["../../../src/lib/interfaces/menu-item.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,KAAK,KAAK,GAAG;IACX,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IACjC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IACzC,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,KAAK,QAAQ,GAAG;IACd,UAAU;IACV,cAAc;IACd,WAAW;IACX,UAAU;IACV,aAAa;IACb,cAAc;CACf,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG;IACpD,MAAM,EAAE;QACN,QAAQ,EAAE,OAAO,CAAC;KACnB,CAAC;IACF,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC"}
@@ -1,39 +1,89 @@
1
1
  import { ClassNameComponent } from '../utils';
2
2
  import { MenuItemInterface } from '../interfaces/menu-item.interface';
3
- export declare const menuItemStyle: (states: {
4
- label: any;
3
+ export declare const menuItemStyle: (states: (({
5
4
  value: any;
5
+ label: any;
6
+ children: any;
6
7
  leadingIcon: any;
7
8
  trailingIcon: any;
8
9
  disabled: any;
9
- selected: any;
10
10
  variant: any;
11
- onItemSelect: any;
11
+ onClick: any;
12
+ onToggle: any;
13
+ activated: any;
14
+ href: any;
15
+ } | {
16
+ value: any;
17
+ label: any;
12
18
  children: any;
13
- } & {
19
+ leadingIcon: any;
20
+ trailingIcon: any;
21
+ disabled: any;
22
+ variant: any;
23
+ onClick: any;
24
+ onToggle: any;
25
+ activated: any;
26
+ href: any;
27
+ }) & (({
28
+ value?: string | number;
14
29
  label?: string;
15
- value: string | number;
30
+ children?: React.ReactNode;
16
31
  leadingIcon?: any;
17
32
  trailingIcon?: any;
18
33
  disabled?: boolean;
19
- selected?: boolean;
20
34
  variant?: "standard" | "vibrant";
21
- onItemSelect?: (value: string | number) => void;
35
+ onClick?: (e?: React.MouseEvent) => void;
36
+ onToggle?: (activated: boolean) => void;
37
+ activated?: boolean;
38
+ } & {
39
+ href?: string;
40
+ }) | ({
41
+ value?: string | number;
42
+ label?: string;
22
43
  children?: React.ReactNode;
23
- } & Record<string, any> & {
44
+ leadingIcon?: any;
45
+ trailingIcon?: any;
46
+ disabled?: boolean;
47
+ variant?: "standard" | "vibrant";
48
+ onClick?: (e?: React.MouseEvent) => void;
49
+ onToggle?: (activated: boolean) => void;
50
+ activated?: boolean;
51
+ } & {
52
+ href?: never;
53
+ }))) & {
54
+ isActive: boolean;
55
+ } & {
24
56
  className: string | ClassNameComponent<MenuItemInterface> | undefined;
25
57
  }) => Record<"leadingIcon" | "trailingIcon" | "selectedItem" | "menuItem" | "itemLabel" | "itemIcon", string>;
26
- export declare const useMenuItemStyle: (states: Record<string, any> & {
58
+ export declare const useMenuItemStyle: (states: {
59
+ isActive: boolean;
60
+ } & ((({
61
+ value?: string | number;
27
62
  label?: string;
28
- value: string | number;
63
+ children?: React.ReactNode;
29
64
  leadingIcon?: any;
30
65
  trailingIcon?: any;
31
66
  disabled?: boolean;
32
- selected?: boolean;
33
67
  variant?: "standard" | "vibrant";
34
- onItemSelect?: (value: string | number) => void;
68
+ onClick?: (e?: React.MouseEvent) => void;
69
+ onToggle?: (activated: boolean) => void;
70
+ activated?: boolean;
71
+ } & {
72
+ href?: string;
73
+ }) | ({
74
+ value?: string | number;
75
+ label?: string;
35
76
  children?: React.ReactNode;
77
+ leadingIcon?: any;
78
+ trailingIcon?: any;
79
+ disabled?: boolean;
80
+ variant?: "standard" | "vibrant";
81
+ onClick?: (e?: React.MouseEvent) => void;
82
+ onToggle?: (activated: boolean) => void;
83
+ activated?: boolean;
36
84
  } & {
85
+ href?: never;
86
+ })) & {
37
87
  className?: string | ClassNameComponent<MenuItemInterface> | undefined;
38
- }) => Record<"leadingIcon" | "trailingIcon" | "selectedItem" | "menuItem" | "itemLabel" | "itemIcon", string>;
88
+ })) => Record<"leadingIcon" | "trailingIcon" | "selectedItem" | "menuItem" | "itemLabel" | "itemIcon", string>;
39
89
  //# sourceMappingURL=menu-item.style.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"menu-item.style.d.ts","sourceRoot":"","sources":["../../../src/lib/styles/menu-item.style.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EAIxB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAuCtE,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;6GAGzB,CAAC;AACF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;6GAG5B,CAAC"}
1
+ {"version":3,"file":"menu-item.style.d.ts","sourceRoot":"","sources":["../../../src/lib/styles/menu-item.style.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EAIxB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AA+BtE,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA1BpB,CAAC;;;;;;;;;;;;;gBAAD,CAAC;;;;;;;;;6GA6BN,CAAC;AACF,eAAO,MAAM,gBAAgB;;;;;;;;;;gBA9BvB,CAAC;;;;;;;;;;;;;gBAAD,CAAC;;;;;;;8GAiCN,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@udixio/ui-react",
3
- "version": "2.10.1",
3
+ "version": "2.10.3",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -37,8 +37,8 @@
37
37
  "devDependencies": {
38
38
  "react": "^19.1.1",
39
39
  "react-dom": "^19.1.1",
40
- "@udixio/theme": "2.1.13",
41
- "@udixio/tailwind": "2.4.13"
40
+ "@udixio/theme": "2.1.14",
41
+ "@udixio/tailwind": "2.4.14"
42
42
  },
43
43
  "repository": {
44
44
  "type": "git",
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useRef } from 'react';
1
+ import React, { useRef } from 'react';
2
2
  import { MenuInterface } from '../interfaces/menu.interface';
3
3
  import { useMenuStyle } from '../styles/menu.style';
4
4
  import { classNames } from '../utils';
@@ -22,8 +22,6 @@ import { MenuGroup } from './MenuGroup';
22
22
  */
23
23
  export const Menu = ({
24
24
  children,
25
- selected,
26
- onItemSelect,
27
25
  className,
28
26
  variant = 'standard',
29
27
  ...restProps
@@ -34,8 +32,6 @@ export const Menu = ({
34
32
  );
35
33
  const styles = useMenuStyle({
36
34
  children,
37
- selected,
38
- onItemSelect,
39
35
  className,
40
36
  variant,
41
37
  hasGroups,
@@ -44,18 +40,6 @@ export const Menu = ({
44
40
 
45
41
  const listRef = useRef<HTMLDivElement>(null);
46
42
 
47
- // Scroll to selected item on open
48
- useEffect(() => {
49
- if (listRef.current) {
50
- const selectedEl = listRef.current.querySelector(
51
- '[aria-selected="true"]',
52
- ) as HTMLElement;
53
- if (selectedEl) {
54
- selectedEl.scrollIntoView({ block: 'nearest' });
55
- }
56
- }
57
- }, []);
58
-
59
43
  const renderChildren = (nodes: React.ReactNode): React.ReactNode => {
60
44
  return React.Children.map(nodes, (child) => {
61
45
  if (!React.isValidElement(child)) return child;
@@ -70,17 +54,8 @@ export const Menu = ({
70
54
  }
71
55
 
72
56
  if (child.type === MenuItem) {
73
- const childValue = (child.props as any).value;
74
- const isSelected = Array.isArray(selected)
75
- ? selected.includes(childValue)
76
- : selected === childValue;
77
-
78
57
  return React.cloneElement(child, {
79
- selected: isSelected,
80
58
  variant: variant,
81
- onItemSelect: (val: string | number) => {
82
- onItemSelect?.(val);
83
- },
84
59
  } as any);
85
60
  }
86
61
 
@@ -1,9 +1,9 @@
1
- import React, { useRef, useState } from 'react';
1
+ import React, { useEffect, useRef, useState } from 'react';
2
2
  import { Icon } from '../icon';
3
3
  import { classNames, ReactProps } from '../utils';
4
4
  import { MenuItemInterface } from '../interfaces/menu-item.interface';
5
5
  import { useMenuItemStyle } from '../styles/menu-item.style';
6
- import { faChevronRight } from '@fortawesome/free-solid-svg-icons';
6
+ import { faCheck, faChevronRight } from '@fortawesome/free-solid-svg-icons';
7
7
  import { AnchorPositioner } from './AnchorPositioner';
8
8
  import { State } from '../effects';
9
9
 
@@ -19,10 +19,11 @@ export const MenuItem = ({
19
19
  leadingIcon,
20
20
  trailingIcon,
21
21
  disabled,
22
- selected,
23
- variant,
22
+ variant = 'standard',
23
+ href,
24
24
  onClick,
25
- onItemSelect, // Injected by Menu
25
+ onToggle,
26
+ activated = false,
26
27
  className,
27
28
  ...restProps
28
29
  }: ReactProps<MenuItemInterface>) => {
@@ -47,15 +48,26 @@ export const MenuItem = ({
47
48
  const labelContent = contentChildren.length > 0 ? contentChildren : label;
48
49
 
49
50
  const [isSubMenuOpen, setIsSubMenuOpen] = useState(false);
50
- const itemRef = useRef<HTMLDivElement>(null);
51
+ const [isActive, setIsActive] = useState(activated);
52
+
53
+ if (isActive) {
54
+ leadingIcon = faCheck;
55
+ }
56
+
57
+ const itemRef = useRef<HTMLButtonElement | HTMLAnchorElement>(null);
51
58
  const closeTimerRef = useRef<any>(null);
52
59
 
60
+ useEffect(() => {
61
+ setIsActive(activated);
62
+ }, [activated]);
63
+
53
64
  const styles = useMenuItemStyle({
54
65
  variant,
55
66
  disabled,
56
- selected,
57
67
  className,
58
68
  value,
69
+ activated: isActive,
70
+ isActive,
59
71
  });
60
72
 
61
73
  const handleClick = (e: React.MouseEvent) => {
@@ -69,9 +81,11 @@ export const MenuItem = ({
69
81
  return;
70
82
  }
71
83
 
72
- onClick?.(e);
73
- if (onItemSelect) {
74
- onItemSelect(value);
84
+ if (onToggle) {
85
+ setIsActive(!isActive);
86
+ onToggle(!isActive);
87
+ } else {
88
+ onClick?.(e);
75
89
  }
76
90
  };
77
91
 
@@ -104,20 +118,23 @@ export const MenuItem = ({
104
118
  const effectiveTrailingIcon =
105
119
  trailingIcon ?? (subMenuElement ? faChevronRight : undefined);
106
120
 
121
+ const ElementType = href ? 'a' : 'button';
122
+
107
123
  return (
108
- <div
109
- ref={itemRef}
110
- className={styles.menuItem} // Added relative and overflow-hidden for State
124
+ <ElementType
125
+ ref={itemRef as any}
126
+ href={href}
127
+ className={styles.menuItem}
111
128
  onClick={handleClick}
112
129
  onMouseEnter={handleMouseEnter}
113
130
  onMouseLeave={handleMouseLeave}
114
131
  role="option"
115
132
  aria-haspopup={!!subMenuElement}
116
133
  aria-expanded={isSubMenuOpen}
117
- aria-selected={selected}
134
+ aria-pressed={onToggle ? isActive : undefined}
118
135
  tabIndex={disabled ? -1 : 0}
136
+ disabled={!href ? disabled : undefined}
119
137
  onKeyDown={(e) => {
120
- // ... key handlers ...
121
138
  if (e.key === 'Enter' || e.key === ' ') {
122
139
  e.preventDefault();
123
140
  if (subMenuElement) {
@@ -135,14 +152,15 @@ export const MenuItem = ({
135
152
  e.stopPropagation();
136
153
  }
137
154
  }}
138
- {...restProps}
155
+ {...(restProps as any)}
139
156
  >
140
157
  <State
141
158
  className="absolute inset-0 pointer-events-none"
142
159
  colorName={classNames(
143
160
  // Match text color for state layer usually
144
- variant === 'vibrant' ? 'on-tertiary-container' : 'on-surface',
145
- selected && 'on-secondary-container',
161
+ variant === 'vibrant' || isActive
162
+ ? 'on-tertiary-container'
163
+ : 'on-secondary-container',
146
164
  )}
147
165
  stateClassName={'state-ripple-group-[menu-item]'}
148
166
  />
@@ -192,6 +210,6 @@ export const MenuItem = ({
192
210
  </div>
193
211
  </AnchorPositioner>
194
212
  )}
195
- </div>
213
+ </ElementType>
196
214
  );
197
215
  };
@@ -1,35 +1,30 @@
1
- import { ComponentInterface } from '../utils/component';
1
+ import { ActionOrLink } from '../utils/component';
2
2
 
3
- export interface MenuItemInterface extends ComponentInterface {
4
- value: string | number;
3
+ type Props = {
4
+ value?: string | number;
5
5
  label?: string;
6
6
  children?: React.ReactNode;
7
7
  leadingIcon?: any;
8
8
  trailingIcon?: any;
9
9
  disabled?: boolean;
10
- selected?: boolean; // Injected by parent
11
10
  variant?: 'standard' | 'vibrant'; // Injected by parent
12
11
  onClick?: (e?: React.MouseEvent) => void;
13
- // ComponentInterface implementation
14
- type: 'div';
15
- props: {
16
- label?: string;
17
- value: string | number;
18
- leadingIcon?: any;
19
- trailingIcon?: any;
20
- disabled?: boolean;
21
- selected?: boolean;
22
- variant?: 'standard' | 'vibrant';
23
- onItemSelect?: (value: string | number) => void; // Injected
24
- children?: React.ReactNode;
12
+ onToggle?: (activated: boolean) => void;
13
+ activated?: boolean;
14
+ };
15
+
16
+ type Elements = [
17
+ 'menuItem',
18
+ 'selectedItem',
19
+ 'itemLabel',
20
+ 'itemIcon',
21
+ 'leadingIcon',
22
+ 'trailingIcon',
23
+ ];
24
+
25
+ export type MenuItemInterface = ActionOrLink<Props> & {
26
+ states: {
27
+ isActive: boolean;
25
28
  };
26
- states: Record<string, any>;
27
- elements: [
28
- 'menuItem',
29
- 'selectedItem',
30
- 'itemLabel',
31
- 'itemIcon',
32
- 'leadingIcon',
33
- 'trailingIcon',
34
- ];
35
- }
29
+ elements: Elements;
30
+ };
@@ -9,31 +9,23 @@ import { MenuItemInterface } from '../interfaces/menu-item.interface';
9
9
  const menuItemConfig: ClassNameComponent<MenuItemInterface> = ({
10
10
  variant,
11
11
  disabled,
12
- selected,
12
+ isActive,
13
13
  }) => ({
14
14
  menuItem: classNames(
15
- 'group/menu-item overflow-hidden flex items-center h-12 px-3 cursor-pointer outline-none select-none shrink-0 ',
15
+ 'group/menu-item text-start overflow-hidden flex items-center h-12 px-3 cursor-pointer outline-none select-none shrink-0 ',
16
16
  'text-label-large',
17
17
  'transition-colors duration-200',
18
- {
19
- 'rounded-sm': selected,
20
- 'rounded-xl': !selected,
21
- },
18
+ 'rounded-xl',
19
+
22
20
  {
23
21
  'text-on-surface': !variant || variant === 'standard',
24
22
  // 'hover:bg-on-surface/[0.08] focus:bg-on-surface/[0.12]': !props?.variant || props.variant === 'standard', // Handled by State
25
23
  // 'hover:bg-on-tertiary-container/[0.08] focus:bg-on-tertiary-container/[0.12]': props?.variant === 'vibrant', // Handled by State
26
24
  'opacity-38 pointer-events-none': disabled,
27
25
  },
28
- ),
29
- selectedItem: classNames(
30
- 'bg-secondary-container text-on-secondary-container',
31
- // 'hover:bg-secondary-container/[0.8]',
32
- '[&_.menu-item-icon]:text-inherit',
33
- {
34
- // For vibrant, selected state
35
- '!bg-on-tertiary-container/[0.12]': variant === 'vibrant',
36
- },
26
+ (variant === 'vibrant' || isActive) && [
27
+ 'bg-secondary-container text-on-secondary-container',
28
+ ],
37
29
  ),
38
30
  itemLabel: classNames('flex-1 truncate'),
39
31
  itemIcon: classNames(