@collabchron/notiq 0.2.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.
Files changed (188) hide show
  1. package/README.md +71 -0
  2. package/components.json +21 -0
  3. package/eslint.config.mjs +16 -0
  4. package/next.config.ts +12 -0
  5. package/package.json +108 -0
  6. package/postcss.config.mjs +5 -0
  7. package/public/file.svg +1 -0
  8. package/public/globe.svg +1 -0
  9. package/public/images/icons/plus.svg +10 -0
  10. package/public/next.svg +1 -0
  11. package/public/vercel.svg +1 -0
  12. package/public/window.svg +1 -0
  13. package/src/app/actions.ts +2 -0
  14. package/src/app/api/ai/route.ts +175 -0
  15. package/src/app/api/edgestore/[...edgestore]/route.ts +28 -0
  16. package/src/app/favicon.ico +0 -0
  17. package/src/app/globals.css +205 -0
  18. package/src/app/layout.tsx +38 -0
  19. package/src/app/page.tsx +12 -0
  20. package/src/components/editor/Core.tsx +220 -0
  21. package/src/components/editor/hooks/instructions-messages.ts +300 -0
  22. package/src/components/editor/hooks/use-mobile.ts +19 -0
  23. package/src/components/editor/hooks/useReport.ts +67 -0
  24. package/src/components/editor/hooks/useResizeObservert.ts +22 -0
  25. package/src/components/editor/index.tsx +39 -0
  26. package/src/components/editor/lexical-on-change.tsx +28 -0
  27. package/src/components/editor/nodes/CollapsibleNode/CollapsibleContainerNode.ts +92 -0
  28. package/src/components/editor/nodes/CollapsibleNode/CollapsibleContentNode.ts +65 -0
  29. package/src/components/editor/nodes/CollapsibleNode/CollapsibleTitleNode.ts +105 -0
  30. package/src/components/editor/nodes/EquationNode/EquationComponent.tsx +143 -0
  31. package/src/components/editor/nodes/EquationNode/EquationNode.tsx +170 -0
  32. package/src/components/editor/nodes/ExcalidrawNode/ExcalidrawComponent.tsx +228 -0
  33. package/src/components/editor/nodes/ExcalidrawNode/ExcalidrawImage.tsx +137 -0
  34. package/src/components/editor/nodes/ExcalidrawNode/ImageResizer.tsx +317 -0
  35. package/src/components/editor/nodes/ExcalidrawNode/index.tsx +204 -0
  36. package/src/components/editor/nodes/FigmaNode/FigmaNode.tsx +134 -0
  37. package/src/components/editor/nodes/Hint/HintComponet.tsx +221 -0
  38. package/src/components/editor/nodes/Hint/index.tsx +190 -0
  39. package/src/components/editor/nodes/ImageNode/index.tsx +328 -0
  40. package/src/components/editor/nodes/InlineImageNode/InlineImageComponent.tsx +383 -0
  41. package/src/components/editor/nodes/InlineImageNode/InlineImageNode.css +94 -0
  42. package/src/components/editor/nodes/InlineImageNode/InlineImageNode.tsx +309 -0
  43. package/src/components/editor/nodes/LayoutNode/LayoutContainerNode.ts +146 -0
  44. package/src/components/editor/nodes/LayoutNode/LayoutItemNode.ts +79 -0
  45. package/src/components/editor/nodes/PollNode/index.tsx +204 -0
  46. package/src/components/editor/nodes/Stepper/index.tsx +260 -0
  47. package/src/components/editor/nodes/TweetNode/index.tsx +214 -0
  48. package/src/components/editor/nodes/index.ts +81 -0
  49. package/src/components/editor/plugins/AutoEmbedPlugin/index.tsx +350 -0
  50. package/src/components/editor/plugins/AutoLinkPlugin/index.tsx +56 -0
  51. package/src/components/editor/plugins/CodeActionMenuPlugin/components/CopyButton.tsx +70 -0
  52. package/src/components/editor/plugins/CodeActionMenuPlugin/components/PrettierButton.tsx +192 -0
  53. package/src/components/editor/plugins/CodeActionMenuPlugin/index.tsx +217 -0
  54. package/src/components/editor/plugins/CodeActionMenuPlugin/utils.ts +26 -0
  55. package/src/components/editor/plugins/CodeHighlightPlugin/index.ts +21 -0
  56. package/src/components/editor/plugins/CollapsiblePlugin/Collapsible.css +76 -0
  57. package/src/components/editor/plugins/CollapsiblePlugin/index.ts +228 -0
  58. package/src/components/editor/plugins/DragDropPastePlugin/index.tsx +44 -0
  59. package/src/components/editor/plugins/DraggableBlockPlugin/index.tsx +52 -0
  60. package/src/components/editor/plugins/EquationsPlugin/index.tsx +85 -0
  61. package/src/components/editor/plugins/ExcalidrawPlugin/index.tsx +98 -0
  62. package/src/components/editor/plugins/FigmaPlugin/index.tsx +42 -0
  63. package/src/components/editor/plugins/FloatingLinkEditorPlugin/index.tsx +445 -0
  64. package/src/components/editor/plugins/FloatingTextFormatToolbarPlugin/index.tsx +275 -0
  65. package/src/components/editor/plugins/ImagesPlugin/index.tsx +222 -0
  66. package/src/components/editor/plugins/InlineImagePlugin/index.tsx +351 -0
  67. package/src/components/editor/plugins/LayoutPlugin/index.tsx +238 -0
  68. package/src/components/editor/plugins/LinkPlugin/index.tsx +36 -0
  69. package/src/components/editor/plugins/LinkWithMetaData/index.tsx +271 -0
  70. package/src/components/editor/plugins/MarkdownShortcutPlugin/index.tsx +11 -0
  71. package/src/components/editor/plugins/MarkdownTransformers/index.tsx +304 -0
  72. package/src/components/editor/plugins/PollPlugin/index.tsx +49 -0
  73. package/src/components/editor/plugins/ShortcutsPlugin/index.tsx +180 -0
  74. package/src/components/editor/plugins/ShortcutsPlugin/shortcuts.ts +253 -0
  75. package/src/components/editor/plugins/SlashCommand/index.tsx +621 -0
  76. package/src/components/editor/plugins/SpeechToTextPlugin/index.ts +127 -0
  77. package/src/components/editor/plugins/TabFocusPlugin/index.ts +58 -0
  78. package/src/components/editor/plugins/TableCellActionMenuPlugin/index.tsx +759 -0
  79. package/src/components/editor/plugins/TableCellResizer/index.tsx +438 -0
  80. package/src/components/editor/plugins/TableHoverActionsPlugin/index.tsx +314 -0
  81. package/src/components/editor/plugins/TablePlugin/index.tsx +99 -0
  82. package/src/components/editor/plugins/ToolbarPlugin/index.tsx +522 -0
  83. package/src/components/editor/plugins/TwitterPlugin/index.ts +35 -0
  84. package/src/components/editor/plugins/YouTubeNode/index.tsx +179 -0
  85. package/src/components/editor/plugins/YouTubePlugin/index.ts +41 -0
  86. package/src/components/editor/themes/editor-theme.ts +113 -0
  87. package/src/components/editor/themes/theme.css +377 -0
  88. package/src/components/editor/utils/ai.ts +291 -0
  89. package/src/components/editor/utils/canUseDOM.ts +12 -0
  90. package/src/components/editor/utils/editorFormatting.ts +282 -0
  91. package/src/components/editor/utils/environment.ts +50 -0
  92. package/src/components/editor/utils/extract-data.ts +166 -0
  93. package/src/components/editor/utils/getAllLexicalChildren.ts +13 -0
  94. package/src/components/editor/utils/getDOMRangeRect.ts +27 -0
  95. package/src/components/editor/utils/getSelectedNode.ts +27 -0
  96. package/src/components/editor/utils/gif.ts +29 -0
  97. package/src/components/editor/utils/invariant.ts +15 -0
  98. package/src/components/editor/utils/setFloatingElemPosition.ts +51 -0
  99. package/src/components/editor/utils/setFloatingElemPositionForLinkEditor.ts +40 -0
  100. package/src/components/editor/utils/setNodePlaceholderFromSelection/getNodePlaceholder.ts +51 -0
  101. package/src/components/editor/utils/setNodePlaceholderFromSelection/setNodePlaceholderFromSelection.ts +15 -0
  102. package/src/components/editor/utils/setNodePlaceholderFromSelection/setPlaceholderOnSelection.ts +114 -0
  103. package/src/components/editor/utils/setNodePlaceholderFromSelection/styles.css +6 -0
  104. package/src/components/editor/utils/url.ts +109 -0
  105. package/src/components/editor/utils/useLayoutEffect.ts +13 -0
  106. package/src/components/providers/QueryProvider.tsx +15 -0
  107. package/src/components/providers/SharedHistoryContext.tsx +28 -0
  108. package/src/components/providers/ToolbarContext.tsx +123 -0
  109. package/src/components/providers/theme-provider.tsx +11 -0
  110. package/src/components/theme/ModeToggle.tsx +40 -0
  111. package/src/components/ui/FileInput.tsx +40 -0
  112. package/src/components/ui/Input.css +32 -0
  113. package/src/components/ui/Select.css +42 -0
  114. package/src/components/ui/Select.tsx +36 -0
  115. package/src/components/ui/TextInput.tsx +48 -0
  116. package/src/components/ui/ai/ai-button.tsx +574 -0
  117. package/src/components/ui/ai/border.tsx +99 -0
  118. package/src/components/ui/ai/placeholder-input-vanish.tsx +282 -0
  119. package/src/components/ui/button.tsx +89 -0
  120. package/src/components/ui/card.tsx +76 -0
  121. package/src/components/ui/checkbox.tsx +30 -0
  122. package/src/components/ui/command.tsx +153 -0
  123. package/src/components/ui/dialog/Dialog.css +25 -0
  124. package/src/components/ui/dialog/Dialog.tsx +34 -0
  125. package/src/components/ui/dialog.tsx +122 -0
  126. package/src/components/ui/drop-downs/background-color.tsx +183 -0
  127. package/src/components/ui/drop-downs/block-format.tsx +159 -0
  128. package/src/components/ui/drop-downs/code.tsx +42 -0
  129. package/src/components/ui/drop-downs/color.tsx +177 -0
  130. package/src/components/ui/drop-downs/font-size.tsx +138 -0
  131. package/src/components/ui/drop-downs/font.tsx +155 -0
  132. package/src/components/ui/drop-downs/index.tsx +122 -0
  133. package/src/components/ui/drop-downs/insert-node.tsx +213 -0
  134. package/src/components/ui/drop-downs/text-align.tsx +123 -0
  135. package/src/components/ui/drop-downs/text-format.tsx +104 -0
  136. package/src/components/ui/dropdown-menu.tsx +201 -0
  137. package/src/components/ui/equation/EquationEditor.css +38 -0
  138. package/src/components/ui/equation/EquationEditor.tsx +56 -0
  139. package/src/components/ui/equation/KatexEquationAlterer.css +41 -0
  140. package/src/components/ui/equation/KatexEquationAlterer.tsx +83 -0
  141. package/src/components/ui/equation/KatexRenderer.tsx +66 -0
  142. package/src/components/ui/excalidraw/ExcalidrawModal.css +64 -0
  143. package/src/components/ui/excalidraw/ExcalidrawModal.tsx +234 -0
  144. package/src/components/ui/excalidraw/Modal.css +62 -0
  145. package/src/components/ui/excalidraw/Modal.tsx +110 -0
  146. package/src/components/ui/hover-card.tsx +29 -0
  147. package/src/components/ui/image/error-image.tsx +17 -0
  148. package/src/components/ui/image/file-upload.tsx +240 -0
  149. package/src/components/ui/image/image-resizer.tsx +297 -0
  150. package/src/components/ui/image/image-toolbar.tsx +264 -0
  151. package/src/components/ui/image/index.tsx +408 -0
  152. package/src/components/ui/image/lazy-image.tsx +68 -0
  153. package/src/components/ui/image/lazy-video.tsx +71 -0
  154. package/src/components/ui/input.tsx +22 -0
  155. package/src/components/ui/models/custom-dialog.tsx +320 -0
  156. package/src/components/ui/models/insert-gif.tsx +90 -0
  157. package/src/components/ui/models/insert-image.tsx +52 -0
  158. package/src/components/ui/models/insert-poll.tsx +29 -0
  159. package/src/components/ui/models/insert-table.tsx +62 -0
  160. package/src/components/ui/models/use-model.tsx +91 -0
  161. package/src/components/ui/poll/poll-component.tsx +304 -0
  162. package/src/components/ui/popover.tsx +33 -0
  163. package/src/components/ui/progress.tsx +28 -0
  164. package/src/components/ui/scroll-area.tsx +48 -0
  165. package/src/components/ui/separator.tsx +31 -0
  166. package/src/components/ui/skeleton.tsx +15 -0
  167. package/src/components/ui/sonner.tsx +31 -0
  168. package/src/components/ui/stepper/step.tsx +179 -0
  169. package/src/components/ui/stepper/stepper.tsx +89 -0
  170. package/src/components/ui/textarea.tsx +22 -0
  171. package/src/components/ui/toggle.tsx +71 -0
  172. package/src/components/ui/tooltip.tsx +32 -0
  173. package/src/components/ui/write/text-format-floting-toolbar.tsx +346 -0
  174. package/src/lib/edgestore.ts +9 -0
  175. package/src/lib/pinecone-client.ts +0 -0
  176. package/src/lib/utils.ts +6 -0
  177. package/src/utils/docSerialization.ts +77 -0
  178. package/src/utils/emoji-list.ts +16615 -0
  179. package/src/utils/getDOMRangeRect.ts +27 -0
  180. package/src/utils/getSelectedNode.ts +27 -0
  181. package/src/utils/getThemeSelector.ts +25 -0
  182. package/src/utils/isMobileWidth.ts +7 -0
  183. package/src/utils/joinClasses.ts +13 -0
  184. package/src/utils/setFloatingElemPosition.ts +74 -0
  185. package/src/utils/setFloatingElemPositionForLinkEditor.ts +46 -0
  186. package/src/utils/swipe.ts +127 -0
  187. package/src/utils/url.ts +38 -0
  188. package/tsconfig.json +27 -0
