@react-cupertino-ui/context-menu 0.0.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.
- package/LICENSE +24 -0
- package/dist/index.css +249 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.js +174 -0
- package/dist/index.scss +249 -0
- package/package.json +36 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Anderson Lima
|
|
4
|
+
|
|
5
|
+
This project is inspired by Apple's design principles but is not affiliated with, endorsed, or sponsored by Apple Inc.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
in the Software without restriction, including without limitation the rights
|
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
SOFTWARE.
|
package/dist/index.css
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
.react-cupertino-ui-context-menu__content, .react-cupertino-ui-context-menu__sub-content {
|
|
2
|
+
min-width: 220px;
|
|
3
|
+
background: rgba(255, 255, 255, 0.75);
|
|
4
|
+
background: rgba(255, 255, 255, 0.75);
|
|
5
|
+
backdrop-filter: blur(40px) saturate(var(--glass-saturation, 180%));
|
|
6
|
+
-webkit-backdrop-filter: blur(40px) saturate(var(--glass-saturation, 180%));
|
|
7
|
+
border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.18));
|
|
8
|
+
box-shadow: var(--glass-shadow, 0 8px 32px rgba(0, 0, 0, 0.12));
|
|
9
|
+
position: relative;
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
}
|
|
12
|
+
.react-cupertino-ui-context-menu__content::before, .react-cupertino-ui-context-menu__sub-content::before {
|
|
13
|
+
content: "";
|
|
14
|
+
position: absolute;
|
|
15
|
+
inset: 0;
|
|
16
|
+
background: var(--glass-highlight, linear-gradient(135deg, rgba(255, 255, 255, 0.4) 0%, transparent 55%));
|
|
17
|
+
border-radius: inherit;
|
|
18
|
+
opacity: var(--glass-highlight-opacity, 0.95);
|
|
19
|
+
pointer-events: none;
|
|
20
|
+
mix-blend-mode: screen;
|
|
21
|
+
}
|
|
22
|
+
.react-cupertino-ui-context-menu__content, .react-cupertino-ui-context-menu__sub-content {
|
|
23
|
+
border-radius: 12px;
|
|
24
|
+
padding: 6px;
|
|
25
|
+
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
|
|
26
|
+
animation: zoomIn 0.2s ease-out;
|
|
27
|
+
z-index: 50;
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-direction: column;
|
|
30
|
+
gap: 4px;
|
|
31
|
+
}
|
|
32
|
+
@media (prefers-color-scheme: dark) {
|
|
33
|
+
.react-cupertino-ui-context-menu__content, .react-cupertino-ui-context-menu__sub-content {
|
|
34
|
+
background: rgba(30, 30, 30, 0.75);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
.react-cupertino-ui-context-menu__item, .react-cupertino-ui-context-menu__checkbox-item, .react-cupertino-ui-context-menu__radio-item, .react-cupertino-ui-context-menu__sub-trigger {
|
|
38
|
+
position: relative;
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
border-radius: 6px;
|
|
42
|
+
padding: 8px 12px;
|
|
43
|
+
font-size: 14px;
|
|
44
|
+
outline: none;
|
|
45
|
+
cursor: default;
|
|
46
|
+
user-select: none;
|
|
47
|
+
color: var(--foreground);
|
|
48
|
+
}
|
|
49
|
+
.react-cupertino-ui-context-menu__item[data-state=open], .react-cupertino-ui-context-menu__checkbox-item[data-state=open], .react-cupertino-ui-context-menu__radio-item[data-state=open], .react-cupertino-ui-context-menu__sub-trigger[data-state=open] {
|
|
50
|
+
background: var(--color-blue);
|
|
51
|
+
color: white;
|
|
52
|
+
}
|
|
53
|
+
.react-cupertino-ui-context-menu__item[data-highlighted], .react-cupertino-ui-context-menu__checkbox-item[data-highlighted], .react-cupertino-ui-context-menu__radio-item[data-highlighted], .react-cupertino-ui-context-menu__sub-trigger[data-highlighted] {
|
|
54
|
+
background: var(--color-blue);
|
|
55
|
+
color: white;
|
|
56
|
+
}
|
|
57
|
+
.react-cupertino-ui-context-menu__item[data-highlighted] .react-cupertino-ui-context-menu__shortcut, .react-cupertino-ui-context-menu__checkbox-item[data-highlighted] .react-cupertino-ui-context-menu__shortcut, .react-cupertino-ui-context-menu__radio-item[data-highlighted] .react-cupertino-ui-context-menu__shortcut, .react-cupertino-ui-context-menu__sub-trigger[data-highlighted] .react-cupertino-ui-context-menu__shortcut {
|
|
58
|
+
color: rgba(255, 255, 255, 0.8);
|
|
59
|
+
}
|
|
60
|
+
.react-cupertino-ui-context-menu__item[data-disabled], .react-cupertino-ui-context-menu__checkbox-item[data-disabled], .react-cupertino-ui-context-menu__radio-item[data-disabled], .react-cupertino-ui-context-menu__sub-trigger[data-disabled] {
|
|
61
|
+
opacity: 0.5;
|
|
62
|
+
pointer-events: none;
|
|
63
|
+
}
|
|
64
|
+
.react-cupertino-ui-context-menu__item.inset, .react-cupertino-ui-context-menu__checkbox-item.inset, .react-cupertino-ui-context-menu__radio-item.inset, .react-cupertino-ui-context-menu__sub-trigger.inset {
|
|
65
|
+
padding-left: 32px;
|
|
66
|
+
}
|
|
67
|
+
.react-cupertino-ui-context-menu__separator {
|
|
68
|
+
height: 1px;
|
|
69
|
+
background: rgba(0, 0, 0, 0.1);
|
|
70
|
+
margin: 4px -6px;
|
|
71
|
+
}
|
|
72
|
+
@media (prefers-color-scheme: dark) {
|
|
73
|
+
.react-cupertino-ui-context-menu__separator {
|
|
74
|
+
background: rgba(255, 255, 255, 0.1);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
.react-cupertino-ui-context-menu__label {
|
|
78
|
+
padding: 8px 12px;
|
|
79
|
+
font-size: 12px;
|
|
80
|
+
font-weight: 600;
|
|
81
|
+
color: var(--muted-foreground);
|
|
82
|
+
}
|
|
83
|
+
.react-cupertino-ui-context-menu__label.inset {
|
|
84
|
+
padding-left: 32px;
|
|
85
|
+
}
|
|
86
|
+
.react-cupertino-ui-context-menu__shortcut {
|
|
87
|
+
margin-left: auto;
|
|
88
|
+
font-size: 12px;
|
|
89
|
+
color: var(--muted-foreground);
|
|
90
|
+
letter-spacing: 1px;
|
|
91
|
+
}
|
|
92
|
+
.react-cupertino-ui-context-menu .checkbox-indicator,
|
|
93
|
+
.react-cupertino-ui-context-menu .radio-indicator {
|
|
94
|
+
position: absolute;
|
|
95
|
+
left: 8px;
|
|
96
|
+
width: 16px;
|
|
97
|
+
display: flex;
|
|
98
|
+
align-items: center;
|
|
99
|
+
justify-content: center;
|
|
100
|
+
}
|
|
101
|
+
.react-cupertino-ui-context-menu__preview {
|
|
102
|
+
width: 100%;
|
|
103
|
+
margin: 2px 0 6px;
|
|
104
|
+
display: flex;
|
|
105
|
+
justify-content: center;
|
|
106
|
+
--preview-height: 180px;
|
|
107
|
+
}
|
|
108
|
+
.react-cupertino-ui-context-menu__preview.size-sm {
|
|
109
|
+
--preview-height: 140px;
|
|
110
|
+
}
|
|
111
|
+
.react-cupertino-ui-context-menu__preview.size-lg {
|
|
112
|
+
--preview-height: 220px;
|
|
113
|
+
}
|
|
114
|
+
.react-cupertino-ui-context-menu__preview-card {
|
|
115
|
+
width: 100%;
|
|
116
|
+
border-radius: 18px;
|
|
117
|
+
overflow: hidden;
|
|
118
|
+
position: relative;
|
|
119
|
+
background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.65));
|
|
120
|
+
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
|
|
121
|
+
border: 1px solid rgba(255, 255, 255, 0.6);
|
|
122
|
+
color: var(--foreground);
|
|
123
|
+
}
|
|
124
|
+
@media (prefers-color-scheme: dark) {
|
|
125
|
+
.react-cupertino-ui-context-menu__preview-card {
|
|
126
|
+
background: linear-gradient(180deg, rgba(20, 20, 20, 0.95), rgba(35, 35, 35, 0.7));
|
|
127
|
+
border-color: rgba(255, 255, 255, 0.15);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
.react-cupertino-ui-context-menu__preview-media {
|
|
131
|
+
width: 100%;
|
|
132
|
+
height: var(--preview-height);
|
|
133
|
+
overflow: hidden;
|
|
134
|
+
}
|
|
135
|
+
.react-cupertino-ui-context-menu__preview-media img,
|
|
136
|
+
.react-cupertino-ui-context-menu__preview-media video,
|
|
137
|
+
.react-cupertino-ui-context-menu__preview-media picture,
|
|
138
|
+
.react-cupertino-ui-context-menu__preview-media canvas,
|
|
139
|
+
.react-cupertino-ui-context-menu__preview-media div {
|
|
140
|
+
width: 100%;
|
|
141
|
+
height: 100%;
|
|
142
|
+
object-fit: cover;
|
|
143
|
+
display: block;
|
|
144
|
+
}
|
|
145
|
+
.react-cupertino-ui-context-menu__preview-body {
|
|
146
|
+
padding: 0.85rem 1rem 0.85rem;
|
|
147
|
+
display: flex;
|
|
148
|
+
flex-direction: column;
|
|
149
|
+
gap: 0.25rem;
|
|
150
|
+
}
|
|
151
|
+
.react-cupertino-ui-context-menu__preview-title {
|
|
152
|
+
font-size: 0.95rem;
|
|
153
|
+
font-weight: 600;
|
|
154
|
+
}
|
|
155
|
+
.react-cupertino-ui-context-menu__preview-subtitle {
|
|
156
|
+
font-size: 0.8rem;
|
|
157
|
+
color: var(--muted-foreground);
|
|
158
|
+
}
|
|
159
|
+
.react-cupertino-ui-context-menu__preview-children {
|
|
160
|
+
font-size: 0.78rem;
|
|
161
|
+
color: color-mix(in srgb, var(--foreground), transparent 40%);
|
|
162
|
+
}
|
|
163
|
+
.react-cupertino-ui-context-menu__preview-meta {
|
|
164
|
+
font-size: 0.72rem;
|
|
165
|
+
text-transform: uppercase;
|
|
166
|
+
letter-spacing: 0.08em;
|
|
167
|
+
color: color-mix(in srgb, var(--foreground), transparent 30%);
|
|
168
|
+
}
|
|
169
|
+
.react-cupertino-ui-context-menu__preview-footer {
|
|
170
|
+
padding: 0 1rem 0.85rem;
|
|
171
|
+
font-size: 0.78rem;
|
|
172
|
+
color: color-mix(in srgb, var(--foreground), transparent 20%);
|
|
173
|
+
}
|
|
174
|
+
.react-cupertino-ui-context-menu__trigger-preview {
|
|
175
|
+
position: fixed;
|
|
176
|
+
z-index: 60;
|
|
177
|
+
pointer-events: none;
|
|
178
|
+
transform: translate(-50%, -50%) scale(0.95);
|
|
179
|
+
opacity: 0;
|
|
180
|
+
transition: opacity 200ms ease, transform 320ms cubic-bezier(0.18, 0.86, 0.35, 1.15);
|
|
181
|
+
--trigger-preview-width: 280px;
|
|
182
|
+
}
|
|
183
|
+
.react-cupertino-ui-context-menu__trigger-preview.size-sm {
|
|
184
|
+
--trigger-preview-width: 220px;
|
|
185
|
+
}
|
|
186
|
+
.react-cupertino-ui-context-menu__trigger-preview.size-lg {
|
|
187
|
+
--trigger-preview-width: 320px;
|
|
188
|
+
}
|
|
189
|
+
.react-cupertino-ui-context-menu__trigger-preview[data-state=open] {
|
|
190
|
+
opacity: 1;
|
|
191
|
+
transform: translate(-50%, -50%) scale(1);
|
|
192
|
+
}
|
|
193
|
+
.react-cupertino-ui-context-menu__trigger-preview-inner {
|
|
194
|
+
width: min(var(--trigger-preview-width), 100vw - 2rem);
|
|
195
|
+
border-radius: 22px;
|
|
196
|
+
overflow: hidden;
|
|
197
|
+
background: rgba(255, 255, 255, 0.72);
|
|
198
|
+
backdrop-filter: blur(var(--glass-blur, 48px)) saturate(var(--glass-saturation, 180%));
|
|
199
|
+
-webkit-backdrop-filter: blur(var(--glass-blur, 48px)) saturate(var(--glass-saturation, 180%));
|
|
200
|
+
border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.18));
|
|
201
|
+
box-shadow: var(--glass-shadow, 0 8px 32px rgba(0, 0, 0, 0.12));
|
|
202
|
+
position: relative;
|
|
203
|
+
overflow: hidden;
|
|
204
|
+
}
|
|
205
|
+
.react-cupertino-ui-context-menu__trigger-preview-inner::before {
|
|
206
|
+
content: "";
|
|
207
|
+
position: absolute;
|
|
208
|
+
inset: 0;
|
|
209
|
+
background: var(--glass-highlight, linear-gradient(135deg, rgba(255, 255, 255, 0.4) 0%, transparent 55%));
|
|
210
|
+
border-radius: inherit;
|
|
211
|
+
opacity: var(--glass-highlight-opacity, 0.95);
|
|
212
|
+
pointer-events: none;
|
|
213
|
+
mix-blend-mode: screen;
|
|
214
|
+
}
|
|
215
|
+
.react-cupertino-ui-context-menu__trigger-preview-inner {
|
|
216
|
+
box-shadow: 0 30px 70px rgba(15, 15, 15, 0.35), 0 8px 24px rgba(0, 0, 0, 0.2);
|
|
217
|
+
backdrop-filter: blur(var(--glass-blur, 48px)) saturate(170%);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
[data-context-menu-trigger=true] {
|
|
221
|
+
transition: transform 240ms cubic-bezier(0.2, 0.8, 0.4, 1), filter 200ms ease, box-shadow 200ms ease;
|
|
222
|
+
will-change: transform;
|
|
223
|
+
}
|
|
224
|
+
[data-context-menu-trigger=true][data-preview-visible=true] {
|
|
225
|
+
transform: scale(0.97) translateZ(0);
|
|
226
|
+
filter: brightness(1.02);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
@media (prefers-reduced-motion: reduce) {
|
|
230
|
+
[data-context-menu-trigger=true] {
|
|
231
|
+
transition: none;
|
|
232
|
+
}
|
|
233
|
+
[data-context-menu-trigger=true][data-preview-visible=true] {
|
|
234
|
+
transform: none;
|
|
235
|
+
}
|
|
236
|
+
.react-cupertino-ui-context-menu__trigger-preview {
|
|
237
|
+
transition: none;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
@keyframes zoomIn {
|
|
241
|
+
from {
|
|
242
|
+
opacity: 0;
|
|
243
|
+
transform: scale(0.95);
|
|
244
|
+
}
|
|
245
|
+
to {
|
|
246
|
+
opacity: 1;
|
|
247
|
+
transform: scale(1);
|
|
248
|
+
}
|
|
249
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as ContextMenuPrimitive from "@radix-ui/react-context-menu";
|
|
3
|
+
import "./index.scss";
|
|
4
|
+
type PreviewPlacement = "menu" | "trigger" | "both";
|
|
5
|
+
interface ContextMenuProps extends Omit<React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Root>, "children"> {
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
declare const ContextMenu: ({ children, onOpenChange, ...props }: ContextMenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare const ContextMenuTrigger: React.ForwardRefExoticComponent<Omit<ContextMenuPrimitive.ContextMenuTriggerProps & React.RefAttributes<HTMLSpanElement>, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
10
|
+
declare const ContextMenuGroup: React.ForwardRefExoticComponent<ContextMenuPrimitive.ContextMenuGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
11
|
+
declare const ContextMenuPortal: React.FC<ContextMenuPrimitive.ContextMenuPortalProps>;
|
|
12
|
+
declare const ContextMenuSub: React.FC<ContextMenuPrimitive.ContextMenuSubProps>;
|
|
13
|
+
declare const ContextMenuRadioGroup: React.ForwardRefExoticComponent<ContextMenuPrimitive.ContextMenuRadioGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
14
|
+
declare const ContextMenuSubTrigger: React.ForwardRefExoticComponent<Omit<ContextMenuPrimitive.ContextMenuSubTriggerProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
15
|
+
inset?: boolean;
|
|
16
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
17
|
+
declare const ContextMenuSubContent: React.ForwardRefExoticComponent<Omit<ContextMenuPrimitive.ContextMenuSubContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
18
|
+
interface ContextMenuContentProps extends React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content> {
|
|
19
|
+
preview?: React.ReactNode;
|
|
20
|
+
previewSize?: "sm" | "md" | "lg";
|
|
21
|
+
previewPlacement?: PreviewPlacement;
|
|
22
|
+
previewOffset?: number;
|
|
23
|
+
}
|
|
24
|
+
declare const ContextMenuContent: React.ForwardRefExoticComponent<ContextMenuContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
25
|
+
interface ContextMenuPreviewProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title"> {
|
|
26
|
+
media?: React.ReactNode;
|
|
27
|
+
title?: React.ReactNode;
|
|
28
|
+
subtitle?: React.ReactNode;
|
|
29
|
+
meta?: React.ReactNode;
|
|
30
|
+
footer?: React.ReactNode;
|
|
31
|
+
}
|
|
32
|
+
declare const ContextMenuPreview: {
|
|
33
|
+
({ className, media, title, subtitle, meta, footer, children, ...props }: ContextMenuPreviewProps): import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
displayName: string;
|
|
35
|
+
};
|
|
36
|
+
declare const ContextMenuItem: React.ForwardRefExoticComponent<Omit<ContextMenuPrimitive.ContextMenuItemProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
37
|
+
inset?: boolean;
|
|
38
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
39
|
+
declare const ContextMenuCheckboxItem: React.ForwardRefExoticComponent<Omit<ContextMenuPrimitive.ContextMenuCheckboxItemProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
40
|
+
declare const ContextMenuRadioItem: React.ForwardRefExoticComponent<Omit<ContextMenuPrimitive.ContextMenuRadioItemProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
41
|
+
declare const ContextMenuLabel: React.ForwardRefExoticComponent<Omit<ContextMenuPrimitive.ContextMenuLabelProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
42
|
+
inset?: boolean;
|
|
43
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
44
|
+
declare const ContextMenuSeparator: React.ForwardRefExoticComponent<Omit<ContextMenuPrimitive.ContextMenuSeparatorProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
45
|
+
declare const ContextMenuShortcut: {
|
|
46
|
+
({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>): import("react/jsx-runtime").JSX.Element;
|
|
47
|
+
displayName: string;
|
|
48
|
+
};
|
|
49
|
+
export { ContextMenu, ContextMenuTrigger, ContextMenuContent, ContextMenuItem, ContextMenuCheckboxItem, ContextMenuRadioItem, ContextMenuLabel, ContextMenuSeparator, ContextMenuShortcut, ContextMenuGroup, ContextMenuPortal, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuRadioGroup, ContextMenuPreview, };
|
|
50
|
+
export type { ContextMenuContentProps, ContextMenuProps };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { createPortal } from "react-dom";
|
|
4
|
+
import * as ContextMenuPrimitive from "@radix-ui/react-context-menu";
|
|
5
|
+
import { Check, ChevronRight, Circle } from "lucide-react";
|
|
6
|
+
import { cn } from "@react-cupertino-ui/shared/lib/utils";
|
|
7
|
+
import "./index.scss";
|
|
8
|
+
const defaultPreviewConfig = {
|
|
9
|
+
size: "md",
|
|
10
|
+
placement: "menu",
|
|
11
|
+
offset: -28,
|
|
12
|
+
};
|
|
13
|
+
const ContextMenuPreviewContext = React.createContext(null);
|
|
14
|
+
const useContextMenuPreview = () => React.useContext(ContextMenuPreviewContext);
|
|
15
|
+
const ContextMenuTriggerPreview = () => {
|
|
16
|
+
const context = useContextMenuPreview();
|
|
17
|
+
const previewNode = context?.previewState.node;
|
|
18
|
+
const { placement, size, offset } = context?.previewState.config ?? defaultPreviewConfig;
|
|
19
|
+
const triggerNode = context?.triggerNode;
|
|
20
|
+
const shouldShow = Boolean(typeof document !== "undefined" &&
|
|
21
|
+
previewNode &&
|
|
22
|
+
triggerNode &&
|
|
23
|
+
context?.isOpen &&
|
|
24
|
+
(placement === "trigger" || placement === "both"));
|
|
25
|
+
const [position, setPosition] = React.useState({ x: 0, y: 0 });
|
|
26
|
+
const updatePosition = React.useCallback(() => {
|
|
27
|
+
if (!triggerNode || typeof window === "undefined") {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const rect = triggerNode.getBoundingClientRect();
|
|
31
|
+
setPosition({
|
|
32
|
+
x: rect.left + rect.width / 2,
|
|
33
|
+
y: rect.top + rect.height / 2 + offset,
|
|
34
|
+
});
|
|
35
|
+
}, [offset, triggerNode]);
|
|
36
|
+
React.useLayoutEffect(() => {
|
|
37
|
+
if (shouldShow) {
|
|
38
|
+
updatePosition();
|
|
39
|
+
}
|
|
40
|
+
}, [shouldShow, updatePosition]);
|
|
41
|
+
React.useEffect(() => {
|
|
42
|
+
if (!shouldShow) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const handle = () => updatePosition();
|
|
46
|
+
window.addEventListener("resize", handle);
|
|
47
|
+
window.addEventListener("scroll", handle, true);
|
|
48
|
+
return () => {
|
|
49
|
+
window.removeEventListener("resize", handle);
|
|
50
|
+
window.removeEventListener("scroll", handle, true);
|
|
51
|
+
};
|
|
52
|
+
}, [shouldShow, updatePosition]);
|
|
53
|
+
if (!shouldShow || typeof document === "undefined") {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
return createPortal(_jsx("div", { className: cn("react-cupertino-ui-context-menu__trigger-preview", `size-${size}`), style: { left: `${position.x}px`, top: `${position.y}px` }, "data-state": context?.isOpen ? "open" : "closed", children: _jsx("div", { className: "react-cupertino-ui-context-menu__trigger-preview-inner", children: previewNode }) }), document.body);
|
|
57
|
+
};
|
|
58
|
+
function assignRef(ref, value) {
|
|
59
|
+
if (!ref)
|
|
60
|
+
return;
|
|
61
|
+
if (typeof ref === "function") {
|
|
62
|
+
ref(value);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
ref.current = value;
|
|
66
|
+
}
|
|
67
|
+
const ContextMenu = ({ children, onOpenChange, ...props }) => {
|
|
68
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
69
|
+
const [triggerNode, setTriggerNode] = React.useState(null);
|
|
70
|
+
const [previewState, setPreviewState] = React.useState({
|
|
71
|
+
node: null,
|
|
72
|
+
config: defaultPreviewConfig,
|
|
73
|
+
});
|
|
74
|
+
const handleOpenChange = React.useCallback((nextOpen) => {
|
|
75
|
+
setIsOpen(nextOpen);
|
|
76
|
+
onOpenChange?.(nextOpen);
|
|
77
|
+
}, [onOpenChange]);
|
|
78
|
+
const setPreview = React.useCallback((node, config) => {
|
|
79
|
+
if (!node) {
|
|
80
|
+
setPreviewState({ node: null, config: defaultPreviewConfig });
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
setPreviewState((prev) => ({
|
|
84
|
+
node,
|
|
85
|
+
config: {
|
|
86
|
+
size: config?.size ?? prev.config.size,
|
|
87
|
+
placement: config?.placement ?? prev.config.placement,
|
|
88
|
+
offset: config?.offset ?? prev.config.offset,
|
|
89
|
+
},
|
|
90
|
+
}));
|
|
91
|
+
}, []);
|
|
92
|
+
const contextValue = React.useMemo(() => ({
|
|
93
|
+
triggerNode,
|
|
94
|
+
setTriggerNode,
|
|
95
|
+
previewState,
|
|
96
|
+
setPreview,
|
|
97
|
+
isOpen,
|
|
98
|
+
}), [isOpen, previewState, setPreview, triggerNode]);
|
|
99
|
+
return (_jsxs(ContextMenuPreviewContext.Provider, { value: contextValue, children: [_jsx(ContextMenuPrimitive.Root, { ...props, onOpenChange: handleOpenChange, children: children }), _jsx(ContextMenuTriggerPreview, {})] }));
|
|
100
|
+
};
|
|
101
|
+
const ContextMenuTrigger = React.forwardRef((props, forwardedRef) => {
|
|
102
|
+
const { className, ...rest } = props;
|
|
103
|
+
const context = useContextMenuPreview();
|
|
104
|
+
const showPreview = Boolean(context?.isOpen &&
|
|
105
|
+
context.previewState.node &&
|
|
106
|
+
(context.previewState.config.placement === "trigger" ||
|
|
107
|
+
context.previewState.config.placement === "both"));
|
|
108
|
+
const setTriggerNode = context?.setTriggerNode;
|
|
109
|
+
const composedRef = React.useCallback((node) => {
|
|
110
|
+
if (setTriggerNode) {
|
|
111
|
+
if (node instanceof HTMLElement) {
|
|
112
|
+
setTriggerNode(node);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
setTriggerNode(null);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
assignRef(forwardedRef, node);
|
|
119
|
+
}, [forwardedRef, setTriggerNode]);
|
|
120
|
+
return (_jsx(ContextMenuPrimitive.Trigger, { ...rest, ref: composedRef, className: className, "data-context-menu-trigger": "true", "data-preview-visible": showPreview ? "true" : undefined }));
|
|
121
|
+
});
|
|
122
|
+
ContextMenuTrigger.displayName = ContextMenuPrimitive.Trigger.displayName;
|
|
123
|
+
const ContextMenuGroup = ContextMenuPrimitive.Group;
|
|
124
|
+
const ContextMenuPortal = ContextMenuPrimitive.Portal;
|
|
125
|
+
const ContextMenuSub = ContextMenuPrimitive.Sub;
|
|
126
|
+
const ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup;
|
|
127
|
+
const ContextMenuSubTrigger = React.forwardRef(({ className, inset, children, ...props }, ref) => (_jsxs(ContextMenuPrimitive.SubTrigger, { ref: ref, className: cn("react-cupertino-ui-context-menu__sub-trigger", inset && "inset", className), ...props, children: [children, _jsx(ChevronRight, { className: "ml-auto h-4 w-4" })] })));
|
|
128
|
+
ContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName;
|
|
129
|
+
const ContextMenuSubContent = React.forwardRef(({ className, ...props }, ref) => (_jsx(ContextMenuPrimitive.SubContent, { ref: ref, className: cn("react-cupertino-ui-context-menu__sub-content", className), ...props })));
|
|
130
|
+
ContextMenuSubContent.displayName = ContextMenuPrimitive.SubContent.displayName;
|
|
131
|
+
const ContextMenuContent = React.forwardRef(({ className, preview, previewSize = "md", previewPlacement = "menu", previewOffset, children, ...props }, ref) => {
|
|
132
|
+
const previewContext = useContextMenuPreview();
|
|
133
|
+
const previewApi = previewContext?.setPreview;
|
|
134
|
+
const shouldRenderInline = Boolean(preview && (previewPlacement === "menu" || previewPlacement === "both"));
|
|
135
|
+
React.useEffect(() => {
|
|
136
|
+
if (!previewApi) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (!preview) {
|
|
140
|
+
previewApi(null);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
previewApi(preview, {
|
|
144
|
+
size: previewSize,
|
|
145
|
+
placement: previewPlacement,
|
|
146
|
+
offset: previewOffset ?? defaultPreviewConfig.offset,
|
|
147
|
+
});
|
|
148
|
+
return () => {
|
|
149
|
+
previewApi(null);
|
|
150
|
+
};
|
|
151
|
+
}, [previewApi, preview, previewSize, previewPlacement, previewOffset]);
|
|
152
|
+
return (_jsx(ContextMenuPrimitive.Portal, { children: _jsxs(ContextMenuPrimitive.Content, { ref: ref, className: cn("react-cupertino-ui-context-menu__content", shouldRenderInline && "has-preview", className), "data-has-preview": shouldRenderInline ? "true" : undefined, ...props, children: [shouldRenderInline ? (_jsx("div", { className: cn("react-cupertino-ui-context-menu__preview", `size-${previewSize}`), children: preview })) : null, children] }) }));
|
|
153
|
+
});
|
|
154
|
+
ContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName;
|
|
155
|
+
const ContextMenuPreview = ({ className, media, title, subtitle, meta, footer, children, ...props }) => {
|
|
156
|
+
return (_jsxs("div", { className: cn("react-cupertino-ui-context-menu__preview-card", className), ...props, children: [media ? (_jsx("div", { className: "react-cupertino-ui-context-menu__preview-media", children: media })) : null, (title || subtitle || meta || children) && (_jsxs("div", { className: "react-cupertino-ui-context-menu__preview-body", children: [title && _jsx("p", { className: "react-cupertino-ui-context-menu__preview-title", children: title }), subtitle && (_jsx("p", { className: "react-cupertino-ui-context-menu__preview-subtitle", children: subtitle })), children ? (_jsx("div", { className: "react-cupertino-ui-context-menu__preview-children", children: children })) : null, meta && _jsx("span", { className: "react-cupertino-ui-context-menu__preview-meta", children: meta })] })), footer ? (_jsx("div", { className: "react-cupertino-ui-context-menu__preview-footer", children: footer })) : null] }));
|
|
157
|
+
};
|
|
158
|
+
ContextMenuPreview.displayName = "ContextMenuPreview";
|
|
159
|
+
const ContextMenuItem = React.forwardRef(({ className, inset, ...props }, ref) => (_jsx(ContextMenuPrimitive.Item, { ref: ref, className: cn("react-cupertino-ui-context-menu__item", inset && "inset", className), ...props })));
|
|
160
|
+
ContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName;
|
|
161
|
+
const ContextMenuCheckboxItem = React.forwardRef(({ className, children, checked, ...props }, ref) => (_jsxs(ContextMenuPrimitive.CheckboxItem, { ref: ref, className: cn("react-cupertino-ui-context-menu__checkbox-item", className), checked: checked, ...props, children: [_jsx("span", { className: "checkbox-indicator", children: _jsx(ContextMenuPrimitive.ItemIndicator, { children: _jsx(Check, { className: "h-4 w-4" }) }) }), children] })));
|
|
162
|
+
ContextMenuCheckboxItem.displayName =
|
|
163
|
+
ContextMenuPrimitive.CheckboxItem.displayName;
|
|
164
|
+
const ContextMenuRadioItem = React.forwardRef(({ className, children, ...props }, ref) => (_jsxs(ContextMenuPrimitive.RadioItem, { ref: ref, className: cn("react-cupertino-ui-context-menu__radio-item", className), ...props, children: [_jsx("span", { className: "radio-indicator", children: _jsx(ContextMenuPrimitive.ItemIndicator, { children: _jsx(Circle, { className: "h-2 w-2 fill-current" }) }) }), children] })));
|
|
165
|
+
ContextMenuRadioItem.displayName = ContextMenuPrimitive.RadioItem.displayName;
|
|
166
|
+
const ContextMenuLabel = React.forwardRef(({ className, inset, ...props }, ref) => (_jsx(ContextMenuPrimitive.Label, { ref: ref, className: cn("react-cupertino-ui-context-menu__label", inset && "inset", className), ...props })));
|
|
167
|
+
ContextMenuLabel.displayName = ContextMenuPrimitive.Label.displayName;
|
|
168
|
+
const ContextMenuSeparator = React.forwardRef(({ className, ...props }, ref) => (_jsx(ContextMenuPrimitive.Separator, { ref: ref, className: cn("react-cupertino-ui-context-menu__separator", className), ...props })));
|
|
169
|
+
ContextMenuSeparator.displayName = ContextMenuPrimitive.Separator.displayName;
|
|
170
|
+
const ContextMenuShortcut = ({ className, ...props }) => {
|
|
171
|
+
return (_jsx("span", { className: cn("react-cupertino-ui-context-menu__shortcut", className), ...props }));
|
|
172
|
+
};
|
|
173
|
+
ContextMenuShortcut.displayName = "ContextMenuShortcut";
|
|
174
|
+
export { ContextMenu, ContextMenuTrigger, ContextMenuContent, ContextMenuItem, ContextMenuCheckboxItem, ContextMenuRadioItem, ContextMenuLabel, ContextMenuSeparator, ContextMenuShortcut, ContextMenuGroup, ContextMenuPortal, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuRadioGroup, ContextMenuPreview, };
|
package/dist/index.scss
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
@use "@/styles/mixins/glass" as glass;
|
|
2
|
+
|
|
3
|
+
.react-cupertino-ui-context-menu {
|
|
4
|
+
|
|
5
|
+
&__content,
|
|
6
|
+
&__sub-content {
|
|
7
|
+
min-width: 220px;
|
|
8
|
+
background: rgba(255, 255, 255, 0.75);
|
|
9
|
+
@include glass.glass-panel(light, 40px, 0.75);
|
|
10
|
+
border-radius: 12px;
|
|
11
|
+
padding: 6px;
|
|
12
|
+
box-shadow: 0 10px 40px rgba(0,0,0,0.2);
|
|
13
|
+
animation: zoomIn 0.2s ease-out;
|
|
14
|
+
z-index: 50;
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
gap: 4px;
|
|
18
|
+
|
|
19
|
+
@media (prefers-color-scheme: dark) {
|
|
20
|
+
background: rgba(30, 30, 30, 0.75);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&__item,
|
|
25
|
+
&__checkbox-item,
|
|
26
|
+
&__radio-item,
|
|
27
|
+
&__sub-trigger {
|
|
28
|
+
position: relative;
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
border-radius: 6px;
|
|
32
|
+
padding: 8px 12px;
|
|
33
|
+
font-size: 14px;
|
|
34
|
+
outline: none;
|
|
35
|
+
cursor: default;
|
|
36
|
+
user-select: none;
|
|
37
|
+
color: var(--foreground);
|
|
38
|
+
|
|
39
|
+
&[data-state="open"] {
|
|
40
|
+
background: var(--color-blue);
|
|
41
|
+
color: white;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&[data-highlighted] {
|
|
45
|
+
background: var(--color-blue);
|
|
46
|
+
color: white;
|
|
47
|
+
|
|
48
|
+
.react-cupertino-ui-context-menu__shortcut {
|
|
49
|
+
color: rgba(255,255,255,0.8);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
&[data-disabled] {
|
|
54
|
+
opacity: 0.5;
|
|
55
|
+
pointer-events: none;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&.inset {
|
|
59
|
+
padding-left: 32px;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&__separator {
|
|
64
|
+
height: 1px;
|
|
65
|
+
background: rgba(0,0,0,0.1);
|
|
66
|
+
margin: 4px -6px;
|
|
67
|
+
|
|
68
|
+
@media (prefers-color-scheme: dark) {
|
|
69
|
+
background: rgba(255,255,255,0.1);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&__label {
|
|
74
|
+
padding: 8px 12px;
|
|
75
|
+
font-size: 12px;
|
|
76
|
+
font-weight: 600;
|
|
77
|
+
color: var(--muted-foreground);
|
|
78
|
+
|
|
79
|
+
&.inset {
|
|
80
|
+
padding-left: 32px;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&__shortcut {
|
|
85
|
+
margin-left: auto;
|
|
86
|
+
font-size: 12px;
|
|
87
|
+
color: var(--muted-foreground);
|
|
88
|
+
letter-spacing: 1px;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.checkbox-indicator,
|
|
92
|
+
.radio-indicator {
|
|
93
|
+
position: absolute;
|
|
94
|
+
left: 8px;
|
|
95
|
+
width: 16px;
|
|
96
|
+
display: flex;
|
|
97
|
+
align-items: center;
|
|
98
|
+
justify-content: center;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
&__preview {
|
|
102
|
+
width: 100%;
|
|
103
|
+
margin: 2px 0 6px;
|
|
104
|
+
display: flex;
|
|
105
|
+
justify-content: center;
|
|
106
|
+
--preview-height: 180px;
|
|
107
|
+
|
|
108
|
+
&.size-sm {
|
|
109
|
+
--preview-height: 140px;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
&.size-lg {
|
|
113
|
+
--preview-height: 220px;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
&__preview-card {
|
|
118
|
+
width: 100%;
|
|
119
|
+
border-radius: 18px;
|
|
120
|
+
overflow: hidden;
|
|
121
|
+
position: relative;
|
|
122
|
+
background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(255,255,255,0.65));
|
|
123
|
+
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
|
|
124
|
+
border: 1px solid rgba(255,255,255,0.6);
|
|
125
|
+
color: var(--foreground);
|
|
126
|
+
|
|
127
|
+
@media (prefers-color-scheme: dark) {
|
|
128
|
+
background: linear-gradient(180deg, rgba(20,20,20,0.95), rgba(35,35,35,0.7));
|
|
129
|
+
border-color: rgba(255,255,255,0.15);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
&__preview-media {
|
|
134
|
+
width: 100%;
|
|
135
|
+
height: var(--preview-height);
|
|
136
|
+
overflow: hidden;
|
|
137
|
+
|
|
138
|
+
img,
|
|
139
|
+
video,
|
|
140
|
+
picture,
|
|
141
|
+
canvas,
|
|
142
|
+
div {
|
|
143
|
+
width: 100%;
|
|
144
|
+
height: 100%;
|
|
145
|
+
object-fit: cover;
|
|
146
|
+
display: block;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
&__preview-body {
|
|
151
|
+
padding: 0.85rem 1rem 0.85rem;
|
|
152
|
+
display: flex;
|
|
153
|
+
flex-direction: column;
|
|
154
|
+
gap: 0.25rem;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
&__preview-title {
|
|
158
|
+
font-size: 0.95rem;
|
|
159
|
+
font-weight: 600;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
&__preview-subtitle {
|
|
163
|
+
font-size: 0.8rem;
|
|
164
|
+
color: var(--muted-foreground);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
&__preview-children {
|
|
168
|
+
font-size: 0.78rem;
|
|
169
|
+
color: color-mix(in srgb, var(--foreground), transparent 40%);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
&__preview-meta {
|
|
173
|
+
font-size: 0.72rem;
|
|
174
|
+
text-transform: uppercase;
|
|
175
|
+
letter-spacing: 0.08em;
|
|
176
|
+
color: color-mix(in srgb, var(--foreground), transparent 30%);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
&__preview-footer {
|
|
180
|
+
padding: 0 1rem 0.85rem;
|
|
181
|
+
font-size: 0.78rem;
|
|
182
|
+
color: color-mix(in srgb, var(--foreground), transparent 20%);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
&__trigger-preview {
|
|
186
|
+
position: fixed;
|
|
187
|
+
z-index: 60;
|
|
188
|
+
pointer-events: none;
|
|
189
|
+
transform: translate(-50%, -50%) scale(0.95);
|
|
190
|
+
opacity: 0;
|
|
191
|
+
transition: opacity 200ms ease, transform 320ms cubic-bezier(0.18, 0.86, 0.35, 1.15);
|
|
192
|
+
--trigger-preview-width: 280px;
|
|
193
|
+
|
|
194
|
+
&.size-sm {
|
|
195
|
+
--trigger-preview-width: 220px;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
&.size-lg {
|
|
199
|
+
--trigger-preview-width: 320px;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
&[data-state="open"] {
|
|
203
|
+
opacity: 1;
|
|
204
|
+
transform: translate(-50%, -50%) scale(1);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
&__trigger-preview-inner {
|
|
209
|
+
width: min(var(--trigger-preview-width), calc(100vw - 2rem));
|
|
210
|
+
border-radius: 22px;
|
|
211
|
+
overflow: hidden;
|
|
212
|
+
@include glass.glass-panel(light, var(--glass-blur, 48px), 0.72);
|
|
213
|
+
box-shadow:
|
|
214
|
+
0 30px 70px rgba(15, 15, 15, 0.35),
|
|
215
|
+
0 8px 24px rgba(0, 0, 0, 0.2);
|
|
216
|
+
backdrop-filter: blur(var(--glass-blur, 48px)) saturate(170%);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
[data-context-menu-trigger="true"] {
|
|
221
|
+
transition:
|
|
222
|
+
transform 240ms cubic-bezier(0.2, 0.8, 0.4, 1),
|
|
223
|
+
filter 200ms ease,
|
|
224
|
+
box-shadow 200ms ease;
|
|
225
|
+
will-change: transform;
|
|
226
|
+
|
|
227
|
+
&[data-preview-visible="true"] {
|
|
228
|
+
transform: scale(0.97) translateZ(0);
|
|
229
|
+
filter: brightness(1.02);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
@media (prefers-reduced-motion: reduce) {
|
|
234
|
+
[data-context-menu-trigger="true"] {
|
|
235
|
+
transition: none;
|
|
236
|
+
&[data-preview-visible="true"] {
|
|
237
|
+
transform: none;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.react-cupertino-ui-context-menu__trigger-preview {
|
|
242
|
+
transition: none;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
@keyframes zoomIn {
|
|
247
|
+
from { opacity: 0; transform: scale(0.95); }
|
|
248
|
+
to { opacity: 1; transform: scale(1); }
|
|
249
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-cupertino-ui/context-menu",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "ContextMenu component from React Cupertino UI",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"sideEffects": [
|
|
13
|
+
"./dist/**/*.css",
|
|
14
|
+
"./dist/**/*.scss"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc -p tsconfig.build.json && npm run build:styles",
|
|
18
|
+
"build:styles": "node ../../../scripts/build-styles.mjs"
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"react": "^18.3.1",
|
|
22
|
+
"react-dom": "^18.3.1"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@radix-ui/react-context-menu": "^2.2.16",
|
|
26
|
+
"@react-cupertino-ui/shared": "0.0.0",
|
|
27
|
+
"lucide-react": "^0.417.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"typescript": "^5.2.2"
|
|
31
|
+
},
|
|
32
|
+
"gitHead": "a6b07a7a8a0ab6f4c80884b6fb9d5eb16ee6da1d",
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
}
|
|
36
|
+
}
|