@rolder/kit 3.0.0-alpha.12 → 3.0.0-alpha.14
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/dist/index.d.ts +0 -14
- package/package.json +32 -8
- package/dist/functions/getCookie.js +0 -8
- package/dist/functions/setCookie.js +0 -19
- package/dist/functions/setCookies.js +0 -13
- package/dist/hooks/useMutation.js +0 -8
- package/dist/hooks/useMutationWithInvalidate.js +0 -16
- package/dist/index.js +0 -23
- package/dist/surreal/connection.js +0 -49
- package/dist/surreal/deafaultCrud.js +0 -18
- package/dist/surreal/deserialize.js +0 -46
- package/dist/surreal/encryption.js +0 -30
- package/dist/ui/AnimatedChevron.js +0 -31
- package/dist/ui/JsonInput.js +0 -45
- package/dist/ui/RouterLink.js +0 -36
- package/dist/ui/editor/Content.js +0 -13
- package/dist/ui/editor/Provider.js +0 -80
- package/dist/ui/editor/Root.js +0 -18
- package/dist/ui/editor/Toolbar.js +0 -156
- package/dist/ui/editor/index.js +0 -11
- package/dist/ui/editor/types.js +0 -0
- package/dist/ui/error/DefaultError.js +0 -62
- package/dist/ui/error/DefaultNotFound.js +0 -37
- package/dist/ui/error/Forbidden.js +0 -32
- package/dist/ui/error/defaultErrorNotification.js +0 -8
- package/dist/ui/error/index.js +0 -5
- package/dist/ui/form/blurOnError.js +0 -11
- package/dist/ui/form/buttons/CancelButton.js +0 -44
- package/dist/ui/form/buttons/SubmitButton.js +0 -47
- package/dist/ui/form/buttons/SubscribeActionIcon.js +0 -15
- package/dist/ui/form/buttons/SubscribeButton.js +0 -16
- package/dist/ui/form/buttons/index.js +0 -4
- package/dist/ui/form/context.js +0 -26
- package/dist/ui/form/fields/JsonField.js +0 -13
- package/dist/ui/form/fields/MultiSelectField.js +0 -15
- package/dist/ui/form/fields/NumberField.js +0 -15
- package/dist/ui/form/fields/PassowrdField.js +0 -18
- package/dist/ui/form/fields/SelectField.js +0 -15
- package/dist/ui/form/fields/SwitchField.js +0 -15
- package/dist/ui/form/fields/TextField.js +0 -15
- package/dist/ui/form/fields/TextPassowrdField.js +0 -51
- package/dist/ui/form/fields/TextareaField.js +0 -15
- package/dist/ui/form/fields/index.js +0 -9
- package/dist/ui/form/fieldsSchema.js +0 -13
- package/dist/ui/form/index.js +0 -4
- package/dist/ui/hoverPaper/HoverPaper.js +0 -15
- package/dist/ui/hoverPaper/index.js +0 -3
- package/dist/ui/hoverPaper/usePaperHover.js +0 -9
- package/dist/ui/saveInput/JsonInput.js +0 -34
- package/dist/ui/saveInput/NumberInput.js +0 -27
- package/dist/ui/saveInput/SaveInput.js +0 -15
- package/dist/ui/saveInput/Select.js +0 -27
- package/dist/ui/saveInput/Switch.js +0 -30
- package/dist/ui/saveInput/TextInput.js +0 -26
- package/dist/ui/saveInput/Textarea.js +0 -26
- package/dist/ui/saveInput/index.js +0 -2
package/dist/index.d.ts
CHANGED
|
@@ -6,18 +6,4 @@ export { parseAiMessagePart } from './ai/utils/parseAiMessagePart';
|
|
|
6
6
|
export { DefaultApp } from './app/DefaultApp';
|
|
7
7
|
export { defaultRequestMiddlewares } from './app/defaultRequestMiddlewares';
|
|
8
8
|
export { defaultTheme } from './app/defaultTheme';
|
|
9
|
-
export { getCookie } from './functions/getCookie';
|
|
10
|
-
export { setCookie } from './functions/setCookie';
|
|
11
|
-
export { setCookies } from './functions/setCookies';
|
|
12
|
-
export { useMutation } from './hooks/useMutation';
|
|
13
|
-
export { useMutationWithInvalidate } from './hooks/useMutationWithInvalidate';
|
|
14
|
-
export { getDB } from './surreal/connection';
|
|
15
|
-
export { surrealDeleteFn, surrealUnsubscribeFn } from './surreal/deafaultCrud';
|
|
16
|
-
export { deserialize } from './surreal/deserialize';
|
|
17
|
-
export { encryptionFn } from './surreal/encryption';
|
|
18
|
-
export { Editor, useEditor } from './ui/editor';
|
|
19
|
-
export { DefaultError, DefaultNotFound, defaultErrorNotification, Forbidden, } from './ui/error';
|
|
20
|
-
export { AnimatedChevron } from './ui/AnimatedChevron';
|
|
21
|
-
export { HoverPaper, usePaperHover } from './ui/hoverPaper';
|
|
22
|
-
export { RouterLink } from './ui/RouterLink';
|
|
23
9
|
export { ScrollArea, useScrollArea, type ScrollAreaContextValue, type ScrollAreaHook, type ScrollAreaProps, type ScrollAreaState, type ScrollButtonProps, type ScrollPosition, } from './ui/scrollArea';
|
package/package.json
CHANGED
|
@@ -1,20 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rolder/kit",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
|
-
".":
|
|
10
|
-
|
|
11
|
-
"import": "./dist/index.js"
|
|
9
|
+
"./styles.css": "./dist/styles.css",
|
|
10
|
+
"./conversation": {
|
|
11
|
+
"import": "./dist/ai/ui/conversation/index.js"
|
|
12
12
|
},
|
|
13
|
-
"./
|
|
13
|
+
"./promptInput": {
|
|
14
|
+
"import": "./dist/ai/ui/promptInput/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./convertFileUIPartBlobToDataURL": {
|
|
17
|
+
"import": "./dist/ai/utils/convertFileUIPartBlobToDataURL.js"
|
|
18
|
+
},
|
|
19
|
+
"./parseAiMessagePart": {
|
|
20
|
+
"import": "./dist/ai/utils/parseAiMessagePart.js"
|
|
21
|
+
},
|
|
22
|
+
"./AppDefaults": {
|
|
23
|
+
"import": "./dist/app/AppDefaults.js"
|
|
24
|
+
},
|
|
25
|
+
"./cookieColorSchemeManager": {
|
|
26
|
+
"import": "./dist/app/cookieColorSchemeManager.js"
|
|
27
|
+
},
|
|
28
|
+
"./DefaultApp": {
|
|
29
|
+
"import": "./dist/app/DefaultApp.js"
|
|
30
|
+
},
|
|
31
|
+
"./defaultRequestMiddlewares": {
|
|
32
|
+
"import": "./dist/app/defaultRequestMiddlewares.js"
|
|
33
|
+
},
|
|
34
|
+
"./defaultTheme": {
|
|
35
|
+
"import": "./dist/app/defaultTheme.js"
|
|
36
|
+
},
|
|
37
|
+
"./scrollArea": {
|
|
38
|
+
"import": "./dist/ui/scrollArea/index.js"
|
|
39
|
+
}
|
|
14
40
|
},
|
|
15
|
-
"sideEffects":
|
|
16
|
-
"*.css"
|
|
17
|
-
],
|
|
41
|
+
"sideEffects": false,
|
|
18
42
|
"files": [
|
|
19
43
|
"dist"
|
|
20
44
|
],
|
|
@@ -1,8 +0,0 @@
|
|
|
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 };
|
|
@@ -1,19 +0,0 @@
|
|
|
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 };
|
|
@@ -1,13 +0,0 @@
|
|
|
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 };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
2
|
-
const useMutationWithInvalidate = (fn, queryKey, options)=>{
|
|
3
|
-
const queryClient = useQueryClient();
|
|
4
|
-
return useMutation({
|
|
5
|
-
mutationFn: (data)=>fn({
|
|
6
|
-
data
|
|
7
|
-
}),
|
|
8
|
-
onSettled: async (_, error)=>{
|
|
9
|
-
if (!error && queryKey.length) await queryClient.invalidateQueries({
|
|
10
|
-
queryKey
|
|
11
|
-
});
|
|
12
|
-
},
|
|
13
|
-
...options
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
export { useMutationWithInvalidate };
|
package/dist/index.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Conversation, useChatMessage } from "./ai/ui/conversation/index.js";
|
|
2
|
-
import { PromptInput } from "./ai/ui/promptInput/index.js";
|
|
3
|
-
import { convertFileUIPartBlobToDataURL } from "./ai/utils/convertFileUIPartBlobToDataURL.js";
|
|
4
|
-
import { parseAiMessagePart } from "./ai/utils/parseAiMessagePart.js";
|
|
5
|
-
import { DefaultApp } from "./app/DefaultApp.js";
|
|
6
|
-
import { defaultRequestMiddlewares } from "./app/defaultRequestMiddlewares.js";
|
|
7
|
-
import { defaultTheme } from "./app/defaultTheme.js";
|
|
8
|
-
import { getCookie } from "./functions/getCookie.js";
|
|
9
|
-
import { setCookie } from "./functions/setCookie.js";
|
|
10
|
-
import { setCookies } from "./functions/setCookies.js";
|
|
11
|
-
import { useMutation } from "./hooks/useMutation.js";
|
|
12
|
-
import { useMutationWithInvalidate } from "./hooks/useMutationWithInvalidate.js";
|
|
13
|
-
import { getDB } from "./surreal/connection.js";
|
|
14
|
-
import { surrealDeleteFn, surrealUnsubscribeFn } from "./surreal/deafaultCrud.js";
|
|
15
|
-
import { deserialize } from "./surreal/deserialize.js";
|
|
16
|
-
import { encryptionFn } from "./surreal/encryption.js";
|
|
17
|
-
import { Editor, useEditor } from "./ui/editor/index.js";
|
|
18
|
-
import { DefaultError, DefaultNotFound, Forbidden, defaultErrorNotification } from "./ui/error/index.js";
|
|
19
|
-
import { AnimatedChevron } from "./ui/AnimatedChevron.js";
|
|
20
|
-
import { HoverPaper, usePaperHover } from "./ui/hoverPaper/index.js";
|
|
21
|
-
import { RouterLink } from "./ui/RouterLink.js";
|
|
22
|
-
import { ScrollArea, useScrollArea } from "./ui/scrollArea/index.js";
|
|
23
|
-
export { AnimatedChevron, Conversation, DefaultApp, DefaultError, DefaultNotFound, Editor, Forbidden, HoverPaper, PromptInput, RouterLink, ScrollArea, convertFileUIPartBlobToDataURL, defaultErrorNotification, defaultRequestMiddlewares, defaultTheme, deserialize, encryptionFn, getCookie, getDB, parseAiMessagePart, setCookie, setCookies, surrealDeleteFn, surrealUnsubscribeFn, useChatMessage, useEditor, useMutation, useMutationWithInvalidate, usePaperHover, useScrollArea };
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { createServerOnlyFn } from "@tanstack/react-start";
|
|
2
|
-
import { getCookie } from "@tanstack/react-start/server";
|
|
3
|
-
import { DateTime, Surreal } from "surrealdb";
|
|
4
|
-
let db = null;
|
|
5
|
-
const getDB = createServerOnlyFn(async (params = {})=>{
|
|
6
|
-
if (db?.isConnected) return db;
|
|
7
|
-
const locale = getCookie('locale') || 'ru-RU';
|
|
8
|
-
const timeZone = getCookie('tz') || 'UTC';
|
|
9
|
-
const instance = new Surreal({
|
|
10
|
-
codecOptions: params.codecOptions || {
|
|
11
|
-
valueDecodeVisitor (value) {
|
|
12
|
-
if (value instanceof DateTime) return new Date(value.toDate()).toLocaleDateString(locale, {
|
|
13
|
-
hour: 'numeric',
|
|
14
|
-
minute: 'numeric',
|
|
15
|
-
timeZone
|
|
16
|
-
});
|
|
17
|
-
return value;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
try {
|
|
22
|
-
const url = params.url || process.env.SURREALDB_URL;
|
|
23
|
-
if (!url) throw new Error('Missing required SurrealDB URL');
|
|
24
|
-
const namespace = params.namespace || process.env.SURREALDB_NAMESPACE;
|
|
25
|
-
if (!namespace) throw new Error('Missing required SurrealDB namespace');
|
|
26
|
-
const database = params.database || process.env.SURREALDB_DATABASE;
|
|
27
|
-
if (!database) throw new Error('Missing required SurrealDB database');
|
|
28
|
-
const username = params.username || process.env.SURREALDB_USERNAME;
|
|
29
|
-
const password = params.password || process.env.SURREALDB_PASSWORD;
|
|
30
|
-
if (username && password) await instance.connect(url, {
|
|
31
|
-
authentication: {
|
|
32
|
-
username,
|
|
33
|
-
password
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
else await instance.connect(url);
|
|
37
|
-
await instance.use({
|
|
38
|
-
namespace,
|
|
39
|
-
database
|
|
40
|
-
});
|
|
41
|
-
db = instance;
|
|
42
|
-
return instance;
|
|
43
|
-
} catch (error) {
|
|
44
|
-
console.error('Failed to connect to SurrealDB:', error);
|
|
45
|
-
db = null;
|
|
46
|
-
throw error;
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
export { getDB };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { createServerFn } from "@tanstack/react-start";
|
|
2
|
-
import { getDB } from "./connection.js";
|
|
3
|
-
import { deserialize } from "./deserialize.js";
|
|
4
|
-
const surrealDeleteFn = createServerFn({
|
|
5
|
-
method: 'POST'
|
|
6
|
-
}).inputValidator((data)=>data).handler(async ({ data })=>{
|
|
7
|
-
const db = await getDB();
|
|
8
|
-
const id = deserialize(data);
|
|
9
|
-
await db.delete(id);
|
|
10
|
-
});
|
|
11
|
-
const surrealUnsubscribeFn = createServerFn({
|
|
12
|
-
method: 'POST'
|
|
13
|
-
}).inputValidator((data)=>data).handler(async ({ data })=>{
|
|
14
|
-
const db = await getDB();
|
|
15
|
-
const live = await db.liveOf(data);
|
|
16
|
-
await live.kill();
|
|
17
|
-
});
|
|
18
|
-
export { surrealDeleteFn, surrealUnsubscribeFn };
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { RecordId } from "surrealdb";
|
|
2
|
-
const extractTableName = (str)=>{
|
|
3
|
-
const match = str.match(/^([^:]+):/);
|
|
4
|
-
return match ? match[1] : null;
|
|
5
|
-
};
|
|
6
|
-
const isRecordIdFormat = (str)=>/^[^:]+:.+$/.test(str);
|
|
7
|
-
function deserialize(dto, idPaths) {
|
|
8
|
-
if (Array.isArray(dto)) return dto.map((item)=>convertStringsToRecordIds(item, idPaths || []));
|
|
9
|
-
return convertStringsToRecordIds(dto, idPaths || []);
|
|
10
|
-
}
|
|
11
|
-
const convertStringsToRecordIds = (obj, idPaths, currentPath = '')=>{
|
|
12
|
-
if (null == obj) return obj;
|
|
13
|
-
if (Array.isArray(obj)) {
|
|
14
|
-
if (idPaths.includes(currentPath)) return obj.map((item)=>{
|
|
15
|
-
if ('string' == typeof item && isRecordIdFormat(item)) {
|
|
16
|
-
const tableName = extractTableName(item);
|
|
17
|
-
if (tableName) return new RecordId(tableName, item.split(':')[1]);
|
|
18
|
-
}
|
|
19
|
-
return item;
|
|
20
|
-
});
|
|
21
|
-
return obj.map((item, index)=>convertStringsToRecordIds(item, idPaths, `${currentPath}[${index}]`));
|
|
22
|
-
}
|
|
23
|
-
if ('object' == typeof obj && !(obj instanceof Date)) {
|
|
24
|
-
const result = {};
|
|
25
|
-
for (const [key, value] of Object.entries(obj)){
|
|
26
|
-
const fieldPath = currentPath ? `${currentPath}.${key}` : key;
|
|
27
|
-
if ('string' == typeof value) {
|
|
28
|
-
const shouldConvert = idPaths.includes(fieldPath) && isRecordIdFormat(value);
|
|
29
|
-
if (shouldConvert) {
|
|
30
|
-
const tableName = extractTableName(value);
|
|
31
|
-
if (tableName) result[key] = new RecordId(tableName, value.split(':')[1]);
|
|
32
|
-
else result[key] = value;
|
|
33
|
-
} else result[key] = value;
|
|
34
|
-
} else result[key] = convertStringsToRecordIds(value, idPaths, fieldPath);
|
|
35
|
-
}
|
|
36
|
-
return result;
|
|
37
|
-
}
|
|
38
|
-
if ('string' == typeof obj) {
|
|
39
|
-
if (0 === idPaths.length && isRecordIdFormat(obj)) {
|
|
40
|
-
const tableName = extractTableName(obj);
|
|
41
|
-
if (tableName) return new RecordId(tableName, obj.split(':')[1]);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return obj;
|
|
45
|
-
};
|
|
46
|
-
export { deserialize };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
|
|
2
|
-
import { createServerOnlyFn } from "@tanstack/react-start";
|
|
3
|
-
const encryptionFn = createServerOnlyFn((secretHash)=>{
|
|
4
|
-
class Encryption {
|
|
5
|
-
key;
|
|
6
|
-
constructor(secretHash){
|
|
7
|
-
this.key = Buffer.from(secretHash, 'hex');
|
|
8
|
-
}
|
|
9
|
-
encrypt(text) {
|
|
10
|
-
const algorithm = 'aes-256-cbc';
|
|
11
|
-
const iv = randomBytes(16);
|
|
12
|
-
const cipher = createCipheriv(algorithm, this.key, iv);
|
|
13
|
-
let encrypted = cipher.update(text, 'utf8', 'hex');
|
|
14
|
-
encrypted += cipher.final('hex');
|
|
15
|
-
return `${iv.toString('hex')}:${encrypted}`;
|
|
16
|
-
}
|
|
17
|
-
decrypt(encryptedText) {
|
|
18
|
-
const algorithm = 'aes-256-cbc';
|
|
19
|
-
const parts = encryptedText.split(':');
|
|
20
|
-
const iv = Buffer.from(parts[0], 'hex');
|
|
21
|
-
const encrypted = parts[1];
|
|
22
|
-
const decipher = createDecipheriv(algorithm, this.key, iv);
|
|
23
|
-
let decrypted = decipher.update(encrypted, 'hex', 'utf8');
|
|
24
|
-
decrypted += decipher.final('utf8');
|
|
25
|
-
return decrypted;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return new Encryption(secretHash);
|
|
29
|
-
});
|
|
30
|
-
export { encryptionFn };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
const AnimatedChevron = ({ expanded, style, ...props })=>/*#__PURE__*/ jsxs("svg", {
|
|
3
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
4
|
-
width: "24",
|
|
5
|
-
height: "24",
|
|
6
|
-
viewBox: "0 0 24 24",
|
|
7
|
-
fill: "none",
|
|
8
|
-
stroke: "currentColor",
|
|
9
|
-
strokeWidth: "1.5",
|
|
10
|
-
strokeLinecap: "round",
|
|
11
|
-
strokeLinejoin: "round",
|
|
12
|
-
role: "img",
|
|
13
|
-
"aria-label": "Chevron",
|
|
14
|
-
style: {
|
|
15
|
-
transition: 'transform 0.2s ease-in-out',
|
|
16
|
-
transform: expanded ? 'rotate(-180deg)' : 'rotate(0deg)',
|
|
17
|
-
...style
|
|
18
|
-
},
|
|
19
|
-
...props,
|
|
20
|
-
children: [
|
|
21
|
-
/*#__PURE__*/ jsx("path", {
|
|
22
|
-
stroke: "none",
|
|
23
|
-
d: "M0 0h24v24H0z",
|
|
24
|
-
fill: "none"
|
|
25
|
-
}),
|
|
26
|
-
/*#__PURE__*/ jsx("path", {
|
|
27
|
-
d: "M6 9l6 6l6 -6"
|
|
28
|
-
})
|
|
29
|
-
]
|
|
30
|
-
});
|
|
31
|
-
export { AnimatedChevron };
|
package/dist/ui/JsonInput.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
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/getCookie.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 };
|
package/dist/ui/RouterLink.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { ActionIcon, Anchor, Button, UnstyledButton } from "@mantine/core";
|
|
3
|
-
import { createLink } from "@tanstack/react-router";
|
|
4
|
-
import { forwardRef } from "react";
|
|
5
|
-
const MantineLinkComponent = /*#__PURE__*/ forwardRef(({ classNames, ...props }, ref)=>/*#__PURE__*/ jsx(Anchor, {
|
|
6
|
-
ref: ref,
|
|
7
|
-
classNames: {
|
|
8
|
-
root: 'rolder-router-link-root',
|
|
9
|
-
...classNames
|
|
10
|
-
},
|
|
11
|
-
c: "inherit",
|
|
12
|
-
underline: "never",
|
|
13
|
-
...props
|
|
14
|
-
}));
|
|
15
|
-
const MantineButtonComponent = /*#__PURE__*/ forwardRef((props, ref)=>/*#__PURE__*/ jsx(Button, {
|
|
16
|
-
ref: ref,
|
|
17
|
-
...props
|
|
18
|
-
}));
|
|
19
|
-
const MantineActionIconComponent = /*#__PURE__*/ forwardRef((props, ref)=>/*#__PURE__*/ jsx(ActionIcon, {
|
|
20
|
-
ref: ref,
|
|
21
|
-
...props
|
|
22
|
-
}));
|
|
23
|
-
const MantineUnstyledButtonComponent = /*#__PURE__*/ forwardRef((props, ref)=>/*#__PURE__*/ jsx(UnstyledButton, {
|
|
24
|
-
ref: ref,
|
|
25
|
-
...props
|
|
26
|
-
}));
|
|
27
|
-
const RouterLinkBase = createLink(MantineLinkComponent);
|
|
28
|
-
const RouterLinkButton = createLink(MantineButtonComponent);
|
|
29
|
-
const RouterLinkActionIcon = createLink(MantineActionIconComponent);
|
|
30
|
-
const RouterLinkUnstyledButton = createLink(MantineUnstyledButtonComponent);
|
|
31
|
-
const RouterLink = Object.assign(RouterLinkBase, {
|
|
32
|
-
Button: RouterLinkButton,
|
|
33
|
-
ActionIcon: RouterLinkActionIcon,
|
|
34
|
-
UnstyledButton: RouterLinkUnstyledButton
|
|
35
|
-
});
|
|
36
|
-
export { RouterLink };
|
|
@@ -1,13 +0,0 @@
|
|
|
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 };
|
|
@@ -1,80 +0,0 @@
|
|
|
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 };
|
package/dist/ui/editor/Root.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { RichTextEditor } from "@mantine/tiptap";
|
|
3
|
-
import { useEditor } from "./Provider.js";
|
|
4
|
-
const Root = ({ children, classNames, ...props })=>{
|
|
5
|
-
const { editor } = useEditor();
|
|
6
|
-
return /*#__PURE__*/ jsx(RichTextEditor, {
|
|
7
|
-
editor: editor,
|
|
8
|
-
classNames: {
|
|
9
|
-
root: 'rolder-editor-root',
|
|
10
|
-
content: 'rolder-editor-content',
|
|
11
|
-
toolbar: 'rolder-editor-toolbar',
|
|
12
|
-
...classNames
|
|
13
|
-
},
|
|
14
|
-
...props,
|
|
15
|
-
children: children
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
export { Root };
|