@oppulence/design-system 1.0.4 → 1.0.5
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/hooks/use-resize-observer.ts +24 -0
- package/lib/ai.ts +31 -0
- package/package.json +19 -1
- package/src/components/atoms/animated-size-container.tsx +59 -0
- package/src/components/atoms/currency-input.tsx +16 -0
- package/src/components/atoms/icons.tsx +840 -0
- package/src/components/atoms/image.tsx +23 -0
- package/src/components/atoms/index.ts +10 -0
- package/src/components/atoms/loader.tsx +92 -0
- package/src/components/atoms/quantity-input.tsx +103 -0
- package/src/components/atoms/record-button.tsx +178 -0
- package/src/components/atoms/submit-button.tsx +26 -0
- package/src/components/atoms/text-effect.tsx +251 -0
- package/src/components/atoms/text-shimmer.tsx +74 -0
- package/src/components/molecules/actions.tsx +53 -0
- package/src/components/molecules/branch.tsx +192 -0
- package/src/components/molecules/code-block.tsx +151 -0
- package/src/components/molecules/form.tsx +177 -0
- package/src/components/molecules/index.ts +12 -0
- package/src/components/molecules/inline-citation.tsx +295 -0
- package/src/components/molecules/message.tsx +64 -0
- package/src/components/molecules/sources.tsx +116 -0
- package/src/components/molecules/suggestion.tsx +53 -0
- package/src/components/molecules/task.tsx +74 -0
- package/src/components/molecules/time-range-input.tsx +73 -0
- package/src/components/molecules/tool-call-indicator.tsx +42 -0
- package/src/components/molecules/tool.tsx +130 -0
- package/src/components/organisms/combobox-dropdown.tsx +171 -0
- package/src/components/organisms/conversation.tsx +98 -0
- package/src/components/organisms/date-range-picker.tsx +53 -0
- package/src/components/organisms/editor/extentions/bubble-menu/bubble-item.tsx +30 -0
- package/src/components/organisms/editor/extentions/bubble-menu/bubble-menu-button.tsx +27 -0
- package/src/components/organisms/editor/extentions/bubble-menu/index.tsx +63 -0
- package/src/components/organisms/editor/extentions/bubble-menu/link-item.tsx +104 -0
- package/src/components/organisms/editor/extentions/register.ts +22 -0
- package/src/components/organisms/editor/index.tsx +50 -0
- package/src/components/organisms/editor/styles.css +31 -0
- package/src/components/organisms/editor/utils.ts +19 -0
- package/src/components/organisms/index.ts +11 -0
- package/src/components/organisms/multiple-selector.tsx +632 -0
- package/src/components/organisms/prompt-input.tsx +747 -0
- package/src/components/organisms/reasoning.tsx +170 -0
- package/src/components/organisms/response.tsx +121 -0
- package/src/components/organisms/toast-toaster.tsx +84 -0
- package/src/components/organisms/toast.tsx +124 -0
- package/src/components/organisms/use-toast.tsx +206 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { Editor } from "@tiptap/react";
|
|
4
|
+
import { useRef, useState } from "react";
|
|
5
|
+
import {
|
|
6
|
+
MdOutlineAddLink,
|
|
7
|
+
MdOutlineCheck,
|
|
8
|
+
MdOutlineDelete,
|
|
9
|
+
MdOutlineLinkOff,
|
|
10
|
+
} from "react-icons/md";
|
|
11
|
+
import { cn } from "../../../../../../lib/utils";
|
|
12
|
+
import { buttonVariants } from "../../../../atoms/button";
|
|
13
|
+
import { Popover, PopoverContent, PopoverTrigger } from "../../../../molecules/popover";
|
|
14
|
+
import { formatUrlWithProtocol } from "../../utils";
|
|
15
|
+
import { BubbleMenuButton } from "./bubble-menu-button";
|
|
16
|
+
|
|
17
|
+
interface LinkItemProps {
|
|
18
|
+
editor: Editor;
|
|
19
|
+
open: boolean;
|
|
20
|
+
setOpen: (open: boolean) => void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function LinkItem({ editor, open, setOpen }: LinkItemProps) {
|
|
24
|
+
const [value, setValue] = useState("");
|
|
25
|
+
const isActive = editor.isActive("link");
|
|
26
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
27
|
+
const linkValue = editor.getAttributes("link").href;
|
|
28
|
+
|
|
29
|
+
const handleSubmit = () => {
|
|
30
|
+
const url = formatUrlWithProtocol(value);
|
|
31
|
+
|
|
32
|
+
if (url) {
|
|
33
|
+
editor
|
|
34
|
+
.chain()
|
|
35
|
+
.focus()
|
|
36
|
+
.extendMarkRange("link")
|
|
37
|
+
.setLink({ href: url })
|
|
38
|
+
.run();
|
|
39
|
+
|
|
40
|
+
setOpen(false);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<Popover modal={false} open={open} onOpenChange={setOpen}>
|
|
46
|
+
<PopoverTrigger
|
|
47
|
+
render={<BubbleMenuButton isActive={isActive} action={() => setOpen(true)} />}
|
|
48
|
+
>
|
|
49
|
+
{linkValue ? (
|
|
50
|
+
<MdOutlineLinkOff className="size-4" />
|
|
51
|
+
) : (
|
|
52
|
+
<MdOutlineAddLink className="size-4" />
|
|
53
|
+
)}
|
|
54
|
+
</PopoverTrigger>
|
|
55
|
+
<PopoverContent align="end" sideOffset={10}>
|
|
56
|
+
<div className="flex p-1 w-60">
|
|
57
|
+
<input
|
|
58
|
+
ref={inputRef}
|
|
59
|
+
type="text"
|
|
60
|
+
placeholder="Paste a link"
|
|
61
|
+
className="flex-1 bg-background p-0.5 h-7 text-xs outline-none placeholder:text-[#878787]"
|
|
62
|
+
defaultValue={linkValue || ""}
|
|
63
|
+
onChange={(e) => setValue(e.target.value)}
|
|
64
|
+
onKeyDown={(e) => {
|
|
65
|
+
if (e.key === "Enter") {
|
|
66
|
+
handleSubmit();
|
|
67
|
+
}
|
|
68
|
+
}}
|
|
69
|
+
/>
|
|
70
|
+
|
|
71
|
+
{linkValue ? (
|
|
72
|
+
<button
|
|
73
|
+
className={cn(
|
|
74
|
+
buttonVariants({ variant: "outline", size: "icon-xs" }),
|
|
75
|
+
"flex size-7 items-center p-1 text-red-600 transition-all hover:bg-red-100 dark:hover:bg-red-800 hover:border-none",
|
|
76
|
+
)}
|
|
77
|
+
type="button"
|
|
78
|
+
onClick={() => {
|
|
79
|
+
editor.chain().focus().unsetLink().run();
|
|
80
|
+
if (inputRef.current) {
|
|
81
|
+
inputRef.current.value = "";
|
|
82
|
+
}
|
|
83
|
+
setOpen(false);
|
|
84
|
+
}}
|
|
85
|
+
>
|
|
86
|
+
<MdOutlineDelete className="size-4" />
|
|
87
|
+
</button>
|
|
88
|
+
) : (
|
|
89
|
+
<button
|
|
90
|
+
className={cn(
|
|
91
|
+
buttonVariants({ variant: "default", size: "icon-xs" }),
|
|
92
|
+
"size-7",
|
|
93
|
+
)}
|
|
94
|
+
type="button"
|
|
95
|
+
onClick={handleSubmit}
|
|
96
|
+
>
|
|
97
|
+
<MdOutlineCheck className="size-4" />
|
|
98
|
+
</button>
|
|
99
|
+
)}
|
|
100
|
+
</div>
|
|
101
|
+
</PopoverContent>
|
|
102
|
+
</Popover>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// You can find the list of extensions here: https://tiptap.dev/docs/editor/extensions/functionality
|
|
2
|
+
|
|
3
|
+
import Link from "@tiptap/extension-link";
|
|
4
|
+
import Placeholder from "@tiptap/extension-placeholder";
|
|
5
|
+
import Underline from "@tiptap/extension-underline";
|
|
6
|
+
import StarterKit from "@tiptap/starter-kit";
|
|
7
|
+
|
|
8
|
+
// Add your extensions here
|
|
9
|
+
const extensions = [
|
|
10
|
+
StarterKit,
|
|
11
|
+
Underline,
|
|
12
|
+
Link.configure({
|
|
13
|
+
openOnClick: false,
|
|
14
|
+
autolink: true,
|
|
15
|
+
defaultProtocol: "https",
|
|
16
|
+
}),
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
export function registerExtensions(options?: { placeholder?: string }) {
|
|
20
|
+
const { placeholder } = options ?? {};
|
|
21
|
+
return [...extensions, Placeholder.configure({ placeholder })];
|
|
22
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import "./styles.css";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
EditorContent,
|
|
7
|
+
type Editor as EditorInstance,
|
|
8
|
+
type JSONContent,
|
|
9
|
+
useEditor,
|
|
10
|
+
} from "@tiptap/react";
|
|
11
|
+
import { BubbleMenu } from "./extentions/bubble-menu";
|
|
12
|
+
import { registerExtensions } from "./extentions/register";
|
|
13
|
+
|
|
14
|
+
type EditorProps = {
|
|
15
|
+
initialContent?: JSONContent | string;
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
onUpdate?: (editor: EditorInstance) => void;
|
|
18
|
+
onBlur?: () => void;
|
|
19
|
+
onFocus?: () => void;
|
|
20
|
+
tabIndex?: number;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function Editor({
|
|
24
|
+
initialContent,
|
|
25
|
+
placeholder,
|
|
26
|
+
onUpdate,
|
|
27
|
+
onBlur,
|
|
28
|
+
onFocus,
|
|
29
|
+
tabIndex,
|
|
30
|
+
}: EditorProps) {
|
|
31
|
+
const editor = useEditor({
|
|
32
|
+
extensions: registerExtensions({ placeholder }),
|
|
33
|
+
content: initialContent,
|
|
34
|
+
immediatelyRender: false,
|
|
35
|
+
onBlur,
|
|
36
|
+
onFocus,
|
|
37
|
+
onUpdate: ({ editor }) => {
|
|
38
|
+
onUpdate?.(editor);
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (!editor) return null;
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<>
|
|
46
|
+
<EditorContent editor={editor} tabIndex={tabIndex} />
|
|
47
|
+
<BubbleMenu editor={editor} />
|
|
48
|
+
</>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
@reference "../../../styles/globals.css";
|
|
2
|
+
|
|
3
|
+
.ProseMirror-focused {
|
|
4
|
+
@apply outline-none;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.tiptap {
|
|
8
|
+
@apply text-xs leading-loose;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.tiptap h2 {
|
|
12
|
+
@apply text-2xl;
|
|
13
|
+
@apply font-sans;
|
|
14
|
+
margin-bottom: 1.5rem;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.tiptap a {
|
|
18
|
+
@apply underline;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.tiptap .bubble-menu {
|
|
22
|
+
@apply flex gap-2;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.tiptap p.is-empty::before {
|
|
26
|
+
color: #404040;
|
|
27
|
+
content: attr(data-placeholder);
|
|
28
|
+
float: left;
|
|
29
|
+
height: 0;
|
|
30
|
+
pointer-events: none;
|
|
31
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function isValidUrlFormat(urlString: string) {
|
|
2
|
+
try {
|
|
3
|
+
new URL(urlString);
|
|
4
|
+
return true;
|
|
5
|
+
} catch (_error) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function formatUrlWithProtocol(rawUrlString: string) {
|
|
11
|
+
if (isValidUrlFormat(rawUrlString)) return rawUrlString;
|
|
12
|
+
try {
|
|
13
|
+
if (rawUrlString.includes(".") && !rawUrlString.includes(" ")) {
|
|
14
|
+
return new URL(`https://${rawUrlString}`).toString();
|
|
15
|
+
}
|
|
16
|
+
} catch (_error) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -4,14 +4,25 @@ export * from "./calendar";
|
|
|
4
4
|
export * from "./carousel";
|
|
5
5
|
export * from "./chart";
|
|
6
6
|
export * from "./combobox";
|
|
7
|
+
export * from "./combobox-dropdown";
|
|
7
8
|
export * from "./command";
|
|
9
|
+
export * from "./conversation";
|
|
8
10
|
export * from "./context-menu";
|
|
11
|
+
export * from "./date-range-picker";
|
|
9
12
|
export * from "./dialog";
|
|
10
13
|
export * from "./drawer";
|
|
11
14
|
export * from "./dropdown-menu";
|
|
15
|
+
export * from "./editor";
|
|
12
16
|
export * from "./menubar";
|
|
17
|
+
export * from "./multiple-selector";
|
|
13
18
|
export * from "./navigation-menu";
|
|
14
19
|
export * from "./page-layout";
|
|
20
|
+
export * from "./prompt-input";
|
|
21
|
+
export * from "./reasoning";
|
|
22
|
+
export * from "./response";
|
|
15
23
|
export * from "./sheet";
|
|
16
24
|
export * from "./sidebar";
|
|
17
25
|
export * from "./sonner";
|
|
26
|
+
export * from "./toast";
|
|
27
|
+
export * from "./toast-toaster";
|
|
28
|
+
export * from "./use-toast";
|