react-native-platform-components 0.5.5 → 0.6.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.
@@ -0,0 +1,141 @@
1
+ // ContextMenuNativeComponent.ts
2
+ import type { CodegenTypes, HostComponent, ViewProps } from 'react-native';
3
+ import { codegenNativeComponent } from 'react-native';
4
+
5
+ /**
6
+ * Attributes for a context menu action.
7
+ */
8
+ export type ContextMenuActionAttributes = Readonly<{
9
+ /** Whether the action is destructive (red styling) */
10
+ destructive?: string; // 'true' | 'false'
11
+ /** Whether the action is disabled (grayed out) */
12
+ disabled?: string; // 'true' | 'false'
13
+ /** Whether the action is hidden */
14
+ hidden?: string; // 'true' | 'false'
15
+ }>;
16
+
17
+ /**
18
+ * A leaf subaction (no further nesting to avoid codegen recursion issues).
19
+ */
20
+ export type ContextMenuSubaction = Readonly<{
21
+ /** Unique identifier returned in callbacks */
22
+ id: string;
23
+ /** Display title */
24
+ title: string;
25
+ /** Secondary text (iOS only) */
26
+ subtitle?: string;
27
+ /** Icon name (SF Symbol on iOS, drawable resource on Android) */
28
+ image?: string;
29
+ /** Tint color for the icon (hex string, e.g., "#FF0000") */
30
+ imageColor?: string;
31
+ /** Action attributes */
32
+ attributes?: ContextMenuActionAttributes;
33
+ /** Checkmark state: 'off' | 'on' | 'mixed' */
34
+ state?: string;
35
+ }>;
36
+
37
+ /**
38
+ * A single action in the context menu.
39
+ * Actions can be nested one level via `subactions` for submenus.
40
+ */
41
+ export type ContextMenuAction = Readonly<{
42
+ /** Unique identifier returned in callbacks */
43
+ id: string;
44
+ /** Display title */
45
+ title: string;
46
+ /** Secondary text (iOS only) */
47
+ subtitle?: string;
48
+ /** Icon name (SF Symbol on iOS, drawable resource on Android) */
49
+ image?: string;
50
+ /** Tint color for the icon (hex string, e.g., "#FF0000") */
51
+ imageColor?: string;
52
+ /** Action attributes */
53
+ attributes?: ContextMenuActionAttributes;
54
+ /** Checkmark state: 'off' | 'on' | 'mixed' */
55
+ state?: string;
56
+ /** Nested actions for submenu (one level deep) */
57
+ subactions?: ReadonlyArray<ContextMenuSubaction>;
58
+ }>;
59
+
60
+ /**
61
+ * Event emitted when an action is pressed.
62
+ */
63
+ export type ContextMenuPressActionEvent = Readonly<{
64
+ /** The action's unique identifier */
65
+ actionId: string;
66
+ /** The action's title */
67
+ actionTitle: string;
68
+ }>;
69
+
70
+ /** Interactivity state (no booleans for codegen). */
71
+ export type ContextMenuInteractivity = 'enabled' | 'disabled';
72
+
73
+ /** Trigger mode for opening the menu. */
74
+ export type ContextMenuTrigger = 'longPress' | 'tap';
75
+
76
+ /**
77
+ * iOS-specific configuration.
78
+ */
79
+ export type IOSProps = Readonly<{
80
+ /** Enable preview when long-pressing */
81
+ enablePreview?: string; // 'true' | 'false'
82
+ }>;
83
+
84
+ /**
85
+ * Android-specific configuration.
86
+ */
87
+ export type AndroidProps = Readonly<{
88
+ /** Anchor position for the popup menu */
89
+ anchorPosition?: string; // 'left' | 'right'
90
+ /**
91
+ * Programmatic visibility control (Android only).
92
+ * 'open' to show the menu, 'closed' to hide it.
93
+ */
94
+ visible?: string; // 'open' | 'closed'
95
+ }>;
96
+
97
+ export interface ContextMenuProps extends ViewProps {
98
+ /**
99
+ * Menu title (shown as header on iOS).
100
+ */
101
+ title?: string;
102
+
103
+ /**
104
+ * Menu actions.
105
+ */
106
+ actions: ReadonlyArray<ContextMenuAction>;
107
+
108
+ /**
109
+ * Enabled / disabled state.
110
+ */
111
+ interactivity?: string; // ContextMenuInteractivity
112
+
113
+ /**
114
+ * How the menu is triggered:
115
+ * - 'longPress' (default): Long-press opens the menu
116
+ * - 'tap': Single tap opens the menu
117
+ */
118
+ trigger?: string; // ContextMenuTrigger
119
+
120
+ /**
121
+ * Fired when user presses an action.
122
+ */
123
+ onPressAction?: CodegenTypes.BubblingEventHandler<ContextMenuPressActionEvent>;
124
+
125
+ /**
126
+ * Fired when menu opens.
127
+ */
128
+ onMenuOpen?: CodegenTypes.BubblingEventHandler<Readonly<{}>>;
129
+
130
+ /**
131
+ * Fired when menu closes.
132
+ */
133
+ onMenuClose?: CodegenTypes.BubblingEventHandler<Readonly<{}>>;
134
+
135
+ ios?: IOSProps;
136
+ android?: AndroidProps;
137
+ }
138
+
139
+ export default codegenNativeComponent<ContextMenuProps>(
140
+ 'PCContextMenu'
141
+ ) as HostComponent<ContextMenuProps>;
package/src/index.tsx CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './DatePicker';
2
2
  export * from './SelectionMenu';
3
+ export * from './ContextMenu';
3
4
  export * from './sharedTypes';