@valbuild/ui 0.21.2 → 0.22.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/.storybook/theme.css +5 -1
- package/components.json +16 -0
- package/dist/valbuild-ui.cjs.d.ts +11 -7
- package/dist/valbuild-ui.cjs.js +43607 -33216
- package/dist/valbuild-ui.esm.js +48313 -37938
- package/fix-server-hack.js +45 -0
- package/fullscreen.vite.config.ts +11 -0
- package/index.html +13 -0
- package/package.json +52 -13
- package/server/dist/manifest.json +16 -0
- package/server/dist/style.css +2145 -0
- package/server/dist/valbuild-ui-main.cjs.js +74441 -0
- package/server/dist/valbuild-ui-main.esm.js +74442 -0
- package/server/dist/valbuild-ui-server.cjs.js +19 -2
- package/server/dist/valbuild-ui-server.esm.js +19 -2
- package/server.vite.config.ts +2 -0
- package/src/App.tsx +73 -0
- package/src/assets/icons/Logo.tsx +103 -0
- package/src/components/Button.tsx +10 -2
- package/src/components/Dropdown.tsx +2 -2
- package/src/components/{dashboard/Grid.stories.tsx → Grid.stories.tsx} +8 -17
- package/src/components/{dashboard/Grid.tsx → Grid.tsx} +36 -23
- package/src/components/RichTextEditor/ContentEditable.tsx +109 -1
- package/src/components/RichTextEditor/Plugins/Toolbar.tsx +2 -2
- package/src/components/RichTextEditor/RichTextEditor.tsx +1 -1
- package/src/components/ValFormField.tsx +576 -0
- package/src/components/ValFullscreen.tsx +1283 -0
- package/src/components/ValMenu.tsx +65 -13
- package/src/components/ValOverlay.tsx +32 -338
- package/src/components/ValWindow.tsx +12 -9
- package/src/components/dashboard/FormGroup.tsx +12 -6
- package/src/components/dashboard/Tree.tsx +2 -2
- package/src/components/ui/accordion.tsx +58 -0
- package/src/components/ui/alert-dialog.tsx +139 -0
- package/src/components/ui/avatar.tsx +48 -0
- package/src/components/ui/button.tsx +56 -0
- package/src/components/ui/calendar.tsx +62 -0
- package/src/components/ui/card.tsx +86 -0
- package/src/components/ui/checkbox.tsx +28 -0
- package/src/components/ui/command.tsx +153 -0
- package/src/components/ui/dialog.tsx +120 -0
- package/src/components/ui/dropdown-menu.tsx +198 -0
- package/src/components/ui/form.tsx +177 -0
- package/src/components/ui/input.tsx +24 -0
- package/src/components/ui/label.tsx +24 -0
- package/src/components/ui/popover.tsx +29 -0
- package/src/components/ui/progress.tsx +26 -0
- package/src/components/ui/radio-group.tsx +42 -0
- package/src/components/ui/scroll-area.tsx +51 -0
- package/src/components/ui/select.tsx +119 -0
- package/src/components/ui/switch.tsx +27 -0
- package/src/components/ui/tabs.tsx +53 -0
- package/src/components/ui/toggle.tsx +43 -0
- package/src/components/ui/tooltip.tsx +28 -0
- package/src/components/usePatch.ts +86 -0
- package/src/components/useTheme.ts +45 -0
- package/src/exports.ts +2 -1
- package/src/index.css +96 -60
- package/src/lib/IValStore.ts +6 -0
- package/src/lib/utils.ts +6 -0
- package/src/main.jsx +10 -0
- package/src/richtext/conversion/lexicalToRichTextSource.ts +0 -1
- package/src/richtext/shadowRootPolyFill.js +115 -0
- package/src/server.ts +39 -2
- package/src/utils/resolvePath.ts +0 -1
- package/src/vite-server.ts +20 -3
- package/tailwind.config.js +63 -51
- package/tsconfig.json +2 -1
- package/vite.config.ts +10 -0
- package/src/components/dashboard/ValDashboard.tsx +0 -150
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as SelectPrimitive from "@radix-ui/react-select";
|
|
3
|
+
import { Check, ChevronDown } from "lucide-react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "../../lib/utils";
|
|
6
|
+
|
|
7
|
+
const Select = SelectPrimitive.Root;
|
|
8
|
+
|
|
9
|
+
const SelectGroup = SelectPrimitive.Group;
|
|
10
|
+
|
|
11
|
+
const SelectValue = SelectPrimitive.Value;
|
|
12
|
+
|
|
13
|
+
const SelectTrigger = React.forwardRef<
|
|
14
|
+
React.ElementRef<typeof SelectPrimitive.Trigger>,
|
|
15
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
|
|
16
|
+
>(({ className, children, ...props }, ref) => (
|
|
17
|
+
<SelectPrimitive.Trigger
|
|
18
|
+
ref={ref}
|
|
19
|
+
className={cn(
|
|
20
|
+
"flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
|
21
|
+
className
|
|
22
|
+
)}
|
|
23
|
+
{...props}
|
|
24
|
+
>
|
|
25
|
+
{children}
|
|
26
|
+
<SelectPrimitive.Icon asChild>
|
|
27
|
+
<ChevronDown className="w-4 h-4 opacity-50" />
|
|
28
|
+
</SelectPrimitive.Icon>
|
|
29
|
+
</SelectPrimitive.Trigger>
|
|
30
|
+
));
|
|
31
|
+
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
32
|
+
|
|
33
|
+
const SelectContent = React.forwardRef<
|
|
34
|
+
React.ElementRef<typeof SelectPrimitive.Content>,
|
|
35
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
|
|
36
|
+
>(({ className, children, position = "popper", ...props }, ref) => (
|
|
37
|
+
<SelectPrimitive.Portal>
|
|
38
|
+
<SelectPrimitive.Content
|
|
39
|
+
ref={ref}
|
|
40
|
+
className={cn(
|
|
41
|
+
"relative z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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",
|
|
42
|
+
position === "popper" &&
|
|
43
|
+
"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
|
44
|
+
className
|
|
45
|
+
)}
|
|
46
|
+
position={position}
|
|
47
|
+
{...props}
|
|
48
|
+
>
|
|
49
|
+
<SelectPrimitive.Viewport
|
|
50
|
+
className={cn(
|
|
51
|
+
"p-1",
|
|
52
|
+
position === "popper" &&
|
|
53
|
+
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
|
|
54
|
+
)}
|
|
55
|
+
>
|
|
56
|
+
{children}
|
|
57
|
+
</SelectPrimitive.Viewport>
|
|
58
|
+
</SelectPrimitive.Content>
|
|
59
|
+
</SelectPrimitive.Portal>
|
|
60
|
+
));
|
|
61
|
+
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
62
|
+
|
|
63
|
+
const SelectLabel = React.forwardRef<
|
|
64
|
+
React.ElementRef<typeof SelectPrimitive.Label>,
|
|
65
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
|
|
66
|
+
>(({ className, ...props }, ref) => (
|
|
67
|
+
<SelectPrimitive.Label
|
|
68
|
+
ref={ref}
|
|
69
|
+
className={cn("py-1.5 pl-8 pr-2 text-sm font-semibold", className)}
|
|
70
|
+
{...props}
|
|
71
|
+
/>
|
|
72
|
+
));
|
|
73
|
+
SelectLabel.displayName = SelectPrimitive.Label.displayName;
|
|
74
|
+
|
|
75
|
+
const SelectItem = React.forwardRef<
|
|
76
|
+
React.ElementRef<typeof SelectPrimitive.Item>,
|
|
77
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
|
|
78
|
+
>(({ className, children, ...props }, ref) => (
|
|
79
|
+
<SelectPrimitive.Item
|
|
80
|
+
ref={ref}
|
|
81
|
+
className={cn(
|
|
82
|
+
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
83
|
+
className
|
|
84
|
+
)}
|
|
85
|
+
{...props}
|
|
86
|
+
>
|
|
87
|
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
88
|
+
<SelectPrimitive.ItemIndicator>
|
|
89
|
+
<Check className="w-4 h-4" />
|
|
90
|
+
</SelectPrimitive.ItemIndicator>
|
|
91
|
+
</span>
|
|
92
|
+
|
|
93
|
+
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
|
94
|
+
</SelectPrimitive.Item>
|
|
95
|
+
));
|
|
96
|
+
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
97
|
+
|
|
98
|
+
const SelectSeparator = React.forwardRef<
|
|
99
|
+
React.ElementRef<typeof SelectPrimitive.Separator>,
|
|
100
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
|
|
101
|
+
>(({ className, ...props }, ref) => (
|
|
102
|
+
<SelectPrimitive.Separator
|
|
103
|
+
ref={ref}
|
|
104
|
+
className={cn("-mx-1 my-1 h-px bg-muted", className)}
|
|
105
|
+
{...props}
|
|
106
|
+
/>
|
|
107
|
+
));
|
|
108
|
+
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
|
|
109
|
+
|
|
110
|
+
export {
|
|
111
|
+
Select,
|
|
112
|
+
SelectGroup,
|
|
113
|
+
SelectValue,
|
|
114
|
+
SelectTrigger,
|
|
115
|
+
SelectContent,
|
|
116
|
+
SelectLabel,
|
|
117
|
+
SelectItem,
|
|
118
|
+
SelectSeparator,
|
|
119
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as SwitchPrimitives from "@radix-ui/react-switch";
|
|
3
|
+
|
|
4
|
+
import { cn } from "../../lib/utils";
|
|
5
|
+
|
|
6
|
+
const Switch = React.forwardRef<
|
|
7
|
+
React.ElementRef<typeof SwitchPrimitives.Root>,
|
|
8
|
+
React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>
|
|
9
|
+
>(({ className, ...props }, ref) => (
|
|
10
|
+
<SwitchPrimitives.Root
|
|
11
|
+
className={cn(
|
|
12
|
+
"peer inline-flex h-[22px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-accent data-[state=unchecked]:bg-primary",
|
|
13
|
+
className
|
|
14
|
+
)}
|
|
15
|
+
{...props}
|
|
16
|
+
ref={ref}
|
|
17
|
+
>
|
|
18
|
+
<SwitchPrimitives.Thumb
|
|
19
|
+
className={cn(
|
|
20
|
+
"pointer-events-none block h-[18px] w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0"
|
|
21
|
+
)}
|
|
22
|
+
/>
|
|
23
|
+
</SwitchPrimitives.Root>
|
|
24
|
+
));
|
|
25
|
+
Switch.displayName = SwitchPrimitives.Root.displayName;
|
|
26
|
+
|
|
27
|
+
export { Switch };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as TabsPrimitive from "@radix-ui/react-tabs";
|
|
3
|
+
|
|
4
|
+
import { cn } from "../../lib/utils";
|
|
5
|
+
|
|
6
|
+
const Tabs = TabsPrimitive.Root;
|
|
7
|
+
|
|
8
|
+
const TabsList = React.forwardRef<
|
|
9
|
+
React.ElementRef<typeof TabsPrimitive.List>,
|
|
10
|
+
React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
|
|
11
|
+
>(({ className, ...props }, ref) => (
|
|
12
|
+
<TabsPrimitive.List
|
|
13
|
+
ref={ref}
|
|
14
|
+
className={cn(
|
|
15
|
+
"inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",
|
|
16
|
+
className
|
|
17
|
+
)}
|
|
18
|
+
{...props}
|
|
19
|
+
/>
|
|
20
|
+
));
|
|
21
|
+
TabsList.displayName = TabsPrimitive.List.displayName;
|
|
22
|
+
|
|
23
|
+
const TabsTrigger = React.forwardRef<
|
|
24
|
+
React.ElementRef<typeof TabsPrimitive.Trigger>,
|
|
25
|
+
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
|
|
26
|
+
>(({ className, ...props }, ref) => (
|
|
27
|
+
<TabsPrimitive.Trigger
|
|
28
|
+
ref={ref}
|
|
29
|
+
className={cn(
|
|
30
|
+
"inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",
|
|
31
|
+
className
|
|
32
|
+
)}
|
|
33
|
+
{...props}
|
|
34
|
+
/>
|
|
35
|
+
));
|
|
36
|
+
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
|
|
37
|
+
|
|
38
|
+
const TabsContent = React.forwardRef<
|
|
39
|
+
React.ElementRef<typeof TabsPrimitive.Content>,
|
|
40
|
+
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
|
|
41
|
+
>(({ className, ...props }, ref) => (
|
|
42
|
+
<TabsPrimitive.Content
|
|
43
|
+
ref={ref}
|
|
44
|
+
className={cn(
|
|
45
|
+
"mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
46
|
+
className
|
|
47
|
+
)}
|
|
48
|
+
{...props}
|
|
49
|
+
/>
|
|
50
|
+
));
|
|
51
|
+
TabsContent.displayName = TabsPrimitive.Content.displayName;
|
|
52
|
+
|
|
53
|
+
export { Tabs, TabsList, TabsTrigger, TabsContent };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as TogglePrimitive from "@radix-ui/react-toggle";
|
|
3
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
4
|
+
|
|
5
|
+
import { cn } from "../../lib/utils";
|
|
6
|
+
|
|
7
|
+
const toggleVariants = cva(
|
|
8
|
+
"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
default: "bg-transparent",
|
|
13
|
+
outline:
|
|
14
|
+
"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground",
|
|
15
|
+
},
|
|
16
|
+
size: {
|
|
17
|
+
default: "h-10 px-3",
|
|
18
|
+
sm: "h-9 px-2.5",
|
|
19
|
+
lg: "h-11 px-5",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
defaultVariants: {
|
|
23
|
+
variant: "default",
|
|
24
|
+
size: "default",
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const Toggle = React.forwardRef<
|
|
30
|
+
React.ElementRef<typeof TogglePrimitive.Root>,
|
|
31
|
+
React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root> &
|
|
32
|
+
VariantProps<typeof toggleVariants>
|
|
33
|
+
>(({ className, variant, size, ...props }, ref) => (
|
|
34
|
+
<TogglePrimitive.Root
|
|
35
|
+
ref={ref}
|
|
36
|
+
className={cn(toggleVariants({ variant, size, className }))}
|
|
37
|
+
{...props}
|
|
38
|
+
/>
|
|
39
|
+
));
|
|
40
|
+
|
|
41
|
+
Toggle.displayName = TogglePrimitive.Root.displayName;
|
|
42
|
+
|
|
43
|
+
export { Toggle, toggleVariants };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
3
|
+
|
|
4
|
+
import { cn } from "../../lib/utils";
|
|
5
|
+
|
|
6
|
+
const TooltipProvider = TooltipPrimitive.Provider;
|
|
7
|
+
|
|
8
|
+
const Tooltip = TooltipPrimitive.Root;
|
|
9
|
+
|
|
10
|
+
const TooltipTrigger = TooltipPrimitive.Trigger;
|
|
11
|
+
|
|
12
|
+
const TooltipContent = React.forwardRef<
|
|
13
|
+
React.ElementRef<typeof TooltipPrimitive.Content>,
|
|
14
|
+
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
|
|
15
|
+
>(({ className, sideOffset = 4, ...props }, ref) => (
|
|
16
|
+
<TooltipPrimitive.Content
|
|
17
|
+
ref={ref}
|
|
18
|
+
sideOffset={sideOffset}
|
|
19
|
+
className={cn(
|
|
20
|
+
"z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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",
|
|
21
|
+
className
|
|
22
|
+
)}
|
|
23
|
+
{...props}
|
|
24
|
+
/>
|
|
25
|
+
));
|
|
26
|
+
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
|
27
|
+
|
|
28
|
+
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { SourcePath, Internal, ModuleId, ValApi } from "@valbuild/core";
|
|
2
|
+
import { result } from "@valbuild/core/fp";
|
|
3
|
+
import { PatchJSON } from "@valbuild/core/patch";
|
|
4
|
+
import { useCallback, useEffect, useState } from "react";
|
|
5
|
+
import { IValStore } from "../exports";
|
|
6
|
+
|
|
7
|
+
export type PatchCallback = (modulePath: string) => Promise<PatchJSON>;
|
|
8
|
+
|
|
9
|
+
export type InitPatchCallback = (
|
|
10
|
+
currentPath: SourcePath
|
|
11
|
+
) => (callback: PatchCallback) => void;
|
|
12
|
+
|
|
13
|
+
export type PatchCallbackState = {
|
|
14
|
+
[path: SourcePath]: () => Promise<PatchJSON>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export function usePatch(
|
|
18
|
+
paths: SourcePath[],
|
|
19
|
+
api: ValApi,
|
|
20
|
+
valStore: IValStore
|
|
21
|
+
) {
|
|
22
|
+
const [state, setState] = useState<PatchCallbackState>({});
|
|
23
|
+
|
|
24
|
+
const initPatchCallback: InitPatchCallback = useCallback(
|
|
25
|
+
(currentPath: SourcePath) => {
|
|
26
|
+
return (callback: PatchCallback) => {
|
|
27
|
+
const patchPath = Internal.createPatchJSONPath(
|
|
28
|
+
Internal.splitModuleIdAndModulePath(currentPath)[1]
|
|
29
|
+
);
|
|
30
|
+
setState((prev) => {
|
|
31
|
+
return {
|
|
32
|
+
...prev,
|
|
33
|
+
[currentPath]: () => callback(patchPath),
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
[]
|
|
39
|
+
);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
setState((prev) => {
|
|
42
|
+
const newState: PatchCallbackState = {};
|
|
43
|
+
// filter out paths that no longer are selected
|
|
44
|
+
for (const path of paths) {
|
|
45
|
+
if (prev[path]) {
|
|
46
|
+
newState[path] = prev[path];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (Object.keys(newState).length === Object.keys(prev).length) {
|
|
50
|
+
// avoid infinite loops
|
|
51
|
+
return prev;
|
|
52
|
+
}
|
|
53
|
+
return newState;
|
|
54
|
+
});
|
|
55
|
+
}, [paths]);
|
|
56
|
+
|
|
57
|
+
const onSubmitPatch = useCallback(async () => {
|
|
58
|
+
const patches: Record<ModuleId, PatchJSON> = {};
|
|
59
|
+
for (const path in state) {
|
|
60
|
+
const [moduleId] = Internal.splitModuleIdAndModulePath(
|
|
61
|
+
path as SourcePath
|
|
62
|
+
);
|
|
63
|
+
const patch = await state[path as SourcePath]();
|
|
64
|
+
patches[moduleId] = patch;
|
|
65
|
+
}
|
|
66
|
+
return Promise.all(
|
|
67
|
+
Object.entries(patches).map(([moduleId, patch]) =>
|
|
68
|
+
api.postPatches(moduleId as ModuleId, patch).then((res) => {
|
|
69
|
+
if (result.isErr(res)) {
|
|
70
|
+
throw res.error;
|
|
71
|
+
} else {
|
|
72
|
+
res.value;
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
)
|
|
76
|
+
).then(() => {
|
|
77
|
+
return valStore.update(
|
|
78
|
+
paths.map(
|
|
79
|
+
(path) => Internal.splitModuleIdAndModulePath(path as SourcePath)[0]
|
|
80
|
+
)
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
}, [state]);
|
|
84
|
+
|
|
85
|
+
return { initPatchCallback, onSubmitPatch };
|
|
86
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useState, useEffect } from "react";
|
|
2
|
+
import { Theme } from "./ValOverlayContext";
|
|
3
|
+
|
|
4
|
+
export function useTheme(defaultTheme: Theme = "dark") {
|
|
5
|
+
const [theme, setTheme] = useState<Theme>(defaultTheme);
|
|
6
|
+
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (localStorage.getItem("val-theme") === "light") {
|
|
9
|
+
setTheme("light");
|
|
10
|
+
} else if (localStorage.getItem("val-theme") === "dark") {
|
|
11
|
+
setTheme("dark");
|
|
12
|
+
} else if (
|
|
13
|
+
window.matchMedia &&
|
|
14
|
+
window.matchMedia("(prefers-color-scheme: dark)").matches
|
|
15
|
+
) {
|
|
16
|
+
setTheme("dark");
|
|
17
|
+
} else if (
|
|
18
|
+
window.matchMedia &&
|
|
19
|
+
window.matchMedia("(prefers-color-scheme: light)").matches
|
|
20
|
+
) {
|
|
21
|
+
setTheme("light");
|
|
22
|
+
}
|
|
23
|
+
const themeListener = (e: MediaQueryListEvent) => {
|
|
24
|
+
if (!localStorage.getItem("val-theme")) {
|
|
25
|
+
setTheme(e.matches ? "dark" : "light");
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
window
|
|
29
|
+
.matchMedia("(prefers-color-scheme: dark)")
|
|
30
|
+
.addEventListener("change", themeListener);
|
|
31
|
+
return () => {
|
|
32
|
+
window
|
|
33
|
+
.matchMedia("(prefers-color-scheme: dark)")
|
|
34
|
+
.removeEventListener("change", themeListener);
|
|
35
|
+
};
|
|
36
|
+
}, []);
|
|
37
|
+
|
|
38
|
+
return [
|
|
39
|
+
theme,
|
|
40
|
+
(theme: Theme) => {
|
|
41
|
+
localStorage.setItem("val-theme", theme);
|
|
42
|
+
setTheme(theme);
|
|
43
|
+
},
|
|
44
|
+
] as const;
|
|
45
|
+
}
|
package/src/exports.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { RichTextEditor } from "./components/RichTextEditor/RichTextEditor";
|
|
2
2
|
export { ValOverlay } from "./components/ValOverlay";
|
|
3
3
|
export { type Inputs } from "./components/forms/Form";
|
|
4
|
-
export {
|
|
4
|
+
export { ValFullscreen } from "./components/ValFullscreen";
|
|
5
5
|
export { parseRichTextSource } from "./richtext/conversion/parseRichTextSource";
|
|
6
|
+
export { type IValStore } from "./lib/IValStore";
|
package/src/index.css
CHANGED
|
@@ -4,76 +4,112 @@
|
|
|
4
4
|
*/
|
|
5
5
|
@config "../tailwind.config.js";
|
|
6
6
|
|
|
7
|
+
@tailwind base;
|
|
8
|
+
@tailwind components;
|
|
9
|
+
@tailwind utilities;
|
|
10
|
+
|
|
7
11
|
@layer base {
|
|
8
|
-
/*
|
|
12
|
+
/* :host for use with Shadow DOM, copied from the TailwindCSS prelude */
|
|
9
13
|
:host {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
--
|
|
21
|
-
|
|
22
|
-
--
|
|
23
|
-
--
|
|
24
|
-
|
|
25
|
-
--
|
|
26
|
-
--
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
--
|
|
32
|
-
--
|
|
33
|
-
|
|
34
|
-
--
|
|
14
|
+
--background: 0 0% 100%;
|
|
15
|
+
--foreground: 222.2 84% 4.9%;
|
|
16
|
+
|
|
17
|
+
--card: 0 0% 100%;
|
|
18
|
+
--card-foreground: 222.2 84% 4.9%;
|
|
19
|
+
|
|
20
|
+
--popover: 0 0% 100%;
|
|
21
|
+
--popover-foreground: 222.2 84% 4.9%;
|
|
22
|
+
|
|
23
|
+
--primary: 222.2 47.4% 11.2%;
|
|
24
|
+
--primary-foreground: 210 40% 98%;
|
|
25
|
+
|
|
26
|
+
--secondary: 210 40% 96.1%;
|
|
27
|
+
--secondary-foreground: 222.2 47.4% 11.2%;
|
|
28
|
+
|
|
29
|
+
--muted: 0 0% 57.3%;
|
|
30
|
+
--muted-foreground: 215.4 16.3% 46.9%;
|
|
31
|
+
|
|
32
|
+
--accent: 159, 60%, 51%, 1;
|
|
33
|
+
--accent-foreground: 222.2 47.4% 11.2%;
|
|
34
|
+
|
|
35
|
+
--destructive: 0 84.2% 60.2%;
|
|
36
|
+
--destructive-foreground: 210 40% 98%;
|
|
37
|
+
|
|
38
|
+
--border: 214.3 31.8% 91.4%;
|
|
39
|
+
--input: 214.3 31.8% 91.4%;
|
|
40
|
+
--ring: 222.2 84% 4.9%;
|
|
41
|
+
|
|
42
|
+
--radius: 0.5rem;
|
|
43
|
+
}
|
|
44
|
+
:root {
|
|
45
|
+
--background: 0 0% 100%;
|
|
46
|
+
--foreground: 222.2 84% 4.9%;
|
|
47
|
+
|
|
48
|
+
--card: 0 0% 100%;
|
|
49
|
+
--card-foreground: 222.2 84% 4.9%;
|
|
50
|
+
|
|
51
|
+
--popover: 0 0% 100%;
|
|
52
|
+
--popover-foreground: 222.2 84% 4.9%;
|
|
53
|
+
|
|
54
|
+
--primary: 222.2 47.4% 11.2%;
|
|
55
|
+
--primary-foreground: 210 40% 98%;
|
|
56
|
+
|
|
57
|
+
--secondary: 210 40% 96.1%;
|
|
58
|
+
--secondary-foreground: 222.2 47.4% 11.2%;
|
|
59
|
+
|
|
60
|
+
--muted: 0 0% 57.3%;
|
|
61
|
+
--muted-foreground: 215.4 16.3% 46.9%;
|
|
62
|
+
|
|
63
|
+
--accent: 159, 60%, 51%, 1;
|
|
64
|
+
--accent-foreground: 222.2 47.4% 11.2%;
|
|
65
|
+
|
|
66
|
+
--destructive: 0 84.2% 60.2%;
|
|
67
|
+
--destructive-foreground: 210 40% 98%;
|
|
68
|
+
|
|
69
|
+
--border: 214.3 31.8% 91.4%;
|
|
70
|
+
--input: 214.3 31.8% 91.4%;
|
|
71
|
+
--ring: 222.2 84% 4.9%;
|
|
72
|
+
|
|
73
|
+
--radius: 0.5rem;
|
|
35
74
|
}
|
|
36
75
|
|
|
37
76
|
/* dark theme */
|
|
38
77
|
*[data-mode="dark"] {
|
|
39
|
-
--
|
|
40
|
-
--
|
|
41
|
-
--val-theme-border: var(--val-theme-dark-gray);
|
|
42
|
-
--val-theme-fill: var(--val-theme-medium-black);
|
|
43
|
-
--val-theme-primary: var(--val-theme-white);
|
|
44
|
-
}
|
|
78
|
+
--background: 0 0% 4%;
|
|
79
|
+
--foreground: 210 40% 98%;
|
|
45
80
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
81
|
+
--card: 222.2 84% 4.9%;
|
|
82
|
+
--card-foreground: 210 40% 98%;
|
|
83
|
+
|
|
84
|
+
--popover: 222.2 84% 4.9%;
|
|
85
|
+
--popover-foreground: 210 40% 98%;
|
|
86
|
+
|
|
87
|
+
--primary: 210 40% 98%;
|
|
88
|
+
--primary-foreground: 222.2 47.4% 11.2%;
|
|
89
|
+
|
|
90
|
+
--secondary: 217.2 32.6% 17.5%;
|
|
91
|
+
--secondary-foreground: 210 40% 98%;
|
|
54
92
|
|
|
55
|
-
|
|
56
|
-
|
|
93
|
+
--muted: 178, 23%, 76%, 1;
|
|
94
|
+
--muted-foreground: 215 20.2% 65.1%;
|
|
57
95
|
|
|
58
|
-
|
|
59
|
-
|
|
96
|
+
--accent: 159, 60%, 51%, 1;
|
|
97
|
+
--accent-foreground: 210 40% 98%;
|
|
98
|
+
|
|
99
|
+
--destructive: 0 62.8% 30.6%;
|
|
100
|
+
--destructive-foreground: 210 40% 98%;
|
|
101
|
+
|
|
102
|
+
--border: 217.2 32.6% 17.5%;
|
|
103
|
+
--input: 217.2 32.6% 17.5%;
|
|
104
|
+
--ring: 212.7 26.8% 83.9%;
|
|
60
105
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@layer base {
|
|
109
|
+
* {
|
|
110
|
+
@apply border-border;
|
|
64
111
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
/* Identical styling required!! */
|
|
68
|
-
border: 1px solid black;
|
|
69
|
-
padding: 0.5rem;
|
|
70
|
-
font: inherit;
|
|
71
|
-
|
|
72
|
-
/* Place on top of each other */
|
|
73
|
-
grid-area: 1 / 1 / 2 / 2;
|
|
112
|
+
body {
|
|
113
|
+
@apply bg-background text-foreground;
|
|
74
114
|
}
|
|
75
115
|
}
|
|
76
|
-
|
|
77
|
-
@tailwind base;
|
|
78
|
-
@tailwind components;
|
|
79
|
-
@tailwind utilities;
|
package/src/lib/utils.ts
ADDED
package/src/main.jsx
ADDED
|
@@ -229,7 +229,6 @@ async function fromLexicalImageNode(
|
|
|
229
229
|
files: Record<string, string>
|
|
230
230
|
) {
|
|
231
231
|
if (node.src.startsWith("data:")) {
|
|
232
|
-
console.log("node", node);
|
|
233
232
|
const sha256 = await Internal.getSHA256Hash(textEncoder.encode(node.src));
|
|
234
233
|
const mimeType = getMimeType(node.src);
|
|
235
234
|
if (mimeType === undefined) {
|