@idealyst/mcp-server 1.0.87 → 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,439 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Popover Component Examples
|
|
3
|
+
*
|
|
4
|
+
* These examples are type-checked against the actual PopoverProps interface
|
|
5
|
+
* to ensure accuracy and correctness.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { Popover, View, Text, Button, Icon, Pressable } from '@idealyst/components';
|
|
10
|
+
|
|
11
|
+
// Example 1: Basic Popover
|
|
12
|
+
export function BasicPopover() {
|
|
13
|
+
const [open, setOpen] = React.useState(false);
|
|
14
|
+
const anchorRef = React.useRef<Element>(null);
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<View spacing="md">
|
|
18
|
+
<Button ref={anchorRef} onPress={() => setOpen(true)}>
|
|
19
|
+
Open Popover
|
|
20
|
+
</Button>
|
|
21
|
+
<Popover open={open} onOpenChange={setOpen} anchor={anchorRef as React.RefObject<Element>}>
|
|
22
|
+
<View spacing="md" background="primary" radius="md">
|
|
23
|
+
<Text>This is a basic popover content</Text>
|
|
24
|
+
</View>
|
|
25
|
+
</Popover>
|
|
26
|
+
</View>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Example 2: Popover Placements
|
|
31
|
+
export function PopoverPlacements() {
|
|
32
|
+
const [placement, setPlacement] = React.useState<
|
|
33
|
+
| 'top'
|
|
34
|
+
| 'top-start'
|
|
35
|
+
| 'top-end'
|
|
36
|
+
| 'bottom'
|
|
37
|
+
| 'bottom-start'
|
|
38
|
+
| 'bottom-end'
|
|
39
|
+
| 'left'
|
|
40
|
+
| 'left-start'
|
|
41
|
+
| 'left-end'
|
|
42
|
+
| 'right'
|
|
43
|
+
| 'right-start'
|
|
44
|
+
| 'right-end'
|
|
45
|
+
>('bottom');
|
|
46
|
+
const [open, setOpen] = React.useState(false);
|
|
47
|
+
const anchorRef = React.useRef<Element>(null);
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<View spacing="lg">
|
|
51
|
+
<View spacing="sm">
|
|
52
|
+
<Button size="sm" onPress={() => { setPlacement('top'); setOpen(true); }}>
|
|
53
|
+
Top
|
|
54
|
+
</Button>
|
|
55
|
+
<Button size="sm" onPress={() => { setPlacement('bottom'); setOpen(true); }}>
|
|
56
|
+
Bottom
|
|
57
|
+
</Button>
|
|
58
|
+
<Button size="sm" onPress={() => { setPlacement('left'); setOpen(true); }}>
|
|
59
|
+
Left
|
|
60
|
+
</Button>
|
|
61
|
+
<Button size="sm" onPress={() => { setPlacement('right'); setOpen(true); }}>
|
|
62
|
+
Right
|
|
63
|
+
</Button>
|
|
64
|
+
</View>
|
|
65
|
+
<Button ref={anchorRef}>Anchor Element</Button>
|
|
66
|
+
<Popover open={open} onOpenChange={setOpen} anchor={anchorRef as React.RefObject<Element>} placement={placement}>
|
|
67
|
+
<View spacing="md" background="primary" radius="md">
|
|
68
|
+
<Text>Popover at {placement}</Text>
|
|
69
|
+
</View>
|
|
70
|
+
</Popover>
|
|
71
|
+
</View>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Example 3: Popover with Arrow
|
|
76
|
+
export function PopoverWithArrow() {
|
|
77
|
+
const [open, setOpen] = React.useState(false);
|
|
78
|
+
const anchorRef = React.useRef<Element>(null);
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<View spacing="md">
|
|
82
|
+
<Button ref={anchorRef} onPress={() => setOpen(true)}>
|
|
83
|
+
Open Popover with Arrow
|
|
84
|
+
</Button>
|
|
85
|
+
<Popover open={open} onOpenChange={setOpen} anchor={anchorRef as React.RefObject<Element>} showArrow>
|
|
86
|
+
<View spacing="md" background="primary" radius="md">
|
|
87
|
+
<Text>This popover has an arrow pointing to the anchor</Text>
|
|
88
|
+
</View>
|
|
89
|
+
</Popover>
|
|
90
|
+
</View>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Example 4: Popover with Offset
|
|
95
|
+
export function PopoverWithOffset() {
|
|
96
|
+
const [open, setOpen] = React.useState(false);
|
|
97
|
+
const anchorRef = React.useRef<Element>(null);
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<View spacing="md">
|
|
101
|
+
<Button ref={anchorRef} onPress={() => setOpen(true)}>
|
|
102
|
+
Open Popover
|
|
103
|
+
</Button>
|
|
104
|
+
<Popover open={open} onOpenChange={setOpen} anchor={anchorRef as React.RefObject<Element>} offset={20} showArrow>
|
|
105
|
+
<View spacing="md" background="primary" radius="md">
|
|
106
|
+
<Text>This popover has 20px offset from anchor</Text>
|
|
107
|
+
</View>
|
|
108
|
+
</Popover>
|
|
109
|
+
</View>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Example 5: Popover with Close Behaviors
|
|
114
|
+
export function PopoverWithCloseBehaviors() {
|
|
115
|
+
const [open1, setOpen1] = React.useState(false);
|
|
116
|
+
const [open2, setOpen2] = React.useState(false);
|
|
117
|
+
const anchor1Ref = React.useRef<Element>(null);
|
|
118
|
+
const anchor2Ref = React.useRef<Element>(null);
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<View spacing="lg">
|
|
122
|
+
<View spacing="md">
|
|
123
|
+
<Text weight="semibold">Closes on outside click</Text>
|
|
124
|
+
<Button ref={anchor1Ref} onPress={() => setOpen1(true)}>
|
|
125
|
+
Open Popover
|
|
126
|
+
</Button>
|
|
127
|
+
<Popover
|
|
128
|
+
open={open1}
|
|
129
|
+
onOpenChange={setOpen1}
|
|
130
|
+
anchor={anchor1Ref as React.RefObject<Element>}
|
|
131
|
+
closeOnClickOutside
|
|
132
|
+
>
|
|
133
|
+
<View spacing="md" background="primary" radius="md">
|
|
134
|
+
<Text>Click outside to close</Text>
|
|
135
|
+
</View>
|
|
136
|
+
</Popover>
|
|
137
|
+
</View>
|
|
138
|
+
|
|
139
|
+
<View spacing="md">
|
|
140
|
+
<Text weight="semibold">Stays open on outside click</Text>
|
|
141
|
+
<Button ref={anchor2Ref} onPress={() => setOpen2(true)}>
|
|
142
|
+
Open Popover
|
|
143
|
+
</Button>
|
|
144
|
+
<Popover
|
|
145
|
+
open={open2}
|
|
146
|
+
onOpenChange={setOpen2}
|
|
147
|
+
anchor={anchor2Ref as React.RefObject<Element>}
|
|
148
|
+
closeOnClickOutside={false}
|
|
149
|
+
>
|
|
150
|
+
<View spacing="md" background="primary" radius="md">
|
|
151
|
+
<Text>Use close button</Text>
|
|
152
|
+
<Button size="sm" onPress={() => setOpen2(false)}>
|
|
153
|
+
Close
|
|
154
|
+
</Button>
|
|
155
|
+
</View>
|
|
156
|
+
</Popover>
|
|
157
|
+
</View>
|
|
158
|
+
</View>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Example 6: Popover with Form
|
|
163
|
+
export function PopoverWithForm() {
|
|
164
|
+
const [open, setOpen] = React.useState(false);
|
|
165
|
+
const [name, setName] = React.useState('');
|
|
166
|
+
const [email, setEmail] = React.useState('');
|
|
167
|
+
const anchorRef = React.useRef<Element>(null);
|
|
168
|
+
|
|
169
|
+
const handleSubmit = () => {
|
|
170
|
+
console.log('Submitted:', { name, email });
|
|
171
|
+
setOpen(false);
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
return (
|
|
175
|
+
<View spacing="md">
|
|
176
|
+
<Button ref={anchorRef} onPress={() => setOpen(true)}>
|
|
177
|
+
Quick Add User
|
|
178
|
+
</Button>
|
|
179
|
+
<Popover
|
|
180
|
+
open={open}
|
|
181
|
+
onOpenChange={setOpen}
|
|
182
|
+
anchor={anchorRef as React.RefObject<Element>}
|
|
183
|
+
placement="bottom-start"
|
|
184
|
+
closeOnClickOutside={false}
|
|
185
|
+
>
|
|
186
|
+
<View spacing="lg" background="primary" radius="md">
|
|
187
|
+
<Text weight="bold">Add New User</Text>
|
|
188
|
+
<View spacing="sm">
|
|
189
|
+
<Text size="sm">Name (placeholder for input)</Text>
|
|
190
|
+
<Text size="sm">Email (placeholder for input)</Text>
|
|
191
|
+
</View>
|
|
192
|
+
<View spacing="sm">
|
|
193
|
+
<Button size="sm" onPress={handleSubmit}>
|
|
194
|
+
Add
|
|
195
|
+
</Button>
|
|
196
|
+
<Button size="sm" type="outlined" onPress={() => setOpen(false)}>
|
|
197
|
+
Cancel
|
|
198
|
+
</Button>
|
|
199
|
+
</View>
|
|
200
|
+
</View>
|
|
201
|
+
</Popover>
|
|
202
|
+
</View>
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// Example 7: Popover with Rich Content
|
|
207
|
+
export function PopoverWithRichContent() {
|
|
208
|
+
const [open, setOpen] = React.useState(false);
|
|
209
|
+
const anchorRef = React.useRef<Element>(null);
|
|
210
|
+
|
|
211
|
+
return (
|
|
212
|
+
<View spacing="md">
|
|
213
|
+
<Button ref={anchorRef} onPress={() => setOpen(true)}>
|
|
214
|
+
View Profile
|
|
215
|
+
</Button>
|
|
216
|
+
<Popover
|
|
217
|
+
open={open}
|
|
218
|
+
onOpenChange={setOpen}
|
|
219
|
+
anchor={anchorRef as React.RefObject<Element>}
|
|
220
|
+
placement="bottom-start"
|
|
221
|
+
showArrow
|
|
222
|
+
>
|
|
223
|
+
<View spacing="md" background="primary" radius="lg">
|
|
224
|
+
<View spacing="sm">
|
|
225
|
+
<Text size="lg" weight="bold">
|
|
226
|
+
John Doe
|
|
227
|
+
</Text>
|
|
228
|
+
<Text size="sm" >
|
|
229
|
+
@johndoe
|
|
230
|
+
</Text>
|
|
231
|
+
</View>
|
|
232
|
+
<View spacing="xs">
|
|
233
|
+
<Text size="sm">Software Engineer at Tech Corp</Text>
|
|
234
|
+
<Text size="sm" >
|
|
235
|
+
San Francisco, CA
|
|
236
|
+
</Text>
|
|
237
|
+
</View>
|
|
238
|
+
<View spacing="sm">
|
|
239
|
+
<Text size="sm" weight="semibold">
|
|
240
|
+
Bio
|
|
241
|
+
</Text>
|
|
242
|
+
<Text size="sm">
|
|
243
|
+
Passionate about building great products and writing clean code.
|
|
244
|
+
</Text>
|
|
245
|
+
</View>
|
|
246
|
+
<Button size="sm">View Full Profile</Button>
|
|
247
|
+
</View>
|
|
248
|
+
</Popover>
|
|
249
|
+
</View>
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// Example 8: Popover Menu
|
|
254
|
+
export function PopoverMenu() {
|
|
255
|
+
const [open, setOpen] = React.useState(false);
|
|
256
|
+
const anchorRef = React.useRef<Element>(null);
|
|
257
|
+
|
|
258
|
+
const menuItems = [
|
|
259
|
+
{ icon: 'pencil' as const, label: 'Edit', onClick: () => console.log('Edit') },
|
|
260
|
+
{ icon: 'content-copy' as const, label: 'Duplicate', onClick: () => console.log('Duplicate') },
|
|
261
|
+
{ icon: 'share' as const, label: 'Share', onClick: () => console.log('Share') },
|
|
262
|
+
{ icon: 'delete' as const, label: 'Delete', onClick: () => console.log('Delete') },
|
|
263
|
+
];
|
|
264
|
+
|
|
265
|
+
return (
|
|
266
|
+
<View spacing="md">
|
|
267
|
+
<Button ref={anchorRef} type="outlined" onPress={() => setOpen(true)}>
|
|
268
|
+
<Icon name="dots-vertical" />
|
|
269
|
+
</Button>
|
|
270
|
+
<Popover
|
|
271
|
+
open={open}
|
|
272
|
+
onOpenChange={setOpen}
|
|
273
|
+
anchor={anchorRef as React.RefObject<Element>}
|
|
274
|
+
placement="bottom-end"
|
|
275
|
+
closeOnClickOutside
|
|
276
|
+
>
|
|
277
|
+
<View spacing="none" background="primary" radius="md">
|
|
278
|
+
{menuItems.map((item, index) => (
|
|
279
|
+
<Pressable
|
|
280
|
+
key={index}
|
|
281
|
+
style={{ cursor: 'pointer', padding: 8, flexDirection: 'row', alignItems: 'center', gap: 8 }}
|
|
282
|
+
onPress={() => {
|
|
283
|
+
item.onClick();
|
|
284
|
+
setOpen(false);
|
|
285
|
+
}}
|
|
286
|
+
>
|
|
287
|
+
<Icon name={item.icon} size="sm" />
|
|
288
|
+
<Text size="sm">{item.label}</Text>
|
|
289
|
+
</Pressable>
|
|
290
|
+
))}
|
|
291
|
+
</View>
|
|
292
|
+
</Popover>
|
|
293
|
+
</View>
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// Example 9: Color Picker Popover
|
|
298
|
+
export function ColorPickerPopover() {
|
|
299
|
+
const [open, setOpen] = React.useState(false);
|
|
300
|
+
const [selectedColor, setSelectedColor] = React.useState('#3b82f6');
|
|
301
|
+
const anchorRef = React.useRef<Element>(null);
|
|
302
|
+
|
|
303
|
+
const colors = [
|
|
304
|
+
'#ef4444',
|
|
305
|
+
'#f59e0b',
|
|
306
|
+
'#10b981',
|
|
307
|
+
'#3b82f6',
|
|
308
|
+
'#6366f1',
|
|
309
|
+
'#8b5cf6',
|
|
310
|
+
'#ec4899',
|
|
311
|
+
'#6b7280',
|
|
312
|
+
];
|
|
313
|
+
|
|
314
|
+
return (
|
|
315
|
+
<View spacing="md">
|
|
316
|
+
<Button
|
|
317
|
+
ref={anchorRef}
|
|
318
|
+
onPress={() => setOpen(true)}
|
|
319
|
+
style={{ backgroundColor: selectedColor }}
|
|
320
|
+
>
|
|
321
|
+
Pick Color
|
|
322
|
+
</Button>
|
|
323
|
+
<Popover
|
|
324
|
+
open={open}
|
|
325
|
+
onOpenChange={setOpen}
|
|
326
|
+
anchor={anchorRef as React.RefObject<Element>}
|
|
327
|
+
placement="bottom"
|
|
328
|
+
closeOnClickOutside
|
|
329
|
+
>
|
|
330
|
+
<View spacing="md" background="primary" radius="md">
|
|
331
|
+
<Text weight="semibold">Choose a color</Text>
|
|
332
|
+
<View spacing="sm" style={{ flexDirection: 'row', flexWrap: 'wrap' }}>
|
|
333
|
+
{colors.map((color) => (
|
|
334
|
+
<Pressable
|
|
335
|
+
key={color}
|
|
336
|
+
style={{
|
|
337
|
+
width: 40,
|
|
338
|
+
height: 40,
|
|
339
|
+
backgroundColor: color,
|
|
340
|
+
borderRadius: 8,
|
|
341
|
+
cursor: 'pointer',
|
|
342
|
+
borderWidth: selectedColor === color ? 2 : 0,
|
|
343
|
+
borderColor: selectedColor === color ? 'black' : 'transparent',
|
|
344
|
+
}}
|
|
345
|
+
onPress={() => {
|
|
346
|
+
setSelectedColor(color);
|
|
347
|
+
setOpen(false);
|
|
348
|
+
}}
|
|
349
|
+
/>
|
|
350
|
+
))}
|
|
351
|
+
</View>
|
|
352
|
+
</View>
|
|
353
|
+
</Popover>
|
|
354
|
+
</View>
|
|
355
|
+
);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// Example 10: Info Popover
|
|
359
|
+
export function InfoPopover() {
|
|
360
|
+
const [open, setOpen] = React.useState(false);
|
|
361
|
+
const anchorRef = React.useRef<Element>(null);
|
|
362
|
+
|
|
363
|
+
return (
|
|
364
|
+
<View spacing="md">
|
|
365
|
+
<View spacing="sm" style={{ flexDirection: 'row', alignItems: 'center' }}>
|
|
366
|
+
<Text>Account Status</Text>
|
|
367
|
+
<Pressable
|
|
368
|
+
ref={anchorRef}
|
|
369
|
+
style={{ cursor: 'pointer' }}
|
|
370
|
+
onPress={() => setOpen(true)}
|
|
371
|
+
>
|
|
372
|
+
<Icon name="information" size="sm" />
|
|
373
|
+
</Pressable>
|
|
374
|
+
</View>
|
|
375
|
+
<Popover
|
|
376
|
+
open={open}
|
|
377
|
+
onOpenChange={setOpen}
|
|
378
|
+
anchor={anchorRef as React.RefObject<Element>}
|
|
379
|
+
placement="right"
|
|
380
|
+
showArrow
|
|
381
|
+
offset={8}
|
|
382
|
+
>
|
|
383
|
+
<View spacing="sm" background="primary" radius="md">
|
|
384
|
+
<Text weight="semibold" size="sm">
|
|
385
|
+
What does this mean?
|
|
386
|
+
</Text>
|
|
387
|
+
<Text size="sm">
|
|
388
|
+
Your account status determines which features you have access to. Active accounts have
|
|
389
|
+
full access to all features.
|
|
390
|
+
</Text>
|
|
391
|
+
</View>
|
|
392
|
+
</Popover>
|
|
393
|
+
</View>
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// Example 11: Share Popover
|
|
398
|
+
export function SharePopover() {
|
|
399
|
+
const [open, setOpen] = React.useState(false);
|
|
400
|
+
const anchorRef = React.useRef<Element>(null);
|
|
401
|
+
|
|
402
|
+
return (
|
|
403
|
+
<View spacing="md">
|
|
404
|
+
<Button ref={anchorRef} type="outlined" onPress={() => setOpen(true)}>
|
|
405
|
+
<Icon name="share" />
|
|
406
|
+
Share
|
|
407
|
+
</Button>
|
|
408
|
+
<Popover
|
|
409
|
+
open={open}
|
|
410
|
+
onOpenChange={setOpen}
|
|
411
|
+
anchor={anchorRef as React.RefObject<Element>}
|
|
412
|
+
placement="bottom"
|
|
413
|
+
showArrow
|
|
414
|
+
>
|
|
415
|
+
<View spacing="md" background="primary" radius="md">
|
|
416
|
+
<Text weight="bold">Share this content</Text>
|
|
417
|
+
<View spacing="sm">
|
|
418
|
+
<Button size="sm" type="outlined">
|
|
419
|
+
<Icon name="facebook" size="sm" />
|
|
420
|
+
Facebook
|
|
421
|
+
</Button>
|
|
422
|
+
<Button size="sm" type="outlined">
|
|
423
|
+
<Icon name="twitter" size="sm" />
|
|
424
|
+
Twitter
|
|
425
|
+
</Button>
|
|
426
|
+
<Button size="sm" type="outlined">
|
|
427
|
+
<Icon name="linkedin" size="sm" />
|
|
428
|
+
LinkedIn
|
|
429
|
+
</Button>
|
|
430
|
+
<Button size="sm" type="outlined">
|
|
431
|
+
<Icon name="email" size="sm" />
|
|
432
|
+
Email
|
|
433
|
+
</Button>
|
|
434
|
+
</View>
|
|
435
|
+
</View>
|
|
436
|
+
</Popover>
|
|
437
|
+
</View>
|
|
438
|
+
);
|
|
439
|
+
}
|