@octane-xplat/context-menu 0.18.0 → 0.20.0

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 (38) hide show
  1. package/README.md +2 -124
  2. package/package.json +92 -86
  3. package/src/AppKitContextMenu.macos.css +1 -0
  4. package/src/AppKitContextMenu.macos.tsrx +41 -21
  5. package/src/AppKitContextMenu.tsrx +2 -0
  6. package/src/ContextMenu.tsrx +2 -0
  7. package/src/ContextMenu.web.tsrx +168 -149
  8. package/src/MaterialContextMenu.android.tsrx +128 -101
  9. package/src/MaterialContextMenu.tsrx +2 -0
  10. package/src/SwiftUIContextMenu.ios.tsrx +104 -84
  11. package/src/SwiftUIContextMenu.tsrx +2 -0
  12. package/src/android/index.ts +3 -3
  13. package/src/android/types.ts +29 -18
  14. package/src/context-menu-owner.macos.ts +213 -0
  15. package/src/ios/types.ts +28 -19
  16. package/src/macos/types.ts +27 -18
  17. package/src/web/types.ts +29 -14
  18. package/types/generated/.tsrx-typegen-manifest.json +19 -0
  19. package/types/generated/AppKitContextMenu.macos.d.ts +8 -0
  20. package/types/generated/ContextMenu.web.d.ts +7 -0
  21. package/types/generated/MaterialContextMenu.android.d.ts +16 -0
  22. package/types/generated/SwiftUIContextMenu.ios.d.ts +17 -0
  23. package/types/generated/android/index.d.ts +2 -0
  24. package/types/generated/android/types.d.ts +35 -0
  25. package/types/generated/context-menu-owner.macos.d.ts +16 -0
  26. package/types/generated/index.d.ts +1 -0
  27. package/types/generated/ios/index.d.ts +2 -0
  28. package/types/generated/ios/types.d.ts +33 -0
  29. package/types/generated/macos/index.d.ts +2 -0
  30. package/types/generated/macos/types.d.ts +32 -0
  31. package/types/generated/web/index.d.ts +2 -0
  32. package/types/generated/web/types.d.ts +34 -0
  33. package/LICENSE +0 -21
  34. package/types/android/index.d.ts +0 -22
  35. package/types/index.d.ts +0 -1
  36. package/types/ios/index.d.ts +0 -20
  37. package/types/macos/index.d.ts +0 -19
  38. package/types/web/index.d.ts +0 -22
