@examplary/ui 1.0.0 → 1.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/dist/components/rich-text/index.d.ts +1 -1
- package/dist/components/rich-text/index.js +1 -1
- package/dist/components/rich-text/minimal-rich-text-field.d.ts +1 -2
- package/dist/components/rich-text/minimal-rich-text-field.js +21 -4
- package/dist/components/rich-text/rich-text-field.d.ts +2 -0
- package/dist/components/rich-text/{rich-text-input.js → rich-text-field.js} +4 -6
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/types/frontend-components.d.ts +27 -0
- package/dist/types/frontend-components.js +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/package.json +5 -1
- package/dist/components/rich-text/rich-text-input.d.ts +0 -14
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { RichTextDisplay } from "./rich-text-display";
|
|
2
|
-
export {
|
|
2
|
+
export { RichTextField } from "./rich-text-field";
|
|
3
3
|
export { RichTextToolbar } from "./rich-text-toolbar";
|
|
4
4
|
export { MinimalRichTextField } from "./minimal-rich-text-field";
|
|
5
5
|
export { processFilesAsString } from "./tiptap/file-handler";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { RichTextDisplay } from "./rich-text-display";
|
|
2
|
-
export {
|
|
2
|
+
export { RichTextField } from "./rich-text-field";
|
|
3
3
|
export { RichTextToolbar } from "./rich-text-toolbar";
|
|
4
4
|
export { MinimalRichTextField } from "./minimal-rich-text-field";
|
|
5
5
|
export { processFilesAsString } from "./tiptap/file-handler";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { EditorContentProps } from "@tiptap/react";
|
|
2
2
|
export type MinimalRichTextFieldProps = {
|
|
3
3
|
className?: string;
|
|
4
|
-
editorClassName?: string;
|
|
5
4
|
value?: string;
|
|
6
5
|
placeholder?: string;
|
|
7
6
|
onChange?: (value: string) => void;
|
|
@@ -14,4 +13,4 @@ export type MinimalRichTextFieldProps = {
|
|
|
14
13
|
name: string;
|
|
15
14
|
}>;
|
|
16
15
|
} & Omit<EditorContentProps, "editor">;
|
|
17
|
-
export declare const MinimalRichTextField: ({ className,
|
|
16
|
+
export declare const MinimalRichTextField: ({ className, value, placeholder, onChange, slotBefore, singleLine, autoFocus, showFormattingMenu, uploadFile, ...props }: MinimalRichTextFieldProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -48,9 +48,25 @@ import Image from "./tiptap/image";
|
|
|
48
48
|
import PageClipping from "./tiptap/page-clipping";
|
|
49
49
|
import { RichTextFormattingMenu } from "./tiptap/rich-text-formatting-menu";
|
|
50
50
|
registerWebComponents();
|
|
51
|
+
var isEmpty = function (value) {
|
|
52
|
+
var _a;
|
|
53
|
+
if (!value) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
if (!((_a = value.trim) === null || _a === void 0 ? void 0 : _a.call(value))) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
if (value.trim() === "<p></p>" || value.trim() === "<p><br></p>") {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
if (value.trim() === "<p> </p>" || value.trim() === "<p></p><p></p>") {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
66
|
+
};
|
|
51
67
|
export var MinimalRichTextField = function (_a) {
|
|
52
|
-
var _b = _a.className, className = _b === void 0 ? "" : _b, _c = _a.
|
|
53
|
-
var
|
|
68
|
+
var _b = _a.className, className = _b === void 0 ? "" : _b, _c = _a.value, value = _c === void 0 ? "" : _c, _d = _a.placeholder, placeholder = _d === void 0 ? "" : _d, onChange = _a.onChange, slotBefore = _a.slotBefore, _e = _a.singleLine, singleLine = _e === void 0 ? false : _e, _f = _a.autoFocus, autoFocus = _f === void 0 ? false : _f, _g = _a.showFormattingMenu, showFormattingMenu = _g === void 0 ? false : _g, _h = _a.uploadFile, uploadFile = _h === void 0 ? undefined : _h, props = __rest(_a, ["className", "value", "placeholder", "onChange", "slotBefore", "singleLine", "autoFocus", "showFormattingMenu", "uploadFile"]);
|
|
69
|
+
var _j = useState(value), content = _j[0], setContent = _j[1];
|
|
54
70
|
var extensions = useMemo(function () {
|
|
55
71
|
return __spreadArray(__spreadArray([], (singleLine
|
|
56
72
|
? [
|
|
@@ -80,6 +96,7 @@ export var MinimalRichTextField = function (_a) {
|
|
|
80
96
|
onUpdate: function (_a) {
|
|
81
97
|
var editor = _a.editor;
|
|
82
98
|
var html = editor.getHTML();
|
|
99
|
+
html = isEmpty(html) ? "" : html;
|
|
83
100
|
setContent(html);
|
|
84
101
|
onChange === null || onChange === void 0 ? void 0 : onChange(html);
|
|
85
102
|
},
|
|
@@ -91,7 +108,7 @@ export var MinimalRichTextField = function (_a) {
|
|
|
91
108
|
extensions: extensions,
|
|
92
109
|
editorProps: {
|
|
93
110
|
attributes: {
|
|
94
|
-
class:
|
|
111
|
+
class: cn("max-w-none", className),
|
|
95
112
|
},
|
|
96
113
|
},
|
|
97
114
|
});
|
|
@@ -106,5 +123,5 @@ export var MinimalRichTextField = function (_a) {
|
|
|
106
123
|
});
|
|
107
124
|
}
|
|
108
125
|
}, [value, content, editor]);
|
|
109
|
-
return (_jsxs(_Fragment, { children: [slotBefore ? slotBefore(editor) : null, showFormattingMenu && _jsx(RichTextFormattingMenu, { editor: editor }), _jsx(
|
|
126
|
+
return (_jsxs(_Fragment, { children: [slotBefore ? slotBefore(editor) : null, showFormattingMenu && _jsx(RichTextFormattingMenu, { editor: editor }), _jsx(EditorContent, __assign({ editor: editor }, props))] }));
|
|
110
127
|
};
|
|
@@ -20,12 +20,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
}
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
|
-
import { jsx as _jsx
|
|
24
|
-
import { useState } from "react";
|
|
23
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
25
24
|
import { MinimalRichTextField, } from "./minimal-rich-text-field";
|
|
26
25
|
import { cn } from "../../utils";
|
|
27
|
-
export var
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
return (_jsxs(_Fragment, { children: [_jsx("input", { type: "hidden", name: name, value: value }), _jsx(MinimalRichTextField, __assign({ className: cn("rounded-base border-2 text-sm font-base bg-white", "ring-offset-white focus-within:outline-none focus-within:ring-2 focus-within:ring-black focus-within:ring-offset-2", disabled && "opacity-50 pointer-events-none", className), editorClassName: "px-3 py-2", value: value, onChange: setValue }, props))] }));
|
|
26
|
+
export var RichTextField = function (_a) {
|
|
27
|
+
var singleLine = _a.singleLine, className = _a.className, props = __rest(_a, ["singleLine", "className"]);
|
|
28
|
+
return (_jsx(MinimalRichTextField, __assign({ singleLine: singleLine, className: cn("box p-3 text-sm", !singleLine && "min-h-16", className) }, props)));
|
|
31
29
|
};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type ComponentType } from "react";
|
|
2
|
+
type Answer = {
|
|
3
|
+
value: string | string[];
|
|
4
|
+
completed?: boolean;
|
|
5
|
+
context?: any;
|
|
6
|
+
};
|
|
7
|
+
export type FrontendQuestionComponent = ComponentType<{
|
|
8
|
+
question: any;
|
|
9
|
+
isPreview: boolean;
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
answer?: Answer;
|
|
12
|
+
saveAnswer: (answer: Answer) => Promise<void>;
|
|
13
|
+
}>;
|
|
14
|
+
export type FrontendPrintComponent = ComponentType<{
|
|
15
|
+
question: any;
|
|
16
|
+
answerBoxes: boolean;
|
|
17
|
+
}>;
|
|
18
|
+
export type FrontendResultsComponent = ComponentType<{
|
|
19
|
+
question: any;
|
|
20
|
+
answer: Answer;
|
|
21
|
+
}>;
|
|
22
|
+
export type FrontendQuestionSettingsAreaComponent = ComponentType<{
|
|
23
|
+
question: any;
|
|
24
|
+
value: any;
|
|
25
|
+
onChange: (value: any) => void;
|
|
26
|
+
}>;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./frontend-components";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./frontend-components";
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@examplary/ui",
|
|
3
3
|
"description": "UI components for the Examplary testing platform.",
|
|
4
4
|
"packageManager": "yarn@4.5.3",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"files": [
|
|
@@ -33,6 +33,10 @@
|
|
|
33
33
|
"tailwind-merge": "^3.3.1",
|
|
34
34
|
"tailwindcss-animate": "^1.0.7"
|
|
35
35
|
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"react": ">=18.0.0",
|
|
38
|
+
"react-dom": ">=18.0.0"
|
|
39
|
+
},
|
|
36
40
|
"devDependencies": {
|
|
37
41
|
"typescript": "^5.8.3"
|
|
38
42
|
},
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { MinimalRichTextFieldProps } from "./minimal-rich-text-field";
|
|
2
|
-
export type RichTextInputProps = {
|
|
3
|
-
name: string;
|
|
4
|
-
defaultValue?: string;
|
|
5
|
-
className?: string;
|
|
6
|
-
disabled?: boolean;
|
|
7
|
-
} & MinimalRichTextFieldProps;
|
|
8
|
-
export declare const RichTextInput: ({ name, defaultValue, className, disabled, ...props }: {
|
|
9
|
-
[x: string]: any;
|
|
10
|
-
name: any;
|
|
11
|
-
defaultValue: any;
|
|
12
|
-
className?: string;
|
|
13
|
-
disabled?: boolean;
|
|
14
|
-
}) => import("react/jsx-runtime").JSX.Element;
|