@@ -0,0 +1,282 @@
1
+ "use client";
2
+
3
+ import { AnimatePresence, motion } from "framer-motion";
4
+ import { useCallback, useEffect, useRef, useState } from "react";
5
+ import { cn } from "@/lib/utils";
6
+
7
+ export function PlaceholdersAndVanishInput({
8
+ placeholders,
9
+ onChange,
10
+ onSubmit,
11
+ disabled
12
+ }: {
13
+ placeholders: string[];
14
+ onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
15
+ onSubmit: (e: React.FormEvent<HTMLFormElement>) => void;
16
+ disabled:boolean
17
+ }) {
18
+ const [currentPlaceholder, setCurrentPlaceholder] = useState(0);
19
+
20
+
21
+ const intervalRef = useRef<NodeJS.Timeout | null>(null);
22
+ const startAnimation = () => {
23
+ intervalRef.current = setInterval(() => {
24
+ setCurrentPlaceholder((prev) => (prev + 1) % placeholders.length);
25
+ }, 3000);
26
+ };
27
+ const handleVisibilityChange = () => {
28
+ if (document.visibilityState !== "visible" && intervalRef.current) {
29
+ clearInterval(intervalRef.current); // Clear the interval when the tab is not visible
30
+ intervalRef.current = null;
31
+ } else if (document.visibilityState === "visible") {
32
+ startAnimation(); // Restart the interval when the tab becomes visible
33
+ }
34
+ };
35
+
36
+ useEffect(() => {
37
+ startAnimation();
38
+ document.addEventListener("visibilitychange", handleVisibilityChange);
39
+
40
+ return () => {
41
+ if (intervalRef.current) {
42
+ clearInterval(intervalRef.current);
43
+ }
44
+ document.removeEventListener("visibilitychange", handleVisibilityChange);
45
+ };
46
+ }, [placeholders]);
47
+
48
+ const canvasRef = useRef<HTMLCanvasElement>(null);
49
+ const newDataRef = useRef<any[]>([]);
50
+ const inputRef = useRef<HTMLInputElement>(null);
51
+ const [value, setValue] = useState("");
52
+ const [animating, setAnimating] = useState(false);
53
+
54
+ const draw = useCallback(() => {
55
+ if (!inputRef.current) return;
56
+ const canvas = canvasRef.current;
57
+ if (!canvas) return;
58
+ const ctx = canvas.getContext("2d");
59
+ if (!ctx) return;
60
+
61
+ canvas.width = 800;
62
+ canvas.height = 800;
63
+ ctx.clearRect(0, 0, 800, 800);
64
+ const computedStyles = getComputedStyle(inputRef.current);
65
+
66
+ const fontSize = parseFloat(computedStyles.getPropertyValue("font-size"));
67
+ ctx.font = `${fontSize * 2}px ${computedStyles.fontFamily}`;
68
+ ctx.fillStyle = "#FFF";
69
+ ctx.fillText(value, 16, 40);
70
+
71
+ const imageData = ctx.getImageData(0, 0, 800, 800);
72
+ const pixelData = imageData.data;
73
+ const newData: any[] = [];
74
+
75
+ for (let t = 0; t < 800; t++) {
76
+ let i = 4 * t * 800;
77
+ for (let n = 0; n < 800; n++) {
78
+ let e = i + 4 * n;
79
+ if (
80
+ pixelData[e] !== 0 &&
81
+ pixelData[e + 1] !== 0 &&
82
+ pixelData[e + 2] !== 0
83
+ ) {
84
+ newData.push({
85
+ x: n,
86
+ y: t,
87
+ color: [
88
+ pixelData[e],
89
+ pixelData[e + 1],
90
+ pixelData[e + 2],
91
+ pixelData[e + 3],
92
+ ],
93
+ });
94
+ }
95
+ }
96
+ }
97
+
98
+ newDataRef.current = newData.map(({ x, y, color }) => ({
99
+ x,
100
+ y,
101
+ r: 1,
102
+ color: `rgba(${color[0]}, ${color[1]}, ${color[2]}, ${color[3]})`,
103
+ }));
104
+ }, [value]);
105
+
106
+ useEffect(() => {
107
+ draw();
108
+ }, [value, draw]);
109
+
110
+ const animate = (start: number) => {
111
+ const animateFrame = (pos: number = 0) => {
112
+ requestAnimationFrame(() => {
113
+ const newArr = [];
114
+ for (let i = 0; i < newDataRef.current.length; i++) {
115
+ const current = newDataRef.current[i];
116
+ if (current.x < pos) {
117
+ newArr.push(current);
118
+ } else {
119
+ if (current.r <= 0) {
120
+ current.r = 0;
121
+ continue;
122
+ }
123
+ current.x += Math.random() > 0.5 ? 1 : -1;
124
+ current.y += Math.random() > 0.5 ? 1 : -1;
125
+ current.r -= 0.05 * Math.random();
126
+ newArr.push(current);
127
+ }
128
+ }
129
+ newDataRef.current = newArr;
130
+ const ctx = canvasRef.current?.getContext("2d");
131
+ if (ctx) {
132
+ ctx.clearRect(pos, 0, 800, 800);
133
+ newDataRef.current.forEach((t) => {
134
+ const { x: n, y: i, r: s, color: color } = t;
135
+ if (n > pos) {
136
+ ctx.beginPath();
137
+ ctx.rect(n, i, s, s);
138
+ ctx.fillStyle = color;
139
+ ctx.strokeStyle = color;
140
+ ctx.stroke();
141
+ }
142
+ });
143
+ }
144
+ if (newDataRef.current.length > 0) {
145
+ animateFrame(pos - 8);
146
+ } else {
147
+ setValue("");
148
+ setAnimating(false);
149
+ }
150
+ });
151
+ };
152
+ animateFrame(start);
153
+ };
154
+
155
+ const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
156
+ if (e.key === "Enter" && !animating) {
157
+ vanishAndSubmit();
158
+ }
159
+ };
160
+
161
+ const vanishAndSubmit = () => {
162
+ setAnimating(true);
163
+ draw();
164
+
165
+ const value = inputRef.current?.value || "";
166
+ if (value && inputRef.current) {
167
+ const maxX = newDataRef.current.reduce(
168
+ (prev, current) => (current.x > prev ? current.x : prev),
169
+ 0
170
+ );
171
+ animate(maxX);
172
+ }
173
+ };
174
+
175
+ const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
176
+ e.preventDefault();
177
+ vanishAndSubmit();
178
+ onSubmit && onSubmit(e);
179
+ };
180
+
181
+ return (
182
+ <form
183
+
184
+ suppressHydrationWarning
185
+ className={cn(
186
+ "w-full relative max-w-xl mx-auto h-9 rounded-sm overflow-hidden shadow-[0px_2px_3px_-1px_rgba(0,0,0,0.1),_0px_1px_0px_0px_rgba(25,28,33,0.02),_0px_0px_0px_1px_rgba(25,28,33,0.08)] transition duration-200",
187
+ )}
188
+ onSubmit={handleSubmit}
189
+ >
190
+ <canvas
191
+ className={cn(
192
+ "absolute pointer-events-none text-base transform scale-50 top-[20%] left-2 sm:left-8 origin-top-left filter invert dark:invert-0 pr-20",
193
+ !animating ? "opacity-0" : "opacity-100"
194
+ )}
195
+ ref={canvasRef}
196
+ />
197
+ <input
198
+ disabled={disabled}
199
+ onChange={(e) => {
200
+ if (!animating) {
201
+ setValue(e.target.value);
202
+ onChange && onChange(e);
203
+ }
204
+ }}
205
+ onKeyDown={handleKeyDown}
206
+ ref={inputRef}
207
+ value={value}
208
+ type="text"
209
+ className={cn(
210
+ "w-full relative text-sm sm:text-base z-50 border-none dark:text-white bg-transparent text-black h-full focus:outline-none focus:ring-0 pl-4 sm:pl-10 pr-20",
211
+ animating && "text-transparent dark:text-transparent"
212
+ )}
213
+ />
214
+
215
+ <button
216
+ disabled={!value || disabled}
217
+ type="submit"
218
+ className="absolute right-2 top-1/2 z-50 -translate-y-1/2 h-5 w-5 rounded-full disabled:bg-gray-100 bg-black dark:bg-zinc-900 dark:disabled:bg-zinc-800 transition duration-200 flex items-center justify-center"
219
+ >
220
+ <motion.svg
221
+ xmlns="http://www.w3.org/2000/svg"
222
+ width="24"
223
+ height="24"
224
+ viewBox="0 0 24 24"
225
+ fill="none"
226
+ stroke="currentColor"
227
+ strokeWidth="2"
228
+ strokeLinecap="round"
229
+ strokeLinejoin="round"
230
+ className="text-gray-300 h-4 w-4"
231
+ >
232
+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />
233
+ <motion.path
234
+ d="M5 12l14 0"
235
+ initial={{
236
+ strokeDasharray: "50%",
237
+ strokeDashoffset: "50%",
238
+ }}
239
+ animate={{
240
+ strokeDashoffset: value ? 0 : "50%",
241
+ }}
242
+ transition={{
243
+ duration: 0.3,
244
+ ease: "linear",
245
+ }}
246
+ />
247
+ <path d="M13 18l6 -6" />
248
+ <path d="M13 6l6 6" />
249
+ </motion.svg>
250
+ </button>
251
+
252
+ <div className="absolute inset-0 flex items-center rounded-full pointer-events-none">
253
+ <AnimatePresence mode="wait">
254
+ {!value && (
255
+ <motion.p
256
+ initial={{
257
+ y: 5,
258
+ opacity: 0,
259
+ }}
260
+ key={`current-placeholder-${currentPlaceholder}`}
261
+ animate={{
262
+ y: 0,
263
+ opacity: 1,
264
+ }}
265
+ exit={{
266
+ y: -15,
267
+ opacity: 0,
268
+ }}
269
+ transition={{
270
+ duration: 0.3,
271
+ ease: "linear",
272
+ }}
273
+ className="dark:text-zinc-500 text-sm sm:text-base font-normal text-neutral-500 pl-4 sm:pl-12 text-left w-[calc(100%-2rem)] truncate"
274
+ >
275
+ {placeholders[currentPlaceholder]}
276
+ </motion.p>
277
+ )}
278
+ </AnimatePresence>
279
+ </div>
280
+ </form>
281
+ );
282
+ }
@@ -0,0 +1,89 @@
1
+ import * as React from "react"
2
+ import { Slot } from "@radix-ui/react-slot"
3
+ import { cva, type VariantProps } from "class-variance-authority"
4
+
5
+ import { cn } from "@/lib/utils"
6
+
7
+ import {
8
+ Tooltip,
9
+ TooltipContent,
10
+ TooltipProvider,
11
+ TooltipTrigger,
12
+ } from "@/components/ui/tooltip"
13
+
14
+
15
+ const buttonVariants = cva(
16
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
17
+ {
18
+ variants: {
19
+ variant: {
20
+ default:
21
+ "bg-primary text-primary-foreground shadow hover:bg-primary/90",
22
+ destructive:
23
+ "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
24
+ outline:
25
+ "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
26
+ secondary:
27
+ "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
28
+ ghost: "hover:bg-accent hover:text-accent-foreground",
29
+ link: "text-primary underline-offset-4 hover:underline",
30
+ transparent:"bg-transparent border border-input"
31
+ },
32
+ size: {
33
+ default: "h-9 px-4 py-2",
34
+ sm: "h-8 rounded-md px-3 text-xs",
35
+ lg: "h-10 rounded-md px-8",
36
+ icon: "h-9 w-9",
37
+ Toolbar:"h-7 w-7 p-3 ",
38
+ custom:""
39
+ },
40
+ },
41
+ defaultVariants: {
42
+ variant: "default",
43
+ size: "default",
44
+ },
45
+ }
46
+ )
47
+
48
+ export interface ButtonProps
49
+ extends React.ButtonHTMLAttributes<HTMLButtonElement>,
50
+ VariantProps<typeof buttonVariants> {
51
+ asChild?: boolean
52
+ tip?:string
53
+ }
54
+
55
+ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
56
+ ({ className, variant, tip, size, asChild = false, ...props }, ref) => {
57
+ const Comp = asChild ? Slot : "button";
58
+ return (
59
+ <>
60
+ {!!tip ? (
61
+ <TooltipProvider >
62
+ <Tooltip >
63
+ <TooltipTrigger asChild >
64
+ <Comp
65
+
66
+ className={cn(buttonVariants({ variant, size, className }))}
67
+ ref={ref}
68
+ {...props}
69
+ />
70
+ </TooltipTrigger>
71
+ <TooltipContent>
72
+ <p>{tip}</p>
73
+ </TooltipContent>
74
+ </Tooltip>
75
+ </TooltipProvider>
76
+ ) : (
77
+ <Comp
78
+ className={cn(buttonVariants({ variant, size, className }))}
79
+ ref={ref}
80
+ {...props}
81
+ />
82
+ )}
83
+ </>
84
+ );
85
+ }
86
+ );
87
+ Button.displayName = "Button"
88
+
89
+ export { Button, buttonVariants }
@@ -0,0 +1,76 @@
1
+ import * as React from "react"
2
+
3
+ import { cn } from "@/lib/utils"
4
+
5
+ const Card = React.forwardRef<
6
+ HTMLDivElement,
7
+ React.HTMLAttributes<HTMLDivElement>
8
+ >(({ className, ...props }, ref) => (
9
+ <div
10
+ ref={ref}
11
+ className={cn(
12
+ "rounded-xl border bg-card text-card-foreground shadow",
13
+ className
14
+ )}
15
+ {...props}
16
+ />
17
+ ))
18
+ Card.displayName = "Card"
19
+
20
+ const CardHeader = React.forwardRef<
21
+ HTMLDivElement,
22
+ React.HTMLAttributes<HTMLDivElement>
23
+ >(({ className, ...props }, ref) => (
24
+ <div
25
+ ref={ref}
26
+ className={cn("flex flex-col space-y-1.5 p-6", className)}
27
+ {...props}
28
+ />
29
+ ))
30
+ CardHeader.displayName = "CardHeader"
31
+
32
+ const CardTitle = React.forwardRef<
33
+ HTMLDivElement,
34
+ React.HTMLAttributes<HTMLDivElement>
35
+ >(({ className, ...props }, ref) => (
36
+ <div
37
+ ref={ref}
38
+ className={cn("font-semibold leading-none tracking-tight", className)}
39
+ {...props}
40
+ />
41
+ ))
42
+ CardTitle.displayName = "CardTitle"
43
+
44
+ const CardDescription = React.forwardRef<
45
+ HTMLDivElement,
46
+ React.HTMLAttributes<HTMLDivElement>
47
+ >(({ className, ...props }, ref) => (
48
+ <div
49
+ ref={ref}
50
+ className={cn("text-sm text-muted-foreground", className)}
51
+ {...props}
52
+ />
53
+ ))
54
+ CardDescription.displayName = "CardDescription"
55
+
56
+ const CardContent = React.forwardRef<
57
+ HTMLDivElement,
58
+ React.HTMLAttributes<HTMLDivElement>
59
+ >(({ className, ...props }, ref) => (
60
+ <div ref={ref} className={cn("p-6 ", className)} {...props} />
61
+ ))
62
+ CardContent.displayName = "CardContent"
63
+
64
+ const CardFooter = React.forwardRef<
65
+ HTMLDivElement,
66
+ React.HTMLAttributes<HTMLDivElement>
67
+ >(({ className, ...props }, ref) => (
68
+ <div
69
+ ref={ref}
70
+ className={cn("flex items-center p-6 ", className)}
71
+ {...props}
72
+ />
73
+ ))
74
+ CardFooter.displayName = "CardFooter"
75
+
76
+ export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }
@@ -0,0 +1,30 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
5
+ import { Check } from "lucide-react"
6
+
7
+ import { cn } from "@/lib/utils"
8
+
9
+ const Checkbox = React.forwardRef<
10
+ React.ElementRef<typeof CheckboxPrimitive.Root>,
11
+ React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
12
+ >(({ className, ...props }, ref) => (
13
+ <CheckboxPrimitive.Root
14
+ ref={ref}
15
+ className={cn(
16
+ "peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
17
+ className
18
+ )}
19
+ {...props}
20
+ >
21
+ <CheckboxPrimitive.Indicator
22
+ className={cn("flex items-center justify-center text-current")}
23
+ >
24
+ <Check className="h-4 w-4" />
25
+ </CheckboxPrimitive.Indicator>
26
+ </CheckboxPrimitive.Root>
27
+ ))
28
+ Checkbox.displayName = CheckboxPrimitive.Root.displayName
29
+
30
+ export { Checkbox }
@@ -0,0 +1,153 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { type DialogProps } from "@radix-ui/react-dialog"
5
+ import { Command as CommandPrimitive } from "cmdk"
6
+ import { Search } from "lucide-react"
7
+
8
+ import { cn } from "@/lib/utils"
9
+ import { Dialog, DialogContent } from "@/components/ui/dialog"
10
+
11
+ const Command = React.forwardRef<
12
+ React.ElementRef<typeof CommandPrimitive>,
13
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive>
14
+ >(({ className, ...props }, ref) => (
15
+ <CommandPrimitive
16
+ ref={ref}
17
+ className={cn(
18
+ "flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
19
+ className
20
+ )}
21
+ {...props}
22
+ />
23
+ ))
24
+ Command.displayName = CommandPrimitive.displayName
25
+
26
+ const CommandDialog = ({ children, ...props }: DialogProps) => {
27
+ return (
28
+ <Dialog {...props}>
29
+ <DialogContent className="overflow-hidden p-0">
30
+ <Command className="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
31
+ {children}
32
+ </Command>
33
+ </DialogContent>
34
+ </Dialog>
35
+ )
36
+ }
37
+
38
+ const CommandInput = React.forwardRef<
39
+ React.ElementRef<typeof CommandPrimitive.Input>,
40
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>
41
+ >(({ className, ...props }, ref) => (
42
+ <div className="flex items-center border-b px-3" cmdk-input-wrapper="">
43
+ <Search className="mr-2 h-4 w-4 shrink-0 opacity-50" />
44
+ <CommandPrimitive.Input
45
+ ref={ref}
46
+ className={cn(
47
+ "flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
48
+ className
49
+ )}
50
+ {...props}
51
+ />
52
+ </div>
53
+ ))
54
+
55
+ CommandInput.displayName = CommandPrimitive.Input.displayName
56
+
57
+ const CommandList = React.forwardRef<
58
+ React.ElementRef<typeof CommandPrimitive.List>,
59
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
60
+ >(({ className, ...props }, ref) => (
61
+ <CommandPrimitive.List
62
+ ref={ref}
63
+ className={cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className)}
64
+ {...props}
65
+ />
66
+ ))
67
+
68
+ CommandList.displayName = CommandPrimitive.List.displayName
69
+
70
+ const CommandEmpty = React.forwardRef<
71
+ React.ElementRef<typeof CommandPrimitive.Empty>,
72
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
73
+ >((props, ref) => (
74
+ <CommandPrimitive.Empty
75
+ ref={ref}
76
+ className="py-6 text-center text-sm"
77
+ {...props}
78
+ />
79
+ ))
80
+
81
+ CommandEmpty.displayName = CommandPrimitive.Empty.displayName
82
+
83
+ const CommandGroup = React.forwardRef<
84
+ React.ElementRef<typeof CommandPrimitive.Group>,
85
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>
86
+ >(({ className, ...props }, ref) => (
87
+ <CommandPrimitive.Group
88
+ ref={ref}
89
+ className={cn(
90
+ "overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
91
+ className
92
+ )}
93
+ {...props}
94
+ />
95
+ ))
96
+
97
+ CommandGroup.displayName = CommandPrimitive.Group.displayName
98
+
99
+ const CommandSeparator = React.forwardRef<
100
+ React.ElementRef<typeof CommandPrimitive.Separator>,
101
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>
102
+ >(({ className, ...props }, ref) => (
103
+ <CommandPrimitive.Separator
104
+ ref={ref}
105
+ className={cn("-mx-1 h-px bg-border", className)}
106
+ {...props}
107
+ />
108
+ ))
109
+ CommandSeparator.displayName = CommandPrimitive.Separator.displayName
110
+
111
+ const CommandItem = React.forwardRef<
112
+ React.ElementRef<typeof CommandPrimitive.Item>,
113
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
114
+ >(({ className, ...props }, ref) => (
115
+ <CommandPrimitive.Item
116
+ ref={ref}
117
+ className={cn(
118
+ "relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
119
+ className
120
+ )}
121
+ {...props}
122
+ />
123
+ ))
124
+
125
+ CommandItem.displayName = CommandPrimitive.Item.displayName
126
+
127
+ const CommandShortcut = ({
128
+ className,
129
+ ...props
130
+ }: React.HTMLAttributes<HTMLSpanElement>) => {
131
+ return (
132
+ <span
133
+ className={cn(
134
+ "ml-auto text-xs tracking-widest text-muted-foreground",
135
+ className
136
+ )}
137
+ {...props}
138
+ />
139
+ )
140
+ }
141
+ CommandShortcut.displayName = "CommandShortcut"
142
+
143
+ export {
144
+ Command,
145
+ CommandDialog,
146
+ CommandInput,
147
+ CommandList,
148
+ CommandEmpty,
149
+ CommandGroup,
150
+ CommandItem,
151
+ CommandShortcut,
152
+ CommandSeparator,
153
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ .DialogActions {
10
+ display: flex;
11
+ flex-direction: row;
12
+ justify-content: right;
13
+ margin-top: 20px;
14
+ }
15
+
16
+ .DialogButtonsList {
17
+ display: flex;
18
+ flex-direction: column;
19
+ justify-content: right;
20
+ margin-top: 20px;
21
+ }
22
+
23
+ .DialogButtonsList button {
24
+ margin-bottom: 20px;
25
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import type {JSX} from 'react';
10
+
11
+ import './Dialog.css';
12
+
13
+ import * as React from 'react';
14
+ import {ReactNode} from 'react';
15
+
16
+ type Props = Readonly<{
17
+ 'data-test-id'?: string;
18
+ children: ReactNode;
19
+ }>;
20
+
21
+ export function DialogButtonsList({children}: Props): JSX.Element {
22
+ return <div className="DialogButtonsList">{children}</div>;
23
+ }
24
+
25
+ export function DialogActions({
26
+ 'data-test-id': dataTestId,
27
+ children,
28
+ }: Props): JSX.Element {
29
+ return (
30
+ <div className="DialogActions" data-test-id={dataTestId}>
31
+ {children}
32
+ </div>
33
+ );
34
+ }