jattac.libs.web.overflow-menu 0.0.30 → 0.0.32

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.
package/docs/api.md ADDED
@@ -0,0 +1,40 @@
1
+ # API Reference: Technical Blueprint
2
+
3
+ This document provides exhaustive technical specifications for the Jattac Overflow Menu component and its associated types.
4
+
5
+ ### Table of Contents
6
+ 1. [OverflowMenu Component](#overflowmenu-component)
7
+ 2. [IOverflowMenuItem Interface](#ioverflowmenuitem-interface)
8
+
9
+ [Previous: Features](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/docs/features.md) | [Next: Configuration](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/docs/configuration.md)
10
+
11
+ ---
12
+
13
+ ### OverflowMenu Component
14
+
15
+ The primary component for rendering the overflow menu.
16
+
17
+ | Prop | Type | Required | Default | Description |
18
+ | :--- | :--- | :--- | :--- | :--- |
19
+ | `items` | `IOverflowMenuItem[]` | Yes | - | An array of objects defining the menu items and their behavior. |
20
+ | `icon` | `React.ReactNode` | No | `<DefaultIcon />` | A custom React node to be used as the menu trigger. |
21
+ | `className` | `string` | No | `''` | A custom CSS class to apply to the trigger button for styling. |
22
+ | `portal` | `HTMLElement` | No | `null` | A reference to a DOM element to render the menu content into using a React Portal. |
23
+
24
+ ### IOverflowMenuItem Interface
25
+
26
+ The interface defining the structure of each item in the `items` array.
27
+
28
+ | Property | Type | Required | Default | Description |
29
+ | :--- | :--- | :--- | :--- | :--- |
30
+ | `content` | `React.ReactNode` | Yes | - | The visual content to be displayed for the menu item. |
31
+ | `onClick` | `() => void` | No | - | A callback function to execute when the menu item is selected. |
32
+ | `children` | `IOverflowMenuItem[]` | No | - | An optional array of child items to create a nested submenu. |
33
+
34
+ #### Notes on Type Behavior
35
+ - If `children` is provided and contains at least one item, the menu item will render as a `SubmenuTrigger` rather than a standard `MenuItem`.
36
+ - When an item has `children`, its `onClick` handler is ignored in favor of opening the submenu.
37
+
38
+ ---
39
+
40
+ [Previous: Features](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/docs/features.md) | [Next: Configuration](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/docs/configuration.md)
@@ -0,0 +1,39 @@
1
+ # Upgrade Path: Breaking Changes
2
+
3
+ This document provides information about major version changes and breaking changes to the Jattac Overflow Menu.
4
+
5
+ ### Table of Contents
6
+ 1. [Version 0.0.30 (Upcoming)](#version-0-0-30-upcoming)
7
+
8
+ [Previous: Development](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/docs/development.md) | [Next: README](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/README.md)
9
+
10
+ ---
11
+
12
+ ### Version 0.0.30 (Upcoming)
13
+
14
+ Version 0.0.30 introduces significant enhancements to the component's internal architecture, including support for multi-level submenus. While the primary API remains consistent, some internal types and styles have changed.
15
+
16
+ **Before: Flat Items Only**
17
+ ```tsx
18
+ const items: IOverflowMenuItem[] = [
19
+ { content: 'Item 1', onClick: () => {} },
20
+ ];
21
+ ```
22
+
23
+ **After: Multi-Level Support**
24
+ ```tsx
25
+ const items: IOverflowMenuItem[] = [
26
+ {
27
+ content: 'Item 1',
28
+ children: [
29
+ { content: 'Child Item', onClick: () => {} },
30
+ ],
31
+ },
32
+ ];
33
+ ```
34
+
35
+ For detailed implementation information, refer to the [Multi-Level Child Menus recipe](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/docs/examples.md#multi-level-child-menus) in the Cookbook.
36
+
37
+ ---
38
+
39
+ [Previous: Development](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/docs/development.md) | [Next: README](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/README.md)
@@ -0,0 +1,48 @@
1
+ # Configuration: The Control Panel
2
+
3
+ The Jattac Overflow Menu is designed to be easily customized. This document outlines the available configuration and styling options.
4
+
5
+ ### Table of Contents
6
+ 1. [Styling and Customization](#styling-and-customization)
7
+ 2. [Advanced Styling with Data Attributes](#advanced-styling-with-data-attributes)
8
+ 3. [Portal Usage and Z-Index](#portal-usage-and-z-index)
9
+
10
+ [Previous: API Reference](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/docs/api.md) | [Next: Development](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/docs/development.md)
11
+
12
+ ---
13
+
14
+ ### Styling and Customization
15
+
16
+ The component uses CSS Modules internally, but its styles can be overridden using standard CSS selectors. The primary classes used are:
17
+ - `.jattac-overflow-menu-content`: The container for the menu items.
18
+ - `.jattac-overflow-menu-item`: Individual menu items.
19
+ - `.jattac-overflow-menu-trigger`: The trigger button for the menu.
20
+
21
+ ### Advanced Styling with Data Attributes
22
+
23
+ The underlying Radix UI components expose data attributes that can be used to target specific states of the menu:
24
+ - `[data-state="open"]`: Applied to the trigger when the menu is visible.
25
+ - `[data-state="closed"]`: Applied to the trigger when the menu is hidden.
26
+ - `[data-highlighted]`: Applied to a menu item when it is being hovered or navigated via keyboard.
27
+
28
+ **Example: Customizing a Highlighted Item**
29
+ ```css
30
+ /* In your application's global CSS file */
31
+ .jattac-overflow-menu-item[data-highlighted] {
32
+ background-color: #f0f0f0;
33
+ color: #333;
34
+ }
35
+ ```
36
+
37
+ ### Portal Usage and Z-Index
38
+
39
+ The `portal` prop is used to render the menu content into a specific DOM element. This is essential for layouts where:
40
+ - A parent container has `overflow: hidden` or `overflow: scroll`.
41
+ - The menu is nested within a complex stacking context (e.g., a modal inside a table).
42
+ - You need to explicitly manage the z-index of the menu content relative to other components in your application.
43
+
44
+ For implementation details, refer to the [Using a Portal recipe](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/docs/examples.md#using-a-portal-for-complex-layouts).
45
+
46
+ ---
47
+
48
+ [Previous: API Reference](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/docs/api.md) | [Next: Development](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/docs/development.md)
@@ -0,0 +1,47 @@
1
+ # Development Guide: Contributing to Jattac Overflow Menu
2
+
3
+ Thank you for your interest in contributing to the Jattac Overflow Menu. This document provides instructions for setting up your local environment and understanding the project's internal structure.
4
+
5
+ ### Table of Contents
6
+ 1. [Local Setup](#local-setup)
7
+ 2. [Internal Architecture](#internal-architecture)
8
+ 3. [Available Scripts](#available-scripts)
9
+ 4. [Testing and Quality Assurance](#testing-and-quality-assurance)
10
+
11
+ [Previous: Configuration](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/docs/configuration.md) | [Next: Breaking Changes](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/docs/breaking-changes.md)
12
+
13
+ ---
14
+
15
+ ### Local Setup
16
+
17
+ To get started with local development, ensure you have Node.js and npm installed.
18
+ 1. Clone the repository.
19
+ 2. Install dependencies by running `npm install`.
20
+ 3. To start the development build in watch mode, run `npm run watch`.
21
+
22
+ ### Internal Architecture
23
+
24
+ The project is structured to maintain a clean separation between data, styles, and UI components:
25
+ - `src/Data`: Contains TypeScript interfaces and types, such as `IOverflowMenuItem`.
26
+ - `src/Styles`: Contains CSS Modules for component styling.
27
+ - `src/UI`: Contains the core React components, including `OverflowMenu.tsx`.
28
+ - `test-app/`: A standalone React environment for manual testing and component verification.
29
+ - `test-app2/`: A Next.js (App Router) environment for verifying compatibility with modern frameworks.
30
+
31
+ ### Available Scripts
32
+
33
+ - `npm run build`: Compiles the library using Rollup into ESM and CommonJS formats.
34
+ - `npm run watch`: Compiles the library in watch mode for a faster development cycle.
35
+ - `npm run lint`: Executes ESLint to ensure code quality and style consistency.
36
+ - `npm run size`: Analyzes the bundle size to maintain a lightweight footprint.
37
+
38
+ ### Testing and Quality Assurance
39
+
40
+ Before submitting a pull request, please ensure that:
41
+ - The project builds without errors (`npm run build`).
42
+ - No linting issues are present (`npm run lint`).
43
+ - The component is manually verified in both `test-app` and `test-app2` to ensure cross-framework compatibility.
44
+
45
+ ---
46
+
47
+ [Previous: Configuration](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/docs/configuration.md) | [Next: Breaking Changes](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/docs/breaking-changes.md)
@@ -0,0 +1,147 @@
1
+ # Cookbook: Practical Examples
2
+
3
+ The Jattac Overflow Menu is designed to be highly flexible. This cookbook provides practical, copy-paste recipes for common scenarios, ranging from simple action lists to complex nested menus.
4
+
5
+ ### Table of Contents
6
+ 1. [Simple Action Menu](#simple-action-menu)
7
+ 2. [Custom Trigger Icon](#custom-trigger-icon)
8
+ 3. [Rich Content Items](#rich-content-items)
9
+ 4. [Multi-Level Child Menus](#multi-level-child-menus)
10
+ 5. [Using a Portal for Complex Layouts](#using-a-portal-for-complex-layouts)
11
+
12
+ [Previous: README](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/README.md) | [Next: Features](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/docs/features.md)
13
+
14
+ ---
15
+
16
+ ### Simple Action Menu
17
+
18
+ The most common use case is a flat list of actions. This recipe shows the minimum configuration required to implement a standard overflow menu.
19
+
20
+ ```tsx
21
+ import React from 'react';
22
+ import OverflowMenu, { IOverflowMenuItem } from 'jattac.libs.web.overflow-menu';
23
+
24
+ const items: IOverflowMenuItem[] = [
25
+ { content: 'Edit', onClick: () => console.log('Edit clicked') },
26
+ { content: 'Delete', onClick: () => console.log('Delete clicked') },
27
+ ];
28
+
29
+ const MyComponent = () => (
30
+ <OverflowMenu items={items} />
31
+ );
32
+ ```
33
+
34
+ ### Custom Trigger Icon
35
+
36
+ You can override the default animated "three dots" icon with any React node. This is useful for integrating with icon libraries like `react-icons` or `lucide-react`.
37
+
38
+ ```tsx
39
+ import React from 'react';
40
+ import { FiSettings } from 'react-icons/fi';
41
+ import OverflowMenu, { IOverflowMenuItem } from 'jattac.libs.web.overflow-menu';
42
+
43
+ const items: IOverflowMenuItem[] = [
44
+ { content: 'Profile', onClick: () => {} },
45
+ { content: 'Security', onClick: () => {} },
46
+ ];
47
+
48
+ const MyComponent = () => (
49
+ <OverflowMenu items={items} icon={<FiSettings size={20} />} />
50
+ );
51
+ ```
52
+
53
+ ### Rich Content Items
54
+
55
+ The `content` property of each menu item can be a complex React node. This allows for items with icons, badges, or specialized typography.
56
+
57
+ ```tsx
58
+ import React from 'react';
59
+ import { FiEdit2, FiTrash2 } from 'react-icons/fi';
60
+ import OverflowMenu, { IOverflowMenuItem } from 'jattac.libs.web.overflow-menu';
61
+
62
+ const items: IOverflowMenuItem[] = [
63
+ {
64
+ content: (
65
+ <div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
66
+ <FiEdit2 /> <span>Edit Entry</span>
67
+ </div>
68
+ ),
69
+ onClick: () => {},
70
+ },
71
+ {
72
+ content: (
73
+ <div style={{ display: 'flex', alignItems: 'center', gap: '8px', color: 'red' }}>
74
+ <FiTrash2 /> <span>Delete Entry</span>
75
+ </div>
76
+ ),
77
+ onClick: () => {},
78
+ },
79
+ ];
80
+
81
+ const MyComponent = () => (
82
+ <OverflowMenu items={items} />
83
+ );
84
+ ```
85
+
86
+ ### Multi-Level Child Menus
87
+
88
+ Support for nested menus is built-in. Simply add a `children` array to any item. The component will recursively render submenus with consistent styling and animations.
89
+
90
+ ```tsx
91
+ import React from 'react';
92
+ import OverflowMenu, { IOverflowMenuItem } from 'jattac.libs.web.overflow-menu';
93
+
94
+ const items: IOverflowMenuItem[] = [
95
+ {
96
+ content: 'Share',
97
+ children: [
98
+ { content: 'Email', onClick: () => {} },
99
+ { content: 'Message', onClick: () => {} },
100
+ {
101
+ content: 'Social Media',
102
+ children: [
103
+ { content: 'Twitter', onClick: () => {} },
104
+ { content: 'Facebook', onClick: () => {} },
105
+ ],
106
+ },
107
+ ],
108
+ },
109
+ { content: 'Download', onClick: () => {} },
110
+ ];
111
+
112
+ const MyComponent = () => (
113
+ <OverflowMenu items={items} />
114
+ );
115
+ ```
116
+
117
+ ### Using a Portal for Complex Layouts
118
+
119
+ When a menu is rendered inside a container with `overflow: hidden` or restricted z-indexing (e.g., a table cell or a modal), use the `portal` prop to render the menu outside the parent's stacking context.
120
+
121
+ ```tsx
122
+ import React, { useRef } from 'react';
123
+ import OverflowMenu, { IOverflowMenuItem } from 'jattac.libs.web.overflow-menu';
124
+
125
+ const App = () => {
126
+ const portalRef = useRef<HTMLDivElement>(null);
127
+
128
+ const items: IOverflowMenuItem[] = [
129
+ { content: 'Action 1', onClick: () => {} },
130
+ ];
131
+
132
+ return (
133
+ <div style={{ position: 'relative' }}>
134
+ <div style={{ overflow: 'hidden', height: '100px' }}>
135
+ <OverflowMenu items={items} portal={portalRef.current} />
136
+ </div>
137
+
138
+ {/* The menu will be rendered here, outside the hidden container */}
139
+ <div ref={portalRef} id="menu-portal" />
140
+ </div>
141
+ );
142
+ };
143
+ ```
144
+
145
+ ---
146
+
147
+ [Previous: README](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/README.md) | [Next: Features](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/docs/features.md)
@@ -0,0 +1,47 @@
1
+ # Showcase: Feature Overview
2
+
3
+ The Jattac Overflow Menu offers a powerful set of features designed to simplify the management of secondary actions while providing a premium user experience.
4
+
5
+ ### Table of Contents
6
+ 1. [Full Accessibility](#full-accessibility)
7
+ 2. [Multi-Level Submenus](#multi-level-submenus)
8
+ 3. [Advanced Animations](#advanced-animations)
9
+ 4. [Modern Frosted-Glass Aesthetic](#modern-frosted-glass-aesthetic)
10
+ 5. [Flexible Trigger Icons](#flexible-trigger-icons)
11
+
12
+ [Previous: Cookbook](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/docs/examples.md) | [Next: API Reference](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/docs/api.md)
13
+
14
+ ---
15
+
16
+ ### Full Accessibility
17
+
18
+ The component is built on top of Radix UI primitives, ensuring that it is fully accessible to all users. It adheres to the WAI-ARIA Menu Button pattern, providing:
19
+ - Full keyboard navigation (arrow keys, Enter, Space, Escape, Tab).
20
+ - Focus management to ensure proper tab order.
21
+ - ARIA attributes that automatically communicate the state of the menu to assistive technologies.
22
+
23
+ For implementation details, refer to the [Simple Action Menu recipe](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/docs/examples.md#simple-action-menu).
24
+
25
+ ### Multi-Level Submenus
26
+
27
+ Organize complex sets of actions with ease using recursive submenus. The library handles the logic for positioning, timing, and keyboard navigation for nested menus, ensuring a smooth experience regardless of depth.
28
+
29
+ For implementation details, refer to the [Multi-Level Child Menus recipe](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/docs/examples.md#multi-level-child-menus).
30
+
31
+ ### Advanced Animations
32
+
33
+ Powered by Framer Motion, every interaction feels deliberate and responsive. The trigger features spring-based hover effects, and the menu items use staggered entry animations to guide the user's eye.
34
+
35
+ ### Modern Frosted-Glass Aesthetic
36
+
37
+ Out of the box, the component features a "glassmorphism" design, including backdrop blur and a subtle translucent background. This allows it to blend seamlessly into modern, high-quality user interfaces without extensive customization.
38
+
39
+ ### Flexible Trigger Icons
40
+
41
+ The default "three dots" icon is animated and interactive. However, the component supports any React node as a custom trigger, making it easy to adapt to your application's specific iconography.
42
+
43
+ For implementation details, refer to the [Custom Trigger Icon recipe](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/docs/examples.md#custom-trigger-icon).
44
+
45
+ ---
46
+
47
+ [Previous: Cookbook](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/docs/examples.md) | [Next: API Reference](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/docs/api.md)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jattac.libs.web.overflow-menu",
3
- "version": "0.0.30",
4
- "description": "A customizable and lightweight React overflow menu component with a modern design.",
3
+ "version": "0.0.32",
4
+ "description": "Enterprise-grade, accessible, and highly customizable React overflow menu component. Built on Radix UI and Framer Motion for premium UX and full WAI-ARIA compliance.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",
7
7
  "types": "dist/index.d.ts",
@@ -16,29 +16,57 @@
16
16
  "require": "./dist/index.css"
17
17
  }
18
18
  },
19
+ "sideEffects": [
20
+ "*.css"
21
+ ],
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/nyingimaina/jattac.libs.web.overflow-menu.git"
25
+ },
26
+ "bugs": {
27
+ "url": "https://github.com/nyingimaina/jattac.libs.web.overflow-menu/issues"
28
+ },
29
+ "homepage": "https://github.com/nyingimaina/jattac.libs.web.overflow-menu#readme",
30
+ "engines": {
31
+ "node": ">=16.0.0",
32
+ "npm": ">=8.0.0"
33
+ },
19
34
  "files": [
20
- "dist"
35
+ "dist",
36
+ "docs"
21
37
  ],
22
38
  "scripts": {
23
39
  "build": "rollup -c",
24
40
  "watch": "rollup -c -w",
25
41
  "lint": "eslint \"./{src,app}/**/*.{ts,tsx}\"",
42
+ "lint:fix": "eslint \"./{src,app}/**/*.{ts,tsx}\" --fix",
43
+ "format": "prettier --write \"src/**/*.{ts,tsx,css,md}\"",
44
+ "type-check": "tsc --noEmit",
26
45
  "size": "size-limit",
27
- "prepare": "npm run build"
46
+ "prepare": "npm run build",
47
+ "prepublishOnly": "npm run lint && npm run type-check && npm run build"
28
48
  },
29
49
  "keywords": [
30
50
  "react",
31
51
  "typescript",
32
52
  "menu",
33
53
  "overflow-menu",
34
- "component"
54
+ "dropdown",
55
+ "context-menu",
56
+ "accessible",
57
+ "radix-ui",
58
+ "framer-motion",
59
+ "ui-component",
60
+ "enterprise",
61
+ "nested-menu",
62
+ "submenu"
35
63
  ],
36
64
  "author": "Nyingi Maina",
37
65
  "license": "MIT",
38
66
  "peerDependencies": {
67
+ "framer-motion": ">=11.0.0",
39
68
  "react": ">=18.2.0",
40
- "react-dom": ">=18.2.0",
41
- "framer-motion": ">=11.0.0"
69
+ "react-dom": ">=18.2.0"
42
70
  },
43
71
  "devDependencies": {
44
72
  "@rollup/plugin-commonjs": "^25.0.7",