@rolder/kit 3.0.0-alpha-1
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 +23 -0
- package/dist/functions/cookies/getCookie.d.ts +3 -0
- package/dist/functions/cookies/getCookie.js +8 -0
- package/dist/functions/cookies/index.d.ts +3 -0
- package/dist/functions/cookies/index.js +3 -0
- package/dist/functions/cookies/setCookie.d.ts +10 -0
- package/dist/functions/cookies/setCookie.js +19 -0
- package/dist/functions/cookies/setCookies.d.ts +14 -0
- package/dist/functions/cookies/setCookies.js +13 -0
- package/dist/functions/index.d.ts +1 -0
- package/dist/functions/index.js +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/ui/AnimatedChevron.d.ts +6 -0
- package/dist/ui/AnimatedChevron.js +13 -0
- package/dist/ui/JsonInput.d.ts +2 -0
- package/dist/ui/JsonInput.js +45 -0
- package/dist/ui/editor/Content.d.ts +3 -0
- package/dist/ui/editor/Content.js +13 -0
- package/dist/ui/editor/Provider.d.ts +17 -0
- package/dist/ui/editor/Provider.js +80 -0
- package/dist/ui/editor/Root.d.ts +2 -0
- package/dist/ui/editor/Root.js +19 -0
- package/dist/ui/editor/Toolbar.d.ts +5 -0
- package/dist/ui/editor/Toolbar.js +138 -0
- package/dist/ui/editor/index.d.ts +12 -0
- package/dist/ui/editor/index.js +11 -0
- package/dist/ui/editor/types.d.ts +7 -0
- package/dist/ui/editor/types.js +0 -0
- package/dist/ui/form/blurOnError.d.ts +4 -0
- package/dist/ui/form/blurOnError.js +11 -0
- package/dist/ui/form/buttons/CancelButton.d.ts +5 -0
- package/dist/ui/form/buttons/CancelButton.js +22 -0
- package/dist/ui/form/buttons/SubmitButton.d.ts +5 -0
- package/dist/ui/form/buttons/SubmitButton.js +22 -0
- package/dist/ui/form/buttons/SubscribeActionIcon.d.ts +4 -0
- package/dist/ui/form/buttons/SubscribeActionIcon.js +15 -0
- package/dist/ui/form/buttons/SubscribeButton.d.ts +5 -0
- package/dist/ui/form/buttons/SubscribeButton.js +16 -0
- package/dist/ui/form/buttons/index.d.ts +4 -0
- package/dist/ui/form/buttons/index.js +4 -0
- package/dist/ui/form/context.d.ts +83 -0
- package/dist/ui/form/context.js +26 -0
- package/dist/ui/form/fields/JsonField.d.ts +2 -0
- package/dist/ui/form/fields/JsonField.js +13 -0
- package/dist/ui/form/fields/MultiSelectField.d.ts +2 -0
- package/dist/ui/form/fields/MultiSelectField.js +15 -0
- package/dist/ui/form/fields/NumberField.d.ts +2 -0
- package/dist/ui/form/fields/NumberField.js +15 -0
- package/dist/ui/form/fields/PassowrdField.d.ts +2 -0
- package/dist/ui/form/fields/PassowrdField.js +18 -0
- package/dist/ui/form/fields/SelectField.d.ts +2 -0
- package/dist/ui/form/fields/SelectField.js +15 -0
- package/dist/ui/form/fields/SwitchField.d.ts +2 -0
- package/dist/ui/form/fields/SwitchField.js +15 -0
- package/dist/ui/form/fields/TextField.d.ts +2 -0
- package/dist/ui/form/fields/TextField.js +15 -0
- package/dist/ui/form/fields/TextPassowrdField.d.ts +2 -0
- package/dist/ui/form/fields/TextPassowrdField.js +29 -0
- package/dist/ui/form/fields/TextareaField.d.ts +2 -0
- package/dist/ui/form/fields/TextareaField.js +15 -0
- package/dist/ui/form/fields/index.d.ts +9 -0
- package/dist/ui/form/fields/index.js +9 -0
- package/dist/ui/form/fieldsSchema.d.ts +12 -0
- package/dist/ui/form/fieldsSchema.js +13 -0
- package/dist/ui/form/index.d.ts +3 -0
- package/dist/ui/form/index.js +4 -0
- package/dist/ui/hoverActionIcon/HoverActionIcon.d.ts +6 -0
- package/dist/ui/hoverActionIcon/HoverActionIcon.js +14 -0
- package/dist/ui/hoverActionIcon/index.d.ts +1 -0
- package/dist/ui/hoverActionIcon/index.js +1 -0
- package/dist/ui/hoverPaper/HoverPaper.d.ts +6 -0
- package/dist/ui/hoverPaper/HoverPaper.js +16 -0
- package/dist/ui/hoverPaper/index.d.ts +2 -0
- package/dist/ui/hoverPaper/index.js +2 -0
- package/dist/ui/hoverPaper/usePaperHover.d.ts +4 -0
- package/dist/ui/hoverPaper/usePaperHover.js +9 -0
- package/dist/ui/index.d.ts +9 -0
- package/dist/ui/index.js +9 -0
- package/dist/ui/routerLink/RouterLink.d.ts +16 -0
- package/dist/ui/routerLink/RouterLink.js +37 -0
- package/dist/ui/routerLink/index.d.ts +1 -0
- package/dist/ui/routerLink/index.js +1 -0
- package/dist/ui/saveInput/JsonInput.d.ts +6 -0
- package/dist/ui/saveInput/JsonInput.js +34 -0
- package/dist/ui/saveInput/NumberInput.d.ts +6 -0
- package/dist/ui/saveInput/NumberInput.js +27 -0
- package/dist/ui/saveInput/SaveInput.d.ts +36 -0
- package/dist/ui/saveInput/SaveInput.js +15 -0
- package/dist/ui/saveInput/Select.d.ts +6 -0
- package/dist/ui/saveInput/Select.js +27 -0
- package/dist/ui/saveInput/Switch.d.ts +6 -0
- package/dist/ui/saveInput/Switch.js +30 -0
- package/dist/ui/saveInput/TextInput.d.ts +6 -0
- package/dist/ui/saveInput/TextInput.js +26 -0
- package/dist/ui/saveInput/Textarea.d.ts +6 -0
- package/dist/ui/saveInput/Textarea.js +26 -0
- package/dist/ui/saveInput/index.d.ts +1 -0
- package/dist/ui/saveInput/index.js +2 -0
- package/dist/ui/scrollArea/ScrollArea.d.ts +62 -0
- package/dist/ui/scrollArea/ScrollArea.js +30 -0
- package/dist/ui/scrollArea/ScrollAreaButton.d.ts +5 -0
- package/dist/ui/scrollArea/ScrollAreaButton.js +30 -0
- package/dist/ui/scrollArea/ScrollAreaContent.d.ts +6 -0
- package/dist/ui/scrollArea/ScrollAreaContent.js +30 -0
- package/dist/ui/scrollArea/context.d.ts +28 -0
- package/dist/ui/scrollArea/context.js +10 -0
- package/dist/ui/scrollArea/index.d.ts +3 -0
- package/dist/ui/scrollArea/index.js +3 -0
- package/dist/ui/scrollArea/types.d.ts +65 -0
- package/dist/ui/scrollArea/types.js +0 -0
- package/dist/ui/scrollArea/useScrollArea.d.ts +9 -0
- package/dist/ui/scrollArea/useScrollArea.js +146 -0
- package/package.json +59 -0
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Rslib project
|
|
2
|
+
|
|
3
|
+
## Setup
|
|
4
|
+
|
|
5
|
+
Install the dependencies:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun install
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Get started
|
|
12
|
+
|
|
13
|
+
Build the library:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
bun run build
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Build the library in watch mode:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
bun run dev
|
|
23
|
+
```
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createIsomorphicFn } from "@tanstack/react-start";
|
|
2
|
+
import { getCookie } from "@tanstack/react-start/server";
|
|
3
|
+
import js_cookie from "js-cookie";
|
|
4
|
+
const getCookieImpl = createIsomorphicFn().server((name, defaultValue)=>getCookie(name) || defaultValue).client((name, defaultValue)=>js_cookie.get(name) || defaultValue);
|
|
5
|
+
function getCookie_getCookie(name, defaultValue) {
|
|
6
|
+
return getCookieImpl(name, defaultValue);
|
|
7
|
+
}
|
|
8
|
+
export { getCookie_getCookie as getCookie };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Изоморфная функция для установки значения куки.
|
|
3
|
+
* На клиенте использует библиотеку js-cookie для работы с куками.
|
|
4
|
+
* На сервере использует функции getCookie и setCookie из tanstack start.
|
|
5
|
+
*
|
|
6
|
+
* @param {string} name - Имя куки
|
|
7
|
+
* @param {string} value - Значение куки, если не указано, кука будет удалена
|
|
8
|
+
* @param {number} [expires=7] - Количество дней до истечения срока действия куки (по умолчанию 7 дней)
|
|
9
|
+
*/
|
|
10
|
+
export declare const setCookie: import("@tanstack/start-fn-stubs").IsomorphicFn<[name: string, value?: string | undefined, expires?: number | undefined], void, void>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createIsomorphicFn } from "@tanstack/react-start";
|
|
2
|
+
import { deleteCookie, setCookie } from "@tanstack/react-start/server";
|
|
3
|
+
import js_cookie from "js-cookie";
|
|
4
|
+
const setCookie_setCookie = createIsomorphicFn().server((name, value, expires)=>{
|
|
5
|
+
const expiresDate = new Date();
|
|
6
|
+
expiresDate.setDate(expiresDate.getDate() + (expires || 7));
|
|
7
|
+
if (value) setCookie(name, value, {
|
|
8
|
+
expires: expiresDate
|
|
9
|
+
});
|
|
10
|
+
else deleteCookie(name);
|
|
11
|
+
}).client((name, value, expires)=>{
|
|
12
|
+
const expiresDate = new Date();
|
|
13
|
+
expiresDate.setDate(expiresDate.getDate() + (expires || 7));
|
|
14
|
+
if (value) js_cookie.set(name, value, {
|
|
15
|
+
expires: expiresDate
|
|
16
|
+
});
|
|
17
|
+
else js_cookie.remove(name);
|
|
18
|
+
});
|
|
19
|
+
export { setCookie_setCookie as setCookie };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface Cookie {
|
|
2
|
+
name: string;
|
|
3
|
+
value?: string;
|
|
4
|
+
expires?: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Клиентская функция для установки значения нескольких куки.
|
|
8
|
+
* На клиенте использует библиотеку js-cookie для работы с куками.
|
|
9
|
+
* На сервере использует функции getCookie и setCookie из tanstack start.
|
|
10
|
+
*
|
|
11
|
+
* @param {Cookie[]} cookies - Массив объектов с данными куки *
|
|
12
|
+
*/
|
|
13
|
+
export declare const setCookies: (cookies: Cookie[]) => void;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createClientOnlyFn } from "@tanstack/react-start";
|
|
2
|
+
import js_cookie from "js-cookie";
|
|
3
|
+
const setCookies = createClientOnlyFn((cookies)=>{
|
|
4
|
+
cookies.forEach(({ name, value, expires })=>{
|
|
5
|
+
const expiresDate = new Date();
|
|
6
|
+
expiresDate.setDate(expiresDate.getDate() + (expires || 7));
|
|
7
|
+
if (value) js_cookie.set(name, value, {
|
|
8
|
+
expires: expiresDate
|
|
9
|
+
});
|
|
10
|
+
else js_cookie.remove(name);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
export { setCookies };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './cookies';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./cookies/index.js";
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { IconChevronDown } from "@tabler/icons-react";
|
|
3
|
+
const AnimatedChevron = ({ expanded, style, ...props })=>/*#__PURE__*/ jsx(IconChevronDown, {
|
|
4
|
+
strokeWidth: 1.5,
|
|
5
|
+
"data-expanded": expanded,
|
|
6
|
+
style: {
|
|
7
|
+
transition: 'transform 0.2s ease-in-out',
|
|
8
|
+
transform: expanded ? 'rotate(180deg)' : 'rotate(0deg)',
|
|
9
|
+
...style
|
|
10
|
+
},
|
|
11
|
+
...props
|
|
12
|
+
});
|
|
13
|
+
export { AnimatedChevron };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { indentSelection } from "@codemirror/commands";
|
|
3
|
+
import { json, jsonParseLinter } from "@codemirror/lang-json";
|
|
4
|
+
import { linter } from "@codemirror/lint";
|
|
5
|
+
import { keymap } from "@codemirror/view";
|
|
6
|
+
import { vscodeDark, vscodeLight } from "@uiw/codemirror-theme-vscode";
|
|
7
|
+
import react_codemirror from "@uiw/react-codemirror";
|
|
8
|
+
import { getCookie } from "../functions/index.js";
|
|
9
|
+
const formatJson = (view)=>{
|
|
10
|
+
try {
|
|
11
|
+
const text = view.state.doc.toString();
|
|
12
|
+
const parsed = JSON.parse(text);
|
|
13
|
+
const formatted = JSON.stringify(parsed, null, 2);
|
|
14
|
+
view.dispatch({
|
|
15
|
+
changes: {
|
|
16
|
+
from: 0,
|
|
17
|
+
to: view.state.doc.length,
|
|
18
|
+
insert: formatted
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return true;
|
|
22
|
+
} catch (_) {
|
|
23
|
+
return indentSelection(view);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const extensions = [
|
|
27
|
+
json(),
|
|
28
|
+
linter(jsonParseLinter()),
|
|
29
|
+
keymap.of([
|
|
30
|
+
{
|
|
31
|
+
key: 'Mod-Shift-f',
|
|
32
|
+
run: formatJson
|
|
33
|
+
}
|
|
34
|
+
])
|
|
35
|
+
];
|
|
36
|
+
const JsonInput = (props)=>{
|
|
37
|
+
const colorScheme = getCookie('colorScheme');
|
|
38
|
+
return /*#__PURE__*/ jsx(react_codemirror, {
|
|
39
|
+
height: "280px",
|
|
40
|
+
theme: 'light' === colorScheme ? vscodeLight : vscodeDark,
|
|
41
|
+
extensions: extensions,
|
|
42
|
+
...props
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
export { JsonInput };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { RichTextEditor } from "@mantine/tiptap";
|
|
3
|
+
import { ScrollArea } from "../scrollArea/index.js";
|
|
4
|
+
const Content = ({ height })=>/*#__PURE__*/ jsxs(ScrollArea, {
|
|
5
|
+
h: height,
|
|
6
|
+
autoScroll: true,
|
|
7
|
+
radius: "md",
|
|
8
|
+
children: [
|
|
9
|
+
/*#__PURE__*/ jsx(RichTextEditor.Content, {}),
|
|
10
|
+
/*#__PURE__*/ jsx(ScrollArea.ScrollButton, {})
|
|
11
|
+
]
|
|
12
|
+
});
|
|
13
|
+
export { Content };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Editor } from '@tiptap/react';
|
|
2
|
+
import type { EditorProps } from './types';
|
|
3
|
+
interface EditorContext {
|
|
4
|
+
editor: Editor | null;
|
|
5
|
+
editable?: boolean;
|
|
6
|
+
setEditable: (value: boolean) => void;
|
|
7
|
+
disabledToolbar: boolean;
|
|
8
|
+
setDisabledToolbar: (value: boolean) => void;
|
|
9
|
+
focused: boolean;
|
|
10
|
+
setFocused: (value: boolean) => void;
|
|
11
|
+
editedByUser: boolean;
|
|
12
|
+
setEditedByUser: (value: boolean) => void;
|
|
13
|
+
}
|
|
14
|
+
declare const EditorContext: import("react").Context<EditorContext | null>;
|
|
15
|
+
export declare const Provider: ({ children, initialContent, initialEditable, initialDisabledToolbar, onChange, }: EditorProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare const useEditor: () => EditorContext;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Link, getTaskListExtension } from "@mantine/tiptap";
|
|
3
|
+
import extension_highlight from "@tiptap/extension-highlight";
|
|
4
|
+
import extension_placeholder from "@tiptap/extension-placeholder";
|
|
5
|
+
import { TableKit } from "@tiptap/extension-table";
|
|
6
|
+
import extension_task_item from "@tiptap/extension-task-item";
|
|
7
|
+
import extension_task_list from "@tiptap/extension-task-list";
|
|
8
|
+
import extension_text_align from "@tiptap/extension-text-align";
|
|
9
|
+
import { useEditor } from "@tiptap/react";
|
|
10
|
+
import starter_kit from "@tiptap/starter-kit";
|
|
11
|
+
import { createContext, useContext, useEffect, useState } from "react";
|
|
12
|
+
const EditorContext = /*#__PURE__*/ createContext(null);
|
|
13
|
+
const Provider = ({ children, initialContent, initialEditable = true, initialDisabledToolbar, onChange })=>{
|
|
14
|
+
const editor = useEditor({
|
|
15
|
+
shouldRerenderOnTransaction: false,
|
|
16
|
+
immediatelyRender: false,
|
|
17
|
+
extensions: [
|
|
18
|
+
starter_kit.configure({
|
|
19
|
+
link: false
|
|
20
|
+
}),
|
|
21
|
+
extension_placeholder.configure({
|
|
22
|
+
placeholder: 'Документ пуст'
|
|
23
|
+
}),
|
|
24
|
+
Link,
|
|
25
|
+
extension_highlight,
|
|
26
|
+
extension_text_align.configure({
|
|
27
|
+
types: [
|
|
28
|
+
'heading',
|
|
29
|
+
'paragraph'
|
|
30
|
+
]
|
|
31
|
+
}),
|
|
32
|
+
getTaskListExtension(extension_task_list),
|
|
33
|
+
extension_task_item.configure({
|
|
34
|
+
nested: true
|
|
35
|
+
}),
|
|
36
|
+
TableKit
|
|
37
|
+
],
|
|
38
|
+
content: initialContent,
|
|
39
|
+
onUpdate: ({ editor })=>{
|
|
40
|
+
onChange?.(editor.getHTML());
|
|
41
|
+
},
|
|
42
|
+
editable: initialEditable
|
|
43
|
+
});
|
|
44
|
+
const [editable, setEditable] = useState(initialEditable);
|
|
45
|
+
const [disabledToolbar, setDisabledToolbar] = useState(!!initialDisabledToolbar);
|
|
46
|
+
const [editedByUser, setEditedByUser] = useState(true);
|
|
47
|
+
const [focused, setFocused] = useState(false);
|
|
48
|
+
useEffect(()=>{
|
|
49
|
+
editor?.on('focus', ()=>setFocused(true));
|
|
50
|
+
editor?.on('blur', ()=>setFocused(false));
|
|
51
|
+
editor?.on('update', ({ transaction })=>{
|
|
52
|
+
if (transaction.docChanged && focused) setEditedByUser(true);
|
|
53
|
+
if (transaction.docChanged && !focused) setEditedByUser(false);
|
|
54
|
+
});
|
|
55
|
+
}, [
|
|
56
|
+
editor,
|
|
57
|
+
focused
|
|
58
|
+
]);
|
|
59
|
+
const value = {
|
|
60
|
+
editor,
|
|
61
|
+
editable,
|
|
62
|
+
setEditable,
|
|
63
|
+
disabledToolbar,
|
|
64
|
+
setDisabledToolbar,
|
|
65
|
+
editedByUser,
|
|
66
|
+
setEditedByUser,
|
|
67
|
+
focused,
|
|
68
|
+
setFocused
|
|
69
|
+
};
|
|
70
|
+
return /*#__PURE__*/ jsx(EditorContext.Provider, {
|
|
71
|
+
value: value,
|
|
72
|
+
children: children
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
const Provider_useEditor = ()=>{
|
|
76
|
+
const context = useContext(EditorContext);
|
|
77
|
+
if (!context) throw new Error('useEditor must be used within EditorProvider');
|
|
78
|
+
return context;
|
|
79
|
+
};
|
|
80
|
+
export { Provider, Provider_useEditor as useEditor };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { RichTextEditor } from "@mantine/tiptap";
|
|
3
|
+
import { useEditor } from "./Provider.js";
|
|
4
|
+
import styles_module from "./styles.module.js";
|
|
5
|
+
const Root = ({ children, classNames, ...props })=>{
|
|
6
|
+
const { editor } = useEditor();
|
|
7
|
+
return /*#__PURE__*/ jsx(RichTextEditor, {
|
|
8
|
+
editor: editor,
|
|
9
|
+
classNames: {
|
|
10
|
+
root: styles_module.root,
|
|
11
|
+
content: styles_module.content,
|
|
12
|
+
toolbar: styles_module.toolbar,
|
|
13
|
+
...classNames
|
|
14
|
+
},
|
|
15
|
+
...props,
|
|
16
|
+
children: children
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
export { Root };
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Loader } from "@mantine/core";
|
|
3
|
+
import { RichTextEditor } from "@mantine/tiptap";
|
|
4
|
+
import { IconCheck } from "@tabler/icons-react";
|
|
5
|
+
import { useEditor } from "./Provider.js";
|
|
6
|
+
const Toolbar = ({ saving, children })=>{
|
|
7
|
+
const { editor, disabledToolbar } = useEditor();
|
|
8
|
+
return disabledToolbar ? null : /*#__PURE__*/ jsxs(RichTextEditor.Toolbar, {
|
|
9
|
+
sticky: true,
|
|
10
|
+
children: [
|
|
11
|
+
/*#__PURE__*/ jsxs(RichTextEditor.ControlsGroup, {
|
|
12
|
+
children: [
|
|
13
|
+
/*#__PURE__*/ jsx(RichTextEditor.Bold, {
|
|
14
|
+
disabled: !editor?.isEditable
|
|
15
|
+
}),
|
|
16
|
+
/*#__PURE__*/ jsx(RichTextEditor.Italic, {
|
|
17
|
+
disabled: !editor?.isEditable
|
|
18
|
+
}),
|
|
19
|
+
/*#__PURE__*/ jsx(RichTextEditor.Underline, {
|
|
20
|
+
disabled: !editor?.isEditable
|
|
21
|
+
}),
|
|
22
|
+
/*#__PURE__*/ jsx(RichTextEditor.Strikethrough, {
|
|
23
|
+
disabled: !editor?.isEditable
|
|
24
|
+
}),
|
|
25
|
+
/*#__PURE__*/ jsx(RichTextEditor.ClearFormatting, {
|
|
26
|
+
disabled: !editor?.isEditable
|
|
27
|
+
}),
|
|
28
|
+
/*#__PURE__*/ jsx(RichTextEditor.Highlight, {
|
|
29
|
+
disabled: !editor?.isEditable
|
|
30
|
+
}),
|
|
31
|
+
/*#__PURE__*/ jsx(RichTextEditor.Code, {
|
|
32
|
+
disabled: !editor?.isEditable
|
|
33
|
+
})
|
|
34
|
+
]
|
|
35
|
+
}),
|
|
36
|
+
/*#__PURE__*/ jsxs(RichTextEditor.ControlsGroup, {
|
|
37
|
+
children: [
|
|
38
|
+
/*#__PURE__*/ jsx(RichTextEditor.H1, {
|
|
39
|
+
disabled: !editor?.isEditable
|
|
40
|
+
}),
|
|
41
|
+
/*#__PURE__*/ jsx(RichTextEditor.H2, {
|
|
42
|
+
disabled: !editor?.isEditable
|
|
43
|
+
}),
|
|
44
|
+
/*#__PURE__*/ jsx(RichTextEditor.H3, {
|
|
45
|
+
disabled: !editor?.isEditable
|
|
46
|
+
}),
|
|
47
|
+
/*#__PURE__*/ jsx(RichTextEditor.H4, {
|
|
48
|
+
disabled: !editor?.isEditable
|
|
49
|
+
})
|
|
50
|
+
]
|
|
51
|
+
}),
|
|
52
|
+
/*#__PURE__*/ jsxs(RichTextEditor.ControlsGroup, {
|
|
53
|
+
children: [
|
|
54
|
+
/*#__PURE__*/ jsx(RichTextEditor.Blockquote, {
|
|
55
|
+
disabled: !editor?.isEditable
|
|
56
|
+
}),
|
|
57
|
+
/*#__PURE__*/ jsx(RichTextEditor.Hr, {
|
|
58
|
+
disabled: !editor?.isEditable
|
|
59
|
+
}),
|
|
60
|
+
/*#__PURE__*/ jsx(RichTextEditor.BulletList, {
|
|
61
|
+
disabled: !editor?.isEditable
|
|
62
|
+
}),
|
|
63
|
+
/*#__PURE__*/ jsx(RichTextEditor.OrderedList, {
|
|
64
|
+
disabled: !editor?.isEditable
|
|
65
|
+
})
|
|
66
|
+
]
|
|
67
|
+
}),
|
|
68
|
+
/*#__PURE__*/ jsxs(RichTextEditor.ControlsGroup, {
|
|
69
|
+
children: [
|
|
70
|
+
/*#__PURE__*/ jsx(RichTextEditor.TaskList, {
|
|
71
|
+
disabled: !editor?.isEditable
|
|
72
|
+
}),
|
|
73
|
+
/*#__PURE__*/ jsx(RichTextEditor.TaskListLift, {
|
|
74
|
+
disabled: !editor?.isEditable
|
|
75
|
+
}),
|
|
76
|
+
/*#__PURE__*/ jsx(RichTextEditor.TaskListSink, {
|
|
77
|
+
disabled: !editor?.isEditable
|
|
78
|
+
})
|
|
79
|
+
]
|
|
80
|
+
}),
|
|
81
|
+
/*#__PURE__*/ jsxs(RichTextEditor.ControlsGroup, {
|
|
82
|
+
children: [
|
|
83
|
+
/*#__PURE__*/ jsx(RichTextEditor.Link, {
|
|
84
|
+
disabled: !editor?.isEditable
|
|
85
|
+
}),
|
|
86
|
+
/*#__PURE__*/ jsx(RichTextEditor.Unlink, {
|
|
87
|
+
disabled: !editor?.isEditable
|
|
88
|
+
})
|
|
89
|
+
]
|
|
90
|
+
}),
|
|
91
|
+
/*#__PURE__*/ jsxs(RichTextEditor.ControlsGroup, {
|
|
92
|
+
children: [
|
|
93
|
+
/*#__PURE__*/ jsx(RichTextEditor.AlignLeft, {
|
|
94
|
+
disabled: !editor?.isEditable
|
|
95
|
+
}),
|
|
96
|
+
/*#__PURE__*/ jsx(RichTextEditor.AlignCenter, {
|
|
97
|
+
disabled: !editor?.isEditable
|
|
98
|
+
}),
|
|
99
|
+
/*#__PURE__*/ jsx(RichTextEditor.AlignJustify, {
|
|
100
|
+
disabled: !editor?.isEditable
|
|
101
|
+
}),
|
|
102
|
+
/*#__PURE__*/ jsx(RichTextEditor.AlignRight, {
|
|
103
|
+
disabled: !editor?.isEditable
|
|
104
|
+
})
|
|
105
|
+
]
|
|
106
|
+
}),
|
|
107
|
+
/*#__PURE__*/ jsxs(RichTextEditor.ControlsGroup, {
|
|
108
|
+
children: [
|
|
109
|
+
/*#__PURE__*/ jsx(RichTextEditor.Undo, {
|
|
110
|
+
disabled: !editor?.isEditable
|
|
111
|
+
}),
|
|
112
|
+
/*#__PURE__*/ jsx(RichTextEditor.Redo, {
|
|
113
|
+
disabled: !editor?.isEditable
|
|
114
|
+
})
|
|
115
|
+
]
|
|
116
|
+
}),
|
|
117
|
+
/*#__PURE__*/ jsxs(RichTextEditor.ControlsGroup, {
|
|
118
|
+
ml: "auto",
|
|
119
|
+
children: [
|
|
120
|
+
children,
|
|
121
|
+
/*#__PURE__*/ jsx(RichTextEditor.Control, {
|
|
122
|
+
ml: "10px",
|
|
123
|
+
style: {
|
|
124
|
+
cursor: 'default'
|
|
125
|
+
},
|
|
126
|
+
children: saving ? /*#__PURE__*/ jsx(Loader, {
|
|
127
|
+
size: 14
|
|
128
|
+
}) : /*#__PURE__*/ jsx(IconCheck, {
|
|
129
|
+
stroke: 1.5,
|
|
130
|
+
size: 16
|
|
131
|
+
})
|
|
132
|
+
})
|
|
133
|
+
]
|
|
134
|
+
})
|
|
135
|
+
]
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
export { Toolbar };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const Editor: {
|
|
2
|
+
Root: ({ children, classNames, ...props }: Omit<import("@mantine/tiptap").RichTextEditorProps, "editor">) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
Content: ({ height }: {
|
|
4
|
+
height: string;
|
|
5
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
Toolbar: ({ saving, children, }: {
|
|
7
|
+
saving?: boolean;
|
|
8
|
+
children?: import("react").ReactNode;
|
|
9
|
+
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
10
|
+
Provider: ({ children, initialContent, initialEditable, initialDisabledToolbar, onChange, }: import("./types").EditorProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
};
|
|
12
|
+
export { useEditor } from './Provider';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Content } from "./Content.js";
|
|
2
|
+
import { Provider, useEditor } from "./Provider.js";
|
|
3
|
+
import { Root } from "./Root.js";
|
|
4
|
+
import { Toolbar } from "./Toolbar.js";
|
|
5
|
+
const Editor = {
|
|
6
|
+
Root: Root,
|
|
7
|
+
Content: Content,
|
|
8
|
+
Toolbar: Toolbar,
|
|
9
|
+
Provider: Provider
|
|
10
|
+
};
|
|
11
|
+
export { Editor, useEditor };
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const blurOnError = ({ formApi })=>{
|
|
2
|
+
const inputNames = Array.from(new Set(Object.keys(formApi.state.fieldMeta).filter((i)=>formApi.state.fieldMeta[i]?.errors.length)));
|
|
3
|
+
for (const inputName of inputNames){
|
|
4
|
+
const input = document.querySelector(`#form input[name="${inputName}"]`);
|
|
5
|
+
if (input) {
|
|
6
|
+
input.focus();
|
|
7
|
+
break;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
export { blurOnError };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from "@mantine/core";
|
|
3
|
+
import { IconCancel } from "@tabler/icons-react";
|
|
4
|
+
import { useFormContext } from "../context.js";
|
|
5
|
+
const CancelButton = (props)=>{
|
|
6
|
+
const form = useFormContext();
|
|
7
|
+
return /*#__PURE__*/ jsx(form.Subscribe, {
|
|
8
|
+
selector: (state)=>state.isSubmitting,
|
|
9
|
+
children: (isSubmitting)=>/*#__PURE__*/ jsx(Button, {
|
|
10
|
+
type: "reset",
|
|
11
|
+
size: "xs",
|
|
12
|
+
variant: "light",
|
|
13
|
+
leftSection: /*#__PURE__*/ jsx(IconCancel, {
|
|
14
|
+
size: 16
|
|
15
|
+
}),
|
|
16
|
+
disabled: isSubmitting,
|
|
17
|
+
...props,
|
|
18
|
+
children: props.label || 'Отмена'
|
|
19
|
+
})
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
export { CancelButton };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from "@mantine/core";
|
|
3
|
+
import { IconDeviceFloppy } from "@tabler/icons-react";
|
|
4
|
+
import { useFormContext } from "../context.js";
|
|
5
|
+
const SubmitButton = (props)=>{
|
|
6
|
+
const form = useFormContext();
|
|
7
|
+
return /*#__PURE__*/ jsx(form.Subscribe, {
|
|
8
|
+
selector: (state)=>state,
|
|
9
|
+
children: (state)=>/*#__PURE__*/ jsx(Button, {
|
|
10
|
+
type: "submit",
|
|
11
|
+
size: "xs",
|
|
12
|
+
leftSection: /*#__PURE__*/ jsx(IconDeviceFloppy, {
|
|
13
|
+
size: 20
|
|
14
|
+
}),
|
|
15
|
+
loading: state.isSubmitting,
|
|
16
|
+
disabled: !state.isDirty,
|
|
17
|
+
...props,
|
|
18
|
+
children: props.label || 'Сохранить'
|
|
19
|
+
})
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
export { SubmitButton };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ActionIcon } from "@mantine/core";
|
|
3
|
+
import { useFormContext } from "../context.js";
|
|
4
|
+
const SubscribeActionIcon = (props)=>{
|
|
5
|
+
const form = useFormContext();
|
|
6
|
+
return /*#__PURE__*/ jsx(form.Subscribe, {
|
|
7
|
+
selector: (state)=>state.isSubmitting,
|
|
8
|
+
children: (isSubmitting)=>/*#__PURE__*/ jsx(ActionIcon, {
|
|
9
|
+
disabled: isSubmitting,
|
|
10
|
+
...props,
|
|
11
|
+
children: props.children
|
|
12
|
+
})
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
export { SubscribeActionIcon };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from "@mantine/core";
|
|
3
|
+
import { useFormContext } from "../context.js";
|
|
4
|
+
const SubscribeButton = (props)=>{
|
|
5
|
+
const form = useFormContext();
|
|
6
|
+
return /*#__PURE__*/ jsx(form.Subscribe, {
|
|
7
|
+
selector: (state)=>state.isSubmitting,
|
|
8
|
+
children: (isSubmitting)=>/*#__PURE__*/ jsx(Button, {
|
|
9
|
+
type: "button",
|
|
10
|
+
disabled: isSubmitting,
|
|
11
|
+
...props,
|
|
12
|
+
children: props.label
|
|
13
|
+
})
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
export { SubscribeButton };
|