jattac.libs.web.overflow-menu 0.0.32 → 0.0.33
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/dist/Data/IOverflowMenuItem.d.ts +13 -3
- package/dist/UI/Animations.d.ts +4 -0
- package/dist/UI/DefaultIcon.d.ts +3 -0
- package/dist/UI/MenuRow.d.ts +10 -0
- package/dist/Utils/Evaluate.d.ts +10 -0
- package/dist/index.es.js +1 -1
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/docs/api.md +17 -10
- package/docs/breaking-changes.md +39 -2
- package/docs/development.md +11 -6
- package/docs/examples.md +67 -1
- package/docs/features.md +18 -3
- package/package.json +1 -1
package/docs/api.md
CHANGED
|
@@ -4,7 +4,7 @@ This document provides exhaustive technical specifications for the Jattac Overfl
|
|
|
4
4
|
|
|
5
5
|
### Table of Contents
|
|
6
6
|
1. [OverflowMenu Component](#overflowmenu-component)
|
|
7
|
-
2. [IOverflowMenuItem
|
|
7
|
+
2. [IOverflowMenuItem Type](#ioverflowmenuitem-type)
|
|
8
8
|
|
|
9
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
10
|
|
|
@@ -21,19 +21,26 @@ The primary component for rendering the overflow menu.
|
|
|
21
21
|
| `className` | `string` | No | `''` | A custom CSS class to apply to the trigger button for styling. |
|
|
22
22
|
| `portal` | `HTMLElement` | No | `null` | A reference to a DOM element to render the menu content into using a React Portal. |
|
|
23
23
|
|
|
24
|
-
### IOverflowMenuItem
|
|
24
|
+
### IOverflowMenuItem Type
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
`IOverflowMenuItem` is a discriminated union that enforces correct property usage for different menu item roles.
|
|
27
27
|
|
|
28
28
|
| Property | Type | Required | Default | Description |
|
|
29
29
|
| :--- | :--- | :--- | :--- | :--- |
|
|
30
|
-
| `content` | `React.ReactNode` | Yes | - | The visual content
|
|
31
|
-
| `onClick` | `() => void` |
|
|
32
|
-
| `children` | `IOverflowMenuItem[]` |
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
| `content` | `React.ReactNode` | Yes | - | The visual content for the menu item. |
|
|
31
|
+
| `onClick` | `() => void` | **See Note** | - | Callback executed when the item is selected. |
|
|
32
|
+
| `children` | `IOverflowMenuItem[]` | **See Note** | - | Optional child items to create a nested submenu. |
|
|
33
|
+
| `visible` | `boolean \| (() => boolean) \| (() => Promise<boolean>)` | No | `true` | Controls the visibility of the item. Supports booleans, sync, and async functions. |
|
|
34
|
+
| `enabled` | `boolean \| (() => boolean) \| (() => Promise<boolean>)` | No | `true` | Controls whether the item is interactive. Supports booleans, sync, and async functions. |
|
|
35
|
+
|
|
36
|
+
#### Notes on Union Variants
|
|
37
|
+
- **`ActionItem`:** Required `onClick`. Does not accept `children`.
|
|
38
|
+
- **`SubmenuItem`:** Required `children` (minimum 1 item). `onClick` is optional and usually omitted.
|
|
39
|
+
|
|
40
|
+
#### Notes on Visibility and Enabled State
|
|
41
|
+
- If `visible` resolves to `false`, the item will not be rendered at all.
|
|
42
|
+
- If `enabled` resolves to `false`, the item is rendered as disabled and `onClick` will not be triggered.
|
|
43
|
+
- Async functions are evaluated once when the item is mounted or when their reference changes.
|
|
37
44
|
|
|
38
45
|
---
|
|
39
46
|
|
package/docs/breaking-changes.md
CHANGED
|
@@ -3,13 +3,50 @@
|
|
|
3
3
|
This document provides information about major version changes and breaking changes to the Jattac Overflow Menu.
|
|
4
4
|
|
|
5
5
|
### Table of Contents
|
|
6
|
-
1. [Version 0.0.
|
|
6
|
+
1. [Version 0.0.32](#version-0-0-32)
|
|
7
|
+
2. [Version 0.0.30](#version-0-0-30)
|
|
7
8
|
|
|
8
9
|
[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
|
|
|
10
11
|
---
|
|
11
12
|
|
|
12
|
-
### Version 0.0.
|
|
13
|
+
### Version 0.0.32
|
|
14
|
+
|
|
15
|
+
Version 0.0.32 introduces significant API and architectural enhancements to improve type safety and maintainability.
|
|
16
|
+
|
|
17
|
+
**Breaking Change: IOverflowMenuItem Union**
|
|
18
|
+
`IOverflowMenuItem` is now a discriminated union. This change enforces that `onClick` is required for action items (items without `children`).
|
|
19
|
+
|
|
20
|
+
**Before:**
|
|
21
|
+
```tsx
|
|
22
|
+
const items: IOverflowMenuItem[] = [
|
|
23
|
+
{ content: 'Delete' }, // Invalid if children are absent
|
|
24
|
+
];
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**After:**
|
|
28
|
+
```tsx
|
|
29
|
+
const items: IOverflowMenuItem[] = [
|
|
30
|
+
{ content: 'Delete', onClick: () => {} }, // Now correctly required
|
|
31
|
+
];
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Feature: Conditional Visibility & Enabled State**
|
|
35
|
+
Added `visible` and `enabled` properties supporting boolean, synchronous, and asynchronous values.
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
const items: IOverflowMenuItem[] = [
|
|
39
|
+
{
|
|
40
|
+
content: 'Export',
|
|
41
|
+
enabled: async () => await checkExportStatus(),
|
|
42
|
+
onClick: () => {},
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
### Version 0.0.30
|
|
13
50
|
|
|
14
51
|
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
52
|
|
package/docs/development.md
CHANGED
|
@@ -21,12 +21,17 @@ To get started with local development, ensure you have Node.js and npm installed
|
|
|
21
21
|
|
|
22
22
|
### Internal Architecture
|
|
23
23
|
|
|
24
|
-
The project is structured to maintain a clean separation
|
|
25
|
-
- `src/Data`: Contains
|
|
26
|
-
- `src/Styles`: Contains CSS Modules for
|
|
27
|
-
- `src/
|
|
28
|
-
- `
|
|
29
|
-
- `
|
|
24
|
+
The project is structured to maintain a clean separation of concerns:
|
|
25
|
+
- `src/Data`: Contains core types, including the `IOverflowMenuItem` discriminated union.
|
|
26
|
+
- `src/Styles`: Contains CSS Modules for encapsulated styling.
|
|
27
|
+
- `src/Utils`: Includes helper utilities, such as `Evaluate.ts` for handling sync/async properties.
|
|
28
|
+
- `src/UI`: Contains modular components:
|
|
29
|
+
- `Animations.ts`: Centralized Framer Motion variants.
|
|
30
|
+
- `DefaultIcon.tsx`: The default animated trigger icon.
|
|
31
|
+
- `MenuRow.tsx`: Logic for individual menu rows and submenus.
|
|
32
|
+
- `OverflowMenu.tsx`: The root component and coordinator.
|
|
33
|
+
- `test-app/`: A standard React environment for manual testing.
|
|
34
|
+
- `test-app2/`: A Next.js (App Router) environment for cross-framework verification.
|
|
30
35
|
|
|
31
36
|
### Available Scripts
|
|
32
37
|
|
package/docs/examples.md
CHANGED
|
@@ -7,7 +7,9 @@ The Jattac Overflow Menu is designed to be highly flexible. This cookbook provid
|
|
|
7
7
|
2. [Custom Trigger Icon](#custom-trigger-icon)
|
|
8
8
|
3. [Rich Content Items](#rich-content-items)
|
|
9
9
|
4. [Multi-Level Child Menus](#multi-level-child-menus)
|
|
10
|
-
5. [
|
|
10
|
+
5. [Conditional Visibility](#conditional-visibility)
|
|
11
|
+
6. [Enabled Toggling](#enabled-toggling)
|
|
12
|
+
7. [Using a Portal for Complex Layouts](#using-a-portal-for-complex-layouts)
|
|
11
13
|
|
|
12
14
|
[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
15
|
|
|
@@ -114,6 +116,70 @@ const MyComponent = () => (
|
|
|
114
116
|
);
|
|
115
117
|
```
|
|
116
118
|
|
|
119
|
+
### Conditional Visibility
|
|
120
|
+
|
|
121
|
+
Control the visibility of menu items using booleans, synchronous functions, or asynchronous functions. This is ideal for role-based access control or state-dependent actions.
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
import React from 'react';
|
|
125
|
+
import OverflowMenu, { IOverflowMenuItem } from 'jattac.libs.web.overflow-menu';
|
|
126
|
+
|
|
127
|
+
const items: IOverflowMenuItem[] = [
|
|
128
|
+
{
|
|
129
|
+
content: 'Admin Panel',
|
|
130
|
+
visible: false, // Statically hidden
|
|
131
|
+
onClick: () => {},
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
content: 'User Settings',
|
|
135
|
+
visible: () => localStorage.getItem('user') !== null, // Synchronous check
|
|
136
|
+
onClick: () => {},
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
content: 'Delete Project',
|
|
140
|
+
visible: async () => {
|
|
141
|
+
const response = await fetch('/api/check-permissions');
|
|
142
|
+
return response.ok; // Asynchronous check
|
|
143
|
+
},
|
|
144
|
+
onClick: () => {},
|
|
145
|
+
},
|
|
146
|
+
];
|
|
147
|
+
|
|
148
|
+
const MyComponent = () => <OverflowMenu items={items} />;
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Enabled Toggling
|
|
152
|
+
|
|
153
|
+
Similar to visibility, you can disable items while keeping them visible. Disabled items are non-interactive and styled appropriately to indicate their state.
|
|
154
|
+
|
|
155
|
+
```tsx
|
|
156
|
+
import React from 'react';
|
|
157
|
+
import OverflowMenu, { IOverflowMenuItem } from 'jattac.libs.web.overflow-menu';
|
|
158
|
+
|
|
159
|
+
const items: IOverflowMenuItem[] = [
|
|
160
|
+
{
|
|
161
|
+
content: 'Quick Save',
|
|
162
|
+
enabled: true,
|
|
163
|
+
onClick: () => {},
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
content: 'Export Data',
|
|
167
|
+
enabled: () => isDataDirty, // Synchronous check
|
|
168
|
+
onClick: () => {},
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
content: 'Finalize Deployment',
|
|
172
|
+
enabled: async () => {
|
|
173
|
+
const status = await getBuildStatus();
|
|
174
|
+
return status === 'ready'; // Asynchronous check
|
|
175
|
+
},
|
|
176
|
+
onClick: () => {},
|
|
177
|
+
},
|
|
178
|
+
];
|
|
179
|
+
|
|
180
|
+
const MyComponent = () => <OverflowMenu items={items} />;
|
|
181
|
+
```
|
|
182
|
+
|
|
117
183
|
### Using a Portal for Complex Layouts
|
|
118
184
|
|
|
119
185
|
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.
|
package/docs/features.md
CHANGED
|
@@ -5,9 +5,11 @@ The Jattac Overflow Menu offers a powerful set of features designed to simplify
|
|
|
5
5
|
### Table of Contents
|
|
6
6
|
1. [Full Accessibility](#full-accessibility)
|
|
7
7
|
2. [Multi-Level Submenus](#multi-level-submenus)
|
|
8
|
-
3. [
|
|
9
|
-
4. [
|
|
10
|
-
5. [
|
|
8
|
+
3. [Conditional Visibility and Enabled Toggling](#conditional-visibility-and-enabled-toggling)
|
|
9
|
+
4. [Advanced Animations](#advanced-animations)
|
|
10
|
+
5. [Atomic & Maintainable Architecture](#atomic-maintainable-architecture)
|
|
11
|
+
6. [Modern Frosted-Glass Aesthetic](#modern-frosted-glass-aesthetic)
|
|
12
|
+
7. [Flexible Trigger Icons](#flexible-trigger-icons)
|
|
11
13
|
|
|
12
14
|
[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
15
|
|
|
@@ -28,10 +30,23 @@ Organize complex sets of actions with ease using recursive submenus. The library
|
|
|
28
30
|
|
|
29
31
|
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
32
|
|
|
33
|
+
### Conditional Visibility and Enabled Toggling
|
|
34
|
+
|
|
35
|
+
Dynamically control whether actions are visible or interactive. These properties support boolean values, synchronous functions, and asynchronous functions (Promises). This allows for complex logic, such as checking permissions from an API or verifying state before enabling an action.
|
|
36
|
+
|
|
37
|
+
For implementation details, refer to the [Conditional Visibility recipe](https://github.com/nyingimaina/jattac.libs.web.overflow-menu/blob/develop/docs/examples.md#conditional-visibility).
|
|
38
|
+
|
|
31
39
|
### Advanced Animations
|
|
32
40
|
|
|
33
41
|
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
42
|
|
|
43
|
+
### Atomic & Maintainable Architecture
|
|
44
|
+
|
|
45
|
+
The library is designed for enterprise-grade maintainability. The core component has been refactored into atomic, single-responsibility modules, including:
|
|
46
|
+
- **`Evaluate` Utility:** Centralized logic for boolean/sync/async property evaluation.
|
|
47
|
+
- **Animation Hub:** Consolidated Framer Motion variants for consistency.
|
|
48
|
+
- **Isolated UI Components:** Modularized `DefaultIcon` and `MenuRow` for easier testing and extension.
|
|
49
|
+
|
|
35
50
|
### Modern Frosted-Glass Aesthetic
|
|
36
51
|
|
|
37
52
|
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.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jattac.libs.web.overflow-menu",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.33",
|
|
4
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",
|