@ui-annotate/react-vite 0.1.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/dist/code-open.d.ts +17 -0
- package/dist/code-open.js +82 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +4 -0
- package/dist/inspector-transform.d.ts +59 -0
- package/dist/inspector-transform.js +218 -0
- package/dist/protocol/constants.d.ts +7 -0
- package/dist/protocol/constants.js +31 -0
- package/dist/protocol/ids.d.ts +3 -0
- package/dist/protocol/ids.js +15 -0
- package/dist/protocol/index.d.ts +4 -0
- package/dist/protocol/index.js +4 -0
- package/dist/protocol/paths.d.ts +3 -0
- package/dist/protocol/paths.js +36 -0
- package/dist/protocol/task-model.d.ts +35 -0
- package/dist/protocol/task-model.js +68 -0
- package/dist/runtime/app/AnnotateToolbar.d.ts +9 -0
- package/dist/runtime/app/AnnotateToolbar.js +14 -0
- package/dist/runtime/app/AnnotateWindows.d.ts +28 -0
- package/dist/runtime/app/AnnotateWindows.js +8 -0
- package/dist/runtime/app/UiAnnotate.d.ts +5 -0
- package/dist/runtime/app/UiAnnotate.js +540 -0
- package/dist/runtime/index.d.ts +5 -0
- package/dist/runtime/index.js +4 -0
- package/dist/runtime/inspector/target-inspection.d.ts +10 -0
- package/dist/runtime/inspector/target-inspection.js +337 -0
- package/dist/runtime/layout/annotate-storage.d.ts +9 -0
- package/dist/runtime/layout/annotate-storage.js +134 -0
- package/dist/runtime/layout/use-annotate-layout.d.ts +17 -0
- package/dist/runtime/layout/use-annotate-layout.js +147 -0
- package/dist/runtime/overlay/SelectionOverlay.d.ts +7 -0
- package/dist/runtime/overlay/SelectionOverlay.js +95 -0
- package/dist/runtime/shared/annotate-constants.d.ts +13 -0
- package/dist/runtime/shared/annotate-constants.js +13 -0
- package/dist/runtime/shared/annotate-types.d.ts +36 -0
- package/dist/runtime/shared/annotate-types.js +1 -0
- package/dist/runtime/shared/clipboard.d.ts +1 -0
- package/dist/runtime/shared/clipboard.js +33 -0
- package/dist/runtime/style.css +206 -0
- package/dist/runtime/task/annotate-task.d.ts +16 -0
- package/dist/runtime/task/annotate-task.js +85 -0
- package/dist/runtime/task/use-annotate-task.d.ts +16 -0
- package/dist/runtime/task/use-annotate-task.js +115 -0
- package/dist/runtime/windows/AnnotateSettingsWindow.d.ts +6 -0
- package/dist/runtime/windows/AnnotateSettingsWindow.js +5 -0
- package/dist/runtime/windows/AnnotateWindow.d.ts +21 -0
- package/dist/runtime/windows/AnnotateWindow.js +83 -0
- package/dist/runtime/windows/AnnotateWindowFrame.d.ts +26 -0
- package/dist/runtime/windows/AnnotateWindowFrame.js +56 -0
- package/dist/runtime/windows/TargetTraceTree.d.ts +12 -0
- package/dist/runtime/windows/TargetTraceTree.js +163 -0
- package/dist/runtime/windows/window-shared.d.ts +14 -0
- package/dist/runtime/windows/window-shared.js +41 -0
- package/dist/task-api.d.ts +15 -0
- package/dist/task-api.js +239 -0
- package/dist/ui/components/accordion.d.ts +7 -0
- package/dist/ui/components/accordion.js +18 -0
- package/dist/ui/components/alert-dialog.d.ts +18 -0
- package/dist/ui/components/alert-dialog.js +41 -0
- package/dist/ui/components/alert.d.ts +9 -0
- package/dist/ui/components/alert.js +24 -0
- package/dist/ui/components/badge.d.ts +9 -0
- package/dist/ui/components/badge.js +24 -0
- package/dist/ui/components/breadcrumb.d.ts +11 -0
- package/dist/ui/components/breadcrumb.js +27 -0
- package/dist/ui/components/button.d.ts +10 -0
- package/dist/ui/components/button.js +31 -0
- package/dist/ui/components/card.d.ts +9 -0
- package/dist/ui/components/card.js +24 -0
- package/dist/ui/components/dropdown-menu.d.ts +11 -0
- package/dist/ui/components/dropdown-menu.js +21 -0
- package/dist/ui/components/input.d.ts +3 -0
- package/dist/ui/components/input.js +6 -0
- package/dist/ui/components/scroll-area.d.ts +5 -0
- package/dist/ui/components/scroll-area.js +12 -0
- package/dist/ui/components/separator.d.ts +4 -0
- package/dist/ui/components/separator.js +8 -0
- package/dist/ui/components/switch.d.ts +6 -0
- package/dist/ui/components/switch.js +7 -0
- package/dist/ui/components/table.d.ts +10 -0
- package/dist/ui/components/table.js +27 -0
- package/dist/ui/components/tabs.d.ts +11 -0
- package/dist/ui/components/tabs.js +28 -0
- package/dist/ui/components/textarea.d.ts +3 -0
- package/dist/ui/components/textarea.js +6 -0
- package/dist/ui/components/toggle-group.d.ts +9 -0
- package/dist/ui/components/toggle-group.js +22 -0
- package/dist/ui/components/toggle.d.ts +9 -0
- package/dist/ui/components/toggle.js +25 -0
- package/dist/ui/components/tooltip.d.ts +7 -0
- package/dist/ui/components/tooltip.js +18 -0
- package/dist/ui/index.d.ts +2 -0
- package/dist/ui/index.js +2 -0
- package/dist/ui/lib/utils.d.ts +2 -0
- package/dist/ui/lib/utils.js +5 -0
- package/dist/ui/portal/portal-container.d.ts +13 -0
- package/dist/ui/portal/portal-container.js +12 -0
- package/dist/ui-annotate-plugin.d.ts +28 -0
- package/dist/ui-annotate-plugin.js +227 -0
- package/package.json +55 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Switch as SwitchPrimitive } from "radix-ui";
|
|
3
|
+
import { cn } from "../lib/utils.js";
|
|
4
|
+
function Switch({ className, size = "default", ...props }) {
|
|
5
|
+
return (_jsx(SwitchPrimitive.Root, { "data-slot": "switch", "data-size": size, className: cn("peer group/switch inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[1.15rem] data-[size=default]:w-8 data-[size=sm]:h-3.5 data-[size=sm]:w-6 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80", className), ...props, children: _jsx(SwitchPrimitive.Thumb, { "data-slot": "switch-thumb", className: cn("pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0 dark:data-[state=checked]:bg-primary-foreground dark:data-[state=unchecked]:bg-foreground") }) }));
|
|
6
|
+
}
|
|
7
|
+
export { Switch };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
declare function Table({ className, ...props }: React.ComponentProps<"table">): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
declare function TableHeader({ className, ...props }: React.ComponentProps<"thead">): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare function TableBody({ className, ...props }: React.ComponentProps<"tbody">): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare function TableFooter({ className, ...props }: React.ComponentProps<"tfoot">): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare function TableRow({ className, ...props }: React.ComponentProps<"tr">): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
declare function TableHead({ className, ...props }: React.ComponentProps<"th">): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
declare function TableCell({ className, ...props }: React.ComponentProps<"td">): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare function TableCaption({ className, ...props }: React.ComponentProps<"caption">): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption, };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../lib/utils.js";
|
|
3
|
+
function Table({ className, ...props }) {
|
|
4
|
+
return (_jsx("div", { "data-slot": "table-container", className: "relative w-full overflow-x-auto", children: _jsx("table", { "data-slot": "table", className: cn("w-full caption-bottom text-sm", className), ...props }) }));
|
|
5
|
+
}
|
|
6
|
+
function TableHeader({ className, ...props }) {
|
|
7
|
+
return (_jsx("thead", { "data-slot": "table-header", className: cn("[&_tr]:border-b", className), ...props }));
|
|
8
|
+
}
|
|
9
|
+
function TableBody({ className, ...props }) {
|
|
10
|
+
return (_jsx("tbody", { "data-slot": "table-body", className: cn("[&_tr:last-child]:border-0", className), ...props }));
|
|
11
|
+
}
|
|
12
|
+
function TableFooter({ className, ...props }) {
|
|
13
|
+
return (_jsx("tfoot", { "data-slot": "table-footer", className: cn("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0", className), ...props }));
|
|
14
|
+
}
|
|
15
|
+
function TableRow({ className, ...props }) {
|
|
16
|
+
return (_jsx("tr", { "data-slot": "table-row", className: cn("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted", className), ...props }));
|
|
17
|
+
}
|
|
18
|
+
function TableHead({ className, ...props }) {
|
|
19
|
+
return (_jsx("th", { "data-slot": "table-head", className: cn("h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]", className), ...props }));
|
|
20
|
+
}
|
|
21
|
+
function TableCell({ className, ...props }) {
|
|
22
|
+
return (_jsx("td", { "data-slot": "table-cell", className: cn("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]", className), ...props }));
|
|
23
|
+
}
|
|
24
|
+
function TableCaption({ className, ...props }) {
|
|
25
|
+
return (_jsx("caption", { "data-slot": "table-caption", className: cn("mt-4 text-sm text-muted-foreground", className), ...props }));
|
|
26
|
+
}
|
|
27
|
+
export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption, };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type VariantProps } from "class-variance-authority";
|
|
3
|
+
import { Tabs as TabsPrimitive } from "radix-ui";
|
|
4
|
+
declare function Tabs({ className, orientation, ...props }: React.ComponentProps<typeof TabsPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare const tabsListVariants: (props?: ({
|
|
6
|
+
variant?: "default" | "line" | null | undefined;
|
|
7
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
8
|
+
declare function TabsList({ className, variant, ...props }: React.ComponentProps<typeof TabsPrimitive.List> & VariantProps<typeof tabsListVariants>): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare function TabsTrigger({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.Trigger>): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
declare function TabsContent({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.Content>): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export { Tabs, TabsList, TabsTrigger, TabsContent, tabsListVariants };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
import { Tabs as TabsPrimitive } from "radix-ui";
|
|
4
|
+
import { cn } from "../lib/utils.js";
|
|
5
|
+
function Tabs({ className, orientation = "horizontal", ...props }) {
|
|
6
|
+
return (_jsx(TabsPrimitive.Root, { "data-slot": "tabs", "data-orientation": orientation, orientation: orientation, className: cn("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col", className), ...props }));
|
|
7
|
+
}
|
|
8
|
+
const tabsListVariants = cva("group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-9 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none", {
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
default: "bg-muted",
|
|
12
|
+
line: "gap-1 bg-transparent",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
defaultVariants: {
|
|
16
|
+
variant: "default",
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
function TabsList({ className, variant = "default", ...props }) {
|
|
20
|
+
return (_jsx(TabsPrimitive.List, { "data-slot": "tabs-list", "data-variant": variant, className: cn(tabsListVariants({ variant }), className), ...props }));
|
|
21
|
+
}
|
|
22
|
+
function TabsTrigger({ className, ...props }) {
|
|
23
|
+
return (_jsx(TabsPrimitive.Trigger, { "data-slot": "tabs-trigger", className: cn("relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", "group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent", "data-[state=active]:bg-background data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 dark:data-[state=active]:text-foreground", "after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100", className), ...props }));
|
|
24
|
+
}
|
|
25
|
+
function TabsContent({ className, ...props }) {
|
|
26
|
+
return (_jsx(TabsPrimitive.Content, { "data-slot": "tabs-content", className: cn("flex-1 outline-none", className), ...props }));
|
|
27
|
+
}
|
|
28
|
+
export { Tabs, TabsList, TabsTrigger, TabsContent, tabsListVariants };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../lib/utils.js";
|
|
3
|
+
function Textarea({ className, ...props }) {
|
|
4
|
+
return (_jsx("textarea", { "data-slot": "textarea", className: cn("flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:ring-destructive/40", className), ...props }));
|
|
5
|
+
}
|
|
6
|
+
export { Textarea };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type VariantProps } from "class-variance-authority";
|
|
3
|
+
import { ToggleGroup as ToggleGroupPrimitive } from "radix-ui";
|
|
4
|
+
import { toggleVariants } from "./toggle.js";
|
|
5
|
+
declare function ToggleGroup({ className, variant, size, spacing, children, ...props }: React.ComponentProps<typeof ToggleGroupPrimitive.Root> & VariantProps<typeof toggleVariants> & {
|
|
6
|
+
spacing?: number;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
declare function ToggleGroupItem({ className, children, variant, size, ...props }: React.ComponentProps<typeof ToggleGroupPrimitive.Item> & VariantProps<typeof toggleVariants>): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export { ToggleGroup, ToggleGroupItem };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { ToggleGroup as ToggleGroupPrimitive } from "radix-ui";
|
|
5
|
+
import { cn } from "../lib/utils.js";
|
|
6
|
+
import { toggleVariants } from "./toggle.js";
|
|
7
|
+
const ToggleGroupContext = React.createContext({
|
|
8
|
+
size: "default",
|
|
9
|
+
variant: "default",
|
|
10
|
+
spacing: 0,
|
|
11
|
+
});
|
|
12
|
+
function ToggleGroup({ className, variant, size, spacing = 0, children, ...props }) {
|
|
13
|
+
return (_jsx(ToggleGroupPrimitive.Root, { "data-slot": "toggle-group", "data-variant": variant, "data-size": size, "data-spacing": spacing, style: { "--gap": spacing }, className: cn("group/toggle-group flex w-fit items-center gap-[--spacing(var(--gap))] rounded-md data-[spacing=default]:data-[variant=outline]:shadow-xs", className), ...props, children: _jsx(ToggleGroupContext.Provider, { value: { variant, size, spacing }, children: children }) }));
|
|
14
|
+
}
|
|
15
|
+
function ToggleGroupItem({ className, children, variant, size, ...props }) {
|
|
16
|
+
const context = React.useContext(ToggleGroupContext);
|
|
17
|
+
return (_jsx(ToggleGroupPrimitive.Item, { "data-slot": "toggle-group-item", "data-variant": context.variant ?? variant, "data-size": context.size ?? size, "data-spacing": context.spacing, className: cn(toggleVariants({
|
|
18
|
+
variant: context.variant ?? variant,
|
|
19
|
+
size: context.size ?? size,
|
|
20
|
+
}), "w-auto min-w-0 shrink-0 px-3 focus:z-10 focus-visible:z-10", "data-[spacing=0]:rounded-none data-[spacing=0]:shadow-none data-[spacing=0]:first:rounded-l-md data-[spacing=0]:last:rounded-r-md data-[spacing=0]:data-[variant=outline]:border-l-0 data-[spacing=0]:data-[variant=outline]:first:border-l", className), ...props, children: children }));
|
|
21
|
+
}
|
|
22
|
+
export { ToggleGroup, ToggleGroupItem };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type VariantProps } from "class-variance-authority";
|
|
3
|
+
import { Toggle as TogglePrimitive } from "radix-ui";
|
|
4
|
+
declare const toggleVariants: (props?: ({
|
|
5
|
+
variant?: "default" | "outline" | null | undefined;
|
|
6
|
+
size?: "default" | "sm" | "lg" | null | undefined;
|
|
7
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
8
|
+
declare function Toggle({ className, variant, size, ...props }: React.ComponentProps<typeof TogglePrimitive.Root> & VariantProps<typeof toggleVariants>): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export { Toggle, toggleVariants };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
import { Toggle as TogglePrimitive } from "radix-ui";
|
|
4
|
+
import { cn } from "../lib/utils.js";
|
|
5
|
+
const toggleVariants = cva("inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-[color,box-shadow] outline-none hover:bg-muted hover:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
default: "bg-transparent",
|
|
9
|
+
outline: "border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground",
|
|
10
|
+
},
|
|
11
|
+
size: {
|
|
12
|
+
default: "h-9 min-w-9 px-2",
|
|
13
|
+
sm: "h-8 min-w-8 px-1.5",
|
|
14
|
+
lg: "h-10 min-w-10 px-2.5",
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
defaultVariants: {
|
|
18
|
+
variant: "default",
|
|
19
|
+
size: "default",
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
function Toggle({ className, variant, size, ...props }) {
|
|
23
|
+
return (_jsx(TogglePrimitive.Root, { "data-slot": "toggle", className: cn(toggleVariants({ variant, size, className })), ...props }));
|
|
24
|
+
}
|
|
25
|
+
export { Toggle, toggleVariants };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Tooltip as TooltipPrimitive } from "radix-ui";
|
|
3
|
+
declare function TooltipProvider({ delayDuration, ...props }: React.ComponentProps<typeof TooltipPrimitive.Provider>): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare function Tooltip({ ...props }: React.ComponentProps<typeof TooltipPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare function TooltipTrigger({ ...props }: React.ComponentProps<typeof TooltipPrimitive.Trigger>): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare function TooltipContent({ className, sideOffset, children, style, ...props }: React.ComponentProps<typeof TooltipPrimitive.Content>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Tooltip as TooltipPrimitive } from "radix-ui";
|
|
3
|
+
import { cn } from "../lib/utils.js";
|
|
4
|
+
import { usePortalContainer } from "../portal/portal-container.js";
|
|
5
|
+
function TooltipProvider({ delayDuration = 0, ...props }) {
|
|
6
|
+
return (_jsx(TooltipPrimitive.Provider, { "data-slot": "tooltip-provider", delayDuration: delayDuration, ...props }));
|
|
7
|
+
}
|
|
8
|
+
function Tooltip({ ...props }) {
|
|
9
|
+
return _jsx(TooltipPrimitive.Root, { "data-slot": "tooltip", ...props });
|
|
10
|
+
}
|
|
11
|
+
function TooltipTrigger({ ...props }) {
|
|
12
|
+
return _jsx(TooltipPrimitive.Trigger, { "data-slot": "tooltip-trigger", ...props });
|
|
13
|
+
}
|
|
14
|
+
function TooltipContent({ className, sideOffset = 0, children, style, ...props }) {
|
|
15
|
+
const { container, zIndex } = usePortalContainer();
|
|
16
|
+
return (_jsx(TooltipPrimitive.Portal, { container: container ?? undefined, children: _jsxs(TooltipPrimitive.Content, { "data-slot": "tooltip-content", sideOffset: sideOffset, style: { ...style, ...(zIndex === undefined ? {} : { zIndex }) }, className: cn("pointer-events-auto z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-foreground px-3 py-1.5 text-xs text-balance text-background fade-in-0 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 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95", className), ...props, children: [children, _jsx(TooltipPrimitive.Arrow, { className: "z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground" })] }) }));
|
|
17
|
+
}
|
|
18
|
+
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
|
package/dist/ui/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
type PortalContainerContextValue = {
|
|
3
|
+
container: HTMLElement | null;
|
|
4
|
+
zIndex: number | undefined;
|
|
5
|
+
};
|
|
6
|
+
type PortalContainerProviderProps = {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
container?: HTMLElement | null;
|
|
9
|
+
zIndex?: number;
|
|
10
|
+
};
|
|
11
|
+
export declare function PortalContainerProvider({ children, container, zIndex }: PortalContainerProviderProps): ReactNode;
|
|
12
|
+
export declare function usePortalContainer(): PortalContainerContextValue;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
const PortalContainerContext = createContext({
|
|
4
|
+
container: null,
|
|
5
|
+
zIndex: undefined
|
|
6
|
+
});
|
|
7
|
+
export function PortalContainerProvider({ children, container, zIndex }) {
|
|
8
|
+
return (_jsx(PortalContainerContext.Provider, { value: { container: container ?? null, zIndex }, children: children }));
|
|
9
|
+
}
|
|
10
|
+
export function usePortalContainer() {
|
|
11
|
+
return useContext(PortalContainerContext);
|
|
12
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type UiAnnotateInspectorPluginOptions } from "./inspector-transform.js";
|
|
2
|
+
export type UiAnnotatePluginOptions = Pick<UiAnnotateInspectorPluginOptions, "enabled" | "root">;
|
|
3
|
+
type VitePluginLike = {
|
|
4
|
+
name: string;
|
|
5
|
+
apply?: "serve";
|
|
6
|
+
config?(config?: ViteUserConfigLike): unknown;
|
|
7
|
+
resolveId?(id: string): string | undefined;
|
|
8
|
+
load?(this: VitePluginLoadContext, id: string): string | Promise<string | undefined> | undefined;
|
|
9
|
+
transformIndexHtml?(html: string): unknown;
|
|
10
|
+
};
|
|
11
|
+
type VitePluginLoadContext = {
|
|
12
|
+
addWatchFile?(id: string): void;
|
|
13
|
+
};
|
|
14
|
+
type ViteUserConfigLike = {
|
|
15
|
+
server?: {
|
|
16
|
+
watch?: {
|
|
17
|
+
ignored?: WatchIgnored;
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
} | null;
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
};
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
};
|
|
24
|
+
type WatchIgnoredPattern = string | RegExp | ((testString: string, stats?: unknown) => boolean);
|
|
25
|
+
type WatchIgnored = WatchIgnoredPattern | WatchIgnoredPattern[];
|
|
26
|
+
export declare function uiAnnotate(options?: UiAnnotatePluginOptions): VitePluginLike[];
|
|
27
|
+
export declare function createUiAnnotatePlugin(options?: UiAnnotatePluginOptions): VitePluginLike[];
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { basename, dirname, isAbsolute, resolve } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { ANNOTATE_TASK_FILE_NAME } from "./protocol/index.js";
|
|
6
|
+
import { Scanner } from "@tailwindcss/oxide";
|
|
7
|
+
import { compile } from "tailwindcss";
|
|
8
|
+
import { createUiAnnotateInspectorPlugin } from "./inspector-transform.js";
|
|
9
|
+
const UI_ANNOTATE_RUNTIME_MODULE_ID = "virtual:ui-annotate-runtime";
|
|
10
|
+
const RESOLVED_UI_ANNOTATE_RUNTIME_MODULE_ID = `\0${UI_ANNOTATE_RUNTIME_MODULE_ID}`;
|
|
11
|
+
const UI_ANNOTATE_RUNTIME_MODULE_URL = `/@id/__x00__${UI_ANNOTATE_RUNTIME_MODULE_ID}`;
|
|
12
|
+
const UI_ANNOTATE_RUNTIME_IMPORT_ID = "@ui-annotate/react-vite/runtime";
|
|
13
|
+
const UI_ANNOTATE_RUNTIME_STYLE_IMPORT_ID = "@ui-annotate/react-vite/runtime/style.css";
|
|
14
|
+
const ANNOTATE_TASK_WATCH_IGNORES = [
|
|
15
|
+
`**/${ANNOTATE_TASK_FILE_NAME}`
|
|
16
|
+
];
|
|
17
|
+
export function uiAnnotate(options = {}) {
|
|
18
|
+
return createUiAnnotatePlugin(options);
|
|
19
|
+
}
|
|
20
|
+
export function createUiAnnotatePlugin(options = {}) {
|
|
21
|
+
if (options.enabled === false) {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
return [
|
|
25
|
+
createUiAnnotateInspectorPlugin(options),
|
|
26
|
+
createUiAnnotateRuntimePlugin()
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
function createUiAnnotateRuntimePlugin() {
|
|
30
|
+
const require = createRequire(import.meta.url);
|
|
31
|
+
const runtimeEntryPath = resolvePackagedRuntimePath("index.js");
|
|
32
|
+
const runtimeStylePath = resolvePackagedRuntimePath("style.css");
|
|
33
|
+
return {
|
|
34
|
+
name: "ui-annotate-runtime",
|
|
35
|
+
apply: "serve",
|
|
36
|
+
config(config = {}) {
|
|
37
|
+
appendAnnotateTaskWatchIgnores(config);
|
|
38
|
+
return {
|
|
39
|
+
resolve: {
|
|
40
|
+
// Linked host apps can otherwise load one React from the app and another from
|
|
41
|
+
// the embedded UI Annotate runtime, which breaks hooks inside the runtime.
|
|
42
|
+
dedupe: ["react", "react-dom"],
|
|
43
|
+
alias: {
|
|
44
|
+
[UI_ANNOTATE_RUNTIME_STYLE_IMPORT_ID]: runtimeStylePath,
|
|
45
|
+
[UI_ANNOTATE_RUNTIME_IMPORT_ID]: runtimeEntryPath
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
resolveId(id) {
|
|
51
|
+
if (id === UI_ANNOTATE_RUNTIME_MODULE_ID) {
|
|
52
|
+
return RESOLVED_UI_ANNOTATE_RUNTIME_MODULE_ID;
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
async load(id) {
|
|
56
|
+
if (id !== RESOLVED_UI_ANNOTATE_RUNTIME_MODULE_ID) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const { css: annotateCss, dependencies } = await compileUiAnnotateRuntimeCss(require);
|
|
60
|
+
for (const dependency of dependencies) {
|
|
61
|
+
this.addWatchFile?.(dependency);
|
|
62
|
+
}
|
|
63
|
+
return `
|
|
64
|
+
import React from "react";
|
|
65
|
+
import { createRoot } from "react-dom/client";
|
|
66
|
+
import { UiAnnotate } from "${UI_ANNOTATE_RUNTIME_IMPORT_ID}";
|
|
67
|
+
|
|
68
|
+
const rootId = "__ui_annotate_root__";
|
|
69
|
+
const storeKey = "__UI_ANNOTATE_ROOT__";
|
|
70
|
+
const styleId = "ui-annotate-style";
|
|
71
|
+
const appId = "ui-annotate-app";
|
|
72
|
+
const portalId = "ui-annotate-portal";
|
|
73
|
+
const annotateCss = ${JSON.stringify(annotateCss)};
|
|
74
|
+
let rootElement = document.getElementById(rootId);
|
|
75
|
+
|
|
76
|
+
if (!rootElement) {
|
|
77
|
+
rootElement = document.createElement("div");
|
|
78
|
+
rootElement.id = rootId;
|
|
79
|
+
document.body.append(rootElement);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
Object.assign(rootElement.style, {
|
|
83
|
+
position: "fixed",
|
|
84
|
+
inset: "0",
|
|
85
|
+
zIndex: "2147483647",
|
|
86
|
+
pointerEvents: "none"
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const shadowRoot = rootElement.shadowRoot ?? rootElement.attachShadow({ mode: "open" });
|
|
90
|
+
let styleElement = shadowRoot.querySelector(\`style[data-ui-annotate-style="\${styleId}"]\`);
|
|
91
|
+
|
|
92
|
+
if (!styleElement) {
|
|
93
|
+
styleElement = document.createElement("style");
|
|
94
|
+
styleElement.dataset.uiAnnotateStyle = styleId;
|
|
95
|
+
shadowRoot.append(styleElement);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
styleElement.textContent = annotateCss;
|
|
99
|
+
|
|
100
|
+
let appElement = shadowRoot.querySelector(\`[data-ui-annotate-app="\${appId}"]\`);
|
|
101
|
+
|
|
102
|
+
if (!appElement) {
|
|
103
|
+
appElement = document.createElement("div");
|
|
104
|
+
appElement.dataset.uiAnnotateApp = appId;
|
|
105
|
+
shadowRoot.append(appElement);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
let portalElement = shadowRoot.querySelector(\`[data-ui-annotate-portal="\${portalId}"]\`);
|
|
109
|
+
|
|
110
|
+
if (!portalElement) {
|
|
111
|
+
portalElement = document.createElement("div");
|
|
112
|
+
portalElement.dataset.uiAnnotatePortal = portalId;
|
|
113
|
+
shadowRoot.append(portalElement);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const store = window[storeKey] ?? {};
|
|
117
|
+
|
|
118
|
+
if (!store.root || store.appElement !== appElement) {
|
|
119
|
+
store.root = createRoot(appElement);
|
|
120
|
+
store.appElement = appElement;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
window[storeKey] = store;
|
|
124
|
+
store.root.render(React.createElement(UiAnnotate, { rootElement, portalContainer: portalElement }));
|
|
125
|
+
|
|
126
|
+
if (import.meta.hot) {
|
|
127
|
+
import.meta.hot.dispose(() => {
|
|
128
|
+
store.root?.render(React.createElement(React.Fragment));
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
`;
|
|
132
|
+
},
|
|
133
|
+
transformIndexHtml(html) {
|
|
134
|
+
return {
|
|
135
|
+
html,
|
|
136
|
+
tags: [
|
|
137
|
+
{
|
|
138
|
+
tag: "script",
|
|
139
|
+
attrs: {
|
|
140
|
+
type: "module",
|
|
141
|
+
src: UI_ANNOTATE_RUNTIME_MODULE_URL
|
|
142
|
+
},
|
|
143
|
+
injectTo: "body"
|
|
144
|
+
}
|
|
145
|
+
]
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function appendAnnotateTaskWatchIgnores(config) {
|
|
151
|
+
config.server ??= {};
|
|
152
|
+
if (config.server.watch === null) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
config.server.watch ??= {};
|
|
156
|
+
config.server.watch.ignored = mergeWatchIgnored(config.server.watch.ignored, ANNOTATE_TASK_WATCH_IGNORES);
|
|
157
|
+
}
|
|
158
|
+
function mergeWatchIgnored(current, additions) {
|
|
159
|
+
const currentPatterns = current === undefined
|
|
160
|
+
? []
|
|
161
|
+
: Array.isArray(current)
|
|
162
|
+
? current
|
|
163
|
+
: [current];
|
|
164
|
+
const nextPatterns = [...currentPatterns];
|
|
165
|
+
for (const addition of additions) {
|
|
166
|
+
if (!nextPatterns.includes(addition)) {
|
|
167
|
+
nextPatterns.push(addition);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return nextPatterns;
|
|
171
|
+
}
|
|
172
|
+
async function compileUiAnnotateRuntimeCss(require) {
|
|
173
|
+
const cssPath = resolvePackagedRuntimePath("style.css");
|
|
174
|
+
const dependencies = new Set([cssPath]);
|
|
175
|
+
const css = await readFile(cssPath, "utf8");
|
|
176
|
+
const compiler = await compile(css, {
|
|
177
|
+
base: dirname(cssPath),
|
|
178
|
+
from: cssPath,
|
|
179
|
+
loadStylesheet: async (id, base) => {
|
|
180
|
+
const stylesheetPath = resolveStylesheet(id, base, require);
|
|
181
|
+
dependencies.add(stylesheetPath);
|
|
182
|
+
return {
|
|
183
|
+
path: stylesheetPath,
|
|
184
|
+
base: dirname(stylesheetPath),
|
|
185
|
+
content: await readFile(stylesheetPath, "utf8")
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
const scanner = new Scanner({
|
|
190
|
+
sources: resolveUiAnnotateRuntimeSources(compiler.root, compiler.sources, dirname(cssPath))
|
|
191
|
+
});
|
|
192
|
+
const candidates = scanner.scan();
|
|
193
|
+
for (const file of scanner.files) {
|
|
194
|
+
dependencies.add(file);
|
|
195
|
+
}
|
|
196
|
+
return {
|
|
197
|
+
css: compiler.build(candidates),
|
|
198
|
+
dependencies: [...dependencies]
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
function resolveStylesheet(id, base, require) {
|
|
202
|
+
if (id.startsWith(".")) {
|
|
203
|
+
return resolve(base, id);
|
|
204
|
+
}
|
|
205
|
+
if (isAbsolute(id)) {
|
|
206
|
+
return id;
|
|
207
|
+
}
|
|
208
|
+
return require.resolve(id, { paths: [base] });
|
|
209
|
+
}
|
|
210
|
+
function resolveUiAnnotateRuntimeSources(root, sources, fallbackBase) {
|
|
211
|
+
const rootSources = root === "none"
|
|
212
|
+
? []
|
|
213
|
+
: root === null
|
|
214
|
+
? [{ base: fallbackBase, pattern: "**/*", negated: false }]
|
|
215
|
+
: [{ ...root, negated: false }];
|
|
216
|
+
return rootSources.concat(sources);
|
|
217
|
+
}
|
|
218
|
+
function resolvePackagedRuntimePath(subpath) {
|
|
219
|
+
return resolve(resolvePackageDistDir(), "runtime", subpath);
|
|
220
|
+
}
|
|
221
|
+
function resolvePackageDistDir() {
|
|
222
|
+
const moduleDir = dirname(fileURLToPath(import.meta.url));
|
|
223
|
+
if (basename(moduleDir) === "src") {
|
|
224
|
+
return resolve(moduleDir, "../dist");
|
|
225
|
+
}
|
|
226
|
+
return moduleDir;
|
|
227
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ui-annotate/react-vite",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Annotate React UI issues in Vite apps and hand them off to coding agents.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./runtime": {
|
|
20
|
+
"types": "./dist/runtime/index.d.ts",
|
|
21
|
+
"default": "./dist/runtime/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./runtime/style.css": {
|
|
24
|
+
"default": "./dist/runtime/style.css"
|
|
25
|
+
},
|
|
26
|
+
"./package.json": {
|
|
27
|
+
"default": "./package.json"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@tailwindcss/oxide": "^4.3.0",
|
|
32
|
+
"class-variance-authority": "^0.7.1",
|
|
33
|
+
"clsx": "^2.1.1",
|
|
34
|
+
"lucide-react": "^1.16.0",
|
|
35
|
+
"radix-ui": "^1.4.3",
|
|
36
|
+
"tailwind-merge": "^3.6.0",
|
|
37
|
+
"tailwindcss": "^4.3.0",
|
|
38
|
+
"typescript": "^5.8.0"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"react": "^18.2.0 || ^19.0.0",
|
|
42
|
+
"react-dom": "^18.2.0 || ^19.0.0",
|
|
43
|
+
"vite": "^8.0.13"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"vite": "^8.0.13"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "node scripts/build-single-package.mjs",
|
|
50
|
+
"clean": "node -e \"const fs=require('node:fs'); for (const path of ['dist','tsconfig.tsbuildinfo']) fs.rmSync(path,{recursive:true,force:true})\"",
|
|
51
|
+
"test": "tsx --test src/__tests__/*.test.ts",
|
|
52
|
+
"type-check": "tsc -p tsconfig.json --noEmit",
|
|
53
|
+
"typecheck": "pnpm run type-check"
|
|
54
|
+
}
|
|
55
|
+
}
|