@ddd-ts/event-tree-viewer 0.0.0-eventviz.10

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.
Files changed (64) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +21 -0
  3. package/dist/cli.mjs +20 -0
  4. package/index.html +13 -0
  5. package/package.json +67 -0
  6. package/src/App.tsx +153 -0
  7. package/src/application/trpc-client.ts +6 -0
  8. package/src/application/use-direction.ts +18 -0
  9. package/src/application/use-domains.ts +9 -0
  10. package/src/application/use-expansion.ts +42 -0
  11. package/src/application/use-filters.ts +78 -0
  12. package/src/application/use-graph.ts +38 -0
  13. package/src/application/use-reveal.ts +26 -0
  14. package/src/application/use-selection.ts +15 -0
  15. package/src/application/use-settings.ts +84 -0
  16. package/src/application/use-view-mode.ts +14 -0
  17. package/src/assets/fonts/Monor_Regular.otf +0 -0
  18. package/src/assets/fonts/Supreme-Variable.woff2 +0 -0
  19. package/src/assets/fonts/Supreme-VariableItalic.woff2 +0 -0
  20. package/src/assets/fonts/monor-bold.otf +0 -0
  21. package/src/assets/react.svg +1 -0
  22. package/src/cli.ts +29 -0
  23. package/src/components/direction-toggle.tsx +28 -0
  24. package/src/components/domain-header.tsx +44 -0
  25. package/src/components/export-dialog.tsx +164 -0
  26. package/src/components/filter-bar.tsx +17 -0
  27. package/src/components/header.tsx +37 -0
  28. package/src/components/inspector.tsx +183 -0
  29. package/src/components/kind-filter.tsx +70 -0
  30. package/src/components/node-badge.tsx +19 -0
  31. package/src/components/node-name.tsx +66 -0
  32. package/src/components/settings-menu.tsx +147 -0
  33. package/src/components/ui/badge.tsx +52 -0
  34. package/src/components/ui/button.tsx +56 -0
  35. package/src/components/ui/card.tsx +103 -0
  36. package/src/components/ui/checkbox.tsx +28 -0
  37. package/src/components/ui/dialog.tsx +108 -0
  38. package/src/components/ui/input.tsx +20 -0
  39. package/src/components/ui/popover.tsx +88 -0
  40. package/src/components/ui/scroll-area.tsx +54 -0
  41. package/src/components/ui/select.tsx +88 -0
  42. package/src/components/ui/separator.tsx +23 -0
  43. package/src/components/ui/toggle-group.tsx +89 -0
  44. package/src/components/ui/toggle.tsx +43 -0
  45. package/src/components/view-switcher.tsx +28 -0
  46. package/src/components/views/graph-view.tsx +1203 -0
  47. package/src/components/views/list-view.tsx +109 -0
  48. package/src/components/views/tree-view.tsx +485 -0
  49. package/src/domain/cypher-export.ts +66 -0
  50. package/src/domain/direction.ts +1 -0
  51. package/src/domain/domain-grouping.ts +217 -0
  52. package/src/domain/edge.ts +37 -0
  53. package/src/domain/filter.ts +21 -0
  54. package/src/domain/flatten-tree.ts +167 -0
  55. package/src/domain/graph.ts +42 -0
  56. package/src/domain/node.ts +28 -0
  57. package/src/domain/roots.ts +18 -0
  58. package/src/domain/traversal.ts +60 -0
  59. package/src/index.css +205 -0
  60. package/src/lib/utils.ts +6 -0
  61. package/src/main.tsx +16 -0
  62. package/src/server/router.ts +87 -0
  63. package/src/server/vite-plugin.ts +99 -0
  64. package/vite.config.ts +36 -0
