@versini/ui-menu 4.0.10 → 4.0.12

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 +116 -6
  2. package/dist/index.js +3 -3
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,17 +1,28 @@
1
1
  # @versini/ui-menu
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/@versini/ui-menu?style=flat-square)](https://www.npmjs.com/package/@versini/ui-menu)
4
+ ![npm package minimized gzipped size](<https://img.shields.io/bundlejs/size/%40versini%2Fui-menu?style=flat-square&label=size%20(gzip)>)
4
5
 
5
6
  > Accessible and flexible React menu components built with TypeScript and TailwindCSS.
6
7
 
7
- The Menu package provides dropdown menus and navigation components with full keyboard navigation, focus management, and customizable styling.
8
-
8
+ The Menu package provides dropdown menus and navigation components with full keyboard navigation, focus management, theming for triggers, and composable items / separators.
9
9
 
10
10
  ## Table of Contents
11
11
 
12
12
  - [Features](#features)
13
13
  - [Installation](#installation)
14
14
  - [Usage](#usage)
15
+ - [Examples](#examples)
16
+ - [API](#api)
17
+
18
+ ## Features
19
+
20
+ - **📋 Composable**: `Menu`, `MenuItem`, `MenuSeparator`, `MenuGroupLabel`
21
+ - **♿ Accessible**: Built with Floating UI & ARIA roles for robust a11y
22
+ - **⌨️ Keyboard Support**: Arrow navigation, typeahead matching, ESC / click outside close
23
+ - **🎨 Theme & Focus Modes**: Trigger inherits color + separate focus styling
24
+ - **🧭 Smart Positioning**: Auto flip / shift to remain within viewport
25
+ - **🧪 Type Safe**: Strongly typed props & label-based typeahead
15
26
 
16
27
  ## Installation
17
28
 
@@ -19,7 +30,7 @@ The Menu package provides dropdown menus and navigation components with full key
19
30
  npm install @versini/ui-menu
20
31
  ```
21
32
 
22
- > **Note**: This component requires TailwindCSS and the `@versini/ui-styles` plugin for proper styling. See the [root README](../../README.md#tailwindcss-setup) for complete setup instructions.
33
+ > **Note**: This component requires TailwindCSS and the `@versini/ui-styles` plugin for proper styling. See the [installation documentation](https://versini-org.github.io/ui-components/?path=/docs/getting-started-installation--docs) for complete setup instructions.
23
34
 
24
35
  ## Usage
25
36
 
@@ -39,10 +50,109 @@ function App() {
39
50
  </ButtonIcon>
40
51
  }
41
52
  >
42
- <MenuItem label="Profile" onClick={() => console.log('Profile')} />
43
- <MenuItem label="Settings" onClick={() => console.log('Settings')} />
44
- <MenuItem label="Logout" onClick={() => console.log('Logout')} />
53
+ <MenuItem label="Profile" onClick={() => console.log("Profile")} />
54
+ <MenuItem label="Settings" onClick={() => console.log("Settings")} />
55
+ <MenuItem label="Logout" onClick={() => console.log("Logout")} />
56
+ </Menu>
57
+ );
58
+ }
59
+ ```
60
+
61
+ ## Examples
62
+
63
+ ### Menu with Icons & Selection
64
+
65
+ ```tsx
66
+ import { Menu, MenuItem } from "@versini/ui-menu";
67
+ import { ButtonIcon } from "@versini/ui-button";
68
+ import {
69
+ IconMenu,
70
+ IconUser,
71
+ IconSettings,
72
+ IconLogout
73
+ } from "@versini/ui-icons";
74
+
75
+ function AccountMenu() {
76
+ const [last, setLast] = useState("");
77
+ return (
78
+ <Menu
79
+ label="Account options"
80
+ trigger={
81
+ <ButtonIcon label="Account">
82
+ <IconMenu />
83
+ </ButtonIcon>
84
+ }
85
+ onOpenChange={(o) => console.log("open?", o)}
86
+ >
87
+ <MenuItem
88
+ label="Profile"
89
+ icon={<IconUser />}
90
+ onClick={() => setLast("profile")}
91
+ />
92
+ <MenuItem
93
+ label="Settings"
94
+ icon={<IconSettings />}
95
+ onClick={() => setLast("settings")}
96
+ />
97
+ <MenuSeparator />
98
+ <MenuItem
99
+ label="Logout"
100
+ icon={<IconLogout />}
101
+ onClick={() => setLast("logout")}
102
+ />
45
103
  </Menu>
46
104
  );
47
105
  }
48
106
  ```
107
+
108
+ ### Raw Custom Item
109
+
110
+ ```tsx
111
+ <Menu
112
+ trigger={
113
+ <ButtonIcon label="More">
114
+ <IconMenu />
115
+ </ButtonIcon>
116
+ }
117
+ >
118
+ <MenuItem raw ignoreClick>
119
+ <div className="p-2 text-xs uppercase tracking-wide text-copy-medium">
120
+ Custom Header
121
+ </div>
122
+ </MenuItem>
123
+ <MenuItem label="Action" />
124
+ </Menu>
125
+ ```
126
+
127
+ ## API
128
+
129
+ ### Menu Props
130
+
131
+ | Prop | Type | Default | Description |
132
+ | ------------------ | ------------------------- | ---------------- | ------------------------------------------------------------- | ------------- | ---------- | ------------------------------------------------- |
133
+ | `trigger` | `React.ReactNode` | - | Element used to open the menu (Button / ButtonIcon / custom). |
134
+ | `children` | `React.ReactNode` | - | One or more `MenuItem` / `MenuSeparator` / custom nodes. |
135
+ | `defaultPlacement` | `Placement` (Floating UI) | `"bottom-start"` | Initial preferred placement. |
136
+ | `mode` | `"dark" | "light" | "system" | "alt-system"` | `"system"` | Color mode of trigger (when using UI buttons). |
137
+ | `focusMode` | `"dark" | "light" | "system" | "alt-system"` | `"system"` | Focus ring thematic mode (when using UI buttons). |
138
+ | `label` | `string` | `"Open menu"` | Accessible label for the trigger if none present. |
139
+ | `onOpenChange` | `(open: boolean) => void` | - | Called when menu opens or closes. |
140
+
141
+ ### MenuItem Props
142
+
143
+ | Prop | Type | Default | Description |
144
+ | ------------- | ----------------- | ------- | ---------------------------------------------------- |
145
+ | `label` | `string` | - | Text label of the item (used for typeahead). |
146
+ | `disabled` | `boolean` | `false` | Disable item interaction. |
147
+ | `icon` | `React.ReactNode` | - | Icon element displayed before label. |
148
+ | `raw` | `boolean` | `false` | Render custom content (bypasses built-in button). |
149
+ | `ignoreClick` | `boolean` | `false` | Prevent auto menu close on click. |
150
+ | `selected` | `boolean` | `false` | Visually indicate selected state (shows check icon). |
151
+
152
+ ### MenuSeparator
153
+
154
+ Simple visual separator between items.
155
+
156
+ ### MenuGroupLabel
157
+
158
+ Optional label element to group logical sets; pass standard `div` attributes.
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { Menu as _ } from "./components/Menu/Menu.js";
2
2
  import { MenuGroupLabel as n, MenuItem as t, MenuSeparator as u } from "./components/Menu/MenuItem.js";
3
3
  /*!
4
- @versini/ui-menu v4.0.10
4
+ @versini/ui-menu v4.0.12
5
5
  © 2025 gizmette.com
6
6
  */
7
7
  try {
8
8
  window.__VERSINI_UI_MENU__ || (window.__VERSINI_UI_MENU__ = {
9
- version: "4.0.10",
10
- buildTime: "08/23/2025 09:09 AM EDT",
9
+ version: "4.0.12",
10
+ buildTime: "08/23/2025 12:22 PM EDT",
11
11
  homepage: "https://github.com/aversini/ui-components",
12
12
  license: "MIT"
13
13
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versini/ui-menu",
3
- "version": "4.0.10",
3
+ "version": "4.0.12",
4
4
  "license": "MIT",
5
5
  "author": "Arno Versini",
6
6
  "publishConfig": {
@@ -54,5 +54,5 @@
54
54
  "sideEffects": [
55
55
  "**/*.css"
56
56
  ],
57
- "gitHead": "7bbfa99a4441ef5b0828a37d190f694e199b663d"
57
+ "gitHead": "d568e20474c6c87f836c4cb6548f2cc0143a353c"
58
58
  }