@idealyst/mcp-server 1.0.86 → 1.0.88
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/ARCHITECTURE.md +313 -0
- package/README.md +292 -104
- package/TYPE-SYSTEM.md +397 -0
- package/dist/index.js +170 -1
- package/examples/components/Accordion.examples.tsx +147 -0
- package/examples/components/ActivityIndicator.examples.tsx +350 -0
- package/examples/components/Alert.examples.tsx +335 -0
- package/examples/components/Avatar.examples.tsx +188 -0
- package/examples/components/Badge.examples.tsx +242 -0
- package/examples/components/Breadcrumb.examples.tsx +303 -0
- package/examples/components/Button.examples.tsx +113 -0
- package/examples/components/Card.examples.tsx +131 -0
- package/examples/components/Checkbox.examples.tsx +195 -0
- package/examples/components/Chip.examples.tsx +87 -0
- package/examples/components/Dialog.examples.tsx +344 -0
- package/examples/components/Divider.examples.tsx +258 -0
- package/examples/components/Icon.examples.tsx +202 -0
- package/examples/components/Input.examples.tsx +205 -0
- package/examples/components/Menu.examples.tsx +321 -0
- package/examples/components/Popover.examples.tsx +439 -0
- package/examples/components/Progress.examples.tsx +340 -0
- package/examples/components/RadioButton.examples.tsx +443 -0
- package/examples/components/Screen.examples.tsx +347 -0
- package/examples/components/Select.examples.tsx +279 -0
- package/examples/components/Skeleton.examples.tsx +278 -0
- package/examples/components/Slider.examples.tsx +249 -0
- package/examples/components/Switch.examples.tsx +94 -0
- package/examples/components/TabBar.examples.tsx +356 -0
- package/examples/components/Text.examples.tsx +177 -0
- package/examples/components/TextArea.examples.tsx +203 -0
- package/examples/components/Tooltip.examples.tsx +318 -0
- package/examples/components/View.examples.tsx +307 -0
- package/package.json +15 -2
- package/scripts/extract-types.ts +71 -0
- package/scripts/type-extractor.ts +286 -0
- package/scripts/validate-examples.ts +142 -0
- package/src/data/components/Icon.ts +1 -1
- package/src/data/components/index.ts +2 -0
- package/src/index.ts +181 -1
- package/src/tools/get-types.ts +169 -0
- package/tsconfig.examples.json +14 -0
- package/dist/data/cli-commands.d.ts +0 -2
- package/dist/data/cli-commands.d.ts.map +0 -1
- package/dist/data/cli-commands.js +0 -100
- package/dist/data/cli-commands.js.map +0 -1
- package/dist/data/components/Accordion.d.ts +0 -15
- package/dist/data/components/Accordion.d.ts.map +0 -1
- package/dist/data/components/Accordion.js +0 -112
- package/dist/data/components/Accordion.js.map +0 -1
- package/dist/data/components/ActivityIndicator.d.ts +0 -15
- package/dist/data/components/ActivityIndicator.d.ts.map +0 -1
- package/dist/data/components/ActivityIndicator.js +0 -82
- package/dist/data/components/ActivityIndicator.js.map +0 -1
- package/dist/data/components/Alert.d.ts +0 -15
- package/dist/data/components/Alert.d.ts.map +0 -1
- package/dist/data/components/Alert.js +0 -132
- package/dist/data/components/Alert.js.map +0 -1
- package/dist/data/components/Avatar.d.ts +0 -15
- package/dist/data/components/Avatar.d.ts.map +0 -1
- package/dist/data/components/Avatar.js +0 -93
- package/dist/data/components/Avatar.js.map +0 -1
- package/dist/data/components/Badge.d.ts +0 -15
- package/dist/data/components/Badge.d.ts.map +0 -1
- package/dist/data/components/Badge.js +0 -64
- package/dist/data/components/Badge.js.map +0 -1
- package/dist/data/components/Breadcrumb.d.ts +0 -15
- package/dist/data/components/Breadcrumb.d.ts.map +0 -1
- package/dist/data/components/Breadcrumb.js +0 -96
- package/dist/data/components/Breadcrumb.js.map +0 -1
- package/dist/data/components/Button.d.ts +0 -15
- package/dist/data/components/Button.d.ts.map +0 -1
- package/dist/data/components/Button.js +0 -87
- package/dist/data/components/Button.js.map +0 -1
- package/dist/data/components/Card.d.ts +0 -15
- package/dist/data/components/Card.d.ts.map +0 -1
- package/dist/data/components/Card.js +0 -67
- package/dist/data/components/Card.js.map +0 -1
- package/dist/data/components/Checkbox.d.ts +0 -15
- package/dist/data/components/Checkbox.d.ts.map +0 -1
- package/dist/data/components/Checkbox.js +0 -118
- package/dist/data/components/Checkbox.js.map +0 -1
- package/dist/data/components/Chip.d.ts +0 -15
- package/dist/data/components/Chip.d.ts.map +0 -1
- package/dist/data/components/Chip.js +0 -76
- package/dist/data/components/Chip.js.map +0 -1
- package/dist/data/components/Dialog.d.ts +0 -15
- package/dist/data/components/Dialog.d.ts.map +0 -1
- package/dist/data/components/Dialog.js +0 -137
- package/dist/data/components/Dialog.js.map +0 -1
- package/dist/data/components/Divider.d.ts +0 -15
- package/dist/data/components/Divider.d.ts.map +0 -1
- package/dist/data/components/Divider.js +0 -71
- package/dist/data/components/Divider.js.map +0 -1
- package/dist/data/components/Icon.d.ts +0 -15
- package/dist/data/components/Icon.d.ts.map +0 -1
- package/dist/data/components/Icon.js +0 -70
- package/dist/data/components/Icon.js.map +0 -1
- package/dist/data/components/Image.d.ts +0 -15
- package/dist/data/components/Image.d.ts.map +0 -1
- package/dist/data/components/Image.js +0 -122
- package/dist/data/components/Image.js.map +0 -1
- package/dist/data/components/Input.d.ts +0 -15
- package/dist/data/components/Input.d.ts.map +0 -1
- package/dist/data/components/Input.js +0 -109
- package/dist/data/components/Input.js.map +0 -1
- package/dist/data/components/List.d.ts +0 -15
- package/dist/data/components/List.d.ts.map +0 -1
- package/dist/data/components/List.js +0 -113
- package/dist/data/components/List.js.map +0 -1
- package/dist/data/components/Menu.d.ts +0 -15
- package/dist/data/components/Menu.d.ts.map +0 -1
- package/dist/data/components/Menu.js +0 -132
- package/dist/data/components/Menu.js.map +0 -1
- package/dist/data/components/Popover.d.ts +0 -15
- package/dist/data/components/Popover.d.ts.map +0 -1
- package/dist/data/components/Popover.js +0 -159
- package/dist/data/components/Popover.js.map +0 -1
- package/dist/data/components/Pressable.d.ts +0 -15
- package/dist/data/components/Pressable.d.ts.map +0 -1
- package/dist/data/components/Pressable.js +0 -125
- package/dist/data/components/Pressable.js.map +0 -1
- package/dist/data/components/Progress.d.ts +0 -15
- package/dist/data/components/Progress.d.ts.map +0 -1
- package/dist/data/components/Progress.js +0 -95
- package/dist/data/components/Progress.js.map +0 -1
- package/dist/data/components/RadioButton.d.ts +0 -15
- package/dist/data/components/RadioButton.d.ts.map +0 -1
- package/dist/data/components/RadioButton.js +0 -140
- package/dist/data/components/RadioButton.js.map +0 -1
- package/dist/data/components/SVGImage.d.ts +0 -15
- package/dist/data/components/SVGImage.d.ts.map +0 -1
- package/dist/data/components/SVGImage.js +0 -112
- package/dist/data/components/SVGImage.js.map +0 -1
- package/dist/data/components/Screen.d.ts +0 -15
- package/dist/data/components/Screen.d.ts.map +0 -1
- package/dist/data/components/Screen.js +0 -99
- package/dist/data/components/Screen.js.map +0 -1
- package/dist/data/components/Select.d.ts +0 -15
- package/dist/data/components/Select.d.ts.map +0 -1
- package/dist/data/components/Select.js +0 -146
- package/dist/data/components/Select.js.map +0 -1
- package/dist/data/components/Skeleton.d.ts +0 -15
- package/dist/data/components/Skeleton.d.ts.map +0 -1
- package/dist/data/components/Skeleton.js +0 -110
- package/dist/data/components/Skeleton.js.map +0 -1
- package/dist/data/components/Slider.d.ts +0 -15
- package/dist/data/components/Slider.d.ts.map +0 -1
- package/dist/data/components/Slider.js +0 -129
- package/dist/data/components/Slider.js.map +0 -1
- package/dist/data/components/Switch.d.ts +0 -15
- package/dist/data/components/Switch.d.ts.map +0 -1
- package/dist/data/components/Switch.js +0 -127
- package/dist/data/components/Switch.js.map +0 -1
- package/dist/data/components/TabBar.d.ts +0 -15
- package/dist/data/components/TabBar.d.ts.map +0 -1
- package/dist/data/components/TabBar.js +0 -145
- package/dist/data/components/TabBar.js.map +0 -1
- package/dist/data/components/Table.d.ts +0 -15
- package/dist/data/components/Table.d.ts.map +0 -1
- package/dist/data/components/Table.js +0 -151
- package/dist/data/components/Table.js.map +0 -1
- package/dist/data/components/Tabs.d.ts +0 -15
- package/dist/data/components/Tabs.d.ts.map +0 -1
- package/dist/data/components/Tabs.js +0 -150
- package/dist/data/components/Tabs.js.map +0 -1
- package/dist/data/components/Text.d.ts +0 -15
- package/dist/data/components/Text.d.ts.map +0 -1
- package/dist/data/components/Text.js +0 -85
- package/dist/data/components/Text.js.map +0 -1
- package/dist/data/components/TextArea.d.ts +0 -15
- package/dist/data/components/TextArea.d.ts.map +0 -1
- package/dist/data/components/TextArea.js +0 -155
- package/dist/data/components/TextArea.js.map +0 -1
- package/dist/data/components/Tooltip.d.ts +0 -15
- package/dist/data/components/Tooltip.d.ts.map +0 -1
- package/dist/data/components/Tooltip.js +0 -105
- package/dist/data/components/Tooltip.js.map +0 -1
- package/dist/data/components/Video.d.ts +0 -15
- package/dist/data/components/Video.d.ts.map +0 -1
- package/dist/data/components/Video.js +0 -168
- package/dist/data/components/Video.js.map +0 -1
- package/dist/data/components/View.d.ts +0 -15
- package/dist/data/components/View.d.ts.map +0 -1
- package/dist/data/components/View.js +0 -126
- package/dist/data/components/View.js.map +0 -1
- package/dist/data/components/index.d.ts +0 -37
- package/dist/data/components/index.d.ts.map +0 -1
- package/dist/data/components/index.js +0 -110
- package/dist/data/components/index.js.map +0 -1
- package/dist/data/framework-guides.d.ts +0 -2
- package/dist/data/framework-guides.d.ts.map +0 -1
- package/dist/data/framework-guides.js +0 -589
- package/dist/data/framework-guides.js.map +0 -1
- package/dist/data/icon-guide.d.ts +0 -2
- package/dist/data/icon-guide.d.ts.map +0 -1
- package/dist/data/icon-guide.js +0 -285
- package/dist/data/icon-guide.js.map +0 -1
- package/dist/data/icons.json +0 -7452
- package/dist/data/navigation-guides.d.ts +0 -2
- package/dist/data/navigation-guides.d.ts.map +0 -1
- package/dist/data/navigation-guides.js +0 -1196
- package/dist/data/navigation-guides.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Menu Component Examples
|
|
3
|
+
*
|
|
4
|
+
* These examples are type-checked against the actual MenuProps interface
|
|
5
|
+
* to ensure accuracy and correctness.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { Menu, View, Text, Button, Icon } from '@idealyst/components';
|
|
10
|
+
import type { MenuItem } from '@idealyst/components';
|
|
11
|
+
|
|
12
|
+
// Example 1: Basic Menu
|
|
13
|
+
export function BasicMenu() {
|
|
14
|
+
const [open, setOpen] = React.useState(false);
|
|
15
|
+
|
|
16
|
+
const items: MenuItem[] = [
|
|
17
|
+
{ id: '1', label: 'Profile', onClick: () => console.log('Profile') },
|
|
18
|
+
{ id: '2', label: 'Settings', onClick: () => console.log('Settings') },
|
|
19
|
+
{ id: '3', label: 'Logout', onClick: () => console.log('Logout') },
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<Menu items={items} open={open} onOpenChange={setOpen}>
|
|
24
|
+
<Button onPress={() => setOpen(true)}>Open Menu</Button>
|
|
25
|
+
</Menu>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Example 2: Menu with Icons
|
|
30
|
+
export function MenuWithIcons() {
|
|
31
|
+
const [open, setOpen] = React.useState(false);
|
|
32
|
+
|
|
33
|
+
const items: MenuItem[] = [
|
|
34
|
+
{ id: '1', label: 'Profile', icon: 'account', onClick: () => console.log('Profile') },
|
|
35
|
+
{ id: '2', label: 'Settings', icon: 'cog', onClick: () => console.log('Settings') },
|
|
36
|
+
{ id: '3', label: 'Help', icon: 'help-circle', onClick: () => console.log('Help') },
|
|
37
|
+
{ id: '4', label: 'Logout', icon: 'logout', onClick: () => console.log('Logout') },
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<Menu items={items} open={open} onOpenChange={setOpen}>
|
|
42
|
+
<Button onPress={() => setOpen(true)}>User Menu</Button>
|
|
43
|
+
</Menu>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Example 3: Menu with Custom Icon Components
|
|
48
|
+
export function MenuWithCustomIcons() {
|
|
49
|
+
const [open, setOpen] = React.useState(false);
|
|
50
|
+
|
|
51
|
+
const items: MenuItem[] = [
|
|
52
|
+
{
|
|
53
|
+
id: '1',
|
|
54
|
+
label: 'Dashboard',
|
|
55
|
+
icon: <Icon name="view-dashboard" size="sm" />,
|
|
56
|
+
onClick: () => console.log('Dashboard'),
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: '2',
|
|
60
|
+
label: 'Analytics',
|
|
61
|
+
icon: <Icon name="chart-line" size="sm" />,
|
|
62
|
+
onClick: () => console.log('Analytics'),
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: '3',
|
|
66
|
+
label: 'Reports',
|
|
67
|
+
icon: <Icon name="file-chart" size="sm" />,
|
|
68
|
+
onClick: () => console.log('Reports'),
|
|
69
|
+
},
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<Menu items={items} open={open} onOpenChange={setOpen}>
|
|
74
|
+
<Button onPress={() => setOpen(true)}>Navigation</Button>
|
|
75
|
+
</Menu>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Example 4: Menu Sizes
|
|
80
|
+
export function MenuSizes() {
|
|
81
|
+
const [open, setOpen] = React.useState(false);
|
|
82
|
+
|
|
83
|
+
const items: MenuItem[] = [
|
|
84
|
+
{ id: '1', label: 'Option 1', onClick: () => {} },
|
|
85
|
+
{ id: '2', label: 'Option 2', onClick: () => {} },
|
|
86
|
+
{ id: '3', label: 'Option 3', onClick: () => {} },
|
|
87
|
+
];
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<View spacing="md">
|
|
91
|
+
<Menu items={items} size="xs" open={open} onOpenChange={setOpen}>
|
|
92
|
+
<Button size="xs" onPress={() => setOpen(true)}>
|
|
93
|
+
XS Menu
|
|
94
|
+
</Button>
|
|
95
|
+
</Menu>
|
|
96
|
+
<Menu items={items} size="sm" open={open} onOpenChange={setOpen}>
|
|
97
|
+
<Button size="sm" onPress={() => setOpen(true)}>
|
|
98
|
+
SM Menu
|
|
99
|
+
</Button>
|
|
100
|
+
</Menu>
|
|
101
|
+
<Menu items={items} size="md" open={open} onOpenChange={setOpen}>
|
|
102
|
+
<Button size="md" onPress={() => setOpen(true)}>
|
|
103
|
+
MD Menu
|
|
104
|
+
</Button>
|
|
105
|
+
</Menu>
|
|
106
|
+
<Menu items={items} size="lg" open={open} onOpenChange={setOpen}>
|
|
107
|
+
<Button size="lg" onPress={() => setOpen(true)}>
|
|
108
|
+
LG Menu
|
|
109
|
+
</Button>
|
|
110
|
+
</Menu>
|
|
111
|
+
</View>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Example 5: Menu Placements
|
|
116
|
+
export function MenuPlacements() {
|
|
117
|
+
const [open, setOpen] = React.useState(false);
|
|
118
|
+
|
|
119
|
+
const items: MenuItem[] = [
|
|
120
|
+
{ id: '1', label: 'Option 1', onClick: () => {} },
|
|
121
|
+
{ id: '2', label: 'Option 2', onClick: () => {} },
|
|
122
|
+
{ id: '3', label: 'Option 3', onClick: () => {} },
|
|
123
|
+
];
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<View spacing="md">
|
|
127
|
+
<Menu items={items} placement="bottom" open={open} onOpenChange={setOpen}>
|
|
128
|
+
<Button onPress={() => setOpen(true)}>Bottom</Button>
|
|
129
|
+
</Menu>
|
|
130
|
+
<Menu items={items} placement="top" open={open} onOpenChange={setOpen}>
|
|
131
|
+
<Button onPress={() => setOpen(true)}>Top</Button>
|
|
132
|
+
</Menu>
|
|
133
|
+
<Menu items={items} placement="left" open={open} onOpenChange={setOpen}>
|
|
134
|
+
<Button onPress={() => setOpen(true)}>Left</Button>
|
|
135
|
+
</Menu>
|
|
136
|
+
<Menu items={items} placement="right" open={open} onOpenChange={setOpen}>
|
|
137
|
+
<Button onPress={() => setOpen(true)}>Right</Button>
|
|
138
|
+
</Menu>
|
|
139
|
+
</View>
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Example 6: Menu with Intent Colors
|
|
144
|
+
export function MenuWithIntent() {
|
|
145
|
+
const [open, setOpen] = React.useState(false);
|
|
146
|
+
|
|
147
|
+
const items: MenuItem[] = [
|
|
148
|
+
{ id: '1', label: 'Edit', icon: 'pencil', intent: 'primary', onClick: () => {} },
|
|
149
|
+
{ id: '2', label: 'Duplicate', icon: 'content-copy', intent: 'info', onClick: () => {} },
|
|
150
|
+
{ id: '3', label: 'Archive', icon: 'archive', intent: 'warning', onClick: () => {} },
|
|
151
|
+
{ id: '4', label: 'Delete', icon: 'delete', intent: 'error', onClick: () => {} },
|
|
152
|
+
];
|
|
153
|
+
|
|
154
|
+
return (
|
|
155
|
+
<Menu items={items} open={open} onOpenChange={setOpen}>
|
|
156
|
+
<Button onPress={() => setOpen(true)}>Actions</Button>
|
|
157
|
+
</Menu>
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Example 7: Menu with Separators
|
|
162
|
+
export function MenuWithSeparators() {
|
|
163
|
+
const [open, setOpen] = React.useState(false);
|
|
164
|
+
|
|
165
|
+
const items: MenuItem[] = [
|
|
166
|
+
{ id: '1', label: 'New File', icon: 'file-plus', onClick: () => {} },
|
|
167
|
+
{ id: '2', label: 'New Folder', icon: 'folder-plus', onClick: () => {} },
|
|
168
|
+
{ id: '3', label: 'separator-1', separator: true },
|
|
169
|
+
{ id: '4', label: 'Open', icon: 'folder-open', onClick: () => {} },
|
|
170
|
+
{ id: '5', label: 'Save', icon: 'content-save', onClick: () => {} },
|
|
171
|
+
{ id: '6', label: 'separator-2', separator: true },
|
|
172
|
+
{ id: '7', label: 'Exit', icon: 'exit-to-app', onClick: () => {} },
|
|
173
|
+
];
|
|
174
|
+
|
|
175
|
+
return (
|
|
176
|
+
<Menu items={items} open={open} onOpenChange={setOpen}>
|
|
177
|
+
<Button onPress={() => setOpen(true)}>File</Button>
|
|
178
|
+
</Menu>
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Example 8: Menu with Disabled Items
|
|
183
|
+
export function MenuWithDisabledItems() {
|
|
184
|
+
const [open, setOpen] = React.useState(false);
|
|
185
|
+
|
|
186
|
+
const items: MenuItem[] = [
|
|
187
|
+
{ id: '1', label: 'Cut', icon: 'content-cut', onClick: () => {} },
|
|
188
|
+
{ id: '2', label: 'Copy', icon: 'content-copy', onClick: () => {} },
|
|
189
|
+
{ id: '3', label: 'Paste', icon: 'content-paste', disabled: true },
|
|
190
|
+
{ id: '4', label: 'separator', separator: true },
|
|
191
|
+
{ id: '5', label: 'Undo', icon: 'undo', disabled: true },
|
|
192
|
+
{ id: '6', label: 'Redo', icon: 'redo', onClick: () => {} },
|
|
193
|
+
];
|
|
194
|
+
|
|
195
|
+
return (
|
|
196
|
+
<Menu items={items} open={open} onOpenChange={setOpen}>
|
|
197
|
+
<Button onPress={() => setOpen(true)}>Edit</Button>
|
|
198
|
+
</Menu>
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Example 9: Menu with Close on Selection
|
|
203
|
+
export function MenuWithCloseOnSelection() {
|
|
204
|
+
const [open, setOpen] = React.useState(false);
|
|
205
|
+
const [selected, setSelected] = React.useState<string>('');
|
|
206
|
+
|
|
207
|
+
const items: MenuItem[] = [
|
|
208
|
+
{
|
|
209
|
+
id: '1',
|
|
210
|
+
label: 'Option 1',
|
|
211
|
+
onClick: () => {
|
|
212
|
+
setSelected('Option 1');
|
|
213
|
+
console.log('Selected Option 1');
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
id: '2',
|
|
218
|
+
label: 'Option 2',
|
|
219
|
+
onClick: () => {
|
|
220
|
+
setSelected('Option 2');
|
|
221
|
+
console.log('Selected Option 2');
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
id: '3',
|
|
226
|
+
label: 'Option 3',
|
|
227
|
+
onClick: () => {
|
|
228
|
+
setSelected('Option 3');
|
|
229
|
+
console.log('Selected Option 3');
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
];
|
|
233
|
+
|
|
234
|
+
return (
|
|
235
|
+
<View spacing="md">
|
|
236
|
+
<Menu items={items} open={open} onOpenChange={setOpen} closeOnSelection>
|
|
237
|
+
<Button onPress={() => setOpen(true)}>Select Option</Button>
|
|
238
|
+
</Menu>
|
|
239
|
+
{selected && (
|
|
240
|
+
<Text size="sm" >
|
|
241
|
+
Selected: {selected}
|
|
242
|
+
</Text>
|
|
243
|
+
)}
|
|
244
|
+
</View>
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// Example 10: Context Menu
|
|
249
|
+
export function ContextMenu() {
|
|
250
|
+
const [open, setOpen] = React.useState(false);
|
|
251
|
+
|
|
252
|
+
const items: MenuItem[] = [
|
|
253
|
+
{ id: '1', label: 'View Details', icon: 'information', onClick: () => {} },
|
|
254
|
+
{ id: '2', label: 'Share', icon: 'share', onClick: () => {} },
|
|
255
|
+
{ id: '3', label: 'separator', separator: true },
|
|
256
|
+
{ id: '4', label: 'Rename', icon: 'pencil', onClick: () => {} },
|
|
257
|
+
{ id: '5', label: 'Move', icon: 'folder-move', onClick: () => {} },
|
|
258
|
+
{ id: '6', label: 'separator-2', separator: true },
|
|
259
|
+
{ id: '7', label: 'Delete', icon: 'delete', intent: 'error', onClick: () => {} },
|
|
260
|
+
];
|
|
261
|
+
|
|
262
|
+
return (
|
|
263
|
+
<Menu items={items} open={open} onOpenChange={setOpen} placement="bottom-start">
|
|
264
|
+
<View
|
|
265
|
+
background="primary"
|
|
266
|
+
spacing="lg"
|
|
267
|
+
radius="md"
|
|
268
|
+
border="thin"
|
|
269
|
+
style={{ cursor: 'pointer' }}
|
|
270
|
+
>
|
|
271
|
+
<Text>Right-click me (or click to open menu)</Text>
|
|
272
|
+
<Button size="sm" onPress={() => setOpen(true)}>
|
|
273
|
+
Open Context Menu
|
|
274
|
+
</Button>
|
|
275
|
+
</View>
|
|
276
|
+
</Menu>
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// Example 11: Dropdown Menu
|
|
281
|
+
export function DropdownMenu() {
|
|
282
|
+
const [open, setOpen] = React.useState(false);
|
|
283
|
+
const [sortBy, setSortBy] = React.useState('name');
|
|
284
|
+
|
|
285
|
+
const items: MenuItem[] = [
|
|
286
|
+
{
|
|
287
|
+
id: '1',
|
|
288
|
+
label: 'Name',
|
|
289
|
+
icon: sortBy === 'name' ? 'check' : undefined,
|
|
290
|
+
onClick: () => setSortBy('name'),
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
id: '2',
|
|
294
|
+
label: 'Date',
|
|
295
|
+
icon: sortBy === 'date' ? 'check' : undefined,
|
|
296
|
+
onClick: () => setSortBy('date'),
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
id: '3',
|
|
300
|
+
label: 'Size',
|
|
301
|
+
icon: sortBy === 'size' ? 'check' : undefined,
|
|
302
|
+
onClick: () => setSortBy('size'),
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
id: '4',
|
|
306
|
+
label: 'Type',
|
|
307
|
+
icon: sortBy === 'type' ? 'check' : undefined,
|
|
308
|
+
onClick: () => setSortBy('type'),
|
|
309
|
+
},
|
|
310
|
+
];
|
|
311
|
+
|
|
312
|
+
return (
|
|
313
|
+
<View spacing="md">
|
|
314
|
+
<Menu items={items} open={open} onOpenChange={setOpen} closeOnSelection>
|
|
315
|
+
<Button type="outlined" onPress={() => setOpen(true)}>
|
|
316
|
+
Sort by: {sortBy.charAt(0).toUpperCase() + sortBy.slice(1)}
|
|
317
|
+
</Button>
|
|
318
|
+
</Menu>
|
|
319
|
+
</View>
|
|
320
|
+
);
|
|
321
|
+
}
|