@@ -0,0 +1,88 @@
1
+ import * as React from "react"
2
+ import { Select as SelectPrimitive } from "@base-ui/react/select"
3
+ import { CaretDownIcon, CheckIcon } from "@phosphor-icons/react"
4
+
5
+ import { cn } from "@/lib/utils"
6
+
7
+ function Select<Value, Multiple extends boolean | undefined = false>(
8
+ props: SelectPrimitive.Root.Props<Value, Multiple>
9
+ ) {
10
+ return <SelectPrimitive.Root {...props} />
11
+ }
12
+
13
+ function SelectTrigger({
14
+ className,
15
+ children,
16
+ ...props
17
+ }: SelectPrimitive.Trigger.Props) {
18
+ return (
19
+ <SelectPrimitive.Trigger
20
+ data-slot="select-trigger"
21
+ className={cn(
22
+ "inline-flex h-7 items-center justify-between gap-1.5 rounded-none border border-border bg-background px-2.5 text-xs text-foreground outline-none transition-colors hover:bg-muted focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 dark:bg-input/30 dark:hover:bg-input/50",
23
+ className
24
+ )}
25
+ {...props}
26
+ >
27
+ {children}
28
+ <SelectPrimitive.Icon className="text-muted-foreground">
29
+ <CaretDownIcon className="size-3" />
30
+ </SelectPrimitive.Icon>
31
+ </SelectPrimitive.Trigger>
32
+ )
33
+ }
34
+
35
+ function SelectValue({ ...props }: SelectPrimitive.Value.Props) {
36
+ return <SelectPrimitive.Value data-slot="select-value" {...props} />
37
+ }
38
+
39
+ function SelectContent({
40
+ className,
41
+ children,
42
+ ...props
43
+ }: SelectPrimitive.Popup.Props) {
44
+ return (
45
+ <SelectPrimitive.Portal>
46
+ <SelectPrimitive.Positioner
47
+ sideOffset={4}
48
+ alignItemWithTrigger={false}
49
+ className="isolate z-50 outline-none"
50
+ >
51
+ <SelectPrimitive.Popup
52
+ data-slot="select-content"
53
+ className={cn(
54
+ "min-w-(--anchor-width) origin-(--transform-origin) rounded-none bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
55
+ className
56
+ )}
57
+ {...props}
58
+ >
59
+ <SelectPrimitive.List>{children}</SelectPrimitive.List>
60
+ </SelectPrimitive.Popup>
61
+ </SelectPrimitive.Positioner>
62
+ </SelectPrimitive.Portal>
63
+ )
64
+ }
65
+
66
+ function SelectItem({
67
+ className,
68
+ children,
69
+ ...props
70
+ }: SelectPrimitive.Item.Props) {
71
+ return (
72
+ <SelectPrimitive.Item
73
+ data-slot="select-item"
74
+ className={cn(
75
+ "relative flex w-full cursor-pointer items-center gap-2 rounded-none px-2 py-1.5 pr-8 text-xs outline-none transition-colors select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-highlighted:bg-muted data-highlighted:text-foreground",
76
+ className
77
+ )}
78
+ {...props}
79
+ >
80
+ <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
81
+ <SelectPrimitive.ItemIndicator className="absolute right-2 inline-flex items-center justify-center text-muted-foreground">
82
+ <CheckIcon className="size-3.5" />
83
+ </SelectPrimitive.ItemIndicator>
84
+ </SelectPrimitive.Item>
85
+ )
86
+ }
87
+
88
+ export { Select, SelectContent, SelectItem, SelectTrigger, SelectValue }
@@ -0,0 +1,23 @@
1
+ import { Separator as SeparatorPrimitive } from "@base-ui/react/separator"
2
+
3
+ import { cn } from "@/lib/utils"
4
+
5
+ function Separator({
6
+ className,
7
+ orientation = "horizontal",
8
+ ...props
9
+ }: SeparatorPrimitive.Props) {
10
+ return (
11
+ <SeparatorPrimitive
12
+ data-slot="separator"
13
+ orientation={orientation}
14
+ className={cn(
15
+ "shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",
16
+ className
17
+ )}
18
+ {...props}
19
+ />
20
+ )
21
+ }
22
+
23
+ export { Separator }
@@ -0,0 +1,89 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { Toggle as TogglePrimitive } from "@base-ui/react/toggle"
5
+ import { ToggleGroup as ToggleGroupPrimitive } from "@base-ui/react/toggle-group"
6
+ import { type VariantProps } from "class-variance-authority"
7
+
8
+ import { cn } from "@/lib/utils"
9
+ import { toggleVariants } from "@/components/ui/toggle"
10
+
11
+ const ToggleGroupContext = React.createContext<
12
+ VariantProps<typeof toggleVariants> & {
13
+ spacing?: number
14
+ orientation?: "horizontal" | "vertical"
15
+ }
16
+ >({
17
+ size: "default",
18
+ variant: "default",
19
+ spacing: 0,
20
+ orientation: "horizontal",
21
+ })
22
+
23
+ function ToggleGroup({
24
+ className,
25
+ variant,
26
+ size,
27
+ spacing = 0,
28
+ orientation = "horizontal",
29
+ children,
30
+ ...props
31
+ }: ToggleGroupPrimitive.Props &
32
+ VariantProps<typeof toggleVariants> & {
33
+ spacing?: number
34
+ orientation?: "horizontal" | "vertical"
35
+ }) {
36
+ return (
37
+ <ToggleGroupPrimitive
38
+ data-slot="toggle-group"
39
+ data-variant={variant}
40
+ data-size={size}
41
+ data-spacing={spacing}
42
+ data-orientation={orientation}
43
+ style={{ "--gap": spacing } as React.CSSProperties}
44
+ className={cn(
45
+ "group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-none data-[size=sm]:rounded-none data-vertical:flex-col data-vertical:items-stretch",
46
+ className
47
+ )}
48
+ {...props}
49
+ >
50
+ <ToggleGroupContext.Provider
51
+ value={{ variant, size, spacing, orientation }}
52
+ >
53
+ {children}
54
+ </ToggleGroupContext.Provider>
55
+ </ToggleGroupPrimitive>
56
+ )
57
+ }
58
+
59
+ function ToggleGroupItem({
60
+ className,
61
+ children,
62
+ variant = "default",
63
+ size = "default",
64
+ ...props
65
+ }: TogglePrimitive.Props & VariantProps<typeof toggleVariants>) {
66
+ const context = React.useContext(ToggleGroupContext)
67
+
68
+ return (
69
+ <TogglePrimitive
70
+ data-slot="toggle-group-item"
71
+ data-variant={context.variant || variant}
72
+ data-size={context.size || size}
73
+ data-spacing={context.spacing}
74
+ className={cn(
75
+ "shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-none group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-none group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-none group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-none group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t",
76
+ toggleVariants({
77
+ variant: context.variant || variant,
78
+ size: context.size || size,
79
+ }),
80
+ className
81
+ )}
82
+ {...props}
83
+ >
84
+ {children}
85
+ </TogglePrimitive>
86
+ )
87
+ }
88
+
89
+ export { ToggleGroup, ToggleGroupItem }
@@ -0,0 +1,43 @@
1
+ import { Toggle as TogglePrimitive } from "@base-ui/react/toggle"
2
+ import { cva, type VariantProps } from "class-variance-authority"
3
+
4
+ import { cn } from "@/lib/utils"
5
+
6
+ const toggleVariants = cva(
7
+ "group/toggle inline-flex items-center justify-center gap-1 rounded-none text-xs font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-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 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
8
+ {
9
+ variants: {
10
+ variant: {
11
+ default: "bg-transparent",
12
+ outline: "border border-input bg-transparent hover:bg-muted",
13
+ },
14
+ size: {
15
+ default:
16
+ "h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
17
+ sm: "h-7 min-w-7 rounded-none px-2.5 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5",
18
+ lg: "h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
19
+ },
20
+ },
21
+ defaultVariants: {
22
+ variant: "default",
23
+ size: "default",
24
+ },
25
+ }
26
+ )
27
+
28
+ function Toggle({
29
+ className,
30
+ variant = "default",
31
+ size = "default",
32
+ ...props
33
+ }: TogglePrimitive.Props & VariantProps<typeof toggleVariants>) {
34
+ return (
35
+ <TogglePrimitive
36
+ data-slot="toggle"
37
+ className={cn(toggleVariants({ variant, size, className }))}
38
+ {...props}
39
+ />
40
+ )
41
+ }
42
+
43
+ export { Toggle, toggleVariants }
@@ -0,0 +1,28 @@
1
+ import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"
2
+ import type { ViewMode, ViewModeApi } from "@/application/use-view-mode"
3
+
4
+ const VIEWS: { value: ViewMode; label: string }[] = [
5
+ { value: "tree", label: "Tree" },
6
+ { value: "list", label: "List" },
7
+ { value: "graph", label: "Graph" },
8
+ ]
9
+
10
+ export function ViewSwitcher({ view }: { view: ViewModeApi }) {
11
+ return (
12
+ <ToggleGroup
13
+ value={[view.view]}
14
+ onValueChange={(next) => {
15
+ const picked = next[0] as ViewMode | undefined
16
+ if (picked) view.setView(picked)
17
+ }}
18
+ variant="outline"
19
+ size="sm"
20
+ >
21
+ {VIEWS.map((v) => (
22
+ <ToggleGroupItem key={v.value} value={v.value}>
23
+ {v.label}
24
+ </ToggleGroupItem>
25
+ ))}
26
+ </ToggleGroup>
27
+ )
28
+ }