@@ -0,0 +1,19 @@
1
+ {
2
+ "version": 1,
3
+ "files": [
4
+ "AppKitContextMenu.macos.d.ts",
5
+ "ContextMenu.web.d.ts",
6
+ "MaterialContextMenu.android.d.ts",
7
+ "SwiftUIContextMenu.ios.d.ts",
8
+ "android/index.d.ts",
9
+ "android/types.d.ts",
10
+ "context-menu-owner.macos.d.ts",
11
+ "index.d.ts",
12
+ "ios/index.d.ts",
13
+ "ios/types.d.ts",
14
+ "macos/index.d.ts",
15
+ "macos/types.d.ts",
16
+ "web/index.d.ts",
17
+ "web/types.d.ts"
18
+ ]
19
+ }
@@ -0,0 +1,8 @@
1
+ /** @jsxImportSource @octane-xplat/jsx */
2
+
3
+ import type { AppKitContextMenuProps } from './macos/types.js';
4
+ /** macOS context menu — the trigger renders inline as this element's
5
+ * children and a real NSMenu is attached to the backing NSView's `menu`,
6
+ * so AppKit drives right-click activation and disabled items. Items are
7
+ * serialized data; selection reports through `onItemSelected`. */
8
+ export declare function AppKitContextMenu(props: AppKitContextMenuProps): unknown;
@@ -0,0 +1,7 @@
1
+ /** @jsxImportSource @octane-xplat/jsx/dom */
2
+ import type { JSX } from 'octane/jsx-runtime';
3
+ import type { ContextMenuProps } from './web/types.js';
4
+ /** Web context menu: the trigger subtree renders inline; right-click (or
5
+ * long-press via the `activation` prop's 'singlePress' = click) opens an
6
+ * in-page menu at the pointer. */
7
+ export declare function ContextMenu(props: ContextMenuProps): JSX.Element;
@@ -0,0 +1,16 @@
1
+ import type { Attributes } from '@octane-xplat/jsx/intrinsics';
2
+ import type { MaterialContextMenuProps } from './android/types.js';
3
+ declare module '@octane-xplat/jsx/intrinsics' {
4
+ interface NativeElements<TElement> {
5
+ xplatandroidcontextmenu: Attributes<TElement, {
6
+ composeId?: string;
7
+ data?: Record<string, unknown>;
8
+ onComposeEvent?: (event: {
9
+ data?: unknown;
10
+ }) => void;
11
+ }>;
12
+ }
13
+ }
14
+ /** Renders a Material 3 DropdownMenu anchored to a NativeScript-hosted
15
+ * trigger subtree portaled from the declaring Octane tree. */
16
+ export declare function MaterialContextMenu(props: MaterialContextMenuProps): unknown;
@@ -0,0 +1,17 @@
1
+ import type { Attributes } from '@octane-xplat/jsx/intrinsics';
2
+ import type { SwiftUIContextMenuProps } from './ios/types.js';
3
+ declare module '@octane-xplat/jsx/intrinsics' {
4
+ interface NativeElements<TElement> {
5
+ xplatioscontextmenu: Attributes<TElement, {
6
+ swiftId?: string;
7
+ data?: Record<string, unknown>;
8
+ onSwiftUIEvent?: (event: {
9
+ data?: unknown;
10
+ }) => void;
11
+ }>;
12
+ }
13
+ }
14
+ /** Renders a SwiftUI .contextMenu whose trigger and optional preview portal
15
+ * from the declaring Octane tree into NativeScript hosts. Menu items arrive
16
+ * as serialized data. */
17
+ export declare function SwiftUIContextMenu(props: SwiftUIContextMenuProps): unknown;
@@ -0,0 +1,2 @@
1
+ export { MaterialContextMenu } from '../MaterialContextMenu.android.js';
2
+ export type { MaterialContextMenuActivation, MaterialContextMenuItem, MaterialContextMenuProps, } from './types.js';
@@ -0,0 +1,35 @@
1
+ /** How the menu opens on Android. */
2
+ export type MaterialContextMenuActivation = 'longPress' | 'singlePress';
3
+ /** One row of serialized menu content carried over the bridge. */
4
+ export interface MaterialContextMenuItem {
5
+ /** Stable id reported to `onItemSelected`. */
6
+ id: string;
7
+ /** Item display text. */
8
+ title: string;
9
+ /** Marks the action destructive (red styling where supported). */
10
+ destructive?: boolean;
11
+ /** Greys the item; not selectable. */
12
+ disabled?: boolean;
13
+ /** Render a divider before this item. */
14
+ divider?: boolean;
15
+ }
16
+ /** Android context-menu props. */
17
+ export interface MaterialContextMenuProps {
18
+ /** Element id passed through to the host element. */
19
+ id?: string;
20
+ /** Class list applied to the element. */
21
+ className?: any;
22
+ /** Inline style (string CSS or object). */
23
+ style?: any;
24
+ /** Activation gesture. @default 'longPress' */
25
+ activation?: MaterialContextMenuActivation;
26
+ /** Menu entries in display order. */
27
+ items?: readonly MaterialContextMenuItem[];
28
+ /** Render fn producing the trigger subtree — portaled from the declaring
29
+ * Octane tree into the menu's AndroidView anchor. */
30
+ trigger: () => any;
31
+ /** Fires with the selected item id. */
32
+ onItemSelected?: (id: string) => void;
33
+ /** Spoken name for assistive tech. */
34
+ accessibilityLabel?: string;
35
+ }
@@ -0,0 +1,16 @@
1
+ import type { AppKitContextMenuItem, AppKitContextMenuProps } from './macos/types.js';
2
+ export type ContextMenuAttach = (view: object, options: {
3
+ items: readonly AppKitContextMenuItem[];
4
+ }, onSelect: (id: string | undefined) => void) => (() => void) | null;
5
+ export type ContextMenuStatus = 'ready' | 'empty' | 'invalid' | 'unavailable';
6
+ /** Current native menu session; callback-only renders preserve its tracking menu. */
7
+ export declare function createContextMenuOwner(deps: {
8
+ props(): AppKitContextMenuProps;
9
+ attach(): ContextMenuAttach | undefined;
10
+ status?(status: ContextMenuStatus): void;
11
+ }): {
12
+ update: () => void;
13
+ bind(next: object | null): void;
14
+ dispose(): void;
15
+ getStatus: () => ContextMenuStatus;
16
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export { SwiftUIContextMenu } from '../SwiftUIContextMenu.ios.js';
2
+ export type { SwiftUIContextMenuItem, SwiftUIContextMenuProps } from './types.js';
@@ -0,0 +1,33 @@
1
+ /** One row of serialized menu content carried over the bridge. */
2
+ export interface SwiftUIContextMenuItem {
3
+ /** Stable id reported to `onItemSelected`. */
4
+ id: string;
5
+ /** Item display text. */
6
+ title: string;
7
+ /** Renders the item with .destructive role. */
8
+ destructive?: boolean;
9
+ /** Greys the item; not selectable. */
10
+ disabled?: boolean;
11
+ /** Render a divider before this item. */
12
+ divider?: boolean;
13
+ }
14
+ /** iOS context-menu props (SwiftUI contextMenu). */
15
+ export interface SwiftUIContextMenuProps {
16
+ /** Element id passed through to the host element. */
17
+ id?: string;
18
+ /** Class list applied to the element. */
19
+ className?: any;
20
+ /** Inline style (string CSS or object). */
21
+ style?: any;
22
+ /** Menu entries in display order. */
23
+ items?: readonly SwiftUIContextMenuItem[];
24
+ /** Render fn producing the activation element — hosted inside the
25
+ * SwiftUI tree via the plugin's NativeScriptView-by-id factory. */
26
+ trigger: () => any;
27
+ /** Optional preview shown while the menu opens (iOS 16+). */
28
+ preview?: () => any;
29
+ /** Fires with the selected item id. */
30
+ onItemSelected?: (id: string) => void;
31
+ /** Spoken name for assistive tech. */
32
+ accessibilityLabel?: string;
33
+ }
@@ -0,0 +1,2 @@
1
+ export { AppKitContextMenu } from '../AppKitContextMenu.macos.js';
2
+ export type { AppKitContextMenuItem, AppKitContextMenuProps } from './types.js';
@@ -0,0 +1,32 @@
1
+ /** One row of serialized menu content carried over the bridge. */
2
+ export interface AppKitContextMenuItem {
3
+ /** Stable id reported to `onItemSelected`; unique within this menu. */
4
+ id: string;
5
+ /** Item display text. */
6
+ title: string;
7
+ /** No AppKit destructive role — kept in the contract for parity; the
8
+ * item renders as a normal menu row. */
9
+ destructive?: boolean;
10
+ /** Greys the item; not selectable. */
11
+ disabled?: boolean;
12
+ /** Render a divider before this item. */
13
+ divider?: boolean;
14
+ }
15
+ /** macOS context-menu props (NSMenu). */
16
+ export interface AppKitContextMenuProps {
17
+ /** Native view identifier. Changing it retires this record's menu session. */
18
+ id?: string;
19
+ /** Class list applied to the element. */
20
+ className?: any;
21
+ /** Inline style (string CSS or object). */
22
+ style?: any;
23
+ /** Menu entries in display order. */
24
+ items?: readonly AppKitContextMenuItem[];
25
+ /** Render fn producing the trigger element — rendered inline; the NSMenu
26
+ * attaches to the host's backing NSView. */
27
+ trigger: () => any;
28
+ /** Current enabled item selections; retired/replaced menu actions are ignored. */
29
+ onItemSelected?: (id: string) => void;
30
+ /** Spoken name for assistive tech. */
31
+ accessibilityLabel?: string;
32
+ }
@@ -0,0 +1,2 @@
1
+ export { ContextMenu } from '../ContextMenu.web.js';
2
+ export type { ContextMenuActivation, ContextMenuItem, ContextMenuProps } from './types.js';
@@ -0,0 +1,34 @@
1
+ /** How the menu opens (right-click/long-press variants). */
2
+ export type ContextMenuActivation = 'longPress' | 'singlePress';
3
+ /** One menu entry or separator. */
4
+ export interface ContextMenuItem {
5
+ /** Element id passed through to the host element. */
6
+ id: string;
7
+ /** Item display text. */
8
+ title: string;
9
+ /** Marks the action destructive (red styling where supported). */
10
+ destructive?: boolean;
11
+ /** Greys the item; not selectable. */
12
+ disabled?: boolean;
13
+ /** Render as a separator instead of an item. */
14
+ divider?: boolean;
15
+ }
16
+ /** Web context-menu props (composed web menu). */
17
+ export interface ContextMenuProps {
18
+ /** Element id passed through to the host element. */
19
+ id?: string;
20
+ /** Class list applied to the element. */
21
+ className?: any;
22
+ /** Inline style (string CSS or object). */
23
+ style?: any;
24
+ /** 'longPress' maps to right-click (contextmenu); 'singlePress' to click. */
25
+ activation?: ContextMenuActivation;
26
+ /** Menu entries in display order. */
27
+ items?: readonly ContextMenuItem[];
28
+ /** Content that hosts the context menu (long-press/right-click). */
29
+ trigger: () => any;
30
+ /** Fires with the selected item id. */
31
+ onItemSelected?: (id: string) => void;
32
+ /** Spoken name for assistive tech. */
33
+ accessibilityLabel?: string;
34
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2026 Alec Larson
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
@@ -1,22 +0,0 @@
1
- export type MaterialContextMenuActivation = 'longPress' | 'singlePress'
2
-
3
- export interface MaterialContextMenuItem {
4
- id: string
5
- title: string
6
- destructive?: boolean
7
- disabled?: boolean
8
- divider?: boolean
9
- }
10
-
11
- export interface MaterialContextMenuProps {
12
- id?: string
13
- className?: any
14
- style?: any
15
- activation?: MaterialContextMenuActivation
16
- items?: readonly MaterialContextMenuItem[]
17
- trigger: () => any
18
- onItemSelected?: (id: string) => void
19
- accessibilityLabel?: string
20
- }
21
-
22
- export declare function MaterialContextMenu(props: MaterialContextMenuProps): unknown
package/types/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export {}
@@ -1,20 +0,0 @@
1
- export interface SwiftUIContextMenuItem {
2
- id: string
3
- title: string
4
- destructive?: boolean
5
- disabled?: boolean
6
- divider?: boolean
7
- }
8
-
9
- export interface SwiftUIContextMenuProps {
10
- id?: string
11
- className?: any
12
- style?: any
13
- items?: readonly SwiftUIContextMenuItem[]
14
- trigger: () => any
15
- preview?: () => any
16
- onItemSelected?: (id: string) => void
17
- accessibilityLabel?: string
18
- }
19
-
20
- export declare function SwiftUIContextMenu(props: SwiftUIContextMenuProps): unknown
@@ -1,19 +0,0 @@
1
- export interface AppKitContextMenuItem {
2
- id: string
3
- title: string
4
- destructive?: boolean
5
- disabled?: boolean
6
- divider?: boolean
7
- }
8
-
9
- export interface AppKitContextMenuProps {
10
- id?: string
11
- className?: any
12
- style?: any
13
- items?: readonly AppKitContextMenuItem[]
14
- trigger: () => any
15
- onItemSelected?: (id: string) => void
16
- accessibilityLabel?: string
17
- }
18
-
19
- export declare function AppKitContextMenu(props: AppKitContextMenuProps): unknown
@@ -1,22 +0,0 @@
1
- export type ContextMenuActivation = 'longPress' | 'singlePress'
2
-
3
- export interface ContextMenuItem {
4
- id: string
5
- title: string
6
- destructive?: boolean
7
- disabled?: boolean
8
- divider?: boolean
9
- }
10
-
11
- export interface ContextMenuProps {
12
- id?: string
13
- className?: any
14
- style?: any
15
- activation?: ContextMenuActivation
16
- items?: readonly ContextMenuItem[]
17
- trigger: () => any
18
- onItemSelected?: (id: string) => void
19
- accessibilityLabel?: string
20
- }
21
-
22
- export declare function ContextMenu(props: ContextMenuProps): unknown