@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.
- package/README.md +71 -0
- package/components.json +21 -0
- package/eslint.config.mjs +16 -0
- package/next.config.ts +12 -0
- package/package.json +108 -0
- package/postcss.config.mjs +5 -0
- package/public/file.svg +1 -0
- package/public/globe.svg +1 -0
- package/public/images/icons/plus.svg +10 -0
- package/public/next.svg +1 -0
- package/public/vercel.svg +1 -0
- package/public/window.svg +1 -0
- package/src/app/actions.ts +2 -0
- package/src/app/api/ai/route.ts +175 -0
- package/src/app/api/edgestore/[...edgestore]/route.ts +28 -0
- package/src/app/favicon.ico +0 -0
- package/src/app/globals.css +205 -0
- package/src/app/layout.tsx +38 -0
- package/src/app/page.tsx +12 -0
- package/src/components/editor/Core.tsx +220 -0
- package/src/components/editor/hooks/instructions-messages.ts +300 -0
- package/src/components/editor/hooks/use-mobile.ts +19 -0
- package/src/components/editor/hooks/useReport.ts +67 -0
- package/src/components/editor/hooks/useResizeObservert.ts +22 -0
- package/src/components/editor/index.tsx +39 -0
- package/src/components/editor/lexical-on-change.tsx +28 -0
- package/src/components/editor/nodes/CollapsibleNode/CollapsibleContainerNode.ts +92 -0
- package/src/components/editor/nodes/CollapsibleNode/CollapsibleContentNode.ts +65 -0
- package/src/components/editor/nodes/CollapsibleNode/CollapsibleTitleNode.ts +105 -0
- package/src/components/editor/nodes/EquationNode/EquationComponent.tsx +143 -0
- package/src/components/editor/nodes/EquationNode/EquationNode.tsx +170 -0
- package/src/components/editor/nodes/ExcalidrawNode/ExcalidrawComponent.tsx +228 -0
- package/src/components/editor/nodes/ExcalidrawNode/ExcalidrawImage.tsx +137 -0
- package/src/components/editor/nodes/ExcalidrawNode/ImageResizer.tsx +317 -0
- package/src/components/editor/nodes/ExcalidrawNode/index.tsx +204 -0
- package/src/components/editor/nodes/FigmaNode/FigmaNode.tsx +134 -0
- package/src/components/editor/nodes/Hint/HintComponet.tsx +221 -0
- package/src/components/editor/nodes/Hint/index.tsx +190 -0
- package/src/components/editor/nodes/ImageNode/index.tsx +328 -0
- package/src/components/editor/nodes/InlineImageNode/InlineImageComponent.tsx +383 -0
- package/src/components/editor/nodes/InlineImageNode/InlineImageNode.css +94 -0
- package/src/components/editor/nodes/InlineImageNode/InlineImageNode.tsx +309 -0
- package/src/components/editor/nodes/LayoutNode/LayoutContainerNode.ts +146 -0
- package/src/components/editor/nodes/LayoutNode/LayoutItemNode.ts +79 -0
- package/src/components/editor/nodes/PollNode/index.tsx +204 -0
- package/src/components/editor/nodes/Stepper/index.tsx +260 -0
- package/src/components/editor/nodes/TweetNode/index.tsx +214 -0
- package/src/components/editor/nodes/index.ts +81 -0
- package/src/components/editor/plugins/AutoEmbedPlugin/index.tsx +350 -0
- package/src/components/editor/plugins/AutoLinkPlugin/index.tsx +56 -0
- package/src/components/editor/plugins/CodeActionMenuPlugin/components/CopyButton.tsx +70 -0
- package/src/components/editor/plugins/CodeActionMenuPlugin/components/PrettierButton.tsx +192 -0
- package/src/components/editor/plugins/CodeActionMenuPlugin/index.tsx +217 -0
- package/src/components/editor/plugins/CodeActionMenuPlugin/utils.ts +26 -0
- package/src/components/editor/plugins/CodeHighlightPlugin/index.ts +21 -0
- package/src/components/editor/plugins/CollapsiblePlugin/Collapsible.css +76 -0
- package/src/components/editor/plugins/CollapsiblePlugin/index.ts +228 -0
- package/src/components/editor/plugins/DragDropPastePlugin/index.tsx +44 -0
- package/src/components/editor/plugins/DraggableBlockPlugin/index.tsx +52 -0
- package/src/components/editor/plugins/EquationsPlugin/index.tsx +85 -0
- package/src/components/editor/plugins/ExcalidrawPlugin/index.tsx +98 -0
- package/src/components/editor/plugins/FigmaPlugin/index.tsx +42 -0
- package/src/components/editor/plugins/FloatingLinkEditorPlugin/index.tsx +445 -0
- package/src/components/editor/plugins/FloatingTextFormatToolbarPlugin/index.tsx +275 -0
- package/src/components/editor/plugins/ImagesPlugin/index.tsx +222 -0
- package/src/components/editor/plugins/InlineImagePlugin/index.tsx +351 -0
- package/src/components/editor/plugins/LayoutPlugin/index.tsx +238 -0
- package/src/components/editor/plugins/LinkPlugin/index.tsx +36 -0
- package/src/components/editor/plugins/LinkWithMetaData/index.tsx +271 -0
- package/src/components/editor/plugins/MarkdownShortcutPlugin/index.tsx +11 -0
- package/src/components/editor/plugins/MarkdownTransformers/index.tsx +304 -0
- package/src/components/editor/plugins/PollPlugin/index.tsx +49 -0
- package/src/components/editor/plugins/ShortcutsPlugin/index.tsx +180 -0
- package/src/components/editor/plugins/ShortcutsPlugin/shortcuts.ts +253 -0
- package/src/components/editor/plugins/SlashCommand/index.tsx +621 -0
- package/src/components/editor/plugins/SpeechToTextPlugin/index.ts +127 -0
- package/src/components/editor/plugins/TabFocusPlugin/index.ts +58 -0
- package/src/components/editor/plugins/TableCellActionMenuPlugin/index.tsx +759 -0
- package/src/components/editor/plugins/TableCellResizer/index.tsx +438 -0
- package/src/components/editor/plugins/TableHoverActionsPlugin/index.tsx +314 -0
- package/src/components/editor/plugins/TablePlugin/index.tsx +99 -0
- package/src/components/editor/plugins/ToolbarPlugin/index.tsx +522 -0
- package/src/components/editor/plugins/TwitterPlugin/index.ts +35 -0
- package/src/components/editor/plugins/YouTubeNode/index.tsx +179 -0
- package/src/components/editor/plugins/YouTubePlugin/index.ts +41 -0
- package/src/components/editor/themes/editor-theme.ts +113 -0
- package/src/components/editor/themes/theme.css +377 -0
- package/src/components/editor/utils/ai.ts +291 -0
- package/src/components/editor/utils/canUseDOM.ts +12 -0
- package/src/components/editor/utils/editorFormatting.ts +282 -0
- package/src/components/editor/utils/environment.ts +50 -0
- package/src/components/editor/utils/extract-data.ts +166 -0
- package/src/components/editor/utils/getAllLexicalChildren.ts +13 -0
- package/src/components/editor/utils/getDOMRangeRect.ts +27 -0
- package/src/components/editor/utils/getSelectedNode.ts +27 -0
- package/src/components/editor/utils/gif.ts +29 -0
- package/src/components/editor/utils/invariant.ts +15 -0
- package/src/components/editor/utils/setFloatingElemPosition.ts +51 -0
- package/src/components/editor/utils/setFloatingElemPositionForLinkEditor.ts +40 -0
- package/src/components/editor/utils/setNodePlaceholderFromSelection/getNodePlaceholder.ts +51 -0
- package/src/components/editor/utils/setNodePlaceholderFromSelection/setNodePlaceholderFromSelection.ts +15 -0
- package/src/components/editor/utils/setNodePlaceholderFromSelection/setPlaceholderOnSelection.ts +114 -0
- package/src/components/editor/utils/setNodePlaceholderFromSelection/styles.css +6 -0
- package/src/components/editor/utils/url.ts +109 -0
- package/src/components/editor/utils/useLayoutEffect.ts +13 -0
- package/src/components/providers/QueryProvider.tsx +15 -0
- package/src/components/providers/SharedHistoryContext.tsx +28 -0
- package/src/components/providers/ToolbarContext.tsx +123 -0
- package/src/components/providers/theme-provider.tsx +11 -0
- package/src/components/theme/ModeToggle.tsx +40 -0
- package/src/components/ui/FileInput.tsx +40 -0
- package/src/components/ui/Input.css +32 -0
- package/src/components/ui/Select.css +42 -0
- package/src/components/ui/Select.tsx +36 -0
- package/src/components/ui/TextInput.tsx +48 -0
- package/src/components/ui/ai/ai-button.tsx +574 -0
- package/src/components/ui/ai/border.tsx +99 -0
- package/src/components/ui/ai/placeholder-input-vanish.tsx +282 -0
- package/src/components/ui/button.tsx +89 -0
- package/src/components/ui/card.tsx +76 -0
- package/src/components/ui/checkbox.tsx +30 -0
- package/src/components/ui/command.tsx +153 -0
- package/src/components/ui/dialog/Dialog.css +25 -0
- package/src/components/ui/dialog/Dialog.tsx +34 -0
- package/src/components/ui/dialog.tsx +122 -0
- package/src/components/ui/drop-downs/background-color.tsx +183 -0
- package/src/components/ui/drop-downs/block-format.tsx +159 -0
- package/src/components/ui/drop-downs/code.tsx +42 -0
- package/src/components/ui/drop-downs/color.tsx +177 -0
- package/src/components/ui/drop-downs/font-size.tsx +138 -0
- package/src/components/ui/drop-downs/font.tsx +155 -0
- package/src/components/ui/drop-downs/index.tsx +122 -0
- package/src/components/ui/drop-downs/insert-node.tsx +213 -0
- package/src/components/ui/drop-downs/text-align.tsx +123 -0
- package/src/components/ui/drop-downs/text-format.tsx +104 -0
- package/src/components/ui/dropdown-menu.tsx +201 -0
- package/src/components/ui/equation/EquationEditor.css +38 -0
- package/src/components/ui/equation/EquationEditor.tsx +56 -0
- package/src/components/ui/equation/KatexEquationAlterer.css +41 -0
- package/src/components/ui/equation/KatexEquationAlterer.tsx +83 -0
- package/src/components/ui/equation/KatexRenderer.tsx +66 -0
- package/src/components/ui/excalidraw/ExcalidrawModal.css +64 -0
- package/src/components/ui/excalidraw/ExcalidrawModal.tsx +234 -0
- package/src/components/ui/excalidraw/Modal.css +62 -0
- package/src/components/ui/excalidraw/Modal.tsx +110 -0
- package/src/components/ui/hover-card.tsx +29 -0
- package/src/components/ui/image/error-image.tsx +17 -0
- package/src/components/ui/image/file-upload.tsx +240 -0
- package/src/components/ui/image/image-resizer.tsx +297 -0
- package/src/components/ui/image/image-toolbar.tsx +264 -0
- package/src/components/ui/image/index.tsx +408 -0
- package/src/components/ui/image/lazy-image.tsx +68 -0
- package/src/components/ui/image/lazy-video.tsx +71 -0
- package/src/components/ui/input.tsx +22 -0
- package/src/components/ui/models/custom-dialog.tsx +320 -0
- package/src/components/ui/models/insert-gif.tsx +90 -0
- package/src/components/ui/models/insert-image.tsx +52 -0
- package/src/components/ui/models/insert-poll.tsx +29 -0
- package/src/components/ui/models/insert-table.tsx +62 -0
- package/src/components/ui/models/use-model.tsx +91 -0
- package/src/components/ui/poll/poll-component.tsx +304 -0
- package/src/components/ui/popover.tsx +33 -0
- package/src/components/ui/progress.tsx +28 -0
- package/src/components/ui/scroll-area.tsx +48 -0
- package/src/components/ui/separator.tsx +31 -0
- package/src/components/ui/skeleton.tsx +15 -0
- package/src/components/ui/sonner.tsx +31 -0
- package/src/components/ui/stepper/step.tsx +179 -0
- package/src/components/ui/stepper/stepper.tsx +89 -0
- package/src/components/ui/textarea.tsx +22 -0
- package/src/components/ui/toggle.tsx +71 -0
- package/src/components/ui/tooltip.tsx +32 -0
- package/src/components/ui/write/text-format-floting-toolbar.tsx +346 -0
- package/src/lib/edgestore.ts +9 -0
- package/src/lib/pinecone-client.ts +0 -0
- package/src/lib/utils.ts +6 -0
- package/src/utils/docSerialization.ts +77 -0
- package/src/utils/emoji-list.ts +16615 -0
- package/src/utils/getDOMRangeRect.ts +27 -0
- package/src/utils/getSelectedNode.ts +27 -0
- package/src/utils/getThemeSelector.ts +25 -0
- package/src/utils/isMobileWidth.ts +7 -0
- package/src/utils/joinClasses.ts +13 -0
- package/src/utils/setFloatingElemPosition.ts +74 -0
- package/src/utils/setFloatingElemPositionForLinkEditor.ts +46 -0
- package/src/utils/swipe.ts +127 -0
- package/src/utils/url.ts +38 -0
- package/tsconfig.json +27 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { QueryClientProvider, QueryClient } from "@tanstack/react-query";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default function QueryProvider({ children }: Props) {
|
|
11
|
+
const [queryClient] = useState(() => new QueryClient());
|
|
12
|
+
return (
|
|
13
|
+
<QueryClientProvider client={queryClient}> {children} </QueryClientProvider>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
import type {HistoryState} from '@lexical/react/LexicalHistoryPlugin';
|
|
3
|
+
import {createEmptyHistoryState} from '@lexical/react/LexicalHistoryPlugin';
|
|
4
|
+
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import {createContext, ReactNode, useContext, useMemo} from 'react';
|
|
7
|
+
|
|
8
|
+
type ContextShape = {
|
|
9
|
+
historyState?: HistoryState;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const Context: React.Context<ContextShape> = createContext({});
|
|
13
|
+
|
|
14
|
+
export const SharedHistoryContext = ({
|
|
15
|
+
children,
|
|
16
|
+
}: {
|
|
17
|
+
children: ReactNode;
|
|
18
|
+
}) => {
|
|
19
|
+
const historyContext = useMemo(
|
|
20
|
+
() => ({historyState: createEmptyHistoryState()}),
|
|
21
|
+
[],
|
|
22
|
+
);
|
|
23
|
+
return <Context.Provider value={historyContext}>{children}</Context.Provider>;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const useSharedHistoryContext = (): ContextShape => {
|
|
27
|
+
return useContext(Context);
|
|
28
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
import {ElementFormatType} from 'lexical';
|
|
3
|
+
import React, {
|
|
4
|
+
createContext,
|
|
5
|
+
ReactNode,
|
|
6
|
+
useCallback,
|
|
7
|
+
useContext,
|
|
8
|
+
useEffect,
|
|
9
|
+
useMemo,
|
|
10
|
+
useState,
|
|
11
|
+
} from 'react';
|
|
12
|
+
|
|
13
|
+
export const MIN_ALLOWED_FONT_SIZE = 8;
|
|
14
|
+
export const MAX_ALLOWED_FONT_SIZE = 72;
|
|
15
|
+
export const DEFAULT_FONT_SIZE = 15;
|
|
16
|
+
|
|
17
|
+
const rootTypeToRootName = {
|
|
18
|
+
root: 'Root',
|
|
19
|
+
table: 'Table',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const blockTypeToBlockName = {
|
|
23
|
+
bullet: 'Bulleted List',
|
|
24
|
+
check: 'Check List',
|
|
25
|
+
code: 'Code Block',
|
|
26
|
+
h1: 'Heading 1',
|
|
27
|
+
h2: 'Heading 2',
|
|
28
|
+
h3: 'Heading 3',
|
|
29
|
+
h4: 'Heading 4',
|
|
30
|
+
h5: 'Heading 5',
|
|
31
|
+
h6: 'Heading 6',
|
|
32
|
+
number: 'Numbered List',
|
|
33
|
+
paragraph: 'Normal',
|
|
34
|
+
quote: 'Quote',
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const INITIAL_TOOLBAR_STATE = {
|
|
38
|
+
bgColor: '#fff',
|
|
39
|
+
blockType: 'paragraph' as keyof typeof blockTypeToBlockName,
|
|
40
|
+
canRedo: false,
|
|
41
|
+
canUndo: false,
|
|
42
|
+
codeLanguage: '',
|
|
43
|
+
elementFormat: 'left' as ElementFormatType,
|
|
44
|
+
fontColor: '#000',
|
|
45
|
+
fontFamily: 'Arial',
|
|
46
|
+
// Current font size in px
|
|
47
|
+
fontSize: `${DEFAULT_FONT_SIZE}px`,
|
|
48
|
+
// Font size input value - for controlled input
|
|
49
|
+
fontSizeInputValue: `${DEFAULT_FONT_SIZE}`,
|
|
50
|
+
isBold: false,
|
|
51
|
+
isCode: false,
|
|
52
|
+
isImageCaption: false,
|
|
53
|
+
isItalic: false,
|
|
54
|
+
isLink: false,
|
|
55
|
+
isRTL: false,
|
|
56
|
+
isStrikethrough: false,
|
|
57
|
+
isSubscript: false,
|
|
58
|
+
isSuperscript: false,
|
|
59
|
+
isUnderline: false,
|
|
60
|
+
isLowercase: false,
|
|
61
|
+
isUppercase: false,
|
|
62
|
+
isCapitalize: false,
|
|
63
|
+
rootType: 'root' as keyof typeof rootTypeToRootName,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
type ToolbarState = typeof INITIAL_TOOLBAR_STATE;
|
|
67
|
+
|
|
68
|
+
// Utility type to get keys and infer value types
|
|
69
|
+
type ToolbarStateKey = keyof ToolbarState;
|
|
70
|
+
type ToolbarStateValue<Key extends ToolbarStateKey> = ToolbarState[Key];
|
|
71
|
+
|
|
72
|
+
export type ContextShape = {
|
|
73
|
+
toolbarState: ToolbarState;
|
|
74
|
+
updateToolbarState<Key extends ToolbarStateKey>(
|
|
75
|
+
key: Key,
|
|
76
|
+
value: ToolbarStateValue<Key>,
|
|
77
|
+
): void;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
const Context = createContext<ContextShape | undefined>(undefined);
|
|
82
|
+
|
|
83
|
+
export const ToolbarContext = ({
|
|
84
|
+
children,
|
|
85
|
+
}: {
|
|
86
|
+
children: ReactNode;
|
|
87
|
+
}) => {
|
|
88
|
+
const [toolbarState, setToolbarState] = useState(INITIAL_TOOLBAR_STATE);
|
|
89
|
+
const selectionFontSize = toolbarState.fontSize;
|
|
90
|
+
|
|
91
|
+
const updateToolbarState = useCallback(
|
|
92
|
+
<Key extends ToolbarStateKey>(key: Key, value: ToolbarStateValue<Key>) => {
|
|
93
|
+
setToolbarState((prev) => ({
|
|
94
|
+
...prev,
|
|
95
|
+
[key]: value,
|
|
96
|
+
}));
|
|
97
|
+
},
|
|
98
|
+
[],
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
updateToolbarState('fontSizeInputValue', selectionFontSize.slice(0, -2));
|
|
103
|
+
}, [selectionFontSize, updateToolbarState]);
|
|
104
|
+
|
|
105
|
+
const contextValue = useMemo(() => {
|
|
106
|
+
return {
|
|
107
|
+
toolbarState,
|
|
108
|
+
updateToolbarState,
|
|
109
|
+
};
|
|
110
|
+
}, [toolbarState, updateToolbarState]);
|
|
111
|
+
|
|
112
|
+
return <Context.Provider value={contextValue}>{children}</Context.Provider>;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export const useToolbarState = () => {
|
|
116
|
+
const context = useContext(Context);
|
|
117
|
+
|
|
118
|
+
if (context === undefined) {
|
|
119
|
+
throw new Error('useToolbarState must be used within a ToolbarProvider');
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return context;
|
|
123
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { ThemeProvider as NextThemesProvider } from "next-themes"
|
|
5
|
+
|
|
6
|
+
export function ThemeProvider({
|
|
7
|
+
children,
|
|
8
|
+
...props
|
|
9
|
+
}: React.ComponentProps<typeof NextThemesProvider>) {
|
|
10
|
+
return <NextThemesProvider {...props}>{children}</NextThemesProvider>
|
|
11
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { Moon, Sun } from "lucide-react"
|
|
5
|
+
import { useTheme } from "next-themes"
|
|
6
|
+
|
|
7
|
+
import { Button } from "@/components/ui/button"
|
|
8
|
+
import {
|
|
9
|
+
DropdownMenu,
|
|
10
|
+
DropdownMenuContent,
|
|
11
|
+
DropdownMenuItem,
|
|
12
|
+
DropdownMenuTrigger,
|
|
13
|
+
} from "@/components/ui/dropdown-menu"
|
|
14
|
+
|
|
15
|
+
export function ModeToggle() {
|
|
16
|
+
const { setTheme } = useTheme()
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<DropdownMenu>
|
|
20
|
+
<DropdownMenuTrigger asChild>
|
|
21
|
+
<Button variant={"outline"} size={"Toolbar"} type="button" className="border-none">
|
|
22
|
+
<Sun className="h-[1.2rem] w-[1.2rem] scale-100 rotate-0 transition-all dark:scale-0 dark:-rotate-90" />
|
|
23
|
+
<Moon className="absolute h-[1.2rem] w-[1.2rem] scale-0 rotate-90 transition-all dark:scale-100 dark:rotate-0" />
|
|
24
|
+
<span className="sr-only">Toggle theme</span>
|
|
25
|
+
</Button>
|
|
26
|
+
</DropdownMenuTrigger>
|
|
27
|
+
<DropdownMenuContent align="end">
|
|
28
|
+
<DropdownMenuItem onClick={() => setTheme("light")}>
|
|
29
|
+
Light
|
|
30
|
+
</DropdownMenuItem>
|
|
31
|
+
<DropdownMenuItem onClick={() => setTheme("dark")}>
|
|
32
|
+
Dark
|
|
33
|
+
</DropdownMenuItem>
|
|
34
|
+
<DropdownMenuItem onClick={() => setTheme("system")}>
|
|
35
|
+
System
|
|
36
|
+
</DropdownMenuItem>
|
|
37
|
+
</DropdownMenuContent>
|
|
38
|
+
</DropdownMenu>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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 './Input.css';
|
|
12
|
+
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
|
|
15
|
+
type Props = Readonly<{
|
|
16
|
+
'data-test-id'?: string;
|
|
17
|
+
accept?: string;
|
|
18
|
+
label: string;
|
|
19
|
+
onChange: (files: FileList | null) => void;
|
|
20
|
+
}>;
|
|
21
|
+
|
|
22
|
+
export default function FileInput({
|
|
23
|
+
accept,
|
|
24
|
+
label,
|
|
25
|
+
onChange,
|
|
26
|
+
'data-test-id': dataTestId,
|
|
27
|
+
}: Props): JSX.Element {
|
|
28
|
+
return (
|
|
29
|
+
<div className="Input__wrapper">
|
|
30
|
+
<label className="Input__label">{label}</label>
|
|
31
|
+
<input
|
|
32
|
+
type="file"
|
|
33
|
+
accept={accept}
|
|
34
|
+
className="Input__input"
|
|
35
|
+
onChange={(e) => onChange(e.target.files)}
|
|
36
|
+
data-test-id={dataTestId}
|
|
37
|
+
/>
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
|
|
10
|
+
.Input__wrapper {
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: row;
|
|
13
|
+
align-items: center;
|
|
14
|
+
margin-bottom: 10px;
|
|
15
|
+
}
|
|
16
|
+
.Input__label {
|
|
17
|
+
display: flex;
|
|
18
|
+
flex: 1;
|
|
19
|
+
color: #666;
|
|
20
|
+
}
|
|
21
|
+
.Input__input {
|
|
22
|
+
display: flex;
|
|
23
|
+
flex: 2;
|
|
24
|
+
border: 1px solid #999;
|
|
25
|
+
padding-top: 7px;
|
|
26
|
+
padding-bottom: 7px;
|
|
27
|
+
padding-left: 10px;
|
|
28
|
+
padding-right: 10px;
|
|
29
|
+
font-size: 16px;
|
|
30
|
+
border-radius: 5px;
|
|
31
|
+
min-width: 0;
|
|
32
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
select {
|
|
10
|
+
appearance: none;
|
|
11
|
+
-webkit-appearance: none;
|
|
12
|
+
-moz-appearance: none;
|
|
13
|
+
background-color: transparent;
|
|
14
|
+
border: none;
|
|
15
|
+
padding: 0 1em 0 0;
|
|
16
|
+
margin: 0;
|
|
17
|
+
font-family: inherit;
|
|
18
|
+
font-size: inherit;
|
|
19
|
+
cursor: inherit;
|
|
20
|
+
line-height: inherit;
|
|
21
|
+
|
|
22
|
+
z-index: 1;
|
|
23
|
+
outline: none;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
:root {
|
|
27
|
+
--select-border: #393939;
|
|
28
|
+
--select-focus: #101484;
|
|
29
|
+
--select-arrow: var(--select-border);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.select {
|
|
33
|
+
min-width: 160px;
|
|
34
|
+
max-width: 290px;
|
|
35
|
+
border: 1px solid var(--select-border);
|
|
36
|
+
border-radius: 0.25em;
|
|
37
|
+
padding: 0.25em 0.5em;
|
|
38
|
+
font-size: 1rem;
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
line-height: 1.4;
|
|
41
|
+
background: linear-gradient(to bottom, #ffffff 0%, #e5e5e5 100%);
|
|
42
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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 './Select.css';
|
|
12
|
+
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
|
|
15
|
+
type SelectIntrinsicProps = JSX.IntrinsicElements['select'];
|
|
16
|
+
interface SelectProps extends SelectIntrinsicProps {
|
|
17
|
+
label: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default function Select({
|
|
21
|
+
children,
|
|
22
|
+
label,
|
|
23
|
+
className,
|
|
24
|
+
...other
|
|
25
|
+
}: SelectProps): JSX.Element {
|
|
26
|
+
return (
|
|
27
|
+
<div className="Input__wrapper">
|
|
28
|
+
<label style={{marginTop: '-1em'}} className="Input__label">
|
|
29
|
+
{label}
|
|
30
|
+
</label>
|
|
31
|
+
<select {...other} className={className || 'select'}>
|
|
32
|
+
{children}
|
|
33
|
+
</select>
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
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 './Input.css';
|
|
12
|
+
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
import {HTMLInputTypeAttribute} from 'react';
|
|
15
|
+
|
|
16
|
+
type Props = Readonly<{
|
|
17
|
+
'data-test-id'?: string;
|
|
18
|
+
label: string;
|
|
19
|
+
onChange: (val: string) => void;
|
|
20
|
+
placeholder?: string;
|
|
21
|
+
value: string;
|
|
22
|
+
type?: HTMLInputTypeAttribute;
|
|
23
|
+
}>;
|
|
24
|
+
|
|
25
|
+
export default function TextInput({
|
|
26
|
+
label,
|
|
27
|
+
value,
|
|
28
|
+
onChange,
|
|
29
|
+
placeholder = '',
|
|
30
|
+
'data-test-id': dataTestId,
|
|
31
|
+
type = 'text',
|
|
32
|
+
}: Props): JSX.Element {
|
|
33
|
+
return (
|
|
34
|
+
<div className="Input__wrapper">
|
|
35
|
+
<label className="Input__label">{label}</label>
|
|
36
|
+
<input
|
|
37
|
+
type={type}
|
|
38
|
+
className="Input__input"
|
|
39
|
+
placeholder={placeholder}
|
|
40
|
+
value={value}
|
|
41
|
+
onChange={(e) => {
|
|
42
|
+
onChange(e.target.value);
|
|
43
|
+
}}
|
|
44
|
+
data-test-id={dataTestId}
|
|
45
|
+
/>
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
}
|