@meith/ui 0.3.0 → 0.3.1

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/menu.tsx +17 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meith/ui",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Meith's shared UI primitives: buttons, menus and the class utilities themes build with.",
5
5
  "license": "LGPL-3.0-or-later",
6
6
  "repository": {
package/src/menu.tsx CHANGED
@@ -1,12 +1,14 @@
1
1
  'use client'
2
2
 
3
3
  import { Menu as MenuPrimitive } from '@base-ui/react/menu'
4
+ import { Fragment } from 'react'
4
5
 
5
6
  import { cn } from './utils'
6
7
 
7
8
  export interface MenuLink {
8
9
  readonly label: string
9
10
  readonly href: string
11
+ readonly group?: string
10
12
  }
11
13
 
12
14
  export interface MenuProps {
@@ -47,18 +49,22 @@ function Menu({ label, trigger, triggerClassName, items, children, align = 'end'
47
49
  'data-[ending-style]:scale-95 data-[ending-style]:opacity-0',
48
50
  )}
49
51
  >
50
- {items.map((item) => (
51
- <MenuPrimitive.LinkItem
52
- key={item.href}
53
- href={item.href}
54
- closeOnClick
55
- className={cn(
56
- 'flex cursor-default items-center rounded-md px-2.5 py-1.5 text-sm text-foreground outline-none select-none',
57
- 'data-[highlighted]:bg-muted',
52
+ {items.map((item, index) => (
53
+ <Fragment key={item.href}>
54
+ {index > 0 && item.group !== items[index - 1]?.group && (
55
+ <MenuPrimitive.Separator className="-mx-1 my-1 h-px bg-border" />
58
56
  )}
59
- >
60
- {item.label}
61
- </MenuPrimitive.LinkItem>
57
+ <MenuPrimitive.LinkItem
58
+ href={item.href}
59
+ closeOnClick
60
+ className={cn(
61
+ 'flex cursor-default items-center rounded-md px-2.5 py-1.5 text-sm text-foreground outline-none select-none',
62
+ 'data-[highlighted]:bg-muted',
63
+ )}
64
+ >
65
+ {item.label}
66
+ </MenuPrimitive.LinkItem>
67
+ </Fragment>
62
68
  ))}
63
69
 
64
70
  {children !== undefined && children !== null && (