1+ "use client"
2+
3+ import React from "react" ;
4+ import { Code0ComponentProps , Color , mergeCode0Props } from "../../utils" ;
5+ import * as Radix from "@radix-ui/react-context-menu" ;
6+ import "./ContextMenu.style.scss"
7+ import { Card } from "../card/Card" ;
8+ import { Flex } from "../flex/Flex" ;
9+ import { Badge } from "../badge/Badge" ;
10+ import { IconArrowDown , IconArrowUp , IconCornerDownLeft } from "@tabler/icons-react" ;
11+ import { Spacing } from "../spacing/Spacing" ;
12+
13+ export type ContextMenuProps = Code0ComponentProps & Radix . ContextMenuProps
14+ export type ContextMenuTriggerProps = Code0ComponentProps & Radix . ContextMenuTriggerProps
15+ export type ContextMenuPortalProps = Code0ComponentProps & Radix . ContextMenuPortalProps
16+ export type ContextMenuContentProps = Code0ComponentProps & Radix . ContextMenuContentProps & {
17+ color ?: Color
18+ }
19+ export type ContextMenuLabelProps = Code0ComponentProps & Radix . ContextMenuLabelProps
20+ export type ContextMenuItemProps = Code0ComponentProps & Radix . ContextMenuItemProps
21+ export type ContextMenuGroupProps = Code0ComponentProps & Radix . ContextMenuGroupProps
22+ export type ContextMenuSubProps = Code0ComponentProps & Radix . ContextMenuSubProps
23+ export type ContextMenuSubTriggerProps = Code0ComponentProps & Radix . ContextMenuSubTriggerProps
24+ export type ContextMenuSubContentProps = Code0ComponentProps & Radix . ContextMenuSubContentProps & {
25+ color ?: Color
26+ }
27+ export type ContextMenuSeparatorProps = Code0ComponentProps & Radix . ContextMenuSeparatorProps
28+ export type ContextMenuArrowProps = Code0ComponentProps & Radix . ContextMenuArrowProps
29+
30+ export const ContextMenu : React . FC < ContextMenuProps > = ( props ) => {
31+ return < Radix . ContextMenu { ...mergeCode0Props ( `context-menu` , props ) as ContextMenuProps } />
32+ }
33+
34+ export const ContextMenuTrigger : React . FC < ContextMenuTriggerProps > = ( props ) => {
35+ return < Radix . ContextMenuTrigger { ...mergeCode0Props ( "context-menu__trigger" , props ) as ContextMenuTriggerProps } />
36+ }
37+
38+ export const ContextMenuPortal : React . FC < ContextMenuPortalProps > = ( props ) => {
39+ return < Radix . ContextMenuPortal { ...mergeCode0Props ( "context-menu__portal" , props ) as ContextMenuPortalProps } />
40+ }
41+
42+ export const ContextMenuContent : React . FC < ContextMenuContentProps > = ( props ) => {
43+ return < Radix . ContextMenuContent
44+ align = { props . align } { ...mergeCode0Props ( `context-menu__content context-menu__content--${ props . color ?? "secondary" } ` , props ) as ContextMenuContentProps } >
45+ < Card paddingSize = { "xxs" } mt = { - 0.35 } mx = { - 0.35 } style = { { borderWidth : "2px" } } >
46+ { props . children }
47+ </ Card >
48+ < ContextMenuLabel >
49+ < Flex style = { { gap : ".35rem" } } >
50+ < Flex align = { "center" } style = { { gap : "0.35rem" } } >
51+ < Flex >
52+ < Badge border > < IconArrowUp size = { 12 } /> </ Badge >
53+ < Badge border > < IconArrowDown size = { 12 } /> </ Badge >
54+ </ Flex >
55+ move
56+ </ Flex >
57+ < Spacing spacing = { "xxs" } />
58+ < Flex align = { "center" } style = { { gap : ".35rem" } } >
59+ < Badge border > < IconCornerDownLeft size = { 12 } /> </ Badge >
60+ select
61+ </ Flex >
62+ </ Flex >
63+ </ ContextMenuLabel >
64+ </ Radix . ContextMenuContent >
65+ }
66+
67+ export const ContextMenuLabel : React . FC < ContextMenuLabelProps > = ( props ) => {
68+ return < Radix . ContextMenuLabel { ...mergeCode0Props ( "context-menu__label" , props ) as ContextMenuLabelProps } />
69+ }
70+
71+ export const ContextMenuItem : React . FC < ContextMenuItemProps > = ( props ) => {
72+ return < Radix . ContextMenuItem { ...mergeCode0Props ( "context-menu__item" , props ) as ContextMenuItemProps } />
73+ }
74+
75+ export const ContextMenuGroup : React . FC < ContextMenuGroupProps > = ( props ) => {
76+ return < Radix . ContextMenuGroup { ...mergeCode0Props ( "context-menu__group" , props ) as ContextMenuGroupProps } />
77+ }
78+
79+ export const ContextMenuSub : React . FC < ContextMenuSubProps > = ( props ) => {
80+ return < Radix . ContextMenuSub { ...mergeCode0Props ( "context-menu__sub" , props ) as ContextMenuSubProps } />
81+ }
82+
83+ export const ContextMenuSubTrigger : React . FC < ContextMenuSubTriggerProps > = ( props ) => {
84+ return < Radix . ContextMenuSubTrigger { ...mergeCode0Props ( "context-menu__sub-trigger" , props ) as ContextMenuSubTriggerProps } />
85+ }
86+
87+ export const ContextMenuSubContent : React . FC < ContextMenuSubContentProps > = ( props ) => {
88+ return < Radix . ContextMenuSubContent { ...mergeCode0Props ( `context-menu__sub-content context-menu__sub-content--${ props . color ?? "secondary" } ` , props ) as ContextMenuSubContentProps } >
89+ < Card paddingSize = { "xxs" } mt = { - 0.35 } mx = { - 0.35 } style = { { borderWidth : "2px" } } >
90+ { props . children }
91+ </ Card >
92+ < ContextMenuLabel >
93+ < Flex style = { { gap : ".35rem" } } >
94+ < Flex align = { "center" } style = { { gap : "0.35rem" } } >
95+ < Flex >
96+ < Badge border > < IconArrowUp size = { 12 } /> </ Badge >
97+ < Badge border > < IconArrowDown size = { 12 } /> </ Badge >
98+ </ Flex >
99+ move
100+ </ Flex >
101+ < Spacing spacing = { "xxs" } />
102+ < Flex align = { "center" } style = { { gap : ".35rem" } } >
103+ < Badge border > < IconCornerDownLeft size = { 12 } /> </ Badge >
104+ select
105+ </ Flex >
106+ </ Flex >
107+ </ ContextMenuLabel >
108+ </ Radix . ContextMenuSubContent >
109+ }
110+
111+ export const ContextMenuSeparator : React . FC < ContextMenuSeparatorProps > = ( props ) => {
112+ return < Radix . ContextMenuSeparator { ...mergeCode0Props ( "context-menu__separator" , props ) as ContextMenuSeparatorProps } />
113+ }
114+
115+ export const ContextMenuArrow : React . FC < ContextMenuArrowProps > = ( props ) => {
116+ return < Radix . ContextMenuArrow { ...mergeCode0Props ( "context-menu__arrow" , props ) as ContextMenuArrowProps } />
117+ }
0 commit comments