@examplary/ui 1.4.0 → 1.5.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 (31) hide show
  1. package/dist/components/chat/chat-input.d.ts +7 -0
  2. package/dist/components/chat/chat-input.js +50 -0
  3. package/dist/components/chat/chat-typing-indicator.d.ts +1 -0
  4. package/dist/components/chat/chat-typing-indicator.js +5 -0
  5. package/dist/components/chat/chat-view.d.ts +7 -0
  6. package/dist/components/chat/chat-view.js +38 -0
  7. package/dist/components/chat/index.d.ts +3 -0
  8. package/dist/components/chat/index.js +3 -0
  9. package/dist/components/question-types/fetch-component.d.ts +2 -0
  10. package/dist/components/question-types/fetch-component.js +88 -0
  11. package/dist/components/question-types/format-question-type.d.ts +49 -0
  12. package/dist/components/question-types/format-question-type.js +60 -0
  13. package/dist/components/question-types/index.d.ts +2 -0
  14. package/dist/components/question-types/index.js +2 -0
  15. package/dist/components/rich-text/minimal-rich-text-field.d.ts +2 -1
  16. package/dist/components/rich-text/minimal-rich-text-field.js +2 -1
  17. package/dist/components/ui/index.d.ts +4 -0
  18. package/dist/components/ui/index.js +4 -0
  19. package/dist/components/ui/input.d.ts +4 -0
  20. package/dist/components/ui/input.js +31 -0
  21. package/dist/components/ui/label.d.ts +5 -0
  22. package/dist/components/ui/label.js +35 -0
  23. package/dist/components/ui/radio-group.d.ts +5 -0
  24. package/dist/components/ui/radio-group.js +39 -0
  25. package/dist/components/ui/select.d.ts +13 -0
  26. package/dist/components/ui/select.js +69 -0
  27. package/dist/index.d.ts +3 -0
  28. package/dist/index.js +3 -0
  29. package/dist/types/frontend-components.d.ts +2 -2
  30. package/package.json +11 -4
  31. package/src/global.css +73 -0
