@ttoss/components 2.14.29 → 2.14.31

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.
Files changed (3) hide show
  1. package/README.md +15 -5
  2. package/dist/index.mjs +30 -20
  3. package/package.json +4 -4
package/README.md CHANGED
@@ -209,14 +209,24 @@ import { Markdown } from '@ttoss/components';
209
209
 
210
210
  ### Menu
211
211
 
212
- Dropdown menus with customizable triggers. [Docs](https://storybook.ttoss.dev/?path=/docs/components-menu--docs)
212
+ Floating dropdown panel with a configurable trigger icon. Use `NavList` as children for navigation items. [Docs](https://storybook.ttoss.dev/?path=/docs/components-menu--docs)
213
213
 
214
214
  ```tsx
215
- import { Menu } from '@ttoss/components';
215
+ import { Menu, NavList } from '@ttoss/components';
216
+
217
+ <Menu>
218
+ <NavList
219
+ variant="menu"
220
+ items={[
221
+ { href: '/dashboard', label: 'Dashboard', icon: 'mdi:home-outline' },
222
+ { href: '/settings', label: 'Settings', icon: 'mdi:cog-outline' },
223
+ ]}
224
+ />
225
+ </Menu>;
216
226
 
217
- <Menu trigger={<Button>Open Menu</Button>}>
218
- <Menu.Item onClick={() => {}}>Action 1</Menu.Item>
219
- <Menu.Item onClick={() => {}}>Action 2</Menu.Item>
227
+ // Custom trigger icon
228
+ <Menu menuIcon="mdi:dots-vertical">
229
+ <NavList variant="menu" items={items} />
220
230
  </Menu>;
221
231
  ```
222
232
 
package/dist/index.mjs CHANGED
@@ -1676,7 +1676,9 @@ var Menu = ({
1676
1676
  menuIcon = "menu-open"
1677
1677
  }) => {
1678
1678
  const [isOpen, setIsOpen] = React.useState(false);
1679
- const [stylePos, setStylePos] = React.useState({});
1679
+ const [stylePos, setStylePos] = React.useState({
1680
+ visibility: "hidden"
1681
+ });
1680
1682
  const triggerRef = React.useRef(null);
1681
1683
  const panelRef = React.useRef(null);
1682
1684
  const toggle = () => {
@@ -1762,7 +1764,6 @@ var Menu = ({
1762
1764
  ...stylePos
1763
1765
  },
1764
1766
  children: /* @__PURE__ */jsx(Box, {
1765
- as: "nav",
1766
1767
  children
1767
1768
  })
1768
1769
  }) : null;
@@ -2267,13 +2268,15 @@ var getVariantStyles = variant => {
2267
2268
  width: "full"
2268
2269
  },
2269
2270
  item: {
2270
- backgroundColor: "transparent",
2271
+ backgroundColor: "navigation.background.muted.default",
2272
+ color: "navigation.text.primary.default",
2271
2273
  padding: "3",
2272
2274
  borderRadius: "none",
2273
2275
  fontSize: "md",
2274
- transition: "background-color 0.15s ease",
2276
+ transition: "background-color 0.15s ease, color 0.15s ease",
2275
2277
  "&:hover": {
2276
2278
  backgroundColor: "navigation.background.muted.hover",
2279
+ color: "navigation.text.primary.hover",
2277
2280
  textDecoration: "none"
2278
2281
  }
2279
2282
  },
@@ -2303,13 +2306,15 @@ var getVariantStyles = variant => {
2303
2306
  width: "full"
2304
2307
  },
2305
2308
  item: {
2306
- backgroundColor: "transparent",
2309
+ backgroundColor: "navigation.background.muted.default",
2310
+ color: "navigation.text.primary.default",
2307
2311
  borderRadius: "md",
2308
2312
  padding: "2",
2309
2313
  fontSize: "md",
2310
2314
  transition: "all 0.2s ease",
2311
2315
  "&:hover": {
2312
2316
  backgroundColor: "navigation.background.muted.hover",
2317
+ color: "navigation.text.primary.hover",
2313
2318
  transform: "translateX(4px)",
2314
2319
  textDecoration: "none"
2315
2320
  }
@@ -2337,14 +2342,16 @@ var getVariantStyles = variant => {
2337
2342
  width: "full"
2338
2343
  },
2339
2344
  item: {
2340
- backgroundColor: "transparent",
2345
+ backgroundColor: "navigation.background.muted.default",
2346
+ color: "navigation.text.primary.default",
2341
2347
  padding: "2",
2342
2348
  fontSize: "sm",
2343
2349
  borderBottom: "sm",
2344
2350
  borderColor: "display.border.muted.default",
2345
- transition: "background-color 0.1s ease",
2351
+ transition: "background-color 0.1s ease, color 0.1s ease",
2346
2352
  "&:hover": {
2347
2353
  backgroundColor: "navigation.background.muted.hover",
2354
+ color: "navigation.text.primary.hover",
2348
2355
  textDecoration: "none"
2349
2356
  }
2350
2357
  },
@@ -2368,6 +2375,17 @@ var getVariantStyles = variant => {
2368
2375
  return getVariantStyles("menu");
2369
2376
  }
2370
2377
  };
2378
+ var resolveItemStyles = (item, variantStyles) => {
2379
+ return {
2380
+ ...variantStyles.item,
2381
+ ...(item.active ? variantStyles.activeItem : {}),
2382
+ ...(item.disabled ? {
2383
+ opacity: .5,
2384
+ cursor: "not-allowed",
2385
+ pointerEvents: "none"
2386
+ } : {})
2387
+ };
2388
+ };
2371
2389
  var NavListItemComponent = ({
2372
2390
  item,
2373
2391
  onItemClick,
@@ -2384,21 +2402,13 @@ var NavListItemComponent = ({
2384
2402
  item.onClick?.(event);
2385
2403
  onItemClick?.(item);
2386
2404
  };
2387
- const itemStyles = {
2388
- ...variantStyles.item,
2389
- ...(item.active ? variantStyles.activeItem : {}),
2390
- ...(item.disabled ? {
2391
- opacity: .5,
2392
- cursor: "not-allowed",
2393
- pointerEvents: "none"
2394
- } : {})
2395
- };
2405
+ const itemStyles = resolveItemStyles(item, variantStyles);
2406
+ const ariaCurrent = item.active ? "page" : void 0;
2396
2407
  const isDefaultLink = LinkComponent === Link;
2397
2408
  const linkContent = /* @__PURE__ */jsxs(Flex, {
2398
2409
  sx: {
2399
2410
  alignItems: "center",
2400
- gap: "2",
2401
- color: "navigation.text.primary.default"
2411
+ gap: "2"
2402
2412
  },
2403
2413
  children: [item.icon && /* @__PURE__ */jsx(Icon, {
2404
2414
  icon: item.icon,
@@ -2414,7 +2424,7 @@ var NavListItemComponent = ({
2414
2424
  onClick: handleClick,
2415
2425
  sx: itemStyles,
2416
2426
  "aria-disabled": item.disabled,
2417
- "aria-current": item.active ? "page" : void 0,
2427
+ "aria-current": ariaCurrent,
2418
2428
  quiet: true,
2419
2429
  children: linkContent
2420
2430
  }) : /* @__PURE__ */jsx(Link, {
@@ -2423,7 +2433,7 @@ var NavListItemComponent = ({
2423
2433
  onClick: handleClick,
2424
2434
  sx: itemStyles,
2425
2435
  "aria-disabled": item.disabled,
2426
- "aria-current": item.active ? "page" : void 0,
2436
+ "aria-current": ariaCurrent,
2427
2437
  quiet: true,
2428
2438
  children: linkContent
2429
2439
  }), showDivider && /* @__PURE__ */jsx(Divider, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/components",
3
- "version": "2.14.29",
3
+ "version": "2.14.31",
4
4
  "description": "React components for ttoss ecosystem.",
5
5
  "keywords": [
6
6
  "React",
@@ -53,13 +53,13 @@
53
53
  "react": "^19.2.6",
54
54
  "tsdown": "^0.22.2",
55
55
  "tsx": "^4.21.0",
56
+ "@ttoss/config": "^1.37.17",
56
57
  "@ttoss/i18n-cli": "^0.8.17",
57
- "@ttoss/react-hooks": "^2.3.20",
58
58
  "@ttoss/react-i18n": "^2.2.21",
59
+ "@ttoss/react-hooks": "^2.3.20",
59
60
  "@ttoss/react-icons": "^0.7.21",
60
- "@ttoss/test-utils": "^4.2.18",
61
61
  "@ttoss/ui": "^6.9.27",
62
- "@ttoss/config": "^1.37.17"
62
+ "@ttoss/test-utils": "^4.2.18"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "react": ">=16.8.0",