@uipath/apollo-wind 2.42.0 → 2.43.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/ui/combobox.cjs +1 -1
- package/dist/components/ui/combobox.js +1 -1
- package/dist/components/ui/dropdown-menu.cjs +12 -2
- package/dist/components/ui/dropdown-menu.d.ts +8 -1
- package/dist/components/ui/dropdown-menu.js +12 -2
- package/dist/components/ui/index.cjs +14 -14
- package/dist/components/ui/multi-select.cjs +2 -2
- package/dist/components/ui/multi-select.js +2 -2
- package/dist/components/ui/prompt-editor/components/EditorToolbar.cjs +3 -3
- package/dist/components/ui/prompt-editor/components/EditorToolbar.d.ts +2 -1
- package/dist/components/ui/prompt-editor/components/EditorToolbar.js +3 -3
- package/dist/components/ui/prompt-editor/prompt-editor.cjs +30 -7
- package/dist/components/ui/prompt-editor/prompt-editor.d.ts +9 -1
- package/dist/components/ui/prompt-editor/prompt-editor.js +31 -8
- package/dist/styles.css +17 -6
- package/package.json +1 -1
|
@@ -50,7 +50,7 @@ const combobox_Combobox = /*#__PURE__*/ external_react_namespaceObject.forwardRe
|
|
|
50
50
|
role: "combobox",
|
|
51
51
|
"aria-expanded": open,
|
|
52
52
|
"aria-label": selectedItem ? selectedItem.label : placeholder,
|
|
53
|
-
className: (0, index_cjs_namespaceObject.cn)('w-[280px] justify-between future:rounded-xl future:border-0 future:bg-surface-overlay future:hover:bg-surface-hover future:font-normal future:text-muted-foreground', className),
|
|
53
|
+
className: (0, index_cjs_namespaceObject.cn)('w-[280px] justify-between future:h-10 future:rounded-xl future:border-0 future:bg-surface-overlay future:px-4 future:gap-4 future:hover:bg-surface-hover future:font-normal future:text-muted-foreground future:focus-visible:ring-offset-2 future:focus-visible:ring-offset-background', className),
|
|
54
54
|
disabled: disabled,
|
|
55
55
|
children: [
|
|
56
56
|
selectedItem ? selectedItem.label : placeholder,
|
|
@@ -22,7 +22,7 @@ const combobox_Combobox = /*#__PURE__*/ forwardRef(function({ items, value, onVa
|
|
|
22
22
|
role: "combobox",
|
|
23
23
|
"aria-expanded": open,
|
|
24
24
|
"aria-label": selectedItem ? selectedItem.label : placeholder,
|
|
25
|
-
className: cn('w-[280px] justify-between future:rounded-xl future:border-0 future:bg-surface-overlay future:hover:bg-surface-hover future:font-normal future:text-muted-foreground', className),
|
|
25
|
+
className: cn('w-[280px] justify-between future:h-10 future:rounded-xl future:border-0 future:bg-surface-overlay future:px-4 future:gap-4 future:hover:bg-surface-hover future:font-normal future:text-muted-foreground future:focus-visible:ring-offset-2 future:focus-visible:ring-offset-background', className),
|
|
26
26
|
disabled: disabled,
|
|
27
27
|
children: [
|
|
28
28
|
selectedItem ? selectedItem.label : placeholder,
|
|
@@ -52,11 +52,21 @@ const DropdownMenu = (props)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)
|
|
|
52
52
|
...props
|
|
53
53
|
});
|
|
54
54
|
DropdownMenu.displayName = 'DropdownMenu';
|
|
55
|
-
const DropdownMenuTrigger = /*#__PURE__*/ external_react_namespaceObject.forwardRef((
|
|
55
|
+
const DropdownMenuTrigger = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ className, field, error, errorId, 'aria-describedby': ariaDescribedBy, 'aria-invalid': ariaInvalid, 'aria-errormessage': ariaErrorMessage, ...props }, ref)=>{
|
|
56
|
+
const describedBy = [
|
|
57
|
+
ariaDescribedBy,
|
|
58
|
+
error ? errorId : void 0
|
|
59
|
+
].filter(Boolean).join(' ');
|
|
60
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_dropdown_menu_namespaceObject.Trigger, {
|
|
56
61
|
ref: ref,
|
|
57
62
|
"data-slot": "dropdown-menu-trigger",
|
|
63
|
+
className: (0, index_cjs_namespaceObject.cn)(field && 'future:h-10 future:rounded-xl future:border-0 future:bg-surface-overlay future:px-4 future:gap-4 future:font-normal future:text-muted-foreground future:hover:bg-surface-hover', error && 'border-error ring-1 ring-error/20 future:ring-error/40', className),
|
|
64
|
+
"aria-describedby": describedBy || void 0,
|
|
65
|
+
"aria-errormessage": error ? errorId ?? ariaErrorMessage : ariaErrorMessage,
|
|
66
|
+
"aria-invalid": error ? true : ariaInvalid,
|
|
58
67
|
...props
|
|
59
|
-
})
|
|
68
|
+
});
|
|
69
|
+
});
|
|
60
70
|
DropdownMenuTrigger.displayName = react_dropdown_menu_namespaceObject.Trigger.displayName;
|
|
61
71
|
const DropdownMenuGroup = /*#__PURE__*/ external_react_namespaceObject.forwardRef((props, ref)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_dropdown_menu_namespaceObject.Group, {
|
|
62
72
|
ref: ref,
|
|
@@ -5,7 +5,14 @@ declare const DropdownMenu: {
|
|
|
5
5
|
(props: React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
displayName: string;
|
|
7
7
|
};
|
|
8
|
-
declare const DropdownMenuTrigger: React.ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuTriggerProps & React.RefAttributes<HTMLButtonElement>, "ref"> &
|
|
8
|
+
declare const DropdownMenuTrigger: React.ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuTriggerProps & React.RefAttributes<HTMLButtonElement>, "ref"> & {
|
|
9
|
+
/** Apply the Future theme field treatment when the trigger is used as a form control. */
|
|
10
|
+
field?: boolean;
|
|
11
|
+
/** Field-specific validation feedback rendered below the trigger by the consumer. */
|
|
12
|
+
error?: React.ReactNode;
|
|
13
|
+
/** Optional id for the validation message referenced by aria-describedby. */
|
|
14
|
+
errorId?: string;
|
|
15
|
+
} & React.RefAttributes<HTMLButtonElement>>;
|
|
9
16
|
declare const DropdownMenuGroup: React.ForwardRefExoticComponent<Omit<DropdownMenuPrimitive.DropdownMenuGroupProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
10
17
|
declare const DropdownMenuPortal: {
|
|
11
18
|
(props: React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Portal>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -10,11 +10,21 @@ const DropdownMenu = (props)=>/*#__PURE__*/ jsx(Root, {
|
|
|
10
10
|
...props
|
|
11
11
|
});
|
|
12
12
|
DropdownMenu.displayName = 'DropdownMenu';
|
|
13
|
-
const DropdownMenuTrigger = /*#__PURE__*/ forwardRef((props, ref)
|
|
13
|
+
const DropdownMenuTrigger = /*#__PURE__*/ forwardRef(({ className, field, error, errorId, 'aria-describedby': ariaDescribedBy, 'aria-invalid': ariaInvalid, 'aria-errormessage': ariaErrorMessage, ...props }, ref)=>{
|
|
14
|
+
const describedBy = [
|
|
15
|
+
ariaDescribedBy,
|
|
16
|
+
error ? errorId : void 0
|
|
17
|
+
].filter(Boolean).join(' ');
|
|
18
|
+
return /*#__PURE__*/ jsx(Trigger, {
|
|
14
19
|
ref: ref,
|
|
15
20
|
"data-slot": "dropdown-menu-trigger",
|
|
21
|
+
className: cn(field && 'future:h-10 future:rounded-xl future:border-0 future:bg-surface-overlay future:px-4 future:gap-4 future:font-normal future:text-muted-foreground future:hover:bg-surface-hover', error && 'border-error ring-1 ring-error/20 future:ring-error/40', className),
|
|
22
|
+
"aria-describedby": describedBy || void 0,
|
|
23
|
+
"aria-errormessage": error ? errorId ?? ariaErrorMessage : ariaErrorMessage,
|
|
24
|
+
"aria-invalid": error ? true : ariaInvalid,
|
|
16
25
|
...props
|
|
17
|
-
})
|
|
26
|
+
});
|
|
27
|
+
});
|
|
18
28
|
DropdownMenuTrigger.displayName = Trigger.displayName;
|
|
19
29
|
const DropdownMenuGroup = /*#__PURE__*/ forwardRef((props, ref)=>/*#__PURE__*/ jsx(Group, {
|
|
20
30
|
ref: ref,
|
|
@@ -15,7 +15,7 @@ var __webpack_modules__ = {
|
|
|
15
15
|
"./avatar" (module) {
|
|
16
16
|
module.exports = require("./avatar.cjs");
|
|
17
17
|
},
|
|
18
|
-
"
|
|
18
|
+
"@/components/ui/badge" (module) {
|
|
19
19
|
module.exports = require("./badge.cjs");
|
|
20
20
|
},
|
|
21
21
|
"./breadcrumb" (module) {
|
|
@@ -36,7 +36,7 @@ var __webpack_modules__ = {
|
|
|
36
36
|
"./chart" (module) {
|
|
37
37
|
module.exports = require("./chart.cjs");
|
|
38
38
|
},
|
|
39
|
-
"
|
|
39
|
+
"@/components/ui/checkbox" (module) {
|
|
40
40
|
module.exports = require("./checkbox.cjs");
|
|
41
41
|
},
|
|
42
42
|
"./collapsible" (module) {
|
|
@@ -60,7 +60,7 @@ var __webpack_modules__ = {
|
|
|
60
60
|
"./datetime-picker" (module) {
|
|
61
61
|
module.exports = require("./datetime-picker.cjs");
|
|
62
62
|
},
|
|
63
|
-
"
|
|
63
|
+
"@/components/ui/dialog" (module) {
|
|
64
64
|
module.exports = require("./dialog.cjs");
|
|
65
65
|
},
|
|
66
66
|
"./drawer" (module) {
|
|
@@ -84,13 +84,13 @@ var __webpack_modules__ = {
|
|
|
84
84
|
"./hover-card" (module) {
|
|
85
85
|
module.exports = require("./hover-card.cjs");
|
|
86
86
|
},
|
|
87
|
-
"
|
|
87
|
+
"./input-group" (module) {
|
|
88
88
|
module.exports = require("./input-group.cjs");
|
|
89
89
|
},
|
|
90
|
-
"
|
|
90
|
+
"@/components/ui/input" (module) {
|
|
91
91
|
module.exports = require("./input.cjs");
|
|
92
92
|
},
|
|
93
|
-
"
|
|
93
|
+
"@/components/ui/label" (module) {
|
|
94
94
|
module.exports = require("./label.cjs");
|
|
95
95
|
},
|
|
96
96
|
"./layout" (module) {
|
|
@@ -171,7 +171,7 @@ var __webpack_modules__ = {
|
|
|
171
171
|
"./toggle-group" (module) {
|
|
172
172
|
module.exports = require("./toggle-group.cjs");
|
|
173
173
|
},
|
|
174
|
-
"
|
|
174
|
+
"./toggle" (module) {
|
|
175
175
|
module.exports = require("./toggle.cjs");
|
|
176
176
|
},
|
|
177
177
|
"./tooltip" (module) {
|
|
@@ -265,7 +265,7 @@ var __webpack_exports__ = {};
|
|
|
265
265
|
"default"
|
|
266
266
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_avatar__rspack_import_4[__rspack_import_key];
|
|
267
267
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
268
|
-
var _badge__rspack_import_5 = __webpack_require__("
|
|
268
|
+
var _badge__rspack_import_5 = __webpack_require__("@/components/ui/badge");
|
|
269
269
|
var __rspack_reexport = {};
|
|
270
270
|
for(const __rspack_import_key in _badge__rspack_import_5)if ([
|
|
271
271
|
"TreeView",
|
|
@@ -314,7 +314,7 @@ var __webpack_exports__ = {};
|
|
|
314
314
|
"default"
|
|
315
315
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_chart__rspack_import_11[__rspack_import_key];
|
|
316
316
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
317
|
-
var _checkbox__rspack_import_12 = __webpack_require__("
|
|
317
|
+
var _checkbox__rspack_import_12 = __webpack_require__("@/components/ui/checkbox");
|
|
318
318
|
var __rspack_reexport = {};
|
|
319
319
|
for(const __rspack_import_key in _checkbox__rspack_import_12)if ([
|
|
320
320
|
"TreeView",
|
|
@@ -370,7 +370,7 @@ var __webpack_exports__ = {};
|
|
|
370
370
|
"default"
|
|
371
371
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_datetime_picker__rspack_import_19[__rspack_import_key];
|
|
372
372
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
373
|
-
var _dialog__rspack_import_20 = __webpack_require__("
|
|
373
|
+
var _dialog__rspack_import_20 = __webpack_require__("@/components/ui/dialog");
|
|
374
374
|
var __rspack_reexport = {};
|
|
375
375
|
for(const __rspack_import_key in _dialog__rspack_import_20)if ([
|
|
376
376
|
"TreeView",
|
|
@@ -426,21 +426,21 @@ var __webpack_exports__ = {};
|
|
|
426
426
|
"default"
|
|
427
427
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_hover_card__rspack_import_27[__rspack_import_key];
|
|
428
428
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
429
|
-
var _input__rspack_import_28 = __webpack_require__("
|
|
429
|
+
var _input__rspack_import_28 = __webpack_require__("@/components/ui/input");
|
|
430
430
|
var __rspack_reexport = {};
|
|
431
431
|
for(const __rspack_import_key in _input__rspack_import_28)if ([
|
|
432
432
|
"TreeView",
|
|
433
433
|
"default"
|
|
434
434
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_input__rspack_import_28[__rspack_import_key];
|
|
435
435
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
436
|
-
var _input_group__rspack_import_29 = __webpack_require__("
|
|
436
|
+
var _input_group__rspack_import_29 = __webpack_require__("./input-group");
|
|
437
437
|
var __rspack_reexport = {};
|
|
438
438
|
for(const __rspack_import_key in _input_group__rspack_import_29)if ([
|
|
439
439
|
"TreeView",
|
|
440
440
|
"default"
|
|
441
441
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_input_group__rspack_import_29[__rspack_import_key];
|
|
442
442
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
443
|
-
var _label__rspack_import_30 = __webpack_require__("
|
|
443
|
+
var _label__rspack_import_30 = __webpack_require__("@/components/ui/label");
|
|
444
444
|
var __rspack_reexport = {};
|
|
445
445
|
for(const __rspack_import_key in _label__rspack_import_30)if ([
|
|
446
446
|
"TreeView",
|
|
@@ -622,7 +622,7 @@ var __webpack_exports__ = {};
|
|
|
622
622
|
"default"
|
|
623
623
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_textarea__rspack_import_55[__rspack_import_key];
|
|
624
624
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
625
|
-
var _toggle__rspack_import_56 = __webpack_require__("
|
|
625
|
+
var _toggle__rspack_import_56 = __webpack_require__("./toggle");
|
|
626
626
|
var __rspack_reexport = {};
|
|
627
627
|
for(const __rspack_import_key in _toggle__rspack_import_56)if ([
|
|
628
628
|
"TreeView",
|
|
@@ -75,13 +75,13 @@ const MultiSelect = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ i
|
|
|
75
75
|
"aria-describedby": ariaDescribedBy,
|
|
76
76
|
"aria-errormessage": ariaErrorMessage,
|
|
77
77
|
"aria-label": id ? void 0 : selected.length > 0 ? `${selected.length} ${1 === selected.length ? 'item' : 'items'} selected` : placeholder,
|
|
78
|
-
className: (0, index_cjs_namespaceObject.cn)('w-full justify-between future:rounded-xl future:border-0 future:bg-surface-overlay future:hover:bg-surface-hover future:font-normal future:text-muted-foreground', selected.length > 0 ? 'h-auto min-h-10' : 'h-10'),
|
|
78
|
+
className: (0, index_cjs_namespaceObject.cn)('w-full justify-between future:rounded-xl future:border-0 future:bg-surface-overlay future:px-4 future:gap-4 future:hover:bg-surface-hover future:font-normal future:text-muted-foreground future:focus-visible:ring-offset-2 future:focus-visible:ring-offset-background', selected.length > 0 ? 'h-auto min-h-10' : 'h-10'),
|
|
79
79
|
disabled: disabled,
|
|
80
80
|
children: [
|
|
81
81
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
82
82
|
className: "flex flex-wrap gap-1 flex-1",
|
|
83
83
|
children: 0 === selected.length ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
84
|
-
className: "text-muted-foreground",
|
|
84
|
+
className: "text-muted-foreground future:text-foreground-muted",
|
|
85
85
|
children: placeholder
|
|
86
86
|
}) : selected.map((value)=>{
|
|
87
87
|
const option = options.find((opt)=>opt.value === value);
|
|
@@ -47,13 +47,13 @@ const MultiSelect = /*#__PURE__*/ forwardRef(({ id, options, selected, onChange,
|
|
|
47
47
|
"aria-describedby": ariaDescribedBy,
|
|
48
48
|
"aria-errormessage": ariaErrorMessage,
|
|
49
49
|
"aria-label": id ? void 0 : selected.length > 0 ? `${selected.length} ${1 === selected.length ? 'item' : 'items'} selected` : placeholder,
|
|
50
|
-
className: cn('w-full justify-between future:rounded-xl future:border-0 future:bg-surface-overlay future:hover:bg-surface-hover future:font-normal future:text-muted-foreground', selected.length > 0 ? 'h-auto min-h-10' : 'h-10'),
|
|
50
|
+
className: cn('w-full justify-between future:rounded-xl future:border-0 future:bg-surface-overlay future:px-4 future:gap-4 future:hover:bg-surface-hover future:font-normal future:text-muted-foreground future:focus-visible:ring-offset-2 future:focus-visible:ring-offset-background', selected.length > 0 ? 'h-auto min-h-10' : 'h-10'),
|
|
51
51
|
disabled: disabled,
|
|
52
52
|
children: [
|
|
53
53
|
/*#__PURE__*/ jsx("div", {
|
|
54
54
|
className: "flex flex-wrap gap-1 flex-1",
|
|
55
55
|
children: 0 === selected.length ? /*#__PURE__*/ jsx("span", {
|
|
56
|
-
className: "text-muted-foreground",
|
|
56
|
+
className: "text-muted-foreground future:text-foreground-muted",
|
|
57
57
|
children: placeholder
|
|
58
58
|
}) : selected.map((value)=>{
|
|
59
59
|
const option = options.find((opt)=>opt.value === value);
|
|
@@ -28,8 +28,8 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
28
28
|
});
|
|
29
29
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
30
|
const external_lucide_react_namespaceObject = require("lucide-react");
|
|
31
|
-
const index_cjs_namespaceObject = require("../../../../lib/index.cjs");
|
|
32
31
|
const external_tooltip_cjs_namespaceObject = require("../../tooltip.cjs");
|
|
32
|
+
const index_cjs_namespaceObject = require("../../../../lib/index.cjs");
|
|
33
33
|
const ToolbarButton = ({ icon: Icon, label, disabled, onClick })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_tooltip_cjs_namespaceObject.Tooltip, {
|
|
34
34
|
children: [
|
|
35
35
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_tooltip_cjs_namespaceObject.TooltipTrigger, {
|
|
@@ -58,7 +58,7 @@ const ToolbarSeparator = ()=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
|
58
58
|
"aria-hidden": true,
|
|
59
59
|
className: "mx-1 h-4 w-px bg-border/60"
|
|
60
60
|
});
|
|
61
|
-
const EditorToolbar = ({ mode, onModeChange, disabled, actionsRef, onFullscreen })=>{
|
|
61
|
+
const EditorToolbar = ({ mode, onModeChange, disabled, error, actionsRef, onFullscreen })=>{
|
|
62
62
|
const isEditMode = 'edit' === mode;
|
|
63
63
|
const handleFormat = (actionName)=>()=>{
|
|
64
64
|
if (!disabled && isEditMode) {
|
|
@@ -67,7 +67,7 @@ const EditorToolbar = ({ mode, onModeChange, disabled, actionsRef, onFullscreen
|
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
69
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
70
|
-
className:
|
|
70
|
+
className: (0, index_cjs_namespaceObject.cn)('relative flex items-center justify-between gap-1 overflow-hidden rounded-t-md border border-b-0 bg-background px-2 py-1 future:rounded-t-xl future:border-0 future:bg-surface-overlay', error && 'border-error ring-1 ring-error/20 future:ring-error/40'),
|
|
71
71
|
"data-testid": "editor-toolbar",
|
|
72
72
|
children: [
|
|
73
73
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
@@ -3,7 +3,8 @@ export interface EditorToolbarProps {
|
|
|
3
3
|
mode: PromptEditorMode;
|
|
4
4
|
onModeChange: (mode: PromptEditorMode) => void;
|
|
5
5
|
disabled?: boolean;
|
|
6
|
+
error?: boolean;
|
|
6
7
|
actionsRef?: React.RefObject<PromptEditorToolbarActionsRef | null>;
|
|
7
8
|
onFullscreen?: () => void;
|
|
8
9
|
}
|
|
9
|
-
export declare const EditorToolbar: ({ mode, onModeChange, disabled, actionsRef, onFullscreen, }: EditorToolbarProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare const EditorToolbar: ({ mode, onModeChange, disabled, error, actionsRef, onFullscreen, }: EditorToolbarProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Bold, Italic, List, ListOrdered, Maximize2, Strikethrough } from "lucide-react";
|
|
3
|
-
import { cn } from "../../../../lib/index.js";
|
|
4
3
|
import { Tooltip, TooltipContent, TooltipTrigger } from "../../tooltip.js";
|
|
4
|
+
import { cn } from "../../../../lib/index.js";
|
|
5
5
|
const ToolbarButton = ({ icon: Icon, label, disabled, onClick })=>/*#__PURE__*/ jsxs(Tooltip, {
|
|
6
6
|
children: [
|
|
7
7
|
/*#__PURE__*/ jsx(TooltipTrigger, {
|
|
@@ -30,7 +30,7 @@ const ToolbarSeparator = ()=>/*#__PURE__*/ jsx("span", {
|
|
|
30
30
|
"aria-hidden": true,
|
|
31
31
|
className: "mx-1 h-4 w-px bg-border/60"
|
|
32
32
|
});
|
|
33
|
-
const EditorToolbar = ({ mode, onModeChange, disabled, actionsRef, onFullscreen })=>{
|
|
33
|
+
const EditorToolbar = ({ mode, onModeChange, disabled, error, actionsRef, onFullscreen })=>{
|
|
34
34
|
const isEditMode = 'edit' === mode;
|
|
35
35
|
const handleFormat = (actionName)=>()=>{
|
|
36
36
|
if (!disabled && isEditMode) {
|
|
@@ -39,7 +39,7 @@ const EditorToolbar = ({ mode, onModeChange, disabled, actionsRef, onFullscreen
|
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
return /*#__PURE__*/ jsxs("div", {
|
|
42
|
-
className:
|
|
42
|
+
className: cn('relative flex items-center justify-between gap-1 overflow-hidden rounded-t-md border border-b-0 bg-background px-2 py-1 future:rounded-t-xl future:border-0 future:bg-surface-overlay', error && 'border-error ring-1 ring-error/20 future:ring-error/40'),
|
|
43
43
|
"data-testid": "editor-toolbar",
|
|
44
44
|
children: [
|
|
45
45
|
/*#__PURE__*/ jsx("span", {
|
|
@@ -35,6 +35,7 @@ const LexicalOnChangePlugin_namespaceObject = require("@lexical/react/LexicalOnC
|
|
|
35
35
|
const LexicalPlainTextPlugin_namespaceObject = require("@lexical/react/LexicalPlainTextPlugin");
|
|
36
36
|
const external_lexical_namespaceObject = require("lexical");
|
|
37
37
|
const external_react_namespaceObject = require("react");
|
|
38
|
+
const external_form_field_cjs_namespaceObject = require("../form-field.cjs");
|
|
38
39
|
const external_tooltip_cjs_namespaceObject = require("../tooltip.cjs");
|
|
39
40
|
const EditorToolbar_cjs_namespaceObject = require("./components/EditorToolbar.cjs");
|
|
40
41
|
const MarkdownPreview_cjs_namespaceObject = require("./components/MarkdownPreview.cjs");
|
|
@@ -56,7 +57,7 @@ const LINE_HEIGHT = 20;
|
|
|
56
57
|
const EMPTY_AUTOCOMPLETE_OPTIONS = [];
|
|
57
58
|
const EMPTY_TOKENS = [];
|
|
58
59
|
const toTokenArray = (v)=>void 0 === v ? void 0 : Array.isArray(v) ? v : EMPTY_TOKENS;
|
|
59
|
-
const EditorInner = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)(({ initialValue, value, onChange, autoCompleteOptions = EMPTY_AUTOCOMPLETE_OPTIONS, multiline = true, minRows = DEFAULT_MIN_ROWS, maxRows = DEFAULT_MAX_ROWS, placeholder, disabled, ariaLabel, fillHeight, borderless, mapVarDropToToken, toolbarActionsRef, showToolbar }, ref)=>{
|
|
60
|
+
const EditorInner = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)(({ initialValue, value, onChange, autoCompleteOptions = EMPTY_AUTOCOMPLETE_OPTIONS, multiline = true, minRows = DEFAULT_MIN_ROWS, maxRows = DEFAULT_MAX_ROWS, placeholder, disabled, ariaLabel, fillHeight, borderless, error, errorId, ariaDescribedBy, mapVarDropToToken, toolbarActionsRef, showToolbar }, ref)=>{
|
|
60
61
|
const editorRef = (0, external_react_namespaceObject.useRef)(null);
|
|
61
62
|
const [isEmpty, setIsEmpty] = (0, external_react_namespaceObject.useState)(()=>{
|
|
62
63
|
const seed = initialValue ?? value;
|
|
@@ -195,9 +196,10 @@ const EditorInner = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)
|
|
|
195
196
|
disabled
|
|
196
197
|
]);
|
|
197
198
|
const options = Array.isArray(autoCompleteOptions) ? autoCompleteOptions : EMPTY_AUTOCOMPLETE_OPTIONS;
|
|
198
|
-
const wrapperClassName = borderless ? 'flex flex-col w-full relative' : `prompt-editor-shell flex flex-col w-full relative border bg-background ${showToolbar ? 'border-t-0 rounded-b-md' : 'rounded-md'}`;
|
|
199
|
+
const wrapperClassName = borderless ? 'flex flex-col w-full relative' : `prompt-editor-shell flex flex-col w-full relative border bg-background future:border-0 future:bg-surface-overlay ${showToolbar ? 'border-t-0 rounded-b-md future:rounded-b-xl' : 'rounded-md future:rounded-xl'} ${error ? 'border-error ring-1 ring-error/20 future:ring-error/40' : ''}`;
|
|
199
200
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
200
201
|
className: wrapperClassName,
|
|
202
|
+
"data-invalid": error ? 'true' : void 0,
|
|
201
203
|
style: {
|
|
202
204
|
fontFamily: "'Noto Sans', sans-serif",
|
|
203
205
|
fontSize: '14px',
|
|
@@ -211,7 +213,7 @@ const EditorInner = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)
|
|
|
211
213
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("style", {
|
|
212
214
|
children: `
|
|
213
215
|
.prompt-editor-paragraph { padding: 0; margin: 0; }
|
|
214
|
-
${borderless ? '' : '.prompt-editor-shell:focus-within { border-color: var(--color-ring); box-shadow: 0 0 0 1px var(--color-ring); }'}
|
|
216
|
+
${borderless ? '' : '.prompt-editor-shell:not([data-invalid="true"]):focus-within { border-color: var(--color-ring); box-shadow: 0 0 0 1px var(--color-ring); } .future .prompt-editor-shell:not([data-invalid="true"]):focus-within { box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-ring) 35%, transparent); }'}
|
|
215
217
|
.prompt-editor-root *::selection { background-color: color-mix(in srgb, var(--color-primary) 30%, transparent); }
|
|
216
218
|
`
|
|
217
219
|
}),
|
|
@@ -230,7 +232,10 @@ const EditorInner = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)
|
|
|
230
232
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(LexicalPlainTextPlugin_namespaceObject.PlainTextPlugin, {
|
|
231
233
|
contentEditable: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(LexicalContentEditable_namespaceObject.ContentEditable, {
|
|
232
234
|
style: contentEditableStyle,
|
|
233
|
-
ariaLabel: ariaLabel
|
|
235
|
+
ariaLabel: ariaLabel,
|
|
236
|
+
"aria-invalid": error ? true : void 0,
|
|
237
|
+
"aria-describedby": ariaDescribedBy,
|
|
238
|
+
"aria-errormessage": error ? errorId : void 0
|
|
234
239
|
}),
|
|
235
240
|
placeholder: null,
|
|
236
241
|
ErrorBoundary: LexicalErrorBoundary_namespaceObject.LexicalErrorBoundary
|
|
@@ -252,7 +257,7 @@ const EditorInner = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)
|
|
|
252
257
|
textOverflow: 'ellipsis'
|
|
253
258
|
}
|
|
254
259
|
},
|
|
255
|
-
className: "text-muted-foreground
|
|
260
|
+
className: "text-muted-foreground future:text-foreground-muted future:font-normal",
|
|
256
261
|
children: placeholder
|
|
257
262
|
})
|
|
258
263
|
]
|
|
@@ -297,7 +302,7 @@ const EditorInner = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)
|
|
|
297
302
|
});
|
|
298
303
|
});
|
|
299
304
|
EditorInner.displayName = 'PromptEditorInner';
|
|
300
|
-
const PromptEditor = ({ value: rawValue, initialValue: rawInitialValue, onChange, multiline = true, minRows = DEFAULT_MIN_ROWS, maxRows = DEFAULT_MAX_ROWS, placeholder, disabled, ariaLabel, autoCompleteOptions, showToolbar = false, mode: controlledMode, onModeChange, onFullscreen, editorRef, fillHeight, borderless, mapVarDropToToken })=>{
|
|
305
|
+
const PromptEditor = ({ value: rawValue, initialValue: rawInitialValue, onChange, multiline = true, minRows = DEFAULT_MIN_ROWS, maxRows = DEFAULT_MAX_ROWS, placeholder, disabled, ariaLabel, autoCompleteOptions, showToolbar = false, mode: controlledMode, onModeChange, onFullscreen, editorRef, fillHeight, borderless, error, errorId: providedErrorId, 'aria-describedby': nativeAriaDescribedBy, ariaDescribedBy: legacyAriaDescribedBy, mapVarDropToToken })=>{
|
|
301
306
|
const value = toTokenArray(rawValue);
|
|
302
307
|
const initialValue = toTokenArray(rawInitialValue);
|
|
303
308
|
const [internalMode, setInternalMode] = (0, external_react_namespaceObject.useState)('edit');
|
|
@@ -325,6 +330,13 @@ const PromptEditor = ({ value: rawValue, initialValue: rawInitialValue, onChange
|
|
|
325
330
|
}), []);
|
|
326
331
|
const isControlled = void 0 !== value;
|
|
327
332
|
const previewTokens = isControlled ? value : uncontrolledPreviewTokens;
|
|
333
|
+
const generatedErrorId = (0, external_react_namespaceObject.useId)();
|
|
334
|
+
const errorId = providedErrorId ?? `prompt-editor-${generatedErrorId.replace(/:/g, '')}-error`;
|
|
335
|
+
const additionalDescribedBy = nativeAriaDescribedBy ?? legacyAriaDescribedBy;
|
|
336
|
+
const describedBy = [
|
|
337
|
+
additionalDescribedBy,
|
|
338
|
+
error ? errorId : void 0
|
|
339
|
+
].filter(Boolean).join(' ');
|
|
328
340
|
const handleEditorChange = (0, external_react_namespaceObject.useCallback)((tokens)=>{
|
|
329
341
|
if (!isControlled) setUncontrolledPreviewTokens(tokens);
|
|
330
342
|
onChange?.(tokens);
|
|
@@ -347,12 +359,14 @@ const PromptEditor = ({ value: rawValue, initialValue: rawInitialValue, onChange
|
|
|
347
359
|
showToolbar && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(EditorToolbar_cjs_namespaceObject.EditorToolbar, {
|
|
348
360
|
mode: mode,
|
|
349
361
|
disabled: disabled,
|
|
362
|
+
error: Boolean(error),
|
|
350
363
|
actionsRef: toolbarActionsRef,
|
|
351
364
|
onModeChange: handleModeChange,
|
|
352
365
|
onFullscreen: onFullscreen
|
|
353
366
|
}),
|
|
354
367
|
'preview' === mode && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
355
|
-
|
|
368
|
+
"data-invalid": error ? 'true' : void 0,
|
|
369
|
+
className: borderless ? void 0 : `border bg-background future:border-0 future:bg-surface-overlay ${showToolbar ? 'border-t-0 rounded-b-md future:rounded-b-xl' : 'rounded-md future:rounded-xl'} ${error ? 'border-error ring-1 ring-error/20 future:ring-error/40' : ''}`,
|
|
356
370
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(MarkdownPreview_cjs_namespaceObject.MarkdownPreview, {
|
|
357
371
|
tokens: previewTokens,
|
|
358
372
|
minRows: minRows
|
|
@@ -374,6 +388,9 @@ const PromptEditor = ({ value: rawValue, initialValue: rawInitialValue, onChange
|
|
|
374
388
|
autoCompleteOptions: autoCompleteOptions,
|
|
375
389
|
disabled: disabled,
|
|
376
390
|
ariaLabel: ariaLabel,
|
|
391
|
+
error: error,
|
|
392
|
+
errorId: error ? errorId : void 0,
|
|
393
|
+
ariaDescribedBy: describedBy || void 0,
|
|
377
394
|
initialValue: initialValue,
|
|
378
395
|
maxRows: maxRows,
|
|
379
396
|
minRows: minRows,
|
|
@@ -388,6 +405,12 @@ const PromptEditor = ({ value: rawValue, initialValue: rawInitialValue, onChange
|
|
|
388
405
|
onChange: handleEditorChange
|
|
389
406
|
})
|
|
390
407
|
})
|
|
408
|
+
}),
|
|
409
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldError, {
|
|
410
|
+
id: errorId,
|
|
411
|
+
"data-slot": "prompt-editor-error",
|
|
412
|
+
className: "mt-1",
|
|
413
|
+
children: error
|
|
391
414
|
})
|
|
392
415
|
]
|
|
393
416
|
})
|
|
@@ -25,6 +25,14 @@ export interface PromptEditorProps {
|
|
|
25
25
|
fillHeight?: boolean;
|
|
26
26
|
/** Drop the editor's own border/background/rounding so a parent can provide the field chrome. */
|
|
27
27
|
borderless?: boolean;
|
|
28
|
+
/** Field-specific validation feedback rendered below the editor. */
|
|
29
|
+
error?: React.ReactNode;
|
|
30
|
+
/** Optional id for the inline validation message. */
|
|
31
|
+
errorId?: string;
|
|
32
|
+
/** Additional description id(s) associated with the editor. */
|
|
33
|
+
'aria-describedby'?: string;
|
|
34
|
+
/** @deprecated Use the native `aria-describedby` prop instead. */
|
|
35
|
+
ariaDescribedBy?: string;
|
|
28
36
|
/**
|
|
29
37
|
* Enable variable drag-drop: map a path dropped onto the editor (see `VARIABLE_DRAG_MIME`) to the
|
|
30
38
|
* token to insert at the drop point. The drag *source* is the consumer's (it sets the path on
|
|
@@ -32,4 +40,4 @@ export interface PromptEditorProps {
|
|
|
32
40
|
*/
|
|
33
41
|
mapVarDropToToken?: (insertPath: string) => PromptEditorAutoCompleteOption;
|
|
34
42
|
}
|
|
35
|
-
export declare const PromptEditor: ({ value: rawValue, initialValue: rawInitialValue, onChange, multiline, minRows, maxRows, placeholder, disabled, ariaLabel, autoCompleteOptions, showToolbar, mode: controlledMode, onModeChange, onFullscreen, editorRef, fillHeight, borderless, mapVarDropToToken, }: PromptEditorProps) => import("react/jsx-runtime").JSX.Element;
|
|
43
|
+
export declare const PromptEditor: ({ value: rawValue, initialValue: rawInitialValue, onChange, multiline, minRows, maxRows, placeholder, disabled, ariaLabel, autoCompleteOptions, showToolbar, mode: controlledMode, onModeChange, onFullscreen, editorRef, fillHeight, borderless, error, errorId: providedErrorId, "aria-describedby": nativeAriaDescribedBy, ariaDescribedBy: legacyAriaDescribedBy, mapVarDropToToken, }: PromptEditorProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -6,7 +6,8 @@ import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin";
|
|
|
6
6
|
import { OnChangePlugin } from "@lexical/react/LexicalOnChangePlugin";
|
|
7
7
|
import { PlainTextPlugin } from "@lexical/react/LexicalPlainTextPlugin";
|
|
8
8
|
import { $getSelection, $isRangeSelection } from "lexical";
|
|
9
|
-
import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
9
|
+
import { forwardRef, useCallback, useEffect, useId, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
10
|
+
import { FormFieldError } from "../form-field.js";
|
|
10
11
|
import { TooltipProvider } from "../tooltip.js";
|
|
11
12
|
import { EditorToolbar } from "./components/EditorToolbar.js";
|
|
12
13
|
import { MarkdownPreview } from "./components/MarkdownPreview.js";
|
|
@@ -28,7 +29,7 @@ const LINE_HEIGHT = 20;
|
|
|
28
29
|
const EMPTY_AUTOCOMPLETE_OPTIONS = [];
|
|
29
30
|
const EMPTY_TOKENS = [];
|
|
30
31
|
const toTokenArray = (v)=>void 0 === v ? void 0 : Array.isArray(v) ? v : EMPTY_TOKENS;
|
|
31
|
-
const EditorInner = /*#__PURE__*/ forwardRef(({ initialValue, value, onChange, autoCompleteOptions = EMPTY_AUTOCOMPLETE_OPTIONS, multiline = true, minRows = DEFAULT_MIN_ROWS, maxRows = DEFAULT_MAX_ROWS, placeholder, disabled, ariaLabel, fillHeight, borderless, mapVarDropToToken, toolbarActionsRef, showToolbar }, ref)=>{
|
|
32
|
+
const EditorInner = /*#__PURE__*/ forwardRef(({ initialValue, value, onChange, autoCompleteOptions = EMPTY_AUTOCOMPLETE_OPTIONS, multiline = true, minRows = DEFAULT_MIN_ROWS, maxRows = DEFAULT_MAX_ROWS, placeholder, disabled, ariaLabel, fillHeight, borderless, error, errorId, ariaDescribedBy, mapVarDropToToken, toolbarActionsRef, showToolbar }, ref)=>{
|
|
32
33
|
const editorRef = useRef(null);
|
|
33
34
|
const [isEmpty, setIsEmpty] = useState(()=>{
|
|
34
35
|
const seed = initialValue ?? value;
|
|
@@ -167,9 +168,10 @@ const EditorInner = /*#__PURE__*/ forwardRef(({ initialValue, value, onChange, a
|
|
|
167
168
|
disabled
|
|
168
169
|
]);
|
|
169
170
|
const options = Array.isArray(autoCompleteOptions) ? autoCompleteOptions : EMPTY_AUTOCOMPLETE_OPTIONS;
|
|
170
|
-
const wrapperClassName = borderless ? 'flex flex-col w-full relative' : `prompt-editor-shell flex flex-col w-full relative border bg-background ${showToolbar ? 'border-t-0 rounded-b-md' : 'rounded-md'}`;
|
|
171
|
+
const wrapperClassName = borderless ? 'flex flex-col w-full relative' : `prompt-editor-shell flex flex-col w-full relative border bg-background future:border-0 future:bg-surface-overlay ${showToolbar ? 'border-t-0 rounded-b-md future:rounded-b-xl' : 'rounded-md future:rounded-xl'} ${error ? 'border-error ring-1 ring-error/20 future:ring-error/40' : ''}`;
|
|
171
172
|
return /*#__PURE__*/ jsxs("div", {
|
|
172
173
|
className: wrapperClassName,
|
|
174
|
+
"data-invalid": error ? 'true' : void 0,
|
|
173
175
|
style: {
|
|
174
176
|
fontFamily: "'Noto Sans', sans-serif",
|
|
175
177
|
fontSize: '14px',
|
|
@@ -183,7 +185,7 @@ const EditorInner = /*#__PURE__*/ forwardRef(({ initialValue, value, onChange, a
|
|
|
183
185
|
/*#__PURE__*/ jsx("style", {
|
|
184
186
|
children: `
|
|
185
187
|
.prompt-editor-paragraph { padding: 0; margin: 0; }
|
|
186
|
-
${borderless ? '' : '.prompt-editor-shell:focus-within { border-color: var(--color-ring); box-shadow: 0 0 0 1px var(--color-ring); }'}
|
|
188
|
+
${borderless ? '' : '.prompt-editor-shell:not([data-invalid="true"]):focus-within { border-color: var(--color-ring); box-shadow: 0 0 0 1px var(--color-ring); } .future .prompt-editor-shell:not([data-invalid="true"]):focus-within { box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-ring) 35%, transparent); }'}
|
|
187
189
|
.prompt-editor-root *::selection { background-color: color-mix(in srgb, var(--color-primary) 30%, transparent); }
|
|
188
190
|
`
|
|
189
191
|
}),
|
|
@@ -202,7 +204,10 @@ const EditorInner = /*#__PURE__*/ forwardRef(({ initialValue, value, onChange, a
|
|
|
202
204
|
/*#__PURE__*/ jsx(PlainTextPlugin, {
|
|
203
205
|
contentEditable: /*#__PURE__*/ jsx(ContentEditable, {
|
|
204
206
|
style: contentEditableStyle,
|
|
205
|
-
ariaLabel: ariaLabel
|
|
207
|
+
ariaLabel: ariaLabel,
|
|
208
|
+
"aria-invalid": error ? true : void 0,
|
|
209
|
+
"aria-describedby": ariaDescribedBy,
|
|
210
|
+
"aria-errormessage": error ? errorId : void 0
|
|
206
211
|
}),
|
|
207
212
|
placeholder: null,
|
|
208
213
|
ErrorBoundary: LexicalErrorBoundary
|
|
@@ -224,7 +229,7 @@ const EditorInner = /*#__PURE__*/ forwardRef(({ initialValue, value, onChange, a
|
|
|
224
229
|
textOverflow: 'ellipsis'
|
|
225
230
|
}
|
|
226
231
|
},
|
|
227
|
-
className: "text-muted-foreground
|
|
232
|
+
className: "text-muted-foreground future:text-foreground-muted future:font-normal",
|
|
228
233
|
children: placeholder
|
|
229
234
|
})
|
|
230
235
|
]
|
|
@@ -269,7 +274,7 @@ const EditorInner = /*#__PURE__*/ forwardRef(({ initialValue, value, onChange, a
|
|
|
269
274
|
});
|
|
270
275
|
});
|
|
271
276
|
EditorInner.displayName = 'PromptEditorInner';
|
|
272
|
-
const PromptEditor = ({ value: rawValue, initialValue: rawInitialValue, onChange, multiline = true, minRows = DEFAULT_MIN_ROWS, maxRows = DEFAULT_MAX_ROWS, placeholder, disabled, ariaLabel, autoCompleteOptions, showToolbar = false, mode: controlledMode, onModeChange, onFullscreen, editorRef, fillHeight, borderless, mapVarDropToToken })=>{
|
|
277
|
+
const PromptEditor = ({ value: rawValue, initialValue: rawInitialValue, onChange, multiline = true, minRows = DEFAULT_MIN_ROWS, maxRows = DEFAULT_MAX_ROWS, placeholder, disabled, ariaLabel, autoCompleteOptions, showToolbar = false, mode: controlledMode, onModeChange, onFullscreen, editorRef, fillHeight, borderless, error, errorId: providedErrorId, 'aria-describedby': nativeAriaDescribedBy, ariaDescribedBy: legacyAriaDescribedBy, mapVarDropToToken })=>{
|
|
273
278
|
const value = toTokenArray(rawValue);
|
|
274
279
|
const initialValue = toTokenArray(rawInitialValue);
|
|
275
280
|
const [internalMode, setInternalMode] = useState('edit');
|
|
@@ -297,6 +302,13 @@ const PromptEditor = ({ value: rawValue, initialValue: rawInitialValue, onChange
|
|
|
297
302
|
}), []);
|
|
298
303
|
const isControlled = void 0 !== value;
|
|
299
304
|
const previewTokens = isControlled ? value : uncontrolledPreviewTokens;
|
|
305
|
+
const generatedErrorId = useId();
|
|
306
|
+
const errorId = providedErrorId ?? `prompt-editor-${generatedErrorId.replace(/:/g, '')}-error`;
|
|
307
|
+
const additionalDescribedBy = nativeAriaDescribedBy ?? legacyAriaDescribedBy;
|
|
308
|
+
const describedBy = [
|
|
309
|
+
additionalDescribedBy,
|
|
310
|
+
error ? errorId : void 0
|
|
311
|
+
].filter(Boolean).join(' ');
|
|
300
312
|
const handleEditorChange = useCallback((tokens)=>{
|
|
301
313
|
if (!isControlled) setUncontrolledPreviewTokens(tokens);
|
|
302
314
|
onChange?.(tokens);
|
|
@@ -319,12 +331,14 @@ const PromptEditor = ({ value: rawValue, initialValue: rawInitialValue, onChange
|
|
|
319
331
|
showToolbar && /*#__PURE__*/ jsx(EditorToolbar, {
|
|
320
332
|
mode: mode,
|
|
321
333
|
disabled: disabled,
|
|
334
|
+
error: Boolean(error),
|
|
322
335
|
actionsRef: toolbarActionsRef,
|
|
323
336
|
onModeChange: handleModeChange,
|
|
324
337
|
onFullscreen: onFullscreen
|
|
325
338
|
}),
|
|
326
339
|
'preview' === mode && /*#__PURE__*/ jsx("div", {
|
|
327
|
-
|
|
340
|
+
"data-invalid": error ? 'true' : void 0,
|
|
341
|
+
className: borderless ? void 0 : `border bg-background future:border-0 future:bg-surface-overlay ${showToolbar ? 'border-t-0 rounded-b-md future:rounded-b-xl' : 'rounded-md future:rounded-xl'} ${error ? 'border-error ring-1 ring-error/20 future:ring-error/40' : ''}`,
|
|
328
342
|
children: /*#__PURE__*/ jsx(MarkdownPreview, {
|
|
329
343
|
tokens: previewTokens,
|
|
330
344
|
minRows: minRows
|
|
@@ -346,6 +360,9 @@ const PromptEditor = ({ value: rawValue, initialValue: rawInitialValue, onChange
|
|
|
346
360
|
autoCompleteOptions: autoCompleteOptions,
|
|
347
361
|
disabled: disabled,
|
|
348
362
|
ariaLabel: ariaLabel,
|
|
363
|
+
error: error,
|
|
364
|
+
errorId: error ? errorId : void 0,
|
|
365
|
+
ariaDescribedBy: describedBy || void 0,
|
|
349
366
|
initialValue: initialValue,
|
|
350
367
|
maxRows: maxRows,
|
|
351
368
|
minRows: minRows,
|
|
@@ -360,6 +377,12 @@ const PromptEditor = ({ value: rawValue, initialValue: rawInitialValue, onChange
|
|
|
360
377
|
onChange: handleEditorChange
|
|
361
378
|
})
|
|
362
379
|
})
|
|
380
|
+
}),
|
|
381
|
+
/*#__PURE__*/ jsx(FormFieldError, {
|
|
382
|
+
id: errorId,
|
|
383
|
+
"data-slot": "prompt-editor-error",
|
|
384
|
+
className: "mt-1",
|
|
385
|
+
children: error
|
|
363
386
|
})
|
|
364
387
|
]
|
|
365
388
|
})
|
package/dist/styles.css
CHANGED
|
@@ -4070,12 +4070,6 @@
|
|
|
4070
4070
|
.text-muted-foreground {
|
|
4071
4071
|
color: var(--muted-foreground);
|
|
4072
4072
|
}
|
|
4073
|
-
.text-muted-foreground\/60 {
|
|
4074
|
-
color: var(--muted-foreground);
|
|
4075
|
-
@supports (color: color-mix(in lab, red, red)) {
|
|
4076
|
-
color: color-mix(in oklab, var(--muted-foreground) 60%, transparent);
|
|
4077
|
-
}
|
|
4078
|
-
}
|
|
4079
4073
|
.text-muted-foreground\/70 {
|
|
4080
4074
|
color: var(--muted-foreground);
|
|
4081
4075
|
@supports (color: color-mix(in lab, red, red)) {
|
|
@@ -6235,6 +6229,18 @@
|
|
|
6235
6229
|
border-radius: var(--radius-xl);
|
|
6236
6230
|
}
|
|
6237
6231
|
}
|
|
6232
|
+
.future\:rounded-t-xl {
|
|
6233
|
+
:is(.future-dark, .future-light) & {
|
|
6234
|
+
border-top-left-radius: var(--radius-xl);
|
|
6235
|
+
border-top-right-radius: var(--radius-xl);
|
|
6236
|
+
}
|
|
6237
|
+
}
|
|
6238
|
+
.future\:rounded-b-xl {
|
|
6239
|
+
:is(.future-dark, .future-light) & {
|
|
6240
|
+
border-bottom-right-radius: var(--radius-xl);
|
|
6241
|
+
border-bottom-left-radius: var(--radius-xl);
|
|
6242
|
+
}
|
|
6243
|
+
}
|
|
6238
6244
|
.future\:border-0 {
|
|
6239
6245
|
:is(.future-dark, .future-light) & {
|
|
6240
6246
|
border-style: var(--tw-border-style);
|
|
@@ -6323,6 +6329,11 @@
|
|
|
6323
6329
|
color: var(--foreground-inverse);
|
|
6324
6330
|
}
|
|
6325
6331
|
}
|
|
6332
|
+
.future\:text-foreground-muted {
|
|
6333
|
+
:is(.future-dark, .future-light) & {
|
|
6334
|
+
color: var(--foreground-muted);
|
|
6335
|
+
}
|
|
6336
|
+
}
|
|
6326
6337
|
.future\:text-muted-foreground {
|
|
6327
6338
|
:is(.future-dark, .future-light) & {
|
|
6328
6339
|
color: var(--muted-foreground);
|