@olympusoss/canvas 2.20.1 → 4.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/package.json +41 -177
- package/src/cn.ts +3 -0
- package/src/index.ts +12 -603
- package/src/theme.ts +41 -0
- package/src/tokens.ts +11 -0
- package/styles/base.css +17 -0
- package/styles/canvas.css +69 -52
- package/styles/components/alert.css +66 -0
- package/styles/components/app-shell.css +46 -0
- package/styles/components/avatar.css +15 -0
- package/styles/components/badge.css +83 -0
- package/styles/components/breadcrumb.css +35 -0
- package/styles/components/button-group.css +23 -0
- package/styles/components/button.css +107 -0
- package/styles/components/calendar.css +73 -0
- package/styles/components/card.css +58 -0
- package/styles/components/checkbox.css +55 -0
- package/styles/components/code-block.css +18 -0
- package/styles/components/combobox.css +75 -0
- package/styles/components/command.css +94 -0
- package/styles/components/data-table.css +142 -0
- package/styles/components/dialog.css +72 -0
- package/styles/components/dropdown.css +54 -0
- package/styles/components/empty-state.css +17 -0
- package/styles/components/field.css +27 -0
- package/styles/components/filter-panel.css +58 -0
- package/styles/components/form.css +27 -0
- package/styles/components/icon.css +8 -0
- package/styles/components/input-group.css +45 -0
- package/styles/components/input.css +56 -0
- package/styles/components/kbd.css +15 -0
- package/styles/components/page-header.css +52 -0
- package/styles/components/pagination.css +48 -0
- package/styles/components/popover.css +14 -0
- package/styles/components/radio.css +28 -0
- package/styles/components/row-menu.css +69 -0
- package/styles/components/section-card.css +49 -0
- package/styles/components/select.css +57 -0
- package/styles/components/separator.css +32 -0
- package/styles/components/sheet.css +70 -0
- package/styles/components/sidebar.css +146 -0
- package/styles/components/skeleton.css +32 -0
- package/styles/components/spinner.css +26 -0
- package/styles/components/stat-card.css +71 -0
- package/styles/components/stepper.css +63 -0
- package/styles/components/switch.css +45 -0
- package/styles/components/tabs.css +40 -0
- package/styles/components/textarea.css +31 -0
- package/styles/components/toast.css +95 -0
- package/styles/components/tooltip.css +53 -0
- package/styles/components/topbar.css +24 -0
- package/styles/components/typography.css +105 -0
- package/styles/patterns/backdrops.css +35 -0
- package/styles/patterns/density.css +66 -0
- package/styles/patterns/focus.css +38 -0
- package/styles/patterns/glass.css +85 -0
- package/styles/patterns/high-contrast.css +70 -0
- package/styles/patterns/reduced-motion.css +12 -0
- package/styles/patterns/scrollbar.css +10 -0
- package/styles/reset.css +89 -0
- package/styles/tokens/colors.css +106 -0
- package/styles/tokens/motion.css +33 -0
- package/styles/tokens/radius.css +10 -0
- package/styles/tokens/shadows.css +35 -0
- package/styles/tokens/spacing.css +19 -0
- package/styles/tokens/typography.css +6 -0
- package/styles/tokens/z-index.css +12 -0
- package/tsconfig.json +20 -21
- package/README.md +0 -60
- package/src/components/atoms/README.md +0 -11
- package/src/components/atoms/aspect-ratio.tsx +0 -32
- package/src/components/atoms/avatar.tsx +0 -98
- package/src/components/atoms/badge.tsx +0 -44
- package/src/components/atoms/brand-mark.tsx +0 -74
- package/src/components/atoms/button.tsx +0 -105
- package/src/components/atoms/checkbox.tsx +0 -63
- package/src/components/atoms/flex-box.tsx +0 -105
- package/src/components/atoms/icon.tsx +0 -34
- package/src/components/atoms/input.tsx +0 -92
- package/src/components/atoms/label.tsx +0 -41
- package/src/components/atoms/logo.tsx +0 -89
- package/src/components/atoms/progress.tsx +0 -55
- package/src/components/atoms/radio-group.tsx +0 -122
- package/src/components/atoms/scroll-area.tsx +0 -106
- package/src/components/atoms/section.tsx +0 -48
- package/src/components/atoms/separator.tsx +0 -45
- package/src/components/atoms/skeleton.tsx +0 -17
- package/src/components/atoms/slider.tsx +0 -93
- package/src/components/atoms/spinner.tsx +0 -47
- package/src/components/atoms/switch.tsx +0 -60
- package/src/components/atoms/textarea.tsx +0 -78
- package/src/components/atoms/toggle.tsx +0 -80
- package/src/components/charts/activity-heatmap.tsx +0 -186
- package/src/components/charts/axes.tsx +0 -21
- package/src/components/charts/chart-container.tsx +0 -254
- package/src/components/charts/chart-legend.tsx +0 -67
- package/src/components/charts/chart-tooltip.tsx +0 -161
- package/src/components/charts/chart-types.tsx +0 -49
- package/src/components/charts/containers.tsx +0 -11
- package/src/components/charts/data.tsx +0 -16
- package/src/components/charts/details.tsx +0 -25
- package/src/components/charts/dot-pulse.tsx +0 -61
- package/src/components/charts/gauge.tsx +0 -106
- package/src/components/charts/grids.tsx +0 -8
- package/src/components/charts/index.ts +0 -62
- package/src/components/charts/labeled-bar-list.tsx +0 -85
- package/src/components/charts/metric-breakdown.tsx +0 -316
- package/src/components/charts/references.tsx +0 -8
- package/src/components/charts/service-health-list.tsx +0 -85
- package/src/components/charts/sparkline-area.tsx +0 -80
- package/src/components/charts/sparkline.tsx +0 -52
- package/src/components/charts/stacked-bar.tsx +0 -104
- package/src/components/charts/text.tsx +0 -10
- package/src/components/charts/world-heat-map-inner.tsx +0 -317
- package/src/components/charts/world-heat-map.tsx +0 -184
- package/src/components/molecules/README.md +0 -12
- package/src/components/molecules/action-bar.tsx +0 -73
- package/src/components/molecules/activity-item.tsx +0 -74
- package/src/components/molecules/alert.tsx +0 -86
- package/src/components/molecules/animated-background.tsx +0 -92
- package/src/components/molecules/auth-shell.tsx +0 -95
- package/src/components/molecules/brand-lockup.tsx +0 -48
- package/src/components/molecules/breadcrumb.tsx +0 -157
- package/src/components/molecules/button-group.tsx +0 -104
- package/src/components/molecules/calendar.tsx +0 -217
- package/src/components/molecules/card.tsx +0 -102
- package/src/components/molecules/client-brand.tsx +0 -95
- package/src/components/molecules/code-block.tsx +0 -86
- package/src/components/molecules/countdown-button.tsx +0 -92
- package/src/components/molecules/empty-state.tsx +0 -56
- package/src/components/molecules/error-state.tsx +0 -42
- package/src/components/molecules/field-display.tsx +0 -35
- package/src/components/molecules/input-otp.tsx +0 -74
- package/src/components/molecules/launcher-card.tsx +0 -152
- package/src/components/molecules/loading-state.tsx +0 -36
- package/src/components/molecules/notification-item.tsx +0 -67
- package/src/components/molecules/notification-list.tsx +0 -45
- package/src/components/molecules/number-badge.tsx +0 -53
- package/src/components/molecules/or-separator.tsx +0 -38
- package/src/components/molecules/page-header.tsx +0 -88
- package/src/components/molecules/page-tabs.tsx +0 -94
- package/src/components/molecules/pagination.tsx +0 -150
- package/src/components/molecules/password-input.tsx +0 -83
- package/src/components/molecules/password-strength-meter.tsx +0 -104
- package/src/components/molecules/phone-input.tsx +0 -200
- package/src/components/molecules/search-bar.tsx +0 -64
- package/src/components/molecules/secret-field.tsx +0 -158
- package/src/components/molecules/section-card.tsx +0 -91
- package/src/components/molecules/social-buttons.tsx +0 -165
- package/src/components/molecules/stat-card.tsx +0 -100
- package/src/components/molecules/status-badge.tsx +0 -42
- package/src/components/molecules/stepper.tsx +0 -96
- package/src/components/molecules/table.tsx +0 -157
- package/src/components/molecules/terminal.tsx +0 -74
- package/src/components/molecules/toggle-group.tsx +0 -145
- package/src/components/molecules/tooltip.tsx +0 -155
- package/src/components/molecules/user-avatar-chip.tsx +0 -71
- package/src/components/organisms/README.md +0 -14
- package/src/components/organisms/accordion.tsx +0 -154
- package/src/components/organisms/alert-dialog.tsx +0 -277
- package/src/components/organisms/carousel.tsx +0 -244
- package/src/components/organisms/collapsible.tsx +0 -69
- package/src/components/organisms/command.tsx +0 -144
- package/src/components/organisms/context-menu.tsx +0 -339
- package/src/components/organisms/dashboard-grid.tsx +0 -369
- package/src/components/organisms/data-table.tsx +0 -330
- package/src/components/organisms/dialog.tsx +0 -312
- package/src/components/organisms/drawer.tsx +0 -123
- package/src/components/organisms/dropdown-menu.tsx +0 -440
- package/src/components/organisms/editors/code-editor.tsx +0 -144
- package/src/components/organisms/editors/index.ts +0 -4
- package/src/components/organisms/editors/markdown-editor.tsx +0 -153
- package/src/components/organisms/editors/markdown-renderer.ts +0 -27
- package/src/components/organisms/editors/prose-canvas-classes.ts +0 -45
- package/src/components/organisms/editors/rich-text-editor.tsx +0 -126
- package/src/components/organisms/editors/toolbar/md-toolbar.tsx +0 -129
- package/src/components/organisms/editors/toolbar/rte-toolbar.tsx +0 -211
- package/src/components/organisms/editors/toolbar/toolbar-shell.tsx +0 -45
- package/src/components/organisms/editors/use-codemirror-theme.ts +0 -61
- package/src/components/organisms/error-boundary.tsx +0 -61
- package/src/components/organisms/form.tsx +0 -174
- package/src/components/organisms/hover-card.tsx +0 -115
- package/src/components/organisms/menubar.tsx +0 -498
- package/src/components/organisms/navbar.tsx +0 -104
- package/src/components/organisms/navigation-menu.tsx +0 -235
- package/src/components/organisms/popover.tsx +0 -149
- package/src/components/organisms/resizable.tsx +0 -58
- package/src/components/organisms/schema-form.tsx +0 -232
- package/src/components/organisms/select.tsx +0 -309
- package/src/components/organisms/sheet.tsx +0 -265
- package/src/components/organisms/sidebar.tsx +0 -1040
- package/src/components/organisms/sonner.tsx +0 -96
- package/src/components/organisms/tabs.tsx +0 -133
- package/src/components/organisms/theme-provider.tsx +0 -101
- package/src/hooks/use-mobile.tsx +0 -19
- package/src/lib/portal-container.tsx +0 -35
- package/src/lib/utils.ts +0 -6
- package/src/native.ts +0 -23
- package/src/tokens/colors.ts +0 -91
- package/src/tokens/index.ts +0 -3
- package/src/tokens/spacing.ts +0 -55
- package/src/tokens/typography.ts +0 -27
- package/styles/dashboard-grid.css +0 -47
- package/styles/fonts/Roboto-VariableFont_wdth_wght.ttf +0 -0
- package/styles/glass.css +0 -171
- package/styles/leaflet.css +0 -13
- package/styles/tokens.css +0 -317
- package/tailwind.config.ts +0 -70
|
@@ -1,440 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
4
|
-
import { Check, ChevronRight, Circle } from "lucide-react";
|
|
5
|
-
import * as React from "react";
|
|
6
|
-
|
|
7
|
-
import { usePortalContainer } from "../../lib/portal-container";
|
|
8
|
-
import { cn } from "../../lib/utils";
|
|
9
|
-
|
|
10
|
-
export interface DropdownMenuProps extends React.ComponentProps<typeof DropdownMenuPrimitive.Root> {
|
|
11
|
-
/** Controlled open state. Pair with `onOpenChange`. */
|
|
12
|
-
open?: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Initial open state for uncontrolled usage.
|
|
15
|
-
* @default false
|
|
16
|
-
*/
|
|
17
|
-
defaultOpen?: boolean;
|
|
18
|
-
/** Fires whenever the menu opens or closes. */
|
|
19
|
-
onOpenChange?: (open: boolean) => void;
|
|
20
|
-
/**
|
|
21
|
-
* When true, blocks focus from leaving the menu.
|
|
22
|
-
* @default true
|
|
23
|
-
*/
|
|
24
|
-
modal?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Reading direction. Affects keyboard arrow navigation.
|
|
27
|
-
* @default "ltr"
|
|
28
|
-
*/
|
|
29
|
-
dir?: "ltr" | "rtl";
|
|
30
|
-
/** Trigger + Content. */
|
|
31
|
-
children?: React.ReactNode;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const DropdownMenu = DropdownMenuPrimitive.Root as React.FC<DropdownMenuProps>;
|
|
35
|
-
|
|
36
|
-
export interface DropdownMenuTriggerProps
|
|
37
|
-
extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Trigger> {
|
|
38
|
-
/**
|
|
39
|
-
* Render as a Radix Slot.
|
|
40
|
-
* @default false
|
|
41
|
-
*/
|
|
42
|
-
asChild?: boolean;
|
|
43
|
-
children?: React.ReactNode;
|
|
44
|
-
className?: string;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger as React.ForwardRefExoticComponent<
|
|
48
|
-
DropdownMenuTriggerProps & React.RefAttributes<HTMLButtonElement>
|
|
49
|
-
>;
|
|
50
|
-
|
|
51
|
-
export interface DropdownMenuGroupProps
|
|
52
|
-
extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Group> {
|
|
53
|
-
/** Items grouped together for screen-reader semantics. */
|
|
54
|
-
children?: React.ReactNode;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const DropdownMenuGroup = DropdownMenuPrimitive.Group as React.ForwardRefExoticComponent<
|
|
58
|
-
DropdownMenuGroupProps & React.RefAttributes<HTMLDivElement>
|
|
59
|
-
>;
|
|
60
|
-
|
|
61
|
-
export interface DropdownMenuPortalProps
|
|
62
|
-
extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Portal> {
|
|
63
|
-
/** DOM element to portal into. Defaults to `document.body`. */
|
|
64
|
-
container?: HTMLElement | null;
|
|
65
|
-
/**
|
|
66
|
-
* Force the portal to mount even when the menu is closed.
|
|
67
|
-
* @default false
|
|
68
|
-
*/
|
|
69
|
-
forceMount?: true;
|
|
70
|
-
children?: React.ReactNode;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const DropdownMenuPortal = DropdownMenuPrimitive.Portal as React.FC<DropdownMenuPortalProps>;
|
|
74
|
-
|
|
75
|
-
export interface DropdownMenuSubProps
|
|
76
|
-
extends React.ComponentProps<typeof DropdownMenuPrimitive.Sub> {
|
|
77
|
-
/** Controlled open state of the sub-menu. */
|
|
78
|
-
open?: boolean;
|
|
79
|
-
/** Initial open state for uncontrolled usage. */
|
|
80
|
-
defaultOpen?: boolean;
|
|
81
|
-
/** Fires whenever the sub-menu opens or closes. */
|
|
82
|
-
onOpenChange?: (open: boolean) => void;
|
|
83
|
-
/** SubTrigger + SubContent. */
|
|
84
|
-
children?: React.ReactNode;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const DropdownMenuSub = DropdownMenuPrimitive.Sub as React.FC<DropdownMenuSubProps>;
|
|
88
|
-
|
|
89
|
-
export interface DropdownMenuRadioGroupProps
|
|
90
|
-
extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioGroup> {
|
|
91
|
-
/** Currently selected value (the value of the active RadioItem). */
|
|
92
|
-
value?: string;
|
|
93
|
-
/** Fires when the user picks a different RadioItem. */
|
|
94
|
-
onValueChange?: (value: string) => void;
|
|
95
|
-
/** A list of `<DropdownMenuRadioItem>`s. */
|
|
96
|
-
children?: React.ReactNode;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup as React.ForwardRefExoticComponent<
|
|
100
|
-
DropdownMenuRadioGroupProps & React.RefAttributes<HTMLDivElement>
|
|
101
|
-
>;
|
|
102
|
-
|
|
103
|
-
export interface DropdownMenuSubTriggerProps
|
|
104
|
-
extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> {
|
|
105
|
-
/**
|
|
106
|
-
* Add left padding so this row visually aligns with sibling
|
|
107
|
-
* checkbox/radio items that have leading indicators.
|
|
108
|
-
* @default false
|
|
109
|
-
*/
|
|
110
|
-
inset?: boolean;
|
|
111
|
-
/**
|
|
112
|
-
* Disable the sub-trigger.
|
|
113
|
-
* @default false
|
|
114
|
-
*/
|
|
115
|
-
disabled?: boolean;
|
|
116
|
-
/**
|
|
117
|
-
* Render as a Radix Slot.
|
|
118
|
-
* @default false
|
|
119
|
-
*/
|
|
120
|
-
asChild?: boolean;
|
|
121
|
-
/** Trigger label. */
|
|
122
|
-
children?: React.ReactNode;
|
|
123
|
-
className?: string;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const DropdownMenuSubTrigger = React.forwardRef<
|
|
127
|
-
React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
|
|
128
|
-
DropdownMenuSubTriggerProps
|
|
129
|
-
>(({ className, inset, children, ...props }, ref) => (
|
|
130
|
-
<DropdownMenuPrimitive.SubTrigger
|
|
131
|
-
ref={ref}
|
|
132
|
-
className={cn(
|
|
133
|
-
"flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
134
|
-
inset && "pl-8",
|
|
135
|
-
className,
|
|
136
|
-
)}
|
|
137
|
-
{...props}
|
|
138
|
-
>
|
|
139
|
-
{children}
|
|
140
|
-
<ChevronRight className="ml-auto" />
|
|
141
|
-
</DropdownMenuPrimitive.SubTrigger>
|
|
142
|
-
));
|
|
143
|
-
DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
|
|
144
|
-
|
|
145
|
-
export interface DropdownMenuSubContentProps
|
|
146
|
-
extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent> {
|
|
147
|
-
/** Distance from the parent menu (px). */
|
|
148
|
-
sideOffset?: number;
|
|
149
|
-
/** Distance from the alignment edge (px). */
|
|
150
|
-
alignOffset?: number;
|
|
151
|
-
/** Avoid colliding with viewport edges. */
|
|
152
|
-
avoidCollisions?: boolean;
|
|
153
|
-
/** Force the sub-content to mount even when closed. */
|
|
154
|
-
forceMount?: true;
|
|
155
|
-
asChild?: boolean;
|
|
156
|
-
children?: React.ReactNode;
|
|
157
|
-
className?: string;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const DropdownMenuSubContent = React.forwardRef<
|
|
161
|
-
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
|
|
162
|
-
DropdownMenuSubContentProps
|
|
163
|
-
>(({ className, ...props }, ref) => (
|
|
164
|
-
<DropdownMenuPrimitive.SubContent
|
|
165
|
-
ref={ref}
|
|
166
|
-
data-slot="dropdown-menu-sub-content"
|
|
167
|
-
className={cn(
|
|
168
|
-
"z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[var(--radix-dropdown-menu-content-transform-origin)]",
|
|
169
|
-
className,
|
|
170
|
-
)}
|
|
171
|
-
{...props}
|
|
172
|
-
/>
|
|
173
|
-
));
|
|
174
|
-
DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
|
|
175
|
-
|
|
176
|
-
export interface DropdownMenuContentProps
|
|
177
|
-
extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content> {
|
|
178
|
-
/**
|
|
179
|
-
* Distance from the trigger (px).
|
|
180
|
-
* @default 4
|
|
181
|
-
*/
|
|
182
|
-
sideOffset?: number;
|
|
183
|
-
/**
|
|
184
|
-
* Distance from the alignment edge (px).
|
|
185
|
-
* @default 0
|
|
186
|
-
*/
|
|
187
|
-
alignOffset?: number;
|
|
188
|
-
/**
|
|
189
|
-
* Preferred side of the trigger to render on.
|
|
190
|
-
* @default "bottom"
|
|
191
|
-
*/
|
|
192
|
-
side?: "top" | "right" | "bottom" | "left";
|
|
193
|
-
/**
|
|
194
|
-
* Alignment along the chosen side.
|
|
195
|
-
* @default "center"
|
|
196
|
-
*/
|
|
197
|
-
align?: "start" | "center" | "end";
|
|
198
|
-
/**
|
|
199
|
-
* Avoid colliding with the viewport edges.
|
|
200
|
-
* @default true
|
|
201
|
-
*/
|
|
202
|
-
avoidCollisions?: boolean;
|
|
203
|
-
/** Padding kept from collision boundaries. */
|
|
204
|
-
collisionPadding?: number | { top?: number; right?: number; bottom?: number; left?: number };
|
|
205
|
-
/** Force the content to mount even when closed. */
|
|
206
|
-
forceMount?: true;
|
|
207
|
-
/** Render as a Radix Slot. */
|
|
208
|
-
asChild?: boolean;
|
|
209
|
-
/** Loop arrow-key navigation through items. */
|
|
210
|
-
loop?: boolean;
|
|
211
|
-
/** Fires when the Escape key is pressed. */
|
|
212
|
-
onEscapeKeyDown?: (event: KeyboardEvent) => void;
|
|
213
|
-
/** Fires on pointer event outside the menu. */
|
|
214
|
-
onPointerDownOutside?: (event: CustomEvent<{ originalEvent: PointerEvent }>) => void;
|
|
215
|
-
/** Fires on any interaction outside (focus + pointer). */
|
|
216
|
-
onInteractOutside?: (event: Event) => void;
|
|
217
|
-
/** Items, separators, labels, sub-menus. */
|
|
218
|
-
children?: React.ReactNode;
|
|
219
|
-
className?: string;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
const DropdownMenuContent = React.forwardRef<
|
|
223
|
-
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
|
|
224
|
-
DropdownMenuContentProps
|
|
225
|
-
>(({ className, sideOffset = 4, ...props }, ref) => {
|
|
226
|
-
const container = usePortalContainer();
|
|
227
|
-
return (
|
|
228
|
-
<DropdownMenuPrimitive.Portal container={container ?? undefined}>
|
|
229
|
-
<DropdownMenuPrimitive.Content
|
|
230
|
-
ref={ref}
|
|
231
|
-
data-slot="dropdown-menu-content"
|
|
232
|
-
sideOffset={sideOffset}
|
|
233
|
-
className={cn(
|
|
234
|
-
"z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md",
|
|
235
|
-
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[var(--radix-dropdown-menu-content-transform-origin)]",
|
|
236
|
-
className,
|
|
237
|
-
)}
|
|
238
|
-
{...props}
|
|
239
|
-
/>
|
|
240
|
-
</DropdownMenuPrimitive.Portal>
|
|
241
|
-
);
|
|
242
|
-
});
|
|
243
|
-
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
|
244
|
-
|
|
245
|
-
export interface DropdownMenuItemProps
|
|
246
|
-
extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> {
|
|
247
|
-
/**
|
|
248
|
-
* Add left padding so this row aligns with sibling checkbox/radio
|
|
249
|
-
* items that have leading indicators.
|
|
250
|
-
* @default false
|
|
251
|
-
*/
|
|
252
|
-
inset?: boolean;
|
|
253
|
-
/**
|
|
254
|
-
* Disable the item.
|
|
255
|
-
* @default false
|
|
256
|
-
*/
|
|
257
|
-
disabled?: boolean;
|
|
258
|
-
/** Fires when the item is activated (click, Enter, Space). */
|
|
259
|
-
onSelect?: (event: Event) => void;
|
|
260
|
-
/**
|
|
261
|
-
* Render as a Radix Slot — wrap a router `<Link>` to use the item as
|
|
262
|
-
* navigation.
|
|
263
|
-
* @default false
|
|
264
|
-
*/
|
|
265
|
-
asChild?: boolean;
|
|
266
|
-
/** Item label or any nested elements. */
|
|
267
|
-
children?: React.ReactNode;
|
|
268
|
-
className?: string;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
const DropdownMenuItem = React.forwardRef<
|
|
272
|
-
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
|
|
273
|
-
DropdownMenuItemProps
|
|
274
|
-
>(({ className, inset, ...props }, ref) => (
|
|
275
|
-
<DropdownMenuPrimitive.Item
|
|
276
|
-
ref={ref}
|
|
277
|
-
className={cn(
|
|
278
|
-
"relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",
|
|
279
|
-
inset && "pl-8",
|
|
280
|
-
className,
|
|
281
|
-
)}
|
|
282
|
-
{...props}
|
|
283
|
-
/>
|
|
284
|
-
));
|
|
285
|
-
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
|
|
286
|
-
|
|
287
|
-
export interface DropdownMenuCheckboxItemProps
|
|
288
|
-
extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem> {
|
|
289
|
-
/** Controlled checked state. */
|
|
290
|
-
checked?: boolean | "indeterminate";
|
|
291
|
-
/** Fires when the user toggles the item. */
|
|
292
|
-
onCheckedChange?: (checked: boolean) => void;
|
|
293
|
-
/**
|
|
294
|
-
* Disable the item.
|
|
295
|
-
* @default false
|
|
296
|
-
*/
|
|
297
|
-
disabled?: boolean;
|
|
298
|
-
/** Fires when the item is activated. */
|
|
299
|
-
onSelect?: (event: Event) => void;
|
|
300
|
-
asChild?: boolean;
|
|
301
|
-
/** Item label. */
|
|
302
|
-
children?: React.ReactNode;
|
|
303
|
-
className?: string;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
const DropdownMenuCheckboxItem = React.forwardRef<
|
|
307
|
-
React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
|
|
308
|
-
DropdownMenuCheckboxItemProps
|
|
309
|
-
>(({ className, children, checked, ...props }, ref) => (
|
|
310
|
-
<DropdownMenuPrimitive.CheckboxItem
|
|
311
|
-
ref={ref}
|
|
312
|
-
className={cn(
|
|
313
|
-
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
314
|
-
className,
|
|
315
|
-
)}
|
|
316
|
-
checked={checked}
|
|
317
|
-
{...props}
|
|
318
|
-
>
|
|
319
|
-
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
320
|
-
<DropdownMenuPrimitive.ItemIndicator>
|
|
321
|
-
<Check className="h-4 w-4" />
|
|
322
|
-
</DropdownMenuPrimitive.ItemIndicator>
|
|
323
|
-
</span>
|
|
324
|
-
{children}
|
|
325
|
-
</DropdownMenuPrimitive.CheckboxItem>
|
|
326
|
-
));
|
|
327
|
-
DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;
|
|
328
|
-
|
|
329
|
-
export interface DropdownMenuRadioItemProps
|
|
330
|
-
extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem> {
|
|
331
|
-
/** Required — value reported when this item is selected. Match parent `<RadioGroup>`'s value. */
|
|
332
|
-
value: string;
|
|
333
|
-
/**
|
|
334
|
-
* Disable the item.
|
|
335
|
-
* @default false
|
|
336
|
-
*/
|
|
337
|
-
disabled?: boolean;
|
|
338
|
-
/** Fires when the item is activated. */
|
|
339
|
-
onSelect?: (event: Event) => void;
|
|
340
|
-
asChild?: boolean;
|
|
341
|
-
children?: React.ReactNode;
|
|
342
|
-
className?: string;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
const DropdownMenuRadioItem = React.forwardRef<
|
|
346
|
-
React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
|
|
347
|
-
DropdownMenuRadioItemProps
|
|
348
|
-
>(({ className, children, ...props }, ref) => (
|
|
349
|
-
<DropdownMenuPrimitive.RadioItem
|
|
350
|
-
ref={ref}
|
|
351
|
-
className={cn(
|
|
352
|
-
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
353
|
-
className,
|
|
354
|
-
)}
|
|
355
|
-
{...props}
|
|
356
|
-
>
|
|
357
|
-
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
358
|
-
<DropdownMenuPrimitive.ItemIndicator>
|
|
359
|
-
<Circle className="h-2 w-2 fill-current" />
|
|
360
|
-
</DropdownMenuPrimitive.ItemIndicator>
|
|
361
|
-
</span>
|
|
362
|
-
{children}
|
|
363
|
-
</DropdownMenuPrimitive.RadioItem>
|
|
364
|
-
));
|
|
365
|
-
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
|
|
366
|
-
|
|
367
|
-
export interface DropdownMenuLabelProps
|
|
368
|
-
extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> {
|
|
369
|
-
/**
|
|
370
|
-
* Add left padding so this row aligns with sibling checkbox/radio
|
|
371
|
-
* items.
|
|
372
|
-
* @default false
|
|
373
|
-
*/
|
|
374
|
-
inset?: boolean;
|
|
375
|
-
asChild?: boolean;
|
|
376
|
-
/** Section heading text. */
|
|
377
|
-
children?: React.ReactNode;
|
|
378
|
-
className?: string;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
const DropdownMenuLabel = React.forwardRef<
|
|
382
|
-
React.ElementRef<typeof DropdownMenuPrimitive.Label>,
|
|
383
|
-
DropdownMenuLabelProps
|
|
384
|
-
>(({ className, inset, ...props }, ref) => (
|
|
385
|
-
<DropdownMenuPrimitive.Label
|
|
386
|
-
ref={ref}
|
|
387
|
-
className={cn("px-2 py-1.5 text-sm font-semibold", inset && "pl-8", className)}
|
|
388
|
-
{...props}
|
|
389
|
-
/>
|
|
390
|
-
));
|
|
391
|
-
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
|
|
392
|
-
|
|
393
|
-
export interface DropdownMenuSeparatorProps
|
|
394
|
-
extends React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator> {
|
|
395
|
-
asChild?: boolean;
|
|
396
|
-
className?: string;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
const DropdownMenuSeparator = React.forwardRef<
|
|
400
|
-
React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
|
|
401
|
-
DropdownMenuSeparatorProps
|
|
402
|
-
>(({ className, ...props }, ref) => (
|
|
403
|
-
<DropdownMenuPrimitive.Separator
|
|
404
|
-
ref={ref}
|
|
405
|
-
className={cn("-mx-1 my-1 h-px bg-muted", className)}
|
|
406
|
-
{...props}
|
|
407
|
-
/>
|
|
408
|
-
));
|
|
409
|
-
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
|
|
410
|
-
|
|
411
|
-
export interface DropdownMenuShortcutProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
412
|
-
/** Keyboard shortcut text (e.g. "⌘K", "⌃Z"). */
|
|
413
|
-
children?: React.ReactNode;
|
|
414
|
-
className?: string;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
const DropdownMenuShortcut = ({ className, ...props }: DropdownMenuShortcutProps) => {
|
|
418
|
-
return (
|
|
419
|
-
<span className={cn("ml-auto text-xs tracking-widest opacity-60", className)} {...props} />
|
|
420
|
-
);
|
|
421
|
-
};
|
|
422
|
-
DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
|
|
423
|
-
|
|
424
|
-
export {
|
|
425
|
-
DropdownMenu,
|
|
426
|
-
DropdownMenuCheckboxItem,
|
|
427
|
-
DropdownMenuContent,
|
|
428
|
-
DropdownMenuGroup,
|
|
429
|
-
DropdownMenuItem,
|
|
430
|
-
DropdownMenuLabel,
|
|
431
|
-
DropdownMenuPortal,
|
|
432
|
-
DropdownMenuRadioGroup,
|
|
433
|
-
DropdownMenuRadioItem,
|
|
434
|
-
DropdownMenuSeparator,
|
|
435
|
-
DropdownMenuShortcut,
|
|
436
|
-
DropdownMenuSub,
|
|
437
|
-
DropdownMenuSubContent,
|
|
438
|
-
DropdownMenuSubTrigger,
|
|
439
|
-
DropdownMenuTrigger,
|
|
440
|
-
};
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
/* c8 ignore file -- CodeMirror requires real DOM measurements; jsdom-incompatible.
|
|
4
|
-
* Verified visually in the docs site. */
|
|
5
|
-
|
|
6
|
-
import { defaultKeymap, history, historyKeymap, indentWithTab } from "@codemirror/commands";
|
|
7
|
-
import { css } from "@codemirror/lang-css";
|
|
8
|
-
import { html } from "@codemirror/lang-html";
|
|
9
|
-
import { javascript } from "@codemirror/lang-javascript";
|
|
10
|
-
import { json } from "@codemirror/lang-json";
|
|
11
|
-
import { markdown as markdownLang } from "@codemirror/lang-markdown";
|
|
12
|
-
import { EditorState, type Extension } from "@codemirror/state";
|
|
13
|
-
import {
|
|
14
|
-
EditorView,
|
|
15
|
-
keymap,
|
|
16
|
-
lineNumbers as lineNumbersExt,
|
|
17
|
-
placeholder as placeholderExt,
|
|
18
|
-
} from "@codemirror/view";
|
|
19
|
-
import * as React from "react";
|
|
20
|
-
|
|
21
|
-
import { cn } from "../../../lib/utils";
|
|
22
|
-
import { useCodemirrorTheme } from "./use-codemirror-theme";
|
|
23
|
-
|
|
24
|
-
export type CodeEditorLanguage = "javascript" | "typescript" | "json" | "markdown" | "html" | "css";
|
|
25
|
-
|
|
26
|
-
export interface CodeEditorProps {
|
|
27
|
-
value: string;
|
|
28
|
-
onChange: (next: string) => void;
|
|
29
|
-
language: CodeEditorLanguage;
|
|
30
|
-
placeholder?: string;
|
|
31
|
-
disabled?: boolean;
|
|
32
|
-
readonly?: boolean;
|
|
33
|
-
ariaLabel: string;
|
|
34
|
-
className?: string;
|
|
35
|
-
/** Render the gutter with line numbers. Default true. */
|
|
36
|
-
lineNumbers?: boolean;
|
|
37
|
-
/** Pixel height (or any CSS length). Default `240`. */
|
|
38
|
-
height?: number | string;
|
|
39
|
-
/** Extra CodeMirror extensions appended after the canvas defaults. */
|
|
40
|
-
extensions?: Extension[];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const LANGUAGE_EXTENSIONS: Record<CodeEditorLanguage, () => Extension> = {
|
|
44
|
-
javascript: () => javascript(),
|
|
45
|
-
typescript: () => javascript({ jsx: true, typescript: true }),
|
|
46
|
-
json: () => json(),
|
|
47
|
-
markdown: () => markdownLang(),
|
|
48
|
-
html: () => html(),
|
|
49
|
-
css: () => css(),
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Source-code editor backed by CodeMirror 6. Pick a language with the
|
|
54
|
-
* `language` prop; the wrapper loads the matching highlighter and applies
|
|
55
|
-
* canvas-themed colours via `useCodemirrorTheme()`.
|
|
56
|
-
*/
|
|
57
|
-
const CodeEditor = React.forwardRef<HTMLDivElement, CodeEditorProps>(
|
|
58
|
-
(
|
|
59
|
-
{
|
|
60
|
-
value,
|
|
61
|
-
onChange,
|
|
62
|
-
language,
|
|
63
|
-
placeholder,
|
|
64
|
-
disabled = false,
|
|
65
|
-
readonly = false,
|
|
66
|
-
ariaLabel,
|
|
67
|
-
className,
|
|
68
|
-
lineNumbers = true,
|
|
69
|
-
height = 240,
|
|
70
|
-
extensions: extraExtensions,
|
|
71
|
-
},
|
|
72
|
-
ref,
|
|
73
|
-
) => {
|
|
74
|
-
const editorParentRef = React.useRef<HTMLDivElement>(null);
|
|
75
|
-
const viewRef = React.useRef<EditorView | null>(null);
|
|
76
|
-
const onChangeRef = React.useRef(onChange);
|
|
77
|
-
onChangeRef.current = onChange;
|
|
78
|
-
const theme = useCodemirrorTheme();
|
|
79
|
-
|
|
80
|
-
React.useEffect(() => {
|
|
81
|
-
if (!editorParentRef.current) return;
|
|
82
|
-
const extensions: Extension[] = [
|
|
83
|
-
history(),
|
|
84
|
-
keymap.of([...defaultKeymap, ...historyKeymap, indentWithTab]),
|
|
85
|
-
LANGUAGE_EXTENSIONS[language](),
|
|
86
|
-
EditorView.lineWrapping,
|
|
87
|
-
theme,
|
|
88
|
-
EditorView.editable.of(!disabled),
|
|
89
|
-
EditorState.readOnly.of(disabled || readonly),
|
|
90
|
-
];
|
|
91
|
-
if (lineNumbers) extensions.push(lineNumbersExt());
|
|
92
|
-
if (placeholder) extensions.push(placeholderExt(placeholder));
|
|
93
|
-
extensions.push(
|
|
94
|
-
EditorView.updateListener.of((update) => {
|
|
95
|
-
if (update.docChanged) {
|
|
96
|
-
onChangeRef.current(update.state.doc.toString());
|
|
97
|
-
}
|
|
98
|
-
}),
|
|
99
|
-
);
|
|
100
|
-
if (extraExtensions) extensions.push(...extraExtensions);
|
|
101
|
-
|
|
102
|
-
const v = new EditorView({
|
|
103
|
-
state: EditorState.create({ doc: value, extensions }),
|
|
104
|
-
parent: editorParentRef.current,
|
|
105
|
-
});
|
|
106
|
-
viewRef.current = v;
|
|
107
|
-
return () => {
|
|
108
|
-
v.destroy();
|
|
109
|
-
viewRef.current = null;
|
|
110
|
-
};
|
|
111
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
112
|
-
}, [theme, language, lineNumbers, disabled, readonly, placeholder]);
|
|
113
|
-
|
|
114
|
-
React.useEffect(() => {
|
|
115
|
-
const v = viewRef.current;
|
|
116
|
-
if (!v) return;
|
|
117
|
-
const current = v.state.doc.toString();
|
|
118
|
-
if (current !== value) {
|
|
119
|
-
v.dispatch({ changes: { from: 0, to: current.length, insert: value } });
|
|
120
|
-
}
|
|
121
|
-
}, [value]);
|
|
122
|
-
|
|
123
|
-
const heightStyle = typeof height === "number" ? `${height}px` : height;
|
|
124
|
-
|
|
125
|
-
return (
|
|
126
|
-
<div
|
|
127
|
-
ref={ref}
|
|
128
|
-
role="group"
|
|
129
|
-
aria-label={ariaLabel}
|
|
130
|
-
className={cn(
|
|
131
|
-
"overflow-hidden rounded-md border border-input bg-background shadow-sm focus-within:ring-1 focus-within:ring-ring",
|
|
132
|
-
disabled && "pointer-events-none opacity-50",
|
|
133
|
-
className,
|
|
134
|
-
)}
|
|
135
|
-
style={{ height: heightStyle }}
|
|
136
|
-
>
|
|
137
|
-
<div ref={editorParentRef} className="h-full overflow-y-auto" />
|
|
138
|
-
</div>
|
|
139
|
-
);
|
|
140
|
-
},
|
|
141
|
-
);
|
|
142
|
-
CodeEditor.displayName = "CodeEditor";
|
|
143
|
-
|
|
144
|
-
export { CodeEditor };
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { CodeEditor, type CodeEditorLanguage, type CodeEditorProps } from "./code-editor";
|
|
2
|
-
export { MarkdownEditor, type MarkdownEditorProps } from "./markdown-editor";
|
|
3
|
-
export { RichTextEditor, type RichTextEditorProps } from "./rich-text-editor";
|
|
4
|
-
export { TOOLBAR_ITEM_IDS, type ToolbarItemId } from "./toolbar/rte-toolbar";
|