@@ -0,0 +1,7 @@
1
+ export declare const ChatInput: ({ loading, autoFocus, submit, placeholder, ...props }: {
2
+ [x: string]: any;
3
+ loading?: boolean;
4
+ autoFocus?: boolean;
5
+ submit: any;
6
+ placeholder?: string;
7
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,50 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
+ import { useState } from "react";
25
+ import { SendHorizontalIcon } from "lucide-react";
26
+ import { cn } from "../../utils";
27
+ export var ChatInput = function (_a) {
28
+ var _b = _a.loading, loading = _b === void 0 ? false : _b, _c = _a.autoFocus, autoFocus = _c === void 0 ? true : _c, submit = _a.submit, _d = _a.placeholder, placeholder = _d === void 0 ? "" : _d, props = __rest(_a, ["loading", "autoFocus", "submit", "placeholder"]);
29
+ var _e = useState(""), value = _e[0], setValue = _e[1];
30
+ return (_jsxs("div", { className: cn("rounded-[26px]! w-full text-sm mt-2 box flex justify-between items-end", loading ? "bg-gray-100 cursor-not-allowed" : "bg-white"), children: [_jsx("textarea", __assign({ disabled: loading, autoFocus: autoFocus, className: "pl-5.5 pr-2 py-3.5 text-sm flex-1 resize-none outline-0 h-[3rem]", placeholder: placeholder, value: value, onChange: function (e) { return setValue(e.target.value); }, onInput: function (e) {
31
+ var el = e.target;
32
+ if (el.value.trim().length) {
33
+ el.style.height = "".concat(el.scrollHeight, "px");
34
+ }
35
+ else {
36
+ el.style.height = "3rem";
37
+ }
38
+ }, onKeyDown: function (e) {
39
+ if (e.key === "Enter" && !e.shiftKey) {
40
+ e.preventDefault();
41
+ submit(value.trim());
42
+ setValue("");
43
+ }
44
+ } }, props), "input"), _jsx("button", { className: cn("border-2 bg-green-400 flex items-center justify-center rounded-full size-10 m-1", loading ? "cursor-not-allowed" : "hover:bg-green-600 cursor-pointer"), onClick: function () {
45
+ if (loading || !value.trim())
46
+ return;
47
+ submit(value.trim());
48
+ setValue("");
49
+ }, disabled: loading, title: "Send", children: _jsx(SendHorizontalIcon, { className: "size-5" }) })] }));
50
+ };
@@ -0,0 +1 @@
1
+ export declare const ChatTypingIndicator: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cn } from "../../utils";
3
+ export var ChatTypingIndicator = function () {
4
+ return (_jsx("div", { className: cn("flex gap-2 text-sm", "max-w-2xl border-2 rounded-4xl px-4 py-2", "bg-pink-200 rounded-tl-sm"), children: _jsxs("div", { className: "flex items-center gap-1 py-2", children: [_jsx("div", { className: "size-1.5 bg-current rounded-full animate-bounce" }), _jsx("div", { className: "size-1.5 bg-current rounded-full animate-bounce" }), _jsx("div", { className: "size-1.5 bg-current rounded-full animate-bounce" })] }) }));
5
+ };
@@ -0,0 +1,7 @@
1
+ export declare const ChatView: ({ messages, typing, showTeacherContext, className, ...props }: {
2
+ [x: string]: any;
3
+ messages: any;
4
+ typing?: boolean;
5
+ showTeacherContext?: boolean;
6
+ className?: string;
7
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,38 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
24
+ import { CheckCircle2Icon, SparkleIcon } from "lucide-react";
25
+ import { ChatTypingIndicator } from "./chat-typing-indicator";
26
+ import { cn } from "../../utils";
27
+ import { RichTextDisplay } from "../rich-text/rich-text-display";
28
+ export var ChatView = function (_a) {
29
+ var messages = _a.messages, _b = _a.typing, typing = _b === void 0 ? false : _b, _c = _a.showTeacherContext, showTeacherContext = _c === void 0 ? false : _c, _d = _a.className, className = _d === void 0 ? "" : _d, props = __rest(_a, ["messages", "typing", "showTeacherContext", "className"]);
30
+ return (_jsxs("div", __assign({ className: cn("flex flex-col gap-2 items-start", className) }, props, { children: [messages
31
+ .filter(function (_a) {
32
+ var role = _a.role;
33
+ return role !== "system";
34
+ })
35
+ .map(function (item, index) { return (_jsxs(_Fragment, { children: [_jsx("div", { className: cn("flex gap-2 text-sm", "max-w-[85%] border-2 rounded-3xl px-4 py-3", item.role === "user"
36
+ ? "bg-white ml-auto rounded-tr-sm"
37
+ : "bg-pink-200 rounded-tl-sm"), children: _jsx(RichTextDisplay, { children: item.content }) }, index), showTeacherContext && item.reason ? (_jsxs("div", { className: cn("text-xs text-gray-500 mb-1 max-w-[85%]"), children: [_jsx(SparkleIcon, { className: "size-3 -mt-0.5 inline-block mr-1", strokeWidth: 2.5 }), _jsx("span", { className: "font-semibold", children: "Reasoning:" }), " ", item.reason] }, "reason-".concat(index))) : null, showTeacherContext && item.completed && item.completionReason ? (_jsxs("div", { className: cn("text-xs text-gray-500 mb-1 max-w-[85%]"), children: [_jsxs("span", { className: "font-semibold text-emerald-600", children: [_jsx(CheckCircle2Icon, { className: "size-3 -mt-0.5 inline-block mr-1", strokeWidth: 2.6 }), "Completion reasoning:"] }), " ", item.completionReason] }, "reason-".concat(index))) : null] })); }), typing && _jsx(ChatTypingIndicator, {})] })));
38
+ };
@@ -0,0 +1,3 @@
1
+ export * from "./chat-input";
2
+ export * from "./chat-view";
3
+ export * from "./chat-typing-indicator";
@@ -0,0 +1,3 @@
1
+ export * from "./chat-input";
2
+ export * from "./chat-view";
3
+ export * from "./chat-typing-indicator";
@@ -0,0 +1,2 @@
1
+ import { ComponentType } from "react";
2
+ export declare const fetchComponent: (url: any) => Promise<ComponentType>;
@@ -0,0 +1,88 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import * as _React from "react";
38
+ import * as ExamplaryUI from "../../index";
39
+ var componentCache = new Map();
40
+ // Little helper to evaluate the JS code in the context of the module
41
+ var evalInScope = function (js, contextAsScope) {
42
+ return new Function("with (this) { ".concat(js, " }")).call(contextAsScope);
43
+ };
44
+ export var fetchComponent = function (url) { return __awaiter(void 0, void 0, void 0, function () {
45
+ var js, _componentResult;
46
+ return __generator(this, function (_a) {
47
+ switch (_a.label) {
48
+ case 0:
49
+ if (componentCache.has(url)) {
50
+ return [2 /*return*/, componentCache.get(url)];
51
+ }
52
+ return [4 /*yield*/, fetch(url).then(function (res) { return res.text(); })];
53
+ case 1:
54
+ js = _a.sent();
55
+ (function () {
56
+ var _a;
57
+ try {
58
+ var module_1 = { exports: { default: null } };
59
+ var require_1 = function (name) {
60
+ if (name === "react")
61
+ return _React;
62
+ if (name === "@examplary/ui")
63
+ return ExamplaryUI;
64
+ throw new Error("Module not found: ".concat(name));
65
+ };
66
+ evalInScope(js, {
67
+ module: module_1,
68
+ exports: module_1.exports,
69
+ React: _React,
70
+ require: require_1,
71
+ __dirname: "/web/task",
72
+ __filename: "dynamic-module.js",
73
+ });
74
+ _componentResult = (_a = module_1.exports) === null || _a === void 0 ? void 0 : _a.default;
75
+ if (!_componentResult) {
76
+ throw new Error("No default export found in the module");
77
+ }
78
+ }
79
+ catch (e) {
80
+ console.error(e);
81
+ throw new Error("Failed to evaluate component: ".concat(e.message));
82
+ }
83
+ })();
84
+ componentCache.set(url, _componentResult);
85
+ return [2 /*return*/, _componentResult];
86
+ }
87
+ });
88
+ }); };
@@ -0,0 +1,49 @@
1
+ import type { QuestionType } from "@examplary/schemas";
2
+ export declare const formatQuestionType: (type: QuestionType, i18n: any) => {
3
+ translationNs: string;
4
+ name: any;
5
+ description: any;
6
+ enforceTitle: any;
7
+ titlePlaceholder: any;
8
+ descriptionPlaceholder: any;
9
+ untitledPlaceholder: any;
10
+ settings: {
11
+ name: any;
12
+ placeholder: any;
13
+ options: {
14
+ label: any;
15
+ value: string;
16
+ }[];
17
+ id: string;
18
+ type: "string" | "number" | "boolean" | "enum" | "custom" | "scoring-criteria" | "question-type";
19
+ default?: any;
20
+ required?: boolean;
21
+ step?: number;
22
+ min?: number;
23
+ max?: number;
24
+ }[];
25
+ id: string;
26
+ $schema?: string;
27
+ icon?: string;
28
+ shortcut?: string;
29
+ canAutoGenerate?: boolean;
30
+ timeEstimateMinutes?: number;
31
+ isAi?: boolean;
32
+ backgroundColor?: string;
33
+ iconBackgroundColor?: string;
34
+ enforcePosition?: "end" | "start";
35
+ hideSettings?: boolean;
36
+ isPreviewRefreshable?: boolean;
37
+ hasSimpleScoring?: boolean;
38
+ components?: {
39
+ assessment?: string;
40
+ print?: string;
41
+ "settings-area"?: string;
42
+ results?: string;
43
+ };
44
+ public?: boolean;
45
+ translations?: Record<string, string | Record<string, string>>;
46
+ stylesheet?: string;
47
+ index?: number;
48
+ };
49
+ export type FormattedQuestionType = ReturnType<typeof formatQuestionType>;
@@ -0,0 +1,60 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ export var formatQuestionType = function (type, i18n) {
13
+ var _a, _b;
14
+ var locale = i18n.language;
15
+ var translationNs = "question_type_".concat(type.id);
16
+ var t = i18n.getFixedT(locale, translationNs);
17
+ // Load the translations for the question type
18
+ var resources = {};
19
+ var extractTranslations = function (key, obj) {
20
+ if (!obj)
21
+ return;
22
+ if (typeof obj === "string") {
23
+ resources[locale][key] = obj;
24
+ }
25
+ else if (typeof obj === "object") {
26
+ Object.entries(obj).forEach(function (_a) {
27
+ var lang = _a[0], value = _a[1];
28
+ if (!resources[lang])
29
+ resources[lang] = {};
30
+ resources[lang][key] = value;
31
+ });
32
+ }
33
+ };
34
+ extractTranslations("name", type.name);
35
+ extractTranslations("description", type.description);
36
+ extractTranslations("enforceTitle", type.enforceTitle);
37
+ extractTranslations("titlePlaceholder", type.titlePlaceholder);
38
+ extractTranslations("descriptionPlaceholder", type.descriptionPlaceholder);
39
+ extractTranslations("untitledPlaceholder", type.untitledPlaceholder);
40
+ (_a = type.settings) === null || _a === void 0 ? void 0 : _a.forEach(function (setting) {
41
+ var _a;
42
+ extractTranslations("settings.".concat(setting.id, ".name"), setting.name);
43
+ extractTranslations("settings.".concat(setting.id, ".placeholder"), setting.placeholder);
44
+ (_a = setting.options) === null || _a === void 0 ? void 0 : _a.forEach(function (option) {
45
+ extractTranslations("settings.".concat(setting.id, ".options.").concat(option.value), option.label);
46
+ });
47
+ });
48
+ Object.entries((type === null || type === void 0 ? void 0 : type.translations) || {}).forEach(function (_a) {
49
+ var key = _a[0], value = _a[1];
50
+ return extractTranslations(key, value);
51
+ });
52
+ for (var lang in resources) {
53
+ i18n.addResources(lang, translationNs, resources[lang]);
54
+ }
55
+ i18n.addResources("blorg", "test", { a: "b" });
56
+ return __assign(__assign({}, type), { translationNs: translationNs, name: type.name && t("name"), description: type.description && t("description"), enforceTitle: type.enforceTitle && t("enforceTitle"), titlePlaceholder: type.titlePlaceholder && t("titlePlaceholder"), descriptionPlaceholder: type.descriptionPlaceholder && t("descriptionPlaceholder"), untitledPlaceholder: type.untitledPlaceholder && t("untitledPlaceholder"), settings: (_b = type.settings) === null || _b === void 0 ? void 0 : _b.map(function (setting) {
57
+ var _a;
58
+ return (__assign(__assign({}, setting), { name: setting.name && t("settings.".concat(setting.id, ".name")), placeholder: setting.placeholder && t("settings.".concat(setting.id, ".placeholder")), options: (_a = setting.options) === null || _a === void 0 ? void 0 : _a.map(function (option) { return (__assign(__assign({}, option), { label: option.label && t("settings.".concat(setting.id, ".options.").concat(option.value)) })); }) }));
59
+ }) });
60
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./fetch-component";
2
+ export * from "./format-question-type";
@@ -0,0 +1,2 @@
1
+ export * from "./fetch-component";
2
+ export * from "./format-question-type";
@@ -3,6 +3,7 @@ export type MinimalRichTextFieldProps = {
3
3
  className?: string;
4
4
  value?: string;
5
5
  placeholder?: string;
6
+ style?: string;
6
7
  onChange?: (value: string) => void;
7
8
  slotBefore?: (editor: any) => React.ReactNode;
8
9
  singleLine?: boolean;
@@ -13,4 +14,4 @@ export type MinimalRichTextFieldProps = {
13
14
  name: string;
14
15
  }>;
15
16
  } & Omit<EditorContentProps, "editor">;
16
- export declare const MinimalRichTextField: ({ className, value, placeholder, onChange, slotBefore, singleLine, autoFocus, showFormattingMenu, uploadFile, ...props }: MinimalRichTextFieldProps) => import("react/jsx-runtime").JSX.Element;
17
+ export declare const MinimalRichTextField: ({ className, value, placeholder, onChange, slotBefore, style, singleLine, autoFocus, showFormattingMenu, uploadFile, ...props }: MinimalRichTextFieldProps) => import("react/jsx-runtime").JSX.Element;
@@ -65,7 +65,7 @@ var isEmpty = function (value) {
65
65
  return false;
66
66
  };
67
67
  export var MinimalRichTextField = function (_a) {
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"]);
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, style = _a.style, _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", "style", "singleLine", "autoFocus", "showFormattingMenu", "uploadFile"]);
69
69
  var _j = useState(value), content = _j[0], setContent = _j[1];
70
70
  var extensions = useMemo(function () {
71
71
  return __spreadArray(__spreadArray([], (singleLine
@@ -109,6 +109,7 @@ export var MinimalRichTextField = function (_a) {
109
109
  editorProps: {
110
110
  attributes: {
111
111
  class: cn("max-w-none", className),
112
+ style: style,
112
113
  },
113
114
  },
114
115
  });
@@ -0,0 +1,4 @@
1
+ export * from "./select";
2
+ export * from "./input";
3
+ export * from "./radio-group";
4
+ export * from "./label";
@@ -0,0 +1,4 @@
1
+ export * from "./select";
2
+ export * from "./input";
3
+ export * from "./radio-group";
4
+ export * from "./label";
@@ -0,0 +1,4 @@
1
+ import * as React from "react";
2
+ export type InputProps = React.InputHTMLAttributes<HTMLInputElement>;
3
+ declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
4
+ export { Input };
@@ -0,0 +1,31 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import { jsx as _jsx } from "react/jsx-runtime";
24
+ import * as React from "react";
25
+ import { cn } from "../../utils";
26
+ var Input = React.forwardRef(function (_a, ref) {
27
+ var className = _a.className, type = _a.type, props = __rest(_a, ["className", "type"]);
28
+ return (_jsx("input", __assign({ type: type, className: cn("flex h-10 w-full rounded-base border-2 text-text dark:text-darkText font-base selection:bg-main selection:text-text border-border dark:border-darkBorder bg-white dark:bg-secondaryBlack px-3 py-2 text-sm ring-offset-white file:border-0 file:bg-transparent file:text-sm file:font-base focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-black focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50", className), ref: ref }, props)));
29
+ });
30
+ Input.displayName = "Input";
31
+ export { Input };
@@ -0,0 +1,5 @@
1
+ import * as React from "react";
2
+ import * as LabelPrimitive from "@radix-ui/react-label";
3
+ import { type VariantProps } from "class-variance-authority";
4
+ declare const Label: React.ForwardRefExoticComponent<Omit<LabelPrimitive.LabelProps & React.RefAttributes<HTMLLabelElement>, "ref"> & VariantProps<(props?: import("class-variance-authority/types").ClassProp) => string> & React.RefAttributes<HTMLLabelElement>>;
5
+ export { Label };
@@ -0,0 +1,35 @@
1
+ "use client";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
24
+ import { jsx as _jsx } from "react/jsx-runtime";
25
+ import * as React from "react";
26
+ import * as LabelPrimitive from "@radix-ui/react-label";
27
+ import { cva } from "class-variance-authority";
28
+ import { cn } from "../../utils";
29
+ var labelVariants = cva("block text-sm font-heading font-semibold leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 mb-3");
30
+ var Label = React.forwardRef(function (_a, ref) {
31
+ var className = _a.className, props = __rest(_a, ["className"]);
32
+ return (_jsx(LabelPrimitive.Root, __assign({ ref: ref, className: cn(labelVariants(), className) }, props)));
33
+ });
34
+ Label.displayName = LabelPrimitive.Root.displayName;
35
+ export { Label };
@@ -0,0 +1,5 @@
1
+ import * as React from "react";
2
+ import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
3
+ declare const RadioGroup: React.ForwardRefExoticComponent<Omit<RadioGroupPrimitive.RadioGroupProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
4
+ declare const RadioGroupItem: React.ForwardRefExoticComponent<Omit<RadioGroupPrimitive.RadioGroupItemProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
5
+ export { RadioGroup, RadioGroupItem };
@@ -0,0 +1,39 @@
1
+ "use client";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
24
+ import { jsx as _jsx } from "react/jsx-runtime";
25
+ import * as React from "react";
26
+ import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
27
+ import { Circle } from "lucide-react";
28
+ import { cn } from "../../utils";
29
+ var RadioGroup = React.forwardRef(function (_a, ref) {
30
+ var className = _a.className, props = __rest(_a, ["className"]);
31
+ return (_jsx(RadioGroupPrimitive.Root, __assign({ className: cn("grid gap-2", className) }, props, { ref: ref })));
32
+ });
33
+ RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;
34
+ var RadioGroupItem = React.forwardRef(function (_a, ref) {
35
+ var className = _a.className, props = __rest(_a, ["className"]);
36
+ return (_jsx(RadioGroupPrimitive.Item, __assign({ ref: ref, className: cn("aspect-square h-5 w-5 rounded-full border-2 border-border dark:border-darkBorder text-text dark:text-darkText ring-offset-white focus:outline-none focus-visible:ring-2 focus-visible:ring-black focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:text-zinc-400", className) }, props, { children: _jsx(RadioGroupPrimitive.Indicator, { className: "flex items-center justify-center", children: _jsx(Circle, { className: "h-3 w-3 fill-current text-current" }) }) })));
37
+ });
38
+ RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
39
+ export { RadioGroup, RadioGroupItem };
@@ -0,0 +1,13 @@
1
+ import * as React from "react";
2
+ import * as SelectPrimitive from "@radix-ui/react-select";
3
+ declare const Select: React.FC<SelectPrimitive.SelectProps>;
4
+ declare const SelectGroup: React.ForwardRefExoticComponent<SelectPrimitive.SelectGroupProps & React.RefAttributes<HTMLDivElement>>;
5
+ declare const SelectValue: React.ForwardRefExoticComponent<SelectPrimitive.SelectValueProps & React.RefAttributes<HTMLSpanElement>>;
6
+ declare const SelectTrigger: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectTriggerProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
7
+ declare const SelectScrollUpButton: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectScrollUpButtonProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
8
+ declare const SelectScrollDownButton: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectScrollDownButtonProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
9
+ declare const SelectContent: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
10
+ declare const SelectLabel: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectLabelProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
11
+ declare const SelectItem: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectItemProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
12
+ declare const SelectSeparator: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectSeparatorProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
13
+ export { Select, SelectGroup, SelectValue, SelectTrigger, SelectContent, SelectLabel, SelectItem, SelectSeparator, SelectScrollUpButton, SelectScrollDownButton, };
@@ -0,0 +1,69 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
+ import * as React from "react";
25
+ import * as SelectPrimitive from "@radix-ui/react-select";
26
+ import { Check, ChevronDown, ChevronUp } from "lucide-react";
27
+ import { cn } from "../../utils";
28
+ var Select = SelectPrimitive.Root;
29
+ var SelectGroup = SelectPrimitive.Group;
30
+ var SelectValue = SelectPrimitive.Value;
31
+ var SelectTrigger = React.forwardRef(function (_a, ref) {
32
+ var className = _a.className, children = _a.children, props = __rest(_a, ["className", "children"]);
33
+ return (_jsxs(SelectPrimitive.Trigger, __assign({ ref: ref, className: cn("flex h-10 w-full items-center text-mtext bg-white justify-between rounded-base border-2 px-3 py-2 text-sm font-base ring-offset-white placeholder:text-mtext placeholder:opacity-50 focus:outline-none focus:ring-2 focus:ring-black focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1 border-neutral-800", className) }, props, { children: [children, _jsx(SelectPrimitive.Icon, { asChild: true, children: _jsx(ChevronDown, { className: "h-4 w-4" }) })] })));
34
+ });
35
+ SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
36
+ var SelectScrollUpButton = React.forwardRef(function (_a, ref) {
37
+ var className = _a.className, props = __rest(_a, ["className"]);
38
+ return (_jsx(SelectPrimitive.ScrollUpButton, __assign({ ref: ref, className: cn("flex cursor-default text-mtext items-center justify-center py-1", className) }, props, { children: _jsx(ChevronUp, { className: "h-4 w-4" }) })));
39
+ });
40
+ SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
41
+ var SelectScrollDownButton = React.forwardRef(function (_a, ref) {
42
+ var className = _a.className, props = __rest(_a, ["className"]);
43
+ return (_jsx(SelectPrimitive.ScrollDownButton, __assign({ ref: ref, className: cn("flex cursor-default text-mtext items-center justify-center py-1 font-base", className) }, props, { children: _jsx(ChevronDown, { className: "h-4 w-4" }) })));
44
+ });
45
+ SelectScrollDownButton.displayName =
46
+ SelectPrimitive.ScrollDownButton.displayName;
47
+ var SelectContent = React.forwardRef(function (_a, ref) {
48
+ var className = _a.className, children = _a.children, _b = _a.position, position = _b === void 0 ? "popper" : _b, props = __rest(_a, ["className", "children", "position"]);
49
+ return (_jsx(SelectPrimitive.Portal, { children: _jsxs(SelectPrimitive.Content, __assign({ ref: ref, className: cn("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-base border-2 bg-white font-base text-mtext data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 border-neutral-800", position === "popper" &&
50
+ "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1", className), position: position }, props, { children: [_jsx(SelectScrollUpButton, {}), _jsx(SelectPrimitive.Viewport, { className: cn("p-1", position === "popper" &&
51
+ "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"), children: children }), _jsx(SelectScrollDownButton, {})] })) }));
52
+ });
53
+ SelectContent.displayName = SelectPrimitive.Content.displayName;
54
+ var SelectLabel = React.forwardRef(function (_a, ref) {
55
+ var className = _a.className, props = __rest(_a, ["className"]);
56
+ return (_jsx(SelectPrimitive.Label, __assign({ ref: ref, className: cn("border-2 border-transparent py-1.5 pl-8 pr-2 text-sm font-base text-mtext/80", className) }, props)));
57
+ });
58
+ SelectLabel.displayName = SelectPrimitive.Label.displayName;
59
+ var SelectItem = React.forwardRef(function (_a, ref) {
60
+ var className = _a.className, children = _a.children, props = __rest(_a, ["className", "children"]);
61
+ return (_jsxs(SelectPrimitive.Item, __assign({ ref: ref, className: cn("relative flex w-full text-mtext cursor-default select-none items-center rounded-base border-2 border-transparent py-1.5 pl-8 pr-2 text-sm font-base outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:border-neutral-800", className) }, props, { children: [_jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: _jsx(SelectPrimitive.ItemIndicator, { children: _jsx(Check, { className: "h-4 w-4" }) }) }), _jsx(SelectPrimitive.ItemText, { children: children })] })));
62
+ });
63
+ SelectItem.displayName = SelectPrimitive.Item.displayName;
64
+ var SelectSeparator = React.forwardRef(function (_a, ref) {
65
+ var className = _a.className, props = __rest(_a, ["className"]);
66
+ return (_jsx(SelectPrimitive.Separator, __assign({ ref: ref, className: cn("-mx-1 my-1 h-px bg-neutral-800", className) }, props)));
67
+ });
68
+ SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
69
+ export { Select, SelectGroup, SelectValue, SelectTrigger, SelectContent, SelectLabel, SelectItem, SelectSeparator, SelectScrollUpButton, SelectScrollDownButton, };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,8 @@
1
+ export * from "./components/ui";
1
2
  export * from "./components/rich-text";
3
+ export * from "./components/question-types";
2
4
  export * from "./components/web-components";
3
5
  export * from "./components/print";
6
+ export * from "./components/chat";
4
7
  export * from "./utils";
5
8
  export * from "./types";
package/dist/index.js CHANGED
@@ -1,5 +1,8 @@
1
+ export * from "./components/ui";
1
2
  export * from "./components/rich-text";
3
+ export * from "./components/question-types";
2
4
  export * from "./components/web-components";
3
5
  export * from "./components/print";
6
+ export * from "./components/chat";
4
7
  export * from "./utils";
5
8
  export * from "./types";
@@ -25,7 +25,7 @@ export type FrontendResultsComponent = ComponentType<FrontendBaseComponentProps
25
25
  }>;
26
26
  export type FrontendQuestionSettingsAreaComponent = ComponentType<FrontendBaseComponentProps & {
27
27
  question: any;
28
- value: any;
29
- onChange: (value: any) => void;
28
+ settings: Record<string, any>;
29
+ setSetting: (settingId: string, value: any) => void;
30
30
  }>;
31
31
  export {};
package/package.json CHANGED
@@ -2,11 +2,12 @@
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.4.0",
5
+ "version": "1.5.0",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
8
8
  "files": [
9
- "dist"
9
+ "dist",
10
+ "src/global.css"
10
11
  ],
11
12
  "scripts": {
12
13
  "start": "yarn build --watch",
@@ -14,7 +15,11 @@
14
15
  "release": "semantic-release -e semantic-release-monorepo"
15
16
  },
16
17
  "dependencies": {
18
+ "@examplary/schemas": "*",
17
19
  "@floating-ui/dom": "^1.7.2",
20
+ "@radix-ui/react-label": "^2.1.7",
21
+ "@radix-ui/react-radio-group": "^1.3.7",
22
+ "@radix-ui/react-select": "^2.2.5",
18
23
  "@tailwindcss/forms": "^0.5.10",
19
24
  "@tailwindcss/typography": "^0.5.16",
20
25
  "@tiptap/core": "^3.0.7",
@@ -26,9 +31,11 @@
26
31
  "@tiptap/extension-typography": "^3.0.7",
27
32
  "@tiptap/react": "^3.0.7",
28
33
  "@tiptap/starter-kit": "^3.0.7",
34
+ "class-variance-authority": "^0.7.1",
29
35
  "clsx": "^2.1.1",
36
+ "i18next-browser-languagedetector": "^8.2.0",
30
37
  "katex": "^0.16.22",
31
- "lucide-react": "^0.525.0",
38
+ "lucide-react": "^0.526.0",
32
39
  "tailwind-animate": "^0.2.10",
33
40
  "tailwind-merge": "^3.3.1",
34
41
  "tailwindcss-animate": "^1.0.7"
@@ -40,7 +47,7 @@
40
47
  "devDependencies": {
41
48
  "typescript": "^5.8.3"
42
49
  },
43
- "homepage": "https://developers.examplary.ai",
50
+ "homepage": "https://developers.examplary.ai/",
44
51
  "author": {
45
52
  "name": "Examplary AI",
46
53
  "email": "hi@examplary.ai"
package/src/global.css ADDED
@@ -0,0 +1,73 @@
1
+ @import "tailwindcss";
2
+ @import "katex/dist/katex.min.css";
3
+ @import "./components/rich-text/tiptap/styles.css";
4
+
5
+ @plugin "@tailwindcss/typography";
6
+ @plugin "tailwindcss-animate";
7
+
8
+ @source "../node_modules/@examplary/ui";
9
+ @source "../../node_modules/@examplary/ui";
10
+ @source "../../../node_modules/@examplary/ui";
11
+ @source "../../ui/src/components/*";
12
+
13
+ @theme {
14
+ /* Fonts */
15
+ --font-sans: var(--font-sans), "sans-serif";
16
+ --font-serif: var(--font-serif), "serif";
17
+
18
+ /* Custom colors */
19
+ --color-bright: #eaff00;
20
+ --color-bg: #fff7f0;
21
+ --color-app-bg: #fff7f0;
22
+ --color-nav: #feeee2;
23
+
24
+ /* Neobrutalism */
25
+ --radius-base: 5px;
26
+ --shadow-light: 3px 3px 0px 0px #000;
27
+ --shadow-small: 2px 2px 0px 0px #000;
28
+
29
+ /* Marquee */
30
+ --animate-scroll: scroll 25s linear infinite;
31
+ }
32
+
33
+ @keyframes scroll {
34
+ from {
35
+ transform: translateX(0);
36
+ }
37
+ to {
38
+ transform: translateX(calc(-100% - 2rem));
39
+ }
40
+ }
41
+
42
+ .box {
43
+ @apply border-2 border-black rounded-base;
44
+ }
45
+
46
+ .ProseMirror:focus-visible {
47
+ outline: none !important;
48
+ }
49
+
50
+ .flex-shrink-0 {
51
+ flex-shrink: 0;
52
+ }
53
+
54
+ .translate-x-boxShadowX {
55
+ transform: translateX(4px);
56
+ }
57
+ .translate-y-boxShadowY {
58
+ transform: translateY(4px);
59
+ }
60
+ .hover\:translate-x-boxShadowX:hover {
61
+ transform: translateX(4px);
62
+ }
63
+ .hover\:translate-y-boxShadowY:hover {
64
+ transform: translateY(4px);
65
+ }
66
+
67
+ .translate-shadow-light:hover {
68
+ transform: translate(3px, 3px);
69
+ }
70
+
71
+ .translate-shadow-small:hover {
72
+ transform: translate(2px, 2px);
73
+ }